Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(task-copy): 回包暂存与打包复核沿用同一预算和文件数上限
Dash9158e7331c7e
diff --git a/apps/desktop/src/main/device-link/__tests__/dispatchWeakNetwork.test.ts b/apps/desktop/src/main/device-link/__tests__/dispatchWeakNetwork.test.tsindex 99ea2c8d06..ad8a90e4c3 100644--- a/apps/desktop/src/main/device-link/__tests__/dispatchWeakNetwork.test.ts+++ b/apps/desktop/src/main/device-link/__tests__/dispatchWeakNetwork.test.ts@@ -683,6 +683,11 @@ describe('[5] orphan 截止时间按 channel 收窄', () => {]);expect(orphan('estimate')).toBe(TASK_MIGRATION_ESTIMATE_TIMEOUT_MS * 2);expect(orphan('status')).toBe(60_000);+ // A reply that could not be sent is kept for the same action-specific window.+ const outbox = (action: string) =>+ __testing.outboxEntryMaxAgeMs(TASK_MIGRATION_CHANNEL, [{ action, sessionId: 's' }]);+ expect(outbox('estimate')).toBe(TASK_MIGRATION_ESTIMATE_TIMEOUT_MS * 2);+ expect(outbox('status')).toBe(60_000);});});diff --git a/apps/desktop/src/main/device-link/dispatch.ts b/apps/desktop/src/main/device-link/dispatch.tsindex 6ec5dc7675..0f847d2682 100644--- a/apps/desktop/src/main/device-link/dispatch.ts+++ b/apps/desktop/src/main/device-link/dispatch.ts@@ -753,10 +753,18 @@ const REMOTE_INVOKE_RESULT_OUTBOX_MAX_AGE_MS = REMOTE_INVOKE_MAX_CLIENT_WAIT_MS* 弱网时段最多占 outbox 两分钟纯属浪费配额;长任务 channel(60s 预算)自动保留* 更久。控制端可能配置更短的超时(mobile 15s),推断值只偏保守、不早丢。*/-function outboxEntryMaxAgeMs(channel: string | undefined): number {- const budgetMs =- (channel && INVOKE_TIMEOUT_OVERRIDES_MS[channel]) || DEFAULT_REMOTE_INVOKE_CLIENT_WAIT_MS;- return Math.min(budgetMs * 2, REMOTE_INVOKE_RESULT_OUTBOX_MAX_AGE_MS);+function outboxEntryMaxAgeMs(channel: string | undefined, args?: unknown[]): number {+ return Math.min(remoteInvokeClientBudgetMs(channel, args) * 2, REMOTE_INVOKE_RESULT_OUTBOX_MAX_AGE_MS);+}+/**+ * 控制端对这次调用的等待预算:与桌面控制端同一个 resolver(带 args),所以任务复制+ * estimate/receive 这类按动作区分的预算在被控端的 orphan 与 outbox 两处同样生效。+ */+function remoteInvokeClientBudgetMs(channel: string | undefined, args?: unknown[]): number {+ return (+ (channel && resolveRemoteInvokeTimeoutMs(channel, args, 'desktop')) ||+ DEFAULT_REMOTE_INVOKE_CLIENT_WAIT_MS+ );}/*** ipcMain handler 没有统一 AbortSignal,不能在 30s 客户端超时时假装取消副作用。@@ -771,12 +779,7 @@ const REMOTE_INVOKE_ORPHAN_TIMEOUT_MS = REMOTE_INVOKE_MAX_CLIENT_WAIT_MS * 2;* 动作看起来卡住(BACKPRESSURE)。*/function remoteInvokeOrphanTimeoutMs(channel: string | undefined, args?: unknown[]): number {- // Same resolver as the desktop controller, so action-specific budgets (task copy- // estimate/receive) are honoured here too instead of the channel default.- const budgetMs =- (channel && resolveRemoteInvokeTimeoutMs(channel, args, 'desktop')) ||- DEFAULT_REMOTE_INVOKE_CLIENT_WAIT_MS;- return Math.min(budgetMs * 2, REMOTE_INVOKE_ORPHAN_TIMEOUT_MS);+ return Math.min(remoteInvokeClientBudgetMs(channel, args) * 2, REMOTE_INVOKE_ORPHAN_TIMEOUT_MS);}interface CachedRemoteInvokeResult {result: InvokeResultPayload;@@ -3283,7 +3286,7 @@ function flushRemoteInvokeResultOutbox(onlySrc?: string): void {const blockedPeers = new Set<string>();for (const [key, queued] of remoteInvokeResultOutbox) {if (onlySrc && queued.src !== onlySrc) continue;- if (now - queued.queuedAt >= outboxEntryMaxAgeMs(queued.channel)) {+ if (now - queued.queuedAt >= outboxEntryMaxAgeMs(queued.channel, queued.args)) {log.warn(`dropping expired invoke-result outbox entry for ${queued.channel ?? '?'} ` +`to ${shortId(queued.src)} request=${shortId(queued.requestId)} queuedMs=${now - queued.queuedAt}`,diff --git a/apps/desktop/src/main/task-migration/__tests__/workspace.git-integration.test.ts b/apps/desktop/src/main/task-migration/__tests__/workspace.git-integration.test.tsindex 0eca265ef6..476caa8d29 100644--- a/apps/desktop/src/main/task-migration/__tests__/workspace.git-integration.test.ts+++ b/apps/desktop/src/main/task-migration/__tests__/workspace.git-integration.test.ts@@ -148,6 +148,26 @@ describe('cross-machine project snapshots', () => {const snapshot = await snapshotWorkspace(source, artifacts, randomUUID(), 3);expect(Object.keys(snapshot.archive.files).sort()).toEqual(['a', 'b', 'sub', 'sub/c']);});+ it('keeps the file allowance when files appear while the archive is written', async () => {+ await fs.writeFile(path.join(source, 'a'), 'a');+ const open = fs.open.bind(fs);+ let grown = false;+ // The archive is fsynced via fs.open after packing; grow the tree at that moment.+ const grow = vi.spyOn(fs, 'open').mockImplementation(async (...args) => {+ grow.mockRestore();+ grown = true;+ for (const name of ['b', 'c']) await fs.writeFile(path.join(source, name), name);+ return open(...(args as Parameters<typeof open>));+ });+ try {+ await expect(snapshotWorkspace(source, artifacts, randomUUID(), 2)).rejects.toThrow(+ 'MIGRATION_TOO_MANY_FILES',+ );+ expect(grown).toBe(true);+ } finally {+ grow.mockRestore();+ }+ });it('refuses to overwrite a destination directory', async () => {await fs.writeFile(path.join(source, 'source'), 'copy');const snapshot = await snapshotWorkspace(source, artifacts, randomUUID());diff --git a/apps/desktop/src/main/worktree/recoveryArchiveIO.ts b/apps/desktop/src/main/worktree/recoveryArchiveIO.tsindex a0e18fc96e..d9b852a973 100644--- a/apps/desktop/src/main/worktree/recoveryArchiveIO.ts+++ b/apps/desktop/src/main/worktree/recoveryArchiveIO.ts@@ -153,7 +153,7 @@ export async function createRecoveryArchive(root: string, resourceId: string, ditry { await handle.sync(); } finally { await handle.close(); }const archive = { file, encryptedKey, iv: Buffer.from(iv).toString('base64'), tag: cipher.getAuthTag().toString('base64'), files };await verifyRecoveryArchive(archive, directory, key, maxBytes);- if (!sameWorktreeFiles(await inventoryWorktree(root, undefined, excludeRootNames), files)) throw new Error('worktree changed during archive');+ if (!sameWorktreeFiles(await inventoryWorktree(root, undefined, excludeRootNames, maxFiles), files)) throw new Error('worktree changed during archive');return archive;} catch (error) {await fs.rm(target, { force: true });