@xiaoso/dsh-tool-plus 0.1.0-beta.2 → 0.1.0-beta.3
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.en.md +122 -0
- package/README.md +3 -2
- package/THIRD_PARTY_NOTICES.md +4 -35
- package/lib/abort-B7izMMna.mjs +51 -0
- package/lib/amazon-bedrock-D-shAr1X.mjs +917 -0
- package/lib/anthropic-BWsZFzU8.mjs +262 -0
- package/lib/anthropic-CMT1Qj1t.mjs +3115 -0
- package/lib/api-key-login-CpzSezsi.mjs +157 -0
- package/lib/aws-credentials-8Mgn5MAy.mjs +867 -0
- package/lib/azure-openai-responses-CNkHiLUh.mjs +274 -0
- package/lib/bun-shim.mjs +172 -7
- package/lib/bundled-references-CSuBco5p.mjs +55 -0
- package/lib/callback-server-BEFNf-jf.mjs +398 -0
- package/lib/client.js +110 -40
- package/lib/cursor-BIQfBC6V.mjs +135 -0
- package/lib/cursor-DNk6eXDd.mjs +5470 -0
- package/lib/cursor-MjSm74IJ.mjs +273 -0
- package/lib/device-code-OI_tQcmc.mjs +51 -0
- package/lib/devin-CldyPD8K.mjs +95 -0
- package/lib/devin-CzRpTUOA.mjs +114 -0
- package/lib/devin-DXOeNyU7.mjs +542 -0
- package/lib/error-B3bevhrs.mjs +1449 -0
- package/lib/event-stream-BDPi64mK.mjs +151 -0
- package/lib/github-copilot-4GaMtQmg.mjs +208 -0
- package/lib/github-copilot-B2HGSIJK.mjs +104 -0
- package/lib/gitlab-duo-akICyfeD.mjs +155 -0
- package/lib/gitlab-duo-workflow-CSEgYk3N.mjs +91 -0
- package/lib/google-antigravity-Dlkdhahq.mjs +198 -0
- package/lib/google-auth-DhqpOYrX.mjs +232 -0
- package/lib/google-gemini-cli-BG_LRdIV.mjs +850 -0
- package/lib/google-gemini-cli-zJhiOcND.mjs +211 -0
- package/lib/google-oauth-shared-CwNWYdmR.mjs +147 -0
- package/lib/google-shared-DzhCb9b0.mjs +760 -0
- package/lib/google-vertex-kscbkyRb.mjs +99 -0
- package/lib/google-zyDOG9x7.mjs +30 -0
- package/lib/identity-DnB63pS7.mjs +219 -0
- package/lib/idle-iterator-C6XbWcuB.mjs +366 -0
- package/lib/index.mjs +2865 -2745
- package/lib/kimi-DMVI-zrZ.mjs +236 -0
- package/lib/markit-M0jhziqU.mjs +1417 -0
- package/lib/minimax-code-BK-3eBbz.mjs +53 -0
- package/lib/models-CfT4coYT.mjs +104660 -0
- package/lib/ollama-BQMGPxtV.mjs +589 -0
- package/lib/openai-codex-CQL_kvYL.mjs +255 -0
- package/lib/openai-codex-responses-Cz-2qpC7.mjs +3144 -0
- package/lib/openai-completions-i8doczAk.mjs +1360 -0
- package/lib/openai-reasoning-fallback-DGVVLgd1.mjs +286 -0
- package/lib/openai-responses-DTkBiiy-.mjs +867 -0
- package/lib/opencode-DaJjcUbf.mjs +38 -0
- package/lib/perplexity-9b-RQ0mV.mjs +194 -0
- package/lib/proxy-ZtUcl6r5.mjs +190 -0
- package/lib/scrapers-CL-WgdU1.mjs +9198 -0
- package/lib/scrapers-CipyKyCH.mjs +9198 -0
- package/lib/scrapers-DGfrYhtw.mjs +9198 -0
- package/lib/scrapers-DSUPYoUF.mjs +9198 -0
- package/lib/scrapers-DZ2GXmp7.mjs +9198 -0
- package/lib/src-DTid0g4K.mjs +5001 -0
- package/lib/stream-C_RAoxJC.mjs +10236 -0
- package/lib/stream-markup-healing-2toHXWXM.mjs +491 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/config/fields.d.ts +1 -1
- package/lib/types/config/settings.d.ts +16 -2
- package/lib/types/tools/omp/sdk.d.ts +6 -0
- package/lib/types/tools/omp/tools/fetch.d.ts +2 -0
- package/lib/types/tools/omp/tools/read.d.ts +2 -8
- package/lib/types/tools/omp/utils/image-loading.d.ts +10 -36
- package/lib/types/tools/read/adapter/index.d.ts +4 -1
- package/lib/types/tools/read-image/index.d.ts +4 -0
- package/lib/types/tools/shared/bun-shim.d.ts +35 -3
- package/lib/types/tools/shared/image-bridge.d.ts +98 -0
- package/lib/types/tools/shared/omp-prompt.d.ts +4 -2
- package/lib/utils-2Wq2eATG.mjs +8119 -0
- package/lib/utils-BnX8O3vi.mjs +12303 -0
- package/lib/utils-CE8N8P4Q.mjs +12315 -0
- package/lib/utils-C_MrQ_0z.mjs +12301 -0
- package/lib/utils-D0Z1fyoO.mjs +12299 -0
- package/lib/utils-DppGHXQB.mjs +51 -0
- package/lib/utils-W8WdSBpX.mjs +12315 -0
- package/lib/vision-guard-BDD4OrKo.mjs +92 -0
- package/lib/wafer-DRU0EjZX.mjs +17 -0
- package/lib/xai-oauth-DPHDXKD7.mjs +446 -0
- package/lib/xiaomi-Dd87KSg5.mjs +157 -0
- package/lib/zai-CFeOt-53.mjs +203 -0
- package/lib/zip-D6QXpvaJ.mjs +1316 -0
- package/package.json +14 -10
- package/presets/package.json +1 -1
- package/presets/tool-plus-ptc/preset.yml +1 -1
- package/presets/tool-plus-standard/preset.yml +1 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
import { r as __exportAll } from "./fs-promises-shim-B-9cMxz5.mjs";
|
|
4
|
+
import { c as OAuthError } from "./error-B3bevhrs.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/cursor.ts
|
|
7
|
+
var cursor_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
extractCursorAccessTokenUserId: () => extractCursorAccessTokenUserId,
|
|
9
|
+
generateCursorAuthParams: () => generateCursorAuthParams,
|
|
10
|
+
loginCursor: () => loginCursor,
|
|
11
|
+
pollCursorAuth: () => pollCursorAuth,
|
|
12
|
+
refreshCursorToken: () => refreshCursorToken
|
|
13
|
+
});
|
|
14
|
+
const CURSOR_LOGIN_URL = "https://cursor.com/loginDeepControl";
|
|
15
|
+
const CURSOR_POLL_URL = "https://api2.cursor.sh/auth/poll";
|
|
16
|
+
const CURSOR_REFRESH_URL = "https://api2.cursor.sh/auth/exchange_user_api_key";
|
|
17
|
+
const POLL_MAX_ATTEMPTS = 150;
|
|
18
|
+
const POLL_BASE_DELAY = 1e3;
|
|
19
|
+
const POLL_MAX_DELAY = 1e4;
|
|
20
|
+
const POLL_BACKOFF_MULTIPLIER = 1.2;
|
|
21
|
+
async function generateCursorAuthParams() {
|
|
22
|
+
const { verifier, challenge } = await generatePKCE();
|
|
23
|
+
const uuid = crypto.randomUUID();
|
|
24
|
+
const params = new URLSearchParams({
|
|
25
|
+
challenge,
|
|
26
|
+
uuid,
|
|
27
|
+
mode: "login",
|
|
28
|
+
redirectTarget: "cli"
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
verifier,
|
|
32
|
+
challenge,
|
|
33
|
+
uuid,
|
|
34
|
+
loginUrl: `${CURSOR_LOGIN_URL}?${params.toString()}`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function pollCursorAuth(uuid, verifier) {
|
|
38
|
+
let delay = POLL_BASE_DELAY;
|
|
39
|
+
let consecutiveErrors = 0;
|
|
40
|
+
for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt++) {
|
|
41
|
+
await Bun.sleep(delay);
|
|
42
|
+
try {
|
|
43
|
+
const response = await fetch(`${CURSOR_POLL_URL}?uuid=${uuid}&verifier=${verifier}`);
|
|
44
|
+
if (response.status === 404) {
|
|
45
|
+
consecutiveErrors = 0;
|
|
46
|
+
delay = Math.min(delay * POLL_BACKOFF_MULTIPLIER, POLL_MAX_DELAY);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (response.ok) {
|
|
50
|
+
const data = await response.json();
|
|
51
|
+
return {
|
|
52
|
+
accessToken: data.accessToken,
|
|
53
|
+
refreshToken: data.refreshToken
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
throw new OAuthError(`Poll failed: ${response.status}`, {
|
|
57
|
+
kind: "polling",
|
|
58
|
+
provider: "cursor",
|
|
59
|
+
status: response.status
|
|
60
|
+
});
|
|
61
|
+
} catch {
|
|
62
|
+
consecutiveErrors++;
|
|
63
|
+
if (consecutiveErrors >= 3) throw new OAuthError("Too many consecutive errors during Cursor auth polling", {
|
|
64
|
+
kind: "polling",
|
|
65
|
+
provider: "cursor"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
throw new OAuthError("Cursor authentication polling timeout", {
|
|
70
|
+
kind: "timeout",
|
|
71
|
+
provider: "cursor"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async function loginCursor(onAuthUrl, onPollStart) {
|
|
75
|
+
const { verifier, uuid, loginUrl } = await generateCursorAuthParams();
|
|
76
|
+
onAuthUrl(loginUrl);
|
|
77
|
+
onPollStart?.();
|
|
78
|
+
const { accessToken, refreshToken } = await pollCursorAuth(uuid, verifier);
|
|
79
|
+
return {
|
|
80
|
+
access: accessToken,
|
|
81
|
+
refresh: refreshToken,
|
|
82
|
+
expires: getTokenExpiry(accessToken)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async function refreshCursorToken(apiKeyOrRefreshToken) {
|
|
86
|
+
const response = await fetch(CURSOR_REFRESH_URL, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: {
|
|
89
|
+
Authorization: `Bearer ${apiKeyOrRefreshToken}`,
|
|
90
|
+
"Content-Type": "application/json"
|
|
91
|
+
},
|
|
92
|
+
body: "{}"
|
|
93
|
+
});
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
const error = await response.text();
|
|
96
|
+
throw new OAuthError(`Cursor token refresh failed: ${error}`, {
|
|
97
|
+
kind: "token-refresh",
|
|
98
|
+
provider: "cursor"
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const data = await response.json();
|
|
102
|
+
const expiresAt = getTokenExpiry(data.accessToken);
|
|
103
|
+
return {
|
|
104
|
+
access: data.accessToken,
|
|
105
|
+
refresh: data.refreshToken || apiKeyOrRefreshToken,
|
|
106
|
+
expires: expiresAt
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function decodeCursorAccessTokenPayload(token) {
|
|
110
|
+
const parts = token.split(".");
|
|
111
|
+
if (parts.length !== 3) return void 0;
|
|
112
|
+
const payload = parts[1];
|
|
113
|
+
if (!payload) return void 0;
|
|
114
|
+
return JSON.parse(atob(payload.replace(/-/g, "+").replace(/_/g, "/")));
|
|
115
|
+
}
|
|
116
|
+
function extractCursorAccessTokenUserId(accessToken) {
|
|
117
|
+
try {
|
|
118
|
+
const payload = decodeCursorAccessTokenPayload(accessToken);
|
|
119
|
+
if (!payload || typeof payload !== "object" || !("sub" in payload) || typeof payload.sub !== "string") return;
|
|
120
|
+
const { sub } = payload;
|
|
121
|
+
const parts = sub.split("|");
|
|
122
|
+
return (parts.length > 1 ? parts[1] : sub).trim() || void 0;
|
|
123
|
+
} catch {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getTokenExpiry(token) {
|
|
128
|
+
try {
|
|
129
|
+
const decoded = decodeCursorAccessTokenPayload(token);
|
|
130
|
+
if (decoded && typeof decoded === "object" && "exp" in decoded && typeof decoded.exp === "number") return decoded.exp * 1e3 - 3e5;
|
|
131
|
+
} catch {}
|
|
132
|
+
return Date.now() + 36e5;
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { extractCursorAccessTokenUserId as n, cursor_exports as t };
|