Files
openclaw/src/slack/message-actions.test.ts
msvechla 2c5b898eea feat(slack): add download-file action for on-demand file attachment access (#24723)
* feat(slack): add download-file action for on-demand file attachment access

Adds a new `download-file` message tool action that allows the agent to
download Slack file attachments by file ID on demand. This is a prerequisite
for accessing images posted in thread history, where file attachments are
not automatically resolved.

Changes:
- Add `files` field to `SlackMessageSummary` type so file IDs are
  visible in message read results
- Add `downloadSlackFile()` to fetch a file by ID via `files.info`
  and resolve it through the existing `resolveSlackMedia()` pipeline
- Register `download-file` in `CHANNEL_MESSAGE_ACTION_NAMES`,
  `MESSAGE_ACTION_TARGET_MODE`, and `listSlackMessageActions`
- Add `downloadFile` dispatch case in `handleSlackAction`
- Wire agent-facing `download-file` → internal `downloadFile` in
  `handleSlackMessageAction`

Closes #24681

* style: fix formatting in slack-actions and actions

* test(slack): cover download-file action path

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
2026-03-01 11:45:05 -06:00

23 lines
623 B
TypeScript

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { listSlackMessageActions } from "./message-actions.js";
describe("listSlackMessageActions", () => {
it("includes download-file when message actions are enabled", () => {
const cfg = {
channels: {
slack: {
botToken: "xoxb-test",
actions: {
messages: true,
},
},
},
} as OpenClawConfig;
expect(listSlackMessageActions(cfg)).toEqual(
expect.arrayContaining(["read", "edit", "delete", "download-file"]),
);
});
});