@xiaoso/dsh-tool-plus 0.1.0-beta.2 → 0.1.0-beta.4
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.en.md +122 -0
- package/README.md +3 -2
- package/THIRD_PARTY_NOTICES.md +4 -35
- package/lib/abort-B7izMMna.mjs +51 -0
- package/lib/abort-D1_Z5Ut5.mjs +51 -0
- package/lib/abort-dIkZBV7Q.mjs +51 -0
- package/lib/amazon-bedrock-B0nxT06F.mjs +917 -0
- package/lib/amazon-bedrock-D-shAr1X.mjs +917 -0
- package/lib/amazon-bedrock-WQhvjHYu.mjs +917 -0
- package/lib/anthropic-BWsZFzU8.mjs +262 -0
- package/lib/anthropic-CJCauvYz.mjs +3115 -0
- package/lib/anthropic-CMT1Qj1t.mjs +3115 -0
- package/lib/anthropic-CZghe_9U.mjs +3115 -0
- package/lib/anthropic-sCMH7JID.mjs +262 -0
- package/lib/anthropic-tTntD8BD.mjs +262 -0
- package/lib/api-key-login-BzqNdM2y.mjs +157 -0
- package/lib/api-key-login-CWVwvHT1.mjs +157 -0
- package/lib/api-key-login-CpzSezsi.mjs +157 -0
- package/lib/aws-credentials-8Mgn5MAy.mjs +867 -0
- package/lib/aws-credentials-CXryMobh.mjs +867 -0
- package/lib/aws-credentials-ChG79ey-.mjs +867 -0
- package/lib/azure-openai-responses-CNkHiLUh.mjs +274 -0
- package/lib/azure-openai-responses-Cgmc-rbL.mjs +274 -0
- package/lib/azure-openai-responses-DuukbD0F.mjs +274 -0
- package/lib/bun-shim.mjs +252 -12
- package/lib/bundled-references-CSuBco5p.mjs +55 -0
- package/lib/bundled-references-Cavaffah.mjs +55 -0
- package/lib/bundled-references-sLN0YdXU.mjs +55 -0
- package/lib/callback-server-BEFNf-jf.mjs +398 -0
- package/lib/callback-server-CQ5Jo8F-.mjs +398 -0
- package/lib/callback-server-DDSrZ6l_.mjs +398 -0
- package/lib/client.js +111 -41
- package/lib/cursor-B3zg7EHj.mjs +273 -0
- package/lib/cursor-B6TUEmgP.mjs +135 -0
- package/lib/cursor-BIQfBC6V.mjs +135 -0
- package/lib/cursor-D8gvtTL3.mjs +135 -0
- package/lib/cursor-DNk6eXDd.mjs +5470 -0
- package/lib/cursor-DkSX2h3H.mjs +5441 -0
- package/lib/cursor-MjSm74IJ.mjs +273 -0
- package/lib/cursor-aJrXeYCb.mjs +273 -0
- package/lib/cursor-mJQwUKXK.mjs +5441 -0
- package/lib/device-code-DBo3B5nh.mjs +51 -0
- package/lib/device-code-DIb0FU-H.mjs +51 -0
- package/lib/device-code-OI_tQcmc.mjs +51 -0
- package/lib/devin-BHZZyMhO.mjs +95 -0
- package/lib/devin-BK7DHeca.mjs +114 -0
- package/lib/devin-CfMp3cXS.mjs +95 -0
- package/lib/devin-CldyPD8K.mjs +95 -0
- package/lib/devin-CzRpTUOA.mjs +114 -0
- package/lib/devin-D9zR5B_R.mjs +542 -0
- package/lib/devin-DXOeNyU7.mjs +542 -0
- package/lib/devin-Q1yem3lp.mjs +114 -0
- package/lib/devin-vNZTNUON.mjs +542 -0
- package/lib/error-B3bevhrs.mjs +1449 -0
- package/lib/error-Dd8DIqs-.mjs +1449 -0
- package/lib/error-yCSG0mGC.mjs +1449 -0
- package/lib/event-stream-BDPi64mK.mjs +151 -0
- package/lib/event-stream-BbFZJy-z.mjs +151 -0
- package/lib/event-stream-loUa0s1T.mjs +151 -0
- package/lib/fs-promises-shim-Bx0fpxuk.mjs +57 -0
- package/lib/github-copilot-4GaMtQmg.mjs +208 -0
- package/lib/github-copilot-B1yiyVRh.mjs +104 -0
- package/lib/github-copilot-B2HGSIJK.mjs +104 -0
- package/lib/github-copilot-BWT3eAOF.mjs +208 -0
- package/lib/github-copilot-CYkjeTi3.mjs +208 -0
- package/lib/github-copilot-jscUZ8Hf.mjs +104 -0
- package/lib/gitlab-duo-CM7Ref1H.mjs +155 -0
- package/lib/gitlab-duo-akICyfeD.mjs +155 -0
- package/lib/gitlab-duo-gubO4FNw.mjs +155 -0
- package/lib/gitlab-duo-workflow-BGAF6JDw.mjs +91 -0
- package/lib/gitlab-duo-workflow-CSEgYk3N.mjs +91 -0
- package/lib/gitlab-duo-workflow-D78tdn8E.mjs +91 -0
- package/lib/google-BS4T25Pn.mjs +30 -0
- package/lib/google-TFe-7-of.mjs +30 -0
- package/lib/google-antigravity-DGmwC2KV.mjs +198 -0
- package/lib/google-antigravity-DNYhgTpA.mjs +198 -0
- package/lib/google-antigravity-Dlkdhahq.mjs +198 -0
- package/lib/google-auth-B6gjsZvg.mjs +232 -0
- package/lib/google-auth-De7_s3eo.mjs +232 -0
- package/lib/google-auth-DhqpOYrX.mjs +232 -0
- package/lib/google-gemini-cli-BG_LRdIV.mjs +850 -0
- package/lib/google-gemini-cli-CWu8HvXW.mjs +211 -0
- package/lib/google-gemini-cli-Cb97bzQc.mjs +850 -0
- package/lib/google-gemini-cli-Cqds_Q5T.mjs +850 -0
- package/lib/google-gemini-cli-Dsztq0N5.mjs +211 -0
- package/lib/google-gemini-cli-zJhiOcND.mjs +211 -0
- package/lib/google-oauth-shared-CuEHaDDj.mjs +147 -0
- package/lib/google-oauth-shared-CwNWYdmR.mjs +147 -0
- package/lib/google-oauth-shared-yqlyqPPC.mjs +147 -0
- package/lib/google-shared-CgKmmdO3.mjs +760 -0
- package/lib/google-shared-Dr-VG-ap.mjs +760 -0
- package/lib/google-shared-DzhCb9b0.mjs +760 -0
- package/lib/google-vertex-BDN2tLaD.mjs +99 -0
- package/lib/google-vertex-DopVOQOG.mjs +99 -0
- package/lib/google-vertex-kscbkyRb.mjs +99 -0
- package/lib/google-zyDOG9x7.mjs +30 -0
- package/lib/identity-Da1GPU9a.mjs +219 -0
- package/lib/identity-DnB63pS7.mjs +219 -0
- package/lib/identity-xRP7_eSR.mjs +219 -0
- package/lib/idle-iterator-Baoyn3Hp.mjs +366 -0
- package/lib/idle-iterator-C6XbWcuB.mjs +366 -0
- package/lib/idle-iterator-DUjKQEGT.mjs +366 -0
- package/lib/index.mjs +4608 -3935
- package/lib/kimi--wUOWER5.mjs +236 -0
- package/lib/kimi-DMVI-zrZ.mjs +236 -0
- package/lib/kimi-Dh0pv3WZ.mjs +236 -0
- package/lib/markit-BL3cH47U.mjs +1417 -0
- package/lib/markit-BNiNY6SE.mjs +1417 -0
- package/lib/markit-M0jhziqU.mjs +1417 -0
- package/lib/minimax-code-BK-3eBbz.mjs +53 -0
- package/lib/minimax-code-DCbuA6Yk.mjs +53 -0
- package/lib/minimax-code-Uq8Qu9LW.mjs +53 -0
- package/lib/models-CfT4coYT.mjs +104660 -0
- package/lib/models-D_XnT6ay.mjs +104660 -0
- package/lib/models-SGASygJ3.mjs +104660 -0
- package/lib/ollama-BQMGPxtV.mjs +589 -0
- package/lib/ollama-DPzBmq89.mjs +589 -0
- package/lib/ollama-DoBz5SFm.mjs +589 -0
- package/lib/openai-codex-Bi-4S4PX.mjs +255 -0
- package/lib/openai-codex-CQL_kvYL.mjs +255 -0
- package/lib/openai-codex-Ch8CkT3p.mjs +255 -0
- package/lib/openai-codex-responses-CvxL_FMF.mjs +3144 -0
- package/lib/openai-codex-responses-Cz-2qpC7.mjs +3144 -0
- package/lib/openai-codex-responses-pejZgdZo.mjs +3144 -0
- package/lib/openai-completions-CF8IyNtP.mjs +1360 -0
- package/lib/openai-completions-DIf361kF.mjs +1360 -0
- package/lib/openai-completions-i8doczAk.mjs +1360 -0
- package/lib/openai-reasoning-fallback-DGVVLgd1.mjs +286 -0
- package/lib/openai-reasoning-fallback-Nj6yB2rY.mjs +286 -0
- package/lib/openai-reasoning-fallback-OdJREP1o.mjs +286 -0
- package/lib/openai-responses-BqXJInHX.mjs +867 -0
- package/lib/openai-responses-DTkBiiy-.mjs +867 -0
- package/lib/openai-responses-Db_a-U4-.mjs +867 -0
- package/lib/opencode-DaJjcUbf.mjs +38 -0
- package/lib/opencode-DhMolSoB.mjs +38 -0
- package/lib/opencode-Rq_Q2vAO.mjs +38 -0
- package/lib/perplexity-9b-RQ0mV.mjs +194 -0
- package/lib/perplexity-C4iLVMUj.mjs +194 -0
- package/lib/perplexity-Uu7Jzg5b.mjs +194 -0
- package/lib/proxy-DDqrmjjC.mjs +190 -0
- package/lib/proxy-ZtUcl6r5.mjs +190 -0
- package/lib/proxy-pM_NIv-H.mjs +190 -0
- package/lib/request-debug-HJMoJncL.mjs +183 -0
- package/lib/sanitize-text-CfcXzw5X.mjs +33 -0
- package/lib/scrapers-BkFfcPHj.mjs +9198 -0
- package/lib/scrapers-CL-WgdU1.mjs +9198 -0
- package/lib/scrapers-CVptboMs.mjs +9198 -0
- package/lib/scrapers-CipyKyCH.mjs +9198 -0
- package/lib/scrapers-DGfrYhtw.mjs +9198 -0
- package/lib/scrapers-DSUPYoUF.mjs +9198 -0
- package/lib/scrapers-DZ2GXmp7.mjs +9198 -0
- package/lib/scrapers-nhQAvc8d.mjs +9198 -0
- package/lib/shell-snapshot-fn-env.sh +67 -43
- package/lib/src-BgpusnsB.mjs +5076 -0
- package/lib/src-DTid0g4K.mjs +5001 -0
- package/lib/src-lDmkSRbm.mjs +5006 -0
- package/lib/stream-BlldLkVq.mjs +10236 -0
- package/lib/stream-CRtexYLe.mjs +10236 -0
- package/lib/stream-C_RAoxJC.mjs +10236 -0
- package/lib/stream-markup-healing-2toHXWXM.mjs +491 -0
- package/lib/stream-markup-healing-DMsxBx1L.mjs +491 -0
- package/lib/stream-markup-healing-KMkiAA00.mjs +491 -0
- package/lib/turndown-DN7ByzEI.mjs +667 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/config/fields.d.ts +1 -1
- package/lib/types/config/settings.d.ts +25 -3
- package/lib/types/config/truncate.d.ts +9 -5
- package/lib/types/tools/bash/background.d.ts +1 -1
- package/lib/types/tools/bash/bash-executor.d.ts +4 -0
- package/lib/types/tools/bash/bash-interceptor.d.ts +10 -8
- package/lib/types/tools/bash/cd-workdir.d.ts +35 -0
- package/lib/types/tools/bash/non-interactive-env.d.ts +2 -0
- package/lib/types/tools/bash/render.d.ts +4 -3
- package/lib/types/tools/bash/sanitize-text.d.ts +5 -0
- package/lib/types/tools/bash/shell-snapshot.d.ts +4 -1
- package/lib/types/tools/bash/shell-tokenize.d.ts +60 -0
- package/lib/types/tools/bash/streaming-output.d.ts +12 -212
- package/lib/types/tools/bash/which.d.ts +20 -0
- package/lib/types/tools/bash/windows-shell.d.ts +31 -0
- package/lib/types/tools/edit/adapter/index.d.ts +25 -3
- package/lib/types/tools/edit/adapter/tools/auto-generated-guard.d.ts +7 -17
- package/lib/types/tools/glob/adapter/index.d.ts +27 -1
- package/lib/types/tools/grep/adapter/index.d.ts +29 -1
- package/lib/types/tools/omp/edit/dispatch.d.ts +43 -0
- package/lib/types/tools/omp/edit/hashline/noop-loop-guard.d.ts +3 -1
- package/lib/types/tools/omp/sdk.d.ts +6 -0
- package/lib/types/tools/omp/tools/auto-generated-guard.d.ts +20 -0
- package/lib/types/tools/omp/tools/fetch.d.ts +2 -0
- package/lib/types/tools/omp/tools/read.d.ts +2 -8
- package/lib/types/tools/omp/tools/write.d.ts +4 -4
- package/lib/types/tools/omp/utils/image-loading.d.ts +10 -36
- package/lib/types/tools/read/adapter/index.d.ts +4 -1
- package/lib/types/tools/read-image/index.d.ts +4 -0
- package/lib/types/tools/shared/auto-generated-guard.dsh.d.ts +16 -4
- package/lib/types/tools/shared/bun-shim.d.ts +39 -3
- package/lib/types/tools/shared/fs-promises-shim.d.ts +3 -1
- package/lib/types/tools/shared/image-bridge.d.ts +98 -0
- package/lib/types/tools/shared/omp-prompt.d.ts +17 -9
- package/lib/types/tools/shared/session-state.d.ts +9 -3
- package/lib/utils-2Wq2eATG.mjs +8119 -0
- package/lib/utils-BnX8O3vi.mjs +12303 -0
- package/lib/utils-Bw139LTz.mjs +8119 -0
- package/lib/utils-CE8N8P4Q.mjs +12315 -0
- package/lib/utils-CZw4tVZQ.mjs +12315 -0
- package/lib/utils-C_MrQ_0z.mjs +12301 -0
- package/lib/utils-CiGN7OHR.mjs +12315 -0
- package/lib/utils-Cp76gCyk.mjs +8119 -0
- package/lib/utils-D0GRDgAr.mjs +12315 -0
- package/lib/utils-D0Z1fyoO.mjs +12299 -0
- package/lib/utils-D2YknRk4.mjs +51 -0
- package/lib/utils-DppGHXQB.mjs +51 -0
- package/lib/utils-DzXZDfYc.mjs +51 -0
- package/lib/utils-W8WdSBpX.mjs +12315 -0
- package/lib/vision-guard-01qSwFpf.mjs +92 -0
- package/lib/vision-guard-BDD4OrKo.mjs +92 -0
- package/lib/vision-guard-DzZGaOga.mjs +92 -0
- package/lib/wafer-CgtPHerf.mjs +17 -0
- package/lib/wafer-DRU0EjZX.mjs +17 -0
- package/lib/wafer-cBtrn6q9.mjs +17 -0
- package/lib/xai-oauth-Buk8XVvM.mjs +446 -0
- package/lib/xai-oauth-CMal8l1O.mjs +446 -0
- package/lib/xai-oauth-DPHDXKD7.mjs +446 -0
- package/lib/xiaomi-CZgwvX2G.mjs +157 -0
- package/lib/xiaomi-D2qT5cAC.mjs +157 -0
- package/lib/xiaomi-Dd87KSg5.mjs +157 -0
- package/lib/zai-7DWMkEqM.mjs +203 -0
- package/lib/zai-C59YnomG.mjs +203 -0
- package/lib/zai-CFeOt-53.mjs +203 -0
- package/lib/zip-Cg9ANN_U.mjs +1316 -0
- package/lib/zip-D36ZKsP8.mjs +1316 -0
- package/lib/zip-D6QXpvaJ.mjs +1316 -0
- package/package.json +14 -10
- package/presets/package.json +1 -1
- package/presets/tool-plus-ptc/preset.yml +1 -1
- package/presets/tool-plus-standard/preset.yml +1 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { P as $env } from "./src-BgpusnsB.mjs";
|
|
4
|
+
import { t as ConfigurationError } from "./error-Dd8DIqs-.mjs";
|
|
5
|
+
import { P as resolveVertexEndpointHost } from "./models-SGASygJ3.mjs";
|
|
6
|
+
import { t as getVertexAccessToken } from "./google-auth-B6gjsZvg.mjs";
|
|
7
|
+
import { p as streamGoogleGenAI, t as buildGoogleGenerateContentParams } from "./google-shared-Dr-VG-ap.mjs";
|
|
8
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/google-vertex.ts
|
|
9
|
+
const API_VERSION = "v1";
|
|
10
|
+
const streamGoogleVertex = (model, context, options) => {
|
|
11
|
+
return streamGoogleGenAI({
|
|
12
|
+
model,
|
|
13
|
+
options,
|
|
14
|
+
api: "google-vertex",
|
|
15
|
+
retainTextSignature: true,
|
|
16
|
+
prepare: async () => {
|
|
17
|
+
const apiKey = resolveApiKey(options);
|
|
18
|
+
const params = buildGoogleGenerateContentParams(model, context, options ?? {});
|
|
19
|
+
params.config ||= {};
|
|
20
|
+
if (!params.config.safetySettings) params.config.safetySettings = [
|
|
21
|
+
{
|
|
22
|
+
category: "HARM_CATEGORY_HATE_SPEECH",
|
|
23
|
+
threshold: "OFF"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
category: "HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
27
|
+
threshold: "OFF"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
31
|
+
threshold: "OFF"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
category: "HARM_CATEGORY_HARASSMENT",
|
|
35
|
+
threshold: "OFF"
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
const baseHeaders = {
|
|
39
|
+
...model.headers ?? {},
|
|
40
|
+
...options?.headers ?? {}
|
|
41
|
+
};
|
|
42
|
+
if (options?.serviceTier === "priority") baseHeaders["X-Vertex-AI-LLM-Shared-Request-Type"] = "priority";
|
|
43
|
+
if (apiKey) {
|
|
44
|
+
const explicitLocation = options?.location;
|
|
45
|
+
const location = explicitLocation ?? resolveAmbientLocation() ?? "global";
|
|
46
|
+
const host = resolveVertexEndpointHost(location);
|
|
47
|
+
const path = `${API_VERSION}/publishers/google/models/${model.id}:streamGenerateContent?alt=sse`;
|
|
48
|
+
const useGlobalFallback = !explicitLocation && host !== "aiplatform.googleapis.com";
|
|
49
|
+
return {
|
|
50
|
+
params,
|
|
51
|
+
url: `https://${host}/${path}`,
|
|
52
|
+
fallbackUrl: useGlobalFallback ? `https://aiplatform.googleapis.com/${path}` : void 0,
|
|
53
|
+
headers: {
|
|
54
|
+
...baseHeaders,
|
|
55
|
+
"x-goog-api-key": apiKey
|
|
56
|
+
},
|
|
57
|
+
fetch: options?.fetch
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const project = resolveProject(options);
|
|
61
|
+
const location = resolveLocation(options);
|
|
62
|
+
const accessToken = await getVertexAccessToken({
|
|
63
|
+
signal: options?.signal,
|
|
64
|
+
fetch: options?.fetch
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
params,
|
|
68
|
+
url: `https://${resolveVertexEndpointHost(location)}/${API_VERSION}/projects/${project}/locations/${location}/publishers/google/models/${model.id}:streamGenerateContent?alt=sse`,
|
|
69
|
+
headers: {
|
|
70
|
+
...baseHeaders,
|
|
71
|
+
Authorization: `Bearer ${accessToken}`
|
|
72
|
+
},
|
|
73
|
+
fetch: options?.fetch
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
function resolveApiKey(options) {
|
|
79
|
+
const optKey = options?.apiKey;
|
|
80
|
+
return (optKey && !optKey.startsWith("<") && optKey !== "N/A" ? optKey : void 0) || $env.GOOGLE_CLOUD_API_KEY;
|
|
81
|
+
}
|
|
82
|
+
function resolveProject(options) {
|
|
83
|
+
const project = options?.project || $env.GOOGLE_CLOUD_PROJECT || $env.GCP_PROJECT || $env.GCLOUD_PROJECT;
|
|
84
|
+
if (!project) throw new ConfigurationError("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCP_PROJECT/GCLOUD_PROJECT or pass project in options.");
|
|
85
|
+
return project;
|
|
86
|
+
}
|
|
87
|
+
function resolveAmbientLocation() {
|
|
88
|
+
return $env.GOOGLE_VERTEX_LOCATION || $env.GOOGLE_CLOUD_LOCATION || $env.VERTEX_LOCATION || void 0;
|
|
89
|
+
}
|
|
90
|
+
function resolveOptionalLocation(options) {
|
|
91
|
+
return options?.location || resolveAmbientLocation();
|
|
92
|
+
}
|
|
93
|
+
function resolveLocation(options) {
|
|
94
|
+
const location = resolveOptionalLocation(options);
|
|
95
|
+
if (!location) throw new ConfigurationError("Vertex AI requires a location. Set GOOGLE_VERTEX_LOCATION/GOOGLE_CLOUD_LOCATION/VERTEX_LOCATION or pass location in options.");
|
|
96
|
+
return location;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { streamGoogleVertex };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { P as $env } from "./src-lDmkSRbm.mjs";
|
|
4
|
+
import { t as ConfigurationError } from "./error-yCSG0mGC.mjs";
|
|
5
|
+
import { P as resolveVertexEndpointHost } from "./models-D_XnT6ay.mjs";
|
|
6
|
+
import { t as getVertexAccessToken } from "./google-auth-De7_s3eo.mjs";
|
|
7
|
+
import { p as streamGoogleGenAI, t as buildGoogleGenerateContentParams } from "./google-shared-CgKmmdO3.mjs";
|
|
8
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/google-vertex.ts
|
|
9
|
+
const API_VERSION = "v1";
|
|
10
|
+
const streamGoogleVertex = (model, context, options) => {
|
|
11
|
+
return streamGoogleGenAI({
|
|
12
|
+
model,
|
|
13
|
+
options,
|
|
14
|
+
api: "google-vertex",
|
|
15
|
+
retainTextSignature: true,
|
|
16
|
+
prepare: async () => {
|
|
17
|
+
const apiKey = resolveApiKey(options);
|
|
18
|
+
const params = buildGoogleGenerateContentParams(model, context, options ?? {});
|
|
19
|
+
params.config ||= {};
|
|
20
|
+
if (!params.config.safetySettings) params.config.safetySettings = [
|
|
21
|
+
{
|
|
22
|
+
category: "HARM_CATEGORY_HATE_SPEECH",
|
|
23
|
+
threshold: "OFF"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
category: "HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
27
|
+
threshold: "OFF"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
31
|
+
threshold: "OFF"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
category: "HARM_CATEGORY_HARASSMENT",
|
|
35
|
+
threshold: "OFF"
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
const baseHeaders = {
|
|
39
|
+
...model.headers ?? {},
|
|
40
|
+
...options?.headers ?? {}
|
|
41
|
+
};
|
|
42
|
+
if (options?.serviceTier === "priority") baseHeaders["X-Vertex-AI-LLM-Shared-Request-Type"] = "priority";
|
|
43
|
+
if (apiKey) {
|
|
44
|
+
const explicitLocation = options?.location;
|
|
45
|
+
const location = explicitLocation ?? resolveAmbientLocation() ?? "global";
|
|
46
|
+
const host = resolveVertexEndpointHost(location);
|
|
47
|
+
const path = `${API_VERSION}/publishers/google/models/${model.id}:streamGenerateContent?alt=sse`;
|
|
48
|
+
const useGlobalFallback = !explicitLocation && host !== "aiplatform.googleapis.com";
|
|
49
|
+
return {
|
|
50
|
+
params,
|
|
51
|
+
url: `https://${host}/${path}`,
|
|
52
|
+
fallbackUrl: useGlobalFallback ? `https://aiplatform.googleapis.com/${path}` : void 0,
|
|
53
|
+
headers: {
|
|
54
|
+
...baseHeaders,
|
|
55
|
+
"x-goog-api-key": apiKey
|
|
56
|
+
},
|
|
57
|
+
fetch: options?.fetch
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const project = resolveProject(options);
|
|
61
|
+
const location = resolveLocation(options);
|
|
62
|
+
const accessToken = await getVertexAccessToken({
|
|
63
|
+
signal: options?.signal,
|
|
64
|
+
fetch: options?.fetch
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
params,
|
|
68
|
+
url: `https://${resolveVertexEndpointHost(location)}/${API_VERSION}/projects/${project}/locations/${location}/publishers/google/models/${model.id}:streamGenerateContent?alt=sse`,
|
|
69
|
+
headers: {
|
|
70
|
+
...baseHeaders,
|
|
71
|
+
Authorization: `Bearer ${accessToken}`
|
|
72
|
+
},
|
|
73
|
+
fetch: options?.fetch
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
function resolveApiKey(options) {
|
|
79
|
+
const optKey = options?.apiKey;
|
|
80
|
+
return (optKey && !optKey.startsWith("<") && optKey !== "N/A" ? optKey : void 0) || $env.GOOGLE_CLOUD_API_KEY;
|
|
81
|
+
}
|
|
82
|
+
function resolveProject(options) {
|
|
83
|
+
const project = options?.project || $env.GOOGLE_CLOUD_PROJECT || $env.GCP_PROJECT || $env.GCLOUD_PROJECT;
|
|
84
|
+
if (!project) throw new ConfigurationError("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCP_PROJECT/GCLOUD_PROJECT or pass project in options.");
|
|
85
|
+
return project;
|
|
86
|
+
}
|
|
87
|
+
function resolveAmbientLocation() {
|
|
88
|
+
return $env.GOOGLE_VERTEX_LOCATION || $env.GOOGLE_CLOUD_LOCATION || $env.VERTEX_LOCATION || void 0;
|
|
89
|
+
}
|
|
90
|
+
function resolveOptionalLocation(options) {
|
|
91
|
+
return options?.location || resolveAmbientLocation();
|
|
92
|
+
}
|
|
93
|
+
function resolveLocation(options) {
|
|
94
|
+
const location = resolveOptionalLocation(options);
|
|
95
|
+
if (!location) throw new ConfigurationError("Vertex AI requires a location. Set GOOGLE_VERTEX_LOCATION/GOOGLE_CLOUD_LOCATION/VERTEX_LOCATION or pass location in options.");
|
|
96
|
+
return location;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { streamGoogleVertex };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { P as $env } from "./src-DTid0g4K.mjs";
|
|
4
|
+
import { t as ConfigurationError } from "./error-B3bevhrs.mjs";
|
|
5
|
+
import { P as resolveVertexEndpointHost } from "./models-CfT4coYT.mjs";
|
|
6
|
+
import { t as getVertexAccessToken } from "./google-auth-DhqpOYrX.mjs";
|
|
7
|
+
import { p as streamGoogleGenAI, t as buildGoogleGenerateContentParams } from "./google-shared-DzhCb9b0.mjs";
|
|
8
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/google-vertex.ts
|
|
9
|
+
const API_VERSION = "v1";
|
|
10
|
+
const streamGoogleVertex = (model, context, options) => {
|
|
11
|
+
return streamGoogleGenAI({
|
|
12
|
+
model,
|
|
13
|
+
options,
|
|
14
|
+
api: "google-vertex",
|
|
15
|
+
retainTextSignature: true,
|
|
16
|
+
prepare: async () => {
|
|
17
|
+
const apiKey = resolveApiKey(options);
|
|
18
|
+
const params = buildGoogleGenerateContentParams(model, context, options ?? {});
|
|
19
|
+
params.config ||= {};
|
|
20
|
+
if (!params.config.safetySettings) params.config.safetySettings = [
|
|
21
|
+
{
|
|
22
|
+
category: "HARM_CATEGORY_HATE_SPEECH",
|
|
23
|
+
threshold: "OFF"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
category: "HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
27
|
+
threshold: "OFF"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
31
|
+
threshold: "OFF"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
category: "HARM_CATEGORY_HARASSMENT",
|
|
35
|
+
threshold: "OFF"
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
const baseHeaders = {
|
|
39
|
+
...model.headers ?? {},
|
|
40
|
+
...options?.headers ?? {}
|
|
41
|
+
};
|
|
42
|
+
if (options?.serviceTier === "priority") baseHeaders["X-Vertex-AI-LLM-Shared-Request-Type"] = "priority";
|
|
43
|
+
if (apiKey) {
|
|
44
|
+
const explicitLocation = options?.location;
|
|
45
|
+
const location = explicitLocation ?? resolveAmbientLocation() ?? "global";
|
|
46
|
+
const host = resolveVertexEndpointHost(location);
|
|
47
|
+
const path = `${API_VERSION}/publishers/google/models/${model.id}:streamGenerateContent?alt=sse`;
|
|
48
|
+
const useGlobalFallback = !explicitLocation && host !== "aiplatform.googleapis.com";
|
|
49
|
+
return {
|
|
50
|
+
params,
|
|
51
|
+
url: `https://${host}/${path}`,
|
|
52
|
+
fallbackUrl: useGlobalFallback ? `https://aiplatform.googleapis.com/${path}` : void 0,
|
|
53
|
+
headers: {
|
|
54
|
+
...baseHeaders,
|
|
55
|
+
"x-goog-api-key": apiKey
|
|
56
|
+
},
|
|
57
|
+
fetch: options?.fetch
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const project = resolveProject(options);
|
|
61
|
+
const location = resolveLocation(options);
|
|
62
|
+
const accessToken = await getVertexAccessToken({
|
|
63
|
+
signal: options?.signal,
|
|
64
|
+
fetch: options?.fetch
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
params,
|
|
68
|
+
url: `https://${resolveVertexEndpointHost(location)}/${API_VERSION}/projects/${project}/locations/${location}/publishers/google/models/${model.id}:streamGenerateContent?alt=sse`,
|
|
69
|
+
headers: {
|
|
70
|
+
...baseHeaders,
|
|
71
|
+
Authorization: `Bearer ${accessToken}`
|
|
72
|
+
},
|
|
73
|
+
fetch: options?.fetch
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
function resolveApiKey(options) {
|
|
79
|
+
const optKey = options?.apiKey;
|
|
80
|
+
return (optKey && !optKey.startsWith("<") && optKey !== "N/A" ? optKey : void 0) || $env.GOOGLE_CLOUD_API_KEY;
|
|
81
|
+
}
|
|
82
|
+
function resolveProject(options) {
|
|
83
|
+
const project = options?.project || $env.GOOGLE_CLOUD_PROJECT || $env.GCP_PROJECT || $env.GCLOUD_PROJECT;
|
|
84
|
+
if (!project) throw new ConfigurationError("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCP_PROJECT/GCLOUD_PROJECT or pass project in options.");
|
|
85
|
+
return project;
|
|
86
|
+
}
|
|
87
|
+
function resolveAmbientLocation() {
|
|
88
|
+
return $env.GOOGLE_VERTEX_LOCATION || $env.GOOGLE_CLOUD_LOCATION || $env.VERTEX_LOCATION || void 0;
|
|
89
|
+
}
|
|
90
|
+
function resolveOptionalLocation(options) {
|
|
91
|
+
return options?.location || resolveAmbientLocation();
|
|
92
|
+
}
|
|
93
|
+
function resolveLocation(options) {
|
|
94
|
+
const location = resolveOptionalLocation(options);
|
|
95
|
+
if (!location) throw new ConfigurationError("Vertex AI requires a location. Set GOOGLE_VERTEX_LOCATION/GOOGLE_CLOUD_LOCATION/VERTEX_LOCATION or pass location in options.");
|
|
96
|
+
return location;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { streamGoogleVertex };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { g as MissingApiKeyError } from "./error-B3bevhrs.mjs";
|
|
4
|
+
import { n as getEnvApiKey } from "./stream-C_RAoxJC.mjs";
|
|
5
|
+
import { p as streamGoogleGenAI, t as buildGoogleGenerateContentParams } from "./google-shared-DzhCb9b0.mjs";
|
|
6
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/google.ts
|
|
7
|
+
const DEFAULT_GENERATIVE_LANGUAGE_BASE = "https://generativelanguage.googleapis.com/v1beta";
|
|
8
|
+
const streamGoogle = (model, context, options) => {
|
|
9
|
+
const apiKey = options?.apiKey || getEnvApiKey(model.provider);
|
|
10
|
+
if (!apiKey) throw new MissingApiKeyError(void 0, "Google Generative AI requires an API key (GEMINI_API_KEY or options.apiKey).");
|
|
11
|
+
return streamGoogleGenAI({
|
|
12
|
+
model,
|
|
13
|
+
options,
|
|
14
|
+
api: "google-generative-ai",
|
|
15
|
+
prepare: () => {
|
|
16
|
+
return {
|
|
17
|
+
params: buildGoogleGenerateContentParams(model, context, options ?? {}),
|
|
18
|
+
url: `${model.baseUrl?.trim() || DEFAULT_GENERATIVE_LANGUAGE_BASE}/models/${model.id}:streamGenerateContent?alt=sse`,
|
|
19
|
+
headers: {
|
|
20
|
+
"x-goog-api-key": apiKey,
|
|
21
|
+
...model.headers ?? {},
|
|
22
|
+
...options?.headers ?? {}
|
|
23
|
+
},
|
|
24
|
+
fetch: options?.fetch
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { streamGoogle };
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { i as getBundledProviders, r as getBundledModels, w as modelFamilyToken } from "./models-SGASygJ3.mjs";
|
|
4
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@17.3.5/node_modules/@oh-my-pi/pi-catalog/src/identity/id.ts
|
|
5
|
+
const LEADING_BRACKETED_AFFIX_PATTERN = /^(?:\s*(?:\[|【)[^\]】]+(?:\]|】)\s*)+/u;
|
|
6
|
+
const TRAILING_BRACKETED_AFFIX_PATTERN = /(?:\s*(?:\[|【)[^\]】]+(?:\]|】)\s*)+$/u;
|
|
7
|
+
const MODEL_ID_SEGMENT_PATTERN = /[a-z0-9.:-]+/g;
|
|
8
|
+
const MODEL_FAMILY_PREFIX_PATTERN = /^(claude|gemini|gpt|grok|glm|qwen|deepseek|kimi|mimo|doubao|ernie|gpt-oss|gemma|minimax|step|command|jamba|llama|o[1345])/i;
|
|
9
|
+
function normalizeModelIdWhitespace(value) {
|
|
10
|
+
return value.trim().replace(/\s+/g, " ");
|
|
11
|
+
}
|
|
12
|
+
/** Ordering for model-like segments: longest first, ties broken lexicographically. */
|
|
13
|
+
function compareSegmentPreference(left, right) {
|
|
14
|
+
return left.length !== right.length ? right.length - left.length : left.localeCompare(right);
|
|
15
|
+
}
|
|
16
|
+
function getModelLikeIdSegments(modelId) {
|
|
17
|
+
const matches = normalizeModelIdWhitespace(modelId).toLowerCase().match(MODEL_ID_SEGMENT_PATTERN);
|
|
18
|
+
if (!matches) return [];
|
|
19
|
+
const segments = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const segment of matches) if (MODEL_FAMILY_PREFIX_PATTERN.test(segment) && /\d/.test(segment)) segments.add(segment);
|
|
21
|
+
return [...segments].sort(compareSegmentPreference);
|
|
22
|
+
}
|
|
23
|
+
function getLongestModelLikeIdSegment(modelId) {
|
|
24
|
+
const matches = normalizeModelIdWhitespace(modelId).toLowerCase().match(MODEL_ID_SEGMENT_PATTERN);
|
|
25
|
+
if (!matches) return void 0;
|
|
26
|
+
let best;
|
|
27
|
+
for (const segment of matches) if (MODEL_FAMILY_PREFIX_PATTERN.test(segment) && /\d/.test(segment) && (best === void 0 || compareSegmentPreference(segment, best) < 0)) best = segment;
|
|
28
|
+
return best;
|
|
29
|
+
}
|
|
30
|
+
function hasBracketAffixMarker(value) {
|
|
31
|
+
for (let index = 0; index < value.length; index++) {
|
|
32
|
+
const code = value.charCodeAt(index);
|
|
33
|
+
if (code === 91 || code === 93 || code === 12304 || code === 12305) return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Strip reseller / wrapper tags that are injected as bracketed affixes around an
|
|
39
|
+
* upstream model id, e.g.
|
|
40
|
+
* "[Kiro] claude-opus-4-8" -> "claude-opus-4-8"
|
|
41
|
+
* "[gcli转] gemini-3.1-pro-preview [假流]" -> "gemini-3.1-pro-preview"
|
|
42
|
+
*
|
|
43
|
+
* Candidates are returned most-stripped first: both ends, then leading-only, then trailing-only.
|
|
44
|
+
*/
|
|
45
|
+
function getBracketStrippedModelIdCandidates(modelId) {
|
|
46
|
+
if (!hasBracketAffixMarker(modelId)) return [];
|
|
47
|
+
const normalized = normalizeModelIdWhitespace(modelId);
|
|
48
|
+
if (!normalized) return [];
|
|
49
|
+
const strippedLeading = normalized.replace(LEADING_BRACKETED_AFFIX_PATTERN, "");
|
|
50
|
+
const withoutLeading = normalizeModelIdWhitespace(strippedLeading);
|
|
51
|
+
const withoutTrailing = normalizeModelIdWhitespace(normalized.replace(TRAILING_BRACKETED_AFFIX_PATTERN, ""));
|
|
52
|
+
const withoutBoth = normalizeModelIdWhitespace(strippedLeading.replace(TRAILING_BRACKETED_AFFIX_PATTERN, ""));
|
|
53
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const candidate of [
|
|
55
|
+
withoutBoth,
|
|
56
|
+
withoutLeading,
|
|
57
|
+
withoutTrailing
|
|
58
|
+
]) if (candidate && candidate !== normalized) candidates.add(candidate);
|
|
59
|
+
return [...candidates];
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@17.3.5/node_modules/@oh-my-pi/pi-catalog/src/identity/markers.ts
|
|
63
|
+
/**
|
|
64
|
+
* Trailing-marker vocabulary shared by canonical-id resolution and
|
|
65
|
+
* proxy-reference lookup. A "marker" is a routing/quantization/effort suffix
|
|
66
|
+
* a reseller or aggregator appends to an upstream model id
|
|
67
|
+
* (`-thinking`, `:nitro`, `-fp8`, …) that does not change model identity.
|
|
68
|
+
*/
|
|
69
|
+
const TRAILING_MARKERS = [
|
|
70
|
+
"thinking",
|
|
71
|
+
"customtools",
|
|
72
|
+
"high",
|
|
73
|
+
"low",
|
|
74
|
+
"medium",
|
|
75
|
+
"minimal",
|
|
76
|
+
"xhigh",
|
|
77
|
+
"free",
|
|
78
|
+
"cloud",
|
|
79
|
+
"exacto",
|
|
80
|
+
"nitro",
|
|
81
|
+
"original",
|
|
82
|
+
"optimized",
|
|
83
|
+
"nvfp4",
|
|
84
|
+
"fp8",
|
|
85
|
+
"fp4",
|
|
86
|
+
"bf16",
|
|
87
|
+
"int8",
|
|
88
|
+
"int4"
|
|
89
|
+
];
|
|
90
|
+
/**
|
|
91
|
+
* Markers treated as identity-preserving ONLY when recovering bundled metadata
|
|
92
|
+
* for a proxied model id, never during canonical-id coalescing: Perplexity's
|
|
93
|
+
* `sonar-pro-search` is a distinct model from `sonar-pro`, so canonical
|
|
94
|
+
* resolution must not strip `search`, while a proxy id like
|
|
95
|
+
* `claude-opus-4-6-search` should still inherit the upstream pricing/limits.
|
|
96
|
+
*/
|
|
97
|
+
const REFERENCE_ONLY_TRAILING_MARKERS = ["search"];
|
|
98
|
+
function buildTrailingMarkerPattern(markers) {
|
|
99
|
+
return new RegExp(`[-:](?:${markers.join("|")})$`, "i");
|
|
100
|
+
}
|
|
101
|
+
buildTrailingMarkerPattern(TRAILING_MARKERS);
|
|
102
|
+
/** Marker pattern used by proxy-reference lookup (`search` included). */
|
|
103
|
+
const REFERENCE_TRAILING_MARKER_PATTERN = buildTrailingMarkerPattern([...TRAILING_MARKERS, ...REFERENCE_ONLY_TRAILING_MARKERS]);
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@17.3.5/node_modules/@oh-my-pi/pi-catalog/src/identity/reference.ts
|
|
106
|
+
function isZeroCostXaiOAuthReference(candidate) {
|
|
107
|
+
return candidate.provider === "xai-oauth" && candidate.cost.input === 0 && candidate.cost.output === 0 && candidate.cost.cacheRead === 0 && candidate.cost.cacheWrite === 0;
|
|
108
|
+
}
|
|
109
|
+
function shouldReplaceReference(existing, candidate) {
|
|
110
|
+
if (!existing) return true;
|
|
111
|
+
if (candidate.contextWindow !== existing.contextWindow) return (candidate.contextWindow ?? 0) > (existing.contextWindow ?? 0);
|
|
112
|
+
if (candidate.maxTokens !== existing.maxTokens) return (candidate.maxTokens ?? 0) > (existing.maxTokens ?? 0);
|
|
113
|
+
const existingHasCachePricing = existing.cost.cacheRead > 0 || existing.cost.cacheWrite > 0;
|
|
114
|
+
const candidateHasCachePricing = candidate.cost.cacheRead > 0 || candidate.cost.cacheWrite > 0;
|
|
115
|
+
if (candidateHasCachePricing !== existingHasCachePricing) return candidateHasCachePricing;
|
|
116
|
+
return existing.provider !== "openai" && candidate.provider === "openai";
|
|
117
|
+
}
|
|
118
|
+
function normalizeReferenceKey(value) {
|
|
119
|
+
return value.trim().toLowerCase();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Build a reference index from a model catalog (typically the bundled models).
|
|
123
|
+
* Pure: callers are responsible for memoizing the result.
|
|
124
|
+
*/
|
|
125
|
+
function buildModelReferenceIndex(models) {
|
|
126
|
+
const exact = /* @__PURE__ */ new Map();
|
|
127
|
+
for (const candidate of models) {
|
|
128
|
+
if (isZeroCostXaiOAuthReference(candidate)) continue;
|
|
129
|
+
const key = normalizeReferenceKey(candidate.id);
|
|
130
|
+
if (shouldReplaceReference(exact.get(key), candidate)) exact.set(key, candidate);
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
exact,
|
|
134
|
+
suffixAlias: buildSuffixAliasMap(exact)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function buildSuffixAliasMap(exactReferences) {
|
|
138
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
139
|
+
for (const reference of exactReferences.values()) {
|
|
140
|
+
const slashIndex = reference.id.lastIndexOf("/");
|
|
141
|
+
if (slashIndex === -1) continue;
|
|
142
|
+
const alias = getLongestModelLikeIdSegment(reference.id.slice(slashIndex + 1));
|
|
143
|
+
if (!alias) continue;
|
|
144
|
+
if (shouldReplaceReference(aliases.get(alias), reference)) aliases.set(alias, reference);
|
|
145
|
+
}
|
|
146
|
+
return aliases;
|
|
147
|
+
}
|
|
148
|
+
function stripReferenceTrailingMarker(candidate) {
|
|
149
|
+
const match = REFERENCE_TRAILING_MARKER_PATTERN.exec(candidate);
|
|
150
|
+
return match ? candidate.slice(0, match.index) : void 0;
|
|
151
|
+
}
|
|
152
|
+
function getReferenceCandidateIds(modelId) {
|
|
153
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
154
|
+
const queue = [modelId];
|
|
155
|
+
for (let index = 0; index < queue.length; index += 1) {
|
|
156
|
+
const candidate = queue[index]?.trim();
|
|
157
|
+
if (!candidate || candidates.has(candidate)) continue;
|
|
158
|
+
candidates.add(candidate);
|
|
159
|
+
for (const stripped of getBracketStrippedModelIdCandidates(candidate)) queue.push(stripped);
|
|
160
|
+
for (const segment of getModelLikeIdSegments(candidate)) queue.push(segment);
|
|
161
|
+
for (const suffix of [":cloud", "-cloud"]) if (candidate.toLowerCase().endsWith(suffix)) queue.push(candidate.slice(0, -suffix.length));
|
|
162
|
+
const slashIndex = candidate.lastIndexOf("/");
|
|
163
|
+
if (slashIndex !== -1) queue.push(candidate.slice(slashIndex + 1));
|
|
164
|
+
const colonToDash = candidate.replace(/:/g, "-");
|
|
165
|
+
if (colonToDash !== candidate) queue.push(colonToDash);
|
|
166
|
+
const lowercased = candidate.toLowerCase();
|
|
167
|
+
if (lowercased !== candidate) queue.push(lowercased);
|
|
168
|
+
const strippedMarker = stripReferenceTrailingMarker(candidate);
|
|
169
|
+
if (strippedMarker) queue.push(strippedMarker);
|
|
170
|
+
}
|
|
171
|
+
return [...candidates];
|
|
172
|
+
}
|
|
173
|
+
/** Resolve a (possibly proxied/affixed) model id to its bundled upstream reference. */
|
|
174
|
+
function resolveModelReference(modelId, index) {
|
|
175
|
+
if (modelId.startsWith("@")) return void 0;
|
|
176
|
+
for (const candidate of getReferenceCandidateIds(modelId)) {
|
|
177
|
+
const key = normalizeReferenceKey(candidate);
|
|
178
|
+
const reference = index.exact.get(key) ?? index.suffixAlias.get(key);
|
|
179
|
+
if (reference) return reference;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@17.3.5/node_modules/@oh-my-pi/pi-catalog/src/identity/bundled.ts
|
|
184
|
+
/**
|
|
185
|
+
* Memoized proxy-reference index over the bundled model catalog.
|
|
186
|
+
*
|
|
187
|
+
* Lazy: walking every bundled model (~12K) triggers thinking enrichment, so the
|
|
188
|
+
* walk is deferred off module load and performed once. Consumers that need
|
|
189
|
+
* non-bundled reference data use the pure builder directly
|
|
190
|
+
* ({@link buildModelReferenceIndex}).
|
|
191
|
+
*/
|
|
192
|
+
let bundledModels;
|
|
193
|
+
function getBundledModelList() {
|
|
194
|
+
bundledModels ??= getBundledProviders().flatMap((provider) => getBundledModels(provider));
|
|
195
|
+
return bundledModels;
|
|
196
|
+
}
|
|
197
|
+
let referenceIndex;
|
|
198
|
+
/** Proxy-reference index over the bundled catalog. */
|
|
199
|
+
function getBundledModelReferenceIndex() {
|
|
200
|
+
referenceIndex ??= buildModelReferenceIndex(getBundledModelList());
|
|
201
|
+
return referenceIndex;
|
|
202
|
+
}
|
|
203
|
+
function preferredDialect(modelId) {
|
|
204
|
+
switch (modelFamilyToken(modelId)) {
|
|
205
|
+
case "anthropic": return "anthropic";
|
|
206
|
+
case "glm": return "glm";
|
|
207
|
+
case "gemini": return "gemini";
|
|
208
|
+
case "gemma": return "gemma";
|
|
209
|
+
case "kimi": return "kimi";
|
|
210
|
+
case "qwen": return "qwen3";
|
|
211
|
+
case "deepseek": return "deepseek";
|
|
212
|
+
case "minimax": return "minimax";
|
|
213
|
+
case "openai":
|
|
214
|
+
case "gpt-oss": return "harmony";
|
|
215
|
+
default: return "xml";
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
export { resolveModelReference as i, getBundledModelReferenceIndex as n, isZeroCostXaiOAuthReference as r, preferredDialect as t };
|