@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.
- package/README.md +1 -1
- 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-CE_qK1yk.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-APrc-TBB.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 +43 -41
- package/presets/package.json +1 -1
- package/presets/tool-plus-ptc/agent.cordis.yml +13 -4
- package/presets/tool-plus-standard/agent.cordis.yml +11 -3
- 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,262 +0,0 @@
|
|
|
1
|
-
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
-
__installBunShim();
|
|
3
|
-
import { r as __exportAll } from "./fs-promises-shim-Bx0fpxuk.mjs";
|
|
4
|
-
import { V as ProviderHttpError, c as OAuthError } from "./error-C-f_Wnw4.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/providers/claude-code-fingerprint.ts
|
|
8
|
-
/**
|
|
9
|
-
* Cowork inference-fingerprint constants, kept in a leaf module so consumers
|
|
10
|
-
* outside the provider (`registry/oauth/anthropic`, `usage/claude`) don't
|
|
11
|
-
* import the heavy `providers/anthropic` module.
|
|
12
|
-
*
|
|
13
|
-
* That import edge was a live init cycle: `providers/anthropic` → `stream` →
|
|
14
|
-
* `registry` → `registry/oauth/anthropic` → back into the still-initializing
|
|
15
|
-
* provider module.
|
|
16
|
-
*/
|
|
17
|
-
/** Claude runtime version bundled by the current Cowork desktop release. */
|
|
18
|
-
const claudeCodeVersion = "2.1.220";
|
|
19
|
-
/** User-Agent emitted by Cowork's `claude-desktop` inference entrypoint. */
|
|
20
|
-
const coworkUserAgent = `claude-cli/${claudeCodeVersion} (external, claude-desktop)`;
|
|
21
|
-
/** Identity block prepended by Cowork's Claude runtime. */
|
|
22
|
-
const claudeCodeSystemInstruction = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
|
|
23
|
-
/** Cowork's per-request output-token ceiling. */
|
|
24
|
-
const CLAUDE_CODE_MAX_OUTPUT_TOKENS = 64e3;
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/anthropic.ts
|
|
27
|
-
/**
|
|
28
|
-
* Anthropic OAuth flow (Claude Pro/Max)
|
|
29
|
-
*/
|
|
30
|
-
var anthropic_exports = /* @__PURE__ */ __exportAll({
|
|
31
|
-
ANTHROPIC_OAUTH_GRANT_TTL_MS: () => ANTHROPIC_OAUTH_GRANT_TTL_MS,
|
|
32
|
-
AnthropicOAuthFlow: () => AnthropicOAuthFlow,
|
|
33
|
-
loginAnthropic: () => loginAnthropic,
|
|
34
|
-
refreshAnthropicToken: () => refreshAnthropicToken
|
|
35
|
-
});
|
|
36
|
-
const decode = (s) => atob(s);
|
|
37
|
-
const CLIENT_ID = decode("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
|
|
38
|
-
const AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
|
|
39
|
-
const TOKEN_URL = "https://api.anthropic.com/v1/oauth/token";
|
|
40
|
-
const BOOTSTRAP_URL = "https://api.anthropic.com/api/claude_cli/bootstrap";
|
|
41
|
-
const CLAUDE_CODE_BOOTSTRAP_MODEL = "claude-opus-4-8";
|
|
42
|
-
const CLAUDE_CODE_BOOTSTRAP_USER_AGENT = `claude-code/${claudeCodeVersion}`;
|
|
43
|
-
const CALLBACK_PORT = 54545;
|
|
44
|
-
const CALLBACK_PATH = "/callback";
|
|
45
|
-
const SCOPES = "org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";
|
|
46
|
-
function formatErrorDetails(error) {
|
|
47
|
-
if (error instanceof Error) {
|
|
48
|
-
const details = [`${error.name}: ${error.message}`];
|
|
49
|
-
const errorWithCode = error;
|
|
50
|
-
if (errorWithCode.code) details.push(`code=${errorWithCode.code}`);
|
|
51
|
-
if (typeof errorWithCode.errno !== "undefined") details.push(`errno=${String(errorWithCode.errno)}`);
|
|
52
|
-
if (typeof error.cause !== "undefined") details.push(`cause=${formatErrorDetails(error.cause)}`);
|
|
53
|
-
if (error.stack) details.push(`stack=${error.stack}`);
|
|
54
|
-
return details.join("; ");
|
|
55
|
-
}
|
|
56
|
-
return String(error);
|
|
57
|
-
}
|
|
58
|
-
async function postJson(url, body, fetchImpl, extraHeaders) {
|
|
59
|
-
const response = await fetchImpl(url, {
|
|
60
|
-
method: "POST",
|
|
61
|
-
headers: {
|
|
62
|
-
...extraHeaders,
|
|
63
|
-
"Content-Type": "application/json"
|
|
64
|
-
},
|
|
65
|
-
body: JSON.stringify(body),
|
|
66
|
-
signal: AbortSignal.timeout(3e4)
|
|
67
|
-
});
|
|
68
|
-
const responseBody = await response.text();
|
|
69
|
-
if (!response.ok) throw new ProviderHttpError(`HTTP request failed. status=${response.status}; url=${url}; body=${responseBody}`, response.status);
|
|
70
|
-
return responseBody;
|
|
71
|
-
}
|
|
72
|
-
function nonEmpty(value) {
|
|
73
|
-
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
74
|
-
}
|
|
75
|
-
function parseOAuthTokenResponse(responseBody, operation) {
|
|
76
|
-
try {
|
|
77
|
-
return JSON.parse(responseBody);
|
|
78
|
-
} catch (error) {
|
|
79
|
-
throw new OAuthError(`Anthropic ${operation} returned invalid JSON. url=${TOKEN_URL}; body=${responseBody}; details=${formatErrorDetails(error)}`, {
|
|
80
|
-
kind: "validation",
|
|
81
|
-
provider: "anthropic",
|
|
82
|
-
cause: error
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Lift the OAuth response's `account: { uuid, email_address }` and
|
|
88
|
-
* `organization: { uuid, name }` blocks onto {@link OAuthCredentials} so
|
|
89
|
-
* downstream identity propagation (e.g. `metadata.user_id.account_uuid`,
|
|
90
|
-
* usage tracking, org-scoped credential identity) works without a separate
|
|
91
|
-
* `/api/oauth/profile` round-trip. Returns `undefined` for any field the
|
|
92
|
-
* response omits or carries as a non-string / empty value.
|
|
93
|
-
*/
|
|
94
|
-
function extractAccountFromTokenResponse(data) {
|
|
95
|
-
return {
|
|
96
|
-
accountId: nonEmpty(data.account?.uuid),
|
|
97
|
-
email: nonEmpty(data.account?.email_address),
|
|
98
|
-
orgId: nonEmpty(data.organization?.uuid),
|
|
99
|
-
orgName: nonEmpty(data.organization?.name)
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
async function fetchBootstrapIdentity(accessToken, fetchImpl) {
|
|
103
|
-
const url = `${BOOTSTRAP_URL}?entrypoint=cli&model=${encodeURIComponent(CLAUDE_CODE_BOOTSTRAP_MODEL)}`;
|
|
104
|
-
const response = await fetchImpl(url, {
|
|
105
|
-
method: "GET",
|
|
106
|
-
headers: {
|
|
107
|
-
Accept: "application/json, text/plain, */*",
|
|
108
|
-
Authorization: `Bearer ${accessToken}`,
|
|
109
|
-
"Content-Type": "application/json",
|
|
110
|
-
"User-Agent": CLAUDE_CODE_BOOTSTRAP_USER_AGENT,
|
|
111
|
-
"anthropic-beta": "oauth-2025-04-20"
|
|
112
|
-
},
|
|
113
|
-
signal: AbortSignal.timeout(3e4)
|
|
114
|
-
});
|
|
115
|
-
const responseBody = await response.text();
|
|
116
|
-
if (!response.ok) throw new ProviderHttpError(`HTTP request failed. status=${response.status}; url=${url}; body=${responseBody}`, response.status);
|
|
117
|
-
let data;
|
|
118
|
-
try {
|
|
119
|
-
data = JSON.parse(responseBody);
|
|
120
|
-
} catch (error) {
|
|
121
|
-
throw new OAuthError(`Anthropic bootstrap returned invalid JSON. url=${url}; body=${responseBody}; details=${formatErrorDetails(error)}`, {
|
|
122
|
-
kind: "validation",
|
|
123
|
-
provider: "anthropic",
|
|
124
|
-
cause: error
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
accountId: nonEmpty(data.oauth_account?.account_uuid),
|
|
129
|
-
email: nonEmpty(data.oauth_account?.account_email),
|
|
130
|
-
orgId: nonEmpty(data.oauth_account?.organization_uuid),
|
|
131
|
-
orgName: nonEmpty(data.oauth_account?.organization_name)
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Resolve account (and optionally organization) identity for a token
|
|
136
|
-
* response. `includeOrg` is login-only: the org an access token is scoped to
|
|
137
|
-
* is captured once when the credential is created and deliberately never
|
|
138
|
-
* refreshed afterwards — rewriting identity during background token
|
|
139
|
-
* refreshes could silently re-key stored credentials.
|
|
140
|
-
*/
|
|
141
|
-
async function resolveAccountIdentity(data, fetchImpl, options) {
|
|
142
|
-
const identity = extractAccountFromTokenResponse(data);
|
|
143
|
-
const orgSatisfied = !options?.includeOrg || identity.orgId !== void 0;
|
|
144
|
-
if (identity.accountId && identity.email && orgSatisfied) return identity;
|
|
145
|
-
try {
|
|
146
|
-
const bootstrap = await fetchBootstrapIdentity(data.access_token, fetchImpl);
|
|
147
|
-
return {
|
|
148
|
-
accountId: identity.accountId ?? bootstrap.accountId,
|
|
149
|
-
email: identity.email ?? bootstrap.email,
|
|
150
|
-
orgId: identity.orgId ?? bootstrap.orgId,
|
|
151
|
-
orgName: identity.orgName ?? bootstrap.orgName
|
|
152
|
-
};
|
|
153
|
-
} catch {
|
|
154
|
-
return identity;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
var AnthropicOAuthFlow = class extends OAuthCallbackFlow {
|
|
158
|
-
#verifier = "";
|
|
159
|
-
#challenge = "";
|
|
160
|
-
#fetch;
|
|
161
|
-
constructor(ctrl) {
|
|
162
|
-
super(ctrl, CALLBACK_PORT, CALLBACK_PATH);
|
|
163
|
-
this.#fetch = ctrl.fetch ?? fetch;
|
|
164
|
-
}
|
|
165
|
-
async generateAuthUrl(state, redirectUri) {
|
|
166
|
-
const pkce = await generatePKCE();
|
|
167
|
-
this.#verifier = pkce.verifier;
|
|
168
|
-
this.#challenge = pkce.challenge;
|
|
169
|
-
const authParams = new URLSearchParams({
|
|
170
|
-
code: "true",
|
|
171
|
-
client_id: CLIENT_ID,
|
|
172
|
-
response_type: "code",
|
|
173
|
-
redirect_uri: redirectUri,
|
|
174
|
-
scope: SCOPES,
|
|
175
|
-
code_challenge: this.#challenge,
|
|
176
|
-
code_challenge_method: "S256",
|
|
177
|
-
state
|
|
178
|
-
});
|
|
179
|
-
return {
|
|
180
|
-
url: `${AUTHORIZE_URL}?${authParams.toString()}`,
|
|
181
|
-
instructions: "Complete login in your browser. If the browser cannot reach this machine, paste the final redirect URL or authorization code when prompted."
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
async exchangeToken(code, state, redirectUri) {
|
|
185
|
-
let exchangeCode = code;
|
|
186
|
-
let exchangeState = state;
|
|
187
|
-
const codeFragmentIndex = code.indexOf("#");
|
|
188
|
-
if (codeFragmentIndex >= 0) {
|
|
189
|
-
exchangeCode = code.slice(0, codeFragmentIndex);
|
|
190
|
-
const codeFragmentState = code.slice(codeFragmentIndex + 1);
|
|
191
|
-
if (codeFragmentState.length > 0) exchangeState = codeFragmentState;
|
|
192
|
-
}
|
|
193
|
-
let responseBody;
|
|
194
|
-
try {
|
|
195
|
-
responseBody = await postJson(TOKEN_URL, {
|
|
196
|
-
grant_type: "authorization_code",
|
|
197
|
-
client_id: CLIENT_ID,
|
|
198
|
-
code: exchangeCode,
|
|
199
|
-
state: exchangeState,
|
|
200
|
-
redirect_uri: redirectUri,
|
|
201
|
-
code_verifier: this.#verifier
|
|
202
|
-
}, this.#fetch);
|
|
203
|
-
} catch (error) {
|
|
204
|
-
throw new OAuthError(`Token exchange request failed. url=${TOKEN_URL}; redirect_uri=${redirectUri}; response_type=authorization_code; details=${formatErrorDetails(error)}`, {
|
|
205
|
-
kind: "token-exchange",
|
|
206
|
-
provider: "anthropic",
|
|
207
|
-
cause: error
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
const tokenData = parseOAuthTokenResponse(responseBody, "token exchange");
|
|
211
|
-
const { accountId, email, orgId, orgName } = await resolveAccountIdentity(tokenData, this.#fetch, { includeOrg: true });
|
|
212
|
-
return {
|
|
213
|
-
refresh: tokenData.refresh_token,
|
|
214
|
-
access: tokenData.access_token,
|
|
215
|
-
expires: Date.now() + tokenData.expires_in * 1e3 - 3e5,
|
|
216
|
-
accountId,
|
|
217
|
-
email,
|
|
218
|
-
orgId,
|
|
219
|
-
orgName
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* Login with Anthropic OAuth
|
|
225
|
-
*/
|
|
226
|
-
async function loginAnthropic(ctrl) {
|
|
227
|
-
return new AnthropicOAuthFlow(ctrl).login();
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Refresh Anthropic OAuth token
|
|
231
|
-
*/
|
|
232
|
-
async function refreshAnthropicToken(refreshToken, fetchOverride) {
|
|
233
|
-
const fetchImpl = fetchOverride ?? fetch;
|
|
234
|
-
let responseBody;
|
|
235
|
-
try {
|
|
236
|
-
responseBody = await postJson(TOKEN_URL, {
|
|
237
|
-
grant_type: "refresh_token",
|
|
238
|
-
client_id: CLIENT_ID,
|
|
239
|
-
refresh_token: refreshToken
|
|
240
|
-
}, fetchImpl, {
|
|
241
|
-
"anthropic-beta": "oauth-2025-04-20",
|
|
242
|
-
"User-Agent": "anthropic-sdk-typescript/0.94.0 userOAuthProvider"
|
|
243
|
-
});
|
|
244
|
-
} catch (error) {
|
|
245
|
-
throw new OAuthError(`Anthropic token refresh request failed. url=${TOKEN_URL}; details=${formatErrorDetails(error)}`, {
|
|
246
|
-
kind: "token-refresh",
|
|
247
|
-
provider: "anthropic",
|
|
248
|
-
cause: error
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
const data = parseOAuthTokenResponse(responseBody, "token refresh");
|
|
252
|
-
const { accountId, email } = await resolveAccountIdentity(data, fetchImpl);
|
|
253
|
-
return {
|
|
254
|
-
refresh: data.refresh_token || refreshToken,
|
|
255
|
-
access: data.access_token,
|
|
256
|
-
expires: Date.now() + data.expires_in * 1e3 - 3e5,
|
|
257
|
-
accountId,
|
|
258
|
-
email
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
//#endregion
|
|
262
|
-
export { coworkUserAgent as a, claudeCodeVersion as i, CLAUDE_CODE_MAX_OUTPUT_TOKENS as n, claudeCodeSystemInstruction as r, anthropic_exports as t };
|