Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(helper): support cross-device session unarchive
zqchris84c9fa669437
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.tsindex 67b0f0ceb1..1fcbf9a7af 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts@@ -182,6 +182,7 @@ import {import { retireDeletedPiSubagentState } from '../piSubagentDeletion';import { setSessionRouteLockImplementation } from '../../sessionRouteLock';import { assertTrustedAppRendererEvent } from '../../../security/trustedAppRenderer.js';+import { createRemoteSessionsStatusSetter } from '../../../mcp-integrations/sessionStatusRemote.js';function createDb(): void {const sqlite = new Database(':memory:');@@ -902,6 +903,27 @@ describe('local-db:sessions:update handler wiring', () => {expect(h.closeSharedTask).toHaveBeenCalledWith('codex-local', h.client);});+ it('restores an archived task through the remote adapter and existing patch-meta handler', async () => {+ h.sqlite!.prepare("UPDATE sessions SET status = 'archived' WHERE id = ?").run('codex-local');+ const invoke = vi.fn(async (_device: string, channel: string, args: unknown[]) => {+ expect(channel).toBe('local-db:sessions:patch-meta');+ return { ok: true as const, result: await invokePatchMeta(args[0] as string, args[1] as Record<string, unknown>) };+ });+ const restore = createRemoteSessionsStatusSetter({ captureAccess: () => () => {}, invoke });+ expect(await restore({ deviceId: 'studio', sessionIds: ['codex-local'], status: 'active' })).toMatchObject({+ ok: true, changed: [{ sessionId: 'codex-local', status: 'active' }],+ });+ expect(h.sqlite!.prepare('SELECT status FROM sessions WHERE id = ?').get('codex-local')).toEqual({ status: 'active' });+ expect(invoke).toHaveBeenCalledOnce();+ expect(h.closeSharedTask).not.toHaveBeenCalled();+ });++ it.each(['active', 'archived'] as const)('remote patch-meta cannot change a deleted task to %s', async (status) => {+ h.sqlite!.prepare("UPDATE sessions SET status = 'deleted' WHERE id = ?").run('codex-local');+ await expect(invokePatchMeta('codex-local', { status })).rejects.toThrow('已删除的任务不能恢复或归档');+ expect(h.sqlite!.prepare('SELECT status FROM sessions WHERE id = ?').get('codex-local')).toEqual({ status: 'deleted' });+ });+it('cleans runtime state before releasing the remote terminal status lock', async () => {const order: string[] = [];h.prepareSharedTaskClosure.mockImplementationOnce(async () => {diff --git a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.tsindex 07b83090f0..873df633bb 100644--- a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts@@ -436,6 +436,24 @@ describe('teammate pre-run command approval', () => {});describe('cross-device actions use the task permission mode', () => {+ it.each(['archive_sessions', 'unarchive_sessions'])('reviews remote %s in direct and progressive calls', (name) => {+ for (const session_ids of [['studio::s1'], ['s1', 'studio::s2']]) {+ const args = { session_ids };+ for (const context of [+ { toolName: name, toolParams: args },+ { toolName: 'call_tool', toolParams: { name, args } },+ { toolParams: { name, args } },+ { toolName: 'call_tool', toolParams: JSON.stringify({ name, args: JSON.stringify(args) }) },+ ]) {+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_helper', ...context })).toBe('prompt-each-time');+ }+ }+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_helper', toolName: 'call_tool',+ toolParams: { name, args: { session_ids: ['s1'] } } })).toBe('auto-approve');+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_helper', toolName: 'call_tool',+ toolParams: { name, args: { session_ids: ['local::s1'] } } })).toBe('auto-approve');+ });+const scheduler = (name: string, args: Record<string, unknown>, toolName: string | undefined = 'call_tool') =>getDesktopMcpToolApprovalPolicy({serverName: 'cindy_scheduler',diff --git a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.tsindex 91b1000205..2f8b4ce087 100644--- a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts+++ b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts@@ -235,6 +235,11 @@ export function getDesktopMcpToolApprovalPolicy(if (action === 'send_to_session' && targetsAnotherComputer(sessionIdDevice(args?.target_session_id))) {return 'prompt-each-time';}+ if ((action === 'archive_sessions' || action === 'unarchive_sessions') &&+ (!Array.isArray(args?.session_ids) || args.session_ids.some((id) =>+ typeof id !== 'string' || targetsAnotherComputer(sessionIdDevice(id))))) {+ return 'prompt-each-time';+ }}// 改动另一台电脑上的定时任务(可改写并触发那台电脑上的命令)同样交给权限档:Full Access// 免审批,Auto 走统一审阅,Ask 由用户确认。本机操作与跨电脑读取保持原样。diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/sessionStatusRemote.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/sessionStatusRemote.test.tsnew file mode 100644index 0000000000..c02c808996--- /dev/null+++ b/apps/desktop/src/main/mcp-integrations/__tests__/sessionStatusRemote.test.ts@@ -0,0 +1,89 @@+import { describe, expect, it, vi } from 'vitest';+import { DeviceLinkError, type InvokeResultPayload } from '@cindy/device-link';+import { createRemoteSessionsStatusSetter } from '../sessionStatusRemote.js';++const request = { deviceId: 'studio', sessionIds: ['s1', 's2', 's3'], status: 'active' as const };+const row = (id: string) => ({ ok: true as const, result: { id, status: 'active', title: 'remote title', workingDir: null } });+function setup(outcome: InvokeResultPayload | Error) {+ const invoke = vi.fn(async () => {+ if (outcome instanceof Error) throw outcome;+ return outcome;+ });+ return { invoke, setStatus: createRemoteSessionsStatusSetter({ invoke, captureAccess: () => () => {} }) };+}++describe('remote session archive status', () => {+ it('uses only the existing patch-meta channel with the stripped id and status', async () => {+ const s = setup(row('s1'));+ expect(await s.setStatus({ ...request, sessionIds: ['s1'] })).toEqual({ ok: true, changed: [+ { sessionId: 's1', status: 'active', title: 'remote title', workingDir: null },+ ] });+ expect(s.invoke).toHaveBeenCalledExactlyOnceWith('studio', 'local-db:sessions:patch-meta', ['s1', { status: 'active' }], { preSend: expect.any(Function) });+ });++ it.each([+ ['DEVICE_OFFLINE', '', 'REMOTE_DEVICE_OFFLINE'],+ ['REMOTE_DISABLED', '', 'REMOTE_DISABLED'],+ ['ACCESS_REVOKED', '', 'REMOTE_ACCESS_REVOKED'],+ ['CHANNEL_NOT_ALLOWED', '', 'REMOTE_UNSUPPORTED'],+ ['VERSION_MISMATCH', '', 'REMOTE_UNSUPPORTED'],+ ['NOT_CONNECTED', '', 'REMOTE_UNAVAILABLE'],+ ['DEVICE_UNRESPONSIVE', '', 'REMOTE_UNAVAILABLE'],+ ['IPC_ERROR', '[DEVICE_LINK_CONTROL_DISABLED] off', 'REMOTE_DISABLED'],+ ['IPC_ERROR', '[PRECONDITION_FAILED] 已删除的任务不能恢复或归档', 'PRECONDITION_FAILED'],+ ['IPC_ERROR', '[NOT_FOUND] Session 不存在', 'NOT_FOUND'],+ ['IPC_ERROR', '[NOT_FOUND] Session does not exist', 'REMOTE_RESULT_UNKNOWN'],+ ['IPC_ERROR', '[INTERNAL] failure after write', 'REMOTE_RESULT_UNKNOWN'],+ ['INVOKE_TIMEOUT', '', 'REMOTE_RESULT_UNKNOWN'],+ ])('classifies %s / %s without retry or local fallback', async (code, message, expected) => {+ const s = setup({ ok: false, error: { code, message } });+ expect(await s.setStatus(request)).toMatchObject({ ok: false, errorCode: expected, changed: [], failedSessionId: 's1', remainingSessionIds: ['s2', 's3'] });+ expect(s.invoke).toHaveBeenCalledOnce();+ });++ it('keeps a timeout/disconnect after sending uncertain even when its code looks like a rejection', async () => {+ const s = setup(Object.assign(new DeviceLinkError('NOT_CONNECTED', ''), { inFlight: true }));+ expect(await s.setStatus(request)).toMatchObject({ errorCode: 'REMOTE_RESULT_UNKNOWN' });+ expect(s.invoke).toHaveBeenCalledOnce();+ });++ it('stops at the first failure, retains successful receipts, and never rolls them back', async () => {+ const s = setup({ ok: false, error: { code: 'DEVICE_OFFLINE', message: '' } });+ s.invoke.mockResolvedValueOnce(row('s1'));+ expect(await s.setStatus(request)).toMatchObject({ ok: false, errorCode: 'REMOTE_DEVICE_OFFLINE',+ changed: [{ sessionId: 's1', status: 'active' }], failedSessionId: 's2', remainingSessionIds: ['s3'],+ });+ expect(s.invoke).toHaveBeenCalledTimes(2);+ });++ it.each([null, {}, { id: 's1', status: 'archived' }, { id: 'other', status: 'active' }])('rejects an untrusted success receipt %j', async (result) => {+ const s = setup({ ok: true, result });+ expect(await s.setStatus(request)).toMatchObject({ errorCode: 'REMOTE_RESULT_UNKNOWN', changed: [] });+ });++ it('checks the same account snapshot before every send and after every receipt', async () => {+ let current = true;+ const check = vi.fn(() => { if (!current) throw new Error('owner changed'); });+ const captureAccess = vi.fn(() => check);+ const invoke = vi.fn(async (_device: string, _channel: string, args: unknown[], options?: { preSend?: () => void }) => {+ options?.preSend?.();+ if (args[0] === 's2') current = false;+ return row(String(args[0]));+ });+ const setStatus = createRemoteSessionsStatusSetter({ invoke, captureAccess });+ const result = await setStatus(request);+ expect(result).toMatchObject({ ok: false, errorCode: 'REMOTE_RESULT_UNKNOWN', failedSessionId: 's2', remainingSessionIds: ['s3'],+ changed: [{ sessionId: 's1', title: null, workingDir: null }],+ });+ expect(captureAccess).toHaveBeenCalledOnce();+ expect(invoke).toHaveBeenCalledTimes(2);+ expect(JSON.stringify(result)).not.toContain('remote title');+ });++ it('does not send while the account boundary is unavailable', async () => {+ const invoke = vi.fn();+ const setStatus = createRemoteSessionsStatusSetter({ invoke, captureAccess: () => { throw new Error('switching'); } });+ expect(await setStatus(request)).toMatchObject({ errorCode: 'HOST_NOT_READY', changed: [] });+ expect(invoke).not.toHaveBeenCalled();+ });+});diff --git a/apps/desktop/src/main/mcp-integrations/mcp-providers.ts b/apps/desktop/src/main/mcp-integrations/mcp-providers.tsindex e80ced1801..1714794a7f 100644--- a/apps/desktop/src/main/mcp-integrations/mcp-providers.ts+++ b/apps/desktop/src/main/mcp-integrations/mcp-providers.ts@@ -106,6 +106,7 @@ import {import { botSessionLinks, sessions } from '../localDb/schema.js';import { createSchedulerRemoteDeps } from './schedulerDevices.js';import { createRemoteSessionHandoff } from './sessionHandoffRemote.js';+import { createRemoteSessionsStatusSetter } from './sessionStatusRemote.js';import { isCindyLearnSkillEnabled } from '../skillhub/activationPreferences.js';import { botLearningTracker } from '../maker-ipc/botLearningTracker.js';import { getLearnController } from '../learn-host/index.js';@@ -706,6 +707,9 @@ export function createDesktopMcpProviders(deps: DesktopMcpProvidersDeps): LiziMcreturn { ok: false, errorCode: 'INTERNAL', message };}},+ setRemoteSessionsStatus: deps.historyRemote+ ? createRemoteSessionsStatusSetter({ captureAccess: deps.historyRemote.captureAccess, invoke: deps.invokeRemote })+ : undefined,setSessionsStatus: async ({ sessionIds, status }) => {if (!tryGetDbClient()) {return { ok: false, errorCode: 'HOST_NOT_READY', message: 'localDb not ready' };diff --git a/apps/desktop/src/main/mcp-integrations/sessionStatusRemote.ts b/apps/desktop/src/main/mcp-integrations/sessionStatusRemote.tsnew file mode 100644index 0000000000..b1e7911cd7--- /dev/null+++ b/apps/desktop/src/main/mcp-integrations/sessionStatusRemote.ts@@ -0,0 +1,116 @@+import { DeviceLinkError, type InvokeResultPayload } from '@cindy/device-link';+import type { ArchiveSessionsDeps, SessionStatusChangeItem } from '@cindy/mcps';++type Failure = { errorCode: string; message: string };+const unknownOutcome = (): Failure => ({+ errorCode: 'REMOTE_RESULT_UNKNOWN',+ message: '未收到可信回执,失败项可能已生效;请先查询目标任务状态再决定是否重试。后续项未执行。',+});++/** Only classify proven pre-write rejections as definite failures. */+function failure(code: string, message: string): Failure {+ const actual = code === 'IPC_ERROR'+ ? /(?:^|:\s*(?:Error:\s*)?)\[([A-Z0-9_]+)]/.exec(message)?.[1] ?? code+ : code;+ switch (actual) {+ case 'CHANNEL_NOT_ALLOWED':+ case 'VERSION_MISMATCH':+ return { errorCode: 'REMOTE_UNSUPPORTED', message: '目标电脑的版本不支持远程归档/取消归档。' };+ case 'DEVICE_OFFLINE':+ return { errorCode: 'REMOTE_DEVICE_OFFLINE', message: '目标电脑不在线。' };+ case 'ACCESS_REVOKED':+ return { errorCode: 'REMOTE_ACCESS_REVOKED', message: '目标电脑已撤销远程控制授权。' };+ case 'PERMISSION_DENIED':+ case 'REMOTE_DISABLED':+ case 'DEVICE_LINK_CONTROL_DISABLED':+ return { errorCode: 'REMOTE_DISABLED', message: '未允许远程控制目标电脑。' };+ case 'LINK_NOT_OPEN':+ case 'NOT_CONNECTED':+ case 'BACKPRESSURE':+ case 'DEVICE_LINK_NOT_CONNECTED':+ case 'DEVICE_LINK_STANDBY':+ case 'DEVICE_UNRESPONSIVE':+ return { errorCode: 'REMOTE_UNAVAILABLE', message: '暂时无法连接目标电脑。' };+ case 'INVALID_PARAMS':+ return { errorCode: 'INVALID_ARGS', message: '目标电脑拒绝了归档状态参数。' };+ case 'PRECONDITION_FAILED':+ return { errorCode: 'PRECONDITION_FAILED', message: '目标任务已删除或由专属生命周期管理,不能通过此工具恢复或归档。' };+ case 'NOT_FOUND':+ // dispatch also emits NOT_FOUND *after* the handler on owner/visibility changes.+ if (message.includes('[NOT_FOUND] Session 不存在')) {+ return { errorCode: 'NOT_FOUND', message: '目标任务不存在。' };+ }+ return unknownOutcome();+ default:+ return unknownOutcome();+ }+}++/** Reuse the remote UI's narrow patch-meta service; no new channel, DB writes or retries. */+export function createRemoteSessionsStatusSetter(deps: {+ captureAccess(): () => void;+ invoke(+ deviceId: string,+ channel: string,+ args: unknown[],+ options?: { preSend?: () => void },+ ): Promise<InvokeResultPayload>;+}): NonNullable<ArchiveSessionsDeps['setRemoteSessionsStatus']> {+ return async ({ deviceId, sessionIds, status }) => {+ const changed: SessionStatusChangeItem[] = [];+ const fail = (index: number, reason: Failure) => ({+ ok: false as const,+ ...reason,+ changed,+ failedSessionId: sessionIds[index],+ remainingSessionIds: sessionIds.slice(index + 1),+ });+ let assertCurrent: () => void;+ try {+ assertCurrent = deps.captureAccess();+ } catch {+ return fail(0, { errorCode: 'HOST_NOT_READY', message: '账号正在切换,没有写入。' });+ }+ for (const [index, sessionId] of sessionIds.entries()) {+ try {+ assertCurrent();+ } catch {+ // Preserve receipts without returning the previous account's metadata.+ changed.forEach((item) => { item.title = null; item.workingDir = null; });+ return fail(index, { errorCode: 'HOST_NOT_READY', message: '账号已切换,当前项及后续项未执行。' });+ }+ let response: InvokeResultPayload;+ try {+ response = await deps.invoke(deviceId, 'local-db:sessions:patch-meta', [sessionId, { status }], {+ preSend: assertCurrent,+ });+ } catch (error) {+ try { assertCurrent(); } catch {+ changed.forEach((item) => { item.title = null; item.workingDir = null; });+ }+ const reason = error instanceof DeviceLinkError+ ? (error.inFlight ? unknownOutcome() : failure(error.code, error.message))+ : failure('IPC_ERROR', error instanceof Error ? error.message : '');+ return fail(index, reason);+ }+ try {+ assertCurrent();+ } catch {+ changed.forEach((item) => { item.title = null; item.workingDir = null; });+ return fail(index, unknownOutcome());+ }+ if (!response.ok) return fail(index, failure(response.error.code, response.error.message));+ const row = response.result as Record<string, unknown> | null;+ if (!row || typeof row !== 'object' || Array.isArray(row) || row.id !== sessionId || row.status !== status) {+ return fail(index, unknownOutcome());+ }+ changed.push({+ sessionId,+ status,+ title: typeof row.title === 'string' ? row.title : null,+ workingDir: typeof row.workingDir === 'string' ? row.workingDir : null,+ });+ }+ return { ok: true, changed };+ };+}diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex f6e531478e..f7a5f227a3 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -405,13 +405,41 @@ handler 完成后复核可见性与账号失败(`[NOT_FOUND] Session does not**审批。** `cindy_scheduler` 与 `cindy_helper` 是整体静默的可信 server;跨电脑写操作(`schedule_update` / `pause` / `resume` / `delete` / `run_now` 带非本机 `device`,以及-`send_to_session` 的 `deviceId::sessionId` 目标)在 `mcp-tool-approval-policy.ts` 里按内层动作+`send_to_session` 的 `deviceId::sessionId` 目标,以及 `archive_sessions` / `unarchive_sessions`+含非本机设备前缀的 ID)在 `mcp-tool-approval-policy.ts` 里按内层动作判为逐次审批,交给任务权限档;本机调用与跨电脑读取仍静默。手机与 IM 通过所在电脑的 Agent 使用这些能力,无新增界面。实现与回归见`packages/lizi-mcps/src/scheduler/_devices.ts`、`mcp-integrations/schedulerDevices.ts`、`mcp-integrations/sessionHandoffRemote.ts`、`maker-ipc/sessionHandoffIpc.ts` 及各自的测试。+### Agent 跨电脑归档与取消归档++`archive_sessions` / `unarchive_sessions` 原位接受 `deviceId::sessionId`。本机批次仍调用+`setSessionsStatusInDb`,保持原子性;`local::sessionId` 是本机别名,先规范化再检查重复和当前任务保护,+不允许嵌套设备前缀。远程复用已有 `local-db:sessions:patch-meta(id, { status })`+与目标电脑的 `patchSessionMetaInDb` 生命周期服务,状态仅为 `archived` / `active`。没有新 channel、+allowlist、数据库 migration 或第三台电脑转发。复合 ID 不交给本机服务,无本机回退。++最小批次合同:一次只能指定同一台电脑,混合本机/远程或多设备批次写入前返回 `INVALID_ARGS`。+远程按输入顺序执行,首次失败停止,无回滚、无自动重放。失败 `data` 中 `changed` 为已确认完成项,+`failed_session_id` 为失败或结果未知项,`remaining_session_ids` 为未执行项;各 ID 保留设备前缀。+`partial` 表示已有确认完成项或失败项结果未知,不能把整个远程批次当作事务。++沿用同账号远控、双方允许控制、owner 检查与目标可见性。跨电脑写入进入当前任务权限档,+本机操作保持原样。离线、禁用、撤权、不支持分别明确返回;旧宿主拒绝 `patch-meta` 时返回+`REMOTE_UNSUPPORTED`。已支持这个 channel 和生命周期保护的旧宿主无需新增协议即可执行。+目标服务的不存在与已删除/专属生命周期限制返回 `NOT_FOUND` / `PRECONDITION_FAILED`;+隧道在处理后复核账号/可见性的 NOT_FOUND、超时、在途断连、错误回执与内部错误均按+`REMOTE_RESULT_UNKNOWN`,说明该项可能已生效,调用方先查状态再决定是否重试。+同一账号快照覆盖整个远程批次,切账号后停止并不返回旧账号的标题/目录。++取消归档不发送旧消息、不启动任务执行、不恢复暂停自动化。成功后另调既有 `send_to_session`+继续投递;该通道仍按目标当前状态与已保存权限执行。手机/IM 经执行电脑的 Agent 使用同一工具,+没有新增 UI;SSH 工作目录任务仍由其所属 Desktop 管理状态,不将 SSH 主机视为 device-link 设备。+不改变共享连接的重试、超时或恢复策略。回归见 `archiveSessionsTool.test.ts`、+`sessionStatusRemote.test.ts`、`sessionsUpdate.test.ts` 和 `mcpToolApprovalPolicy.test.ts`。+## Desktop 设备互联 Review桌面控制端的 /review 通过 maker:review:start 请求被控 Desktop 执行。证据收集、Reviewerdiff --git a/docs/product-rules/agent-user-parity.md b/docs/product-rules/agent-user-parity.mdindex 061f126b91..ed34cc6ace 100644--- a/docs/product-rules/agent-user-parity.md+++ b/docs/product-rules/agent-user-parity.md@@ -42,7 +42,8 @@| 任务 | 列出、搜索、读聊天记录、发现电脑 | 有 | 有 || 任务 | 给既有任务发消息 | 有 | 有(2026-10-14) || 任务 | 新建任务 | 有 | 无 |-| 任务 | 改名、归档 / 取消归档、移动、标签 | 有 | 无 |+| 任务 | 归档 / 取消归档 | 有 | 有(2026-10-16) |+| 任务 | 改名、移动、标签 | 有 | 无 || 任务 | 看输入队列;编辑 / 撤回 / 调序自己发的排队消息;插话;停止 | 有 | 无 || 任务 | 模型、推理强度、Fast | 有 | 无 || 任务 | 删除、Fork、Rewind、切换权限档、代用户确认权限或回答提问 | 无 | 无 |diff --git a/packages/lizi-mcps/src/__tests__/archiveSessionsTool.test.ts b/packages/lizi-mcps/src/__tests__/archiveSessionsTool.test.tsindex c1e01d0db6..b218ba26bf 100644--- a/packages/lizi-mcps/src/__tests__/archiveSessionsTool.test.ts+++ b/packages/lizi-mcps/src/__tests__/archiveSessionsTool.test.ts@@ -6,6 +6,7 @@ import { describe, expect, it, vi } from 'vitest';import { XdtHelperToolRegistry } from '../lizi_xdtHelperToolRegistry.js';import type { XdtHelperToolResult } from '../lizi_xdtHelperToolRegistry.js';+import { registerSendToSessionTool } from '../xdt-helper/send_to_session.js';import {registerArchiveSessionsTool,registerUnarchiveSessionsTool,@@ -20,7 +21,7 @@ function parse(result: XdtHelperToolResult) {return JSON.parse(block.text);}-function setup(opts?: { sessionId?: string }) {+function setup(opts?: { sessionId?: string; remote?: ArchiveSessionsDeps['setRemoteSessionsStatus'] }) {const sessionId = opts?.sessionId ?? 'current-session';const setSessionsStatus: ArchiveSessionsDeps['setSessionsStatus'] = vi.fn(async ({ sessionIds, status }: Parameters<ArchiveSessionsDeps['setSessionsStatus']>[0]) => ({@@ -40,6 +41,7 @@ function setup(opts?: { sessionId?: string }) {workingDir: '/tmp/proj',}),setSessionsStatus,+ setRemoteSessionsStatus: opts?.remote,};const registry = new XdtHelperToolRegistry();registerArchiveSessionsTool(registry, deps);@@ -139,6 +141,32 @@ describe('archive_sessions tool', () => {});describe('unarchive_sessions tool', () => {+ it('normalizes the explicit local alias before self-protection and deduplication', async () => {+ const { registry, setSessionsStatus } = setup();+ expect(parse(await registry.call('archive_sessions', { session_ids: ['local::current-session'] })).errorCode).toBe('INVALID_ARGS');+ expect(parse(await registry.call('unarchive_sessions', { session_ids: ['s1', 'local::s1'] })).errorCode).toBe('INVALID_ARGS');+ expect(setSessionsStatus).not.toHaveBeenCalled();+ expect(parse(await registry.call('unarchive_sessions', { session_ids: ['local::s1'] })).ok).toBe(true);+ expect(setSessionsStatus).toHaveBeenCalledExactlyOnceWith({ sessionIds: ['s1'], status: 'active' });+ });++ it('returns an address the existing send tool can use, without sending during restoration', async () => {+ const { registry, setSessionsStatus } = setup({ remote: async () => ({ ok: true, changed: [+ { sessionId: 's1', title: null, workingDir: null, status: 'active' },+ ] }) });+ const sendToSession = vi.fn();+ const sendToRemoteSession = vi.fn(async () => ({ ok: true as const, agentKind: 'codex' as const,+ wakeKind: 'queued' as const, targetTitle: null, targetLastUserSendAt: null,+ }));+ registerSendToSessionTool(registry, { getSessionContext: () => ({ sessionId: 'caller', agentKind: 'codex', workingDir: '/tmp/proj' }), sendToSession, sendToRemoteSession });+ const restored = parse(await registry.call('unarchive_sessions', { session_ids: ['studio::s1'] }));+ expect(sendToRemoteSession).not.toHaveBeenCalled();+ expect(parse(await registry.call('send_to_session', { target_session_id: restored.changed[0].session_id, message: 'continue' }))).toMatchObject({ ok: true, wake_kind: 'queued' });+ expect(sendToRemoteSession).toHaveBeenCalledExactlyOnceWith({ deviceId: 'studio', sessionId: 's1', message: 'continue', dispatcherSessionId: 'caller' });+ expect(sendToSession).not.toHaveBeenCalled();+ expect(setSessionsStatus).not.toHaveBeenCalled();+ });+it('passes status=active to host and allows the current session', async () => {const { registry, setSessionsStatus } = setup({ sessionId: 'current-session' });const res = await registry.call('unarchive_sessions', {@@ -151,4 +179,51 @@ describe('unarchive_sessions tool', () => {});expect(parse(res)).toMatchObject({ ok: true, status: 'active', count: 2 });});++ it.each(['archive_sessions', 'unarchive_sessions'])('routes %s qualified ids exclusively to the remote host', async (name) => {+ const status = name === 'archive_sessions' ? 'archived' : 'active';+ const remote = vi.fn(async () => ({ ok: true as const, changed: [+ { sessionId: 'current-session', title: 'remote', workingDir: null, status: status as 'active' | 'archived' },+ ] }));+ const { registry, setSessionsStatus } = setup({ remote });+ const result = parse(await registry.call(name, { session_ids: ['studio::current-session'] }));+ expect(remote).toHaveBeenCalledExactlyOnceWith({ deviceId: 'studio', sessionIds: ['current-session'], status });+ expect(setSessionsStatus).not.toHaveBeenCalled();+ expect(result).toMatchObject({ ok: true, count: 1, changed: [{ session_id: 'studio::current-session', status }] });+ });++ it.each([+ ['local-task', 'studio::remote-task'],+ ['studio::s1', 'laptop::s2'],+ ['studio::'],+ ['::task'],+ ['local::studio::s1'],+ ])('rejects a mixed/malformed batch before any write: %j', async (...session_ids) => {+ const remote = vi.fn();+ const { registry, setSessionsStatus } = setup({ remote });+ expect(parse(await registry.call('unarchive_sessions', { session_ids })).errorCode).toBe('INVALID_ARGS');+ expect(remote).not.toHaveBeenCalled();+ expect(setSessionsStatus).not.toHaveBeenCalled();+ });++ it('never sends a composite id to the local host when remote support is absent', async () => {+ const { registry, setSessionsStatus } = setup();+ expect(parse(await registry.call('unarchive_sessions', { session_ids: ['studio::s1'] })).errorCode).toBe('REMOTE_UNSUPPORTED');+ expect(setSessionsStatus).not.toHaveBeenCalled();+ });++ it('preserves partial receipts and qualifies the failed and unattempted ids', async () => {+ const remote = vi.fn(async () => ({+ ok: false as const, errorCode: 'REMOTE_RESULT_UNKNOWN', message: 'check status first',+ changed: [{ sessionId: 's1', title: null, workingDir: null, status: 'active' as const }],+ failedSessionId: 's2', remainingSessionIds: ['s3'],+ }));+ const { registry, setSessionsStatus } = setup({ remote });+ const res = await registry.call('unarchive_sessions', { session_ids: ['studio::s1', 'studio::s2', 'studio::s3'] });+ expect(res.isError).toBe(true);+ expect(parse(res)).toMatchObject({ ok: false, errorCode: 'REMOTE_RESULT_UNKNOWN', data: {+ partial: true, changed: [{ session_id: 'studio::s1' }], failed_session_id: 'studio::s2', remaining_session_ids: ['studio::s3'],+ } });+ expect(setSessionsStatus).not.toHaveBeenCalled();+ });});diff --git a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.tsindex 38286febd5..f121561e7c 100644--- a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts+++ b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts@@ -145,7 +145,7 @@ const CATEGORY_ENUM = ['cindy', 'auth', 'control', 'history', 'feedback', 'handoexport const HELPER_CATEGORY_DESCRIPTIONS: Record<(typeof CATEGORY_ENUM)[number], string> = {cindy: `${BRAND_NAME} 能力说明与当前任务信息;get_capabilities({key:"self-management"}) 是管理自己的任务、定时任务、项目、伙伴的工具索引。本机。`,auth: '供应商授权登录(Grok 设备码)。本机。',- control: '管理任务与项目:改名、归档、移动、标签、排队消息、插话、停止、运行设置、项目列表与增删改。本机。',+ control: '管理任务与项目:归档/取消归档支持本机与跨电脑(deviceId::sessionId);改名、移动、标签、排队消息、插话、停止、运行设置、项目列表与增删改仅本机。',history: '查询任务、工作目录、聊天记录与输入队列。任务列表、搜索、读取聊天记录可跨电脑(device 参数 / deviceId::sessionId);其余本机。',feedback: `向 ${BRAND_NAME} 官方提交反馈。`,handoff: '给已有任务发消息,或新建任务。发给已有任务可跨电脑(deviceId::sessionId);新建只在本机。',@@ -839,6 +839,7 @@ export interface XdtHelperMcpDeps {* unarchive_sessions 会被注册。host 负责存在性校验(全有才写)、写库并广播 sessions:patched。*/setSessionsStatus?: ArchiveSessionsDeps['setSessionsStatus'];+ setRemoteSessionsStatus?: ArchiveSessionsDeps['setRemoteSessionsStatus'];}/**@@ -945,6 +946,7 @@ export function createXdtHelperMcpServer(const archiveDeps = {getSessionContext: () => resolveLiziMcpSessionContext(sessionCtx),setSessionsStatus: deps.setSessionsStatus,+ setRemoteSessionsStatus: deps.setRemoteSessionsStatus,};registerArchiveSessionsTool(registry, archiveDeps);registerUnarchiveSessionsTool(registry, archiveDeps);diff --git a/packages/lizi-mcps/src/xdt-helper/archive_sessions.ts b/packages/lizi-mcps/src/xdt-helper/archive_sessions.tsindex da2bf8cc52..eb37f63105 100644--- a/packages/lizi-mcps/src/xdt-helper/archive_sessions.ts+++ b/packages/lizi-mcps/src/xdt-helper/archive_sessions.ts@@ -4,7 +4,7 @@* 归档 = 把 sessions.status 置为 'archived'(从 sidebar 的 active 桶移出,可随时取消);* 取消归档 = 置回 'active'。两者都不删数据,可逆。*- * host 侧走 patchSessionMetaInDb(已校验 status 白名单 + 广播 sessions:patched),+ * 本机走 setSessionsStatusInDb;远程复用 patchSessionMetaInDb(状态校验 + 广播),* 因此改动会即时反映到 sidebar / agent-island,无需用户刷新或重启。** 工具层护栏:@@ -20,6 +20,7 @@ import type { XdtHelperToolRegistry } from '../lizi_xdtHelperToolRegistry.js';import type { ControlResult } from '../lizi_xdtHelperMcpServer.js';import type { LiziMcpSessionContext } from '../types.js';import { errorPayload, okPayload } from './_payload.js';+import { parseQualifiedSessionId } from './send_to_session.js';const MAX_BATCH_SIZE = 50;@@ -42,25 +43,52 @@ export type SetSessionsStatusResult = ControlResult<'NOT_FOUND' | 'PRECONDITION_FAILED'>;+export type RemoteSessionsStatusResult =+ | { ok: true; changed: SessionStatusChangeItem[] }+ | {+ ok: false;+ errorCode: string;+ message: string;+ changed: SessionStatusChangeItem[];+ failedSessionId: string;+ remainingSessionIds: string[];+ };+export interface ArchiveSessionsDeps {getSessionContext(): LiziMcpSessionContext;setSessionsStatus(params: {sessionIds: string[];status: SessionStatus;}): Promise<SetSessionsStatusResult>;+ /** One remote device per batch; sequential, stop on failure, no rollback/replay. */+ setRemoteSessionsStatus?(params: {+ deviceId: string;+ sessionIds: string[];+ status: SessionStatus;+ }): Promise<RemoteSessionsStatusResult>;}+const BATCH_DESCRIPTION =+ '默认本机(也支持 local::sessionId);跨电脑传 deviceId::sessionId(来自 list_sessions),沿用同账号远程控制授权与任务权限档。' ++ '一次只接受一台电脑的任务,混合本机/远程或多台远程电脑在写入前报 INVALID_ARGS。' ++ '本机批次原子写入;远程按顺序逐项写入,首次失败即停止,不回滚已完成项,错误 data 返回 changed、failed_session_id、remaining_session_ids。' ++ 'REMOTE_RESULT_UNKNOWN 表示失败项可能已生效,先查询状态再决定是否重试,不自动重发。' ++ '远程失败码还包括 REMOTE_UNSUPPORTED / REMOTE_DEVICE_OFFLINE / REMOTE_DISABLED / REMOTE_ACCESS_REVOKED / REMOTE_UNAVAILABLE。';+const ARCHIVE_DESCRIPTION =`批量归档 ${BRAND_NAME} 历史对话/session(把 status 置为 archived,从侧栏 active 列表移出)。` +'归档可逆、不删数据,要恢复用 unarchive_sessions;已删除的 session 不能归档或恢复。' +'适合"清理已完成/过期会话"。' +'建议先用 history/list_sessions 找到目标 session_id。' +- '失败码: NOT_FOUND(某些 id 不存在,整批不写) / PRECONDITION_FAILED(目标已删除) / NO_SESSION_CONTEXT / HOST_NOT_READY / INVALID_ARGS。';+ BATCH_DESCRIPTION ++ '失败码: NOT_FOUND / PRECONDITION_FAILED(目标已删除或生命周期受限) / NO_SESSION_CONTEXT / HOST_NOT_READY / INVALID_ARGS。';const UNARCHIVE_DESCRIPTION =`批量取消归档 ${BRAND_NAME} 历史对话/session(把 status 置回 active,恢复到侧栏 active 列表)。` +'是 archive_sessions 的逆操作;已删除的 session 不能通过此工具复活。' +- '失败码: NOT_FOUND / PRECONDITION_FAILED(目标已删除) / NO_SESSION_CONTEXT / HOST_NOT_READY / INVALID_ARGS。';+ '恢复只改归档状态,不发送旧消息、不恢复暂停自动化、不启动执行;恢复成功后可另用 send_to_session 发送新消息。' ++ BATCH_DESCRIPTION ++ '失败码: NOT_FOUND / PRECONDITION_FAILED(目标已删除或生命周期受限) / NO_SESSION_CONTEXT / HOST_NOT_READY / INVALID_ARGS。';function dedupe(ids: string[]): { ids: string[]; duplicate: string | null } {const seen = new Set<string>();@@ -104,7 +132,16 @@ function registerSessionStatusTool(.describe(config.idsDescription),},handler: async ({ session_ids }) => {- const { ids, duplicate } = dedupe(session_ids);+ if (session_ids.some((id) => {+ const target = parseQualifiedSessionId(id);+ return target?.deviceId === 'local' && target.sessionId.includes('::');+ })) {+ return errorPayload('INVALID_ARGS', 'local:: 后必须是本机任务 ID,不能嵌套设备前缀。');+ }+ const { ids, duplicate } = dedupe(session_ids.map((id) => {+ const target = parseQualifiedSessionId(id);+ return target?.deviceId === 'local' ? target.sessionId : id;+ }));if (duplicate) {return errorPayload('INVALID_ARGS', `同一次调用里 session_id 重复: ${duplicate}。`);}@@ -125,6 +162,36 @@ function registerSessionStatusTool();}+ const targets = ids.map(parseQualifiedSessionId);+ if (ids.some((id, i) => id.includes('::') && !targets[i])) {+ return errorPayload('INVALID_ARGS', '设备任务 ID 必须为 deviceId::sessionId。');+ }+ const remote = targets.find((target) => target !== null);+ if (remote) {+ if (targets.some((target) => !target || target.deviceId !== remote.deviceId)) {+ return errorPayload('INVALID_ARGS', '一次只能操作同一台电脑的任务,请按电脑分批调用;本次没有写入。');+ }+ if (!deps.setRemoteSessionsStatus) {+ return errorPayload('REMOTE_UNSUPPORTED', '当前宿主不支持跨电脑归档/取消归档;本次没有写入。');+ }+ const result = await deps.setRemoteSessionsStatus({+ deviceId: remote.deviceId,+ sessionIds: targets.map((target) => target!.sessionId),+ status: config.targetStatus,+ });+ const qualify = (id: string) => `${remote.deviceId}::${id}`;+ const changed = result.changed.map((item) => toPayloadItem({ ...item, sessionId: qualify(item.sessionId) }));+ if (!result.ok) {+ return errorPayload(result.errorCode, result.message, {+ partial: changed.length > 0 || result.errorCode === 'REMOTE_RESULT_UNKNOWN',+ changed,+ failed_session_id: qualify(result.failedSessionId),+ remaining_session_ids: result.remainingSessionIds.map(qualify),+ });+ }+ return okPayload({ status: config.targetStatus, count: changed.length, changed });+ }+const result = await deps.setSessionsStatus({ sessionIds: ids, status: config.targetStatus });if (!result.ok) {if (result.errorCode === 'HOST_NOT_READY') {@@ -153,7 +220,7 @@ export function registerArchiveSessionsTool(name: 'archive_sessions',description: ARCHIVE_DESCRIPTION,targetStatus: 'archived',- idsDescription: `要归档的 session id 列表。一次最多 ${MAX_BATCH_SIZE} 个,建议来自 list_sessions 返回的 id。`,+ idsDescription: `同一台电脑的 session id 列表;远程用 deviceId::sessionId。一次最多 ${MAX_BATCH_SIZE} 个,建议来自 list_sessions 返回的 id。`,});}@@ -165,6 +232,6 @@ export function registerUnarchiveSessionsTool(name: 'unarchive_sessions',description: UNARCHIVE_DESCRIPTION,targetStatus: 'active',- idsDescription: `要取消归档的 session id 列表。一次最多 ${MAX_BATCH_SIZE} 个。`,+ idsDescription: `同一台电脑的 session id 列表;远程用 deviceId::sessionId。一次最多 ${MAX_BATCH_SIZE} 个。`,});}diff --git a/packages/lizi-mcps/src/xdt-helper/capabilities.ts b/packages/lizi-mcps/src/xdt-helper/capabilities.tsindex 34ba10d39f..c50383de8c 100644--- a/packages/lizi-mcps/src/xdt-helper/capabilities.ts+++ b/packages/lizi-mcps/src/xdt-helper/capabilities.ts@@ -56,11 +56,11 @@ export const CAPABILITIES: readonly CapabilityEntry[] = ['用户本人能对自己的任务、定时任务、项目、伙伴做的操作,Agent 有哪些对应工具、哪些能管到另一台电脑。',detail: ['【原则】用户本人能做的操作(含跨电脑),Agent 也应有对应工具;是否执行由权限档与自动审核决定。数据保存在各自的电脑上:下结论「没有 / 没人在跟」之前,先确认查的是不是只有本机。',- '【任务】cindy_helper history 类:list_sessions / search_chat_history(device=local|all|<deviceId>)、get_chat_history(deviceId::sessionId)、list_history_devices 可跨电脑;list_workdirs、list_session_queue 仅本机。handoff 类 send_to_session:发给既有任务可跨电脑(deviceId::sessionId),新建任务仅本机。control 类(改名、归档、移动、标签、排队消息、插话、停止、运行设置、list_projects 与项目增删改)仅本机。',+ '【任务】cindy_helper history 类:list_sessions / search_chat_history(device=local|all|<deviceId>)、get_chat_history(deviceId::sessionId)、list_history_devices 可跨电脑;list_workdirs、list_session_queue 仅本机。handoff 类 send_to_session:发给既有任务可跨电脑(deviceId::sessionId),新建任务仅本机。control 类 archive_sessions / unarchive_sessions 可跨电脑(deviceId::sessionId,单次限定一台电脑);改名、移动、标签、排队消息、插话、停止、运行设置、list_projects 与项目增删改仅本机。','【定时任务】cindy_scheduler:schedule_list / get / list_runs(device=local|all|<deviceId>,list 可用 query 做文本筛选)与 schedule_update / pause / resume / delete / run_now(device=<deviceId>)可跨电脑;schedule_create、schedule_set_pre_run_hook、当前运行的通知设置仅本机。','【伙伴】cindy_helper bots 类(仅伙伴任务可见):list_agents / send_to_agent 可跨电脑(deviceId::botId);资料、能力、工作台、待办、后台任务仅本机。','【跨电脑的前提】对方电脑在线、同一账号、已开启远程控制。离线、未开启、版本不支持或超时会按电脑写明原因,结果里的 partial=true 表示有电脑没查到。',- '【尚无工具】在另一台电脑上新建任务或定时任务、管理另一台电脑上的任务(改名 / 归档 / 停止 / 队列)与项目;这些用户可在远程控制里手动完成。',+ '【尚无工具】在另一台电脑上新建任务或定时任务、管理另一台电脑上的任务(改名 / 停止 / 队列)与项目;这些用户可在远程控制里手动完成。',].join(' '),},{@@ -107,7 +107,7 @@ export const CAPABILITIES: readonly CapabilityEntry[] = ['【skill 端伪代码】first_seen -> sid = get_current_session_id(); store(key, sid.session_id); later -> sid = load(key); if sid then send_to_worker / send_to_session({ target_session_id: sid, message: "...增量..." }) else fallback normal flow。','【跨电脑】target_session_id 传 deviceId::sessionId(list_sessions 用 device 参数查到的 id)可发给另一台电脑上的既有任务,对方电脑需在线并开启远程控制;不能在另一台电脑新建任务。','【硬规则】send_to_session 要发给已有任务时 target_session_id 必传;不知道 id 先用 history 类目的 list_sessions 查。完全省略该参数不会报错,而是 create:静默新建一个专属任务、把消息当首条输入并立刻跑一轮,返回 wake_kind=created 和 note。只有明确要为业务对象新建专属任务时才省略;拿到 created 不等于已投给既有任务。',- '【失败码】NOT_FOUND / DELETED 通常表示绑定失效,skill 应清掉绑定并回退; ARCHIVED 表示 session 已归档,skill 自己决定是否回退或等待未来的 unarchive 能力; 传了 id 但目标不存在只会返 NOT_FOUND,绝不自动新建。jump 撞上目标正在跑 turn 时不再返 BUSY,而是入队并成功返回 wake_kind=queued(可用 update/cancel_session_queued_message 管理);BUSY 仅是 create 模式的罕见兜底。',+ '【失败码】NOT_FOUND / DELETED 通常表示绑定失效,skill 应清掉绑定并回退; ARCHIVED 表示 session 已归档,在已有恢复授权时可先用 control/unarchive_sessions 恢复,再发送新消息,不能自行推翻用户归档意图; 传了 id 但目标不存在只会返 NOT_FOUND,绝不自动新建。jump 撞上目标正在跑 turn 时不再返 BUSY,而是入队并成功返回 wake_kind=queued(可用 update/cancel_session_queued_message 管理);BUSY 仅是 create 模式的罕见兜底。','【边界】它不是普通聊天入口,而是 session 间 handoff 的控制层能力;不会自动关闭当前 dispatcher session,也不会替 skill 管理绑定键的存储语义。',].join(' '),},@@ -133,8 +133,9 @@ export const CAPABILITIES: readonly CapabilityEntry[] = ['会话列表带搜索、按时间和工程目录组织。','Fork:在任意历史消息处分裂出新会话,继承到该点为止的全部上文。','Rewind:在当前会话回到历史点,改写发送内容后重新运行,原分支被替换。',- 'agent 批量整理:control 类工具 rename_sessions(批量改名)、archive_sessions / unarchive_sessions(批量归档/取消归档,把 status 在 active↔archived 间切换)。',- '归档可逆、不删数据,经统一权威出口写库并广播 sessions:patched,侧栏即时收敛;不能归档当前正在运行的会话。',+ 'agent 批量整理:control 类工具 rename_sessions(批量改名)、archive_sessions / unarchive_sessions(批量归档/取消归档,把 status 在 active↔archived 间切换;跨电脑传 deviceId::sessionId,单次限定一台电脑)。',+ '归档可逆、不删数据,经统一权威出口写库并广播 sessions:patched,侧栏即时收敛;不能归档当前正在运行的会话。恢复不启动执行、不发旧消息、不恢复暂停自动化;之后可用 send_to_session 发送新消息。',+ '本机批次原子写入;远程逐项执行,失败即停并返回已完成、失败与未执行项,不保证跨项事务;回执未知时先查状态再决定重试。','以上操作都不破坏原数据,可放心试错。',].join(' '),},diff --git a/packages/lizi-mcps/src/xdt-helper/index.ts b/packages/lizi-mcps/src/xdt-helper/index.tsindex 56c065b522..1c78632135 100644--- a/packages/lizi-mcps/src/xdt-helper/index.ts+++ b/packages/lizi-mcps/src/xdt-helper/index.ts@@ -41,6 +41,7 @@ export {type SessionStatus,type SessionStatusChangeItem,type SetSessionsStatusResult,+ type RemoteSessionsStatusResult,} from './archive_sessions.js';// multi-worker Phase 1 control toolsexport {diff --git a/packages/lizi-mcps/src/xdt-helper/send_to_session.ts b/packages/lizi-mcps/src/xdt-helper/send_to_session.tsindex dd3a96c7d5..a6cbb577b1 100644--- a/packages/lizi-mcps/src/xdt-helper/send_to_session.ts+++ b/packages/lizi-mcps/src/xdt-helper/send_to_session.ts@@ -134,7 +134,7 @@ const DESCRIPTION = ["","【失败码语义】","- NOT_FOUND: 目标 session 不存在。skill 应清掉自己的绑定并回退到新建/普通流程。",- "- ARCHIVED: 目标 session 已归档。skill 应决定是清绑定、回退新流程,还是等未来的 unarchive 工具。",+ "- ARCHIVED: 目标 session 已归档。已有恢复授权时,可先用 control/unarchive_sessions(支持 deviceId::sessionId)恢复,再发送新消息;不能自行推翻用户归档意图。","- DELETED: 目标 session 已删除。skill 应清绑定并回退。","- BUSY: 仅 create 模式的罕见兜底(新建 session 意外已有 turn 在跑)。jump 模式撞忙不再返 BUSY,而是入队并成功返回 wake_kind=queued。","- WORKTREE_UNAVAILABLE: 仅 create + use_worktree=true:无法创建 worktree(非 git 仓库 / git 未装 / git worktree add 失败,message 带具体原因)。skill 决定是去掉 use_worktree 重试还是放弃。",