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 into sandbox/pi-live
Chris508715ecda3a
diff --cc apps/desktop/src/main/maker-host/__tests__/claudeProxyScopeGate.test.tsindex 634adcfb42,56816c1fd8..3ee7030ab7--- a/apps/desktop/src/main/maker-host/__tests__/claudeProxyScopeGate.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/claudeProxyScopeGate.test.ts@@@ -154,75 -149,3 +154,75 @@@ describe('cc routingTransform — xAI �expect(readClaudeSessionRoute('sess-grok')).toBe('gateway');});});++describe('pi routingTransform — xdt session header selects the Pi provider route', () => {+ afterEach(() => {+ clearSessionProvider('sess-pi');+ setProviderOAuthTokenReader(() => null);+ resetPiProxySessionsForTest();+ });++ it('routes an Anthropic Pi request with host-managed OAuth and strips Pi placeholder auth', async () => {+ setClaudeProxyGatewayKeyReader(() => 'sk-gw');+ setSessionProvider('sess-pi', 'anthropic');+ setProviderOAuthTokenReader((providerId, agent) =>+ providerId === 'anthropic' && agent === 'pi' ? Promise.resolve('pi-claude-token') : null,+ );+ registerPiProxySession('sess-pi', 'session-secret');+ const decision = createModelRoutingTransform()(+ { model: 'claude-opus-5' },+ ctxWith({+ 'x-cindy-pi-session-id': 'sess-pi',+ 'x-cindy-pi-session-token': 'session-secret',+ 'x-api-key': 'cindy-pi-provider-auth-placeholder',+ }),+ );+ await expect(Promise.resolve(decision)).resolves.toEqual({+ upstreamOverride: 'https://api.anthropic.com',+ headerOverride: {+ 'anthropic-version': '2023-06-01',+ 'anthropic-beta': 'oauth-2025-04-20',+ authorization: 'Bearer pi-claude-token',+ },+ headerDelete: [+ 'x-api-key',+ 'x-cindy-pi-session-id',+ 'x-cindy-pi-session-token',+ ],+ });+ });++ it('rejects a forged session id before provider credentials can be selected', async () => {+ setSessionProvider('sess-pi', 'anthropic');+ registerPiProxySession('sess-pi', 'real-secret');+ const decision = await createModelRoutingTransform()(+ { model: 'claude-opus-5' },+ ctxWith({+ 'x-cindy-pi-session-id': 'sess-pi',+ 'x-cindy-pi-session-token': 'wrong-secret',+ }),+ );+ expect(decision).toEqual({ localHandler: expect.any(Function) });++ const response = {+ status: 0,+ body: '',+ writeHead(status: number) { this.status = status; },+ end(body: string) { this.body = body; },+ };+ await decision?.localHandler?.({ res: response } as never);+ expect(response.status).toBe(401);+ expect(response.body).toContain('invalid_pi_session_token');+ });++ it('never forwards an orphaned internal Pi token header', async () => {- const decision = createModelRoutingTransform()(++ const decision = await Promise.resolve(createModelRoutingTransform()(+ { model: 'claude-opus-5' },+ ctxWith({ 'x-cindy-pi-session-token': 'orphaned-secret' }),- );++ ));+ expect(decision).toMatchObject({+ headerDelete: ['x-cindy-pi-session-id', 'x-cindy-pi-session-token'],+ });+ expect(decision?.headerOverride).not.toHaveProperty('x-cindy-pi-session-token');+ });+});