feat: safe mode — redirect send to draft editor, block edit/delete - #106
Conversation
Adds an enforced human-in-the-loop mode (AGENT_SLACK_SAFE_MODE env var or global --safe-mode flag) for AI agent environments: - message send is redirected to the browser draft editor with the text and thread context pre-filled; output includes safe_mode/redirected_from markers and a stderr warning. Flags the editor cannot represent (--attach, --blocks, --schedule, --schedule-in, --reply-broadcast) are rejected instead of silently dropped, and the CI direct-send shortcut is blocked so safe mode cannot be bypassed with CI=1. - message edit and message delete are blocked with a clear error. - Read operations and reactions are unchanged. Implements feature 1 of stablyai#80.
|
gonna take a look in these two days :-) |
|
@AmethystLiang any thoughts? |
|
@AmethystLiang just wanted to ping again. Would really love this to be built in, Im running a fork right now and would love to come back to mainline 😊 |
|
Oh interesting. Makes sense. Jinjing has been busy, but this makes sense! |
|
✅ Taken over, verified, and merged into Branch Security property preserved: Verified:
Your commit |
Summary
AGENT_SLACK_SAFE_MODEenv var (1/true/yes/on) or a global--safe-modeflagmessage sendis redirected to the browser draft editor andmessage edit/message deleteare blockedChanges
Skill instructions like "always use draft, never send" are guidance an agent can ignore. Safe mode enforces the policy at the tool level so nothing posts to Slack without human review.
src/cli/safe-mode.ts(new):isSafeModeEnabled()(env var + CLI flag),safeModeBlockedError(), andredirectSendToDraft(). The redirect opens the draft editor with the send text and thread context pre-filled, prints a stderr warning, and marks the JSON output with"safe_mode": trueand"redirected_from": "send". Send flags the editor cannot represent (--attach,--blocks,--schedule,--schedule-in,--reply-broadcast) are rejected with an explicit error instead of being silently dropped. The CI direct-send shortcut in the draft path is also blocked, soCI=1cannot bypass safe mode.src/cli/message-command.ts: wires the redirect intosendand the blocks intoedit/delete. Read operations and reactions are unchanged (reactions felt low-risk; easy to gate later if desired).src/index.ts: registers the global--safe-modeflag.test/safe-mode.test.ts(new): 22 tests covering env var parsing, flag override, unsupported-flag rejection (individually and combined), the CI guard, and the redirect payload/draft invocation via an injected draft function.skills/agent-slack/references/commands.mdnotes onsend/edit/delete, and aSKILL.mdmention so agents know the behavior exists.Verified manually: env var and flag both block
edit/delete(exit 1),sendwith unsupported flags errors, andsendwith plain text opens the draft editor pre-filled with the warning on stderr. Full suite passes (261 tests), typecheck clean, lint warnings unchanged from baseline.