@xiaoso/dsh-tool-plus 0.1.0-beta.3 → 0.1.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/lib/abort-D1_Z5Ut5.mjs +51 -0
  2. package/lib/abort-dIkZBV7Q.mjs +51 -0
  3. package/lib/amazon-bedrock-B0nxT06F.mjs +917 -0
  4. package/lib/amazon-bedrock-WQhvjHYu.mjs +917 -0
  5. package/lib/anthropic-CJCauvYz.mjs +3115 -0
  6. package/lib/anthropic-CZghe_9U.mjs +3115 -0
  7. package/lib/anthropic-sCMH7JID.mjs +262 -0
  8. package/lib/anthropic-tTntD8BD.mjs +262 -0
  9. package/lib/api-key-login-BzqNdM2y.mjs +157 -0
  10. package/lib/api-key-login-CWVwvHT1.mjs +157 -0
  11. package/lib/aws-credentials-CXryMobh.mjs +867 -0
  12. package/lib/aws-credentials-ChG79ey-.mjs +867 -0
  13. package/lib/azure-openai-responses-Cgmc-rbL.mjs +274 -0
  14. package/lib/azure-openai-responses-DuukbD0F.mjs +274 -0
  15. package/lib/bun-shim.mjs +81 -6
  16. package/lib/bundled-references-Cavaffah.mjs +55 -0
  17. package/lib/bundled-references-sLN0YdXU.mjs +55 -0
  18. package/lib/callback-server-CQ5Jo8F-.mjs +398 -0
  19. package/lib/callback-server-DDSrZ6l_.mjs +398 -0
  20. package/lib/client.js +1 -1
  21. package/lib/cursor-B3zg7EHj.mjs +273 -0
  22. package/lib/cursor-B6TUEmgP.mjs +135 -0
  23. package/lib/cursor-D8gvtTL3.mjs +135 -0
  24. package/lib/cursor-DkSX2h3H.mjs +5441 -0
  25. package/lib/cursor-aJrXeYCb.mjs +273 -0
  26. package/lib/cursor-mJQwUKXK.mjs +5441 -0
  27. package/lib/device-code-DBo3B5nh.mjs +51 -0
  28. package/lib/device-code-DIb0FU-H.mjs +51 -0
  29. package/lib/devin-BHZZyMhO.mjs +95 -0
  30. package/lib/devin-BK7DHeca.mjs +114 -0
  31. package/lib/devin-CfMp3cXS.mjs +95 -0
  32. package/lib/devin-D9zR5B_R.mjs +542 -0
  33. package/lib/devin-Q1yem3lp.mjs +114 -0
  34. package/lib/devin-vNZTNUON.mjs +542 -0
  35. package/lib/error-Dd8DIqs-.mjs +1449 -0
  36. package/lib/error-yCSG0mGC.mjs +1449 -0
  37. package/lib/event-stream-BbFZJy-z.mjs +151 -0
  38. package/lib/event-stream-loUa0s1T.mjs +151 -0
  39. package/lib/fs-promises-shim-Bx0fpxuk.mjs +57 -0
  40. package/lib/github-copilot-B1yiyVRh.mjs +104 -0
  41. package/lib/github-copilot-BWT3eAOF.mjs +208 -0
  42. package/lib/github-copilot-CYkjeTi3.mjs +208 -0
  43. package/lib/github-copilot-jscUZ8Hf.mjs +104 -0
  44. package/lib/gitlab-duo-CM7Ref1H.mjs +155 -0
  45. package/lib/gitlab-duo-gubO4FNw.mjs +155 -0
  46. package/lib/gitlab-duo-workflow-BGAF6JDw.mjs +91 -0
  47. package/lib/gitlab-duo-workflow-D78tdn8E.mjs +91 -0
  48. package/lib/google-BS4T25Pn.mjs +30 -0
  49. package/lib/google-TFe-7-of.mjs +30 -0
  50. package/lib/google-antigravity-DGmwC2KV.mjs +198 -0
  51. package/lib/google-antigravity-DNYhgTpA.mjs +198 -0
  52. package/lib/google-auth-B6gjsZvg.mjs +232 -0
  53. package/lib/google-auth-De7_s3eo.mjs +232 -0
  54. package/lib/google-gemini-cli-CWu8HvXW.mjs +211 -0
  55. package/lib/google-gemini-cli-Cb97bzQc.mjs +850 -0
  56. package/lib/google-gemini-cli-Cqds_Q5T.mjs +850 -0
  57. package/lib/google-gemini-cli-Dsztq0N5.mjs +211 -0
  58. package/lib/google-oauth-shared-CuEHaDDj.mjs +147 -0
  59. package/lib/google-oauth-shared-yqlyqPPC.mjs +147 -0
  60. package/lib/google-shared-CgKmmdO3.mjs +760 -0
  61. package/lib/google-shared-Dr-VG-ap.mjs +760 -0
  62. package/lib/google-vertex-BDN2tLaD.mjs +99 -0
  63. package/lib/google-vertex-DopVOQOG.mjs +99 -0
  64. package/lib/identity-Da1GPU9a.mjs +219 -0
  65. package/lib/identity-xRP7_eSR.mjs +219 -0
  66. package/lib/idle-iterator-Baoyn3Hp.mjs +366 -0
  67. package/lib/idle-iterator-DUjKQEGT.mjs +366 -0
  68. package/lib/index.mjs +1731 -1178
  69. package/lib/kimi--wUOWER5.mjs +236 -0
  70. package/lib/kimi-Dh0pv3WZ.mjs +236 -0
  71. package/lib/markit-BL3cH47U.mjs +1417 -0
  72. package/lib/markit-BNiNY6SE.mjs +1417 -0
  73. package/lib/minimax-code-DCbuA6Yk.mjs +53 -0
  74. package/lib/minimax-code-Uq8Qu9LW.mjs +53 -0
  75. package/lib/models-D_XnT6ay.mjs +104660 -0
  76. package/lib/models-SGASygJ3.mjs +104660 -0
  77. package/lib/ollama-DPzBmq89.mjs +589 -0
  78. package/lib/ollama-DoBz5SFm.mjs +589 -0
  79. package/lib/openai-codex-Bi-4S4PX.mjs +255 -0
  80. package/lib/openai-codex-Ch8CkT3p.mjs +255 -0
  81. package/lib/openai-codex-responses-CvxL_FMF.mjs +3144 -0
  82. package/lib/openai-codex-responses-pejZgdZo.mjs +3144 -0
  83. package/lib/openai-completions-CF8IyNtP.mjs +1360 -0
  84. package/lib/openai-completions-DIf361kF.mjs +1360 -0
  85. package/lib/openai-reasoning-fallback-Nj6yB2rY.mjs +286 -0
  86. package/lib/openai-reasoning-fallback-OdJREP1o.mjs +286 -0
  87. package/lib/openai-responses-BqXJInHX.mjs +867 -0
  88. package/lib/openai-responses-Db_a-U4-.mjs +867 -0
  89. package/lib/opencode-DhMolSoB.mjs +38 -0
  90. package/lib/opencode-Rq_Q2vAO.mjs +38 -0
  91. package/lib/perplexity-C4iLVMUj.mjs +194 -0
  92. package/lib/perplexity-Uu7Jzg5b.mjs +194 -0
  93. package/lib/proxy-DDqrmjjC.mjs +190 -0
  94. package/lib/proxy-pM_NIv-H.mjs +190 -0
  95. package/lib/request-debug-HJMoJncL.mjs +183 -0
  96. package/lib/sanitize-text-CfcXzw5X.mjs +33 -0
  97. package/lib/scrapers-BkFfcPHj.mjs +9198 -0
  98. package/lib/scrapers-CVptboMs.mjs +9198 -0
  99. package/lib/scrapers-nhQAvc8d.mjs +9198 -0
  100. package/lib/shell-snapshot-fn-env.sh +67 -43
  101. package/lib/src-BgpusnsB.mjs +5076 -0
  102. package/lib/src-lDmkSRbm.mjs +5006 -0
  103. package/lib/stream-BlldLkVq.mjs +10236 -0
  104. package/lib/stream-CRtexYLe.mjs +10236 -0
  105. package/lib/stream-markup-healing-DMsxBx1L.mjs +491 -0
  106. package/lib/stream-markup-healing-KMkiAA00.mjs +491 -0
  107. package/lib/turndown-DN7ByzEI.mjs +667 -0
  108. package/lib/types/config/settings.d.ts +9 -1
  109. package/lib/types/config/truncate.d.ts +9 -5
  110. package/lib/types/tools/bash/background.d.ts +1 -1
  111. package/lib/types/tools/bash/bash-executor.d.ts +4 -0
  112. package/lib/types/tools/bash/bash-interceptor.d.ts +10 -8
  113. package/lib/types/tools/bash/cd-workdir.d.ts +35 -0
  114. package/lib/types/tools/bash/non-interactive-env.d.ts +2 -0
  115. package/lib/types/tools/bash/render.d.ts +4 -3
  116. package/lib/types/tools/bash/sanitize-text.d.ts +5 -0
  117. package/lib/types/tools/bash/shell-snapshot.d.ts +4 -1
  118. package/lib/types/tools/bash/shell-tokenize.d.ts +60 -0
  119. package/lib/types/tools/bash/streaming-output.d.ts +12 -212
  120. package/lib/types/tools/bash/which.d.ts +20 -0
  121. package/lib/types/tools/bash/windows-shell.d.ts +31 -0
  122. package/lib/types/tools/edit/adapter/index.d.ts +25 -3
  123. package/lib/types/tools/edit/adapter/tools/auto-generated-guard.d.ts +7 -17
  124. package/lib/types/tools/glob/adapter/index.d.ts +27 -1
  125. package/lib/types/tools/grep/adapter/index.d.ts +29 -1
  126. package/lib/types/tools/omp/edit/dispatch.d.ts +43 -0
  127. package/lib/types/tools/omp/edit/hashline/noop-loop-guard.d.ts +3 -1
  128. package/lib/types/tools/omp/tools/auto-generated-guard.d.ts +20 -0
  129. package/lib/types/tools/omp/tools/write.d.ts +4 -4
  130. package/lib/types/tools/shared/auto-generated-guard.dsh.d.ts +16 -4
  131. package/lib/types/tools/shared/bun-shim.d.ts +4 -0
  132. package/lib/types/tools/shared/fs-promises-shim.d.ts +3 -1
  133. package/lib/types/tools/shared/omp-prompt.d.ts +13 -7
  134. package/lib/types/tools/shared/session-state.d.ts +9 -3
  135. package/lib/utils-Bw139LTz.mjs +8119 -0
  136. package/lib/utils-CZw4tVZQ.mjs +12315 -0
  137. package/lib/utils-CiGN7OHR.mjs +12315 -0
  138. package/lib/utils-Cp76gCyk.mjs +8119 -0
  139. package/lib/utils-D0GRDgAr.mjs +12315 -0
  140. package/lib/utils-D2YknRk4.mjs +51 -0
  141. package/lib/utils-DzXZDfYc.mjs +51 -0
  142. package/lib/vision-guard-01qSwFpf.mjs +92 -0
  143. package/lib/vision-guard-DzZGaOga.mjs +92 -0
  144. package/lib/wafer-CgtPHerf.mjs +17 -0
  145. package/lib/wafer-cBtrn6q9.mjs +17 -0
  146. package/lib/xai-oauth-Buk8XVvM.mjs +446 -0
  147. package/lib/xai-oauth-CMal8l1O.mjs +446 -0
  148. package/lib/xiaomi-CZgwvX2G.mjs +157 -0
  149. package/lib/xiaomi-D2qT5cAC.mjs +157 -0
  150. package/lib/zai-7DWMkEqM.mjs +203 -0
  151. package/lib/zai-C59YnomG.mjs +203 -0
  152. package/lib/zip-Cg9ANN_U.mjs +1316 -0
  153. package/lib/zip-D36ZKsP8.mjs +1316 -0
  154. package/package.json +1 -1
  155. package/presets/package.json +1 -1
@@ -0,0 +1,91 @@
1
+ import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
+ __installBunShim();
3
+ import { c as OAuthError } from "./error-Dd8DIqs-.mjs";
4
+ import { t as OAuthCallbackFlow } from "./callback-server-CQ5Jo8F-.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 };
@@ -0,0 +1,91 @@
1
+ import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
+ __installBunShim();
3
+ import { c as OAuthError } from "./error-yCSG0mGC.mjs";
4
+ import { t as OAuthCallbackFlow } from "./callback-server-DDSrZ6l_.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 };
@@ -0,0 +1,30 @@
1
+ import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
+ __installBunShim();
3
+ import { g as MissingApiKeyError } from "./error-Dd8DIqs-.mjs";
4
+ import { n as getEnvApiKey } from "./stream-CRtexYLe.mjs";
5
+ import { p as streamGoogleGenAI, t as buildGoogleGenerateContentParams } from "./google-shared-Dr-VG-ap.mjs";
6
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/google.ts
7
+ const DEFAULT_GENERATIVE_LANGUAGE_BASE = "https://generativelanguage.googleapis.com/v1beta";
8
+ const streamGoogle = (model, context, options) => {
9
+ const apiKey = options?.apiKey || getEnvApiKey(model.provider);
10
+ if (!apiKey) throw new MissingApiKeyError(void 0, "Google Generative AI requires an API key (GEMINI_API_KEY or options.apiKey).");
11
+ return streamGoogleGenAI({
12
+ model,
13
+ options,
14
+ api: "google-generative-ai",
15
+ prepare: () => {
16
+ return {
17
+ params: buildGoogleGenerateContentParams(model, context, options ?? {}),
18
+ url: `${model.baseUrl?.trim() || DEFAULT_GENERATIVE_LANGUAGE_BASE}/models/${model.id}:streamGenerateContent?alt=sse`,
19
+ headers: {
20
+ "x-goog-api-key": apiKey,
21
+ ...model.headers ?? {},
22
+ ...options?.headers ?? {}
23
+ },
24
+ fetch: options?.fetch
25
+ };
26
+ }
27
+ });
28
+ };
29
+ //#endregion
30
+ export { streamGoogle };
@@ -0,0 +1,30 @@
1
+ import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
+ __installBunShim();
3
+ import { g as MissingApiKeyError } from "./error-yCSG0mGC.mjs";
4
+ import { n as getEnvApiKey } from "./stream-BlldLkVq.mjs";
5
+ import { p as streamGoogleGenAI, t as buildGoogleGenerateContentParams } from "./google-shared-CgKmmdO3.mjs";
6
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/google.ts
7
+ const DEFAULT_GENERATIVE_LANGUAGE_BASE = "https://generativelanguage.googleapis.com/v1beta";
8
+ const streamGoogle = (model, context, options) => {
9
+ const apiKey = options?.apiKey || getEnvApiKey(model.provider);
10
+ if (!apiKey) throw new MissingApiKeyError(void 0, "Google Generative AI requires an API key (GEMINI_API_KEY or options.apiKey).");
11
+ return streamGoogleGenAI({
12
+ model,
13
+ options,
14
+ api: "google-generative-ai",
15
+ prepare: () => {
16
+ return {
17
+ params: buildGoogleGenerateContentParams(model, context, options ?? {}),
18
+ url: `${model.baseUrl?.trim() || DEFAULT_GENERATIVE_LANGUAGE_BASE}/models/${model.id}:streamGenerateContent?alt=sse`,
19
+ headers: {
20
+ "x-goog-api-key": apiKey,
21
+ ...model.headers ?? {},
22
+ ...options?.headers ?? {}
23
+ },
24
+ fetch: options?.fetch
25
+ };
26
+ }
27
+ });
28
+ };
29
+ //#endregion
30
+ export { streamGoogle };
@@ -0,0 +1,198 @@
1
+ import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
+ __installBunShim();
3
+ import { c as OAuthError, h as LoginCancelledError } from "./error-Dd8DIqs-.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-CuEHaDDj.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 };
@@ -0,0 +1,198 @@
1
+ import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
+ __installBunShim();
3
+ import { c as OAuthError, h as LoginCancelledError } from "./error-yCSG0mGC.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-yqlyqPPC.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 };