fix: allow media-only sends

This commit is contained in:
Peter Steinberger
2026-01-16 03:15:07 +00:00
parent f449115ec5
commit a0d2a7232e
15 changed files with 200 additions and 9 deletions

View File

@@ -37,6 +37,37 @@ describe("runMessageAction context isolation", () => {
expect(result.kind).toBe("send");
});
it("allows media-only send when target matches current channel", async () => {
const result = await runMessageAction({
cfg: slackConfig,
action: "send",
params: {
channel: "slack",
to: "#C123",
media: "https://example.com/note.ogg",
},
toolContext: { currentChannelId: "C123" },
dryRun: true,
});
expect(result.kind).toBe("send");
});
it("requires message when no media hint is provided", async () => {
await expect(
runMessageAction({
cfg: slackConfig,
action: "send",
params: {
channel: "slack",
to: "#C123",
},
toolContext: { currentChannelId: "C123" },
dryRun: true,
}),
).rejects.toThrow(/message required/i);
});
it("blocks send when target differs from current channel", async () => {
await expect(
runMessageAction({

View File

@@ -208,10 +208,12 @@ export async function runMessageAction(
if (action === "send") {
const to = readStringParam(params, "to", { required: true });
// Allow message to be omitted when sending media-only (e.g., voice notes)
const mediaHint = readStringParam(params, "media", { trim: false });
let message = readStringParam(params, "message", {
required: true,
required: !mediaHint, // Only require message if no media hint
allowEmpty: true,
});
}) ?? "";
const parsed = parseReplyDirectives(message);
message = parsed.text;