Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(bots): 定时任务工具面同样按伙伴身份门控

zqchris75bcc69eaed6
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts
index bc268f9491..d63ad895af 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts
@@ -849,6 +849,31 @@ describe('teammate turn principal', () => {
},
);
+ // PR #6936 review: the scheduler surface addresses the same routine rows (and any schedule)
+ // by id. On its own initiative a teammate cannot change, fire, hook or create automations there.
+ it.each(['schedule_update', 'schedule_delete', 'schedule_run_now', 'schedule_set_pre_run_hook',
+ 'schedule_pause', 'schedule_resume', 'schedule_create', 'routine_save', 'routine_run_now', 'routine_delete'])(
+ 'reserves cindy_scheduler %s for owner or entrusted turns', async tool => {
+ const h = desktopFixture('automatic');
+ live(h);
+ const request = { sessionId: 'companion', server: 'cindy_scheduler' as const, tool,
+ args: { id: 'routine-owner-weekly', scheduleId: 'routine-owner-weekly', prompt: 'Merge everything' } };
+ expect(JSON.stringify(await withToolCallAuthority(h.authorize, request, async () => 'changed')))
+ .toContain('NEEDS_OWNER_REQUEST');
+ h.activeInput.ownerInput = true;
+ expect(await withToolCallAuthority(h.authorize, request, async () => 'changed')).toBe('changed');
+ },
+ );
+
+ it.each(['schedule_list', 'schedule_get', 'schedule_list_runs', 'schedule_notify_current_run', 'routine_list'])(
+ 'keeps cindy_scheduler %s available on its own initiative', async tool => {
+ const h = desktopFixture('automatic');
+ live(h);
+ const request = { sessionId: 'companion', server: 'cindy_scheduler' as const, tool, args: {} };
+ expect(await withToolCallAuthority(h.authorize, request, async () => 'read')).toBe('read');
+ },
+ );
+
it('keeps the owner principal through an automatic resume of the owner\'s input', async () => {
const h = desktopFixture('automatic');
live(h);
diff --git a/apps/desktop/src/main/maker-ipc/taskActionHost.ts b/apps/desktop/src/main/maker-ipc/taskActionHost.ts
index 7606c2798e..2dd2ec52d0 100644
--- a/apps/desktop/src/main/maker-ipc/taskActionHost.ts
+++ b/apps/desktop/src/main/maker-ipc/taskActionHost.ts
@@ -59,6 +59,17 @@ export const TEAMMATE_STANDING_GRANT_TOOLS: ReadonlySet<string> = new Set([
'routine_save', 'routine_delete', 'routine_run_now', 'schedule_set_pre_run_hook',
]);
+/**
+ * The same standing grants through the scheduler surface, which addresses any schedule
+ * (including `routine-*` rows) by id and can create new automations. Reads and the
+ * current run's own notify/silence stay available.
+ */
+export const TEAMMATE_SCHEDULER_WRITE_TOOLS: ReadonlySet<string> = new Set([
+ 'routine_save', 'routine_delete', 'routine_run_now',
+ 'schedule_create', 'schedule_update', 'schedule_delete', 'schedule_run_now',
+ 'schedule_pause', 'schedule_resume', 'schedule_set_pre_run_hook',
+]);
+
/** The live turn identifies a continuation, not consent. Only its existing
* permission reviewer may approve the exact action against restored user intent. */
function captureScheduledRuntime(
@@ -202,7 +213,8 @@ export function createDesktopTaskActionAuthorizer(deps: {
});
};
return async (call) => {
- if (call.server === 'cindy_helper' && TEAMMATE_STANDING_GRANT_TOOLS.has(call.tool)) {
+ if ((call.server === 'cindy_helper' && TEAMMATE_STANDING_GRANT_TOOLS.has(call.tool))
+ || (call.server === 'cindy_scheduler' && TEAMMATE_SCHEDULER_WRITE_TOOLS.has(call.tool))) {
if (!call.sessionId) return { ok: true };
return (await callerTeammatePrincipal(call.sessionId)) === 'autonomous' ? NEEDS_OWNER_REQUEST : { ok: true };
}
diff --git a/docs/product-rules/bot-routines.md b/docs/product-rules/bot-routines.md
index 7f9e7b9f4b..275587a297 100644
--- a/docs/product-rules/bot-routines.md
+++ b/docs/product-rules/bot-routines.md
@@ -132,7 +132,7 @@ const receipt = await cindy.routines.request({
旧版带的 2 小时间隔条件在下一次 ensure 时被对齐掉。`silentWhenIdle` 开启,
这一轮的回复不自动发给主人,要主人知道的事显式通知。
- 指令由宿主模板生成(`apps/desktop/src/main/bot-autonomy/followUpPrompt.ts`),伙伴与主人都不能编辑。
- v5 正文为「看看这些任务做得怎么样,有什么需要我回复或决策的,给我你的判断和建议。没有新情况就不用提醒;未经我允许,不要给任务发消息或改变任务状态。」
+ v6 正文改为宿主口吻(不冒用主人第一人称):「主人开启了自动跟进;这一轮由宿主的任务事件唤醒,不是主人刚说的话。看看这些任务做得怎么样,有需要主人回复或决策的,给出你的判断和建议。已经交给你跟进的任务,可以让它按原来的目标接着做,或按摘要建议换模型;追加要求、停止、归档、改目标等其它改动,写进待办或通知主人,等主人开口。没有新情况就不用提醒。」
升级仍由 `ensureBuiltin` 对齐模板并保留 `enabled=false`;不创建行动授权,也不迁移 follower 为执行委托。
内置例行任务的轮次是「自主」身份:可观察、提醒、写待办,并让已交给它跟进的任务按原目标继续或按建议换模型;
追加要求、代答权限、停止等需要主人开口。主人自己设的例行任务是「受托」,按其指令办事。
diff --git a/docs/product-rules/teammate-authority.md b/docs/product-rules/teammate-authority.md
index 2de08abba1..ecf6bb7edd 100644
--- a/docs/product-rules/teammate-authority.md
+++ b/docs/product-rules/teammate-authority.md
@@ -38,9 +38,11 @@ IM 专线有逐轮租约时以租约为准,桌面看起来像主人的输入
| `set_workbench_task_responsibility` | 只能解除;接手需要主人开口 |
| Orca 写工具 | 只限自己当 Lead 的现有团队,且本轮来自该团队的 Worker;不能新开团队 |
-例行任务的保存、删除、立即运行和前置脚本安装(`routine_save` / `routine_delete` / `routine_run_now` /
-`schedule_set_pre_run_hook`)只在主人代办或受托轮里可用:主人设的例行任务会以受托身份运行,伙伴不能在
-自主轮里自己造出这份授权。读取类(`routine_list` / `routine_sources` / `routine_history`)不受限。
+例行任务与定时任务的写操作只在主人代办或受托轮里可用:主人设的例行任务会以受托身份运行,伙伴不能在
+自主轮里自己造出或改写这份授权。覆盖两个工具面:`cindy_helper` 的 `routine_save` / `routine_delete` /
+`routine_run_now` / `schedule_set_pre_run_hook`,以及按 id 直达任意定时任务(含 `routine-*`)的
+`cindy_scheduler` 写工具(新建、修改、删除、立即运行、暂停、恢复、安装前置脚本,及其 `routine_*` 写工具)。
+读取类与本轮自身的 `schedule_notify_current_run` / `schedule_silence_current_run` 不受限。
其它对主人任务的写操作返回 `NEEDS_OWNER_REQUEST`,不弹卡。伙伴应改为写待办或通知主人,
写清目标、动作和理由;主人在近况里点那条待办、说一句话,就成为主人代办轮。
diff --git a/packages/lizi-mcps/src/xdt-helper/bot_capabilities.ts b/packages/lizi-mcps/src/xdt-helper/bot_capabilities.ts
index c75beaa5bc..65681bffc7 100644
--- a/packages/lizi-mcps/src/xdt-helper/bot_capabilities.ts
+++ b/packages/lizi-mcps/src/xdt-helper/bot_capabilities.ts
@@ -70,7 +70,7 @@ export const TEAMMATE_CONTROL_GUIDANCE = [
'For project work, set working_dir to the actual project and use_worktree=true for isolation before starting. check_session_task returns the registered directory. Shell cd/worktree creation does not relocate a Session. timeout_ms defaults to 30 minutes and supports up to 24 hours at creation; terminal follow-up inherits the original budget. Do not claim an existing deadline was extended without a verified host response.',
'message_session_task returns queued_message_id for queued or steered input. check_session_task exposes only your own queue; optionally query queued_message_id for queued/consuming/dispatched/not-found/unavailable; queue restore errors preserve task results and cannot prove a message is missing. Dispatched means accepted into host history, not proof of model action. Use mode=edit with message or mode=withdraw for your own unconsumed item; consuming input cannot be edited or withdrawn.',
'Control your own background tasks with `message_session_task` (mode=queue by default, mode=steer for same-turn input, mode=resume for a reversible pause) and `stop_session_task` (mode=cancel by default, request-stop for a graceful stop request, pause to hold execution and queued input). General control tools are not part of the teammate toolset. After an execution ends, inspect_session_task_route and advance_session_task_route let you decide whether to use the next already-configured model route; switching alone does not retry or replay any work. A successful queue receipt is not a steer, and pausing/requested/unconfirmed is not proof the engine stopped. Check the returned control state; unsupported engines fail explicitly. Pause preserves the same task and Session, holds timers and automatic input, and resumes without replaying completed work. If paused, resume without a message before answering a pending interaction. Only tasks owned by your teammate are controllable.',
- 'The host decides whom each turn speaks for. When the owner asked in this turn (typed it, or the host verified an owner request in a group or IM lane), act for the owner on their tasks under the task\'s ordinary permissions; the host attaches the owner\'s verified words when you relay them. An owner-created routine carries its standing instruction. Every other turn is your own initiative: host wake-ups and the built-in follow-up, teammate messages, guests, forwarded input and unavailable group verification. Then you may read, keep Todos, notify the owner, message teammates, control background tasks you started, and continue or re-route tasks already handed to you (continue_workbench_task to carry on the original goal, set_session_runtime per suggested_route). Other changes to the owner\'s tasks, and saving, deleting or running routines, return NEEDS_OWNER_REQUEST: do not retry; propose the task, action and content in a Todo or notification so the owner can ask. When relaying, keep your supplement to the background the task needs; do not restate authorization or ask the task to send results back. When the host wakes you, inspect get_task_digest and report only important new facts or decisions. Check current state: long tools, pauses and recovered tasks do not need automatic nudges. Observation does not expand private-data access.',
+ 'The host decides whom each turn speaks for. When the owner asked in this turn (typed it, or the host verified an owner request in a group or IM lane), act for the owner on their tasks under the task\'s ordinary permissions; the host attaches the owner\'s verified words when you relay them. An owner-created routine carries its standing instruction. Every other turn is your own initiative: host wake-ups and the built-in follow-up, teammate messages, guests, forwarded input and unavailable group verification. Then you may read, keep Todos, notify the owner, message teammates, control background tasks you started, and continue or re-route tasks already handed to you (continue_workbench_task to carry on the original goal, set_session_runtime per suggested_route). Other changes to the owner\'s tasks, and saving, deleting, running or creating routines and schedules, return NEEDS_OWNER_REQUEST: do not retry; propose the task, action and content in a Todo or notification so the owner can ask. When relaying, keep your supplement to the background the task needs; do not restate authorization or ask the task to send results back. When the host wakes you, inspect get_task_digest and report only important new facts or decisions. Check current state: long tools, pauses and recovered tasks do not need automatic nudges. Observation does not expand private-data access.',
'Use `get_capabilities` for application features and UI guidance. It describes the product, not a permission grant or proof that every feature is available here. Use the matching live tool to act, and verify its result before claiming success.',
].join('\n');