@xiaoso/dsh-tool-plus 0.1.16 → 0.1.17-beta.0
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/lib/{abort-DZ54CaKU.mjs → abort-BTblp0Rt.mjs} +2 -2
- package/lib/{alibaba-coding-plan-DODpkcqi.mjs → alibaba-coding-plan-t3R4YKCB.mjs} +3 -3
- package/lib/{alibaba-token-plan-C6lpKCda.mjs → alibaba-token-plan-CO4djG1y.mjs} +4 -4
- package/lib/{alibaba-token-plan-CHGyWOfX.mjs → alibaba-token-plan-CUjYJX0-.mjs} +1 -1
- package/lib/{anthropic-Dv_GGX6g.mjs → anthropic-nf7w6so1.mjs} +48 -21
- package/lib/{api-key-validation-MnMf_ihX.mjs → api-key-validation-C_tZ7Y9a.mjs} +2 -2
- package/lib/behavior-BwvTUtag.mjs +111 -0
- package/lib/{browser-render-BZXt548F.mjs → browser-render-BQaEVK_n.mjs} +4 -4
- package/lib/{reference-CtvM4zLU.mjs → bundled-references-CrQ4dQcT.mjs} +57 -4
- package/lib/cascade-BWjRTD1q.mjs +30265 -0
- package/lib/{cline-pass-BT9CBEOj.mjs → cline-pass-Bjm-O8GG.mjs} +2 -2
- package/lib/cloudflare-CKXRJ0l9.mjs +37 -0
- package/lib/{cloudflare-ai-gateway-DReN6ohJ.mjs → cloudflare-ai-gateway-BpnBSjwV.mjs} +8 -4
- package/lib/cloudflare-workers-ai-odj9XswL.mjs +32 -0
- package/lib/collapse-_nkb2dn7.mjs +1945 -0
- package/lib/{coreweave-C82HrLpb.mjs → coreweave-CGDZOD8-.mjs} +1 -1
- package/lib/{coreweave-C68UgRQO.mjs → coreweave-DwffcgW5.mjs} +4 -4
- package/lib/cursor-BgOuV7Qf.mjs +794 -0
- package/lib/{cursor-_gHHq-Dq.mjs → cursor-CF1iHHbv.mjs} +68 -19
- package/lib/{cursor-proto-Cr_WEMuv.mjs → cursor-proto-BuNTjX3L.mjs} +823 -23
- package/lib/{devin-QpfTSl9H.mjs → devin-7OEeEb80.mjs} +112 -31
- package/lib/{devin-proto-DYhp4Ty6.mjs → devin-proto-C-QreeAv.mjs} +71 -5
- package/lib/{dom-DG3sPESc.mjs → dom-BmbZv4v9.mjs} +598 -182
- package/lib/{error-O63pC8zg.mjs → error-8LVo7tug.mjs} +725 -104
- package/lib/factory-droid-ChhmsGWb.mjs +71 -0
- package/lib/{fs-promises-shim-B2YFWkcd.mjs → fs-promises-shim-CANAxFWh.mjs} +10 -1
- package/lib/{github-copilot-BMEcw8N1.mjs → github-copilot-QwevdT30.mjs} +4 -4
- package/lib/{github-copilot-headers-DnjGEbko.mjs → github-copilot-headers-CAUZ0rUD.mjs} +138 -26
- package/lib/{gitlab-duo-DnHqJjFY.mjs → gitlab-duo-DigV7k_o.mjs} +2 -2
- package/lib/{google-antigravity-B1mSckrK.mjs → google-antigravity-D-oe0r8A.mjs} +6 -7
- package/lib/{google-gemini-cli-DJwThCCn.mjs → google-gemini-cli-CQBHgGJT.mjs} +5 -6
- package/lib/{google-oauth-shared-BctLpVUN.mjs → google-oauth-shared-CvgVIUwJ.mjs} +2 -2
- package/lib/google-validation-CdvRj4ec.mjs +126 -0
- package/lib/id-EJwVLDHE.mjs +2548 -0
- package/lib/index.mjs +248 -258
- package/lib/{kilo-BEgEwMJQ.mjs → kilo-5r6OffCa.mjs} +2 -2
- package/lib/{kimi-T9NldEIJ.mjs → kimi-DOOtbXmm.mjs} +9 -10
- package/lib/{launch-BIWNyrBB.mjs → launch-DkAjib7h.mjs} +1 -1
- package/lib/{markit-Dvp2JPdT.mjs → markit-CCcyeAds.mjs} +359 -140
- package/lib/{models-DnXMYGcJ.mjs → models-DCpDT_im.mjs} +199203 -112275
- package/lib/{muse-code-CNvqqAp6.mjs → muse-code-CYf8zj_B.mjs} +5 -5
- package/lib/{openai-codex-D5-CyTxa.mjs → openai-codex-Cj-TvSFh.mjs} +13 -10
- package/lib/{perplexity-A2PEoGaC.mjs → perplexity-Dh_Qgsmx.mjs} +68 -25
- package/lib/{pkce-BYjmugmw.mjs → pkce-DO-jBJLV.mjs} +1 -1
- package/lib/pricing-DusBEhwm.mjs +593 -0
- package/lib/{readability-uGhqb4GC.mjs → readability-XHK0o3bv.mjs} +287 -27
- package/lib/{scrapers-C1ujjV8k.mjs → scrapers-B6PADOVm.mjs} +13 -13
- package/lib/slugify-ynYWBIA5.mjs +11 -0
- package/lib/snowflake-B_jap6lz.mjs +666 -0
- package/lib/snowflake-Cu1ZyOp6.mjs +151 -0
- package/lib/{src-AELUUb5U.mjs → src-BhinCSpi.mjs} +1172 -458
- package/lib/{stream-AVOoe5Hj.mjs → stream-D2ivg3GH.mjs} +3740 -5311
- package/lib/{turndown-D6fof1OX.mjs → turndown-Vya8SavL.mjs} +82 -30
- package/lib/types/tools/hashline/native/index.d.ts +2 -2
- package/lib/types/tools/hashline/native/policy.d.ts +19 -21
- package/lib/types/tools/omp/session/agent-storage.d.ts +3 -3
- package/lib/types/tools/shared/bun-named-shim.d.ts +5 -0
- package/lib/{types-BLrLohwK.mjs → types-tH1v9uRm.mjs} +2 -2
- package/lib/{utils-cZX3f_Ls.mjs → utils-C_Ncya1r.mjs} +1737 -509
- package/lib/utils-D2tK38xq.mjs +34006 -0
- package/lib/{utils-I4I8azHN.mjs → utils-DrDwmNtu.mjs} +8 -3
- package/lib/{xai-oauth-CbeldUSV.mjs → xai-oauth-DLLzX6my.mjs} +4 -4
- package/lib/{xiaomi-Dl3VSs04.mjs → xiaomi-CqK-KivK.mjs} +2 -2
- package/lib/{zai-FyjGSypr.mjs → zai-DoJ2xPIH.mjs} +2 -2
- package/lib/{zip-DRrycScC.mjs → zip-DG1mUV6X.mjs} +1 -1
- package/package.json +8 -8
- package/lib/amazon-bedrock-Dx0rr9dY.mjs +0 -996
- package/lib/anthropic-ClCw0PV_.mjs +0 -3624
- package/lib/anthropic-wire-lbGAFzYb.mjs +0 -927
- package/lib/azure-openai-responses-WE_bgFWp.mjs +0 -285
- package/lib/bundled-references-DY3EJxZV.mjs +0 -56
- package/lib/cloudflare-ai-gateway-CrMa97Ap.mjs +0 -44
- package/lib/collapse-CkMNRNr7.mjs +0 -2304
- package/lib/cursor-C6jaIJDg.mjs +0 -283
- package/lib/cursor-D-XZYDf_.mjs +0 -4544
- package/lib/deterministic-id-CUEIMSqR.mjs +0 -17
- package/lib/devin-ExGIghmx.mjs +0 -69
- package/lib/devin-u0ljw5P6.mjs +0 -628
- package/lib/effort-BdtQMN-_.mjs +0 -23
- package/lib/event-stream-BKEtb45Y.mjs +0 -167
- package/lib/gemini-headers-Co9cVvex.mjs +0 -54
- package/lib/google-auth-qAN-6DMW.mjs +0 -232
- package/lib/google-gemini-cli-B2Aw1S5w.mjs +0 -844
- package/lib/google-lTxuq28n.mjs +0 -38
- package/lib/google-shared-Y01j9xOr.mjs +0 -856
- package/lib/google-validation-BEkNs-Bx.mjs +0 -18
- package/lib/google-vertex-DcM-FRC5.mjs +0 -99
- package/lib/hosts-00rjRzUD.mjs +0 -203
- package/lib/id-AL5obQzR.mjs +0 -71
- package/lib/idle-iterator-D0ZXEcUq.mjs +0 -366
- package/lib/ollama-6R0oXZks.mjs +0 -574
- package/lib/openai-codex-responses-C8bnBWOe.mjs +0 -3232
- package/lib/openai-completions-DNr3mUsn.mjs +0 -1430
- package/lib/openai-configuration-update-xMYUjaK_.mjs +0 -150
- package/lib/openai-reasoning-fallback-Ju-5pSR8.mjs +0 -380
- package/lib/openai-responses-CjpafAEr.mjs +0 -861
- package/lib/protobuf-BMgDYu_U.mjs +0 -717
- package/lib/provider-response-SqKSkkUc.mjs +0 -22
- package/lib/proxy-DxvCQOCA.mjs +0 -230
- package/lib/request-debug-BwPOqN_j.mjs +0 -183
- package/lib/sanitize-text-BCf5KmCf.mjs +0 -33
- package/lib/sse-debug-B-tkLCPW.mjs +0 -11
- package/lib/stream-markup-healing-CN3RsqG9.mjs +0 -267
- package/lib/strict-tool-validation-CBTz1dAA.mjs +0 -105
- package/lib/taxonomy-DSIM99rS.mjs +0 -15392
- package/lib/thinking-ngMwf_1Y.mjs +0 -336
- package/lib/type-guards-CttAANEx.mjs +0 -11
- package/lib/utils-CE3DSebh.mjs +0 -11763
- package/lib/vision-guard-BCpXWUj3.mjs +0 -77
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
-
__installBunShim();
|
|
3
|
-
import { r as __exportAll } from "./fs-promises-shim-B2YFWkcd.mjs";
|
|
4
|
-
import { N as $env } from "./src-AELUUb5U.mjs";
|
|
5
|
-
import { B as OpenAIHttpError, _ as AbortError, c as finalize, h as MissingApiKeyError, n as StreamTimeoutError, s as ProviderResponseError, t as ConfigurationError } from "./error-O63pC8zg.mjs";
|
|
6
|
-
import { A as toolWireSchema, c as resolveCacheRetention, z as sanitizeSchemaForOpenAIResponses } from "./utils-cZX3f_Ls.mjs";
|
|
7
|
-
import { At as withReplaySafeStreamRetry, Et as mapToOpenAIResponsesToolChoice, F as buildResponsesInput, V as createInitialResponsesAssistantMessage, dt as parseAzureDeploymentNameMap, et as getOpenAIPromptCacheKey, j as applyResponsesReasoningParams, n as getEnvApiKey, ot as isOpenAIResponsesProgressEvent, pt as processResponsesStream, w as applyCommonResponsesSamplingParams } from "./stream-AVOoe5Hj.mjs";
|
|
8
|
-
import { t as createAbortSourceTracker } from "./abort-DZ54CaKU.mjs";
|
|
9
|
-
import { t as AssistantMessageEventStream } from "./event-stream-BKEtb45Y.mjs";
|
|
10
|
-
import { n as getOpenAIStreamFirstEventTimeoutMs, o as iterateWithIdleTimeout, r as getOpenAIStreamIdleTimeoutMs } from "./idle-iterator-D0ZXEcUq.mjs";
|
|
11
|
-
import { c as postOpenAIStream, r as createOpenAIReasoningEffortFallbackKey, s as resolveOpenAIReasoningEffortFallback, t as applyOpenAIReasoningEffortFallback } from "./openai-reasoning-fallback-Ju-5pSR8.mjs";
|
|
12
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/providers/azure-openai-responses.ts
|
|
13
|
-
var azure_openai_responses_exports = /* @__PURE__ */ __exportAll({ streamAzureOpenAIResponses: () => streamAzureOpenAIResponses });
|
|
14
|
-
const DEFAULT_AZURE_API_VERSION = "v1";
|
|
15
|
-
const AZURE_OPENAI_RESPONSES_FIRST_EVENT_TIMEOUT_MESSAGE = "Azure OpenAI responses stream timed out while waiting for the first event";
|
|
16
|
-
function resolveDeploymentName(model, options) {
|
|
17
|
-
if (options?.azureDeploymentName) return options.azureDeploymentName;
|
|
18
|
-
return parseAzureDeploymentNameMap($env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(model.id) ?? model.id;
|
|
19
|
-
}
|
|
20
|
-
/** Runs one Azure OpenAI Responses request and decodes its event stream. */
|
|
21
|
-
const streamAzureOpenAIResponsesOnce = (model, context, options) => {
|
|
22
|
-
const stream = new AssistantMessageEventStream();
|
|
23
|
-
(async () => {
|
|
24
|
-
const startTime = performance.now();
|
|
25
|
-
let firstTokenTime;
|
|
26
|
-
const deploymentName = resolveDeploymentName(model, options);
|
|
27
|
-
const output = createInitialResponsesAssistantMessage("azure-openai-responses", model.provider, model.id);
|
|
28
|
-
let rawRequestDump;
|
|
29
|
-
const abortTracker = createAbortSourceTracker(options?.signal);
|
|
30
|
-
const firstEventTimeoutAbortError = new StreamTimeoutError(AZURE_OPENAI_RESPONSES_FIRST_EVENT_TIMEOUT_MESSAGE);
|
|
31
|
-
const { requestAbortController, requestSignal } = abortTracker;
|
|
32
|
-
const onSseEvent = options?.onSseEvent;
|
|
33
|
-
const rawSseObserver = onSseEvent ? (event) => {
|
|
34
|
-
if (!event.event && event.data && event.data !== "[DONE]") try {
|
|
35
|
-
const parsed = JSON.parse(event.data);
|
|
36
|
-
const resolvedEvent = typeof parsed.type === "string" ? parsed.type : typeof parsed.object === "string" ? parsed.object : null;
|
|
37
|
-
if (resolvedEvent) {
|
|
38
|
-
event.event = resolvedEvent;
|
|
39
|
-
event.raw = [`event: ${resolvedEvent}`, ...event.raw];
|
|
40
|
-
}
|
|
41
|
-
} catch {}
|
|
42
|
-
onSseEvent(event, model);
|
|
43
|
-
} : void 0;
|
|
44
|
-
try {
|
|
45
|
-
const { url, headers, baseUrl } = buildAzureResponsesRequest(model, options?.apiKey || getEnvApiKey(model.provider) || "", options);
|
|
46
|
-
const requestModel = modelForAzureEndpoint(model, baseUrl);
|
|
47
|
-
let params = buildParams(requestModel, context, options, deploymentName);
|
|
48
|
-
const replacementPayload = await options?.onPayload?.(params, requestModel);
|
|
49
|
-
if (replacementPayload !== void 0) params = replacementPayload;
|
|
50
|
-
const idleTimeoutMs = options?.streamIdleTimeoutMs ?? getOpenAIStreamIdleTimeoutMs();
|
|
51
|
-
const firstEventTimeoutMs = options?.streamFirstEventTimeoutMs ?? getOpenAIStreamFirstEventTimeoutMs(idleTimeoutMs);
|
|
52
|
-
const requestTimeoutMs = firstEventTimeoutMs !== void 0 && firstEventTimeoutMs > 0 ? firstEventTimeoutMs : void 0;
|
|
53
|
-
rawRequestDump = {
|
|
54
|
-
provider: model.provider,
|
|
55
|
-
api: output.api,
|
|
56
|
-
model: model.id,
|
|
57
|
-
method: "POST",
|
|
58
|
-
url,
|
|
59
|
-
body: params
|
|
60
|
-
};
|
|
61
|
-
const reasoningEffortFallbackKey = createOpenAIReasoningEffortFallbackKey("azure-responses", url, typeof params.model === "string" ? params.model : model.id);
|
|
62
|
-
const attemptedReasoningEffortFallbacks = /* @__PURE__ */ new Set();
|
|
63
|
-
let openaiStream;
|
|
64
|
-
while (true) {
|
|
65
|
-
let requestTimeout;
|
|
66
|
-
if (requestTimeoutMs !== void 0) requestTimeout = setTimeout(() => abortTracker.abortLocally(firstEventTimeoutAbortError), requestTimeoutMs);
|
|
67
|
-
try {
|
|
68
|
-
const headersWithTimeout = { ...headers };
|
|
69
|
-
if (requestTimeoutMs !== void 0) headersWithTimeout["X-Stainless-Timeout"] = Math.floor(requestTimeoutMs / 1e3).toString();
|
|
70
|
-
openaiStream = (await postOpenAIStream({
|
|
71
|
-
url,
|
|
72
|
-
headers: headersWithTimeout,
|
|
73
|
-
body: params,
|
|
74
|
-
signal: requestSignal,
|
|
75
|
-
fetch: options?.fetch,
|
|
76
|
-
onSseEvent: rawSseObserver
|
|
77
|
-
})).events;
|
|
78
|
-
break;
|
|
79
|
-
} catch (error) {
|
|
80
|
-
const capturedErrorResponse = error instanceof OpenAIHttpError ? error.captured : void 0;
|
|
81
|
-
const reasoningEffortFallback = !requestSignal.aborted ? resolveOpenAIReasoningEffortFallback(error, capturedErrorResponse, params) : void 0;
|
|
82
|
-
if (reasoningEffortFallback === void 0) throw error;
|
|
83
|
-
const retryMarker = `${reasoningEffortFallbackKey}:${String(reasoningEffortFallback)}`;
|
|
84
|
-
if (attemptedReasoningEffortFallbacks.has(retryMarker)) throw error;
|
|
85
|
-
attemptedReasoningEffortFallbacks.add(retryMarker);
|
|
86
|
-
applyOpenAIReasoningEffortFallback(params, reasoningEffortFallback);
|
|
87
|
-
rawRequestDump.body = params;
|
|
88
|
-
} finally {
|
|
89
|
-
if (requestTimeout !== void 0) clearTimeout(requestTimeout);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
stream.push({
|
|
93
|
-
type: "start",
|
|
94
|
-
partial: output
|
|
95
|
-
});
|
|
96
|
-
const timedOpenaiStream = iterateWithIdleTimeout(openaiStream, {
|
|
97
|
-
idleTimeoutMs,
|
|
98
|
-
firstItemTimeoutMs: firstEventTimeoutMs,
|
|
99
|
-
firstItemErrorMessage: AZURE_OPENAI_RESPONSES_FIRST_EVENT_TIMEOUT_MESSAGE,
|
|
100
|
-
errorMessage: "Azure OpenAI responses stream stalled while waiting for the next event",
|
|
101
|
-
onIdle: () => requestAbortController.abort(),
|
|
102
|
-
onFirstItemTimeout: () => abortTracker.abortLocally(firstEventTimeoutAbortError),
|
|
103
|
-
abortSignal: options?.signal,
|
|
104
|
-
isProgressItem: isOpenAIResponsesProgressEvent
|
|
105
|
-
});
|
|
106
|
-
let sawTerminalResponseEvent = false;
|
|
107
|
-
await processResponsesStream(timedOpenaiStream, output, stream, model, {
|
|
108
|
-
onFirstToken: () => {
|
|
109
|
-
if (!firstTokenTime) firstTokenTime = performance.now();
|
|
110
|
-
},
|
|
111
|
-
onCompleted: () => {
|
|
112
|
-
sawTerminalResponseEvent = true;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
const firstEventTimeoutError = abortTracker.getLocalAbortReason();
|
|
116
|
-
if (firstEventTimeoutError) throw firstEventTimeoutError;
|
|
117
|
-
if (abortTracker.wasCallerAbort()) throw new AbortError();
|
|
118
|
-
if (!sawTerminalResponseEvent) throw new ProviderResponseError("Azure OpenAI responses stream closed before a terminal response event was received", {
|
|
119
|
-
provider: model.provider,
|
|
120
|
-
kind: "incomplete-stream"
|
|
121
|
-
});
|
|
122
|
-
if (output.stopReason === "aborted" || output.stopReason === "error") throw new ProviderResponseError(output.errorMessage ?? "An unknown error occurred", {
|
|
123
|
-
provider: model.provider,
|
|
124
|
-
kind: "output"
|
|
125
|
-
});
|
|
126
|
-
output.duration = performance.now() - startTime;
|
|
127
|
-
if (firstTokenTime) output.ttft = firstTokenTime - startTime;
|
|
128
|
-
stream.push({
|
|
129
|
-
type: "done",
|
|
130
|
-
reason: output.stopReason,
|
|
131
|
-
message: output
|
|
132
|
-
});
|
|
133
|
-
stream.end();
|
|
134
|
-
} catch (error) {
|
|
135
|
-
const result = await finalize(error, {
|
|
136
|
-
api: model.api,
|
|
137
|
-
abortTracker,
|
|
138
|
-
rawRequestDump
|
|
139
|
-
});
|
|
140
|
-
output.stopReason = result.stopReason;
|
|
141
|
-
output.errorStatus = result.status;
|
|
142
|
-
output.errorId = result.id;
|
|
143
|
-
output.errorMessage = result.message;
|
|
144
|
-
output.duration = performance.now() - startTime;
|
|
145
|
-
if (firstTokenTime) output.ttft = firstTokenTime - startTime;
|
|
146
|
-
stream.push({
|
|
147
|
-
type: "error",
|
|
148
|
-
reason: output.stopReason,
|
|
149
|
-
error: output
|
|
150
|
-
});
|
|
151
|
-
stream.end();
|
|
152
|
-
}
|
|
153
|
-
})();
|
|
154
|
-
return stream;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Retries transient Azure stream failures only before assistant output commits
|
|
158
|
-
* the attempt. The unsupported explicit prompt-cache config is rejected
|
|
159
|
-
* synchronously here — callers of the direct entrypoint get the immediate
|
|
160
|
-
* `ConfigurationError` rather than a stream whose `.result()` rejects later.
|
|
161
|
-
*/
|
|
162
|
-
const streamAzureOpenAIResponses = (model, context, options) => {
|
|
163
|
-
if (options?.promptCache?.mode === "explicit" && resolveCacheRetention(options.cacheRetention) !== "none") throw new ConfigurationError(`OpenAI explicit prompt caching is unsupported for ${model.provider}/${model.id}; Azure Responses does not emit explicit cache controls.`);
|
|
164
|
-
return withReplaySafeStreamRetry(model, context, options, streamAzureOpenAIResponsesOnce, {
|
|
165
|
-
retryProviderErrors: true,
|
|
166
|
-
maxProviderErrorRetries: 1
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
function resolveAzureConfig(model, options) {
|
|
170
|
-
const apiVersion = options?.azureApiVersion || $env.AZURE_OPENAI_API_VERSION || DEFAULT_AZURE_API_VERSION;
|
|
171
|
-
const baseUrl = options?.azureBaseUrl?.trim() || $env.AZURE_OPENAI_BASE_URL?.trim() || void 0;
|
|
172
|
-
const resourceName = options?.azureResourceName || $env.AZURE_OPENAI_RESOURCE_NAME;
|
|
173
|
-
let resolvedBaseUrl = baseUrl;
|
|
174
|
-
if (!resolvedBaseUrl && resourceName) resolvedBaseUrl = `https://${resourceName}.openai.azure.com/openai/v1`;
|
|
175
|
-
if (!resolvedBaseUrl && model.baseUrl) resolvedBaseUrl = model.baseUrl;
|
|
176
|
-
if (!resolvedBaseUrl) throw new ConfigurationError("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");
|
|
177
|
-
return {
|
|
178
|
-
baseUrl: resolvedBaseUrl.replace(/\/+$/, ""),
|
|
179
|
-
apiVersion
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
function modelForAzureEndpoint(model, baseUrl) {
|
|
183
|
-
if (model.supportsComputerUseConfig !== void 0 || model.supportsComputerUse !== true) return model;
|
|
184
|
-
try {
|
|
185
|
-
const url = new URL(baseUrl);
|
|
186
|
-
if (url.protocol === "https:" && (url.hostname.endsWith(".openai.azure.com") || url.hostname === "models.inference.ai.azure.com")) return model;
|
|
187
|
-
} catch {}
|
|
188
|
-
return {
|
|
189
|
-
...model,
|
|
190
|
-
supportsComputerUse: false
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Replicates the `AzureOpenAI` SDK client's request shape for `/responses`:
|
|
195
|
-
* a string api key becomes a single `api-key` header (azure.mjs `authHeaders`;
|
|
196
|
-
* never `Authorization: Bearer`), `api-version` rides as a query parameter
|
|
197
|
-
* (azure.mjs constructor `defaultQuery`), and `/responses` is not a
|
|
198
|
-
* deployment-scoped path, so no `/deployments/{model}` URL rewriting applies.
|
|
199
|
-
* Custom model/options headers may override the auth header, matching the SDK's
|
|
200
|
-
* `buildHeaders` precedence.
|
|
201
|
-
*/
|
|
202
|
-
function buildAzureResponsesRequest(model, apiKey, options) {
|
|
203
|
-
if (!apiKey) {
|
|
204
|
-
const envKey = $env.AZURE_OPENAI_API_KEY;
|
|
205
|
-
if (!envKey) throw new MissingApiKeyError(void 0, "Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");
|
|
206
|
-
apiKey = envKey;
|
|
207
|
-
}
|
|
208
|
-
const headers = {
|
|
209
|
-
"api-key": apiKey,
|
|
210
|
-
...model.headers
|
|
211
|
-
};
|
|
212
|
-
if (options?.headers) Object.assign(headers, options.headers);
|
|
213
|
-
const { baseUrl, apiVersion } = resolveAzureConfig(model, options);
|
|
214
|
-
return {
|
|
215
|
-
url: `${baseUrl}/responses?api-version=${encodeURIComponent(apiVersion)}`,
|
|
216
|
-
headers,
|
|
217
|
-
baseUrl
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
function buildParams(model, context, options, deploymentName) {
|
|
221
|
-
const systemRole = model.reasoning && model.compat.supportsDeveloperRole ? "developer" : "system";
|
|
222
|
-
const params = {
|
|
223
|
-
model: deploymentName,
|
|
224
|
-
input: buildResponsesInput({
|
|
225
|
-
model,
|
|
226
|
-
context,
|
|
227
|
-
strictResponsesPairing: true,
|
|
228
|
-
supportsImageDetailOriginal: model.compat.supportsImageDetailOriginal,
|
|
229
|
-
systemRole,
|
|
230
|
-
nativeHistory: {
|
|
231
|
-
replay: true,
|
|
232
|
-
filterReasoning: false
|
|
233
|
-
},
|
|
234
|
-
includeThinkingSignatures: true,
|
|
235
|
-
developerStringContent: true,
|
|
236
|
-
preserveAssistantMessageIds: true,
|
|
237
|
-
repairOrphanOutputs: true
|
|
238
|
-
}),
|
|
239
|
-
stream: true,
|
|
240
|
-
prompt_cache_key: getOpenAIPromptCacheKey(options),
|
|
241
|
-
store: false
|
|
242
|
-
};
|
|
243
|
-
applyCommonResponsesSamplingParams(params, options, model);
|
|
244
|
-
if (options?.include?.length) params.include = Array.from(new Set(options.include));
|
|
245
|
-
if (context.tools) {
|
|
246
|
-
const serializedTools = [];
|
|
247
|
-
for (const tool of context.tools) {
|
|
248
|
-
if (tool.native?.type === "computer") {
|
|
249
|
-
if (model.supportsComputerUse === true) {
|
|
250
|
-
serializedTools.push({ type: "computer" });
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
} else if (tool.native !== void 0) continue;
|
|
254
|
-
serializedTools.push({
|
|
255
|
-
type: "function",
|
|
256
|
-
name: tool.name,
|
|
257
|
-
description: tool.description || "",
|
|
258
|
-
parameters: sanitizeSchemaForOpenAIResponses(toolWireSchema(tool)),
|
|
259
|
-
strict: false
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
if (serializedTools.length > 0) {
|
|
263
|
-
params.tools = serializedTools;
|
|
264
|
-
if (options?.toolChoice) {
|
|
265
|
-
let toolChoice = mapToOpenAIResponsesToolChoice(options.toolChoice);
|
|
266
|
-
const hasComputerTool = serializedTools.some((tool) => tool.type === "computer");
|
|
267
|
-
if (toolChoice && typeof toolChoice !== "string" && toolChoice.type === "computer" && !hasComputerTool) {
|
|
268
|
-
const computer = context.tools.find((tool) => tool.native?.type === "computer");
|
|
269
|
-
if (computer && serializedTools.some((tool) => tool.type === "function" && tool.name === computer.name)) toolChoice = {
|
|
270
|
-
type: "function",
|
|
271
|
-
name: computer.name
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
if (toolChoice && typeof toolChoice !== "string" && toolChoice.type === "function" && hasComputerTool) {
|
|
275
|
-
if (context.tools.find((tool) => tool.native?.type === "computer")?.name === toolChoice.name) toolChoice = { type: "computer" };
|
|
276
|
-
}
|
|
277
|
-
if (toolChoice && (typeof toolChoice === "string" || toolChoice.type === "computer" && hasComputerTool || toolChoice.type === "function" && serializedTools.some((tool) => tool.type === "function" && tool.name === toolChoice.name))) params.tool_choice = toolChoice;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
applyResponsesReasoningParams(params, model, options);
|
|
282
|
-
return params;
|
|
283
|
-
}
|
|
284
|
-
//#endregion
|
|
285
|
-
export { azure_openai_responses_exports as t };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
-
__installBunShim();
|
|
3
|
-
import { i as getBundledProviders, r as getBundledModels } from "./models-DnXMYGcJ.mjs";
|
|
4
|
-
import { n as isZeroCostXaiOAuthReference } from "./reference-CtvM4zLU.mjs";
|
|
5
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@18.1.17/node_modules/@oh-my-pi/pi-catalog/src/provider-models/bundled-references.ts
|
|
6
|
-
/**
|
|
7
|
-
* Project a built `Model` back to spec stage: `compat` becomes the verbatim
|
|
8
|
-
* sparse override record (`compatConfig`), never the resolved view. Discovery
|
|
9
|
-
* mappers spread these references into the specs they hand to the model
|
|
10
|
-
* manager, which rebuilds via `buildModel`.
|
|
11
|
-
*/
|
|
12
|
-
function toModelSpec(model) {
|
|
13
|
-
const { compat: _compat, compatConfig, supportsComputerUse: _derivedComputerUse, supportsComputerUseConfig, ...rest } = model;
|
|
14
|
-
return {
|
|
15
|
-
...rest,
|
|
16
|
-
...supportsComputerUseConfig !== void 0 ? { supportsComputerUse: supportsComputerUseConfig } : {},
|
|
17
|
-
compat: compatConfig
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function createBundledReferenceMap(provider) {
|
|
21
|
-
const references = /* @__PURE__ */ new Map();
|
|
22
|
-
for (const model of getBundledModels(provider)) references.set(model.id, toModelSpec(model));
|
|
23
|
-
return references;
|
|
24
|
-
}
|
|
25
|
-
let globalReferences;
|
|
26
|
-
function getGlobalReferences() {
|
|
27
|
-
if (globalReferences) return globalReferences;
|
|
28
|
-
const references = /* @__PURE__ */ new Map();
|
|
29
|
-
for (const provider of getBundledProviders()) for (const model of getBundledModels(provider)) {
|
|
30
|
-
const candidate = model;
|
|
31
|
-
if (candidate.provider === "cline-pass" || isZeroCostXaiOAuthReference(candidate)) continue;
|
|
32
|
-
const existing = references.get(candidate.id);
|
|
33
|
-
if (!existing) references.set(candidate.id, candidate);
|
|
34
|
-
else if (candidate.contextWindow !== existing.contextWindow) {
|
|
35
|
-
if ((candidate.contextWindow ?? 0) > (existing.contextWindow ?? 0)) references.set(candidate.id, candidate);
|
|
36
|
-
} else if (candidate.maxTokens !== existing.maxTokens) {
|
|
37
|
-
if ((candidate.maxTokens ?? 0) > (existing.maxTokens ?? 0)) references.set(candidate.id, candidate);
|
|
38
|
-
} else if (existing.provider !== "openai" && candidate.provider === "openai") references.set(candidate.id, candidate);
|
|
39
|
-
}
|
|
40
|
-
globalReferences = references;
|
|
41
|
-
return references;
|
|
42
|
-
}
|
|
43
|
-
function createReferenceResolver(providerReferenceSource) {
|
|
44
|
-
let lazyProviderReferences;
|
|
45
|
-
const getProviderReferences = typeof providerReferenceSource === "function" ? () => lazyProviderReferences ??= providerReferenceSource() : () => providerReferenceSource;
|
|
46
|
-
return (modelId) => {
|
|
47
|
-
const providerRefs = getProviderReferences();
|
|
48
|
-
const globalRefs = getGlobalReferences();
|
|
49
|
-
const providerRef = providerRefs.get(modelId);
|
|
50
|
-
if (providerRef) return providerRef;
|
|
51
|
-
const globalRef = globalRefs.get(modelId);
|
|
52
|
-
return globalRef ? toModelSpec(globalRef) : void 0;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { createReferenceResolver as n, toModelSpec as r, createBundledReferenceMap as t };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
-
__installBunShim();
|
|
3
|
-
import { n as isRecord } from "./type-guards-CttAANEx.mjs";
|
|
4
|
-
import "./utils-I4I8azHN.mjs";
|
|
5
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@18.1.17/node_modules/@oh-my-pi/pi-catalog/src/wire/cloudflare-ai-gateway.ts
|
|
6
|
-
/** Provider-native AI Gateway prefix before the upstream route segment. */
|
|
7
|
-
const CLOUDFLARE_AI_GATEWAY_BASE_URL = "https://gateway.ai.cloudflare.com/v1/<account>/<gateway>";
|
|
8
|
-
/** Anthropic Messages passthrough endpoint. */
|
|
9
|
-
const CLOUDFLARE_AI_GATEWAY_ANTHROPIC_BASE_URL = `${CLOUDFLARE_AI_GATEWAY_BASE_URL}/anthropic`;
|
|
10
|
-
/** OpenAI Responses passthrough endpoint. */
|
|
11
|
-
const CLOUDFLARE_AI_GATEWAY_OPENAI_BASE_URL = `${CLOUDFLARE_AI_GATEWAY_BASE_URL}/openai`;
|
|
12
|
-
/** OpenAI-compatible Workers AI endpoint. */
|
|
13
|
-
const CLOUDFLARE_AI_GATEWAY_COMPAT_BASE_URL = `${CLOUDFLARE_AI_GATEWAY_BASE_URL}/compat`;
|
|
14
|
-
/** Parse both structured login credentials and legacy plain gateway tokens. */
|
|
15
|
-
function parseCloudflareAiGatewayCredential(value) {
|
|
16
|
-
const trimmed = value.trim();
|
|
17
|
-
if (!trimmed) return null;
|
|
18
|
-
if (!trimmed.startsWith("{")) return { token: trimmed };
|
|
19
|
-
try {
|
|
20
|
-
const parsed = JSON.parse(trimmed);
|
|
21
|
-
if (!isRecord(parsed)) return null;
|
|
22
|
-
if (typeof parsed.token !== "string" || !parsed.token.trim()) return null;
|
|
23
|
-
if (parsed.accountId !== void 0 && typeof parsed.accountId !== "string") return null;
|
|
24
|
-
if (parsed.gatewayId !== void 0 && typeof parsed.gatewayId !== "string") return null;
|
|
25
|
-
const credential = { token: parsed.token.trim() };
|
|
26
|
-
const accountId = parsed.accountId?.trim();
|
|
27
|
-
const gatewayId = parsed.gatewayId?.trim();
|
|
28
|
-
if (accountId) credential.accountId = accountId;
|
|
29
|
-
if (gatewayId) credential.gatewayId = gatewayId;
|
|
30
|
-
return credential;
|
|
31
|
-
} catch {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/** Serialize the gateway token with the routing identifiers collected during login. */
|
|
36
|
-
function serializeCloudflareAiGatewayCredential(token, accountId, gatewayId) {
|
|
37
|
-
return JSON.stringify({
|
|
38
|
-
token: token.trim(),
|
|
39
|
-
accountId: accountId.trim(),
|
|
40
|
-
gatewayId: gatewayId.trim()
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
export { parseCloudflareAiGatewayCredential as a, CLOUDFLARE_AI_GATEWAY_OPENAI_BASE_URL as i, CLOUDFLARE_AI_GATEWAY_BASE_URL as n, serializeCloudflareAiGatewayCredential as o, CLOUDFLARE_AI_GATEWAY_COMPAT_BASE_URL as r, CLOUDFLARE_AI_GATEWAY_ANTHROPIC_BASE_URL as t };
|