Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge upstream main and resolve Pi provider routing conflict
lizzjinf90ba4367ff7
diff --cc packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.tsindex f0cfefee80,2462982dd4..3f60fd124f--- a/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.ts@@@ -13,24 -21,29 +21,35 @@@ const captured = vi.hoisted(() => (args: [] as string[],env: {} as Record<string, string | undefined>,requests: [] as Array<Record<string, unknown>>,- requestOptions: [] as Array<{- timeoutMs?: number;- refreshTimeoutOnEvent?: (event: { type: string }) => boolean;- } | undefined>,+ requestOptions: [] as Array<+ | {+ timeoutMs?: number;+ refreshTimeoutOnEvent?: (event: { type: string }) => boolean;+ }+ | undefined+ >,closes: 0,- onExit: undefined as undefined | ((info: {- code: number | null;- signal: NodeJS.Signals | null;- }) => void),- requestHandler: undefined as undefined | ((command: Record<string, unknown>) => Promise<{- success: boolean;- command?: unknown;- data?: unknown;- error?: string;- }>),++ onExit: undefined as++ | undefined++ | ((info: {++ code: number | null;++ signal: NodeJS.Signals | null;++ }) => void),+ initialProvider: undefined as string | undefined,+ initialModel: undefined as string | undefined,+ runtimeProvider: undefined as string | undefined,+ runtimeModel: undefined as string | undefined,+ requestHandler: undefined as+ | undefined+ | ((command: Record<string, unknown>) => Promise<{+ success: boolean;+ command?: unknown;+ data?: unknown;+ error?: string;+ }>),}));- vi.mock('../transport.js', () => ({+ vi.mock("../transport.js", () => ({createPiStdioTransport: (opts: {args: string[];env: Record<string, string | undefined>;@@@ -141,10 -205,13 +219,14 @@@ describe("Pi provider-aware model routicaptured.requests = [];captured.requestOptions = [];captured.closes = 0;+ captured.onExit = undefined;+ captured.initialProvider = undefined;+ captured.initialModel = undefined;+ captured.runtimeProvider = undefined;+ captured.runtimeModel = undefined;captured.requestHandler = undefined;- agentHome = mkdtempSync(path.join(tmpdir(), 'pi-provider-home-'));- cwd = mkdtempSync(path.join(tmpdir(), 'pi-provider-cwd-'));+ agentHome = mkdtempSync(path.join(tmpdir(), "pi-provider-home-"));+ cwd = mkdtempSync(path.join(tmpdir(), "pi-provider-cwd-"));});afterEach(() => {@@@ -3857,68 -5398,8 +5413,68 @@@await handle.close();});- it('preserves the stable remote config home across a transport disconnect and reattach', async () => {- const remoteStub: import('../transport.js').PiTransport = {++ it("preserves the stable remote config home across a transport disconnect and reattach", async () => {++ const remoteStub: import("../transport.js").PiTransport = {+ writeLine: async () => {},+ onLine: () => () => {},+ onStderr: () => () => {},+ onClose: () => () => {},+ close: async () => {},+ pid: 4321,+ isClosed: () => false,- remoteBinaryPath: '/remote/pi',++ remoteBinaryPath: "/remote/pi",+ killRemoteSession: async () => {},+ };+ const remoteRm = vi.fn(async () => {});+ const capturedRemoteEnvs: Array<Record<string, string | undefined>> = [];+ const base = byomDeps(async () => ({ providers: [], env: {} }));+ const deps: AgentDeps = {+ ...base,+ runtimeConfig: {+ ...base.runtimeConfig,- remoteEndpoint: 'https://gateway.example.test',++ remoteEndpoint: "https://gateway.example.test",+ },- resolveRemotePiBinaryPath: async () => '/remote/pi',++ resolveRemotePiBinaryPath: async () => "/remote/pi",+ getRemotePiTransport: async (_hostId, opts) => {+ capturedRemoteEnvs.push({ ...(opts.env ?? {}) });+ return remoteStub;+ },+ getRemotePiFileOps: () => ({+ mkdirp: async () => {},+ writeFile: async () => {},+ stat: async () => ({ isFile: true }),+ rm: remoteRm,+ listDir: async () => [],+ }),+ };++ await new PiAgent(deps).startSession({- sessionId: 'remote-disconnect-reattach',++ sessionId: "remote-disconnect-reattach",+ workingDir: cwd,- model: 'local-model',- remoteHostId: 'remote-host',++ model: "local-model",++ remoteHostId: "remote-host",+ });+ const firstEnv = capturedRemoteEnvs[0]!;+ const configHome = firstEnv.PI_CODING_AGENT_DIR!;++ captured.onExit?.({ code: null, signal: null });+ await Promise.resolve();+ expect(remoteRm).not.toHaveBeenCalledWith(configHome, { recursive: true });++ const reattached = await new PiAgent(deps).startSession({- sessionId: 'remote-disconnect-reattach',++ sessionId: "remote-disconnect-reattach",+ workingDir: cwd,- model: 'local-model',- remoteHostId: 'remote-host',++ model: "local-model",++ remoteHostId: "remote-host",+ });+ expect(capturedRemoteEnvs[1]).toEqual(firstEnv);+ expect(capturedRemoteEnvs[1]?.PI_CODING_AGENT_DIR).toBe(configHome);+ await reattached.close();+ expect(remoteRm).not.toHaveBeenCalledWith(configHome, { recursive: true });+ });+- it('hashes the remote permission snapshot into spawn env so a later Full-access attach restarts', async () => {- const remoteStub: import('../transport.js').PiTransport = {+ it("hashes the remote permission snapshot into spawn env so a later Full-access attach restarts", async () => {+ const remoteStub: import("../transport.js").PiTransport = {writeLine: async () => {},onLine: () => () => {},onStderr: () => () => {},