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): preserve routine messaging and home-device boundaries

Chriseec3126a59e7
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts
index 95c0d11df0..5cc3f9ee5d 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts
@@ -97,6 +97,7 @@ function createDatabase(): Database.Database {
('bot-missing', '缺主任务伙伴', 'active', 1);
INSERT INTO sessions VALUES
('a-main', 'bot', 'active'),
+ ('a-routine', 'bot', 'active'),
('a-route', 'bot', 'active'),
('a-history', 'bot', 'active'),
('a-archived', 'bot', 'archived'),
@@ -105,6 +106,7 @@ function createDatabase(): Database.Database {
('ordinary', 'desktop', 'active');
INSERT INTO bot_session_links VALUES
('a-main-link', 'bot-a', 'a-main', 'canonical', NULL),
+ ('a-routine-link', 'bot-a', 'a-routine', 'routine', NULL),
('a-route-link', 'bot-a', 'a-route', 'route', NULL),
('a-history-link', 'bot-a', 'a-history', 'history', 1),
('a-archived-link', 'bot-a', 'a-archived', 'history', 1),
@@ -461,6 +463,21 @@ describe('botDirectMessageService', () => {
afterEach(() => sqlite.close());
+ // #7256: moving a rule out of canonical must preserve its companion identity.
+ // Unit/persistence: a routine must discover peers, send, and recover its queued receipt.
+ it('keeps routine messaging and queued delivery recovery bound to its companion', async () => {
+ const service = createBotDirectMessageService({ dispatch });
+ expect(await service.listAgents('a-routine')).toMatchObject({ ok: true,
+ agents: expect.arrayContaining([{ id: 'bot-b', name: 'Dash Bot', local: true }]) });
+ const sent = await service.messageAgent({ callerSessionId: 'a-routine', targetBotId: 'bot-b', message: 'Daily progress?' });
+ if (!sent.ok) throw new Error(sent.errorCode);
+ expect(sqlite.prepare('SELECT sender_bot_id, sender_session_id FROM bot_direct_messages').get())
+ .toEqual({ sender_bot_id: 'bot-a', sender_session_id: 'a-routine' });
+ await expect(service.assertRestoredQueuedDelivery('b-main', `bot-dm:${sent.threadId}:${sent.messageId}`)).resolves.toBeUndefined();
+ expect(dispatch).toHaveBeenCalledOnce();
+ expect(dispatch.mock.calls[0][0].message).toContain('(bot-a)');
+ });
+
it('coalesces concurrent roster discovery across sessions and clears failed flights', async () => {
let settle!: (value: { agents: []; unavailableDevices: [] }) => void;
let fail!: (error: Error) => void;
@@ -1096,10 +1113,10 @@ describe('cross-device teammate messages', () => {
});
afterEach(() => { h.resolveDb = null; leftDb.close(); rightDb.close(); });
- it('discovers a remote peer and routes a roundtrip by stable identity into both canonical timelines', async () => {
- expect(await atLeft(() => left.listAgents('a-main'))).toMatchObject({ ok: true,
+ it.each(['a-main', 'a-routine'])('discovers a remote peer and routes a roundtrip by stable identity into both canonical timelines (%s)', async (callerSessionId) => {
+ expect(await atLeft(() => left.listAgents(callerSessionId))).toMatchObject({ ok: true,
agents: expect.arrayContaining([{ id: 'right::bot-b', name: 'Mimi', deviceId: 'right', deviceName: 'Studio', local: false }]) });
- const sent = await atLeft(() => left.messageAgent({ callerSessionId: 'a-main', targetBotId: 'right::bot-b', message: 'unique-marker' }));
+ const sent = await atLeft(() => left.messageAgent({ callerSessionId, targetBotId: 'right::bot-b', message: 'unique-marker' }));
expect(sent).toMatchObject({ ok: true, accepted: true, delivered: false, targetBotId: 'right::bot-b' });
expect(rightDispatch.mock.calls[0][0].message).toContain('(left::bot-a)');
expect(rightDispatch.mock.calls[0][0].message).toContain('unique-marker');
@@ -1180,10 +1197,10 @@ describe('cross-device teammate messages', () => {
targetBotId: 'bot-b', message: 'changed', messageId: result.messageId! }))).toMatchObject({ ok: false, errorCode: 'PERMISSION_DENIED' });
});
- it('reconciles a lost native receipt without dispatching again, refunding acceptance, or claiming a reply', async () => {
+ it.each(['a-main', 'a-routine'])('reconciles a lost native receipt without dispatching again, refunding acceptance, or claiming a reply (%s)', async (callerSessionId) => {
failResponse = true;
- const sent = await atLeft(() => left.messageAgent({ callerSessionId: 'a-main', targetBotId: 'right::bot-b', message: 'lost receipt' }));
- const args = { callerSessionId: 'a-main', messageId: sent.messageId! };
+ const sent = await atLeft(() => left.messageAgent({ callerSessionId, targetBotId: 'right::bot-b', message: 'lost receipt' }));
+ const args = { callerSessionId, messageId: sent.messageId! };
expect(await atLeft(() => left.checkMessage({ ...args, callerSessionId: 'b-main' }))).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });
expect(await atLeft(() => left.checkMessage(args))).toMatchObject({ ok: true, source: 'native-receipt', accepted: true, delivered: null, replied: false });
const anchorCount = h.createMessage.mock.calls.length;
@@ -1296,13 +1313,13 @@ describe('ordinary remote conversation reply bridge', () => {
return { service, deps, readReply, send, dispatch, revoke: () => { current = false; },
answer: () => { replies = [{ id: 'answer', content: 'Mimi ordinary reply' }]; } };
}
- it('retains the actual conversation across service recreation and bridges a reply only once without waking another turn', async () => {
+ it.each(['a-main', 'a-routine'])('retains the actual conversation across service recreation and bridges a reply only once without waking another turn (%s)', async (callerSessionId) => {
const h = harness();
- const sent = await h.service.messageAgent({ callerSessionId: 'a-main', targetBotId: 'old::mimi', message: 'Question' });
+ const sent = await h.service.messageAgent({ callerSessionId, targetBotId: 'old::mimi', message: 'Question' });
if (!sent.ok) throw new Error('send failed');
expect(sent.transport).toBe('remote-conversation');
const resumed = createBotDirectMessageService(h.deps);
- const check = { callerSessionId: 'a-main', messageId: sent.messageId };
+ const check = { callerSessionId, messageId: sent.messageId };
expect(await resumed.checkMessage(check)).toMatchObject({ ok: true, replied: false, delivered: null });
h.answer();
expect(await resumed.checkMessage(check)).toMatchObject({ ok: true, replied: true, source: 'remote-conversation', replies: [{ id: 'answer', content: 'Mimi ordinary reply' }] });
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botSessionInputGuard.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botSessionInputGuard.test.ts
index 3cdb1aa1b4..8f71e4dda5 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/botSessionInputGuard.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/botSessionInputGuard.test.ts
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
import {
botSessionInputBlockReason,
- isShadowedCompanionCanonical,
+ isShadowedCompanionSession,
} from '../botSessionInputGuard.js';
describe('Bot task input guard', () => {
@@ -33,16 +33,17 @@ describe('Bot task input guard', () => {
describe('shadowed companion guard', () => {
const shadowed = (botId: string) => botId === 'bot_mia';
- it('blocks only the main task of a demoted copy', () => {
- expect(isShadowedCompanionCanonical({ role: 'canonical', botId: 'bot_mia' }, shadowed)).toBe(
+ // #7256: routine history must not restart a companion on its old computer.
+ it.each(['canonical', 'routine'])('blocks the %s task of a demoted copy', (role) => {
+ expect(isShadowedCompanionSession({ role, botId: 'bot_mia' }, shadowed)).toBe(
true,
);
- expect(isShadowedCompanionCanonical({ role: 'delegation', botId: 'bot_mia' }, shadowed)).toBe(
+ expect(isShadowedCompanionSession({ role: 'delegation', botId: 'bot_mia' }, shadowed)).toBe(
false,
);
- expect(isShadowedCompanionCanonical({ role: 'canonical', botId: 'bot_other' }, shadowed)).toBe(
+ expect(isShadowedCompanionSession({ role, botId: 'bot_other' }, shadowed)).toBe(
false,
);
- expect(isShadowedCompanionCanonical(null, shadowed)).toBe(false);
+ expect(isShadowedCompanionSession(null, shadowed)).toBe(false);
});
});
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts
index 61637a92b8..7aef5bdf4c 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts
@@ -1,4 +1,4 @@
-import { isShadowedCompanionCanonical } from '../botSessionInputGuard.js';
+import { isShadowedCompanionSession } from '../botSessionInputGuard.js';
import { createScheduledModelScope } from '../scheduledModelSelection.js';
import { assertTaskActionCurrent, hasTaskActionAuthorization } from '../taskActionAuthorization.js';
/**
@@ -210,7 +210,7 @@ function botTaskDispatchHarness(
sessions: {},
// 云端伙伴副本门:合成库里没有关联行,目标不是被接管的副本。
botSessionLinks: {},
- isShadowedCompanionCanonical: () => false,
+ isShadowedCompanionSession: () => false,
isCompanionShadowed: () => false,
SHADOWED_COMPANION_INPUT_MESSAGE: 'shadowed',
and: noop,
@@ -284,16 +284,16 @@ it('advances an accepted send_to_session with a dispatcher without touching huma
// this existing guard fixture); assert the route used to send, not call strings.
describe('companion internal delivery after automation', () => {
// #6895: rejected input must not bootstrap the old primary or consume its restore.
- it.each(['already-shadowed', 'shadowed-while-waiting'] as const)('preserves automation state when %s', async (timing) => {
+ it.each(['canonical', 'routine'].flatMap(role => ['already-shadowed', 'shadowed-while-waiting'].map(timing => ({ role, timing }))))('preserves $role automation state when $timing', async ({ role, timing }) => {
let shadowed = timing === 'already-shadowed';
let baseline: string | null = 'saved-pi-route';
const restore = vi.fn(async () => { baseline = null; });
const reconcile = vi.fn(async () => undefined);
const dbChain = { from: () => dbChain, where: () => dbChain,
- limit: async () => [{ role: 'canonical', botId: 'companion' }] };
+ limit: async () => [{ role, botId: 'companion' }] };
const h = botTaskDispatchHarness({ child: { permissionMode: 'auto', planModeEnabled: false } }, {}, {
getDbClient: () => ({ drizzle: { select: () => dbChain } }),
- isShadowedCompanionCanonical, isCompanionShadowed: () => shadowed,
+ isShadowedCompanionSession, isCompanionShadowed: () => shadowed,
scheduledModelScope: { restore }, reconcileBotModelRoute: reconcile,
waitForSendToSessionLock: async () => { shadowed = true; },
});
@@ -308,16 +308,16 @@ describe('companion internal delivery after automation', () => {
// #6895: hand-over may finish while restore awaits, before a turn exists.
// Exercise both consumers of the post-restore routing decision, without timers.
- it.each(['live', 'queued'] as const)('rejects %s delivery when demoted during restoration', async (path) => {
+ it.each(['canonical', 'routine'].flatMap(role => ['live', 'queued'].map(path => ({ role, path }))))('rejects $role $path delivery when demoted during restoration', async ({ role, path }) => {
let shadowed = false;
const dbChain = { from: () => dbChain, where: () => dbChain,
- limit: async () => [{ role: 'canonical', botId: 'companion' }] };
+ limit: async () => [{ role, botId: 'companion' }] };
const enqueue = vi.fn(async () => undefined);
const h = botTaskDispatchHarness({ child: { permissionMode: 'auto', planModeEnabled: false } }, {
child: { id: 'child', agentKind: 'pi', isTurnRunning: () => false, getStatus: () => 'active' },
}, {
getDbClient: () => ({ drizzle: { select: () => dbChain } }),
- isShadowedCompanionCanonical, isCompanionShadowed: () => shadowed,
+ isShadowedCompanionSession, isCompanionShadowed: () => shadowed,
scheduledModelScope: { restore: async () => { shadowed = true; } },
inputCoordinator: { ensureQueueRestored: async () => undefined, shouldQueueNewTurn: () => path === 'queued' },
enqueueSendToSessionMessage: enqueue,
@@ -338,7 +338,7 @@ describe('companion internal delivery after automation', () => {
const h = botTaskDispatchHarness({ child: { permissionMode: 'auto', planModeEnabled: false } },
path === 'live' ? { child: { id: 'child', agentKind: 'pi', isTurnRunning: () => false, getStatus: () => 'active' } } : {}, {
getDbClient: () => ({ drizzle: { select: () => dbChain } }),
- isShadowedCompanionCanonical, isCompanionShadowed: () => shadowed,
+ isShadowedCompanionSession, isCompanionShadowed: () => shadowed,
createDbMessage: async () => { shadowed = true; },
});
expect(await h.dispatchBotSessionMessage({ targetSessionId: 'child', message: 'Late cloud input' }))
diff --git a/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts b/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts
index afd7d3e7d5..220f7ae571 100644
--- a/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts
+++ b/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts
@@ -38,6 +38,11 @@ const MAX_MESSAGES_PER_THREAD = 12;
const THREAD_IDLE_TIMEOUT_MS = 15 * 60_000;
const LIMIT_COOLDOWN_MS = 5 * 60_000;
+/** Routine lanes speak as their companion, with the same per-turn tool authorization. */
+function isCompanionMessageSource(role: string | null | undefined): boolean {
+ return role === 'canonical' || role === 'routine';
+}
+
function trustedHeaderLabel(value: string, maxChars: number): string {
const withoutControlCharacters = Array.from(value, (character) => {
const code = character.charCodeAt(0);
@@ -310,13 +315,13 @@ export function createBotDirectMessageService(deps: BotDirectMessageServiceDeps)
};
// senderSessionId and the durable Bot link retain the source identity across
- // restarts. A missing local link cannot prove canonical authority either.
+ // restarts. A missing local link cannot prove companion ownership either.
const canRestoreDelivery = async (db: ReturnType<typeof getDbClient>['drizzle'], row: typeof botDirectMessages.$inferSelect): Promise<boolean> => {
if (row.deliveryStatus === 'failed') return false;
if (!row.senderSessionId) return !!parseBotPeerAddress(row.senderBotId); // Remote peer, not a deleted local source.
const [link] = await db.select({ role: botSessionLinks.role }).from(botSessionLinks)
.where(and(eq(botSessionLinks.sessionId, row.senderSessionId), eq(botSessionLinks.botId, row.senderBotId))).limit(1);
- return link?.role === 'canonical';
+ return isCompanionMessageSource(link?.role);
};
const assertRestoredQueuedDelivery = async (sessionId: string, clientId: string): Promise<void> => {
@@ -493,7 +498,7 @@ export function createBotDirectMessageService(deps: BotDirectMessageServiceDeps)
}
const groupAuthority = caller.role === 'group'
? await authorizeGroupTool(input.callerSessionId, caller.botId, 'owner-action') : null;
- if ((!groupAuthority && caller.role !== 'canonical') || caller.linkArchivedAt !== null) {
+ if ((!groupAuthority && !isCompanionMessageSource(caller.role)) || caller.linkArchivedAt !== null) {
return failed('NOT_CANONICAL_BOT_SESSION', 'send_to_agent 只能从伙伴主任务发送');
}
if (caller.botId === input.targetBotId) {
@@ -937,7 +942,7 @@ export function createBotDirectMessageService(deps: BotDirectMessageServiceDeps)
const caller = await loadCaller(callerSessionId);
const groupAuthority = caller?.role === 'group'
? await authorizeGroupTool(callerSessionId, caller.botId, 'owner-action') : null;
- if (!caller || (!groupAuthority && caller.role !== 'canonical') || caller.linkArchivedAt !== null
+ if (!caller || (!groupAuthority && !isCompanionMessageSource(caller.role)) || caller.linkArchivedAt !== null
|| caller.sessionSource !== 'bot' || caller.sessionStatus !== 'active' || caller.botStatus !== 'active') {
return { ok: false as const, errorCode: 'NOT_A_BOT_SESSION', message: 'An active canonical teammate is required' };
}
@@ -979,7 +984,7 @@ export function createBotDirectMessageService(deps: BotDirectMessageServiceDeps)
|| row.content !== input.message.trim() || row.deliveryStatus === 'failed' || !row.senderSessionId) return false;
const caller = await loadCaller(row.senderSessionId);
if (scope !== undefined && deps.isOwnerScopeCurrent && !deps.isOwnerScopeCurrent(scope)) return false;
- return !!caller && caller.botId === input.senderBotId && caller.role === 'canonical' && caller.linkArchivedAt === null
+ return !!caller && caller.botId === input.senderBotId && isCompanionMessageSource(caller.role) && caller.linkArchivedAt === null
&& caller.sessionSource === 'bot' && caller.sessionStatus === 'active' && caller.botStatus === 'active';
};
/** Read only the receipt belonging to the authenticated source device and exact pair. */
@@ -1008,7 +1013,7 @@ export function createBotDirectMessageService(deps: BotDirectMessageServiceDeps)
const caller = await loadCaller(input.callerSessionId);
if (
!caller ||
- caller.role !== 'canonical' ||
+ !isCompanionMessageSource(caller.role) ||
caller.linkArchivedAt !== null ||
caller.sessionSource !== 'bot' ||
caller.sessionStatus !== 'active' ||
@@ -1038,7 +1043,7 @@ export function createBotDirectMessageService(deps: BotDirectMessageServiceDeps)
await withPairLock(pairKey, async () => {
const currentCaller = await loadCaller(input.callerSessionId);
assertCurrent();
- if (!currentCaller || currentCaller.botId !== caller.botId || currentCaller.role !== 'canonical'
+ if (!currentCaller || currentCaller.botId !== caller.botId || !isCompanionMessageSource(currentCaller.role)
|| currentCaller.linkArchivedAt !== null || currentCaller.sessionStatus !== 'active' || currentCaller.botStatus !== 'active')
throw Object.assign(new Error('Caller inactive'), { code: 'OWNER_CHANGED' });
const [row] = await db.select().from(botDirectMessages).where(eq(botDirectMessages.id, sent.id)).limit(1);
@@ -1070,7 +1075,7 @@ export function createBotDirectMessageService(deps: BotDirectMessageServiceDeps)
if (
!currentCaller ||
currentCaller.botId !== caller.botId ||
- currentCaller.role !== 'canonical' ||
+ !isCompanionMessageSource(currentCaller.role) ||
currentCaller.linkArchivedAt !== null ||
currentCaller.sessionStatus !== 'active' ||
currentCaller.botStatus !== 'active'
diff --git a/apps/desktop/src/main/maker-ipc/botSessionInputGuard.ts b/apps/desktop/src/main/maker-ipc/botSessionInputGuard.ts
index 4267ac889b..0650b529a0 100644
--- a/apps/desktop/src/main/maker-ipc/botSessionInputGuard.ts
+++ b/apps/desktop/src/main/maker-ipc/botSessionInputGuard.ts
@@ -25,11 +25,11 @@ export const SHADOWED_COMPANION_INPUT_MESSAGE =
/**
* A demoted copy's companion runs on another computer (cloud-companions.md §3): its main
- * task never starts a turn here, whichever send path (renderer, internal, queue drain) asks.
+ * and routine tasks never start a turn here, whichever send path (renderer, internal, queue drain) asks.
*/
-export function isShadowedCompanionCanonical(
+export function isShadowedCompanionSession(
link: { role?: string | null; botId?: string | null } | null | undefined,
isShadowed: (botId: string) => boolean,
): boolean {
- return link?.role === 'canonical' && !!link.botId && isShadowed(link.botId);
+ return (link?.role === 'canonical' || link?.role === 'routine') && !!link.botId && isShadowed(link.botId);
}
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index 955d7202fa..f3db544a43 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -684,7 +684,7 @@ import { createWireNoteMemory } from './wireNoteMemory.js';
import { isBotCanonicalReplacementBusy } from './botCanonicalReplacementGuard.js';
import { configureBotCanonicalReplacementCoordinator } from './botCanonicalReplacementCoordinator.js';
import { configureBotModelSelectionCoordinator, createBotModelSelectionCoordinator } from './botModelSelectionCoordinator.js';
-import { botSessionInputBlockReason, isShadowedCompanionCanonical, SHADOWED_COMPANION_INPUT_MESSAGE } from './botSessionInputGuard.js';
+import { botSessionInputBlockReason, isShadowedCompanionSession, SHADOWED_COMPANION_INPUT_MESSAGE } from './botSessionInputGuard.js';
import { configureBotRuntimeEpochRefreshRequest } from './botRuntimeEpochRefreshSignal.js';
import { createGitSnapshotCoordinator } from '../maker-host/git-snapshot-host.js';
import {
@@ -11972,7 +11972,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
.select({ role: botSessionLinks.role, botId: botSessionLinks.botId })
.from(botSessionLinks).where(eq(botSessionLinks.sessionId, sessionId)).limit(1);
dispatchCompanionLink = link;
- return isShadowedCompanionCanonical(link, isCompanionShadowed)
+ return isShadowedCompanionSession(link, isCompanionShadowed)
? { ok: false as const, errorCode: 'AGENT_NOT_READY' as const, message: SHADOWED_COMPANION_INPUT_MESSAGE }
: null;
};
@@ -11981,7 +11981,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const onInternalDispatching = () => {
// Session invokes this synchronously immediately before provider send,
// after bootstrap, authorization and message persistence have all awaited.
- if (isShadowedCompanionCanonical(dispatchCompanionLink, isCompanionShadowed)) {
+ if (isShadowedCompanionSession(dispatchCompanionLink, isCompanionShadowed)) {
dispatchRejectedForDemotion = true;
throw new TurnDispatchRejectedError(SHADOWED_COMPANION_INPUT_MESSAGE);
}
@@ -18355,7 +18355,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
assertCindyMakeSessionAvailable(botInput?.source);
const blocked = botSessionInputBlockReason(botInput ?? null);
// Rechecked under the send lock right before every real send, including queue drains.
- if (botInput?.source === 'bot' && isShadowedCompanionCanonical(botInput, isCompanionShadowed)) {
+ if (botInput?.source === 'bot' && isShadowedCompanionSession(botInput, isCompanionShadowed)) {
throwIpcError('PRECONDITION_FAILED', SHADOWED_COMPANION_INPUT_MESSAGE);
}
if (args[2] && typeof args[2] === 'object') {
diff --git a/docs/product-rules/bot-routines.md b/docs/product-rules/bot-routines.md
index 2459b80d3f..ba90f9ac79 100644
--- a/docs/product-rules/bot-routines.md
+++ b/docs/product-rules/bot-routines.md
@@ -24,11 +24,11 @@ Bot Market 原生包的例行任务只通过原导入服务保存停用定义,
- 桌面远程控制(2026-10-22):控制另一台电脑上的伙伴时,桌面伙伴设置里的「例行任务」页就是本机同一个页面,列表、保存、立即运行、删除和运行历史由伙伴所在电脑的同一个管理服务执行(`management:settings` 的 `routines.*` 操作,见 [伙伴设置动作](../dev-rules/protocol-compatibility.md#伙伴设置动作-managementsettingsremote-resource2026-10-22));那台电脑上的例行任务变化会推送到打开着的页面重读。这是桌面入口,手机仍不提供管理。
- 桌面 UI / MCP / Remote Resources:共用管理服务,不能冒充事件来源。宿主保留 Remote Resources,当前手机端过滤 `routines` 集合及动作。MCP 管理仅走宿主绑定调用者身份的伙伴必备工具;通用 scheduler MCP 不提供可任意指定 botId 的例行任务入口。
-每条需要 Agent 执行的例行任务对应一个持久独立 Session(`bot_session_links.role = 'routine'`,`route_key = 'routine:<routineId>'`),重复触发复用,不向伙伴主任务追加执行上下文。它与原伙伴共享 Profile、Home、记忆、技能和实际权限,权限与资料更新同样同步到专线;行动身份仍按本轮来源判定,内置跟进不会因独立任务变成主人授权。
+每条需要 Agent 执行的例行任务对应一个持久独立 Session(`bot_session_links.role = 'routine'`,`route_key = 'routine:<routineId>'`),重复触发复用,不向伙伴主任务追加执行上下文。它与原伙伴共享 Profile、Home、记忆、技能和实际权限,权限与资料更新同样同步到专线;`list_agents`、`send_to_agent`、`check_agent_message` 沿用同一伙伴身份(含远程回执核验与排队恢复),逐轮行动授权与防循环上限不变;行动身份仍按本轮来源判定,内置跟进不会因独立任务变成主人授权。
`modelOverride` 可单独选择完整模型路由(引擎、来源、型号、执行位置、推理强度、Fast);缺失或 null 跟随伙伴模型,显式配置不套用伙伴主模型的备用链。旧客户端省略字段时保留已存选择,null 才清除。保存后下一轮通过普通模型切换与交接入口应用;独立任务内继续交流也使用这份配置。每条例行任务最多一个正在执行的运行;等待事件合成一批,各条规则通过各自任务队列派发。
-独立任务保留完整执行记录,历史里的「查看任务」打开原有普通任务页面;静默只控制通知,不隐藏执行正文。它不进入自动跟进的观察列表,避免跟进自己的执行。合成触发输入沿用原有来源说明。夜间学习已有专门宿主流程,不改为这类任务。
+独立任务保留完整执行记录,历史里的「查看任务」打开原有普通任务页面;静默只控制通知,不隐藏执行正文。它不进入自动跟进的观察列表,避免跟进自己的执行。伙伴迁走后,旧电脑上这条任务仍可回看,但普通发送、内部发送和排队派发都不能重新启动它。合成触发输入沿用原有来源说明。夜间学习已有专门宿主流程,不改为这类任务。
远程桌面沿用同一设置页,通过 `routines.saveWithModel` 能力协商展示选模;旧主机不显示选模,新主机接受旧客户端保存时保留覆盖。手机当前仍无例行任务管理入口。模型配置随普通规则的伙伴迁移资料保留,执行任务与运行历史留在执行电脑。