pagegraph 0.12.0 → 0.14.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 (160) hide show
  1. package/README.md +325 -66
  2. package/dist/anthropic-messages-TqKpKmfW.js +1067 -0
  3. package/dist/anthropic-messages-TqKpKmfW.js.map +1 -0
  4. package/dist/audit.d.ts +4 -2
  5. package/dist/audit.js +5 -5
  6. package/dist/audit.js.map +1 -1
  7. package/dist/azure-openai-responses-DJjBLwoI.js +231 -0
  8. package/dist/azure-openai-responses-DJjBLwoI.js.map +1 -0
  9. package/dist/build-only/audit.js +1 -1
  10. package/dist/build-only/claims.d.ts +1 -0
  11. package/dist/build-only/claims.js +6 -0
  12. package/dist/build-only/claims.js.map +1 -0
  13. package/dist/build-only/config.js +1 -1
  14. package/dist/build-only/oxlint.d.ts +1 -0
  15. package/dist/build-only/oxlint.js +6 -0
  16. package/dist/build-only/oxlint.js.map +1 -0
  17. package/dist/build-only/tanstack-start.js +1 -1
  18. package/dist/build-only/vite.js +1 -1
  19. package/dist/{checks-uZk5Em9A.js → checks-BS-aDXB_.js} +2 -2
  20. package/dist/checks-BS-aDXB_.js.map +1 -0
  21. package/dist/claims-Bch7Lxlo.d.ts +92 -0
  22. package/dist/claims-Bv7voeEV.js +431 -0
  23. package/dist/claims-Bv7voeEV.js.map +1 -0
  24. package/dist/claims.d.ts +94 -0
  25. package/dist/claims.js +2 -0
  26. package/dist/cli.js +17607 -43387
  27. package/dist/cli.js.map +1 -1
  28. package/dist/cloudflare-workers-ai-system-one-f3ZrvNYZ.js +41 -0
  29. package/dist/cloudflare-workers-ai-system-one-f3ZrvNYZ.js.map +1 -0
  30. package/dist/config.d.ts +9 -29
  31. package/dist/config.js +2 -2
  32. package/dist/config.js.map +1 -1
  33. package/dist/{content-kcEnQdfi.js → content-CHd0X4s6.js} +2 -2
  34. package/dist/{content-kcEnQdfi.js.map → content-CHd0X4s6.js.map} +1 -1
  35. package/dist/{content-B1cPtL8b.d.ts → content-DgNr7apS.d.ts} +4 -5
  36. package/dist/declare-D5o7hwmv.js.map +1 -1
  37. package/dist/diagnostics-Wt5faNDM.js +108 -0
  38. package/dist/diagnostics-Wt5faNDM.js.map +1 -0
  39. package/dist/dist-B6zg_Z3Z.js +4794 -0
  40. package/dist/dist-B6zg_Z3Z.js.map +1 -0
  41. package/dist/document-CztEu3Vd.d.ts +109 -0
  42. package/dist/document-Dvemcv7V.js +379 -0
  43. package/dist/document-Dvemcv7V.js.map +1 -0
  44. package/dist/env-api-keys-C-OA0yM-.js +124 -0
  45. package/dist/env-api-keys-C-OA0yM-.js.map +1 -0
  46. package/dist/error-body-CyiejW4b.js +103 -0
  47. package/dist/error-body-CyiejW4b.js.map +1 -0
  48. package/dist/facts-1OKclPOk.js +115 -0
  49. package/dist/facts-1OKclPOk.js.map +1 -0
  50. package/dist/github-copilot-headers-CEpMOpQF.js +24 -0
  51. package/dist/github-copilot-headers-CEpMOpQF.js.map +1 -0
  52. package/dist/google-generative-ai-BxABKIKO.js +330 -0
  53. package/dist/google-generative-ai-BxABKIKO.js.map +1 -0
  54. package/dist/google-shared-0gpM2jFi.js +19471 -0
  55. package/dist/google-shared-0gpM2jFi.js.map +1 -0
  56. package/dist/google-vertex-D8Eb5cbu.js +376 -0
  57. package/dist/google-vertex-D8Eb5cbu.js.map +1 -0
  58. package/dist/{declare-DVgdEdOL.d.ts → graph-D1PIndsC.d.ts} +117 -6
  59. package/dist/{graph-Bcsourlv.js → graph-DMNOLXLu.js} +23 -13
  60. package/dist/graph-DMNOLXLu.js.map +1 -0
  61. package/dist/hash-Dp7EzZUo.js +18 -0
  62. package/dist/hash-Dp7EzZUo.js.map +1 -0
  63. package/dist/headers-BRNMVpzu.js +19 -0
  64. package/dist/headers-BRNMVpzu.js.map +1 -0
  65. package/dist/index-C5w9ripz.d.ts +204 -0
  66. package/dist/index.d.ts +6 -160
  67. package/dist/index.js +37 -5
  68. package/dist/index.js.map +1 -1
  69. package/dist/inline-BbS93GAT.js +682 -0
  70. package/dist/inline-BbS93GAT.js.map +1 -0
  71. package/dist/json-parse-C10znB7l.js +383 -0
  72. package/dist/json-parse-C10znB7l.js.map +1 -0
  73. package/dist/llms-Dhr_5u2O.js +19 -0
  74. package/dist/llms-Dhr_5u2O.js.map +1 -0
  75. package/dist/markdown-C6dRE9zD.js +168 -0
  76. package/dist/markdown-C6dRE9zD.js.map +1 -0
  77. package/dist/markdown-path-lJB9BAVZ.js +6 -0
  78. package/dist/markdown-path-lJB9BAVZ.js.map +1 -0
  79. package/dist/{message-DT_CjUdt.js → message-CuBjgZ74.js} +2 -2
  80. package/dist/{message-DT_CjUdt.js.map → message-CuBjgZ74.js.map} +1 -1
  81. package/dist/mistral-conversations-CvaqBWjR.js +690 -0
  82. package/dist/mistral-conversations-CvaqBWjR.js.map +1 -0
  83. package/dist/models-DcT5qOEL.js +1203 -0
  84. package/dist/models-DcT5qOEL.js.map +1 -0
  85. package/dist/node-Ccvru9GE.js +26 -0
  86. package/dist/node-Ccvru9GE.js.map +1 -0
  87. package/dist/node-MEosBOF2.js +2403 -0
  88. package/dist/node-MEosBOF2.js.map +1 -0
  89. package/dist/openai-BCBEd2eO.js +17350 -0
  90. package/dist/openai-BCBEd2eO.js.map +1 -0
  91. package/dist/openai-codex-responses-vJqxeeRC.js +1268 -0
  92. package/dist/openai-codex-responses-vJqxeeRC.js.map +1 -0
  93. package/dist/openai-completions-Cb_fRAbI.js +989 -0
  94. package/dist/openai-completions-Cb_fRAbI.js.map +1 -0
  95. package/dist/openai-prompt-cache-Bc6qNWt0.js +10 -0
  96. package/dist/openai-prompt-cache-Bc6qNWt0.js.map +1 -0
  97. package/dist/openai-responses-sDuh82G5.js +268 -0
  98. package/dist/openai-responses-sDuh82G5.js.map +1 -0
  99. package/dist/openai-responses-shared-mhuo1Jov.js +599 -0
  100. package/dist/openai-responses-shared-mhuo1Jov.js.map +1 -0
  101. package/dist/openrouter-images-CRmBkzpX.js +127 -0
  102. package/dist/openrouter-images-CRmBkzpX.js.map +1 -0
  103. package/dist/oxlint.d.ts +58 -0
  104. package/dist/oxlint.js +202 -0
  105. package/dist/oxlint.js.map +1 -0
  106. package/dist/page-heads-BfjWQvau.d.ts +108 -0
  107. package/dist/{page-heads-6y-CARRQ.js → page-heads-BgbaIjj9.js} +3 -3
  108. package/dist/page-heads-BgbaIjj9.js.map +1 -0
  109. package/dist/pi-Bvw6J0gh.js +56795 -0
  110. package/dist/pi-Bvw6J0gh.js.map +1 -0
  111. package/dist/pi-messages-CejiVYvO.js +308 -0
  112. package/dist/pi-messages-CejiVYvO.js.map +1 -0
  113. package/dist/{projections-DeEFe7XT.d.ts → projections-Bk-qOOsR.d.ts} +2 -2
  114. package/dist/provider-env-t38GK5FF.js +39 -0
  115. package/dist/provider-env-t38GK5FF.js.map +1 -0
  116. package/dist/provider-retry-DzKoh1X7.js +80 -0
  117. package/dist/provider-retry-DzKoh1X7.js.map +1 -0
  118. package/dist/react.d.ts +3 -2
  119. package/dist/react.js +2 -1
  120. package/dist/react.js.map +1 -1
  121. package/dist/rolldown-runtime-B-lAHAz2.js +37 -0
  122. package/dist/sanitize-unicode-Ds14l9Om.js +28 -0
  123. package/dist/sanitize-unicode-Ds14l9Om.js.map +1 -0
  124. package/dist/sdk-C9_wiO6w.js +12503 -0
  125. package/dist/sdk-C9_wiO6w.js.map +1 -0
  126. package/dist/state-BuJP_3Lr.js +28102 -0
  127. package/dist/state-BuJP_3Lr.js.map +1 -0
  128. package/dist/system-one-shared-Dl10ZF7Z.js +167 -0
  129. package/dist/system-one-shared-Dl10ZF7Z.js.map +1 -0
  130. package/dist/tanstack-start/index.d.ts +29 -13
  131. package/dist/tanstack-start/index.js +391 -42
  132. package/dist/tanstack-start/index.js.map +1 -1
  133. package/dist/tanstack-start/markdown.d.ts +12 -0
  134. package/dist/tanstack-start/markdown.js +149 -0
  135. package/dist/tanstack-start/markdown.js.map +1 -0
  136. package/dist/tanstack-start/prerender-worker.d.ts +2 -0
  137. package/dist/tanstack-start/prerender-worker.js +7 -0
  138. package/dist/tanstack-start/prerender-worker.js.map +1 -0
  139. package/dist/tanstack-start/react.d.ts +7 -0
  140. package/dist/tanstack-start/react.js +12 -0
  141. package/dist/tanstack-start/react.js.map +1 -0
  142. package/dist/tanstack-start/server.d.ts +9 -3
  143. package/dist/tanstack-start/server.js +26 -2
  144. package/dist/tanstack-start/server.js.map +1 -1
  145. package/dist/transform-messages-BLJ8EfK6.js +468 -0
  146. package/dist/transform-messages-BLJ8EfK6.js.map +1 -0
  147. package/dist/typesafe-system-one-CwEWMV8P.js +25 -0
  148. package/dist/typesafe-system-one-CwEWMV8P.js.map +1 -0
  149. package/dist/{vite-graph-loader-01p1WxEq.js → vite-graph-loader-CsGiYNWE.js} +6 -5
  150. package/dist/vite-graph-loader-CsGiYNWE.js.map +1 -0
  151. package/dist/vite-graph-loader-DZCwejuJ.d.ts +133 -0
  152. package/package.json +47 -10
  153. package/dist/checks-uZk5Em9A.js.map +0 -1
  154. package/dist/graph-Bcsourlv.js.map +0 -1
  155. package/dist/graph-BxCY90vq.d.ts +0 -104
  156. package/dist/graph-CBIY71w6.d.ts +0 -57
  157. package/dist/page-heads-6y-CARRQ.js.map +0 -1
  158. package/dist/page-heads-DNkjMUEN.d.ts +0 -21
  159. package/dist/vite-graph-loader-01p1WxEq.js.map +0 -1
  160. package/dist/vite-graph-loader-Btgjz5RH.d.ts +0 -56
@@ -0,0 +1,330 @@
1
+ import { a as AssistantMessageEventStream } from "./diagnostics-Wt5faNDM.js";
2
+ import { S as getSystemMessageText, d as getCurrentTools, n as clampThinkingLevel, o as collapseSystemMessages, p as getInitialSystemMessage, t as calculateCost } from "./models-DcT5qOEL.js";
3
+ import { n as providerHeadersToRecord } from "./headers-BRNMVpzu.js";
4
+ import { p as getPiUserAgent, r as buildBaseOptions } from "./transform-messages-BLJ8EfK6.js";
5
+ import { t as sanitizeSurrogates } from "./sanitize-unicode-Ds14l9Om.js";
6
+ import { n as normalizeProviderError, t as formatProviderError } from "./error-body-CyiejW4b.js";
7
+ import { a as mapStopReason, c as retainThoughtSignature, d as toGoogleSdkThinkingLevel, f as toGoogleThinkingLevel, i as isThinkingPart, l as retryGoogleRequest, m as GoogleGenAI, n as convertTools, o as resolveGoogleFunctionCallingMode, p as usesGoogleThinkingLevel, r as getDisabledGoogleThinkingConfig, s as resolveGoogleThinkingLevel, t as convertMessages, u as supportsGoogleStrictToolSampling } from "./google-shared-0gpM2jFi.js";
8
+ //#region node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js
9
+ let toolCallCounter = 0;
10
+ const stream = (model, context, options) => {
11
+ const stream = new AssistantMessageEventStream();
12
+ const normalizedContext = collapseSystemMessages(context);
13
+ (async () => {
14
+ const output = {
15
+ role: "assistant",
16
+ content: [],
17
+ api: "google-generative-ai",
18
+ provider: model.provider,
19
+ model: model.id,
20
+ usage: {
21
+ input: 0,
22
+ output: 0,
23
+ cacheRead: 0,
24
+ cacheWrite: 0,
25
+ totalTokens: 0,
26
+ cost: {
27
+ input: 0,
28
+ output: 0,
29
+ cacheRead: 0,
30
+ cacheWrite: 0,
31
+ total: 0
32
+ }
33
+ },
34
+ stopReason: "pending",
35
+ timestamp: Date.now()
36
+ };
37
+ try {
38
+ if (options?.fetch && options.fetch !== globalThis.fetch) throw new Error("Custom fetch is not supported by the Google Generative AI adapter");
39
+ const apiKey = options?.apiKey;
40
+ if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
41
+ const client = createClient(model, apiKey, options?.headers);
42
+ let params = buildParams(model, normalizedContext, options);
43
+ const nextParams = await options?.onPayload?.(params, model);
44
+ if (nextParams !== void 0) params = nextParams;
45
+ const googleStream = await retryGoogleRequest(() => client.models.generateContentStream(params), options);
46
+ stream.push({
47
+ type: "start",
48
+ partial: output
49
+ });
50
+ let currentBlock = null;
51
+ const blocks = output.content;
52
+ const blockIndex = () => blocks.length - 1;
53
+ for await (const chunk of googleStream) {
54
+ await options?.onProviderStreamEvent?.(chunk, model);
55
+ output.responseId ||= chunk.responseId;
56
+ const candidate = chunk.candidates?.[0];
57
+ if (candidate?.content?.parts) for (const part of candidate.content.parts) {
58
+ if (part.text !== void 0) {
59
+ const isThinking = isThinkingPart(part);
60
+ if (!currentBlock || isThinking && currentBlock.type !== "thinking" || !isThinking && currentBlock.type !== "text") {
61
+ if (currentBlock) if (currentBlock.type === "text") stream.push({
62
+ type: "text_end",
63
+ contentIndex: blocks.length - 1,
64
+ content: currentBlock.text,
65
+ partial: output
66
+ });
67
+ else stream.push({
68
+ type: "thinking_end",
69
+ contentIndex: blockIndex(),
70
+ content: currentBlock.thinking,
71
+ partial: output
72
+ });
73
+ if (isThinking) {
74
+ currentBlock = {
75
+ type: "thinking",
76
+ thinking: "",
77
+ thinkingSignature: void 0
78
+ };
79
+ output.content.push(currentBlock);
80
+ stream.push({
81
+ type: "thinking_start",
82
+ contentIndex: blockIndex(),
83
+ partial: output
84
+ });
85
+ } else {
86
+ currentBlock = {
87
+ type: "text",
88
+ text: ""
89
+ };
90
+ output.content.push(currentBlock);
91
+ stream.push({
92
+ type: "text_start",
93
+ contentIndex: blockIndex(),
94
+ partial: output
95
+ });
96
+ }
97
+ }
98
+ if (currentBlock.type === "thinking") {
99
+ currentBlock.thinking += part.text;
100
+ currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);
101
+ stream.push({
102
+ type: "thinking_delta",
103
+ contentIndex: blockIndex(),
104
+ delta: part.text,
105
+ partial: output
106
+ });
107
+ } else {
108
+ currentBlock.text += part.text;
109
+ currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);
110
+ stream.push({
111
+ type: "text_delta",
112
+ contentIndex: blockIndex(),
113
+ delta: part.text,
114
+ partial: output
115
+ });
116
+ }
117
+ }
118
+ if (part.functionCall) {
119
+ if (currentBlock) {
120
+ if (currentBlock.type === "text") stream.push({
121
+ type: "text_end",
122
+ contentIndex: blockIndex(),
123
+ content: currentBlock.text,
124
+ partial: output
125
+ });
126
+ else stream.push({
127
+ type: "thinking_end",
128
+ contentIndex: blockIndex(),
129
+ content: currentBlock.thinking,
130
+ partial: output
131
+ });
132
+ currentBlock = null;
133
+ }
134
+ const providedId = part.functionCall.id;
135
+ const toolCall = {
136
+ type: "toolCall",
137
+ id: !providedId || output.content.some((b) => b.type === "toolCall" && b.id === providedId) ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}` : providedId,
138
+ name: part.functionCall.name || "",
139
+ arguments: part.functionCall.args ?? {},
140
+ ...part.thoughtSignature && { thoughtSignature: part.thoughtSignature }
141
+ };
142
+ output.content.push(toolCall);
143
+ stream.push({
144
+ type: "toolcall_start",
145
+ contentIndex: blockIndex(),
146
+ partial: output
147
+ });
148
+ stream.push({
149
+ type: "toolcall_delta",
150
+ contentIndex: blockIndex(),
151
+ delta: JSON.stringify(toolCall.arguments),
152
+ partial: output
153
+ });
154
+ stream.push({
155
+ type: "toolcall_end",
156
+ contentIndex: blockIndex(),
157
+ toolCall,
158
+ partial: output
159
+ });
160
+ }
161
+ }
162
+ if (candidate?.finishReason) {
163
+ output.rawStopReason = candidate.finishReason;
164
+ output.stopReason = mapStopReason(candidate.finishReason);
165
+ if (output.content.some((b) => b.type === "toolCall") && output.stopReason === "stop") output.stopReason = "toolUse";
166
+ }
167
+ if (chunk.usageMetadata) {
168
+ output.usage = {
169
+ input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),
170
+ output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),
171
+ cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,
172
+ cacheWrite: 0,
173
+ reasoning: chunk.usageMetadata.thoughtsTokenCount || 0,
174
+ totalTokens: chunk.usageMetadata.totalTokenCount || 0,
175
+ cost: {
176
+ input: 0,
177
+ output: 0,
178
+ cacheRead: 0,
179
+ cacheWrite: 0,
180
+ total: 0
181
+ }
182
+ };
183
+ calculateCost(model, output.usage);
184
+ }
185
+ }
186
+ if (currentBlock) if (currentBlock.type === "text") stream.push({
187
+ type: "text_end",
188
+ contentIndex: blockIndex(),
189
+ content: currentBlock.text,
190
+ partial: output
191
+ });
192
+ else stream.push({
193
+ type: "thinking_end",
194
+ contentIndex: blockIndex(),
195
+ content: currentBlock.thinking,
196
+ partial: output
197
+ });
198
+ if (options?.signal?.aborted) throw new Error("Request was aborted");
199
+ if (output.stopReason === "pending") throw new Error("Google stream ended without a finish reason");
200
+ if (output.stopReason === "aborted" || output.stopReason === "error") {
201
+ const errorMessage = output.rawStopReason ? `Provider stopped with: ${output.rawStopReason}` : "An unknown error occurred";
202
+ throw new Error(errorMessage);
203
+ }
204
+ stream.push({
205
+ type: "done",
206
+ reason: output.stopReason,
207
+ message: output
208
+ });
209
+ stream.end();
210
+ } catch (error) {
211
+ for (const block of output.content) if ("index" in block) delete block.index;
212
+ output.stopReason = options?.signal?.aborted ? "aborted" : "error";
213
+ output.errorMessage = formatProviderError(normalizeProviderError(error));
214
+ stream.push({
215
+ type: "error",
216
+ reason: output.stopReason,
217
+ error: output
218
+ });
219
+ stream.end();
220
+ }
221
+ })();
222
+ return stream;
223
+ };
224
+ const streamSimple = (model, context, options) => {
225
+ const apiKey = options?.apiKey;
226
+ if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
227
+ const base = {
228
+ ...buildBaseOptions(model, context, options, apiKey),
229
+ toolChoice: options?.toolChoice
230
+ };
231
+ if (!options?.reasoning) return stream(model, context, {
232
+ ...base,
233
+ thinking: { enabled: false }
234
+ });
235
+ const clampedReasoning = clampThinkingLevel(model, options.reasoning);
236
+ if (clampedReasoning === "off") return stream(model, context, {
237
+ ...base,
238
+ thinking: { enabled: false }
239
+ });
240
+ const resolvedLevel = resolveGoogleThinkingLevel(model, clampedReasoning);
241
+ if (usesGoogleThinkingLevel(model)) return stream(model, context, {
242
+ ...base,
243
+ thinking: {
244
+ enabled: true,
245
+ level: toGoogleThinkingLevel(resolvedLevel)
246
+ }
247
+ });
248
+ return stream(model, context, {
249
+ ...base,
250
+ thinking: {
251
+ enabled: true,
252
+ budgetTokens: getGoogleBudget(model, resolvedLevel, options.thinkingBudgets)
253
+ }
254
+ });
255
+ };
256
+ function createClient(model, apiKey, optionsHeaders) {
257
+ const httpOptions = {};
258
+ if (model.baseUrl) {
259
+ httpOptions.baseUrl = model.baseUrl;
260
+ httpOptions.apiVersion = "";
261
+ }
262
+ const headers = providerHeadersToRecord({
263
+ "User-Agent": getPiUserAgent(),
264
+ ...model.headers,
265
+ ...optionsHeaders
266
+ });
267
+ if (headers) httpOptions.headers = headers;
268
+ return new GoogleGenAI({
269
+ apiKey,
270
+ httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : void 0
271
+ });
272
+ }
273
+ function buildParams(model, context, options = {}) {
274
+ const contents = convertMessages(model, context);
275
+ const initialSystemMessage = getInitialSystemMessage(context.messages);
276
+ const currentTools = getCurrentTools(context.messages);
277
+ const generationConfig = {};
278
+ if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
279
+ if (options.maxTokens !== void 0) generationConfig.maxOutputTokens = options.maxTokens;
280
+ const supportsStrictMode = supportsGoogleStrictToolSampling(model.id);
281
+ const functionCallingMode = currentTools.length > 0 ? resolveGoogleFunctionCallingMode(currentTools, options.toolChoice, supportsStrictMode) : void 0;
282
+ const systemInstruction = initialSystemMessage ? getSystemMessageText(initialSystemMessage) : "";
283
+ const config = {
284
+ ...Object.keys(generationConfig).length > 0 && generationConfig,
285
+ ...systemInstruction && { systemInstruction: sanitizeSurrogates(systemInstruction) },
286
+ ...currentTools.length > 0 && { tools: convertTools(currentTools, false, supportsStrictMode) },
287
+ ...functionCallingMode !== void 0 && { toolConfig: { functionCallingConfig: { mode: functionCallingMode } } }
288
+ };
289
+ if (options.thinking?.enabled && model.reasoning) {
290
+ const thinkingConfig = { includeThoughts: true };
291
+ if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = toGoogleSdkThinkingLevel(options.thinking.level);
292
+ else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
293
+ config.thinkingConfig = thinkingConfig;
294
+ } else if (model.reasoning && options.thinking && !options.thinking.enabled) config.thinkingConfig = getDisabledGoogleThinkingConfig(model);
295
+ if (options.signal) {
296
+ if (options.signal.aborted) throw new Error("Request aborted");
297
+ config.abortSignal = options.signal;
298
+ }
299
+ return {
300
+ model: model.id,
301
+ contents,
302
+ config
303
+ };
304
+ }
305
+ function getGoogleBudget(model, level, customBudgets) {
306
+ if (customBudgets?.[level] !== void 0) return customBudgets[level];
307
+ if (model.id.includes("2.5-pro")) return {
308
+ minimal: 128,
309
+ low: 2048,
310
+ medium: 8192,
311
+ high: 32768
312
+ }[level];
313
+ if (model.id.includes("2.5-flash-lite")) return {
314
+ minimal: 512,
315
+ low: 2048,
316
+ medium: 8192,
317
+ high: 24576
318
+ }[level];
319
+ if (model.id.includes("2.5-flash")) return {
320
+ minimal: 128,
321
+ low: 2048,
322
+ medium: 8192,
323
+ high: 24576
324
+ }[level];
325
+ return -1;
326
+ }
327
+ //#endregion
328
+ export { stream, streamSimple };
329
+
330
+ //# sourceMappingURL=google-generative-ai-BxABKIKO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-generative-ai-BxABKIKO.js","names":[],"sources":["../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 { getPiUserAgent } from \"../utils/pi-user-agent.js\";\nimport { sanitizeSurrogates } from \"../utils/sanitize-unicode.js\";\nimport { getSystemMessageText } from \"../utils/text.js\";\nimport { collapseSystemMessages, getCurrentTools, getInitialSystemMessage } from \"../utils/transcript.js\";\nimport { convertMessages, convertTools, getDisabledGoogleThinkingConfig, isThinkingPart, mapStopReason, resolveGoogleFunctionCallingMode, resolveGoogleThinkingLevel, retainThoughtSignature, retryGoogleRequest, supportsGoogleStrictToolSampling, toGoogleSdkThinkingLevel, toGoogleThinkingLevel, usesGoogleThinkingLevel, } 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 const normalizedContext = collapseSystemMessages(context);\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, normalizedContext, 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 await options?.onProviderStreamEvent?.(chunk, model);\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\") && output.stopReason === \"stop\") {\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 = {\n ...buildBaseOptions(model, context, options, apiKey),\n toolChoice: options?.toolChoice,\n };\n if (!options?.reasoning) {\n return stream(model, context, { ...base, thinking: { enabled: false } });\n }\n const clampedReasoning = clampThinkingLevel(model, options.reasoning);\n if (clampedReasoning === \"off\") {\n return stream(model, context, { ...base, thinking: { enabled: false } });\n }\n const resolvedLevel = resolveGoogleThinkingLevel(model, clampedReasoning);\n if (usesGoogleThinkingLevel(model)) {\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n level: toGoogleThinkingLevel(resolvedLevel),\n },\n });\n }\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n budgetTokens: getGoogleBudget(model, resolvedLevel, 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({ \"User-Agent\": getPiUserAgent(), ...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 initialSystemMessage = getInitialSystemMessage(context.messages);\n const currentTools = getCurrentTools(context.messages);\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 supportsStrictMode = supportsGoogleStrictToolSampling(model.id);\n const functionCallingMode = currentTools.length > 0\n ? resolveGoogleFunctionCallingMode(currentTools, options.toolChoice, supportsStrictMode)\n : undefined;\n const systemInstruction = initialSystemMessage ? getSystemMessageText(initialSystemMessage) : \"\";\n const config = {\n ...(Object.keys(generationConfig).length > 0 && generationConfig),\n ...(systemInstruction && { systemInstruction: sanitizeSurrogates(systemInstruction) }),\n ...(currentTools.length > 0 && {\n tools: convertTools(currentTools, false, supportsStrictMode),\n }),\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 = toGoogleSdkThinkingLevel(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 = getDisabledGoogleThinkingConfig(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 getGoogleBudget(model, level, customBudgets) {\n if (customBudgets?.[level] !== undefined) {\n return customBudgets[level];\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[level];\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[level];\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[level];\n }\n return -1;\n}\n//# sourceM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