Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(update): Agent 更新绑定确认的账号与版本,结果写回失败时保留标记
Dash7fdcb3d7d8d6
diff --git a/apps/desktop/src/main/__tests__/updateService.test.ts b/apps/desktop/src/main/__tests__/updateService.test.tsindex 1aeb1a24f3..29b7f9e7e0 100644--- a/apps/desktop/src/main/__tests__/updateService.test.ts+++ b/apps/desktop/src/main/__tests__/updateService.test.ts@@ -473,6 +473,28 @@ describe('agent-facing managed app update check', () => {}});+ it('does not install a different version than the one the owner confirmed', async () => {+ download.mockImplementation(async ({ targetPath }: { targetPath: string }) => {+ fs.mkdirSync(path.dirname(targetPath), { recursive: true });+ fs.writeFileSync(targetPath, 'update');+ return { path: targetPath, size: 123 };+ });+ // The card showed 0.0.66, but the channel now stages 0.0.65.+ const service = await freshUpdateService('darwin');+ const beforeRelaunch = vi.fn(async () => true);+ try {+ await expect(+ service.applyConfirmedAppUpdateForAgent({ expectedVersion: '0.0.66', beforeRelaunch }),+ ).resolves.toMatchObject({ status: 'failed', errorCode: 'version_changed' });+ expect(beforeRelaunch).not.toHaveBeenCalled();+ expect(spawnProcess).not.toHaveBeenCalled();+ // The staged patch is kept for the built-in banner.+ expect(await service.checkAppUpdateForAgent()).toMatchObject({ status: 'ready', targetVersion: '0.0.65' });+ } finally {+ service.stopUpdateService();+ }+ });+it('does not relaunch when the download fails or the build is unsupported', async () => {download.mockRejectedValue(new Error('network'));const service = await freshUpdateService('darwin');diff --git a/apps/desktop/src/main/agent-app-update/__tests__/agentAppUpdateService.test.ts b/apps/desktop/src/main/agent-app-update/__tests__/agentAppUpdateService.test.tsindex e2bb919b19..d198cfb835 100644--- a/apps/desktop/src/main/agent-app-update/__tests__/agentAppUpdateService.test.ts+++ b/apps/desktop/src/main/agent-app-update/__tests__/agentAppUpdateService.test.ts@@ -9,6 +9,7 @@ import {import { AGENT_APP_AUTO_UPDATE_TOOL_NAME, AGENT_APP_UPDATE_TOOL_NAME } from '../constants.js';const caller = { sessionId: 'task-1', sessionInstanceId: 'instance-1' };+const ownerA = { ownerId: 'owner-a' };function allow(): InteractionDecision {return { kind: 'permission', behavior: 'allow' };@@ -21,6 +22,7 @@ function deny(reason?: string): InteractionDecision {function setup(overrides: Partial<AgentAppUpdateDeps> = {}) {let marker: AgentAppUpdateMarker | null = null;let autoUpdate = false;+ let activeOwner: { ownerId: string } | null = ownerA;const deps: AgentAppUpdateDeps = {appVersion: () => '0.1.86',platform: 'darwin',@@ -44,8 +46,10 @@ function setup(overrides: Partial<AgentAppUpdateDeps> = {}) {countOtherRunningTasks: vi.fn(() => 2),requestHostPermission: vi.fn(async () => allow()),waitForCallerTurnToEnd: vi.fn(async () => undefined),+ captureOwner: vi.fn(() => activeOwner),+ isOwnerCurrent: vi.fn((owner) => activeOwner?.ownerId === owner.ownerId),marker: {- write: vi.fn((value: AgentAppUpdateMarker) => {+ write: vi.fn((_owner, value: AgentAppUpdateMarker) => {marker = value;}),read: () => marker,@@ -53,7 +57,7 @@ function setup(overrides: Partial<AgentAppUpdateDeps> = {}) {marker = null;}),},- notify: vi.fn(async () => undefined),+ notify: vi.fn(async () => 'written' as const),compareVersions: (candidate, current) =>candidate === current ? 'same' : (candidate ?? '') > current ? 'newer' : 'older',translate: (key) => key,@@ -66,6 +70,9 @@ function setup(overrides: Partial<AgentAppUpdateDeps> = {}) {setMarker: (value: AgentAppUpdateMarker | null) => {marker = value;},+ switchOwner: (owner: { ownerId: string } | null) => {+ activeOwner = owner;+ },};}@@ -116,7 +123,9 @@ describe('Agent app update install', () => {await flush();expect(deps.apply).toHaveBeenCalledOnce();expect(deps.waitForCallerTurnToEnd).toHaveBeenCalledWith(caller);+ expect(deps.apply).toHaveBeenCalledWith(expect.objectContaining({ expectedVersion: '0.1.90' }));expect(deps.marker.write).toHaveBeenCalledWith(+ ownerA,expect.objectContaining({sessionId: 'task-1',fromVersion: '0.1.86',@@ -226,6 +235,7 @@ describe('Agent app update install', () => {await flush();expect(getMarker()).toBeNull();expect(deps.notify).toHaveBeenCalledWith(+ ownerA,'task-1',expect.stringMatching(/^agent-app-update:/),'update.agentInstall.failed 下载更新失败,请稍后重试。 update.agentInstall.retryHint',@@ -235,6 +245,35 @@ describe('Agent app update install', () => {expect(deps.requestHostPermission).toHaveBeenCalledTimes(2);});+ it('cancels the restart after an account switch and never writes into the next account', async () => {+ let restartAllowed: boolean | undefined;+ const harness = setup({+ apply: vi.fn(async ({ beforeRelaunch }) => {+ harness.switchOwner({ ownerId: 'owner-b' });+ restartAllowed = await beforeRelaunch();+ return restartAllowed+ ? { status: 'relaunching' as const }+ : { status: 'failed' as const, reason: 'cancelled', errorCode: 'relaunch_cancelled' };+ }),+ });+ await harness.service.install(caller);+ await flush();+ expect(restartAllowed).toBe(false);+ expect(harness.deps.marker.clear).toHaveBeenCalledWith(ownerA);+ expect(harness.deps.notify).not.toHaveBeenCalled();+ });++ it('refuses to start when no account is active at confirmation', async () => {+ const harness = setup();+ harness.switchOwner(null);+ await expect(harness.service.install(caller)).resolves.toMatchObject({+ ok: false,+ errorCode: 'CALLER_UNAVAILABLE',+ });+ expect(harness.deps.apply).not.toHaveBeenCalled();+ expect(harness.deps.marker.write).not.toHaveBeenCalled();+ });+it('mentions the Linux password prompt only on Linux', async () => {const { deps, service } = setup({ platform: 'linux', countOtherRunningTasks: vi.fn(() => 0) });await service.install(caller);@@ -266,6 +305,7 @@ describe('Agent app update result after restart', () => {await service.deliverPendingResult();expect(deps.notify).toHaveBeenCalledOnce();expect(deps.notify).toHaveBeenCalledWith(+ ownerA,'task-1','agent-app-update:req-1','updated to 0.1.90 from 0.1.86',@@ -278,12 +318,46 @@ describe('Agent app update result after restart', () => {setMarker(marker());await service.deliverPendingResult();expect(deps.notify).toHaveBeenCalledWith(+ ownerA,'task-1','agent-app-update:req-1','update.agentInstall.failed update.agentInstall.retryHint',);});+ it('keeps the marker after a transient write failure and retries without duplicating', async () => {+ const notify = vi+ .fn<AgentAppUpdateDeps['notify']>()+ .mockRejectedValueOnce(new Error('database busy'))+ .mockResolvedValueOnce('written');+ const { service, setMarker, getMarker } = setup({ notify });+ setMarker(marker());+ await service.deliverPendingResult();+ expect(getMarker()).not.toBeNull();+ await service.deliverPendingResult();+ expect(getMarker()).toBeNull();+ expect(notify).toHaveBeenCalledTimes(2);+ expect(notify.mock.calls[0]![2]).toBe(notify.mock.calls[1]![2]);+ });++ it('clears the marker when the task no longer exists', async () => {+ const { service, setMarker, getMarker } = setup({+ notify: vi.fn(async () => 'task-missing' as const),+ });+ setMarker(marker());+ await service.deliverPendingResult();+ expect(getMarker()).toBeNull();+ });++ it('waits for an active account before reading the marker', async () => {+ const harness = setup();+ harness.setMarker(marker());+ harness.switchOwner(null);+ await harness.service.deliverPendingResult();+ expect(harness.deps.notify).not.toHaveBeenCalled();+ expect(harness.getMarker()).not.toBeNull();+ });+it('ignores a marker written by this same process (no restart yet)', async () => {const { deps, service, setMarker, getMarker } = setup();setMarker(marker({ pid: 100 }));diff --git a/apps/desktop/src/main/agent-app-update/agentAppUpdateService.ts b/apps/desktop/src/main/agent-app-update/agentAppUpdateService.tsindex a0fdeb3048..8cbd4a74f7 100644--- a/apps/desktop/src/main/agent-app-update/agentAppUpdateService.ts+++ b/apps/desktop/src/main/agent-app-update/agentAppUpdateService.ts@@ -49,13 +49,30 @@ export interface AgentAppUpdateMarker {type PermissionRequest = Extract<InteractionRequest, { kind: 'permission' }>;+/**+ * The account that confirmed an install. Captured once at confirmation; the+ * marker, the restart gate and every result notice stay bound to it so an+ * account switch can neither restart the next owner's app nor receive the+ * previous owner's result. Opaque to this module.+ */+export interface AgentAppUpdateOwner {+ readonly ownerId: string;+}++/** `task-missing`: the task no longer exists for that owner, so the result can never be shown. */+export type AgentAppUpdateNotifyOutcome = 'written' | 'task-missing';+export interface AgentAppUpdateDeps {appVersion(): string;platform: NodeJS.Platform;pid: number;now(): number;check(): Promise<AgentAppUpdateCheck>;- apply(options: { beforeRelaunch: () => Promise<boolean> }): Promise<AgentAppUpdateApplyResult>;+ /** Built-in updater. `expectedVersion` is the version the owner confirmed; a different staged version is not installed. */+ apply(options: {+ expectedVersion?: string;+ beforeRelaunch: () => Promise<boolean>;+ }): Promise<AgentAppUpdateApplyResult>;readAutoUpdate(): boolean;writeAutoUpdate(enabled: boolean): boolean;/** 'owner' only for a live local turn the account owner started (see callerAuthority.ts). */@@ -70,13 +87,25 @@ export interface AgentAppUpdateDeps {): Promise<InteractionDecision | null>;/** Let the calling turn finish its reply before the restart (bounded by the host). */waitForCallerTurnToEnd(caller: AgentAppUpdateCaller): Promise<void>;+ /** The current account, or null while none is active or an account boundary is pending. */+ captureOwner(): AgentAppUpdateOwner | null;+ /** The captured account is still active and no account boundary is pending. */+ isOwnerCurrent(owner: AgentAppUpdateOwner): boolean;marker: {- write(marker: AgentAppUpdateMarker): void;- read(): AgentAppUpdateMarker | null;- clear(): void;+ write(owner: AgentAppUpdateOwner, marker: AgentAppUpdateMarker): void;+ read(owner: AgentAppUpdateOwner): AgentAppUpdateMarker | null;+ clear(owner: AgentAppUpdateOwner): void;};- /** Persist a visible host notice in the task (idempotent per clientId). */- notify(sessionId: string, clientId: string, text: string): Promise<void>;+ /**+ * Persist a visible host notice in the owner's task (idempotent per clientId).+ * Throws on transient failure or when the owner is no longer current.+ */+ notify(+ owner: AgentAppUpdateOwner,+ sessionId: string,+ clientId: string,+ text: string,+ ): Promise<AgentAppUpdateNotifyOutcome>;compareVersions(candidate: string | undefined, current: string): string;translate(key: string): string;logger?: { info?(msg: string, meta?: unknown): void; warn?(msg: string, meta?: unknown): void };@@ -179,7 +208,14 @@ export function createAgentAppUpdateService(deps: AgentAppUpdateDeps) {};};- const reportFailure = async (sessionId: string, requestId: string, reason: string) => {+ const reportFailure = async (+ owner: AgentAppUpdateOwner,+ sessionId: string,+ requestId: string,+ reason: string,+ ) => {+ // Never write into whichever account replaced the one that confirmed.+ if (!deps.isOwnerCurrent(owner)) return;const message = [text('update.agentInstall.failed', { version: deps.appVersion() }),reason,@@ -188,27 +224,34 @@ export function createAgentAppUpdateService(deps: AgentAppUpdateDeps) {.filter(Boolean).join(' ');try {- await deps.notify(sessionId, `agent-app-update:${requestId}`, message);+ await deps.notify(owner, sessionId, `agent-app-update:${requestId}`, message);} catch (error) {deps.logger?.warn?.('agent app update failure notice failed', { error: String(error) });}};- const runInstall = async (caller: AgentAppUpdateCaller, marker: AgentAppUpdateMarker) => {+ const runInstall = async (+ caller: AgentAppUpdateCaller,+ owner: AgentAppUpdateOwner,+ marker: AgentAppUpdateMarker,+ ) => {try {const result = await deps.apply({+ ...(marker.targetVersion ? { expectedVersion: marker.targetVersion } : {}),beforeRelaunch: async () => {await deps.waitForCallerTurnToEnd(caller);- return true;+ // Logout or an account switch cancels the restart; the patch stays staged.+ return deps.isOwnerCurrent(owner);},});// A relaunch ends this process; the next start reports from the marker.if (result.status === 'relaunching') return;- deps.marker.clear();- await reportFailure(caller.sessionId, marker.requestId, result.reason);+ deps.marker.clear(owner);+ await reportFailure(owner, caller.sessionId, marker.requestId, result.reason);} catch (error) {- deps.marker.clear();+ deps.marker.clear(owner);await reportFailure(+ owner,caller.sessionId,marker.requestId,String(error instanceof Error ? error.message : error),@@ -267,6 +310,8 @@ export function createAgentAppUpdateService(deps: AgentAppUpdateDeps) {const current = deps.resolveCaller(caller);if (current === 'unavailable') return callerUnavailable();if (current !== 'owner') return ownerTurnRequired();+ const owner = deps.captureOwner();+ if (!owner) return callerUnavailable();const marker: AgentAppUpdateMarker = {requestId: randomUUID(),sessionId: caller.sessionId,@@ -275,10 +320,10 @@ export function createAgentAppUpdateService(deps: AgentAppUpdateDeps) {requestedAt: deps.now(),pid: deps.pid,};- deps.marker.write(marker);+ deps.marker.write(owner, marker);flow = { kind: 'installing', targetVersion: check.targetVersion };started = true;- void runInstall(caller, marker);+ void runInstall(caller, owner, marker);return {status: 'started',currentVersion: from,@@ -335,10 +380,12 @@ export function createAgentAppUpdateService(deps: AgentAppUpdateDeps) {/** Write the outcome of a pre-restart install back to its task. Safe to call repeatedly. */async deliverPendingResult(): Promise<void> {- const marker = deps.marker.read();+ const owner = deps.captureOwner();+ if (!owner) return;+ const marker = deps.marker.read(owner);if (!marker || marker.pid === deps.pid) return;if (deps.now() - marker.requestedAt > MARKER_MAX_AGE_MS) {- deps.marker.clear();+ deps.marker.clear(owner);return;}const version = deps.appVersion();@@ -349,14 +396,24 @@ export function createAgentAppUpdateService(deps: AgentAppUpdateDeps) {text('update.agentInstall.failed', { version }),text('update.agentInstall.retryHint'),].join(' ');+ let outcome: AgentAppUpdateNotifyOutcome;try {- await deps.notify(marker.sessionId, `agent-app-update:${marker.requestId}`, message);+ outcome = await deps.notify(+ owner,+ marker.sessionId,+ `agent-app-update:${marker.requestId}`,+ message,+ );} catch (error) {- // A deleted task or a different account cannot receive it; do not retry forever.- deps.logger?.warn?.('agent app update result notice failed', { error: String(error) });+ // Transient failure: keep the marker; the next owner-ready start retries+ // and the clientId keeps the retry from duplicating the message.+ deps.logger?.warn?.('agent app update result notice failed; will retry', {+ error: String(error),+ });+ return;}- deps.marker.clear();- deps.logger?.info?.('agent app update result delivered', { updated });+ deps.marker.clear(owner);+ deps.logger?.info?.('agent app update result delivered', { updated, outcome });},};}diff --git a/apps/desktop/src/main/agent-app-update/index.ts b/apps/desktop/src/main/agent-app-update/index.tsindex 6c014f4514..812e4bb696 100644--- a/apps/desktop/src/main/agent-app-update/index.ts+++ b/apps/desktop/src/main/agent-app-update/index.ts@@ -9,11 +9,20 @@ import { app } from 'electron';import type { XdtHelperMcpDeps } from '@cindy/mcps';-import { ownerScopedUserDataPath } from '../appSessionState.js';+import { eq } from 'drizzle-orm';++import {+ getActiveAppSession,+ isAppSessionBoundaryPending,+ ownerScopedUserDataPath,+} from '../appSessionState.js';import {captureDataOwnerBroadcastScope,isDataOwnerBroadcastScopeCurrent,+ type DataOwnerBroadcastScope,} from '../device-link/broadcast-tap.js';+import { getDbClient } from '../localDb/client/current.js';+import { sessions } from '../localDb/schema.js';import { t } from '../i18n.js';import { createMessage } from '../localDb/ipc/messages.js';import { createLogger } from '../logger.js';@@ -29,9 +38,16 @@ import {createAgentAppUpdateService,type AgentAppUpdateDeps,type AgentAppUpdateMarker,+ type AgentAppUpdateOwner,type AgentAppUpdateService,} from './agentAppUpdateService.js';+/** Owner binding: broadcast scope for current-ness checks and the owner's own marker path. */+interface DesktopAgentAppUpdateOwner extends AgentAppUpdateOwner {+ readonly scope: DataOwnerBroadcastScope;+ readonly markerPath: string;+}+type AppUpdateCallbacks = NonNullable<XdtHelperMcpDeps['appUpdate']>;const log = createLogger('agent-app-update');@@ -45,8 +61,31 @@ export type AgentAppUpdateSessionHost = Pick<let sessionHost: AgentAppUpdateSessionHost | null = null;let service: AgentAppUpdateService | null = null;-function markerPath(): string {- return ownerScopedUserDataPath(MARKER_FILE);+function captureOwner(): DesktopAgentAppUpdateOwner | null {+ if (isAppSessionBoundaryPending()) return null;+ const ownerId = getActiveAppSession().dataOwnerId;+ if (!ownerId) return null;+ return {+ ownerId,+ scope: captureDataOwnerBroadcastScope(),+ markerPath: ownerScopedUserDataPath(MARKER_FILE),+ };+}++function isOwnerCurrent(owner: AgentAppUpdateOwner): boolean {+ return (+ !isAppSessionBoundaryPending() &&+ isDataOwnerBroadcastScopeCurrent((owner as DesktopAgentAppUpdateOwner).scope)+ );+}++function markerPathOf(owner: AgentAppUpdateOwner): string {+ return (owner as DesktopAgentAppUpdateOwner).markerPath;+}++function assertOwnerCurrent(owner: AgentAppUpdateOwner): void {+ if (!isOwnerCurrent(owner))+ throw new Error('The account that confirmed the update is no longer active');}function parseMarker(raw: string | null): AgentAppUpdateMarker | null {@@ -93,22 +132,24 @@ function getService(): AgentAppUpdateService {countOtherRunningTasks: (sessionId) => requireSessionHost().countOtherRunningTasks(sessionId),requestHostPermission: (...args) => requireSessionHost().requestHostPermission(...args),waitForCallerTurnToEnd: (caller) => requireSessionHost().waitForCallerTurnToEnd(caller),+ captureOwner,+ isOwnerCurrent,marker: {- write: (marker) => {- const file = markerPath();+ write: (owner, marker) => {+ const file = markerPathOf(owner);fs.mkdirSync(path.dirname(file), { recursive: true });atomicWriteFileSync(file, JSON.stringify(marker));},- read: () => {+ read: (owner) => {try {- return parseMarker(readAtomicFileSync(markerPath()));+ return parseMarker(readAtomicFileSync(markerPathOf(owner)));} catch (error) {log.warn('agent app update marker read failed', { error: String(error) });return null;}},- clear: () => {- const file = markerPath();+ clear: (owner) => {+ const file = markerPathOf(owner);for (const target of [file, `${file}.bak`]) {try {fs.rmSync(target, { force: true });@@ -118,16 +159,27 @@ function getService(): AgentAppUpdateService {}},},- notify: async (sessionId, clientId, text) => {- const ownerScope = captureDataOwnerBroadcastScope();+ notify: async (owner, sessionId, clientId, text) => {+ assertOwnerCurrent(owner);+ const [task] = await getDbClient()+ .drizzle.select({ id: sessions.id })+ .from(sessions)+ .where(eq(sessions.id, sessionId))+ .limit(1);+ assertOwnerCurrent(owner);+ if (!task) return 'task-missing';+ const scope = (owner as DesktopAgentAppUpdateOwner).scope;await createMessage(sessionId,{ clientId, role: 'assistant', content: text },{- broadcastOwnerScope: ownerScope,- shouldBroadcast: () => isDataOwnerBroadcastScopeCurrent(ownerScope),+ broadcastOwnerScope: scope,+ shouldBroadcast: () => isOwnerCurrent(owner),+ // Re-checked around the write; an account switch rolls the row back.+ beforePublish: async () => assertOwnerCurrent(owner),},);+ return 'written';},compareVersions: compareAppUpdateVersions,translate: (key) => t(key),diff --git a/apps/desktop/src/main/updateService.ts b/apps/desktop/src/main/updateService.tsindex 09a168c7f1..d10eadfbf2 100644--- a/apps/desktop/src/main/updateService.ts+++ b/apps/desktop/src/main/updateService.ts@@ -2154,12 +2154,23 @@ export type AgentConfirmedAppUpdateResult =* concurrent request on the same download) and `executeRelaunch()` applies it* with every existing platform, Subagent and channel guard.*- * `beforeRelaunch` runs after the patch is staged; returning false keeps the- * patch staged and skips the restart.+ * `expectedVersion` is the version shown on the card the owner approved; a+ * different staged version (the channel moved on meanwhile) is not installed+ * without a new confirmation. `beforeRelaunch` runs after the patch is staged;+ * returning false keeps the patch staged and skips the restart.*/export async function applyConfirmedAppUpdateForAgent(options: {+ expectedVersion?: string;beforeRelaunch: () => Promise<boolean>;}): Promise<AgentConfirmedAppUpdateResult> {+ const versionChanged = (): AgentConfirmedAppUpdateResult | null =>+ options.expectedVersion && readyVersion !== options.expectedVersion+ ? {+ status: 'failed',+ reason: `当前渠道的新版本是 ${readyVersion ?? '未知版本'},与确认的 ${options.expectedVersion} 不同,本次没有安装;请重新发起更新。`,+ errorCode: 'version_changed',+ }+ : null;const unsupported = agentUpdateUnsupportedReason();if (unsupported) return { status: 'failed', reason: unsupported, errorCode: 'unsupported' };if (isRelaunching || autoRelaunchInProgress) return { status: 'relaunching', targetVersion: readyVersion };@@ -2169,6 +2180,8 @@ export async function applyConfirmedAppUpdateForAgent(options: {return { status: 'failed', reason: AGENT_UPDATE_FAILURE_REASONS[result], errorCode: result };}}+ const changedAfterDownload = versionChanged();+ if (changedAfterDownload) return changedAfterDownload;if (!await options.beforeRelaunch()) {return { status: 'failed', reason: '更新已下载,但本次没有重启。', errorCode: 'relaunch_cancelled' };}@@ -2176,6 +2189,9 @@ export async function applyConfirmedAppUpdateForAgent(options: {if (currentStatus !== 'ready' || !readyVersion) {return { status: 'failed', reason: '已下载的更新不再可用,请重新检查更新。', errorCode: 'not_ready' };}+ // A background check may have superseded the staged patch during the wait.+ const changedBeforeRelaunch = versionChanged();+ if (changedBeforeRelaunch) return changedBeforeRelaunch;const targetVersion = readyVersion;// macOS / Linux exit inside this call once the updater is spawned; Windows// returns with `isRelaunching` still set and exits from its own callbacks.diff --git a/docs/product-rules/agent-app-update.md b/docs/product-rules/agent-app-update.mdindex 41043d4083..1fe7b92110 100644--- a/docs/product-rules/agent-app-update.md+++ b/docs/product-rules/agent-app-update.md@@ -15,10 +15,13 @@ Agent 只能反复引导用户去点「检查更新」;那次收紧的起因安装卡写明从哪个版本到哪个版本、Cindy 会重启、另有几个任务正在运行会被中断(重启后在任务里点「继续」恢复)、本任务在这轮回复后重启、远程连接会短暂断开;Linux 另提示需要输入系统密码。- 确认后走「设置 → 关于」同一条更新状态机:`checkForUpdate()` 下载(单飞,重复调用不重复下载),- 等调用任务这轮回复结束(最多 2 分钟)后 `executeRelaunch()` 重启。拒绝、超时或卡片未送达都不下载、+ 等调用任务这轮回复结束(最多 2 分钟)后 `executeRelaunch()` 重启。安装只认卡片上确认的版本:+ 渠道期间换了新版本时不安装,提示重新发起。安装绑定确认时的账号:退出或切换账号会取消重启,+ 标记与结果消息只写回该账号,绝不写进后来的账号。拒绝、超时或卡片未送达都不下载、不重启。同一时刻只有一个安装请求;确认卡等待中或已开始安装时再次调用直接返回当前状态。- 重启前在账号私有目录写一份标记;新版本启动、该账号数据库就绪后,把结果(新版本号或「仍是旧版本」)- 作为一条普通助手消息写回发起任务,桌面和手机重连后都能看到。未重启就失败(下载失败、更新器没启动)+ 作为一条普通助手消息写回发起任务,桌面和手机重连后都能看到。写入暂时失败时保留标记、下次就绪再写+ (按 clientId 去重);任务已不存在才丢弃。未重启就失败(下载失败、更新器没启动)时立即写回失败原因。- 自动更新开关写入既有 `auto-update-settings-store`(用户显式 override),与设置页同一开关。`check_app_update` 在有可安装更新且开关未开时返回一次 `autoUpdateHint`,同一任务内只提示一次。@@ -32,6 +35,8 @@ Agent 只能反复引导用户去点「检查更新」;那次收紧的起因- 桌面与同账号手机:输入协调器里当前轮次的输入必须是主人亲手输入的文字;自动化、其他任务(`send_to_session`)、Orca、插件、共享任务访客、自动续跑、合成指令都不算。- 个人 IM:沿用控制命令的主人判据(私聊已过渠道 owner 门;群里看发言人 `isOwner`)。+- 个人微信:私聊联系人无法证明是主人(其权限策略本就记为 `requesterAuthority: unknown`),一律拒绝,+ 主人可在桌面、手机或其他已验证主人的渠道发起。- 官方 Hook:仅 Telegram 私聊(服务端按账号绑定路由);群与其他渠道不算。- scheduler / goal 轮次一律拒绝。