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。

Merge remote-tracking branch 'upstream/main' into tmp2-5529

Zhang Yunjin5f80a19d7f30
diff --cc apps/desktop/src/main/maker-ipc/orcaTeamService.ts
index 4d9e353173,84fc02fe3b..76d58b8121
--- a/apps/desktop/src/main/maker-ipc/orcaTeamService.ts
+++ b/apps/desktop/src/main/maker-ipc/orcaTeamService.ts
@@@ -277,22 -264,8 +279,24 @@@ export interface OrcaTeamServiceDeps
worker: OrcaWorkerRecordSnapshot,
link: OrcaWorkerLinkSnapshot,
): Promise<void>;
+ /** 修订 worker 的 role/label;label 唯一性由 store 的唯一索引把关。 */
+ updateWorkerIdentity: (input: {
+ workerId: string;
+ role: string;
+ label: string | null;
+ previousRole: string;
+ previousLabel: string | null;
+ }) => Promise<{ ok: true } | { ok: false; errorCode: 'NOT_FOUND' | 'DUPLICATE_LABEL' }>;
+ /**
+ * true = 这些 label 中被当前 lead 的插件 team plan 未结算条目引用,改名会破坏计划归属与委派自动授权。
+ * 非插件任务 / 无计划 / 已结算时不锁定。可选:未注入时不做计划锁。
+ */
+ isWorkerLabelLockedByPlan?: (params: {
+ leadSessionId: string;
+ labels: ReadonlyArray<string | null>;
+ }) => Promise<boolean>;
+ /** 取消该 worker session 尚未落地的后台唤醒(focus 预热);释放 runtime 前调用。 */
+ cancelWorkerResume?(sessionId: string): void;
updateWorkerStatus(workerId: string, status: OrcaWorkerStatus): Promise<void>;
markWorkerIdle(workerId: string): Promise<void>;
markWorkerIdleIfStatus(workerId: string, expectedStatus: 'done'): Promise<boolean>;
diff --cc apps/desktop/src/main/maker-ipc/register.ts
index 6d6643f819,8ab84b248d..5c4681e80b
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@@ -14941,27 -15024,12 +15052,30 @@@ export function registerMakerIpc(maker
listWorkersByLead,
getLiveSession: (sessionId) => maker.getSession(sessionId) ?? null,
resumeWorkerSession: async (target) => {
- await resumeOrcaWorkerSessionIfMissing(target);
+ // 与 focus 后台预热共享同一套去重/锁:派活不会和切换触发两次 bootstrap。
+ await orcaWorkerResumeScheduler.request(target);
},
+ // 归档 / 显式 idle 会释放 runtime;先取消未落地的后台预热,避免释放后被重新拉起。
+ cancelWorkerResume: (sessionId) => orcaWorkerResumeScheduler.cancel(sessionId),
updateWorkerStatus,
+ updateWorkerIdentity,
+ isWorkerLabelLockedByPlan: async ({ leadSessionId, labels }) => {
+ const epoch = getCurrentDbClientSnapshot();
+ if (!epoch) throw new Error('plugin task storage unavailable');
+ const receipt = await createPluginTaskStore(epoch.client).get(leadSessionId);
+ if (epoch !== getCurrentDbClientSnapshot()) throw new Error('account changed');
+ // 仅"插件已卸载(任务归属确实撤销)"解除计划锁;停用 / 未批准可恢复,重新启用后
+ // 计划仍会继续,保持锁定(fail closed)。
+ //
+ // 收据里存的是**存储 part**(带命名空间时形如 `_ns__acme__helper`),只按
+ // manifest.id 查会把它当成「不在册」,于是仍被计划引用的 Worker 被人改名,
+ // 收据续期也随之失效。先按实例标识解一次,再退回 manifest.id。
+ const pluginInstalled =
+ receipt !== undefined &&
+ (findAvailableGhostForAuthorization(receipt.pluginId) !== null ||
+ findGhostForInstanceId(receipt.pluginId) !== null);
+ return isTeamPlanLabelLockedByReceipt(receipt, pluginInstalled, labels);
+ },
markWorkerIdle: async (workerId) => {
const now = Date.now();
const db = getDbClient().drizzle;