Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Preserve Codex resume instructions and gate scheduler actions
Dash094ead4d00ff
diff --git a/apps/desktop/src/main/im/shared/__tests__/channelToolPolicy.test.ts b/apps/desktop/src/main/im/shared/__tests__/channelToolPolicy.test.tsindex 59a26f041a..be838cbb8c 100644--- a/apps/desktop/src/main/im/shared/__tests__/channelToolPolicy.test.ts+++ b/apps/desktop/src/main/im/shared/__tests__/channelToolPolicy.test.ts@@ -30,3 +30,23 @@ describe('production channel policy for Pi management', () => {expect(channelForceConfirmToolCall('read', { path: 'notes.md' })).toBe(false);});});++describe('channel policy for scheduler command execution', () => {+ it.each(['schedule_create', 'schedule_update', 'schedule_set_pre_run_hook', 'schedule_resume', 'schedule_run_now'])(+ 'requires per-turn confirmation for %s, even inside a trusted scheduler MCP', (name) => {+ expect(channelForceConfirmToolCall('mcp__cindy_scheduler__call_tool', { name, args: {} })).toBe(true);+ expect(channelForceConfirmToolCall('mcp:cindy_scheduler', {+ toolParams: { name: 'call_tool', args: { name, args: {} } },+ })).toBe(true);+ expect(channelForceConfirmToolCall(name, {})).toBe(true);+ },+ );++ it('keeps scheduler discovery and reads outside forced confirmation', () => {+ for (const name of ['schedule_list', 'schedule_get', 'schedule_list_runs']) {+ expect(channelForceConfirmToolCall('mcp:cindy_scheduler', {+ toolParams: { name: 'call_tool', args: { name, args: {} } },+ })).toBe(false);+ }+ });+});diff --git a/apps/desktop/src/main/im/shared/channelToolPolicy.ts b/apps/desktop/src/main/im/shared/channelToolPolicy.tsindex 0c2edfe0cf..098cb958f9 100644--- a/apps/desktop/src/main/im/shared/channelToolPolicy.ts+++ b/apps/desktop/src/main/im/shared/channelToolPolicy.ts@@ -28,6 +28,17 @@ function record(value: unknown): Record<string, unknown> | null {*/const DESTRUCTIVE_INNER_NAME_RE = /(?:^|_)(?:merge|system_write|overwrite)(?:_|$)/i;+// These scheduler actions can install a command, resume it, or trigger it now.+// A restored trusted MCP must still pass the channel's per-turn approval.+const SCHEDULER_EXECUTION_TOOL_NAMES = new Set([+ 'schedule_create', 'schedule_update', 'schedule_set_pre_run_hook',+ 'schedule_resume', 'schedule_run_now',+]);++function schedulerExecutionNeedsConfirmation(toolName: string): boolean {+ return SCHEDULER_EXECUTION_TOOL_NAMES.has(toolLeafName(toolName));+}+function isOpaqueWriteToolName(toolName: string): boolean {const normalized = toolName.toLowerCase();return normalized === 'file_change' || normalized === 'permissions';@@ -131,10 +142,12 @@ export function channelForceConfirmToolCall(toolName: string, input: unknown): b// 1. 顶层工具名 / shell 命令(Bash/bash/PowerShell)直接命中破坏性规则。if (checkChannelDestructiveToolCall(toolName, input).destructive) return true;if (piManagementNeedsConfirmation(toolName, input)) return true;+ if (schedulerExecutionNeedsConfirmation(toolName)) return true;// 2. 包装 / 二级分派的内层动作。for (const inner of unwrapInnerCalls(toolName, input)) {if (piManagementNeedsConfirmation(inner.name, inner.args)+ || schedulerExecutionNeedsConfirmation(inner.name)|| isOpaqueWriteToolName(inner.name) || DESTRUCTIVE_INNER_NAME_RE.test(inner.name)) {return true;}diff --git a/docs/product-rules/telegram-bot-parity.md b/docs/product-rules/telegram-bot-parity.mdindex f71f31f348..eee633d8c8 100644--- a/docs/product-rules/telegram-bot-parity.md+++ b/docs/product-rules/telegram-bot-parity.md@@ -140,7 +140,7 @@ Hook 与本地 IM 共享消息级来源及上下文快照结构。本地所有| 差异 | 官方 | 个人 | 裁决与理由 ||---|---|---|---|-| 群轮次权限档 | 完全按用户配的走 | Auto 对渠道策略命中的动作先交 AI 三态审阅;Ask 保留逐次确认;「完全访问」只让 owner 触发的轮次按该档直接执行,非 owner 的群消息继续保留逐轮策略并 fail-closed | Chris 2026-09-04 实踩裁决:个人 bot 的群任务已经明确设成 Pi + Grok + Full access,Cindy 侧能继续对话,Telegram 却因额外挂的逐轮策略与 Full access 互斥而在模型启动前拒绝每条消息。**owner 明确选择的完全访问必须正常执行,但不能把这份授权扩给同群其他成员**;个人侧在 `bypassPermissions` 下仅对 owner 触发的 policy 通过 `turnPolicyOptionalForMode` 取缔逐轮策略,非 owner 的授权边界与群历史 lane 隔离照常保留;Auto 的风险判定交 AI,只有 ask 或服务不可用才转 owner 确认。官方侧继续完全按用户配置,不改服务端行为。见 `hook-control/session-runner.ts`、`im/telegram/adapter.ts` 与 `im/shared/turnRunner.ts` |+| 群轮次权限档 | 完全按用户配的走 | Auto 对渠道策略命中的动作先交 AI 三态审阅;Ask 保留逐次确认;「完全访问」只让 owner 触发的轮次按该档直接执行,非 owner 的群消息继续保留逐轮策略并 fail-closed | Chris 2026-09-04 实踩裁决:个人 bot 的群任务已经明确设成 Pi + Grok + Full access,Cindy 侧能继续对话,Telegram 却因额外挂的逐轮策略与 Full access 互斥而在模型启动前拒绝每条消息。**owner 明确选择的完全访问必须正常执行,但不能把这份授权扩给同群其他成员**;个人侧在 `bypassPermissions` 下仅对 owner 触发的 policy 通过 `turnPolicyOptionalForMode` 取缔逐轮策略,非 owner 的授权边界与群历史 lane 隔离照常保留;scheduler 的创建、修改、前置脚本安装、恢复和立即运行同样进入该逐轮策略,防止可信 MCP 绕过群轮次权限;Auto 的风险判定交 AI,只有 ask 或服务不可用才转 owner 确认。官方侧继续完全按用户配置,不改服务端行为。见 `hook-control/session-runner.ts`、`im/telegram/adapter.ts`、`im/shared/channelToolPolicy.ts` 与 `im/shared/turnRunner.ts` || 私聊过程态的载体 | 默认真实进度消息;开启 `TELEGRAM_DM_DRAFT_ENABLED` 时使用 Telegram **草稿**(`sendDraft`),终稿一发草稿自然消失 | 真实消息,原地 `editMessageText` 覆盖 | 草稿只有官方路径拿得到。个人栈**不是零推送**:惰性占位让「没有真实内容就不建消息」,但**第一帧真实内容那次 `sendMessage` 会推送**,之后的编辑才不推送。`presentationCapabilities.ts` 的 `progressSilent: true` 说的是「过程帧不额外推送」,不是「整轮零推送」 || `/status` | 有 | 无 | 官方 bot 经服务端中继,链路可断,所以有「关联状态」可看;个人 bot 由桌面直连 Bot API,没有等价概念。见注册表 `parityNote` || `/unlink` | 有 | 无 | 官方 bot 的关联由服务端持有;个人 bot 的 token 是用户自填的,解绑入口在桌面设置页 |diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.tsindex d3808d1708..456e2f37cd 100644--- a/packages/maker-core/src/agents/codex/index.test.ts+++ b/packages/maker-core/src/agents/codex/index.test.ts@@ -10033,7 +10033,7 @@ describe('CodexAgent MCP thread context hooks', () => {it('cold-resumes the same Codex thread when its configured scheduler MCP is missing', async () => {const threadId = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee';- const agent = new CodexAgent(createDeps());+ const agent = new CodexAgent(createDeps({ systemPrompt: 'HOST PRODUCT PROMPT' }));let resumeCount = 0;const host = installFakeHost(agent, (method, params) => {if (method === Method.ThreadResume) {@@ -10054,14 +10054,18 @@ describe('CodexAgent MCP thread context hooks', () => {});const handle = await agent.startSession({sessionId: 'session-scheduler-recovery', resumeSessionId: threadId,- model: 'gpt-5.4', workingDir: '/repo',+ model: 'gpt-5.4', workingDir: '/repo', userPrompt: 'USER PROMPT',});const originalSubscription = host.subscribeThread.mock.results[0]!.value;expect(originalSubscription.release).toHaveBeenCalledOnce();expect(host.subscribeThread).toHaveBeenCalledTimes(2);expect(host.request.mock.calls.filter(([method]) => method === Method.ThreadResume)).toHaveLength(2);- const coldResume = host.request.mock.calls.filter(([method]) => method === Method.ThreadResume)[1]![1];+ const coldResume = host.request.mock.calls.filter(([method]) => method === Method.ThreadResume)[1]![1] as {+ threadId: string; config: Record<string, unknown>; developerInstructions?: string;+ };expect(coldResume).toMatchObject({ threadId, config: { 'mcp_servers.cindy_scheduler.url': 'http://127.0.0.1:47100/mcp/cindy_scheduler' } });+ expect(coldResume.developerInstructions).toContain('HOST PRODUCT PROMPT');+ expect(coldResume.developerInstructions).toContain('USER PROMPT');const checksBeforeSend = host.request.mock.calls.filter(([method]) => method === Method.McpServerStatusList).length;await handle.send({ type: 'user', content: 'Create the heartbeat.' });expect(host.request.mock.calls.filter(([method]) => method === Method.McpServerStatusList)).toHaveLength(checksBeforeSend);diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.tsindex e2629f327a..ffb30fd0a2 100644--- a/packages/maker-core/src/agents/codex/index.ts+++ b/packages/maker-core/src/agents/codex/index.ts@@ -7298,6 +7298,7 @@ assertRouteCurrent();...(threadModelProvider ? { modelProvider: threadModelProvider } : {}),...(mutableModel && mutableModel !== 'gpt-5' ? { model: mutableModel } : {}),...(mutableServiceTier !== undefined ? { serviceTier: mutableServiceTier } : {}),+ ...(developerInstructions && !useProxyChannel ? { developerInstructions } : {}),}),onLateResolve: async () => {await runThreadCleanupOrRetire({