@xiaoso/dsh-tool-plus 0.1.0-beta.5 → 0.1.0-beta.7

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 (71) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +2 -2
  3. package/THIRD_PARTY_NOTICES.md +42 -42
  4. package/lib/{abort-dIkZBV7Q.mjs → abort-CsjZitYv.mjs} +1 -1
  5. package/lib/{amazon-bedrock-WQhvjHYu.mjs → amazon-bedrock-CfNIDi5k.mjs} +7 -7
  6. package/lib/{anthropic-CJCauvYz.mjs → anthropic-BVfZdnMp.mjs} +12 -12
  7. package/lib/{anthropic-tTntD8BD.mjs → anthropic-DGXmmg43.mjs} +2 -2
  8. package/lib/{api-key-login-BzqNdM2y.mjs → api-key-login-BikQAfD-.mjs} +1 -1
  9. package/lib/{aws-credentials-CXryMobh.mjs → aws-credentials-DrssNMn_.mjs} +4 -4
  10. package/lib/{azure-openai-responses-DuukbD0F.mjs → azure-openai-responses-C-5q-5K2.mjs} +8 -8
  11. package/lib/browser-render-z6b8Ljo9.mjs +183 -0
  12. package/lib/{bundled-references-Cavaffah.mjs → bundled-references-D71z7_T3.mjs} +2 -2
  13. package/lib/{callback-server-CQ5Jo8F-.mjs → callback-server-Di6C4RqI.mjs} +1 -1
  14. package/lib/client.js +613 -107
  15. package/lib/{cursor-B6TUEmgP.mjs → cursor-CQQtygwl.mjs} +1 -1
  16. package/lib/{cursor-DkSX2h3H.mjs → cursor-DXJxwdcg.mjs} +7 -7
  17. package/lib/{cursor-aJrXeYCb.mjs → cursor-Hr5Zw1gt.mjs} +3 -3
  18. package/lib/{device-code-DBo3B5nh.mjs → device-code-wZUbgPdB.mjs} +1 -1
  19. package/lib/{devin-BHZZyMhO.mjs → devin-CF6UhCFw.mjs} +2 -2
  20. package/lib/{devin-BK7DHeca.mjs → devin-DXJoDlW2.mjs} +1 -1
  21. package/lib/{devin-vNZTNUON.mjs → devin-P37gURs_.mjs} +5 -5
  22. package/lib/{dom-DGdYAVTv.mjs → dom-CawWi8fa.mjs} +14 -1
  23. package/lib/{error-Dd8DIqs-.mjs → error-DoHuatWw.mjs} +1 -1
  24. package/lib/{event-stream-BbFZJy-z.mjs → event-stream-C-FmBYUt.mjs} +1 -1
  25. package/lib/{github-copilot-CYkjeTi3.mjs → github-copilot-C2dTonBX.mjs} +3 -3
  26. package/lib/{github-copilot-B1yiyVRh.mjs → github-copilot-qETlj_bD.mjs} +1 -1
  27. package/lib/{gitlab-duo-CM7Ref1H.mjs → gitlab-duo-FQZiFRQe.mjs} +3 -3
  28. package/lib/{gitlab-duo-workflow-BGAF6JDw.mjs → gitlab-duo-workflow-DLTabzOy.mjs} +2 -2
  29. package/lib/{google-BS4T25Pn.mjs → google-BilwFSzx.mjs} +3 -3
  30. package/lib/{google-antigravity-DGmwC2KV.mjs → google-antigravity-BfBiINdu.mjs} +2 -2
  31. package/lib/{google-auth-B6gjsZvg.mjs → google-auth-CWlKXJ-H.mjs} +3 -3
  32. package/lib/{google-gemini-cli-Dsztq0N5.mjs → google-gemini-cli-CB89ljNz.mjs} +3 -3
  33. package/lib/{google-gemini-cli-Cqds_Q5T.mjs → google-gemini-cli-CygFcR6N.mjs} +8 -8
  34. package/lib/{google-oauth-shared-CuEHaDDj.mjs → google-oauth-shared-Cn82h1o2.mjs} +2 -2
  35. package/lib/{google-shared-Dr-VG-ap.mjs → google-shared-CF1JrqTM.mjs} +6 -6
  36. package/lib/{google-vertex-BDN2tLaD.mjs → google-vertex-DgMhhFw8.mjs} +5 -5
  37. package/lib/{identity-Da1GPU9a.mjs → identity-C0SPVyIZ.mjs} +1 -1
  38. package/lib/{idle-iterator-DUjKQEGT.mjs → idle-iterator-HzbbfXP4.mjs} +2 -2
  39. package/lib/index.mjs +310 -29
  40. package/lib/{kimi-Dh0pv3WZ.mjs → kimi-DHDO6Fde.mjs} +3 -3
  41. package/lib/launch-DwpE70Pv.mjs +148 -0
  42. package/lib/{markit-BL3cH47U.mjs → markit-B9exZ0ZV.mjs} +1 -1
  43. package/lib/{minimax-code-Uq8Qu9LW.mjs → minimax-code-vAhEXhev.mjs} +1 -1
  44. package/lib/{models-SGASygJ3.mjs → models-Cp3PzU3l.mjs} +1 -1
  45. package/lib/{ollama-DPzBmq89.mjs → ollama-TrkXTNqE.mjs} +8 -8
  46. package/lib/{openai-codex-Ch8CkT3p.mjs → openai-codex-CrjHtSH4.mjs} +3 -3
  47. package/lib/{openai-codex-responses-pejZgdZo.mjs → openai-codex-responses-C4uMpWNy.mjs} +10 -10
  48. package/lib/{openai-completions-DIf361kF.mjs → openai-completions-1ydXm5vF.mjs} +13 -13
  49. package/lib/{openai-reasoning-fallback-Nj6yB2rY.mjs → openai-reasoning-fallback-CigKCyzc.mjs} +2 -2
  50. package/lib/{openai-responses-Db_a-U4-.mjs → openai-responses-CN79gRGQ.mjs} +10 -10
  51. package/lib/{opencode-Rq_Q2vAO.mjs → opencode-CEGlimzL.mjs} +1 -1
  52. package/lib/{perplexity-C4iLVMUj.mjs → perplexity-BLJN-8dM.mjs} +2 -2
  53. package/lib/{proxy-pM_NIv-H.mjs → proxy-XOYi58TM.mjs} +1 -1
  54. package/lib/readability-Cpm-ocau.mjs +455 -0
  55. package/lib/{scrapers-1FTlHNQV.mjs → scrapers-DrSYgPyf.mjs} +11 -10
  56. package/lib/{src-BgpusnsB.mjs → src-D_e1qMwi.mjs} +5 -1
  57. package/lib/{stream-CRtexYLe.mjs → stream-DveNFWSN.mjs} +56 -56
  58. package/lib/{stream-markup-healing-KMkiAA00.mjs → stream-markup-healing-C9eC7Gf8.mjs} +3 -3
  59. package/lib/tool-errors-DoyxivAR.mjs +47 -0
  60. package/lib/types-BUO0JXO-.mjs +251 -0
  61. package/lib/{utils-D2YknRk4.mjs → utils-B-mTYQBc.mjs} +1 -1
  62. package/lib/{utils-C616y7eF.mjs → utils-DSEEKy3G.mjs} +28 -268
  63. package/lib/{utils-Cp76gCyk.mjs → utils-fnV2zzp3.mjs} +3 -3
  64. package/lib/{vision-guard-01qSwFpf.mjs → vision-guard-BsvOWmfB.mjs} +2 -2
  65. package/lib/{wafer-CgtPHerf.mjs → wafer-Dpy7tL3l.mjs} +1 -1
  66. package/lib/{xai-oauth-Buk8XVvM.mjs → xai-oauth-BkPNQS-q.mjs} +2 -2
  67. package/lib/{xiaomi-D2qT5cAC.mjs → xiaomi-CG3TsYRz.mjs} +1 -1
  68. package/lib/{zai-C59YnomG.mjs → zai--cewobzN.mjs} +2 -2
  69. package/lib/{zip-Cg9ANN_U.mjs → zip-CqKW2-TK.mjs} +3 -46
  70. package/package.json +3 -1
  71. package/presets/package.json +1 -1
@@ -0,0 +1,251 @@
1
+ import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
+ __installBunShim();
3
+ import { c as combineSignals } from "./src-D_e1qMwi.mjs";
4
+ import { t as ToolAbortError } from "./tool-errors-DoyxivAR.mjs";
5
+ import { scheduler } from "node:timers/promises";
6
+ //#region src/tools/omp/web/scrapers/types.ts
7
+ /**
8
+ * Shared types and utilities for web-fetch handlers
9
+ */
10
+ const MAX_OUTPUT_CHARS = 5e5;
11
+ const MAX_BYTES = 52428800;
12
+ const USER_AGENTS = [
13
+ "curl/8.0",
14
+ "Mozilla/5.0 (compatible; TextBot/1.0)",
15
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
16
+ ];
17
+ function isBotBlocked(status, content) {
18
+ if (status === 403 || status === 503) {
19
+ const lower = content.toLowerCase();
20
+ return lower.includes("cloudflare") || lower.includes("captcha") || lower.includes("challenge") || lower.includes("blocked") || lower.includes("access denied") || lower.includes("bot detection");
21
+ }
22
+ return false;
23
+ }
24
+ /**
25
+ * Truncate and cleanup output
26
+ */
27
+ function finalizeOutput(content) {
28
+ const cleaned = content.replace(/\n{3,}/g, "\n\n").trim();
29
+ const truncated = cleaned.length > MAX_OUTPUT_CHARS;
30
+ return {
31
+ content: cleaned.slice(0, MAX_OUTPUT_CHARS),
32
+ truncated
33
+ };
34
+ }
35
+ const RETRY_AFTER_MAX_MS = 1e4;
36
+ /** Parse a Retry-After header (seconds or HTTP-date) into a bounded delay. */
37
+ function parseRetryAfterMs(value) {
38
+ if (!value) return 1e3;
39
+ const seconds = Number(value);
40
+ if (Number.isFinite(seconds)) return Math.min(Math.max(seconds, 0) * 1e3, RETRY_AFTER_MAX_MS);
41
+ const date = Date.parse(value);
42
+ if (!Number.isNaN(date)) return Math.min(Math.max(date - Date.now(), 0), RETRY_AFTER_MAX_MS);
43
+ return 1e3;
44
+ }
45
+ function charsetFromContentType(header) {
46
+ return /charset\s*=\s*"?([\w-]+)"?/i.exec(header)?.[1];
47
+ }
48
+ /**
49
+ * Decode a response body honoring the declared charset (Content-Type header,
50
+ * then a cheap <meta charset> sniff), falling back to UTF-8.
51
+ */
52
+ function decodeBody(bytes, contentTypeHeader) {
53
+ let label = charsetFromContentType(contentTypeHeader);
54
+ if (!label) label = /<meta[^>]+charset\s*=\s*["']?([\w-]+)/i.exec(bytes.subarray(0, 2048).toString("latin1"))?.[1];
55
+ if (label && !/^utf-?8$/i.test(label)) try {
56
+ return new TextDecoder(label).decode(bytes);
57
+ } catch {}
58
+ return bytes.toString("utf-8");
59
+ }
60
+ /**
61
+ * Fetch a page with timeout and size limit
62
+ */
63
+ async function loadPage(url, options = {}) {
64
+ const { timeout = 20, headers = {}, maxBytes = MAX_BYTES, signal, method = "GET", body } = options;
65
+ let lastError;
66
+ let retried429 = false;
67
+ for (let attempt = 0; attempt < USER_AGENTS.length; attempt++) {
68
+ if (signal?.aborted) throw new ToolAbortError();
69
+ const userAgent = USER_AGENTS[attempt];
70
+ const requestSignal = combineSignals(signal, timeout * 1e3);
71
+ try {
72
+ const requestInit = {
73
+ signal: requestSignal,
74
+ method,
75
+ headers: {
76
+ "User-Agent": userAgent,
77
+ Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
78
+ "Accept-Language": "en-US,en;q=0.5",
79
+ "Accept-Encoding": "identity",
80
+ ...headers
81
+ },
82
+ redirect: "follow"
83
+ };
84
+ if (body !== void 0) requestInit.body = body;
85
+ const response = await fetch(url, requestInit);
86
+ const rawContentType = response.headers.get("content-type") ?? "";
87
+ const contentType = rawContentType.split(";")[0]?.trim().toLowerCase() ?? "";
88
+ const finalUrl = response.url;
89
+ if (response.status === 429 && !retried429) {
90
+ retried429 = true;
91
+ const delayMs = parseRetryAfterMs(response.headers.get("retry-after"));
92
+ response.body?.cancel().catch(() => {});
93
+ try {
94
+ await scheduler.wait(delayMs, { signal });
95
+ } catch {
96
+ throw new ToolAbortError();
97
+ }
98
+ attempt--;
99
+ continue;
100
+ }
101
+ if (response.ok && options.skipBodyForContentType?.(contentType)) {
102
+ response.body?.cancel().catch(() => {});
103
+ return {
104
+ content: "",
105
+ contentType,
106
+ finalUrl,
107
+ ok: true,
108
+ status: response.status,
109
+ bodySkipped: true
110
+ };
111
+ }
112
+ const reader = response.body?.getReader();
113
+ if (!reader) return {
114
+ content: "",
115
+ contentType,
116
+ finalUrl,
117
+ ok: false,
118
+ status: response.status
119
+ };
120
+ const chunks = [];
121
+ let totalSize = 0;
122
+ let truncated = false;
123
+ while (true) {
124
+ const { done, value } = await reader.read();
125
+ if (done) break;
126
+ chunks.push(value);
127
+ totalSize += value.length;
128
+ if (totalSize > maxBytes) {
129
+ truncated = true;
130
+ reader.cancel().catch(() => {});
131
+ break;
132
+ }
133
+ }
134
+ const content = decodeBody(Buffer.concat(chunks), rawContentType);
135
+ if (isBotBlocked(response.status, content) && attempt < USER_AGENTS.length - 1) continue;
136
+ if (!response.ok) return {
137
+ content,
138
+ contentType,
139
+ finalUrl,
140
+ ok: false,
141
+ status: response.status,
142
+ truncated
143
+ };
144
+ return {
145
+ content,
146
+ contentType,
147
+ finalUrl,
148
+ ok: true,
149
+ status: response.status,
150
+ truncated
151
+ };
152
+ } catch (error) {
153
+ if (signal?.aborted) throw new ToolAbortError();
154
+ lastError = error instanceof Error ? error.message : String(error);
155
+ if (attempt === USER_AGENTS.length - 1) return {
156
+ content: "",
157
+ contentType: "",
158
+ finalUrl: url,
159
+ ok: false,
160
+ error: lastError
161
+ };
162
+ }
163
+ }
164
+ return {
165
+ content: "",
166
+ contentType: "",
167
+ finalUrl: url,
168
+ ok: false,
169
+ error: lastError
170
+ };
171
+ }
172
+ /** Module-level Turndown instance — built lazily on first use. */
173
+ let turndownPromise;
174
+ function getTurndown() {
175
+ turndownPromise ||= initTurndown();
176
+ return turndownPromise;
177
+ }
178
+ async function initTurndown() {
179
+ const { createTurndown } = await import("./turndown-DN7ByzEI.mjs").then((n) => n.r);
180
+ return createTurndown();
181
+ }
182
+ /**
183
+ * Convert HTML to markdown using Turndown with GFM support.
184
+ * Strips script/style tags before conversion.
185
+ */
186
+ async function htmlToBasicMarkdown(html) {
187
+ const cleaned = html.replace(/<script[\s\S]*?<\/script>/gi, "").replace(/<style[\s\S]*?<\/style>/gi, "");
188
+ return (await getTurndown()).turndown(cleaned).trim();
189
+ }
190
+ /**
191
+ * Build a RenderResult from markdown content. Calls finalizeOutput internally.
192
+ */
193
+ function buildResult(md, opts) {
194
+ const output = finalizeOutput(md);
195
+ return {
196
+ url: opts.url,
197
+ finalUrl: opts.finalUrl ?? opts.url,
198
+ contentType: opts.contentType ?? "text/markdown",
199
+ method: opts.method,
200
+ content: output.content,
201
+ fetchedAt: opts.fetchedAt,
202
+ truncated: output.truncated,
203
+ notes: opts.notes ?? []
204
+ };
205
+ }
206
+ /**
207
+ * Format a date value as YYYY-MM-DD. Returns empty string on invalid input.
208
+ */
209
+ function formatIsoDate(value) {
210
+ if (value == null) return "";
211
+ if (typeof value === "string") {
212
+ const datePrefix = value.match(/^\d{4}-\d{2}-\d{2}/);
213
+ if (datePrefix) return datePrefix[0];
214
+ }
215
+ try {
216
+ return new Date(value).toISOString().split("T")[0];
217
+ } catch {
218
+ return "";
219
+ }
220
+ }
221
+ /**
222
+ * Decode common HTML entities.
223
+ */
224
+ function decodeHtmlEntities(text) {
225
+ return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, "\"").replace(/&#0?39;/g, "'").replace(/&#x27;/g, "'").replace(/&#x2F;/g, "/").replace(/&nbsp;/g, " ");
226
+ }
227
+ /**
228
+ * Format seconds into HH:MM:SS or MM:SS.
229
+ */
230
+ function formatMediaDuration(totalSeconds) {
231
+ const hours = Math.floor(totalSeconds / 3600);
232
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
233
+ const secs = Math.floor(totalSeconds % 60);
234
+ if (hours > 0) return `${hours}:${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
235
+ return `${minutes}:${String(secs).padStart(2, "0")}`;
236
+ }
237
+ function getLocalizedText(value, defaultLocale) {
238
+ if (value == null) return void 0;
239
+ if (typeof value === "string") return value;
240
+ if (defaultLocale && value[defaultLocale]) return value[defaultLocale];
241
+ return value["en-US"] ?? value.en_US ?? value.en ?? Object.values(value).find((v) => typeof v === "string") ?? void 0;
242
+ }
243
+ /**
244
+ * Check if content looks like HTML by inspecting the leading tag.
245
+ */
246
+ function looksLikeHtml(content) {
247
+ const trimmed = content.trim().toLowerCase();
248
+ return trimmed.startsWith("<!doctype") || trimmed.startsWith("<html") || trimmed.startsWith("<head") || trimmed.startsWith("<body");
249
+ }
250
+ //#endregion
251
+ export { finalizeOutput as a, getLocalizedText as c, looksLikeHtml as d, decodeHtmlEntities as i, htmlToBasicMarkdown as l, MAX_OUTPUT_CHARS as n, formatIsoDate as o, buildResult as r, formatMediaDuration as s, MAX_BYTES as t, loadPage as u };
@@ -1,6 +1,6 @@
1
1
  import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
2
  __installBunShim();
3
- import { n as wrapFetchForExtraCa } from "./src-BgpusnsB.mjs";
3
+ import { n as wrapFetchForExtraCa } from "./src-D_e1qMwi.mjs";
4
4
  //#region node_modules/.pnpm/@oh-my-pi+pi-catalog@17.3.5/node_modules/@oh-my-pi/pi-catalog/src/utils.ts
5
5
  /**
6
6
  * Fetch implementation for catalog discovery probes: the caller's override
@@ -1,29 +1,31 @@
1
1
  import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
2
  __installBunShim();
3
3
  import { n as fs_promises_shim_exports } from "./fs-promises-shim-Bx0fpxuk.mjs";
4
- import { B as USER_AGENT, I as $flag, K as getDocumentConversionCacheDir, P as $env, R as isBunTestRuntime, S as debug, T as warn, W as getDebugLogPath, X as getToolsDir, c as combineSignals, d as $which, et as untilAborted, l as exec, r as TempDir, y as isEnoent, z as isTerminalHeadless } from "./src-BgpusnsB.mjs";
5
- import { V as ProviderHttpError, a as isTransientStatus } from "./error-Dd8DIqs-.mjs";
6
- import "./utils-Cp76gCyk.mjs";
4
+ import { B as USER_AGENT, I as $flag, K as getDocumentConversionCacheDir, P as $env, R as isBunTestRuntime, S as debug, T as warn, W as getDebugLogPath, Z as getToolsDir, c as combineSignals, d as $which, l as exec, r as TempDir, tt as untilAborted, y as isEnoent, z as isTerminalHeadless } from "./src-D_e1qMwi.mjs";
5
+ import { V as ProviderHttpError, a as isTransientStatus } from "./error-DoHuatWw.mjs";
6
+ import "./utils-fnV2zzp3.mjs";
7
7
  import { n as isRecord } from "./type-guards-B9VVjRDK.mjs";
8
- import { f as ToolAbortError, n as extractArchive } from "./zip-Cg9ANN_U.mjs";
9
- import { Et as parseAlibabaTokenPlanCredential, Tt as ALIBABA_TOKEN_PLAN_CN_BASE_URL, n as getEnvApiKey } from "./stream-CRtexYLe.mjs";
10
- import { a as toNumber, i as toBoolean$1 } from "./utils-D2YknRk4.mjs";
11
- import "./identity-Da1GPU9a.mjs";
12
- import { n as OPENCODE_HEADERS } from "./github-copilot-B1yiyVRh.mjs";
13
- import "./vision-guard-01qSwFpf.mjs";
14
- import "./event-stream-BbFZJy-z.mjs";
15
- import { i as claudeCodeVersion } from "./anthropic-tTntD8BD.mjs";
8
+ import { t as ToolAbortError } from "./tool-errors-DoyxivAR.mjs";
9
+ import { n as extractArchive } from "./zip-CqKW2-TK.mjs";
10
+ import { Et as parseAlibabaTokenPlanCredential, Tt as ALIBABA_TOKEN_PLAN_CN_BASE_URL, n as getEnvApiKey } from "./stream-DveNFWSN.mjs";
11
+ import { a as toNumber, i as toBoolean$1 } from "./utils-B-mTYQBc.mjs";
12
+ import "./identity-C0SPVyIZ.mjs";
13
+ import { n as OPENCODE_HEADERS } from "./github-copilot-qETlj_bD.mjs";
14
+ import "./vision-guard-BsvOWmfB.mjs";
15
+ import "./event-stream-C-FmBYUt.mjs";
16
+ import { i as claudeCodeVersion } from "./anthropic-DGXmmg43.mjs";
16
17
  import { i as getGeminiCliHeaders, n as getAntigravityUserAgent } from "./gemini-headers-DKUShltF.mjs";
17
18
  import { t as CODEX_BASE_URL } from "./codex-P1dGpX7G.mjs";
18
- import { t as getKimiCommonHeaders } from "./kimi-Dh0pv3WZ.mjs";
19
- import "./anthropic-CJCauvYz.mjs";
20
- import { n as extractCursorAccessTokenUserId } from "./cursor-B6TUEmgP.mjs";
21
- import { i as getXAICliBillingHeaders, n as extractXAIAccessTokenSubject, r as fetchXAIOAuthIdentity, t as buildXAICliBillingUrl } from "./xai-oauth-Buk8XVvM.mjs";
22
- import "./openai-codex-responses-pejZgdZo.mjs";
23
- import "./azure-openai-responses-DuukbD0F.mjs";
24
- import "./ollama-DPzBmq89.mjs";
25
- import "./openai-completions-DIf361kF.mjs";
26
- import "./openai-responses-Db_a-U4-.mjs";
19
+ import { t as getKimiCommonHeaders } from "./kimi-DHDO6Fde.mjs";
20
+ import "./anthropic-BVfZdnMp.mjs";
21
+ import { n as extractCursorAccessTokenUserId } from "./cursor-CQQtygwl.mjs";
22
+ import { i as getXAICliBillingHeaders, n as extractXAIAccessTokenSubject, r as fetchXAIOAuthIdentity, t as buildXAICliBillingUrl } from "./xai-oauth-BkPNQS-q.mjs";
23
+ import "./openai-codex-responses-C4uMpWNy.mjs";
24
+ import "./azure-openai-responses-C-5q-5K2.mjs";
25
+ import "./ollama-TrkXTNqE.mjs";
26
+ import "./openai-completions-1ydXm5vF.mjs";
27
+ import "./openai-responses-CN79gRGQ.mjs";
28
+ import { t as MAX_BYTES } from "./types-BUO0JXO-.mjs";
27
29
  import * as path from "node:path";
28
30
  import * as fs from "node:fs";
29
31
  import { Ellipsis, Ellipsis as Ellipsis$1, extractSegments, matchesKey, sliceWithWidth, truncateToWidth } from "@oh-my-pi/pi-natives";
@@ -7096,6 +7098,8 @@ const OMP_KEY_TO_FIELD = {
7096
7098
  "astGrep.enabled": "astGrepEnabled",
7097
7099
  "astEdit.enabled": "astEditEnabled",
7098
7100
  "fetch.enabled": "fetchEnabled",
7101
+ "providers.fetch": "fetchReader",
7102
+ "browser.readerEnabled": "browserReaderEnabled",
7099
7103
  "tools.maxTimeout": "fetchMaxTimeoutSeconds",
7100
7104
  "images.autoResize": "imagesAutoResize",
7101
7105
  "images.blockImages": "imagesBlockImages",
@@ -7144,6 +7148,7 @@ const OMP_DEFAULTS = {
7144
7148
  "images.resizeJpegQuality": 80,
7145
7149
  "memory.backend": "off",
7146
7150
  "providers.fetch": "auto",
7151
+ "browser.readerEnabled": true,
7147
7152
  "searxng.endpoint": void 0,
7148
7153
  "dev.autoqa": true,
7149
7154
  "dev.autoqaConsent": void 0
@@ -7197,7 +7202,7 @@ const settings = {
7197
7202
  };
7198
7203
  //#endregion
7199
7204
  //#region package.json
7200
- var version = "0.1.0-beta.5";
7205
+ var version = "0.1.0-beta.7";
7201
7206
  /** `.tmp` files older than this are treated as orphaned writes and swept. */
7202
7207
  const TMP_ORPHAN_MAX_AGE_MS = 3e5;
7203
7208
  function markitConversionCacheKey(bytes, extension) {
@@ -7331,7 +7336,7 @@ const CONVERTIBLE_EXTENSIONS = /* @__PURE__ */ new Set([
7331
7336
  ".epub"
7332
7337
  ]);
7333
7338
  let markit = async () => {
7334
- const promise = import("./markit-BL3cH47U.mjs").then(({ Markit }) => {
7339
+ const promise = import("./markit-B9exZ0ZV.mjs").then(({ Markit }) => {
7335
7340
  const instance = new Markit();
7336
7341
  markit = () => instance;
7337
7342
  return instance;
@@ -11981,251 +11986,6 @@ async function extractWithParallel(urls, options, storage) {
11981
11986
  return parseExtractPayload(await parseParallelJsonResponse(response, "extract"));
11982
11987
  }
11983
11988
  //#endregion
11984
- //#region src/tools/omp/web/scrapers/types.ts
11985
- /**
11986
- * Shared types and utilities for web-fetch handlers
11987
- */
11988
- const MAX_OUTPUT_CHARS = 5e5;
11989
- const MAX_BYTES = 52428800;
11990
- const USER_AGENTS = [
11991
- "curl/8.0",
11992
- "Mozilla/5.0 (compatible; TextBot/1.0)",
11993
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
11994
- ];
11995
- function isBotBlocked(status, content) {
11996
- if (status === 403 || status === 503) {
11997
- const lower = content.toLowerCase();
11998
- return lower.includes("cloudflare") || lower.includes("captcha") || lower.includes("challenge") || lower.includes("blocked") || lower.includes("access denied") || lower.includes("bot detection");
11999
- }
12000
- return false;
12001
- }
12002
- /**
12003
- * Truncate and cleanup output
12004
- */
12005
- function finalizeOutput(content) {
12006
- const cleaned = content.replace(/\n{3,}/g, "\n\n").trim();
12007
- const truncated = cleaned.length > MAX_OUTPUT_CHARS;
12008
- return {
12009
- content: cleaned.slice(0, MAX_OUTPUT_CHARS),
12010
- truncated
12011
- };
12012
- }
12013
- const RETRY_AFTER_MAX_MS = 1e4;
12014
- /** Parse a Retry-After header (seconds or HTTP-date) into a bounded delay. */
12015
- function parseRetryAfterMs(value) {
12016
- if (!value) return 1e3;
12017
- const seconds = Number(value);
12018
- if (Number.isFinite(seconds)) return Math.min(Math.max(seconds, 0) * 1e3, RETRY_AFTER_MAX_MS);
12019
- const date = Date.parse(value);
12020
- if (!Number.isNaN(date)) return Math.min(Math.max(date - Date.now(), 0), RETRY_AFTER_MAX_MS);
12021
- return 1e3;
12022
- }
12023
- function charsetFromContentType(header) {
12024
- return /charset\s*=\s*"?([\w-]+)"?/i.exec(header)?.[1];
12025
- }
12026
- /**
12027
- * Decode a response body honoring the declared charset (Content-Type header,
12028
- * then a cheap <meta charset> sniff), falling back to UTF-8.
12029
- */
12030
- function decodeBody(bytes, contentTypeHeader) {
12031
- let label = charsetFromContentType(contentTypeHeader);
12032
- if (!label) label = /<meta[^>]+charset\s*=\s*["']?([\w-]+)/i.exec(bytes.subarray(0, 2048).toString("latin1"))?.[1];
12033
- if (label && !/^utf-?8$/i.test(label)) try {
12034
- return new TextDecoder(label).decode(bytes);
12035
- } catch {}
12036
- return bytes.toString("utf-8");
12037
- }
12038
- /**
12039
- * Fetch a page with timeout and size limit
12040
- */
12041
- async function loadPage(url, options = {}) {
12042
- const { timeout = 20, headers = {}, maxBytes = MAX_BYTES, signal, method = "GET", body } = options;
12043
- let lastError;
12044
- let retried429 = false;
12045
- for (let attempt = 0; attempt < USER_AGENTS.length; attempt++) {
12046
- if (signal?.aborted) throw new ToolAbortError();
12047
- const userAgent = USER_AGENTS[attempt];
12048
- const requestSignal = combineSignals(signal, timeout * 1e3);
12049
- try {
12050
- const requestInit = {
12051
- signal: requestSignal,
12052
- method,
12053
- headers: {
12054
- "User-Agent": userAgent,
12055
- Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
12056
- "Accept-Language": "en-US,en;q=0.5",
12057
- "Accept-Encoding": "identity",
12058
- ...headers
12059
- },
12060
- redirect: "follow"
12061
- };
12062
- if (body !== void 0) requestInit.body = body;
12063
- const response = await fetch(url, requestInit);
12064
- const rawContentType = response.headers.get("content-type") ?? "";
12065
- const contentType = rawContentType.split(";")[0]?.trim().toLowerCase() ?? "";
12066
- const finalUrl = response.url;
12067
- if (response.status === 429 && !retried429) {
12068
- retried429 = true;
12069
- const delayMs = parseRetryAfterMs(response.headers.get("retry-after"));
12070
- response.body?.cancel().catch(() => {});
12071
- try {
12072
- await scheduler.wait(delayMs, { signal });
12073
- } catch {
12074
- throw new ToolAbortError();
12075
- }
12076
- attempt--;
12077
- continue;
12078
- }
12079
- if (response.ok && options.skipBodyForContentType?.(contentType)) {
12080
- response.body?.cancel().catch(() => {});
12081
- return {
12082
- content: "",
12083
- contentType,
12084
- finalUrl,
12085
- ok: true,
12086
- status: response.status,
12087
- bodySkipped: true
12088
- };
12089
- }
12090
- const reader = response.body?.getReader();
12091
- if (!reader) return {
12092
- content: "",
12093
- contentType,
12094
- finalUrl,
12095
- ok: false,
12096
- status: response.status
12097
- };
12098
- const chunks = [];
12099
- let totalSize = 0;
12100
- let truncated = false;
12101
- while (true) {
12102
- const { done, value } = await reader.read();
12103
- if (done) break;
12104
- chunks.push(value);
12105
- totalSize += value.length;
12106
- if (totalSize > maxBytes) {
12107
- truncated = true;
12108
- reader.cancel().catch(() => {});
12109
- break;
12110
- }
12111
- }
12112
- const content = decodeBody(Buffer.concat(chunks), rawContentType);
12113
- if (isBotBlocked(response.status, content) && attempt < USER_AGENTS.length - 1) continue;
12114
- if (!response.ok) return {
12115
- content,
12116
- contentType,
12117
- finalUrl,
12118
- ok: false,
12119
- status: response.status,
12120
- truncated
12121
- };
12122
- return {
12123
- content,
12124
- contentType,
12125
- finalUrl,
12126
- ok: true,
12127
- status: response.status,
12128
- truncated
12129
- };
12130
- } catch (error) {
12131
- if (signal?.aborted) throw new ToolAbortError();
12132
- lastError = error instanceof Error ? error.message : String(error);
12133
- if (attempt === USER_AGENTS.length - 1) return {
12134
- content: "",
12135
- contentType: "",
12136
- finalUrl: url,
12137
- ok: false,
12138
- error: lastError
12139
- };
12140
- }
12141
- }
12142
- return {
12143
- content: "",
12144
- contentType: "",
12145
- finalUrl: url,
12146
- ok: false,
12147
- error: lastError
12148
- };
12149
- }
12150
- /** Module-level Turndown instance — built lazily on first use. */
12151
- let turndownPromise;
12152
- function getTurndown() {
12153
- turndownPromise ||= initTurndown();
12154
- return turndownPromise;
12155
- }
12156
- async function initTurndown() {
12157
- const { createTurndown } = await import("./turndown-DN7ByzEI.mjs").then((n) => n.r);
12158
- return createTurndown();
12159
- }
12160
- /**
12161
- * Convert HTML to markdown using Turndown with GFM support.
12162
- * Strips script/style tags before conversion.
12163
- */
12164
- async function htmlToBasicMarkdown(html) {
12165
- const cleaned = html.replace(/<script[\s\S]*?<\/script>/gi, "").replace(/<style[\s\S]*?<\/style>/gi, "");
12166
- return (await getTurndown()).turndown(cleaned).trim();
12167
- }
12168
- /**
12169
- * Build a RenderResult from markdown content. Calls finalizeOutput internally.
12170
- */
12171
- function buildResult(md, opts) {
12172
- const output = finalizeOutput(md);
12173
- return {
12174
- url: opts.url,
12175
- finalUrl: opts.finalUrl ?? opts.url,
12176
- contentType: opts.contentType ?? "text/markdown",
12177
- method: opts.method,
12178
- content: output.content,
12179
- fetchedAt: opts.fetchedAt,
12180
- truncated: output.truncated,
12181
- notes: opts.notes ?? []
12182
- };
12183
- }
12184
- /**
12185
- * Format a date value as YYYY-MM-DD. Returns empty string on invalid input.
12186
- */
12187
- function formatIsoDate(value) {
12188
- if (value == null) return "";
12189
- if (typeof value === "string") {
12190
- const datePrefix = value.match(/^\d{4}-\d{2}-\d{2}/);
12191
- if (datePrefix) return datePrefix[0];
12192
- }
12193
- try {
12194
- return new Date(value).toISOString().split("T")[0];
12195
- } catch {
12196
- return "";
12197
- }
12198
- }
12199
- /**
12200
- * Decode common HTML entities.
12201
- */
12202
- function decodeHtmlEntities(text) {
12203
- return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, "\"").replace(/&#0?39;/g, "'").replace(/&#x27;/g, "'").replace(/&#x2F;/g, "/").replace(/&nbsp;/g, " ");
12204
- }
12205
- /**
12206
- * Format seconds into HH:MM:SS or MM:SS.
12207
- */
12208
- function formatMediaDuration(totalSeconds) {
12209
- const hours = Math.floor(totalSeconds / 3600);
12210
- const minutes = Math.floor(totalSeconds % 3600 / 60);
12211
- const secs = Math.floor(totalSeconds % 60);
12212
- if (hours > 0) return `${hours}:${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
12213
- return `${minutes}:${String(secs).padStart(2, "0")}`;
12214
- }
12215
- function getLocalizedText(value, defaultLocale) {
12216
- if (value == null) return void 0;
12217
- if (typeof value === "string") return value;
12218
- if (defaultLocale && value[defaultLocale]) return value[defaultLocale];
12219
- return value["en-US"] ?? value.en_US ?? value.en ?? Object.values(value).find((v) => typeof v === "string") ?? void 0;
12220
- }
12221
- /**
12222
- * Check if content looks like HTML by inspecting the leading tag.
12223
- */
12224
- function looksLikeHtml(content) {
12225
- const trimmed = content.trim().toLowerCase();
12226
- return trimmed.startsWith("<!doctype") || trimmed.startsWith("<html") || trimmed.startsWith("<head") || trimmed.startsWith("<body");
12227
- }
12228
- //#endregion
12229
11989
  //#region src/tools/omp/web/scrapers/utils.ts
12230
11990
  function asRecord(value) {
12231
11991
  return isRecord(value) ? value : null;
@@ -12312,4 +12072,4 @@ async function convertWithMarkit(buffer, extension, timeout = 20, signal) {
12312
12072
  return convertBufferWithMarkit(buffer, extension, combineSignals(signal, timeout * 1e3));
12313
12073
  }
12314
12074
  //#endregion
12315
- export { shortenPath as A, Settings as C, capParseErrors as D, OMP_DEFAULTS as E, padding as M, replaceTabs as N, formatCodeFrameLine as O, truncateToWidth$1 as P, convertFileWithMarkit as S, settings as T, extractWithParallel as _, fetchBinary as a, ensureTool as b, buildResult as c, formatIsoDate as d, formatMediaDuration as f, looksLikeHtml as g, loadPage as h, convertWithMarkit as i, LRUCache as j, formatParseErrors as k, decodeHtmlEntities as l, htmlToBasicMarkdown as m, asRecord as n, MAX_BYTES as o, getLocalizedText as p, asString as r, MAX_OUTPUT_CHARS as s, asNumber as t, finalizeOutput as u, findParallelApiKey as v, isSettingsInitialized as w, CONVERTIBLE_EXTENSIONS as x, getParallelExtractContent as y };
12075
+ export { truncateToWidth$1 as C, replaceTabs as S, formatCodeFrameLine as _, fetchBinary as a, LRUCache as b, getParallelExtractContent as c, convertFileWithMarkit as d, Settings as f, capParseErrors as g, OMP_DEFAULTS as h, convertWithMarkit as i, ensureTool as l, settings as m, asRecord as n, extractWithParallel as o, isSettingsInitialized as p, asString as r, findParallelApiKey as s, asNumber as t, CONVERTIBLE_EXTENSIONS as u, formatParseErrors as v, padding as x, shortenPath as y };
@@ -1,8 +1,8 @@
1
1
  import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
2
  __installBunShim();
3
- import { I as $flag, P as $env, S as debug, g as parseStreamingJson, h as parseJsonWithRepair } from "./src-BgpusnsB.mjs";
4
- import { r as ValidationError } from "./error-Dd8DIqs-.mjs";
5
- import { t as preferredDialect } from "./identity-Da1GPU9a.mjs";
3
+ import { I as $flag, P as $env, S as debug, g as parseStreamingJson, h as parseJsonWithRepair } from "./src-D_e1qMwi.mjs";
4
+ import { r as ValidationError } from "./error-DoHuatWw.mjs";
5
+ import { t as preferredDialect } from "./identity-C0SPVyIZ.mjs";
6
6
  //#region node_modules/.pnpm/@oh-my-pi+pi-utils@17.3.5/node_modules/@oh-my-pi/pi-utils/src/json.ts
7
7
  /**
8
8
  * Try to parse JSON, returning null on failure.
@@ -1,7 +1,7 @@
1
1
  import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
2
  __installBunShim();
3
- import { M as isDashscopeCompatibleModeUrl, S as isQwenModelId, x as isOpenAIModelId } from "./models-SGASygJ3.mjs";
4
- import "./identity-Da1GPU9a.mjs";
3
+ import { M as isDashscopeCompatibleModeUrl, S as isQwenModelId, x as isOpenAIModelId } from "./models-Cp3PzU3l.mjs";
4
+ import "./identity-C0SPVyIZ.mjs";
5
5
  //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/types.ts
6
6
  /**
7
7
  * Ceiling on the output-token count omp requests from any OpenAI-family endpoint
@@ -1,6 +1,6 @@
1
1
  import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
2
  __installBunShim();
3
- import { t as createApiKeyLogin } from "./api-key-login-BzqNdM2y.mjs";
3
+ import { t as createApiKeyLogin } from "./api-key-login-BikQAfD-.mjs";
4
4
  const loginWaferServerless = createApiKeyLogin({
5
5
  providerLabel: "Wafer Serverless",
6
6
  authUrl: "https://app.wafer.ai/usage",
@@ -1,8 +1,8 @@
1
1
  import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
2
  __installBunShim();
3
3
  import { r as __exportAll } from "./fs-promises-shim-Bx0fpxuk.mjs";
4
- import { c as OAuthError, h as LoginCancelledError } from "./error-Dd8DIqs-.mjs";
5
- import { t as pollOAuthDeviceCodeFlow } from "./device-code-DBo3B5nh.mjs";
4
+ import { c as OAuthError, h as LoginCancelledError } from "./error-DoHuatWw.mjs";
5
+ import { t as pollOAuthDeviceCodeFlow } from "./device-code-wZUbgPdB.mjs";
6
6
  //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/xai-oauth.ts
7
7
  /**
8
8
  * xAI Grok OAuth device authorization flow.
@@ -1,6 +1,6 @@
1
1
  import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
2
  __installBunShim();
3
- import { _ as OnPromptRequiredError, c as OAuthError, h as LoginCancelledError, m as ApiKeyRequiredError } from "./error-Dd8DIqs-.mjs";
3
+ import { _ as OnPromptRequiredError, c as OAuthError, h as LoginCancelledError, m as ApiKeyRequiredError } from "./error-DoHuatWw.mjs";
4
4
  //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/xiaomi.ts
5
5
  /**
6
6
  * Xiaomi MiMo login flow.
@@ -1,7 +1,7 @@
1
1
  import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
2
  __installBunShim();
3
- import { V as ProviderHttpError, c as OAuthError, h as LoginCancelledError } from "./error-Dd8DIqs-.mjs";
4
- import { t as OAuthCallbackFlow } from "./callback-server-CQ5Jo8F-.mjs";
3
+ import { V as ProviderHttpError, c as OAuthError, h as LoginCancelledError } from "./error-DoHuatWw.mjs";
4
+ import { t as OAuthCallbackFlow } from "./callback-server-Di6C4RqI.mjs";
5
5
  //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/zai.ts
6
6
  /**
7
7
  * Z.ai / GLM OAuth flow (GLM Coding Plan · Sign in)