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(teammates): confirm standing routine instruction grants

Chris7b336298d965
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 d12a004b8f..3e43d5d685 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts
@@ -304,7 +304,7 @@ function desktopFixture(kind: 'private' | 'group' | 'automatic' = 'group') {
},
};
});
- const routines = new Map<string, { enabled: boolean; revision: number }>();
+ const routines = new Map<string, { enabled: boolean; revision: number; prompt?: string; preRunCommand?: string }>();
const schedules = new Map<string, TaskActionScheduleDefinition>();
const authorize = createDesktopTaskActionAuthorizer({
input: () => ({ ...activeInput }), confirm, getSession,
@@ -314,7 +314,7 @@ function desktopFixture(kind: 'private' | 'group' | 'automatic' = 'group') {
const row = routines.get(id);
if (!row) return undefined;
const captured = { ...row };
- return { ...captured, assertCurrent() {
+ return { ...captured, prompt: captured.prompt ?? '', details: { routine: { id, ...captured } }, assertCurrent() {
if (routines.get(id)?.revision !== captured.revision)
throw new Error('TASK_ACTION_AUTHORIZATION_EXPIRED');
} };
@@ -863,12 +863,12 @@ describe('teammate turn principal', () => {
else expect(JSON.stringify(result)).toContain('TASK_ACTION_SOURCE_UNAUTHORIZED');
});
- // Creating/updating routines is ordinary work; deleting one needs an exact decision.
+ // Drafts/non-executing inputs remain ordinary; deletion needs an exact decision.
it.each(['routine_save', 'routine_run_now', 'routine_delete', 'schedule_set_pre_run_hook'])(
- 'allows %s through ordinary permissions and asks only for deletion', async tool => {
+ 'keeps draft or non-executing %s payloads ordinary except deletion', async tool => {
const h = desktopFixture('automatic');
live(h);
- const request = helper(tool, { name: 'r', prompt: 'Message the owner\'s task', enabled: true });
+ const request = helper(tool, { name: 'r', prompt: 'Message the owner\'s task', enabled: false });
expect(await withToolCallAuthority(h.authorize, request, async () => 'saved')).toBe('saved');
expect(h.confirm).toHaveBeenCalledTimes(tool === 'routine_delete' ? 1 : 0);
h.activeInput.ownerInput = true;
@@ -1005,6 +1005,75 @@ describe('teammate turn principal', () => {
expect(h.confirm).not.toHaveBeenCalled();
});
+ // Security r4409367066: saving instructions must not manufacture a standing
+ // owner grant for the next routine turn. Unit, production admission + effect.
+ it.each(['cindy_helper', 'cindy_scheduler'] as const)(
+ 'requires an owner decision to mint or rewrite active routine instructions through %s', async server => {
+ const h = desktopFixture('automatic');
+ live(h);
+ const call = (args: Record<string, unknown>, effect = vi.fn(async () => 'saved')) =>
+ withToolCallAuthority(h.authorize, { ...helper('routine_save', args), server }, effect);
+ h.confirm.mockResolvedValue(false);
+ const create = vi.fn(async () => 'saved');
+ expect(JSON.stringify(await call({ botId: 'bot', prompt: 'Run my new instructions', enabled: true }, create)))
+ .toContain('USER_CANCELLED');
+ expect(create).not.toHaveBeenCalled();
+ expect(h.confirm).toHaveBeenCalledWith('companion', 'routine_save', expect.anything(),
+ { server, risk: 'authority' });
+ h.confirm.mockClear();
+ h.routines.set('standing', { enabled: true, revision: 1, prompt: 'Owner standing instructions' });
+ expect(await call({ botId: 'bot', id: 'standing', enabled: true, prompt: 'Owner standing instructions', name: 'Renamed' }))
+ .toBe('saved');
+ expect(await call({ botId: 'bot', enabled: false, prompt: 'Unapproved draft' })).toBe('saved');
+ expect(h.confirm).not.toHaveBeenCalled();
+ const rewrite = vi.fn(async () => 'saved');
+ expect(JSON.stringify(await call({ botId: 'bot', id: 'standing', enabled: true, prompt: 'Replacement instructions' }, rewrite)))
+ .toContain('USER_CANCELLED');
+ expect(rewrite).not.toHaveBeenCalled();
+ h.confirm.mockResolvedValue(true);
+ expect(await call({ botId: 'bot', prompt: 'Reviewed standing instructions', enabled: true })).toBe('saved');
+ h.confirm.mockClear();
+ h.activeInput.ownerInput = true;
+ expect(await call({ botId: 'bot', prompt: 'Owner explicit instructions', enabled: true })).toBe('saved');
+ expect(h.confirm).not.toHaveBeenCalled();
+ },
+ );
+
+ it.each(['cindy_helper', 'cindy_scheduler'] as const)(
+ 'does not turn a disabled draft into an entrusted run through %s without approval', async server => {
+ const h = desktopFixture('automatic');
+ live(h);
+ h.routines.set('draft', { enabled: false, revision: 2, prompt: 'Unapproved instructions' });
+ const request = { ...helper('routine_run_now', { botId: 'bot', id: 'draft' }), server };
+ const enqueue = vi.fn(async () => taskActionRoutineRevision('bot', 'draft'));
+ h.confirm.mockResolvedValue(false);
+ expect(JSON.stringify(await withToolCallAuthority(h.authorize, request, enqueue))).toContain('USER_CANCELLED');
+ expect(enqueue).not.toHaveBeenCalled();
+ expect(h.confirm).toHaveBeenCalledWith('companion', 'routine_run_now', request.args,
+ expect.objectContaining({ server, risk: 'resume' }));
+ h.confirm.mockResolvedValue(true);
+ expect(await withToolCallAuthority(h.authorize, request, enqueue)).toBe(2);
+ expect(enqueue).toHaveBeenCalledTimes(1);
+ },
+ );
+
+ it.each(['cindy_helper', 'cindy_scheduler'] as const)('requires a command decision only for a changed routine hook through %s', async server => {
+ const h = desktopFixture('automatic');
+ live(h);
+ h.routines.set('standing', { enabled: true, revision: 1, prompt: 'Owner instructions', preRunCommand: 'node owner.mjs' });
+ const hook = { command: 'node owner.mjs' };
+ const request = { ...helper('routine_save', { botId: 'bot', id: 'standing', enabled: true,
+ prompt: 'Owner instructions', preRunHook: hook }), server };
+ const effect = vi.fn(async () => 'saved');
+ expect(await withToolCallAuthority(h.authorize, request, effect)).toBe('saved');
+ expect(h.confirm).not.toHaveBeenCalled();
+ hook.command = 'node replacement.mjs';
+ h.confirm.mockResolvedValue(false);
+ expect(JSON.stringify(await withToolCallAuthority(h.authorize, request, effect))).toContain('USER_CANCELLED');
+ expect(effect).toHaveBeenCalledTimes(1);
+ expect(h.confirm).toHaveBeenCalledWith('companion', request.tool, request.args, { server, risk: 'command' });
+ });
+
// Review #7782: approval must describe and bind the child's exact request, not
// whichever request is current after the parent card is answered. Unit tier.
it.each(['request-id', 'arguments'] as const)('expires a permission answer when child %s changes', async change => {
@@ -1046,7 +1115,7 @@ describe('teammate turn principal', () => {
expect(h.confirm).not.toHaveBeenCalled();
});
- it('does not restore a routine changed during confirmation', async () => {
+ it.each(['routine_save', 'routine_run_now'])('does not execute %s after its routine changes during confirmation', async tool => {
const h = desktopFixture('automatic');
live(h);
h.routines.set('saved', { enabled: false, revision: 1 });
@@ -1056,7 +1125,7 @@ describe('teammate turn principal', () => {
});
const effect = vi.fn(async () => 'enabled');
const result = await withToolCallAuthority(h.authorize,
- helper('routine_save', { id: 'saved', enabled: true }), effect);
+ helper(tool, { id: 'saved', enabled: true }), effect);
expect(JSON.stringify(result)).toContain('AUTHORIZATION_EXPIRED');
expect(effect).not.toHaveBeenCalled();
});
diff --git a/apps/desktop/src/main/maker-ipc/botSystemPrompt.ts b/apps/desktop/src/main/maker-ipc/botSystemPrompt.ts
index 9f758f027a..e9d3123db9 100644
--- a/apps/desktop/src/main/maker-ipc/botSystemPrompt.ts
+++ b/apps/desktop/src/main/maker-ipc/botSystemPrompt.ts
@@ -154,7 +154,7 @@ const SESSION_CONTROL_GUIDANCE = [
'## 你能看、能管主人的任务',
'你和主人开的普通任务用同一套工具(cindy_helper,先 `list_tools` 看类目再 `call_tool`):history 类的 `list_sessions` / `get_chat_history` / `search_chat_history` 看有哪些任务、它们在说什么;control 类的 `steer_session`、`stop_session_turn`、`set_session_runtime`、`rename_sessions`、`archive_sessions`、标签与项目工具管理任务;handoff 类的 `send_to_session` 给已有任务发话或开一条新的普通任务。',
'每一轮代表谁由宿主判定。主人这一轮亲口要求时(宿主核实的主人输入,包括群里和 IM 专线里核实为主人的请求),你可以代主人去操作他的任务:找到对应任务、发话、追加需求、停止、改名、归档等,照常走当前任务的权限档;你转达时宿主会附上核实过的主人原话。',
- '主人输入、例行任务和自主跟进都沿用当前任务的权限档;缺少本轮主人输入标记不代表主人拒绝,也不阻止普通任务操作或保存例行任务。自主执行只对少数明确风险(删除自动化、代答授权、恢复暂停、本机调度的命令执行)等待主人决定:宿主显示授权请求,同意后继续本次调用,拒绝或取消后停止,不要换工具重试。来源身份与账号访问范围仍由宿主核验;自动唤醒和别人的消息不会变成主人原话。',
+ '主人输入、例行任务和自主跟进都沿用当前任务的权限档;缺少本轮主人输入标记不代表主人拒绝,也不阻止普通任务操作或保存例行任务。自主执行只对少数明确风险(删除自动化、代答授权、恢复暂停、本机调度的命令执行、设定新的常驻指令)等待主人决定:宿主显示授权请求,同意后继续本次调用,拒绝或取消后停止,不要换工具重试。来源身份与账号访问范围仍由宿主核验;自动唤醒和别人的消息不会变成主人原话。',
'转达时 Agent 补充只写对方完成任务需要的背景,不要复述「用户已授权」之类的话,也不要让对方用 send_to_session 回传;需要结果时自己用 `get_task_digest` 去看。工具回执决定实际结果;账号、连接或平台未就绪时如实说明。',
'主人让你接手某件任务时,用 `set_workbench_task_responsibility` 记下;之后它卡住、等主人、出错或做完时宿主会叫醒你,先用 history 类的 `get_task_digest` 读摘要再决定怎么跟进。',
].join('\n');
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index 1fa06c625f..3a6dbfccb0 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -3375,8 +3375,10 @@ export async function confirmTaskAction(
kind: 'permission', requestId: randomUUID(),
title: t('taskActionConfirmation.title'),
// Generic tool previews are shortened. The owner must see the complete
- // command and working directory here, including on remote permission cards.
- description: context?.risk === 'command' ? `${description}\n\n${JSON.stringify(input, null, 2)}` : description,
+ // command or standing instructions here, including on remote permission cards.
+ description: context?.risk === 'command' || context?.risk === 'authority' ||
+ (tool === 'routine_run_now' && context?.risk === 'resume')
+ ? `${description}\n\n${JSON.stringify(input, null, 2)}` : description,
toolName: `mcp__${context?.server ?? 'cindy_helper'}__${tool}`,
input,
metadata: { hostOwnedConfirmation: 'task_action' },
diff --git a/apps/desktop/src/main/maker-ipc/taskActionAuthorization.ts b/apps/desktop/src/main/maker-ipc/taskActionAuthorization.ts
index 731ccba01a..4d12218451 100644
--- a/apps/desktop/src/main/maker-ipc/taskActionAuthorization.ts
+++ b/apps/desktop/src/main/maker-ipc/taskActionAuthorization.ts
@@ -114,7 +114,7 @@ export const SCHEDULER_TASK_ACTION_TOOLS: ReadonlySet<string> = new Set([
'schedule_pause', 'schedule_resume', 'schedule_set_pre_run_hook',
]);
-export type TaskActionRisk = 'remove' | 'permission' | 'resume' | 'command';
+export type TaskActionRisk = 'remove' | 'permission' | 'resume' | 'command' | 'authority';
export type TaskActionScheduleDefinition = Pick<Schedule,
'id' | 'name' | 'executionMode' | 'scriptConfig' | 'preRunHook' | 'workingDir' | 'targetSessionId'>;
export interface TaskActionConfirmation {
@@ -129,6 +129,10 @@ export interface TaskActionTarget {
}
export interface TaskActionRoutineSnapshot {
+ prompt: string;
+ builtin?: boolean;
+ preRunCommand?: string;
+ details?: Record<string, unknown>;
enabled: boolean;
revision: number;
assertCurrent(): void;
@@ -136,7 +140,7 @@ export interface TaskActionRoutineSnapshot {
/** A small, explicit risk list. Everything else follows the task's normal permissions. */
export function taskActionRisk(call: Pick<Call, 'server' | 'tool' | 'args'>,
- facts?: { routineEnabled?: boolean; schedule?: TaskActionScheduleDefinition | null }): TaskActionRisk | undefined {
+ facts?: { routineEnabled?: boolean; routinePrompt?: string; routineBuiltin?: boolean; routinePreRunCommand?: string; schedule?: TaskActionScheduleDefinition | null }): TaskActionRisk | undefined {
const args = call.args && typeof call.args === 'object' && !Array.isArray(call.args)
? call.args as Record<string, unknown> : {};
// The local scheduler is a trusted MCP, but its script runner bypasses the
@@ -155,10 +159,20 @@ export function taskActionRisk(call: Pick<Call, 'server' | 'tool' | 'args'>,
return 'command';
}
}
+ const routineHook = args.preRunHook;
+ if (call.tool === 'routine_save' && routineHook && typeof routineHook === 'object' &&
+ 'command' in routineHook && typeof routineHook.command === 'string' && routineHook.command.trim() &&
+ routineHook.command !== facts?.routinePreRunCommand) return 'command';
if (call.tool === 'routine_delete' || call.tool === 'schedule_delete')
return 'remove';
if (call.tool === 'message_session_task' && args.decision !== undefined) return 'permission';
- if (call.tool === 'routine_save' && args.enabled === true && facts?.routineEnabled === false) return 'resume';
+ if ((call.tool === 'routine_save' && args.enabled === true || call.tool === 'routine_run_now') &&
+ facts?.routineEnabled === false) return 'resume';
+ // An active custom routine becomes a standing owner instruction on its next run.
+ // Drafts stay ordinary; manually running a draft requires the resume decision above.
+ if (call.tool === 'routine_save' && args.enabled === true && !facts?.routineBuiltin &&
+ typeof args.prompt === 'string' && args.prompt.trim() && args.prompt !== facts?.routinePrompt)
+ return 'authority';
if ((call.tool === 'message_session_task' && args.mode === 'resume') || call.tool === 'schedule_resume')
return 'resume';
return undefined;
@@ -250,10 +264,10 @@ export function taskActionPrincipal(callerSessionId: string): TaskActionPrincipa
return current?.sessionId === callerSessionId ? current.principal : undefined;
}
-/** Keep a saved routine's reviewed state through the service's atomic revision check. */
+/** Bind a routine save or manual execution to the service's atomic revision check. */
export function taskActionRoutineRevision(botId: string, id?: string): number | undefined {
const current = actionContext.getStore();
- return current?.tool === 'routine_save' && current.routine?.botId === botId && current.routine.id === id
+ return current && ['routine_save', 'routine_run_now'].includes(current.tool) && current.routine?.botId === botId && current.routine.id === id
? current.routine.revision : undefined;
}
diff --git a/apps/desktop/src/main/maker-ipc/taskActionHost.ts b/apps/desktop/src/main/maker-ipc/taskActionHost.ts
index 5864df3677..06a1d27282 100644
--- a/apps/desktop/src/main/maker-ipc/taskActionHost.ts
+++ b/apps/desktop/src/main/maker-ipc/taskActionHost.ts
@@ -222,7 +222,7 @@ export function createDesktopTaskActionAuthorizer(deps: {
? args.botId : caller.botId;
const routineId = typeof args.id === 'string' && args.id ? args.id : undefined;
const routine = principal === 'autonomous' && runtimePermissionApplies &&
- call.tool === 'routine_save' && args.enabled === true && routineBotId && routineId
+ (call.tool === 'routine_save' && (args.enabled === true || args.preRunHook != null) || call.tool === 'routine_run_now') && routineBotId && routineId
? await deps.captureRoutine(routineBotId, routineId) : undefined;
// Read saved commands for execution/partial updates; the card must show
// what a bare schedule ID will run, and a changed definition expires it.
@@ -368,13 +368,16 @@ export function createDesktopTaskActionAuthorizer(deps: {
};
// Missing owner provenance no longer disables ordinary work. Only explicit
// risks on autonomous turns need an exact, visible owner decision. The decision
- // does not change the principal or grant future calls; admission stays single-use.
- const risk = principal === 'autonomous' ? taskActionRisk(call, { routineEnabled: routine?.enabled, schedule }) : undefined;
+ // keeps the caller principal and admits only this invocation. Reviewed active
+ // routine instructions can become the standing grant for later routine runs.
+ const risk = principal === 'autonomous' ? taskActionRisk(call, { routineEnabled: routine?.enabled, routinePrompt: routine?.prompt,
+ routineBuiltin: routine?.builtin, routinePreRunCommand: routine?.preRunCommand, schedule }) : undefined;
if (risk && runtimePermissionApplies) {
await scope.assertCurrent();
const confirmed = await deps.confirm(sessionId, call.tool, structuredClone(call.args),
{ server: call.server, risk, ...(permissionTarget ? { details: permissionTarget.details }
- : risk === 'command' && schedule ? { details: { schedule } } : {}) });
+ : risk === 'command' && schedule ? { details: { schedule } }
+ : call.tool === 'routine_run_now' && routine?.details ? { details: routine.details } : {}) });
if (!confirmed) {
rejectedDecision = { ok: false, errorCode: 'USER_CANCELLED',
message: 'The action was not approved. Do not execute or retry it without a new request.' };
diff --git a/apps/desktop/src/main/mcp-integrations/mcp-providers.ts b/apps/desktop/src/main/mcp-integrations/mcp-providers.ts
index be40f7fe3a..ca33ebe68f 100644
--- a/apps/desktop/src/main/mcp-integrations/mcp-providers.ts
+++ b/apps/desktop/src/main/mcp-integrations/mcp-providers.ts
@@ -326,7 +326,10 @@ export function createDesktopMcpProviders(deps: DesktopMcpProvidersDeps): LiziMc
const routine = (await routineTools.list(botId)).find(row => row.id === id);
if (!routine) return undefined;
return {
- enabled: routine.enabled, revision: routine.revision,
+ enabled: routine.enabled, revision: routine.revision, prompt: routine.prompt,
+ builtin: !!routine.builtin, preRunCommand: routine.preRunHook?.command,
+ details: { routine: { id, name: routine.name, prompt: routine.prompt, enabled: routine.enabled,
+ revision: routine.revision, preRunHook: routine.preRunHook } },
assertCurrent() {
if (engine.list(botId).find(row => row.id === id)?.revision !== routine.revision)
throw new Error('TASK_ACTION_AUTHORIZATION_EXPIRED');
@@ -1052,6 +1055,7 @@ export function createDesktopMcpProviders(deps: DesktopMcpProvidersDeps): LiziMc
...routineTools,
save: (botId, input, id) => routineTools.save(botId, input, id,
taskActionRoutineRevision(botId, id)),
+ runNow: (botId, id) => routineTools.runNow(botId, id, taskActionRoutineRevision(botId, id)),
},
resolveBotId: async (callerSessionId) => {
const scope = activeOwnerScopeKey();
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index b92bc4a920..1d08ddd2b2 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -116,7 +116,8 @@
"remove": "This deletes automation. Review the target; approval applies only once.",
"permission": "This answers a permission request in another task on your behalf. Review the action; approval applies only once.",
"resume": "This resumes paused execution. Review the target; approval applies only once.",
- "command": "This saves or runs a command on your computer outside the agent’s tool approval. Review the command and working folder; approval applies only once."
+ "command": "This saves or runs a command on your computer outside the agent’s tool approval. Review the command and working folder; approval applies only once.",
+ "authority": "This creates or changes automation instructions that future runs will treat as standing authorization. Review the complete instructions; approval applies to this save."
},
"logSupport": {
"title": "Logs and Feedback",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 7b161faad5..ec13f05e63 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -116,7 +116,8 @@
"remove": "自動化を削除します。対象を確認してください。許可は今回のみ有効です。",
"permission": "別のタスクの権限リクエストに、あなたに代わって回答します。操作を確認してください。許可は今回のみ有効です。",
"resume": "一時停止中の実行を再開します。対象を確認してください。許可は今回のみ有効です。",
- "command": "エージェントのツール承認を経ずに、コンピューター上でコマンドを保存または実行します。コマンドと作業フォルダーを確認してください。許可は今回のみ有効です。"
+ "command": "エージェントのツール承認を経ずに、コンピューター上でコマンドを保存または実行します。コマンドと作業フォルダーを確認してください。許可は今回のみ有効です。",
+ "authority": "自動実行の指示を新規作成または変更します。以後の実行はこの指示への許可に基づきます。指示全体を確認してください。許可は今回の保存に適用されます。"
},
"logSupport": {
"title": "ログとフィードバック",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index eb305ae1ff..ceadf849f8 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -116,7 +116,8 @@
"remove": "자동화를 삭제합니다. 대상을 확인하세요. 허용은 이번 작업에만 적용됩니다.",
"permission": "다른 작업의 권한 요청에 사용자를 대신해 답합니다. 내용을 확인하세요. 허용은 이번 작업에만 적용됩니다.",
"resume": "일시 중지된 실행을 재개합니다. 대상을 확인하세요. 허용은 이번 작업에만 적용됩니다.",
- "command": "에이전트의 도구 승인 없이 컴퓨터에서 명령을 저장하거나 실행합니다. 명령과 작업 폴더를 확인하세요. 승인은 이번 한 번만 적용됩니다."
+ "command": "에이전트의 도구 승인 없이 컴퓨터에서 명령을 저장하거나 실행합니다. 명령과 작업 폴더를 확인하세요. 승인은 이번 한 번만 적용됩니다.",
+ "authority": "자동 실행 지침을 새로 만들거나 변경합니다. 이후 실행은 이 지침에 대한 권한을 따릅니다. 전체 지침을 확인하세요. 승인은 이번 저장에 적용됩니다."
},
"logSupport": {
"title": "로그 및 피드백",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 17ab760e60..7499c1b61d 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -116,7 +116,8 @@
"remove": "这会删除自动化。请核对目标,仅允许这一次。",
"permission": "这会代你回答另一个任务的授权请求。请核对操作,仅允许这一次。",
"resume": "这会恢复已暂停的执行。请核对目标,仅允许这一次。",
- "command": "这会在电脑上保存或运行命令,执行时不经过 Agent 的工具审批。请核对命令和工作目录,仅允许这一次。"
+ "command": "这会在电脑上保存或运行命令,执行时不经过 Agent 的工具审批。请核对命令和工作目录,仅允许这一次。",
+ "authority": "这会创建或改写自动执行的指令,后续执行将沿用这份授权。请核对完整指令,批准仅用于本次保存。"
},
"logSupport": {
"title": "日志与反馈",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index bdc2c07ec6..8727939c07 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -116,7 +116,8 @@
"remove": "這會刪除自動化。請核對目標,僅允許這一次。",
"permission": "這會代你回答另一個任務的授權請求。請核對操作,僅允許這一次。",
"resume": "這會恢復已暫停的執行。請核對目標,僅允許這一次。",
- "command": "這會在電腦上儲存或執行命令,執行時不經過 Agent 的工具審批。請核對命令與工作目錄,僅允許這一次。"
+ "command": "這會在電腦上儲存或執行命令,執行時不經過 Agent 的工具審批。請核對命令與工作目錄,僅允許這一次。",
+ "authority": "這會建立或改寫自動執行的指令,後續執行將沿用這份授權。請核對完整指令,批准僅用於本次儲存。"
},
"logSupport": {
"title": "日誌與回饋",
diff --git a/docs/product-rules/agent-user-parity.md b/docs/product-rules/agent-user-parity.md
index 80316a5f9d..6b1e7edf66 100644
--- a/docs/product-rules/agent-user-parity.md
+++ b/docs/product-rules/agent-user-parity.md
@@ -134,7 +134,7 @@ Ask 或审核要求确认时复用现有确认入口;Plan 不允许副作用
不得借定时工作扩大原授权范围。
2026-10-29 修订:伙伴的来源记录与访问权限、操作风险分开。移除自主工具白名单与
例行任务的静默 `NEEDS_OWNER_REQUEST`;普通操作沿用任务权限,仅对自主删除自动化、
-代答授权、恢复暂停、本机调度命令等明确风险显示可操作的一次性授权请求与等待状态。
+代答授权、恢复暂停、本机调度命令、授予常驻指令等明确风险显示可操作的一次性授权请求与等待状态。
确认、拒绝与取消共用桌面/手机原交互通道。见 [伙伴操作权限](teammate-authority.md)。
2026-10-22 修订:伙伴、转入消息与定时跟进的任务操作
统一沿用普通任务权限流程:Full Access 免审、Auto 使用原有自动审核、Ask 使用原有确认。
diff --git a/docs/product-rules/bot-routines.md b/docs/product-rules/bot-routines.md
index f996c0c83c..e9caebcfda 100644
--- a/docs/product-rules/bot-routines.md
+++ b/docs/product-rules/bot-routines.md
@@ -4,7 +4,7 @@
2026-09-07,用户批准借鉴 Grok Bot 的 Routine 交互,明确第一阶段只做本地内部协议,不建设公网 Webhook。参考仓为 `zqchris/grok-bot-0.18-reconstructed`,它是重建版本;Cindy 复用现有伙伴与调度执行器,不恢复旧版伙伴的项目、outbox 或独立会话管理器。
-一条例行任务属于一个伙伴,包含名称、常驻指令、启用状态和多个触发条件。条件之间是 OR:同一事件命中多个条件只入队一次。时间条件与事件条件可以共存,适合「PR 更新时检查,每小时兜底」。条件编辑不授予模型额外权限。
+一条例行任务属于一个伙伴,包含名称、常驻指令、启用状态和多个触发条件。条件之间是 OR:同一事件命中多个条件只入队一次。时间条件与事件条件可以共存,适合「PR 更新时检查,每小时兜底」。条件编辑不授予模型额外权限。自主创建启用的自定义规则或改写启用指令须经本人确认后才成为后续运行的常驻授权;禁用草稿可普通保存,手动执行停用规则须走同一恢复确认。只改名称、时间且沿用原指令及命令不追加授权。判据与版本绑定见 [伙伴操作权限](teammate-authority.md)。
桌面入口在伙伴设置「例行任务」及伙伴任务的标准右侧栏。已创建的例行任务 Session 也进入桌面和手机任务列表,按真实伙伴归属显示头像、参与伙伴来源筛选;仅有自动化规则、尚未创建 Session 时不凭空生成列表任务。列表里的普通规则和内置规则都用右侧开关直接启停,文字明确显示启用/暂停,排队/运行中单独显示,不以时钟或暂停图标代替状态。点普通规则名称进入详情,仍可修改指令、立即运行、增删触发条件、删除规则和查看历史;历史的失败/中断结果在展开前可读。立即运行先保存当前编辑,再运行,避免执行屏幕上看不到的旧指令。
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index ff789152cd..bb74496d2f 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -961,7 +961,7 @@ Host 在直接工具和渐进调用共用的执行入口核验身份与执行范
2026-10-22 修订:所有实时执行权限档覆盖伙伴任务操作;Full Access 免审、Auto 使用原有自动审核、
Ask 使用原有确认,不再因转入、自动唤醒或主人输入标记缺失追加行动同意判定。
2026-10-29 修订:删除自主工具白名单与静默拒绝。来源只决定原话归属,普通工作沿用现有权限。
-自主删除自动化、代答授权、恢复暂停及本机调度命令进入普通授权交互,等待状态与操作卡在桌面、手机可见,
+自主删除自动化、代答授权、恢复暂停、本机调度命令及授予常驻指令进入普通授权交互,等待状态与操作卡在桌面、手机可见,
同意后继续当前调用,拒绝后停止;正本见 [伙伴操作权限](teammate-authority.md)。
helper 与 Orca 的写操作均使用同一逐次审批策略;Orca 的只读操作仍沿用可信查询策略。
权限只读运行中任务的稳定状态;从 Host 接收调用并捕获快照起,权限切换、计划模式、实例变化
diff --git a/docs/product-rules/teammate-authority.md b/docs/product-rules/teammate-authority.md
index 3a83b22fcb..266d99d745 100644
--- a/docs/product-rules/teammate-authority.md
+++ b/docs/product-rules/teammate-authority.md
@@ -19,18 +19,21 @@
| 风险 | 实际入口 |
| --- | --- |
-| 本机调度命令 | `schedule_create` / `schedule_update` 保存脚本执行或命令前置检查、`schedule_run_now` 执行含此类命令的已存定义、`cindy_helper` 和 `cindy_scheduler` 两个入口的 `schedule_set_pre_run_hook` 安装并自测脚本 |
+| 本机调度命令 | `schedule_create` / `schedule_update` 保存脚本执行或命令前置检查、`schedule_run_now` 执行含此类命令的已存定义、`cindy_helper` 和 `cindy_scheduler` 两个入口的 `schedule_set_pre_run_hook` 安装并自测脚本,以及 `routine_save` 保存新命令前置检查(沿用同一命令不追加确认) |
+| 授予常驻指令 | `routine_save` 新建启用的自定义规则或改写启用规则的指令;禁用草稿和不改指令的编辑沿原权限 |
| 删除自动化 | `routine_delete`、`schedule_delete` |
| 代用户回答权限请求 | `message_session_task` 携带 `decision` |
-| 恢复暂停执行 | `message_session_task(mode=resume)`、`schedule_resume`,以及 `routine_save` 将已有停用规则保存为启用(含内置规则) |
+| 恢复暂停执行 | `message_session_task(mode=resume)`、`schedule_resume`,以及 `routine_save` 将已有停用规则保存为启用(含内置规则),以及 `routine_run_now` 手动执行停用规则 |
其余操作不命中风险表就继续现有权限流程。新增普通工具不需要另开“自主解锁”例外。
主人输入、已核实的主人转达和受托指令沿正常权限审核,不再加第二张行动确认卡。
风险表不是平台权限、账号访问或消息来源认证的替代品。
本机调度的脚本及前置检查由宿主直接执行,不经过 Agent 的 Bash 审批;自主调用须展示命令、工作目录及准确动作,由主人决定。普通提示词自动化、提醒与只读工具不追加此类确认。
按 ID 执行或修改时,卡片展示已存命令定义;确认期间定义变化使旧许可失效。跨电脑调度仍沿已有逐次任务权限流程。
-保存新规则、编辑已启用规则和继续保存为停用不追加恢复确认;以宿主读取的现有状态判断,
-不把全部保存操作升级成风险。恢复许可同时绑定规则版本,确认期间修改规则会使旧许可失效。
+禁用草稿、重命名、改时间等不改常驻指令和命令的保存不追加授权;主人输入和受托指令仍沿原权限。
+自主创建启用的自定义指令或改写启用规则指令,必须经一次性本人确认才可作为后续 entrusted 执行的常驻授权,不能靠保存制造主人授权。
+停用草稿可普通保存;启用或手动执行前须确认完整指令。手动执行许可仅限这一次,不改变规则的停用状态。
+指令授权、恢复和手动执行许可绑定规则版本;确认期间修改规则会使旧许可失效,执行沿服务已有原子版本检查。
## 等待、决定与恢复
diff --git a/packages/lizi-mcps/src/xdt-helper/bot_capabilities.ts b/packages/lizi-mcps/src/xdt-helper/bot_capabilities.ts
index 69adcd0602..e58517e8d6 100644
--- a/packages/lizi-mcps/src/xdt-helper/bot_capabilities.ts
+++ b/packages/lizi-mcps/src/xdt-helper/bot_capabilities.ts
@@ -77,7 +77,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.',
- 'Ordinary task operations and routine updates use the current task permissions, including autonomous and scheduled turns. Missing owner-input provenance is not an owner refusal. On autonomous turns the host asks for an exact, one-time decision only for explicit risks: deleting automation, answering permissions, resuming paused execution, and local scheduler commands that run outside agent tool approval. The pending permission is visible; approval continues that invocation, while rejection or cancellation stops it. Do not retry through another tool. Source identity and account access remain separate checks; automation and other speakers never become verified owner words. Relay only necessary background alongside the host-verified request, without inventing authorization. Inspect get_task_digest before intervening; a long-running, paused or already recovered task does not need automatic nudges.',
+ 'Ordinary task operations and routine updates use the current task permissions, including autonomous and scheduled turns. Missing owner-input provenance is not an owner refusal. On autonomous turns the host asks for an exact, one-time decision only for explicit risks: deleting automation, answering permissions, resuming paused execution, local scheduler commands that run outside agent tool approval, and granting new or changed standing automation instructions. The pending permission is visible; approval continues that invocation, while rejection or cancellation stops it. Do not retry through another tool. Source identity and account access remain separate checks; automation and other speakers never become verified owner words. Relay only necessary background alongside the host-verified request, without inventing authorization. Inspect get_task_digest before intervening; a long-running, paused or already recovered task does not need automatic nudges.',
'Use `get_capabilities` for application features, and `get_capabilities` with scope `help` for where things are in the UI and how to use them. 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');