Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge branch 'origin/main' into redo/plugin-approval-receipt-migration
Yuewei-LL6b8712af39f1
diff --cc apps/desktop/src/main/cindy-brain/index.tsindex b125b0612d,fbc022b536..f5a655a175--- a/apps/desktop/src/main/cindy-brain/index.ts+++ b/apps/desktop/src/main/cindy-brain/index.ts@@@ -818,11 -714,20 +819,21 @@@ export function isGhostAvailableForActireturn !isCindyAccountGhostId(id) || getAppCapabilities().canUseCindyAccountServices;}+ /** Live Host capability gate shared by Agent transports and Renderer IPC. */+ export function getIOSSimulatorPluginAccessDecision(+ workingDir: string | null = null,+ ) {+ return resolveIOSSimulatorPluginAccess(getGhostManager().list(), workingDir, {+ isAvailableForActiveSession: isGhostAvailableForActiveSession,+ isDisabledForWorkdir: isGhostDisabledForWorkdir,+ });+ }+function availableGhosts(): InstalledGhost[] {- return getGhostManager()- .list()- .filter((ghost) => isGhostAvailableForActiveSession(ghost.manifest.id));+ if (isAppSessionBoundaryPending()) return [];+ return getGhostManager().list().filter((ghost) =>+ isGhostAvailableForActiveSession(ghost.manifest.id),+ );}function projectGhostForRenderer(ghost: InstalledGhost): InstalledGhost {@@@ -4347,17 -4012,13 +4358,21 @@@ async function installOrUpdateMarketGholet result: Awaited<ReturnType<typeof manager.update>>;let packagePlaced = false;try {- // 与首装分支同一口径:钉住 inspect 时校验过的包字节。receipt 模型下更新必须- // 绑定 receipt token(决策 A:与 main 的 sha 钉扎叠加),否则并发批准变更绕不过去。+ // 市场更新同样会原位 rename 插件目录。Windows 上不能只发停止信号,+ // 必须确认旧 utilityProcess 已离开,否则入口文件仍可能被占用而报 EPERM。+ getGhostAgentSlot().clearGhost(expected.ghostId);+ getGhostErrandSlot().clearGhost(expected.ghostId);- // 与首装分支同一口径:钉住 inspect 时校验过的包字节(见上)。++ // receipt 模型下更新必须绑定 receipt token(决策 A:与 main 的 sha 钉扎叠加),++ // 否则并发批准变更绕不过去。+ if (!expected.expectedInstalledApproval) {+ throwIpcError(+ 'PRECONDITION_FAILED',+ 'Plugin approval state was not bound to the market update',+ );+ }result = await manager.update(cindyFilePath, {expectedPackageSha256: inspected.packageSha256,+ expectedInstalledApproval: expected.expectedInstalledApproval,...(trustOverride ? { trustOverride } : {}),onPackagePlaced: () => {packagePlaced = true;@@@ -5659,13 -5296,16 +5674,18 @@@ export function registerGhostIpc(): voi}rejectReservedGhostId(inspected.manifest.id);rejectUnauthorizedTokenBroker(inspected.manifest);- // 与市场装入/本地装入/卸载共用按 ghostId 的互斥:换目录期间同 id 的其它- // 装入/卸载不得插入(否则并发装入会与本次 rename 竞争、留下不一致态)。- return withGhostInstallLock(inspected.manifest.id, async () => {- const releaseMutation = beginGhostMutation(mutationOwner);- const previousGhost = manager.list().find((g) => g.manifest.id === inspected.manifest.id);- try {+ // 从熄灯到换版收尾整段持 owner 租约:熄灯之后每一步都在改"当前 owner"的插件世界,+ // 中途 owner 切换落定会把后半段(update 落盘/停靠/点火)写进新 owner。租约在锁外,+ // 与市场/本地装入/卸载共用的按 ghostId 互斥叠加(二者语义不同,决策 A 都保留)。++ // 锁序不变量(违反即死锁):owner lease → per-id lock。+ const releaseMutation = beginGhostMutation(mutationOwner);+ try {+ return await withGhostInstallLock(inspected.manifest.id, async () => {+ const previousGhost = manager.list().find((g) => g.manifest.id === inspected.manifest.id);+ runtime.stop(inspected.manifest.id);+ // 等待失败表示旧进程仍可能存活;此时不能恢复 resident,否则会产生+ // 两份后台进程。仅在确认退出后的更新阶段失败时恢复旧版本。+ await getGhostNodeRuntimeBroker().stopAndWait(inspected.manifest.id);let marketRecord: PluginMarketInstallationRecord | null;let marketInstallSubject: string | null = null;let marketRecordWasSuppressed = false;diff --cc apps/desktop/src/main/cindy-brain/nodeRuntimeBroker.tsindex db37f9df1b,860f4cd1bb..cddfb2e5d1--- a/apps/desktop/src/main/cindy-brain/nodeRuntimeBroker.ts+++ b/apps/desktop/src/main/cindy-brain/nodeRuntimeBroker.ts@@@ -147,9 -149,16 +152,17 @@@ interface ChildProcEntrystopping: boolean;}+ /** 已 fork 但尚未完成 spawn 握手的代启子进程。 */+ interface StartingChildProcEntry {+ ghostId: string;+ proc: NodeWorkerProcess;+ hardKillTimer: NodeJS.Timeout | null;+ stopping: boolean;+ }+interface WorkerEntry {ghost: InstalledGhost;+ ownerScopeSnapshot: unknown;/** 本进程对应的入口(相对路径;主入口 = manifest.node.entry)。 */entryRel: string;child: NodeWorkerProcess;@@@ -713,10 -694,16 +726,20 @@@ export class GhostNodeRuntimeBrokermessage: reason,});};+ // stopAndWait 已开始后不得再 fork 新 child;否则它会落在本轮快照之外,+ // 又把目录替换竞态带回来。仍在世的 worker 必须收到拒绝回执,避免它白等+ // 到自己的请求超时;已被移除的 worker 则不再可安全回信。+ if (this.workers.get(GhostNodeRuntimeBroker.keyOf(ghostId, entry.entryRel)) !== entry) {+ return;+ }+ if (this.stoppedGhosts.has(ghostId)) {+ fail('插件正在停止,不能再启动子进程');+ return;+ }+ if (!this.ownerScopeUsable(ghostId, entry.ownerScopeSnapshot)) {+ fail('Plugin owner boundary changed before child process dispatch');+ return;+ }const ghost = this.deps.getGhost(ghostId);const node = ghost?.enabled ? ghost.manifest.node : undefined;if (!node || node.childSpawn !== true) {@@@ -1051,9 -1136,9 +1196,10 @@@} catch (error) {throw new WorkerStartError(error instanceof Error ? error.message : String(error), true);}+ this.trackLiveProcess(ghost.manifest.id, child);const entry: WorkerEntry = {ghost,+ ownerScopeSnapshot,entryRel,child,startupPhase: true,