Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(pi): keep runtime recovery marker inside Main
zqchris164b56e0ac43
diff --git a/apps/desktop/src/main/__tests__/makerEventHotPathOrdering.test.ts b/apps/desktop/src/main/__tests__/makerEventHotPathOrdering.test.tsindex 1f357b6446..bdb157ce86 100644--- a/apps/desktop/src/main/__tests__/makerEventHotPathOrdering.test.ts+++ b/apps/desktop/src/main/__tests__/makerEventHotPathOrdering.test.ts@@ -9,6 +9,8 @@import { readFileSync } from 'node:fs';import { resolve } from 'node:path';import { describe, expect, it } from 'vitest';+import { ScriptTarget, transpileModule } from 'typescript';+import type { AgentEvent } from '@cindy/maker-core';const sourcePath = resolve(__dirname, '..', 'maker-ipc', 'register.ts');const source = readFileSync(sourcePath, 'utf8').replace(/\r\n?/g, '\n');@@ -23,6 +25,30 @@ const goalStorageSourcePath = resolve(__dirname, '..', 'goal-host', 'storage.ts'const goalStorageSource = readFileSync(goalStorageSourcePath, 'utf8').replace(/\r\n?/g, '\n');describe('maker:event hot path ordering', () => {+ it.each([undefined, null, { text: 'Restart Cindy before using Pi again.', isFinal: true }])(+ 'strips Host recovery metadata from the boundary copy with data %j',+ (data) => {+ // Execute the actual boundary function without booting Desktop/register side effects.+ const start = source.indexOf('function redactEventForRenderer');+ const code = source.slice(start, source.indexOf('\nfunction ', start + 1));+ const js = transpileModule(code, {+ compilerOptions: { target: ScriptTarget.ES2022 },+ }).outputText;+ const redact = new Function(`${js}; return redactEventForRenderer;`)() as+ (event: AgentEvent) => AgentEvent;+ const original: AgentEvent = {+ type: 'text', source: 'pi', data, runtimeRecovery: true,+ sessionInstanceId: 'runtime', sessionTurnGeneration: 7,+ };+ const boundary = redact(original);+ expect(boundary).toEqual({ type: 'text', source: 'pi', data });+ expect(original.runtimeRecovery).toBe(true);+ expect(original.sessionInstanceId).toBe('runtime');+ expect(original.sessionTurnGeneration).toBe(7);+ expect(boundary).not.toBe(original);+ },+ );+it('keeps complete PI Subagent returns on the host side of the event boundary', () => {const redactor = source.slice(source.indexOf('function redactEventForRenderer'),diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex c214f02efa..47d9824b4b 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -17687,6 +17687,7 @@ function redactEventForRenderer(event: AgentEvent): AgentEvent {delete rendererEvent.backgroundTurnStartedAt;delete rendererEvent.sessionTurnGeneration;delete rendererEvent.sessionInstanceId;+ delete rendererEvent.runtimeRecovery;if (!event.data || typeof event.data !== 'object') return rendererEvent;const data = event.data as Record<string, unknown>;