@openclaw/ai 2026.11.3 → 2026.11.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/dist/.source-module-urls/fe058cc430242ce2ab0dfbcbe153e240a52cf9c3072c3dc0a73e5f956b6ba49b.json +1 -0
- package/dist/anthropic-DEKgalVg.mjs +182 -0
- package/dist/{anthropic-payload-policy-C0ki72BT.d.mts → anthropic-payload-policy-CXCJ5Pmj.d.mts} +21 -4
- package/dist/{anthropic-stream-reducer-yWDb5Cct.mjs → anthropic-stream-lifecycle-DF2qVvg1.mjs} +845 -649
- package/dist/{anthropic-tool-projection-C2-d1eZ3.d.mts → anthropic-tool-projection-D5DyrL6C.d.mts} +6 -7
- package/dist/{anthropic-tool-projection-DZOKfAmL.mjs → anthropic-tool-projection-dGRfr4iT.mjs} +22 -32
- package/dist/{api-registry-gDt0faai.d.mts → api-registry-DY2MLUyg.d.mts} +2 -2
- package/dist/assistant-output-CD4kY9gu.mjs +16 -0
- package/dist/{azure-openai-responses-BvvXzZbi.mjs → azure-openai-responses-DbQV5RTx.mjs} +47 -53
- package/dist/{cloudflare-Dttf8jKq.mjs → cloudflare-BJ2_Xabx.mjs} +1 -1
- package/dist/{credential-redaction-XvsPf7Yi.d.mts → credential-redaction-DrgndwTJ.d.mts} +5 -3
- package/dist/{deferred-event-buffer-DAvyP7qA.mjs → deferred-event-buffer-tIGkTkTm.mjs} +1 -2
- package/dist/{diagnostics-v7oVEW59.mjs → diagnostics-CloVGQiK.mjs} +27 -20
- package/dist/{diagnostics-DzrF1h4J.mjs → diagnostics-o1PrVNQb.mjs} +11 -4
- package/dist/diagnostics.d.mts +6 -7
- package/dist/diagnostics.mjs +4 -4
- package/dist/{env-api-keys-Xd8dm_aV.mjs → env-api-keys-BuHc86ya.mjs} +1 -26
- package/dist/event-stream-B4ZcSvsu.d.mts +1 -0
- package/dist/{event-stream-CzpE1g_o.d.mts → event-stream-BYmtRe8-.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -2
- package/dist/expect-lbe3Hgrh.mjs +8 -0
- package/dist/{github-copilot-request-facts-F-EmvkpW.mjs → github-copilot-request-facts-BZ_EMo7X.mjs} +1 -1
- package/dist/{google-Cpi_cLKZ.mjs → google-B1g82bn4.mjs} +7 -8
- package/dist/{google-interactions-CGINbsjO.mjs → google-interactions-Ckr0Z99Z.mjs} +243 -269
- package/dist/{google-messages-DQMgG5yG.mjs → google-messages-A-9d3y5V.mjs} +52 -18
- package/dist/{google-provider-stream-BHd0cST9.mjs → google-provider-stream-CNVh4gpm.mjs} +19 -11
- package/dist/{google-shared-vtag8bj5.mjs → google-shared-WNM86ZcW.mjs} +72 -42
- package/dist/{google-vertex-eKoUnW7N.mjs → google-vertex-CXjleC6g.mjs} +3 -3
- package/dist/{google-video-slots-D8tPH8wX.mjs → google-video-slots-Bxt-OXO8.mjs} +1 -1
- package/dist/{host-CWt55nnF.mjs → host-DX7ORpeH.mjs} +46 -39
- package/dist/{host-jJOffdlW.d.mts → host-ccbwPC3A.d.mts} +17 -9
- package/dist/{host-policy-Dm7PM6AD.mjs → host-policy-jCZebuXx.mjs} +2 -2
- package/dist/index-Bczt0MnO.d.mts +17 -0
- package/dist/index.d.mts +8 -7
- package/dist/index.mjs +9 -7
- package/dist/internal/anthropic.d.mts +21 -26
- package/dist/internal/anthropic.mjs +6 -6
- package/dist/internal/google-model-family.mjs +1 -1
- package/dist/internal/google.d.mts +15 -0
- package/dist/internal/google.mjs +1 -0
- package/dist/internal/model-request-body.d.mts +37 -0
- package/dist/internal/model-request-body.mjs +106 -0
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +14 -12
- package/dist/internal/openai.mjs +11 -10
- package/dist/internal/reasoning-tag-text-partitioner.d.mts +26 -0
- package/dist/{reasoning-tag-text-partitioner-CU9A4Lg8.mjs → internal/reasoning-tag-text-partitioner.mjs} +313 -111
- package/dist/internal/retry-after.d.mts +2 -2
- package/dist/internal/retry-after.mjs +96 -32
- package/dist/internal/runtime.d.mts +15 -41
- package/dist/internal/runtime.mjs +9 -10
- package/dist/internal/shared.d.mts +21 -25
- package/dist/internal/shared.mjs +9 -98
- package/dist/internal/tool-schema.d.mts +10 -10
- package/dist/internal/tool-schema.mjs +4 -4
- package/dist/{llm-request-activity-CfMuh5cC.mjs → llm-request-activity-DzaHoRAU.mjs} +2 -2
- package/dist/mistral-CjHkvsqR.mjs +3741 -0
- package/dist/{openai.LICENSE → mistral.LICENSE} +1 -1
- package/dist/{model-transport-url-BrsjjdjR.d.mts → model-transport-url-BdksnBqu.d.mts} +6 -8
- package/dist/{number-coercion-37gmNkuA.mjs → number-coercion-C7HsBgUL.mjs} +7 -2
- package/dist/observe-async-iterator-AlARO5wS.d.mts +178 -0
- package/dist/observe-async-iterator-DgmegcZR.mjs +181 -0
- package/dist/{openai-chatgpt-responses-BZa3SySh.mjs → openai-chatgpt-responses-CwS5JP7A.mjs} +61 -80
- package/dist/{openai-completions-compat-CBvb2eld.d.mts → openai-completions-compat-CJ-NsDzg.d.mts} +12 -6
- package/dist/{openai-completions-compat-bNQXF1y9.mjs → openai-completions-compat-CstlTQuF.mjs} +74 -50
- package/dist/{openai-completions-CCZ_UHCk.mjs → openai-completions-sj4S-RXQ.mjs} +5 -5
- package/dist/openai-completions-transport-BDAIA0_P.mjs +3406 -0
- package/dist/{openai-prompt-cache-DgjD-UL5.d.mts → openai-prompt-cache-BZGaIWYh.d.mts} +4 -4
- package/dist/{openai-prompt-cache-B9AvdoEo.mjs → openai-prompt-cache-CgDoFhO0.mjs} +5 -4
- package/dist/{openai-responses-compaction-replay-_sUXtcwU.d.mts → openai-responses-compaction-replay-CNHk6k53.d.mts} +4 -4
- package/dist/{openai-responses-contracts-B1nkeLL6.d.mts → openai-responses-contracts-BXMcvO7F.d.mts} +4 -10
- package/dist/{openai-responses-contracts-B5mGAbR6.mjs → openai-responses-contracts-xU-n9AJJ.mjs} +36 -37
- package/dist/{openai-responses-endpoint-CfKR6N5f.mjs → openai-responses-endpoint-DCkURKS0.mjs} +55 -8
- package/dist/openai-responses-ev_c6oTy.mjs +89 -0
- package/dist/{openai-responses-payload-policy-BzM52TTH.d.mts → openai-responses-payload-policy-DyE30gdD.d.mts} +7 -7
- package/dist/{openai-responses-request-lifecycle-CTqHc02t.mjs → openai-responses-request-lifecycle-BuOs0mwI.mjs} +12 -26
- package/dist/{openai-responses-shared-wx9v1MCn.mjs → openai-responses-shared-BmRQnUPP.mjs} +633 -1493
- package/dist/{openai-responses-terminal-usage-CpVjkqn-.d.mts → openai-responses-terminal-usage-D7IhRA6i.d.mts} +9 -3
- package/dist/{openai-tool-schema-BTEU2xmN.mjs → openai-tool-schema-CsoYgnWy.mjs} +97 -122
- package/dist/otel-Buswj0Mf.mjs +766 -0
- package/dist/{overflow-OF3PgPbw.mjs → overflow-CpApyjG2.mjs} +1 -1
- package/dist/{positive-integer-Bb4Evc7L.mjs → positive-integer-DiqE5vNi.mjs} +2 -3
- package/dist/{prompt-cache-stability-D_MeCQFI.mjs → prompt-cache-stability-w-ICeyOI.mjs} +1 -1
- package/dist/{provider-error-qtZD2inE.mjs → provider-error-DD-fo4Rz.mjs} +71 -234
- package/dist/{provider-options-DAzsyi49.d.mts → provider-options-Mo8NM5d1.d.mts} +16 -5
- package/dist/{provider-replay-context-4vxI7p4V.mjs → provider-replay-context-xyU7-CiT.mjs} +2 -2
- package/dist/provider-transcript-transform-DtaxNcC1.mjs +32 -0
- package/dist/{provider-transport-turn-state-D_GjPJHe.mjs → provider-transport-turn-state-BIS8maBK.mjs} +4 -4
- package/dist/{provider-types-CWl4VXvE.d.mts → provider-types-B1e98js5.d.mts} +3 -3
- package/dist/provider-types.d.mts +7 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +26 -29
- package/dist/{record-coerce-CNDovvft.mjs → record-coerce-BQaoiN3r.mjs} +4 -1
- package/dist/request-headers-DO4Mqhw1.mjs +10 -0
- package/dist/{required-api-key-D088S4Cd.mjs → required-api-key-2zZTkmsi.mjs} +1 -1
- package/dist/{retry-after-BrmTv0jL.d.mts → retry-after-DnHBlFS2.d.mts} +21 -1
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/{sanitize-unicode-ZqVLLEKC.d.mts → sanitize-unicode-BISmUlUv.d.mts} +2 -2
- package/dist/{simple-options-xJkqrG_E.mjs → simple-options-tLSeECry.mjs} +108 -82
- package/dist/src-BUsVkrNt.mjs +105 -0
- package/dist/{src-CyA0zJnt.mjs → src-CQ7nH2mL.mjs} +4 -7
- package/dist/stable-stringify-CchQEmeA.mjs +84 -0
- package/dist/{stream-C4YDqhFj.mjs → stream-DrtAWu7c.mjs} +2 -6
- package/dist/{stream-first-event-timeout-D_TfJHRJ.mjs → stream-first-event-timeout-B7RcufAV.mjs} +16 -13
- package/dist/{string-coerce-Cj8sqWHx.mjs → string-coerce-BCuWMIrk.mjs} +1 -1
- package/dist/string-normalization-B8TDDBX_.mjs +32 -0
- package/dist/telemetry-CvK1yQg7.mjs +582 -0
- package/dist/{tool-schema-json-projection-B1sTYwfH.mjs → tool-schema-json-projection-BQpiJlXJ.mjs} +53 -69
- package/dist/{transport-stream-shared-lhgkTOz3.mjs → transport-stream-shared-D2uFMhMc.mjs} +177 -93
- package/dist/{transport-stream-shared-8ru8eX4s.d.mts → transport-stream-shared-D3IAU4jn.d.mts} +29 -15
- package/dist/{transport-utils-DwOpuTjL.mjs → transport-utils-Da_39MYi.mjs} +23 -38
- package/dist/transports.d.mts +42 -39
- package/dist/transports.mjs +215 -296
- package/dist/{types-CVYzKrMl.d.mts → types-BVdTf0YV.d.mts} +38 -3
- package/dist/types-Cb3-5WM9.d.mts +1 -0
- package/dist/{types-BXd0kI8-.mjs → types-OVEWUaDh.mjs} +3 -1
- package/dist/types.d.mts +7 -6
- package/dist/types.mjs +7 -5
- package/dist/{validation-9FSkE8T-.mjs → validation-DGXqfvkj.mjs} +45 -27
- package/dist/{validation-BQ5u20Ru.d.mts → validation-QmyD0E5A.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -2
- package/package.json +40 -6
- package/dist/anthropic-lueA8LUg.mjs +0 -221
- package/dist/assistant-output-BnQm3fov.mjs +0 -47
- package/dist/event-stream-CDpFza-M.d.mts +0 -1
- package/dist/index-DSprYWaz.d.mts +0 -185
- package/dist/mistral-CQ7aoWg2.mjs +0 -512
- package/dist/model-request-body-BD5vy4rP.d.mts +0 -17
- package/dist/openai-CiRi-nVE.mjs +0 -20077
- package/dist/openai-completions-transport-DFvSBbUT.mjs +0 -10881
- package/dist/openai-responses-DQsZKUoI.mjs +0 -87
- package/dist/rolldown-runtime-B4iAMlE-.mjs +0 -35
- package/dist/types-CBJthzJX.d.mts +0 -1
- package/dist/ws.LICENSE +0 -20
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import "../src-BUsVkrNt.mjs";
|
|
3
|
+
import { t as expectDefined } from "../expect-lbe3Hgrh.mjs";
|
|
3
4
|
//#region node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
|
|
4
5
|
/**
|
|
5
6
|
* @typedef {import('mdast').Nodes} Nodes
|
|
@@ -11831,7 +11832,7 @@ function getPoint(events, index) {
|
|
|
11831
11832
|
return event[1][side];
|
|
11832
11833
|
}
|
|
11833
11834
|
//#endregion
|
|
11834
|
-
//#region packages/markdown-core/src/reasoning-tag-
|
|
11835
|
+
//#region packages/markdown-core/src/reasoning-tag-syntax.ts
|
|
11835
11836
|
const REASONING_TAG_NAMES = [
|
|
11836
11837
|
"think",
|
|
11837
11838
|
"thinking",
|
|
@@ -11849,7 +11850,6 @@ const REASONING_TAG_NAMES = [
|
|
|
11849
11850
|
"mm:reasoning"
|
|
11850
11851
|
];
|
|
11851
11852
|
const REASONING_TAG_NAME_SET = new Set(REASONING_TAG_NAMES);
|
|
11852
|
-
const DISABLE_HTML_MARKDOWN = { disable: { null: ["htmlFlow", "htmlText"] } };
|
|
11853
11853
|
/** Scans quote-aware provider reasoning tags with iterative malformed recovery. */
|
|
11854
11854
|
function scanReasoningTags(text, final = true) {
|
|
11855
11855
|
const tags = [];
|
|
@@ -11953,6 +11953,143 @@ function findNextLineEnding(text, start) {
|
|
|
11953
11953
|
if (carriageReturn === -1) return lineFeed;
|
|
11954
11954
|
return lineFeed === -1 ? carriageReturn : Math.min(carriageReturn, lineFeed);
|
|
11955
11955
|
}
|
|
11956
|
+
function isInsideCode(index, spans) {
|
|
11957
|
+
let low = 0;
|
|
11958
|
+
let high = spans.length - 1;
|
|
11959
|
+
while (low <= high) {
|
|
11960
|
+
const middle = Math.floor((low + high) / 2);
|
|
11961
|
+
const span = spans[middle];
|
|
11962
|
+
if (!span) return false;
|
|
11963
|
+
if (index < span[0]) high = middle - 1;
|
|
11964
|
+
else if (index >= span[1]) low = middle + 1;
|
|
11965
|
+
else return true;
|
|
11966
|
+
}
|
|
11967
|
+
return false;
|
|
11968
|
+
}
|
|
11969
|
+
function reduceReasoningText(text, codeSpans, state, options) {
|
|
11970
|
+
const output = [];
|
|
11971
|
+
const checkpoint = options.checkpoint;
|
|
11972
|
+
let openStart;
|
|
11973
|
+
const emit = (kind, value) => {
|
|
11974
|
+
if (!value) return;
|
|
11975
|
+
const previous = output.at(-1);
|
|
11976
|
+
if (previous?.kind === kind) previous.text += value;
|
|
11977
|
+
else output.push({
|
|
11978
|
+
kind,
|
|
11979
|
+
text: value
|
|
11980
|
+
});
|
|
11981
|
+
if (kind === "text" && value.trim()) state.visibleEver = true;
|
|
11982
|
+
};
|
|
11983
|
+
const append = (value) => {
|
|
11984
|
+
if (!value) return;
|
|
11985
|
+
if (state.depth > 0 && state.pending) {
|
|
11986
|
+
state.pending.content += value;
|
|
11987
|
+
state.pending.protectedClose ||= scanReasoningTags(value).tags.some((tag) => tag.isClose);
|
|
11988
|
+
} else emit("text", value);
|
|
11989
|
+
};
|
|
11990
|
+
const start = options.start ?? 0;
|
|
11991
|
+
const scan = scanReasoningTags(text.slice(start), options.final);
|
|
11992
|
+
const tags = [];
|
|
11993
|
+
for (const scannedTag of scan.tags) {
|
|
11994
|
+
const index = scannedTag.index + start;
|
|
11995
|
+
if (!isInsideCode(index, codeSpans)) tags.push({
|
|
11996
|
+
...scannedTag,
|
|
11997
|
+
index
|
|
11998
|
+
});
|
|
11999
|
+
}
|
|
12000
|
+
const mustParseRemainder = [];
|
|
12001
|
+
if (options.scope === "leading") {
|
|
12002
|
+
let mustParse = false;
|
|
12003
|
+
for (let index = tags.length - 1; index >= 0; index -= 1) {
|
|
12004
|
+
mustParse ||= tags[index]?.isPrivate === true;
|
|
12005
|
+
mustParseRemainder[index] = mustParse;
|
|
12006
|
+
mustParse ||= tags[index]?.isClose === true;
|
|
12007
|
+
}
|
|
12008
|
+
}
|
|
12009
|
+
let cursor = start;
|
|
12010
|
+
for (const [tagIndex, tag] of tags.entries()) {
|
|
12011
|
+
const beforeTag = text.slice(cursor, tag.index);
|
|
12012
|
+
append(beforeTag);
|
|
12013
|
+
const tagEnd = tag.index + tag.text.length;
|
|
12014
|
+
if (checkpoint && tag.index < checkpoint.boundary && tagEnd > checkpoint.boundary) checkpoint.holdStart = Math.min(checkpoint.holdStart, tag.index);
|
|
12015
|
+
if (tag.isSelfClosing) {
|
|
12016
|
+
if (checkpoint && state.depth === 0 && options.scope === "leading" && state.visibleEver) checkpoint.terminalLiteral = true;
|
|
12017
|
+
if (state.depth === 0 && options.scope === "leading" && state.visibleEver) {
|
|
12018
|
+
emit("text", text.slice(tag.index));
|
|
12019
|
+
cursor = text.length;
|
|
12020
|
+
break;
|
|
12021
|
+
}
|
|
12022
|
+
cursor = tagEnd;
|
|
12023
|
+
continue;
|
|
12024
|
+
}
|
|
12025
|
+
if (!tag.isClose) {
|
|
12026
|
+
if (state.depth === 0 && options.scope === "leading" && state.visibleEver && !mustParseRemainder[tagIndex]) {
|
|
12027
|
+
if (checkpoint) checkpoint.holdStart = Math.min(checkpoint.holdStart, tag.index);
|
|
12028
|
+
emit("text", text.slice(tag.index));
|
|
12029
|
+
cursor = text.length;
|
|
12030
|
+
break;
|
|
12031
|
+
}
|
|
12032
|
+
if (state.depth === 0) {
|
|
12033
|
+
openStart = tag.index;
|
|
12034
|
+
state.pending = {
|
|
12035
|
+
content: "",
|
|
12036
|
+
containsPrivate: tag.isPrivate,
|
|
12037
|
+
openTag: tag.text,
|
|
12038
|
+
protectedClose: false,
|
|
12039
|
+
visibleBefore: state.visibleEver
|
|
12040
|
+
};
|
|
12041
|
+
} else if (state.pending) state.pending.containsPrivate ||= tag.isPrivate;
|
|
12042
|
+
state.depth += 1;
|
|
12043
|
+
cursor = tagEnd;
|
|
12044
|
+
continue;
|
|
12045
|
+
}
|
|
12046
|
+
if (state.depth > 0) {
|
|
12047
|
+
state.depth -= 1;
|
|
12048
|
+
if (state.depth === 0 && state.pending) {
|
|
12049
|
+
if (checkpoint && openStart !== void 0 && openStart < checkpoint.boundary && tagEnd > checkpoint.boundary) checkpoint.holdStart = Math.min(checkpoint.holdStart, openStart);
|
|
12050
|
+
openStart = void 0;
|
|
12051
|
+
if (!state.pending.containsPrivate) emit("thinking", state.pending.content);
|
|
12052
|
+
state.pending = void 0;
|
|
12053
|
+
} else if (state.pending) state.pending.protectedClose = true;
|
|
12054
|
+
cursor = tagEnd;
|
|
12055
|
+
continue;
|
|
12056
|
+
}
|
|
12057
|
+
if (options.mode === "visible") append(tag.text);
|
|
12058
|
+
else {
|
|
12059
|
+
const after = text.slice(tagEnd);
|
|
12060
|
+
const rawBefore = Boolean(beforeTag.trim()) || cursor === start && checkpoint?.rawBefore;
|
|
12061
|
+
if (checkpoint && rawBefore && !after.trim()) checkpoint.holdStart = Math.min(checkpoint.holdStart, tag.index);
|
|
12062
|
+
if (rawBefore && after.trim()) {
|
|
12063
|
+
if (checkpoint) {
|
|
12064
|
+
checkpoint.reset = true;
|
|
12065
|
+
checkpoint.lastReset = tag.index;
|
|
12066
|
+
}
|
|
12067
|
+
const thinking = output.filter((delta) => delta.kind === "thinking");
|
|
12068
|
+
output.splice(0, output.length, ...thinking);
|
|
12069
|
+
state.visibleEver = false;
|
|
12070
|
+
}
|
|
12071
|
+
}
|
|
12072
|
+
cursor = tagEnd;
|
|
12073
|
+
}
|
|
12074
|
+
append(text.slice(cursor));
|
|
12075
|
+
if (checkpoint) {
|
|
12076
|
+
checkpoint.rawBefore = Boolean(text.slice(cursor).trim()) || cursor === start && checkpoint.rawBefore;
|
|
12077
|
+
if (openStart !== void 0) checkpoint.holdStart = Math.min(checkpoint.holdStart, openStart);
|
|
12078
|
+
}
|
|
12079
|
+
if (options.final && state.depth > 0 && state.pending) {
|
|
12080
|
+
const pending = state.pending;
|
|
12081
|
+
if (!pending.containsPrivate) {
|
|
12082
|
+
if ((options.mode === "static-preserve" || options.mode === "static-strict" && !pending.visibleBefore && !pending.protectedClose || options.mode === "visible" && !pending.protectedClose) && options.recoverUnclosed !== false) emit("text", options.mode === "visible" && pending.visibleBefore ? pending.openTag + pending.content : pending.content);
|
|
12083
|
+
else emit("thinking", pending.content);
|
|
12084
|
+
}
|
|
12085
|
+
state.depth = 0;
|
|
12086
|
+
state.pending = void 0;
|
|
12087
|
+
}
|
|
12088
|
+
return output;
|
|
12089
|
+
}
|
|
12090
|
+
//#endregion
|
|
12091
|
+
//#region packages/markdown-core/src/reasoning-tag-parser.ts
|
|
12092
|
+
const DISABLE_HTML_MARKDOWN = { disable: { null: ["htmlFlow", "htmlText"] } };
|
|
11956
12093
|
function appendMarkdownSource(source, start, token, value) {
|
|
11957
12094
|
const extra = value.length - (token.end.offset - token.start.offset);
|
|
11958
12095
|
for (let cursor = start + source.offsets.length; cursor < token.end.offset; cursor += 1) {
|
|
@@ -12033,6 +12170,8 @@ function parseMarkdownOwnership(text, options) {
|
|
|
12033
12170
|
textSpans: [],
|
|
12034
12171
|
retainStart: 0,
|
|
12035
12172
|
completedParagraphs: [],
|
|
12173
|
+
definitions: [],
|
|
12174
|
+
unsettledDefinitionStarts: [],
|
|
12036
12175
|
...paragraphs ? { paragraphs } : {}
|
|
12037
12176
|
};
|
|
12038
12177
|
const sources = /* @__PURE__ */ new Map();
|
|
@@ -12050,13 +12189,17 @@ function parseMarkdownOwnership(text, options) {
|
|
|
12050
12189
|
const completedParagraphs = [];
|
|
12051
12190
|
const regions = [];
|
|
12052
12191
|
const textSpans = [];
|
|
12192
|
+
const definitions = [];
|
|
12193
|
+
let unresolvedImageCodeStart;
|
|
12053
12194
|
const blocks = tree.children ?? [];
|
|
12195
|
+
let retainStart = findListItemRetentionStart(text, blocks);
|
|
12054
12196
|
for (let index = 0; index < blocks.length; index += 1) {
|
|
12055
12197
|
const block = expectDefined(blocks[index], "Markdown block");
|
|
12056
12198
|
const next = blocks[index + 1]?.position?.start;
|
|
12057
12199
|
const blockStart = block.position?.start?.offset;
|
|
12058
12200
|
const endLine = block.position?.end?.line;
|
|
12059
12201
|
const blockEnd = block.position?.end?.offset;
|
|
12202
|
+
retainStart = retainTableParagraph(retainStart, text.length, block, blocks[index - 1]);
|
|
12060
12203
|
if (paragraphs && block.type === "paragraph" && blockStart !== void 0 && blockEnd !== void 0) paragraphs.push({
|
|
12061
12204
|
start: blockStart,
|
|
12062
12205
|
end: blockEnd
|
|
@@ -12071,11 +12214,23 @@ function parseMarkdownOwnership(text, options) {
|
|
|
12071
12214
|
completedParagraphs.push(paragraph);
|
|
12072
12215
|
}
|
|
12073
12216
|
const pending = [block];
|
|
12217
|
+
const regionStart = regions.length;
|
|
12218
|
+
let hasReferenceCandidate = false;
|
|
12219
|
+
let hasInlineCode = false;
|
|
12074
12220
|
while (pending.length > 0) {
|
|
12075
12221
|
const node = expectDefined(pending.pop(), "Markdown ownership node");
|
|
12076
|
-
if (
|
|
12222
|
+
if (node.type === "text" && node.value?.includes("[")) {
|
|
12223
|
+
hasReferenceCandidate = true;
|
|
12224
|
+
if (paragraph) paragraph.hasReferenceCandidate = true;
|
|
12225
|
+
}
|
|
12226
|
+
hasInlineCode ||= node.type === "inlineCode";
|
|
12077
12227
|
const start = node.position?.start?.offset;
|
|
12078
12228
|
const end = node.position?.end?.offset;
|
|
12229
|
+
if (node.type === "definition" && node.identifier !== void 0 && start !== void 0 && end !== void 0) definitions.push({
|
|
12230
|
+
identifier: node.identifier,
|
|
12231
|
+
start,
|
|
12232
|
+
end
|
|
12233
|
+
});
|
|
12079
12234
|
if (options?.includeText && node.type === "text" && start !== void 0 && end !== void 0) textSpans.push([start, end]);
|
|
12080
12235
|
if ((node.type === "code" || node.type === "inlineCode") && start !== void 0 && end !== void 0) {
|
|
12081
12236
|
const source = sources.get(start);
|
|
@@ -12098,131 +12253,178 @@ function parseMarkdownOwnership(text, options) {
|
|
|
12098
12253
|
}
|
|
12099
12254
|
for (const child of node.children?.toReversed() ?? []) pending.push(child);
|
|
12100
12255
|
}
|
|
12256
|
+
if (hasReferenceCandidate && hasInlineCode && blockStart !== void 0 && blockEnd !== void 0 && scanBracketOwnership(text, blockStart, blockEnd, regions, regionStart).hasImageCode) {
|
|
12257
|
+
unresolvedImageCodeStart = blockStart;
|
|
12258
|
+
retainStart = Math.min(retainStart, blockStart);
|
|
12259
|
+
}
|
|
12101
12260
|
}
|
|
12261
|
+
const { unsettledDefinitionStarts, retainStart: referenceStart } = findReferenceDefinitionRetention(text, definitions);
|
|
12262
|
+
retainStart = findListItemRetentionStart(text, blocks, Math.min(retainStart, referenceStart));
|
|
12102
12263
|
regions.sort((left, right) => left.start - right.start);
|
|
12264
|
+
const continuation = findContainerContinuation(text, blocks.at(-1), retainStart);
|
|
12103
12265
|
return {
|
|
12104
12266
|
regions,
|
|
12105
12267
|
codeSpans: regions.map(({ start, end }) => [start, end]),
|
|
12106
12268
|
textSpans,
|
|
12107
|
-
retainStart
|
|
12269
|
+
retainStart,
|
|
12270
|
+
...continuation ? { continuation } : {},
|
|
12271
|
+
...unresolvedImageCodeStart === void 0 ? {} : { unresolvedImageCodeStart },
|
|
12108
12272
|
completedParagraphs,
|
|
12273
|
+
definitions,
|
|
12274
|
+
unsettledDefinitionStarts,
|
|
12109
12275
|
...paragraphs ? { paragraphs } : {}
|
|
12110
12276
|
};
|
|
12111
12277
|
}
|
|
12112
|
-
function
|
|
12113
|
-
let
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
const
|
|
12118
|
-
if (
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12278
|
+
function scanBracketOwnership(text, start, end, regions, regionStart) {
|
|
12279
|
+
let regionIndex = regionStart;
|
|
12280
|
+
const brackets = [];
|
|
12281
|
+
let hasImageCode = false;
|
|
12282
|
+
for (let cursor = start; cursor < end; cursor += 1) {
|
|
12283
|
+
const region = regions[regionIndex];
|
|
12284
|
+
if (region?.start === cursor) {
|
|
12285
|
+
if (!region.block) for (const bracket of brackets) bracket.code ||= bracket.image;
|
|
12286
|
+
cursor = region.end - 1;
|
|
12287
|
+
regionIndex += 1;
|
|
12288
|
+
} else if (text[cursor] === "\\") cursor += 1;
|
|
12289
|
+
else if (text[cursor] === "!" && text[cursor + 1] === "[") {
|
|
12290
|
+
brackets.push({
|
|
12291
|
+
image: true,
|
|
12292
|
+
code: false
|
|
12293
|
+
});
|
|
12294
|
+
cursor += 1;
|
|
12295
|
+
} else if (text[cursor] === "[") brackets.push({
|
|
12296
|
+
image: false,
|
|
12297
|
+
code: false
|
|
12298
|
+
});
|
|
12299
|
+
else if (text[cursor] === "]" && brackets.pop()?.code) hasImageCode = true;
|
|
12122
12300
|
}
|
|
12123
|
-
return
|
|
12301
|
+
return {
|
|
12302
|
+
hasImageCode: hasImageCode || brackets.some((bracket) => bracket.image && bracket.code),
|
|
12303
|
+
hasOpenLabel: brackets.length > 0
|
|
12304
|
+
};
|
|
12124
12305
|
}
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
const
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
if (kind === "text" && value.trim()) state.visibleEver = true;
|
|
12306
|
+
/** Preserve an open container without retaining its already-stable literal lines. */
|
|
12307
|
+
function findContainerContinuation(text, block, retainStart) {
|
|
12308
|
+
const start = block?.position?.start?.offset;
|
|
12309
|
+
const end = block?.position?.end?.offset;
|
|
12310
|
+
if (start === void 0 || end === void 0 || retainStart < start || /\r(?!\n)/u.test(text)) return;
|
|
12311
|
+
const offset = text.lastIndexOf("\n", end - 1) + 1;
|
|
12312
|
+
if (offset <= start) return;
|
|
12313
|
+
if (block?.type === "code" && /^(?: {4}| {0,3}\t)/u.test(text.slice(start))) return {
|
|
12314
|
+
offset,
|
|
12315
|
+
context: " x\n"
|
|
12136
12316
|
};
|
|
12137
|
-
const
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12317
|
+
const paragraph = block?.children?.length === 1 ? block.children[0] : void 0;
|
|
12318
|
+
const paragraphStart = paragraph?.position?.start?.offset;
|
|
12319
|
+
if (block?.type !== "blockquote" || paragraph?.type !== "paragraph" || paragraphStart === void 0) return;
|
|
12320
|
+
const prefix = text.slice(paragraphStart, offset);
|
|
12321
|
+
if (/[`|]|\][(:]/u.test(prefix) || scanBracketOwnership(text, paragraphStart, offset, [], 0).hasOpenLabel) return;
|
|
12322
|
+
return {
|
|
12323
|
+
offset,
|
|
12324
|
+
context: text.slice(start, paragraphStart) + "x\n"
|
|
12143
12325
|
};
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12326
|
+
}
|
|
12327
|
+
/** Retain the current item, including any container framing an earlier reference needs. */
|
|
12328
|
+
function findListItemRetentionStart(text, blocks, retainStart) {
|
|
12329
|
+
const offset = retainStart ?? blocks.at(-1)?.position?.start?.offset ?? text.length;
|
|
12330
|
+
const block = blocks.findLast((entry) => (entry.position?.start?.offset ?? Infinity) <= offset);
|
|
12331
|
+
if (block?.type !== "list") return offset;
|
|
12332
|
+
const completeLineEnd = Math.max(text.lastIndexOf("\n"), text.lastIndexOf("\r"));
|
|
12333
|
+
return block.children?.findLast((item) => {
|
|
12334
|
+
const start = item.position?.start?.offset;
|
|
12335
|
+
return start !== void 0 && start <= (retainStart ?? text.length) && start < completeLineEnd;
|
|
12336
|
+
})?.position?.start?.offset ?? offset;
|
|
12337
|
+
}
|
|
12338
|
+
function findReferenceDefinitionRetention(text, definitions) {
|
|
12339
|
+
const unsettledDefinitionStarts = definitions.filter((definition) => canStillHaveReferenceTitle(text, definition.end)).map(({ start }) => start);
|
|
12340
|
+
return {
|
|
12341
|
+
unsettledDefinitionStarts,
|
|
12342
|
+
retainStart: definitions.reduce((offset, { identifier, start }) => identifier.length > 999 ? Math.min(offset, start) : offset, Math.min(text.length, ...unsettledDefinitionStarts))
|
|
12343
|
+
};
|
|
12344
|
+
}
|
|
12345
|
+
function canStillHaveReferenceTitle(text, start) {
|
|
12163
12346
|
let cursor = start;
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
else if (state.pending) state.pending.containsPrivate ||= tag.isPrivate;
|
|
12191
|
-
state.depth += 1;
|
|
12192
|
-
cursor = tagEnd;
|
|
12347
|
+
while (text[cursor] === " " || text[cursor] === " ") cursor += 1;
|
|
12348
|
+
if (cursor === text.length) return true;
|
|
12349
|
+
const lineEndingWidth = getLineEndingWidth(text, cursor);
|
|
12350
|
+
if (lineEndingWidth > 0) {
|
|
12351
|
+
cursor += lineEndingWidth;
|
|
12352
|
+
if (cursor === text.length) return true;
|
|
12353
|
+
}
|
|
12354
|
+
const titleStart = findPossibleTitleStart(text, cursor);
|
|
12355
|
+
if (titleStart === void 0) return false;
|
|
12356
|
+
return hasUnclosedTitle(text, titleStart);
|
|
12357
|
+
}
|
|
12358
|
+
function findPossibleTitleStart(text, start) {
|
|
12359
|
+
let cursor = skipContainerPrefixes(text, start);
|
|
12360
|
+
while (text[cursor] === " " || text[cursor] === " ") cursor += 1;
|
|
12361
|
+
if (cursor === text.length) return cursor;
|
|
12362
|
+
const opening = text[cursor];
|
|
12363
|
+
return opening === "\"" || opening === "'" || opening === "(" ? cursor : void 0;
|
|
12364
|
+
}
|
|
12365
|
+
function skipContainerPrefixes(text, start) {
|
|
12366
|
+
let cursor = start;
|
|
12367
|
+
while (cursor < text.length) {
|
|
12368
|
+
let markerStart = cursor;
|
|
12369
|
+
while (text[markerStart] === " " || text[markerStart] === " ") markerStart += 1;
|
|
12370
|
+
if (text[markerStart] === ">") {
|
|
12371
|
+
cursor = markerStart + 1;
|
|
12372
|
+
if (text[cursor] === " " || text[cursor] === " ") cursor += 1;
|
|
12193
12373
|
continue;
|
|
12194
12374
|
}
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
state.pending = void 0;
|
|
12200
|
-
} else if (state.pending) state.pending.protectedClose = true;
|
|
12201
|
-
cursor = tagEnd;
|
|
12375
|
+
const markerEnd = listMarkerEnd(text, markerStart);
|
|
12376
|
+
if (markerEnd > markerStart) {
|
|
12377
|
+
cursor = markerEnd;
|
|
12378
|
+
while (text[cursor] === " " || text[cursor] === " ") cursor += 1;
|
|
12202
12379
|
continue;
|
|
12203
12380
|
}
|
|
12204
|
-
|
|
12205
|
-
else {
|
|
12206
|
-
const after = text.slice(tagEnd);
|
|
12207
|
-
if (beforeTag.trim() && after.trim()) {
|
|
12208
|
-
const thinking = output.filter((delta) => delta.kind === "thinking");
|
|
12209
|
-
output.splice(0, output.length, ...thinking);
|
|
12210
|
-
state.visibleEver = false;
|
|
12211
|
-
}
|
|
12212
|
-
}
|
|
12213
|
-
cursor = tagEnd;
|
|
12214
|
-
}
|
|
12215
|
-
append(text.slice(cursor));
|
|
12216
|
-
if (options.final && state.depth > 0 && state.pending) {
|
|
12217
|
-
const pending = state.pending;
|
|
12218
|
-
if (!pending.containsPrivate) {
|
|
12219
|
-
if ((options.mode === "static-preserve" || options.mode === "static-strict" && !pending.visibleBefore && !pending.protectedClose || options.mode === "visible" && !pending.protectedClose) && options.recoverUnclosed !== false) emit("text", options.mode === "visible" && pending.visibleBefore ? pending.openTag + pending.content : pending.content);
|
|
12220
|
-
else emit("thinking", pending.content);
|
|
12221
|
-
}
|
|
12222
|
-
state.depth = 0;
|
|
12223
|
-
state.pending = void 0;
|
|
12381
|
+
break;
|
|
12224
12382
|
}
|
|
12225
|
-
return
|
|
12383
|
+
return cursor;
|
|
12384
|
+
}
|
|
12385
|
+
function listMarkerEnd(text, start) {
|
|
12386
|
+
const first = text[start] ?? "";
|
|
12387
|
+
let markerEnd = start;
|
|
12388
|
+
if (first === "-" || first === "+" || first === "*") markerEnd += 1;
|
|
12389
|
+
else if (first >= "0" && first <= "9") {
|
|
12390
|
+
while ((text[markerEnd] ?? "") >= "0" && (text[markerEnd] ?? "") <= "9") markerEnd += 1;
|
|
12391
|
+
const delimiter = text[markerEnd] ?? "";
|
|
12392
|
+
if (markerEnd - start > 9 || delimiter !== "." && delimiter !== ")") return start;
|
|
12393
|
+
markerEnd += 1;
|
|
12394
|
+
} else return start;
|
|
12395
|
+
const trailingSpace = text[markerEnd];
|
|
12396
|
+
return trailingSpace === " " || trailingSpace === " " ? markerEnd : start;
|
|
12397
|
+
}
|
|
12398
|
+
function hasUnclosedTitle(text, start) {
|
|
12399
|
+
if (start === text.length) return true;
|
|
12400
|
+
const opening = text[start];
|
|
12401
|
+
if (opening !== "\"" && opening !== "'" && opening !== "(") return false;
|
|
12402
|
+
const closing = opening === "(" ? ")" : opening;
|
|
12403
|
+
let escaped = false;
|
|
12404
|
+
for (let cursor = start + 1; cursor < text.length; cursor += 1) {
|
|
12405
|
+
const character = text[cursor];
|
|
12406
|
+
if (escaped) escaped = false;
|
|
12407
|
+
else if (character === "\\") escaped = true;
|
|
12408
|
+
else if (character === closing) return false;
|
|
12409
|
+
const lineEndingWidth = getLineEndingWidth(text, cursor);
|
|
12410
|
+
if (lineEndingWidth > 0) {
|
|
12411
|
+
let nextLine = cursor + lineEndingWidth;
|
|
12412
|
+
while (text[nextLine] === " " || text[nextLine] === " ") nextLine += 1;
|
|
12413
|
+
if (getLineEndingWidth(text, nextLine) > 0) return false;
|
|
12414
|
+
cursor += lineEndingWidth - 1;
|
|
12415
|
+
}
|
|
12416
|
+
}
|
|
12417
|
+
return true;
|
|
12418
|
+
}
|
|
12419
|
+
function getLineEndingWidth(text, index) {
|
|
12420
|
+
if (text[index] === "\n") return 1;
|
|
12421
|
+
if (text[index] !== "\r") return 0;
|
|
12422
|
+
return text[index + 1] === "\n" ? 2 : 1;
|
|
12423
|
+
}
|
|
12424
|
+
/** An unfinished table delimiter can still rejoin its preceding paragraph. */
|
|
12425
|
+
function retainTableParagraph(retainStart, textLength, block, previous) {
|
|
12426
|
+
const startLine = block.position?.start?.line;
|
|
12427
|
+
return block.type === "table" && block.children?.length === 1 && block.position?.end?.offset === textLength && previous?.type === "paragraph" && startLine !== void 0 && previous.position?.end?.line === startLine - 1 ? Math.min(retainStart, previous.position?.start?.offset ?? retainStart) : retainStart;
|
|
12226
12428
|
}
|
|
12227
12429
|
//#endregion
|
|
12228
12430
|
//#region packages/markdown-core/src/reasoning-tags.ts
|
|
@@ -12583,4 +12785,4 @@ function createReasoningTagTextPartitioner() {
|
|
|
12583
12785
|
};
|
|
12584
12786
|
}
|
|
12585
12787
|
//#endregion
|
|
12586
|
-
export { createReasoningTagTextPartitioner
|
|
12788
|
+
export { createReasoningTagTextPartitioner };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as parseRetryAfterHeadersSeconds, i as
|
|
2
|
-
export { RETRY_AFTER_TEXT_RE, parseGoogleRetryDelaySeconds, parseHttpDateInstant, parseRetryAfterErrorSeconds, parseRetryAfterHeadersSeconds, parseRetryAfterHttpDateMs, parseRetryAfterTextSeconds };
|
|
1
|
+
import { a as parseHttpDateInstant, c as parseRetryAfterHeadersSeconds, d as parseRetryAfterTextSeconds, f as resolveProviderErrorRetrySeconds, i as parseGoogleRetryDelaySeconds, l as parseRetryAfterHeadersTiming, n as RetryAfterTiming, o as parseRetryAfterErrorSeconds, r as hasExplicitRetryText, s as parseRetryAfterErrorTiming, t as RETRY_AFTER_TEXT_RE, u as parseRetryAfterHttpDateMs } from "../retry-after-DnHBlFS2.mjs";
|
|
2
|
+
export { RETRY_AFTER_TEXT_RE, RetryAfterTiming, hasExplicitRetryText, parseGoogleRetryDelaySeconds, parseHttpDateInstant, parseRetryAfterErrorSeconds, parseRetryAfterErrorTiming, parseRetryAfterHeadersSeconds, parseRetryAfterHeadersTiming, parseRetryAfterHttpDateMs, parseRetryAfterTextSeconds, resolveProviderErrorRetrySeconds };
|