@xiaoso/dsh-tool-plus 0.1.16 → 0.1.17-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/lib/{abort-DZ54CaKU.mjs → abort-BTblp0Rt.mjs} +2 -2
  2. package/lib/{alibaba-coding-plan-DODpkcqi.mjs → alibaba-coding-plan-t3R4YKCB.mjs} +3 -3
  3. package/lib/{alibaba-token-plan-C6lpKCda.mjs → alibaba-token-plan-CO4djG1y.mjs} +4 -4
  4. package/lib/{alibaba-token-plan-CHGyWOfX.mjs → alibaba-token-plan-CUjYJX0-.mjs} +1 -1
  5. package/lib/{anthropic-Dv_GGX6g.mjs → anthropic-nf7w6so1.mjs} +48 -21
  6. package/lib/{api-key-validation-MnMf_ihX.mjs → api-key-validation-C_tZ7Y9a.mjs} +2 -2
  7. package/lib/behavior-BwvTUtag.mjs +111 -0
  8. package/lib/{browser-render-BZXt548F.mjs → browser-render-BQaEVK_n.mjs} +4 -4
  9. package/lib/{reference-CtvM4zLU.mjs → bundled-references-CrQ4dQcT.mjs} +57 -4
  10. package/lib/cascade-BWjRTD1q.mjs +30265 -0
  11. package/lib/{cline-pass-BT9CBEOj.mjs → cline-pass-Bjm-O8GG.mjs} +2 -2
  12. package/lib/cloudflare-CKXRJ0l9.mjs +37 -0
  13. package/lib/{cloudflare-ai-gateway-DReN6ohJ.mjs → cloudflare-ai-gateway-BpnBSjwV.mjs} +8 -4
  14. package/lib/cloudflare-workers-ai-odj9XswL.mjs +32 -0
  15. package/lib/collapse-_nkb2dn7.mjs +1945 -0
  16. package/lib/{coreweave-C82HrLpb.mjs → coreweave-CGDZOD8-.mjs} +1 -1
  17. package/lib/{coreweave-C68UgRQO.mjs → coreweave-DwffcgW5.mjs} +4 -4
  18. package/lib/cursor-BgOuV7Qf.mjs +794 -0
  19. package/lib/{cursor-_gHHq-Dq.mjs → cursor-CF1iHHbv.mjs} +68 -19
  20. package/lib/{cursor-proto-Cr_WEMuv.mjs → cursor-proto-BuNTjX3L.mjs} +823 -23
  21. package/lib/{devin-QpfTSl9H.mjs → devin-7OEeEb80.mjs} +112 -31
  22. package/lib/{devin-proto-DYhp4Ty6.mjs → devin-proto-C-QreeAv.mjs} +71 -5
  23. package/lib/{dom-DG3sPESc.mjs → dom-BmbZv4v9.mjs} +598 -182
  24. package/lib/{error-O63pC8zg.mjs → error-8LVo7tug.mjs} +725 -104
  25. package/lib/factory-droid-ChhmsGWb.mjs +71 -0
  26. package/lib/{fs-promises-shim-B2YFWkcd.mjs → fs-promises-shim-CANAxFWh.mjs} +10 -1
  27. package/lib/{github-copilot-BMEcw8N1.mjs → github-copilot-QwevdT30.mjs} +4 -4
  28. package/lib/{github-copilot-headers-DnjGEbko.mjs → github-copilot-headers-CAUZ0rUD.mjs} +138 -26
  29. package/lib/{gitlab-duo-DnHqJjFY.mjs → gitlab-duo-DigV7k_o.mjs} +2 -2
  30. package/lib/{google-antigravity-B1mSckrK.mjs → google-antigravity-D-oe0r8A.mjs} +6 -7
  31. package/lib/{google-gemini-cli-DJwThCCn.mjs → google-gemini-cli-CQBHgGJT.mjs} +5 -6
  32. package/lib/{google-oauth-shared-BctLpVUN.mjs → google-oauth-shared-CvgVIUwJ.mjs} +2 -2
  33. package/lib/google-validation-CdvRj4ec.mjs +126 -0
  34. package/lib/id-EJwVLDHE.mjs +2548 -0
  35. package/lib/index.mjs +248 -258
  36. package/lib/{kilo-BEgEwMJQ.mjs → kilo-5r6OffCa.mjs} +2 -2
  37. package/lib/{kimi-T9NldEIJ.mjs → kimi-DOOtbXmm.mjs} +9 -10
  38. package/lib/{launch-BIWNyrBB.mjs → launch-DkAjib7h.mjs} +1 -1
  39. package/lib/{markit-Dvp2JPdT.mjs → markit-CCcyeAds.mjs} +359 -140
  40. package/lib/{models-DnXMYGcJ.mjs → models-DCpDT_im.mjs} +199203 -112275
  41. package/lib/{muse-code-CNvqqAp6.mjs → muse-code-CYf8zj_B.mjs} +5 -5
  42. package/lib/{openai-codex-D5-CyTxa.mjs → openai-codex-Cj-TvSFh.mjs} +13 -10
  43. package/lib/{perplexity-A2PEoGaC.mjs → perplexity-Dh_Qgsmx.mjs} +68 -25
  44. package/lib/{pkce-BYjmugmw.mjs → pkce-DO-jBJLV.mjs} +1 -1
  45. package/lib/pricing-DusBEhwm.mjs +593 -0
  46. package/lib/{readability-uGhqb4GC.mjs → readability-XHK0o3bv.mjs} +287 -27
  47. package/lib/{scrapers-C1ujjV8k.mjs → scrapers-B6PADOVm.mjs} +13 -13
  48. package/lib/slugify-ynYWBIA5.mjs +11 -0
  49. package/lib/snowflake-B_jap6lz.mjs +666 -0
  50. package/lib/snowflake-Cu1ZyOp6.mjs +151 -0
  51. package/lib/{src-AELUUb5U.mjs → src-BhinCSpi.mjs} +1172 -458
  52. package/lib/{stream-AVOoe5Hj.mjs → stream-D2ivg3GH.mjs} +3740 -5311
  53. package/lib/{turndown-D6fof1OX.mjs → turndown-Vya8SavL.mjs} +82 -30
  54. package/lib/types/tools/hashline/native/index.d.ts +2 -2
  55. package/lib/types/tools/hashline/native/policy.d.ts +19 -21
  56. package/lib/types/tools/omp/session/agent-storage.d.ts +3 -3
  57. package/lib/types/tools/shared/bun-named-shim.d.ts +5 -0
  58. package/lib/{types-BLrLohwK.mjs → types-tH1v9uRm.mjs} +2 -2
  59. package/lib/{utils-cZX3f_Ls.mjs → utils-C_Ncya1r.mjs} +1737 -509
  60. package/lib/utils-D2tK38xq.mjs +34006 -0
  61. package/lib/{utils-I4I8azHN.mjs → utils-DrDwmNtu.mjs} +8 -3
  62. package/lib/{xai-oauth-CbeldUSV.mjs → xai-oauth-DLLzX6my.mjs} +4 -4
  63. package/lib/{xiaomi-Dl3VSs04.mjs → xiaomi-CqK-KivK.mjs} +2 -2
  64. package/lib/{zai-FyjGSypr.mjs → zai-DoJ2xPIH.mjs} +2 -2
  65. package/lib/{zip-DRrycScC.mjs → zip-DG1mUV6X.mjs} +1 -1
  66. package/package.json +8 -8
  67. package/lib/amazon-bedrock-Dx0rr9dY.mjs +0 -996
  68. package/lib/anthropic-ClCw0PV_.mjs +0 -3624
  69. package/lib/anthropic-wire-lbGAFzYb.mjs +0 -927
  70. package/lib/azure-openai-responses-WE_bgFWp.mjs +0 -285
  71. package/lib/bundled-references-DY3EJxZV.mjs +0 -56
  72. package/lib/cloudflare-ai-gateway-CrMa97Ap.mjs +0 -44
  73. package/lib/collapse-CkMNRNr7.mjs +0 -2304
  74. package/lib/cursor-C6jaIJDg.mjs +0 -283
  75. package/lib/cursor-D-XZYDf_.mjs +0 -4544
  76. package/lib/deterministic-id-CUEIMSqR.mjs +0 -17
  77. package/lib/devin-ExGIghmx.mjs +0 -69
  78. package/lib/devin-u0ljw5P6.mjs +0 -628
  79. package/lib/effort-BdtQMN-_.mjs +0 -23
  80. package/lib/event-stream-BKEtb45Y.mjs +0 -167
  81. package/lib/gemini-headers-Co9cVvex.mjs +0 -54
  82. package/lib/google-auth-qAN-6DMW.mjs +0 -232
  83. package/lib/google-gemini-cli-B2Aw1S5w.mjs +0 -844
  84. package/lib/google-lTxuq28n.mjs +0 -38
  85. package/lib/google-shared-Y01j9xOr.mjs +0 -856
  86. package/lib/google-validation-BEkNs-Bx.mjs +0 -18
  87. package/lib/google-vertex-DcM-FRC5.mjs +0 -99
  88. package/lib/hosts-00rjRzUD.mjs +0 -203
  89. package/lib/id-AL5obQzR.mjs +0 -71
  90. package/lib/idle-iterator-D0ZXEcUq.mjs +0 -366
  91. package/lib/ollama-6R0oXZks.mjs +0 -574
  92. package/lib/openai-codex-responses-C8bnBWOe.mjs +0 -3232
  93. package/lib/openai-completions-DNr3mUsn.mjs +0 -1430
  94. package/lib/openai-configuration-update-xMYUjaK_.mjs +0 -150
  95. package/lib/openai-reasoning-fallback-Ju-5pSR8.mjs +0 -380
  96. package/lib/openai-responses-CjpafAEr.mjs +0 -861
  97. package/lib/protobuf-BMgDYu_U.mjs +0 -717
  98. package/lib/provider-response-SqKSkkUc.mjs +0 -22
  99. package/lib/proxy-DxvCQOCA.mjs +0 -230
  100. package/lib/request-debug-BwPOqN_j.mjs +0 -183
  101. package/lib/sanitize-text-BCf5KmCf.mjs +0 -33
  102. package/lib/sse-debug-B-tkLCPW.mjs +0 -11
  103. package/lib/stream-markup-healing-CN3RsqG9.mjs +0 -267
  104. package/lib/strict-tool-validation-CBTz1dAA.mjs +0 -105
  105. package/lib/taxonomy-DSIM99rS.mjs +0 -15392
  106. package/lib/thinking-ngMwf_1Y.mjs +0 -336
  107. package/lib/type-guards-CttAANEx.mjs +0 -11
  108. package/lib/utils-CE3DSebh.mjs +0 -11763
  109. package/lib/vision-guard-BCpXWUj3.mjs +0 -77
@@ -1,22 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/provider-response.ts
4
- function normalizeProviderResponse(response, requestId, metadata) {
5
- const headers = {};
6
- response.headers.forEach((value, key) => {
7
- headers[key.toLowerCase()] = value;
8
- });
9
- const providerResponse = {
10
- status: response.status,
11
- headers
12
- };
13
- if (requestId !== void 0) providerResponse.requestId = requestId;
14
- if (metadata !== void 0) providerResponse.metadata = metadata;
15
- return providerResponse;
16
- }
17
- async function notifyProviderResponse(options, response, model, requestId, metadata) {
18
- if (!options?.onResponse) return;
19
- await options.onResponse(normalizeProviderResponse(response, requestId, metadata), model);
20
- }
21
- //#endregion
22
- export { notifyProviderResponse as t };
@@ -1,230 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { b as debug } from "./src-AELUUb5U.mjs";
4
- import { _ as AbortError, n as StreamTimeoutError, r as ValidationError } from "./error-O63pC8zg.mjs";
5
- import * as tls from "node:tls";
6
- import * as net from "node:net";
7
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/proxy.ts
8
- /**
9
- * Host:port of a proxy URL for logging. Proxy URLs can carry basic-auth
10
- * credentials, so never log the raw value.
11
- */
12
- function proxyLogTarget(proxyUrl) {
13
- try {
14
- return new URL(proxyUrl).host;
15
- } catch {
16
- return "<unparseable>";
17
- }
18
- }
19
- /**
20
- * Checks if a host is local or cloud metadata, which should always bypass the proxy
21
- * (e.g. localhost, 127/8, ::1, 169.254.169.254, metadata.google.internal).
22
- */
23
- function isLocalOrMetadataHost(host) {
24
- const lowerHost = host.toLowerCase();
25
- if (lowerHost === "localhost" || lowerHost.endsWith(".localhost") || lowerHost === "metadata.google.internal") return true;
26
- const ip = lowerHost.replace(/^\[|\]$/g, "");
27
- const v4 = ip.match(/^(\d{1,3})\.(\d{1,3})\.\d{1,3}\.\d{1,3}$/);
28
- if (v4) {
29
- const a = Number(v4[1]);
30
- const b = Number(v4[2]);
31
- if (a === 127 || a === 10 || a === 0) return true;
32
- if (a === 169 && b === 254) return true;
33
- if (a === 192 && b === 168) return true;
34
- if (a === 172 && b >= 16 && b <= 31) return true;
35
- return false;
36
- }
37
- if (ip === "::1" || ip === "::") return true;
38
- if (/^fe[89ab][0-9a-f]:/.test(ip)) return true;
39
- if (/^f[cd][0-9a-f]{2}:/.test(ip)) return true;
40
- return false;
41
- }
42
- /**
43
- * Check if the url should bypass the proxy due to hard-coded localhost/metadata checks
44
- * or custom NO_PROXY/no_proxy environment variables rules.
45
- */
46
- function shouldBypassProxy(urlObj) {
47
- if (isLocalOrMetadataHost(urlObj.hostname)) return true;
48
- const noProxyVal = Bun.env.NO_PROXY || Bun.env.no_proxy;
49
- if (!noProxyVal) return false;
50
- const rules = noProxyVal.split(/[,\s]+/).map((r) => r.trim()).filter(Boolean);
51
- const targetHost = urlObj.hostname.toLowerCase();
52
- const targetPort = urlObj.port || (urlObj.protocol === "https:" || urlObj.protocol === "wss:" ? "443" : "80");
53
- for (const rule of rules) {
54
- if (rule === "*") return true;
55
- let ruleHost = rule.toLowerCase();
56
- let rulePort;
57
- if (ruleHost.includes("]:")) {
58
- const lastColon = ruleHost.lastIndexOf(":");
59
- rulePort = ruleHost.slice(lastColon + 1);
60
- ruleHost = ruleHost.slice(0, lastColon);
61
- } else if (!ruleHost.includes("]") && ruleHost.includes(":")) {
62
- const lastColon = ruleHost.lastIndexOf(":");
63
- rulePort = ruleHost.slice(lastColon + 1);
64
- ruleHost = ruleHost.slice(0, lastColon);
65
- }
66
- ruleHost = ruleHost.replace(/^\[|\]$/g, "");
67
- if (rulePort && rulePort !== targetPort) continue;
68
- if (ruleHost.startsWith(".")) {
69
- const suffix = ruleHost;
70
- if (targetHost === ruleHost.slice(1) || targetHost.endsWith(suffix)) return true;
71
- } else if (targetHost === ruleHost || targetHost.endsWith(`.${ruleHost}`)) return true;
72
- }
73
- return false;
74
- }
75
- const proxyCache = /* @__PURE__ */ new Map();
76
- /**
77
- * Normalizes provider id (e.g. github-copilot -> PI_PROXY_GITHUB_COPILOT) and looks it up.
78
- * If not found, falls back to PI_PROXY. Results are memoized because env values are static
79
- * for the lifetime of the process and this function is called for every outgoing request.
80
- */
81
- function getProxyForProvider(provider) {
82
- if (proxyCache.has(provider)) return proxyCache.get(provider);
83
- const envKey = `PI_PROXY_${provider.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`;
84
- const value = Bun.env[envKey] || Bun.env.PI_PROXY;
85
- proxyCache.set(provider, value);
86
- debug("provider proxy resolved", {
87
- provider,
88
- source: Bun.env[envKey] ? envKey : value ? "PI_PROXY" : "none",
89
- proxy: value ? proxyLogTarget(value) : void 0
90
- });
91
- return value;
92
- }
93
- /** Resolves provider-specific and standard proxy variables for a target URL, honoring NO_PROXY. */
94
- function getProxyForUrl(provider, url) {
95
- if (shouldBypassProxy(url)) return void 0;
96
- const protocolProxy = url.protocol === "https:" || url.protocol === "wss:" ? Bun.env.HTTPS_PROXY || Bun.env.https_proxy : Bun.env.HTTP_PROXY || Bun.env.http_proxy;
97
- return getProxyForProvider(provider) || protocolProxy || Bun.env.ALL_PROXY || Bun.env.all_proxy || void 0;
98
- }
99
- /**
100
- * Tunnel a socket connection through an HTTP CONNECT proxy.
101
- * This is used specifically to wrap Node's `http2.connect(baseUrl, { createConnection })` for Cursor.
102
- */
103
- async function connectProxiedSocket(proxyUrlStr, targetUrlStr, options) {
104
- if (options?.signal?.aborted) throw new AbortError("Proxy tunnel aborted");
105
- const proxyUrl = new URL(proxyUrlStr);
106
- const targetUrl = new URL(targetUrlStr);
107
- const useProxySsl = proxyUrl.protocol === "https:";
108
- const proxyPort = proxyUrl.port ? parseInt(proxyUrl.port, 10) : useProxySsl ? 443 : 80;
109
- const proxyHost = proxyUrl.hostname;
110
- const targetPort = targetUrl.port ? parseInt(targetUrl.port, 10) : 443;
111
- const targetHost = targetUrl.hostname;
112
- const { promise, resolve, reject } = Promise.withResolvers();
113
- const readyEvent = useProxySsl ? "secureConnect" : "connect";
114
- let tunnelSocket;
115
- let timeout;
116
- let responseData = "";
117
- let settled = false;
118
- const cleanup = () => {
119
- if (timeout) {
120
- clearTimeout(timeout);
121
- timeout = void 0;
122
- }
123
- options?.signal?.removeEventListener("abort", onAbort);
124
- rawSocket?.off("error", onRawError);
125
- rawSocket?.off(readyEvent, onProxyReady);
126
- rawSocket?.off("data", onProxyData);
127
- tunnelSocket?.off("secureConnect", onTunnelReady);
128
- tunnelSocket?.off("error", onTunnelError);
129
- };
130
- const destroyInProgress = () => {
131
- tunnelSocket?.destroy();
132
- rawSocket?.destroy();
133
- };
134
- const rejectOnce = (error) => {
135
- if (settled) return;
136
- settled = true;
137
- cleanup();
138
- destroyInProgress();
139
- debug("proxy tunnel failed", {
140
- proxy: `${proxyHost}:${proxyPort}`,
141
- target: `${targetHost}:${targetPort}`,
142
- error: String(error),
143
- code: "code" in error ? String(error.code) : void 0
144
- });
145
- reject(error);
146
- };
147
- const resolveOnce = (socket) => {
148
- if (settled) return;
149
- settled = true;
150
- cleanup();
151
- resolve(socket);
152
- };
153
- const onAbort = () => rejectOnce(new AbortError("Proxy tunnel aborted"));
154
- const onRawError = (error) => rejectOnce(error);
155
- const onTunnelError = (error) => rejectOnce(error);
156
- const onTunnelReady = () => {
157
- if (!tunnelSocket) return;
158
- debug("proxy tunnel established", {
159
- proxy: `${proxyHost}:${proxyPort}`,
160
- target: `${targetHost}:${targetPort}`,
161
- peer: `${rawSocket?.remoteAddress ?? "?"}:${rawSocket?.remotePort ?? "?"}`,
162
- localPort: rawSocket?.localPort,
163
- alpn: tunnelSocket.alpnProtocol,
164
- authorized: tunnelSocket.authorized
165
- });
166
- resolveOnce(tunnelSocket);
167
- };
168
- const onProxyData = (chunk) => {
169
- if (!rawSocket) return;
170
- responseData += chunk.toString("binary");
171
- if (!responseData.includes("\r\n\r\n")) return;
172
- rawSocket.off("data", onProxyData);
173
- rawSocket.off("error", onRawError);
174
- const firstLine = responseData.split("\r\n")[0];
175
- debug("proxy tunnel CONNECT reply", {
176
- proxy: `${proxyHost}:${proxyPort}`,
177
- target: `${targetHost}:${targetPort}`,
178
- reply: firstLine
179
- });
180
- if (!firstLine.includes(" 200 ")) {
181
- rejectOnce(new ValidationError(`Proxy tunnel failed: ${firstLine}`));
182
- return;
183
- }
184
- const tlsOptions = options?.tls;
185
- tunnelSocket = tls.connect({
186
- ...tlsOptions,
187
- socket: rawSocket,
188
- servername: tlsOptions?.servername ?? targetHost,
189
- ALPNProtocols: tlsOptions?.ALPNProtocols ?? ["h2"]
190
- });
191
- tunnelSocket.once("secureConnect", onTunnelReady);
192
- tunnelSocket.once("error", onTunnelError);
193
- };
194
- const onProxyReady = () => {
195
- if (!rawSocket) return;
196
- let connectReq = `CONNECT ${targetHost}:${targetPort} HTTP/1.1\r\nHost: ${targetHost}:${targetPort}\r\n`;
197
- if (proxyUrl.username || proxyUrl.password) {
198
- const creds = Buffer.from(`${decodeURIComponent(proxyUrl.username)}:${decodeURIComponent(proxyUrl.password)}`).toString("base64");
199
- connectReq += `Proxy-Authorization: Basic ${creds}\r\n`;
200
- }
201
- connectReq += "\r\n";
202
- rawSocket.write(connectReq);
203
- rawSocket.on("data", onProxyData);
204
- debug("proxy tunnel CONNECT sent", {
205
- proxy: `${proxyHost}:${proxyPort}`,
206
- target: `${targetHost}:${targetPort}`,
207
- peer: `${rawSocket.remoteAddress ?? "?"}:${rawSocket.remotePort ?? "?"}`
208
- });
209
- };
210
- options?.signal?.addEventListener("abort", onAbort, { once: true });
211
- if (options?.timeoutMs !== void 0 && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0) {
212
- const timeoutMs = Math.trunc(options.timeoutMs);
213
- timeout = setTimeout(() => {
214
- rejectOnce(new StreamTimeoutError(`Proxy tunnel timed out after ${timeoutMs}ms`));
215
- }, timeoutMs);
216
- timeout.unref?.();
217
- }
218
- const rawSocket = useProxySsl ? tls.connect({
219
- host: proxyHost,
220
- port: proxyPort
221
- }) : net.connect({
222
- host: proxyHost,
223
- port: proxyPort
224
- });
225
- rawSocket.once("error", onRawError);
226
- rawSocket.once(readyEvent, onProxyReady);
227
- return promise;
228
- }
229
- //#endregion
230
- export { getProxyForUrl as n, isLocalOrMetadataHost as r, connectProxiedSocket as t };
@@ -1,183 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- import { n as fs_promises_shim_exports } from "./fs-promises-shim-B2YFWkcd.mjs";
4
- import "node:buffer";
5
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/request-debug.ts
6
- const REQUEST_DEBUG_ENV = "PI_REQ_DEBUG";
7
- const textEncoder = new TextEncoder();
8
- new TextDecoder("utf-8", { fatal: true });
9
- let nextSessionId = 1;
10
- function isRequestDebugEnvEnabled() {
11
- return Bun.env[REQUEST_DEBUG_ENV] === "1";
12
- }
13
- function isRequestDebugEnabled() {
14
- return isRequestDebugEnvEnabled();
15
- }
16
- async function createRequestDebugSession(payload) {
17
- const { id, requestPath, responsePath, handle, overwrite } = await reserveRequestDebugFile();
18
- const requestDump = {
19
- id,
20
- protocol: payload.protocol ?? "http",
21
- method: payload.method,
22
- url: payload.url
23
- };
24
- const headers = headersToRecord(payload.headers);
25
- if (headers) requestDump.headers = headers;
26
- if (payload.body !== void 0) requestDump.body = payload.body;
27
- if (payload.bodyText !== void 0) requestDump.bodyText = payload.bodyText;
28
- if (payload.bodyBase64 !== void 0) requestDump.bodyBase64 = payload.bodyBase64;
29
- if (payload.bodyUnavailable !== void 0) requestDump.bodyUnavailable = payload.bodyUnavailable;
30
- try {
31
- await handle.writeFile(`${JSON.stringify(requestDump, null, 2)}\n`, "utf8");
32
- } finally {
33
- await handle.close();
34
- }
35
- return new FileRequestDebugSession(id, requestPath, responsePath, overwrite);
36
- }
37
- var FileRequestDebugSession = class {
38
- id;
39
- requestPath;
40
- responsePath;
41
- #overwriteResponseLog;
42
- constructor(id, requestPath, responsePath, overwriteResponseLog) {
43
- this.id = id;
44
- this.requestPath = requestPath;
45
- this.responsePath = responsePath;
46
- this.#overwriteResponseLog = overwriteResponseLog;
47
- }
48
- async openResponseLog(statusLine, headers) {
49
- const handle = await fs_promises_shim_exports.open(this.responsePath, this.#overwriteResponseLog ? "w" : "wx");
50
- const headerBlock = formatResponseHeaderBlock(statusLine, headers);
51
- await handle.write(textEncoder.encode(headerBlock));
52
- return new FileRequestDebugResponseLog(handle);
53
- }
54
- async wrapResponse(response) {
55
- const log = await this.openResponseLog(`HTTP ${response.status} ${response.statusText}`.trim(), response.headers);
56
- if (!response.body) {
57
- await log.close();
58
- return response;
59
- }
60
- const reader = response.body.getReader();
61
- const teed = new ReadableStream({
62
- async pull(controller) {
63
- try {
64
- const { done, value } = await reader.read();
65
- if (done) {
66
- await log.close();
67
- controller.close();
68
- return;
69
- }
70
- log.write(value);
71
- controller.enqueue(value);
72
- } catch (error) {
73
- await log.close().catch(() => void 0);
74
- controller.error(error);
75
- }
76
- },
77
- async cancel(reason) {
78
- try {
79
- await reader.cancel(reason);
80
- } finally {
81
- await log.close();
82
- }
83
- }
84
- });
85
- const wrapped = new Response(teed, {
86
- status: response.status,
87
- statusText: response.statusText,
88
- headers: response.headers
89
- });
90
- copyResponseMetadata(wrapped, response);
91
- return wrapped;
92
- }
93
- };
94
- var FileRequestDebugResponseLog = class {
95
- #handle;
96
- #pending = Promise.resolve();
97
- #closed;
98
- constructor(handle) {
99
- this.#handle = handle;
100
- }
101
- write(chunk) {
102
- const handle = this.#handle;
103
- if (!handle) return;
104
- const bytes = typeof chunk === "string" ? textEncoder.encode(chunk) : chunk.slice();
105
- this.#pending = this.#pending.then(async () => {
106
- await handle.write(bytes);
107
- });
108
- }
109
- close() {
110
- if (this.#closed) return this.#closed;
111
- const handle = this.#handle;
112
- if (!handle) return Promise.resolve();
113
- this.#handle = void 0;
114
- this.#closed = (async () => {
115
- try {
116
- await this.#pending;
117
- } finally {
118
- await handle.close();
119
- }
120
- })();
121
- return this.#closed;
122
- }
123
- };
124
- function copyResponseMetadata(target, source) {
125
- const sourceUrl = source.url;
126
- if (!sourceUrl) return;
127
- try {
128
- Object.defineProperty(target, "url", {
129
- value: sourceUrl,
130
- configurable: true
131
- });
132
- } catch {}
133
- }
134
- async function reserveRequestDebugFile() {
135
- for (;;) {
136
- const id = nextSessionId++;
137
- const requestPath = `rr-session-${id}.json`;
138
- try {
139
- const handle = await fs_promises_shim_exports.open(requestPath, "wx");
140
- return {
141
- id,
142
- requestPath,
143
- responsePath: `rr-session-${id}.res.log`,
144
- handle,
145
- overwrite: false
146
- };
147
- } catch (error) {
148
- if (isFileExistsError(error)) continue;
149
- throw error;
150
- }
151
- }
152
- }
153
- function formatResponseHeaderBlock(statusLine, headers) {
154
- const lines = [statusLine];
155
- const record = headersToRecord(headers);
156
- if (record) for (const name in record) {
157
- const value = record[name];
158
- if (Array.isArray(value)) for (const item of value) lines.push(`${name}: ${item}`);
159
- else lines.push(`${name}: ${value}`);
160
- }
161
- return `${lines.join("\r\n")}\r\n\r\n`;
162
- }
163
- function headersToRecord(headers) {
164
- if (!headers) return void 0;
165
- const record = {};
166
- let hasHeaders = false;
167
- if (headers instanceof Headers) headers.forEach((value, key) => {
168
- hasHeaders = true;
169
- record[key] = value;
170
- });
171
- else for (const key in headers) {
172
- const value = headers[key];
173
- if (value === void 0 || value === null) continue;
174
- hasHeaders = true;
175
- record[key] = Array.isArray(value) ? value.map(String) : String(value);
176
- }
177
- return hasHeaders ? record : void 0;
178
- }
179
- function isFileExistsError(error) {
180
- return typeof error === "object" && error !== null && error.code === "EEXIST";
181
- }
182
- //#endregion
183
- export { isRequestDebugEnabled as n, createRequestDebugSession as t };
@@ -1,33 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- //#region node_modules/.pnpm/@oh-my-pi+pi-utils@18.1.17/node_modules/@oh-my-pi/pi-utils/src/sanitize-text.ts
4
- /**
5
- * Strip ANSI escape sequences, remove control characters / lone surrogates,
6
- * and normalize line endings.
7
- *
8
- * Bun-native implementation of the former native `sanitizeText` (see
9
- * `crates/pi-natives/src/text.rs::sanitize_text`). JavaScript strings are
10
- * already UTF-16 code-unit arrays. `toWellFormed()` handles the uncommon
11
- * malformed path; when it changes the input, replacement characters are
12
- * dropped and the normalized result goes through the well-formed sanitizer.
13
- *
14
- * Fast path: well-formed input with no controls or ANSI returns the original
15
- * string after the control probe.
16
- */
17
- const ESC_CHAR = "\x1B";
18
- const CONTROL_RE = /[\x00-\x08\x0B-\x1F\x7F-\x9F]/g;
19
- const REPLACEMENT_CHAR = "�";
20
- function sanitizeText(text) {
21
- const wellFormed = text.toWellFormed();
22
- if (wellFormed !== text) return sanitizeWellFormedText(wellFormed.replaceAll(REPLACEMENT_CHAR, ""));
23
- return sanitizeWellFormedText(text);
24
- }
25
- function sanitizeWellFormedText(text) {
26
- CONTROL_RE.lastIndex = 0;
27
- if (CONTROL_RE.exec(text) === null) return text;
28
- const stripped = text.indexOf(ESC_CHAR) === -1 ? text : Bun.stripANSI(text);
29
- CONTROL_RE.lastIndex = 0;
30
- return stripped.replace(CONTROL_RE, "");
31
- }
32
- //#endregion
33
- export { sanitizeText as t };
@@ -1,11 +0,0 @@
1
- import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
- __installBunShim();
3
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/sse-debug.ts
4
- function notifyRawSseEvent(observer, event) {
5
- if (!observer) return;
6
- try {
7
- observer(event);
8
- } catch {}
9
- }
10
- //#endregion
11
- export { notifyRawSseEvent as t };