pi2dsh 0.3.1 → 0.3.2
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 +15 -10
- package/README.zh.md +15 -10
- package/dist/all-Rt4K68QA.mjs +28512 -0
- package/dist/all-Rt4K68QA.mjs.map +1 -0
- package/dist/anthropic-messages-Beym0_aC.mjs +6438 -0
- package/dist/anthropic-messages-Beym0_aC.mjs.map +1 -0
- package/dist/azure-openai-responses-cHqZTgLD.mjs +209 -0
- package/dist/azure-openai-responses-cHqZTgLD.mjs.map +1 -0
- package/dist/{build-DsGYAgiT.mjs → build-BG7p2Lbr.mjs} +2 -2
- package/dist/{build-DsGYAgiT.mjs.map → build-BG7p2Lbr.mjs.map} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/compat/pi-ai.d.mts +16 -3
- package/dist/compat/pi-ai.d.mts.map +1 -1
- package/dist/compat/pi-ai.mjs +3 -3
- package/dist/compat/pi-coding-agent.d.mts +12 -1
- package/dist/compat/pi-coding-agent.d.mts.map +1 -1
- package/dist/compat/pi-coding-agent.mjs +2 -2
- package/dist/credentials-oauth.mjs +3 -3
- package/dist/deferred-tools-BD4g5QUx.mjs +32 -0
- package/dist/deferred-tools-BD4g5QUx.mjs.map +1 -0
- package/dist/diagnostics-CJye1UFh.mjs +99 -0
- package/dist/diagnostics-CJye1UFh.mjs.map +1 -0
- package/dist/dist-IQKOgQyt.mjs +10035 -0
- package/dist/dist-IQKOgQyt.mjs.map +1 -0
- package/dist/dist-QBBA-dL_.mjs +1246 -0
- package/dist/dist-QBBA-dL_.mjs.map +1 -0
- package/dist/error-body-DKA3lknR.mjs +104 -0
- package/dist/error-body-DKA3lknR.mjs.map +1 -0
- package/dist/github-copilot-headers-CZo2QHrt.mjs +25 -0
- package/dist/github-copilot-headers-CZo2QHrt.mjs.map +1 -0
- package/dist/google-generative-ai-B7OZs5lu.mjs +358 -0
- package/dist/google-generative-ai-B7OZs5lu.mjs.map +1 -0
- package/dist/google-shared-CRsAUItF.mjs +29042 -0
- package/dist/google-shared-CRsAUItF.mjs.map +1 -0
- package/dist/google-vertex-DmdaHQtB.mjs +402 -0
- package/dist/google-vertex-DmdaHQtB.mjs.map +1 -0
- package/dist/hash-Dbggamac.mjs +19 -0
- package/dist/hash-Dbggamac.mjs.map +1 -0
- package/dist/headers-CPzZhJQn.mjs +17 -0
- package/dist/headers-CPzZhJQn.mjs.map +1 -0
- package/dist/host.d.mts.map +1 -1
- package/dist/host.mjs +13 -3
- package/dist/host.mjs.map +1 -1
- package/dist/images-models-DJtHo9Rp.mjs +1068 -0
- package/dist/images-models-DJtHo9Rp.mjs.map +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/json-parse-CFyFZSLJ.mjs +384 -0
- package/dist/json-parse-CFyFZSLJ.mjs.map +1 -0
- package/dist/{mcp-config-gqg7GJEE.mjs → mcp-config-D2B3kv-Z.mjs} +34 -16
- package/dist/mcp-config-D2B3kv-Z.mjs.map +1 -0
- package/dist/mistral-conversations-HHZCcFv_.mjs +42007 -0
- package/dist/mistral-conversations-HHZCcFv_.mjs.map +1 -0
- package/dist/multipart-parser-CIa5BbwO.mjs +301 -0
- package/dist/multipart-parser-CIa5BbwO.mjs.map +1 -0
- package/dist/{oauth-bridge-BpPrppjR.mjs → oauth-bridge-C6fL1qSv.mjs} +20 -4
- package/dist/oauth-bridge-C6fL1qSv.mjs.map +1 -0
- package/dist/openai-DkzRh5_G.mjs +6732 -0
- package/dist/openai-DkzRh5_G.mjs.map +1 -0
- package/dist/openai-codex-responses-vmovNu-q.mjs +1169 -0
- package/dist/openai-codex-responses-vmovNu-q.mjs.map +1 -0
- package/dist/openai-completions-fXHhRolF.mjs +947 -0
- package/dist/openai-completions-fXHhRolF.mjs.map +1 -0
- package/dist/openai-prompt-cache-BDWtZRKh.mjs +11 -0
- package/dist/openai-prompt-cache-BDWtZRKh.mjs.map +1 -0
- package/dist/openai-responses-DKdCYf3h.mjs +247 -0
- package/dist/openai-responses-DKdCYf3h.mjs.map +1 -0
- package/dist/openai-responses-shared-D0Jq7yVP.mjs +572 -0
- package/dist/openai-responses-shared-D0Jq7yVP.mjs.map +1 -0
- package/dist/openrouter-images-fG3Aj6M4.mjs +127 -0
- package/dist/openrouter-images-fG3Aj6M4.mjs.map +1 -0
- package/dist/otel-BQSQRBLF.mjs +24935 -0
- package/dist/otel-BQSQRBLF.mjs.map +1 -0
- package/dist/{pi-ai-CWFlgigJ.mjs → pi-ai-DhYGgq4Y.mjs} +49 -12
- package/dist/{pi-ai-CWFlgigJ.mjs.map → pi-ai-DhYGgq4Y.mjs.map} +1 -1
- package/dist/{pi-coding-agent-Z1hTs61i.mjs → pi-coding-agent-fPHwKP4d.mjs} +27 -3
- package/dist/{pi-coding-agent-Z1hTs61i.mjs.map → pi-coding-agent-fPHwKP4d.mjs.map} +1 -1
- package/dist/pi-messages-CV-Ts8An.mjs +306 -0
- package/dist/pi-messages-CV-Ts8An.mjs.map +1 -0
- package/dist/provider-env-C72pF4vP.mjs +40 -0
- package/dist/provider-env-C72pF4vP.mjs.map +1 -0
- package/dist/provider-retry-Cw6YJ4cr.mjs +80 -0
- package/dist/provider-retry-Cw6YJ4cr.mjs.map +1 -0
- package/dist/rolldown-runtime-CTfmNlz1.mjs +44 -0
- package/dist/{runtime-6DefpI6h.mjs → runtime-B9R7bDWT.mjs} +874 -37
- package/dist/runtime-B9R7bDWT.mjs.map +1 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/sanitize-unicode-wLA11KvZ.mjs +29 -0
- package/dist/sanitize-unicode-wLA11KvZ.mjs.map +1 -0
- package/dist/src-C3WBfOks.mjs +5031 -0
- package/dist/src-C3WBfOks.mjs.map +1 -0
- package/dist/transform-messages-DGq9mvhA.mjs +379 -0
- package/dist/transform-messages-DGq9mvhA.mjs.map +1 -0
- package/dist/uuid-DtFT7tOE.mjs +65 -0
- package/dist/uuid-DtFT7tOE.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/mcp-config-gqg7GJEE.mjs.map +0 -1
- package/dist/oauth-bridge-BpPrppjR.mjs.map +0 -1
- package/dist/rolldown-runtime-D-uZhY3_.mjs +0 -16
- package/dist/runtime-6DefpI6h.mjs.map +0 -1
|
@@ -0,0 +1,358 @@
|
|
|
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 sanitizeSurrogates } from "./sanitize-unicode-wLA11KvZ.mjs";
|
|
6
|
+
import { i as buildBaseOptions } from "./transform-messages-DGq9mvhA.mjs";
|
|
7
|
+
import { n as normalizeProviderError, t as formatProviderError } from "./error-body-DKA3lknR.mjs";
|
|
8
|
+
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-CRsAUItF.mjs";
|
|
9
|
+
//#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
|
|
10
|
+
let toolCallCounter = 0;
|
|
11
|
+
const stream = (model, context, options) => {
|
|
12
|
+
const stream = new AssistantMessageEventStream();
|
|
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, context, 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
|
+
output.responseId ||= chunk.responseId;
|
|
55
|
+
const candidate = chunk.candidates?.[0];
|
|
56
|
+
if (candidate?.content?.parts) for (const part of candidate.content.parts) {
|
|
57
|
+
if (part.text !== void 0) {
|
|
58
|
+
const isThinking = isThinkingPart(part);
|
|
59
|
+
if (!currentBlock || isThinking && currentBlock.type !== "thinking" || !isThinking && currentBlock.type !== "text") {
|
|
60
|
+
if (currentBlock) {
|
|
61
|
+
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
|
+
}
|
|
74
|
+
if (isThinking) {
|
|
75
|
+
currentBlock = {
|
|
76
|
+
type: "thinking",
|
|
77
|
+
thinking: "",
|
|
78
|
+
thinkingSignature: void 0
|
|
79
|
+
};
|
|
80
|
+
output.content.push(currentBlock);
|
|
81
|
+
stream.push({
|
|
82
|
+
type: "thinking_start",
|
|
83
|
+
contentIndex: blockIndex(),
|
|
84
|
+
partial: output
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
currentBlock = {
|
|
88
|
+
type: "text",
|
|
89
|
+
text: ""
|
|
90
|
+
};
|
|
91
|
+
output.content.push(currentBlock);
|
|
92
|
+
stream.push({
|
|
93
|
+
type: "text_start",
|
|
94
|
+
contentIndex: blockIndex(),
|
|
95
|
+
partial: output
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (currentBlock.type === "thinking") {
|
|
100
|
+
currentBlock.thinking += part.text;
|
|
101
|
+
currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);
|
|
102
|
+
stream.push({
|
|
103
|
+
type: "thinking_delta",
|
|
104
|
+
contentIndex: blockIndex(),
|
|
105
|
+
delta: part.text,
|
|
106
|
+
partial: output
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
currentBlock.text += part.text;
|
|
110
|
+
currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);
|
|
111
|
+
stream.push({
|
|
112
|
+
type: "text_delta",
|
|
113
|
+
contentIndex: blockIndex(),
|
|
114
|
+
delta: part.text,
|
|
115
|
+
partial: output
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (part.functionCall) {
|
|
120
|
+
if (currentBlock) {
|
|
121
|
+
if (currentBlock.type === "text") stream.push({
|
|
122
|
+
type: "text_end",
|
|
123
|
+
contentIndex: blockIndex(),
|
|
124
|
+
content: currentBlock.text,
|
|
125
|
+
partial: output
|
|
126
|
+
});
|
|
127
|
+
else stream.push({
|
|
128
|
+
type: "thinking_end",
|
|
129
|
+
contentIndex: blockIndex(),
|
|
130
|
+
content: currentBlock.thinking,
|
|
131
|
+
partial: output
|
|
132
|
+
});
|
|
133
|
+
currentBlock = null;
|
|
134
|
+
}
|
|
135
|
+
const providedId = part.functionCall.id;
|
|
136
|
+
const toolCall = {
|
|
137
|
+
type: "toolCall",
|
|
138
|
+
id: !providedId || output.content.some((b) => b.type === "toolCall" && b.id === providedId) ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}` : providedId,
|
|
139
|
+
name: part.functionCall.name || "",
|
|
140
|
+
arguments: part.functionCall.args ?? {},
|
|
141
|
+
...part.thoughtSignature && { thoughtSignature: part.thoughtSignature }
|
|
142
|
+
};
|
|
143
|
+
output.content.push(toolCall);
|
|
144
|
+
stream.push({
|
|
145
|
+
type: "toolcall_start",
|
|
146
|
+
contentIndex: blockIndex(),
|
|
147
|
+
partial: output
|
|
148
|
+
});
|
|
149
|
+
stream.push({
|
|
150
|
+
type: "toolcall_delta",
|
|
151
|
+
contentIndex: blockIndex(),
|
|
152
|
+
delta: JSON.stringify(toolCall.arguments),
|
|
153
|
+
partial: output
|
|
154
|
+
});
|
|
155
|
+
stream.push({
|
|
156
|
+
type: "toolcall_end",
|
|
157
|
+
contentIndex: blockIndex(),
|
|
158
|
+
toolCall,
|
|
159
|
+
partial: output
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (candidate?.finishReason) {
|
|
164
|
+
output.rawStopReason = candidate.finishReason;
|
|
165
|
+
output.stopReason = mapStopReason(candidate.finishReason);
|
|
166
|
+
if (output.content.some((b) => b.type === "toolCall")) output.stopReason = "toolUse";
|
|
167
|
+
}
|
|
168
|
+
if (chunk.usageMetadata) {
|
|
169
|
+
output.usage = {
|
|
170
|
+
input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),
|
|
171
|
+
output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),
|
|
172
|
+
cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,
|
|
173
|
+
cacheWrite: 0,
|
|
174
|
+
reasoning: chunk.usageMetadata.thoughtsTokenCount || 0,
|
|
175
|
+
totalTokens: chunk.usageMetadata.totalTokenCount || 0,
|
|
176
|
+
cost: {
|
|
177
|
+
input: 0,
|
|
178
|
+
output: 0,
|
|
179
|
+
cacheRead: 0,
|
|
180
|
+
cacheWrite: 0,
|
|
181
|
+
total: 0
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
calculateCost(model, output.usage);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (currentBlock) {
|
|
188
|
+
if (currentBlock.type === "text") stream.push({
|
|
189
|
+
type: "text_end",
|
|
190
|
+
contentIndex: blockIndex(),
|
|
191
|
+
content: currentBlock.text,
|
|
192
|
+
partial: output
|
|
193
|
+
});
|
|
194
|
+
else stream.push({
|
|
195
|
+
type: "thinking_end",
|
|
196
|
+
contentIndex: blockIndex(),
|
|
197
|
+
content: currentBlock.thinking,
|
|
198
|
+
partial: output
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (options?.signal?.aborted) throw new Error("Request was aborted");
|
|
202
|
+
if (output.stopReason === "pending") throw new Error("Google stream ended without a finish reason");
|
|
203
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
204
|
+
const errorMessage = output.rawStopReason ? `Provider stopped with: ${output.rawStopReason}` : "An unknown error occurred";
|
|
205
|
+
throw new Error(errorMessage);
|
|
206
|
+
}
|
|
207
|
+
stream.push({
|
|
208
|
+
type: "done",
|
|
209
|
+
reason: output.stopReason,
|
|
210
|
+
message: output
|
|
211
|
+
});
|
|
212
|
+
stream.end();
|
|
213
|
+
} catch (error) {
|
|
214
|
+
for (const block of output.content) if ("index" in block) delete block.index;
|
|
215
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
216
|
+
output.errorMessage = formatProviderError(normalizeProviderError(error));
|
|
217
|
+
stream.push({
|
|
218
|
+
type: "error",
|
|
219
|
+
reason: output.stopReason,
|
|
220
|
+
error: output
|
|
221
|
+
});
|
|
222
|
+
stream.end();
|
|
223
|
+
}
|
|
224
|
+
})();
|
|
225
|
+
return stream;
|
|
226
|
+
};
|
|
227
|
+
const streamSimple = (model, context, options) => {
|
|
228
|
+
const apiKey = options?.apiKey;
|
|
229
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
230
|
+
const base = buildBaseOptions(model, context, options, apiKey);
|
|
231
|
+
if (!options?.reasoning) return stream(model, context, {
|
|
232
|
+
...base,
|
|
233
|
+
thinking: { enabled: false }
|
|
234
|
+
});
|
|
235
|
+
const clampedReasoning = clampThinkingLevel(model, options.reasoning);
|
|
236
|
+
const effort = clampedReasoning === "off" ? "high" : clampedReasoning;
|
|
237
|
+
const googleModel = model;
|
|
238
|
+
if (isGemini3ProModel(googleModel) || isGemini3FlashModel(googleModel) || isGemma4Model(googleModel)) return stream(model, context, {
|
|
239
|
+
...base,
|
|
240
|
+
thinking: {
|
|
241
|
+
enabled: true,
|
|
242
|
+
level: getThinkingLevel(effort, googleModel)
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
return stream(model, context, {
|
|
246
|
+
...base,
|
|
247
|
+
thinking: {
|
|
248
|
+
enabled: true,
|
|
249
|
+
budgetTokens: getGoogleBudget(googleModel, effort, options.thinkingBudgets)
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
function createClient(model, apiKey, optionsHeaders) {
|
|
254
|
+
const httpOptions = {};
|
|
255
|
+
if (model.baseUrl) {
|
|
256
|
+
httpOptions.baseUrl = model.baseUrl;
|
|
257
|
+
httpOptions.apiVersion = "";
|
|
258
|
+
}
|
|
259
|
+
const headers = providerHeadersToRecord({
|
|
260
|
+
...model.headers,
|
|
261
|
+
...optionsHeaders
|
|
262
|
+
});
|
|
263
|
+
if (headers) httpOptions.headers = headers;
|
|
264
|
+
return new GoogleGenAI({
|
|
265
|
+
apiKey,
|
|
266
|
+
httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : void 0
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function buildParams(model, context, options = {}) {
|
|
270
|
+
const contents = convertMessages(model, context);
|
|
271
|
+
const generationConfig = {};
|
|
272
|
+
if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
|
|
273
|
+
if (options.maxTokens !== void 0) generationConfig.maxOutputTokens = options.maxTokens;
|
|
274
|
+
const functionCallingMode = context.tools?.length ? resolveGoogleFunctionCallingMode(context.tools, options.toolChoice, supportsGoogleStrictToolSampling(model.id)) : void 0;
|
|
275
|
+
const config = {
|
|
276
|
+
...Object.keys(generationConfig).length > 0 && generationConfig,
|
|
277
|
+
...context.systemPrompt && { systemInstruction: sanitizeSurrogates(context.systemPrompt) },
|
|
278
|
+
...context.tools && context.tools.length > 0 && { tools: convertTools(context.tools) },
|
|
279
|
+
...functionCallingMode !== void 0 && { toolConfig: { functionCallingConfig: { mode: functionCallingMode } } }
|
|
280
|
+
};
|
|
281
|
+
if (options.thinking?.enabled && model.reasoning) {
|
|
282
|
+
const thinkingConfig = { includeThoughts: true };
|
|
283
|
+
if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = options.thinking.level;
|
|
284
|
+
else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
|
|
285
|
+
config.thinkingConfig = thinkingConfig;
|
|
286
|
+
} else if (model.reasoning && options.thinking && !options.thinking.enabled) config.thinkingConfig = getDisabledThinkingConfig(model);
|
|
287
|
+
if (options.signal) {
|
|
288
|
+
if (options.signal.aborted) throw new Error("Request aborted");
|
|
289
|
+
config.abortSignal = options.signal;
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
model: model.id,
|
|
293
|
+
contents,
|
|
294
|
+
config
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function isGemma4Model(model) {
|
|
298
|
+
return /gemma-?4/.test(model.id.toLowerCase());
|
|
299
|
+
}
|
|
300
|
+
function isGemini3ProModel(model) {
|
|
301
|
+
return /gemini-3(?:\.\d+)?-pro/.test(model.id.toLowerCase());
|
|
302
|
+
}
|
|
303
|
+
function isGemini3FlashModel(model) {
|
|
304
|
+
const id = model.id.toLowerCase();
|
|
305
|
+
return /gemini-3(?:\.\d+)?-flash/.test(id) || id === "gemini-flash-latest" || id === "gemini-flash-lite-latest";
|
|
306
|
+
}
|
|
307
|
+
function getDisabledThinkingConfig(model) {
|
|
308
|
+
if (isGemini3ProModel(model)) return { thinkingLevel: "LOW" };
|
|
309
|
+
if (isGemini3FlashModel(model)) return { thinkingLevel: "MINIMAL" };
|
|
310
|
+
if (isGemma4Model(model)) return { thinkingLevel: "MINIMAL" };
|
|
311
|
+
return { thinkingBudget: 0 };
|
|
312
|
+
}
|
|
313
|
+
function getThinkingLevel(effort, model) {
|
|
314
|
+
if (isGemini3ProModel(model)) switch (effort) {
|
|
315
|
+
case "minimal":
|
|
316
|
+
case "low": return "LOW";
|
|
317
|
+
case "medium":
|
|
318
|
+
case "high": return "HIGH";
|
|
319
|
+
}
|
|
320
|
+
if (isGemma4Model(model)) switch (effort) {
|
|
321
|
+
case "minimal":
|
|
322
|
+
case "low": return "MINIMAL";
|
|
323
|
+
case "medium":
|
|
324
|
+
case "high": return "HIGH";
|
|
325
|
+
}
|
|
326
|
+
switch (effort) {
|
|
327
|
+
case "minimal": return "MINIMAL";
|
|
328
|
+
case "low": return "LOW";
|
|
329
|
+
case "medium": return "MEDIUM";
|
|
330
|
+
case "high": return "HIGH";
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function getGoogleBudget(model, effort, customBudgets) {
|
|
334
|
+
if (customBudgets?.[effort] !== void 0) return customBudgets[effort];
|
|
335
|
+
if (model.id.includes("2.5-pro")) return {
|
|
336
|
+
minimal: 128,
|
|
337
|
+
low: 2048,
|
|
338
|
+
medium: 8192,
|
|
339
|
+
high: 32768
|
|
340
|
+
}[effort];
|
|
341
|
+
if (model.id.includes("2.5-flash-lite")) return {
|
|
342
|
+
minimal: 512,
|
|
343
|
+
low: 2048,
|
|
344
|
+
medium: 8192,
|
|
345
|
+
high: 24576
|
|
346
|
+
}[effort];
|
|
347
|
+
if (model.id.includes("2.5-flash")) return {
|
|
348
|
+
minimal: 128,
|
|
349
|
+
low: 2048,
|
|
350
|
+
medium: 8192,
|
|
351
|
+
high: 24576
|
|
352
|
+
}[effort];
|
|
353
|
+
return -1;
|
|
354
|
+
}
|
|
355
|
+
//#endregion
|
|
356
|
+
export { stream, streamSimple };
|
|
357
|
+
|
|
358
|
+
//# sourceMappingURL=google-generative-ai-B7OZs5lu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-generative-ai-B7OZs5lu.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,SAAS,OAAO;GAC3D,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,sBAA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