@xiaoso/dsh-tool-plus 0.1.5 → 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 (120) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +9 -3
  3. package/lib/{abort-Cwwm4Err.mjs → abort-Caqff3M6.mjs} +2 -2
  4. package/lib/alibaba-coding-plan-DTupMiAi.mjs +73 -0
  5. package/lib/alibaba-token-plan-CHGyWOfX.mjs +46 -0
  6. package/lib/alibaba-token-plan-Dj3OZhEE.mjs +82 -0
  7. package/lib/{amazon-bedrock-TVMpUTRG.mjs → amazon-bedrock-DbFSYXfJ.mjs} +117 -38
  8. package/lib/{anthropic-BL6LFDQS.mjs → anthropic-CTJ3IQVa.mjs} +675 -166
  9. package/lib/anthropic-CXfWlp-x.mjs +105 -0
  10. package/lib/{aws-credentials-B20dliS7.mjs → anthropic-wire-CKuhDwZ1.mjs} +74 -14
  11. package/lib/{api-key-login-CIDnXeYd.mjs → api-key-validation-CGCJFbFr.mjs} +27 -68
  12. package/lib/{azure-openai-responses-BkhsLmN3.mjs → azure-openai-responses-ChFbWaGj.mjs} +27 -16
  13. package/lib/{browser-render-CmgvSNte.mjs → browser-render-9o0Rknop.mjs} +4 -4
  14. package/lib/bun-shim.mjs +71 -2
  15. package/lib/{bundled-references-ChZSPDFw.mjs → bundled-references-DY3EJxZV.mjs} +6 -5
  16. package/lib/cline-pass-Bwg3esu9.mjs +44 -0
  17. package/lib/cloudflare-ai-gateway-BupNXyKK.mjs +35 -0
  18. package/lib/cloudflare-ai-gateway-EWo0VkP5.mjs +44 -0
  19. package/lib/collapse-DOR8sOGf.mjs +2304 -0
  20. package/lib/coreweave-C82HrLpb.mjs +31 -0
  21. package/lib/coreweave-Ct8cF-da.mjs +14 -0
  22. package/lib/{cursor-B6HcmplF.mjs → cursor-B95LzVWV.mjs} +11 -3
  23. package/lib/{cursor-CRpLpaZ3.mjs → cursor-DJV_dcgB.mjs} +887 -1784
  24. package/lib/{cursor-B8m6SqAH.mjs → cursor-LKGjucn2.mjs} +48 -38
  25. package/lib/cursor-proto-B8Wj8bv9.mjs +10513 -0
  26. package/lib/{deterministic-id-D-yIV_eI.mjs → deterministic-id-CUEIMSqR.mjs} +1 -1
  27. package/lib/devin-BMTdx_hx.mjs +316 -0
  28. package/lib/{devin-DUAfvBsW.mjs → devin-DSp0Rw_E.mjs} +172 -86
  29. package/lib/devin-ExGIghmx.mjs +69 -0
  30. package/lib/devin-proto-Br8fdyNl.mjs +2888 -0
  31. package/lib/{dom-CawWi8fa.mjs → dom-DG3sPESc.mjs} +8 -8
  32. package/lib/effort-BdtQMN-_.mjs +23 -0
  33. package/lib/{error-C-f_Wnw4.mjs → error-CORgGg5a.mjs} +275 -154
  34. package/lib/{event-stream-Dh2guZxS.mjs → event-stream-ulcDenZD.mjs} +20 -4
  35. package/lib/{gemini-headers-DKUShltF.mjs → gemini-headers-Co9cVvex.mjs} +2 -2
  36. package/lib/{github-copilot-suDymKrx.mjs → github-copilot-Dstq1D3s.mjs} +69 -29
  37. package/lib/github-copilot-headers-DOh1gt_w.mjs +312 -0
  38. package/lib/gitlab-duo-DSCMrU0m.mjs +11 -0
  39. package/lib/google-CtsKkOQK.mjs +38 -0
  40. package/lib/google-antigravity-z-5KsEci.mjs +252 -0
  41. package/lib/{google-auth-DYJLM792.mjs → google-auth-ieLBaneO.mjs} +4 -4
  42. package/lib/{google-gemini-cli-8BT513Ul.mjs → google-gemini-cli-C6NE5mWz.mjs} +28 -54
  43. package/lib/{google-gemini-cli-D6cSmfvB.mjs → google-gemini-cli-CAIPSl7e.mjs} +23 -29
  44. package/lib/google-oauth-shared-DhMllAkt.mjs +53 -0
  45. package/lib/{google-shared-CVbHK5vZ.mjs → google-shared-B0aNCYEH.mjs} +140 -44
  46. package/lib/{google-validation-Cgbn3tWJ.mjs → google-validation-BEkNs-Bx.mjs} +1 -1
  47. package/lib/{google-vertex-Bui-ypAe.mjs → google-vertex-Bbd1tYNc.mjs} +8 -8
  48. package/lib/hosts-00rjRzUD.mjs +203 -0
  49. package/lib/id-AL5obQzR.mjs +71 -0
  50. package/lib/{idle-iterator-CYAxUkSD.mjs → idle-iterator-DlUkEfzW.mjs} +3 -3
  51. package/lib/index.mjs +587 -5266
  52. package/lib/kilo-ChJL54wq.mjs +81 -0
  53. package/lib/kimi-C2c_Zq8A.mjs +67 -0
  54. package/lib/{launch-BmgEUycu.mjs → launch-DKDH71En.mjs} +1 -1
  55. package/lib/markit-CmRfm4E2.mjs +9885 -0
  56. package/lib/models-DnXMYGcJ.mjs +381604 -0
  57. package/lib/muse-code-Di1VZmB1.mjs +143 -0
  58. package/lib/{ollama-Df9ce-Cp.mjs → ollama-B8ic3sEp.mjs} +15 -30
  59. package/lib/{openai-codex-CAVI3Me-.mjs → openai-codex-DuJNC99x.mjs} +29 -99
  60. package/lib/{openai-codex-responses-BcnOotRB.mjs → openai-codex-responses-BL29nh9K.mjs} +204 -116
  61. package/lib/{openai-completions-Bq4WT47M.mjs → openai-completions-BK2f2dBv.mjs} +152 -82
  62. package/lib/openai-configuration-update-xMYUjaK_.mjs +150 -0
  63. package/lib/{openai-reasoning-fallback-DXsfiSXO.mjs → openai-reasoning-fallback-BdB3RCbj.mjs} +106 -12
  64. package/lib/{openai-responses-Mq_-PjvE.mjs → openai-responses-CGQPlIIy.mjs} +76 -82
  65. package/lib/{perplexity-XgLF73E7.mjs → perplexity-TBjz3VMB.mjs} +52 -9
  66. package/lib/{pkce-BlQikGPu.mjs → pkce-BYjmugmw.mjs} +1 -1
  67. package/lib/protobuf-aab1UGVn.mjs +717 -0
  68. package/lib/{provider-response-C6vcbQyO.mjs → provider-response-SqKSkkUc.mjs} +1 -1
  69. package/lib/{proxy-D9lm7ONA.mjs → proxy-5nWqRL1f.mjs} +45 -5
  70. package/lib/{readability-Cpm-ocau.mjs → readability-uGhqb4GC.mjs} +2 -2
  71. package/lib/reference-CtvM4zLU.mjs +114 -0
  72. package/lib/{request-debug-HJMoJncL.mjs → request-debug-NQN0BjHH.mjs} +1 -1
  73. package/lib/{sanitize-text-CfcXzw5X.mjs → sanitize-text-BCf5KmCf.mjs} +1 -1
  74. package/lib/{scrapers-CE_qK1yk.mjs → scrapers-D8oWspgW.mjs} +12 -12
  75. package/lib/{src-BcD0_rQR.mjs → src-BwW51vA5.mjs} +979 -388
  76. package/lib/{sse-debug-CYdjOC96.mjs → sse-debug-B-tkLCPW.mjs} +1 -1
  77. package/lib/{stream-Bjq8wjfr.mjs → stream-B_7qN-bA.mjs} +3802 -2623
  78. package/lib/stream-markup-healing-DKT1lnkW.mjs +267 -0
  79. package/lib/{strict-tool-validation-imVLUcbI.mjs → strict-tool-validation-CBTz1dAA.mjs} +2 -2
  80. package/lib/taxonomy-DSIM99rS.mjs +15392 -0
  81. package/lib/{stream-markup-healing-DZ6bVDxH.mjs → thinking-CiLa2LFB.mjs} +31 -186
  82. package/lib/{turndown-DN7ByzEI.mjs → turndown-DrX1M4WG.mjs} +4 -4
  83. package/lib/{type-guards-B9VVjRDK.mjs → type-guards-CttAANEx.mjs} +1 -1
  84. package/lib/{types-DX_bvuus.mjs → types-PVueGi9S.mjs} +2 -2
  85. package/lib/{utils-APrc-TBB.mjs → utils-CCfhUQen.mjs} +2364 -2676
  86. package/lib/{utils-Cp2Mxf_U.mjs → utils-CUPhpw9A.mjs} +413 -134
  87. package/lib/{utils-CQHPEQ3W.mjs → utils-DeWqNWV8.mjs} +2 -2
  88. package/lib/{vision-guard-mBmtAHx0.mjs → vision-guard-_XwsL1DF.mjs} +14 -29
  89. package/lib/xai-oauth-CXhnz0gO.mjs +210 -0
  90. package/lib/{xiaomi-7mE345KX.mjs → xiaomi-psoUItal.mjs} +8 -37
  91. package/lib/{zai-CeNpMV3W.mjs → zai-ApJ8HBgT.mjs} +8 -71
  92. package/lib/{zip-BK7UHCwX.mjs → zip-Kd602XNe.mjs} +1 -1
  93. package/package.json +43 -41
  94. package/presets/package.json +1 -1
  95. package/presets/tool-plus-ptc/agent.cordis.yml +13 -4
  96. package/presets/tool-plus-standard/agent.cordis.yml +11 -3
  97. package/lib/agent_pb-Rizyt9Zg.mjs +0 -805
  98. package/lib/anthropic-CDmj476p.mjs +0 -262
  99. package/lib/api_server_pb-CDZgLMta.mjs +0 -252
  100. package/lib/callback-server-CFJK-jvK.mjs +0 -398
  101. package/lib/codex-P1dGpX7G.mjs +0 -54
  102. package/lib/device-code-CuXTWYwY.mjs +0 -51
  103. package/lib/devin-BcQwht1W.mjs +0 -114
  104. package/lib/devin-BvMfGevz.mjs +0 -95
  105. package/lib/github-copilot-B3kQl0g0.mjs +0 -104
  106. package/lib/gitlab-duo-BriUTP8k.mjs +0 -155
  107. package/lib/gitlab-duo-workflow-wK5Ljzmc.mjs +0 -91
  108. package/lib/google-CE5tFDod.mjs +0 -30
  109. package/lib/google-antigravity-C1jgNljz.mjs +0 -198
  110. package/lib/google-oauth-shared-BLVTvokk.mjs +0 -147
  111. package/lib/grammar-D-NqNUxQ.mjs +0 -49
  112. package/lib/identity-HNO1Oe9B.mjs +0 -219
  113. package/lib/kimi-DgcUpPtK.mjs +0 -236
  114. package/lib/markit-DtGoRE6M.mjs +0 -1417
  115. package/lib/minimax-code-Y3h5li9N.mjs +0 -53
  116. package/lib/models-DRA2c_8U.mjs +0 -104660
  117. package/lib/opencode-BsVw9rCD.mjs +0 -38
  118. package/lib/to-binary-B1BEBIPC.mjs +0 -6002
  119. package/lib/wafer-BlhWLweO.mjs +0 -17
  120. package/lib/xai-oauth-5pORHUrg.mjs +0 -446
@@ -1,95 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { c as OAuthError } from "./error-C-f_Wnw4.mjs";
4
- import { t as OAuthCallbackFlow } from "./callback-server-CFJK-jvK.mjs";
5
- import { t as generatePKCE } from "./pkce-BlQikGPu.mjs";
6
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/devin.ts
7
- const DEVIN_WEBAPP_URL = "https://app.devin.ai";
8
- const DEVIN_API_URL = "https://api.devin.ai";
9
- const CALLBACK_PORT = 59653;
10
- const CALLBACK_PATH = "/callback";
11
- const TOKEN_PATH = "/auth/cli/token";
12
- const FALLBACK_EXPIRES_MS = 31536e6;
13
- async function loginDevin(ctrl) {
14
- return new DevinOAuthFlow(ctrl).login();
15
- }
16
- var DevinOAuthFlow = class extends OAuthCallbackFlow {
17
- #pkce;
18
- constructor(ctrl) {
19
- super(ctrl, {
20
- preferredPort: CALLBACK_PORT,
21
- callbackPath: CALLBACK_PATH,
22
- callbackHostname: "127.0.0.1"
23
- });
24
- }
25
- generateState() {
26
- return crypto.randomUUID();
27
- }
28
- async generateAuthUrl(state, redirectUri) {
29
- this.#pkce = await generatePKCE();
30
- const params = new URLSearchParams({
31
- redirect_uri: redirectUri,
32
- state,
33
- prompt: "select_account",
34
- code_challenge: this.#pkce.challenge,
35
- code_challenge_method: "S256"
36
- });
37
- return {
38
- url: `${DEVIN_WEBAPP_URL}/auth/cli/continue?${params.toString()}`,
39
- instructions: "Sign in to Devin in your browser."
40
- };
41
- }
42
- async exchangeToken(code) {
43
- if (!this.#pkce) throw new OAuthError("Devin PKCE verifier was not initialized", {
44
- kind: "configuration",
45
- provider: "devin"
46
- });
47
- const token = await exchangeDevinCliToken(code, this.#pkce.verifier, this.ctrl.fetch);
48
- return {
49
- access: token,
50
- refresh: token,
51
- expires: getTokenExpiry(token),
52
- apiEndpoint: DEVIN_API_URL,
53
- enterpriseUrl: DEVIN_WEBAPP_URL
54
- };
55
- }
56
- };
57
- async function exchangeDevinCliToken(authorizationCode, codeVerifier, fetchImpl = fetch) {
58
- const response = await fetchImpl(`${DEVIN_API_URL}${TOKEN_PATH}`, {
59
- method: "POST",
60
- headers: {
61
- Accept: "application/json",
62
- "Content-Type": "application/json"
63
- },
64
- body: JSON.stringify({
65
- code: authorizationCode,
66
- code_verifier: codeVerifier
67
- })
68
- });
69
- if (!response.ok) {
70
- const error = await response.text();
71
- throw new OAuthError(`Devin CLI token exchange failed: ${response.status} ${error}`.trim(), {
72
- kind: "token-exchange",
73
- provider: "devin",
74
- status: response.status
75
- });
76
- }
77
- const data = await response.json();
78
- if (typeof data.token !== "string" || data.token.length === 0) throw new OAuthError("Devin CLI token exchange returned an empty token", {
79
- kind: "validation",
80
- provider: "devin"
81
- });
82
- return data.token;
83
- }
84
- function getTokenExpiry(token) {
85
- try {
86
- const [, payload] = token.split(".");
87
- if (payload) {
88
- const decoded = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
89
- if (typeof decoded.exp === "number" && Number.isFinite(decoded.exp)) return decoded.exp * 1e3 - 3e5;
90
- }
91
- } catch {}
92
- return Date.now() + FALLBACK_EXPIRES_MS;
93
- }
94
- //#endregion
95
- export { loginDevin };
@@ -1,104 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { n as isRecord } from "./type-guards-B9VVjRDK.mjs";
4
- import "./utils-CQHPEQ3W.mjs";
5
- const OPENCODE_HEADERS = { "User-Agent": "opencode/1.3.15" };
6
- /**
7
- * Copilot API version sent on `api.githubcopilot.com` requests (`/models`,
8
- * chat endpoints). Newer versions unlock tiered context metadata: `/models`
9
- * reports the full long-context window in `capabilities.limits` plus per-tier
10
- * boundaries/prices under `billing.token_prices.{default,long_context}`.
11
- * Without it the endpoint serves default-tier limits only (e.g. 264k instead
12
- * of 1M for Claude Opus). Never send this to `api.github.com` REST endpoints —
13
- * they validate `X-GitHub-Api-Version` against the REST version vocabulary.
14
- */
15
- const COPILOT_API_VERSION = "2026-06-01";
16
- /** Headers for `api.githubcopilot.com` (capi) requests: discovery, chat, policy. */
17
- const COPILOT_API_HEADERS = {
18
- ...OPENCODE_HEADERS,
19
- "X-GitHub-Api-Version": COPILOT_API_VERSION
20
- };
21
- const PUBLIC_GITHUB_HOSTS = /* @__PURE__ */ new Set([
22
- "api.github.com",
23
- "github.com",
24
- "www.github.com"
25
- ]);
26
- function isPublicGitHubHost(host) {
27
- return PUBLIC_GITHUB_HOSTS.has(host.trim().toLowerCase());
28
- }
29
- /** Canonical personal-Copilot API host. */
30
- const PERSONAL_GITHUB_COPILOT_BASE_URL = "https://api.githubcopilot.com";
31
- /** `true` when the resolved base URL is the canonical personal-Copilot host. */
32
- function isPersonalGitHubCopilotBaseUrl(baseUrl) {
33
- return baseUrl === PERSONAL_GITHUB_COPILOT_BASE_URL;
34
- }
35
- function normalizeGitHubCopilotEnterpriseDomain(input) {
36
- const trimmed = input?.trim();
37
- if (!trimmed) return void 0;
38
- const normalized = normalizeDomain(trimmed) ?? trimmed.toLowerCase();
39
- if (!normalized || isPublicGitHubHost(normalized)) return void 0;
40
- return normalized;
41
- }
42
- function normalizeGitHubCopilotApiEndpoint(input) {
43
- const trimmed = input?.trim();
44
- if (!trimmed?.startsWith("https://")) return void 0;
45
- try {
46
- const url = new URL(trimmed);
47
- if (url.protocol !== "https:" || !url.hostname) return void 0;
48
- return trimmed.replace(/\/+$/, "");
49
- } catch {
50
- return;
51
- }
52
- }
53
- /**
54
- * Resolve the plan-specific Copilot API endpoint advertised for a GitHub token.
55
- * Login and raw environment-token discovery share this best-effort probe. Pass
56
- * a `signal` to bound it against the same discovery deadline as `/models`; a
57
- * stalled probe otherwise blocks discovery indefinitely.
58
- */
59
- async function discoverGitHubCopilotApiEndpoint(token, fetchImpl, signal) {
60
- try {
61
- const response = await fetchImpl("https://api.github.com/copilot_internal/user", {
62
- headers: {
63
- Accept: "application/json",
64
- Authorization: `token ${token}`,
65
- ...OPENCODE_HEADERS
66
- },
67
- signal
68
- });
69
- if (!response.ok) return void 0;
70
- const data = await response.json();
71
- if (!isRecord(data) || !isRecord(data.endpoints)) return void 0;
72
- const endpoint = data.endpoints.api;
73
- return typeof endpoint === "string" ? normalizeGitHubCopilotApiEndpoint(endpoint) : void 0;
74
- } catch {
75
- return;
76
- }
77
- }
78
- function parseGitHubCopilotApiKey(apiKeyRaw) {
79
- try {
80
- const parsed = JSON.parse(apiKeyRaw);
81
- if (typeof parsed.token === "string") return {
82
- accessToken: parsed.token,
83
- enterpriseUrl: typeof parsed.enterpriseUrl === "string" ? normalizeGitHubCopilotEnterpriseDomain(parsed.enterpriseUrl) : void 0,
84
- apiEndpoint: typeof parsed.apiEndpoint === "string" ? normalizeGitHubCopilotApiEndpoint(parsed.apiEndpoint) : void 0
85
- };
86
- } catch {}
87
- return { accessToken: apiKeyRaw };
88
- }
89
- function normalizeDomain(input) {
90
- const trimmed = input.trim();
91
- if (!trimmed) return null;
92
- try {
93
- return (trimmed.includes("://") ? new URL(trimmed) : new URL(`https://${trimmed}`)).hostname;
94
- } catch {
95
- return null;
96
- }
97
- }
98
- function getGitHubCopilotBaseUrl(enterpriseDomain) {
99
- const normalizedEnterpriseDomain = normalizeGitHubCopilotEnterpriseDomain(enterpriseDomain);
100
- if (!normalizedEnterpriseDomain) return "https://api.githubcopilot.com";
101
- return `https://${normalizedEnterpriseDomain.startsWith("copilot-api.") ? normalizedEnterpriseDomain : `copilot-api.${normalizedEnterpriseDomain}`}`;
102
- }
103
- //#endregion
104
- export { getGitHubCopilotBaseUrl as a, normalizeDomain as c, discoverGitHubCopilotApiEndpoint as i, normalizeGitHubCopilotEnterpriseDomain as l, OPENCODE_HEADERS as n, isPersonalGitHubCopilotBaseUrl as o, PERSONAL_GITHUB_COPILOT_BASE_URL as r, isPublicGitHubHost as s, COPILOT_API_HEADERS as t, parseGitHubCopilotApiKey as u };
@@ -1,155 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { c as OAuthError } from "./error-C-f_Wnw4.mjs";
4
- import { i as clearGitLabDuoDirectAccessCache } from "./stream-Bjq8wjfr.mjs";
5
- import { t as OAuthCallbackFlow } from "./callback-server-CFJK-jvK.mjs";
6
- import { t as generatePKCE } from "./pkce-BlQikGPu.mjs";
7
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/gitlab-duo.ts
8
- const GITLAB_COM_URL = "https://gitlab.com";
9
- /**
10
- * Default OAuth client id baked into the bundled GitLab Duo login flow. GitLab
11
- * authorize requests are rejected outright (`The redirect URI included is not
12
- * valid`) whenever this client id's registered redirect URI list drifts from
13
- * `http://localhost:8080/callback`. Users hitting that case can either:
14
- *
15
- * - register their own GitLab OAuth application and override the bundled
16
- * credentials with `GITLAB_CLIENT_ID` + `GITLAB_REDIRECT_URI`, or
17
- * - skip OAuth entirely and supply a Personal Access Token via `GITLAB_TOKEN`.
18
- *
19
- * @see https://github.com/can1357/oh-my-pi/issues/2424
20
- */
21
- const DEFAULT_CLIENT_ID = "da4edff2e6ebd2bc3208611e2768bc1c1dd7be791dc5ff26ca34ca9ee44f7d4b";
22
- const OAUTH_SCOPES = ["api"];
23
- const DEFAULT_CALLBACK_PORT = 8080;
24
- const DEFAULT_CALLBACK_PATH = "/callback";
25
- const DEFAULT_CALLBACK_HOSTNAME = "localhost";
26
- /**
27
- * Resolve the OAuth client id, preferring `GITLAB_CLIENT_ID` when set so users
28
- * with their own GitLab OAuth application can bypass the bundled credentials.
29
- */
30
- function resolveClientId() {
31
- const env = process.env.GITLAB_CLIENT_ID?.trim();
32
- return env && env.length > 0 ? env : DEFAULT_CLIENT_ID;
33
- }
34
- /**
35
- * Resolve callback-server options from `GITLAB_REDIRECT_URI`. When set, the
36
- * exact string is advertised to GitLab (strict matching), random-port fallback
37
- * is disabled, and HTTP loopback URIs bind the listener to the URI's host/port
38
- * so the browser callback lands on us. HTTPS loopback URIs are rejected because
39
- * the local callback server is plaintext HTTP. Non-loopback URIs bind a random
40
- * local port — only the paste-code path can complete in that case.
41
- */
42
- function resolveCallbackOptions() {
43
- const raw = process.env.GITLAB_REDIRECT_URI?.trim();
44
- if (!raw) return {
45
- preferredPort: DEFAULT_CALLBACK_PORT,
46
- callbackPath: DEFAULT_CALLBACK_PATH,
47
- callbackHostname: DEFAULT_CALLBACK_HOSTNAME
48
- };
49
- let parsed;
50
- try {
51
- parsed = new URL(raw);
52
- } catch {
53
- throw new OAuthError(`Invalid GITLAB_REDIRECT_URI: ${raw}`, {
54
- kind: "configuration",
55
- provider: "gitlab-duo"
56
- });
57
- }
58
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new OAuthError(`GITLAB_REDIRECT_URI must use http:// or https://, got: ${raw}`, {
59
- kind: "configuration",
60
- provider: "gitlab-duo"
61
- });
62
- const isLoopback = parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "[::1]";
63
- if (isLoopback && parsed.protocol !== "http:") throw new OAuthError(`GITLAB_REDIRECT_URI loopback callbacks must use http://, got: ${raw}`, {
64
- kind: "configuration",
65
- provider: "gitlab-duo"
66
- });
67
- const port = parsed.port ? Number.parseInt(parsed.port, 10) : parsed.protocol === "https:" ? 443 : 80;
68
- return {
69
- preferredPort: isLoopback ? port : 0,
70
- callbackPath: parsed.pathname || DEFAULT_CALLBACK_PATH,
71
- callbackHostname: isLoopback ? parsed.hostname : DEFAULT_CALLBACK_HOSTNAME,
72
- redirectUri: raw
73
- };
74
- }
75
- function mapTokenResponse(payload) {
76
- if (!payload.access_token || !payload.refresh_token || typeof payload.expires_in !== "number") throw new OAuthError("GitLab OAuth token response missing required fields", {
77
- kind: "validation",
78
- provider: "gitlab-duo"
79
- });
80
- const createdAtMs = typeof payload.created_at === "number" && Number.isFinite(payload.created_at) ? payload.created_at * 1e3 : Date.now();
81
- return {
82
- access: payload.access_token,
83
- refresh: payload.refresh_token,
84
- expires: createdAtMs + payload.expires_in * 1e3 - 3e5
85
- };
86
- }
87
- var GitLabDuoOAuthFlow = class extends OAuthCallbackFlow {
88
- #pkce;
89
- #clientId;
90
- #fetch;
91
- constructor(ctrl, pkce, clientId, options) {
92
- super(ctrl, options);
93
- this.#pkce = pkce;
94
- this.#clientId = clientId;
95
- this.#fetch = ctrl.fetch ?? fetch;
96
- }
97
- async generateAuthUrl(state, redirectUri) {
98
- const authParams = new URLSearchParams({
99
- client_id: this.#clientId,
100
- redirect_uri: redirectUri,
101
- response_type: "code",
102
- scope: OAUTH_SCOPES.join(" "),
103
- code_challenge: this.#pkce.challenge,
104
- code_challenge_method: "S256",
105
- state
106
- });
107
- return {
108
- url: `${GITLAB_COM_URL}/oauth/authorize?${authParams.toString()}`,
109
- instructions: "Complete GitLab login in browser. If GitLab responds with \"The redirect URI included is not valid\", register your own GitLab OAuth application and set GITLAB_CLIENT_ID + GITLAB_REDIRECT_URI, or use a Personal Access Token via GITLAB_TOKEN."
110
- };
111
- }
112
- async exchangeToken(code, _state, redirectUri) {
113
- const response = await this.#fetch(`${GITLAB_COM_URL}/oauth/token`, {
114
- method: "POST",
115
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
116
- body: new URLSearchParams({
117
- client_id: this.#clientId,
118
- grant_type: "authorization_code",
119
- code,
120
- code_verifier: this.#pkce.verifier,
121
- redirect_uri: redirectUri
122
- }).toString()
123
- });
124
- if (!response.ok) throw new OAuthError(`GitLab OAuth token exchange failed: ${response.status} ${await response.text()}`, {
125
- kind: "token-exchange",
126
- provider: "gitlab-duo",
127
- status: response.status
128
- });
129
- clearGitLabDuoDirectAccessCache();
130
- return mapTokenResponse(await response.json());
131
- }
132
- };
133
- async function loginGitLabDuo(callbacks) {
134
- return new GitLabDuoOAuthFlow(callbacks, await generatePKCE(), resolveClientId(), resolveCallbackOptions()).login();
135
- }
136
- async function refreshGitLabDuoToken(credentials) {
137
- const response = await fetch(`${GITLAB_COM_URL}/oauth/token`, {
138
- method: "POST",
139
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
140
- body: new URLSearchParams({
141
- client_id: resolveClientId(),
142
- grant_type: "refresh_token",
143
- refresh_token: credentials.refresh
144
- }).toString()
145
- });
146
- if (!response.ok) throw new OAuthError(`GitLab OAuth refresh failed: ${response.status} ${await response.text()}`, {
147
- kind: "token-refresh",
148
- provider: "gitlab-duo",
149
- status: response.status
150
- });
151
- clearGitLabDuoDirectAccessCache();
152
- return mapTokenResponse(await response.json());
153
- }
154
- //#endregion
155
- export { loginGitLabDuo, refreshGitLabDuoToken };
@@ -1,91 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { c as OAuthError } from "./error-C-f_Wnw4.mjs";
4
- import { t as OAuthCallbackFlow } from "./callback-server-CFJK-jvK.mjs";
5
- import { t as generatePKCE } from "./pkce-BlQikGPu.mjs";
6
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/gitlab-duo-workflow.ts
7
- const GITLAB_COM_URL = "https://gitlab.com";
8
- const GITLAB_DUO_WORKFLOW_OAUTH_CLIENT_ID = "36f2a70cddeb5a0889d4fd8295c241b7e9848e89cf9e599d0eed2d8e5350fbf5";
9
- const GITLAB_DUO_WORKFLOW_OAUTH_REDIRECT_URI = "vscode://gitlab.gitlab-workflow/authentication";
10
- const OAUTH_SCOPES = ["api"];
11
- function mapTokenResponse(payload) {
12
- if (!payload.access_token || !payload.refresh_token || typeof payload.expires_in !== "number") throw new OAuthError("GitLab Duo Workflow OAuth token response missing required fields", {
13
- kind: "validation",
14
- provider: "gitlab-duo-workflow"
15
- });
16
- const createdAtMs = typeof payload.created_at === "number" && Number.isFinite(payload.created_at) ? payload.created_at * 1e3 : Date.now();
17
- return {
18
- access: payload.access_token,
19
- refresh: payload.refresh_token,
20
- expires: createdAtMs + payload.expires_in * 1e3 - 3e5
21
- };
22
- }
23
- var GitLabDuoWorkflowOAuthFlow = class extends OAuthCallbackFlow {
24
- #pkce;
25
- #fetch;
26
- constructor(ctrl, pkce) {
27
- super(ctrl, {
28
- preferredPort: 0,
29
- redirectUri: GITLAB_DUO_WORKFLOW_OAUTH_REDIRECT_URI
30
- });
31
- this.#pkce = pkce;
32
- this.#fetch = ctrl.fetch ?? fetch;
33
- }
34
- async generateAuthUrl(state) {
35
- const authParams = new URLSearchParams({
36
- client_id: GITLAB_DUO_WORKFLOW_OAUTH_CLIENT_ID,
37
- redirect_uri: GITLAB_DUO_WORKFLOW_OAUTH_REDIRECT_URI,
38
- response_type: "code",
39
- scope: OAUTH_SCOPES.join(" "),
40
- code_challenge: this.#pkce.challenge,
41
- code_challenge_method: "S256",
42
- state
43
- });
44
- return {
45
- url: `${GITLAB_COM_URL}/oauth/authorize?${authParams.toString()}`,
46
- instructions: "Complete GitLab login in your browser. This uses GitLab's official VS Code OAuth application. If the redirect opens VS Code instead of returning to OMP, copy the full vscode://gitlab.gitlab-workflow/authentication?... callback URL from VS Code/browser and paste it back into OMP."
47
- };
48
- }
49
- async exchangeToken(code) {
50
- const response = await this.#fetch(`${GITLAB_COM_URL}/oauth/token`, {
51
- method: "POST",
52
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
53
- body: new URLSearchParams({
54
- client_id: GITLAB_DUO_WORKFLOW_OAUTH_CLIENT_ID,
55
- redirect_uri: GITLAB_DUO_WORKFLOW_OAUTH_REDIRECT_URI,
56
- grant_type: "authorization_code",
57
- code,
58
- code_verifier: this.#pkce.verifier
59
- }).toString()
60
- });
61
- if (!response.ok) throw new OAuthError(`GitLab Duo Workflow OAuth token exchange failed: ${response.status} ${await response.text()}`, {
62
- kind: "token-exchange",
63
- provider: "gitlab-duo-workflow",
64
- status: response.status
65
- });
66
- return mapTokenResponse(await response.json());
67
- }
68
- };
69
- async function loginGitLabDuoWorkflow(callbacks) {
70
- return new GitLabDuoWorkflowOAuthFlow(callbacks, await generatePKCE()).login();
71
- }
72
- async function refreshGitLabDuoWorkflowToken(credentials, fetchImpl = fetch) {
73
- const response = await fetchImpl(`${GITLAB_COM_URL}/oauth/token`, {
74
- method: "POST",
75
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
76
- body: new URLSearchParams({
77
- client_id: GITLAB_DUO_WORKFLOW_OAUTH_CLIENT_ID,
78
- redirect_uri: GITLAB_DUO_WORKFLOW_OAUTH_REDIRECT_URI,
79
- grant_type: "refresh_token",
80
- refresh_token: credentials.refresh
81
- }).toString()
82
- });
83
- if (!response.ok) throw new OAuthError(`GitLab Duo Workflow OAuth refresh failed: ${response.status} ${await response.text()}`, {
84
- kind: "token-refresh",
85
- provider: "gitlab-duo-workflow",
86
- status: response.status
87
- });
88
- return mapTokenResponse(await response.json());
89
- }
90
- //#endregion
91
- export { loginGitLabDuoWorkflow, refreshGitLabDuoWorkflowToken };
@@ -1,30 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { g as MissingApiKeyError } from "./error-C-f_Wnw4.mjs";
4
- import { n as getEnvApiKey } from "./stream-Bjq8wjfr.mjs";
5
- import { p as streamGoogleGenAI, t as buildGoogleGenerateContentParams } from "./google-shared-CVbHK5vZ.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 };
@@ -1,198 +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 { n as getAntigravityUserAgent, r as getAntigravityVersion } from "./gemini-headers-DKUShltF.mjs";
5
- import { n as runGoogleOAuthLogin, r as throwIfLoginCancelled, t as oauthFetch } from "./google-oauth-shared-BLVTvokk.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-antigravity.ts
7
- /**
8
- * Antigravity OAuth flow (Gemini 3, Claude, GPT-OSS via Google Cloud)
9
- * Uses different OAuth credentials than google-gemini-cli for access to additional models.
10
- */
11
- const decode = (s) => atob(s);
12
- const CLIENT_ID = decode("MTA3MTAwNjA2MDU5MS10bWhzc2luMmgyMWxjcmUyMzV2dG9sb2poNGc0MDNlcC5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbQ==");
13
- const CLIENT_SECRET = decode("R09DU1BYLUs1OEZXUjQ4NkxkTEoxbUxCOHNYQzR6NnFEQWY=");
14
- const CALLBACK_PORT = 51121;
15
- const CALLBACK_PATH = "/oauth-callback";
16
- const SCOPES = [
17
- "https://www.googleapis.com/auth/cloud-platform",
18
- "https://www.googleapis.com/auth/userinfo.email",
19
- "https://www.googleapis.com/auth/userinfo.profile",
20
- "https://www.googleapis.com/auth/cclog",
21
- "https://www.googleapis.com/auth/experimentsandconfigs"
22
- ];
23
- const AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
24
- const TOKEN_URL = "https://oauth2.googleapis.com/token";
25
- const CLOUD_CODE_ENDPOINT = "https://cloudcode-pa.googleapis.com";
26
- const DAILY_CLOUD_CODE_ENDPOINT = "https://daily-cloudcode-pa.googleapis.com";
27
- const NODE_API_CLIENT_USER_AGENT = "google-api-nodejs-client/10.3.0";
28
- const GOOG_API_CLIENT_HEADER = "gl-node/22.21.1";
29
- const TIER_FREE = "free-tier";
30
- const PROJECT_ONBOARD_MAX_ATTEMPTS = 5;
31
- const PROJECT_ONBOARD_INTERVAL_MS = 2e3;
32
- const ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA = Object.freeze({ ideType: "ANTIGRAVITY" });
33
- function getAntigravityOnboardMetadata() {
34
- return {
35
- ide_type: "ANTIGRAVITY",
36
- ide_version: getAntigravityVersion(),
37
- ide_name: "antigravity"
38
- };
39
- }
40
- function readProjectId(value) {
41
- if (typeof value === "string" && value.length > 0) return value.trim();
42
- if (value && typeof value === "object" && "id" in value && typeof value.id === "string") {
43
- const id = value.id.trim();
44
- if (id.length > 0) return id;
45
- }
46
- }
47
- function extractProjectId(payload) {
48
- if (!payload || typeof payload !== "object") return void 0;
49
- const record = payload;
50
- for (const key of [
51
- "cloudaicompanionProject",
52
- "projectId",
53
- "project"
54
- ]) {
55
- const id = readProjectId(record[key]);
56
- if (id) return id;
57
- }
58
- }
59
- function getDefaultTierId(allowedTiers, currentTier) {
60
- if (allowedTiers && allowedTiers.length > 0) {
61
- const defaultTier = allowedTiers.find((tier) => tier.isDefault && typeof tier.id === "string" && tier.id.trim().length > 0);
62
- if (defaultTier?.id) return defaultTier.id.trim();
63
- }
64
- if (currentTier && typeof currentTier.id === "string" && currentTier.id.trim().length > 0) return currentTier.id.trim();
65
- return TIER_FREE;
66
- }
67
- async function onboardProjectWithRetries(endpoint, headers, onboardBody, signal, onProgress) {
68
- for (let attempt = 1; attempt <= PROJECT_ONBOARD_MAX_ATTEMPTS; attempt += 1) {
69
- if (attempt > 1) {
70
- onProgress?.(`Waiting for project provisioning (attempt ${attempt}/${PROJECT_ONBOARD_MAX_ATTEMPTS})...`);
71
- throwIfLoginCancelled(signal);
72
- await Bun.sleep(PROJECT_ONBOARD_INTERVAL_MS);
73
- }
74
- throwIfLoginCancelled(signal);
75
- const onboardResponse = await oauthFetch(`${endpoint}/v1internal:onboardUser`, {
76
- method: "POST",
77
- headers,
78
- body: JSON.stringify(onboardBody)
79
- }, {
80
- provider: "google-antigravity",
81
- signal
82
- });
83
- if (!onboardResponse.ok) {
84
- const errorText = await onboardResponse.text();
85
- throw new OAuthError(`onboardUser failed: ${onboardResponse.status} ${onboardResponse.statusText}: ${errorText}`, {
86
- kind: "provisioning",
87
- provider: "google-antigravity",
88
- status: onboardResponse.status
89
- });
90
- }
91
- const operation = await onboardResponse.json();
92
- if (!operation.done) continue;
93
- const projectId = extractProjectId(operation.response);
94
- if (projectId) return projectId;
95
- }
96
- throw new OAuthError(`onboardUser did not return a provisioned project id after ${PROJECT_ONBOARD_MAX_ATTEMPTS} attempts`, {
97
- kind: "provisioning",
98
- provider: "google-antigravity"
99
- });
100
- }
101
- async function discoverProject(accessToken, onProgress, signal) {
102
- const headers = {
103
- Authorization: `Bearer ${accessToken}`,
104
- "Content-Type": "application/json",
105
- "User-Agent": getAntigravityUserAgent()
106
- };
107
- onProgress?.("Checking for existing project...");
108
- try {
109
- let lastErrorText;
110
- let lastStatus;
111
- let fallbackTierId = TIER_FREE;
112
- let loadedSuccessfully = false;
113
- for (const endpoint of [DAILY_CLOUD_CODE_ENDPOINT, CLOUD_CODE_ENDPOINT]) {
114
- throwIfLoginCancelled(signal);
115
- const loadResponse = await oauthFetch(`${endpoint}/v1internal:loadCodeAssist`, {
116
- method: "POST",
117
- headers,
118
- body: JSON.stringify({ metadata: ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA })
119
- }, {
120
- provider: "google-antigravity",
121
- signal
122
- });
123
- if (!loadResponse.ok) {
124
- lastStatus = loadResponse.status;
125
- lastErrorText = await loadResponse.text();
126
- continue;
127
- }
128
- loadedSuccessfully = true;
129
- const loadPayload = await loadResponse.json();
130
- const existingProject = extractProjectId(loadPayload);
131
- if (existingProject) return existingProject;
132
- fallbackTierId = getDefaultTierId(loadPayload.allowedTiers, loadPayload.currentTier);
133
- }
134
- if (!loadedSuccessfully && lastStatus !== void 0) throw new OAuthError(`loadCodeAssist failed: ${lastStatus}: ${lastErrorText || "unknown error"}`, {
135
- kind: "discovery",
136
- status: lastStatus
137
- });
138
- onProgress?.("Provisioning project...");
139
- const onboardBody = {
140
- tier_id: fallbackTierId,
141
- metadata: getAntigravityOnboardMetadata()
142
- };
143
- const onboardHeaders = {
144
- ...headers,
145
- "User-Agent": `${headers["User-Agent"]} ${NODE_API_CLIENT_USER_AGENT}`,
146
- "X-Goog-Api-Client": GOOG_API_CLIENT_HEADER
147
- };
148
- return await onboardProjectWithRetries(DAILY_CLOUD_CODE_ENDPOINT, onboardHeaders, onboardBody, signal, onProgress);
149
- } catch (error) {
150
- if (error instanceof LoginCancelledError || error instanceof OAuthError) throw error;
151
- throw new OAuthError(`Could not discover or provision an Antigravity project. ${error instanceof Error ? error.message : String(error)}`, {
152
- kind: "discovery",
153
- provider: "google-antigravity",
154
- cause: error
155
- });
156
- }
157
- }
158
- async function loginAntigravity(ctrl) {
159
- return runGoogleOAuthLogin(ctrl, {
160
- provider: "google-antigravity",
161
- clientId: CLIENT_ID,
162
- clientSecret: CLIENT_SECRET,
163
- authUrl: AUTH_URL,
164
- tokenUrl: TOKEN_URL,
165
- scopes: SCOPES,
166
- callbackPort: CALLBACK_PORT,
167
- callbackPath: CALLBACK_PATH,
168
- discoverProject
169
- });
170
- }
171
- /**
172
- * Refresh Antigravity token
173
- */
174
- async function refreshAntigravityToken(refreshToken, projectId) {
175
- const response = await fetch(TOKEN_URL, {
176
- method: "POST",
177
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
178
- body: new URLSearchParams({
179
- client_id: CLIENT_ID,
180
- client_secret: CLIENT_SECRET,
181
- refresh_token: refreshToken,
182
- grant_type: "refresh_token"
183
- })
184
- });
185
- if (!response.ok) {
186
- const error = await response.text();
187
- throw new OAuthError(`Antigravity token refresh failed: ${error}`, { kind: "token-refresh" });
188
- }
189
- const data = await response.json();
190
- return {
191
- refresh: data.refresh_token || refreshToken,
192
- access: data.access_token,
193
- expires: Date.now() + data.expires_in * 1e3 - 3e5,
194
- projectId
195
- };
196
- }
197
- //#endregion
198
- export { loginAntigravity, refreshAntigravityToken };