@xiaoso/dsh-tool-plus 0.1.6 → 0.1.7-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +9 -3
- package/lib/{abort-Cwwm4Err.mjs → abort-Caqff3M6.mjs} +2 -2
- package/lib/alibaba-coding-plan-DTupMiAi.mjs +73 -0
- package/lib/alibaba-token-plan-CHGyWOfX.mjs +46 -0
- package/lib/alibaba-token-plan-Dj3OZhEE.mjs +82 -0
- package/lib/{amazon-bedrock-TVMpUTRG.mjs → amazon-bedrock-DbFSYXfJ.mjs} +117 -38
- package/lib/{anthropic-BL6LFDQS.mjs → anthropic-CTJ3IQVa.mjs} +675 -166
- package/lib/anthropic-CXfWlp-x.mjs +105 -0
- package/lib/{aws-credentials-B20dliS7.mjs → anthropic-wire-CKuhDwZ1.mjs} +74 -14
- package/lib/{api-key-login-CIDnXeYd.mjs → api-key-validation-CGCJFbFr.mjs} +27 -68
- package/lib/{azure-openai-responses-BkhsLmN3.mjs → azure-openai-responses-ChFbWaGj.mjs} +27 -16
- package/lib/{browser-render-CmgvSNte.mjs → browser-render-9o0Rknop.mjs} +4 -4
- package/lib/bun-shim.mjs +71 -2
- package/lib/{bundled-references-ChZSPDFw.mjs → bundled-references-DY3EJxZV.mjs} +6 -5
- package/lib/cline-pass-Bwg3esu9.mjs +44 -0
- package/lib/cloudflare-ai-gateway-BupNXyKK.mjs +35 -0
- package/lib/cloudflare-ai-gateway-EWo0VkP5.mjs +44 -0
- package/lib/collapse-DOR8sOGf.mjs +2304 -0
- package/lib/coreweave-C82HrLpb.mjs +31 -0
- package/lib/coreweave-Ct8cF-da.mjs +14 -0
- package/lib/{cursor-B6HcmplF.mjs → cursor-B95LzVWV.mjs} +11 -3
- package/lib/{cursor-CRpLpaZ3.mjs → cursor-DJV_dcgB.mjs} +887 -1784
- package/lib/{cursor-B8m6SqAH.mjs → cursor-LKGjucn2.mjs} +48 -38
- package/lib/cursor-proto-B8Wj8bv9.mjs +10513 -0
- package/lib/{deterministic-id-D-yIV_eI.mjs → deterministic-id-CUEIMSqR.mjs} +1 -1
- package/lib/devin-BMTdx_hx.mjs +316 -0
- package/lib/{devin-DUAfvBsW.mjs → devin-DSp0Rw_E.mjs} +172 -86
- package/lib/devin-ExGIghmx.mjs +69 -0
- package/lib/devin-proto-Br8fdyNl.mjs +2888 -0
- package/lib/{dom-CawWi8fa.mjs → dom-DG3sPESc.mjs} +8 -8
- package/lib/effort-BdtQMN-_.mjs +23 -0
- package/lib/{error-C-f_Wnw4.mjs → error-CORgGg5a.mjs} +275 -154
- package/lib/{event-stream-Dh2guZxS.mjs → event-stream-ulcDenZD.mjs} +20 -4
- package/lib/{gemini-headers-DKUShltF.mjs → gemini-headers-Co9cVvex.mjs} +2 -2
- package/lib/{github-copilot-suDymKrx.mjs → github-copilot-Dstq1D3s.mjs} +69 -29
- package/lib/github-copilot-headers-DOh1gt_w.mjs +312 -0
- package/lib/gitlab-duo-DSCMrU0m.mjs +11 -0
- package/lib/google-CtsKkOQK.mjs +38 -0
- package/lib/google-antigravity-z-5KsEci.mjs +252 -0
- package/lib/{google-auth-DYJLM792.mjs → google-auth-ieLBaneO.mjs} +4 -4
- package/lib/{google-gemini-cli-8BT513Ul.mjs → google-gemini-cli-C6NE5mWz.mjs} +28 -54
- package/lib/{google-gemini-cli-D6cSmfvB.mjs → google-gemini-cli-CAIPSl7e.mjs} +23 -29
- package/lib/google-oauth-shared-DhMllAkt.mjs +53 -0
- package/lib/{google-shared-CVbHK5vZ.mjs → google-shared-B0aNCYEH.mjs} +140 -44
- package/lib/{google-validation-Cgbn3tWJ.mjs → google-validation-BEkNs-Bx.mjs} +1 -1
- package/lib/{google-vertex-Bui-ypAe.mjs → google-vertex-Bbd1tYNc.mjs} +8 -8
- package/lib/hosts-00rjRzUD.mjs +203 -0
- package/lib/id-AL5obQzR.mjs +71 -0
- package/lib/{idle-iterator-CYAxUkSD.mjs → idle-iterator-DlUkEfzW.mjs} +3 -3
- package/lib/index.mjs +587 -5266
- package/lib/kilo-ChJL54wq.mjs +81 -0
- package/lib/kimi-C2c_Zq8A.mjs +67 -0
- package/lib/{launch-BmgEUycu.mjs → launch-DKDH71En.mjs} +1 -1
- package/lib/markit-CmRfm4E2.mjs +9885 -0
- package/lib/models-DnXMYGcJ.mjs +381604 -0
- package/lib/muse-code-Di1VZmB1.mjs +143 -0
- package/lib/{ollama-Df9ce-Cp.mjs → ollama-B8ic3sEp.mjs} +15 -30
- package/lib/{openai-codex-CAVI3Me-.mjs → openai-codex-DuJNC99x.mjs} +29 -99
- package/lib/{openai-codex-responses-BcnOotRB.mjs → openai-codex-responses-BL29nh9K.mjs} +204 -116
- package/lib/{openai-completions-Bq4WT47M.mjs → openai-completions-BK2f2dBv.mjs} +152 -82
- package/lib/openai-configuration-update-xMYUjaK_.mjs +150 -0
- package/lib/{openai-reasoning-fallback-DXsfiSXO.mjs → openai-reasoning-fallback-BdB3RCbj.mjs} +106 -12
- package/lib/{openai-responses-Mq_-PjvE.mjs → openai-responses-CGQPlIIy.mjs} +76 -82
- package/lib/{perplexity-XgLF73E7.mjs → perplexity-TBjz3VMB.mjs} +52 -9
- package/lib/{pkce-BlQikGPu.mjs → pkce-BYjmugmw.mjs} +1 -1
- package/lib/protobuf-aab1UGVn.mjs +717 -0
- package/lib/{provider-response-C6vcbQyO.mjs → provider-response-SqKSkkUc.mjs} +1 -1
- package/lib/{proxy-D9lm7ONA.mjs → proxy-5nWqRL1f.mjs} +45 -5
- package/lib/{readability-Cpm-ocau.mjs → readability-uGhqb4GC.mjs} +2 -2
- package/lib/reference-CtvM4zLU.mjs +114 -0
- package/lib/{request-debug-HJMoJncL.mjs → request-debug-NQN0BjHH.mjs} +1 -1
- package/lib/{sanitize-text-CfcXzw5X.mjs → sanitize-text-BCf5KmCf.mjs} +1 -1
- package/lib/{scrapers-Cg5w77td.mjs → scrapers-D8oWspgW.mjs} +12 -12
- package/lib/{src-BcD0_rQR.mjs → src-BwW51vA5.mjs} +979 -388
- package/lib/{sse-debug-CYdjOC96.mjs → sse-debug-B-tkLCPW.mjs} +1 -1
- package/lib/{stream-Bjq8wjfr.mjs → stream-B_7qN-bA.mjs} +3802 -2623
- package/lib/stream-markup-healing-DKT1lnkW.mjs +267 -0
- package/lib/{strict-tool-validation-imVLUcbI.mjs → strict-tool-validation-CBTz1dAA.mjs} +2 -2
- package/lib/taxonomy-DSIM99rS.mjs +15392 -0
- package/lib/{stream-markup-healing-DZ6bVDxH.mjs → thinking-CiLa2LFB.mjs} +31 -186
- package/lib/{turndown-DN7ByzEI.mjs → turndown-DrX1M4WG.mjs} +4 -4
- package/lib/{type-guards-B9VVjRDK.mjs → type-guards-CttAANEx.mjs} +1 -1
- package/lib/{types-DX_bvuus.mjs → types-PVueGi9S.mjs} +2 -2
- package/lib/{utils-C-dSORPa.mjs → utils-CCfhUQen.mjs} +2364 -2676
- package/lib/{utils-Cp2Mxf_U.mjs → utils-CUPhpw9A.mjs} +413 -134
- package/lib/{utils-CQHPEQ3W.mjs → utils-DeWqNWV8.mjs} +2 -2
- package/lib/{vision-guard-mBmtAHx0.mjs → vision-guard-_XwsL1DF.mjs} +14 -29
- package/lib/xai-oauth-CXhnz0gO.mjs +210 -0
- package/lib/{xiaomi-7mE345KX.mjs → xiaomi-psoUItal.mjs} +8 -37
- package/lib/{zai-CeNpMV3W.mjs → zai-ApJ8HBgT.mjs} +8 -71
- package/lib/{zip-BK7UHCwX.mjs → zip-Kd602XNe.mjs} +1 -1
- package/package.json +11 -11
- package/presets/package.json +1 -1
- package/presets/tool-plus-ptc/agent.cordis.yml +1 -1
- package/presets/tool-plus-standard/agent.cordis.yml +1 -1
- package/lib/agent_pb-Rizyt9Zg.mjs +0 -805
- package/lib/anthropic-CDmj476p.mjs +0 -262
- package/lib/api_server_pb-CDZgLMta.mjs +0 -252
- package/lib/callback-server-CFJK-jvK.mjs +0 -398
- package/lib/codex-P1dGpX7G.mjs +0 -54
- package/lib/device-code-CuXTWYwY.mjs +0 -51
- package/lib/devin-BcQwht1W.mjs +0 -114
- package/lib/devin-BvMfGevz.mjs +0 -95
- package/lib/github-copilot-B3kQl0g0.mjs +0 -104
- package/lib/gitlab-duo-BriUTP8k.mjs +0 -155
- package/lib/gitlab-duo-workflow-wK5Ljzmc.mjs +0 -91
- package/lib/google-CE5tFDod.mjs +0 -30
- package/lib/google-antigravity-C1jgNljz.mjs +0 -198
- package/lib/google-oauth-shared-BLVTvokk.mjs +0 -147
- package/lib/grammar-D-NqNUxQ.mjs +0 -49
- package/lib/identity-HNO1Oe9B.mjs +0 -219
- package/lib/kimi-DgcUpPtK.mjs +0 -236
- package/lib/markit-DtGoRE6M.mjs +0 -1417
- package/lib/minimax-code-Y3h5li9N.mjs +0 -53
- package/lib/models-DRA2c_8U.mjs +0 -104660
- package/lib/opencode-BsVw9rCD.mjs +0 -38
- package/lib/to-binary-B1BEBIPC.mjs +0 -6002
- package/lib/wafer-BlhWLweO.mjs +0 -17
- package/lib/xai-oauth-5pORHUrg.mjs +0 -446
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { D as
|
|
4
|
-
|
|
5
|
-
import "./identity-HNO1Oe9B.mjs";
|
|
6
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/thinking.ts
|
|
3
|
+
import { D as FencedThinkingScanner, O as partialSuffixOverlapAny } from "./utils-CUPhpw9A.mjs";
|
|
4
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/thinking.ts
|
|
7
5
|
/**
|
|
8
6
|
* Every dialect's in-band thinking section in its canonical `renderThinking`
|
|
9
7
|
* form (see the sibling `./*.ts` scanners). {@link ThinkingInbandScanner} heals
|
|
@@ -18,7 +16,8 @@ import "./identity-HNO1Oe9B.mjs";
|
|
|
18
16
|
const TAGS = [
|
|
19
17
|
{
|
|
20
18
|
open: "<think>",
|
|
21
|
-
close: "</think>"
|
|
19
|
+
close: "</think>",
|
|
20
|
+
impliedOpen: true
|
|
22
21
|
},
|
|
23
22
|
{
|
|
24
23
|
open: "<thinking>",
|
|
@@ -47,7 +46,10 @@ const TAGS = [
|
|
|
47
46
|
}
|
|
48
47
|
];
|
|
49
48
|
const OPENS = TAGS.map((tag) => tag.open);
|
|
49
|
+
const IMPLIED_OPEN_TAGS = TAGS.filter((tag) => tag.impliedOpen);
|
|
50
|
+
const IMPLIED_OPEN_DELIMITERS = [...OPENS, ...IMPLIED_OPEN_TAGS.map((tag) => tag.close)];
|
|
50
51
|
var ThinkingInbandScanner = class {
|
|
52
|
+
#impliedOpen;
|
|
51
53
|
#buffer = "";
|
|
52
54
|
#closeTag = "";
|
|
53
55
|
#thinking = "";
|
|
@@ -63,6 +65,9 @@ var ThinkingInbandScanner = class {
|
|
|
63
65
|
* stream — or one indented ≤3 spaces, as CommonMark allows — is recognized.
|
|
64
66
|
*/
|
|
65
67
|
#lineIndent = 0;
|
|
68
|
+
constructor(options = {}) {
|
|
69
|
+
this.#impliedOpen = options.impliedOpen === true;
|
|
70
|
+
}
|
|
66
71
|
feed(text) {
|
|
67
72
|
if (text.length === 0) return [];
|
|
68
73
|
this.#buffer += text;
|
|
@@ -127,7 +132,7 @@ var ThinkingInbandScanner = class {
|
|
|
127
132
|
if (this.#emitCode(final, events)) continue;
|
|
128
133
|
break;
|
|
129
134
|
}
|
|
130
|
-
const hit = scanVisible(this.#buffer, final);
|
|
135
|
+
const hit = scanVisible(this.#buffer, final, this.#impliedOpen);
|
|
131
136
|
if (hit.kind === "none") {
|
|
132
137
|
this.#emitText(this.#buffer, events);
|
|
133
138
|
this.#buffer = "";
|
|
@@ -138,6 +143,11 @@ var ThinkingInbandScanner = class {
|
|
|
138
143
|
this.#buffer = this.#buffer.slice(hit.index);
|
|
139
144
|
break;
|
|
140
145
|
}
|
|
146
|
+
if (hit.kind === "impliedClose") {
|
|
147
|
+
this.#buffer = this.#buffer.slice(hit.index + hit.tag.close.length);
|
|
148
|
+
events.push({ type: "impliedThinkingEnd" });
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
141
151
|
if (hit.kind === "code") {
|
|
142
152
|
const fenced = hit.ticks >= 3 && this.#lineIndent >= 0 && this.#lineIndent <= 3;
|
|
143
153
|
this.#emitText(this.#buffer.slice(hit.index, hit.index + hit.ticks), events);
|
|
@@ -217,14 +227,16 @@ var ThinkingInbandScanner = class {
|
|
|
217
227
|
};
|
|
218
228
|
/**
|
|
219
229
|
* Walk idle visible text for the earliest boundary: a leaked reasoning-tag open,
|
|
220
|
-
* a
|
|
221
|
-
*
|
|
230
|
+
* a bare close of an implied-open tag (when `impliedOpen`), a Markdown
|
|
231
|
+
* code-span/fence opener (a backtick run), or — when more chunks may follow — a
|
|
232
|
+
* held partial delimiter at the buffer tail.
|
|
222
233
|
*
|
|
223
234
|
* Reasoning tags win at any position so the gemini ` ```thinking ` fence is
|
|
224
235
|
* healed instead of being read as a code fence. Backtick runs enter code mode so
|
|
225
236
|
* a literal `<think>` inside inline code or a fenced block stays visible text.
|
|
226
237
|
*/
|
|
227
|
-
function scanVisible(buffer, final) {
|
|
238
|
+
function scanVisible(buffer, final, impliedOpen) {
|
|
239
|
+
const delimiters = impliedOpen ? IMPLIED_OPEN_DELIMITERS : OPENS;
|
|
228
240
|
for (let i = 0; i < buffer.length; i++) {
|
|
229
241
|
const tag = TAGS.find((candidate) => buffer.startsWith(candidate.open, i));
|
|
230
242
|
if (tag) return {
|
|
@@ -232,9 +244,17 @@ function scanVisible(buffer, final) {
|
|
|
232
244
|
index: i,
|
|
233
245
|
tag
|
|
234
246
|
};
|
|
247
|
+
if (impliedOpen) {
|
|
248
|
+
const closed = IMPLIED_OPEN_TAGS.find((candidate) => buffer.startsWith(candidate.close, i));
|
|
249
|
+
if (closed) return {
|
|
250
|
+
kind: "impliedClose",
|
|
251
|
+
index: i,
|
|
252
|
+
tag: closed
|
|
253
|
+
};
|
|
254
|
+
}
|
|
235
255
|
if (!final) {
|
|
236
256
|
const rest = buffer.slice(i);
|
|
237
|
-
if (
|
|
257
|
+
if (delimiters.some((delimiter) => delimiter.length > rest.length && delimiter.startsWith(rest))) return {
|
|
238
258
|
kind: "hold",
|
|
239
259
|
index: i
|
|
240
260
|
};
|
|
@@ -313,179 +333,4 @@ function isAllBackticks(text) {
|
|
|
313
333
|
return text.length > 0;
|
|
314
334
|
}
|
|
315
335
|
//#endregion
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Streaming-safe filters for leaked chat-template tool-call and thinking markup.
|
|
319
|
-
*
|
|
320
|
-
* Hosted models sometimes leak raw template markup into visible `content` instead
|
|
321
|
-
* of returning structured events. Tool-call healing delegates to the same
|
|
322
|
-
* dialect scanners used by owned in-band tool calling; this file keeps the
|
|
323
|
-
* provider-facing compatibility wrapper and model/provider gating.
|
|
324
|
-
*/
|
|
325
|
-
const KIMI_SECTION_END = "<|tool_calls_section_end|>";
|
|
326
|
-
const DSML_TOOL_CALLS_CLOSE_FULLWIDTH = "</|DSML|tool_calls>";
|
|
327
|
-
const DSML_TOOL_CALLS_CLOSE_ASCII = "</|DSML|tool_calls>";
|
|
328
|
-
/**
|
|
329
|
-
* State machine that consumes streamed visible text and emits cleaned text,
|
|
330
|
-
* thinking deltas, and reconstructed tool calls.
|
|
331
|
-
*
|
|
332
|
-
* A {@link ThinkingInbandScanner} always heals leaked reasoning idioms
|
|
333
|
-
* (`<think>`, `<thinking>`, ` ```thinking `, Gemma/Harmony channels, …) out of
|
|
334
|
-
* the visible channel. For Kimi / DeepSeek-DSML the provider tool-call grammar
|
|
335
|
-
* runs first and its cleaned text is piped through that thinking healer, so a
|
|
336
|
-
* model can leak tool-call markup and reasoning in the same stream.
|
|
337
|
-
*
|
|
338
|
-
* Feed only one stream channel (usually `delta.content` / `message.content`).
|
|
339
|
-
* Mixing reasoning and visible text into the same instance can corrupt held-back
|
|
340
|
-
* partial tag buffers.
|
|
341
|
-
*/
|
|
342
|
-
var StreamMarkupHealing = class {
|
|
343
|
-
#pattern;
|
|
344
|
-
/** Provider tool-call grammar (Kimi tokens / DSML envelope); absent for plain text streams. */
|
|
345
|
-
#toolScanner;
|
|
346
|
-
/** Always-on healer for leaked reasoning idioms in the visible text channel. */
|
|
347
|
-
#thinkingScanner = new ThinkingInbandScanner();
|
|
348
|
-
#sectionTerminated = false;
|
|
349
|
-
#completed = [];
|
|
350
|
-
constructor(options) {
|
|
351
|
-
this.#pattern = options.pattern;
|
|
352
|
-
this.#toolScanner = options.pattern === "kimi" ? createInbandScanner("kimi") : options.pattern === "dsml" ? createInbandScanner("xml", { xmlTagset: "dsml" }) : void 0;
|
|
353
|
-
}
|
|
354
|
-
get pattern() {
|
|
355
|
-
return this.#pattern;
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Feed a chunk and return visible text only. Reconstructed tool calls are
|
|
359
|
-
* stored for {@link drainCompleted}; thinking blocks are intentionally not
|
|
360
|
-
* returned by this compatibility helper. Use {@link feedEvents} when the caller
|
|
361
|
-
* needs ordered text/thinking/tool-call events.
|
|
362
|
-
*/
|
|
363
|
-
feed(text) {
|
|
364
|
-
let clean = "";
|
|
365
|
-
for (const event of this.feedEvents(text)) if (event.type === "text") clean += event.text;
|
|
366
|
-
else if (event.type === "toolCall") this.#completed.push(event.call);
|
|
367
|
-
return clean;
|
|
368
|
-
}
|
|
369
|
-
/** Feed a chunk and return cleaned text/thinking/tool-call events in stream order. */
|
|
370
|
-
feedEvents(text) {
|
|
371
|
-
if (text.length === 0) return [];
|
|
372
|
-
this.#markSectionClosed(text);
|
|
373
|
-
if (!this.#toolScanner) return this.#convertScannerEvents(this.#thinkingScanner.feed(text));
|
|
374
|
-
return this.#convertScannerEvents(this.#healThinking(this.#toolScanner.feed(text)));
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Feed a chunk and return cleaned events, excluding synthesized tool calls.
|
|
378
|
-
* Used when the upstream chunk also carries structured `tool_calls`, keeping
|
|
379
|
-
* that structured payload as the single source of truth while preserving
|
|
380
|
-
* adjacent text and thinking events.
|
|
381
|
-
*/
|
|
382
|
-
feedEventsWithoutCalls(text) {
|
|
383
|
-
const events = this.feedEvents(text);
|
|
384
|
-
let out;
|
|
385
|
-
for (let i = 0; i < events.length; i++) {
|
|
386
|
-
const event = events[i];
|
|
387
|
-
if (event.type === "toolCall") out ??= events.slice(0, i);
|
|
388
|
-
else if (out) out.push(event);
|
|
389
|
-
}
|
|
390
|
-
return out ?? events;
|
|
391
|
-
}
|
|
392
|
-
/** Drain accumulated tool calls from calls to {@link feed}. */
|
|
393
|
-
drainCompleted() {
|
|
394
|
-
if (this.#completed.length === 0) return [];
|
|
395
|
-
return this.#completed.splice(0, this.#completed.length);
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Flush held-back stream-end fragments as ordered events. Partial tool-call
|
|
399
|
-
* sections/envelopes are dropped by the delegated scanners; unterminated
|
|
400
|
-
* thinking blocks are emitted as thinking, matching the previous MiniMax parser
|
|
401
|
-
* behavior.
|
|
402
|
-
*/
|
|
403
|
-
flushEvents() {
|
|
404
|
-
const tail = this.#toolScanner ? this.#healThinking(this.#toolScanner.flush()) : [];
|
|
405
|
-
tail.push(...this.#thinkingScanner.flush());
|
|
406
|
-
return this.#convertScannerEvents(tail);
|
|
407
|
-
}
|
|
408
|
-
/** Flush held-back text only. Reconstructed calls are retained for {@link drainCompleted}. */
|
|
409
|
-
flushPending() {
|
|
410
|
-
let clean = "";
|
|
411
|
-
for (const event of this.flushEvents()) if (event.type === "text") clean += event.text;
|
|
412
|
-
else if (event.type === "toolCall") this.#completed.push(event.call);
|
|
413
|
-
return clean;
|
|
414
|
-
}
|
|
415
|
-
/** True once any configured tool-call section/envelope has fully closed. */
|
|
416
|
-
get sectionClosed() {
|
|
417
|
-
return this.#sectionTerminated;
|
|
418
|
-
}
|
|
419
|
-
#markSectionClosed(text) {
|
|
420
|
-
if (this.#sectionTerminated || !this.#toolScanner) return;
|
|
421
|
-
if (this.#pattern === "kimi") {
|
|
422
|
-
this.#sectionTerminated = text.includes(KIMI_SECTION_END);
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
this.#sectionTerminated = text.includes(DSML_TOOL_CALLS_CLOSE_FULLWIDTH) || text.includes(DSML_TOOL_CALLS_CLOSE_ASCII);
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Re-scan the tool scanner's visible text through the always-on thinking
|
|
429
|
-
* healer: `text` events are healed for leaked reasoning idioms, while the tool
|
|
430
|
-
* scanner's own thinking / tool-call events pass through in stream order.
|
|
431
|
-
*/
|
|
432
|
-
#healThinking(toolEvents) {
|
|
433
|
-
const out = [];
|
|
434
|
-
for (const event of toolEvents) if (event.type === "text") out.push(...this.#thinkingScanner.feed(event.text));
|
|
435
|
-
else out.push(event);
|
|
436
|
-
return out;
|
|
437
|
-
}
|
|
438
|
-
#convertScannerEvents(events) {
|
|
439
|
-
const out = [];
|
|
440
|
-
for (const event of events) switch (event.type) {
|
|
441
|
-
case "text":
|
|
442
|
-
out.push({
|
|
443
|
-
type: "text",
|
|
444
|
-
text: event.text
|
|
445
|
-
});
|
|
446
|
-
break;
|
|
447
|
-
case "thinkingDelta":
|
|
448
|
-
if (event.delta.length > 0) out.push({
|
|
449
|
-
type: "thinking",
|
|
450
|
-
thinking: event.delta
|
|
451
|
-
});
|
|
452
|
-
break;
|
|
453
|
-
case "toolEnd": out.push({
|
|
454
|
-
type: "toolCall",
|
|
455
|
-
call: {
|
|
456
|
-
id: generateHealedToolCallId(),
|
|
457
|
-
name: event.name,
|
|
458
|
-
arguments: JSON.stringify(event.arguments)
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
return out;
|
|
463
|
-
}
|
|
464
|
-
};
|
|
465
|
-
function generateHealedToolCallId() {
|
|
466
|
-
return `call_${crypto.randomUUID().replace(/-/g, "").slice(0, 24)}`;
|
|
467
|
-
}
|
|
468
|
-
/** Cheap model/provider gate for Kimi-K2 chat-template token leaks. */
|
|
469
|
-
function modelMayLeakKimiToolCalls(provider, modelId) {
|
|
470
|
-
if (provider === "kimi-code" || provider === "moonshot") return true;
|
|
471
|
-
return /kimi[-/_.]?k2/i.test(modelId);
|
|
472
|
-
}
|
|
473
|
-
/** Cheap model/provider gate for DeepSeek DSML envelope leaks. */
|
|
474
|
-
function modelMayLeakDsmlToolCalls(provider, modelId) {
|
|
475
|
-
if (!isDeepseekModelIdOrName(modelId)) return false;
|
|
476
|
-
return provider === "ollama" || provider === "ollama-cloud" || provider === "nvidia" || provider === "deepseek" || provider === "fireworks" || provider === "nanogpt" || provider === "opencode-go" || provider === "openrouter";
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Pick the leaked-markup healer for an OpenAI-compatible / Ollama visible-text
|
|
480
|
-
* stream. Kimi chat-template tokens and DeepSeek DSML envelopes need their
|
|
481
|
-
* dedicated tool-call grammars; every other model uses `"thinking"`. All three
|
|
482
|
-
* patterns run the generic {@link ThinkingInbandScanner}, so leaked reasoning
|
|
483
|
-
* idioms (e.g. a Gemini ` ```thinking ` fence on OpenRouter) are always healed.
|
|
484
|
-
*/
|
|
485
|
-
function getStreamMarkupHealingPattern(provider, modelId) {
|
|
486
|
-
if (modelMayLeakKimiToolCalls(provider, modelId)) return "kimi";
|
|
487
|
-
if (modelMayLeakDsmlToolCalls(provider, modelId)) return "dsml";
|
|
488
|
-
return "thinking";
|
|
489
|
-
}
|
|
490
|
-
//#endregion
|
|
491
|
-
export { getStreamMarkupHealingPattern as n, StreamMarkupHealing as t };
|
|
336
|
+
export { ThinkingInbandScanner as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@
|
|
4
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@18.1.17/node_modules/@oh-my-pi/pi-utils/src/turndown/gfm.ts
|
|
5
5
|
function descendantElements(node, name) {
|
|
6
6
|
const matches = [];
|
|
7
7
|
for (const child of Array.from(node.children)) {
|
|
@@ -98,7 +98,7 @@ const gfm = (service) => {
|
|
|
98
98
|
taskListItems(service);
|
|
99
99
|
};
|
|
100
100
|
//#endregion
|
|
101
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@
|
|
101
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@18.1.17/node_modules/@oh-my-pi/pi-utils/src/turndown/html.ts
|
|
102
102
|
const VOID_ELEMENTS = {
|
|
103
103
|
AREA: true,
|
|
104
104
|
BASE: true,
|
|
@@ -284,7 +284,7 @@ function parseHtmlFragment(html) {
|
|
|
284
284
|
const stack = [root];
|
|
285
285
|
for (const token of htmlTokens(html)) {
|
|
286
286
|
const parent = stack[stack.length - 1] ?? root;
|
|
287
|
-
if (token.startsWith("<!--") ||
|
|
287
|
+
if (token.startsWith("<!--") || token.startsWith("<!")) continue;
|
|
288
288
|
if (!token.startsWith("<")) {
|
|
289
289
|
parent.append(new HtmlText(decodeEntities(token)));
|
|
290
290
|
continue;
|
|
@@ -317,7 +317,7 @@ function serializeNode(node) {
|
|
|
317
317
|
return Array.from(node.childNodes).map(serializeNode).join("");
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@
|
|
320
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@18.1.17/node_modules/@oh-my-pi/pi-utils/src/turndown/service.ts
|
|
321
321
|
const BLOCK_ELEMENTS = {
|
|
322
322
|
ADDRESS: true,
|
|
323
323
|
ARTICLE: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@
|
|
3
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@18.1.17/node_modules/@oh-my-pi/pi-utils/src/type-guards.ts
|
|
4
4
|
function isRecord(value) {
|
|
5
5
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { c as combineSignals } from "./src-
|
|
3
|
+
import { c as combineSignals } from "./src-BwW51vA5.mjs";
|
|
4
4
|
import { t as ToolAbortError } from "./tool-errors-DoyxivAR.mjs";
|
|
5
5
|
import { scheduler } from "node:timers/promises";
|
|
6
6
|
//#region src/tools/omp/web/scrapers/types.ts
|
|
@@ -176,7 +176,7 @@ function getTurndown() {
|
|
|
176
176
|
return turndownPromise;
|
|
177
177
|
}
|
|
178
178
|
async function initTurndown() {
|
|
179
|
-
const { createTurndown } = await import("./turndown-
|
|
179
|
+
const { createTurndown } = await import("./turndown-DrX1M4WG.mjs").then((n) => n.r);
|
|
180
180
|
return createTurndown();
|
|
181
181
|
}
|
|
182
182
|
/**
|