@xiaoso/dsh-tool-plus 0.1.0-beta.2 → 0.1.0-beta.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.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/amazon-bedrock-D-shAr1X.mjs +917 -0
- package/lib/anthropic-BWsZFzU8.mjs +262 -0
- package/lib/anthropic-CMT1Qj1t.mjs +3115 -0
- package/lib/api-key-login-CpzSezsi.mjs +157 -0
- package/lib/aws-credentials-8Mgn5MAy.mjs +867 -0
- package/lib/azure-openai-responses-CNkHiLUh.mjs +274 -0
- package/lib/bun-shim.mjs +172 -7
- package/lib/bundled-references-CSuBco5p.mjs +55 -0
- package/lib/callback-server-BEFNf-jf.mjs +398 -0
- package/lib/client.js +110 -40
- package/lib/cursor-BIQfBC6V.mjs +135 -0
- package/lib/cursor-DNk6eXDd.mjs +5470 -0
- package/lib/cursor-MjSm74IJ.mjs +273 -0
- package/lib/device-code-OI_tQcmc.mjs +51 -0
- package/lib/devin-CldyPD8K.mjs +95 -0
- package/lib/devin-CzRpTUOA.mjs +114 -0
- package/lib/devin-DXOeNyU7.mjs +542 -0
- package/lib/error-B3bevhrs.mjs +1449 -0
- package/lib/event-stream-BDPi64mK.mjs +151 -0
- package/lib/github-copilot-4GaMtQmg.mjs +208 -0
- package/lib/github-copilot-B2HGSIJK.mjs +104 -0
- package/lib/gitlab-duo-akICyfeD.mjs +155 -0
- package/lib/gitlab-duo-workflow-CSEgYk3N.mjs +91 -0
- package/lib/google-antigravity-Dlkdhahq.mjs +198 -0
- package/lib/google-auth-DhqpOYrX.mjs +232 -0
- package/lib/google-gemini-cli-BG_LRdIV.mjs +850 -0
- package/lib/google-gemini-cli-zJhiOcND.mjs +211 -0
- package/lib/google-oauth-shared-CwNWYdmR.mjs +147 -0
- package/lib/google-shared-DzhCb9b0.mjs +760 -0
- package/lib/google-vertex-kscbkyRb.mjs +99 -0
- package/lib/google-zyDOG9x7.mjs +30 -0
- package/lib/identity-DnB63pS7.mjs +219 -0
- package/lib/idle-iterator-C6XbWcuB.mjs +366 -0
- package/lib/index.mjs +2865 -2745
- package/lib/kimi-DMVI-zrZ.mjs +236 -0
- package/lib/markit-M0jhziqU.mjs +1417 -0
- package/lib/minimax-code-BK-3eBbz.mjs +53 -0
- package/lib/models-CfT4coYT.mjs +104660 -0
- package/lib/ollama-BQMGPxtV.mjs +589 -0
- package/lib/openai-codex-CQL_kvYL.mjs +255 -0
- package/lib/openai-codex-responses-Cz-2qpC7.mjs +3144 -0
- package/lib/openai-completions-i8doczAk.mjs +1360 -0
- package/lib/openai-reasoning-fallback-DGVVLgd1.mjs +286 -0
- package/lib/openai-responses-DTkBiiy-.mjs +867 -0
- package/lib/opencode-DaJjcUbf.mjs +38 -0
- package/lib/perplexity-9b-RQ0mV.mjs +194 -0
- package/lib/proxy-ZtUcl6r5.mjs +190 -0
- package/lib/scrapers-CL-WgdU1.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/src-DTid0g4K.mjs +5001 -0
- package/lib/stream-C_RAoxJC.mjs +10236 -0
- package/lib/stream-markup-healing-2toHXWXM.mjs +491 -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 +16 -2
- package/lib/types/tools/omp/sdk.d.ts +6 -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/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/bun-shim.d.ts +35 -3
- package/lib/types/tools/shared/image-bridge.d.ts +98 -0
- package/lib/types/tools/shared/omp-prompt.d.ts +4 -2
- package/lib/utils-2Wq2eATG.mjs +8119 -0
- package/lib/utils-BnX8O3vi.mjs +12303 -0
- package/lib/utils-CE8N8P4Q.mjs +12315 -0
- package/lib/utils-C_MrQ_0z.mjs +12301 -0
- package/lib/utils-D0Z1fyoO.mjs +12299 -0
- package/lib/utils-DppGHXQB.mjs +51 -0
- package/lib/utils-W8WdSBpX.mjs +12315 -0
- package/lib/vision-guard-BDD4OrKo.mjs +92 -0
- package/lib/wafer-DRU0EjZX.mjs +17 -0
- package/lib/xai-oauth-DPHDXKD7.mjs +446 -0
- package/lib/xiaomi-Dd87KSg5.mjs +157 -0
- package/lib/zai-CFeOt-53.mjs +203 -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,157 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { V as ProviderHttpError, _ as OnPromptRequiredError, h as LoginCancelledError, m as ApiKeyRequiredError } from "./error-B3bevhrs.mjs";
|
|
4
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/api-key-validation.ts
|
|
5
|
+
const VALIDATION_TIMEOUT_MS = 15e3;
|
|
6
|
+
function normalizeAnthropicCompatibleBaseUrl(baseUrl) {
|
|
7
|
+
const trimmed = baseUrl.trim().replace(/\/+$/, "");
|
|
8
|
+
return trimmed.endsWith("/v1") ? trimmed.slice(0, -3) : trimmed;
|
|
9
|
+
}
|
|
10
|
+
function resolveValidationHeaders(headers) {
|
|
11
|
+
return typeof headers === "function" ? headers() : headers;
|
|
12
|
+
}
|
|
13
|
+
async function createApiKeyValidationError(provider, response) {
|
|
14
|
+
let details = "";
|
|
15
|
+
try {
|
|
16
|
+
details = (await response.text()).trim();
|
|
17
|
+
} catch {}
|
|
18
|
+
const message = details ? `${provider} API key validation failed (${response.status}): ${details}` : `${provider} API key validation failed (${response.status})`;
|
|
19
|
+
return new ProviderHttpError(message, response.status, { headers: response.headers });
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Validate an API key against an OpenAI-compatible chat completions endpoint.
|
|
23
|
+
*
|
|
24
|
+
* Performs a minimal request to verify credentials and endpoint access.
|
|
25
|
+
*/
|
|
26
|
+
async function validateOpenAICompatibleApiKey(options) {
|
|
27
|
+
const timeoutSignal = AbortSignal.timeout(VALIDATION_TIMEOUT_MS);
|
|
28
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
|
|
29
|
+
const response = await (options.fetch ?? fetch)(`${options.baseUrl}/chat/completions`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
Authorization: `Bearer ${options.apiKey}`
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
model: options.model,
|
|
37
|
+
messages: [{
|
|
38
|
+
role: "user",
|
|
39
|
+
content: "ping"
|
|
40
|
+
}],
|
|
41
|
+
max_tokens: 1,
|
|
42
|
+
temperature: 0
|
|
43
|
+
}),
|
|
44
|
+
signal
|
|
45
|
+
});
|
|
46
|
+
if (response.ok) return;
|
|
47
|
+
throw await createApiKeyValidationError(options.provider, response);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validate an API key against an Anthropic-compatible messages endpoint.
|
|
51
|
+
*/
|
|
52
|
+
async function validateAnthropicCompatibleApiKey(options) {
|
|
53
|
+
const timeoutSignal = AbortSignal.timeout(VALIDATION_TIMEOUT_MS);
|
|
54
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
|
|
55
|
+
const baseUrl = normalizeAnthropicCompatibleBaseUrl(options.baseUrl);
|
|
56
|
+
const response = await (options.fetch ?? fetch)(`${baseUrl}/v1/messages`, {
|
|
57
|
+
method: "POST",
|
|
58
|
+
headers: {
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
|
+
"anthropic-version": "2023-06-01",
|
|
61
|
+
"x-api-key": options.apiKey
|
|
62
|
+
},
|
|
63
|
+
body: JSON.stringify({
|
|
64
|
+
model: options.model,
|
|
65
|
+
messages: [{
|
|
66
|
+
role: "user",
|
|
67
|
+
content: "ping"
|
|
68
|
+
}],
|
|
69
|
+
max_tokens: 1
|
|
70
|
+
}),
|
|
71
|
+
signal
|
|
72
|
+
});
|
|
73
|
+
if (response.ok) return;
|
|
74
|
+
throw await createApiKeyValidationError(options.provider, response);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validate an API key against a provider models endpoint.
|
|
78
|
+
*
|
|
79
|
+
* Useful for providers where access to specific models may vary by plan and
|
|
80
|
+
* should not block key validation.
|
|
81
|
+
*/
|
|
82
|
+
async function validateApiKeyAgainstModelsEndpoint(options) {
|
|
83
|
+
const timeoutSignal = AbortSignal.timeout(VALIDATION_TIMEOUT_MS);
|
|
84
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
|
|
85
|
+
const response = await (options.fetch ?? fetch)(options.modelsUrl, {
|
|
86
|
+
method: "GET",
|
|
87
|
+
headers: {
|
|
88
|
+
...resolveValidationHeaders(options.headers) ?? {},
|
|
89
|
+
Authorization: `Bearer ${options.apiKey}`
|
|
90
|
+
},
|
|
91
|
+
signal
|
|
92
|
+
});
|
|
93
|
+
if (response.ok) return;
|
|
94
|
+
throw await createApiKeyValidationError(options.provider, response);
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/api-key-login.ts
|
|
98
|
+
/**
|
|
99
|
+
* Shared factory for API-key-paste "login" flows.
|
|
100
|
+
*
|
|
101
|
+
* Several providers (Cerebras, Synthetic, Moonshot, Together, NanoGPT, ZenMux)
|
|
102
|
+
* don't actually implement OAuth — they just ask the user to paste an API key,
|
|
103
|
+
* optionally validate it, and return the trimmed key.
|
|
104
|
+
*/
|
|
105
|
+
function createApiKeyLogin(config) {
|
|
106
|
+
return async function login(options) {
|
|
107
|
+
if (!options.onPrompt) throw new OnPromptRequiredError(config.providerLabel);
|
|
108
|
+
if (config.authUrl && config.instructions) options.onAuth?.({
|
|
109
|
+
url: config.authUrl,
|
|
110
|
+
instructions: config.instructions
|
|
111
|
+
});
|
|
112
|
+
const apiKey = config.emptyKeyFallback === void 0 ? await options.onPrompt({
|
|
113
|
+
message: config.promptMessage,
|
|
114
|
+
placeholder: config.placeholder
|
|
115
|
+
}) : await options.onPrompt({
|
|
116
|
+
message: config.promptMessage,
|
|
117
|
+
placeholder: config.placeholder,
|
|
118
|
+
allowEmpty: true
|
|
119
|
+
});
|
|
120
|
+
if (options.signal?.aborted) throw new LoginCancelledError();
|
|
121
|
+
const trimmed = apiKey.trim();
|
|
122
|
+
if (!trimmed) {
|
|
123
|
+
if (config.emptyKeyFallback !== void 0) return config.emptyKeyFallback;
|
|
124
|
+
throw new ApiKeyRequiredError();
|
|
125
|
+
}
|
|
126
|
+
if (config.validation) {
|
|
127
|
+
options.onProgress?.("Validating API key...");
|
|
128
|
+
if (config.validation.kind === "chat-completions") await validateOpenAICompatibleApiKey({
|
|
129
|
+
provider: config.validation.provider,
|
|
130
|
+
apiKey: trimmed,
|
|
131
|
+
baseUrl: config.validation.baseUrl,
|
|
132
|
+
model: config.validation.model,
|
|
133
|
+
signal: options.signal,
|
|
134
|
+
fetch: options.fetch
|
|
135
|
+
});
|
|
136
|
+
else if (config.validation.kind === "anthropic-messages") await validateAnthropicCompatibleApiKey({
|
|
137
|
+
provider: config.validation.provider,
|
|
138
|
+
apiKey: trimmed,
|
|
139
|
+
baseUrl: config.validation.baseUrl,
|
|
140
|
+
model: config.validation.model,
|
|
141
|
+
signal: options.signal,
|
|
142
|
+
fetch: options.fetch
|
|
143
|
+
});
|
|
144
|
+
else await validateApiKeyAgainstModelsEndpoint({
|
|
145
|
+
provider: config.validation.provider,
|
|
146
|
+
apiKey: trimmed,
|
|
147
|
+
modelsUrl: typeof config.validation.modelsUrl === "function" ? config.validation.modelsUrl() : config.validation.modelsUrl,
|
|
148
|
+
headers: config.validation.headers,
|
|
149
|
+
signal: options.signal,
|
|
150
|
+
fetch: options.fetch
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return trimmed;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { validateApiKeyAgainstModelsEndpoint as n, validateOpenAICompatibleApiKey as r, createApiKeyLogin as t };
|