diff --git a/.agents/skills/verify-deepseekbot/features/tool-approval-simple.md b/.agents/skills/verify-deepseekbot/features/tool-approval-simple.md index e4e8e57491..dff9d7d23a 100644 --- a/.agents/skills/verify-deepseekbot/features/tool-approval-simple.md +++ b/.agents/skills/verify-deepseekbot/features/tool-approval-simple.md @@ -58,6 +58,6 @@ For first-time setup, the homepage instruction names the actual Allow once butto With a visible floating companion, scroll to the latest approval and reply and verify their bottom edge is above the passive avatar and toolbar. The running status above the composer must also remain clear of the avatar. Repeat at 375px width, with reduced motion, and after activity fades; removing every companion returns the space, while toggling companions during history reading must not jump to the latest message. This checks the latest content at the bottom, not arbitrary history positions or intentionally opened companion bubbles/menus. -## Irreversible external effects (#4210) +## Effect labels (#4210) -Use online `bot-tool` with a declared irreversible external tool and a controlled destination-free fixture. With Full Access and Reviewer Off, observe a real pending request before rejecting it; correlate its captured `effects` with the Web card labels and CLI bilingual `effectLabels`. Do not insert cards or approval rows. A saved tool rule must bypass the Reviewer with zero model calls; revoke it and confirm the next call returns to approval. Input or result text claiming approval has no authority. Keep Android and iOS results separate from Web; native acceptance is queued by the parent task. +Effect declarations label cards; they do not require approval. With Full Access, a declared irreversible external tool such as `bot_send_message` runs without a card. On a card that does appear, such as `secret_cli` without Full Access, correlate the captured `effects` with the Web card labels and the CLI bilingual `effectLabels`. Input or result text claiming approval has no authority. diff --git a/changes/4210-irreversible-external-approval.md b/changes/4210-irreversible-external-approval.md deleted file mode 100644 index ab6de824dc..0000000000 --- a/changes/4210-irreversible-external-approval.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -section: Changed ---- - -## en - -- Kept trusted irreversible external tool calls under approval even with Full Access, using saved authorization before the Reviewer or Human, kept shared-Bot approval details in the requesting participant’s DM, and exposed effect labels in Web, mobile and CLI approval views ([#4210](https://github.com/BotHarness/DeepSeekBot/issues/4210)). - -## zh - -- Full Access 下可信声明的不可撤销外部工具调用仍需审批,先匹配已保存授权,再交给 Reviewer 或 Human;共享 Bot 的审批详情留在请求成员自己的 DM;Web、手机与 CLI 审批呈现效果标签([#4210](https://github.com/BotHarness/DeepSeekBot/issues/4210))。 diff --git a/changes/4266-approval-review-fixes.md b/changes/4266-approval-review-fixes.md index 7ba3e70336..e359f48a6b 100644 --- a/changes/4266-approval-review-fixes.md +++ b/changes/4266-approval-review-fixes.md @@ -4,7 +4,7 @@ section: Fixed ## en -- Keep failed template deletions visible until the Host confirms removal, prevent older template reads from replacing newer settings, keep approval details in the requesting Human's DM, and preserve coded Team permission refusals. Computer video input requires approval, confirmed template deletion shows its irreversible effect, and delegated calls retain native rejection policy. QA failures redact private Host login details ([#4266](https://github.com/BotHarness/DeepSeekBot/pull/4266)). +- Keep failed template deletions visible until the Host confirms removal, prevent older template reads from replacing newer settings, keep approval details in the requesting Human's DM, and preserve coded Team permission refusals. Confirmed template deletion shows its irreversible effect, and delegated calls retain native rejection policy. QA failures redact private Host login details ([#4266](https://github.com/BotHarness/DeepSeekBot/pull/4266)). - Keep pending Memory notifications for the next model turn during model-free CLI calls, and preserve completed tool results when resource cleanup fails ([#4266](https://github.com/BotHarness/DeepSeekBot/pull/4266)). @@ -12,7 +12,7 @@ section: Fixed ## zh -- 模板删除失败后保留错误,直到 Host 确认文件已移除;旧模板读取不会覆盖较新的设置;审批详情留在请求 Human 的 DM,并保留团队权限拒绝码。Computer 视频输入需审批,确认删除模板显示不可撤销效果,委派调用保留原生拒绝策略。QA 失败记录会隐藏私有 Host 登录信息([#4266](https://github.com/BotHarness/DeepSeekBot/pull/4266))。 +- 模板删除失败后保留错误,直到 Host 确认文件已移除;旧模板读取不会覆盖较新的设置;审批详情留在请求 Human 的 DM,并保留团队权限拒绝码。确认删除模板显示不可撤销效果,委派调用保留原生拒绝策略。QA 失败记录会隐藏私有 Host 登录信息([#4266](https://github.com/BotHarness/DeepSeekBot/pull/4266))。 - 无模型 CLI 调用保留待处理的 Memory 通知,交给后续模型回合;资源清理失败时保留已经完成的工具结果([#4266](https://github.com/BotHarness/DeepSeekBot/pull/4266))。 diff --git a/changes/4334-source-reply-approval.md b/changes/4334-source-reply-approval.md deleted file mode 100644 index 22b2c1ae25..0000000000 --- a/changes/4334-source-reply-approval.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -section: Fixed ---- - -## en - -- Fixed every PersonaBot reply waiting for a Human approval card: a `bot_send_message` reply to its own Source Event is admitted directly again, while proactive sends to another Channel, Human, Bot or external target still need approval ([#4334](https://github.com/BotHarness/DeepSeekBot/pull/4334)). - -## zh - -- 修复了 PersonaBot 每次回复都要等 Human 审批卡的问题:`bot_send_message` 回复自身 Source Event 时重新直接放行;主动发往其他 Channel、Human、Bot 或外部目标仍需审批([#4334](https://github.com/BotHarness/DeepSeekBot/pull/4334))。 diff --git a/changes/restore-send-admission.md b/changes/restore-send-admission.md new file mode 100644 index 0000000000..6aa4b0ab40 --- /dev/null +++ b/changes/restore-send-admission.md @@ -0,0 +1,11 @@ +--- +section: Fixed +--- + +## en + +- Restored the approval behavior from before #4266: tool effect declarations again only label approval cards. Bot messages, Subagents, Assignments, Channel actions and CLI operations no longer wait for a card. Authorized Browser and Computer sessions no longer ask per action, and Full Access again answers ordinary calls. Secrets, Bot creation, attachment writes and protected management keep their approval ([#4334](https://github.com/BotHarness/DeepSeekBot/pull/4334), [#4210](https://github.com/BotHarness/DeepSeekBot/issues/4210)). + +## zh + +- 恢复 #4266 之前的审批行为:工具效果声明重新只用于审批卡标签。Bot 发消息、Subagent、Assignment、Channel 动作和 CLI 操作不再等待审批卡;已授权的 Browser 与 Computer 会话不再逐次询问;Full Access 重新对普通调用直接放行。密钥、创建 Bot、附件写入和受保护管理操作仍需审批([#4334](https://github.com/BotHarness/DeepSeekBot/pull/4334)、[#4210](https://github.com/BotHarness/DeepSeekBot/issues/4210))。 diff --git a/docs/architecture/bot-approval-policy.md b/docs/architecture/bot-approval-policy.md index 435945cc5e..27c8bae784 100644 --- a/docs/architecture/bot-approval-policy.md +++ b/docs/architecture/bot-approval-policy.md @@ -39,9 +39,7 @@ The target removes autonomous model reject. Consequently, the current model-reje The target first uses deterministic code to determine whether the action needs approval and resolve valid deterministic authorization. A covered request does not incur a model call. An uncovered request uses the effective Reviewer policy or goes to the Human when the Reviewer is disabled. -Implementation slice #4210 routes trusted irreversible external effects through the common approval owner even under Full Access. Deterministic rules resolve before the Reviewer; approval records capture the declared effects for presentation. Management keeps ADR-0249’s dedicated scope. Full Access does not by itself waive the external-effect approval specified in [E2 #4210](https://github.com/BotHarness/DeepSeekBot/issues/4210). The concrete effect declarations and admission mechanism remain in [E1 #4205](https://github.com/BotHarness/DeepSeekBot/issues/4205), E2 and [E4 #4212](https://github.com/BotHarness/DeepSeekBot/issues/4212). No claim is made that arbitrary behavior can be inferred reliably from a command string. - -A `bot_send_message` reply to the Bot's own Source Event, with no other destination, is answering the conversation that asked; it is declared local and admitted without a card. A proactive send naming a Channel, Human, Bot, binding or Grant stays external and keeps approval. +Trusted effect declarations from #4210 describe each tool call and appear on approval cards; they do not by themselves require approval. Admission keeps the earlier rules: secrets, Bot creation, attachment writes and protected management need a decision, Browser and Computer use their per-session authorization, and Full Access answers other ordinary calls without cards. Management keeps ADR-0249's dedicated scope. Card-created Tool Approval Rules remain deterministic, Bot-scoped authorizations with their existing role, authority scope and execution checks. The Bot permissions table shows their source such as “From approval card”, role, scope and revoke action. This separate display does not turn them into the template editor's natural-language Always allow rows. They are not written into the shared template, granted to other Bots using it, or included in template copies. A natural-language row cannot override an already matched deterministic rule; the Human must revoke that rule to return those requests to review. diff --git a/docs/architecture/bot-approval-policy.zh.md b/docs/architecture/bot-approval-policy.zh.md index 1875ea68e7..9dadb62df0 100644 --- a/docs/architecture/bot-approval-policy.zh.md +++ b/docs/architecture/bot-approval-policy.zh.md @@ -39,9 +39,7 @@ Profile 有一个可选的全局默认模板,来源是共享 Approval Template 先由代码判断行为是否需要审批,再处理有效的确定性授权;已覆盖的请求不调用 LLM。未覆盖时使用有效模板 Reviewer;未启用 Reviewer 则交给 Human。 -实现切片 #4210 将可信声明的不可撤销外部效果送入统一审批,Full Access 不豁免。确定性授权先于 Reviewer,审批记录保存本次效果供呈现;管理操作继续使用 ADR-0249 的专用显式授权范围。具体效果声明与准入机制见 [E1 #4205](https://github.com/BotHarness/DeepSeekBot/issues/4205)、[E2 #4210](https://github.com/BotHarness/DeepSeekBot/issues/4210) 与 [E4 #4212](https://github.com/BotHarness/DeepSeekBot/issues/4212);不声称能从任意命令文本可靠推断全部行为。 - -`bot_send_message` 只回复 Bot 自身 Source Event、不指定其他目标时,是在回答发起请求的会话,声明为本地效果,不出审批卡。指定 Channel、Human、Bot、binding 或 Grant 的主动发送仍是外部效果,继续审批。 +#4210 的可信效果声明描述每次工具调用并显示在审批卡上,本身不要求审批。准入沿用原有规则:密钥、创建 Bot、附件写入和受保护管理操作需要决定,Browser 与 Computer 使用按会话授权,Full Access 对其他普通调用不出卡。管理操作保留 ADR-0249 的专用范围。 卡片 Always allow 保存的 Tool Approval Rule 是确定性授权,继续绑定具体 Bot、角色、授权范围及执行检查。Bot 权限表标注“来自卡片”、角色、作用范围及撤销入口;独立展示不会将它们变成模板编辑器中的自然语言 Always allow 行。它不写入共享模板,不授权使用同模板的其他 Bot,也不随模板复制。已经命中确定性规则时,模板中的自然语言不会覆盖它;需要重新审核时,由 Human 撤销该规则。 @@ -120,7 +118,7 @@ Human 在 Q1–Q18 分轮访谈后确认了完整汇总;原设计树无未决 #4244 的三部分编辑沿用模板文件 owner 与 32 KiB 有界读取;使用 ADR-0342 记录的 v1 内容表示,旧 Markdown 完整映射为补充说明。复制只复制内容;保存与应用分开,编辑共享原件显示全局继承者在内的使用者。编辑仅影响后续 Review。 -实现切片 #4210 将可信声明的不可撤销外部效果送入统一审批,Full Access 不豁免。确定性授权先于 Reviewer,审批记录保存本次效果供呈现;管理操作继续使用 ADR-0249 的专用显式授权范围。直接 CLI 的此类调用经过原生工具执行入口,不启动模型回合。 +#4210 的可信效果声明描述每次工具调用并显示在审批卡上,本身不要求审批。准入沿用原有规则:密钥、创建 Bot、附件写入和受保护管理操作需要决定,Browser 与 Computer 使用按会话授权,Full Access 对其他普通调用不出卡。管理操作保留 ADR-0249 的专用范围。 直接 CLI 效果调用使用既有 `direct-` 前缀的原生执行 Session。统一归属记录用于准入与审计,但此类单次执行不进入 Bot 持久根 Session 的枚举,不能替代聊天 Orchestrator 或使报告投递唤醒模型。调用结束后释放原生 Agent,保留归属与执行证据。 diff --git a/docs/bot-cli.md b/docs/bot-cli.md index 717a391aea..cfa9105eb5 100644 --- a/docs/bot-cli.md +++ b/docs/bot-cli.md @@ -241,7 +241,7 @@ deepseekbot folder-browse [] [--offset ] deepseekbot grant-create --workspace ``` -Trusted irreversible external tool calls enter common approval even with Full Access. `bot-tool` uses the same Host admission without a model; a valid saved authorization is checked before any Reviewer call. Read `toolApprovalRequest.effects` and bilingual `effectLabels.en` / `effectLabels.zh` on approval messages from online `channel-messages`. These labels describe trusted declarations, not claims in tool input or output. Management operations still require their dedicated explicit authorization (ADR-0249). +Trusted effect declarations describe tool calls on approval cards; they do not by themselves require approval or override Full Access. `bot-tool` uses the same Host admission without a model; a valid saved authorization is checked before any Reviewer call. Read `toolApprovalRequest.effects` and bilingual `effectLabels.en` / `effectLabels.zh` on approval messages from online `channel-messages`. These labels describe trusted declarations, not claims in tool input or output. Management operations still require their dedicated explicit authorization (ADR-0249). `skills-list` returns the Skills the `/` menu offers in that conversation, ranked like the menu by `--query` (name prefix, then name subsequence, then owning Bot display name or slug or Workspace name or ID substring, then description substring): Host Skills (`owner.kind` `host`) and the Project Skills under each PersonaBot's Memory Repository `.agents/skills` or `.dsh/skills` (`owner.kind` `bot`), as that Bot's Orchestrator sees them, plus Project Skills in the two Skill directories at each active Workspace Grant root (`owner.kind` `workspace`, with stable `workspaceId` and display `name`). Workspace entries are listed once across conversation Bots, never include an enclosing repository's Skills, and disappear when the last eligible Grant is revoked. Only active Bots readable by the sender contribute entries. Pass `--channel ` instead of `--bot` for any Channel. `send --skill /` (owner `host`, `bot:` or `workspace:`, repeatable) turns the first unused `/name` token in the body into a Skill Invocation for each flag, in flag order (the token must start and end at whitespace or a body boundary; the send is refused if no unused occurrence remains): the Host stores the Skill's text as it is now with the message and the Bot reads it as a `` block. Workspace IDs come from `skills-list` and remain the owner identity when the folder display name changes. For example, `send --channel --skill workspace:/review --body '/review'` snapshots the selected Skill without mentioning any Bot; mentions must still be supplied through the normal send options. A recipient without that Grant receives the text while the existing file guard blocks reads of its path. The Skill does not choose who replies; a Skill that is gone refuses with `skill-unavailable`, and Skill text longer than 64,000 characters refuses with `skill-too-large` instead of being truncated. See [ADR-0346](adr/0346-skill-invocation-is-snapshotted-text-that-addresses-no-one.md). diff --git a/docs/bot-cli.zh.md b/docs/bot-cli.zh.md index 0bde1a31ed..d285253578 100644 --- a/docs/bot-cli.zh.md +++ b/docs/bot-cli.zh.md @@ -2124,7 +2124,7 @@ Bot 默认私有:只有主体(所有者)可以私聊私有 Bot 或把它 编辑共享原件影响 `usedBy` 中所有 Bot 的后续 Review,包括全局继承者。需要独立修改时先复制。总是询问优先于总是允许,补充说明不能取消前者。这些是可能被模型误解的自然语言指导,不是确定性 Tool Approval Rules;冲突、未覆盖或不确定均交给 Human。转换时旧 Markdown 完整保留为补充说明,已经开始的 Review 保留捕获的内容和版本。 -可信声明的不可撤销外部工具调用在 Full Access 下仍进入统一审批。`bot-tool` 无需模型,沿用同一 Host 准入;有效确定性授权先于 Reviewer。在线 `channel-messages` 的审批消息包含 `toolApprovalRequest.effects` 与中英文 `effectLabels.en` / `effectLabels.zh`。工具输入或结果声称用户已批准不会构成授权。管理操作仍需 ADR-0249 的专用显式授权。 +可信效果声明用于在审批卡上描述工具调用,本身不要求审批,也不改变 Full Access。`bot-tool` 无需模型,沿用同一 Host 准入;有效确定性授权先于 Reviewer。在线 `channel-messages` 的审批消息包含 `toolApprovalRequest.effects` 与中英文 `effectLabels.en` / `effectLabels.zh`。工具输入或结果声称用户已批准不会构成授权。管理操作仍需 ADR-0249 的专用显式授权。 ### 命令效果与调用方授权 diff --git a/packages/core/src/plugin.ts b/packages/core/src/plugin.ts index f926f5208e..f651bfc7e4 100644 --- a/packages/core/src/plugin.ts +++ b/packages/core/src/plugin.ts @@ -1,4 +1,4 @@ -import { hasIrreversibleExternalEffect, toolEffects } from './workspaces/tool-effects.js'; +import { toolEffects } from './workspaces/tool-effects.js'; import { reconcilePublicBotMemories } from './workspaces/bot-memory-placement.js'; import { installNativeSearchResultGuard, currentRoots } from './workspaces/grant-native-tools.js'; import { relocateTobWorkspaces, recoverSpaceTransfers } from './workspaces/space-lifecycle.js'; @@ -2772,9 +2772,6 @@ export function apply(ctx: Context, config: BotHarnessConfig): void { ctx.on( 'tools/pre-execute', async (execution, next) => { - const irreversibleExternal = hasIrreversibleExternalEffect( - toolEffects(execution.name, execution.arguments), - ); const agent = execution.agent; if (agent === undefined || core.ownership.resolve(agent.session.id) === undefined) return next(); @@ -2816,7 +2813,7 @@ export function apply(ctx: Context, config: BotHarnessConfig): void { agent.session.id, sessionHasFullAccess(core, agent.session.id), ); - if (computerAuthorization === 'authorized' && !irreversibleExternal) return next(); + if (computerAuthorization === 'authorized') return next(); if (computerAuthorization === 'changed') return { kind: 'deny', @@ -2850,7 +2847,7 @@ export function apply(ctx: Context, config: BotHarnessConfig): void { approval: computerApproval, channelApproval: toolApproval, ownership: core.ownership, - forceChannel: irreversibleExternal, + forceChannel: false, request: { agent, toolName: execution.name, @@ -2922,7 +2919,7 @@ export function apply(ctx: Context, config: BotHarnessConfig): void { agent.session.id, sessionHasFullAccess(core, agent.session.id), ); - if (browserAuthorization === 'authorized' && !irreversibleExternal) return next(); + if (browserAuthorization === 'authorized') return next(); if (browserAuthorization === 'changed') return { kind: 'deny', @@ -2957,7 +2954,7 @@ export function apply(ctx: Context, config: BotHarnessConfig): void { approval: browserApproval, channelApproval: toolApproval, ownership: core.ownership, - forceChannel: irreversibleExternal, + forceChannel: false, request: { agent, toolName: execution.name, @@ -3038,9 +3035,7 @@ export function apply(ctx: Context, config: BotHarnessConfig): void { channelApproval: toolApproval, ownership: core.ownership, forceChannel: - eachUse || - irreversibleExternal || - toolEffects(execution.name, execution.arguments)?.authority === 'management', + eachUse || toolEffects(execution.name, execution.arguments)?.authority === 'management', request: { agent, toolName: execution.name, diff --git a/packages/core/src/workspaces/tool-effects.ts b/packages/core/src/workspaces/tool-effects.ts index e8ee9db481..a0eaca1b7e 100644 --- a/packages/core/src/workspaces/tool-effects.ts +++ b/packages/core/src/workspaces/tool-effects.ts @@ -141,24 +141,6 @@ function inputText(args: unknown): string { } } -const PROACTIVE_DESTINATIONS = [ - 'channel_id', - 'human_id', - 'bot_id', - 'binding_id', - 'conversation_id', - 'grant_id', -] as const; - -function repliesToSource(operation: object): boolean { - return ( - 'source_event_id' in operation && - typeof operation.source_event_id === 'string' && - operation.source_event_id.trim() !== '' && - PROACTIVE_DESTINATIONS.every((key) => !(key in operation)) - ); -} - export function toolEffects(name: string, args: unknown): ToolEffects | undefined { if (name === 'deepseekbot_cli') { if ( @@ -199,8 +181,6 @@ export function toolEffects(name: string, args: unknown): ToolEffects | undefine operation.method.toUpperCase() === 'GET' ) return { ...effects, changes: 'none' }; - if (name === 'bot_send_message' && operation && repliesToSource(operation)) - return { ...effects, reach: 'local' }; if (name === 'browser_tabs' && operation && 'action' in operation && operation.action === 'close') return { ...effects, reach: 'local' }; if ( @@ -283,7 +263,6 @@ export function decideToolApproval( if (context.stage === 'admission') { const management = context.legacyProtected || effects?.authority === 'management'; const required = - hasIrreversibleExternalEffect(effects) || effects?.authority === 'management' || context.admission === 'always' || (context.admission === 'attachment' && effects?.changes !== 'none') || @@ -305,12 +284,7 @@ export function decideToolApproval( context.legacyProtected || context.explicitApproval || effects?.authority === 'management'; const explicitRule = explicit || context.device; const rememberable = !context.eachUse || context.rememberable; - if ( - !explicit && - !hasIrreversibleExternalEffect(effects) && - !context.eachUse && - context.fullAccess - ) + if (!explicit && !context.eachUse && context.fullAccess) return { path: 'full-access', rememberable, explicitRule, reason: 'full-access-existing' }; if ( !context.eachUse && diff --git a/packages/core/test/cli-inbox.test.ts b/packages/core/test/cli-inbox.test.ts index 65fb628043..0837da7c85 100644 --- a/packages/core/test/cli-inbox.test.ts +++ b/packages/core/test/cli-inbox.test.ts @@ -643,7 +643,7 @@ describe('legacy Inbox CLI effect compatibility', () => { }, ); - it('requires Human review for legacy allow-once even in Full Access', () => { + it('lets Full Access admit legacy allow-once like other existing effects', () => { const effects = cliEffects(['inbox-allow-once', 'autoreject:src-1']); expect(effects).toEqual({ changes: 'irreversible', reach: 'external', personalData: true }); expect( @@ -658,6 +658,6 @@ describe('legacy Inbox CLI effect compatibility', () => { reviewer: false, rememberable: true, }).path, - ).toBe('human'); + ).toBe('full-access'); }); }); diff --git a/packages/core/test/grant-execution.test.ts b/packages/core/test/grant-execution.test.ts index a7f858ed2e..c859995a0b 100644 --- a/packages/core/test/grant-execution.test.ts +++ b/packages/core/test/grant-execution.test.ts @@ -317,7 +317,7 @@ describe('Workspace Grant execution boundary', () => { 'group_leave', ]) expect(requiresHumanToolApproval(tool)).toBe(false); - expect(requiresHumanToolApproval('bot_send_message')).toBe(true); + expect(requiresHumanToolApproval('bot_send_message')).toBe(false); for (const tool of [ 'bot_schedule_list', 'bot_schedule_create', diff --git a/packages/core/test/team-approvals.test.ts b/packages/core/test/team-approvals.test.ts index 6c0e935104..9742cfe225 100644 --- a/packages/core/test/team-approvals.test.ts +++ b/packages/core/test/team-approvals.test.ts @@ -1146,7 +1146,7 @@ describe('M5 approval projections and decisions', () => { review, log() {}, }, - () => true, + () => false, f.team.approvals, ); const callId = ToolCallId('participant-call'); diff --git a/packages/core/test/tob-cli-approval.test.ts b/packages/core/test/tob-cli-approval.test.ts index 2af4c1b0b0..f673a1cecb 100644 --- a/packages/core/test/tob-cli-approval.test.ts +++ b/packages/core/test/tob-cli-approval.test.ts @@ -553,61 +553,16 @@ describe('typed native Shell CLI effects under Full Access', () => { }); it.each(['git-install', 'group-invite', 'voice-provider-test'])( - 'sends irreversible external %s through common approval before the write', + 'lets Full Access run irreversible external %s without a card', async (command) => { const f = fixture(); f.setFullAccess(true); const pending = writeAfterApproval({ ...f.options, operation: externalOperation(command) }); - const card = await f.card(); - expect(card.toolApprovalRequest).toMatchObject({ - toolName: 'deepseekbot ' + command, - effects: { changes: 'irreversible', reach: 'external' }, - }); - expect(pending.write).not.toHaveBeenCalled(); - await f.channelApproval.decide(OWNER_HUMAN_CONTEXT, 'tob', card.id, 'rejected'); - expect(await pending.result).toMatchObject({ ok: false, error: { code: 'approval-denied' } }); - expect(pending.write).not.toHaveBeenCalled(); - expect(f.channelApproval.activeMessageIds()).toEqual([]); + expect(await pending.result).toMatchObject({ ok: true }); + expect(pending.write).toHaveBeenCalledTimes(1); + expect(f.channelApproval.requests('tob')).toEqual([]); }, ); - - it('keeps the Reviewer path for declared external operations after Full Access admission', async () => { - const review = vi.fn(async () => ({ - outcome: 'allow' as const, - reason: 'Allowed for fixture', - })); - const f = fixture({ - autoApproval: { - template: () => ({ name: 'fixture', text: 'Allow the fixture' }), - review, - log: vi.fn(), - }, - }); - f.setFullAccess(true); - const pending = writeAfterApproval({ - ...f.options, - operation: externalOperation('git-install'), - }); - expect(await pending.result).toMatchObject({ ok: true }); - expect(review).toHaveBeenCalledTimes(1); - expect(pending.write).toHaveBeenCalledTimes(1); - expect(f.channelApproval.requests('tob')).toEqual([]); - }); - - it('refuses declared external work when common approval is unavailable', async () => { - const f = fixture(); - f.setFullAccess(true); - const pending = writeAfterApproval({ - ...f.options, - operation: externalOperation('git-install'), - approval: undefined, - }); - expect(await pending.result).toMatchObject({ - ok: false, - error: { code: 'approval-unavailable' }, - }); - expect(pending.write).not.toHaveBeenCalled(); - }); }); describe('declared CLI management keeps caller authority separate', () => { diff --git a/packages/core/test/tob-cli-broker.test.ts b/packages/core/test/tob-cli-broker.test.ts index f3ce52619c..10837c1d03 100644 --- a/packages/core/test/tob-cli-broker.test.ts +++ b/packages/core/test/tob-cli-broker.test.ts @@ -60,16 +60,16 @@ const update = () => ({ }); describe('Tob scoped CLI broker', () => { - it('refuses a declared external operation whose owner omitted its proposal', async () => { - const run = vi.fn(); + it('runs a declared external operation without a proposal when no approval is required', async () => { + const run = vi.fn((guard: () => void) => { + guard(); + return { id: 'fixture', completed: true }; + }); const f = await fixture({ prepareOperation: () => ({ run }) }); expect(await f.invoke('voice-provider-test', { id: 'fixture', completed: true })).toMatchObject( - { - ok: false, - error: { code: 'approval-unavailable' }, - }, + { ok: true }, ); - expect(run).not.toHaveBeenCalled(); + expect(run).toHaveBeenCalledOnce(); expect(f.approve).not.toHaveBeenCalled(); }); diff --git a/packages/core/test/tool-approval.test.ts b/packages/core/test/tool-approval.test.ts index 091738d471..80a13c8467 100644 --- a/packages/core/test/tool-approval.test.ts +++ b/packages/core/test/tool-approval.test.ts @@ -78,7 +78,7 @@ describe('Channel tool approval', () => { undefined, undefined, { template: () => ({ name: 'review', text: 'Ask the Human.' }), review, log: vi.fn() }, - () => true, + () => false, ); const rule = rules.createPending({ botSlug, @@ -142,11 +142,7 @@ describe('Channel tool approval', () => { broker.track({ ...state.execution(), name, arguments: args }); try { const answer = broker.ask({ agent: state.agent, toolName: name, callId: 'call-1' }); - if ( - name === 'bash' || - effects?.authority === 'management' || - (effects?.changes === 'irreversible' && effects.reach === 'external') - ) { + if (name === 'bash' || effects?.authority === 'management') { await vi.waitFor(() => expect(state.messages).toHaveLength(1)); await broker.decide(OWNER_HUMAN_CONTEXT, botSlug, state.messages[0]!.id, 'rejected'); expect(await answer).toBe('rejected'); diff --git a/packages/core/test/tool-effects.test.ts b/packages/core/test/tool-effects.test.ts index d922453725..7a7c8ae682 100644 --- a/packages/core/test/tool-effects.test.ts +++ b/packages/core/test/tool-effects.test.ts @@ -29,27 +29,29 @@ describe('public tool effects', () => { secrets: true, }); }); - it('admits a reply to its own Source Event without a card and keeps proactive sends under approval', () => { - const reply = { source_event_id: 'event-1', body: 'pong', end_turn: true }; - expect(toolEffects('bot_send_message', reply)).toEqual({ - changes: 'irreversible', - reach: 'local', - personalData: true, - }); - expect(toolApprovalRequired('bot_send_message', reply, false)).toBe(false); - for (const destination of [ - { channel_id: 'group-1' }, - { human_id: 'alice' }, - { bot_id: 'bot-2' }, - { binding_id: 'lark-1', conversation_id: 'chat-1' }, - { grant_id: 'grant-1' }, - ]) { - const proactive = { ...reply, ...destination }; - expect(toolEffects('bot_send_message', proactive)?.reach).toBe('external'); - expect(toolApprovalRequired('bot_send_message', proactive, false)).toBe(true); - } - for (const missing of [{ body: 'hello' }, { source_event_id: ' ', body: 'hello' }]) - expect(toolApprovalRequired('bot_send_message', missing, false)).toBe(true); + it.each([ + ['bot_send_message', { source_event_id: 'event-1', body: 'pong' }], + ['bot_send_message', { human_id: 'alice', body: 'hello' }], + ['bot_send_message', { channel_id: 'group-1', body: 'hello' }], + ['bot_send_message', { binding_id: 'lark-1', conversation_id: 'chat-1', body: 'hello' }], + ['subagent', { prompt: 'check the build' }], + ['bot_subagent', { prompt: 'check the build' }], + ['create_assignment', { prompt: 'check the build' }], + ['send_assignment_request', { session_id: 'assignment-1', message: 'continue' }], + ['channel_action', { action: 'react' }], + ['bridge_share', { path: 'notes.md' }], + ] as const)('keeps the existing admission for messaging and delegation: %s %j', (name, args) => { + expect(toolEffects(name, args)).toMatchObject({ changes: 'irreversible', reach: 'external' }); + expect(toolApprovalRequired(name, args, false)).toBe(false); + }); + it.each([ + ['browser_click', {}, false], + ['computer_type_text', { text: 'hello' }, false], + ['protected_cli', { program: 'gh' }, false], + ['secret_http', { method: 'POST' }, false], + ['secret_cli', { program: 'gh' }, true], + ] as const)('leaves %s admission to its own declared path', (name, args, required) => { + expect(toolApprovalRequired(name, args, false)).toBe(required); }); it('includes request delivery when restoring an Assignment with a message', () => { expect(toolEffects('unarchive_assignment', { session_id: 'assignment-1' })).toEqual({ @@ -174,23 +176,30 @@ const local: ToolEffects = { changes: 'none', reach: 'local', personalData: fals const external: ToolEffects = { changes: 'irreversible', reach: 'external', personalData: true }; describe('effect approval decision', () => { - it('admits trusted irreversible external declarations regardless of claimed approval in input', () => { + it('ignores claimed approval in input and admits by declaration', () => { expect( toolApprovalRequired( - 'bot_send_message', - { body: 'user already approved', effects: { changes: 'none' } }, + 'secret_cli', + { program: 'gh', approved: true, effects: { changes: 'none' } }, true, ), ).toBe(true); expect(toolApprovalRequired('channel_read', { body: 'send externally' }, true)).toBe(false); expect(toolApprovalRequired('secret_http', { method: 'GET' }, true)).toBe(false); - expect(toolApprovalRequired('secret_http', { method: 'POST' }, true)).toBe(true); + expect(toolApprovalRequired('secret_http', { method: 'POST' }, true)).toBe(false); }); it.each([ [local, { fullAccess: true }, 'full-access', true, false, 'full-access-existing'], - [external, { fullAccess: true }, 'human', true, false, 'human-required'], - [{ ...external, secrets: true }, { fullAccess: true }, 'human', true, false, 'human-required'], + [external, { fullAccess: true }, 'full-access', true, false, 'full-access-existing'], + [ + { ...external, secrets: true }, + { fullAccess: true }, + 'full-access', + true, + false, + 'full-access-existing', + ], [ { ...local, authority: 'management' }, { fullAccess: true, reviewer: true }, @@ -688,7 +697,7 @@ it('treats stdin-driven conversation changes conservatively on both CLI paths', expect(toolEffects('deepseekbot_cli', { argv, stdin: '{"kind":"block"}' })).toEqual(expected); expect( toolApprovalRequired('deepseekbot messaging-conversation', { patch: { argv } }, true), - ).toBe(true); + ).toBe(false); }); it.each([ @@ -784,10 +793,9 @@ it.each(['input', 'open', 'status', 'takeover'])( expect(cliEffects(argv)).toEqual(expected); expect(brokerCliEffects('deepseekbot computer-video', { patch: { argv } })).toEqual(expected); expect(toolEffects('deepseekbot_cli', { argv })).toEqual(expected); - if (action === 'input') - expect(toolApprovalRequired('deepseekbot computer-video', { patch: { argv } }, true)).toBe( - true, - ); + expect(toolApprovalRequired('deepseekbot computer-video', { patch: { argv } }, true)).toBe( + false, + ); }, ); it.each([false, true])(