pi2dsh 0.15.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -60
- package/README.zh.md +34 -54
- package/dist/{analyzer-C5FQXB7R.mjs → analyzer-dRAMYI3l.mjs} +2 -2
- package/dist/{analyzer-C5FQXB7R.mjs.map → analyzer-dRAMYI3l.mjs.map} +1 -1
- package/dist/cli.mjs +2 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/compat/pi-ai.d.mts +1 -1
- package/dist/compat/pi-ai.mjs +1 -2
- package/dist/compat/pi-coding-agent.mjs +1 -1
- package/dist/credentials-oauth.d.mts +8 -2
- package/dist/credentials-oauth.d.mts.map +1 -1
- package/dist/credentials-oauth.mjs +134 -1
- package/dist/credentials-oauth.mjs.map +1 -0
- package/dist/{google-generative-ai-2gCFYp-t.mjs → google-generative-ai-Dpb_X-Kt.mjs} +2 -2
- package/dist/{google-generative-ai-2gCFYp-t.mjs.map → google-generative-ai-Dpb_X-Kt.mjs.map} +1 -1
- package/dist/{google-shared-75IdVyrx.mjs → google-shared-CL1Za-ev.mjs} +12 -12
- package/dist/{google-shared-75IdVyrx.mjs.map → google-shared-CL1Za-ev.mjs.map} +1 -1
- package/dist/{google-vertex-Bhyo4z2i.mjs → google-vertex-BXRKa49Y.mjs} +2 -2
- package/dist/{google-vertex-Bhyo4z2i.mjs.map → google-vertex-BXRKa49Y.mjs.map} +1 -1
- package/dist/host.mjs +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{compatibility-DVMqXJux.mjs → mcp-config-2s_i_H3R.mjs} +180 -3
- package/dist/mcp-config-2s_i_H3R.mjs.map +1 -0
- package/dist/{mistral-conversations-DJyeTo8C.mjs → mistral-conversations-D-Kf38nj.mjs} +5491 -407
- package/dist/mistral-conversations-D-Kf38nj.mjs.map +1 -0
- package/dist/{multipart-parser-SRcGkVuX.mjs → multipart-parser-CBAi6PxA.mjs} +2 -2
- package/dist/{multipart-parser-SRcGkVuX.mjs.map → multipart-parser-CBAi6PxA.mjs.map} +1 -1
- package/dist/{credentials-oauth-Didpkkjx.mjs → oauth-bridge-C_MAPMGA.mjs} +11 -88
- package/dist/oauth-bridge-C_MAPMGA.mjs.map +1 -0
- package/dist/oauth-bridge-hOnT3acY.d.mts +34 -0
- package/dist/oauth-bridge-hOnT3acY.d.mts.map +1 -0
- package/dist/{otel-CBhmS-NR.mjs → otel-EL651-JR.mjs} +2 -2
- package/dist/{otel-CBhmS-NR.mjs.map → otel-EL651-JR.mjs.map} +1 -1
- package/dist/{pi-ai-DpqiLdPA.mjs → pi-ai-DQPHUR9S.mjs} +252 -7
- package/dist/pi-ai-DQPHUR9S.mjs.map +1 -0
- package/dist/{pi-ai-ZU5MelXy.d.mts → pi-ai-hGbYES_v.d.mts} +2 -2
- package/dist/{pi-ai-ZU5MelXy.d.mts.map → pi-ai-hGbYES_v.d.mts.map} +1 -1
- package/dist/{pi-coding-agent-DK8hbJP5.mjs → pi-coding-agent-f3_hNCpd.mjs} +0 -0
- package/dist/{pi-coding-agent-DK8hbJP5.mjs.map → pi-coding-agent-f3_hNCpd.mjs.map} +1 -1
- package/dist/{runtime-BlbKWw7W.mjs → runtime-C6_pOPmL.mjs} +198 -47
- package/dist/runtime-C6_pOPmL.mjs.map +1 -0
- package/dist/runtime.d.mts +29 -47
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/{from-BCscBQ9P.mjs → src-85HOaW5W.mjs} +1185 -10
- package/dist/src-85HOaW5W.mjs.map +1 -0
- package/package.json +28 -21
- package/dist/compatibility-DVMqXJux.mjs.map +0 -1
- package/dist/completionchunk-Dhk56lZl.mjs +0 -5212
- package/dist/completionchunk-Dhk56lZl.mjs.map +0 -1
- package/dist/credentials-oauth-Didpkkjx.mjs.map +0 -1
- package/dist/from-BCscBQ9P.mjs.map +0 -1
- package/dist/mcp-config-jmzbgdHa.mjs +0 -181
- package/dist/mcp-config-jmzbgdHa.mjs.map +0 -1
- package/dist/mistral-conversations-DJyeTo8C.mjs.map +0 -1
- package/dist/openai-responses-BRdGpBX6.mjs +0 -251
- package/dist/openai-responses-BRdGpBX6.mjs.map +0 -1
- package/dist/pi-ai-DpqiLdPA.mjs.map +0 -1
- package/dist/runtime-BlbKWw7W.mjs.map +0 -1
- package/dist/src-DlTagfW5.mjs +0 -1186
- package/dist/src-DlTagfW5.mjs.map +0 -1
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["// The analyzer (which pulls the 23 MB typescript compiler, an optional peer)\n// loads lazily inside its own command only — `matrix` and `mcp-config` must\n// run on an install without typescript.\nimport { writeFileSync } from 'node:fs'\nimport { parseArgs } from 'node:util'\nimport { API_RULES, CONTEXT_RULES, EVENT_RULES, HOST_IMPORT_RULES, UI_CONTEXT_RULES } from './compatibility.js'\nimport { convertPiMcpConfig, renderMcpPatch } from './mcp-config.js'\nimport { resolvePiPackage } from './source.js'\nimport type { CompatibilityReport } from './types.js'\n\nfunction usage(): string {\n return `pi2dsh — migrate Pi packages to DeepSeek Harness\\n\\n`\n + `Usage:\\n`\n + ` pi2dsh inspect <package-or-path> [--json]\\n`\n + ` pi2dsh mcp-config [--cwd <dir>] [--out <file>] [--json]\\n`\n + ` pi2dsh matrix [--json]\\n\\n`\n + `Installing is dsh's own job — \\`dsh plugin add pi2dsh\\`, then\\n`\n + `\\`dsh plugin add <pi package>\\`. This CLI only inspects.\\n\\n`\n + `mcp-config reads Pi's standard mcpServers files (six-layer precedence)\\n`\n + `and emits DSH cordis.patch.yml entries for the official dsh-mcp-client —\\n`\n + `Pi's MCP adapter code is never executed.\\n`\n}\n\nfunction reportText(report: CompatibilityReport): string {\n const lines = [\n `${report.package.name}@${report.package.version}: ${report.verdict.toUpperCase()}`,\n `full=${report.summary.full} partial=${report.summary.partial} unsupported=${report.summary.unsupported}`,\n `extensions=${report.resources.extensions.length} skills=${report.resources.skills.length} prompts=${report.resources.prompts.length} themes=${report.resources.themes.length}`,\n ]\n for (const finding of report.findings) {\n lines.push(`${finding.level.toUpperCase().padEnd(11)} ${finding.file}:${finding.line} ${finding.capability} — ${finding.detail}`)\n }\n return lines.join('\\n')\n}\n\nfunction matrix(json: boolean): void {\n const value = {\n api: API_RULES,\n events: EVENT_RULES,\n context: CONTEXT_RULES,\n uiContext: UI_CONTEXT_RULES,\n hostImports: HOST_IMPORT_RULES,\n }\n if (json) console.log(JSON.stringify(value, null, 2))\n else {\n for (const [kind, rules] of Object.entries(value)) {\n console.log(`${kind}:`)\n for (const [name, candidate] of Object.entries(rules)) {\n if ('level' in candidate && 'detail' in candidate) {\n console.log(` ${candidate.level.padEnd(11)} ${name} — ${candidate.detail}`)\n } else {\n const hostRules = candidate as Readonly<Record<string, { level: string; detail: string }>>\n for (const [exportName, hostRule] of Object.entries(hostRules)) {\n console.log(` ${hostRule.level.padEnd(11)} ${name}:${exportName} — ${hostRule.detail}`)\n }\n }\n }\n }\n }\n}\n\nasync function main(): Promise<void> {\n const parsed = parseArgs({\n allowPositionals: true,\n strict: true,\n options: {\n json: { type: 'boolean', default: false },\n out: { type: 'string' },\n cwd: { type: 'string' },\n help: { type: 'boolean', short: 'h', default: false },\n },\n })\n const [command, source] = parsed.positionals\n if (parsed.values.help || command === undefined) {\n console.log(usage())\n return\n }\n if (command === 'matrix') {\n matrix(parsed.values.json)\n return\n }\n if (command === 'mcp-config') {\n const result = convertPiMcpConfig(parsed.values.cwd ?? process.cwd())\n for (const warning of result.warnings) {\n console.error(`warning: ${warning.server}: ${warning.message}`)\n }\n const output = parsed.values.json ? `${JSON.stringify(result, null, 2)}\\n` : renderMcpPatch(result)\n if (parsed.values.out === undefined) process.stdout.write(output)\n else {\n writeFileSync(parsed.values.out, output)\n console.error(`wrote ${result.entries.length} MCP server entr${result.entries.length === 1 ? 'y' : 'ies'} from ${result.sources.length} Pi config file(s) to ${parsed.values.out}`)\n }\n return\n }\n if (command !== 'inspect' || source === undefined) {\n throw new Error(`invalid command\\n\\n${usage()}`)\n }\n\n const pkg = await resolvePiPackage(source)\n try {\n const { analyzePackage } = await import('./analyzer.js')\n const report = await analyzePackage(pkg)\n console.log(parsed.values.json ? JSON.stringify(report, null, 2) : reportText(report))\n if (report.verdict === 'blocked') process.exitCode = 2\n } finally {\n await pkg.dispose()\n }\n}\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error))\n process.exitCode = 1\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["// The analyzer (which pulls the 23 MB typescript compiler, an optional peer)\n// loads lazily inside its own command only — `matrix` and `mcp-config` must\n// run on an install without typescript.\nimport { writeFileSync } from 'node:fs'\nimport { parseArgs } from 'node:util'\nimport { API_RULES, CONTEXT_RULES, EVENT_RULES, HOST_IMPORT_RULES, UI_CONTEXT_RULES } from './compatibility.js'\nimport { convertPiMcpConfig, renderMcpPatch } from './mcp-config.js'\nimport { resolvePiPackage } from './source.js'\nimport type { CompatibilityReport } from './types.js'\n\nfunction usage(): string {\n return `pi2dsh — migrate Pi packages to DeepSeek Harness\\n\\n`\n + `Usage:\\n`\n + ` pi2dsh inspect <package-or-path> [--json]\\n`\n + ` pi2dsh mcp-config [--cwd <dir>] [--out <file>] [--json]\\n`\n + ` pi2dsh matrix [--json]\\n\\n`\n + `Installing is dsh's own job — \\`dsh plugin add pi2dsh\\`, then\\n`\n + `\\`dsh plugin add <pi package>\\`. This CLI only inspects.\\n\\n`\n + `mcp-config reads Pi's standard mcpServers files (six-layer precedence)\\n`\n + `and emits DSH cordis.patch.yml entries for the official dsh-mcp-client —\\n`\n + `Pi's MCP adapter code is never executed.\\n`\n}\n\nfunction reportText(report: CompatibilityReport): string {\n const lines = [\n `${report.package.name}@${report.package.version}: ${report.verdict.toUpperCase()}`,\n `full=${report.summary.full} partial=${report.summary.partial} unsupported=${report.summary.unsupported}`,\n `extensions=${report.resources.extensions.length} skills=${report.resources.skills.length} prompts=${report.resources.prompts.length} themes=${report.resources.themes.length}`,\n ]\n for (const finding of report.findings) {\n lines.push(`${finding.level.toUpperCase().padEnd(11)} ${finding.file}:${finding.line} ${finding.capability} — ${finding.detail}`)\n }\n return lines.join('\\n')\n}\n\nfunction matrix(json: boolean): void {\n const value = {\n api: API_RULES,\n events: EVENT_RULES,\n context: CONTEXT_RULES,\n uiContext: UI_CONTEXT_RULES,\n hostImports: HOST_IMPORT_RULES,\n }\n if (json) console.log(JSON.stringify(value, null, 2))\n else {\n for (const [kind, rules] of Object.entries(value)) {\n console.log(`${kind}:`)\n for (const [name, candidate] of Object.entries(rules)) {\n if ('level' in candidate && 'detail' in candidate) {\n console.log(` ${candidate.level.padEnd(11)} ${name} — ${candidate.detail}`)\n } else {\n const hostRules = candidate as Readonly<Record<string, { level: string; detail: string }>>\n for (const [exportName, hostRule] of Object.entries(hostRules)) {\n console.log(` ${hostRule.level.padEnd(11)} ${name}:${exportName} — ${hostRule.detail}`)\n }\n }\n }\n }\n }\n}\n\nasync function main(): Promise<void> {\n const parsed = parseArgs({\n allowPositionals: true,\n strict: true,\n options: {\n json: { type: 'boolean', default: false },\n out: { type: 'string' },\n cwd: { type: 'string' },\n help: { type: 'boolean', short: 'h', default: false },\n },\n })\n const [command, source] = parsed.positionals\n if (parsed.values.help || command === undefined) {\n console.log(usage())\n return\n }\n if (command === 'matrix') {\n matrix(parsed.values.json)\n return\n }\n if (command === 'mcp-config') {\n const result = convertPiMcpConfig(parsed.values.cwd ?? process.cwd())\n for (const warning of result.warnings) {\n console.error(`warning: ${warning.server}: ${warning.message}`)\n }\n const output = parsed.values.json ? `${JSON.stringify(result, null, 2)}\\n` : renderMcpPatch(result)\n if (parsed.values.out === undefined) process.stdout.write(output)\n else {\n writeFileSync(parsed.values.out, output)\n console.error(`wrote ${result.entries.length} MCP server entr${result.entries.length === 1 ? 'y' : 'ies'} from ${result.sources.length} Pi config file(s) to ${parsed.values.out}`)\n }\n return\n }\n if (command !== 'inspect' || source === undefined) {\n throw new Error(`invalid command\\n\\n${usage()}`)\n }\n\n const pkg = await resolvePiPackage(source)\n try {\n const { analyzePackage } = await import('./analyzer.js')\n const report = await analyzePackage(pkg)\n console.log(parsed.values.json ? JSON.stringify(report, null, 2) : reportText(report))\n if (report.verdict === 'blocked') process.exitCode = 2\n } finally {\n await pkg.dispose()\n }\n}\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error))\n process.exitCode = 1\n})\n"],"mappings":";;;;;;AAUA,SAAS,QAAgB;CACvB,OAAO;AAUT;AAEA,SAAS,WAAW,QAAqC;CACvD,MAAM,QAAQ;EACZ,GAAG,OAAO,QAAQ,KAAK,GAAG,OAAO,QAAQ,QAAQ,IAAI,OAAO,QAAQ,YAAY;EAChF,QAAQ,OAAO,QAAQ,KAAK,WAAW,OAAO,QAAQ,QAAQ,eAAe,OAAO,QAAQ;EAC5F,cAAc,OAAO,UAAU,WAAW,OAAO,UAAU,OAAO,UAAU,OAAO,OAAO,WAAW,OAAO,UAAU,QAAQ,OAAO,UAAU,OAAO,UAAU,OAAO;CACzK;CACA,KAAK,MAAM,WAAW,OAAO,UAC3B,MAAM,KAAK,GAAG,QAAQ,MAAM,YAAY,CAAC,CAAC,OAAO,EAAE,EAAE,GAAG,QAAQ,KAAK,GAAG,QAAQ,KAAK,GAAG,QAAQ,WAAW,KAAK,QAAQ,QAAQ;CAElI,OAAO,MAAM,KAAK,IAAI;AACxB;AAEA,SAAS,OAAO,MAAqB;CACnC,MAAM,QAAQ;EACZ,KAAK;EACL,QAAQ;EACR,SAAS;EACT,WAAW;EACX,aAAa;CACf;CACA,IAAI,MAAM,QAAQ,IAAI,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;MAElD,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAAK,GAAG;EACj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AAM;GACvC,QAAQ,MAAM,SAAS,OAAO,QAAQ,OAAO,kBAAkB,OAAO,QAAQ,WAAW,IAAI,MAAM,MAAM,QAAQ,OAAO,QAAQ,OAAO,wBAAwB,OAAO,OAAO,KAAK;EACpL;EACA;CACF;CACA,IAAI,YAAY,aAAa,WAAW,KAAA,GACtC,MAAM,IAAI,MAAM,sBAAsB,MAAM,GAAG;CAGjD,MAAM,MAAM,MAAM,iBAAiB,MAAM;CACzC,IAAI;EACF,MAAM,EAAE,mBAAmB,MAAM,OAAO;EACxC,MAAM,SAAS,MAAM,eAAe,GAAG;EACvC,QAAQ,IAAI,OAAO,OAAO,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC,IAAI,WAAW,MAAM,CAAC;EACrF,IAAI,OAAO,YAAY,WAAW,QAAQ,WAAW;CACvD,UAAU;EACR,MAAM,IAAI,QAAQ;CACpB;AACF;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE,QAAQ,WAAW;AACrB,CAAC"}
|
package/dist/compat/pi-ai.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
2
|
import { a as TextContent, c as ToolResultMessage, i as Message, l as Usage, n as AssistantMessage, o as ThinkingContent, r as ImageContent, s as ToolCallContent, t as AgentMessage, u as UserMessage } from "../pi-types-KazmR2O5.mjs";
|
|
3
|
-
import { $ as githubCopilotOAuth, A as getSupportedThinkingLevels, B as piMessagesApi, C as getBuiltinModel, D as getModels, E as getModel, F as modelsAreEqual, G as azureOpenAIResponsesApi, H as mistralConversationsApi, I as registerApiProvider, J as openAICompletionsApi, K as openAICodexResponsesApi, L as registerProvider, M as loadGitHubCopilotOAuth, N as loadKimiCodingOAuth, O as getProvider, P as loadOpenAICodexOAuth, Q as kimiCodingOAuth, R as stream, S as getApiProviders, T as getBuiltinProviders, U as googleVertexApi, V as bedrockConverseStreamApi, W as googleGenerativeAIApi, X as pollOAuthDeviceCodeFlow, Y as anthropicMessagesApi, Z as generatePKCE, _ as clampThinkingLevel, a as StringEnum, at as AssistantMessageEventStream, b as envApiKeyAuth, c as ThinkingLevel, ct as uuidv7, d as __createPiAiRuntimeRegistry, dt as isRecoverableLength, et as anthropicOAuth, f as __getPiAiLlmBridge, g as builtinProviders, h as __setPiAiLlmBridge, i as Static, it as lazyStream, j as loadAnthropicOAuth, k as getProviders, l as ThinkingLevelMap, lt as isRetryableAssistantError, m as __runWithPiAiRuntime, n as Model, nt as streamSimple, o as StringEnumOptions, ot as ModelsError, p as __runWithPiAiLlmBridge, q as openAIResponsesApi, r as ModelThinkingLevel, rt as lazyApi, s as TSchema, st as createProvider, t as Api, tt as openaiCodexOAuth, u as Type, ut as isContextOverflow, v as complete, w as getBuiltinModels, x as getApiProvider, y as contentText, z as unregisterApiProviders } from "../pi-ai-
|
|
3
|
+
import { $ as githubCopilotOAuth, A as getSupportedThinkingLevels, B as piMessagesApi, C as getBuiltinModel, D as getModels, E as getModel, F as modelsAreEqual, G as azureOpenAIResponsesApi, H as mistralConversationsApi, I as registerApiProvider, J as openAICompletionsApi, K as openAICodexResponsesApi, L as registerProvider, M as loadGitHubCopilotOAuth, N as loadKimiCodingOAuth, O as getProvider, P as loadOpenAICodexOAuth, Q as kimiCodingOAuth, R as stream, S as getApiProviders, T as getBuiltinProviders, U as googleVertexApi, V as bedrockConverseStreamApi, W as googleGenerativeAIApi, X as pollOAuthDeviceCodeFlow, Y as anthropicMessagesApi, Z as generatePKCE, _ as clampThinkingLevel, a as StringEnum, at as AssistantMessageEventStream, b as envApiKeyAuth, c as ThinkingLevel, ct as uuidv7, d as __createPiAiRuntimeRegistry, dt as isRecoverableLength, et as anthropicOAuth, f as __getPiAiLlmBridge, g as builtinProviders, h as __setPiAiLlmBridge, i as Static, it as lazyStream, j as loadAnthropicOAuth, k as getProviders, l as ThinkingLevelMap, lt as isRetryableAssistantError, m as __runWithPiAiRuntime, n as Model, nt as streamSimple, o as StringEnumOptions, ot as ModelsError, p as __runWithPiAiLlmBridge, q as openAIResponsesApi, r as ModelThinkingLevel, rt as lazyApi, s as TSchema, st as createProvider, t as Api, tt as openaiCodexOAuth, u as Type, ut as isContextOverflow, v as complete, w as getBuiltinModels, x as getApiProvider, y as contentText, z as unregisterApiProviders } from "../pi-ai-hGbYES_v.mjs";
|
|
4
4
|
export { type AgentMessage, Api, type AssistantMessage, AssistantMessageEventStream, type ImageContent, type Message, Model, ModelThinkingLevel, ModelsError, type Static, StringEnum, StringEnumOptions, type TSchema, type TextContent, type ThinkingContent, ThinkingLevel, ThinkingLevelMap, type ToolCallContent, type ToolResultMessage, Type, type Usage, type UserMessage, __createPiAiRuntimeRegistry, __getPiAiLlmBridge, __runWithPiAiLlmBridge, __runWithPiAiRuntime, __setPiAiLlmBridge, anthropicMessagesApi, anthropicOAuth, azureOpenAIResponsesApi, bedrockConverseStreamApi, builtinProviders, clampThinkingLevel, complete, contentText, createProvider, envApiKeyAuth, generatePKCE, getApiProvider, getApiProviders, getBuiltinModel, getBuiltinModels, getBuiltinProviders, getModel, getModels, getProvider, getProviders, getSupportedThinkingLevels, githubCopilotOAuth, googleGenerativeAIApi, googleVertexApi, isContextOverflow, isRecoverableLength, isRetryableAssistantError, kimiCodingOAuth, lazyApi, lazyStream, loadAnthropicOAuth, loadGitHubCopilotOAuth, loadKimiCodingOAuth, loadOpenAICodexOAuth, mistralConversationsApi, modelsAreEqual, openAICodexResponsesApi, openAICompletionsApi, openAIResponsesApi, openaiCodexOAuth, piMessagesApi, pollOAuthDeviceCodeFlow, registerApiProvider, registerProvider, stream, streamSimple as streamSimpleOpenAIResponses, unregisterApiProviders, uuidv7 };
|
package/dist/compat/pi-ai.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { $ as
|
|
3
|
-
import { n as streamSimple } from "../openai-responses-BRdGpBX6.mjs";
|
|
2
|
+
import { $ as AssistantMessageEventStream, A as stream, B as openAICompletionsApi, C as loadAnthropicOAuth, D as modelsAreEqual, E as loadOpenAICodexOAuth, F as googleVertexApi, G as openaiCodexOAuth, H as kimiCodingOAuth, I as googleGenerativeAIApi, J as streamSimple, K as generatePKCE, L as azureOpenAIResponsesApi, M as piMessagesApi, N as bedrockConverseStreamApi, O as registerApiProvider, P as mistralConversationsApi, Q as lazyStream, R as openAICodexResponsesApi, S as getSupportedThinkingLevels, T as loadKimiCodingOAuth, U as githubCopilotOAuth, V as anthropicMessagesApi, W as anthropicOAuth, X as createProvider, Y as ModelsError, Z as lazyApi, _ as getBuiltinProviders, a as __runWithPiAiLlmBridge, b as getProvider, c as builtinProviders, d as contentText, et as isContextOverflow, f as envApiKeyAuth, g as getBuiltinModels, h as getBuiltinModel, i as __getPiAiLlmBridge, it as uuidv7, j as unregisterApiProviders, k as registerProvider, l as clampThinkingLevel, m as getApiProviders, n as Type, nt as isRetryableAssistantError, o as __runWithPiAiRuntime, p as getApiProvider, q as pollOAuthDeviceCodeFlow, r as __createPiAiRuntimeRegistry, s as __setPiAiLlmBridge, t as StringEnum, tt as isRecoverableLength, u as complete, v as getModel, w as loadGitHubCopilotOAuth, x as getProviders, y as getModels, z as openAIResponsesApi } from "../pi-ai-DQPHUR9S.mjs";
|
|
4
3
|
export { AssistantMessageEventStream, ModelsError, StringEnum, Type, __createPiAiRuntimeRegistry, __getPiAiLlmBridge, __runWithPiAiLlmBridge, __runWithPiAiRuntime, __setPiAiLlmBridge, anthropicMessagesApi, anthropicOAuth, azureOpenAIResponsesApi, bedrockConverseStreamApi, builtinProviders, clampThinkingLevel, complete, contentText, createProvider, envApiKeyAuth, generatePKCE, getApiProvider, getApiProviders, getBuiltinModel, getBuiltinModels, getBuiltinProviders, getModel, getModels, getProvider, getProviders, getSupportedThinkingLevels, githubCopilotOAuth, googleGenerativeAIApi, googleVertexApi, isContextOverflow, isRecoverableLength, isRetryableAssistantError, kimiCodingOAuth, lazyApi, lazyStream, loadAnthropicOAuth, loadGitHubCopilotOAuth, loadKimiCodingOAuth, loadOpenAICodexOAuth, mistralConversationsApi, modelsAreEqual, openAICodexResponsesApi, openAICompletionsApi, openAIResponsesApi, openaiCodexOAuth, piMessagesApi, pollOAuthDeviceCodeFlow, registerApiProvider, registerProvider, stream, streamSimple as streamSimpleOpenAIResponses, unregisterApiProviders, uuidv7 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import { $ as isReadToolResult, $t as DEFAULT_MAX_LINES, A as createCodingTools, At as serializeConversation, B as getMarkdownTheme, Bt as createEditTool, C as VERSION, Cn as createCompactionSummaryMessage, Ct as collectEntriesForBranchSummary, D as convertToPng, Dt as getLastAssistantUsage, E as compact, Et as findTurnStartIndex, F as generateBranchSummary, Ft as createFindToolDefinition, G as getToolPath, Gt as bashToolSystemPromptContribution, H as getReadmePath, Ht as renderDiff, I as generateSummary, It as createGrepTool, J as isBashToolResult, Jt as createLocalBashOperations, K as highlightCode, Kt as createBashTool, L as generateSummaryWithUsage, Lt as createGrepToolDefinition, M as createReadOnlyTools, Mt as createLsTool, N as defineTool, Nt as createLsToolDefinition, O as copyToClipboard, Ot as prepareBranchEntries, P as ensureTool, Pt as createFindTool, Q as isLsToolResult, Qt as DEFAULT_MAX_BYTES, R as getBinDir, Rt as createWriteTool, S as UserMessageComponent, Sn as createBranchSummaryMessage, St as calculateContextTokens, T as __setSubagentSessionFactory, Tt as findCutPoint, U as getSelectListTheme, Ut as createReadTool, V as getPackageDir, Vt as createEditToolDefinition, W as getSettingsListTheme, Wt as createReadToolDefinition, X as isFindToolResult, Xt as createExtensionRuntime, Y as isEditToolResult, Yt as truncateToVisualLines, Z as isGrepToolResult, Zt as withFileMutationQueue, _ as ModelRuntime, _n as BRANCH_SUMMARY_SUFFIX, _t as wrapToolDefinition, a as CustomMessageComponent, an as SessionManager, at as processImage, b as Theme, bn as bashExecutionToText, bt as stripFrontmatter, c as DynamicBorder, cn as buildSessionContext, ct as resizeImage, d as ExtensionRunner, dn as getLatestCompactionEntry, dt as formatSkillsForPrompt, en as formatSize, et as isToolCallEventType, f as ExtensionSelectorComponent, fn as loadEntriesFromFile, ft as loadSkills, g as ModelRegistry, gn as BRANCH_SUMMARY_PREFIX, gt as wrapRegisteredTools, h as InMemorySettingsStorage, hn as sessionEntryToContextMessages, ht as wrapRegisteredTool, i as CustomEditor, in as CURRENT_SESSION_VERSION, it as parseSkillBlock, j as createEventBus, jt as shouldCompact, k as createAgentSession, kt as prepareCompaction, l as ExtensionEditorComponent, ln as findMostRecentSession, lt as theme, m as FooterComponent, mn as parseSessionEntries, mt as ProjectTrustStore, n as BorderedLoader, nn as truncateLine, nt as keyHint, o as DefaultPackageManager, on as assertValidSessionId, ot as rawKeyHint, p as FileSettingsStorage, pn as migrateSessionEntries, pt as loadSkillsFromDir, q as initTheme, qt as createBashToolDefinition, r as CONFIG_DIR_NAME, rn as truncateTail, rt as keyText, s as DefaultResourceLoader, sn as buildContextEntries, st as readStoredCredential, t as AssistantMessageComponent, tn as truncateHead, tt as isWriteToolResult, u as ExtensionInputComponent, un as getDefaultSessionDir, ut as getShellConfig, v as SettingsManager, vn as COMPACTION_SUMMARY_PREFIX, vt as wrapToolDefinitions, w as __runWithSubagentSessionFactory, wn as createCustomMessage, wt as estimateTokens, x as ToolExecutionComponent, xn as convertToLlm, xt as DEFAULT_COMPACTION_SETTINGS, y as SettingsSelectorComponent, yn as COMPACTION_SUMMARY_SUFFIX, yt as parseFrontmatter, z as getLanguageFromPath, zt as createWriteToolDefinition } from "../pi-coding-agent-
|
|
2
|
+
import { $ as isReadToolResult, $t as DEFAULT_MAX_LINES, A as createCodingTools, At as serializeConversation, B as getMarkdownTheme, Bt as createEditTool, C as VERSION, Cn as createCompactionSummaryMessage, Ct as collectEntriesForBranchSummary, D as convertToPng, Dt as getLastAssistantUsage, E as compact, Et as findTurnStartIndex, F as generateBranchSummary, Ft as createFindToolDefinition, G as getToolPath, Gt as bashToolSystemPromptContribution, H as getReadmePath, Ht as renderDiff, I as generateSummary, It as createGrepTool, J as isBashToolResult, Jt as createLocalBashOperations, K as highlightCode, Kt as createBashTool, L as generateSummaryWithUsage, Lt as createGrepToolDefinition, M as createReadOnlyTools, Mt as createLsTool, N as defineTool, Nt as createLsToolDefinition, O as copyToClipboard, Ot as prepareBranchEntries, P as ensureTool, Pt as createFindTool, Q as isLsToolResult, Qt as DEFAULT_MAX_BYTES, R as getBinDir, Rt as createWriteTool, S as UserMessageComponent, Sn as createBranchSummaryMessage, St as calculateContextTokens, T as __setSubagentSessionFactory, Tt as findCutPoint, U as getSelectListTheme, Ut as createReadTool, V as getPackageDir, Vt as createEditToolDefinition, W as getSettingsListTheme, Wt as createReadToolDefinition, X as isFindToolResult, Xt as createExtensionRuntime, Y as isEditToolResult, Yt as truncateToVisualLines, Z as isGrepToolResult, Zt as withFileMutationQueue, _ as ModelRuntime, _n as BRANCH_SUMMARY_SUFFIX, _t as wrapToolDefinition, a as CustomMessageComponent, an as SessionManager, at as processImage, b as Theme, bn as bashExecutionToText, bt as stripFrontmatter, c as DynamicBorder, cn as buildSessionContext, ct as resizeImage, d as ExtensionRunner, dn as getLatestCompactionEntry, dt as formatSkillsForPrompt, en as formatSize, et as isToolCallEventType, f as ExtensionSelectorComponent, fn as loadEntriesFromFile, ft as loadSkills, g as ModelRegistry, gn as BRANCH_SUMMARY_PREFIX, gt as wrapRegisteredTools, h as InMemorySettingsStorage, hn as sessionEntryToContextMessages, ht as wrapRegisteredTool, i as CustomEditor, in as CURRENT_SESSION_VERSION, it as parseSkillBlock, j as createEventBus, jt as shouldCompact, k as createAgentSession, kt as prepareCompaction, l as ExtensionEditorComponent, ln as findMostRecentSession, lt as theme, m as FooterComponent, mn as parseSessionEntries, mt as ProjectTrustStore, n as BorderedLoader, nn as truncateLine, nt as keyHint, o as DefaultPackageManager, on as assertValidSessionId, ot as rawKeyHint, p as FileSettingsStorage, pn as migrateSessionEntries, pt as loadSkillsFromDir, q as initTheme, qt as createBashToolDefinition, r as CONFIG_DIR_NAME, rn as truncateTail, rt as keyText, s as DefaultResourceLoader, sn as buildContextEntries, st as readStoredCredential, t as AssistantMessageComponent, tn as truncateHead, tt as isWriteToolResult, u as ExtensionInputComponent, un as getDefaultSessionDir, ut as getShellConfig, v as SettingsManager, vn as COMPACTION_SUMMARY_PREFIX, vt as wrapToolDefinitions, w as __runWithSubagentSessionFactory, wn as createCustomMessage, wt as estimateTokens, x as ToolExecutionComponent, xn as convertToLlm, xt as DEFAULT_COMPACTION_SETTINGS, y as SettingsSelectorComponent, yn as COMPACTION_SUMMARY_SUFFIX, yt as parseFrontmatter, z as getLanguageFromPath, zt as createWriteToolDefinition } from "../pi-coding-agent-f3_hNCpd.mjs";
|
|
3
3
|
import { t as getAgentDir } from "../pi-config-shim-CZ1wFzqM.mjs";
|
|
4
4
|
export { AssistantMessageComponent, BRANCH_SUMMARY_PREFIX, BRANCH_SUMMARY_SUFFIX, BorderedLoader, COMPACTION_SUMMARY_PREFIX, COMPACTION_SUMMARY_SUFFIX, CONFIG_DIR_NAME, CURRENT_SESSION_VERSION, CustomEditor, CustomMessageComponent, DEFAULT_COMPACTION_SETTINGS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DefaultPackageManager, DefaultResourceLoader, DynamicBorder, ExtensionEditorComponent, ExtensionInputComponent, ExtensionRunner, ExtensionSelectorComponent, FileSettingsStorage, FooterComponent, InMemorySettingsStorage, ModelRegistry, ModelRuntime, ProjectTrustStore, SessionManager, SettingsManager, SettingsSelectorComponent, Theme, ToolExecutionComponent, UserMessageComponent, VERSION, __runWithSubagentSessionFactory, __setSubagentSessionFactory, assertValidSessionId, bashExecutionToText, bashToolSystemPromptContribution, buildContextEntries, buildSessionContext, calculateContextTokens, collectEntriesForBranchSummary, compact, convertToLlm, convertToPng, copyToClipboard, createAgentSession, createBashTool, createBashToolDefinition, createBranchSummaryMessage, createCodingTools, createCompactionSummaryMessage, createCustomMessage, createEditTool, createEditToolDefinition, createEventBus, createExtensionRuntime, createFindTool, createFindToolDefinition, createGrepTool, createGrepToolDefinition, createLocalBashOperations, createLsTool, createLsToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, defineTool, ensureTool, estimateTokens, findCutPoint, findMostRecentSession, findTurnStartIndex, formatSize, formatSkillsForPrompt, generateBranchSummary, generateSummary, generateSummaryWithUsage, getAgentDir, getBinDir, getDefaultSessionDir, getLanguageFromPath, getLastAssistantUsage, getLatestCompactionEntry, getMarkdownTheme, getPackageDir, getReadmePath, getSelectListTheme, getSettingsListTheme, getShellConfig, getToolPath, highlightCode, initTheme, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, keyHint, keyText, loadEntriesFromFile, loadSkills, loadSkillsFromDir, migrateSessionEntries, parseFrontmatter, parseSessionEntries, parseSkillBlock, prepareBranchEntries, prepareCompaction, processImage, rawKeyHint, readStoredCredential, renderDiff, resizeImage, serializeConversation, sessionEntryToContextMessages, shouldCompact, stripFrontmatter, theme, truncateHead, truncateLine, truncateTail, truncateToVisualLines, withFileMutationQueue, wrapRegisteredTool, wrapRegisteredTools, wrapToolDefinition, wrapToolDefinitions };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { n as oauthCredentialRef } from "./oauth-bridge-hOnT3acY.mjs";
|
|
3
|
+
import { CredentialInfo, CredentialKey, CredentialProvider, CredentialRecord, CredentialRecordEntry, CredentialRecordInfo, CredentialRef, ResolvedCredential } from "@deepseek-ai/dsh-credentials";
|
|
3
4
|
import { Context } from "@deepseek-ai/cordis";
|
|
4
5
|
//#region src/credentials-oauth.d.ts
|
|
5
6
|
type UnknownRecord = Record<string, unknown>;
|
|
6
|
-
declare function oauthCredentialRef(providerId: string): string;
|
|
7
7
|
interface PiOAuthCredentialProviderOptions {
|
|
8
8
|
/** Path to the Pi-format auth.json; defaults to `$agentDir/auth.json`. */
|
|
9
9
|
authPath?: string;
|
|
@@ -19,6 +19,12 @@ declare class PiOAuthCredentialProvider extends CredentialProvider {
|
|
|
19
19
|
describe(ref: CredentialRef): Promise<CredentialInfo>;
|
|
20
20
|
set(ref: CredentialRef, _value: string): Promise<void>;
|
|
21
21
|
unset(ref: CredentialRef): Promise<void>;
|
|
22
|
+
private recordProviderId;
|
|
23
|
+
readRecord(key: CredentialKey): Promise<CredentialRecord | undefined>;
|
|
24
|
+
describeRecord(key: CredentialKey): Promise<CredentialRecordInfo>;
|
|
25
|
+
listRecords(): Promise<readonly CredentialRecordEntry[]>;
|
|
26
|
+
modifyRecord(key: CredentialKey, mutate: (current: CredentialRecord | undefined) => Promise<CredentialRecord | undefined>): Promise<CredentialRecord | undefined>;
|
|
27
|
+
deleteRecord(key: CredentialKey): Promise<void>;
|
|
22
28
|
}
|
|
23
29
|
declare const name = "pi2dsh-credentials-oauth";
|
|
24
30
|
declare function apply(ctx: Context, config?: PiOAuthCredentialProviderOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials-oauth.d.mts","names":[],"sources":["../src/credentials-oauth.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"credentials-oauth.d.mts","names":[],"sources":["../src/credentials-oauth.ts"],"mappings":";;;;;KAOK,gBAAgB;UAmBJ;;EAEf;;EAEA,YAAY,oBAAoB;;cAGrB,kCAAkC;mBAC5B;mBACA;EAEL,YAAA,KAAK,SAAS,UAAS;UAM3B;EAQF,QAAQ,KAAK,gBAAgB,QAAQ;EAiBrC,SAAS,KAAK,gBAAgB,QAAQ;EAUtC,IAAI,KAAK,eAAe,iBAAiB;EAIzC,MAAM,KAAK,gBAAgB;UAgBzB;EAKF,WAAW,KAAK,gBAAgB,QAAQ;EAQxC,eAAe,KAAK,gBAAgB,QAAQ;EAK5C,eAAe,iBAAiB;EAchC,aACJ,KAAK,eACL,SAAS,SAAS,iCAAiC,QAAQ,gCAC1D,QAAQ;EAcL,aAAa,KAAK,gBAAgB;;cAQ7B;iBAEG,MAAM,KAAK,SAAS,SAAQ"}
|
|
@@ -1,3 +1,136 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
2
|
+
import "./pi-coding-agent-f3_hNCpd.mjs";
|
|
3
|
+
import { t as getAgentDir } from "./pi-config-shim-CZ1wFzqM.mjs";
|
|
4
|
+
import { c as builtinProviders } from "./pi-ai-DQPHUR9S.mjs";
|
|
5
|
+
import { a as providerIdOfOAuthRef, i as oauthCredentialRef, l as storedOAuthCredential, o as providerSupportsOAuth, s as resolveOAuthApiKey, t as FileCredentialStore } from "./oauth-bridge-C_MAPMGA.mjs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { CredentialProvider } from "@deepseek-ai/dsh-credentials";
|
|
8
|
+
//#region src/credentials-oauth.ts
|
|
9
|
+
const providerIdOfRef = providerIdOfOAuthRef;
|
|
10
|
+
var PiOAuthCredentialProvider = class extends CredentialProvider {
|
|
11
|
+
oauthStore;
|
|
12
|
+
extraProviders;
|
|
13
|
+
constructor(ctx, options = {}) {
|
|
14
|
+
super(ctx);
|
|
15
|
+
this.oauthStore = new FileCredentialStore(options.authPath ?? join(getAgentDir(), "auth.json"));
|
|
16
|
+
this.extraProviders = options.providers ?? /* @__PURE__ */ new Map();
|
|
17
|
+
}
|
|
18
|
+
oauthConfigFor(providerId) {
|
|
19
|
+
const registered = this.extraProviders.get(providerId);
|
|
20
|
+
if (providerSupportsOAuth(registered)) return registered;
|
|
21
|
+
const builtin = builtinProviders().find((provider) => provider.id === providerId);
|
|
22
|
+
if (builtin === void 0) return void 0;
|
|
23
|
+
return {
|
|
24
|
+
name: builtin.name,
|
|
25
|
+
baseUrl: builtin.baseUrl,
|
|
26
|
+
oauth: builtin.auth.oauth
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async resolve(ref) {
|
|
30
|
+
const providerId = providerIdOfRef(String(ref));
|
|
31
|
+
if (providerId === void 0) {
|
|
32
|
+
const value = process.env[String(ref)];
|
|
33
|
+
return value !== void 0 && value.length > 0 ? {
|
|
34
|
+
value,
|
|
35
|
+
source: "env"
|
|
36
|
+
} : void 0;
|
|
37
|
+
}
|
|
38
|
+
const config = this.oauthConfigFor(providerId);
|
|
39
|
+
if (config === void 0) return void 0;
|
|
40
|
+
const value = await resolveOAuthApiKey({
|
|
41
|
+
providerId,
|
|
42
|
+
providerName: typeof config.name === "string" ? config.name : providerId,
|
|
43
|
+
providerConfig: config,
|
|
44
|
+
store: this.oauthStore
|
|
45
|
+
});
|
|
46
|
+
return value !== void 0 && value.length > 0 ? {
|
|
47
|
+
value,
|
|
48
|
+
source: "pi-oauth"
|
|
49
|
+
} : void 0;
|
|
50
|
+
}
|
|
51
|
+
async describe(ref) {
|
|
52
|
+
const providerId = providerIdOfRef(String(ref));
|
|
53
|
+
if (providerId === void 0) {
|
|
54
|
+
const value = process.env[String(ref)];
|
|
55
|
+
return {
|
|
56
|
+
configured: value !== void 0 && value.length > 0,
|
|
57
|
+
...value ? { source: "env" } : {},
|
|
58
|
+
writable: false
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const stored = await storedOAuthCredential(this.oauthStore, providerId);
|
|
62
|
+
return {
|
|
63
|
+
configured: stored !== void 0,
|
|
64
|
+
...stored !== void 0 ? { source: "pi-oauth" } : {},
|
|
65
|
+
writable: false
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async set(ref, _value) {
|
|
69
|
+
throw new Error(`credential ${String(ref)} is read-only here: OAuth tokens are managed by /login, environment values by the shell`);
|
|
70
|
+
}
|
|
71
|
+
async unset(ref) {
|
|
72
|
+
const providerId = providerIdOfRef(String(ref));
|
|
73
|
+
if (providerId === void 0) throw new Error(`credential ${String(ref)} is read-only here: environment values are managed by the shell`);
|
|
74
|
+
await this.oauthStore.delete(providerId, void 0);
|
|
75
|
+
}
|
|
76
|
+
recordProviderId(key) {
|
|
77
|
+
const value = String(key);
|
|
78
|
+
return value.startsWith("pi2dsh/") ? value.slice(7) : void 0;
|
|
79
|
+
}
|
|
80
|
+
async readRecord(key) {
|
|
81
|
+
const providerId = this.recordProviderId(key);
|
|
82
|
+
if (providerId === void 0) return void 0;
|
|
83
|
+
if (await storedOAuthCredential(this.oauthStore, providerId) === void 0) return void 0;
|
|
84
|
+
return {
|
|
85
|
+
kind: "grant",
|
|
86
|
+
payload: {
|
|
87
|
+
provider: providerId,
|
|
88
|
+
managedBy: "pi2dsh"
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async describeRecord(key) {
|
|
93
|
+
const record = await this.readRecord(key);
|
|
94
|
+
return {
|
|
95
|
+
configured: record !== void 0,
|
|
96
|
+
...record === void 0 ? {} : { kind: "grant" },
|
|
97
|
+
writable: true
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async listRecords() {
|
|
101
|
+
const entries = [];
|
|
102
|
+
const seen = /* @__PURE__ */ new Set();
|
|
103
|
+
const ids = [...this.extraProviders.keys(), ...builtinProviders().map((provider) => provider.id)];
|
|
104
|
+
for (const providerId of ids) {
|
|
105
|
+
if (seen.has(providerId)) continue;
|
|
106
|
+
seen.add(providerId);
|
|
107
|
+
if (await storedOAuthCredential(this.oauthStore, providerId) !== void 0) entries.push({
|
|
108
|
+
key: `pi2dsh/${providerId}`,
|
|
109
|
+
kind: "grant"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return entries;
|
|
113
|
+
}
|
|
114
|
+
async modifyRecord(key, mutate) {
|
|
115
|
+
const providerId = this.recordProviderId(key);
|
|
116
|
+
if (providerId === void 0) throw new Error(`credential record ${String(key)} is not managed by this provider`);
|
|
117
|
+
const next = await mutate(await this.readRecord(key));
|
|
118
|
+
if (next === void 0) await this.oauthStore.delete(providerId, void 0);
|
|
119
|
+
this.notifyRecordUpdated?.(key);
|
|
120
|
+
return next;
|
|
121
|
+
}
|
|
122
|
+
async deleteRecord(key) {
|
|
123
|
+
const providerId = this.recordProviderId(key);
|
|
124
|
+
if (providerId === void 0) return;
|
|
125
|
+
await this.oauthStore.delete(providerId, void 0);
|
|
126
|
+
this.notifyRecordUpdated?.(key);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const name = "pi2dsh-credentials-oauth";
|
|
130
|
+
function apply(ctx, config = {}) {
|
|
131
|
+
new PiOAuthCredentialProvider(ctx, config);
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
3
134
|
export { PiOAuthCredentialProvider, apply, name, oauthCredentialRef };
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=credentials-oauth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials-oauth.mjs","names":[],"sources":["../src/credentials-oauth.ts"],"sourcesContent":["import { join } from 'node:path'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { CredentialProvider, type CredentialInfo, type CredentialKey, type CredentialRecord, type CredentialRecordEntry, type CredentialRecordInfo, type CredentialRef, type ResolvedCredential } from '@deepseek-ai/dsh-credentials'\nimport { FileCredentialStore, oauthCredentialRef, providerIdOfOAuthRef, providerSupportsOAuth, resolveOAuthApiKey, storedOAuthCredential } from './oauth-bridge.js'\nimport { builtinProviders } from './compat/pi-ai.js'\nimport { getAgentDir } from './compat/pi-coding-agent.js'\n\ntype UnknownRecord = Record<string, unknown>\n\n// L4 of the OAuth host seam: a standard dsh-credentials provider that serves\n// Pi OAuth tokens to DSH's native LLM request path. A route configured as\n// `apiKeyEnv: PI2DSH_OAUTH_OPENAI_CODEX` resolves per request through this\n// provider — Pi's double-checked-lock refresh runs on every resolution, so a\n// rotated token reaches the next model call with no restart, exactly the\n// per-operation semantics the credentials seam demands. Every other reference\n// falls through to the process environment, so one provider instance serves a\n// whole composition.\n//\n// Reference convention: PI2DSH_OAUTH_<PROVIDER_ID> where the provider id is\n// upper-cased with `-` as `_` (openai-codex → PI2DSH_OAUTH_OPENAI_CODEX).\n// The helpers live in oauth-bridge (see the note there); re-exported here so\n// this module's public surface is unchanged.\n\nexport { oauthCredentialRef } from './oauth-bridge.js'\nconst providerIdOfRef = providerIdOfOAuthRef\n\nexport interface PiOAuthCredentialProviderOptions {\n /** Path to the Pi-format auth.json; defaults to `$agentDir/auth.json`. */\n authPath?: string\n /** Additional provider configs (id → config with an oauth block), e.g. from packages that registered providers. */\n providers?: ReadonlyMap<string, UnknownRecord>\n}\n\nexport class PiOAuthCredentialProvider extends CredentialProvider {\n private readonly oauthStore: FileCredentialStore\n private readonly extraProviders: ReadonlyMap<string, UnknownRecord>\n\n constructor(ctx: Context, options: PiOAuthCredentialProviderOptions = {}) {\n super(ctx)\n this.oauthStore = new FileCredentialStore(options.authPath ?? join(getAgentDir(), 'auth.json'))\n this.extraProviders = options.providers ?? new Map()\n }\n\n private oauthConfigFor(providerId: string): UnknownRecord | undefined {\n const registered = this.extraProviders.get(providerId)\n if (providerSupportsOAuth(registered)) return registered\n const builtin = builtinProviders().find(provider => provider.id === providerId)\n if (builtin === undefined) return undefined\n return { name: builtin.name, baseUrl: builtin.baseUrl, oauth: builtin.auth.oauth }\n }\n\n async resolve(ref: CredentialRef): Promise<ResolvedCredential | undefined> {\n const providerId = providerIdOfRef(String(ref))\n if (providerId === undefined) {\n const value = process.env[String(ref)]\n return value !== undefined && value.length > 0 ? { value, source: 'env' } : undefined\n }\n const config = this.oauthConfigFor(providerId)\n if (config === undefined) return undefined\n const value = await resolveOAuthApiKey({\n providerId,\n providerName: typeof config.name === 'string' ? config.name : providerId,\n providerConfig: config,\n store: this.oauthStore,\n })\n return value !== undefined && value.length > 0 ? { value, source: 'pi-oauth' } : undefined\n }\n\n async describe(ref: CredentialRef): Promise<CredentialInfo> {\n const providerId = providerIdOfRef(String(ref))\n if (providerId === undefined) {\n const value = process.env[String(ref)]\n return { configured: value !== undefined && value.length > 0, ...(value ? { source: 'env' } : {}), writable: false }\n }\n const stored = await storedOAuthCredential(this.oauthStore, providerId)\n return { configured: stored !== undefined, ...(stored !== undefined ? { source: 'pi-oauth' } : {}), writable: false }\n }\n\n async set(ref: CredentialRef, _value: string): Promise<void> {\n throw new Error(`credential ${String(ref)} is read-only here: OAuth tokens are managed by /login, environment values by the shell`)\n }\n\n async unset(ref: CredentialRef): Promise<void> {\n const providerId = providerIdOfRef(String(ref))\n if (providerId === undefined) {\n throw new Error(`credential ${String(ref)} is read-only here: environment values are managed by the shell`)\n }\n // Logging out is a legitimate unset: drop the stored token.\n await this.oauthStore.delete(providerId, undefined)\n }\n\n // ---- credential records (0.1.1-line abstract members) --------------------\n // The record space projects the SAME Pi-format store: a `pi2dsh/<provider>`\n // key answers for that provider's stored OAuth login. Grant payloads never\n // carry the token itself — resolution stays per-request through resolve().\n // On the rc.8 line the base class has no record members and these concrete\n // methods are simply extra.\n\n private recordProviderId(key: unknown): string | undefined {\n const value = String(key)\n return value.startsWith('pi2dsh/') ? value.slice('pi2dsh/'.length) : undefined\n }\n\n async readRecord(key: CredentialKey): Promise<CredentialRecord | undefined> {\n const providerId = this.recordProviderId(key)\n if (providerId === undefined) return undefined\n const stored = await storedOAuthCredential(this.oauthStore, providerId)\n if (stored === undefined) return undefined\n return { kind: 'grant', payload: { provider: providerId, managedBy: 'pi2dsh' } }\n }\n\n async describeRecord(key: CredentialKey): Promise<CredentialRecordInfo> {\n const record = await this.readRecord(key)\n return { configured: record !== undefined, ...(record === undefined ? {} : { kind: 'grant' as const }), writable: true }\n }\n\n async listRecords(): Promise<readonly CredentialRecordEntry[]> {\n const entries: CredentialRecordEntry[] = []\n const seen = new Set<string>()\n const ids = [...this.extraProviders.keys(), ...builtinProviders().map(provider => provider.id)]\n for (const providerId of ids) {\n if (seen.has(providerId)) continue\n seen.add(providerId)\n if (await storedOAuthCredential(this.oauthStore, providerId) !== undefined) {\n entries.push({ key: `pi2dsh/${providerId}` as CredentialKey, kind: 'grant' })\n }\n }\n return entries\n }\n\n async modifyRecord(\n key: CredentialKey,\n mutate: (current: CredentialRecord | undefined) => Promise<CredentialRecord | undefined>,\n ): Promise<CredentialRecord | undefined> {\n const providerId = this.recordProviderId(key)\n if (providerId === undefined) throw new Error(`credential record ${String(key)} is not managed by this provider`)\n const next = await mutate(await this.readRecord(key))\n if (next === undefined) {\n await this.oauthStore.delete(providerId, undefined)\n }\n // A written grant is a registration witness; the token itself is managed\n // by the login flow through the Pi store, so there is nothing to persist\n // beyond what the flow already committed.\n ;(this as unknown as { notifyRecordUpdated?(key: unknown): void }).notifyRecordUpdated?.(key)\n return next\n }\n\n async deleteRecord(key: CredentialKey): Promise<void> {\n const providerId = this.recordProviderId(key)\n if (providerId === undefined) return\n await this.oauthStore.delete(providerId, undefined)\n ;(this as unknown as { notifyRecordUpdated?(key: unknown): void }).notifyRecordUpdated?.(key)\n }\n}\n\nexport const name = 'pi2dsh-credentials-oauth'\n\nexport function apply(ctx: Context, config: PiOAuthCredentialProviderOptions = {}): void {\n // The Service constructor registers itself as ctx.credentials.\n void new PiOAuthCredentialProvider(ctx, config)\n}\n"],"mappings":";;;;;;;;AAwBA,MAAM,kBAAkB;AASxB,IAAa,4BAAb,cAA+C,mBAAmB;CAChE;CACA;CAEA,YAAY,KAAc,UAA4C,CAAC,GAAG;EACxE,MAAM,GAAG;EACT,KAAK,aAAa,IAAI,oBAAoB,QAAQ,YAAY,KAAK,YAAY,GAAG,WAAW,CAAC;EAC9F,KAAK,iBAAiB,QAAQ,6BAAa,IAAI,IAAI;CACrD;CAEA,eAAuB,YAA+C;EACpE,MAAM,aAAa,KAAK,eAAe,IAAI,UAAU;EACrD,IAAI,sBAAsB,UAAU,GAAG,OAAO;EAC9C,MAAM,UAAU,iBAAiB,CAAC,CAAC,MAAK,aAAY,SAAS,OAAO,UAAU;EAC9E,IAAI,YAAY,KAAA,GAAW,OAAO,KAAA;EAClC,OAAO;GAAE,MAAM,QAAQ;GAAM,SAAS,QAAQ;GAAS,OAAO,QAAQ,KAAK;EAAM;CACnF;CAEA,MAAM,QAAQ,KAA6D;EACzE,MAAM,aAAa,gBAAgB,OAAO,GAAG,CAAC;EAC9C,IAAI,eAAe,KAAA,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YAAY,KAAA,CAAS;EAKnD,KAAkE,sBAAsB,GAAG;EAC5F,OAAO;CACT;CAEA,MAAM,aAAa,KAAmC;EACpD,MAAM,aAAa,KAAK,iBAAiB,GAAG;EAC5C,IAAI,eAAe,KAAA,GAAW;EAC9B,MAAM,KAAK,WAAW,OAAO,YAAY,KAAA,CAAS;EACjD,KAAkE,sBAAsB,GAAG;CAC9F;AACF;AAEA,MAAa,OAAO;AAEpB,SAAgB,MAAM,KAAc,SAA2C,CAAC,GAAS;CAEvF,IAAS,0BAA0B,KAAK,MAAM;AAChD"}
|
|
@@ -3,7 +3,7 @@ import { t as AssistantMessageEventStream } from "./event-stream-QxN1yvIF.mjs";
|
|
|
3
3
|
import { m as clampThinkingLevel, p as calculateCost, r as buildBaseOptions, s as sanitizeSurrogates } from "./simple-options-B_GO8FDE.mjs";
|
|
4
4
|
import { n as normalizeProviderError, t as formatProviderError } from "./error-body-DKA3lknR.mjs";
|
|
5
5
|
import { n as providerHeadersToRecord } from "./headers-CPzZhJQn.mjs";
|
|
6
|
-
import { a as resolveGoogleFunctionCallingMode, c as supportsGoogleStrictToolSampling, i as mapStopReason, l as GoogleGenAI, n as convertTools, o as retainThoughtSignature, r as isThinkingPart, s as retryGoogleRequest, t as convertMessages } from "./google-shared-
|
|
6
|
+
import { a as resolveGoogleFunctionCallingMode, c as supportsGoogleStrictToolSampling, i as mapStopReason, l as GoogleGenAI, n as convertTools, o as retainThoughtSignature, r as isThinkingPart, s as retryGoogleRequest, t as convertMessages } from "./google-shared-CL1Za-ev.mjs";
|
|
7
7
|
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.84.1_ws@8.21.3_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js
|
|
8
8
|
let toolCallCounter = 0;
|
|
9
9
|
const stream = (model, context, options) => {
|
|
@@ -353,4 +353,4 @@ function getGoogleBudget(model, effort, customBudgets) {
|
|
|
353
353
|
//#endregion
|
|
354
354
|
export { stream, streamSimple };
|
|
355
355
|
|
|
356
|
-
//# sourceMappingURL=google-generative-ai-
|
|
356
|
+
//# sourceMappingURL=google-generative-ai-Dpb_X-Kt.mjs.map
|
package/dist/{google-generative-ai-2gCFYp-t.mjs.map → google-generative-ai-Dpb_X-Kt.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-generative-ai-2gCFYp-t.mjs","names":[],"sources":["../node_modules/.pnpm/@earendil-works+pi-ai@0.84.1_ws@8.21.3_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js"],"sourcesContent":["import { GoogleGenAI, } from \"@google/genai\";\nimport { calculateCost, clampThinkingLevel } from \"../models.js\";\nimport { formatProviderError, normalizeProviderError } from \"../utils/error-body.js\";\nimport { AssistantMessageEventStream } from \"../utils/event-stream.js\";\nimport { providerHeadersToRecord } from \"../utils/headers.js\";\nimport { sanitizeSurrogates } from \"../utils/sanitize-unicode.js\";\nimport { convertMessages, convertTools, isThinkingPart, mapStopReason, resolveGoogleFunctionCallingMode, retainThoughtSignature, retryGoogleRequest, supportsGoogleStrictToolSampling, } from \"./google-shared.js\";\nimport { buildBaseOptions } from \"./simple-options.js\";\n// Counter for generating unique tool call IDs\nlet toolCallCounter = 0;\nexport const stream = (model, context, options) => {\n const stream = new AssistantMessageEventStream();\n (async () => {\n const output = {\n role: \"assistant\",\n content: [],\n api: \"google-generative-ai\",\n provider: model.provider,\n model: model.id,\n usage: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n totalTokens: 0,\n cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n },\n stopReason: \"pending\",\n timestamp: Date.now(),\n };\n try {\n if (options?.fetch && options.fetch !== globalThis.fetch) {\n throw new Error(\"Custom fetch is not supported by the Google Generative AI adapter\");\n }\n const apiKey = options?.apiKey;\n if (!apiKey) {\n throw new Error(`No API key for provider: ${model.provider}`);\n }\n const client = createClient(model, apiKey, options?.headers);\n let params = buildParams(model, context, options);\n const nextParams = await options?.onPayload?.(params, model);\n if (nextParams !== undefined) {\n params = nextParams;\n }\n const googleStream = await retryGoogleRequest(() => client.models.generateContentStream(params), options);\n stream.push({ type: \"start\", partial: output });\n let currentBlock = null;\n const blocks = output.content;\n const blockIndex = () => blocks.length - 1;\n for await (const chunk of googleStream) {\n // @google/genai documents GenerateContentResponse.responseId as an output-only field\n // used to identify each response. Keep the first non-empty one from the stream.\n output.responseId ||= chunk.responseId;\n const candidate = chunk.candidates?.[0];\n if (candidate?.content?.parts) {\n for (const part of candidate.content.parts) {\n if (part.text !== undefined) {\n const isThinking = isThinkingPart(part);\n if (!currentBlock ||\n (isThinking && currentBlock.type !== \"thinking\") ||\n (!isThinking && currentBlock.type !== \"text\")) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blocks.length - 1,\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (isThinking) {\n currentBlock = { type: \"thinking\", thinking: \"\", thinkingSignature: undefined };\n output.content.push(currentBlock);\n stream.push({ type: \"thinking_start\", contentIndex: blockIndex(), partial: output });\n }\n else {\n currentBlock = { type: \"text\", text: \"\" };\n output.content.push(currentBlock);\n stream.push({ type: \"text_start\", contentIndex: blockIndex(), partial: output });\n }\n }\n if (currentBlock.type === \"thinking\") {\n currentBlock.thinking += part.text;\n currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);\n stream.push({\n type: \"thinking_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n else {\n currentBlock.text += part.text;\n currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);\n stream.push({\n type: \"text_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n }\n if (part.functionCall) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n currentBlock = null;\n }\n // Generate unique ID if not provided or if it's a duplicate\n const providedId = part.functionCall.id;\n const needsNewId = !providedId || output.content.some((b) => b.type === \"toolCall\" && b.id === providedId);\n const toolCallId = needsNewId\n ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}`\n : providedId;\n const toolCall = {\n type: \"toolCall\",\n id: toolCallId,\n name: part.functionCall.name || \"\",\n arguments: part.functionCall.args ?? {},\n ...(part.thoughtSignature && { thoughtSignature: part.thoughtSignature }),\n };\n output.content.push(toolCall);\n stream.push({ type: \"toolcall_start\", contentIndex: blockIndex(), partial: output });\n stream.push({\n type: \"toolcall_delta\",\n contentIndex: blockIndex(),\n delta: JSON.stringify(toolCall.arguments),\n partial: output,\n });\n stream.push({ type: \"toolcall_end\", contentIndex: blockIndex(), toolCall, partial: output });\n }\n }\n }\n if (candidate?.finishReason) {\n output.rawStopReason = candidate.finishReason;\n output.stopReason = mapStopReason(candidate.finishReason);\n if (output.content.some((b) => b.type === \"toolCall\")) {\n output.stopReason = \"toolUse\";\n }\n }\n if (chunk.usageMetadata) {\n output.usage = {\n input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),\n output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),\n cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,\n cacheWrite: 0,\n reasoning: chunk.usageMetadata.thoughtsTokenCount || 0,\n totalTokens: chunk.usageMetadata.totalTokenCount || 0,\n cost: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n total: 0,\n },\n };\n calculateCost(model, output.usage);\n }\n }\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (options?.signal?.aborted) {\n throw new Error(\"Request was aborted\");\n }\n if (output.stopReason === \"pending\") {\n throw new Error(\"Google stream ended without a finish reason\");\n }\n if (output.stopReason === \"aborted\" || output.stopReason === \"error\") {\n const errorMessage = output.rawStopReason\n ? `Provider stopped with: ${output.rawStopReason}`\n : \"An unknown error occurred\";\n throw new Error(errorMessage);\n }\n stream.push({ type: \"done\", reason: output.stopReason, message: output });\n stream.end();\n }\n catch (error) {\n // Remove internal index property used during streaming\n for (const block of output.content) {\n if (\"index\" in block) {\n delete block.index;\n }\n }\n output.stopReason = options?.signal?.aborted ? \"aborted\" : \"error\";\n output.errorMessage = formatProviderError(normalizeProviderError(error));\n stream.push({ type: \"error\", reason: output.stopReason, error: output });\n stream.end();\n }\n })();\n return stream;\n};\nexport const streamSimple = (model, context, options) => {\n const apiKey = options?.apiKey;\n if (!apiKey) {\n throw new Error(`No API key for provider: ${model.provider}`);\n }\n const base = buildBaseOptions(model, context, options, apiKey);\n if (!options?.reasoning) {\n return stream(model, context, { ...base, thinking: { enabled: false } });\n }\n const clampedReasoning = clampThinkingLevel(model, options.reasoning);\n const effort = (clampedReasoning === \"off\" ? \"high\" : clampedReasoning);\n const googleModel = model;\n if (isGemini3ProModel(googleModel) || isGemini3FlashModel(googleModel) || isGemma4Model(googleModel)) {\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n level: getThinkingLevel(effort, googleModel),\n },\n });\n }\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n budgetTokens: getGoogleBudget(googleModel, effort, options.thinkingBudgets),\n },\n });\n};\nfunction createClient(model, apiKey, optionsHeaders) {\n const httpOptions = {};\n if (model.baseUrl) {\n httpOptions.baseUrl = model.baseUrl;\n httpOptions.apiVersion = \"\"; // baseUrl already includes version path, don't append\n }\n const headers = providerHeadersToRecord({ ...model.headers, ...optionsHeaders });\n if (headers) {\n httpOptions.headers = headers;\n }\n return new GoogleGenAI({\n apiKey,\n httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : undefined,\n });\n}\nfunction buildParams(model, context, options = {}) {\n const contents = convertMessages(model, context);\n const generationConfig = {};\n if (options.temperature !== undefined) {\n generationConfig.temperature = options.temperature;\n }\n if (options.maxTokens !== undefined) {\n generationConfig.maxOutputTokens = options.maxTokens;\n }\n const functionCallingMode = context.tools?.length\n ? resolveGoogleFunctionCallingMode(context.tools, options.toolChoice, supportsGoogleStrictToolSampling(model.id))\n : undefined;\n const config = {\n ...(Object.keys(generationConfig).length > 0 && generationConfig),\n ...(context.systemPrompt && { systemInstruction: sanitizeSurrogates(context.systemPrompt) }),\n ...(context.tools && context.tools.length > 0 && { tools: convertTools(context.tools) }),\n ...(functionCallingMode !== undefined && {\n toolConfig: { functionCallingConfig: { mode: functionCallingMode } },\n }),\n };\n if (options.thinking?.enabled && model.reasoning) {\n const thinkingConfig = { includeThoughts: true };\n if (options.thinking.level !== undefined) {\n // Cast to any since our GoogleThinkingLevel mirrors Google's ThinkingLevel enum values\n thinkingConfig.thinkingLevel = options.thinking.level;\n }\n else if (options.thinking.budgetTokens !== undefined) {\n thinkingConfig.thinkingBudget = options.thinking.budgetTokens;\n }\n config.thinkingConfig = thinkingConfig;\n }\n else if (model.reasoning && options.thinking && !options.thinking.enabled) {\n config.thinkingConfig = getDisabledThinkingConfig(model);\n }\n if (options.signal) {\n if (options.signal.aborted) {\n throw new Error(\"Request aborted\");\n }\n config.abortSignal = options.signal;\n }\n const params = {\n model: model.id,\n contents,\n config,\n };\n return params;\n}\nfunction isGemma4Model(model) {\n return /gemma-?4/.test(model.id.toLowerCase());\n}\nfunction isGemini3ProModel(model) {\n return /gemini-3(?:\\.\\d+)?-pro/.test(model.id.toLowerCase());\n}\nfunction isGemini3FlashModel(model) {\n const id = model.id.toLowerCase();\n return /gemini-3(?:\\.\\d+)?-flash/.test(id) || id === \"gemini-flash-latest\" || id === \"gemini-flash-lite-latest\";\n}\nfunction getDisabledThinkingConfig(model) {\n // Google docs: Gemini 3.1 Pro cannot disable thinking, and Gemini 3 Flash / Flash-Lite\n // do not support full thinking-off either. For Gemini 3 models, use the lowest supported\n // thinkingLevel without includeThoughts so hidden thinking remains invisible to pi.\n if (isGemini3ProModel(model)) {\n return { thinkingLevel: \"LOW\" };\n }\n if (isGemini3FlashModel(model)) {\n return { thinkingLevel: \"MINIMAL\" };\n }\n if (isGemma4Model(model)) {\n return { thinkingLevel: \"MINIMAL\" };\n }\n // Gemini 2.x supports disabling via thinkingBudget = 0.\n return { thinkingBudget: 0 };\n}\nfunction getThinkingLevel(effort, model) {\n if (isGemini3ProModel(model)) {\n switch (effort) {\n case \"minimal\":\n case \"low\":\n return \"LOW\";\n case \"medium\":\n case \"high\":\n return \"HIGH\";\n }\n }\n if (isGemma4Model(model)) {\n switch (effort) {\n case \"minimal\":\n case \"low\":\n return \"MINIMAL\";\n case \"medium\":\n case \"high\":\n return \"HIGH\";\n }\n }\n switch (effort) {\n case \"minimal\":\n return \"MINIMAL\";\n case \"low\":\n return \"LOW\";\n case \"medium\":\n return \"MEDIUM\";\n case \"high\":\n return \"HIGH\";\n }\n}\nfunction getGoogleBudget(model, effort, customBudgets) {\n if (customBudgets?.[effort] !== undefined) {\n return customBudgets[effort];\n }\n if (model.id.includes(\"2.5-pro\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 32768,\n };\n return budgets[effort];\n }\n if (model.id.includes(\"2.5-flash-lite\")) {\n const budgets = {\n minimal: 512,\n low: 2048,\n medium: 8192,\n high: 24576,\n };\n return budgets[effort];\n }\n if (model.id.includes(\"2.5-flash\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 24576,\n };\n return budgets[effort];\n }\n return -1;\n}\n//# sourceMappingURL=google-generative-ai.js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CACrC,IAAI,kBAAkB,KAAK,GACvB,QAAQ,QAAR;EACI,KAAK;EACL,KAAK,OACD,OAAO;EACX,KAAK;EACL,KAAK,QACD,OAAO;CACf;CAEJ,IAAI,cAAc,KAAK,GACnB,QAAQ,QAAR;EACI,KAAK;EACL,KAAK,OACD,OAAO;EACX,KAAK;EACL,KAAK,QACD,OAAO;CACf;CAEJ,QAAQ,QAAR;EACI,KAAK,WACD,OAAO;EACX,KAAK,OACD,OAAO;EACX,KAAK,UACD,OAAO;EACX,KAAK,QACD,OAAO;CACf;AACJ;AACA,SAAS,gBAAgB,OAAO,QAAQ,eAAe;CACnD,IAAI,gBAAgB,YAAY,KAAA,GAC5B,OAAO,cAAc;CAEzB,IAAI,MAAM,GAAG,SAAS,SAAS,GAO3B,OAAO;EALH,SAAS;EACT,KAAK;EACL,QAAQ;EACR,MAAM;CAEG,EAAE;CAEnB,IAAI,MAAM,GAAG,SAAS,gBAAgB,GAOlC,OAAO;EALH,SAAS;EACT,KAAK;EACL,QAAQ;EACR,MAAM;CAEG,EAAE;CAEnB,IAAI,MAAM,GAAG,SAAS,WAAW,GAO7B,OAAO;EALH,SAAS;EACT,KAAK;EACL,QAAQ;EACR,MAAM;CAEG,EAAE;CAEnB,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"google-generative-ai-Dpb_X-Kt.mjs","names":[],"sources":["../node_modules/.pnpm/@earendil-works+pi-ai@0.84.1_ws@8.21.3_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js"],"sourcesContent":["import { GoogleGenAI, } from \"@google/genai\";\nimport { calculateCost, clampThinkingLevel } from \"../models.js\";\nimport { formatProviderError, normalizeProviderError } from \"../utils/error-body.js\";\nimport { AssistantMessageEventStream } from \"../utils/event-stream.js\";\nimport { providerHeadersToRecord } from \"../utils/headers.js\";\nimport { sanitizeSurrogates } from \"../utils/sanitize-unicode.js\";\nimport { convertMessages, convertTools, isThinkingPart, mapStopReason, resolveGoogleFunctionCallingMode, retainThoughtSignature, retryGoogleRequest, supportsGoogleStrictToolSampling, } from \"./google-shared.js\";\nimport { buildBaseOptions } from \"./simple-options.js\";\n// Counter for generating unique tool call IDs\nlet toolCallCounter = 0;\nexport const stream = (model, context, options) => {\n const stream = new AssistantMessageEventStream();\n (async () => {\n const output = {\n role: \"assistant\",\n content: [],\n api: \"google-generative-ai\",\n provider: model.provider,\n model: model.id,\n usage: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n totalTokens: 0,\n cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n },\n stopReason: \"pending\",\n timestamp: Date.now(),\n };\n try {\n if (options?.fetch && options.fetch !== globalThis.fetch) {\n throw new Error(\"Custom fetch is not supported by the Google Generative AI adapter\");\n }\n const apiKey = options?.apiKey;\n if (!apiKey) {\n throw new Error(`No API key for provider: ${model.provider}`);\n }\n const client = createClient(model, apiKey, options?.headers);\n let params = buildParams(model, context, options);\n const nextParams = await options?.onPayload?.(params, model);\n if (nextParams !== undefined) {\n params = nextParams;\n }\n const googleStream = await retryGoogleRequest(() => client.models.generateContentStream(params), options);\n stream.push({ type: \"start\", partial: output });\n let currentBlock = null;\n const blocks = output.content;\n const blockIndex = () => blocks.length - 1;\n for await (const chunk of googleStream) {\n // @google/genai documents GenerateContentResponse.responseId as an output-only field\n // used to identify each response. Keep the first non-empty one from the stream.\n output.responseId ||= chunk.responseId;\n const candidate = chunk.candidates?.[0];\n if (candidate?.content?.parts) {\n for (const part of candidate.content.parts) {\n if (part.text !== undefined) {\n const isThinking = isThinkingPart(part);\n if (!currentBlock ||\n (isThinking && currentBlock.type !== \"thinking\") ||\n (!isThinking && currentBlock.type !== \"text\")) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blocks.length - 1,\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (isThinking) {\n currentBlock = { type: \"thinking\", thinking: \"\", thinkingSignature: undefined };\n output.content.push(currentBlock);\n stream.push({ type: \"thinking_start\", contentIndex: blockIndex(), partial: output });\n }\n else {\n currentBlock = { type: \"text\", text: \"\" };\n output.content.push(currentBlock);\n stream.push({ type: \"text_start\", contentIndex: blockIndex(), partial: output });\n }\n }\n if (currentBlock.type === \"thinking\") {\n currentBlock.thinking += part.text;\n currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);\n stream.push({\n type: \"thinking_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n else {\n currentBlock.text += part.text;\n currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);\n stream.push({\n type: \"text_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n }\n if (part.functionCall) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n currentBlock = null;\n }\n // Generate unique ID if not provided or if it's a duplicate\n const providedId = part.functionCall.id;\n const needsNewId = !providedId || output.content.some((b) => b.type === \"toolCall\" && b.id === providedId);\n const toolCallId = needsNewId\n ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}`\n : providedId;\n const toolCall = {\n type: \"toolCall\",\n id: toolCallId,\n name: part.functionCall.name || \"\",\n arguments: part.functionCall.args ?? {},\n ...(part.thoughtSignature && { thoughtSignature: part.thoughtSignature }),\n };\n output.content.push(toolCall);\n stream.push({ type: \"toolcall_start\", contentIndex: blockIndex(), partial: output });\n stream.push({\n type: \"toolcall_delta\",\n contentIndex: blockIndex(),\n delta: JSON.stringify(toolCall.arguments),\n partial: output,\n });\n stream.push({ type: \"toolcall_end\", contentIndex: blockIndex(), toolCall, partial: output });\n }\n }\n }\n if (candidate?.finishReason) {\n output.rawStopReason = candidate.finishReason;\n output.stopReason = mapStopReason(candidate.finishReason);\n if (output.content.some((b) => b.type === \"toolCall\")) {\n output.stopReason = \"toolUse\";\n }\n }\n if (chunk.usageMetadata) {\n output.usage = {\n input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),\n output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),\n cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,\n cacheWrite: 0,\n reasoning: chunk.usageMetadata.thoughtsTokenCount || 0,\n totalTokens: chunk.usageMetadata.totalTokenCount || 0,\n cost: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n total: 0,\n },\n };\n calculateCost(model, output.usage);\n }\n }\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (options?.signal?.aborted) {\n throw new Error(\"Request was aborted\");\n }\n if (output.stopReason === \"pending\") {\n throw new Error(\"Google stream ended without a finish reason\");\n }\n if (output.stopReason === \"aborted\" || output.stopReason === \"error\") {\n const errorMessage = output.rawStopReason\n ? `Provider stopped with: ${output.rawStopReason}`\n : \"An unknown error occurred\";\n throw new Error(errorMessage);\n }\n stream.push({ type: \"done\", reason: output.stopReason, message: output });\n stream.end();\n }\n catch (error) {\n // Remove internal index property used during streaming\n for (const block of output.content) {\n if (\"index\" in block) {\n delete block.index;\n }\n }\n output.stopReason = options?.signal?.aborted ? \"aborted\" : \"error\";\n output.errorMessage = formatProviderError(normalizeProviderError(error));\n stream.push({ type: \"error\", reason: output.stopReason, error: output });\n stream.end();\n }\n })();\n return stream;\n};\nexport const streamSimple = (model, context, options) => {\n const apiKey = options?.apiKey;\n if (!apiKey) {\n throw new Error(`No API key for provider: ${model.provider}`);\n }\n const base = buildBaseOptions(model, context, options, apiKey);\n if (!options?.reasoning) {\n return stream(model, context, { ...base, thinking: { enabled: false } });\n }\n const clampedReasoning = clampThinkingLevel(model, options.reasoning);\n const effort = (clampedReasoning === \"off\" ? \"high\" : clampedReasoning);\n const googleModel = model;\n if (isGemini3ProModel(googleModel) || isGemini3FlashModel(googleModel) || isGemma4Model(googleModel)) {\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n level: getThinkingLevel(effort, googleModel),\n },\n });\n }\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n budgetTokens: getGoogleBudget(googleModel, effort, options.thinkingBudgets),\n },\n });\n};\nfunction createClient(model, apiKey, optionsHeaders) {\n const httpOptions = {};\n if (model.baseUrl) {\n httpOptions.baseUrl = model.baseUrl;\n httpOptions.apiVersion = \"\"; // baseUrl already includes version path, don't append\n }\n const headers = providerHeadersToRecord({ ...model.headers, ...optionsHeaders });\n if (headers) {\n httpOptions.headers = headers;\n }\n return new GoogleGenAI({\n apiKey,\n httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : undefined,\n });\n}\nfunction buildParams(model, context, options = {}) {\n const contents = convertMessages(model, context);\n const generationConfig = {};\n if (options.temperature !== undefined) {\n generationConfig.temperature = options.temperature;\n }\n if (options.maxTokens !== undefined) {\n generationConfig.maxOutputTokens = options.maxTokens;\n }\n const functionCallingMode = context.tools?.length\n ? resolveGoogleFunctionCallingMode(context.tools, options.toolChoice, supportsGoogleStrictToolSampling(model.id))\n : undefined;\n const config = {\n ...(Object.keys(generationConfig).length > 0 && generationConfig),\n ...(context.systemPrompt && { systemInstruction: sanitizeSurrogates(context.systemPrompt) }),\n ...(context.tools && context.tools.length > 0 && { tools: convertTools(context.tools) }),\n ...(functionCallingMode !== undefined && {\n toolConfig: { functionCallingConfig: { mode: functionCallingMode } },\n }),\n };\n if (options.thinking?.enabled && model.reasoning) {\n const thinkingConfig = { includeThoughts: true };\n if (options.thinking.level !== undefined) {\n // Cast to any since our GoogleThinkingLevel mirrors Google's ThinkingLevel enum values\n thinkingConfig.thinkingLevel = options.thinking.level;\n }\n else if (options.thinking.budgetTokens !== undefined) {\n thinkingConfig.thinkingBudget = options.thinking.budgetTokens;\n }\n config.thinkingConfig = thinkingConfig;\n }\n else if (model.reasoning && options.thinking && !options.thinking.enabled) {\n config.thinkingConfig = getDisabledThinkingConfig(model);\n }\n if (options.signal) {\n if (options.signal.aborted) {\n throw new Error(\"Request aborted\");\n }\n config.abortSignal = options.signal;\n }\n const params = {\n model: model.id,\n contents,\n config,\n };\n return params;\n}\nfunction isGemma4Model(model) {\n return /gemma-?4/.test(model.id.toLowerCase());\n}\nfunction isGemini3ProModel(model) {\n return /gemini-3(?:\\.\\d+)?-pro/.test(model.id.toLowerCase());\n}\nfunction isGemini3FlashModel(model) {\n const id = model.id.toLowerCase();\n return /gemini-3(?:\\.\\d+)?-flash/.test(id) || id === \"gemini-flash-latest\" || id === \"gemini-flash-lite-latest\";\n}\nfunction getDisabledThinkingConfig(model) {\n // Google docs: Gemini 3.1 Pro cannot disable thinking, and Gemini 3 Flash / Flash-Lite\n // do not support full thinking-off either. For Gemini 3 models, use the lowest supported\n // thinkingLevel without includeThoughts so hidden thinking remains invisible to pi.\n if (isGemini3ProModel(model)) {\n return { thinkingLevel: \"LOW\" };\n }\n if (isGemini3FlashModel(model)) {\n return { thinkingLevel: \"MINIMAL\" };\n }\n if (isGemma4Model(model)) {\n return { thinkingLevel: \"MINIMAL\" };\n }\n // Gemini 2.x supports disabling via thinkingBudget = 0.\n return { thinkingBudget: 0 };\n}\nfunction getThinkingLevel(effort, model) {\n if (isGemini3ProModel(model)) {\n switch (effort) {\n case \"minimal\":\n case \"low\":\n return \"LOW\";\n case \"medium\":\n case \"high\":\n return \"HIGH\";\n }\n }\n if (isGemma4Model(model)) {\n switch (effort) {\n case \"minimal\":\n case \"low\":\n return \"MINIMAL\";\n case \"medium\":\n case \"high\":\n return \"HIGH\";\n }\n }\n switch (effort) {\n case \"minimal\":\n return \"MINIMAL\";\n case \"low\":\n return \"LOW\";\n case \"medium\":\n return \"MEDIUM\";\n case \"high\":\n return \"HIGH\";\n }\n}\nfunction getGoogleBudget(model, effort, customBudgets) {\n if (customBudgets?.[effort] !== undefined) {\n return customBudgets[effort];\n }\n if (model.id.includes(\"2.5-pro\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 32768,\n };\n return budgets[effort];\n }\n if (model.id.includes(\"2.5-flash-lite\")) {\n const budgets = {\n minimal: 512,\n low: 2048,\n medium: 8192,\n high: 24576,\n };\n return budgets[effort];\n }\n if (model.id.includes(\"2.5-flash\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 24576,\n };\n return budgets[effort];\n }\n return -1;\n}\n//# sourceMappingURL=google-generative-ai.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;AASA,IAAI,kBAAkB;AACtB,MAAa,UAAU,OAAO,SAAS,YAAY;CAC/C,MAAM,SAAS,IAAI,4BAA4B;CAC/C,CAAC,YAAY;EACT,MAAM,SAAS;GACX,MAAM;GACN,SAAS,CAAC;GACV,KAAK;GACL,UAAU,MAAM;GAChB,OAAO,MAAM;GACb,OAAO;IACH,OAAO;IACP,QAAQ;IACR,WAAW;IACX,YAAY;IACZ,aAAa;IACb,MAAM;KAAE,OAAO;KAAG,QAAQ;KAAG,WAAW;KAAG,YAAY;KAAG,OAAO;IAAE;GACvE;GACA,YAAY;GACZ,WAAW,KAAK,IAAI;EACxB;EACA,IAAI;GACA,IAAI,SAAS,SAAS,QAAQ,UAAU,WAAW,OAC/C,MAAM,IAAI,MAAM,mEAAmE;GAEvF,MAAM,SAAS,SAAS;GACxB,IAAI,CAAC,QACD,MAAM,IAAI,MAAM,4BAA4B,MAAM,UAAU;GAEhE,MAAM,SAAS,aAAa,OAAO,QAAQ,SAA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CAEG,EAAE;CAEnB,IAAI,MAAM,GAAG,SAAS,WAAW,GAO7B,OAAO;EALH,SAAS;EACT,KAAK;EACL,QAAQ;EACR,MAAM;CAEG,EAAE;CAEnB,OAAO;AACX"}
|
|
@@ -327,11 +327,11 @@ var require_extend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
327
327
|
};
|
|
328
328
|
}));
|
|
329
329
|
//#endregion
|
|
330
|
-
//#region node_modules/.pnpm/gaxios@7.3.
|
|
330
|
+
//#region node_modules/.pnpm/gaxios@7.3.1/node_modules/gaxios/package.json
|
|
331
331
|
var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
332
332
|
module.exports = {
|
|
333
333
|
"name": "gaxios",
|
|
334
|
-
"version": "7.3.
|
|
334
|
+
"version": "7.3.1",
|
|
335
335
|
"description": "A simple common HTTP client specifically for Google APIs and services.",
|
|
336
336
|
"main": "build/cjs/src/index.js",
|
|
337
337
|
"types": "build/cjs/src/index.d.ts",
|
|
@@ -401,7 +401,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
401
401
|
"karma-mocha": "^2.0.0",
|
|
402
402
|
"karma-remap-coverage": "^0.1.5",
|
|
403
403
|
"karma-sourcemap-loader": "^0.4.0",
|
|
404
|
-
"karma-webpack": "^5.0.
|
|
404
|
+
"karma-webpack": "^5.0.0",
|
|
405
405
|
"mocha": "^11.1.0",
|
|
406
406
|
"multiparty": "^4.2.1",
|
|
407
407
|
"mv": "^2.1.1",
|
|
@@ -412,7 +412,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
412
412
|
"puppeteer": "^24.0.0",
|
|
413
413
|
"sinon": "21.0.3",
|
|
414
414
|
"stream-browserify": "^3.0.0",
|
|
415
|
-
"tmp": "0.2.
|
|
415
|
+
"tmp": "0.2.7",
|
|
416
416
|
"ts-loader": "^9.5.2",
|
|
417
417
|
"typescript": "5.8.3",
|
|
418
418
|
"undici-types": "^7.24.1",
|
|
@@ -428,12 +428,12 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
428
428
|
};
|
|
429
429
|
}));
|
|
430
430
|
//#endregion
|
|
431
|
-
//#region node_modules/.pnpm/gaxios@7.3.
|
|
431
|
+
//#region node_modules/.pnpm/gaxios@7.3.1/node_modules/gaxios/build/cjs/src/util.cjs
|
|
432
432
|
var require_util$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
433
433
|
module.exports = { pkg: require_package$1() };
|
|
434
434
|
}));
|
|
435
435
|
//#endregion
|
|
436
|
-
//#region node_modules/.pnpm/gaxios@7.3.
|
|
436
|
+
//#region node_modules/.pnpm/gaxios@7.3.1/node_modules/gaxios/build/cjs/src/common.js
|
|
437
437
|
var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
438
438
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
439
439
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
@@ -639,7 +639,7 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
639
639
|
}
|
|
640
640
|
}));
|
|
641
641
|
//#endregion
|
|
642
|
-
//#region node_modules/.pnpm/gaxios@7.3.
|
|
642
|
+
//#region node_modules/.pnpm/gaxios@7.3.1/node_modules/gaxios/build/cjs/src/retry.js
|
|
643
643
|
var require_retry = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
644
644
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
645
645
|
exports.getRetryConfig = getRetryConfig;
|
|
@@ -729,7 +729,7 @@ var require_retry = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
729
729
|
}
|
|
730
730
|
}));
|
|
731
731
|
//#endregion
|
|
732
|
-
//#region node_modules/.pnpm/gaxios@7.3.
|
|
732
|
+
//#region node_modules/.pnpm/gaxios@7.3.1/node_modules/gaxios/build/cjs/src/interceptor.js
|
|
733
733
|
var require_interceptor = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
734
734
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
735
735
|
exports.GaxiosInterceptorManager = void 0;
|
|
@@ -740,7 +740,7 @@ var require_interceptor = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
740
740
|
exports.GaxiosInterceptorManager = GaxiosInterceptorManager;
|
|
741
741
|
}));
|
|
742
742
|
//#endregion
|
|
743
|
-
//#region node_modules/.pnpm/gaxios@7.3.
|
|
743
|
+
//#region node_modules/.pnpm/gaxios@7.3.1/node_modules/gaxios/build/cjs/src/gaxios.js
|
|
744
744
|
var require_gaxios = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
745
745
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
746
746
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
@@ -1093,7 +1093,7 @@ var require_gaxios = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
1093
1093
|
}
|
|
1094
1094
|
static async #getFetch() {
|
|
1095
1095
|
const hasWindow = typeof window !== "undefined" && !!window;
|
|
1096
|
-
this.#fetch ||= hasWindow ? window.fetch : (await import("./src-
|
|
1096
|
+
this.#fetch ||= hasWindow ? window.fetch : (await import("./src-85HOaW5W.mjs")).default;
|
|
1097
1097
|
return this.#fetch;
|
|
1098
1098
|
}
|
|
1099
1099
|
/**
|
|
@@ -1124,7 +1124,7 @@ var require_gaxios = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
1124
1124
|
_a = Gaxios;
|
|
1125
1125
|
}));
|
|
1126
1126
|
//#endregion
|
|
1127
|
-
//#region node_modules/.pnpm/gaxios@7.3.
|
|
1127
|
+
//#region node_modules/.pnpm/gaxios@7.3.1/node_modules/gaxios/build/cjs/src/index.js
|
|
1128
1128
|
var require_src$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1129
1129
|
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1130
1130
|
if (k2 === void 0) k2 = k;
|
|
@@ -29038,4 +29038,4 @@ function retryGoogleRequest(request, options) {
|
|
|
29038
29038
|
//#endregion
|
|
29039
29039
|
export { resolveGoogleFunctionCallingMode as a, supportsGoogleStrictToolSampling as c, ThinkingLevel as d, mapStopReason as i, GoogleGenAI as l, convertTools as n, retainThoughtSignature as o, isThinkingPart as r, retryGoogleRequest as s, convertMessages as t, ResourceScope as u };
|
|
29040
29040
|
|
|
29041
|
-
//# sourceMappingURL=google-shared-
|
|
29041
|
+
//# sourceMappingURL=google-shared-CL1Za-ev.mjs.map
|