pi2dsh 0.4.0 → 0.6.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.
Files changed (93) hide show
  1. package/README.md +54 -14
  2. package/README.zh.md +43 -14
  3. package/cordis.patch.yml +3 -0
  4. package/dist/cli.mjs +1 -1
  5. package/dist/compat/pi-ai.mjs +1 -1
  6. package/dist/compat/pi-coding-agent.mjs +1 -1
  7. package/dist/credentials-oauth.mjs +3 -3
  8. package/dist/host.mjs +2 -2
  9. package/dist/index.d.mts +30 -1
  10. package/dist/index.d.mts.map +1 -1
  11. package/dist/index.mjs +98 -2
  12. package/dist/index.mjs.map +1 -0
  13. package/dist/{mcp-config-B3h5jTBb.mjs → mcp-config-vU1LZ7fC.mjs} +6 -6
  14. package/dist/mcp-config-vU1LZ7fC.mjs.map +1 -0
  15. package/dist/{oauth-bridge-C6fL1qSv.mjs → oauth-bridge-CfyImWx4.mjs} +2 -2
  16. package/dist/{oauth-bridge-C6fL1qSv.mjs.map → oauth-bridge-CfyImWx4.mjs.map} +1 -1
  17. package/dist/{pi-ai-B_88Wb0r.mjs → pi-ai-7HR3ciAs.mjs} +4 -42
  18. package/dist/{pi-ai-B_88Wb0r.mjs.map → pi-ai-7HR3ciAs.mjs.map} +1 -1
  19. package/dist/{pi-coding-agent-COMX0KHL.mjs → pi-coding-agent-CznNsOnV.mjs} +3 -3
  20. package/dist/{pi-coding-agent-COMX0KHL.mjs.map → pi-coding-agent-CznNsOnV.mjs.map} +1 -1
  21. package/dist/{runtime-B7mEIRf-.mjs → runtime-xNd10ACP.mjs} +194 -21
  22. package/dist/runtime-xNd10ACP.mjs.map +1 -0
  23. package/dist/runtime.d.mts.map +1 -1
  24. package/dist/runtime.mjs +1 -1
  25. package/package.json +9 -2
  26. package/dist/all-DSpxKvHa.mjs +0 -28512
  27. package/dist/all-DSpxKvHa.mjs.map +0 -1
  28. package/dist/anthropic-messages-BL9N1Idv.mjs +0 -6438
  29. package/dist/anthropic-messages-BL9N1Idv.mjs.map +0 -1
  30. package/dist/azure-openai-responses-A67VbaZ1.mjs +0 -209
  31. package/dist/azure-openai-responses-A67VbaZ1.mjs.map +0 -1
  32. package/dist/deferred-tools-BD4g5QUx.mjs +0 -32
  33. package/dist/deferred-tools-BD4g5QUx.mjs.map +0 -1
  34. package/dist/diagnostics-CJye1UFh.mjs +0 -99
  35. package/dist/diagnostics-CJye1UFh.mjs.map +0 -1
  36. package/dist/dist-BYA74yh_.mjs +0 -1246
  37. package/dist/dist-BYA74yh_.mjs.map +0 -1
  38. package/dist/dist-DeonWo7m.mjs +0 -1089
  39. package/dist/dist-DeonWo7m.mjs.map +0 -1
  40. package/dist/error-body-DKA3lknR.mjs +0 -104
  41. package/dist/error-body-DKA3lknR.mjs.map +0 -1
  42. package/dist/github-copilot-headers-CZo2QHrt.mjs +0 -25
  43. package/dist/github-copilot-headers-CZo2QHrt.mjs.map +0 -1
  44. package/dist/google-generative-ai-DT5S8D8y.mjs +0 -358
  45. package/dist/google-generative-ai-DT5S8D8y.mjs.map +0 -1
  46. package/dist/google-shared-DYP_9cnK.mjs +0 -29042
  47. package/dist/google-shared-DYP_9cnK.mjs.map +0 -1
  48. package/dist/google-vertex-Dpq7O7Be.mjs +0 -402
  49. package/dist/google-vertex-Dpq7O7Be.mjs.map +0 -1
  50. package/dist/hash-Dbggamac.mjs +0 -19
  51. package/dist/hash-Dbggamac.mjs.map +0 -1
  52. package/dist/headers-CPzZhJQn.mjs +0 -17
  53. package/dist/headers-CPzZhJQn.mjs.map +0 -1
  54. package/dist/images-models-DJtHo9Rp.mjs +0 -1068
  55. package/dist/images-models-DJtHo9Rp.mjs.map +0 -1
  56. package/dist/json-parse-Dz5sKMTv.mjs +0 -384
  57. package/dist/json-parse-Dz5sKMTv.mjs.map +0 -1
  58. package/dist/mcp-config-B3h5jTBb.mjs.map +0 -1
  59. package/dist/mistral-conversations-BsxbCCWx.mjs +0 -42007
  60. package/dist/mistral-conversations-BsxbCCWx.mjs.map +0 -1
  61. package/dist/multipart-parser-woKCuALW.mjs +0 -301
  62. package/dist/multipart-parser-woKCuALW.mjs.map +0 -1
  63. package/dist/openai-DkzRh5_G.mjs +0 -6732
  64. package/dist/openai-DkzRh5_G.mjs.map +0 -1
  65. package/dist/openai-codex-responses-C7vviVT2.mjs +0 -1169
  66. package/dist/openai-codex-responses-C7vviVT2.mjs.map +0 -1
  67. package/dist/openai-completions-By8QNX1P.mjs +0 -947
  68. package/dist/openai-completions-By8QNX1P.mjs.map +0 -1
  69. package/dist/openai-prompt-cache-BDWtZRKh.mjs +0 -11
  70. package/dist/openai-prompt-cache-BDWtZRKh.mjs.map +0 -1
  71. package/dist/openai-responses-DboJUcFN.mjs +0 -247
  72. package/dist/openai-responses-DboJUcFN.mjs.map +0 -1
  73. package/dist/openai-responses-shared-BDzn7nJY.mjs +0 -572
  74. package/dist/openai-responses-shared-BDzn7nJY.mjs.map +0 -1
  75. package/dist/openrouter-images-fG3Aj6M4.mjs +0 -127
  76. package/dist/openrouter-images-fG3Aj6M4.mjs.map +0 -1
  77. package/dist/otel-PimLMoiV.mjs +0 -24935
  78. package/dist/otel-PimLMoiV.mjs.map +0 -1
  79. package/dist/pi-messages-B-7Xo_I0.mjs +0 -306
  80. package/dist/pi-messages-B-7Xo_I0.mjs.map +0 -1
  81. package/dist/provider-env-D-cCRWzv.mjs +0 -40
  82. package/dist/provider-env-D-cCRWzv.mjs.map +0 -1
  83. package/dist/provider-retry-Cw6YJ4cr.mjs +0 -80
  84. package/dist/provider-retry-Cw6YJ4cr.mjs.map +0 -1
  85. package/dist/runtime-B7mEIRf-.mjs.map +0 -1
  86. package/dist/sanitize-unicode-wLA11KvZ.mjs +0 -29
  87. package/dist/sanitize-unicode-wLA11KvZ.mjs.map +0 -1
  88. package/dist/src-BEl3QrGL.mjs +0 -5031
  89. package/dist/src-BEl3QrGL.mjs.map +0 -1
  90. package/dist/transform-messages-DGq9mvhA.mjs +0 -379
  91. package/dist/transform-messages-DGq9mvhA.mjs.map +0 -1
  92. package/dist/uuid-DtFT7tOE.mjs +0 -65
  93. package/dist/uuid-DtFT7tOE.mjs.map +0 -1
@@ -1,402 +0,0 @@
1
-
2
- import { a as AssistantMessageEventStream } from "./diagnostics-CJye1UFh.mjs";
3
- import { a as calculateCost, o as clampThinkingLevel } from "./images-models-DJtHo9Rp.mjs";
4
- import { n as providerHeadersToRecord } from "./headers-CPzZhJQn.mjs";
5
- import { t as getProviderEnvValue } from "./provider-env-D-cCRWzv.mjs";
6
- import { t as sanitizeSurrogates } from "./sanitize-unicode-wLA11KvZ.mjs";
7
- import { i as buildBaseOptions } from "./transform-messages-DGq9mvhA.mjs";
8
- import { n as normalizeProviderError, t as formatProviderError } from "./error-body-DKA3lknR.mjs";
9
- import { a as resolveGoogleFunctionCallingMode, c as supportsGoogleStrictToolSampling, d as ThinkingLevel, i as mapStopReason, l as GoogleGenAI, n as convertTools, o as retainThoughtSignature, r as isThinkingPart, s as retryGoogleRequest, t as convertMessages, u as ResourceScope } from "./google-shared-DYP_9cnK.mjs";
10
- //#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-vertex.js
11
- const API_VERSION = "v1";
12
- const GCP_VERTEX_CREDENTIALS_MARKER = "gcp-vertex-credentials";
13
- const THINKING_LEVEL_MAP = {
14
- THINKING_LEVEL_UNSPECIFIED: ThinkingLevel.THINKING_LEVEL_UNSPECIFIED,
15
- MINIMAL: ThinkingLevel.MINIMAL,
16
- LOW: ThinkingLevel.LOW,
17
- MEDIUM: ThinkingLevel.MEDIUM,
18
- HIGH: ThinkingLevel.HIGH
19
- };
20
- let toolCallCounter = 0;
21
- const stream = (model, context, options) => {
22
- const stream = new AssistantMessageEventStream();
23
- (async () => {
24
- const output = {
25
- role: "assistant",
26
- content: [],
27
- api: "google-vertex",
28
- provider: model.provider,
29
- model: model.id,
30
- usage: {
31
- input: 0,
32
- output: 0,
33
- cacheRead: 0,
34
- cacheWrite: 0,
35
- totalTokens: 0,
36
- cost: {
37
- input: 0,
38
- output: 0,
39
- cacheRead: 0,
40
- cacheWrite: 0,
41
- total: 0
42
- }
43
- },
44
- stopReason: "pending",
45
- timestamp: Date.now()
46
- };
47
- try {
48
- if (options?.fetch && options.fetch !== globalThis.fetch) throw new Error("Custom fetch is not supported by the Google Vertex adapter");
49
- const apiKey = resolveApiKey(options);
50
- const client = apiKey ? createClientWithApiKey(model, apiKey, options?.headers) : createClient(model, resolveProject(options), resolveLocation(options), options?.headers, options?.env);
51
- let params = buildParams(model, context, options);
52
- const nextParams = await options?.onPayload?.(params, model);
53
- if (nextParams !== void 0) params = nextParams;
54
- const googleStream = await retryGoogleRequest(() => client.models.generateContentStream(params), options);
55
- stream.push({
56
- type: "start",
57
- partial: output
58
- });
59
- let currentBlock = null;
60
- const blocks = output.content;
61
- const blockIndex = () => blocks.length - 1;
62
- for await (const chunk of googleStream) {
63
- output.responseId ||= chunk.responseId;
64
- const candidate = chunk.candidates?.[0];
65
- if (candidate?.content?.parts) for (const part of candidate.content.parts) {
66
- if (part.text !== void 0) {
67
- const isThinking = isThinkingPart(part);
68
- if (!currentBlock || isThinking && currentBlock.type !== "thinking" || !isThinking && currentBlock.type !== "text") {
69
- if (currentBlock) {
70
- if (currentBlock.type === "text") stream.push({
71
- type: "text_end",
72
- contentIndex: blocks.length - 1,
73
- content: currentBlock.text,
74
- partial: output
75
- });
76
- else stream.push({
77
- type: "thinking_end",
78
- contentIndex: blockIndex(),
79
- content: currentBlock.thinking,
80
- partial: output
81
- });
82
- }
83
- if (isThinking) {
84
- currentBlock = {
85
- type: "thinking",
86
- thinking: "",
87
- thinkingSignature: void 0
88
- };
89
- output.content.push(currentBlock);
90
- stream.push({
91
- type: "thinking_start",
92
- contentIndex: blockIndex(),
93
- partial: output
94
- });
95
- } else {
96
- currentBlock = {
97
- type: "text",
98
- text: ""
99
- };
100
- output.content.push(currentBlock);
101
- stream.push({
102
- type: "text_start",
103
- contentIndex: blockIndex(),
104
- partial: output
105
- });
106
- }
107
- }
108
- if (currentBlock.type === "thinking") {
109
- currentBlock.thinking += part.text;
110
- currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);
111
- stream.push({
112
- type: "thinking_delta",
113
- contentIndex: blockIndex(),
114
- delta: part.text,
115
- partial: output
116
- });
117
- } else {
118
- currentBlock.text += part.text;
119
- currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);
120
- stream.push({
121
- type: "text_delta",
122
- contentIndex: blockIndex(),
123
- delta: part.text,
124
- partial: output
125
- });
126
- }
127
- }
128
- if (part.functionCall) {
129
- if (currentBlock) {
130
- if (currentBlock.type === "text") stream.push({
131
- type: "text_end",
132
- contentIndex: blockIndex(),
133
- content: currentBlock.text,
134
- partial: output
135
- });
136
- else stream.push({
137
- type: "thinking_end",
138
- contentIndex: blockIndex(),
139
- content: currentBlock.thinking,
140
- partial: output
141
- });
142
- currentBlock = null;
143
- }
144
- const providedId = part.functionCall.id;
145
- const toolCall = {
146
- type: "toolCall",
147
- id: !providedId || output.content.some((b) => b.type === "toolCall" && b.id === providedId) ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}` : providedId,
148
- name: part.functionCall.name || "",
149
- arguments: part.functionCall.args ?? {},
150
- ...part.thoughtSignature && { thoughtSignature: part.thoughtSignature }
151
- };
152
- output.content.push(toolCall);
153
- stream.push({
154
- type: "toolcall_start",
155
- contentIndex: blockIndex(),
156
- partial: output
157
- });
158
- stream.push({
159
- type: "toolcall_delta",
160
- contentIndex: blockIndex(),
161
- delta: JSON.stringify(toolCall.arguments),
162
- partial: output
163
- });
164
- stream.push({
165
- type: "toolcall_end",
166
- contentIndex: blockIndex(),
167
- toolCall,
168
- partial: output
169
- });
170
- }
171
- }
172
- if (candidate?.finishReason) {
173
- output.rawStopReason = candidate.finishReason;
174
- output.stopReason = mapStopReason(candidate.finishReason);
175
- if (output.content.some((b) => b.type === "toolCall")) output.stopReason = "toolUse";
176
- }
177
- if (chunk.usageMetadata) {
178
- output.usage = {
179
- input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),
180
- output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),
181
- cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,
182
- cacheWrite: 0,
183
- reasoning: chunk.usageMetadata.thoughtsTokenCount || 0,
184
- totalTokens: chunk.usageMetadata.totalTokenCount || 0,
185
- cost: {
186
- input: 0,
187
- output: 0,
188
- cacheRead: 0,
189
- cacheWrite: 0,
190
- total: 0
191
- }
192
- };
193
- calculateCost(model, output.usage);
194
- }
195
- }
196
- if (currentBlock) {
197
- if (currentBlock.type === "text") stream.push({
198
- type: "text_end",
199
- contentIndex: blockIndex(),
200
- content: currentBlock.text,
201
- partial: output
202
- });
203
- else stream.push({
204
- type: "thinking_end",
205
- contentIndex: blockIndex(),
206
- content: currentBlock.thinking,
207
- partial: output
208
- });
209
- }
210
- if (options?.signal?.aborted) throw new Error("Request was aborted");
211
- if (output.stopReason === "pending") throw new Error("Google Vertex stream ended without a finish reason");
212
- if (output.stopReason === "aborted" || output.stopReason === "error") {
213
- const errorMessage = output.rawStopReason ? `Provider stopped with: ${output.rawStopReason}` : "An unknown error occurred";
214
- throw new Error(errorMessage);
215
- }
216
- stream.push({
217
- type: "done",
218
- reason: output.stopReason,
219
- message: output
220
- });
221
- stream.end();
222
- } catch (error) {
223
- for (const block of output.content) if ("index" in block) delete block.index;
224
- output.stopReason = options?.signal?.aborted ? "aborted" : "error";
225
- output.errorMessage = formatProviderError(normalizeProviderError(error));
226
- stream.push({
227
- type: "error",
228
- reason: output.stopReason,
229
- error: output
230
- });
231
- stream.end();
232
- }
233
- })();
234
- return stream;
235
- };
236
- const streamSimple = (model, context, options) => {
237
- const base = buildBaseOptions(model, context, options, void 0);
238
- if (!options?.reasoning) return stream(model, context, {
239
- ...base,
240
- thinking: { enabled: false }
241
- });
242
- const clampedReasoning = clampThinkingLevel(model, options.reasoning);
243
- const effort = clampedReasoning === "off" ? "high" : clampedReasoning;
244
- const geminiModel = model;
245
- if (isGemini3ProModel(geminiModel) || isGemini3FlashModel(geminiModel)) return stream(model, context, {
246
- ...base,
247
- thinking: {
248
- enabled: true,
249
- level: getGemini3ThinkingLevel(effort, geminiModel)
250
- }
251
- });
252
- return stream(model, context, {
253
- ...base,
254
- thinking: {
255
- enabled: true,
256
- budgetTokens: getGoogleBudget(geminiModel, effort, options.thinkingBudgets)
257
- }
258
- });
259
- };
260
- function createClient(model, project, location, optionsHeaders, env) {
261
- const googleAuthOptions = buildGoogleAuthOptions(env);
262
- return new GoogleGenAI({
263
- vertexai: true,
264
- project,
265
- location,
266
- apiVersion: API_VERSION,
267
- ...googleAuthOptions ? { googleAuthOptions } : {},
268
- httpOptions: buildHttpOptions(model, optionsHeaders)
269
- });
270
- }
271
- function createClientWithApiKey(model, apiKey, optionsHeaders) {
272
- return new GoogleGenAI({
273
- vertexai: true,
274
- apiKey,
275
- apiVersion: API_VERSION,
276
- httpOptions: buildHttpOptions(model, optionsHeaders)
277
- });
278
- }
279
- function buildHttpOptions(model, optionsHeaders) {
280
- const httpOptions = {};
281
- const baseUrl = resolveCustomBaseUrl(model.baseUrl);
282
- if (baseUrl) {
283
- httpOptions.baseUrl = baseUrl;
284
- httpOptions.baseUrlResourceScope = ResourceScope.COLLECTION;
285
- if (baseUrlIncludesApiVersion(baseUrl)) httpOptions.apiVersion = "";
286
- }
287
- const headers = providerHeadersToRecord({
288
- ...model.headers,
289
- ...optionsHeaders
290
- });
291
- if (headers) httpOptions.headers = headers;
292
- return Object.keys(httpOptions).length > 0 ? httpOptions : void 0;
293
- }
294
- function resolveCustomBaseUrl(baseUrl) {
295
- const trimmed = baseUrl.trim();
296
- if (!trimmed || trimmed.includes("{location}")) return;
297
- return trimmed;
298
- }
299
- function baseUrlIncludesApiVersion(baseUrl) {
300
- try {
301
- return new URL(baseUrl).pathname.split("/").some((part) => /^v\d+(?:beta\d*)?$/.test(part));
302
- } catch {
303
- return /(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(baseUrl);
304
- }
305
- }
306
- function buildGoogleAuthOptions(env) {
307
- const keyFilename = getProviderEnvValue("GOOGLE_APPLICATION_CREDENTIALS", env);
308
- return keyFilename ? { keyFilename } : void 0;
309
- }
310
- function resolveApiKey(options) {
311
- const apiKey = options?.apiKey?.trim();
312
- if (!apiKey || apiKey === GCP_VERTEX_CREDENTIALS_MARKER || isPlaceholderApiKey(apiKey)) return;
313
- return apiKey;
314
- }
315
- function isPlaceholderApiKey(apiKey) {
316
- return /^<[^>]+>$/.test(apiKey);
317
- }
318
- function resolveProject(options) {
319
- const project = options?.project || getProviderEnvValue("GOOGLE_CLOUD_PROJECT", options?.env) || getProviderEnvValue("GCLOUD_PROJECT", options?.env);
320
- if (!project) throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");
321
- return project;
322
- }
323
- function resolveLocation(options) {
324
- const location = options?.location || getProviderEnvValue("GOOGLE_CLOUD_LOCATION", options?.env);
325
- if (!location) throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");
326
- return location;
327
- }
328
- function buildParams(model, context, options = {}) {
329
- const contents = convertMessages(model, context);
330
- const generationConfig = {};
331
- if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
332
- if (options.maxTokens !== void 0) generationConfig.maxOutputTokens = options.maxTokens;
333
- const functionCallingMode = context.tools?.length ? resolveGoogleFunctionCallingMode(context.tools, options.toolChoice, supportsGoogleStrictToolSampling(model.id)) : void 0;
334
- const config = {
335
- ...Object.keys(generationConfig).length > 0 && generationConfig,
336
- ...context.systemPrompt && { systemInstruction: sanitizeSurrogates(context.systemPrompt) },
337
- ...context.tools && context.tools.length > 0 && { tools: convertTools(context.tools) },
338
- ...functionCallingMode !== void 0 && { toolConfig: { functionCallingConfig: { mode: functionCallingMode } } }
339
- };
340
- if (options.thinking?.enabled && model.reasoning) {
341
- const thinkingConfig = { includeThoughts: true };
342
- if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = THINKING_LEVEL_MAP[options.thinking.level];
343
- else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
344
- config.thinkingConfig = thinkingConfig;
345
- } else if (model.reasoning && options.thinking && !options.thinking.enabled) config.thinkingConfig = getDisabledThinkingConfig(model);
346
- if (options.signal) {
347
- if (options.signal.aborted) throw new Error("Request aborted");
348
- config.abortSignal = options.signal;
349
- }
350
- return {
351
- model: model.id,
352
- contents,
353
- config
354
- };
355
- }
356
- function isGemini3ProModel(model) {
357
- return /gemini-3(?:\.\d+)?-pro/.test(model.id.toLowerCase());
358
- }
359
- function isGemini3FlashModel(model) {
360
- const id = model.id.toLowerCase();
361
- return /gemini-3(?:\.\d+)?-flash/.test(id) || id === "gemini-flash-latest" || id === "gemini-flash-lite-latest";
362
- }
363
- function getDisabledThinkingConfig(model) {
364
- const geminiModel = model;
365
- if (isGemini3ProModel(geminiModel)) return { thinkingLevel: ThinkingLevel.LOW };
366
- if (isGemini3FlashModel(geminiModel)) return { thinkingLevel: ThinkingLevel.MINIMAL };
367
- return { thinkingBudget: 0 };
368
- }
369
- function getGemini3ThinkingLevel(effort, model) {
370
- if (isGemini3ProModel(model)) switch (effort) {
371
- case "minimal":
372
- case "low": return "LOW";
373
- case "medium":
374
- case "high": return "HIGH";
375
- }
376
- switch (effort) {
377
- case "minimal": return "MINIMAL";
378
- case "low": return "LOW";
379
- case "medium": return "MEDIUM";
380
- case "high": return "HIGH";
381
- }
382
- }
383
- function getGoogleBudget(model, effort, customBudgets) {
384
- if (customBudgets?.[effort] !== void 0) return customBudgets[effort];
385
- if (model.id.includes("2.5-pro")) return {
386
- minimal: 128,
387
- low: 2048,
388
- medium: 8192,
389
- high: 32768
390
- }[effort];
391
- if (model.id.includes("2.5-flash")) return {
392
- minimal: 128,
393
- low: 2048,
394
- medium: 8192,
395
- high: 24576
396
- }[effort];
397
- return -1;
398
- }
399
- //#endregion
400
- export { stream, streamSimple };
401
-
402
- //# sourceMappingURL=google-vertex-Dpq7O7Be.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"google-vertex-Dpq7O7Be.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-vertex.js"],"sourcesContent":["import { GoogleGenAI, ResourceScope, ThinkingLevel, } 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 { getProviderEnvValue } from \"../utils/provider-env.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\";\nconst API_VERSION = \"v1\";\nconst GCP_VERTEX_CREDENTIALS_MARKER = \"gcp-vertex-credentials\";\nconst THINKING_LEVEL_MAP = {\n THINKING_LEVEL_UNSPECIFIED: ThinkingLevel.THINKING_LEVEL_UNSPECIFIED,\n MINIMAL: ThinkingLevel.MINIMAL,\n LOW: ThinkingLevel.LOW,\n MEDIUM: ThinkingLevel.MEDIUM,\n HIGH: ThinkingLevel.HIGH,\n};\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-vertex\",\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 Vertex adapter\");\n }\n const apiKey = resolveApiKey(options);\n // Create the client using either a Vertex API key, if provided, or ADC with project and location\n const client = apiKey\n ? createClientWithApiKey(model, apiKey, options?.headers)\n : createClient(model, resolveProject(options), resolveLocation(options), options?.headers, options?.env);\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 // Vertex uses the same @google/genai GenerateContentResponse type as Gemini.\n // responseId is documented there as an output-only identifier for each response.\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 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 Vertex 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 base = buildBaseOptions(model, context, options, undefined);\n if (!options?.reasoning) {\n return stream(model, context, {\n ...base,\n thinking: { enabled: false },\n });\n }\n const clampedReasoning = clampThinkingLevel(model, options.reasoning);\n const effort = (clampedReasoning === \"off\" ? \"high\" : clampedReasoning);\n const geminiModel = model;\n if (isGemini3ProModel(geminiModel) || isGemini3FlashModel(geminiModel)) {\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n level: getGemini3ThinkingLevel(effort, geminiModel),\n },\n });\n }\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n budgetTokens: getGoogleBudget(geminiModel, effort, options.thinkingBudgets),\n },\n });\n};\nfunction createClient(model, project, location, optionsHeaders, env) {\n const googleAuthOptions = buildGoogleAuthOptions(env);\n return new GoogleGenAI({\n vertexai: true,\n project,\n location,\n apiVersion: API_VERSION,\n ...(googleAuthOptions ? { googleAuthOptions } : {}),\n httpOptions: buildHttpOptions(model, optionsHeaders),\n });\n}\nfunction createClientWithApiKey(model, apiKey, optionsHeaders) {\n return new GoogleGenAI({\n vertexai: true,\n apiKey,\n apiVersion: API_VERSION,\n httpOptions: buildHttpOptions(model, optionsHeaders),\n });\n}\nfunction buildHttpOptions(model, optionsHeaders) {\n const httpOptions = {};\n const baseUrl = resolveCustomBaseUrl(model.baseUrl);\n if (baseUrl) {\n httpOptions.baseUrl = baseUrl;\n httpOptions.baseUrlResourceScope = ResourceScope.COLLECTION;\n if (baseUrlIncludesApiVersion(baseUrl)) {\n httpOptions.apiVersion = \"\";\n }\n }\n const headers = providerHeadersToRecord({ ...model.headers, ...optionsHeaders });\n if (headers) {\n httpOptions.headers = headers;\n }\n return Object.keys(httpOptions).length > 0 ? httpOptions : undefined;\n}\nfunction resolveCustomBaseUrl(baseUrl) {\n const trimmed = baseUrl.trim();\n if (!trimmed || trimmed.includes(\"{location}\")) {\n return undefined;\n }\n return trimmed;\n}\nfunction baseUrlIncludesApiVersion(baseUrl) {\n try {\n const url = new URL(baseUrl);\n return url.pathname.split(\"/\").some((part) => /^v\\d+(?:beta\\d*)?$/.test(part));\n }\n catch {\n return /(?:^|\\/)v\\d+(?:beta\\d*)?(?:\\/|$)/.test(baseUrl);\n }\n}\nfunction buildGoogleAuthOptions(env) {\n const keyFilename = getProviderEnvValue(\"GOOGLE_APPLICATION_CREDENTIALS\", env);\n return keyFilename ? { keyFilename } : undefined;\n}\nfunction resolveApiKey(options) {\n const apiKey = options?.apiKey?.trim();\n if (!apiKey || apiKey === GCP_VERTEX_CREDENTIALS_MARKER || isPlaceholderApiKey(apiKey)) {\n return undefined;\n }\n return apiKey;\n}\nfunction isPlaceholderApiKey(apiKey) {\n return /^<[^>]+>$/.test(apiKey);\n}\nfunction resolveProject(options) {\n const project = options?.project ||\n getProviderEnvValue(\"GOOGLE_CLOUD_PROJECT\", options?.env) ||\n getProviderEnvValue(\"GCLOUD_PROJECT\", options?.env);\n if (!project) {\n throw new Error(\"Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.\");\n }\n return project;\n}\nfunction resolveLocation(options) {\n const location = options?.location || getProviderEnvValue(\"GOOGLE_CLOUD_LOCATION\", options?.env);\n if (!location) {\n throw new Error(\"Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.\");\n }\n return location;\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 thinkingConfig.thinkingLevel = THINKING_LEVEL_MAP[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 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 const geminiModel = model;\n if (isGemini3ProModel(geminiModel)) {\n return { thinkingLevel: ThinkingLevel.LOW };\n }\n if (isGemini3FlashModel(geminiModel)) {\n return { thinkingLevel: ThinkingLevel.MINIMAL };\n }\n // Gemini 2.x supports disabling via thinkingBudget = 0.\n return { thinkingBudget: 0 };\n}\nfunction getGemini3ThinkingLevel(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 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\")) {\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-vertex.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;AASA,MAAM,cAAc;AACpB,MAAM,gCAAgC;AACtC,MAAM,qBAAqB;CACvB,4BAA4B,cAAc;CAC1C,SAAS,cAAc;CACvB,KAAK,cAAc;CACnB,QAAQ,cAAc;CACtB,MAAM,cAAc;AACxB;AAEA,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,4DAA4D;GAEhF,MAAM,SAAS,cAAc,OAAO;GAEpC,MAAM,SAAS,SACT,uBAAuB,OAAO,QAAQ,SAAS,OAAO,IACtD,aAAa,OAAO,eAAe,OAAO,GAAG,gBAAgB,OAAO,GAAG,SAAS,SAAS,SAAS,GAAG;GAC3G,IAAI,SAAS,YAAY,OAAO,SAAS,OAAO;GAChD,MAAM,aAAa,MAAM,SAAS,YAAY,QAAQ,KAAK;GAC3D,IAAI,eAAe,KAAA,GACf,SAAS;GAEb,MAAM,eAAe,MAAM,yBAAyB,OAAO,OAAO,sBAAsB,MAAM,GAAG,OAAO;GACxG,OAAO,KAAK;IAAE,MAAM;IAAS,SAAS;GAAO,CAAC;GAC9C,IAAI,eAAe;GACnB,MAAM,SAAS,OAAO;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O;AACzF;AACA,SAAS,0BAA0B,OAAO;CAItC,MAAM,cAAc;CACpB,IAAI,kBAAkB,WAAW,GAC7B,OAAO,EAAE,eAAe,cAAc,IAAI;CAE9C,IAAI,oBAAoB,WAAW,GAC/B,OAAO,EAAE,eAAe,cAAc,QAAQ;CAGlD,OAAO,EAAE,gBAAgB,EAAE;AAC/B;AACA,SAAS,wBAAwB,QAAQ,OAAO;CAC5C,IAAI,kBAAkB,KAAK,GACvB,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,WAAW,GAO7B,OAAO;EALH,SAAS;EACT,KAAK;EACL,QAAQ;EACR,MAAM;CAEG,EAAE;CAEnB,OAAO;AACX"}
@@ -1,19 +0,0 @@
1
-
2
- //#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/utils/hash.js
3
- /** Fast deterministic hash to shorten long strings */
4
- function shortHash(str) {
5
- let h1 = 3735928559;
6
- let h2 = 1103547991;
7
- for (let i = 0; i < str.length; i++) {
8
- const ch = str.charCodeAt(i);
9
- h1 = Math.imul(h1 ^ ch, 2654435761);
10
- h2 = Math.imul(h2 ^ ch, 1597334677);
11
- }
12
- h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
13
- h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
14
- return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);
15
- }
16
- //#endregion
17
- export { shortHash as t };
18
-
19
- //# sourceMappingURL=hash-Dbggamac.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash-Dbggamac.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/utils/hash.js"],"sourcesContent":["/** Fast deterministic hash to shorten long strings */\nexport function shortHash(str) {\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);\n}\n//# sourceMappingURL=hash.js.map"],"x_google_ignoreList":[0],"mappings":";;;AACA,SAAgB,UAAU,KAAK;CAC3B,IAAI,KAAK;CACT,IAAI,KAAK;CACT,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;EACjC,MAAM,KAAK,IAAI,WAAW,CAAC;EAC3B,KAAK,KAAK,KAAK,KAAK,IAAI,UAAU;EAClC,KAAK,KAAK,KAAK,KAAK,IAAI,UAAU;CACtC;CACA,KAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU,IAAI,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CACrF,KAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU,IAAI,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CACrF,QAAQ,OAAO,EAAA,CAAG,SAAS,EAAE,KAAK,OAAO,EAAA,CAAG,SAAS,EAAE;AAC3D"}
@@ -1,17 +0,0 @@
1
-
2
- //#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/utils/headers.js
3
- function headersToRecord(headers) {
4
- const result = {};
5
- for (const [key, value] of headers.entries()) result[key] = value;
6
- return result;
7
- }
8
- function providerHeadersToRecord(headers) {
9
- if (!headers) return void 0;
10
- const result = {};
11
- for (const [key, value] of Object.entries(headers)) if (value !== null) result[key] = value;
12
- return Object.keys(result).length > 0 ? result : void 0;
13
- }
14
- //#endregion
15
- export { providerHeadersToRecord as n, headersToRecord as t };
16
-
17
- //# sourceMappingURL=headers-CPzZhJQn.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"headers-CPzZhJQn.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/utils/headers.js"],"sourcesContent":["export function headersToRecord(headers) {\n const result = {};\n for (const [key, value] of headers.entries()) {\n result[key] = value;\n }\n return result;\n}\nexport function providerHeadersToRecord(headers) {\n if (!headers)\n return undefined;\n const result = {};\n for (const [key, value] of Object.entries(headers)) {\n if (value !== null)\n result[key] = value;\n }\n return Object.keys(result).length > 0 ? result : undefined;\n}\n//# sourceMappingURL=headers.js.map"],"x_google_ignoreList":[0],"mappings":";;AAAA,SAAgB,gBAAgB,SAAS;CACrC,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,CAAC,KAAK,UAAU,QAAQ,QAAQ,GACvC,OAAO,OAAO;CAElB,OAAO;AACX;AACA,SAAgB,wBAAwB,SAAS;CAC7C,IAAI,CAAC,SACD,OAAO,KAAA;CACX,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAC7C,IAAI,UAAU,MACV,OAAO,OAAO;CAEtB,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,IAAI,SAAS,KAAA;AACrD"}