@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.
- package/THIRD_PARTY_NOTICES.md +9 -3
- package/lib/{abort-Cwwm4Err.mjs → abort-Caqff3M6.mjs} +2 -2
- package/lib/alibaba-coding-plan-DTupMiAi.mjs +73 -0
- package/lib/alibaba-token-plan-CHGyWOfX.mjs +46 -0
- package/lib/alibaba-token-plan-Dj3OZhEE.mjs +82 -0
- package/lib/{amazon-bedrock-TVMpUTRG.mjs → amazon-bedrock-DbFSYXfJ.mjs} +117 -38
- package/lib/{anthropic-BL6LFDQS.mjs → anthropic-CTJ3IQVa.mjs} +675 -166
- package/lib/anthropic-CXfWlp-x.mjs +105 -0
- package/lib/{aws-credentials-B20dliS7.mjs → anthropic-wire-CKuhDwZ1.mjs} +74 -14
- package/lib/{api-key-login-CIDnXeYd.mjs → api-key-validation-CGCJFbFr.mjs} +27 -68
- package/lib/{azure-openai-responses-BkhsLmN3.mjs → azure-openai-responses-ChFbWaGj.mjs} +27 -16
- package/lib/{browser-render-CmgvSNte.mjs → browser-render-9o0Rknop.mjs} +4 -4
- package/lib/bun-shim.mjs +71 -2
- package/lib/{bundled-references-ChZSPDFw.mjs → bundled-references-DY3EJxZV.mjs} +6 -5
- package/lib/cline-pass-Bwg3esu9.mjs +44 -0
- package/lib/cloudflare-ai-gateway-BupNXyKK.mjs +35 -0
- package/lib/cloudflare-ai-gateway-EWo0VkP5.mjs +44 -0
- package/lib/collapse-DOR8sOGf.mjs +2304 -0
- package/lib/coreweave-C82HrLpb.mjs +31 -0
- package/lib/coreweave-Ct8cF-da.mjs +14 -0
- package/lib/{cursor-B6HcmplF.mjs → cursor-B95LzVWV.mjs} +11 -3
- package/lib/{cursor-CRpLpaZ3.mjs → cursor-DJV_dcgB.mjs} +887 -1784
- package/lib/{cursor-B8m6SqAH.mjs → cursor-LKGjucn2.mjs} +48 -38
- package/lib/cursor-proto-B8Wj8bv9.mjs +10513 -0
- package/lib/{deterministic-id-D-yIV_eI.mjs → deterministic-id-CUEIMSqR.mjs} +1 -1
- package/lib/devin-BMTdx_hx.mjs +316 -0
- package/lib/{devin-DUAfvBsW.mjs → devin-DSp0Rw_E.mjs} +172 -86
- package/lib/devin-ExGIghmx.mjs +69 -0
- package/lib/devin-proto-Br8fdyNl.mjs +2888 -0
- package/lib/{dom-CawWi8fa.mjs → dom-DG3sPESc.mjs} +8 -8
- package/lib/effort-BdtQMN-_.mjs +23 -0
- package/lib/{error-C-f_Wnw4.mjs → error-CORgGg5a.mjs} +275 -154
- package/lib/{event-stream-Dh2guZxS.mjs → event-stream-ulcDenZD.mjs} +20 -4
- package/lib/{gemini-headers-DKUShltF.mjs → gemini-headers-Co9cVvex.mjs} +2 -2
- package/lib/{github-copilot-suDymKrx.mjs → github-copilot-Dstq1D3s.mjs} +69 -29
- package/lib/github-copilot-headers-DOh1gt_w.mjs +312 -0
- package/lib/gitlab-duo-DSCMrU0m.mjs +11 -0
- package/lib/google-CtsKkOQK.mjs +38 -0
- package/lib/google-antigravity-z-5KsEci.mjs +252 -0
- package/lib/{google-auth-DYJLM792.mjs → google-auth-ieLBaneO.mjs} +4 -4
- package/lib/{google-gemini-cli-8BT513Ul.mjs → google-gemini-cli-C6NE5mWz.mjs} +28 -54
- package/lib/{google-gemini-cli-D6cSmfvB.mjs → google-gemini-cli-CAIPSl7e.mjs} +23 -29
- package/lib/google-oauth-shared-DhMllAkt.mjs +53 -0
- package/lib/{google-shared-CVbHK5vZ.mjs → google-shared-B0aNCYEH.mjs} +140 -44
- package/lib/{google-validation-Cgbn3tWJ.mjs → google-validation-BEkNs-Bx.mjs} +1 -1
- package/lib/{google-vertex-Bui-ypAe.mjs → google-vertex-Bbd1tYNc.mjs} +8 -8
- package/lib/hosts-00rjRzUD.mjs +203 -0
- package/lib/id-AL5obQzR.mjs +71 -0
- package/lib/{idle-iterator-CYAxUkSD.mjs → idle-iterator-DlUkEfzW.mjs} +3 -3
- package/lib/index.mjs +587 -5266
- package/lib/kilo-ChJL54wq.mjs +81 -0
- package/lib/kimi-C2c_Zq8A.mjs +67 -0
- package/lib/{launch-BmgEUycu.mjs → launch-DKDH71En.mjs} +1 -1
- package/lib/markit-CmRfm4E2.mjs +9885 -0
- package/lib/models-DnXMYGcJ.mjs +381604 -0
- package/lib/muse-code-Di1VZmB1.mjs +143 -0
- package/lib/{ollama-Df9ce-Cp.mjs → ollama-B8ic3sEp.mjs} +15 -30
- package/lib/{openai-codex-CAVI3Me-.mjs → openai-codex-DuJNC99x.mjs} +29 -99
- package/lib/{openai-codex-responses-BcnOotRB.mjs → openai-codex-responses-BL29nh9K.mjs} +204 -116
- package/lib/{openai-completions-Bq4WT47M.mjs → openai-completions-BK2f2dBv.mjs} +152 -82
- package/lib/openai-configuration-update-xMYUjaK_.mjs +150 -0
- package/lib/{openai-reasoning-fallback-DXsfiSXO.mjs → openai-reasoning-fallback-BdB3RCbj.mjs} +106 -12
- package/lib/{openai-responses-Mq_-PjvE.mjs → openai-responses-CGQPlIIy.mjs} +76 -82
- package/lib/{perplexity-XgLF73E7.mjs → perplexity-TBjz3VMB.mjs} +52 -9
- package/lib/{pkce-BlQikGPu.mjs → pkce-BYjmugmw.mjs} +1 -1
- package/lib/protobuf-aab1UGVn.mjs +717 -0
- package/lib/{provider-response-C6vcbQyO.mjs → provider-response-SqKSkkUc.mjs} +1 -1
- package/lib/{proxy-D9lm7ONA.mjs → proxy-5nWqRL1f.mjs} +45 -5
- package/lib/{readability-Cpm-ocau.mjs → readability-uGhqb4GC.mjs} +2 -2
- package/lib/reference-CtvM4zLU.mjs +114 -0
- package/lib/{request-debug-HJMoJncL.mjs → request-debug-NQN0BjHH.mjs} +1 -1
- package/lib/{sanitize-text-CfcXzw5X.mjs → sanitize-text-BCf5KmCf.mjs} +1 -1
- package/lib/{scrapers-Cg5w77td.mjs → scrapers-D8oWspgW.mjs} +12 -12
- package/lib/{src-BcD0_rQR.mjs → src-BwW51vA5.mjs} +979 -388
- package/lib/{sse-debug-CYdjOC96.mjs → sse-debug-B-tkLCPW.mjs} +1 -1
- package/lib/{stream-Bjq8wjfr.mjs → stream-B_7qN-bA.mjs} +3802 -2623
- package/lib/stream-markup-healing-DKT1lnkW.mjs +267 -0
- package/lib/{strict-tool-validation-imVLUcbI.mjs → strict-tool-validation-CBTz1dAA.mjs} +2 -2
- package/lib/taxonomy-DSIM99rS.mjs +15392 -0
- package/lib/{stream-markup-healing-DZ6bVDxH.mjs → thinking-CiLa2LFB.mjs} +31 -186
- package/lib/{turndown-DN7ByzEI.mjs → turndown-DrX1M4WG.mjs} +4 -4
- package/lib/{type-guards-B9VVjRDK.mjs → type-guards-CttAANEx.mjs} +1 -1
- package/lib/{types-DX_bvuus.mjs → types-PVueGi9S.mjs} +2 -2
- package/lib/{utils-C-dSORPa.mjs → utils-CCfhUQen.mjs} +2364 -2676
- package/lib/{utils-Cp2Mxf_U.mjs → utils-CUPhpw9A.mjs} +413 -134
- package/lib/{utils-CQHPEQ3W.mjs → utils-DeWqNWV8.mjs} +2 -2
- package/lib/{vision-guard-mBmtAHx0.mjs → vision-guard-_XwsL1DF.mjs} +14 -29
- package/lib/xai-oauth-CXhnz0gO.mjs +210 -0
- package/lib/{xiaomi-7mE345KX.mjs → xiaomi-psoUItal.mjs} +8 -37
- package/lib/{zai-CeNpMV3W.mjs → zai-ApJ8HBgT.mjs} +8 -71
- package/lib/{zip-BK7UHCwX.mjs → zip-Kd602XNe.mjs} +1 -1
- package/package.json +11 -11
- package/presets/package.json +1 -1
- package/presets/tool-plus-ptc/agent.cordis.yml +1 -1
- package/presets/tool-plus-standard/agent.cordis.yml +1 -1
- package/lib/agent_pb-Rizyt9Zg.mjs +0 -805
- package/lib/anthropic-CDmj476p.mjs +0 -262
- package/lib/api_server_pb-CDZgLMta.mjs +0 -252
- package/lib/callback-server-CFJK-jvK.mjs +0 -398
- package/lib/codex-P1dGpX7G.mjs +0 -54
- package/lib/device-code-CuXTWYwY.mjs +0 -51
- package/lib/devin-BcQwht1W.mjs +0 -114
- package/lib/devin-BvMfGevz.mjs +0 -95
- package/lib/github-copilot-B3kQl0g0.mjs +0 -104
- package/lib/gitlab-duo-BriUTP8k.mjs +0 -155
- package/lib/gitlab-duo-workflow-wK5Ljzmc.mjs +0 -91
- package/lib/google-CE5tFDod.mjs +0 -30
- package/lib/google-antigravity-C1jgNljz.mjs +0 -198
- package/lib/google-oauth-shared-BLVTvokk.mjs +0 -147
- package/lib/grammar-D-NqNUxQ.mjs +0 -49
- package/lib/identity-HNO1Oe9B.mjs +0 -219
- package/lib/kimi-DgcUpPtK.mjs +0 -236
- package/lib/markit-DtGoRE6M.mjs +0 -1417
- package/lib/minimax-code-Y3h5li9N.mjs +0 -53
- package/lib/models-DRA2c_8U.mjs +0 -104660
- package/lib/opencode-BsVw9rCD.mjs +0 -38
- package/lib/to-binary-B1BEBIPC.mjs +0 -6002
- package/lib/wafer-BlhWLweO.mjs +0 -17
- package/lib/xai-oauth-5pORHUrg.mjs +0 -446
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import {
|
|
4
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@
|
|
3
|
+
import { s as ProviderResponseError, w as classifyMessage } from "./error-CORgGg5a.mjs";
|
|
4
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/event-stream.ts
|
|
5
5
|
var EventStream = class {
|
|
6
6
|
queue = [];
|
|
7
7
|
waiting = [];
|
|
@@ -18,6 +18,13 @@ var EventStream = class {
|
|
|
18
18
|
* not a provider stall; idle watchdogs consult {@link hasPendingLocalWork}.
|
|
19
19
|
*/
|
|
20
20
|
#pendingLocalWork = 0;
|
|
21
|
+
/**
|
|
22
|
+
* A downstream stream whose local work also counts as ours — set when this
|
|
23
|
+
* stream forwards another stream's events (e.g. the Cursor discovered-id
|
|
24
|
+
* retry drains an inner stream), so the watchdog on this stream sees the
|
|
25
|
+
* inner exec bridge's busy state instead of aborting a healthy tool run.
|
|
26
|
+
*/
|
|
27
|
+
#localWorkDelegate;
|
|
21
28
|
finalResultPromise;
|
|
22
29
|
resolveFinalResult;
|
|
23
30
|
rejectFinalResult;
|
|
@@ -99,9 +106,18 @@ var EventStream = class {
|
|
|
99
106
|
result() {
|
|
100
107
|
return this.finalResultPromise;
|
|
101
108
|
}
|
|
102
|
-
/** True while local work tracked via {@link trackLocalWork} is pending. */
|
|
109
|
+
/** True while local work tracked via {@link trackLocalWork} — on this stream or a forwarded delegate — is pending. */
|
|
103
110
|
get hasPendingLocalWork() {
|
|
104
|
-
return this.#pendingLocalWork > 0;
|
|
111
|
+
return this.#pendingLocalWork > 0 || (this.#localWorkDelegate?.hasPendingLocalWork ?? false);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Count `source`'s pending local work as this stream's own. Used when this
|
|
115
|
+
* stream forwards another's events (Cursor discovered-id retry) so the
|
|
116
|
+
* watchdog does not abort a live tool run happening on the inner stream.
|
|
117
|
+
* Pass `undefined` to detach once forwarding ends.
|
|
118
|
+
*/
|
|
119
|
+
forwardLocalWorkFrom(source) {
|
|
120
|
+
this.#localWorkDelegate = source;
|
|
105
121
|
}
|
|
106
122
|
/**
|
|
107
123
|
* Track a local-work promise so idle watchdogs on this stream do not treat
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@
|
|
3
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@18.1.17/node_modules/@oh-my-pi/pi-catalog/src/wire/gemini-headers.ts
|
|
4
4
|
/**
|
|
5
5
|
* Build a User-Agent string that identifies as Gemini CLI to unlock higher rate limits.
|
|
6
6
|
* Uses the same format as the official Gemini CLI (v0.35+):
|
|
@@ -51,4 +51,4 @@ function getAntigravityModelWireProfile(wireModelId) {
|
|
|
51
51
|
return ANTIGRAVITY_MODEL_WIRE_PROFILES[wireModelId];
|
|
52
52
|
}
|
|
53
53
|
//#endregion
|
|
54
|
-
export {
|
|
54
|
+
export { getAntigravityUserAgent as n, getGeminiCliHeaders as r, getAntigravityModelWireProfile as t };
|
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { V as ProviderHttpError,
|
|
4
|
-
import { r as getBundledModels } from "./models-
|
|
5
|
-
import {
|
|
3
|
+
import { V as ProviderHttpError, f as OAuthError, g as OnPromptRequiredError, m as LoginCancelledError } from "./error-CORgGg5a.mjs";
|
|
4
|
+
import { r as getBundledModels } from "./models-DnXMYGcJ.mjs";
|
|
5
|
+
import { _ as normalizeCopilotIntegrationId, f as discoverGitHubCopilotApiEndpoint, h as isPublicGitHubHost, o as wrapFetchForCopilotFallback, p as getGitHubCopilotBaseUrl, r as resolveCopilotIntegrationIdOverride, s as COPILOT_API_HEADERS, v as normalizeDomain, y as normalizeGitHubCopilotEnterpriseDomain } from "./github-copilot-headers-DOh1gt_w.mjs";
|
|
6
6
|
import { scheduler } from "node:timers/promises";
|
|
7
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@
|
|
7
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/github-copilot.ts
|
|
8
8
|
/**
|
|
9
|
-
* GitHub Copilot OAuth flow (
|
|
9
|
+
* GitHub Copilot OAuth flow (OpenCode OAuth app, minimal read:user grant).
|
|
10
|
+
*
|
|
11
|
+
* The device flow intentionally uses the OpenCode app identity rather than
|
|
12
|
+
* the official Copilot CLI app: GitHub renders each app's existing per-user
|
|
13
|
+
* grant (Existing access) on the consent page, and Enterprise orgs that
|
|
14
|
+
* restrict OAuth apps block the CLI app's broad historic grant
|
|
15
|
+
* (repo/gist/codespace) no matter what scope this request asks for
|
|
16
|
+
* (issue #11275). API request identity still mimics the Copilot CLI via
|
|
17
|
+
* COPILOT_API_HEADERS. Enterprise domains keep the GitHub-owned Copilot CLI
|
|
18
|
+
* client: private instances run their own OAuth registry and reject the
|
|
19
|
+
* github.com-registered OpenCode client.
|
|
20
|
+
*/
|
|
21
|
+
const OPENCODE_CLIENT_ID = "Ov23li8tweQw6odWQebz";
|
|
22
|
+
const COPILOT_CLI_CLIENT_ID = "Ov23ctDVkRmgkPke0Mmm";
|
|
23
|
+
/**
|
|
24
|
+
* OAuth client for the device flow. Public github.com uses the minimal-grant
|
|
25
|
+
* OpenCode app (narrow consent, issue #11275); private GitHub Enterprise
|
|
26
|
+
* instances run their own OAuth registry, which does not know that github.com
|
|
27
|
+
* registration, so they keep the GitHub-owned Copilot CLI client.
|
|
10
28
|
*/
|
|
11
|
-
|
|
29
|
+
function resolveOAuthClientId(domain) {
|
|
30
|
+
return isPublicGitHubHost(domain) ? OPENCODE_CLIENT_ID : COPILOT_CLI_CLIENT_ID;
|
|
31
|
+
}
|
|
32
|
+
const OAUTH_SCOPE = "read:user";
|
|
33
|
+
const OAUTH_HEADERS = {
|
|
34
|
+
Accept: "application/json",
|
|
35
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
36
|
+
"User-Agent": "copilot-developer-action/0.0.1"
|
|
37
|
+
};
|
|
12
38
|
const INITIAL_POLL_INTERVAL_MULTIPLIER = 1.2;
|
|
13
39
|
const SLOW_DOWN_POLL_INTERVAL_MULTIPLIER = 1.4;
|
|
14
40
|
function getUrls(domain) {
|
|
@@ -28,14 +54,10 @@ async function fetchJson(url, init, fetchImpl) {
|
|
|
28
54
|
async function startDeviceFlow(domain, fetchImpl) {
|
|
29
55
|
const data = await fetchJson(getUrls(domain).deviceCodeUrl, {
|
|
30
56
|
method: "POST",
|
|
31
|
-
headers:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
body: JSON.stringify({
|
|
37
|
-
client_id: CLIENT_ID,
|
|
38
|
-
scope: "read:user"
|
|
57
|
+
headers: OAUTH_HEADERS,
|
|
58
|
+
body: new URLSearchParams({
|
|
59
|
+
client_id: resolveOAuthClientId(domain),
|
|
60
|
+
scope: OAUTH_SCOPE
|
|
39
61
|
})
|
|
40
62
|
}, fetchImpl);
|
|
41
63
|
if (!data || typeof data !== "object") throw new OAuthError("Invalid device code response", {
|
|
@@ -76,13 +98,9 @@ async function pollForGitHubAccessToken(domain, deviceCode, intervalSeconds, exp
|
|
|
76
98
|
}
|
|
77
99
|
const raw = await fetchJson(urls.accessTokenUrl, {
|
|
78
100
|
method: "POST",
|
|
79
|
-
headers:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
...OPENCODE_HEADERS
|
|
83
|
-
},
|
|
84
|
-
body: JSON.stringify({
|
|
85
|
-
client_id: CLIENT_ID,
|
|
101
|
+
headers: OAUTH_HEADERS,
|
|
102
|
+
body: new URLSearchParams({
|
|
103
|
+
client_id: resolveOAuthClientId(domain),
|
|
86
104
|
device_code: deviceCode,
|
|
87
105
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code"
|
|
88
106
|
})
|
|
@@ -117,7 +135,8 @@ async function pollForGitHubAccessToken(domain, deviceCode, intervalSeconds, exp
|
|
|
117
135
|
const FAR_FUTURE_MS = Date.now() + 315576e6;
|
|
118
136
|
/**
|
|
119
137
|
* Refresh GitHub Copilot token.
|
|
120
|
-
*
|
|
138
|
+
* GitHub OAuth tokens from both the OpenCode app and the Copilot CLI app
|
|
139
|
+
* remain directly usable, so existing logins need no token exchange or migration.
|
|
121
140
|
*/
|
|
122
141
|
function refreshGitHubCopilotToken(refreshToken, enterpriseDomain, apiEndpoint) {
|
|
123
142
|
return {
|
|
@@ -128,11 +147,14 @@ function refreshGitHubCopilotToken(refreshToken, enterpriseDomain, apiEndpoint)
|
|
|
128
147
|
apiEndpoint
|
|
129
148
|
};
|
|
130
149
|
}
|
|
150
|
+
async function refreshGitHubCopilotHook(credentials) {
|
|
151
|
+
return refreshGitHubCopilotToken(credentials.refresh, credentials.enterpriseUrl, credentials.apiEndpoint);
|
|
152
|
+
}
|
|
131
153
|
/**
|
|
132
154
|
* Enable a model for the user's GitHub Copilot account.
|
|
133
155
|
* This is required for some models (like Claude, Grok) before they can be used.
|
|
134
156
|
*/
|
|
135
|
-
async function enableGitHubCopilotModel(token, modelId, fetchImpl, enterpriseDomain, apiEndpoint) {
|
|
157
|
+
async function enableGitHubCopilotModel(token, modelId, fetchImpl, enterpriseDomain, apiEndpoint, integrationId) {
|
|
136
158
|
const url = `${apiEndpoint ?? getGitHubCopilotBaseUrl(enterpriseDomain)}/models/${modelId}/policy`;
|
|
137
159
|
try {
|
|
138
160
|
return (await fetchImpl(url, {
|
|
@@ -141,8 +163,10 @@ async function enableGitHubCopilotModel(token, modelId, fetchImpl, enterpriseDom
|
|
|
141
163
|
"Content-Type": "application/json",
|
|
142
164
|
Authorization: `Bearer ${token}`,
|
|
143
165
|
...COPILOT_API_HEADERS,
|
|
144
|
-
"
|
|
145
|
-
"
|
|
166
|
+
"Copilot-Integration-Id": integrationId ?? "copilot-chat",
|
|
167
|
+
"Openai-Intent": "chat-policy",
|
|
168
|
+
"X-Initiator": "user",
|
|
169
|
+
"X-Interaction-Type": "chat-policy"
|
|
146
170
|
},
|
|
147
171
|
body: JSON.stringify({ state: "enabled" })
|
|
148
172
|
})).ok;
|
|
@@ -154,13 +178,15 @@ async function enableGitHubCopilotModel(token, modelId, fetchImpl, enterpriseDom
|
|
|
154
178
|
* Enable all known GitHub Copilot models that may require policy acceptance.
|
|
155
179
|
* Called after successful login to ensure all models are available.
|
|
156
180
|
*/
|
|
157
|
-
async function enableAllGitHubCopilotModels(token, enterpriseDomain, apiEndpoint, fetchImpl, onProgress) {
|
|
181
|
+
async function enableAllGitHubCopilotModels(token, enterpriseDomain, apiEndpoint, fetchImpl, onProgress, integrationId) {
|
|
158
182
|
const wireModelIds = [...new Set(getBundledModels("github-copilot").map((model) => model.requestModelId ?? model.id))];
|
|
183
|
+
const resolvedId = normalizeCopilotIntegrationId(integrationId) ?? resolveCopilotIntegrationIdOverride();
|
|
184
|
+
const copilotFetch = wrapFetchForCopilotFallback(fetchImpl, true, resolvedId);
|
|
159
185
|
const BATCH_SIZE = 5;
|
|
160
186
|
for (let i = 0; i < wireModelIds.length; i += BATCH_SIZE) {
|
|
161
187
|
const batch = wireModelIds.slice(i, i + BATCH_SIZE);
|
|
162
188
|
await Promise.all(batch.map(async (modelId) => {
|
|
163
|
-
const success = await enableGitHubCopilotModel(token, modelId,
|
|
189
|
+
const success = await enableGitHubCopilotModel(token, modelId, copilotFetch, enterpriseDomain, apiEndpoint, resolvedId);
|
|
164
190
|
onProgress?.(modelId, success);
|
|
165
191
|
}));
|
|
166
192
|
}
|
|
@@ -201,8 +227,22 @@ async function loginGitHubCopilot(options) {
|
|
|
201
227
|
apiEndpoint
|
|
202
228
|
};
|
|
203
229
|
options.onProgress?.("Enabling models...");
|
|
204
|
-
await enableAllGitHubCopilotModels(githubAccessToken, enterpriseDomain ?? void 0, apiEndpoint, fetchImpl);
|
|
230
|
+
await enableAllGitHubCopilotModels(githubAccessToken, enterpriseDomain ?? void 0, apiEndpoint, fetchImpl, void 0, options.copilotIntegrationId);
|
|
205
231
|
return credentials;
|
|
206
232
|
}
|
|
233
|
+
async function loginGitHubCopilotHook(callbacks) {
|
|
234
|
+
const onPrompt = callbacks.onPrompt;
|
|
235
|
+
if (!onPrompt) throw new OnPromptRequiredError("GitHub Copilot");
|
|
236
|
+
return loginGitHubCopilot({
|
|
237
|
+
onAuth: (url, instructions) => callbacks.onAuth?.({
|
|
238
|
+
url,
|
|
239
|
+
instructions
|
|
240
|
+
}),
|
|
241
|
+
onPrompt,
|
|
242
|
+
onProgress: callbacks.onProgress,
|
|
243
|
+
signal: callbacks.signal,
|
|
244
|
+
fetch: callbacks.fetch
|
|
245
|
+
});
|
|
246
|
+
}
|
|
207
247
|
//#endregion
|
|
208
|
-
export {
|
|
248
|
+
export { loginGitHubCopilotHook, refreshGitHubCopilotHook };
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { C as warn, N as $env } from "./src-BwW51vA5.mjs";
|
|
4
|
+
import { n as isRecord } from "./type-guards-CttAANEx.mjs";
|
|
5
|
+
import "./utils-DeWqNWV8.mjs";
|
|
6
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@18.1.17/node_modules/@oh-my-pi/pi-catalog/src/wire/github-copilot.ts
|
|
7
|
+
const COPILOT_CLI_USER_AGENT = `copilot/1.0.82`;
|
|
8
|
+
/** Headers sent by Copilot CLI to GitHub API and OAuth endpoints. */
|
|
9
|
+
const COPILOT_GITHUB_HEADERS = { "User-Agent": COPILOT_CLI_USER_AGENT };
|
|
10
|
+
/** Copilot CLI identity sent to the Copilot API. */
|
|
11
|
+
const COPILOT_CAPI_IDENTITY_HEADERS = {
|
|
12
|
+
...COPILOT_GITHUB_HEADERS,
|
|
13
|
+
"Editor-Version": COPILOT_CLI_USER_AGENT,
|
|
14
|
+
"Copilot-Integration-Id": "copilot-developer-cli",
|
|
15
|
+
"Copilot-Harness-Id": "copilot-sdk",
|
|
16
|
+
"Openai-Intent": "conversation-agent"
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Chat-surface identity for Copilot chat and model-policy requests.
|
|
20
|
+
* Some Business organizations gate premium models per client surface and
|
|
21
|
+
* block the CLI identity while allowing chat (issue #11372), so chat traffic
|
|
22
|
+
* defaults to this id with `COPILOT_INTEGRATION_ID` as an explicit pin and a
|
|
23
|
+
* one-shot CLI retry on denial. Model discovery keeps the CLI identity above:
|
|
24
|
+
* it unlocks enterprise/experimental models and listing is not policy-gated
|
|
25
|
+
* the way chat completions are.
|
|
26
|
+
*/
|
|
27
|
+
const COPILOT_CHAT_INTEGRATION_ID = "copilot-chat";
|
|
28
|
+
/**
|
|
29
|
+
* Copilot API version sent on `api.githubcopilot.com` requests (`/models`,
|
|
30
|
+
* chat endpoints). Newer versions unlock tiered context metadata: `/models`
|
|
31
|
+
* reports the full long-context window in `capabilities.limits` plus per-tier
|
|
32
|
+
* boundaries/prices under `billing.token_prices.{default,long_context}`.
|
|
33
|
+
* Without it the endpoint serves default-tier limits only (e.g. 264k instead
|
|
34
|
+
* of 1M for Claude Opus). Never send this to `api.github.com` REST endpoints —
|
|
35
|
+
* they validate `X-GitHub-Api-Version` against the REST version vocabulary.
|
|
36
|
+
*/
|
|
37
|
+
const COPILOT_API_VERSION = "2026-08-01";
|
|
38
|
+
/** Headers shared by Copilot API model requests and model definitions. */
|
|
39
|
+
const COPILOT_API_HEADERS = {
|
|
40
|
+
...COPILOT_CAPI_IDENTITY_HEADERS,
|
|
41
|
+
"X-GitHub-Api-Version": COPILOT_API_VERSION
|
|
42
|
+
};
|
|
43
|
+
/** Copilot CLI headers for user-initiated model discovery. */
|
|
44
|
+
const COPILOT_DISCOVERY_HEADERS = {
|
|
45
|
+
...COPILOT_API_HEADERS,
|
|
46
|
+
"X-Initiator": "user"
|
|
47
|
+
};
|
|
48
|
+
const MANAGED_COPILOT_HEADER_NAMES = {
|
|
49
|
+
"user-agent": true,
|
|
50
|
+
"editor-version": true,
|
|
51
|
+
"copilot-integration-id": true,
|
|
52
|
+
"copilot-harness-id": true,
|
|
53
|
+
"openai-intent": true,
|
|
54
|
+
"x-github-api-version": true,
|
|
55
|
+
"x-initiator": true,
|
|
56
|
+
"x-interaction-type": true
|
|
57
|
+
};
|
|
58
|
+
/** Preserve model-specific headers while enforcing the current Copilot API identity. */
|
|
59
|
+
function mergeCopilotApiHeaders(headers) {
|
|
60
|
+
const merged = {};
|
|
61
|
+
if (headers) for (const name in headers) {
|
|
62
|
+
const value = headers[name];
|
|
63
|
+
if (value !== void 0 && !MANAGED_COPILOT_HEADER_NAMES[name.toLowerCase()]) merged[name] = value;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...merged,
|
|
67
|
+
...COPILOT_API_HEADERS
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Validate an explicit `Copilot-Integration-Id` override.
|
|
72
|
+
* omp identifies as the Copilot CLI (`copilot-developer-cli`); some Business
|
|
73
|
+
* organizations allow Chat clients but block CLI/agentic ones, rejecting every
|
|
74
|
+
* model with HTTP 403 on an otherwise valid token (issue #11372). Callers pass
|
|
75
|
+
* the raw `COPILOT_INTEGRATION_ID` value; blank or CR/LF-bearing values are
|
|
76
|
+
* rejected so the header stays well-formed and the default identity applies.
|
|
77
|
+
*/
|
|
78
|
+
function normalizeCopilotIntegrationId(value) {
|
|
79
|
+
if (typeof value !== "string") return void 0;
|
|
80
|
+
const trimmed = value.trim();
|
|
81
|
+
if (!trimmed || /[\r\n]/.test(trimmed)) return void 0;
|
|
82
|
+
return trimmed;
|
|
83
|
+
}
|
|
84
|
+
const PUBLIC_GITHUB_HOSTS = /* @__PURE__ */ new Set([
|
|
85
|
+
"api.github.com",
|
|
86
|
+
"github.com",
|
|
87
|
+
"www.github.com"
|
|
88
|
+
]);
|
|
89
|
+
function isPublicGitHubHost(host) {
|
|
90
|
+
return PUBLIC_GITHUB_HOSTS.has(host.trim().toLowerCase());
|
|
91
|
+
}
|
|
92
|
+
/** Canonical personal-Copilot API host. */
|
|
93
|
+
const PERSONAL_GITHUB_COPILOT_BASE_URL = "https://api.githubcopilot.com";
|
|
94
|
+
/** `true` when the resolved base URL is the canonical personal-Copilot host. */
|
|
95
|
+
function isPersonalGitHubCopilotBaseUrl(baseUrl) {
|
|
96
|
+
return baseUrl === PERSONAL_GITHUB_COPILOT_BASE_URL;
|
|
97
|
+
}
|
|
98
|
+
function normalizeGitHubCopilotEnterpriseDomain(input) {
|
|
99
|
+
const trimmed = input?.trim();
|
|
100
|
+
if (!trimmed) return void 0;
|
|
101
|
+
const normalized = normalizeDomain(trimmed) ?? trimmed.toLowerCase();
|
|
102
|
+
if (!normalized || isPublicGitHubHost(normalized)) return void 0;
|
|
103
|
+
return normalized;
|
|
104
|
+
}
|
|
105
|
+
function normalizeGitHubCopilotApiEndpoint(input) {
|
|
106
|
+
const trimmed = input?.trim();
|
|
107
|
+
if (!trimmed?.startsWith("https://")) return void 0;
|
|
108
|
+
try {
|
|
109
|
+
const url = new URL(trimmed);
|
|
110
|
+
if (url.protocol !== "https:" || !url.hostname) return void 0;
|
|
111
|
+
return trimmed.replace(/\/+$/, "");
|
|
112
|
+
} catch {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Resolve the plan-specific Copilot API endpoint advertised for a GitHub token.
|
|
118
|
+
* Login and raw environment-token discovery share this best-effort probe. Pass
|
|
119
|
+
* a `signal` to bound it against the same discovery deadline as `/models`; a
|
|
120
|
+
* stalled probe otherwise blocks discovery indefinitely.
|
|
121
|
+
*/
|
|
122
|
+
async function discoverGitHubCopilotApiEndpoint(token, fetchImpl, signal) {
|
|
123
|
+
try {
|
|
124
|
+
const response = await fetchImpl("https://api.github.com/copilot_internal/user", {
|
|
125
|
+
headers: {
|
|
126
|
+
Accept: "application/json",
|
|
127
|
+
Authorization: `token ${token}`,
|
|
128
|
+
...COPILOT_GITHUB_HEADERS
|
|
129
|
+
},
|
|
130
|
+
signal
|
|
131
|
+
});
|
|
132
|
+
if (!response.ok) return void 0;
|
|
133
|
+
const data = await response.json();
|
|
134
|
+
if (!isRecord(data) || !isRecord(data.endpoints)) return void 0;
|
|
135
|
+
const endpoint = data.endpoints.api;
|
|
136
|
+
return typeof endpoint === "string" ? normalizeGitHubCopilotApiEndpoint(endpoint) : void 0;
|
|
137
|
+
} catch {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function parseGitHubCopilotApiKey(apiKeyRaw) {
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(apiKeyRaw);
|
|
144
|
+
if (typeof parsed.token === "string") return {
|
|
145
|
+
accessToken: parsed.token,
|
|
146
|
+
enterpriseUrl: typeof parsed.enterpriseUrl === "string" ? normalizeGitHubCopilotEnterpriseDomain(parsed.enterpriseUrl) : void 0,
|
|
147
|
+
apiEndpoint: typeof parsed.apiEndpoint === "string" ? normalizeGitHubCopilotApiEndpoint(parsed.apiEndpoint) : void 0
|
|
148
|
+
};
|
|
149
|
+
} catch {}
|
|
150
|
+
return { accessToken: apiKeyRaw };
|
|
151
|
+
}
|
|
152
|
+
function normalizeDomain(input) {
|
|
153
|
+
const trimmed = input.trim();
|
|
154
|
+
if (!trimmed) return null;
|
|
155
|
+
try {
|
|
156
|
+
return (trimmed.includes("://") ? new URL(trimmed) : new URL(`https://${trimmed}`)).hostname;
|
|
157
|
+
} catch {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function getGitHubCopilotBaseUrl(enterpriseDomain) {
|
|
162
|
+
const normalizedEnterpriseDomain = normalizeGitHubCopilotEnterpriseDomain(enterpriseDomain);
|
|
163
|
+
if (!normalizedEnterpriseDomain) return "https://api.githubcopilot.com";
|
|
164
|
+
return `https://${normalizedEnterpriseDomain.startsWith("copilot-api.") ? normalizedEnterpriseDomain : `copilot-api.${normalizedEnterpriseDomain}`}`;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/providers/github-copilot-headers.ts
|
|
168
|
+
function resolveGitHubCopilotBaseUrl(baseUrl, apiKey) {
|
|
169
|
+
if (!apiKey) return baseUrl;
|
|
170
|
+
const { enterpriseUrl, apiEndpoint } = parseGitHubCopilotApiKey(apiKey);
|
|
171
|
+
if (apiEndpoint && (!baseUrl || baseUrl.includes("githubcopilot.com"))) return apiEndpoint;
|
|
172
|
+
if (!enterpriseUrl) return baseUrl;
|
|
173
|
+
if (baseUrl && !baseUrl.includes("githubcopilot.com")) return baseUrl;
|
|
174
|
+
return getGitHubCopilotBaseUrl(enterpriseUrl);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Opt-in `Copilot-Integration-Id` override for chat and model-policy requests.
|
|
178
|
+
* Reads `COPILOT_INTEGRATION_ID`; unset/invalid keeps the chat-surface default
|
|
179
|
+
* (`COPILOT_CHAT_INTEGRATION_ID`). Model discovery keeps the CLI identity: it
|
|
180
|
+
* unlocks enterprise/experimental models and listing models is not
|
|
181
|
+
* policy-gated the way chat completions are (#11372).
|
|
182
|
+
*/
|
|
183
|
+
function resolveCopilotIntegrationIdOverride(env = $env) {
|
|
184
|
+
return normalizeCopilotIntegrationId(env.COPILOT_INTEGRATION_ID);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Explicit caller-supplied `Copilot-Integration-Id`, matched case-insensitively.
|
|
188
|
+
* Takes only caller layers (`extraHeaders` / `options.headers`) — never model
|
|
189
|
+
* catalog headers — so a catalog default can never masquerade as a choice.
|
|
190
|
+
*/
|
|
191
|
+
function explicitCopilotIntegrationId(headers) {
|
|
192
|
+
if (!headers) return void 0;
|
|
193
|
+
for (const name of Object.keys(headers)) if (name.toLowerCase() === "copilot-integration-id") return headers[name];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Effective identity before the chat-surface default: explicit value, then
|
|
197
|
+
* request headers, then `COPILOT_INTEGRATION_ID`. Pure given its inputs, so
|
|
198
|
+
* tests inject literals instead of mutating process state.
|
|
199
|
+
*/
|
|
200
|
+
function resolveCopilotRequestIdentity(headers, explicit, env = $env) {
|
|
201
|
+
return normalizeCopilotIntegrationId(explicit) ?? normalizeCopilotIntegrationId(explicitCopilotIntegrationId(headers)) ?? resolveCopilotIntegrationIdOverride(env);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Reissue chat-surface Copilot 403s once as the Copilot CLI.
|
|
205
|
+
*
|
|
206
|
+
* Chat is the default surface (`COPILOT_CHAT_INTEGRATION_ID`) because Business
|
|
207
|
+
* organizations that gate premium models per client surface commonly allow
|
|
208
|
+
* chat while blocking CLI/agentic clients (issue #11372). The retry fires
|
|
209
|
+
* only for requests carrying the chat default and only when the caller
|
|
210
|
+
* resolved no explicit identity — an explicit choice is never second-guessed.
|
|
211
|
+
* The denied body is drained before reissuing, and the retry carries the CLI
|
|
212
|
+
* identity so the guard passes it through: at most two requests, never a loop.
|
|
213
|
+
*/
|
|
214
|
+
function wrapFetchForCopilotFallback(base, enabled, integrationId) {
|
|
215
|
+
const inner = base ?? fetch;
|
|
216
|
+
if (!enabled) return inner;
|
|
217
|
+
return async (input, init) => {
|
|
218
|
+
const response = await inner(input, init);
|
|
219
|
+
if (response.status !== 403) return response;
|
|
220
|
+
if (input instanceof Request) return response;
|
|
221
|
+
if (normalizeCopilotIntegrationId(integrationId) !== void 0) return response;
|
|
222
|
+
const outgoing = new Headers(init?.headers);
|
|
223
|
+
if (outgoing.get("Copilot-Integration-Id") !== "copilot-chat") return response;
|
|
224
|
+
try {
|
|
225
|
+
await response.arrayBuffer();
|
|
226
|
+
} catch {}
|
|
227
|
+
warn("GitHub Copilot chat identity denied (HTTP 403); retrying once as the Copilot CLI");
|
|
228
|
+
const retryHeaders = new Headers(outgoing);
|
|
229
|
+
retryHeaders.set("Copilot-Integration-Id", COPILOT_CAPI_IDENTITY_HEADERS["Copilot-Integration-Id"]);
|
|
230
|
+
return inner(input, {
|
|
231
|
+
...init,
|
|
232
|
+
headers: retryHeaders
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function inferCopilotInitiator(messages) {
|
|
237
|
+
if (messages.length === 0) return "user";
|
|
238
|
+
const last = messages[messages.length - 1];
|
|
239
|
+
const attribution = last.attribution;
|
|
240
|
+
if (typeof attribution === "string") {
|
|
241
|
+
const normalizedAttribution = attribution.trim().toLowerCase();
|
|
242
|
+
if (normalizedAttribution === "user" || normalizedAttribution === "agent") return normalizedAttribution;
|
|
243
|
+
}
|
|
244
|
+
const role = last.role;
|
|
245
|
+
if (!role) return "user";
|
|
246
|
+
if (role !== "user") return "agent";
|
|
247
|
+
const content = last.content;
|
|
248
|
+
if (Array.isArray(content) && content.length > 0) {
|
|
249
|
+
if (content[content.length - 1].type === "tool_result") return "agent";
|
|
250
|
+
}
|
|
251
|
+
return "user";
|
|
252
|
+
}
|
|
253
|
+
/** Check whether any message in the conversation contains image content. */
|
|
254
|
+
function hasCopilotVisionInput(messages) {
|
|
255
|
+
return messages.some((msg) => {
|
|
256
|
+
if (msg.role === "user" && Array.isArray(msg.content)) return msg.content.some((c) => c.type === "image");
|
|
257
|
+
if (msg.role === "toolResult" && Array.isArray(msg.content)) return msg.content.some((c) => c.type === "image");
|
|
258
|
+
return false;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Resolve an explicitly configured Copilot initiator header, if present.
|
|
263
|
+
* Handles case-insensitive X-Initiator keys and returns the last valid value.
|
|
264
|
+
*/
|
|
265
|
+
function getCopilotInitiatorOverride(headers) {
|
|
266
|
+
if (!headers) return void 0;
|
|
267
|
+
let override;
|
|
268
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
269
|
+
if (key.toLowerCase() !== "x-initiator") continue;
|
|
270
|
+
const normalized = value.trim().toLowerCase();
|
|
271
|
+
if (normalized === "user" || normalized === "agent") override = normalized;
|
|
272
|
+
}
|
|
273
|
+
return override;
|
|
274
|
+
}
|
|
275
|
+
function normalizeCopilotPlanTier(planTier) {
|
|
276
|
+
if (planTier === "paid") return "paid";
|
|
277
|
+
return "free";
|
|
278
|
+
}
|
|
279
|
+
function getCopilotPremiumMultiplier(premiumMultiplier, planTier) {
|
|
280
|
+
const normalizedMultiplier = premiumMultiplier ?? 1;
|
|
281
|
+
if (normalizeCopilotPlanTier(planTier) === "free" && normalizedMultiplier === 0) return 1;
|
|
282
|
+
return normalizedMultiplier;
|
|
283
|
+
}
|
|
284
|
+
function getCopilotPremiumRequests(params) {
|
|
285
|
+
if (params.initiator === "agent") return 0;
|
|
286
|
+
return getCopilotPremiumMultiplier(params.premiumMultiplier, params.planTier);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Build dynamic Copilot headers that vary per-request.
|
|
290
|
+
* Static headers (User-Agent, Editor-Version, etc.) come from model.headers.
|
|
291
|
+
*/
|
|
292
|
+
function buildCopilotDynamicHeaders(params) {
|
|
293
|
+
const initiator = params.initiatorOverride ?? getCopilotInitiatorOverride(params.headers) ?? inferCopilotInitiator(params.messages);
|
|
294
|
+
const headers = {
|
|
295
|
+
...COPILOT_CAPI_IDENTITY_HEADERS,
|
|
296
|
+
"X-Initiator": initiator,
|
|
297
|
+
"X-Interaction-Type": `conversation-${initiator}`
|
|
298
|
+
};
|
|
299
|
+
headers["Copilot-Integration-Id"] = normalizeCopilotIntegrationId(params.integrationId) ?? "copilot-chat";
|
|
300
|
+
if (params.hasImages) headers["Copilot-Vision-Request"] = "true";
|
|
301
|
+
return {
|
|
302
|
+
headers,
|
|
303
|
+
initiator,
|
|
304
|
+
premiumRequests: getCopilotPremiumRequests({
|
|
305
|
+
initiator,
|
|
306
|
+
premiumMultiplier: params.premiumMultiplier,
|
|
307
|
+
planTier: params.planTier
|
|
308
|
+
})
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
export { normalizeCopilotIntegrationId as _, resolveGitHubCopilotBaseUrl as a, parseGitHubCopilotApiKey as b, COPILOT_CHAT_INTEGRATION_ID as c, PERSONAL_GITHUB_COPILOT_BASE_URL as d, discoverGitHubCopilotApiEndpoint as f, mergeCopilotApiHeaders as g, isPublicGitHubHost as h, resolveCopilotRequestIdentity as i, COPILOT_DISCOVERY_HEADERS as l, isPersonalGitHubCopilotBaseUrl as m, hasCopilotVisionInput as n, wrapFetchForCopilotFallback as o, getGitHubCopilotBaseUrl as p, resolveCopilotIntegrationIdOverride as r, COPILOT_API_HEADERS as s, buildCopilotDynamicHeaders as t, COPILOT_GITHUB_HEADERS as u, normalizeDomain as v, normalizeGitHubCopilotEnterpriseDomain as y };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { i as clearGitLabDuoDirectAccessCache } from "./stream-B_7qN-bA.mjs";
|
|
4
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/gitlab-duo.ts
|
|
5
|
+
/** GitLab Duo OAuth residue: invalidate direct-access credentials after token rotation. */
|
|
6
|
+
const gitLabDuoClearCacheHook = async (credentials) => {
|
|
7
|
+
clearGitLabDuoDirectAccessCache();
|
|
8
|
+
return credentials;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { gitLabDuoClearCacheHook };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { h as MissingApiKeyError } from "./error-CORgGg5a.mjs";
|
|
4
|
+
import { Ct as applyInferenceHeaders, n as getEnvApiKey } from "./stream-B_7qN-bA.mjs";
|
|
5
|
+
import { p as streamGoogleGenAI, t as buildGoogleGenerateContentParams } from "./google-shared-B0aNCYEH.mjs";
|
|
6
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/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
|
+
const params = buildGoogleGenerateContentParams(model, context, options ?? {});
|
|
17
|
+
const url = `${model.baseUrl?.trim() || DEFAULT_GENERATIVE_LANGUAGE_BASE}/models/${model.id}:streamGenerateContent?alt=sse`;
|
|
18
|
+
const headers = {
|
|
19
|
+
"x-goog-api-key": apiKey,
|
|
20
|
+
...model.headers,
|
|
21
|
+
...options?.headers
|
|
22
|
+
};
|
|
23
|
+
applyInferenceHeaders(headers, {
|
|
24
|
+
provider: model.provider,
|
|
25
|
+
protocol: "google",
|
|
26
|
+
sessionId: options?.sessionId ?? options?.promptCacheKey
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
params,
|
|
30
|
+
url,
|
|
31
|
+
headers,
|
|
32
|
+
fetch: options?.fetch
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { streamGoogle };
|