@xiaoso/dsh-tool-plus 0.1.6 → 0.1.7-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.
Files changed (119) hide show
  1. package/THIRD_PARTY_NOTICES.md +9 -3
  2. package/lib/{abort-Cwwm4Err.mjs → abort-Caqff3M6.mjs} +2 -2
  3. package/lib/alibaba-coding-plan-DTupMiAi.mjs +73 -0
  4. package/lib/alibaba-token-plan-CHGyWOfX.mjs +46 -0
  5. package/lib/alibaba-token-plan-Dj3OZhEE.mjs +82 -0
  6. package/lib/{amazon-bedrock-TVMpUTRG.mjs → amazon-bedrock-DbFSYXfJ.mjs} +117 -38
  7. package/lib/{anthropic-BL6LFDQS.mjs → anthropic-CTJ3IQVa.mjs} +675 -166
  8. package/lib/anthropic-CXfWlp-x.mjs +105 -0
  9. package/lib/{aws-credentials-B20dliS7.mjs → anthropic-wire-CKuhDwZ1.mjs} +74 -14
  10. package/lib/{api-key-login-CIDnXeYd.mjs → api-key-validation-CGCJFbFr.mjs} +27 -68
  11. package/lib/{azure-openai-responses-BkhsLmN3.mjs → azure-openai-responses-ChFbWaGj.mjs} +27 -16
  12. package/lib/{browser-render-CmgvSNte.mjs → browser-render-9o0Rknop.mjs} +4 -4
  13. package/lib/bun-shim.mjs +71 -2
  14. package/lib/{bundled-references-ChZSPDFw.mjs → bundled-references-DY3EJxZV.mjs} +6 -5
  15. package/lib/cline-pass-Bwg3esu9.mjs +44 -0
  16. package/lib/cloudflare-ai-gateway-BupNXyKK.mjs +35 -0
  17. package/lib/cloudflare-ai-gateway-EWo0VkP5.mjs +44 -0
  18. package/lib/collapse-DOR8sOGf.mjs +2304 -0
  19. package/lib/coreweave-C82HrLpb.mjs +31 -0
  20. package/lib/coreweave-Ct8cF-da.mjs +14 -0
  21. package/lib/{cursor-B6HcmplF.mjs → cursor-B95LzVWV.mjs} +11 -3
  22. package/lib/{cursor-CRpLpaZ3.mjs → cursor-DJV_dcgB.mjs} +887 -1784
  23. package/lib/{cursor-B8m6SqAH.mjs → cursor-LKGjucn2.mjs} +48 -38
  24. package/lib/cursor-proto-B8Wj8bv9.mjs +10513 -0
  25. package/lib/{deterministic-id-D-yIV_eI.mjs → deterministic-id-CUEIMSqR.mjs} +1 -1
  26. package/lib/devin-BMTdx_hx.mjs +316 -0
  27. package/lib/{devin-DUAfvBsW.mjs → devin-DSp0Rw_E.mjs} +172 -86
  28. package/lib/devin-ExGIghmx.mjs +69 -0
  29. package/lib/devin-proto-Br8fdyNl.mjs +2888 -0
  30. package/lib/{dom-CawWi8fa.mjs → dom-DG3sPESc.mjs} +8 -8
  31. package/lib/effort-BdtQMN-_.mjs +23 -0
  32. package/lib/{error-C-f_Wnw4.mjs → error-CORgGg5a.mjs} +275 -154
  33. package/lib/{event-stream-Dh2guZxS.mjs → event-stream-ulcDenZD.mjs} +20 -4
  34. package/lib/{gemini-headers-DKUShltF.mjs → gemini-headers-Co9cVvex.mjs} +2 -2
  35. package/lib/{github-copilot-suDymKrx.mjs → github-copilot-Dstq1D3s.mjs} +69 -29
  36. package/lib/github-copilot-headers-DOh1gt_w.mjs +312 -0
  37. package/lib/gitlab-duo-DSCMrU0m.mjs +11 -0
  38. package/lib/google-CtsKkOQK.mjs +38 -0
  39. package/lib/google-antigravity-z-5KsEci.mjs +252 -0
  40. package/lib/{google-auth-DYJLM792.mjs → google-auth-ieLBaneO.mjs} +4 -4
  41. package/lib/{google-gemini-cli-8BT513Ul.mjs → google-gemini-cli-C6NE5mWz.mjs} +28 -54
  42. package/lib/{google-gemini-cli-D6cSmfvB.mjs → google-gemini-cli-CAIPSl7e.mjs} +23 -29
  43. package/lib/google-oauth-shared-DhMllAkt.mjs +53 -0
  44. package/lib/{google-shared-CVbHK5vZ.mjs → google-shared-B0aNCYEH.mjs} +140 -44
  45. package/lib/{google-validation-Cgbn3tWJ.mjs → google-validation-BEkNs-Bx.mjs} +1 -1
  46. package/lib/{google-vertex-Bui-ypAe.mjs → google-vertex-Bbd1tYNc.mjs} +8 -8
  47. package/lib/hosts-00rjRzUD.mjs +203 -0
  48. package/lib/id-AL5obQzR.mjs +71 -0
  49. package/lib/{idle-iterator-CYAxUkSD.mjs → idle-iterator-DlUkEfzW.mjs} +3 -3
  50. package/lib/index.mjs +587 -5266
  51. package/lib/kilo-ChJL54wq.mjs +81 -0
  52. package/lib/kimi-C2c_Zq8A.mjs +67 -0
  53. package/lib/{launch-BmgEUycu.mjs → launch-DKDH71En.mjs} +1 -1
  54. package/lib/markit-CmRfm4E2.mjs +9885 -0
  55. package/lib/models-DnXMYGcJ.mjs +381604 -0
  56. package/lib/muse-code-Di1VZmB1.mjs +143 -0
  57. package/lib/{ollama-Df9ce-Cp.mjs → ollama-B8ic3sEp.mjs} +15 -30
  58. package/lib/{openai-codex-CAVI3Me-.mjs → openai-codex-DuJNC99x.mjs} +29 -99
  59. package/lib/{openai-codex-responses-BcnOotRB.mjs → openai-codex-responses-BL29nh9K.mjs} +204 -116
  60. package/lib/{openai-completions-Bq4WT47M.mjs → openai-completions-BK2f2dBv.mjs} +152 -82
  61. package/lib/openai-configuration-update-xMYUjaK_.mjs +150 -0
  62. package/lib/{openai-reasoning-fallback-DXsfiSXO.mjs → openai-reasoning-fallback-BdB3RCbj.mjs} +106 -12
  63. package/lib/{openai-responses-Mq_-PjvE.mjs → openai-responses-CGQPlIIy.mjs} +76 -82
  64. package/lib/{perplexity-XgLF73E7.mjs → perplexity-TBjz3VMB.mjs} +52 -9
  65. package/lib/{pkce-BlQikGPu.mjs → pkce-BYjmugmw.mjs} +1 -1
  66. package/lib/protobuf-aab1UGVn.mjs +717 -0
  67. package/lib/{provider-response-C6vcbQyO.mjs → provider-response-SqKSkkUc.mjs} +1 -1
  68. package/lib/{proxy-D9lm7ONA.mjs → proxy-5nWqRL1f.mjs} +45 -5
  69. package/lib/{readability-Cpm-ocau.mjs → readability-uGhqb4GC.mjs} +2 -2
  70. package/lib/reference-CtvM4zLU.mjs +114 -0
  71. package/lib/{request-debug-HJMoJncL.mjs → request-debug-NQN0BjHH.mjs} +1 -1
  72. package/lib/{sanitize-text-CfcXzw5X.mjs → sanitize-text-BCf5KmCf.mjs} +1 -1
  73. package/lib/{scrapers-Cg5w77td.mjs → scrapers-D8oWspgW.mjs} +12 -12
  74. package/lib/{src-BcD0_rQR.mjs → src-BwW51vA5.mjs} +979 -388
  75. package/lib/{sse-debug-CYdjOC96.mjs → sse-debug-B-tkLCPW.mjs} +1 -1
  76. package/lib/{stream-Bjq8wjfr.mjs → stream-B_7qN-bA.mjs} +3802 -2623
  77. package/lib/stream-markup-healing-DKT1lnkW.mjs +267 -0
  78. package/lib/{strict-tool-validation-imVLUcbI.mjs → strict-tool-validation-CBTz1dAA.mjs} +2 -2
  79. package/lib/taxonomy-DSIM99rS.mjs +15392 -0
  80. package/lib/{stream-markup-healing-DZ6bVDxH.mjs → thinking-CiLa2LFB.mjs} +31 -186
  81. package/lib/{turndown-DN7ByzEI.mjs → turndown-DrX1M4WG.mjs} +4 -4
  82. package/lib/{type-guards-B9VVjRDK.mjs → type-guards-CttAANEx.mjs} +1 -1
  83. package/lib/{types-DX_bvuus.mjs → types-PVueGi9S.mjs} +2 -2
  84. package/lib/{utils-C-dSORPa.mjs → utils-CCfhUQen.mjs} +2364 -2676
  85. package/lib/{utils-Cp2Mxf_U.mjs → utils-CUPhpw9A.mjs} +413 -134
  86. package/lib/{utils-CQHPEQ3W.mjs → utils-DeWqNWV8.mjs} +2 -2
  87. package/lib/{vision-guard-mBmtAHx0.mjs → vision-guard-_XwsL1DF.mjs} +14 -29
  88. package/lib/xai-oauth-CXhnz0gO.mjs +210 -0
  89. package/lib/{xiaomi-7mE345KX.mjs → xiaomi-psoUItal.mjs} +8 -37
  90. package/lib/{zai-CeNpMV3W.mjs → zai-ApJ8HBgT.mjs} +8 -71
  91. package/lib/{zip-BK7UHCwX.mjs → zip-Kd602XNe.mjs} +1 -1
  92. package/package.json +11 -11
  93. package/presets/package.json +1 -1
  94. package/presets/tool-plus-ptc/agent.cordis.yml +1 -1
  95. package/presets/tool-plus-standard/agent.cordis.yml +1 -1
  96. package/lib/agent_pb-Rizyt9Zg.mjs +0 -805
  97. package/lib/anthropic-CDmj476p.mjs +0 -262
  98. package/lib/api_server_pb-CDZgLMta.mjs +0 -252
  99. package/lib/callback-server-CFJK-jvK.mjs +0 -398
  100. package/lib/codex-P1dGpX7G.mjs +0 -54
  101. package/lib/device-code-CuXTWYwY.mjs +0 -51
  102. package/lib/devin-BcQwht1W.mjs +0 -114
  103. package/lib/devin-BvMfGevz.mjs +0 -95
  104. package/lib/github-copilot-B3kQl0g0.mjs +0 -104
  105. package/lib/gitlab-duo-BriUTP8k.mjs +0 -155
  106. package/lib/gitlab-duo-workflow-wK5Ljzmc.mjs +0 -91
  107. package/lib/google-CE5tFDod.mjs +0 -30
  108. package/lib/google-antigravity-C1jgNljz.mjs +0 -198
  109. package/lib/google-oauth-shared-BLVTvokk.mjs +0 -147
  110. package/lib/grammar-D-NqNUxQ.mjs +0 -49
  111. package/lib/identity-HNO1Oe9B.mjs +0 -219
  112. package/lib/kimi-DgcUpPtK.mjs +0 -236
  113. package/lib/markit-DtGoRE6M.mjs +0 -1417
  114. package/lib/minimax-code-Y3h5li9N.mjs +0 -53
  115. package/lib/models-DRA2c_8U.mjs +0 -104660
  116. package/lib/opencode-BsVw9rCD.mjs +0 -38
  117. package/lib/to-binary-B1BEBIPC.mjs +0 -6002
  118. package/lib/wafer-BlhWLweO.mjs +0 -17
  119. package/lib/xai-oauth-5pORHUrg.mjs +0 -446
@@ -1,147 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { c as OAuthError, h as LoginCancelledError } from "./error-C-f_Wnw4.mjs";
4
- import { t as OAuthCallbackFlow } from "./callback-server-CFJK-jvK.mjs";
5
- import { n as formatGoogleValidationRequiredMessage, t as extractGoogleValidationUrl } from "./google-validation-Cgbn3tWJ.mjs";
6
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/google-oauth-shared.ts
7
- /**
8
- * Shared OAuth flow for Google-style providers (Gemini CLI, Antigravity).
9
- *
10
- * Both providers use the same authorization-code flow shape; only the client
11
- * credentials, scopes, endpoint constants, and project-discovery logic differ.
12
- */
13
- /**
14
- * Per-request timeout for the post-callback provisioning phase (token exchange,
15
- * user-info, project discovery/onboarding, LRO polling). These Cloud Code
16
- * Assist calls normally settle in well under this window; a longer stall means
17
- * a hung endpoint that must surface a login error instead of hanging forever.
18
- * The callback server's own 300s deadline covers only the browser-callback wait
19
- * ({@link OAuthCallbackFlow}) and does not gate this phase.
20
- */
21
- const OAUTH_REQUEST_TIMEOUT_MS = 3e4;
22
- /**
23
- * Throw {@link AIError.LoginCancelledError} when the controller signal has
24
- * already aborted. Gates each provisioning round-trip, which the callback-wait
25
- * cancellation checks in {@link OAuthCallbackFlow} do not reach.
26
- */
27
- function throwIfLoginCancelled(signal) {
28
- if (signal?.aborted) throw new LoginCancelledError(`OAuth login cancelled: ${String(signal.reason)}`);
29
- }
30
- /**
31
- * `fetch` for the provisioning phase: composes the controller signal with a
32
- * per-request timeout so a stalled endpoint aborts instead of hanging login,
33
- * and user cancellation aborts the in-flight request. Cancellation surfaces as
34
- * {@link AIError.LoginCancelledError}; a timeout surfaces as an
35
- * {@link AIError.OAuthError} with `kind: "timeout"`.
36
- */
37
- async function oauthFetch(url, init, { provider, signal, timeoutMs = OAUTH_REQUEST_TIMEOUT_MS }) {
38
- const timeoutSignal = AbortSignal.timeout(timeoutMs);
39
- const requestSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
40
- try {
41
- return await fetch(url, {
42
- ...init,
43
- signal: requestSignal
44
- });
45
- } catch (err) {
46
- if (signal?.aborted) throw new LoginCancelledError(`OAuth login cancelled: ${String(signal.reason)}`);
47
- if (timeoutSignal.aborted) throw new OAuthError(`Timed out after ${timeoutMs}ms waiting for ${url}`, {
48
- kind: "timeout",
49
- provider
50
- });
51
- throw err;
52
- }
53
- }
54
- async function getUserEmail(accessToken, provider, signal) {
55
- try {
56
- const response = await oauthFetch("https://www.googleapis.com/oauth2/v1/userinfo?alt=json", { headers: { Authorization: `Bearer ${accessToken}` } }, {
57
- provider,
58
- signal
59
- });
60
- if (response.ok) return (await response.json()).email;
61
- } catch {}
62
- }
63
- var GoogleOAuthFlow = class extends OAuthCallbackFlow {
64
- config;
65
- constructor(ctrl, config) {
66
- super(ctrl, {
67
- preferredPort: config.callbackPort,
68
- callbackPath: config.callbackPath,
69
- callbackHostname: "127.0.0.1"
70
- });
71
- this.config = config;
72
- }
73
- async generateAuthUrl(state, redirectUri) {
74
- const authParams = new URLSearchParams({
75
- client_id: this.config.clientId,
76
- response_type: "code",
77
- redirect_uri: redirectUri,
78
- scope: this.config.scopes.join(" "),
79
- state,
80
- access_type: "offline",
81
- prompt: "consent"
82
- });
83
- return {
84
- url: `${this.config.authUrl}?${authParams.toString()}`,
85
- instructions: "Complete the sign-in in your browser."
86
- };
87
- }
88
- async exchangeToken(code, _state, redirectUri) {
89
- const { provider } = this.config;
90
- const signal = this.ctrl.signal;
91
- throwIfLoginCancelled(signal);
92
- this.ctrl.onProgress?.("Exchanging authorization code for tokens...");
93
- const tokenResponse = await oauthFetch(this.config.tokenUrl, {
94
- method: "POST",
95
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
96
- body: new URLSearchParams({
97
- client_id: this.config.clientId,
98
- client_secret: this.config.clientSecret,
99
- code,
100
- grant_type: "authorization_code",
101
- redirect_uri: redirectUri
102
- })
103
- }, {
104
- provider,
105
- signal
106
- });
107
- if (!tokenResponse.ok) {
108
- const error = await tokenResponse.text();
109
- throw new OAuthError(`Token exchange failed: ${error}`, {
110
- kind: "token-exchange",
111
- provider
112
- });
113
- }
114
- const tokenData = await tokenResponse.json();
115
- if (!tokenData.refresh_token) throw new OAuthError("No refresh token received. Please try again.", {
116
- kind: "validation",
117
- provider
118
- });
119
- throwIfLoginCancelled(signal);
120
- this.ctrl.onProgress?.("Getting user info...");
121
- const email = await getUserEmail(tokenData.access_token, provider, signal);
122
- throwIfLoginCancelled(signal);
123
- let projectId;
124
- try {
125
- projectId = await this.config.discoverProject(tokenData.access_token, this.ctrl.onProgress, signal);
126
- } catch (err) {
127
- const validationUrl = extractGoogleValidationUrl(err instanceof Error ? err.message : String(err));
128
- if (!validationUrl) throw err;
129
- throw new OAuthError(formatGoogleValidationRequiredMessage(validationUrl, "sign in again", email), {
130
- kind: "validation",
131
- provider
132
- });
133
- }
134
- return {
135
- refresh: tokenData.refresh_token,
136
- access: tokenData.access_token,
137
- expires: Date.now() + tokenData.expires_in * 1e3 - 3e5,
138
- projectId,
139
- email
140
- };
141
- }
142
- };
143
- async function runGoogleOAuthLogin(ctrl, config) {
144
- return new GoogleOAuthFlow(ctrl, config).login();
145
- }
146
- //#endregion
147
- export { runGoogleOAuthLogin as n, throwIfLoginCancelled as r, oauthFetch as t };
@@ -1,49 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/grammar.ts
4
- function compactGrammarDefinition(syntax, definition) {
5
- if (syntax !== "lark") return definition;
6
- return compactLarkGrammarDefinition(definition);
7
- }
8
- function compactLarkGrammarDefinition(definition) {
9
- const lines = [];
10
- for (const line of definition.split(/\r?\n/)) {
11
- const uncommented = stripLarkLineComment(line).trimEnd();
12
- if (uncommented.trim()) lines.push(uncommented);
13
- }
14
- return lines.join("\n");
15
- }
16
- function stripLarkLineComment(line) {
17
- let inString;
18
- let inRegex = false;
19
- let escaped = false;
20
- for (let i = 0; i < line.length; i++) {
21
- const char = line[i];
22
- const next = line[i + 1];
23
- if (escaped) {
24
- escaped = false;
25
- continue;
26
- }
27
- if (char === "\\") {
28
- escaped = true;
29
- continue;
30
- }
31
- if (inString) {
32
- if (char === inString) inString = void 0;
33
- continue;
34
- }
35
- if (inRegex) {
36
- if (char === "/") inRegex = false;
37
- continue;
38
- }
39
- if (char === "/" && next === "/") return line.slice(0, i);
40
- if (char === "\"" || char === "'") {
41
- inString = char;
42
- continue;
43
- }
44
- if (char === "/") inRegex = true;
45
- }
46
- return line;
47
- }
48
- //#endregion
49
- export { compactGrammarDefinition as t };
@@ -1,219 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { i as getBundledProviders, r as getBundledModels, w as modelFamilyToken } from "./models-DRA2c_8U.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 };
@@ -1,236 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { r as __exportAll } from "./fs-promises-shim-Bx0fpxuk.mjs";
4
- import { H as getAgentDir, P as $env } from "./src-BcD0_rQR.mjs";
5
- import { c as OAuthError, h as LoginCancelledError } from "./error-C-f_Wnw4.mjs";
6
- import "./utils-Cp2Mxf_U.mjs";
7
- import { n as isRecord } from "./type-guards-B9VVjRDK.mjs";
8
- import * as fs from "node:fs";
9
- import * as path from "node:path";
10
- import * as os from "node:os";
11
- import { scheduler } from "node:timers/promises";
12
- import * as crypto from "node:crypto";
13
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/package.json
14
- var version = "17.3.5";
15
- //#endregion
16
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/kimi.ts
17
- /**
18
- * Kimi Code OAuth flow (device authorization grant)
19
- */
20
- var kimi_exports = /* @__PURE__ */ __exportAll({
21
- getKimiCommonHeaders: () => getKimiCommonHeaders,
22
- loginKimi: () => loginKimi,
23
- refreshKimiToken: () => refreshKimiToken
24
- });
25
- const CLIENT_ID = "17e5f671-d194-4dfb-9706-5516cb48c098";
26
- const DEFAULT_OAUTH_HOST = "https://auth.kimi.com";
27
- const DEVICE_ID_FILENAME = "kimi-device-id";
28
- const DEFAULT_POLL_INTERVAL_MS = 5e3;
29
- const DEFAULT_DEVICE_FLOW_TTL_MS = 9e5;
30
- const OAUTH_EXPIRY_SKEW_MS = 3e5;
31
- function resolveOAuthHost() {
32
- return $env.KIMI_CODE_OAUTH_HOST || $env.KIMI_OAUTH_HOST || DEFAULT_OAUTH_HOST;
33
- }
34
- function formatDeviceModel(system, release, arch) {
35
- return [
36
- system,
37
- release,
38
- arch
39
- ].filter(Boolean).join(" ").trim();
40
- }
41
- function getDeviceModel() {
42
- const platform = os.platform();
43
- const release = os.release();
44
- const arch = os.arch();
45
- if (platform === "darwin") return formatDeviceModel("macOS", release, arch);
46
- if (platform === "win32") return formatDeviceModel("Windows", release, arch);
47
- return formatDeviceModel(platform === "linux" ? "Linux" : platform, release, arch);
48
- }
49
- let getDeviceId = () => {
50
- const deviceIdPath = path.join(getAgentDir(), DEVICE_ID_FILENAME);
51
- try {
52
- const existing = fs.readFileSync(deviceIdPath, "utf-8").trim();
53
- if (existing) {
54
- getDeviceId = () => existing;
55
- return existing;
56
- }
57
- } catch {}
58
- const deviceId = crypto.randomUUID().replace(/-/g, "");
59
- try {
60
- fs.mkdirSync(path.dirname(deviceIdPath), { recursive: true });
61
- fs.writeFileSync(deviceIdPath, `${deviceId}\n`, { mode: 384 });
62
- } catch {}
63
- getDeviceId = () => deviceId;
64
- return deviceId;
65
- };
66
- function sanitizeHeaderValue(value, fallback = "") {
67
- return value.replace(/[^\x20-\x7E]/g, "").trim() || fallback;
68
- }
69
- let getKimiCommonHeaders = () => {
70
- const headers = Object.freeze({
71
- "User-Agent": `KimiCLI/${version}`,
72
- "X-Msh-Platform": "kimi_cli",
73
- "X-Msh-Version": version,
74
- "X-Msh-Device-Name": sanitizeHeaderValue(os.hostname(), "unknown"),
75
- "X-Msh-Device-Model": sanitizeHeaderValue(getDeviceModel(), "unknown"),
76
- "X-Msh-Os-Version": sanitizeHeaderValue(os.version(), "unknown"),
77
- "X-Msh-Device-Id": sanitizeHeaderValue(getDeviceId(), "unknown")
78
- });
79
- getKimiCommonHeaders = () => headers;
80
- return headers;
81
- };
82
- async function requestDeviceAuthorization() {
83
- const response = await fetch(`${resolveOAuthHost()}/api/oauth/device_authorization`, {
84
- method: "POST",
85
- headers: {
86
- "Content-Type": "application/x-www-form-urlencoded",
87
- ...getKimiCommonHeaders()
88
- },
89
- body: new URLSearchParams({ client_id: CLIENT_ID })
90
- });
91
- if (!response.ok) {
92
- const text = await response.text();
93
- throw new OAuthError(`Kimi device authorization failed: ${response.status} ${text}`, {
94
- kind: "device-auth",
95
- provider: "kimi",
96
- status: response.status
97
- });
98
- }
99
- const payload = await response.json();
100
- const userCode = payload.user_code;
101
- const deviceCode = payload.device_code;
102
- const verificationUri = payload.verification_uri;
103
- const verificationUriComplete = payload.verification_uri_complete;
104
- if (!userCode || !deviceCode || !verificationUri) throw new OAuthError("Kimi device authorization response missing required fields", {
105
- kind: "validation",
106
- provider: "kimi"
107
- });
108
- const expiresInMs = typeof payload.expires_in === "number" ? payload.expires_in * 1e3 : DEFAULT_DEVICE_FLOW_TTL_MS;
109
- const intervalMs = typeof payload.interval === "number" && payload.interval > 0 ? payload.interval * 1e3 : DEFAULT_POLL_INTERVAL_MS;
110
- return {
111
- userCode,
112
- deviceCode,
113
- verificationUri,
114
- verificationUriComplete: verificationUriComplete || verificationUri,
115
- expiresInMs,
116
- intervalMs
117
- };
118
- }
119
- function parseTokenPayload(payload, refreshTokenFallback) {
120
- if (!payload.access_token || typeof payload.expires_in !== "number") throw new OAuthError("Kimi token response missing required fields", {
121
- kind: "validation",
122
- provider: "kimi"
123
- });
124
- const refresh = payload.refresh_token ?? refreshTokenFallback;
125
- if (!refresh) throw new OAuthError("Kimi token response missing refresh token", {
126
- kind: "validation",
127
- provider: "kimi"
128
- });
129
- let accountId;
130
- const tokenParts = payload.access_token.split(".");
131
- const jwtPayloadPart = tokenParts.length === 3 ? tokenParts[1] : void 0;
132
- if (jwtPayloadPart) try {
133
- const jwtPayload = JSON.parse(new TextDecoder("utf-8").decode(Uint8Array.fromBase64(jwtPayloadPart, { alphabet: "base64url" })));
134
- if (isRecord(jwtPayload)) {
135
- const userId = typeof jwtPayload.user_id === "string" ? jwtPayload.user_id.trim() : "";
136
- const subject = typeof jwtPayload.sub === "string" ? jwtPayload.sub.trim() : "";
137
- accountId = userId || subject || void 0;
138
- }
139
- } catch {}
140
- return {
141
- access: payload.access_token,
142
- refresh,
143
- expires: Date.now() + payload.expires_in * 1e3 - OAUTH_EXPIRY_SKEW_MS,
144
- accountId
145
- };
146
- }
147
- async function pollForToken(deviceCode, intervalMs, expiresInMs, signal) {
148
- const deadline = Date.now() + expiresInMs;
149
- let waitMs = Math.max(1e3, intervalMs);
150
- while (Date.now() < deadline) {
151
- if (signal?.aborted) throw new LoginCancelledError();
152
- const response = await fetch(`${resolveOAuthHost()}/api/oauth/token`, {
153
- method: "POST",
154
- headers: {
155
- "Content-Type": "application/x-www-form-urlencoded",
156
- ...getKimiCommonHeaders()
157
- },
158
- body: new URLSearchParams({
159
- client_id: CLIENT_ID,
160
- device_code: deviceCode,
161
- grant_type: "urn:ietf:params:oauth:grant-type:device_code"
162
- })
163
- });
164
- const payload = await response.json();
165
- if (response.ok && payload.access_token) return parseTokenPayload(payload);
166
- const error = payload.error;
167
- if (error === "authorization_pending") {
168
- await scheduler.wait(waitMs, { signal });
169
- continue;
170
- }
171
- if (error === "slow_down") {
172
- waitMs += 5e3;
173
- const retryAfter = typeof payload.interval === "number" ? payload.interval * 1e3 : void 0;
174
- if (retryAfter && retryAfter > waitMs) waitMs = retryAfter;
175
- await scheduler.wait(waitMs, { signal });
176
- continue;
177
- }
178
- if (error === "expired_token") throw new OAuthError("Kimi device authorization expired", {
179
- kind: "validation",
180
- provider: "kimi"
181
- });
182
- if (error === "access_denied") throw new OAuthError("Kimi device authorization denied", {
183
- kind: "validation",
184
- provider: "kimi"
185
- });
186
- const description = payload.error_description ? `: ${payload.error_description}` : "";
187
- throw new OAuthError(`Kimi device flow failed: ${error ?? response.status}${description}`, {
188
- kind: "polling",
189
- provider: "kimi"
190
- });
191
- }
192
- throw new OAuthError("Kimi device flow timed out", {
193
- kind: "timeout",
194
- provider: "kimi"
195
- });
196
- }
197
- /**
198
- * Login with Kimi Code OAuth (device code flow).
199
- */
200
- async function loginKimi(options) {
201
- const device = await requestDeviceAuthorization();
202
- options.onAuth?.({
203
- url: device.verificationUriComplete,
204
- instructions: `Enter code: ${device.userCode}`
205
- });
206
- return pollForToken(device.deviceCode, device.intervalMs, device.expiresInMs, options.signal);
207
- }
208
- /**
209
- * Refresh Kimi OAuth token.
210
- */
211
- async function refreshKimiToken(refreshToken) {
212
- const response = await fetch(`${resolveOAuthHost()}/api/oauth/token`, {
213
- method: "POST",
214
- headers: {
215
- "Content-Type": "application/x-www-form-urlencoded",
216
- ...getKimiCommonHeaders()
217
- },
218
- body: new URLSearchParams({
219
- grant_type: "refresh_token",
220
- refresh_token: refreshToken,
221
- client_id: CLIENT_ID
222
- })
223
- });
224
- if (!response.ok) {
225
- const payload = await response.json().catch(() => void 0);
226
- const description = payload?.error_description ? `: ${payload.error_description}` : "";
227
- throw new OAuthError(`Kimi token refresh failed: ${response.status}${description}`, {
228
- kind: "token-refresh",
229
- provider: "kimi",
230
- status: response.status
231
- });
232
- }
233
- return parseTokenPayload(await response.json(), refreshToken);
234
- }
235
- //#endregion
236
- export { kimi_exports as n, getKimiCommonHeaders as t };