pi2dsh 0.13.2 → 0.13.3
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 +22 -19
- package/README.zh.md +18 -15
- package/dist/{analyzer-CJFwQlSG.mjs → analyzer-DBtUYKI1.mjs} +2 -2
- package/dist/{analyzer-CJFwQlSG.mjs.map → analyzer-DBtUYKI1.mjs.map} +1 -1
- package/dist/anthropic-messages-CaYTgvLF.mjs +6436 -0
- package/dist/anthropic-messages-CaYTgvLF.mjs.map +1 -0
- package/dist/azure-openai-responses-HKWkzl2m.mjs +208 -0
- package/dist/azure-openai-responses-HKWkzl2m.mjs.map +1 -0
- package/dist/cli.mjs +3 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/compat/pi-ai.d.mts +3 -2636
- package/dist/compat/pi-ai.mjs +3 -2
- package/dist/compat/pi-coding-agent.d.mts +2 -2
- package/dist/compat/pi-coding-agent.mjs +2 -2
- package/dist/{mcp-config-_idn-pzI.mjs → compatibility-Bz6ZXA7F.mjs} +8 -185
- package/dist/compatibility-Bz6ZXA7F.mjs.map +1 -0
- package/dist/completionchunk-Dhk56lZl.mjs +5212 -0
- package/dist/completionchunk-Dhk56lZl.mjs.map +1 -0
- package/dist/{credentials-oauth-Txs6oew8.mjs → credentials-oauth-CAohSLcB.mjs} +3 -3
- package/dist/{credentials-oauth-Txs6oew8.mjs.map → credentials-oauth-CAohSLcB.mjs.map} +1 -1
- package/dist/credentials-oauth.mjs +1 -1
- package/dist/deferred-tools-BD4g5QUx.mjs +32 -0
- package/dist/deferred-tools-BD4g5QUx.mjs.map +1 -0
- package/dist/diagnostics-BqYkodgB.mjs +35 -0
- package/dist/diagnostics-BqYkodgB.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/event-stream-QxN1yvIF.mjs +64 -0
- package/dist/event-stream-QxN1yvIF.mjs.map +1 -0
- package/dist/from-BCscBQ9P.mjs +3856 -0
- package/dist/from-BCscBQ9P.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-2gCFYp-t.mjs +356 -0
- package/dist/google-generative-ai-2gCFYp-t.mjs.map +1 -0
- package/dist/google-shared-75IdVyrx.mjs +29041 -0
- package/dist/google-shared-75IdVyrx.mjs.map +1 -0
- package/dist/google-vertex-Bhyo4z2i.mjs +400 -0
- package/dist/google-vertex-Bhyo4z2i.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 +12 -2
- package/dist/host.d.mts.map +1 -1
- package/dist/host.mjs +43 -5
- package/dist/host.mjs.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +40 -16
- package/dist/index.mjs.map +1 -1
- package/dist/json-parse-CZ0U0sj_.mjs +384 -0
- package/dist/json-parse-CZ0U0sj_.mjs.map +1 -0
- package/dist/mcp-config-jmzbgdHa.mjs +181 -0
- package/dist/mcp-config-jmzbgdHa.mjs.map +1 -0
- package/dist/mistral-conversations-DJyeTo8C.mjs +36921 -0
- package/dist/mistral-conversations-DJyeTo8C.mjs.map +1 -0
- package/dist/multipart-parser-SRcGkVuX.mjs +301 -0
- package/dist/multipart-parser-SRcGkVuX.mjs.map +1 -0
- package/dist/{pi-ai-D7PqVeWs.mjs → openai-DkzRh5_G.mjs} +78 -5063
- package/dist/openai-DkzRh5_G.mjs.map +1 -0
- package/dist/openai-codex-responses-DedxQjNG.mjs +1220 -0
- package/dist/openai-codex-responses-DedxQjNG.mjs.map +1 -0
- package/dist/openai-completions-DrjrWRdX.mjs +945 -0
- package/dist/openai-completions-DrjrWRdX.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-BRdGpBX6.mjs +251 -0
- package/dist/openai-responses-BRdGpBX6.mjs.map +1 -0
- package/dist/openai-responses-shared-BmnSvdKL.mjs +570 -0
- package/dist/openai-responses-shared-BmnSvdKL.mjs.map +1 -0
- package/dist/otel-CBhmS-NR.mjs +24935 -0
- package/dist/otel-CBhmS-NR.mjs.map +1 -0
- package/dist/pi-ai-CfokFhIL.d.mts +2673 -0
- package/dist/pi-ai-CfokFhIL.d.mts.map +1 -0
- package/dist/pi-ai-Dh7HUxbt.mjs +3239 -0
- package/dist/pi-ai-Dh7HUxbt.mjs.map +1 -0
- package/dist/{pi-coding-agent-B0PT23gE.d.mts → pi-coding-agent-69yY0ke-.d.mts} +4 -2
- package/dist/{pi-coding-agent-B0PT23gE.d.mts.map → pi-coding-agent-69yY0ke-.d.mts.map} +1 -1
- package/dist/{pi-coding-agent-BVZu0dHG.mjs → pi-coding-agent-Cvez0jkF.mjs} +0 -0
- package/dist/{pi-coding-agent-BVZu0dHG.mjs.map → pi-coding-agent-Cvez0jkF.mjs.map} +1 -1
- package/dist/pi-messages-D61G2tgs.mjs +307 -0
- package/dist/pi-messages-D61G2tgs.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-DEjs_Qlf.mjs → runtime-Dd2KhoX-.mjs} +659 -125
- package/dist/runtime-Dd2KhoX-.mjs.map +1 -0
- package/dist/runtime.d.mts +135 -26
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/simple-options-B_GO8FDE.mjs +456 -0
- package/dist/simple-options-B_GO8FDE.mjs.map +1 -0
- package/dist/src-DlTagfW5.mjs +1186 -0
- package/dist/src-DlTagfW5.mjs.map +1 -0
- package/dist/{types-7IWJPPvS.d.mts → types-B9VBF8le.d.mts} +2 -9
- package/dist/{types-7IWJPPvS.d.mts.map → types-B9VBF8le.d.mts.map} +1 -1
- package/package.json +2 -2
- package/dist/compat/pi-ai.d.mts.map +0 -1
- package/dist/mcp-config-_idn-pzI.mjs.map +0 -1
- package/dist/pi-ai-D7PqVeWs.mjs.map +0 -1
- package/dist/runtime-DEjs_Qlf.mjs.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
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/api/github-copilot-headers.js
|
|
3
|
+
function inferCopilotInitiator(messages) {
|
|
4
|
+
const last = messages[messages.length - 1];
|
|
5
|
+
return last && last.role !== "user" ? "agent" : "user";
|
|
6
|
+
}
|
|
7
|
+
function hasCopilotVisionInput(messages) {
|
|
8
|
+
return messages.some((msg) => {
|
|
9
|
+
if (msg.role === "user" && Array.isArray(msg.content)) return msg.content.some((c) => c.type === "image");
|
|
10
|
+
if (msg.role === "toolResult" && Array.isArray(msg.content)) return msg.content.some((c) => c.type === "image");
|
|
11
|
+
return false;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function buildCopilotDynamicHeaders(params) {
|
|
15
|
+
const headers = {
|
|
16
|
+
"X-Initiator": inferCopilotInitiator(params.messages),
|
|
17
|
+
"Openai-Intent": "conversation-edits"
|
|
18
|
+
};
|
|
19
|
+
if (params.hasImages) headers["Copilot-Vision-Request"] = "true";
|
|
20
|
+
return headers;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { hasCopilotVisionInput as n, buildCopilotDynamicHeaders as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=github-copilot-headers-CZo2QHrt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-copilot-headers-CZo2QHrt.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/github-copilot-headers.js"],"sourcesContent":["// Copilot expects X-Initiator to indicate whether the request is user-initiated\n// or agent-initiated (e.g. follow-up after assistant/tool messages).\nexport function inferCopilotInitiator(messages) {\n const last = messages[messages.length - 1];\n return last && last.role !== \"user\" ? \"agent\" : \"user\";\n}\n// Copilot requires Copilot-Vision-Request header when sending images\nexport function hasCopilotVisionInput(messages) {\n return messages.some((msg) => {\n if (msg.role === \"user\" && Array.isArray(msg.content)) {\n return msg.content.some((c) => c.type === \"image\");\n }\n if (msg.role === \"toolResult\" && Array.isArray(msg.content)) {\n return msg.content.some((c) => c.type === \"image\");\n }\n return false;\n });\n}\nexport function buildCopilotDynamicHeaders(params) {\n const headers = {\n \"X-Initiator\": inferCopilotInitiator(params.messages),\n \"Openai-Intent\": \"conversation-edits\",\n };\n if (params.hasImages) {\n headers[\"Copilot-Vision-Request\"] = \"true\";\n }\n return headers;\n}\n//# sourceMappingURL=github-copilot-headers.js.map"],"x_google_ignoreList":[0],"mappings":";;AAEA,SAAgB,sBAAsB,UAAU;CAC5C,MAAM,OAAO,SAAS,SAAS,SAAS;CACxC,OAAO,QAAQ,KAAK,SAAS,SAAS,UAAU;AACpD;AAEA,SAAgB,sBAAsB,UAAU;CAC5C,OAAO,SAAS,MAAM,QAAQ;EAC1B,IAAI,IAAI,SAAS,UAAU,MAAM,QAAQ,IAAI,OAAO,GAChD,OAAO,IAAI,QAAQ,MAAM,MAAM,EAAE,SAAS,OAAO;EAErD,IAAI,IAAI,SAAS,gBAAgB,MAAM,QAAQ,IAAI,OAAO,GACtD,OAAO,IAAI,QAAQ,MAAM,MAAM,EAAE,SAAS,OAAO;EAErD,OAAO;CACX,CAAC;AACL;AACA,SAAgB,2BAA2B,QAAQ;CAC/C,MAAM,UAAU;EACZ,eAAe,sBAAsB,OAAO,QAAQ;EACpD,iBAAiB;CACrB;CACA,IAAI,OAAO,WACP,QAAQ,4BAA4B;CAExC,OAAO;AACX"}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
|
|
2
|
+
import { t as AssistantMessageEventStream } from "./event-stream-QxN1yvIF.mjs";
|
|
3
|
+
import { m as clampThinkingLevel, p as calculateCost, r as buildBaseOptions, s as sanitizeSurrogates } from "./simple-options-B_GO8FDE.mjs";
|
|
4
|
+
import { n as normalizeProviderError, t as formatProviderError } from "./error-body-DKA3lknR.mjs";
|
|
5
|
+
import { n as providerHeadersToRecord } from "./headers-CPzZhJQn.mjs";
|
|
6
|
+
import { a as resolveGoogleFunctionCallingMode, c as supportsGoogleStrictToolSampling, i as mapStopReason, l as GoogleGenAI, n as convertTools, o as retainThoughtSignature, r as isThinkingPart, s as retryGoogleRequest, t as convertMessages } from "./google-shared-75IdVyrx.mjs";
|
|
7
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.84.1_ws@8.21.3_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js
|
|
8
|
+
let toolCallCounter = 0;
|
|
9
|
+
const stream = (model, context, options) => {
|
|
10
|
+
const stream = new AssistantMessageEventStream();
|
|
11
|
+
(async () => {
|
|
12
|
+
const output = {
|
|
13
|
+
role: "assistant",
|
|
14
|
+
content: [],
|
|
15
|
+
api: "google-generative-ai",
|
|
16
|
+
provider: model.provider,
|
|
17
|
+
model: model.id,
|
|
18
|
+
usage: {
|
|
19
|
+
input: 0,
|
|
20
|
+
output: 0,
|
|
21
|
+
cacheRead: 0,
|
|
22
|
+
cacheWrite: 0,
|
|
23
|
+
totalTokens: 0,
|
|
24
|
+
cost: {
|
|
25
|
+
input: 0,
|
|
26
|
+
output: 0,
|
|
27
|
+
cacheRead: 0,
|
|
28
|
+
cacheWrite: 0,
|
|
29
|
+
total: 0
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
stopReason: "pending",
|
|
33
|
+
timestamp: Date.now()
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
if (options?.fetch && options.fetch !== globalThis.fetch) throw new Error("Custom fetch is not supported by the Google Generative AI adapter");
|
|
37
|
+
const apiKey = options?.apiKey;
|
|
38
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
39
|
+
const client = createClient(model, apiKey, options?.headers);
|
|
40
|
+
let params = buildParams(model, context, options);
|
|
41
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
42
|
+
if (nextParams !== void 0) params = nextParams;
|
|
43
|
+
const googleStream = await retryGoogleRequest(() => client.models.generateContentStream(params), options);
|
|
44
|
+
stream.push({
|
|
45
|
+
type: "start",
|
|
46
|
+
partial: output
|
|
47
|
+
});
|
|
48
|
+
let currentBlock = null;
|
|
49
|
+
const blocks = output.content;
|
|
50
|
+
const blockIndex = () => blocks.length - 1;
|
|
51
|
+
for await (const chunk of googleStream) {
|
|
52
|
+
output.responseId ||= chunk.responseId;
|
|
53
|
+
const candidate = chunk.candidates?.[0];
|
|
54
|
+
if (candidate?.content?.parts) for (const part of candidate.content.parts) {
|
|
55
|
+
if (part.text !== void 0) {
|
|
56
|
+
const isThinking = isThinkingPart(part);
|
|
57
|
+
if (!currentBlock || isThinking && currentBlock.type !== "thinking" || !isThinking && currentBlock.type !== "text") {
|
|
58
|
+
if (currentBlock) {
|
|
59
|
+
if (currentBlock.type === "text") stream.push({
|
|
60
|
+
type: "text_end",
|
|
61
|
+
contentIndex: blocks.length - 1,
|
|
62
|
+
content: currentBlock.text,
|
|
63
|
+
partial: output
|
|
64
|
+
});
|
|
65
|
+
else stream.push({
|
|
66
|
+
type: "thinking_end",
|
|
67
|
+
contentIndex: blockIndex(),
|
|
68
|
+
content: currentBlock.thinking,
|
|
69
|
+
partial: output
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (isThinking) {
|
|
73
|
+
currentBlock = {
|
|
74
|
+
type: "thinking",
|
|
75
|
+
thinking: "",
|
|
76
|
+
thinkingSignature: void 0
|
|
77
|
+
};
|
|
78
|
+
output.content.push(currentBlock);
|
|
79
|
+
stream.push({
|
|
80
|
+
type: "thinking_start",
|
|
81
|
+
contentIndex: blockIndex(),
|
|
82
|
+
partial: output
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
currentBlock = {
|
|
86
|
+
type: "text",
|
|
87
|
+
text: ""
|
|
88
|
+
};
|
|
89
|
+
output.content.push(currentBlock);
|
|
90
|
+
stream.push({
|
|
91
|
+
type: "text_start",
|
|
92
|
+
contentIndex: blockIndex(),
|
|
93
|
+
partial: output
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (currentBlock.type === "thinking") {
|
|
98
|
+
currentBlock.thinking += part.text;
|
|
99
|
+
currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);
|
|
100
|
+
stream.push({
|
|
101
|
+
type: "thinking_delta",
|
|
102
|
+
contentIndex: blockIndex(),
|
|
103
|
+
delta: part.text,
|
|
104
|
+
partial: output
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
currentBlock.text += part.text;
|
|
108
|
+
currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);
|
|
109
|
+
stream.push({
|
|
110
|
+
type: "text_delta",
|
|
111
|
+
contentIndex: blockIndex(),
|
|
112
|
+
delta: part.text,
|
|
113
|
+
partial: output
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (part.functionCall) {
|
|
118
|
+
if (currentBlock) {
|
|
119
|
+
if (currentBlock.type === "text") stream.push({
|
|
120
|
+
type: "text_end",
|
|
121
|
+
contentIndex: blockIndex(),
|
|
122
|
+
content: currentBlock.text,
|
|
123
|
+
partial: output
|
|
124
|
+
});
|
|
125
|
+
else stream.push({
|
|
126
|
+
type: "thinking_end",
|
|
127
|
+
contentIndex: blockIndex(),
|
|
128
|
+
content: currentBlock.thinking,
|
|
129
|
+
partial: output
|
|
130
|
+
});
|
|
131
|
+
currentBlock = null;
|
|
132
|
+
}
|
|
133
|
+
const providedId = part.functionCall.id;
|
|
134
|
+
const toolCall = {
|
|
135
|
+
type: "toolCall",
|
|
136
|
+
id: !providedId || output.content.some((b) => b.type === "toolCall" && b.id === providedId) ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}` : providedId,
|
|
137
|
+
name: part.functionCall.name || "",
|
|
138
|
+
arguments: part.functionCall.args ?? {},
|
|
139
|
+
...part.thoughtSignature && { thoughtSignature: part.thoughtSignature }
|
|
140
|
+
};
|
|
141
|
+
output.content.push(toolCall);
|
|
142
|
+
stream.push({
|
|
143
|
+
type: "toolcall_start",
|
|
144
|
+
contentIndex: blockIndex(),
|
|
145
|
+
partial: output
|
|
146
|
+
});
|
|
147
|
+
stream.push({
|
|
148
|
+
type: "toolcall_delta",
|
|
149
|
+
contentIndex: blockIndex(),
|
|
150
|
+
delta: JSON.stringify(toolCall.arguments),
|
|
151
|
+
partial: output
|
|
152
|
+
});
|
|
153
|
+
stream.push({
|
|
154
|
+
type: "toolcall_end",
|
|
155
|
+
contentIndex: blockIndex(),
|
|
156
|
+
toolCall,
|
|
157
|
+
partial: output
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (candidate?.finishReason) {
|
|
162
|
+
output.rawStopReason = candidate.finishReason;
|
|
163
|
+
output.stopReason = mapStopReason(candidate.finishReason);
|
|
164
|
+
if (output.content.some((b) => b.type === "toolCall")) output.stopReason = "toolUse";
|
|
165
|
+
}
|
|
166
|
+
if (chunk.usageMetadata) {
|
|
167
|
+
output.usage = {
|
|
168
|
+
input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),
|
|
169
|
+
output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),
|
|
170
|
+
cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,
|
|
171
|
+
cacheWrite: 0,
|
|
172
|
+
reasoning: chunk.usageMetadata.thoughtsTokenCount || 0,
|
|
173
|
+
totalTokens: chunk.usageMetadata.totalTokenCount || 0,
|
|
174
|
+
cost: {
|
|
175
|
+
input: 0,
|
|
176
|
+
output: 0,
|
|
177
|
+
cacheRead: 0,
|
|
178
|
+
cacheWrite: 0,
|
|
179
|
+
total: 0
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
calculateCost(model, output.usage);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (currentBlock) {
|
|
186
|
+
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
|
+
}
|
|
199
|
+
if (options?.signal?.aborted) throw new Error("Request was aborted");
|
|
200
|
+
if (output.stopReason === "pending") throw new Error("Google stream ended without a finish reason");
|
|
201
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
202
|
+
const errorMessage = output.rawStopReason ? `Provider stopped with: ${output.rawStopReason}` : "An unknown error occurred";
|
|
203
|
+
throw new Error(errorMessage);
|
|
204
|
+
}
|
|
205
|
+
stream.push({
|
|
206
|
+
type: "done",
|
|
207
|
+
reason: output.stopReason,
|
|
208
|
+
message: output
|
|
209
|
+
});
|
|
210
|
+
stream.end();
|
|
211
|
+
} catch (error) {
|
|
212
|
+
for (const block of output.content) if ("index" in block) delete block.index;
|
|
213
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
214
|
+
output.errorMessage = formatProviderError(normalizeProviderError(error));
|
|
215
|
+
stream.push({
|
|
216
|
+
type: "error",
|
|
217
|
+
reason: output.stopReason,
|
|
218
|
+
error: output
|
|
219
|
+
});
|
|
220
|
+
stream.end();
|
|
221
|
+
}
|
|
222
|
+
})();
|
|
223
|
+
return stream;
|
|
224
|
+
};
|
|
225
|
+
const streamSimple = (model, context, options) => {
|
|
226
|
+
const apiKey = options?.apiKey;
|
|
227
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
228
|
+
const base = buildBaseOptions(model, context, options, apiKey);
|
|
229
|
+
if (!options?.reasoning) return stream(model, context, {
|
|
230
|
+
...base,
|
|
231
|
+
thinking: { enabled: false }
|
|
232
|
+
});
|
|
233
|
+
const clampedReasoning = clampThinkingLevel(model, options.reasoning);
|
|
234
|
+
const effort = clampedReasoning === "off" ? "high" : clampedReasoning;
|
|
235
|
+
const googleModel = model;
|
|
236
|
+
if (isGemini3ProModel(googleModel) || isGemini3FlashModel(googleModel) || isGemma4Model(googleModel)) return stream(model, context, {
|
|
237
|
+
...base,
|
|
238
|
+
thinking: {
|
|
239
|
+
enabled: true,
|
|
240
|
+
level: getThinkingLevel(effort, googleModel)
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return stream(model, context, {
|
|
244
|
+
...base,
|
|
245
|
+
thinking: {
|
|
246
|
+
enabled: true,
|
|
247
|
+
budgetTokens: getGoogleBudget(googleModel, effort, options.thinkingBudgets)
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
function createClient(model, apiKey, optionsHeaders) {
|
|
252
|
+
const httpOptions = {};
|
|
253
|
+
if (model.baseUrl) {
|
|
254
|
+
httpOptions.baseUrl = model.baseUrl;
|
|
255
|
+
httpOptions.apiVersion = "";
|
|
256
|
+
}
|
|
257
|
+
const headers = providerHeadersToRecord({
|
|
258
|
+
...model.headers,
|
|
259
|
+
...optionsHeaders
|
|
260
|
+
});
|
|
261
|
+
if (headers) httpOptions.headers = headers;
|
|
262
|
+
return new GoogleGenAI({
|
|
263
|
+
apiKey,
|
|
264
|
+
httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : void 0
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function buildParams(model, context, options = {}) {
|
|
268
|
+
const contents = convertMessages(model, context);
|
|
269
|
+
const generationConfig = {};
|
|
270
|
+
if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
|
|
271
|
+
if (options.maxTokens !== void 0) generationConfig.maxOutputTokens = options.maxTokens;
|
|
272
|
+
const functionCallingMode = context.tools?.length ? resolveGoogleFunctionCallingMode(context.tools, options.toolChoice, supportsGoogleStrictToolSampling(model.id)) : void 0;
|
|
273
|
+
const config = {
|
|
274
|
+
...Object.keys(generationConfig).length > 0 && generationConfig,
|
|
275
|
+
...context.systemPrompt && { systemInstruction: sanitizeSurrogates(context.systemPrompt) },
|
|
276
|
+
...context.tools && context.tools.length > 0 && { tools: convertTools(context.tools) },
|
|
277
|
+
...functionCallingMode !== void 0 && { toolConfig: { functionCallingConfig: { mode: functionCallingMode } } }
|
|
278
|
+
};
|
|
279
|
+
if (options.thinking?.enabled && model.reasoning) {
|
|
280
|
+
const thinkingConfig = { includeThoughts: true };
|
|
281
|
+
if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = options.thinking.level;
|
|
282
|
+
else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
|
|
283
|
+
config.thinkingConfig = thinkingConfig;
|
|
284
|
+
} else if (model.reasoning && options.thinking && !options.thinking.enabled) config.thinkingConfig = getDisabledThinkingConfig(model);
|
|
285
|
+
if (options.signal) {
|
|
286
|
+
if (options.signal.aborted) throw new Error("Request aborted");
|
|
287
|
+
config.abortSignal = options.signal;
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
model: model.id,
|
|
291
|
+
contents,
|
|
292
|
+
config
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function isGemma4Model(model) {
|
|
296
|
+
return /gemma-?4/.test(model.id.toLowerCase());
|
|
297
|
+
}
|
|
298
|
+
function isGemini3ProModel(model) {
|
|
299
|
+
return /gemini-3(?:\.\d+)?-pro/.test(model.id.toLowerCase());
|
|
300
|
+
}
|
|
301
|
+
function isGemini3FlashModel(model) {
|
|
302
|
+
const id = model.id.toLowerCase();
|
|
303
|
+
return /gemini-3(?:\.\d+)?-flash/.test(id) || id === "gemini-flash-latest" || id === "gemini-flash-lite-latest";
|
|
304
|
+
}
|
|
305
|
+
function getDisabledThinkingConfig(model) {
|
|
306
|
+
if (isGemini3ProModel(model)) return { thinkingLevel: "LOW" };
|
|
307
|
+
if (isGemini3FlashModel(model)) return { thinkingLevel: "MINIMAL" };
|
|
308
|
+
if (isGemma4Model(model)) return { thinkingLevel: "MINIMAL" };
|
|
309
|
+
return { thinkingBudget: 0 };
|
|
310
|
+
}
|
|
311
|
+
function getThinkingLevel(effort, model) {
|
|
312
|
+
if (isGemini3ProModel(model)) switch (effort) {
|
|
313
|
+
case "minimal":
|
|
314
|
+
case "low": return "LOW";
|
|
315
|
+
case "medium":
|
|
316
|
+
case "high": return "HIGH";
|
|
317
|
+
}
|
|
318
|
+
if (isGemma4Model(model)) switch (effort) {
|
|
319
|
+
case "minimal":
|
|
320
|
+
case "low": return "MINIMAL";
|
|
321
|
+
case "medium":
|
|
322
|
+
case "high": return "HIGH";
|
|
323
|
+
}
|
|
324
|
+
switch (effort) {
|
|
325
|
+
case "minimal": return "MINIMAL";
|
|
326
|
+
case "low": return "LOW";
|
|
327
|
+
case "medium": return "MEDIUM";
|
|
328
|
+
case "high": return "HIGH";
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function getGoogleBudget(model, effort, customBudgets) {
|
|
332
|
+
if (customBudgets?.[effort] !== void 0) return customBudgets[effort];
|
|
333
|
+
if (model.id.includes("2.5-pro")) return {
|
|
334
|
+
minimal: 128,
|
|
335
|
+
low: 2048,
|
|
336
|
+
medium: 8192,
|
|
337
|
+
high: 32768
|
|
338
|
+
}[effort];
|
|
339
|
+
if (model.id.includes("2.5-flash-lite")) return {
|
|
340
|
+
minimal: 512,
|
|
341
|
+
low: 2048,
|
|
342
|
+
medium: 8192,
|
|
343
|
+
high: 24576
|
|
344
|
+
}[effort];
|
|
345
|
+
if (model.id.includes("2.5-flash")) return {
|
|
346
|
+
minimal: 128,
|
|
347
|
+
low: 2048,
|
|
348
|
+
medium: 8192,
|
|
349
|
+
high: 24576
|
|
350
|
+
}[effort];
|
|
351
|
+
return -1;
|
|
352
|
+
}
|
|
353
|
+
//#endregion
|
|
354
|
+
export { stream, streamSimple };
|
|
355
|
+
|
|
356
|
+
//# sourceMappingURL=google-generative-ai-2gCFYp-t.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-generative-ai-2gCFYp-t.mjs","names":[],"sources":["../node_modules/.pnpm/@earendil-works+pi-ai@0.84.1_ws@8.21.3_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js"],"sourcesContent":["import { GoogleGenAI, } from \"@google/genai\";\nimport { calculateCost, clampThinkingLevel } from \"../models.js\";\nimport { formatProviderError, normalizeProviderError } from \"../utils/error-body.js\";\nimport { AssistantMessageEventStream } from \"../utils/event-stream.js\";\nimport { providerHeadersToRecord } from \"../utils/headers.js\";\nimport { sanitizeSurrogates } from \"../utils/sanitize-unicode.js\";\nimport { convertMessages, convertTools, isThinkingPart, mapStopReason, resolveGoogleFunctionCallingMode, retainThoughtSignature, retryGoogleRequest, supportsGoogleStrictToolSampling, } from \"./google-shared.js\";\nimport { buildBaseOptions } from \"./simple-options.js\";\n// Counter for generating unique tool call IDs\nlet toolCallCounter = 0;\nexport const stream = (model, context, options) => {\n const stream = new AssistantMessageEventStream();\n (async () => {\n const output = {\n role: \"assistant\",\n content: [],\n api: \"google-generative-ai\",\n provider: model.provider,\n model: model.id,\n usage: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n totalTokens: 0,\n cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n },\n stopReason: \"pending\",\n timestamp: Date.now(),\n };\n try {\n if (options?.fetch && options.fetch !== globalThis.fetch) {\n throw new Error(\"Custom fetch is not supported by the Google Generative AI adapter\");\n }\n const apiKey = options?.apiKey;\n if (!apiKey) {\n throw new Error(`No API key for provider: ${model.provider}`);\n }\n const client = createClient(model, apiKey, options?.headers);\n let params = buildParams(model, context, options);\n const nextParams = await options?.onPayload?.(params, model);\n if (nextParams !== undefined) {\n params = nextParams;\n }\n const googleStream = await retryGoogleRequest(() => client.models.generateContentStream(params), options);\n stream.push({ type: \"start\", partial: output });\n let currentBlock = null;\n const blocks = output.content;\n const blockIndex = () => blocks.length - 1;\n for await (const chunk of googleStream) {\n // @google/genai documents GenerateContentResponse.responseId as an output-only field\n // used to identify each response. Keep the first non-empty one from the stream.\n output.responseId ||= chunk.responseId;\n const candidate = chunk.candidates?.[0];\n if (candidate?.content?.parts) {\n for (const part of candidate.content.parts) {\n if (part.text !== undefined) {\n const isThinking = isThinkingPart(part);\n if (!currentBlock ||\n (isThinking && currentBlock.type !== \"thinking\") ||\n (!isThinking && currentBlock.type !== \"text\")) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blocks.length - 1,\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (isThinking) {\n currentBlock = { type: \"thinking\", thinking: \"\", thinkingSignature: undefined };\n output.content.push(currentBlock);\n stream.push({ type: \"thinking_start\", contentIndex: blockIndex(), partial: output });\n }\n else {\n currentBlock = { type: \"text\", text: \"\" };\n output.content.push(currentBlock);\n stream.push({ type: \"text_start\", contentIndex: blockIndex(), partial: output });\n }\n }\n if (currentBlock.type === \"thinking\") {\n currentBlock.thinking += part.text;\n currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);\n stream.push({\n type: \"thinking_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n else {\n currentBlock.text += part.text;\n currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);\n stream.push({\n type: \"text_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n }\n if (part.functionCall) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n currentBlock = null;\n }\n // Generate unique ID if not provided or if it's a duplicate\n const providedId = part.functionCall.id;\n const needsNewId = !providedId || output.content.some((b) => b.type === \"toolCall\" && b.id === providedId);\n const toolCallId = needsNewId\n ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}`\n : providedId;\n const toolCall = {\n type: \"toolCall\",\n id: toolCallId,\n name: part.functionCall.name || \"\",\n arguments: part.functionCall.args ?? {},\n ...(part.thoughtSignature && { thoughtSignature: part.thoughtSignature }),\n };\n output.content.push(toolCall);\n stream.push({ type: \"toolcall_start\", contentIndex: blockIndex(), partial: output });\n stream.push({\n type: \"toolcall_delta\",\n contentIndex: blockIndex(),\n delta: JSON.stringify(toolCall.arguments),\n partial: output,\n });\n stream.push({ type: \"toolcall_end\", contentIndex: blockIndex(), toolCall, partial: output });\n }\n }\n }\n if (candidate?.finishReason) {\n output.rawStopReason = candidate.finishReason;\n output.stopReason = mapStopReason(candidate.finishReason);\n if (output.content.some((b) => b.type === \"toolCall\")) {\n output.stopReason = \"toolUse\";\n }\n }\n if (chunk.usageMetadata) {\n output.usage = {\n input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),\n output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),\n cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,\n cacheWrite: 0,\n reasoning: chunk.usageMetadata.thoughtsTokenCount || 0,\n totalTokens: chunk.usageMetadata.totalTokenCount || 0,\n cost: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n total: 0,\n },\n };\n calculateCost(model, output.usage);\n }\n }\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (options?.signal?.aborted) {\n throw new Error(\"Request was aborted\");\n }\n if (output.stopReason === \"pending\") {\n throw new Error(\"Google stream ended without a finish reason\");\n }\n if (output.stopReason === \"aborted\" || output.stopReason === \"error\") {\n const errorMessage = output.rawStopReason\n ? `Provider stopped with: ${output.rawStopReason}`\n : \"An unknown error occurred\";\n throw new Error(errorMessage);\n }\n stream.push({ type: \"done\", reason: output.stopReason, message: output });\n stream.end();\n }\n catch (error) {\n // Remove internal index property used during streaming\n for (const block of output.content) {\n if (\"index\" in block) {\n delete block.index;\n }\n }\n output.stopReason = options?.signal?.aborted ? \"aborted\" : \"error\";\n output.errorMessage = formatProviderError(normalizeProviderError(error));\n stream.push({ type: \"error\", reason: output.stopReason, error: output });\n stream.end();\n }\n })();\n return stream;\n};\nexport const streamSimple = (model, context, options) => {\n const apiKey = options?.apiKey;\n if (!apiKey) {\n throw new Error(`No API key for provider: ${model.provider}`);\n }\n const base = buildBaseOptions(model, context, options, apiKey);\n if (!options?.reasoning) {\n return stream(model, context, { ...base, thinking: { enabled: false } });\n }\n const clampedReasoning = clampThinkingLevel(model, options.reasoning);\n const effort = (clampedReasoning === \"off\" ? \"high\" : clampedReasoning);\n const googleModel = model;\n if (isGemini3ProModel(googleModel) || isGemini3FlashModel(googleModel) || isGemma4Model(googleModel)) {\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n level: getThinkingLevel(effort, googleModel),\n },\n });\n }\n return stream(model, context, {\n ...base,\n thinking: {\n enabled: true,\n budgetTokens: getGoogleBudget(googleModel, effort, options.thinkingBudgets),\n },\n });\n};\nfunction createClient(model, apiKey, optionsHeaders) {\n const httpOptions = {};\n if (model.baseUrl) {\n httpOptions.baseUrl = model.baseUrl;\n httpOptions.apiVersion = \"\"; // baseUrl already includes version path, don't append\n }\n const headers = providerHeadersToRecord({ ...model.headers, ...optionsHeaders });\n if (headers) {\n httpOptions.headers = headers;\n }\n return new GoogleGenAI({\n apiKey,\n httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : undefined,\n });\n}\nfunction buildParams(model, context, options = {}) {\n const contents = convertMessages(model, context);\n const generationConfig = {};\n if (options.temperature !== undefined) {\n generationConfig.temperature = options.temperature;\n }\n if (options.maxTokens !== undefined) {\n generationConfig.maxOutputTokens = options.maxTokens;\n }\n const functionCallingMode = context.tools?.length\n ? resolveGoogleFunctionCallingMode(context.tools, options.toolChoice, supportsGoogleStrictToolSampling(model.id))\n : undefined;\n const config = {\n ...(Object.keys(generationConfig).length > 0 && generationConfig),\n ...(context.systemPrompt && { systemInstruction: sanitizeSurrogates(context.systemPrompt) }),\n ...(context.tools && context.tools.length > 0 && { tools: convertTools(context.tools) }),\n ...(functionCallingMode !== undefined && {\n toolConfig: { functionCallingConfig: { mode: functionCallingMode } },\n }),\n };\n if (options.thinking?.enabled && model.reasoning) {\n const thinkingConfig = { includeThoughts: true };\n if (options.thinking.level !== undefined) {\n // Cast to any since our GoogleThinkingLevel mirrors Google's ThinkingLevel enum values\n thinkingConfig.thinkingLevel = options.thinking.level;\n }\n else if (options.thinking.budgetTokens !== undefined) {\n thinkingConfig.thinkingBudget = options.thinking.budgetTokens;\n }\n config.thinkingConfig = thinkingConfig;\n }\n else if (model.reasoning && options.thinking && !options.thinking.enabled) {\n config.thinkingConfig = getDisabledThinkingConfig(model);\n }\n if (options.signal) {\n if (options.signal.aborted) {\n throw new Error(\"Request aborted\");\n }\n config.abortSignal = options.signal;\n }\n const params = {\n model: model.id,\n contents,\n config,\n };\n return params;\n}\nfunction isGemma4Model(model) {\n return /gemma-?4/.test(model.id.toLowerCase());\n}\nfunction isGemini3ProModel(model) {\n return /gemini-3(?:\\.\\d+)?-pro/.test(model.id.toLowerCase());\n}\nfunction isGemini3FlashModel(model) {\n const id = model.id.toLowerCase();\n return /gemini-3(?:\\.\\d+)?-flash/.test(id) || id === \"gemini-flash-latest\" || id === \"gemini-flash-lite-latest\";\n}\nfunction getDisabledThinkingConfig(model) {\n // Google docs: Gemini 3.1 Pro cannot disable thinking, and Gemini 3 Flash / Flash-Lite\n // do not support full thinking-off either. For Gemini 3 models, use the lowest supported\n // thinkingLevel without includeThoughts so hidden thinking remains invisible to pi.\n if (isGemini3ProModel(model)) {\n return { thinkingLevel: \"LOW\" };\n }\n if (isGemini3FlashModel(model)) {\n return { thinkingLevel: \"MINIMAL\" };\n }\n if (isGemma4Model(model)) {\n return { thinkingLevel: \"MINIMAL\" };\n }\n // Gemini 2.x supports disabling via thinkingBudget = 0.\n return { thinkingBudget: 0 };\n}\nfunction getThinkingLevel(effort, model) {\n if (isGemini3ProModel(model)) {\n switch (effort) {\n case \"minimal\":\n case \"low\":\n return \"LOW\";\n case \"medium\":\n case \"high\":\n return \"HIGH\";\n }\n }\n if (isGemma4Model(model)) {\n switch (effort) {\n case \"minimal\":\n case \"low\":\n return \"MINIMAL\";\n case \"medium\":\n case \"high\":\n return \"HIGH\";\n }\n }\n switch (effort) {\n case \"minimal\":\n return \"MINIMAL\";\n case \"low\":\n return \"LOW\";\n case \"medium\":\n return \"MEDIUM\";\n case \"high\":\n return \"HIGH\";\n }\n}\nfunction getGoogleBudget(model, effort, customBudgets) {\n if (customBudgets?.[effort] !== undefined) {\n return customBudgets[effort];\n }\n if (model.id.includes(\"2.5-pro\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 32768,\n };\n return budgets[effort];\n }\n if (model.id.includes(\"2.5-flash-lite\")) {\n const budgets = {\n minimal: 512,\n low: 2048,\n medium: 8192,\n high: 24576,\n };\n return budgets[effort];\n }\n if (model.id.includes(\"2.5-flash\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 24576,\n };\n return budgets[effort];\n }\n return -1;\n}\n//# sourceMappingURL=google-generative-ai.js.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,sBAAsB,MAAM,GAAG,OAAO;GACxG,OAAO,KAAK;IAAE,MAAM;IAAS,SAAS;GAAO,CAAC;GAC9C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