@vibe-lark/larkpal 0.1.84 → 0.1.86
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/dist/account-id-BM1T6029-DYjVxojW.mjs +46 -0
- package/dist/activation-context--5yu1dPF-Bwsn3moT.mjs +172 -0
- package/dist/anthropic-TH8ERTXK.mjs +5962 -0
- package/dist/assistant-visible-text-DuFWokAt-CsbII5KS.mjs +596 -0
- package/dist/azure-openai-responses-Bt_Ag9Er.mjs +166 -0
- package/dist/boundary-file-read-BSd9MXPy--KThL5e6.mjs +594 -0
- package/dist/browser-lifecycle-cleanup-BdNsMhMD-O3tnAM4i.mjs +60 -0
- package/dist/build-DgTrEpge.mjs +3333 -0
- package/dist/bundled-compat-BpaDaAAu-D7oazKjD.mjs +5216 -0
- package/dist/bundled-dir-U738ay4K-DXK0q_TV.mjs +258 -0
- package/dist/call-DimWbpgJ-ColD4W-y.mjs +9993 -0
- package/dist/channel-bootstrap.runtime-BVclcGv1-DJv_Z-Kr.mjs +2 -0
- package/dist/channel-bootstrap.runtime-Cwcr38m2-VRfVCR-i.mjs +33 -0
- package/dist/chunk-D6SyT4dJ.mjs +36 -0
- package/dist/cli.mjs +6 -6
- package/dist/command-format-LSnUCVVF-BQ2SMKka.mjs +685 -0
- package/dist/config-Bim2pi8a-BQUdfiEi.mjs +9 -0
- package/dist/delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs +72 -0
- package/dist/diagnostic-ClMwNnUA-D6nUtLnb.mjs +140 -0
- package/dist/dist-CEGw8-2W.mjs +429 -0
- package/dist/dist-DD2aJ2UL.mjs +125135 -0
- package/dist/env-api-keys-BVvSg7T2.mjs +68 -0
- package/dist/event-stream-xaQWmyas.mjs +15226 -0
- package/dist/facade-loader-DFzIYYt_-CIr4HKtE.mjs +194 -0
- package/dist/from-DF7cl2wz.mjs +3842 -0
- package/dist/gateway-method-policy-C7rf0SeV-CJQMEYIE.mjs +28 -0
- package/dist/github-copilot-headers-DjqWtUoP.mjs +22 -0
- package/dist/google-C2pVrgBZ.mjs +336 -0
- package/dist/google-gemini-cli-BBxgS5Ho.mjs +623 -0
- package/dist/google-shared-BsWgwEk1.mjs +22791 -0
- package/dist/google-vertex-BsVLJrrC.mjs +358 -0
- package/dist/hash-DAFtW_W7.mjs +16 -0
- package/dist/headers-R3HdCbAE.mjs +8 -0
- package/dist/home-dir-C44RaPME-CBRS4HLP.mjs +93 -0
- package/dist/ids-BPsM98Uu-CwuxvUai.mjs +77 -0
- package/dist/image-2w3cApg7-CxpHvoB5.mjs +207 -0
- package/dist/io-CH2g3vsv-BOGlLlB8.mjs +26218 -0
- package/dist/jiti-loader-cache-Bat69wam-D6hCxboy.mjs +5049 -0
- package/dist/json-file-BQRNuxmK-DhJM5NsG.mjs +108 -0
- package/dist/json-parse-v_HIJjjI.mjs +381 -0
- package/dist/jws-GFcTvvVT.mjs +2291 -0
- package/dist/{lark-cli-provider-7LvtOIF_.mjs → lark-cli-provider-BARgbbmo.mjs} +1 -1
- package/dist/{live-smoke-nvTUPtrv.mjs → live-smoke-BhkBOcH9.mjs} +3 -3
- package/dist/load-context-mb7uvLSn-B10MAi3I.mjs +29 -0
- package/dist/loader-708jrx4Y-BOswuvpe.mjs +5053 -0
- package/dist/main.mjs +56780 -476
- package/dist/manifest-registry-_hxKCS2K-CZdeyN0f.mjs +3512 -0
- package/dist/mcp-server.mjs +1 -1
- package/dist/message-channel-Bk_YHfQg-AeNrPPpp.mjs +50 -0
- package/dist/message-channel-core-DTA--Gjh-CY4Tkb7N.mjs +29 -0
- package/dist/message.config.runtime-K-k4XOyq-DZTmXomP.mjs +2 -0
- package/dist/message.gateway.runtime-DqHOHRTQ-DH4ml0YF.mjs +2 -0
- package/dist/mistral-CaR4DiLu.mjs +28657 -0
- package/dist/model-auth-env-oyg2Hexc-DU_rOUU5.mjs +1306 -0
- package/dist/models-config-BmpSQJQF-Gfvh1n3A.mjs +1282 -0
- package/dist/models-config.runtime-BsU_22xk.mjs +2 -0
- package/dist/multipart-parser-DedmaB5g.mjs +294 -0
- package/dist/oauth-DOJeGfcE.mjs +6392 -0
- package/dist/openai-BDtIh3Ja.mjs +6693 -0
- package/dist/openai-codex-responses-C5EORu31.mjs +664 -0
- package/dist/openai-completions-CR_cS6gX.mjs +669 -0
- package/dist/openai-responses-oGxwZyuC.mjs +184 -0
- package/dist/openai-responses-shared-BixMSDZE.mjs +398 -0
- package/dist/paths-D6msg0S1-C2lYuisN.mjs +189 -0
- package/dist/paths-D92DjaZ--CTOESW2b.mjs +192 -0
- package/dist/pi-model-discovery-Bd0TWzo8-BFsJmeMb.mjs +227 -0
- package/dist/pi-model-discovery-runtime-CCCZxkd8.mjs +2 -0
- package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-C5ewk8kK.mjs +399 -0
- package/dist/plugin-auto-enable-DdH3n9V8-DsA1isaF.mjs +1456 -0
- package/dist/process-scoped-map-B2cWkYET-CXwUZ8CZ.mjs +61 -0
- package/dist/provider-discovery.runtime-BPzz1PFj.mjs +58 -0
- package/dist/provider-model-compat-CFqcq0it-BDDuBI3A.mjs +118 -0
- package/dist/provider-runtime-C8rljsNs-CIT93zoy.mjs +2 -0
- package/dist/provider-runtime-CT50mNIX-BwEV6GyO.mjs +573 -0
- package/dist/provider-stream-COLujAAo-CbJPDngm.mjs +35449 -0
- package/dist/providers.runtime-Ba7tOlq7-CXkhkzU9.mjs +219 -0
- package/dist/public-surface-loader-BVl0NQAE-C0piXtsT.mjs +117 -0
- package/dist/resolve-C33B7eeu-BNvYTl6k.mjs +1041 -0
- package/dist/runtime-Cym-fqI8-DaSDMH-a.mjs +120 -0
- package/dist/runtime-channel-state-CohMybAh-hXR6y5Gx.mjs +19 -0
- package/dist/runtime-snapshot-C54O1-gI-40cbyi7P.mjs +677 -0
- package/dist/runtime-state-IBOIXKOx-Bf9tcLvc.mjs +10 -0
- package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BCVImm7a.mjs +39 -0
- package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-Cb4nJkRT.mjs +2 -0
- package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-BrQdXzOQ.mjs +2 -0
- package/dist/session-archive.runtime-B52_5vs4-BG-_IwNJ.mjs +2 -0
- package/dist/session-key-Cn2QoOyX-CuHbJMgR.mjs +82 -0
- package/dist/session-transcript-files.fs-DEeFXruQ-B1PF6nLy.mjs +147 -0
- package/dist/src-BgCX0MLG.mjs +813 -0
- package/dist/src-DYbqlAqf.mjs +1177 -0
- package/dist/subagent-announce-L5WsQatW-CQWI9GMd.mjs +344 -0
- package/dist/subagent-announce.registry.runtime-DiqZyeTs-BKuniyi3.mjs +28 -0
- package/dist/subagent-registry-steer-runtime-DFgZFC0j-BhBz0roy.mjs +211 -0
- package/dist/subagent-system-prompt-C1qnN--K-DpnTFP47.mjs +3061 -0
- package/dist/target-parsing-loaded-DKkb6jJY-BMD4CkpS.mjs +1002 -0
- package/dist/task-registry-delivery-runtime-Dd1CUkZF-C8U40a3O.mjs +2950 -0
- package/dist/task-registry-delivery-runtime-ragbeVx5-CNbFAkjD.mjs +2 -0
- package/dist/thinking-Bh-7MqXz-D3woGbO7.mjs +2 -0
- package/dist/transcript-E_-ISOkD-DWCfZP2p.mjs +2019 -0
- package/dist/transcript.runtime-BqhvZZdl-BPy42vBP.mjs +2 -0
- package/dist/transform-messages-DbhIzTxq.mjs +207 -0
- package/dist/web-provider-public-artifacts-BlpRwIUS-CGPSV4W2.mjs +295 -0
- package/dist/web-search-providers.runtime--0aUtC3b-DyuhC95V.mjs +200 -0
- package/package.json +3 -3
- package/dist/rolldown-runtime-wcPFST8Q.mjs +0 -13
- /package/dist/{interactive-init-B6j8j_Ap.mjs → interactive-init-BXQBalNr.mjs} +0 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { r as calculateCost, t as AssistantMessageEventStream } from "./event-stream-xaQWmyas.mjs";
|
|
2
|
+
import { a as sanitizeSurrogates, i as clampReasoning, r as buildBaseOptions } from "./transform-messages-DbhIzTxq.mjs";
|
|
3
|
+
import { c as GoogleGenAI, i as mapStopReason, l as ThinkingLevel, n as convertTools, o as mapToolChoice, r as isThinkingPart, s as retainThoughtSignature, t as convertMessages } from "./google-shared-BsWgwEk1.mjs";
|
|
4
|
+
//#region node_modules/.pnpm/@mariozechner+pi-ai@0.69.0_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__ws@8.21.0_zod@4.3.6/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js
|
|
5
|
+
const API_VERSION = "v1";
|
|
6
|
+
const GCP_VERTEX_CREDENTIALS_MARKER = "gcp-vertex-credentials";
|
|
7
|
+
const THINKING_LEVEL_MAP = {
|
|
8
|
+
THINKING_LEVEL_UNSPECIFIED: ThinkingLevel.THINKING_LEVEL_UNSPECIFIED,
|
|
9
|
+
MINIMAL: ThinkingLevel.MINIMAL,
|
|
10
|
+
LOW: ThinkingLevel.LOW,
|
|
11
|
+
MEDIUM: ThinkingLevel.MEDIUM,
|
|
12
|
+
HIGH: ThinkingLevel.HIGH
|
|
13
|
+
};
|
|
14
|
+
let toolCallCounter = 0;
|
|
15
|
+
const streamGoogleVertex = (model, context, options) => {
|
|
16
|
+
const stream = new AssistantMessageEventStream();
|
|
17
|
+
(async () => {
|
|
18
|
+
const output = {
|
|
19
|
+
role: "assistant",
|
|
20
|
+
content: [],
|
|
21
|
+
api: "google-vertex",
|
|
22
|
+
provider: model.provider,
|
|
23
|
+
model: model.id,
|
|
24
|
+
usage: {
|
|
25
|
+
input: 0,
|
|
26
|
+
output: 0,
|
|
27
|
+
cacheRead: 0,
|
|
28
|
+
cacheWrite: 0,
|
|
29
|
+
totalTokens: 0,
|
|
30
|
+
cost: {
|
|
31
|
+
input: 0,
|
|
32
|
+
output: 0,
|
|
33
|
+
cacheRead: 0,
|
|
34
|
+
cacheWrite: 0,
|
|
35
|
+
total: 0
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
stopReason: "stop",
|
|
39
|
+
timestamp: Date.now()
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
const apiKey = resolveApiKey(options);
|
|
43
|
+
const client = apiKey ? createClientWithApiKey(model, apiKey, options?.headers) : createClient(model, resolveProject(options), resolveLocation(options), options?.headers);
|
|
44
|
+
let params = buildParams(model, context, options);
|
|
45
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
46
|
+
if (nextParams !== void 0) params = nextParams;
|
|
47
|
+
const googleStream = await client.models.generateContentStream(params);
|
|
48
|
+
stream.push({
|
|
49
|
+
type: "start",
|
|
50
|
+
partial: output
|
|
51
|
+
});
|
|
52
|
+
let currentBlock = null;
|
|
53
|
+
const blocks = output.content;
|
|
54
|
+
const blockIndex = () => blocks.length - 1;
|
|
55
|
+
for await (const chunk of googleStream) {
|
|
56
|
+
output.responseId ||= chunk.responseId;
|
|
57
|
+
const candidate = chunk.candidates?.[0];
|
|
58
|
+
if (candidate?.content?.parts) for (const part of candidate.content.parts) {
|
|
59
|
+
if (part.text !== void 0) {
|
|
60
|
+
const isThinking = isThinkingPart(part);
|
|
61
|
+
if (!currentBlock || isThinking && currentBlock.type !== "thinking" || !isThinking && currentBlock.type !== "text") {
|
|
62
|
+
if (currentBlock) if (currentBlock.type === "text") stream.push({
|
|
63
|
+
type: "text_end",
|
|
64
|
+
contentIndex: blocks.length - 1,
|
|
65
|
+
content: currentBlock.text,
|
|
66
|
+
partial: output
|
|
67
|
+
});
|
|
68
|
+
else stream.push({
|
|
69
|
+
type: "thinking_end",
|
|
70
|
+
contentIndex: blockIndex(),
|
|
71
|
+
content: currentBlock.thinking,
|
|
72
|
+
partial: output
|
|
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.stopReason = mapStopReason(candidate.finishReason);
|
|
165
|
+
if (output.content.some((b) => b.type === "toolCall")) 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
|
+
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) if (currentBlock.type === "text") stream.push({
|
|
186
|
+
type: "text_end",
|
|
187
|
+
contentIndex: blockIndex(),
|
|
188
|
+
content: currentBlock.text,
|
|
189
|
+
partial: output
|
|
190
|
+
});
|
|
191
|
+
else stream.push({
|
|
192
|
+
type: "thinking_end",
|
|
193
|
+
contentIndex: blockIndex(),
|
|
194
|
+
content: currentBlock.thinking,
|
|
195
|
+
partial: output
|
|
196
|
+
});
|
|
197
|
+
if (options?.signal?.aborted) throw new Error("Request was aborted");
|
|
198
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error("An unknown error occurred");
|
|
199
|
+
stream.push({
|
|
200
|
+
type: "done",
|
|
201
|
+
reason: output.stopReason,
|
|
202
|
+
message: output
|
|
203
|
+
});
|
|
204
|
+
stream.end();
|
|
205
|
+
} catch (error) {
|
|
206
|
+
for (const block of output.content) if ("index" in block) delete block.index;
|
|
207
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
208
|
+
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
209
|
+
stream.push({
|
|
210
|
+
type: "error",
|
|
211
|
+
reason: output.stopReason,
|
|
212
|
+
error: output
|
|
213
|
+
});
|
|
214
|
+
stream.end();
|
|
215
|
+
}
|
|
216
|
+
})();
|
|
217
|
+
return stream;
|
|
218
|
+
};
|
|
219
|
+
const streamSimpleGoogleVertex = (model, context, options) => {
|
|
220
|
+
const base = buildBaseOptions(model, options, void 0);
|
|
221
|
+
if (!options?.reasoning) return streamGoogleVertex(model, context, {
|
|
222
|
+
...base,
|
|
223
|
+
thinking: { enabled: false }
|
|
224
|
+
});
|
|
225
|
+
const effort = clampReasoning(options.reasoning);
|
|
226
|
+
const geminiModel = model;
|
|
227
|
+
if (isGemini3ProModel(geminiModel) || isGemini3FlashModel(geminiModel)) return streamGoogleVertex(model, context, {
|
|
228
|
+
...base,
|
|
229
|
+
thinking: {
|
|
230
|
+
enabled: true,
|
|
231
|
+
level: getGemini3ThinkingLevel(effort, geminiModel)
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
return streamGoogleVertex(model, context, {
|
|
235
|
+
...base,
|
|
236
|
+
thinking: {
|
|
237
|
+
enabled: true,
|
|
238
|
+
budgetTokens: getGoogleBudget(geminiModel, effort, options.thinkingBudgets)
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
function createClient(model, project, location, optionsHeaders) {
|
|
243
|
+
const httpOptions = {};
|
|
244
|
+
if (model.headers || optionsHeaders) httpOptions.headers = {
|
|
245
|
+
...model.headers,
|
|
246
|
+
...optionsHeaders
|
|
247
|
+
};
|
|
248
|
+
return new GoogleGenAI({
|
|
249
|
+
vertexai: true,
|
|
250
|
+
project,
|
|
251
|
+
location,
|
|
252
|
+
apiVersion: API_VERSION,
|
|
253
|
+
httpOptions: Object.values(httpOptions).some(Boolean) ? httpOptions : void 0
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function createClientWithApiKey(model, apiKey, optionsHeaders) {
|
|
257
|
+
const httpOptions = {};
|
|
258
|
+
if (model.headers || optionsHeaders) httpOptions.headers = {
|
|
259
|
+
...model.headers,
|
|
260
|
+
...optionsHeaders
|
|
261
|
+
};
|
|
262
|
+
return new GoogleGenAI({
|
|
263
|
+
vertexai: true,
|
|
264
|
+
apiKey,
|
|
265
|
+
apiVersion: API_VERSION,
|
|
266
|
+
httpOptions: Object.values(httpOptions).some(Boolean) ? httpOptions : void 0
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function resolveApiKey(options) {
|
|
270
|
+
const apiKey = options?.apiKey?.trim() || process.env.GOOGLE_CLOUD_API_KEY?.trim();
|
|
271
|
+
if (!apiKey || apiKey === GCP_VERTEX_CREDENTIALS_MARKER || isPlaceholderApiKey(apiKey)) return;
|
|
272
|
+
return apiKey;
|
|
273
|
+
}
|
|
274
|
+
function isPlaceholderApiKey(apiKey) {
|
|
275
|
+
return /^<[^>]+>$/.test(apiKey);
|
|
276
|
+
}
|
|
277
|
+
function resolveProject(options) {
|
|
278
|
+
const project = options?.project || process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT;
|
|
279
|
+
if (!project) throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");
|
|
280
|
+
return project;
|
|
281
|
+
}
|
|
282
|
+
function resolveLocation(options) {
|
|
283
|
+
const location = options?.location || process.env.GOOGLE_CLOUD_LOCATION;
|
|
284
|
+
if (!location) throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");
|
|
285
|
+
return location;
|
|
286
|
+
}
|
|
287
|
+
function buildParams(model, context, options = {}) {
|
|
288
|
+
const contents = convertMessages(model, context);
|
|
289
|
+
const generationConfig = {};
|
|
290
|
+
if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
|
|
291
|
+
if (options.maxTokens !== void 0) generationConfig.maxOutputTokens = options.maxTokens;
|
|
292
|
+
const config = {
|
|
293
|
+
...Object.keys(generationConfig).length > 0 && generationConfig,
|
|
294
|
+
...context.systemPrompt && { systemInstruction: sanitizeSurrogates(context.systemPrompt) },
|
|
295
|
+
...context.tools && context.tools.length > 0 && { tools: convertTools(context.tools) }
|
|
296
|
+
};
|
|
297
|
+
if (context.tools && context.tools.length > 0 && options.toolChoice) config.toolConfig = { functionCallingConfig: { mode: mapToolChoice(options.toolChoice) } };
|
|
298
|
+
else config.toolConfig = void 0;
|
|
299
|
+
if (options.thinking?.enabled && model.reasoning) {
|
|
300
|
+
const thinkingConfig = { includeThoughts: true };
|
|
301
|
+
if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = THINKING_LEVEL_MAP[options.thinking.level];
|
|
302
|
+
else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
|
|
303
|
+
config.thinkingConfig = thinkingConfig;
|
|
304
|
+
} else if (model.reasoning && options.thinking && !options.thinking.enabled) config.thinkingConfig = getDisabledThinkingConfig(model);
|
|
305
|
+
if (options.signal) {
|
|
306
|
+
if (options.signal.aborted) throw new Error("Request aborted");
|
|
307
|
+
config.abortSignal = options.signal;
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
model: model.id,
|
|
311
|
+
contents,
|
|
312
|
+
config
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function isGemini3ProModel(model) {
|
|
316
|
+
return /gemini-3(?:\.\d+)?-pro/.test(model.id.toLowerCase());
|
|
317
|
+
}
|
|
318
|
+
function isGemini3FlashModel(model) {
|
|
319
|
+
return /gemini-3(?:\.\d+)?-flash/.test(model.id.toLowerCase());
|
|
320
|
+
}
|
|
321
|
+
function getDisabledThinkingConfig(model) {
|
|
322
|
+
const geminiModel = model;
|
|
323
|
+
if (isGemini3ProModel(geminiModel)) return { thinkingLevel: ThinkingLevel.LOW };
|
|
324
|
+
if (isGemini3FlashModel(geminiModel)) return { thinkingLevel: ThinkingLevel.MINIMAL };
|
|
325
|
+
return { thinkingBudget: 0 };
|
|
326
|
+
}
|
|
327
|
+
function getGemini3ThinkingLevel(effort, model) {
|
|
328
|
+
if (isGemini3ProModel(model)) switch (effort) {
|
|
329
|
+
case "minimal":
|
|
330
|
+
case "low": return "LOW";
|
|
331
|
+
case "medium":
|
|
332
|
+
case "high": return "HIGH";
|
|
333
|
+
}
|
|
334
|
+
switch (effort) {
|
|
335
|
+
case "minimal": return "MINIMAL";
|
|
336
|
+
case "low": return "LOW";
|
|
337
|
+
case "medium": return "MEDIUM";
|
|
338
|
+
case "high": return "HIGH";
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function getGoogleBudget(model, effort, customBudgets) {
|
|
342
|
+
if (customBudgets?.[effort] !== void 0) return customBudgets[effort];
|
|
343
|
+
if (model.id.includes("2.5-pro")) return {
|
|
344
|
+
minimal: 128,
|
|
345
|
+
low: 2048,
|
|
346
|
+
medium: 8192,
|
|
347
|
+
high: 32768
|
|
348
|
+
}[effort];
|
|
349
|
+
if (model.id.includes("2.5-flash")) return {
|
|
350
|
+
minimal: 128,
|
|
351
|
+
low: 2048,
|
|
352
|
+
medium: 8192,
|
|
353
|
+
high: 24576
|
|
354
|
+
}[effort];
|
|
355
|
+
return -1;
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
export { streamGoogleVertex, streamSimpleGoogleVertex };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@mariozechner+pi-ai@0.69.0_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__ws@8.21.0_zod@4.3.6/node_modules/@mariozechner/pi-ai/dist/utils/hash.js
|
|
2
|
+
/** Fast deterministic hash to shorten long strings */
|
|
3
|
+
function shortHash(str) {
|
|
4
|
+
let h1 = 3735928559;
|
|
5
|
+
let h2 = 1103547991;
|
|
6
|
+
for (let i = 0; i < str.length; i++) {
|
|
7
|
+
const ch = str.charCodeAt(i);
|
|
8
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
9
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
10
|
+
}
|
|
11
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
12
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
13
|
+
return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { shortHash as t };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@mariozechner+pi-ai@0.69.0_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__ws@8.21.0_zod@4.3.6/node_modules/@mariozechner/pi-ai/dist/utils/headers.js
|
|
2
|
+
function headersToRecord(headers) {
|
|
3
|
+
const result = {};
|
|
4
|
+
for (const [key, value] of headers.entries()) result[key] = value;
|
|
5
|
+
return result;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { headersToRecord as t };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/string-coerce-CjxCKZ6B.js
|
|
4
|
+
function readStringValue(value) {
|
|
5
|
+
return typeof value === "string" ? value : void 0;
|
|
6
|
+
}
|
|
7
|
+
function normalizeNullableString(value) {
|
|
8
|
+
if (typeof value !== "string") return null;
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
return trimmed ? trimmed : null;
|
|
11
|
+
}
|
|
12
|
+
function normalizeOptionalString(value) {
|
|
13
|
+
return normalizeNullableString(value) ?? void 0;
|
|
14
|
+
}
|
|
15
|
+
function normalizeStringifiedOptionalString(value) {
|
|
16
|
+
if (typeof value === "string") return normalizeOptionalString(value);
|
|
17
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return normalizeOptionalString(String(value));
|
|
18
|
+
}
|
|
19
|
+
function normalizeOptionalLowercaseString(value) {
|
|
20
|
+
return normalizeOptionalString(value)?.toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
function normalizeLowercaseStringOrEmpty(value) {
|
|
23
|
+
return normalizeOptionalLowercaseString(value) ?? "";
|
|
24
|
+
}
|
|
25
|
+
function normalizeOptionalThreadValue(value) {
|
|
26
|
+
if (typeof value === "number") return Number.isFinite(value) ? Math.trunc(value) : void 0;
|
|
27
|
+
return normalizeOptionalString(value);
|
|
28
|
+
}
|
|
29
|
+
function hasNonEmptyString(value) {
|
|
30
|
+
return normalizeOptionalString(value) !== void 0;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/home-dir-C44RaPME.js
|
|
34
|
+
function normalize(value) {
|
|
35
|
+
const trimmed = normalizeOptionalString(value);
|
|
36
|
+
if (!trimmed) return;
|
|
37
|
+
if (trimmed === "undefined" || trimmed === "null") return;
|
|
38
|
+
return trimmed;
|
|
39
|
+
}
|
|
40
|
+
function resolveEffectiveHomeDir(env = process.env, homedir = os.homedir) {
|
|
41
|
+
const raw = resolveRawHomeDir(env, homedir);
|
|
42
|
+
return raw ? path.resolve(raw) : void 0;
|
|
43
|
+
}
|
|
44
|
+
function resolveRawHomeDir(env, homedir) {
|
|
45
|
+
const explicitHome = normalize(env.OPENCLAW_HOME);
|
|
46
|
+
if (explicitHome) {
|
|
47
|
+
if (explicitHome === "~" || explicitHome.startsWith("~/") || explicitHome.startsWith("~\\")) {
|
|
48
|
+
const fallbackHome = resolveRawOsHomeDir(env, homedir);
|
|
49
|
+
if (fallbackHome) return explicitHome.replace(/^~(?=$|[\\/])/, fallbackHome);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
return explicitHome;
|
|
53
|
+
}
|
|
54
|
+
return resolveRawOsHomeDir(env, homedir);
|
|
55
|
+
}
|
|
56
|
+
function resolveRawOsHomeDir(env, homedir) {
|
|
57
|
+
const envHome = normalize(env.HOME);
|
|
58
|
+
if (envHome) return envHome;
|
|
59
|
+
const userProfile = normalize(env.USERPROFILE);
|
|
60
|
+
if (userProfile) return userProfile;
|
|
61
|
+
return normalizeSafe(homedir);
|
|
62
|
+
}
|
|
63
|
+
function normalizeSafe(homedir) {
|
|
64
|
+
try {
|
|
65
|
+
return normalize(homedir());
|
|
66
|
+
} catch {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function resolveRequiredHomeDir(env = process.env, homedir = os.homedir) {
|
|
71
|
+
return resolveEffectiveHomeDir(env, homedir) ?? path.resolve(process.cwd());
|
|
72
|
+
}
|
|
73
|
+
function expandHomePrefix(input, opts) {
|
|
74
|
+
if (!input.startsWith("~")) return input;
|
|
75
|
+
const home = normalize(opts?.home) ?? resolveEffectiveHomeDir(opts?.env ?? process.env, opts?.homedir ?? os.homedir);
|
|
76
|
+
if (!home) return input;
|
|
77
|
+
return input.replace(/^~(?=$|[\\/])/, home);
|
|
78
|
+
}
|
|
79
|
+
function resolveHomeRelativePath(input, opts) {
|
|
80
|
+
const trimmed = input.trim();
|
|
81
|
+
if (!trimmed) return trimmed;
|
|
82
|
+
if (trimmed.startsWith("~")) {
|
|
83
|
+
const expanded = expandHomePrefix(trimmed, {
|
|
84
|
+
home: resolveRequiredHomeDir(opts?.env ?? process.env, opts?.homedir ?? os.homedir),
|
|
85
|
+
env: opts?.env,
|
|
86
|
+
homedir: opts?.homedir
|
|
87
|
+
});
|
|
88
|
+
return path.resolve(expanded);
|
|
89
|
+
}
|
|
90
|
+
return path.resolve(trimmed);
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
export { hasNonEmptyString as a, normalizeOptionalString as c, readStringValue as d, resolveRequiredHomeDir as i, normalizeOptionalThreadValue as l, resolveEffectiveHomeDir as n, normalizeLowercaseStringOrEmpty as o, resolveHomeRelativePath as r, normalizeOptionalLowercaseString as s, expandHomePrefix as t, normalizeStringifiedOptionalString as u };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { s as normalizeOptionalLowercaseString } from "./home-dir-C44RaPME-CBRS4HLP.mjs";
|
|
2
|
+
import { n as resolveOpenClawPackageRootSync, t as resolveBundledPluginsDir } from "./bundled-dir-U738ay4K-DXK0q_TV.mjs";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/ids-BPsM98Uu.js
|
|
6
|
+
const OFFICIAL_CHANNEL_CATALOG_RELATIVE_PATH = path.join("dist", "channel-catalog.json");
|
|
7
|
+
function listPackageRoots() {
|
|
8
|
+
return [resolveOpenClawPackageRootSync({ cwd: process.cwd() }), resolveOpenClawPackageRootSync({ moduleUrl: import.meta.url })].filter((entry, index, all) => Boolean(entry) && all.indexOf(entry) === index);
|
|
9
|
+
}
|
|
10
|
+
function listBundledExtensionPackageJsonPaths(env = process.env) {
|
|
11
|
+
const extensionsRoot = resolveBundledPluginsDir(env);
|
|
12
|
+
if (!extensionsRoot) return [];
|
|
13
|
+
try {
|
|
14
|
+
return fs.readdirSync(extensionsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => path.join(extensionsRoot, entry.name, "package.json")).filter((entry) => fs.existsSync(entry));
|
|
15
|
+
} catch {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function readBundledExtensionCatalogEntriesSync() {
|
|
20
|
+
const entries = [];
|
|
21
|
+
for (const packageJsonPath of listBundledExtensionPackageJsonPaths()) try {
|
|
22
|
+
const payload = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
23
|
+
entries.push(payload);
|
|
24
|
+
} catch {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
return entries;
|
|
28
|
+
}
|
|
29
|
+
function readOfficialCatalogFileSync() {
|
|
30
|
+
for (const packageRoot of listPackageRoots()) {
|
|
31
|
+
const candidate = path.join(packageRoot, OFFICIAL_CHANNEL_CATALOG_RELATIVE_PATH);
|
|
32
|
+
if (!fs.existsSync(candidate)) continue;
|
|
33
|
+
try {
|
|
34
|
+
const payload = JSON.parse(fs.readFileSync(candidate, "utf8"));
|
|
35
|
+
return Array.isArray(payload.entries) ? payload.entries : [];
|
|
36
|
+
} catch {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
function toBundledChannelEntry(entry) {
|
|
43
|
+
const channel = entry.openclaw?.channel;
|
|
44
|
+
const id = normalizeOptionalLowercaseString(channel?.id);
|
|
45
|
+
if (!id || !channel) return null;
|
|
46
|
+
return {
|
|
47
|
+
id,
|
|
48
|
+
channel,
|
|
49
|
+
aliases: Array.isArray(channel.aliases) ? channel.aliases.map((alias) => normalizeOptionalLowercaseString(alias)).filter((alias) => Boolean(alias)) : [],
|
|
50
|
+
order: typeof channel.order === "number" && Number.isFinite(channel.order) ? channel.order : Number.MAX_SAFE_INTEGER
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function listBundledChannelCatalogEntries() {
|
|
54
|
+
const bundledEntries = readBundledExtensionCatalogEntriesSync().map((entry) => toBundledChannelEntry(entry)).filter((entry) => Boolean(entry));
|
|
55
|
+
if (bundledEntries.length > 0) return bundledEntries;
|
|
56
|
+
return readOfficialCatalogFileSync().map((entry) => toBundledChannelEntry(entry)).filter((entry) => Boolean(entry));
|
|
57
|
+
}
|
|
58
|
+
function listBundledChatChannelEntries() {
|
|
59
|
+
return listBundledChannelCatalogEntries().map((entry) => ({
|
|
60
|
+
id: normalizeOptionalLowercaseString(entry.id) ?? entry.id,
|
|
61
|
+
aliases: entry.aliases,
|
|
62
|
+
order: entry.order
|
|
63
|
+
})).toSorted((left, right) => left.order - right.order || left.id.localeCompare(right.id, "en", { sensitivity: "base" }));
|
|
64
|
+
}
|
|
65
|
+
const BUNDLED_CHAT_CHANNEL_ENTRIES = Object.freeze(listBundledChatChannelEntries());
|
|
66
|
+
const CHAT_CHANNEL_ID_SET = new Set(BUNDLED_CHAT_CHANNEL_ENTRIES.map((entry) => entry.id));
|
|
67
|
+
const CHAT_CHANNEL_ORDER = Object.freeze(BUNDLED_CHAT_CHANNEL_ENTRIES.map((entry) => entry.id));
|
|
68
|
+
const CHANNEL_IDS = CHAT_CHANNEL_ORDER;
|
|
69
|
+
const CHAT_CHANNEL_ALIASES = Object.freeze(Object.fromEntries(BUNDLED_CHAT_CHANNEL_ENTRIES.flatMap((entry) => entry.aliases.map((alias) => [alias, entry.id]))));
|
|
70
|
+
function normalizeChatChannelId(raw) {
|
|
71
|
+
const normalized = normalizeOptionalLowercaseString(raw);
|
|
72
|
+
if (!normalized) return null;
|
|
73
|
+
const resolved = CHAT_CHANNEL_ALIASES[normalized] ?? normalized;
|
|
74
|
+
return CHAT_CHANNEL_ID_SET.has(resolved) ? resolved : null;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { normalizeChatChannelId as i, CHAT_CHANNEL_ORDER as n, listBundledChannelCatalogEntries as r, CHANNEL_IDS as t };
|