page-agent-sdk 1.4.1 → 1.4.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/dist/page-agent-sdk.css +1 -1
- package/dist/page-agent-sdk.iife.js +112 -112
- package/dist/page-agent-sdk.js +948 -930
- package/dist/page-agent-sdk.umd.cjs +55 -55
- package/package.json +1 -1
- package/types/index.d.ts +6 -3
package/dist/page-agent-sdk.js
CHANGED
|
@@ -4236,8 +4236,26 @@ function xl(e = {}) {
|
|
|
4236
4236
|
};
|
|
4237
4237
|
}
|
|
4238
4238
|
//#endregion
|
|
4239
|
+
//#region src/core/utils/clipboard.ts
|
|
4240
|
+
async function Sl(e) {
|
|
4241
|
+
try {
|
|
4242
|
+
let t = globalThis.navigator?.clipboard;
|
|
4243
|
+
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
4244
|
+
} catch {}
|
|
4245
|
+
try {
|
|
4246
|
+
let t = globalThis.document;
|
|
4247
|
+
if (!t || !t.body) return !1;
|
|
4248
|
+
let n = t.createElement("textarea");
|
|
4249
|
+
n.value = e, n.setAttribute("readonly", ""), n.style.position = "fixed", n.style.top = "0", n.style.left = "0", n.style.opacity = "0", t.body.appendChild(n), n.select();
|
|
4250
|
+
let r = t.execCommand("copy");
|
|
4251
|
+
return t.body.removeChild(n), r;
|
|
4252
|
+
} catch {
|
|
4253
|
+
return !1;
|
|
4254
|
+
}
|
|
4255
|
+
}
|
|
4256
|
+
//#endregion
|
|
4239
4257
|
//#region node_modules/marked/lib/marked.esm.js
|
|
4240
|
-
function
|
|
4258
|
+
function Cl() {
|
|
4241
4259
|
return {
|
|
4242
4260
|
async: !1,
|
|
4243
4261
|
breaks: !1,
|
|
@@ -4251,12 +4269,12 @@ function Sl() {
|
|
|
4251
4269
|
walkTokens: null
|
|
4252
4270
|
};
|
|
4253
4271
|
}
|
|
4254
|
-
var
|
|
4255
|
-
function
|
|
4256
|
-
|
|
4272
|
+
var wl = Cl();
|
|
4273
|
+
function Tl(e) {
|
|
4274
|
+
wl = e;
|
|
4257
4275
|
}
|
|
4258
|
-
var
|
|
4259
|
-
function
|
|
4276
|
+
var El = { exec: () => null };
|
|
4277
|
+
function Dl(e) {
|
|
4260
4278
|
let t = [];
|
|
4261
4279
|
return (n) => {
|
|
4262
4280
|
let r = Math.max(0, Math.min(3, n - 1)), i = t[r];
|
|
@@ -4267,19 +4285,19 @@ function Z(e, t = "") {
|
|
|
4267
4285
|
let n = typeof e == "string" ? e : e.source, r = {
|
|
4268
4286
|
replace: (e, t) => {
|
|
4269
4287
|
let i = typeof t == "string" ? t : t.source;
|
|
4270
|
-
return i = i.replace(
|
|
4288
|
+
return i = i.replace(kl.caret, "$1"), n = n.replace(e, i), r;
|
|
4271
4289
|
},
|
|
4272
4290
|
getRegex: () => new RegExp(n, t)
|
|
4273
4291
|
};
|
|
4274
4292
|
return r;
|
|
4275
4293
|
}
|
|
4276
|
-
var
|
|
4294
|
+
var Ol = ((e = "") => {
|
|
4277
4295
|
try {
|
|
4278
4296
|
return !!RegExp("(?<=1)(?<!1)" + e);
|
|
4279
4297
|
} catch {
|
|
4280
4298
|
return !1;
|
|
4281
4299
|
}
|
|
4282
|
-
})(),
|
|
4300
|
+
})(), kl = {
|
|
4283
4301
|
codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
|
|
4284
4302
|
outputLinkReplace: /\\([\[\]])/g,
|
|
4285
4303
|
indentCodeCompensation: /^(\s+)(?:```)/,
|
|
@@ -4330,121 +4348,121 @@ var Dl = ((e = "") => {
|
|
|
4330
4348
|
notSpaceStart: /^\S*/,
|
|
4331
4349
|
endingNewline: /\n$/,
|
|
4332
4350
|
listItemRegex: (e) => RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
4333
|
-
nextBulletRegex:
|
|
4334
|
-
hrRegex:
|
|
4335
|
-
fencesBeginRegex:
|
|
4336
|
-
headingBeginRegex:
|
|
4337
|
-
htmlBeginRegex:
|
|
4338
|
-
blockquoteBeginRegex:
|
|
4339
|
-
},
|
|
4340
|
-
blockquote: Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",
|
|
4341
|
-
code:
|
|
4342
|
-
def:
|
|
4343
|
-
fences:
|
|
4344
|
-
heading:
|
|
4345
|
-
hr:
|
|
4346
|
-
html:
|
|
4347
|
-
lheading: Il,
|
|
4348
|
-
list: Hl,
|
|
4349
|
-
newline: kl,
|
|
4350
|
-
paragraph: ql,
|
|
4351
|
-
table: Tl,
|
|
4352
|
-
text: zl
|
|
4353
|
-
}, Xl = Z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", Ml).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Ul).getRegex(), Zl = {
|
|
4354
|
-
...Yl,
|
|
4351
|
+
nextBulletRegex: Dl((e) => RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),
|
|
4352
|
+
hrRegex: Dl((e) => RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),
|
|
4353
|
+
fencesBeginRegex: Dl((e) => RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),
|
|
4354
|
+
headingBeginRegex: Dl((e) => RegExp(`^ {0,${e}}#`)),
|
|
4355
|
+
htmlBeginRegex: Dl((e) => RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`, "i")),
|
|
4356
|
+
blockquoteBeginRegex: Dl((e) => RegExp(`^ {0,${e}}>`))
|
|
4357
|
+
}, Al = /^(?:[ \t]*(?:\n|$))+/, jl = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Ml = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, Nl = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Pl = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Fl = / {0,3}(?:[*+-]|\d{1,9}[.)])/, Il = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, Ll = Z(Il).replace(/bull/g, Fl).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), Rl = Z(Il).replace(/bull/g, Fl).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), zl = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Bl = /^[^\n]+/, Vl = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Hl = Z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Vl).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Ul = Z(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, Fl).getRegex(), Wl = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", Gl = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Kl = Z("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n+|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n+|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n+|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", Gl).replace("tag", Wl).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), ql = (e) => Z(zl).replace("hr", Nl).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", e).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Wl).getRegex(), Jl = ql(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/), Yl = ql(/ {0,3}(?:[*+-]|\d{1,9}[.)])[ \t]+[^ \t\n]/), Xl = {
|
|
4358
|
+
blockquote: Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Yl).getRegex(),
|
|
4359
|
+
code: jl,
|
|
4360
|
+
def: Hl,
|
|
4361
|
+
fences: Ml,
|
|
4362
|
+
heading: Pl,
|
|
4363
|
+
hr: Nl,
|
|
4364
|
+
html: Kl,
|
|
4355
4365
|
lheading: Ll,
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4366
|
+
list: Ul,
|
|
4367
|
+
newline: Al,
|
|
4368
|
+
paragraph: Jl,
|
|
4369
|
+
table: El,
|
|
4370
|
+
text: Bl
|
|
4371
|
+
}, Zl = Z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", Nl).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Wl).getRegex(), Ql = {
|
|
4372
|
+
...Xl,
|
|
4373
|
+
lheading: Rl,
|
|
4374
|
+
table: Zl,
|
|
4375
|
+
paragraph: Z(zl).replace("hr", Nl).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Zl).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Wl).getRegex()
|
|
4376
|
+
}, $l = {
|
|
4377
|
+
...Xl,
|
|
4378
|
+
html: Z("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", Gl).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
|
|
4361
4379
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
4362
4380
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
4363
|
-
fences:
|
|
4381
|
+
fences: El,
|
|
4364
4382
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
4365
|
-
paragraph: Z(
|
|
4366
|
-
},
|
|
4367
|
-
_backpedal:
|
|
4368
|
-
anyPunctuation:
|
|
4369
|
-
autolink:
|
|
4370
|
-
blockSkip:
|
|
4371
|
-
br:
|
|
4372
|
-
code:
|
|
4373
|
-
del:
|
|
4374
|
-
delLDelim:
|
|
4375
|
-
delRDelim:
|
|
4376
|
-
emStrongLDelim: fu,
|
|
4377
|
-
emStrongRDelimAst: hu,
|
|
4378
|
-
emStrongRDelimUnd: _u,
|
|
4379
|
-
escape: $l,
|
|
4380
|
-
link: Tu,
|
|
4381
|
-
nolink: Du,
|
|
4382
|
-
punctuation: ou,
|
|
4383
|
-
reflink: Eu,
|
|
4384
|
-
reflinkSearch: Ou,
|
|
4385
|
-
tag: Cu,
|
|
4386
|
-
text: nu,
|
|
4387
|
-
url: Tl
|
|
4388
|
-
}, ju = {
|
|
4389
|
-
...Au,
|
|
4390
|
-
link: Z(/^!?\[(label)\]\((.*?)\)/).replace("label", wu).getRegex(),
|
|
4391
|
-
reflink: Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", wu).getRegex()
|
|
4392
|
-
}, Mu = {
|
|
4393
|
-
...Au,
|
|
4394
|
-
emStrongRDelimAst: gu,
|
|
4383
|
+
paragraph: Z(zl).replace("hr", Nl).replace("heading", " *#{1,6} *[^\n]").replace("lheading", Ll).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
4384
|
+
}, eu = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, tu = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, nu = /^( {2,}|\\)\n(?!\s*$)/, ru = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, iu = /[\p{P}\p{S}]/u, au = /[\s\p{P}\p{S}]/u, ou = /[^\s\p{P}\p{S}]/u, su = Z(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, au).getRegex(), cu = /(?!~)[\p{P}\p{S}]/u, lu = /(?!~)[\s\p{P}\p{S}]/u, uu = /(?:[^\s\p{P}\p{S}]|~)/u, du = Z(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Ol ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), fu = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, pu = Z(fu, "u").replace(/punct/g, iu).getRegex(), mu = Z(fu, "u").replace(/punct/g, cu).getRegex(), hu = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", gu = Z(hu, "gu").replace(/notPunctSpace/g, ou).replace(/punctSpace/g, au).replace(/punct/g, iu).getRegex(), _u = Z(hu, "gu").replace(/notPunctSpace/g, uu).replace(/punctSpace/g, lu).replace(/punct/g, cu).getRegex(), vu = Z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ou).replace(/punctSpace/g, au).replace(/punct/g, iu).getRegex(), yu = Z(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, iu).getRegex(), bu = Z("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, ou).replace(/punctSpace/g, au).replace(/punct/g, iu).getRegex(), xu = Z(/\\(punct)/, "gu").replace(/punct/g, iu).getRegex(), Su = Z(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), Cu = Z(Gl).replace("(?:-->|$)", "-->").getRegex(), wu = Z("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Cu).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Tu = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/, Eu = Z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", Tu).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Du = Z(/^!?\[(label)\]\[(ref)\]/).replace("label", Tu).replace("ref", Vl).getRegex(), Ou = Z(/^!?\[(ref)\](?:\[\])?/).replace("ref", Vl).getRegex(), ku = Z("reflink|nolink(?!\\()", "g").replace("reflink", Du).replace("nolink", Ou).getRegex(), Au = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, ju = {
|
|
4385
|
+
_backpedal: El,
|
|
4386
|
+
anyPunctuation: xu,
|
|
4387
|
+
autolink: Su,
|
|
4388
|
+
blockSkip: du,
|
|
4389
|
+
br: nu,
|
|
4390
|
+
code: tu,
|
|
4391
|
+
del: El,
|
|
4392
|
+
delLDelim: El,
|
|
4393
|
+
delRDelim: El,
|
|
4395
4394
|
emStrongLDelim: pu,
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4395
|
+
emStrongRDelimAst: gu,
|
|
4396
|
+
emStrongRDelimUnd: vu,
|
|
4397
|
+
escape: eu,
|
|
4398
|
+
link: Eu,
|
|
4399
|
+
nolink: Ou,
|
|
4400
|
+
punctuation: su,
|
|
4401
|
+
reflink: Du,
|
|
4402
|
+
reflinkSearch: ku,
|
|
4403
|
+
tag: wu,
|
|
4404
|
+
text: ru,
|
|
4405
|
+
url: El
|
|
4406
|
+
}, Mu = {
|
|
4407
|
+
...ju,
|
|
4408
|
+
link: Z(/^!?\[(label)\]\((.*?)\)/).replace("label", Tu).getRegex(),
|
|
4409
|
+
reflink: Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Tu).getRegex()
|
|
4410
|
+
}, Nu = {
|
|
4411
|
+
...ju,
|
|
4412
|
+
emStrongRDelimAst: _u,
|
|
4413
|
+
emStrongLDelim: mu,
|
|
4414
|
+
delLDelim: yu,
|
|
4415
|
+
delRDelim: bu,
|
|
4416
|
+
url: Z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", Au).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
|
|
4399
4417
|
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
4400
4418
|
del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
|
|
4401
|
-
text: Z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",
|
|
4402
|
-
}, Nu = {
|
|
4403
|
-
...Mu,
|
|
4404
|
-
br: Z(tu).replace("{2,}", "*").getRegex(),
|
|
4405
|
-
text: Z(Mu.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
4419
|
+
text: Z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", Au).getRegex()
|
|
4406
4420
|
}, Pu = {
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4421
|
+
...Nu,
|
|
4422
|
+
br: Z(nu).replace("{2,}", "*").getRegex(),
|
|
4423
|
+
text: Z(Nu.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
4410
4424
|
}, Fu = {
|
|
4411
|
-
normal:
|
|
4412
|
-
gfm:
|
|
4413
|
-
|
|
4414
|
-
pedantic: ju
|
|
4425
|
+
normal: Xl,
|
|
4426
|
+
gfm: Ql,
|
|
4427
|
+
pedantic: $l
|
|
4415
4428
|
}, Iu = {
|
|
4429
|
+
normal: ju,
|
|
4430
|
+
gfm: Nu,
|
|
4431
|
+
breaks: Pu,
|
|
4432
|
+
pedantic: Mu
|
|
4433
|
+
}, Lu = {
|
|
4416
4434
|
"&": "&",
|
|
4417
4435
|
"<": "<",
|
|
4418
4436
|
">": ">",
|
|
4419
4437
|
"\"": """,
|
|
4420
4438
|
"'": "'"
|
|
4421
|
-
},
|
|
4422
|
-
function
|
|
4439
|
+
}, Ru = (e) => Lu[e];
|
|
4440
|
+
function zu(e, t) {
|
|
4423
4441
|
if (t) {
|
|
4424
|
-
if (
|
|
4425
|
-
} else if (
|
|
4442
|
+
if (kl.escapeTest.test(e)) return e.replace(kl.escapeReplace, Ru);
|
|
4443
|
+
} else if (kl.escapeTestNoEncode.test(e)) return e.replace(kl.escapeReplaceNoEncode, Ru);
|
|
4426
4444
|
return e;
|
|
4427
4445
|
}
|
|
4428
|
-
function
|
|
4446
|
+
function Bu(e) {
|
|
4429
4447
|
try {
|
|
4430
|
-
e = encodeURI(e).replace(
|
|
4448
|
+
e = encodeURI(e).replace(kl.percentDecode, "%");
|
|
4431
4449
|
} catch {
|
|
4432
4450
|
return null;
|
|
4433
4451
|
}
|
|
4434
4452
|
return e;
|
|
4435
4453
|
}
|
|
4436
|
-
function
|
|
4437
|
-
let n = e.replace(
|
|
4454
|
+
function Vu(e, t) {
|
|
4455
|
+
let n = e.replace(kl.findPipe, (e, t, n) => {
|
|
4438
4456
|
let r = !1, i = t;
|
|
4439
4457
|
for (; --i >= 0 && n[i] === "\\";) r = !r;
|
|
4440
4458
|
return r ? "|" : " |";
|
|
4441
|
-
}).split(
|
|
4459
|
+
}).split(kl.splitPipe), r = 0;
|
|
4442
4460
|
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), t) if (n.length > t) n.splice(t);
|
|
4443
4461
|
else for (; n.length < t;) n.push("");
|
|
4444
|
-
for (; r < n.length; r++) n[r] = n[r].trim().replace(
|
|
4462
|
+
for (; r < n.length; r++) n[r] = n[r].trim().replace(kl.slashPipe, "|");
|
|
4445
4463
|
return n;
|
|
4446
4464
|
}
|
|
4447
|
-
function
|
|
4465
|
+
function Hu(e, t, n) {
|
|
4448
4466
|
let r = e.length;
|
|
4449
4467
|
if (r === 0) return "";
|
|
4450
4468
|
let i = 0;
|
|
@@ -4456,12 +4474,12 @@ function Vu(e, t, n) {
|
|
|
4456
4474
|
}
|
|
4457
4475
|
return e.slice(0, r - i);
|
|
4458
4476
|
}
|
|
4459
|
-
function
|
|
4477
|
+
function Uu(e) {
|
|
4460
4478
|
let t = e.split("\n"), n = t.length - 1;
|
|
4461
|
-
for (; n >= 0 &&
|
|
4479
|
+
for (; n >= 0 && kl.blankLine.test(t[n]);) n--;
|
|
4462
4480
|
return t.length - n <= 2 ? e : t.slice(0, n + 1).join("\n");
|
|
4463
4481
|
}
|
|
4464
|
-
function
|
|
4482
|
+
function Wu(e, t) {
|
|
4465
4483
|
if (e.indexOf(t[1]) === -1) return -1;
|
|
4466
4484
|
let n = 0;
|
|
4467
4485
|
for (let r = 0; r < e.length; r++) if (e[r] === "\\") r++;
|
|
@@ -4469,7 +4487,7 @@ function Uu(e, t) {
|
|
|
4469
4487
|
else if (e[r] === t[1] && (n--, n < 0)) return r;
|
|
4470
4488
|
return n > 0 ? -2 : -1;
|
|
4471
4489
|
}
|
|
4472
|
-
function
|
|
4490
|
+
function Gu(e, t = 0) {
|
|
4473
4491
|
let n = t, r = "";
|
|
4474
4492
|
for (let t of e) if (t === " ") {
|
|
4475
4493
|
let e = 4 - n % 4;
|
|
@@ -4477,7 +4495,7 @@ function Wu(e, t = 0) {
|
|
|
4477
4495
|
} else r += t, n++;
|
|
4478
4496
|
return r;
|
|
4479
4497
|
}
|
|
4480
|
-
function
|
|
4498
|
+
function Ku(e, t, n, r, i) {
|
|
4481
4499
|
let a = t.href, o = t.title || null, s = e[1].replace(i.other.outputLinkReplace, "$1");
|
|
4482
4500
|
r.state.inLink = !0;
|
|
4483
4501
|
let c = {
|
|
@@ -4490,7 +4508,7 @@ function Gu(e, t, n, r, i) {
|
|
|
4490
4508
|
};
|
|
4491
4509
|
return r.state.inLink = !1, c;
|
|
4492
4510
|
}
|
|
4493
|
-
function
|
|
4511
|
+
function qu(e, t, n) {
|
|
4494
4512
|
let r = e.match(n.other.indentCodeCompensation);
|
|
4495
4513
|
if (r === null) return t;
|
|
4496
4514
|
let i = r[1];
|
|
@@ -4501,12 +4519,12 @@ function Ku(e, t, n) {
|
|
|
4501
4519
|
return r.length >= i.length ? e.slice(i.length) : e;
|
|
4502
4520
|
}).join("\n");
|
|
4503
4521
|
}
|
|
4504
|
-
var
|
|
4522
|
+
var Ju = class {
|
|
4505
4523
|
options;
|
|
4506
4524
|
rules;
|
|
4507
4525
|
lexer;
|
|
4508
4526
|
constructor(e) {
|
|
4509
|
-
this.options = e ||
|
|
4527
|
+
this.options = e || wl;
|
|
4510
4528
|
}
|
|
4511
4529
|
space(e) {
|
|
4512
4530
|
let t = this.rules.block.newline.exec(e);
|
|
@@ -4518,7 +4536,7 @@ var qu = class {
|
|
|
4518
4536
|
code(e) {
|
|
4519
4537
|
let t = this.rules.block.code.exec(e);
|
|
4520
4538
|
if (t) {
|
|
4521
|
-
let e = this.options.pedantic ? t[0] :
|
|
4539
|
+
let e = this.options.pedantic ? t[0] : Uu(t[0]);
|
|
4522
4540
|
return {
|
|
4523
4541
|
type: "code",
|
|
4524
4542
|
raw: e,
|
|
@@ -4530,7 +4548,7 @@ var qu = class {
|
|
|
4530
4548
|
fences(e) {
|
|
4531
4549
|
let t = this.rules.block.fences.exec(e);
|
|
4532
4550
|
if (t) {
|
|
4533
|
-
let e = t[0], n =
|
|
4551
|
+
let e = t[0], n = qu(e, t[3] || "", this.rules);
|
|
4534
4552
|
return {
|
|
4535
4553
|
type: "code",
|
|
4536
4554
|
raw: e,
|
|
@@ -4544,12 +4562,12 @@ var qu = class {
|
|
|
4544
4562
|
if (t) {
|
|
4545
4563
|
let e = t[2].trim();
|
|
4546
4564
|
if (this.rules.other.endingHash.test(e)) {
|
|
4547
|
-
let t =
|
|
4565
|
+
let t = Hu(e, "#");
|
|
4548
4566
|
(this.options.pedantic || !t || this.rules.other.endingSpaceChar.test(t)) && (e = t.trim());
|
|
4549
4567
|
}
|
|
4550
4568
|
return {
|
|
4551
4569
|
type: "heading",
|
|
4552
|
-
raw:
|
|
4570
|
+
raw: Hu(t[0], "\n"),
|
|
4553
4571
|
depth: t[1].length,
|
|
4554
4572
|
text: e,
|
|
4555
4573
|
tokens: this.lexer.inline(e)
|
|
@@ -4560,13 +4578,13 @@ var qu = class {
|
|
|
4560
4578
|
let t = this.rules.block.hr.exec(e);
|
|
4561
4579
|
if (t) return {
|
|
4562
4580
|
type: "hr",
|
|
4563
|
-
raw:
|
|
4581
|
+
raw: Hu(t[0], "\n")
|
|
4564
4582
|
};
|
|
4565
4583
|
}
|
|
4566
4584
|
blockquote(e) {
|
|
4567
4585
|
let t = this.rules.block.blockquote.exec(e);
|
|
4568
4586
|
if (t) {
|
|
4569
|
-
let e =
|
|
4587
|
+
let e = Hu(t[0], "\n").split("\n"), n = "", r = "", i = [];
|
|
4570
4588
|
for (; e.length > 0;) {
|
|
4571
4589
|
let t = !1, a = [], o;
|
|
4572
4590
|
for (o = 0; o < e.length; o++) if (this.rules.other.blockquoteStart.test(e[o])) a.push(e[o]), t = !0;
|
|
@@ -4616,7 +4634,7 @@ ${c}` : c;
|
|
|
4616
4634
|
let n = !1, r = "", s = "";
|
|
4617
4635
|
if (!(t = a.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
4618
4636
|
r = t[0], e = e.substring(r.length);
|
|
4619
|
-
let c =
|
|
4637
|
+
let c = Gu(t[2].split("\n", 1)[0], t[1].length), l = e.split("\n", 1)[0], u = !c.trim(), d = 0;
|
|
4620
4638
|
if (this.options.pedantic ? (d = 2, s = c.trimStart()) : u ? d = t[1].length + 1 : (d = c.search(this.rules.other.nonSpaceChar), d = d > 4 ? 1 : d, s = c.slice(d), d += t[1].length), u && this.rules.other.blankLine.test(l) && (r += l + "\n", e = e.substring(l.length + 1), n = !0), !n) {
|
|
4621
4639
|
let t = this.rules.other.nextBulletRegex(d), n = this.rules.other.hrRegex(d), i = this.rules.other.fencesBeginRegex(d), a = this.rules.other.headingBeginRegex(d), o = this.rules.other.htmlBeginRegex(d), f = this.rules.other.blockquoteBeginRegex(d);
|
|
4622
4640
|
for (; e;) {
|
|
@@ -4682,7 +4700,7 @@ ${c}` : c;
|
|
|
4682
4700
|
html(e) {
|
|
4683
4701
|
let t = this.rules.block.html.exec(e);
|
|
4684
4702
|
if (t) {
|
|
4685
|
-
let e =
|
|
4703
|
+
let e = Uu(t[0]);
|
|
4686
4704
|
return {
|
|
4687
4705
|
type: "html",
|
|
4688
4706
|
block: !0,
|
|
@@ -4699,7 +4717,7 @@ ${c}` : c;
|
|
|
4699
4717
|
return {
|
|
4700
4718
|
type: "def",
|
|
4701
4719
|
tag: e,
|
|
4702
|
-
raw:
|
|
4720
|
+
raw: Hu(t[0], "\n"),
|
|
4703
4721
|
href: n,
|
|
4704
4722
|
title: r
|
|
4705
4723
|
};
|
|
@@ -4708,9 +4726,9 @@ ${c}` : c;
|
|
|
4708
4726
|
table(e) {
|
|
4709
4727
|
let t = this.rules.block.table.exec(e);
|
|
4710
4728
|
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
4711
|
-
let n =
|
|
4729
|
+
let n = Vu(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [], a = {
|
|
4712
4730
|
type: "table",
|
|
4713
|
-
raw:
|
|
4731
|
+
raw: Hu(t[0], "\n"),
|
|
4714
4732
|
header: [],
|
|
4715
4733
|
align: [],
|
|
4716
4734
|
rows: []
|
|
@@ -4723,7 +4741,7 @@ ${c}` : c;
|
|
|
4723
4741
|
header: !0,
|
|
4724
4742
|
align: a.align[e]
|
|
4725
4743
|
});
|
|
4726
|
-
for (let e of i) a.rows.push(
|
|
4744
|
+
for (let e of i) a.rows.push(Vu(e, a.header.length).map((e, t) => ({
|
|
4727
4745
|
text: e,
|
|
4728
4746
|
tokens: this.lexer.inline(e),
|
|
4729
4747
|
header: !1,
|
|
@@ -4738,7 +4756,7 @@ ${c}` : c;
|
|
|
4738
4756
|
let e = t[1].trim();
|
|
4739
4757
|
return {
|
|
4740
4758
|
type: "heading",
|
|
4741
|
-
raw:
|
|
4759
|
+
raw: Hu(t[0], "\n"),
|
|
4742
4760
|
depth: t[2].charAt(0) === "=" ? 1 : 2,
|
|
4743
4761
|
text: e,
|
|
4744
4762
|
tokens: this.lexer.inline(e)
|
|
@@ -4791,10 +4809,10 @@ ${c}` : c;
|
|
|
4791
4809
|
let e = t[2].trim();
|
|
4792
4810
|
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(e)) {
|
|
4793
4811
|
if (!this.rules.other.endAngleBracket.test(e)) return;
|
|
4794
|
-
let t =
|
|
4812
|
+
let t = Hu(e.slice(0, -1), "\\");
|
|
4795
4813
|
if ((e.length - t.length) % 2 == 0) return;
|
|
4796
4814
|
} else {
|
|
4797
|
-
let e =
|
|
4815
|
+
let e = Wu(t[2], "()");
|
|
4798
4816
|
if (e === -2) return;
|
|
4799
4817
|
if (e > -1) {
|
|
4800
4818
|
let n = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + e;
|
|
@@ -4806,7 +4824,7 @@ ${c}` : c;
|
|
|
4806
4824
|
let e = this.rules.other.pedanticHrefTitle.exec(n);
|
|
4807
4825
|
e && (n = e[1], r = e[3]);
|
|
4808
4826
|
} else r = t[3] ? t[3].slice(1, -1) : "";
|
|
4809
|
-
return n = n.trim(), this.rules.other.startAngleBracket.test(n) && (n = this.options.pedantic && !this.rules.other.endAngleBracket.test(e) ? n.slice(1) : n.slice(1, -1)),
|
|
4827
|
+
return n = n.trim(), this.rules.other.startAngleBracket.test(n) && (n = this.options.pedantic && !this.rules.other.endAngleBracket.test(e) ? n.slice(1) : n.slice(1, -1)), Ku(t, {
|
|
4810
4828
|
href: n && n.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
4811
4829
|
title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
|
|
4812
4830
|
}, t[0], this.lexer, this.rules);
|
|
@@ -4824,7 +4842,7 @@ ${c}` : c;
|
|
|
4824
4842
|
text: e
|
|
4825
4843
|
};
|
|
4826
4844
|
}
|
|
4827
|
-
return
|
|
4845
|
+
return Ku(n, e, n[0], this.lexer, this.rules);
|
|
4828
4846
|
}
|
|
4829
4847
|
}
|
|
4830
4848
|
emStrong(e, t, n = "") {
|
|
@@ -4956,29 +4974,29 @@ ${c}` : c;
|
|
|
4956
4974
|
};
|
|
4957
4975
|
}
|
|
4958
4976
|
}
|
|
4959
|
-
},
|
|
4977
|
+
}, Yu = class e {
|
|
4960
4978
|
tokens;
|
|
4961
4979
|
options;
|
|
4962
4980
|
state;
|
|
4963
4981
|
inlineQueue;
|
|
4964
4982
|
tokenizer;
|
|
4965
4983
|
constructor(e) {
|
|
4966
|
-
this.tokens = [], this.tokens.links = Object.create(null), this.options = e ||
|
|
4984
|
+
this.tokens = [], this.tokens.links = Object.create(null), this.options = e || wl, this.options.tokenizer = this.options.tokenizer || new Ju(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
4967
4985
|
inLink: !1,
|
|
4968
4986
|
inRawBlock: !1,
|
|
4969
4987
|
top: !0
|
|
4970
4988
|
};
|
|
4971
4989
|
let t = {
|
|
4972
|
-
other:
|
|
4973
|
-
block:
|
|
4974
|
-
inline:
|
|
4990
|
+
other: kl,
|
|
4991
|
+
block: Fu.normal,
|
|
4992
|
+
inline: Iu.normal
|
|
4975
4993
|
};
|
|
4976
|
-
this.options.pedantic ? (t.block =
|
|
4994
|
+
this.options.pedantic ? (t.block = Fu.pedantic, t.inline = Iu.pedantic) : this.options.gfm && (t.block = Fu.gfm, this.options.breaks ? t.inline = Iu.breaks : t.inline = Iu.gfm), this.tokenizer.rules = t;
|
|
4977
4995
|
}
|
|
4978
4996
|
static get rules() {
|
|
4979
4997
|
return {
|
|
4980
|
-
block:
|
|
4981
|
-
inline:
|
|
4998
|
+
block: Fu,
|
|
4999
|
+
inline: Iu
|
|
4982
5000
|
};
|
|
4983
5001
|
}
|
|
4984
5002
|
static lex(t, n) {
|
|
@@ -4988,7 +5006,7 @@ ${c}` : c;
|
|
|
4988
5006
|
return new e(n).inlineTokens(t);
|
|
4989
5007
|
}
|
|
4990
5008
|
lex(e) {
|
|
4991
|
-
e = e.replace(
|
|
5009
|
+
e = e.replace(kl.carriageReturn, "\n"), this.blockTokens(e, this.tokens);
|
|
4992
5010
|
for (let e = 0; e < this.inlineQueue.length; e++) {
|
|
4993
5011
|
let t = this.inlineQueue[e];
|
|
4994
5012
|
this.inlineTokens(t.src, t.tokens);
|
|
@@ -4996,7 +5014,7 @@ ${c}` : c;
|
|
|
4996
5014
|
return this.inlineQueue = [], this.tokens;
|
|
4997
5015
|
}
|
|
4998
5016
|
blockTokens(e, t = [], n = !1) {
|
|
4999
|
-
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(
|
|
5017
|
+
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(kl.tabCharGlobal, " ").replace(kl.spaceLine, ""));
|
|
5000
5018
|
let r = Infinity;
|
|
5001
5019
|
for (; e;) {
|
|
5002
5020
|
if (e.length < r) r = e.length;
|
|
@@ -5178,18 +5196,18 @@ ${c}` : c;
|
|
|
5178
5196
|
if (this.options.silent) console.error(t);
|
|
5179
5197
|
else throw Error(t);
|
|
5180
5198
|
}
|
|
5181
|
-
},
|
|
5199
|
+
}, Xu = class {
|
|
5182
5200
|
options;
|
|
5183
5201
|
parser;
|
|
5184
5202
|
constructor(e) {
|
|
5185
|
-
this.options = e ||
|
|
5203
|
+
this.options = e || wl;
|
|
5186
5204
|
}
|
|
5187
5205
|
space(e) {
|
|
5188
5206
|
return "";
|
|
5189
5207
|
}
|
|
5190
5208
|
code({ text: e, lang: t, escaped: n }) {
|
|
5191
|
-
let r = (t || "").match(
|
|
5192
|
-
return r ? "<pre><code class=\"language-" +
|
|
5209
|
+
let r = (t || "").match(kl.notSpaceStart)?.[0], i = e.replace(kl.endingNewline, "") + "\n";
|
|
5210
|
+
return r ? "<pre><code class=\"language-" + zu(r) + "\">" + (n ? i : zu(i, !0)) + "</code></pre>\n" : "<pre><code>" + (n ? i : zu(i, !0)) + "</code></pre>\n";
|
|
5193
5211
|
}
|
|
5194
5212
|
blockquote({ tokens: e }) {
|
|
5195
5213
|
return `<blockquote>
|
|
@@ -5259,7 +5277,7 @@ ${e}</tr>
|
|
|
5259
5277
|
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
5260
5278
|
}
|
|
5261
5279
|
codespan({ text: e }) {
|
|
5262
|
-
return `<code>${
|
|
5280
|
+
return `<code>${zu(e, !0)}</code>`;
|
|
5263
5281
|
}
|
|
5264
5282
|
br(e) {
|
|
5265
5283
|
return "<br>";
|
|
@@ -5268,24 +5286,24 @@ ${e}</tr>
|
|
|
5268
5286
|
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
5269
5287
|
}
|
|
5270
5288
|
link({ href: e, title: t, tokens: n }) {
|
|
5271
|
-
let r = this.parser.parseInline(n), i =
|
|
5289
|
+
let r = this.parser.parseInline(n), i = Bu(e);
|
|
5272
5290
|
if (i === null) return r;
|
|
5273
5291
|
e = i;
|
|
5274
5292
|
let a = "<a href=\"" + e + "\"";
|
|
5275
|
-
return t && (a += " title=\"" +
|
|
5293
|
+
return t && (a += " title=\"" + zu(t) + "\""), a += ">" + r + "</a>", a;
|
|
5276
5294
|
}
|
|
5277
5295
|
image({ href: e, title: t, text: n, tokens: r }) {
|
|
5278
5296
|
r && (n = this.parser.parseInline(r, this.parser.textRenderer));
|
|
5279
|
-
let i =
|
|
5280
|
-
if (i === null) return
|
|
5297
|
+
let i = Bu(e);
|
|
5298
|
+
if (i === null) return zu(n);
|
|
5281
5299
|
e = i;
|
|
5282
|
-
let a = `<img src="${e}" alt="${
|
|
5283
|
-
return t && (a += ` title="${
|
|
5300
|
+
let a = `<img src="${e}" alt="${zu(n)}"`;
|
|
5301
|
+
return t && (a += ` title="${zu(t)}"`), a += ">", a;
|
|
5284
5302
|
}
|
|
5285
5303
|
text(e) {
|
|
5286
|
-
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text :
|
|
5304
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : zu(e.text);
|
|
5287
5305
|
}
|
|
5288
|
-
},
|
|
5306
|
+
}, Zu = class {
|
|
5289
5307
|
strong({ text: e }) {
|
|
5290
5308
|
return e;
|
|
5291
5309
|
}
|
|
@@ -5316,12 +5334,12 @@ ${e}</tr>
|
|
|
5316
5334
|
checkbox({ raw: e }) {
|
|
5317
5335
|
return e;
|
|
5318
5336
|
}
|
|
5319
|
-
},
|
|
5337
|
+
}, Qu = class e {
|
|
5320
5338
|
options;
|
|
5321
5339
|
renderer;
|
|
5322
5340
|
textRenderer;
|
|
5323
5341
|
constructor(e) {
|
|
5324
|
-
this.options = e ||
|
|
5342
|
+
this.options = e || wl, this.options.renderer = this.options.renderer || new Xu(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new Zu();
|
|
5325
5343
|
}
|
|
5326
5344
|
static parse(t, n) {
|
|
5327
5345
|
return new e(n).parse(t);
|
|
@@ -5467,11 +5485,11 @@ ${e}</tr>
|
|
|
5467
5485
|
}
|
|
5468
5486
|
return n;
|
|
5469
5487
|
}
|
|
5470
|
-
},
|
|
5488
|
+
}, $u = class {
|
|
5471
5489
|
options;
|
|
5472
5490
|
block;
|
|
5473
5491
|
constructor(e) {
|
|
5474
|
-
this.options = e ||
|
|
5492
|
+
this.options = e || wl;
|
|
5475
5493
|
}
|
|
5476
5494
|
static passThroughHooks = /* @__PURE__ */ new Set([
|
|
5477
5495
|
"preprocess",
|
|
@@ -5497,22 +5515,22 @@ ${e}</tr>
|
|
|
5497
5515
|
return e;
|
|
5498
5516
|
}
|
|
5499
5517
|
provideLexer(e = this.block) {
|
|
5500
|
-
return e ?
|
|
5518
|
+
return e ? Yu.lex : Yu.lexInline;
|
|
5501
5519
|
}
|
|
5502
5520
|
provideParser(e = this.block) {
|
|
5503
|
-
return e ?
|
|
5521
|
+
return e ? Qu.parse : Qu.parseInline;
|
|
5504
5522
|
}
|
|
5505
|
-
},
|
|
5506
|
-
defaults =
|
|
5523
|
+
}, ed = new class {
|
|
5524
|
+
defaults = Cl();
|
|
5507
5525
|
options = this.setOptions;
|
|
5508
5526
|
parse = this.parseMarkdown(!0);
|
|
5509
5527
|
parseInline = this.parseMarkdown(!1);
|
|
5510
|
-
Parser =
|
|
5511
|
-
Renderer =
|
|
5512
|
-
TextRenderer =
|
|
5513
|
-
Lexer =
|
|
5514
|
-
Tokenizer =
|
|
5515
|
-
Hooks =
|
|
5528
|
+
Parser = Qu;
|
|
5529
|
+
Renderer = Xu;
|
|
5530
|
+
TextRenderer = Zu;
|
|
5531
|
+
Lexer = Yu;
|
|
5532
|
+
Tokenizer = Ju;
|
|
5533
|
+
Hooks = $u;
|
|
5516
5534
|
constructor(...e) {
|
|
5517
5535
|
this.use(...e);
|
|
5518
5536
|
}
|
|
@@ -5563,7 +5581,7 @@ ${e}</tr>
|
|
|
5563
5581
|
}
|
|
5564
5582
|
"childTokens" in e && e.childTokens && (t.childTokens[e.name] = e.childTokens);
|
|
5565
5583
|
}), n.extensions = t), e.renderer) {
|
|
5566
|
-
let t = this.defaults.renderer || new
|
|
5584
|
+
let t = this.defaults.renderer || new Xu(this.defaults);
|
|
5567
5585
|
for (let n in e.renderer) {
|
|
5568
5586
|
if (!(n in t)) throw Error(`renderer '${n}' does not exist`);
|
|
5569
5587
|
if (["options", "parser"].includes(n)) continue;
|
|
@@ -5576,7 +5594,7 @@ ${e}</tr>
|
|
|
5576
5594
|
n.renderer = t;
|
|
5577
5595
|
}
|
|
5578
5596
|
if (e.tokenizer) {
|
|
5579
|
-
let t = this.defaults.tokenizer || new
|
|
5597
|
+
let t = this.defaults.tokenizer || new Ju(this.defaults);
|
|
5580
5598
|
for (let n in e.tokenizer) {
|
|
5581
5599
|
if (!(n in t)) throw Error(`tokenizer '${n}' does not exist`);
|
|
5582
5600
|
if ([
|
|
@@ -5593,13 +5611,13 @@ ${e}</tr>
|
|
|
5593
5611
|
n.tokenizer = t;
|
|
5594
5612
|
}
|
|
5595
5613
|
if (e.hooks) {
|
|
5596
|
-
let t = this.defaults.hooks || new
|
|
5614
|
+
let t = this.defaults.hooks || new $u();
|
|
5597
5615
|
for (let n in e.hooks) {
|
|
5598
5616
|
if (!(n in t)) throw Error(`hook '${n}' does not exist`);
|
|
5599
5617
|
if (["options", "block"].includes(n)) continue;
|
|
5600
5618
|
let r = n, i = e.hooks[r], a = t[r];
|
|
5601
|
-
|
|
5602
|
-
if (this.defaults.async &&
|
|
5619
|
+
$u.passThroughHooks.has(n) ? t[r] = (e) => {
|
|
5620
|
+
if (this.defaults.async && $u.passThroughHooksRespectAsync.has(n)) return (async () => {
|
|
5603
5621
|
let n = await i.call(t, e);
|
|
5604
5622
|
return a.call(t, n);
|
|
5605
5623
|
})();
|
|
@@ -5636,10 +5654,10 @@ ${e}</tr>
|
|
|
5636
5654
|
}, this;
|
|
5637
5655
|
}
|
|
5638
5656
|
lexer(e, t) {
|
|
5639
|
-
return
|
|
5657
|
+
return Yu.lex(e, t ?? this.defaults);
|
|
5640
5658
|
}
|
|
5641
5659
|
parser(e, t) {
|
|
5642
|
-
return
|
|
5660
|
+
return Qu.parse(e, t ?? this.defaults);
|
|
5643
5661
|
}
|
|
5644
5662
|
parseMarkdown(e) {
|
|
5645
5663
|
return (t, n) => {
|
|
@@ -5651,16 +5669,16 @@ ${e}</tr>
|
|
|
5651
5669
|
if (typeof t > "u" || t === null) return a(/* @__PURE__ */ Error("marked(): input parameter is undefined or null"));
|
|
5652
5670
|
if (typeof t != "string") return a(/* @__PURE__ */ Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
|
|
5653
5671
|
if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
|
|
5654
|
-
let n = i.hooks ? await i.hooks.preprocess(t) : t, r = await (i.hooks ? await i.hooks.provideLexer(e) : e ?
|
|
5672
|
+
let n = i.hooks ? await i.hooks.preprocess(t) : t, r = await (i.hooks ? await i.hooks.provideLexer(e) : e ? Yu.lex : Yu.lexInline)(n, i), a = i.hooks ? await i.hooks.processAllTokens(r) : r;
|
|
5655
5673
|
i.walkTokens && await Promise.all(this.walkTokens(a, i.walkTokens));
|
|
5656
|
-
let o = await (i.hooks ? await i.hooks.provideParser(e) : e ?
|
|
5674
|
+
let o = await (i.hooks ? await i.hooks.provideParser(e) : e ? Qu.parse : Qu.parseInline)(a, i);
|
|
5657
5675
|
return i.hooks ? await i.hooks.postprocess(o) : o;
|
|
5658
5676
|
})().catch(a);
|
|
5659
5677
|
try {
|
|
5660
5678
|
i.hooks && (t = i.hooks.preprocess(t));
|
|
5661
|
-
let n = (i.hooks ? i.hooks.provideLexer(e) : e ?
|
|
5679
|
+
let n = (i.hooks ? i.hooks.provideLexer(e) : e ? Yu.lex : Yu.lexInline)(t, i);
|
|
5662
5680
|
i.hooks && (n = i.hooks.processAllTokens(n)), i.walkTokens && this.walkTokens(n, i.walkTokens);
|
|
5663
|
-
let r = (i.hooks ? i.hooks.provideParser(e) : e ?
|
|
5681
|
+
let r = (i.hooks ? i.hooks.provideParser(e) : e ? Qu.parse : Qu.parseInline)(n, i);
|
|
5664
5682
|
return i.hooks && (r = i.hooks.postprocess(r)), r;
|
|
5665
5683
|
} catch (e) {
|
|
5666
5684
|
return a(e);
|
|
@@ -5670,7 +5688,7 @@ ${e}</tr>
|
|
|
5670
5688
|
onError(e, t) {
|
|
5671
5689
|
return (n) => {
|
|
5672
5690
|
if (n.message += "\nPlease report this to https://github.com/markedjs/marked.", e) {
|
|
5673
|
-
let e = "<p>An error occurred:</p><pre>" +
|
|
5691
|
+
let e = "<p>An error occurred:</p><pre>" + zu(n.message + "", !0) + "</pre>";
|
|
5674
5692
|
return t ? Promise.resolve(e) : e;
|
|
5675
5693
|
}
|
|
5676
5694
|
if (t) return Promise.reject(n);
|
|
@@ -5679,18 +5697,18 @@ ${e}</tr>
|
|
|
5679
5697
|
}
|
|
5680
5698
|
}();
|
|
5681
5699
|
function Q(e, t) {
|
|
5682
|
-
return
|
|
5700
|
+
return ed.parse(e, t);
|
|
5683
5701
|
}
|
|
5684
5702
|
Q.options = Q.setOptions = function(e) {
|
|
5685
|
-
return
|
|
5686
|
-
}, Q.getDefaults =
|
|
5687
|
-
return
|
|
5703
|
+
return ed.setOptions(e), Q.defaults = ed.defaults, Tl(Q.defaults), Q;
|
|
5704
|
+
}, Q.getDefaults = Cl, Q.defaults = wl, Q.use = function(...e) {
|
|
5705
|
+
return ed.use(...e), Q.defaults = ed.defaults, Tl(Q.defaults), Q;
|
|
5688
5706
|
}, Q.walkTokens = function(e, t) {
|
|
5689
|
-
return
|
|
5690
|
-
}, Q.parseInline =
|
|
5707
|
+
return ed.walkTokens(e, t);
|
|
5708
|
+
}, Q.parseInline = ed.parseInline, Q.Parser = Qu, Q.parser = Qu.parse, Q.Renderer = Xu, Q.TextRenderer = Zu, Q.Lexer = Yu, Q.lexer = Yu.lex, Q.Tokenizer = Ju, Q.Hooks = $u, Q.parse = Q, Q.options, Q.setOptions, Q.use, Q.walkTokens, Q.parseInline, Qu.parse, Yu.lex;
|
|
5691
5709
|
//#endregion
|
|
5692
5710
|
//#region node_modules/highlight.js/lib/core.js
|
|
5693
|
-
var
|
|
5711
|
+
var td = /* @__PURE__ */ m(((e, t) => {
|
|
5694
5712
|
function n(e) {
|
|
5695
5713
|
return e instanceof Map ? e.clear = e.delete = e.set = function() {
|
|
5696
5714
|
throw Error("map is read-only");
|
|
@@ -6531,7 +6549,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6531
6549
|
return Object.assign(e, z), e;
|
|
6532
6550
|
}, Me = je({});
|
|
6533
6551
|
Me.newInstance = () => je({}), t.exports = Me, Me.HighlightJS = Me, Me.default = Me;
|
|
6534
|
-
})),
|
|
6552
|
+
})), nd = /* @__PURE__ */ m(((e, t) => {
|
|
6535
6553
|
function n(e) {
|
|
6536
6554
|
let t = e.regex, n = t.concat(/[\p{L}_]/u, t.optional(/[\p{L}0-9_.-]*:/u), /[\p{L}0-9_.-]*/u), r = /[\p{L}0-9._:-]+/u, i = {
|
|
6537
6555
|
className: "symbol",
|
|
@@ -6696,7 +6714,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6696
6714
|
};
|
|
6697
6715
|
}
|
|
6698
6716
|
t.exports = n;
|
|
6699
|
-
})),
|
|
6717
|
+
})), rd = /* @__PURE__ */ m(((e, t) => {
|
|
6700
6718
|
function n(e) {
|
|
6701
6719
|
let t = e.regex, n = {}, r = {
|
|
6702
6720
|
begin: /\$\{/,
|
|
@@ -6864,7 +6882,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6864
6882
|
};
|
|
6865
6883
|
}
|
|
6866
6884
|
t.exports = n;
|
|
6867
|
-
})),
|
|
6885
|
+
})), id = /* @__PURE__ */ m(((e, t) => {
|
|
6868
6886
|
function n(e) {
|
|
6869
6887
|
let t = e.regex, n = e.COMMENT("//", "$", { contains: [{ begin: /\\\n/ }] }), r = "[a-zA-Z_]\\w*::", i = "(decltype\\(auto\\)|" + t.optional(r) + "[a-zA-Z_]\\w*" + t.optional("<[^<>]+>") + ")", a = {
|
|
6870
6888
|
className: "type",
|
|
@@ -7039,7 +7057,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
7039
7057
|
};
|
|
7040
7058
|
}
|
|
7041
7059
|
t.exports = n;
|
|
7042
|
-
})),
|
|
7060
|
+
})), ad = /* @__PURE__ */ m(((e, t) => {
|
|
7043
7061
|
function n(e) {
|
|
7044
7062
|
let t = e.regex, n = e.COMMENT("//", "$", { contains: [{ begin: /\\\n/ }] }), r = "[a-zA-Z_]\\w*::", i = "(?!struct)(decltype\\(auto\\)|" + t.optional(r) + "[a-zA-Z_]\\w*" + t.optional("<[^<>]+>") + ")", a = {
|
|
7045
7063
|
className: "type",
|
|
@@ -7263,7 +7281,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
7263
7281
|
};
|
|
7264
7282
|
}
|
|
7265
7283
|
t.exports = n;
|
|
7266
|
-
})),
|
|
7284
|
+
})), od = /* @__PURE__ */ m(((e, t) => {
|
|
7267
7285
|
function n(e) {
|
|
7268
7286
|
let t = [
|
|
7269
7287
|
"bool",
|
|
@@ -7522,7 +7540,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
7522
7540
|
};
|
|
7523
7541
|
}
|
|
7524
7542
|
t.exports = n;
|
|
7525
|
-
})),
|
|
7543
|
+
})), sd = /* @__PURE__ */ m(((e, t) => {
|
|
7526
7544
|
var n = (e) => ({
|
|
7527
7545
|
IMPORTANT: {
|
|
7528
7546
|
scope: "meta",
|
|
@@ -7661,7 +7679,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
7661
7679
|
};
|
|
7662
7680
|
}
|
|
7663
7681
|
t.exports = u;
|
|
7664
|
-
})),
|
|
7682
|
+
})), cd = /* @__PURE__ */ m(((e, t) => {
|
|
7665
7683
|
function n(e) {
|
|
7666
7684
|
let t = e.regex, n = {
|
|
7667
7685
|
begin: /<\/?[A-Za-z_]/,
|
|
@@ -7841,7 +7859,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
7841
7859
|
};
|
|
7842
7860
|
}
|
|
7843
7861
|
t.exports = n;
|
|
7844
|
-
})),
|
|
7862
|
+
})), ld = /* @__PURE__ */ m(((e, t) => {
|
|
7845
7863
|
function n(e) {
|
|
7846
7864
|
let t = e.regex;
|
|
7847
7865
|
return {
|
|
@@ -7879,7 +7897,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
7879
7897
|
};
|
|
7880
7898
|
}
|
|
7881
7899
|
t.exports = n;
|
|
7882
|
-
})),
|
|
7900
|
+
})), ud = /* @__PURE__ */ m(((e, t) => {
|
|
7883
7901
|
function n(e) {
|
|
7884
7902
|
let t = e.regex, n = "([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)", r = t.either(/\b([A-Z]+[a-z0-9]+)+/, /\b([A-Z]+[a-z0-9]+)+[A-Z]+/), i = t.concat(r, /(::\w+)*/), a = {
|
|
7885
7903
|
"variable.constant": [
|
|
@@ -8140,7 +8158,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8140
8158
|
};
|
|
8141
8159
|
}
|
|
8142
8160
|
t.exports = n;
|
|
8143
|
-
})),
|
|
8161
|
+
})), dd = /* @__PURE__ */ m(((e, t) => {
|
|
8144
8162
|
function n(e) {
|
|
8145
8163
|
let t = {
|
|
8146
8164
|
keyword: [
|
|
@@ -8279,7 +8297,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8279
8297
|
};
|
|
8280
8298
|
}
|
|
8281
8299
|
t.exports = n;
|
|
8282
|
-
})),
|
|
8300
|
+
})), fd = /* @__PURE__ */ m(((e, t) => {
|
|
8283
8301
|
function n(e) {
|
|
8284
8302
|
let t = e.regex;
|
|
8285
8303
|
return {
|
|
@@ -8345,7 +8363,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8345
8363
|
};
|
|
8346
8364
|
}
|
|
8347
8365
|
t.exports = n;
|
|
8348
|
-
})),
|
|
8366
|
+
})), pd = /* @__PURE__ */ m(((e, t) => {
|
|
8349
8367
|
function n(e) {
|
|
8350
8368
|
let t = e.regex, n = {
|
|
8351
8369
|
className: "number",
|
|
@@ -8432,7 +8450,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8432
8450
|
};
|
|
8433
8451
|
}
|
|
8434
8452
|
t.exports = n;
|
|
8435
|
-
})),
|
|
8453
|
+
})), md = /* @__PURE__ */ m(((e, t) => {
|
|
8436
8454
|
var n = "[0-9](_*[0-9])*", r = `\\.(${n})`, i = "[0-9a-fA-F](_*[0-9a-fA-F])*", a = {
|
|
8437
8455
|
className: "number",
|
|
8438
8456
|
variants: [
|
|
@@ -8600,7 +8618,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8600
8618
|
};
|
|
8601
8619
|
}
|
|
8602
8620
|
t.exports = s;
|
|
8603
|
-
})),
|
|
8621
|
+
})), hd = /* @__PURE__ */ m(((e, t) => {
|
|
8604
8622
|
var n = "[A-Za-z$_][0-9A-Za-z$_]*", r = /* @__PURE__ */ "as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using".split("."), i = [
|
|
8605
8623
|
"true",
|
|
8606
8624
|
"false",
|
|
@@ -9035,7 +9053,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
9035
9053
|
};
|
|
9036
9054
|
}
|
|
9037
9055
|
t.exports = u;
|
|
9038
|
-
})),
|
|
9056
|
+
})), gd = /* @__PURE__ */ m(((e, t) => {
|
|
9039
9057
|
function n(e) {
|
|
9040
9058
|
let t = {
|
|
9041
9059
|
className: "attr",
|
|
@@ -9070,7 +9088,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
9070
9088
|
};
|
|
9071
9089
|
}
|
|
9072
9090
|
t.exports = n;
|
|
9073
|
-
})),
|
|
9091
|
+
})), _d = /* @__PURE__ */ m(((e, t) => {
|
|
9074
9092
|
var n = "[0-9](_*[0-9])*", r = `\\.(${n})`, i = "[0-9a-fA-F](_*[0-9a-fA-F])*", a = {
|
|
9075
9093
|
className: "number",
|
|
9076
9094
|
variants: [
|
|
@@ -9270,7 +9288,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
9270
9288
|
};
|
|
9271
9289
|
}
|
|
9272
9290
|
t.exports = o;
|
|
9273
|
-
})),
|
|
9291
|
+
})), vd = /* @__PURE__ */ m(((e, t) => {
|
|
9274
9292
|
var n = (e) => ({
|
|
9275
9293
|
IMPORTANT: {
|
|
9276
9294
|
scope: "meta",
|
|
@@ -9461,7 +9479,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
9461
9479
|
};
|
|
9462
9480
|
}
|
|
9463
9481
|
t.exports = d;
|
|
9464
|
-
})),
|
|
9482
|
+
})), yd = /* @__PURE__ */ m(((e, t) => {
|
|
9465
9483
|
function n(e) {
|
|
9466
9484
|
let t = "\\[=*\\[", n = "\\]=*\\]", r = {
|
|
9467
9485
|
begin: t,
|
|
@@ -9506,7 +9524,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
9506
9524
|
};
|
|
9507
9525
|
}
|
|
9508
9526
|
t.exports = n;
|
|
9509
|
-
})),
|
|
9527
|
+
})), bd = /* @__PURE__ */ m(((e, t) => {
|
|
9510
9528
|
function n(e) {
|
|
9511
9529
|
let t = {
|
|
9512
9530
|
className: "variable",
|
|
@@ -9562,7 +9580,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
9562
9580
|
};
|
|
9563
9581
|
}
|
|
9564
9582
|
t.exports = n;
|
|
9565
|
-
})),
|
|
9583
|
+
})), xd = /* @__PURE__ */ m(((e, t) => {
|
|
9566
9584
|
function n(e) {
|
|
9567
9585
|
let t = e.regex, n = /* @__PURE__ */ "abs.accept.alarm.and.atan2.bind.binmode.bless.break.caller.chdir.chmod.chomp.chop.chown.chr.chroot.class.close.closedir.connect.continue.cos.crypt.dbmclose.dbmopen.defined.delete.die.do.dump.each.else.elsif.endgrent.endhostent.endnetent.endprotoent.endpwent.endservent.eof.eval.exec.exists.exit.exp.fcntl.field.fileno.flock.for.foreach.fork.format.formline.getc.getgrent.getgrgid.getgrnam.gethostbyaddr.gethostbyname.gethostent.getlogin.getnetbyaddr.getnetbyname.getnetent.getpeername.getpgrp.getpriority.getprotobyname.getprotobynumber.getprotoent.getpwent.getpwnam.getpwuid.getservbyname.getservbyport.getservent.getsockname.getsockopt.given.glob.gmtime.goto.grep.gt.hex.if.index.int.ioctl.join.keys.kill.last.lc.lcfirst.length.link.listen.local.localtime.log.lstat.lt.ma.map.method.mkdir.msgctl.msgget.msgrcv.msgsnd.my.ne.next.no.not.oct.open.opendir.or.ord.our.pack.package.pipe.pop.pos.print.printf.prototype.push.q|0.qq.quotemeta.qw.qx.rand.read.readdir.readline.readlink.readpipe.recv.redo.ref.rename.require.reset.return.reverse.rewinddir.rindex.rmdir.say.scalar.seek.seekdir.select.semctl.semget.semop.send.setgrent.sethostent.setnetent.setpgrp.setpriority.setprotoent.setpwent.setservent.setsockopt.shift.shmctl.shmget.shmread.shmwrite.shutdown.sin.sleep.socket.socketpair.sort.splice.split.sprintf.sqrt.srand.stat.state.study.sub.substr.symlink.syscall.sysopen.sysread.sysseek.system.syswrite.tell.telldir.tie.tied.time.times.tr.truncate.uc.ucfirst.umask.undef.unless.unlink.unpack.unshift.untie.until.use.utime.values.vec.wait.waitpid.wantarray.warn.when.while.write.x|0.xor.y|0".split("."), r = /[dualxmsipngr]{0,12}/, i = {
|
|
9568
9586
|
$pattern: /[\w.]+/,
|
|
@@ -9753,7 +9771,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
9753
9771
|
};
|
|
9754
9772
|
}
|
|
9755
9773
|
t.exports = n;
|
|
9756
|
-
})),
|
|
9774
|
+
})), Sd = /* @__PURE__ */ m(((e, t) => {
|
|
9757
9775
|
function n(e) {
|
|
9758
9776
|
let t = {
|
|
9759
9777
|
className: "built_in",
|
|
@@ -9869,7 +9887,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
9869
9887
|
};
|
|
9870
9888
|
}
|
|
9871
9889
|
t.exports = n;
|
|
9872
|
-
})),
|
|
9890
|
+
})), Cd = /* @__PURE__ */ m(((e, t) => {
|
|
9873
9891
|
function n(e) {
|
|
9874
9892
|
let t = e.regex, n = /(?![A-Za-z0-9])(?![$])/, r = t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/, n), i = t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/, n), a = t.concat(/[A-Z]+/, n), o = {
|
|
9875
9893
|
scope: "variable",
|
|
@@ -10162,7 +10180,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
10162
10180
|
};
|
|
10163
10181
|
}
|
|
10164
10182
|
t.exports = n;
|
|
10165
|
-
})),
|
|
10183
|
+
})), wd = /* @__PURE__ */ m(((e, t) => {
|
|
10166
10184
|
function n(e) {
|
|
10167
10185
|
return {
|
|
10168
10186
|
name: "PHP template",
|
|
@@ -10204,7 +10222,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
10204
10222
|
};
|
|
10205
10223
|
}
|
|
10206
10224
|
t.exports = n;
|
|
10207
|
-
})),
|
|
10225
|
+
})), Td = /* @__PURE__ */ m(((e, t) => {
|
|
10208
10226
|
function n(e) {
|
|
10209
10227
|
return {
|
|
10210
10228
|
name: "Plain text",
|
|
@@ -10213,7 +10231,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
10213
10231
|
};
|
|
10214
10232
|
}
|
|
10215
10233
|
t.exports = n;
|
|
10216
|
-
})),
|
|
10234
|
+
})), Ed = /* @__PURE__ */ m(((e, t) => {
|
|
10217
10235
|
function n(e) {
|
|
10218
10236
|
let t = e.regex, n = /[\p{XID_Start}_]\p{XID_Continue}*/u, r = /* @__PURE__ */ "and.as.assert.async.await.break.case.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.match.nonlocal|10.not.or.pass.raise.return.try.while.with.yield".split("."), i = {
|
|
10219
10237
|
$pattern: /[A-Za-z]\w+|__\w+__/,
|
|
@@ -10450,7 +10468,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
10450
10468
|
};
|
|
10451
10469
|
}
|
|
10452
10470
|
t.exports = n;
|
|
10453
|
-
})),
|
|
10471
|
+
})), Dd = /* @__PURE__ */ m(((e, t) => {
|
|
10454
10472
|
function n(e) {
|
|
10455
10473
|
return {
|
|
10456
10474
|
aliases: ["pycon"],
|
|
@@ -10468,7 +10486,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
10468
10486
|
};
|
|
10469
10487
|
}
|
|
10470
10488
|
t.exports = n;
|
|
10471
|
-
})),
|
|
10489
|
+
})), Od = /* @__PURE__ */ m(((e, t) => {
|
|
10472
10490
|
function n(e) {
|
|
10473
10491
|
let t = e.regex, n = /(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/, r = t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/, /0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/, /(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/), i = /[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/, a = t.either(/[()]/, /[{}]/, /\[\[/, /[[\]]/, /\\/, /,/);
|
|
10474
10492
|
return {
|
|
@@ -10607,7 +10625,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
10607
10625
|
};
|
|
10608
10626
|
}
|
|
10609
10627
|
t.exports = n;
|
|
10610
|
-
})),
|
|
10628
|
+
})), kd = /* @__PURE__ */ m(((e, t) => {
|
|
10611
10629
|
function n(e) {
|
|
10612
10630
|
let t = e.regex, n = /(r#)?/, r = t.concat(n, e.UNDERSCORE_IDENT_RE), i = t.concat(n, e.IDENT_RE), a = {
|
|
10613
10631
|
className: "title.function.invoke",
|
|
@@ -10775,7 +10793,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
10775
10793
|
};
|
|
10776
10794
|
}
|
|
10777
10795
|
t.exports = n;
|
|
10778
|
-
})),
|
|
10796
|
+
})), Ad = /* @__PURE__ */ m(((e, t) => {
|
|
10779
10797
|
var n = (e) => ({
|
|
10780
10798
|
IMPORTANT: {
|
|
10781
10799
|
scope: "meta",
|
|
@@ -10924,7 +10942,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
10924
10942
|
};
|
|
10925
10943
|
}
|
|
10926
10944
|
t.exports = u;
|
|
10927
|
-
})),
|
|
10945
|
+
})), jd = /* @__PURE__ */ m(((e, t) => {
|
|
10928
10946
|
function n(e) {
|
|
10929
10947
|
return {
|
|
10930
10948
|
name: "Shell Session",
|
|
@@ -10940,7 +10958,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
10940
10958
|
};
|
|
10941
10959
|
}
|
|
10942
10960
|
t.exports = n;
|
|
10943
|
-
})),
|
|
10961
|
+
})), Md = /* @__PURE__ */ m(((e, t) => {
|
|
10944
10962
|
function n(e) {
|
|
10945
10963
|
let t = e.regex, n = e.COMMENT("--", "$"), r = {
|
|
10946
10964
|
scope: "string",
|
|
@@ -11057,7 +11075,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11057
11075
|
};
|
|
11058
11076
|
}
|
|
11059
11077
|
t.exports = n;
|
|
11060
|
-
})),
|
|
11078
|
+
})), Nd = /* @__PURE__ */ m(((e, t) => {
|
|
11061
11079
|
function n(e) {
|
|
11062
11080
|
return e ? typeof e == "string" ? e : e.source : null;
|
|
11063
11081
|
}
|
|
@@ -11630,7 +11648,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11630
11648
|
};
|
|
11631
11649
|
}
|
|
11632
11650
|
t.exports = T;
|
|
11633
|
-
})),
|
|
11651
|
+
})), Pd = /* @__PURE__ */ m(((e, t) => {
|
|
11634
11652
|
function n(e) {
|
|
11635
11653
|
let t = "true false yes no null", n = {
|
|
11636
11654
|
className: "attr",
|
|
@@ -11773,7 +11791,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11773
11791
|
};
|
|
11774
11792
|
}
|
|
11775
11793
|
t.exports = n;
|
|
11776
|
-
})),
|
|
11794
|
+
})), Fd = /* @__PURE__ */ m(((e, t) => {
|
|
11777
11795
|
var n = "[A-Za-z$_][0-9A-Za-z$_]*", r = /* @__PURE__ */ "as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using".split("."), i = [
|
|
11778
11796
|
"true",
|
|
11779
11797
|
"false",
|
|
@@ -12293,7 +12311,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12293
12311
|
}), a;
|
|
12294
12312
|
}
|
|
12295
12313
|
t.exports = d;
|
|
12296
|
-
})),
|
|
12314
|
+
})), Id = /* @__PURE__ */ m(((e, t) => {
|
|
12297
12315
|
function n(e) {
|
|
12298
12316
|
let t = e.regex, n = {
|
|
12299
12317
|
className: "string",
|
|
@@ -12361,7 +12379,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12361
12379
|
};
|
|
12362
12380
|
}
|
|
12363
12381
|
t.exports = n;
|
|
12364
|
-
})),
|
|
12382
|
+
})), Ld = /* @__PURE__ */ m(((e, t) => {
|
|
12365
12383
|
function n(e) {
|
|
12366
12384
|
e.regex;
|
|
12367
12385
|
let t = e.COMMENT(/\(;/, /;\)/);
|
|
@@ -12423,9 +12441,9 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12423
12441
|
};
|
|
12424
12442
|
}
|
|
12425
12443
|
t.exports = n;
|
|
12426
|
-
})),
|
|
12427
|
-
var n =
|
|
12428
|
-
n.registerLanguage("xml",
|
|
12444
|
+
})), Rd = (/* @__PURE__ */ g((/* @__PURE__ */ m(((e, t) => {
|
|
12445
|
+
var n = td();
|
|
12446
|
+
n.registerLanguage("xml", nd()), n.registerLanguage("bash", rd()), n.registerLanguage("c", id()), n.registerLanguage("cpp", ad()), n.registerLanguage("csharp", od()), n.registerLanguage("css", sd()), n.registerLanguage("markdown", cd()), n.registerLanguage("diff", ld()), n.registerLanguage("ruby", ud()), n.registerLanguage("go", dd()), n.registerLanguage("graphql", fd()), n.registerLanguage("ini", pd()), n.registerLanguage("java", md()), n.registerLanguage("javascript", hd()), n.registerLanguage("json", gd()), n.registerLanguage("kotlin", _d()), n.registerLanguage("less", vd()), n.registerLanguage("lua", yd()), n.registerLanguage("makefile", bd()), n.registerLanguage("perl", xd()), n.registerLanguage("objectivec", Sd()), n.registerLanguage("php", Cd()), n.registerLanguage("php-template", wd()), n.registerLanguage("plaintext", Td()), n.registerLanguage("python", Ed()), n.registerLanguage("python-repl", Dd()), n.registerLanguage("r", Od()), n.registerLanguage("rust", kd()), n.registerLanguage("scss", Ad()), n.registerLanguage("shell", jd()), n.registerLanguage("sql", Md()), n.registerLanguage("swift", Nd()), n.registerLanguage("yaml", Pd()), n.registerLanguage("typescript", Fd()), n.registerLanguage("vbnet", Id()), n.registerLanguage("wasm", Ld()), n.HighlightJS = n, n.default = n, t.exports = n;
|
|
12429
12447
|
})))())).default;
|
|
12430
12448
|
//#endregion
|
|
12431
12449
|
//#region src/core/composables/useMarkdown.ts
|
|
@@ -12433,25 +12451,25 @@ Q.setOptions({
|
|
|
12433
12451
|
breaks: !0,
|
|
12434
12452
|
gfm: !0
|
|
12435
12453
|
});
|
|
12436
|
-
var
|
|
12437
|
-
|
|
12454
|
+
var zd = new Q.Renderer();
|
|
12455
|
+
zd.code = ({ text: e, lang: t }) => {
|
|
12438
12456
|
let n = (t || "").trim() || "plaintext", r = "";
|
|
12439
12457
|
try {
|
|
12440
|
-
r =
|
|
12458
|
+
r = Rd.highlight(e, {
|
|
12441
12459
|
language: n,
|
|
12442
12460
|
ignoreIllegals: !0
|
|
12443
12461
|
}).value;
|
|
12444
12462
|
} catch {
|
|
12445
|
-
r =
|
|
12463
|
+
r = Bd(e);
|
|
12446
12464
|
}
|
|
12447
12465
|
return `<pre class="code-block" data-lang="${n}" data-code="${encodeURIComponent(e)}"><code class="hljs language-${n}">${r}</code></pre>`;
|
|
12448
12466
|
};
|
|
12449
|
-
function
|
|
12467
|
+
function Bd(e) {
|
|
12450
12468
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
12451
12469
|
}
|
|
12452
|
-
function
|
|
12470
|
+
function Vd(e) {
|
|
12453
12471
|
return {
|
|
12454
|
-
html: zs(() => Q.parse(e() || "", { renderer:
|
|
12472
|
+
html: zs(() => Q.parse(e() || "", { renderer: zd })),
|
|
12455
12473
|
codeBlocks: zs(() => {
|
|
12456
12474
|
let t = [], n = /```(\w+)?\n([\s\S]*?)```/g, r;
|
|
12457
12475
|
for (; (r = n.exec(e() || "")) !== null;) t.push({
|
|
@@ -12464,10 +12482,10 @@ function Bd(e) {
|
|
|
12464
12482
|
}
|
|
12465
12483
|
//#endregion
|
|
12466
12484
|
//#region src/core/components/CodePreview.vue?vue&type=script&setup=true&lang.ts
|
|
12467
|
-
var
|
|
12485
|
+
var Hd = { class: "code-preview-modal" }, Ud = { class: "preview-header" }, Wd = { class: "preview-title" }, Gd = { class: "preview-tabs" }, Kd = ["disabled"], qd = { class: "preview-actions" }, Jd = ["title"], Yd = { class: "preview-body" }, Xd = ["srcdoc"], Zd = {
|
|
12468
12486
|
key: 1,
|
|
12469
12487
|
class: "preview-source"
|
|
12470
|
-
},
|
|
12488
|
+
}, Qd = /*@__PURE__*/ wi({
|
|
12471
12489
|
__name: "CodePreview",
|
|
12472
12490
|
props: {
|
|
12473
12491
|
code: {},
|
|
@@ -12515,8 +12533,8 @@ app.mount('#app');
|
|
|
12515
12533
|
await Xn(), a.value === "preview" && i.value && (i.value.srcdoc = c.value);
|
|
12516
12534
|
}, { immediate: !0 });
|
|
12517
12535
|
function u() {
|
|
12518
|
-
|
|
12519
|
-
o.value = !0, setTimeout(() => o.value = !1, 1500);
|
|
12536
|
+
Sl(n.code).then((e) => {
|
|
12537
|
+
e && (o.value = !0, setTimeout(() => o.value = !1, 1500));
|
|
12520
12538
|
});
|
|
12521
12539
|
}
|
|
12522
12540
|
function d() {
|
|
@@ -12526,22 +12544,22 @@ app.mount('#app');
|
|
|
12526
12544
|
return (t, n) => (q(), J("div", {
|
|
12527
12545
|
class: "code-preview-overlay",
|
|
12528
12546
|
onClick: n[3] ||= ol((e) => r("close"), ["self"])
|
|
12529
|
-
}, [Y("div",
|
|
12530
|
-
Y("span",
|
|
12531
|
-
Y("div",
|
|
12547
|
+
}, [Y("div", Hd, [Y("div", Ud, [
|
|
12548
|
+
Y("span", Wd, "代码预览 · " + V(e.lang), 1),
|
|
12549
|
+
Y("div", Gd, [Y("button", {
|
|
12532
12550
|
class: Se({ active: a.value === "preview" }),
|
|
12533
12551
|
disabled: !s.value,
|
|
12534
12552
|
onClick: n[0] ||= (e) => a.value = "preview"
|
|
12535
|
-
}, "预览", 10,
|
|
12553
|
+
}, "预览", 10, Kd), Y("button", {
|
|
12536
12554
|
class: Se({ active: a.value === "source" }),
|
|
12537
12555
|
onClick: n[1] ||= (e) => a.value = "source"
|
|
12538
12556
|
}, "源码", 2)]),
|
|
12539
|
-
Y("div",
|
|
12557
|
+
Y("div", qd, [
|
|
12540
12558
|
Y("button", {
|
|
12541
12559
|
class: "icon-btn",
|
|
12542
12560
|
title: o.value ? "已复制" : "复制代码",
|
|
12543
12561
|
onClick: u
|
|
12544
|
-
}, V(o.value ? "✓" : "📋"), 9,
|
|
12562
|
+
}, V(o.value ? "✓" : "📋"), 9, Jd),
|
|
12545
12563
|
Y("button", {
|
|
12546
12564
|
class: "icon-btn",
|
|
12547
12565
|
title: "新窗口打开",
|
|
@@ -12553,24 +12571,24 @@ app.mount('#app');
|
|
|
12553
12571
|
onClick: n[2] ||= (e) => r("close")
|
|
12554
12572
|
}, "✕")
|
|
12555
12573
|
])
|
|
12556
|
-
]), Y("div",
|
|
12574
|
+
]), Y("div", Yd, [a.value === "preview" && s.value ? (q(), J("iframe", {
|
|
12557
12575
|
key: 0,
|
|
12558
12576
|
ref_key: "iframeRef",
|
|
12559
12577
|
ref: i,
|
|
12560
12578
|
class: "preview-iframe",
|
|
12561
12579
|
sandbox: "allow-scripts allow-modals allow-popups allow-forms",
|
|
12562
12580
|
srcdoc: c.value
|
|
12563
|
-
}, null, 8,
|
|
12581
|
+
}, null, 8, Xd)) : (q(), J("pre", Zd, [Y("code", null, V(e.code), 1)]))])])]));
|
|
12564
12582
|
}
|
|
12565
|
-
}),
|
|
12583
|
+
}), $d = (e, t) => {
|
|
12566
12584
|
let n = e.__vccOpts || e;
|
|
12567
12585
|
for (let [e, r] of t) n[e] = r;
|
|
12568
12586
|
return n;
|
|
12569
|
-
},
|
|
12587
|
+
}, ef = /*#__PURE__*/ $d(Qd, [["__scopeId", "data-v-3d6e2a95"]]), tf = ["innerHTML"], nf = /* @__PURE__ */ wi({
|
|
12570
12588
|
__name: "MessageContent",
|
|
12571
12589
|
props: { content: {} },
|
|
12572
12590
|
setup(e) {
|
|
12573
|
-
let t = e, { html: n, codeBlocks: r } =
|
|
12591
|
+
let t = e, { html: n, codeBlocks: r } = Vd(() => t.content), i = /* @__PURE__ */ fn(null), a = /* @__PURE__ */ fn(null), o = [
|
|
12574
12592
|
"html",
|
|
12575
12593
|
"htm",
|
|
12576
12594
|
"vue",
|
|
@@ -12611,8 +12629,9 @@ app.mount('#app');
|
|
|
12611
12629
|
let o = document.createElement("span");
|
|
12612
12630
|
o.className = "code-lang", o.textContent = n, i.appendChild(o);
|
|
12613
12631
|
let l = document.createElement("button");
|
|
12614
|
-
l.className = "code-action-btn", l.innerHTML = "复制", l.onclick = () => {
|
|
12615
|
-
|
|
12632
|
+
l.className = "code-action-btn", l.innerHTML = "复制", l.onclick = async () => {
|
|
12633
|
+
let e = await Sl(r);
|
|
12634
|
+
l.innerHTML = e ? "已复制 ✓" : "复制失败", setTimeout(() => l.innerHTML = "复制", 1500);
|
|
12616
12635
|
}, i.appendChild(l);
|
|
12617
12636
|
let u = document.createElement("button");
|
|
12618
12637
|
if (u.className = "code-action-btn", u.innerHTML = "⬇ 下载", u.title = "下载为文件", u.onclick = () => c(n, r), i.appendChild(u), s(n)) {
|
|
@@ -12632,119 +12651,119 @@ app.mount('#app');
|
|
|
12632
12651
|
ref_key: "containerRef",
|
|
12633
12652
|
ref: i,
|
|
12634
12653
|
innerHTML: W(n)
|
|
12635
|
-
}, null, 8,
|
|
12654
|
+
}, null, 8, tf), (q(), Ko(oi, { to: "body" }, [a.value ? (q(), Ko(ef, {
|
|
12636
12655
|
key: 0,
|
|
12637
12656
|
code: a.value.code,
|
|
12638
12657
|
lang: a.value.lang,
|
|
12639
12658
|
onClose: t[0] ||= (e) => a.value = null
|
|
12640
12659
|
}, null, 8, ["code", "lang"])) : X("", !0)]))], 64));
|
|
12641
12660
|
}
|
|
12642
|
-
}),
|
|
12661
|
+
}), rf = {
|
|
12643
12662
|
key: 0,
|
|
12644
12663
|
class: "debug-drawer"
|
|
12645
|
-
},
|
|
12664
|
+
}, af = { class: "drawer-panel" }, of = { class: "drawer-header" }, sf = { class: "tab-group" }, cf = { class: "header-actions" }, lf = {
|
|
12646
12665
|
key: 0,
|
|
12647
12666
|
class: "drawer-filters"
|
|
12648
|
-
},
|
|
12667
|
+
}, uf = ["onClick"], df = { class: "chip-count" }, ff = { class: "chip-count" }, pf = { class: "drawer-body" }, mf = {
|
|
12649
12668
|
key: 0,
|
|
12650
12669
|
class: "empty"
|
|
12651
|
-
},
|
|
12670
|
+
}, hf = { class: "log-head" }, gf = {
|
|
12652
12671
|
key: 0,
|
|
12653
12672
|
class: "log-source"
|
|
12654
|
-
},
|
|
12673
|
+
}, _f = { class: "log-time" }, vf = { class: "log-body" }, yf = { class: "kv-grid" }, bf = { class: "kv" }, xf = { class: "v" }, Sf = { class: "kv" }, Cf = { class: "v" }, wf = { class: "kv" }, Tf = { class: "v" }, Ef = { class: "kv" }, Df = { class: "v" }, Of = { class: "section-label" }, kf = { class: "chip-row" }, Af = { class: "msg-list" }, jf = { class: "msg-text" }, Mf = { class: "badge-row" }, Nf = { class: "badge" }, Pf = {
|
|
12655
12674
|
key: 0,
|
|
12656
12675
|
class: "badge muted"
|
|
12657
|
-
},
|
|
12676
|
+
}, Ff = { class: "badge muted" }, If = {
|
|
12658
12677
|
key: 1,
|
|
12659
12678
|
class: "badge muted"
|
|
12660
|
-
},
|
|
12679
|
+
}, Lf = ["onClick"], Rf = {
|
|
12661
12680
|
key: 0,
|
|
12662
12681
|
class: "msg-list"
|
|
12663
|
-
},
|
|
12682
|
+
}, zf = { class: "msg-detail" }, Bf = {
|
|
12664
12683
|
key: 0,
|
|
12665
12684
|
class: "msg-text"
|
|
12666
|
-
},
|
|
12685
|
+
}, Vf = { class: "tc-inline-name" }, Hf = { class: "tc-inline-args" }, Uf = {
|
|
12667
12686
|
key: 1,
|
|
12668
12687
|
class: "tc-id"
|
|
12669
|
-
},
|
|
12688
|
+
}, Wf = {
|
|
12670
12689
|
key: 1,
|
|
12671
12690
|
class: "log-raw"
|
|
12672
|
-
},
|
|
12691
|
+
}, Gf = { class: "badge-row" }, Kf = { class: "badge" }, qf = {
|
|
12673
12692
|
key: 0,
|
|
12674
12693
|
class: "badge warn"
|
|
12675
|
-
},
|
|
12694
|
+
}, Jf = {
|
|
12676
12695
|
key: 0,
|
|
12677
12696
|
class: "resp-content"
|
|
12678
|
-
},
|
|
12697
|
+
}, Yf = {
|
|
12679
12698
|
key: 1,
|
|
12680
12699
|
class: "tc-list"
|
|
12681
|
-
},
|
|
12700
|
+
}, Xf = { class: "tc-name" }, Zf = { class: "tc-args" }, Qf = {
|
|
12682
12701
|
key: 2,
|
|
12683
12702
|
class: "usage-row"
|
|
12684
|
-
},
|
|
12703
|
+
}, $f = { class: "usage" }, ep = { class: "usage" }, tp = { class: "usage" }, np = {
|
|
12685
12704
|
key: 3,
|
|
12686
12705
|
class: "tc-card inline"
|
|
12687
|
-
},
|
|
12706
|
+
}, rp = { class: "tc-name" }, ip = { class: "tc-args" }, ap = {
|
|
12688
12707
|
key: 4,
|
|
12689
12708
|
class: "tc-card inline"
|
|
12690
|
-
},
|
|
12709
|
+
}, op = { class: "tc-name" }, sp = { class: "tc-args" }, cp = {
|
|
12691
12710
|
key: 5,
|
|
12692
12711
|
class: "err-box"
|
|
12693
|
-
},
|
|
12712
|
+
}, lp = { class: "log-footer" }, up = ["onClick"], dp = ["onClick"], fp = {
|
|
12694
12713
|
key: 0,
|
|
12695
12714
|
class: "log-raw"
|
|
12696
|
-
},
|
|
12715
|
+
}, pp = {
|
|
12697
12716
|
key: 0,
|
|
12698
12717
|
class: "empty"
|
|
12699
|
-
},
|
|
12718
|
+
}, mp = {
|
|
12700
12719
|
key: 1,
|
|
12701
12720
|
class: "flow-section"
|
|
12702
|
-
},
|
|
12721
|
+
}, hp = { class: "flow-ico" }, gp = { class: "flow-label" }, _p = { class: "flow-detail" }, vp = { class: "flow-time" }, yp = { class: "flow-round-head" }, bp = { class: "flow-round-body" }, xp = { class: "flow-ico" }, Sp = { class: "flow-label" }, Cp = { class: "flow-detail" }, wp = { class: "flow-time" }, Tp = {
|
|
12703
12722
|
key: 2,
|
|
12704
12723
|
class: "info-body"
|
|
12705
|
-
},
|
|
12724
|
+
}, Ep = {
|
|
12706
12725
|
key: 0,
|
|
12707
12726
|
class: "empty"
|
|
12708
|
-
},
|
|
12727
|
+
}, Dp = { class: "info-section" }, Op = { class: "kv-grid" }, kp = { class: "kv" }, Ap = { class: "v" }, jp = { class: "kv" }, Mp = { class: "v" }, Np = { class: "kv" }, Pp = { class: "v" }, Fp = { class: "kv" }, Ip = { class: "v" }, Lp = {
|
|
12709
12728
|
class: "kv",
|
|
12710
12729
|
style: { "margin-top": "6px" }
|
|
12711
|
-
},
|
|
12730
|
+
}, Rp = {
|
|
12712
12731
|
class: "v",
|
|
12713
12732
|
style: { "font-size": "11px" }
|
|
12714
|
-
},
|
|
12733
|
+
}, zp = { class: "info-section" }, Bp = { class: "info-title" }, Vp = { class: "info-name" }, Hp = { class: "info-desc" }, Up = {
|
|
12715
12734
|
key: 0,
|
|
12716
12735
|
class: "info-section"
|
|
12717
|
-
},
|
|
12736
|
+
}, Wp = { class: "info-title" }, Gp = { class: "info-name" }, Kp = { class: "info-desc" }, qp = {
|
|
12718
12737
|
key: 1,
|
|
12719
12738
|
class: "info-section"
|
|
12720
|
-
},
|
|
12739
|
+
}, Jp = { class: "info-title" }, Yp = { class: "info-name" }, Xp = { class: "info-desc" }, Zp = { class: "info-section" }, Qp = { class: "kv-grid" }, $p = { class: "kv" }, em = { class: "v" }, tm = { class: "kv" }, nm = { class: "v" }, rm = { class: "kv" }, im = { class: "v" }, am = { class: "kv" }, om = {
|
|
12721
12740
|
class: "v",
|
|
12722
12741
|
style: { "font-size": "11px" }
|
|
12723
|
-
},
|
|
12742
|
+
}, sm = {
|
|
12724
12743
|
key: 2,
|
|
12725
12744
|
class: "info-section"
|
|
12726
|
-
},
|
|
12745
|
+
}, cm = { class: "info-title" }, lm = { class: "info-name" }, um = { class: "src-tag mcp" }, dm = { class: "info-desc" }, fm = {
|
|
12727
12746
|
key: 3,
|
|
12728
12747
|
class: "info-section"
|
|
12729
|
-
},
|
|
12748
|
+
}, pm = { class: "kv-grid" }, mm = { class: "kv" }, hm = { class: "v" }, gm = { class: "kv" }, _m = { class: "v" }, vm = { class: "kv" }, ym = { class: "v" }, bm = {
|
|
12730
12749
|
key: 0,
|
|
12731
12750
|
class: "kv"
|
|
12732
|
-
},
|
|
12751
|
+
}, xm = {
|
|
12733
12752
|
class: "v",
|
|
12734
12753
|
style: { "font-size": "11px" }
|
|
12735
|
-
},
|
|
12754
|
+
}, Sm = {
|
|
12736
12755
|
key: 4,
|
|
12737
12756
|
class: "info-section"
|
|
12738
|
-
},
|
|
12757
|
+
}, Cm = { class: "info-title" }, wm = {
|
|
12739
12758
|
key: 5,
|
|
12740
12759
|
class: "info-section"
|
|
12741
|
-
},
|
|
12760
|
+
}, Tm = { class: "info-pre" }, Em = {
|
|
12742
12761
|
key: 6,
|
|
12743
12762
|
class: "info-section"
|
|
12744
|
-
},
|
|
12763
|
+
}, Dm = { class: "info-kv" }, Om = { class: "kv" }, km = { class: "v" }, Am = { class: "kv" }, jm = { class: "v" }, Mm = { class: "kv" }, Nm = { class: "v" }, Pm = { class: "kv" }, Fm = { class: "v" }, Im = { class: "kv" }, Lm = {
|
|
12745
12764
|
class: "v",
|
|
12746
12765
|
style: { "font-size": "11px" }
|
|
12747
|
-
},
|
|
12766
|
+
}, Rm = /*#__PURE__*/ $d(/* @__PURE__ */ wi({
|
|
12748
12767
|
__name: "DebugDrawer",
|
|
12749
12768
|
props: {
|
|
12750
12769
|
logs: { default: () => [] },
|
|
@@ -12812,10 +12831,7 @@ app.mount('#app');
|
|
|
12812
12831
|
return String(e);
|
|
12813
12832
|
}
|
|
12814
12833
|
}
|
|
12815
|
-
|
|
12816
|
-
navigator.clipboard.writeText(e);
|
|
12817
|
-
}
|
|
12818
|
-
let g = {
|
|
12834
|
+
let h = {
|
|
12819
12835
|
system: {
|
|
12820
12836
|
label: "SYSTEM",
|
|
12821
12837
|
color: "#6b7280"
|
|
@@ -12841,27 +12857,27 @@ app.mount('#app');
|
|
|
12841
12857
|
color: "#2563eb"
|
|
12842
12858
|
}
|
|
12843
12859
|
};
|
|
12844
|
-
function
|
|
12845
|
-
return
|
|
12860
|
+
function g(e) {
|
|
12861
|
+
return h[e] || {
|
|
12846
12862
|
label: (e || "?").toUpperCase(),
|
|
12847
12863
|
color: "#9ca3af"
|
|
12848
12864
|
};
|
|
12849
12865
|
}
|
|
12850
|
-
function
|
|
12866
|
+
function _() {
|
|
12851
12867
|
r("update:visible", !1);
|
|
12852
12868
|
}
|
|
12853
|
-
function
|
|
12869
|
+
function v() {
|
|
12854
12870
|
a.value = /* @__PURE__ */ new Set(), r("clear");
|
|
12855
12871
|
}
|
|
12856
|
-
let
|
|
12857
|
-
function
|
|
12858
|
-
if (
|
|
12859
|
-
|
|
12872
|
+
let y = /* @__PURE__ */ fn("logs"), b = /* @__PURE__ */ fn(null);
|
|
12873
|
+
function x(e) {
|
|
12874
|
+
if (y.value = e, e === "info" && n.getInfo) try {
|
|
12875
|
+
b.value = n.getInfo();
|
|
12860
12876
|
} catch {
|
|
12861
|
-
|
|
12877
|
+
b.value = null;
|
|
12862
12878
|
}
|
|
12863
12879
|
}
|
|
12864
|
-
let
|
|
12880
|
+
let S = {
|
|
12865
12881
|
pending: {
|
|
12866
12882
|
label: "待办",
|
|
12867
12883
|
color: "#9ca3af"
|
|
@@ -12875,13 +12891,13 @@ app.mount('#app');
|
|
|
12875
12891
|
color: "#059669"
|
|
12876
12892
|
}
|
|
12877
12893
|
};
|
|
12878
|
-
function
|
|
12879
|
-
return
|
|
12894
|
+
function C(e) {
|
|
12895
|
+
return S[e]?.label ?? e;
|
|
12880
12896
|
}
|
|
12881
|
-
function
|
|
12897
|
+
function w(e) {
|
|
12882
12898
|
return e ? e === "builtin" ? "builtin" : e.startsWith("mcp:") ? "mcp" : "user" : "";
|
|
12883
12899
|
}
|
|
12884
|
-
let
|
|
12900
|
+
let T = zs(() => {
|
|
12885
12901
|
let e = /* @__PURE__ */ new Map(), t = [];
|
|
12886
12902
|
for (let n of c.value) {
|
|
12887
12903
|
let r = n.data?.round;
|
|
@@ -12895,316 +12911,316 @@ app.mount('#app');
|
|
|
12895
12911
|
}))
|
|
12896
12912
|
};
|
|
12897
12913
|
});
|
|
12898
|
-
function
|
|
12914
|
+
function E(e, t) {
|
|
12899
12915
|
return e.length > t ? e.slice(0, t) + "…" : e;
|
|
12900
12916
|
}
|
|
12901
|
-
function
|
|
12917
|
+
function D(e) {
|
|
12902
12918
|
let t = e.data || {};
|
|
12903
12919
|
switch (e.type) {
|
|
12904
12920
|
case "context": return `${t.tools?.length ?? 0} 工具 · ${t.totalMessages ?? 0} 消息`;
|
|
12905
12921
|
case "llm_request": return `${(t.messages || []).length} 消息${t.tools?.length ? " · " + t.tools.length + " 工具" : ""}`;
|
|
12906
|
-
case "llm_response": return t.toolCalls?.length ? `${t.toolCalls.length} 个工具调用` : t.content ?
|
|
12922
|
+
case "llm_response": return t.toolCalls?.length ? `${t.toolCalls.length} 个工具调用` : t.content ? E(String(t.content), 50) : "";
|
|
12907
12923
|
case "tool_call": return String(t.name ?? "");
|
|
12908
12924
|
case "tool_result": return `${t.name ?? ""} · ${t.status === "error" ? "❌" : "✅"}`;
|
|
12909
|
-
case "error": return
|
|
12925
|
+
case "error": return E(String(t.error ?? t.tool ?? ""), 60);
|
|
12910
12926
|
case "middleware": return String(t.stage ?? "");
|
|
12911
12927
|
default: return "";
|
|
12912
12928
|
}
|
|
12913
12929
|
}
|
|
12914
12930
|
return (t, n) => (q(), Ko(oi, { to: "body" }, [$o(rc, { name: "drawer" }, {
|
|
12915
|
-
default: Lr(() => [e.visible ? (q(), J("div",
|
|
12916
|
-
Y("div",
|
|
12931
|
+
default: Lr(() => [e.visible ? (q(), J("div", rf, [Y("div", af, [
|
|
12932
|
+
Y("div", of, [Y("div", sf, [
|
|
12917
12933
|
Y("button", {
|
|
12918
|
-
class: Se(["tab-btn", { active:
|
|
12919
|
-
onClick: n[0] ||= (e) =>
|
|
12934
|
+
class: Se(["tab-btn", { active: y.value === "logs" }]),
|
|
12935
|
+
onClick: n[0] ||= (e) => x("logs")
|
|
12920
12936
|
}, "🐛 日志", 2),
|
|
12921
12937
|
Y("button", {
|
|
12922
|
-
class: Se(["tab-btn", { active:
|
|
12923
|
-
onClick: n[1] ||= (e) =>
|
|
12938
|
+
class: Se(["tab-btn", { active: y.value === "flow" }]),
|
|
12939
|
+
onClick: n[1] ||= (e) => x("flow")
|
|
12924
12940
|
}, "🔀 流程", 2),
|
|
12925
12941
|
e.getInfo ? (q(), J("button", {
|
|
12926
12942
|
key: 0,
|
|
12927
|
-
class: Se(["tab-btn", { active:
|
|
12928
|
-
onClick: n[2] ||= (e) =>
|
|
12943
|
+
class: Se(["tab-btn", { active: y.value === "info" }]),
|
|
12944
|
+
onClick: n[2] ||= (e) => x("info")
|
|
12929
12945
|
}, "🧬 Agent 信息", 2)) : X("", !0)
|
|
12930
|
-
]), Y("div",
|
|
12946
|
+
]), Y("div", cf, [y.value === "logs" ? (q(), J("button", {
|
|
12931
12947
|
key: 0,
|
|
12932
12948
|
class: "hd-btn",
|
|
12933
12949
|
title: "清空日志",
|
|
12934
|
-
onClick:
|
|
12950
|
+
onClick: v
|
|
12935
12951
|
}, "🗑️")) : X("", !0), Y("button", {
|
|
12936
12952
|
class: "hd-btn",
|
|
12937
12953
|
title: "关闭",
|
|
12938
|
-
onClick:
|
|
12954
|
+
onClick: _
|
|
12939
12955
|
}, "✕")])]),
|
|
12940
|
-
|
|
12956
|
+
y.value === "logs" ? (q(), J("div", lf, [(q(), J(K, null, Xi(s, (e, t) => Y("button", {
|
|
12941
12957
|
key: t,
|
|
12942
12958
|
class: Se(["filter-chip", { active: i.value === t }]),
|
|
12943
12959
|
style: _e({ "--chip-color": e.color }),
|
|
12944
12960
|
onClick: (e) => i.value = t
|
|
12945
|
-
}, [is(V(e.icon) + " " + V(e.label) + " ", 1), Y("span",
|
|
12961
|
+
}, [is(V(e.icon) + " " + V(e.label) + " ", 1), Y("span", df, V(u.value[t] || 0), 1)], 14, uf)), 64)), Y("button", {
|
|
12946
12962
|
class: Se(["filter-chip all", { active: i.value === "all" }]),
|
|
12947
12963
|
onClick: n[3] ||= (e) => i.value = "all"
|
|
12948
|
-
}, [n[4] ||= is(" 全部 ", -1), Y("span",
|
|
12949
|
-
Y("div",
|
|
12964
|
+
}, [n[4] ||= is(" 全部 ", -1), Y("span", ff, V(u.value.all || 0), 1)], 2)])) : X("", !0),
|
|
12965
|
+
Y("div", pf, [y.value === "logs" ? (q(), J(K, { key: 0 }, [l.value.length === 0 ? (q(), J("div", mf, " 暂无日志,发送消息后这里会显示 Agent 的完整上下文、工具调用等信息 ")) : X("", !0), (q(!0), J(K, null, Xi(l.value, (e, t) => (q(), J("div", {
|
|
12950
12966
|
key: t,
|
|
12951
12967
|
class: "log-item"
|
|
12952
12968
|
}, [
|
|
12953
|
-
Y("div",
|
|
12969
|
+
Y("div", hf, [
|
|
12954
12970
|
Y("span", {
|
|
12955
12971
|
class: "log-type",
|
|
12956
12972
|
style: _e({ background: s[e.type].color })
|
|
12957
12973
|
}, V(s[e.type].icon) + " " + V(s[e.type].label), 5),
|
|
12958
|
-
e.source ? (q(), J("span",
|
|
12959
|
-
Y("span",
|
|
12974
|
+
e.source ? (q(), J("span", gf, "↳ " + V(e.source), 1)) : X("", !0),
|
|
12975
|
+
Y("span", _f, V(d(e.timestamp)), 1)
|
|
12960
12976
|
]),
|
|
12961
|
-
Y("div",
|
|
12962
|
-
Y("div",
|
|
12963
|
-
Y("div",
|
|
12964
|
-
Y("div",
|
|
12965
|
-
Y("div",
|
|
12966
|
-
Y("div",
|
|
12977
|
+
Y("div", vf, [e.type === "context" ? (q(), J(K, { key: 0 }, [
|
|
12978
|
+
Y("div", yf, [
|
|
12979
|
+
Y("div", bf, [n[5] ||= Y("span", { class: "k" }, "模型", -1), Y("span", xf, V(e.data.model), 1)]),
|
|
12980
|
+
Y("div", Sf, [n[6] ||= Y("span", { class: "k" }, "温度", -1), Y("span", Cf, V(e.data.temperature), 1)]),
|
|
12981
|
+
Y("div", wf, [n[7] ||= Y("span", { class: "k" }, "MaxTokens", -1), Y("span", Tf, V(e.data.maxTokens), 1)]),
|
|
12982
|
+
Y("div", Ef, [n[8] ||= Y("span", { class: "k" }, "消息数", -1), Y("span", Df, V(e.data.totalMessages), 1)])
|
|
12967
12983
|
]),
|
|
12968
|
-
Y("div",
|
|
12969
|
-
Y("div",
|
|
12984
|
+
Y("div", Of, "工具 (" + V(e.data.tools?.length || 0) + ")", 1),
|
|
12985
|
+
Y("div", kf, [(q(!0), J(K, null, Xi(e.data.tools, (e) => (q(), J("span", {
|
|
12970
12986
|
key: e,
|
|
12971
12987
|
class: "tool-chip"
|
|
12972
12988
|
}, V(e), 1))), 128))]),
|
|
12973
12989
|
n[9] ||= Y("div", { class: "section-label" }, "上下文消息", -1),
|
|
12974
|
-
Y("div",
|
|
12990
|
+
Y("div", Af, [(q(!0), J(K, null, Xi(e.data.messages, (e, t) => (q(), J("div", {
|
|
12975
12991
|
key: t,
|
|
12976
12992
|
class: "msg-row"
|
|
12977
12993
|
}, [Y("span", {
|
|
12978
12994
|
class: "msg-role",
|
|
12979
|
-
style: _e({ background:
|
|
12980
|
-
}, V(
|
|
12981
|
-
], 64)) : e.type === "llm_request" ? (q(), J(K, { key: 1 }, [Y("div",
|
|
12982
|
-
Y("span",
|
|
12983
|
-
e.data.model ? (q(), J("span",
|
|
12984
|
-
Y("span",
|
|
12985
|
-
e.data.tools?.length ? (q(), J("span",
|
|
12995
|
+
style: _e({ background: g(e.type).color })
|
|
12996
|
+
}, V(g(e.type).label), 5), Y("span", jf, V(e.content), 1)]))), 128))])
|
|
12997
|
+
], 64)) : e.type === "llm_request" ? (q(), J(K, { key: 1 }, [Y("div", Mf, [
|
|
12998
|
+
Y("span", Nf, "第 " + V(e.data.round) + " 轮", 1),
|
|
12999
|
+
e.data.model ? (q(), J("span", Pf, V(e.data.model), 1)) : X("", !0),
|
|
13000
|
+
Y("span", Ff, V((e.data.messages || []).length) + " 条消息", 1),
|
|
13001
|
+
e.data.tools?.length ? (q(), J("span", If, V(e.data.tools.length) + " 工具", 1)) : X("", !0),
|
|
12986
13002
|
Y("button", {
|
|
12987
13003
|
class: "view-toggle",
|
|
12988
13004
|
onClick: (e) => p(t)
|
|
12989
|
-
}, V(o.value.has(t) ? "🗂 卡片视图" : "📋 请求体"), 9,
|
|
12990
|
-
]), o.value.has(t) ? (q(), J("pre",
|
|
13005
|
+
}, V(o.value.has(t) ? "🗂 卡片视图" : "📋 请求体"), 9, Lf)
|
|
13006
|
+
]), o.value.has(t) ? (q(), J("pre", Wf, [Y("code", null, V(m(e.data.messages)), 1)])) : (q(), J("div", Rf, [(q(!0), J(K, null, Xi(e.data.messages, (e, t) => (q(), J("div", {
|
|
12991
13007
|
key: t,
|
|
12992
13008
|
class: "msg-row"
|
|
12993
13009
|
}, [Y("span", {
|
|
12994
13010
|
class: "msg-role",
|
|
12995
|
-
style: _e({ background:
|
|
12996
|
-
}, V(
|
|
12997
|
-
e.content ? (q(), J("span",
|
|
13011
|
+
style: _e({ background: g(e.role).color })
|
|
13012
|
+
}, V(g(e.role).label), 5), Y("div", zf, [
|
|
13013
|
+
e.content ? (q(), J("span", Bf, V(e.content), 1)) : X("", !0),
|
|
12998
13014
|
(q(!0), J(K, null, Xi(e.tool_calls || [], (e, t) => (q(), J("div", {
|
|
12999
13015
|
key: t,
|
|
13000
13016
|
class: "tc-inline"
|
|
13001
|
-
}, [Y("span",
|
|
13002
|
-
e.tool_call_id ? (q(), J("span",
|
|
13017
|
+
}, [Y("span", Vf, "🔧 " + V(e.function?.name || e.name), 1), Y("code", Hf, V(e.function?.arguments ?? e.args), 1)]))), 128)),
|
|
13018
|
+
e.tool_call_id ? (q(), J("span", Uf, "↳ tool_call_id: " + V(e.tool_call_id), 1)) : X("", !0)
|
|
13003
13019
|
])]))), 128))]))], 64)) : e.type === "llm_response" ? (q(), J(K, { key: 2 }, [
|
|
13004
|
-
Y("div",
|
|
13005
|
-
e.data.content ? (q(), J("div",
|
|
13006
|
-
e.data.toolCalls?.length ? (q(), J("div",
|
|
13020
|
+
Y("div", Gf, [Y("span", Kf, "第 " + V(e.data.round) + " 轮", 1), e.data.toolCalls?.length ? (q(), J("span", qf, "🔧 " + V(e.data.toolCalls.length) + " 个工具调用", 1)) : X("", !0)]),
|
|
13021
|
+
e.data.content ? (q(), J("div", Jf, V(e.data.content), 1)) : X("", !0),
|
|
13022
|
+
e.data.toolCalls?.length ? (q(), J("div", Yf, [(q(!0), J(K, null, Xi(e.data.toolCalls, (e, t) => (q(), J("div", {
|
|
13007
13023
|
key: t,
|
|
13008
13024
|
class: "tc-card"
|
|
13009
|
-
}, [Y("div",
|
|
13010
|
-
e.data.usage ? (q(), J("div",
|
|
13011
|
-
Y("span",
|
|
13012
|
-
Y("span",
|
|
13013
|
-
Y("span",
|
|
13025
|
+
}, [Y("div", Xf, "🔧 " + V(e.name), 1), Y("pre", Zf, V(m(e.args)), 1)]))), 128))])) : X("", !0),
|
|
13026
|
+
e.data.usage ? (q(), J("div", Qf, [
|
|
13027
|
+
Y("span", $f, "prompt: " + V(e.data.usage.prompt_tokens ?? "-"), 1),
|
|
13028
|
+
Y("span", ep, "completion: " + V(e.data.usage.completion_tokens ?? "-"), 1),
|
|
13029
|
+
Y("span", tp, "total: " + V(e.data.usage.total_tokens ?? "-"), 1)
|
|
13014
13030
|
])) : X("", !0)
|
|
13015
|
-
], 64)) : e.type === "tool_call" ? (q(), J("div",
|
|
13016
|
-
Y("div",
|
|
13031
|
+
], 64)) : e.type === "tool_call" ? (q(), J("div", np, [Y("div", rp, "🔧 " + V(e.data.name), 1), Y("pre", ip, V(m(e.data.args)), 1)])) : e.type === "tool_result" ? (q(), J("div", ap, [Y("div", op, "✅ " + V(e.data.name) + " 结果", 1), Y("pre", sp, V(e.data.result), 1)])) : e.type === "error" ? (q(), J("div", cp, V(e.data.tool ? `[${e.data.tool}] ` : "") + V(e.data.error), 1)) : X("", !0)]),
|
|
13032
|
+
Y("div", lp, [Y("button", {
|
|
13017
13033
|
class: "raw-toggle",
|
|
13018
13034
|
onClick: (e) => f(t)
|
|
13019
|
-
}, V(a.value.has(t) ? "收起原始 JSON" : "查看原始 JSON"), 9,
|
|
13035
|
+
}, V(a.value.has(t) ? "收起原始 JSON" : "查看原始 JSON"), 9, up), Y("button", {
|
|
13020
13036
|
class: "raw-toggle",
|
|
13021
|
-
onClick: (t) =>
|
|
13022
|
-
}, "复制", 8,
|
|
13023
|
-
a.value.has(t) ? (q(), J("pre",
|
|
13024
|
-
]))), 128))], 64)) :
|
|
13025
|
-
c.value.length ? X("", !0) : (q(), J("div",
|
|
13026
|
-
|
|
13037
|
+
onClick: (t) => W(Sl)(m(e.data))
|
|
13038
|
+
}, "复制", 8, dp)]),
|
|
13039
|
+
a.value.has(t) ? (q(), J("pre", fp, [Y("code", null, V(m(e.data)), 1)])) : X("", !0)
|
|
13040
|
+
]))), 128))], 64)) : y.value === "flow" ? (q(), J(K, { key: 1 }, [
|
|
13041
|
+
c.value.length ? X("", !0) : (q(), J("div", pp, "暂无日志,发送消息后这里按轮次展示执行流程")),
|
|
13042
|
+
T.value.pre.length ? (q(), J("div", mp, [n[10] ||= Y("div", { class: "flow-section-title" }, "⚙️ 准备 / 其他", -1), (q(!0), J(K, null, Xi(T.value.pre, (e, t) => (q(), J("div", {
|
|
13027
13043
|
key: "p" + t,
|
|
13028
13044
|
class: Se(["flow-node", e.type])
|
|
13029
13045
|
}, [
|
|
13030
|
-
Y("span",
|
|
13031
|
-
Y("span",
|
|
13032
|
-
Y("span",
|
|
13033
|
-
Y("span",
|
|
13046
|
+
Y("span", hp, V(s[e.type]?.icon), 1),
|
|
13047
|
+
Y("span", gp, V(s[e.type]?.label), 1),
|
|
13048
|
+
Y("span", _p, V(D(e)), 1),
|
|
13049
|
+
Y("span", vp, V(d(e.timestamp)), 1)
|
|
13034
13050
|
], 2))), 128))])) : X("", !0),
|
|
13035
|
-
(q(!0), J(K, null, Xi(
|
|
13051
|
+
(q(!0), J(K, null, Xi(T.value.rounds, (e) => (q(), J("div", {
|
|
13036
13052
|
key: e.round,
|
|
13037
13053
|
class: "flow-round"
|
|
13038
|
-
}, [Y("div",
|
|
13054
|
+
}, [Y("div", yp, "🔁 第 " + V(e.round) + " 轮", 1), Y("div", bp, [(q(!0), J(K, null, Xi(e.items, (e, t) => (q(), J("div", {
|
|
13039
13055
|
key: t,
|
|
13040
13056
|
class: Se(["flow-node", e.type])
|
|
13041
13057
|
}, [
|
|
13042
|
-
Y("span",
|
|
13043
|
-
Y("span",
|
|
13044
|
-
Y("span",
|
|
13045
|
-
Y("span",
|
|
13058
|
+
Y("span", xp, V(s[e.type]?.icon), 1),
|
|
13059
|
+
Y("span", Sp, V(s[e.type]?.label), 1),
|
|
13060
|
+
Y("span", Cp, V(D(e)), 1),
|
|
13061
|
+
Y("span", wp, V(d(e.timestamp)), 1)
|
|
13046
13062
|
], 2))), 128))])]))), 128))
|
|
13047
|
-
], 64)) : (q(), J("div",
|
|
13048
|
-
Y("div",
|
|
13063
|
+
], 64)) : (q(), J("div", Tp, [b.value ? (q(), J(K, { key: 1 }, [
|
|
13064
|
+
Y("div", Dp, [
|
|
13049
13065
|
n[16] ||= Y("div", { class: "info-title" }, "基本信息", -1),
|
|
13050
|
-
Y("div",
|
|
13051
|
-
Y("div",
|
|
13052
|
-
Y("div",
|
|
13053
|
-
Y("div",
|
|
13054
|
-
Y("div",
|
|
13066
|
+
Y("div", Op, [
|
|
13067
|
+
Y("div", kp, [n[11] ||= Y("span", { class: "k" }, "ID", -1), Y("span", Ap, V(b.value.id), 1)]),
|
|
13068
|
+
Y("div", jp, [n[12] ||= Y("span", { class: "k" }, "模型", -1), Y("span", Mp, V(b.value.model || "-"), 1)]),
|
|
13069
|
+
Y("div", Np, [n[13] ||= Y("span", { class: "k" }, "工具数", -1), Y("span", Pp, V(b.value.tools.length), 1)]),
|
|
13070
|
+
Y("div", Fp, [n[14] ||= Y("span", { class: "k" }, "中间件", -1), Y("span", Ip, V(b.value.middleware.length), 1)])
|
|
13055
13071
|
]),
|
|
13056
|
-
Y("div",
|
|
13072
|
+
Y("div", Lp, [n[15] ||= Y("span", { class: "k" }, "中间件栈", -1), Y("span", Rp, V(b.value.middleware.join(" → ") || "-"), 1)])
|
|
13057
13073
|
]),
|
|
13058
|
-
Y("div",
|
|
13074
|
+
Y("div", zp, [Y("div", Bp, "🔧 工具 (" + V(b.value.tools.length) + ")", 1), (q(!0), J(K, null, Xi(b.value.tools, (e) => (q(), J("div", {
|
|
13059
13075
|
key: e.name,
|
|
13060
13076
|
class: "info-item"
|
|
13061
|
-
}, [Y("div",
|
|
13077
|
+
}, [Y("div", Vp, [is(V(e.name), 1), e.source ? (q(), J("span", {
|
|
13062
13078
|
key: 0,
|
|
13063
|
-
class: Se(["src-tag",
|
|
13064
|
-
}, V(e.source), 3)) : X("", !0)]), Y("div",
|
|
13065
|
-
|
|
13079
|
+
class: Se(["src-tag", w(e.source)])
|
|
13080
|
+
}, V(e.source), 3)) : X("", !0)]), Y("div", Hp, V(e.description), 1)]))), 128))]),
|
|
13081
|
+
b.value.skills.length ? (q(), J("div", Up, [Y("div", Wp, "📘 技能 (" + V(b.value.skills.length) + ")", 1), (q(!0), J(K, null, Xi(b.value.skills, (e) => (q(), J("div", {
|
|
13066
13082
|
key: e.name,
|
|
13067
13083
|
class: "info-item"
|
|
13068
|
-
}, [Y("div",
|
|
13069
|
-
|
|
13084
|
+
}, [Y("div", Gp, V(e.name), 1), Y("div", Kp, V(e.description), 1)]))), 128))])) : X("", !0),
|
|
13085
|
+
b.value.windowProps.length ? (q(), J("div", qp, [Y("div", Jp, "🪟 可操作属性 (" + V(b.value.windowProps.length) + ")", 1), (q(!0), J(K, null, Xi(b.value.windowProps, (e) => (q(), J("div", {
|
|
13070
13086
|
key: e.path,
|
|
13071
13087
|
class: "info-item"
|
|
13072
|
-
}, [Y("div",
|
|
13073
|
-
Y("div",
|
|
13074
|
-
Y("div",
|
|
13075
|
-
Y("div",
|
|
13076
|
-
Y("div",
|
|
13077
|
-
Y("div",
|
|
13088
|
+
}, [Y("div", Yp, V(e.path), 1), Y("div", Xp, V(e.description), 1)]))), 128))])) : X("", !0),
|
|
13089
|
+
Y("div", Zp, [n[21] ||= Y("div", { class: "info-title" }, "🧬 子 Agent", -1), Y("div", Qp, [
|
|
13090
|
+
Y("div", $p, [n[17] ||= Y("span", { class: "k" }, "启用", -1), Y("span", em, V(b.value.subagent.enabled ? "是" : "否"), 1)]),
|
|
13091
|
+
Y("div", tm, [n[18] ||= Y("span", { class: "k" }, "最大递归", -1), Y("span", nm, V(b.value.subagent.maxDepth), 1)]),
|
|
13092
|
+
Y("div", rm, [n[19] ||= Y("span", { class: "k" }, "并行上限", -1), Y("span", im, V(b.value.subagent.maxParallel), 1)]),
|
|
13093
|
+
Y("div", am, [n[20] ||= Y("span", { class: "k" }, "额外工具", -1), Y("span", om, V(b.value.subagent.allowedTools.length ? b.value.subagent.allowedTools.join(", ") : "默认只读"), 1)])
|
|
13078
13094
|
])]),
|
|
13079
|
-
|
|
13095
|
+
b.value.mcp?.servers?.length ? (q(), J("div", sm, [Y("div", cm, "🔌 MCP (" + V(b.value.mcp.servers.length) + ")", 1), (q(!0), J(K, null, Xi(b.value.mcp.servers, (e) => (q(), J("div", {
|
|
13080
13096
|
key: e.name,
|
|
13081
13097
|
class: "info-item"
|
|
13082
|
-
}, [Y("div",
|
|
13083
|
-
|
|
13084
|
-
Y("div",
|
|
13085
|
-
Y("div",
|
|
13086
|
-
Y("div",
|
|
13087
|
-
|
|
13098
|
+
}, [Y("div", lm, [is(V(e.name) + " ", 1), Y("span", um, V(e.toolCount) + " 工具", 1)]), Y("div", dm, V(e.url), 1)]))), 128))])) : X("", !0),
|
|
13099
|
+
b.value.verify ? (q(), J("div", fm, [n[26] ||= Y("div", { class: "info-title" }, "✅ Verify 自检", -1), Y("div", pm, [
|
|
13100
|
+
Y("div", mm, [n[22] ||= Y("span", { class: "k" }, "启用", -1), Y("span", hm, V(b.value.verify.enabled ? "是" : "否"), 1)]),
|
|
13101
|
+
Y("div", gm, [n[23] ||= Y("span", { class: "k" }, "自纠上限", -1), Y("span", _m, V(b.value.verify.maxAttempts), 1)]),
|
|
13102
|
+
Y("div", vm, [n[24] ||= Y("span", { class: "k" }, "对抗验证", -1), Y("span", ym, V(b.value.verify.adversarial ? "开启" : "关闭"), 1)]),
|
|
13103
|
+
b.value.verify.adversarial ? (q(), J("div", bm, [n[25] ||= Y("span", { class: "k" }, "对抗模型", -1), Y("span", xm, V(b.value.model || "-") + "(同主)", 1)])) : X("", !0)
|
|
13088
13104
|
])])) : X("", !0),
|
|
13089
|
-
|
|
13105
|
+
b.value.todos.length ? (q(), J("div", Sm, [Y("div", Cm, "📋 任务清单 (" + V(b.value.todos.length) + ")", 1), (q(!0), J(K, null, Xi(b.value.todos, (e, t) => (q(), J("div", {
|
|
13090
13106
|
key: t,
|
|
13091
13107
|
class: "info-todo"
|
|
13092
13108
|
}, [Y("span", {
|
|
13093
13109
|
class: "todo-tag",
|
|
13094
|
-
style: _e({ background:
|
|
13095
|
-
}, V(
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
Y("div",
|
|
13099
|
-
Y("div",
|
|
13100
|
-
Y("div",
|
|
13101
|
-
Y("div",
|
|
13102
|
-
Y("div",
|
|
13110
|
+
style: _e({ background: S[e.status] && S[e.status].color || "#9ca3af" })
|
|
13111
|
+
}, V(C(e.status)), 5), Y("span", null, V(e.content), 1)]))), 128))])) : X("", !0),
|
|
13112
|
+
b.value.memory ? (q(), J("div", wm, [n[27] ||= Y("div", { class: "info-title" }, "📝 持久指令 (memory)", -1), Y("pre", Tm, V(b.value.memory), 1)])) : X("", !0),
|
|
13113
|
+
b.value.lastCompression ? (q(), J("div", Em, [n[33] ||= Y("div", { class: "info-title" }, "🗜️ 上轮压缩", -1), Y("div", Dm, [
|
|
13114
|
+
Y("div", Om, [n[28] ||= Y("span", { class: "k" }, "触发", -1), Y("span", km, V(b.value.lastCompression.triggered ? "✓" : "✗(未达阈值)"), 1)]),
|
|
13115
|
+
Y("div", Am, [n[29] ||= Y("span", { class: "k" }, "摘要轮次", -1), Y("span", jm, V(b.value.lastCompression.roundsSummarized) + " / " + V(b.value.lastCompression.roundsTotal), 1)]),
|
|
13116
|
+
Y("div", Mm, [n[30] ||= Y("span", { class: "k" }, "召回", -1), Y("span", Nm, V(b.value.lastCompression.roundsRecalled) + " 条", 1)]),
|
|
13117
|
+
Y("div", Pm, [n[31] ||= Y("span", { class: "k" }, "消息数", -1), Y("span", Fm, V(b.value.lastCompression.originalMessages) + " → " + V(b.value.lastCompression.compressedMessages), 1)]),
|
|
13118
|
+
Y("div", Im, [n[32] ||= Y("span", { class: "k" }, "策略", -1), Y("span", Lm, V(b.value.lastCompression.strategy), 1)])
|
|
13103
13119
|
])])) : X("", !0)
|
|
13104
|
-
], 64)) : (q(), J("div",
|
|
13120
|
+
], 64)) : (q(), J("div", Ep, "暂无信息"))]))])
|
|
13105
13121
|
]), Y("div", {
|
|
13106
13122
|
class: "drawer-mask",
|
|
13107
|
-
onClick:
|
|
13123
|
+
onClick: _
|
|
13108
13124
|
})])) : X("", !0)]),
|
|
13109
13125
|
_: 1
|
|
13110
13126
|
})]));
|
|
13111
13127
|
}
|
|
13112
|
-
}), [["__scopeId", "data-v-
|
|
13128
|
+
}), [["__scopeId", "data-v-ac94546c"]]), zm = { class: "chat-header" }, Bm = { class: "header-left" }, Vm = { class: "header-title" }, Hm = {
|
|
13113
13129
|
key: 0,
|
|
13114
13130
|
class: "status-dot pulse"
|
|
13115
|
-
},
|
|
13131
|
+
}, Um = { class: "header-actions" }, Wm = {
|
|
13116
13132
|
key: 0,
|
|
13117
13133
|
class: "debug-badge"
|
|
13118
|
-
},
|
|
13134
|
+
}, Gm = ["disabled"], Km = {
|
|
13119
13135
|
width: "16",
|
|
13120
13136
|
height: "16",
|
|
13121
13137
|
viewBox: "0 0 24 24",
|
|
13122
13138
|
fill: "none",
|
|
13123
13139
|
stroke: "currentColor",
|
|
13124
13140
|
"stroke-width": "2"
|
|
13125
|
-
},
|
|
13141
|
+
}, qm = {
|
|
13126
13142
|
key: 0,
|
|
13127
13143
|
d: "M18 15l-6-6-6 6"
|
|
13128
|
-
},
|
|
13144
|
+
}, Jm = {
|
|
13129
13145
|
key: 1,
|
|
13130
13146
|
d: "M6 9l6 6 6-6"
|
|
13131
|
-
},
|
|
13147
|
+
}, Ym = {
|
|
13132
13148
|
key: 0,
|
|
13133
13149
|
class: "empty-state"
|
|
13134
|
-
},
|
|
13150
|
+
}, Xm = ["data-msg-idx"], Zm = {
|
|
13135
13151
|
key: 0,
|
|
13136
13152
|
class: "message-avatar"
|
|
13137
|
-
},
|
|
13153
|
+
}, Qm = { class: "message-content" }, $m = ["onClick"], eh = { class: "reasoning-toggle" }, th = {
|
|
13138
13154
|
key: 0,
|
|
13139
13155
|
class: "reasoning-body"
|
|
13140
|
-
},
|
|
13156
|
+
}, nh = {
|
|
13141
13157
|
key: 1,
|
|
13142
13158
|
class: "steps-block"
|
|
13143
|
-
},
|
|
13159
|
+
}, rh = { class: "step-head" }, ih = { class: "step-icon" }, ah = { class: "step-name" }, oh = {
|
|
13144
13160
|
key: 0,
|
|
13145
13161
|
class: "step-count"
|
|
13146
|
-
},
|
|
13162
|
+
}, sh = {
|
|
13147
13163
|
key: 1,
|
|
13148
13164
|
class: "step-status running"
|
|
13149
|
-
},
|
|
13165
|
+
}, ch = {
|
|
13150
13166
|
key: 0,
|
|
13151
13167
|
class: "step-children"
|
|
13152
|
-
},
|
|
13168
|
+
}, lh = { class: "step-icon" }, uh = { class: "step-name" }, dh = {
|
|
13153
13169
|
key: 0,
|
|
13154
13170
|
class: "step-status running"
|
|
13155
|
-
},
|
|
13171
|
+
}, fh = {
|
|
13156
13172
|
key: 1,
|
|
13157
13173
|
class: "typing-text"
|
|
13158
|
-
},
|
|
13174
|
+
}, ph = {
|
|
13159
13175
|
key: 2,
|
|
13160
13176
|
class: "stream-cursor"
|
|
13161
|
-
},
|
|
13177
|
+
}, mh = { class: "message-time" }, hh = {
|
|
13162
13178
|
key: 3,
|
|
13163
13179
|
class: "msg-actions"
|
|
13164
|
-
},
|
|
13180
|
+
}, gh = ["title", "onClick"], _h = {
|
|
13165
13181
|
key: 1,
|
|
13166
13182
|
class: "message-row assistant"
|
|
13167
|
-
},
|
|
13183
|
+
}, vh = {
|
|
13168
13184
|
key: 0,
|
|
13169
13185
|
class: "message-avatar"
|
|
13170
|
-
},
|
|
13186
|
+
}, yh = { class: "message-content" }, bh = { class: "message-bubble typing" }, xh = {
|
|
13171
13187
|
key: 1,
|
|
13172
13188
|
class: "typing-text"
|
|
13173
|
-
},
|
|
13189
|
+
}, Sh = {
|
|
13174
13190
|
key: 2,
|
|
13175
13191
|
class: "error-bar"
|
|
13176
|
-
},
|
|
13192
|
+
}, Ch = { class: "error-text" }, wh = {
|
|
13177
13193
|
key: 0,
|
|
13178
13194
|
class: "approval-bar"
|
|
13179
|
-
},
|
|
13195
|
+
}, Th = {
|
|
13180
13196
|
key: 0,
|
|
13181
13197
|
class: "approval-question"
|
|
13182
|
-
},
|
|
13198
|
+
}, Eh = {
|
|
13183
13199
|
key: 1,
|
|
13184
13200
|
class: "approval-context"
|
|
13185
|
-
},
|
|
13201
|
+
}, Dh = {
|
|
13186
13202
|
key: 2,
|
|
13187
13203
|
class: "approval-recommend"
|
|
13188
|
-
},
|
|
13204
|
+
}, Oh = { class: "approval-actions" }, kh = ["onClick"], Ah = { class: "approval-head" }, jh = { class: "approval-title" }, Mh = {
|
|
13189
13205
|
key: 0,
|
|
13190
13206
|
class: "approval-args"
|
|
13191
|
-
},
|
|
13207
|
+
}, Nh = { class: "approval-actions" }, Ph = {
|
|
13192
13208
|
key: 1,
|
|
13193
13209
|
class: "conflict-bar"
|
|
13194
|
-
},
|
|
13210
|
+
}, Fh = { class: "conflict-head" }, Ih = { class: "conflict-title" }, Lh = { class: "conflict-detail" }, Rh = {
|
|
13195
13211
|
key: 0,
|
|
13196
13212
|
class: "conflict-diff"
|
|
13197
|
-
},
|
|
13213
|
+
}, zh = { class: "conflict-diff-col" }, Bh = { class: "conflict-diff-pre" }, Vh = { class: "conflict-diff-col" }, Hh = { class: "conflict-diff-pre" }, Uh = { class: "conflict-actions" }, Wh = { class: "chat-footer" }, Gh = {
|
|
13198
13214
|
key: 0,
|
|
13199
13215
|
class: "cap-badge",
|
|
13200
13216
|
title: "能力概览(MCP / 工具数)"
|
|
13201
|
-
},
|
|
13217
|
+
}, Kh = ["placeholder"], qh = ["disabled", "title"], Jh = {
|
|
13202
13218
|
key: 0,
|
|
13203
13219
|
width: "16",
|
|
13204
13220
|
height: "16",
|
|
13205
13221
|
viewBox: "0 0 24 24",
|
|
13206
13222
|
fill: "currentColor"
|
|
13207
|
-
},
|
|
13223
|
+
}, Yh = {
|
|
13208
13224
|
key: 1,
|
|
13209
13225
|
width: "18",
|
|
13210
13226
|
height: "18",
|
|
@@ -13212,7 +13228,7 @@ app.mount('#app');
|
|
|
13212
13228
|
fill: "none",
|
|
13213
13229
|
stroke: "currentColor",
|
|
13214
13230
|
"stroke-width": "2"
|
|
13215
|
-
},
|
|
13231
|
+
}, Xh = /*#__PURE__*/ $d(/* @__PURE__ */ wi({
|
|
13216
13232
|
__name: "ChatDialog",
|
|
13217
13233
|
props: {
|
|
13218
13234
|
fetchResponse: {},
|
|
@@ -13339,17 +13355,17 @@ app.mount('#app');
|
|
|
13339
13355
|
};
|
|
13340
13356
|
});
|
|
13341
13357
|
function ee(e) {
|
|
13342
|
-
|
|
13343
|
-
R.value = !0, setTimeout(() => R.value = !1, 1500);
|
|
13358
|
+
Sl(e).then((e) => {
|
|
13359
|
+
e && (R.value = !0, setTimeout(() => R.value = !1, 1500));
|
|
13344
13360
|
});
|
|
13345
13361
|
}
|
|
13346
13362
|
let R = /* @__PURE__ */ fn(!1);
|
|
13347
13363
|
return (a, z) => (q(), J("div", { class: Se(["chat-dialog", { collapsed: !C.value }]) }, [
|
|
13348
|
-
Y("div",
|
|
13364
|
+
Y("div", zm, [Y("div", Bm, [
|
|
13349
13365
|
z[19] ||= Y("span", { class: "header-icon" }, "🤖", -1),
|
|
13350
|
-
Y("span",
|
|
13351
|
-
W(n).loading ? (q(), J("span",
|
|
13352
|
-
]), Y("div",
|
|
13366
|
+
Y("span", Vm, V(e.title), 1),
|
|
13367
|
+
W(n).loading ? (q(), J("span", Hm)) : X("", !0)
|
|
13368
|
+
]), Y("div", Um, [
|
|
13353
13369
|
Y("button", {
|
|
13354
13370
|
class: Se(["action-btn debug-btn", { active: w.value }]),
|
|
13355
13371
|
title: "日志 / 执行流程 / Agent 信息",
|
|
@@ -13365,7 +13381,7 @@ app.mount('#app');
|
|
|
13365
13381
|
Y("path", { d: "M9 2v8l-3 3v2h12v-2l-3-3V2" }),
|
|
13366
13382
|
Y("path", { d: "M9 2h6" }),
|
|
13367
13383
|
Y("path", { d: "M9 18h6" })
|
|
13368
|
-
], -1), O.value ? (q(), J("span",
|
|
13384
|
+
], -1), O.value ? (q(), J("span", Wm, V(e.debugLogs?.length), 1)) : X("", !0)], 2),
|
|
13369
13385
|
Y("button", {
|
|
13370
13386
|
class: "action-btn",
|
|
13371
13387
|
title: "清空对话",
|
|
@@ -13378,11 +13394,11 @@ app.mount('#app');
|
|
|
13378
13394
|
fill: "none",
|
|
13379
13395
|
stroke: "currentColor",
|
|
13380
13396
|
"stroke-width": "2"
|
|
13381
|
-
}, [Y("polyline", { points: "3 6 5 6 21 6" }), Y("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })], -1)]], 8,
|
|
13397
|
+
}, [Y("polyline", { points: "3 6 5 6 21 6" }), Y("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })], -1)]], 8, Gm),
|
|
13382
13398
|
Y("button", {
|
|
13383
13399
|
class: "action-btn",
|
|
13384
13400
|
onClick: z[2] ||= (e) => C.value = !C.value
|
|
13385
|
-
}, [(q(), J("svg",
|
|
13401
|
+
}, [(q(), J("svg", Km, [C.value ? (q(), J("path", qm)) : (q(), J("path", Jm))]))])
|
|
13386
13402
|
])]),
|
|
13387
13403
|
zr(Y("div", {
|
|
13388
13404
|
class: "chat-body",
|
|
@@ -13391,12 +13407,12 @@ app.mount('#app');
|
|
|
13391
13407
|
onScroll: z[5] ||= (...e) => W(d) && W(d)(...e),
|
|
13392
13408
|
onWheel: z[6] ||= (...e) => W(f) && W(f)(...e)
|
|
13393
13409
|
}, [
|
|
13394
|
-
E.value ? X("", !0) : (q(), J("div",
|
|
13410
|
+
E.value ? X("", !0) : (q(), J("div", Ym, [...z[22] ||= [Y("div", { class: "empty-icon" }, "💬", -1), Y("p", null, "有什么可以帮你的?", -1)]])),
|
|
13395
13411
|
(q(!0), J(K, null, Xi(W(n).messages, (t, r) => (q(), J("div", {
|
|
13396
13412
|
key: r,
|
|
13397
13413
|
class: Se(["message-row", t.role]),
|
|
13398
13414
|
"data-msg-idx": r
|
|
13399
|
-
}, [e.showAvatar ? (q(), J("div",
|
|
13415
|
+
}, [e.showAvatar ? (q(), J("div", Zm, V(t.role === "user" ? "👤" : "🤖"), 1)) : X("", !0), Y("div", Qm, [
|
|
13400
13416
|
t.role === "assistant" && t.reasoning ? (q(), J("div", {
|
|
13401
13417
|
key: 0,
|
|
13402
13418
|
class: Se(["reasoning-block", { expanded: T.value[r] }])
|
|
@@ -13406,51 +13422,51 @@ app.mount('#app');
|
|
|
13406
13422
|
}, [
|
|
13407
13423
|
z[23] ||= Y("span", { class: "reasoning-icon" }, "🧠", -1),
|
|
13408
13424
|
z[24] ||= Y("span", { class: "reasoning-title" }, "思考过程", -1),
|
|
13409
|
-
Y("span",
|
|
13410
|
-
], 8,
|
|
13411
|
-
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div",
|
|
13425
|
+
Y("span", eh, V(T.value[r] ? "▾" : "▸"), 1)
|
|
13426
|
+
], 8, $m), T.value[r] ? (q(), J("div", th, V(t.reasoning), 1)) : X("", !0)], 2)) : X("", !0),
|
|
13427
|
+
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", nh, [(q(!0), J(K, null, Xi(j(t.steps), (e, t) => (q(), J("div", {
|
|
13412
13428
|
key: t,
|
|
13413
13429
|
class: "step-item"
|
|
13414
|
-
}, [Y("div",
|
|
13415
|
-
Y("span",
|
|
13416
|
-
Y("span",
|
|
13417
|
-
e.count > 1 ? (q(), J("span",
|
|
13418
|
-
e.status === "running" ? (q(), J("span",
|
|
13419
|
-
]), e.children && e.children.length ? (q(), J("div",
|
|
13430
|
+
}, [Y("div", rh, [
|
|
13431
|
+
Y("span", ih, V(M(e.status)), 1),
|
|
13432
|
+
Y("span", ah, V(e.name), 1),
|
|
13433
|
+
e.count > 1 ? (q(), J("span", oh, "×" + V(e.count), 1)) : X("", !0),
|
|
13434
|
+
e.status === "running" ? (q(), J("span", sh, "执行中…")) : X("", !0)
|
|
13435
|
+
]), e.children && e.children.length ? (q(), J("div", ch, [z[25] ||= Y("div", { class: "step-children-label" }, "🧬 子 agent 进度", -1), (q(!0), J(K, null, Xi(e.children, (e, t) => (q(), J("div", {
|
|
13420
13436
|
key: t,
|
|
13421
13437
|
class: "step-child"
|
|
13422
13438
|
}, [
|
|
13423
|
-
Y("span",
|
|
13424
|
-
Y("span",
|
|
13425
|
-
e.status === "running" ? (q(), J("span",
|
|
13439
|
+
Y("span", lh, V(A(e)), 1),
|
|
13440
|
+
Y("span", uh, V(e.name), 1),
|
|
13441
|
+
e.status === "running" ? (q(), J("span", dh, "…")) : X("", !0)
|
|
13426
13442
|
]))), 128))])) : X("", !0)]))), 128))])) : X("", !0),
|
|
13427
13443
|
Y("div", { class: Se(["message-bubble", { typing: N(r) }]) }, [N(r) ? (q(), J(K, { key: 0 }, [e.showTyping ? (q(), J(K, { key: 0 }, [
|
|
13428
13444
|
z[26] ||= Y("span", { class: "dot" }, null, -1),
|
|
13429
13445
|
z[27] ||= Y("span", { class: "dot" }, null, -1),
|
|
13430
13446
|
z[28] ||= Y("span", { class: "dot" }, null, -1)
|
|
13431
|
-
], 64)) : (q(), J("span",
|
|
13447
|
+
], 64)) : (q(), J("span", fh, "思考中…"))], 64)) : (q(), J(K, { key: 1 }, [t.role === "assistant" ? (q(), Ko(nf, {
|
|
13432
13448
|
key: 0,
|
|
13433
13449
|
content: t.content
|
|
13434
13450
|
}, null, 8, ["content"])) : (q(), J(K, { key: 1 }, [is(V(t.content), 1)], 64))], 64))], 2),
|
|
13435
|
-
t.role === "assistant" && W(n).loading && r === W(n).messages.length - 1 && t.content ? (q(), J("span",
|
|
13436
|
-
Y("div",
|
|
13437
|
-
t.role === "assistant" && t.content && !W(n).loading && r === W(n).messages.length - 1 ? (q(), J("div",
|
|
13451
|
+
t.role === "assistant" && W(n).loading && r === W(n).messages.length - 1 && t.content ? (q(), J("span", ph)) : X("", !0),
|
|
13452
|
+
Y("div", mh, V(I(t.timestamp)), 1),
|
|
13453
|
+
t.role === "assistant" && t.content && !W(n).loading && r === W(n).messages.length - 1 ? (q(), J("div", hh, [Y("button", {
|
|
13438
13454
|
class: "msg-action-btn",
|
|
13439
13455
|
title: R.value ? "已复制" : "复制",
|
|
13440
13456
|
onClick: (e) => ee(t.content)
|
|
13441
|
-
}, V(R.value ? "✓ 已复制" : "📋 复制"), 9,
|
|
13457
|
+
}, V(R.value ? "✓ 已复制" : "📋 复制"), 9, gh), Y("button", {
|
|
13442
13458
|
class: "msg-action-btn",
|
|
13443
13459
|
title: "重新生成",
|
|
13444
13460
|
onClick: z[3] ||= (...e) => W(l) && W(l)(...e)
|
|
13445
13461
|
}, "🔄 重新生成")])) : X("", !0)
|
|
13446
|
-
])], 10,
|
|
13447
|
-
W(n).loading && W(n).messages[W(n).messages.length - 1]?.role !== "assistant" ? (q(), J("div",
|
|
13462
|
+
])], 10, Xm))), 128)),
|
|
13463
|
+
W(n).loading && W(n).messages[W(n).messages.length - 1]?.role !== "assistant" ? (q(), J("div", _h, [e.showAvatar ? (q(), J("div", vh, "🤖")) : X("", !0), Y("div", yh, [Y("div", bh, [e.showTyping ? (q(), J(K, { key: 0 }, [
|
|
13448
13464
|
z[29] ||= Y("span", { class: "dot" }, null, -1),
|
|
13449
13465
|
z[30] ||= Y("span", { class: "dot" }, null, -1),
|
|
13450
13466
|
z[31] ||= Y("span", { class: "dot" }, null, -1)
|
|
13451
|
-
], 64)) : (q(), J("span",
|
|
13452
|
-
W(n).error ? (q(), J("div",
|
|
13453
|
-
Y("span",
|
|
13467
|
+
], 64)) : (q(), J("span", xh, "思考中…"))])])])) : X("", !0),
|
|
13468
|
+
W(n).error ? (q(), J("div", Sh, [
|
|
13469
|
+
Y("span", Ch, V(W(n).error), 1),
|
|
13454
13470
|
D.value ? (q(), J("button", {
|
|
13455
13471
|
key: 0,
|
|
13456
13472
|
class: "retry-btn",
|
|
@@ -13464,35 +13480,35 @@ app.mount('#app');
|
|
|
13464
13480
|
}, "↩ 回退")) : X("", !0)
|
|
13465
13481
|
])) : X("", !0)
|
|
13466
13482
|
], 544), [[xc, C.value]]),
|
|
13467
|
-
W(i) ? (q(), J("div",
|
|
13483
|
+
W(i) ? (q(), J("div", wh, [_.value ? (q(), J(K, { key: 0 }, [
|
|
13468
13484
|
z[32] ||= Y("div", { class: "approval-head" }, [Y("span", { class: "approval-icon" }, "❓"), Y("span", { class: "approval-title" }, "AI 需要你确认")], -1),
|
|
13469
|
-
W(i).args?.question ? (q(), J("div",
|
|
13470
|
-
W(i).args?.context ? (q(), J("div",
|
|
13471
|
-
W(i).args?.recommendation ? (q(), J("div",
|
|
13472
|
-
Y("div",
|
|
13485
|
+
W(i).args?.question ? (q(), J("div", Th, V(W(i).args.question), 1)) : X("", !0),
|
|
13486
|
+
W(i).args?.context ? (q(), J("div", Eh, V(W(i).args.context), 1)) : X("", !0),
|
|
13487
|
+
W(i).args?.recommendation ? (q(), J("div", Dh, "💡 推荐:" + V(W(i).args.recommendation), 1)) : X("", !0),
|
|
13488
|
+
Y("div", Oh, [Y("button", {
|
|
13473
13489
|
class: "approval-deny",
|
|
13474
13490
|
onClick: z[7] ||= (e) => W(u)(!1)
|
|
13475
13491
|
}, "拒绝"), v.value.length ? (q(!0), J(K, { key: 0 }, Xi(v.value, (e) => (q(), J("button", {
|
|
13476
13492
|
key: e,
|
|
13477
13493
|
class: "approval-opt",
|
|
13478
13494
|
onClick: (t) => W(u)(e)
|
|
13479
|
-
}, V(e), 9,
|
|
13495
|
+
}, V(e), 9, kh))), 128)) : (q(), J("button", {
|
|
13480
13496
|
key: 1,
|
|
13481
13497
|
class: "approval-allow",
|
|
13482
13498
|
onClick: z[8] ||= (e) => W(u)(!0)
|
|
13483
13499
|
}, "允许"))])
|
|
13484
13500
|
], 64)) : (q(), J(K, { key: 1 }, [
|
|
13485
|
-
Y("div",
|
|
13501
|
+
Y("div", Ah, [
|
|
13486
13502
|
z[34] ||= Y("span", { class: "approval-icon" }, "✋", -1),
|
|
13487
|
-
Y("span",
|
|
13503
|
+
Y("span", jh, [z[33] ||= is("需确认工具调用:", -1), Y("code", null, V(W(i).toolName), 1)]),
|
|
13488
13504
|
p.value ? (q(), J("button", {
|
|
13489
13505
|
key: 0,
|
|
13490
13506
|
class: "approval-toggle",
|
|
13491
13507
|
onClick: z[9] ||= (e) => y.value = !y.value
|
|
13492
13508
|
}, V(y.value ? "收起参数" : "查看参数") + V(y.value ? " ▴" : " ▾"), 1)) : X("", !0)
|
|
13493
13509
|
]),
|
|
13494
|
-
p.value && y.value ? (q(), J("pre",
|
|
13495
|
-
Y("div",
|
|
13510
|
+
p.value && y.value ? (q(), J("pre", Mh, V(p.value), 1)) : X("", !0),
|
|
13511
|
+
Y("div", Nh, [Y("button", {
|
|
13496
13512
|
class: "approval-deny",
|
|
13497
13513
|
onClick: z[10] ||= (e) => W(u)(!1)
|
|
13498
13514
|
}, "拒绝"), Y("button", {
|
|
@@ -13500,19 +13516,19 @@ app.mount('#app');
|
|
|
13500
13516
|
onClick: z[11] ||= (e) => W(u)(!0)
|
|
13501
13517
|
}, "允许")])
|
|
13502
13518
|
], 64))])) : X("", !0),
|
|
13503
|
-
t.pendingConflict ? (q(), J("div",
|
|
13504
|
-
Y("div",
|
|
13519
|
+
t.pendingConflict ? (q(), J("div", Ph, [
|
|
13520
|
+
Y("div", Fh, [z[37] ||= Y("span", { class: "conflict-icon" }, "⚠️", -1), Y("span", Ih, [
|
|
13505
13521
|
z[35] ||= is("写入冲突:", -1),
|
|
13506
13522
|
Y("code", null, V(t.pendingConflict.path), 1),
|
|
13507
13523
|
z[36] ||= is(" 已被外部修改", -1)
|
|
13508
13524
|
])]),
|
|
13509
|
-
Y("div",
|
|
13525
|
+
Y("div", Lh, " AI 基于「读取时的旧值」准备" + V(t.pendingConflict.op === "delete" ? "删除" : "写入") + ",但该属性在你读取之后被外部代码/其他 agent/手动改过。 ", 1),
|
|
13510
13526
|
Y("button", {
|
|
13511
13527
|
class: "conflict-toggle",
|
|
13512
13528
|
onClick: z[12] ||= (e) => g.value = !g.value
|
|
13513
13529
|
}, V(g.value ? "收起对比" : "查看值对比") + V(g.value ? " ▴" : " ▾"), 1),
|
|
13514
|
-
g.value ? (q(), J("div",
|
|
13515
|
-
Y("div",
|
|
13530
|
+
g.value ? (q(), J("div", Rh, [Y("div", zh, [z[38] ||= Y("div", { class: "conflict-diff-label" }, "AI 想写的值", -1), Y("pre", Bh, V(m.value || "(delete 操作无值)"), 1)]), Y("div", Vh, [z[39] ||= Y("div", { class: "conflict-diff-label" }, "外部改后的当前值", -1), Y("pre", Hh, V(h.value), 1)])])) : X("", !0),
|
|
13531
|
+
Y("div", Uh, [
|
|
13516
13532
|
Y("button", {
|
|
13517
13533
|
class: "conflict-keep",
|
|
13518
13534
|
onClick: z[13] ||= (e) => t.onResolveConflict?.("keep_external"),
|
|
@@ -13530,8 +13546,8 @@ app.mount('#app');
|
|
|
13530
13546
|
}, "回退")
|
|
13531
13547
|
])
|
|
13532
13548
|
])) : X("", !0),
|
|
13533
|
-
zr(Y("div",
|
|
13534
|
-
t.getInfo ? (q(), J("span",
|
|
13549
|
+
zr(Y("div", Wh, [
|
|
13550
|
+
t.getInfo ? (q(), J("span", Gh, " 🔌" + V(L.value.mcp) + " · 🔧" + V(L.value.tools), 1)) : X("", !0),
|
|
13535
13551
|
b.value ? (q(), J("button", {
|
|
13536
13552
|
key: 1,
|
|
13537
13553
|
class: "undo-foot-btn",
|
|
@@ -13544,26 +13560,26 @@ app.mount('#app');
|
|
|
13544
13560
|
placeholder: e.placeholder,
|
|
13545
13561
|
rows: "1",
|
|
13546
13562
|
onKeydown: F
|
|
13547
|
-
}, null, 40,
|
|
13563
|
+
}, null, 40, Kh), [[rl, S.value]]),
|
|
13548
13564
|
Y("button", {
|
|
13549
13565
|
class: Se(["send-btn", { "stop-btn": W(n).loading }]),
|
|
13550
13566
|
disabled: !W(n).loading && !S.value.trim(),
|
|
13551
13567
|
title: W(n).loading ? "停止生成" : "发送",
|
|
13552
13568
|
onClick: z[17] ||= (e) => W(n).loading ? W(s)() : P()
|
|
13553
|
-
}, [W(n).loading ? (q(), J("svg",
|
|
13569
|
+
}, [W(n).loading ? (q(), J("svg", Jh, [...z[40] ||= [Y("rect", {
|
|
13554
13570
|
x: "6",
|
|
13555
13571
|
y: "6",
|
|
13556
13572
|
width: "12",
|
|
13557
13573
|
height: "12",
|
|
13558
13574
|
rx: "2"
|
|
13559
|
-
}, null, -1)]])) : (q(), J("svg",
|
|
13575
|
+
}, null, -1)]])) : (q(), J("svg", Yh, [...z[41] ||= [Y("line", {
|
|
13560
13576
|
x1: "22",
|
|
13561
13577
|
y1: "2",
|
|
13562
13578
|
x2: "11",
|
|
13563
13579
|
y2: "13"
|
|
13564
|
-
}, null, -1), Y("polygon", { points: "22 2 15 22 11 13 2 9 22 2" }, null, -1)]]))], 10,
|
|
13580
|
+
}, null, -1), Y("polygon", { points: "22 2 15 22 11 13 2 9 22 2" }, null, -1)]]))], 10, qh)
|
|
13565
13581
|
], 512), [[xc, C.value]]),
|
|
13566
|
-
$o(
|
|
13582
|
+
$o(Rm, {
|
|
13567
13583
|
visible: w.value,
|
|
13568
13584
|
"onUpdate:visible": z[18] ||= (e) => w.value = e,
|
|
13569
13585
|
logs: e.debugLogs,
|
|
@@ -13575,15 +13591,15 @@ app.mount('#app');
|
|
|
13575
13591
|
])
|
|
13576
13592
|
], 2));
|
|
13577
13593
|
}
|
|
13578
|
-
}), [["__scopeId", "data-v-
|
|
13579
|
-
function
|
|
13594
|
+
}), [["__scopeId", "data-v-063f5f71"]]);
|
|
13595
|
+
function Zh(e) {
|
|
13580
13596
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
13581
13597
|
}
|
|
13582
|
-
function
|
|
13598
|
+
function Qh(e, t) {
|
|
13583
13599
|
let n = t.threshold ?? 6e3;
|
|
13584
13600
|
if (e.length <= n) return e;
|
|
13585
13601
|
if (t.vfsAvailable && t.files) {
|
|
13586
|
-
let n = Math.random().toString(36).slice(2, 10), r = `large_results/${t.toolName}-${n}.txt`, i =
|
|
13602
|
+
let n = Math.random().toString(36).slice(2, 10), r = `large_results/${t.toolName}-${n}.txt`, i = Zh(r);
|
|
13587
13603
|
return t.files[i] = {
|
|
13588
13604
|
content: e,
|
|
13589
13605
|
updatedAt: Date.now()
|
|
@@ -13598,7 +13614,7 @@ function Zh(e, t) {
|
|
|
13598
13614
|
}
|
|
13599
13615
|
//#endregion
|
|
13600
13616
|
//#region src/core/utils/pool.ts
|
|
13601
|
-
async function
|
|
13617
|
+
async function $h(e, t, n, r) {
|
|
13602
13618
|
let i = Array(e.length), a = Math.max(1, t);
|
|
13603
13619
|
if (a === 1) {
|
|
13604
13620
|
for (let t = 0; t < e.length && !r?.aborted; t++) i[t] = await n(e[t], t);
|
|
@@ -13615,7 +13631,7 @@ async function Qh(e, t, n, r) {
|
|
|
13615
13631
|
}
|
|
13616
13632
|
//#endregion
|
|
13617
13633
|
//#region src/core/utils/modelCaps.ts
|
|
13618
|
-
var
|
|
13634
|
+
var eg = [
|
|
13619
13635
|
{
|
|
13620
13636
|
pattern: /deepseek-v4/i,
|
|
13621
13637
|
caps: {
|
|
@@ -13777,34 +13793,34 @@ var $h = [
|
|
|
13777
13793
|
maxOutputTokens: 4096
|
|
13778
13794
|
}
|
|
13779
13795
|
}
|
|
13780
|
-
],
|
|
13796
|
+
], tg = {
|
|
13781
13797
|
contextWindow: 32768,
|
|
13782
13798
|
maxOutputTokens: 4096
|
|
13783
13799
|
};
|
|
13784
|
-
function
|
|
13800
|
+
function ng(e = {}) {
|
|
13785
13801
|
let t = (() => {
|
|
13786
|
-
if (e.model) return
|
|
13802
|
+
if (e.model) return eg.find((t) => t.pattern.test(e.model))?.caps;
|
|
13787
13803
|
})();
|
|
13788
13804
|
return {
|
|
13789
|
-
contextWindow: e.contextWindow ?? t?.contextWindow ??
|
|
13790
|
-
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ??
|
|
13805
|
+
contextWindow: e.contextWindow ?? t?.contextWindow ?? tg.contextWindow,
|
|
13806
|
+
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ?? tg.maxOutputTokens
|
|
13791
13807
|
};
|
|
13792
13808
|
}
|
|
13793
|
-
function
|
|
13809
|
+
function rg(e) {
|
|
13794
13810
|
if (!e) return 0;
|
|
13795
13811
|
let t = (e.match(/[\u4e00-\u9fff]/g) || []).length, n = e.length - t;
|
|
13796
13812
|
return Math.ceil(t * 1.5 + n * .25);
|
|
13797
13813
|
}
|
|
13798
|
-
function
|
|
13814
|
+
function ig(e) {
|
|
13799
13815
|
return Math.max(2e3, Math.min(2e4, Math.round(e * .035)));
|
|
13800
13816
|
}
|
|
13801
|
-
function
|
|
13802
|
-
let t =
|
|
13817
|
+
function ag(e) {
|
|
13818
|
+
let t = ig(e);
|
|
13803
13819
|
return Math.min(2e5, Math.max(t, Math.round(e * .7)));
|
|
13804
13820
|
}
|
|
13805
13821
|
//#endregion
|
|
13806
13822
|
//#region src/core/harness/state.ts
|
|
13807
|
-
function
|
|
13823
|
+
function og() {
|
|
13808
13824
|
return {
|
|
13809
13825
|
messages: [],
|
|
13810
13826
|
todos: [],
|
|
@@ -13817,42 +13833,42 @@ function ag() {
|
|
|
13817
13833
|
}
|
|
13818
13834
|
//#endregion
|
|
13819
13835
|
//#region src/core/harness/middleware.ts
|
|
13820
|
-
function
|
|
13836
|
+
function sg(e, t) {
|
|
13821
13837
|
return t ? {
|
|
13822
13838
|
...e,
|
|
13823
13839
|
...t
|
|
13824
13840
|
} : e;
|
|
13825
13841
|
}
|
|
13826
|
-
async function
|
|
13842
|
+
async function cg(e, t) {
|
|
13827
13843
|
let n = t;
|
|
13828
|
-
for (let t of e) t.beforeAgent && (n =
|
|
13844
|
+
for (let t of e) t.beforeAgent && (n = sg(n, await t.beforeAgent(n)));
|
|
13829
13845
|
return n;
|
|
13830
13846
|
}
|
|
13831
|
-
function
|
|
13847
|
+
function lg(e, t) {
|
|
13832
13848
|
let n = t.state;
|
|
13833
|
-
for (let r of e) r.beforeModel && (n =
|
|
13849
|
+
for (let r of e) r.beforeModel && (n = sg(n, r.beforeModel({
|
|
13834
13850
|
messages: t.messages,
|
|
13835
13851
|
state: n
|
|
13836
13852
|
})));
|
|
13837
13853
|
return n;
|
|
13838
13854
|
}
|
|
13839
|
-
function
|
|
13855
|
+
function ug(e, t, n) {
|
|
13840
13856
|
let r = n;
|
|
13841
13857
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
13842
13858
|
let i = e[n];
|
|
13843
|
-
i.afterModel && (r =
|
|
13859
|
+
i.afterModel && (r = sg(r, i.afterModel(t, r)));
|
|
13844
13860
|
}
|
|
13845
13861
|
return r;
|
|
13846
13862
|
}
|
|
13847
|
-
async function
|
|
13863
|
+
async function dg(e, t) {
|
|
13848
13864
|
let n = t;
|
|
13849
13865
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
13850
13866
|
let r = e[t];
|
|
13851
|
-
r.afterAgent && (n =
|
|
13867
|
+
r.afterAgent && (n = sg(n, await r.afterAgent(n)));
|
|
13852
13868
|
}
|
|
13853
13869
|
return n;
|
|
13854
13870
|
}
|
|
13855
|
-
async function
|
|
13871
|
+
async function fg(e, t) {
|
|
13856
13872
|
let n = [];
|
|
13857
13873
|
for (let r of e) {
|
|
13858
13874
|
if (!r.beforeReturn) continue;
|
|
@@ -13861,19 +13877,19 @@ async function dg(e, t) {
|
|
|
13861
13877
|
}
|
|
13862
13878
|
return n.length ? n.join("\n\n") : null;
|
|
13863
13879
|
}
|
|
13864
|
-
function
|
|
13880
|
+
function pg(e, t) {
|
|
13865
13881
|
return e.reduceRight((e, t) => (n) => t.wrapModelCall ? t.wrapModelCall(n, e) : e(n), t);
|
|
13866
13882
|
}
|
|
13867
|
-
function
|
|
13883
|
+
function mg(e, t) {
|
|
13868
13884
|
return e.reduceRight((e, t) => (n) => t.wrapToolCall ? t.wrapToolCall(n, e) : e(n), t);
|
|
13869
13885
|
}
|
|
13870
13886
|
//#endregion
|
|
13871
13887
|
//#region src/core/harness/createAgent.ts
|
|
13872
|
-
function
|
|
13888
|
+
function hg(e) {
|
|
13873
13889
|
return e ? /<|tool_calls|>|<||[^>]*tool_call|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e) : !1;
|
|
13874
13890
|
}
|
|
13875
|
-
var
|
|
13876
|
-
function
|
|
13891
|
+
var gg = 10, _g = 300, vg = 6e3;
|
|
13892
|
+
function yg(e, t) {
|
|
13877
13893
|
let n = e.reduce((e, t) => e + (typeof t.content == "string" ? t.content.length : JSON.stringify(t.content).length), 0);
|
|
13878
13894
|
if (n <= t) return e;
|
|
13879
13895
|
let r = 0, i = n - t, a = Math.max(100, Math.min(400, Math.round(t / 500)));
|
|
@@ -13888,29 +13904,29 @@ function vg(e, t) {
|
|
|
13888
13904
|
});
|
|
13889
13905
|
});
|
|
13890
13906
|
}
|
|
13891
|
-
function
|
|
13892
|
-
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m =
|
|
13907
|
+
function bg(e) {
|
|
13908
|
+
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m = gg, maxRetries: h = 2, retryDelayMs: g = 500, maxParallelTools: _ = 1, maxVerifyAttempts: v = 0, onLog: y, debug: b = !1 } = e, x = ng({
|
|
13893
13909
|
model: c,
|
|
13894
13910
|
contextWindow: e.contextWindow,
|
|
13895
13911
|
maxOutputTokens: e.maxOutputTokens
|
|
13896
|
-
}), S = u ?? x.maxOutputTokens, C =
|
|
13912
|
+
}), S = u ?? x.maxOutputTokens, C = ig(x.contextWindow), w = ag(x.contextWindow), T = /* @__PURE__ */ pn([]);
|
|
13897
13913
|
function E(e, t) {
|
|
13898
13914
|
let n = {
|
|
13899
13915
|
timestamp: Date.now(),
|
|
13900
13916
|
type: e,
|
|
13901
13917
|
data: t
|
|
13902
13918
|
};
|
|
13903
|
-
T.value.push(n), T.value.length >
|
|
13919
|
+
T.value.push(n), T.value.length > _g && T.value.splice(0, T.value.length - _g), gn(T), y?.(n), b && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
|
|
13904
13920
|
}
|
|
13905
13921
|
let D = (e) => {
|
|
13906
|
-
T.value.push(e), T.value.length >
|
|
13922
|
+
T.value.push(e), T.value.length > _g && T.value.splice(0, T.value.length - _g), gn(T);
|
|
13907
13923
|
}, O = [...p.flatMap((e) => e.tools || []), ...f], k = e.llm ?? new s({
|
|
13908
13924
|
apiKey: t,
|
|
13909
13925
|
model: c,
|
|
13910
13926
|
temperature: l,
|
|
13911
13927
|
maxTokens: S,
|
|
13912
13928
|
configuration: n ? { baseURL: n } : void 0
|
|
13913
|
-
}), A = O.length > 0 ? k.bindTools?.(O) ?? k : k, j =
|
|
13929
|
+
}), A = O.length > 0 ? k.bindTools?.(O) ?? k : k, j = og();
|
|
13914
13930
|
function M() {
|
|
13915
13931
|
let e = [d || "你是一个智能助手。"];
|
|
13916
13932
|
for (let t of p) if (t.augmentPrompt) {
|
|
@@ -13985,7 +14001,7 @@ function yg(e) {
|
|
|
13985
14001
|
};
|
|
13986
14002
|
try {
|
|
13987
14003
|
let n = await t.invoke(e.args), r = typeof n == "string" ? n : JSON.stringify(n);
|
|
13988
|
-
return r =
|
|
14004
|
+
return r = Qh(r, {
|
|
13989
14005
|
files: e.state.files,
|
|
13990
14006
|
vfsAvailable: O.some((e) => e.name === "vfs_read"),
|
|
13991
14007
|
toolName: e.name,
|
|
@@ -14006,12 +14022,12 @@ function yg(e) {
|
|
|
14006
14022
|
return e instanceof i ? "human" : e instanceof r ? "ai" : e instanceof a ? "system" : e instanceof o ? "tool" : "unknown";
|
|
14007
14023
|
}
|
|
14008
14024
|
function ee(e, t) {
|
|
14009
|
-
return
|
|
14025
|
+
return yg(e, t);
|
|
14010
14026
|
}
|
|
14011
14027
|
function R(e) {
|
|
14012
14028
|
return e.map((e) => {
|
|
14013
14029
|
let t = L(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
14014
|
-
r && (n.content = r.length >
|
|
14030
|
+
r && (n.content = r.length > vg ? r.slice(0, vg) + `…(截断 ${r.length - vg} 字符)` : r);
|
|
14015
14031
|
let i = e.tool_calls;
|
|
14016
14032
|
Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
|
|
14017
14033
|
id: e.id,
|
|
@@ -14026,7 +14042,7 @@ function yg(e) {
|
|
|
14026
14042
|
});
|
|
14027
14043
|
}
|
|
14028
14044
|
async function z(e, t, n) {
|
|
14029
|
-
T.value = [], j =
|
|
14045
|
+
T.value = [], j = og(), j.messages = e, j = await cg(p, j);
|
|
14030
14046
|
let r = e;
|
|
14031
14047
|
for (let e of p) if (e.compressInput) {
|
|
14032
14048
|
let t = await e.compressInput(r);
|
|
@@ -14041,13 +14057,13 @@ function yg(e) {
|
|
|
14041
14057
|
tools: O.map((e) => e.name),
|
|
14042
14058
|
middleware: p.map((e) => e.name)
|
|
14043
14059
|
});
|
|
14044
|
-
let l =
|
|
14060
|
+
let l = pg(p, (e) => F(e, t, n)), u = mg(p, I), d = 0, f = null, h = 0;
|
|
14045
14061
|
try {
|
|
14046
14062
|
for (; d < m && !n?.aborted;) {
|
|
14047
14063
|
t({
|
|
14048
14064
|
type: "round_start",
|
|
14049
14065
|
round: d + 1
|
|
14050
|
-
}), j =
|
|
14066
|
+
}), j = lg(p, {
|
|
14051
14067
|
messages: s,
|
|
14052
14068
|
state: j
|
|
14053
14069
|
}), s = P(s), s = ee(s, w), E("llm_request", {
|
|
@@ -14064,12 +14080,12 @@ function yg(e) {
|
|
|
14064
14080
|
round: d + 1,
|
|
14065
14081
|
content: e.content,
|
|
14066
14082
|
toolCalls: e.toolCalls
|
|
14067
|
-
}), j =
|
|
14083
|
+
}), j = ug(p, e, j), e.aborted) return t({
|
|
14068
14084
|
type: "done",
|
|
14069
14085
|
content: e.content
|
|
14070
14086
|
}), e.content;
|
|
14071
14087
|
if (!e.toolCalls.length) {
|
|
14072
|
-
if (h < 2 &&
|
|
14088
|
+
if (h < 2 && hg(e.content)) {
|
|
14073
14089
|
h += 1, E("middleware", {
|
|
14074
14090
|
stage: "format_retry",
|
|
14075
14091
|
attempt: h,
|
|
@@ -14078,7 +14094,7 @@ function yg(e) {
|
|
|
14078
14094
|
continue;
|
|
14079
14095
|
}
|
|
14080
14096
|
if (v > 0 && j.verifyAttempts < v) {
|
|
14081
|
-
let t = await
|
|
14097
|
+
let t = await fg(p, {
|
|
14082
14098
|
messages: s,
|
|
14083
14099
|
state: j,
|
|
14084
14100
|
response: e,
|
|
@@ -14113,7 +14129,7 @@ function yg(e) {
|
|
|
14113
14129
|
logSink: D
|
|
14114
14130
|
}
|
|
14115
14131
|
};
|
|
14116
|
-
}), a = await
|
|
14132
|
+
}), a = await $h(r, _, async (e) => {
|
|
14117
14133
|
if (n?.aborted) return;
|
|
14118
14134
|
t({
|
|
14119
14135
|
type: "tool_call",
|
|
@@ -14184,7 +14200,7 @@ function yg(e) {
|
|
|
14184
14200
|
}), r;
|
|
14185
14201
|
} finally {
|
|
14186
14202
|
try {
|
|
14187
|
-
await
|
|
14203
|
+
await dg(p, j);
|
|
14188
14204
|
} catch (e) {
|
|
14189
14205
|
console.warn("[Agent] afterAgent 清理出错(已忽略):", e);
|
|
14190
14206
|
}
|
|
@@ -14206,14 +14222,14 @@ function yg(e) {
|
|
|
14206
14222
|
}
|
|
14207
14223
|
//#endregion
|
|
14208
14224
|
//#region src/core/harness/todos.ts
|
|
14209
|
-
function
|
|
14225
|
+
function xg(e) {
|
|
14210
14226
|
if (e.length) return [
|
|
14211
14227
|
"## 当前任务清单(用 write_todos 工具管理)",
|
|
14212
14228
|
e.map((e, t) => `${t + 1}. [${e.status}] ${e.content}`).join("\n"),
|
|
14213
14229
|
"规则:开始前用 write_todos 拆解;首个任务标 in_progress;完成一个立即标 completed(不批量);保持至少一个 in_progress 直到全部完成。"
|
|
14214
14230
|
].join("\n");
|
|
14215
14231
|
}
|
|
14216
|
-
function
|
|
14232
|
+
function Sg(e = []) {
|
|
14217
14233
|
let r = e.map((e) => ({ ...e })), i = 0;
|
|
14218
14234
|
return {
|
|
14219
14235
|
name: "todos",
|
|
@@ -14231,7 +14247,7 @@ function xg(e = []) {
|
|
|
14231
14247
|
})],
|
|
14232
14248
|
beforeAgent: () => ({ todos: r }),
|
|
14233
14249
|
beforeModel: () => (i = 0, { todos: r }),
|
|
14234
|
-
augmentPrompt: () =>
|
|
14250
|
+
augmentPrompt: () => xg(r),
|
|
14235
14251
|
wrapToolCall: async (e, t) => e.name === "write_todos" && (i++, i > 1) ? {
|
|
14236
14252
|
content: "错误:write_todos 不应在一轮中并行多次调用(整表替换语义)。请串行使用。",
|
|
14237
14253
|
status: "error"
|
|
@@ -14243,18 +14259,18 @@ function xg(e = []) {
|
|
|
14243
14259
|
}
|
|
14244
14260
|
//#endregion
|
|
14245
14261
|
//#region src/core/harness/skills.ts
|
|
14246
|
-
function
|
|
14262
|
+
function Cg(e) {
|
|
14247
14263
|
return e;
|
|
14248
14264
|
}
|
|
14249
|
-
var
|
|
14250
|
-
function wg(e) {
|
|
14251
|
-
return Cg.test(e) || e.startsWith("//") ? "http" : "vfs";
|
|
14252
|
-
}
|
|
14265
|
+
var wg = /^https?:\/\//i;
|
|
14253
14266
|
function Tg(e) {
|
|
14267
|
+
return wg.test(e) || e.startsWith("//") ? "http" : "vfs";
|
|
14268
|
+
}
|
|
14269
|
+
function Eg(e) {
|
|
14254
14270
|
return e.replace(/^vfs:\/\//, "").replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
14255
14271
|
}
|
|
14256
|
-
async function
|
|
14257
|
-
if (
|
|
14272
|
+
async function Dg(e, t) {
|
|
14273
|
+
if (Tg(e) === "http") try {
|
|
14258
14274
|
let t = await fetch(e);
|
|
14259
14275
|
return t.ok ? {
|
|
14260
14276
|
ok: !0,
|
|
@@ -14277,7 +14293,7 @@ async function Eg(e, t) {
|
|
|
14277
14293
|
ok: !1,
|
|
14278
14294
|
error: `skill 文档 ${e} 是 vfs 路径,但 vfs 未启用`
|
|
14279
14295
|
};
|
|
14280
|
-
let n = t(
|
|
14296
|
+
let n = t(Eg(e));
|
|
14281
14297
|
return n == null ? {
|
|
14282
14298
|
ok: !1,
|
|
14283
14299
|
error: `未找到 vfs 文档 ${e}(可用 vfs_ls 查看)`
|
|
@@ -14286,14 +14302,14 @@ async function Eg(e, t) {
|
|
|
14286
14302
|
content: n
|
|
14287
14303
|
};
|
|
14288
14304
|
}
|
|
14289
|
-
function
|
|
14305
|
+
function Og(e) {
|
|
14290
14306
|
if (e.length) return [
|
|
14291
14307
|
"## 可用 Skills(渐进式披露)",
|
|
14292
14308
|
e.map((e) => `- ${e.name}: ${e.description}`).join("\n"),
|
|
14293
14309
|
"当某 skill 适用时,先调用 load_skill(name) 加载其完整指令,再按指令执行。不要凭记忆猜测 skill 内容。"
|
|
14294
14310
|
].join("\n");
|
|
14295
14311
|
}
|
|
14296
|
-
function
|
|
14312
|
+
function kg(e, r) {
|
|
14297
14313
|
let i = new Map(e.map((e) => [e.name, e])), a = /* @__PURE__ */ new Set();
|
|
14298
14314
|
return {
|
|
14299
14315
|
name: "skills",
|
|
@@ -14303,7 +14319,7 @@ function Og(e, r) {
|
|
|
14303
14319
|
if (a.has(e)) return `skill "${e}" 已在本轮加载,无需重复。`;
|
|
14304
14320
|
let n;
|
|
14305
14321
|
if (t.doc) {
|
|
14306
|
-
let i = await
|
|
14322
|
+
let i = await Dg(t.doc, r?.readVfs);
|
|
14307
14323
|
if (!i.ok) return `加载 skill "${e}" 文档失败:${i.error}`;
|
|
14308
14324
|
n = i.content;
|
|
14309
14325
|
} else if (t.getContent) n = await t.getContent();
|
|
@@ -14321,13 +14337,13 @@ function Og(e, r) {
|
|
|
14321
14337
|
})),
|
|
14322
14338
|
skillsLoaded: []
|
|
14323
14339
|
}),
|
|
14324
|
-
augmentPrompt: () =>
|
|
14340
|
+
augmentPrompt: () => Og(e),
|
|
14325
14341
|
afterModel: () => ({ skillsLoaded: [...a] })
|
|
14326
14342
|
};
|
|
14327
14343
|
}
|
|
14328
14344
|
//#endregion
|
|
14329
14345
|
//#region src/core/harness/memory.ts
|
|
14330
|
-
function
|
|
14346
|
+
function Ag(e = "") {
|
|
14331
14347
|
let t = e;
|
|
14332
14348
|
return {
|
|
14333
14349
|
name: "memory",
|
|
@@ -14340,12 +14356,12 @@ function kg(e = "") {
|
|
|
14340
14356
|
}
|
|
14341
14357
|
//#endregion
|
|
14342
14358
|
//#region src/core/harness/permissions.ts
|
|
14343
|
-
var
|
|
14359
|
+
var jg = /* @__PURE__ */ new Set([
|
|
14344
14360
|
"set_window_prop",
|
|
14345
14361
|
"delete_window_prop",
|
|
14346
14362
|
"vfs_write",
|
|
14347
14363
|
"vfs_edit"
|
|
14348
|
-
]),
|
|
14364
|
+
]), Mg = /* @__PURE__ */ new Set([
|
|
14349
14365
|
"get_window_prop",
|
|
14350
14366
|
"describe_window_prop",
|
|
14351
14367
|
"list_window_props",
|
|
@@ -14354,7 +14370,7 @@ var Ag = /* @__PURE__ */ new Set([
|
|
|
14354
14370
|
"vfs_glob",
|
|
14355
14371
|
"vfs_grep"
|
|
14356
14372
|
]);
|
|
14357
|
-
function
|
|
14373
|
+
function Ng(e) {
|
|
14358
14374
|
let t = "";
|
|
14359
14375
|
for (let n = 0; n < e.length; n++) {
|
|
14360
14376
|
let r = e[n];
|
|
@@ -14362,16 +14378,16 @@ function Mg(e) {
|
|
|
14362
14378
|
}
|
|
14363
14379
|
return RegExp("^" + t + "$");
|
|
14364
14380
|
}
|
|
14365
|
-
function
|
|
14366
|
-
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) =>
|
|
14381
|
+
function Pg(e, t, n) {
|
|
14382
|
+
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) => Ng(e).test(n))) return r.mode;
|
|
14367
14383
|
return "allow";
|
|
14368
14384
|
}
|
|
14369
|
-
function
|
|
14385
|
+
function Fg(e) {
|
|
14370
14386
|
return {
|
|
14371
14387
|
name: "permissions",
|
|
14372
14388
|
wrapToolCall: async (t, n) => {
|
|
14373
|
-
let r =
|
|
14374
|
-
return r && i &&
|
|
14389
|
+
let r = jg.has(t.name) ? "write" : Mg.has(t.name) ? "read" : null, i = t.args?.path || "";
|
|
14390
|
+
return r && i && Pg(e, r, i) === "deny" ? {
|
|
14375
14391
|
content: `权限拒绝:${r} 操作 "${i}" 被 permissions 规则禁止。`,
|
|
14376
14392
|
status: "error"
|
|
14377
14393
|
} : n(t);
|
|
@@ -14380,7 +14396,7 @@ function Pg(e) {
|
|
|
14380
14396
|
}
|
|
14381
14397
|
//#endregion
|
|
14382
14398
|
//#region src/core/harness/approval.ts
|
|
14383
|
-
function
|
|
14399
|
+
function Ig(e = {}) {
|
|
14384
14400
|
let t = (t, n) => e.confirm ? !!e.confirm(t, n) : e.tools === void 0 || e.tools.includes(t);
|
|
14385
14401
|
return {
|
|
14386
14402
|
name: "approval",
|
|
@@ -14414,15 +14430,15 @@ function Fg(e = {}) {
|
|
|
14414
14430
|
}
|
|
14415
14431
|
//#endregion
|
|
14416
14432
|
//#region src/core/harness/humanConfirm.ts
|
|
14417
|
-
var
|
|
14433
|
+
var Lg = "request_human_confirmation", Rg = t.object({
|
|
14418
14434
|
question: t.string().describe("要征询用户的问题/方案描述。清晰具体:说明当前情况、为什么需要确认、确认什么。"),
|
|
14419
14435
|
options: t.array(t.string()).optional().describe("可选方案列表(2-4 个)。用户从中选一个。不传则用户只回答允许/拒绝。"),
|
|
14420
14436
|
recommendation: t.string().optional().describe("你推荐的方案(优先在 options 中选一个)及推荐理由,帮用户快速决策。"),
|
|
14421
14437
|
context: t.string().optional().describe("补充上下文:已做了什么、约束、影响范围等,帮用户判断。")
|
|
14422
14438
|
});
|
|
14423
|
-
function
|
|
14439
|
+
function zg() {
|
|
14424
14440
|
return n(async () => "人工确认中间件未装载,无法征询用户。请直接向用户说明情况并等待回复。", {
|
|
14425
|
-
name:
|
|
14441
|
+
name: Lg,
|
|
14426
14442
|
description: [
|
|
14427
14443
|
"当遇到以下情况时,主动调用本工具征询用户确认后再继续(不要默默猜测后直接执行高风险动作):",
|
|
14428
14444
|
"1) 不确定用户意图、需求有歧义;",
|
|
@@ -14432,10 +14448,10 @@ function Rg() {
|
|
|
14432
14448
|
"入参:question=问题/方案描述;options=可选方案列表(多方案时给);recommendation=你推荐的方案及理由。",
|
|
14433
14449
|
"用户选择后,据其回答继续;若用户拒绝,停止当前操作并询问如何调整。"
|
|
14434
14450
|
].join(""),
|
|
14435
|
-
schema:
|
|
14451
|
+
schema: Rg
|
|
14436
14452
|
});
|
|
14437
14453
|
}
|
|
14438
|
-
function
|
|
14454
|
+
function Bg() {
|
|
14439
14455
|
return {
|
|
14440
14456
|
name: "humanConfirm",
|
|
14441
14457
|
wrapToolCall: async (e, t) => e.name === "request_human_confirmation" ? new Promise((t) => {
|
|
@@ -14467,14 +14483,14 @@ function zg() {
|
|
|
14467
14483
|
}
|
|
14468
14484
|
//#endregion
|
|
14469
14485
|
//#region src/core/harness/checkpoint.ts
|
|
14470
|
-
function
|
|
14486
|
+
function Vg(e) {
|
|
14471
14487
|
if (typeof e != "object" || !e) return e;
|
|
14472
14488
|
if (typeof structuredClone == "function") try {
|
|
14473
14489
|
return structuredClone(e);
|
|
14474
14490
|
} catch {}
|
|
14475
14491
|
return JSON.parse(JSON.stringify(e));
|
|
14476
14492
|
}
|
|
14477
|
-
function
|
|
14493
|
+
function Hg(e, t) {
|
|
14478
14494
|
let n = t.split("."), r = e;
|
|
14479
14495
|
for (let e of n) {
|
|
14480
14496
|
if (r == null) return;
|
|
@@ -14482,12 +14498,12 @@ function Vg(e, t) {
|
|
|
14482
14498
|
}
|
|
14483
14499
|
return r;
|
|
14484
14500
|
}
|
|
14485
|
-
function
|
|
14501
|
+
function Ug(e, t, n) {
|
|
14486
14502
|
let r = t.split("."), i = e;
|
|
14487
14503
|
for (let e = 0; e < r.length - 1; e++) i[r[e]] ?? (i[r[e]] = {}), i = i[r[e]];
|
|
14488
14504
|
i[r[r.length - 1]] = n;
|
|
14489
14505
|
}
|
|
14490
|
-
function
|
|
14506
|
+
function Wg(e, t) {
|
|
14491
14507
|
if (Array.isArray(e)) {
|
|
14492
14508
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
14493
14509
|
return;
|
|
@@ -14496,11 +14512,11 @@ function Ug(e, t) {
|
|
|
14496
14512
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
14497
14513
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
14498
14514
|
}
|
|
14499
|
-
function
|
|
14500
|
-
let n =
|
|
14501
|
-
typeof n == "object" && n ?
|
|
14515
|
+
function Gg(e, t) {
|
|
14516
|
+
let n = Hg(window, e);
|
|
14517
|
+
typeof n == "object" && n ? Wg(n, t) : Ug(window, e, t);
|
|
14502
14518
|
}
|
|
14503
|
-
function
|
|
14519
|
+
function Kg(e) {
|
|
14504
14520
|
let t = e.slice();
|
|
14505
14521
|
for (; t.length;) {
|
|
14506
14522
|
let e = t[t.length - 1];
|
|
@@ -14509,20 +14525,20 @@ function Gg(e) {
|
|
|
14509
14525
|
}
|
|
14510
14526
|
return t;
|
|
14511
14527
|
}
|
|
14512
|
-
function
|
|
14528
|
+
function qg(e) {
|
|
14513
14529
|
let t = [], n = e.maxCheckpoints ?? 5, r = 1;
|
|
14514
14530
|
return {
|
|
14515
14531
|
save(i) {
|
|
14516
|
-
let a =
|
|
14517
|
-
for (let t of e.windowPaths) o[t] =
|
|
14532
|
+
let a = Kg(e.messages), o = {};
|
|
14533
|
+
for (let t of e.windowPaths) o[t] = Vg(Hg(window, t));
|
|
14518
14534
|
let s = {
|
|
14519
14535
|
id: r++,
|
|
14520
14536
|
label: i,
|
|
14521
14537
|
timestamp: Date.now(),
|
|
14522
|
-
messages:
|
|
14538
|
+
messages: Vg(a),
|
|
14523
14539
|
windowVals: o,
|
|
14524
|
-
vfs:
|
|
14525
|
-
todos:
|
|
14540
|
+
vfs: Vg(e.vfsStore.files),
|
|
14541
|
+
todos: Vg(e.getTodos()),
|
|
14526
14542
|
messageCount: a.length
|
|
14527
14543
|
};
|
|
14528
14544
|
for (t.push(s); t.length > n;) t.shift();
|
|
@@ -14542,15 +14558,15 @@ function Kg(e) {
|
|
|
14542
14558
|
restore(n) {
|
|
14543
14559
|
let r = n == null ? t[t.length - 1] : t.find((e) => e.id === n);
|
|
14544
14560
|
if (!r) return !1;
|
|
14545
|
-
e.messages.splice(0, e.messages.length, ...
|
|
14546
|
-
for (let [e, t] of Object.entries(r.windowVals))
|
|
14561
|
+
e.messages.splice(0, e.messages.length, ...Vg(r.messages));
|
|
14562
|
+
for (let [e, t] of Object.entries(r.windowVals)) Gg(e, Vg(t));
|
|
14547
14563
|
let i = e.vfsStore.files;
|
|
14548
14564
|
for (let e of Object.keys(i)) delete i[e];
|
|
14549
|
-
return Object.assign(i,
|
|
14565
|
+
return Object.assign(i, Vg(r.vfs)), e.todosMw.reset(Vg(r.todos)), !0;
|
|
14550
14566
|
}
|
|
14551
14567
|
};
|
|
14552
14568
|
}
|
|
14553
|
-
function
|
|
14569
|
+
function Jg(e) {
|
|
14554
14570
|
let t = !1;
|
|
14555
14571
|
return {
|
|
14556
14572
|
name: "checkpoint",
|
|
@@ -14564,22 +14580,22 @@ function qg(e) {
|
|
|
14564
14580
|
}
|
|
14565
14581
|
//#endregion
|
|
14566
14582
|
//#region src/core/harness/subagent.ts
|
|
14567
|
-
function
|
|
14583
|
+
function Yg(e) {
|
|
14568
14584
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14569
14585
|
}
|
|
14570
|
-
var
|
|
14586
|
+
var Xg = [
|
|
14571
14587
|
"get_window_prop",
|
|
14572
14588
|
"get_window_paths",
|
|
14573
14589
|
"list_window_props",
|
|
14574
14590
|
"describe_window_prop",
|
|
14575
14591
|
"fetch_document"
|
|
14576
|
-
],
|
|
14577
|
-
async function
|
|
14578
|
-
let a = t.depth ?? 0, o = t.maxDepth ??
|
|
14592
|
+
], Zg = 1, Qg = 4, $g = 6, e_ = ["spawn_agent", "spawn_agents"];
|
|
14593
|
+
async function t_(e, t, n, r, i) {
|
|
14594
|
+
let a = t.depth ?? 0, o = t.maxDepth ?? Zg, s = /* @__PURE__ */ new Set([...Xg, ...t.allowedTools ?? []]), c = [...t.allTools.filter((e) => s.has(e.name) && !e_.includes(e.name)), ...t.extraTools ?? []], l = a + 1 < o ? [n_({
|
|
14579
14595
|
...t,
|
|
14580
14596
|
depth: a + 1
|
|
14581
|
-
})] : [], u =
|
|
14582
|
-
...
|
|
14597
|
+
})] : [], u = bg({
|
|
14598
|
+
...Yg(t.llm) ? { llm: t.llm } : {
|
|
14583
14599
|
apiKey: t.llm.apiKey,
|
|
14584
14600
|
baseUrl: t.llm.baseUrl,
|
|
14585
14601
|
model: e.model ?? t.llm.model,
|
|
@@ -14588,8 +14604,8 @@ async function e_(e, t, n, r, i) {
|
|
|
14588
14604
|
},
|
|
14589
14605
|
systemPrompt: e.role?.trim() || t.systemPrompt || "你是一个专注的子任务执行者。你只有只读工具(读 window / 抓文档),用它们完成给定任务,给出简洁结论,不要展开多余解释。",
|
|
14590
14606
|
tools: c,
|
|
14591
|
-
middleware: [...t.skills?.length ? [
|
|
14592
|
-
maxToolRounds: t.maxToolRounds ??
|
|
14607
|
+
middleware: [...t.skills?.length ? [kg(t.skills)] : [], ...l],
|
|
14608
|
+
maxToolRounds: t.maxToolRounds ?? $g,
|
|
14593
14609
|
onLog: i,
|
|
14594
14610
|
debug: t.debug
|
|
14595
14611
|
});
|
|
@@ -14601,8 +14617,8 @@ async function e_(e, t, n, r, i) {
|
|
|
14601
14617
|
r && (e.type === "tool_call" || e.type === "tool_result") && r(e);
|
|
14602
14618
|
}, n);
|
|
14603
14619
|
}
|
|
14604
|
-
function
|
|
14605
|
-
let r = e.maxParallel ??
|
|
14620
|
+
function n_(e) {
|
|
14621
|
+
let r = e.maxParallel ?? Qg, i, a, o, s = (e, t) => (n) => {
|
|
14606
14622
|
a && a({
|
|
14607
14623
|
type: "subagent",
|
|
14608
14624
|
taskId: e,
|
|
@@ -14621,7 +14637,7 @@ function t_(e) {
|
|
|
14621
14637
|
...e,
|
|
14622
14638
|
allowedTools: r
|
|
14623
14639
|
} : e, l = `sub-${Math.random().toString(36).slice(2, 8)}`, u = n?.trim() || "子任务";
|
|
14624
|
-
return await
|
|
14640
|
+
return await t_({
|
|
14625
14641
|
prompt: t,
|
|
14626
14642
|
role: n,
|
|
14627
14643
|
model: a
|
|
@@ -14638,9 +14654,9 @@ function t_(e) {
|
|
|
14638
14654
|
tools: t.array(t.string()).optional().describe("子 agent 可用工具名白名单(默认只读 window + fetch)"),
|
|
14639
14655
|
model: t.string().optional().describe("覆盖模型(默认同主)")
|
|
14640
14656
|
})
|
|
14641
|
-
}), n(async ({ tasks: t }) => (await
|
|
14657
|
+
}), n(async ({ tasks: t }) => (await $h(t, r, async (t, n) => {
|
|
14642
14658
|
let r = `sub-${n}-${Math.random().toString(36).slice(2, 6)}`, a = t.role?.trim() || `子任务${n + 1}`;
|
|
14643
|
-
return
|
|
14659
|
+
return t_(t, e, i, s(r, a), (e) => o?.({
|
|
14644
14660
|
...e,
|
|
14645
14661
|
source: `子:${a}`
|
|
14646
14662
|
}));
|
|
@@ -14655,8 +14671,8 @@ function t_(e) {
|
|
|
14655
14671
|
wrapToolCall: async (e, t) => (e.signal && (i = e.signal), e.emit && (a = e.emit), e.logSink && (o = e.logSink), t(e))
|
|
14656
14672
|
};
|
|
14657
14673
|
}
|
|
14658
|
-
var
|
|
14659
|
-
function
|
|
14674
|
+
var r_ = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
14675
|
+
function i_(e, t) {
|
|
14660
14676
|
let n = e.tools ?? [];
|
|
14661
14677
|
return {
|
|
14662
14678
|
llm: e.llm ?? t.llm,
|
|
@@ -14670,9 +14686,9 @@ function r_(e, t) {
|
|
|
14670
14686
|
debug: t.debug
|
|
14671
14687
|
};
|
|
14672
14688
|
}
|
|
14673
|
-
function
|
|
14689
|
+
function a_(e, r) {
|
|
14674
14690
|
let i = /* @__PURE__ */ new Set(), a = e.filter((e) => {
|
|
14675
|
-
if (!
|
|
14691
|
+
if (!r_.test(e.id)) return console.warn(`[subagents] id "${e.id}" 非合法工具名(须 [a-zA-Z_][a-zA-Z0-9_]*),已跳过`), !1;
|
|
14676
14692
|
let t = `use_${e.id}`;
|
|
14677
14693
|
return i.has(t) ? (console.warn(`[subagents] id "${e.id}" 重复,已跳过`), !1) : (i.add(t), !0);
|
|
14678
14694
|
}), o, s, c, l = (e, t) => (n) => {
|
|
@@ -14690,8 +14706,8 @@ function i_(e, r) {
|
|
|
14690
14706
|
return {
|
|
14691
14707
|
name: "subagents",
|
|
14692
14708
|
tools: a.map((e) => n(async ({ task: t }) => {
|
|
14693
|
-
let n =
|
|
14694
|
-
return
|
|
14709
|
+
let n = i_(e, r);
|
|
14710
|
+
return t_({ prompt: t }, n, o, l(`use_${e.id}`, e.id), (t) => c?.({
|
|
14695
14711
|
...t,
|
|
14696
14712
|
source: `子:${e.id}`
|
|
14697
14713
|
}));
|
|
@@ -14710,7 +14726,7 @@ function i_(e, r) {
|
|
|
14710
14726
|
}
|
|
14711
14727
|
//#endregion
|
|
14712
14728
|
//#region src/core/harness/verify.ts
|
|
14713
|
-
function
|
|
14729
|
+
function o_(e) {
|
|
14714
14730
|
return {
|
|
14715
14731
|
name: "verify",
|
|
14716
14732
|
async beforeReturn({ messages: t, state: n, log: r }) {
|
|
@@ -14722,10 +14738,10 @@ function a_(e) {
|
|
|
14722
14738
|
if (e.adversarial) {
|
|
14723
14739
|
r?.("middleware", {
|
|
14724
14740
|
stage: "adversarial_start",
|
|
14725
|
-
model:
|
|
14741
|
+
model: m_(e.adversarial.llm),
|
|
14726
14742
|
tools: (e.adversarial.tools ?? []).length
|
|
14727
14743
|
});
|
|
14728
|
-
let n = await
|
|
14744
|
+
let n = await v_(t, e.adversarial.llm, r, e.adversarial.tools);
|
|
14729
14745
|
if (r?.("middleware", {
|
|
14730
14746
|
stage: "adversarial_done",
|
|
14731
14747
|
clean: n === null,
|
|
@@ -14736,16 +14752,16 @@ function a_(e) {
|
|
|
14736
14752
|
}
|
|
14737
14753
|
};
|
|
14738
14754
|
}
|
|
14739
|
-
var
|
|
14755
|
+
var s_ = /* @__PURE__ */ new Set([
|
|
14740
14756
|
"set_window_prop",
|
|
14741
14757
|
"edit_window_prop",
|
|
14742
14758
|
"delete_window_prop"
|
|
14743
|
-
]),
|
|
14744
|
-
function
|
|
14759
|
+
]), c_ = /校验失败|未在注册表中声明|未注册|不存在|仅支持|必须是/;
|
|
14760
|
+
function l_(e) {
|
|
14745
14761
|
let t = /* @__PURE__ */ new Map();
|
|
14746
14762
|
for (let n of e) {
|
|
14747
14763
|
let e = n?.tool_calls;
|
|
14748
|
-
if (Array.isArray(e)) for (let n of e)
|
|
14764
|
+
if (Array.isArray(e)) for (let n of e) s_.has(n.name) && typeof n?.args?.path == "string" && t.set(n.args.path, {
|
|
14749
14765
|
path: n.args.path,
|
|
14750
14766
|
op: n.name,
|
|
14751
14767
|
callId: n.id
|
|
@@ -14753,7 +14769,7 @@ function c_(e) {
|
|
|
14753
14769
|
}
|
|
14754
14770
|
return [...t.values()];
|
|
14755
14771
|
}
|
|
14756
|
-
function
|
|
14772
|
+
function u_(e) {
|
|
14757
14773
|
let t = /* @__PURE__ */ new Map();
|
|
14758
14774
|
for (let n of e) {
|
|
14759
14775
|
let e = n?.tool_call_id, r = n?.content;
|
|
@@ -14761,7 +14777,7 @@ function l_(e) {
|
|
|
14761
14777
|
}
|
|
14762
14778
|
return t;
|
|
14763
14779
|
}
|
|
14764
|
-
function
|
|
14780
|
+
function d_(e, t) {
|
|
14765
14781
|
if (e == null) return;
|
|
14766
14782
|
let n = e;
|
|
14767
14783
|
for (let e of t.split(".")) {
|
|
@@ -14770,16 +14786,16 @@ function u_(e, t) {
|
|
|
14770
14786
|
}
|
|
14771
14787
|
return n;
|
|
14772
14788
|
}
|
|
14773
|
-
function
|
|
14789
|
+
function f_(e = {}) {
|
|
14774
14790
|
let t = e.window ?? globalThis.window, n = typeof e.schemas == "function" ? e.schemas : () => e.schemas ?? {};
|
|
14775
14791
|
return async ({ messages: e }) => {
|
|
14776
|
-
let r =
|
|
14792
|
+
let r = l_(e);
|
|
14777
14793
|
if (!r.length) return { ok: !0 };
|
|
14778
|
-
let i =
|
|
14794
|
+
let i = u_(e), a = n(), o = [];
|
|
14779
14795
|
for (let { path: e, op: n, callId: s } of r) {
|
|
14780
14796
|
let r = s ? i.get(s) : void 0;
|
|
14781
|
-
if (r &&
|
|
14782
|
-
let c =
|
|
14797
|
+
if (r && c_.test(r)) continue;
|
|
14798
|
+
let c = d_(t, e);
|
|
14783
14799
|
if (n === "delete_window_prop") c !== void 0 && o.push(`${e} 删除后读回仍有值,疑似未生效`);
|
|
14784
14800
|
else if (c == null) o.push(`写入 ${e} 后读回为空,疑似未生效`);
|
|
14785
14801
|
else if (a[e]) {
|
|
@@ -14793,17 +14809,17 @@ function d_(e = {}) {
|
|
|
14793
14809
|
} : { ok: !0 };
|
|
14794
14810
|
};
|
|
14795
14811
|
}
|
|
14796
|
-
function f_(e) {
|
|
14797
|
-
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14798
|
-
}
|
|
14799
14812
|
function p_(e) {
|
|
14800
|
-
return
|
|
14813
|
+
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14801
14814
|
}
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
return m_.test(e);
|
|
14815
|
+
function m_(e) {
|
|
14816
|
+
return p_(e) ? e.model ?? e.modelName ?? "<实例>" : e.model ?? "<配置>";
|
|
14805
14817
|
}
|
|
14818
|
+
var h_ = /无问题|没有问题|未发现问题|没有发现|没问题|未发现/;
|
|
14806
14819
|
function g_(e) {
|
|
14820
|
+
return h_.test(e);
|
|
14821
|
+
}
|
|
14822
|
+
function __(e) {
|
|
14807
14823
|
let t = "", n = "";
|
|
14808
14824
|
for (let a of e) a instanceof i ? t = typeof a.content == "string" ? a.content : "" : a instanceof r && !(a.tool_calls?.length > 0) && (n = typeof a.content == "string" ? a.content : "");
|
|
14809
14825
|
return {
|
|
@@ -14811,8 +14827,8 @@ function g_(e) {
|
|
|
14811
14827
|
lastReply: n
|
|
14812
14828
|
};
|
|
14813
14829
|
}
|
|
14814
|
-
async function
|
|
14815
|
-
let { lastUser: i, lastReply: a } =
|
|
14830
|
+
async function v_(e, t, n, r) {
|
|
14831
|
+
let { lastUser: i, lastReply: a } = __(e);
|
|
14816
14832
|
if (!a) return null;
|
|
14817
14833
|
let o = Array.isArray(r) && r.length > 0, s = [
|
|
14818
14834
|
"你是严格的对抗式审查者,目标是找出以下 AI 助手回复的错误并证明它有问题(事实错误 / 遗漏 / 逻辑矛盾 / 与需求不符)。",
|
|
@@ -14823,7 +14839,7 @@ async function __(e, t, n, r) {
|
|
|
14823
14839
|
].join("\n"), c = "你是严格的对抗式审查者,只找问题不赞美。目标是反驳,不是改进。", l = n ? (e) => n(e.type, {
|
|
14824
14840
|
...e.data,
|
|
14825
14841
|
source: "adversarial"
|
|
14826
|
-
}) : void 0, u = await
|
|
14842
|
+
}) : void 0, u = await bg(p_(t) ? {
|
|
14827
14843
|
llm: t,
|
|
14828
14844
|
tools: r,
|
|
14829
14845
|
maxToolRounds: o ? 4 : 1,
|
|
@@ -14848,17 +14864,17 @@ async function __(e, t, n, r) {
|
|
|
14848
14864
|
stage: "adversarial_verdict",
|
|
14849
14865
|
verdict: u,
|
|
14850
14866
|
source: "adversarial"
|
|
14851
|
-
}),
|
|
14867
|
+
}), g_(u) ? null : u.trim();
|
|
14852
14868
|
}
|
|
14853
14869
|
//#endregion
|
|
14854
14870
|
//#region src/core/mcp/client.ts
|
|
14855
|
-
function
|
|
14871
|
+
function y_(e) {
|
|
14856
14872
|
let t = e?.content;
|
|
14857
14873
|
if (!Array.isArray(t) || !t.length) return "";
|
|
14858
14874
|
let n = t.map((e) => e.type === "text" && e.text ? e.text : e.type === "image" && e.data ? `[image:${String(e.data).slice(0, 32)}…]` : e.type === "audio" && e.data ? "[audio]" : e.type === "resource" && e.resource ? e.resource.text ?? e.resource.blob ?? "" : "").filter(Boolean).join("\n");
|
|
14859
14875
|
return e?.isError ? `工具错误:${n}` : n;
|
|
14860
14876
|
}
|
|
14861
|
-
async function
|
|
14877
|
+
async function b_(e) {
|
|
14862
14878
|
let t = new URL(e.url), n = e.requestInit;
|
|
14863
14879
|
if (e.transport === "http") {
|
|
14864
14880
|
let { StreamableHTTPClientTransport: e } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
@@ -14871,8 +14887,8 @@ async function y_(e) {
|
|
|
14871
14887
|
let { WebSocketClientTransport: r } = await import("@modelcontextprotocol/sdk/client/websocket.js");
|
|
14872
14888
|
return new r(t);
|
|
14873
14889
|
}
|
|
14874
|
-
function
|
|
14875
|
-
return n(async (n) =>
|
|
14890
|
+
function x_(e, t) {
|
|
14891
|
+
return n(async (n) => y_(await t.callTool({
|
|
14876
14892
|
name: e.name,
|
|
14877
14893
|
arguments: n
|
|
14878
14894
|
})), {
|
|
@@ -14881,21 +14897,21 @@ function b_(e, t) {
|
|
|
14881
14897
|
schema: e.inputSchema
|
|
14882
14898
|
});
|
|
14883
14899
|
}
|
|
14884
|
-
async function
|
|
14885
|
-
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await
|
|
14900
|
+
async function S_(e) {
|
|
14901
|
+
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await b_(e), r = new t({
|
|
14886
14902
|
name: "page-agent-sdk",
|
|
14887
14903
|
version: "1.0"
|
|
14888
14904
|
}, { capabilities: {} });
|
|
14889
14905
|
await r.connect(n);
|
|
14890
14906
|
let { tools: i } = await r.listTools();
|
|
14891
14907
|
return {
|
|
14892
|
-
tools: i.map((e) =>
|
|
14908
|
+
tools: i.map((e) => x_(e, r)),
|
|
14893
14909
|
close: () => r.close()
|
|
14894
14910
|
};
|
|
14895
14911
|
}
|
|
14896
14912
|
//#endregion
|
|
14897
14913
|
//#region src/core/utils/rounds.ts
|
|
14898
|
-
function
|
|
14914
|
+
function C_(e) {
|
|
14899
14915
|
let t = [], n = null, r = 0;
|
|
14900
14916
|
for (let i = 0; i < e.length; i++) {
|
|
14901
14917
|
let a = e[i];
|
|
@@ -14909,14 +14925,14 @@ function S_(e) {
|
|
|
14909
14925
|
}
|
|
14910
14926
|
return n && t.push(n), t;
|
|
14911
14927
|
}
|
|
14912
|
-
function
|
|
14928
|
+
function w_(e, t) {
|
|
14913
14929
|
let n = (e || "").replace(/```[\s\S]*?```/g, "[代码]").replace(/`([^`]+)`/g, "$1").replace(/[#*_>\-]\s?/g, "").replace(/\[(代码)\]/g, "「代码」").replace(/\s+/g, " ").trim();
|
|
14914
14930
|
return n.length > t ? n.slice(0, t) + "…" : n;
|
|
14915
14931
|
}
|
|
14916
|
-
var
|
|
14917
|
-
function
|
|
14932
|
+
var T_ = "【更早对话摘要";
|
|
14933
|
+
function E_(e, t) {
|
|
14918
14934
|
if (t <= 0) return { trimmed: !1 };
|
|
14919
|
-
let n =
|
|
14935
|
+
let n = C_(e);
|
|
14920
14936
|
if (n.length <= t) return { trimmed: !1 };
|
|
14921
14937
|
let r = n[n.length - t].startIdx, i = n.slice(0, n.length - t), a = n[0].startIdx, o = "";
|
|
14922
14938
|
for (let t = 0; t < a; t++) {
|
|
@@ -14927,7 +14943,7 @@ function T_(e, t) {
|
|
|
14927
14943
|
}
|
|
14928
14944
|
}
|
|
14929
14945
|
let s = i.map((e) => {
|
|
14930
|
-
let t =
|
|
14946
|
+
let t = w_(e.userMsg.content, 60) || "(空)", n = e.assistantMsgs[0] ? w_(e.assistantMsgs[0].content, 80) : "(无回复)";
|
|
14931
14947
|
return `- 第${e.round}轮:${t} → ${n}`;
|
|
14932
14948
|
}).join("\n"), c = o ? o.replace(/^【[^】]*】\n?/, "") : "";
|
|
14933
14949
|
return {
|
|
@@ -14936,47 +14952,47 @@ function T_(e, t) {
|
|
|
14936
14952
|
deleteCount: r,
|
|
14937
14953
|
summary: {
|
|
14938
14954
|
role: "system",
|
|
14939
|
-
content: c ? `${
|
|
14955
|
+
content: c ? `${T_}(${i.length} 轮,含累积)】\n${c}\n【续】\n${s}` : `${T_}(${i.length} 轮)】\n${s}`,
|
|
14940
14956
|
timestamp: i[0].userMsg.timestamp
|
|
14941
14957
|
}
|
|
14942
14958
|
};
|
|
14943
14959
|
}
|
|
14944
14960
|
//#endregion
|
|
14945
14961
|
//#region src/core/composables/useContextManager.ts
|
|
14946
|
-
var
|
|
14962
|
+
var D_ = {
|
|
14947
14963
|
windowRounds: 6,
|
|
14948
14964
|
summaryThresholdRounds: 8,
|
|
14949
14965
|
toolResultMaxChars: 800,
|
|
14950
14966
|
enableRecall: !0,
|
|
14951
14967
|
recallTopK: 3,
|
|
14952
14968
|
enableLLMSummary: !1
|
|
14953
|
-
},
|
|
14954
|
-
function O_(e) {
|
|
14955
|
-
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !D_.has(e));
|
|
14956
|
-
}
|
|
14969
|
+
}, O_ = /* @__PURE__ */ new Set(/* @__PURE__ */ "的.了.是.在.我.你.他.她.它.这.那.和.与.及.或.一个.什么.怎么.如何.为什么.可以.能.请.帮.一下.需要.想要.the.a.an.is.are.of.to.in.on".split("."));
|
|
14957
14970
|
function k_(e) {
|
|
14971
|
+
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !O_.has(e));
|
|
14972
|
+
}
|
|
14973
|
+
function A_(e) {
|
|
14958
14974
|
let t = typeof e.content == "string" ? e.content : "";
|
|
14959
14975
|
if (e.reasoning && (t += e.reasoning), e.steps) for (let n of e.steps) t += " " + (n.name || ""), n.args != null && (t += " " + (typeof n.args == "string" ? n.args : JSON.stringify(n.args))), n.result && (t += " " + n.result);
|
|
14960
|
-
return
|
|
14976
|
+
return rg(t);
|
|
14961
14977
|
}
|
|
14962
|
-
function
|
|
14963
|
-
let t =
|
|
14964
|
-
for (let n of e.assistantMsgs) t +=
|
|
14978
|
+
function j_(e) {
|
|
14979
|
+
let t = A_(e.userMsg);
|
|
14980
|
+
for (let n of e.assistantMsgs) t += A_(n);
|
|
14965
14981
|
return t;
|
|
14966
14982
|
}
|
|
14967
|
-
function
|
|
14983
|
+
function M_(e, t) {
|
|
14968
14984
|
return e.map((e) => {
|
|
14969
|
-
let n =
|
|
14985
|
+
let n = w_(e.userMsg.content, 60) || "(空)", r = e.assistantMsgs[0] ? w_(e.assistantMsgs[0].content, 80) : "(无回复)", i = e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => e.name)), a = i.length ? ` [工具: ${i.join(", ")}]` : "", o = "";
|
|
14970
14986
|
if (t && t.size) {
|
|
14971
14987
|
let n = [];
|
|
14972
|
-
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${
|
|
14988
|
+
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${w_(e.result, 120)}`);
|
|
14973
14989
|
n.length && (o = `\n 字段提示: ${n.join(" | ")}`);
|
|
14974
14990
|
}
|
|
14975
14991
|
return `- 第${e.round}轮:${n} → ${r}${a}${o}`;
|
|
14976
14992
|
}).join("\n");
|
|
14977
14993
|
}
|
|
14978
|
-
function
|
|
14979
|
-
let r =
|
|
14994
|
+
function N_(e, t, n) {
|
|
14995
|
+
let r = k_(t);
|
|
14980
14996
|
return r.length === 0 ? [] : e.map((e) => {
|
|
14981
14997
|
let t = (e.userMsg.content + " " + e.assistantMsgs.map((e) => e.content).join(" ")).toLowerCase(), n = 0;
|
|
14982
14998
|
for (let e of r) t.includes(e) && n++;
|
|
@@ -14986,13 +15002,13 @@ function M_(e, t, n) {
|
|
|
14986
15002
|
};
|
|
14987
15003
|
}).filter((e) => e.score > 0).sort((e, t) => t.score - e.score).slice(0, n).map((e) => e.r);
|
|
14988
15004
|
}
|
|
14989
|
-
function
|
|
15005
|
+
function P_(e = {}) {
|
|
14990
15006
|
let t = {
|
|
14991
|
-
...
|
|
15007
|
+
...D_,
|
|
14992
15008
|
...e
|
|
14993
15009
|
};
|
|
14994
15010
|
async function n(e) {
|
|
14995
|
-
let n =
|
|
15011
|
+
let n = C_(e), r = e.length, i = (t) => ({
|
|
14996
15012
|
messages: e,
|
|
14997
15013
|
stats: {
|
|
14998
15014
|
triggered: !1,
|
|
@@ -15005,9 +15021,9 @@ function N_(e = {}) {
|
|
|
15005
15021
|
}
|
|
15006
15022
|
}), a, o, s;
|
|
15007
15023
|
if (t.contextWindow && t.contextWindow > 0) {
|
|
15008
|
-
if (n.reduce((e, t) => e +
|
|
15024
|
+
if (n.reduce((e, t) => e + j_(t), 0) <= t.contextWindow * (t.summaryThresholdRatio ?? .5)) return i("none");
|
|
15009
15025
|
let e = t.contextWindow * (t.windowRatio ?? .4), r = 0, c = 0;
|
|
15010
|
-
for (let t = n.length - 1; t >= 0; t--) if (r +=
|
|
15026
|
+
for (let t = n.length - 1; t >= 0; t--) if (r += j_(n[t]), r >= e) {
|
|
15011
15027
|
c = t + 1;
|
|
15012
15028
|
break;
|
|
15013
15029
|
}
|
|
@@ -15020,12 +15036,12 @@ function N_(e = {}) {
|
|
|
15020
15036
|
}
|
|
15021
15037
|
let c = [...e].reverse().find((e) => e.role === "user")?.content || "", l = t.preserveLastToolResults?.length ? new Set(t.preserveLastToolResults) : void 0, u, d;
|
|
15022
15038
|
if (t.enableLLMSummary && t.llmInvoke) try {
|
|
15023
|
-
u = await t.llmInvoke(
|
|
15039
|
+
u = await t.llmInvoke(M_(o, l)), d = s + "llm_summary";
|
|
15024
15040
|
} catch {
|
|
15025
|
-
u =
|
|
15041
|
+
u = M_(o, l), d = s + "index_summary(llm_fallback)";
|
|
15026
15042
|
}
|
|
15027
|
-
else u =
|
|
15028
|
-
let f = t.enableRecall ?
|
|
15043
|
+
else u = M_(o, l), d = s + "index_summary";
|
|
15044
|
+
let f = t.enableRecall ? N_(o, c, t.recallTopK) : [], p = f.length ? f.map((e) => `- 第${e.round}轮:${w_(e.userMsg.content, 60)} → ${e.assistantMsgs[0] ? w_(e.assistantMsgs[0].content, 80) : ""}`).join("\n") : "", m = [`【对话历史摘要】以下是之前 ${o.length} 轮对话的要点(最新 ${a.length} 轮已完整保留):`, u];
|
|
15029
15045
|
if (p && m.push("\n【与当前问题可能相关的早期对话】", p), t.getRegisteredProps) try {
|
|
15030
15046
|
let e = t.getRegisteredProps();
|
|
15031
15047
|
if (e.length) {
|
|
@@ -15056,10 +15072,10 @@ function N_(e = {}) {
|
|
|
15056
15072
|
return {
|
|
15057
15073
|
compress: n,
|
|
15058
15074
|
config: t,
|
|
15059
|
-
trimToolResults:
|
|
15075
|
+
trimToolResults: F_
|
|
15060
15076
|
};
|
|
15061
15077
|
}
|
|
15062
|
-
function
|
|
15078
|
+
function F_(e, t) {
|
|
15063
15079
|
let n = [];
|
|
15064
15080
|
if (e.forEach((e, t) => {
|
|
15065
15081
|
e instanceof o && n.push(t);
|
|
@@ -15078,8 +15094,8 @@ function P_(e, t) {
|
|
|
15078
15094
|
}
|
|
15079
15095
|
//#endregion
|
|
15080
15096
|
//#region src/core/harness/summarization.ts
|
|
15081
|
-
function
|
|
15082
|
-
let t =
|
|
15097
|
+
function I_(e = {}) {
|
|
15098
|
+
let t = P_(e);
|
|
15083
15099
|
return {
|
|
15084
15100
|
name: "summarization",
|
|
15085
15101
|
compressInput: async (e) => {
|
|
@@ -15093,7 +15109,7 @@ function F_(e = {}) {
|
|
|
15093
15109
|
}
|
|
15094
15110
|
//#endregion
|
|
15095
15111
|
//#region src/core/presets.ts
|
|
15096
|
-
var
|
|
15112
|
+
var L_ = {
|
|
15097
15113
|
pageBuilder: { systemPrompt: "你是页面构建助手。流程:get_window_prop 读取当前页面结构 → set_window_prop / edit_window_prop 修改属性 → 页面实时更新。多步任务先用 write_todos 拆解,逐步推进。" },
|
|
15098
15114
|
researcher: {
|
|
15099
15115
|
systemPrompt: "你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。",
|
|
@@ -15107,14 +15123,14 @@ var I_ = {
|
|
|
15107
15123
|
memory: !1,
|
|
15108
15124
|
subagent: !1
|
|
15109
15125
|
} }
|
|
15110
|
-
},
|
|
15126
|
+
}, R_ = { reliableWriteRules: [
|
|
15111
15127
|
"【可靠写入规则】",
|
|
15112
15128
|
"1. 改任何属性前,先用 get_window_prop 读其当前真实值,基于真实值改,不要凭记忆;",
|
|
15113
15129
|
"2. 若不确定可操作哪些属性,先 list_window_props 查看当前注册项(动态组件场景下注册表会增删,以工具返回为准,勿凭旧记忆);",
|
|
15114
15130
|
"3. 不确定某属性字段结构时,先 describe_window_prop 看其说明,字段以 describe 返回为准;",
|
|
15115
15131
|
"4. 写入若被 schema 校验拒绝(返回结构化错误含字段名与期望类型),按错误修正后重试,不要放弃;",
|
|
15116
15132
|
"5. 优先用 edit_window_prop 增量 patch(只发改动),避免 set 整体重传大 JSON 被截断。"
|
|
15117
|
-
].join("\n") },
|
|
15133
|
+
].join("\n") }, z_ = {
|
|
15118
15134
|
auto: {
|
|
15119
15135
|
summaryThresholdRatio: .5,
|
|
15120
15136
|
windowRatio: .4,
|
|
@@ -15136,8 +15152,8 @@ var I_ = {
|
|
|
15136
15152
|
enableLLMSummary: !0
|
|
15137
15153
|
}
|
|
15138
15154
|
};
|
|
15139
|
-
function
|
|
15140
|
-
let n =
|
|
15155
|
+
function B_(e, t) {
|
|
15156
|
+
let n = z_[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
15141
15157
|
return {
|
|
15142
15158
|
...n,
|
|
15143
15159
|
...r,
|
|
@@ -15154,7 +15170,7 @@ function $(e) {
|
|
|
15154
15170
|
};
|
|
15155
15171
|
return e.path !== void 0 && (t.path = e.path), e.hint && (t.hint = e.hint), e.details !== void 0 && (t.details = e.details), `ERROR: ${JSON.stringify(t)}`;
|
|
15156
15172
|
}
|
|
15157
|
-
function
|
|
15173
|
+
function V_(e) {
|
|
15158
15174
|
return e.slice(0, 10).map((e) => {
|
|
15159
15175
|
let t = e, n = {
|
|
15160
15176
|
path: (Array.isArray(t.path) ? t.path.join(".") : String(t.path ?? "")) || "(root)",
|
|
@@ -15163,16 +15179,16 @@ function B_(e) {
|
|
|
15163
15179
|
return t.expected !== void 0 && (n.expected = t.expected), t.received !== void 0 && (n.received = t.received), t.code !== void 0 && (n.code = t.code), n;
|
|
15164
15180
|
});
|
|
15165
15181
|
}
|
|
15166
|
-
function
|
|
15182
|
+
function H_(e, t) {
|
|
15167
15183
|
return $({
|
|
15168
15184
|
code: "SCHEMA_INVALID",
|
|
15169
15185
|
path: e,
|
|
15170
15186
|
message: `值不符合 "${e}" 的 schema(${t.length} 处问题)`,
|
|
15171
15187
|
hint: `按 describe_window_prop("${e}") 查看格式,修正后重试;改大对象优先用 edit_window_prop 增量 patch(只发改动部分)`,
|
|
15172
|
-
details:
|
|
15188
|
+
details: V_(t)
|
|
15173
15189
|
});
|
|
15174
15190
|
}
|
|
15175
|
-
function
|
|
15191
|
+
function U_(e, t, n) {
|
|
15176
15192
|
let r = n?.message || String(n);
|
|
15177
15193
|
return $({
|
|
15178
15194
|
code: "JSON_PARSE",
|
|
@@ -15181,18 +15197,18 @@ function H_(e, t, n) {
|
|
|
15181
15197
|
hint: `检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${t.slice(0, 80)}`
|
|
15182
15198
|
});
|
|
15183
15199
|
}
|
|
15184
|
-
var
|
|
15185
|
-
function
|
|
15200
|
+
var W_ = .9;
|
|
15201
|
+
function G_(e, t = {}) {
|
|
15186
15202
|
let n = Object.create(null);
|
|
15187
|
-
if (e) for (let [t, r] of Object.entries(e)) n[
|
|
15203
|
+
if (e) for (let [t, r] of Object.entries(e)) n[J_(t)] = {
|
|
15188
15204
|
content: r,
|
|
15189
|
-
updatedAt:
|
|
15205
|
+
updatedAt: X_()
|
|
15190
15206
|
};
|
|
15191
15207
|
let { persist: r } = t, i = t.maxBytes ?? 4194304;
|
|
15192
15208
|
function a() {
|
|
15193
|
-
if (
|
|
15194
|
-
let e = i *
|
|
15195
|
-
for (let [r] of t) if (delete n[r],
|
|
15209
|
+
if (q_(n) <= i) return;
|
|
15210
|
+
let e = i * W_, t = Object.entries(n).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
15211
|
+
for (let [r] of t) if (delete n[r], q_(n) <= e) break;
|
|
15196
15212
|
}
|
|
15197
15213
|
let o = null;
|
|
15198
15214
|
function s() {
|
|
@@ -15217,7 +15233,7 @@ function W_(e, t = {}) {
|
|
|
15217
15233
|
}
|
|
15218
15234
|
}) };
|
|
15219
15235
|
return r && (l.hydrate = (e) => {
|
|
15220
|
-
for (let [t, r] of Object.entries(e)) n[
|
|
15236
|
+
for (let [t, r] of Object.entries(e)) n[J_(t)] = r;
|
|
15221
15237
|
a();
|
|
15222
15238
|
}, l.flush = () => {
|
|
15223
15239
|
o &&= (clearTimeout(o), null), s();
|
|
@@ -15226,17 +15242,17 @@ function W_(e, t = {}) {
|
|
|
15226
15242
|
c();
|
|
15227
15243
|
}), l;
|
|
15228
15244
|
}
|
|
15229
|
-
var
|
|
15230
|
-
function
|
|
15231
|
-
|
|
15245
|
+
var K_ = null;
|
|
15246
|
+
function q_(e) {
|
|
15247
|
+
K_ ||= new TextEncoder();
|
|
15232
15248
|
let t = 0;
|
|
15233
|
-
for (let n of Object.values(e)) t +=
|
|
15249
|
+
for (let n of Object.values(e)) t += K_.encode(n.content).length;
|
|
15234
15250
|
return t;
|
|
15235
15251
|
}
|
|
15236
|
-
function
|
|
15252
|
+
function J_(e) {
|
|
15237
15253
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
15238
15254
|
}
|
|
15239
|
-
function
|
|
15255
|
+
function Y_(e) {
|
|
15240
15256
|
let t = "";
|
|
15241
15257
|
for (let n = 0; n < e.length; n++) {
|
|
15242
15258
|
let r = e[n];
|
|
@@ -15244,13 +15260,13 @@ function J_(e) {
|
|
|
15244
15260
|
}
|
|
15245
15261
|
return RegExp("^" + t + "$");
|
|
15246
15262
|
}
|
|
15247
|
-
function
|
|
15263
|
+
function X_() {
|
|
15248
15264
|
return Date.now();
|
|
15249
15265
|
}
|
|
15250
|
-
function
|
|
15266
|
+
function Z_(e) {
|
|
15251
15267
|
return [
|
|
15252
15268
|
n(async ({ path: t, offset: n, limit: r }) => {
|
|
15253
|
-
let i = e.files[
|
|
15269
|
+
let i = e.files[J_(t)];
|
|
15254
15270
|
if (!i) return $({
|
|
15255
15271
|
code: "NOT_FOUND",
|
|
15256
15272
|
path: t,
|
|
@@ -15268,9 +15284,9 @@ function X_(e) {
|
|
|
15268
15284
|
limit: t.number().int().min(1).default(2e3).describe("读取行数")
|
|
15269
15285
|
})
|
|
15270
15286
|
}),
|
|
15271
|
-
n(async ({ path: t, content: n }) => (e.files[
|
|
15287
|
+
n(async ({ path: t, content: n }) => (e.files[J_(t)] = {
|
|
15272
15288
|
content: n,
|
|
15273
|
-
updatedAt:
|
|
15289
|
+
updatedAt: X_()
|
|
15274
15290
|
}, `已写入 ${t}(${n.length} 字符)`), {
|
|
15275
15291
|
name: "vfs_write",
|
|
15276
15292
|
description: "写入/覆盖虚拟工作区文件,作为中间工作记忆。",
|
|
@@ -15280,7 +15296,7 @@ function X_(e) {
|
|
|
15280
15296
|
})
|
|
15281
15297
|
}),
|
|
15282
15298
|
n(async ({ path: t, oldString: n, newString: r }) => {
|
|
15283
|
-
let i =
|
|
15299
|
+
let i = J_(t), a = e.files[i];
|
|
15284
15300
|
if (!a) return $({
|
|
15285
15301
|
code: "NOT_FOUND",
|
|
15286
15302
|
path: t,
|
|
@@ -15310,7 +15326,7 @@ function X_(e) {
|
|
|
15310
15326
|
}
|
|
15311
15327
|
return e.files[i] = {
|
|
15312
15328
|
content: a.content.replace(n, r),
|
|
15313
|
-
updatedAt:
|
|
15329
|
+
updatedAt: X_()
|
|
15314
15330
|
}, `已替换 ${t} 中 1 处。`;
|
|
15315
15331
|
}, {
|
|
15316
15332
|
name: "vfs_edit",
|
|
@@ -15332,7 +15348,7 @@ function X_(e) {
|
|
|
15332
15348
|
n(async ({ pattern: t }) => {
|
|
15333
15349
|
let n;
|
|
15334
15350
|
try {
|
|
15335
|
-
n =
|
|
15351
|
+
n = Y_(t);
|
|
15336
15352
|
} catch (e) {
|
|
15337
15353
|
return $({
|
|
15338
15354
|
code: "GLOB_INVALID",
|
|
@@ -15361,7 +15377,7 @@ function X_(e) {
|
|
|
15361
15377
|
details: { pattern: t }
|
|
15362
15378
|
});
|
|
15363
15379
|
}
|
|
15364
|
-
let i = n ? [
|
|
15380
|
+
let i = n ? [J_(n)] : Object.keys(e.files), a = [];
|
|
15365
15381
|
for (let t of i) {
|
|
15366
15382
|
let n = e.files[t];
|
|
15367
15383
|
n && n.content.split("\n").forEach((e, n) => {
|
|
@@ -15379,17 +15395,17 @@ function X_(e) {
|
|
|
15379
15395
|
})
|
|
15380
15396
|
];
|
|
15381
15397
|
}
|
|
15382
|
-
function
|
|
15398
|
+
function Q_(e) {
|
|
15383
15399
|
return {
|
|
15384
15400
|
name: "vfs",
|
|
15385
|
-
tools:
|
|
15401
|
+
tools: Z_(e),
|
|
15386
15402
|
beforeAgent: () => ({ files: e.files })
|
|
15387
15403
|
};
|
|
15388
15404
|
}
|
|
15389
15405
|
//#endregion
|
|
15390
15406
|
//#region src/core/tools/windowQuery.ts
|
|
15391
|
-
var
|
|
15392
|
-
function
|
|
15407
|
+
var $_ = /[\w$-]/;
|
|
15408
|
+
function ev(e) {
|
|
15393
15409
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
15394
15410
|
for (; r < n.length;) {
|
|
15395
15411
|
let e = n[r];
|
|
@@ -15400,7 +15416,7 @@ function $_(e) {
|
|
|
15400
15416
|
continue;
|
|
15401
15417
|
}
|
|
15402
15418
|
let e = "";
|
|
15403
|
-
for (; r < n.length &&
|
|
15419
|
+
for (; r < n.length && $_.test(n[r]);) e += n[r++];
|
|
15404
15420
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
15405
15421
|
t.push({
|
|
15406
15422
|
type: "descendKey",
|
|
@@ -15413,7 +15429,7 @@ function $_(e) {
|
|
|
15413
15429
|
continue;
|
|
15414
15430
|
}
|
|
15415
15431
|
let e = "";
|
|
15416
|
-
for (; r < n.length &&
|
|
15432
|
+
for (; r < n.length && $_.test(n[r]);) e += n[r++];
|
|
15417
15433
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
15418
15434
|
t.push({
|
|
15419
15435
|
type: "key",
|
|
@@ -15469,7 +15485,7 @@ function $_(e) {
|
|
|
15469
15485
|
}
|
|
15470
15486
|
return t;
|
|
15471
15487
|
}
|
|
15472
|
-
function
|
|
15488
|
+
function tv(e) {
|
|
15473
15489
|
let t = [], n = 0, r = e.trim();
|
|
15474
15490
|
for (; n < r.length;) {
|
|
15475
15491
|
let e = r[n];
|
|
@@ -15514,7 +15530,7 @@ function ev(e) {
|
|
|
15514
15530
|
}
|
|
15515
15531
|
return t;
|
|
15516
15532
|
}
|
|
15517
|
-
var
|
|
15533
|
+
var nv = class {
|
|
15518
15534
|
toks;
|
|
15519
15535
|
item;
|
|
15520
15536
|
pos = 0;
|
|
@@ -15550,12 +15566,12 @@ var tv = class {
|
|
|
15550
15566
|
return this.next(), e;
|
|
15551
15567
|
}
|
|
15552
15568
|
let e = this.operand(), t = this.peek();
|
|
15553
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
15569
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), av(t, e, this.operand())) : rv(e);
|
|
15554
15570
|
}
|
|
15555
15571
|
operand() {
|
|
15556
15572
|
let e = this.next();
|
|
15557
15573
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
15558
|
-
if (e.startsWith("@")) return
|
|
15574
|
+
if (e.startsWith("@")) return iv(e, this.item);
|
|
15559
15575
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
15560
15576
|
if (e === "true") return !0;
|
|
15561
15577
|
if (e === "false") return !1;
|
|
@@ -15565,10 +15581,10 @@ var tv = class {
|
|
|
15565
15581
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
15566
15582
|
}
|
|
15567
15583
|
};
|
|
15568
|
-
function
|
|
15584
|
+
function rv(e) {
|
|
15569
15585
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
15570
15586
|
}
|
|
15571
|
-
function
|
|
15587
|
+
function iv(e, t) {
|
|
15572
15588
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
15573
15589
|
for (let e of n) {
|
|
15574
15590
|
if (typeof r != "object" || !r) return;
|
|
@@ -15576,7 +15592,7 @@ function rv(e, t) {
|
|
|
15576
15592
|
}
|
|
15577
15593
|
return r;
|
|
15578
15594
|
}
|
|
15579
|
-
function
|
|
15595
|
+
function av(e, t, n) {
|
|
15580
15596
|
switch (e) {
|
|
15581
15597
|
case "==": return t === n;
|
|
15582
15598
|
case "!=": return t !== n;
|
|
@@ -15587,47 +15603,47 @@ function iv(e, t, n) {
|
|
|
15587
15603
|
default: return !1;
|
|
15588
15604
|
}
|
|
15589
15605
|
}
|
|
15590
|
-
function av(e, t) {
|
|
15591
|
-
return new tv(ev(e), t).parse();
|
|
15592
|
-
}
|
|
15593
15606
|
function ov(e, t) {
|
|
15594
|
-
return
|
|
15607
|
+
return new nv(tv(e), t).parse();
|
|
15595
15608
|
}
|
|
15596
15609
|
function sv(e, t) {
|
|
15610
|
+
return e ? `${e}.${t}` : String(t);
|
|
15611
|
+
}
|
|
15612
|
+
function cv(e, t) {
|
|
15597
15613
|
let n = [{
|
|
15598
15614
|
path: "",
|
|
15599
15615
|
value: e
|
|
15600
15616
|
}];
|
|
15601
|
-
for (let e of
|
|
15617
|
+
for (let e of ev(t)) {
|
|
15602
15618
|
let t = [];
|
|
15603
15619
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
15604
|
-
path:
|
|
15620
|
+
path: sv(r.path, e.key),
|
|
15605
15621
|
value: r.value[e.key]
|
|
15606
15622
|
});
|
|
15607
15623
|
else if (e.type === "index") {
|
|
15608
15624
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
15609
15625
|
let n = r.value[e.index];
|
|
15610
15626
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
15611
|
-
path:
|
|
15627
|
+
path: sv(r.path, e.index),
|
|
15612
15628
|
value: n,
|
|
15613
15629
|
index: e.index
|
|
15614
15630
|
});
|
|
15615
15631
|
}
|
|
15616
15632
|
} else if (e.type === "wildcard") {
|
|
15617
15633
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
15618
|
-
path:
|
|
15634
|
+
path: sv(e.path, r),
|
|
15619
15635
|
value: n,
|
|
15620
15636
|
index: r
|
|
15621
15637
|
}));
|
|
15622
15638
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
15623
|
-
path:
|
|
15639
|
+
path: sv(e.path, n),
|
|
15624
15640
|
value: e.value[n]
|
|
15625
15641
|
});
|
|
15626
15642
|
} else if (e.type === "descendKey") {
|
|
15627
15643
|
let r = e.key, i = (e) => {
|
|
15628
15644
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
15629
15645
|
let a = {
|
|
15630
|
-
path:
|
|
15646
|
+
path: sv(e.path, n),
|
|
15631
15647
|
value: e.value[n]
|
|
15632
15648
|
};
|
|
15633
15649
|
n === r && t.push(a), i(a);
|
|
@@ -15638,7 +15654,7 @@ function sv(e, t) {
|
|
|
15638
15654
|
let e = (n) => {
|
|
15639
15655
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
15640
15656
|
let i = {
|
|
15641
|
-
path:
|
|
15657
|
+
path: sv(n.path, r),
|
|
15642
15658
|
value: n.value[r]
|
|
15643
15659
|
};
|
|
15644
15660
|
t.push(i), e(i);
|
|
@@ -15647,16 +15663,16 @@ function sv(e, t) {
|
|
|
15647
15663
|
for (let t of n) e(t);
|
|
15648
15664
|
} else if (e.type === "filter") {
|
|
15649
15665
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
15650
|
-
|
|
15651
|
-
path:
|
|
15666
|
+
ov(e.filter, n) && t.push({
|
|
15667
|
+
path: sv(r.path, i),
|
|
15652
15668
|
value: n,
|
|
15653
15669
|
index: i
|
|
15654
15670
|
});
|
|
15655
15671
|
});
|
|
15656
15672
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
15657
15673
|
let i = r.value[n];
|
|
15658
|
-
|
|
15659
|
-
path:
|
|
15674
|
+
ov(e.filter, i) && t.push({
|
|
15675
|
+
path: sv(r.path, n),
|
|
15660
15676
|
value: i
|
|
15661
15677
|
});
|
|
15662
15678
|
}
|
|
@@ -15665,7 +15681,7 @@ function sv(e, t) {
|
|
|
15665
15681
|
}
|
|
15666
15682
|
return n;
|
|
15667
15683
|
}
|
|
15668
|
-
function
|
|
15684
|
+
function lv(e, t) {
|
|
15669
15685
|
let n = e.length, r = t.length;
|
|
15670
15686
|
if (!n) return r;
|
|
15671
15687
|
if (!r) return n;
|
|
@@ -15681,7 +15697,7 @@ function cv(e, t) {
|
|
|
15681
15697
|
}
|
|
15682
15698
|
return i[r];
|
|
15683
15699
|
}
|
|
15684
|
-
function
|
|
15700
|
+
function uv(e, t, n = {}) {
|
|
15685
15701
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
15686
15702
|
if (r === "regex") try {
|
|
15687
15703
|
s = new RegExp(t, "i");
|
|
@@ -15691,11 +15707,11 @@ function lv(e, t, n = {}) {
|
|
|
15691
15707
|
let c = (e, l, u) => {
|
|
15692
15708
|
if (o.length >= i || e == null) return;
|
|
15693
15709
|
if (typeof e == "object") {
|
|
15694
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
15695
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
15710
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, sv(l, t), String(t)));
|
|
15711
|
+
else for (let t of Object.keys(e)) c(e[t], sv(l, t), t);
|
|
15696
15712
|
return;
|
|
15697
15713
|
}
|
|
15698
|
-
let d = String(e), f =
|
|
15714
|
+
let d = String(e), f = dv(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15699
15715
|
if (f) {
|
|
15700
15716
|
o.push({
|
|
15701
15717
|
path: l,
|
|
@@ -15706,7 +15722,7 @@ function lv(e, t, n = {}) {
|
|
|
15706
15722
|
return;
|
|
15707
15723
|
}
|
|
15708
15724
|
if (a && u) {
|
|
15709
|
-
let e =
|
|
15725
|
+
let e = dv(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15710
15726
|
e && o.push({
|
|
15711
15727
|
path: l,
|
|
15712
15728
|
key: u,
|
|
@@ -15717,18 +15733,18 @@ function lv(e, t, n = {}) {
|
|
|
15717
15733
|
};
|
|
15718
15734
|
return c(e, ""), o;
|
|
15719
15735
|
}
|
|
15720
|
-
function
|
|
15736
|
+
function dv(e, t, n, r, i) {
|
|
15721
15737
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
15722
15738
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
15723
15739
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
15724
15740
|
if (n === "fuzzy") {
|
|
15725
15741
|
if (a.includes(o)) return 2;
|
|
15726
|
-
let e =
|
|
15742
|
+
let e = lv(a, o);
|
|
15727
15743
|
return e <= r ? r - e + 1 : null;
|
|
15728
15744
|
}
|
|
15729
15745
|
return null;
|
|
15730
15746
|
}
|
|
15731
|
-
var
|
|
15747
|
+
var fv = [
|
|
15732
15748
|
"self.fetch = () => { throw new Error('fetch 已被沙箱禁用') }",
|
|
15733
15749
|
"self.XMLHttpRequest = function(){ throw new Error('XMLHttpRequest 已被沙箱禁用') }",
|
|
15734
15750
|
"self.importScripts = () => { throw new Error('importScripts 已被沙箱禁用') }",
|
|
@@ -15741,7 +15757,7 @@ var dv = [
|
|
|
15741
15757
|
"try { self.BroadcastChannel = undefined } catch {}",
|
|
15742
15758
|
"if (self.navigator && self.navigator.sendBeacon) self.navigator.sendBeacon = () => { throw new Error('sendBeacon 已被沙箱禁用') }"
|
|
15743
15759
|
].join("\n");
|
|
15744
|
-
function
|
|
15760
|
+
function pv(e, t, n = 3e3) {
|
|
15745
15761
|
return new Promise((r) => {
|
|
15746
15762
|
let i = Date.now(), a = !1, o = (e) => {
|
|
15747
15763
|
if (!a) {
|
|
@@ -15754,7 +15770,7 @@ function fv(e, t, n = 3e3) {
|
|
|
15754
15770
|
elapsedMs: Date.now() - i
|
|
15755
15771
|
});
|
|
15756
15772
|
}
|
|
15757
|
-
}, s =
|
|
15773
|
+
}, s = fv + "\nself.onmessage = async (e) => {\n try {\n const fn = new Function(\"data\", e.data.script);\n let result = fn(e.data.data);\n if (result && typeof result.then === \"function\") result = await result;\n self.postMessage({ ok: true, result });\n } catch (err) {\n self.postMessage({ ok: false, error: String((err && err.message) || err) });\n }\n};", c, l;
|
|
15758
15774
|
try {
|
|
15759
15775
|
let e = new Blob([s], { type: "application/javascript" });
|
|
15760
15776
|
c = URL.createObjectURL(e), l = new Worker(c);
|
|
@@ -15789,19 +15805,19 @@ function fv(e, t, n = 3e3) {
|
|
|
15789
15805
|
}
|
|
15790
15806
|
//#endregion
|
|
15791
15807
|
//#region src/core/tools/windowOps.ts
|
|
15792
|
-
var
|
|
15808
|
+
var mv = /* @__PURE__ */ new Set([
|
|
15793
15809
|
"__proto__",
|
|
15794
15810
|
"constructor",
|
|
15795
15811
|
"prototype"
|
|
15796
15812
|
]);
|
|
15797
|
-
function
|
|
15798
|
-
return e.split(".").some((e) =>
|
|
15799
|
-
}
|
|
15800
|
-
function hv(e, t) {
|
|
15801
|
-
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) pv.has(n) || (e[n] = t[n]);
|
|
15813
|
+
function hv(e) {
|
|
15814
|
+
return e.split(".").some((e) => mv.has(e));
|
|
15802
15815
|
}
|
|
15803
15816
|
function gv(e, t) {
|
|
15804
|
-
if (
|
|
15817
|
+
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) mv.has(n) || (e[n] = t[n]);
|
|
15818
|
+
}
|
|
15819
|
+
function _v(e, t) {
|
|
15820
|
+
if (hv(t)) return;
|
|
15805
15821
|
let n = t.split("."), r = e;
|
|
15806
15822
|
for (let e of n) {
|
|
15807
15823
|
if (r == null) return;
|
|
@@ -15809,8 +15825,8 @@ function gv(e, t) {
|
|
|
15809
15825
|
}
|
|
15810
15826
|
return r;
|
|
15811
15827
|
}
|
|
15812
|
-
function
|
|
15813
|
-
if (
|
|
15828
|
+
function vv(e, t, n) {
|
|
15829
|
+
if (hv(t)) return;
|
|
15814
15830
|
let r = t.split("."), i = e;
|
|
15815
15831
|
for (let e = 0; e < r.length - 1; e++) {
|
|
15816
15832
|
let t = r[e];
|
|
@@ -15818,8 +15834,8 @@ function _v(e, t, n) {
|
|
|
15818
15834
|
}
|
|
15819
15835
|
i[r[r.length - 1]] = n;
|
|
15820
15836
|
}
|
|
15821
|
-
function
|
|
15822
|
-
if (
|
|
15837
|
+
function yv(e, t) {
|
|
15838
|
+
if (hv(t)) return !1;
|
|
15823
15839
|
let n = t.split("."), r = e;
|
|
15824
15840
|
for (let e = 0; e < n.length - 1; e++) {
|
|
15825
15841
|
if (r == null) return !1;
|
|
@@ -15828,10 +15844,10 @@ function vv(e, t) {
|
|
|
15828
15844
|
let i = n[n.length - 1];
|
|
15829
15845
|
return r == null || !(i in r) ? !1 : (delete r[i], !0);
|
|
15830
15846
|
}
|
|
15831
|
-
function
|
|
15847
|
+
function bv(e) {
|
|
15832
15848
|
return e === void 0 ? void 0 : JSON.parse(JSON.stringify(e));
|
|
15833
15849
|
}
|
|
15834
|
-
function
|
|
15850
|
+
function xv(e, t = Infinity) {
|
|
15835
15851
|
let n = /* @__PURE__ */ new WeakSet(), r;
|
|
15836
15852
|
try {
|
|
15837
15853
|
r = JSON.stringify(e, (e, t) => {
|
|
@@ -15850,35 +15866,35 @@ function bv(e, t = Infinity) {
|
|
|
15850
15866
|
}
|
|
15851
15867
|
return r.length > t && (r = r.slice(0, t) + `\n…[已截断,原长度 ${r.length}]`), r;
|
|
15852
15868
|
}
|
|
15853
|
-
function
|
|
15854
|
-
let t =
|
|
15869
|
+
function Sv(e) {
|
|
15870
|
+
let t = xv(e), n = 5381;
|
|
15855
15871
|
for (let e = 0; e < t.length; e++) n = (n << 5) + n + t.charCodeAt(e) >>> 0;
|
|
15856
15872
|
return n.toString(36);
|
|
15857
15873
|
}
|
|
15858
|
-
function
|
|
15859
|
-
if (t === "set") return n ? (
|
|
15860
|
-
if (t === "remove") return n ? (
|
|
15874
|
+
function Cv(e, t, n, r) {
|
|
15875
|
+
if (t === "set") return n ? (vv(e, n, r), null) : "set 操作需要 jsonPath(整体替换请用 set_window_prop)";
|
|
15876
|
+
if (t === "remove") return n ? (yv(e, n), null) : "remove 操作需要 jsonPath";
|
|
15861
15877
|
if (t === "merge") {
|
|
15862
|
-
let t = n ?
|
|
15863
|
-
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (
|
|
15878
|
+
let t = n ? _v(e, n) : e;
|
|
15879
|
+
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (gv(t, r), null);
|
|
15864
15880
|
}
|
|
15865
|
-
let i = n ?
|
|
15881
|
+
let i = n ? _v(e, n) : e;
|
|
15866
15882
|
return Array.isArray(i) ? (Array.isArray(r) ? i.push(...r) : i.push(r), null) : `append 目标${n ? `(${n})` : "(根)"}不是数组`;
|
|
15867
15883
|
}
|
|
15868
|
-
function
|
|
15869
|
-
if (t === "set")
|
|
15870
|
-
else if (t === "remove")
|
|
15871
|
-
else if (t === "merge")
|
|
15884
|
+
function wv(e, t, n, r) {
|
|
15885
|
+
if (t === "set") vv(window, `${e}.${n}`, r);
|
|
15886
|
+
else if (t === "remove") yv(window, `${e}.${n}`);
|
|
15887
|
+
else if (t === "merge") gv(n ? _v(window, `${e}.${n}`) : _v(window, e), r);
|
|
15872
15888
|
else {
|
|
15873
|
-
let t = n ?
|
|
15889
|
+
let t = n ? _v(window, `${e}.${n}`) : _v(window, e);
|
|
15874
15890
|
Array.isArray(r) ? t.push(...r) : t.push(r);
|
|
15875
15891
|
}
|
|
15876
15892
|
}
|
|
15877
|
-
function wv(e, t) {
|
|
15878
|
-
let n = gv(window, e);
|
|
15879
|
-
typeof n == "object" && n ? Tv(n, t) : _v(window, e, t);
|
|
15880
|
-
}
|
|
15881
15893
|
function Tv(e, t) {
|
|
15894
|
+
let n = _v(window, e);
|
|
15895
|
+
typeof n == "object" && n ? Ev(n, t) : vv(window, e, t);
|
|
15896
|
+
}
|
|
15897
|
+
function Ev(e, t) {
|
|
15882
15898
|
if (Array.isArray(e)) {
|
|
15883
15899
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
15884
15900
|
return;
|
|
@@ -15887,7 +15903,7 @@ function Tv(e, t) {
|
|
|
15887
15903
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
15888
15904
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
15889
15905
|
}
|
|
15890
|
-
function
|
|
15906
|
+
function Dv(e, r = {}) {
|
|
15891
15907
|
let i = /* @__PURE__ */ new Map();
|
|
15892
15908
|
for (let t of e) i.set(t.path, t);
|
|
15893
15909
|
let a = /* @__PURE__ */ new Map(), o = r.maxSnapshots ?? 20, s = {
|
|
@@ -15914,7 +15930,7 @@ function Ev(e, r = {}) {
|
|
|
15914
15930
|
return r.allowRawRead ? !0 : [...i.keys()].some((t) => e === t || e.startsWith(t + ".") || u && t.startsWith(e + "."));
|
|
15915
15931
|
}
|
|
15916
15932
|
function f(e, t, n) {
|
|
15917
|
-
let r =
|
|
15933
|
+
let r = bv(_v(window, e)), i = a.get(e) || [], s = i.length ? i[i.length - 1].id + 1 : 1;
|
|
15918
15934
|
for (i.push({
|
|
15919
15935
|
id: s,
|
|
15920
15936
|
ts: Date.now(),
|
|
@@ -15926,13 +15942,13 @@ function Ev(e, r = {}) {
|
|
|
15926
15942
|
}
|
|
15927
15943
|
async function p(e, t, n, i) {
|
|
15928
15944
|
if (!n || n === "") return null;
|
|
15929
|
-
let o =
|
|
15945
|
+
let o = _v(window, e), s = Sv(o);
|
|
15930
15946
|
if (s === n) return null;
|
|
15931
15947
|
if (!r.onConflict) return $({
|
|
15932
15948
|
code: "VERSION_CONFLICT",
|
|
15933
15949
|
path: e,
|
|
15934
15950
|
message: `乐观锁冲突:expectedHash=${n} 但当前 hash=${s}。属性 "${e}" 在你 get 之后已被修改(外部代码/其他 agent/用户手动改)。`,
|
|
15935
|
-
hint: `重新 get_window_prop("${e}") 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${
|
|
15951
|
+
hint: `重新 get_window_prop("${e}") 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${xv(o, 400)}`
|
|
15936
15952
|
});
|
|
15937
15953
|
let c = await r.onConflict({
|
|
15938
15954
|
path: e,
|
|
@@ -15943,14 +15959,14 @@ function Ev(e, r = {}) {
|
|
|
15943
15959
|
expectedHash: n,
|
|
15944
15960
|
snapshotId: 0
|
|
15945
15961
|
});
|
|
15946
|
-
if (c.action === "keep_external") return `已保留外部修改(未写入)。当前值:${
|
|
15962
|
+
if (c.action === "keep_external") return `已保留外部修改(未写入)。当前值:${xv(o, 400)} (hash=${s})。请重新 get_window_prop("${e}") 拿最新值与 hash 再改。`;
|
|
15947
15963
|
if (c.action === "restore") {
|
|
15948
15964
|
let t = a.get(e) || [];
|
|
15949
|
-
if (!t.length) return `无历史快照可回退(本次为首次操作)。当前值:${
|
|
15965
|
+
if (!t.length) return `无历史快照可回退(本次为首次操作)。当前值:${xv(o, 400)} (hash=${s})。请重新 get 再改或选「强制覆盖」。`;
|
|
15950
15966
|
let n = t[t.length - 1];
|
|
15951
|
-
|
|
15952
|
-
let r =
|
|
15953
|
-
return `已回退 ${e} 到历史快照 #${n.id}[${n.op}]。当前值:${
|
|
15967
|
+
Tv(e, bv(n.value));
|
|
15968
|
+
let r = _v(window, e);
|
|
15969
|
+
return `已回退 ${e} 到历史快照 #${n.id}[${n.op}]。当前值:${xv(r, 400)} (hash=${Sv(r)})。请基于回退后的值重写或停止。`;
|
|
15954
15970
|
}
|
|
15955
15971
|
return null;
|
|
15956
15972
|
}
|
|
@@ -15985,8 +16001,8 @@ function Ev(e, r = {}) {
|
|
|
15985
16001
|
message: `属性 "${e}" 不可读取(未注册,且非已注册路径的后代)`,
|
|
15986
16002
|
hint: "用 list_window_props 查看可操作字段;字段白名单读模式下未注册的祖先(整体大 JSON)不暴露,需读其声明子路径"
|
|
15987
16003
|
});
|
|
15988
|
-
let t =
|
|
15989
|
-
return t === void 0 ? `${e} = (undefined)` : `${e} = ${
|
|
16004
|
+
let t = _v(window, e);
|
|
16005
|
+
return t === void 0 ? `${e} = (undefined)` : `${e} = ${xv(t)} (hash=${Sv(t)})`;
|
|
15990
16006
|
}, {
|
|
15991
16007
|
name: "get_window_prop",
|
|
15992
16008
|
description: "读取一个已注册 window 属性的当前值(安全序列化:函数/DOM/循环引用做摘要;大结果由系统自动外存,提示用 vfs_read 回读)。返回含 hash(乐观锁):改属性前先 get 拿 hash,写入时(set/edit/delete)传 expectedHash 回传,系统对比当前 hash 防\"基于过期值覆盖\"(外部代码/其他 agent/用户手动改过会 CONFLICT,需重新 get 再改)。字段白名单读模式(默认)下仅可读注册 path 自身/后代;未注册祖先(整体大 JSON)不可读,避免大 JSON 拉进上下文。",
|
|
@@ -16005,18 +16021,18 @@ function Ev(e, r = {}) {
|
|
|
16005
16021
|
try {
|
|
16006
16022
|
o = JSON.parse(t);
|
|
16007
16023
|
} catch (n) {
|
|
16008
|
-
return
|
|
16024
|
+
return U_(e, t, n);
|
|
16009
16025
|
}
|
|
16010
16026
|
let s = r.schema.safeParse(o);
|
|
16011
|
-
if (!s.success) return
|
|
16027
|
+
if (!s.success) return H_(e, s.error.issues);
|
|
16012
16028
|
f(e, "set");
|
|
16013
|
-
let u =
|
|
16014
|
-
return typeof u == "object" && u && s.data !== null && typeof s.data == "object" ?
|
|
16029
|
+
let u = _v(window, e);
|
|
16030
|
+
return typeof u == "object" && u && s.data !== null && typeof s.data == "object" ? Ev(u, s.data) : vv(window, e, s.data), c({
|
|
16015
16031
|
op: "set",
|
|
16016
16032
|
path: e,
|
|
16017
16033
|
value: s.data,
|
|
16018
16034
|
timestamp: Date.now()
|
|
16019
|
-
}), `已设置 ${e} = ${
|
|
16035
|
+
}), `已设置 ${e} = ${xv(s.data, 600)} (新 hash=${Sv(_v(window, e))})${l()}`;
|
|
16020
16036
|
}, {
|
|
16021
16037
|
name: "set_window_prop",
|
|
16022
16038
|
description: "设置一个已注册 window 属性的值(整体替换)。仅能操作注册表内声明的属性;value 为 JSON 字符串,需通过该属性声明的 schema 校验。校验失败会返回错误而非写入。expectedHash(可选):改前 get_window_prop 返回的 hash,传入则启用乐观锁——若属性已被改过(外部代码/其他 agent/用户手动)则返回 VERSION_CONFLICT 不写入,需重新 get 再改,防\"基于过期值覆盖\"。大对象/数组强烈建议改用 edit_window_prop 增量 patch。",
|
|
@@ -16034,13 +16050,13 @@ function Ev(e, r = {}) {
|
|
|
16034
16050
|
hint: "用 list_window_props 查看可用属性"
|
|
16035
16051
|
});
|
|
16036
16052
|
let s = n || "";
|
|
16037
|
-
if (
|
|
16053
|
+
if (hv(s)) return $({
|
|
16038
16054
|
code: "PATH_UNSAFE",
|
|
16039
16055
|
path: e,
|
|
16040
16056
|
message: `jsonPath "${s}" 含非法段(__proto__/constructor/prototype)`,
|
|
16041
16057
|
hint: "使用正常的属性路径,如 components.0.text(数组索引用数字)"
|
|
16042
16058
|
});
|
|
16043
|
-
let u =
|
|
16059
|
+
let u = _v(window, e), d = await p(e, "edit", a);
|
|
16044
16060
|
if (d !== null) return d;
|
|
16045
16061
|
if (typeof u != "object" || !u) return $({
|
|
16046
16062
|
code: "NOT_OBJECT",
|
|
@@ -16059,10 +16075,10 @@ function Ev(e, r = {}) {
|
|
|
16059
16075
|
try {
|
|
16060
16076
|
m = JSON.parse(r);
|
|
16061
16077
|
} catch (t) {
|
|
16062
|
-
return
|
|
16078
|
+
return U_(e, r, t);
|
|
16063
16079
|
}
|
|
16064
16080
|
}
|
|
16065
|
-
let h =
|
|
16081
|
+
let h = bv(u), g = Cv(h, t, s, m);
|
|
16066
16082
|
if (g) return $({
|
|
16067
16083
|
code: "PATCH_FAILED",
|
|
16068
16084
|
path: e,
|
|
@@ -16070,13 +16086,13 @@ function Ev(e, r = {}) {
|
|
|
16070
16086
|
hint: "检查 op 与目标类型:merge 需目标为对象,append 需目标为数组;jsonPath 指向需存在"
|
|
16071
16087
|
});
|
|
16072
16088
|
let _ = o.schema.safeParse(h);
|
|
16073
|
-
return _.success ? (f(e, "edit"),
|
|
16089
|
+
return _.success ? (f(e, "edit"), wv(e, t, s, m), c({
|
|
16074
16090
|
op: "edit",
|
|
16075
16091
|
path: e,
|
|
16076
16092
|
detail: `${t}${s ? "@" + s : ""}`,
|
|
16077
16093
|
value: m,
|
|
16078
16094
|
timestamp: Date.now()
|
|
16079
|
-
}), `已 edit ${e}(${t}${s ? " @ " + s : ""})。当前值:${
|
|
16095
|
+
}), `已 edit ${e}(${t}${s ? " @ " + s : ""})。当前值:${xv(_v(window, e), 600)} (新 hash=${Sv(_v(window, e))})${l()}`) : H_(e, _.error.issues);
|
|
16080
16096
|
}, {
|
|
16081
16097
|
name: "edit_window_prop",
|
|
16082
16098
|
description: "增量编辑一个已注册的「对象/数组」window 属性,只发改动的 patch,无需重传整个大对象。op:set(在 jsonPath 设值)、remove(删 jsonPath)、merge(把 value 合并到 jsonPath 指向的对象,默认根)、append(把 value 追加到 jsonPath 指向的数组,默认根)。jsonPath 为相对属性根的点号路径(数组索引用数字,如 components.0.text);value 为 JSON 字符串。整体仍经 schema 校验,失败不写入。expectedHash(可选):改前 get_window_prop 返回的 hash,传入启用乐观锁防\"基于过期值覆盖\"。",
|
|
@@ -16102,7 +16118,7 @@ function Ev(e, r = {}) {
|
|
|
16102
16118
|
let n = await p(e, "delete", t);
|
|
16103
16119
|
if (n !== null) return n;
|
|
16104
16120
|
f(e, "delete");
|
|
16105
|
-
let r =
|
|
16121
|
+
let r = yv(window, e);
|
|
16106
16122
|
return c({
|
|
16107
16123
|
op: "delete",
|
|
16108
16124
|
path: e,
|
|
@@ -16176,7 +16192,7 @@ function Ev(e, r = {}) {
|
|
|
16176
16192
|
hint: "用 list_window_snapshots 查看可用快照序号"
|
|
16177
16193
|
});
|
|
16178
16194
|
let s = n.schema.safeParse(o.value);
|
|
16179
|
-
return s.success ? (
|
|
16195
|
+
return s.success ? (Tv(e, bv(o.value)), c({
|
|
16180
16196
|
op: "restore",
|
|
16181
16197
|
path: e,
|
|
16182
16198
|
detail: `#${o.id}`,
|
|
@@ -16186,7 +16202,7 @@ function Ev(e, r = {}) {
|
|
|
16186
16202
|
path: e,
|
|
16187
16203
|
message: `快照 #${o.id} 的值不符合当前 schema,无法回退`,
|
|
16188
16204
|
hint: "schema 可能已变更;该快照已过期,选其他快照或重新设置",
|
|
16189
|
-
details:
|
|
16205
|
+
details: V_(s.error.issues)
|
|
16190
16206
|
});
|
|
16191
16207
|
}, {
|
|
16192
16208
|
name: "restore_window_snapshot",
|
|
@@ -16211,8 +16227,8 @@ function Ev(e, r = {}) {
|
|
|
16211
16227
|
})}`);
|
|
16212
16228
|
continue;
|
|
16213
16229
|
}
|
|
16214
|
-
let e =
|
|
16215
|
-
t.push(`- ${n} = ${e === void 0 ? "(undefined)" :
|
|
16230
|
+
let e = _v(window, n);
|
|
16231
|
+
t.push(`- ${n} = ${e === void 0 ? "(undefined)" : xv(e)}`);
|
|
16216
16232
|
}
|
|
16217
16233
|
return t.join("\n");
|
|
16218
16234
|
}, {
|
|
@@ -16233,7 +16249,7 @@ function Ev(e, r = {}) {
|
|
|
16233
16249
|
message: `属性 "${e}" 未注册`,
|
|
16234
16250
|
hint: "用 list_window_props 查看可用属性"
|
|
16235
16251
|
});
|
|
16236
|
-
let r =
|
|
16252
|
+
let r = _v(window, e);
|
|
16237
16253
|
if (typeof r != "object" || !r) return $({
|
|
16238
16254
|
code: "NOT_OBJECT",
|
|
16239
16255
|
path: e,
|
|
@@ -16242,7 +16258,7 @@ function Ev(e, r = {}) {
|
|
|
16242
16258
|
});
|
|
16243
16259
|
let a;
|
|
16244
16260
|
try {
|
|
16245
|
-
a =
|
|
16261
|
+
a = cv(r, t);
|
|
16246
16262
|
} catch (n) {
|
|
16247
16263
|
return $({
|
|
16248
16264
|
code: "JSONPATH_SYNTAX",
|
|
@@ -16252,7 +16268,7 @@ function Ev(e, r = {}) {
|
|
|
16252
16268
|
details: { expr: t }
|
|
16253
16269
|
});
|
|
16254
16270
|
}
|
|
16255
|
-
let o = n ?? 50, s = a.slice(0, o), c = s.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${
|
|
16271
|
+
let o = n ?? 50, s = a.slice(0, o), c = s.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${xv(e.value)}}`);
|
|
16256
16272
|
return `{"matched":${a.length},"returned":${s.length},"truncated":${a.length > o},"results":[${c.join(",")}]}`;
|
|
16257
16273
|
}, {
|
|
16258
16274
|
name: "query_window_prop",
|
|
@@ -16270,20 +16286,20 @@ function Ev(e, r = {}) {
|
|
|
16270
16286
|
message: `属性 "${e}" 未注册`,
|
|
16271
16287
|
hint: "用 list_window_props 查看可用属性"
|
|
16272
16288
|
});
|
|
16273
|
-
let s =
|
|
16289
|
+
let s = _v(window, e);
|
|
16274
16290
|
if (s == null) return $({
|
|
16275
16291
|
code: "EMPTY",
|
|
16276
16292
|
path: e,
|
|
16277
16293
|
message: `"${e}" 为空,无可搜索内容`
|
|
16278
16294
|
});
|
|
16279
16295
|
try {
|
|
16280
|
-
let e =
|
|
16296
|
+
let e = uv(s, t, {
|
|
16281
16297
|
mode: n,
|
|
16282
16298
|
fuzzyThreshold: r,
|
|
16283
16299
|
matchKey: a,
|
|
16284
16300
|
limit: o ?? 50
|
|
16285
16301
|
});
|
|
16286
|
-
return
|
|
16302
|
+
return xv({
|
|
16287
16303
|
matched: e.length,
|
|
16288
16304
|
results: e
|
|
16289
16305
|
});
|
|
@@ -16326,7 +16342,7 @@ function Ev(e, r = {}) {
|
|
|
16326
16342
|
message: `脚本过长(${t.length} 字符,上限 8000)`,
|
|
16327
16343
|
hint: "精简脚本;复杂逻辑可分步(先 query 探查再 transform 改),或拆成多次 eval"
|
|
16328
16344
|
});
|
|
16329
|
-
let a = await
|
|
16345
|
+
let a = await pv(bv(_v(window, e)), t, 3e3);
|
|
16330
16346
|
if (!a.ok) {
|
|
16331
16347
|
let n = /超时/.test(a.error || "");
|
|
16332
16348
|
return $({
|
|
@@ -16347,18 +16363,18 @@ function Ev(e, r = {}) {
|
|
|
16347
16363
|
path: e,
|
|
16348
16364
|
message: "脚本返回值校验失败,未写入(transform 模式要求返回该属性的完整新值且符合 schema)",
|
|
16349
16365
|
hint: `确认脚本 return 了完整新值(非部分);按 describe_window_prop("${e}") 查看格式`,
|
|
16350
|
-
details:
|
|
16366
|
+
details: V_(t.error.issues)
|
|
16351
16367
|
});
|
|
16352
16368
|
f(e, "edit", "eval_transform");
|
|
16353
|
-
let n =
|
|
16354
|
-
return typeof n == "object" && n && t.data !== null && typeof t.data == "object" ?
|
|
16369
|
+
let n = _v(window, e);
|
|
16370
|
+
return typeof n == "object" && n && t.data !== null && typeof t.data == "object" ? Ev(n, t.data) : vv(window, e, t.data), c({
|
|
16355
16371
|
op: "edit",
|
|
16356
16372
|
path: e,
|
|
16357
16373
|
detail: "eval_transform",
|
|
16358
16374
|
timestamp: Date.now()
|
|
16359
|
-
}), `已通过脚本 transform 更新 ${e}(耗时 ${a.elapsedMs}ms)。当前值: ${
|
|
16375
|
+
}), `已通过脚本 transform 更新 ${e}(耗时 ${a.elapsedMs}ms)。当前值: ${xv(_v(window, e), 600)}`;
|
|
16360
16376
|
}
|
|
16361
|
-
return
|
|
16377
|
+
return xv({
|
|
16362
16378
|
ok: !0,
|
|
16363
16379
|
result: a.result,
|
|
16364
16380
|
elapsedMs: a.elapsedMs
|
|
@@ -16382,8 +16398,8 @@ function Ev(e, r = {}) {
|
|
|
16382
16398
|
}
|
|
16383
16399
|
//#endregion
|
|
16384
16400
|
//#region src/core/tools/fetchDoc.ts
|
|
16385
|
-
var
|
|
16386
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
16401
|
+
var Ov = 3e4, kv = [n(async ({ url: e, as: t }) => {
|
|
16402
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), Ov);
|
|
16387
16403
|
try {
|
|
16388
16404
|
let r = await fetch(e, {
|
|
16389
16405
|
method: "GET",
|
|
@@ -16400,7 +16416,7 @@ var Dv = 3e4, Ov = [n(async ({ url: e, as: t }) => {
|
|
|
16400
16416
|
].join("\n");
|
|
16401
16417
|
} catch (t) {
|
|
16402
16418
|
let r = t?.message || String(t);
|
|
16403
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
16419
|
+
return n.signal.aborted ? `获取失败:请求超时(${Ov}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
16404
16420
|
} finally {
|
|
16405
16421
|
clearTimeout(r);
|
|
16406
16422
|
}
|
|
@@ -16411,24 +16427,24 @@ var Dv = 3e4, Ov = [n(async ({ url: e, as: t }) => {
|
|
|
16411
16427
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
16412
16428
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
16413
16429
|
})
|
|
16414
|
-
})],
|
|
16415
|
-
function
|
|
16416
|
-
return
|
|
16430
|
+
})], Av = kv;
|
|
16431
|
+
function jv(e, t) {
|
|
16432
|
+
return Dv(e, t);
|
|
16417
16433
|
}
|
|
16418
|
-
function
|
|
16434
|
+
function Mv(e, t, n) {
|
|
16419
16435
|
let r = e?.windowOps !== !1, i = e?.fetch !== !1;
|
|
16420
16436
|
return [...r ? t : [], ...i ? n : []];
|
|
16421
16437
|
}
|
|
16422
16438
|
//#endregion
|
|
16423
16439
|
//#region src/core/harness/usageHints.ts
|
|
16424
|
-
var
|
|
16425
|
-
function
|
|
16440
|
+
var Nv = .7;
|
|
16441
|
+
function Pv(e, t) {
|
|
16426
16442
|
return {
|
|
16427
16443
|
name: "usageHints",
|
|
16428
16444
|
augmentPrompt: () => {
|
|
16429
16445
|
let n = [];
|
|
16430
16446
|
if (e?.planning !== !1 && n.push("多步任务建议先 write_todos 拆解为步骤并逐步推进。"), t && (n.push("改属性前先 get_window_prop(path) 读其当前真实值与 hash(返回末尾 hash=xxx),基于真实值改,不要凭记忆。写入(set/edit/delete)时回传 expectedHash=该 hash 启用乐观锁——若属性在你 get 之后被外部代码/其他 agent/用户手动改过,会触发冲突:集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值与 hash 再改。"), n.push("不确定可操作哪些属性时用 list_window_props 查看(动态组件场景下注册表会增删,以工具返回为准,勿凭旧记忆);不确定某属性字段结构时用 describe_window_prop。"), n.push("修改大对象/数组属性优先用 edit_window_prop 增量 patch(只发改动部分),避免 set 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), n.push("修改属性出错时可用 restore_window_snapshot(path) 回退最近一次。"), n.push("在大数组里按条件筛选元素用 query_window_prop(JSONPath,如 $[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_window_prop 改。"), n.push("找名字记不清的元素用 search_window_prop(支持 substring/regex/fuzzy 模糊搜索)。"), n.push("需要过滤/映射/聚合/批量重写大数组时用 eval_window_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。")), e?.subagent !== !1 && n.push("独立子任务可 spawn_agent 委派(只读工具,过程不占主上下文)。"), e?.subagents?.length) {
|
|
16431
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
16447
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= Nv || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), r = e.subagents.filter((e) => (e.temperature ?? 0) < Nv && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
16432
16448
|
n.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (n.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), n.push(" 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。")), r.length && n.push(` · 严谨/易错/校验类 → 可先调 ${r.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), n.push(" · 方案定稿后,由你(主 agent)用 edit_window_prop 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), n.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
16433
16449
|
}
|
|
16434
16450
|
return e?.humanConfirm && (n.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), n.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), n.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), n.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), n.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。")), n.length && n.unshift("调用工具务必用标准 function calling(工具调用)格式发起,不要在回复正文里输出伪 XML/标签(如 deepseek 的 tool_calls 标签、invoke、function_call、tool_call 等)或 JSON 文本——那不会被识别为工具调用,会被当普通文字,工具不执行。"), n.length ? "## 能力使用提示\n" + n.join("\n") : void 0;
|
|
@@ -16437,7 +16453,7 @@ function Nv(e, t) {
|
|
|
16437
16453
|
}
|
|
16438
16454
|
//#endregion
|
|
16439
16455
|
//#region src/core/utils/id.ts
|
|
16440
|
-
function
|
|
16456
|
+
function Fv() {
|
|
16441
16457
|
try {
|
|
16442
16458
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
16443
16459
|
} catch {}
|
|
@@ -16445,57 +16461,57 @@ function Pv() {
|
|
|
16445
16461
|
}
|
|
16446
16462
|
//#endregion
|
|
16447
16463
|
//#region src/core/backends/storage.ts
|
|
16448
|
-
var
|
|
16464
|
+
var Iv = "chat-sdk", Lv = 50 * 1024 * 1024, Rv = 4 * 1024 * 1024, zv = 10 * 1024 * 1024, Bv = .9, Vv = 500, Hv = 300, Uv = "__meta__", Wv = "v:1", Gv = [
|
|
16449
16465
|
"messages",
|
|
16450
16466
|
"vfs",
|
|
16451
16467
|
"todos",
|
|
16452
16468
|
"memory"
|
|
16453
16469
|
];
|
|
16454
|
-
function Gv(e) {
|
|
16455
|
-
return e === "local" || e === "session" ? Lv : Iv;
|
|
16456
|
-
}
|
|
16457
16470
|
function Kv(e) {
|
|
16471
|
+
return e === "local" || e === "session" ? Rv : Lv;
|
|
16472
|
+
}
|
|
16473
|
+
function qv(e) {
|
|
16458
16474
|
if (typeof e != "object" || !e) return !1;
|
|
16459
16475
|
let t = e;
|
|
16460
16476
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
16461
16477
|
}
|
|
16462
|
-
function
|
|
16478
|
+
function Jv(e, t, n, r) {
|
|
16463
16479
|
return [
|
|
16464
|
-
|
|
16480
|
+
Wv,
|
|
16465
16481
|
e,
|
|
16466
16482
|
t,
|
|
16467
16483
|
n,
|
|
16468
16484
|
r
|
|
16469
16485
|
].join("::");
|
|
16470
16486
|
}
|
|
16471
|
-
function
|
|
16487
|
+
function Yv(e, t, n) {
|
|
16472
16488
|
return [
|
|
16473
|
-
|
|
16489
|
+
Wv,
|
|
16474
16490
|
e,
|
|
16475
16491
|
t,
|
|
16476
16492
|
n
|
|
16477
16493
|
].join("::") + "::";
|
|
16478
16494
|
}
|
|
16479
|
-
function
|
|
16495
|
+
function Xv(e, t) {
|
|
16480
16496
|
return [
|
|
16481
|
-
|
|
16497
|
+
Wv,
|
|
16482
16498
|
e,
|
|
16483
16499
|
t
|
|
16484
16500
|
].join("::") + "::";
|
|
16485
16501
|
}
|
|
16486
|
-
function
|
|
16487
|
-
return [
|
|
16502
|
+
function Zv(e) {
|
|
16503
|
+
return [Wv, e].join("::") + "::";
|
|
16488
16504
|
}
|
|
16489
|
-
var
|
|
16490
|
-
function
|
|
16491
|
-
|
|
16505
|
+
var Qv = null;
|
|
16506
|
+
function $v(e) {
|
|
16507
|
+
Qv ||= new TextEncoder();
|
|
16492
16508
|
try {
|
|
16493
|
-
return
|
|
16509
|
+
return Qv.encode(JSON.stringify(e)).length;
|
|
16494
16510
|
} catch {
|
|
16495
16511
|
return 0;
|
|
16496
16512
|
}
|
|
16497
16513
|
}
|
|
16498
|
-
function
|
|
16514
|
+
function ey(e, t, n) {
|
|
16499
16515
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
16500
16516
|
if (r <= t) return [];
|
|
16501
16517
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -16505,7 +16521,7 @@ function $v(e, t, n) {
|
|
|
16505
16521
|
}
|
|
16506
16522
|
return o;
|
|
16507
16523
|
}
|
|
16508
|
-
function
|
|
16524
|
+
function ty() {
|
|
16509
16525
|
let e = /* @__PURE__ */ new Map();
|
|
16510
16526
|
return {
|
|
16511
16527
|
async get(t) {
|
|
@@ -16525,7 +16541,7 @@ function ey() {
|
|
|
16525
16541
|
}
|
|
16526
16542
|
};
|
|
16527
16543
|
}
|
|
16528
|
-
function
|
|
16544
|
+
function ny(e) {
|
|
16529
16545
|
return new Promise((t, n) => {
|
|
16530
16546
|
if (typeof indexedDB > "u") {
|
|
16531
16547
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -16586,7 +16602,7 @@ function ty(e) {
|
|
|
16586
16602
|
}, r.onerror = () => n(r.error);
|
|
16587
16603
|
});
|
|
16588
16604
|
}
|
|
16589
|
-
function
|
|
16605
|
+
function ry(e) {
|
|
16590
16606
|
return {
|
|
16591
16607
|
async get(t) {
|
|
16592
16608
|
let n = e.getItem(t);
|
|
@@ -16620,12 +16636,12 @@ function ny(e) {
|
|
|
16620
16636
|
}
|
|
16621
16637
|
};
|
|
16622
16638
|
}
|
|
16623
|
-
function
|
|
16639
|
+
function iy(e, t, n) {
|
|
16624
16640
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
16625
16641
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
16626
16642
|
}
|
|
16627
|
-
function
|
|
16628
|
-
let t = e.dbName ??
|
|
16643
|
+
function ay(e = {}) {
|
|
16644
|
+
let t = e.dbName ?? Iv, n = e.backend ?? "indexed", r = e.maxBytes ?? Kv(n), i = e.maxBytesPerSession ?? zv, a = e.evictionWatermark ?? Bv, o = e.debounceMs ?? Vv, s = /* @__PURE__ */ new Set();
|
|
16629
16645
|
function c(e) {
|
|
16630
16646
|
for (let t of s) try {
|
|
16631
16647
|
t(e);
|
|
@@ -16638,16 +16654,16 @@ function iy(e = {}) {
|
|
|
16638
16654
|
try {
|
|
16639
16655
|
if (n === "indexed") {
|
|
16640
16656
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
16641
|
-
l = await
|
|
16657
|
+
l = await ny(t), d(!0);
|
|
16642
16658
|
} else if (n === "session") {
|
|
16643
16659
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
16644
|
-
l =
|
|
16660
|
+
l = ry(sessionStorage), d(!0);
|
|
16645
16661
|
} else if (n === "local") {
|
|
16646
16662
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
16647
|
-
l =
|
|
16648
|
-
} else l =
|
|
16663
|
+
l = ry(localStorage), d(!0);
|
|
16664
|
+
} else l = ty(), d(!1);
|
|
16649
16665
|
} catch (e) {
|
|
16650
|
-
l =
|
|
16666
|
+
l = ty();
|
|
16651
16667
|
let t = e instanceof Error ? e.message : String(e);
|
|
16652
16668
|
d(!1), Promise.resolve().then(() => c({
|
|
16653
16669
|
type: "degraded",
|
|
@@ -16657,10 +16673,10 @@ function iy(e = {}) {
|
|
|
16657
16673
|
})();
|
|
16658
16674
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
16659
16675
|
function g(e, n, r, a) {
|
|
16660
|
-
let o =
|
|
16661
|
-
return
|
|
16676
|
+
let o = Jv(t, r, a, Uv);
|
|
16677
|
+
return iy(h, o, async () => {
|
|
16662
16678
|
let t = async () => {
|
|
16663
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
16679
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : $v(s), d = $v(n), f = (t?.bytes ?? 0) + (d - u);
|
|
16664
16680
|
if (f > i) {
|
|
16665
16681
|
c({
|
|
16666
16682
|
type: "quota",
|
|
@@ -16682,12 +16698,12 @@ function iy(e = {}) {
|
|
|
16682
16698
|
try {
|
|
16683
16699
|
await t();
|
|
16684
16700
|
} catch (e) {
|
|
16685
|
-
if (
|
|
16701
|
+
if (qv(e) && !u) {
|
|
16686
16702
|
u = !0;
|
|
16687
16703
|
try {
|
|
16688
16704
|
await b();
|
|
16689
16705
|
} catch {}
|
|
16690
|
-
l =
|
|
16706
|
+
l = ty(), Promise.resolve().then(() => c({
|
|
16691
16707
|
type: "degraded",
|
|
16692
16708
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
16693
16709
|
}));
|
|
@@ -16699,7 +16715,7 @@ function iy(e = {}) {
|
|
|
16699
16715
|
});
|
|
16700
16716
|
}
|
|
16701
16717
|
function _(e, n, r, i) {
|
|
16702
|
-
let a =
|
|
16718
|
+
let a = Jv(t, e, n, r), s = p.get(a);
|
|
16703
16719
|
s && s.resolve();
|
|
16704
16720
|
let c = m.get(a);
|
|
16705
16721
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -16726,15 +16742,15 @@ function iy(e = {}) {
|
|
|
16726
16742
|
function y() {
|
|
16727
16743
|
v ||= setTimeout(() => {
|
|
16728
16744
|
v = null, b();
|
|
16729
|
-
},
|
|
16745
|
+
}, Hv);
|
|
16730
16746
|
}
|
|
16731
16747
|
async function b() {
|
|
16732
16748
|
let e = [];
|
|
16733
|
-
await l.scan(
|
|
16749
|
+
await l.scan(Zv(t), (t, n) => {
|
|
16734
16750
|
t.endsWith("::__meta__") && e.push(n);
|
|
16735
16751
|
});
|
|
16736
|
-
let n =
|
|
16737
|
-
for (let e of n) await l.clearPrefix(
|
|
16752
|
+
let n = ey(e, r, a);
|
|
16753
|
+
for (let e of n) await l.clearPrefix(Yv(t, e.agentId, e.sessionId)), c({
|
|
16738
16754
|
type: "evicted",
|
|
16739
16755
|
agentId: e.agentId,
|
|
16740
16756
|
sessionId: e.sessionId,
|
|
@@ -16745,13 +16761,13 @@ function iy(e = {}) {
|
|
|
16745
16761
|
ready: f,
|
|
16746
16762
|
async listSessions(e) {
|
|
16747
16763
|
let n = [];
|
|
16748
|
-
return await l.scan(
|
|
16764
|
+
return await l.scan(Xv(t, e), (e, t) => {
|
|
16749
16765
|
e.endsWith("::__meta__") && n.push(t);
|
|
16750
16766
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
16751
16767
|
},
|
|
16752
16768
|
async load(e, n) {
|
|
16753
|
-
let r =
|
|
16754
|
-
return await
|
|
16769
|
+
let r = Jv(t, e, n, Uv);
|
|
16770
|
+
return await iy(h, r, async () => {
|
|
16755
16771
|
let i = await l.get(r);
|
|
16756
16772
|
if (!i) return;
|
|
16757
16773
|
let a = {
|
|
@@ -16760,8 +16776,8 @@ function iy(e = {}) {
|
|
|
16760
16776
|
todos: [],
|
|
16761
16777
|
memory: ""
|
|
16762
16778
|
};
|
|
16763
|
-
for (let r of
|
|
16764
|
-
let i = await l.get(
|
|
16779
|
+
for (let r of Gv) {
|
|
16780
|
+
let i = await l.get(Jv(t, e, n, r));
|
|
16765
16781
|
i != null && (a[r] = i);
|
|
16766
16782
|
}
|
|
16767
16783
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -16769,7 +16785,7 @@ function iy(e = {}) {
|
|
|
16769
16785
|
},
|
|
16770
16786
|
async save(e, t, n) {
|
|
16771
16787
|
let r = [];
|
|
16772
|
-
for (let i of
|
|
16788
|
+
for (let i of Gv) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
16773
16789
|
await Promise.all(r);
|
|
16774
16790
|
},
|
|
16775
16791
|
async flush() {
|
|
@@ -16783,10 +16799,10 @@ function iy(e = {}) {
|
|
|
16783
16799
|
})), c({ type: "flush" }), await b();
|
|
16784
16800
|
},
|
|
16785
16801
|
async deleteSession(e, n) {
|
|
16786
|
-
await l.clearPrefix(
|
|
16802
|
+
await l.clearPrefix(Yv(t, e, n));
|
|
16787
16803
|
},
|
|
16788
16804
|
async createSession(e, n, r) {
|
|
16789
|
-
let i = r ??
|
|
16805
|
+
let i = r ?? Fv(), a = Date.now(), o = {
|
|
16790
16806
|
agentId: e,
|
|
16791
16807
|
sessionId: i,
|
|
16792
16808
|
createdAt: a,
|
|
@@ -16794,7 +16810,7 @@ function iy(e = {}) {
|
|
|
16794
16810
|
bytes: 0,
|
|
16795
16811
|
title: n
|
|
16796
16812
|
};
|
|
16797
|
-
return await l.set(
|
|
16813
|
+
return await l.set(Jv(t, e, i, Uv), o), i;
|
|
16798
16814
|
},
|
|
16799
16815
|
onEvent(e) {
|
|
16800
16816
|
s.add(e);
|
|
@@ -16809,28 +16825,28 @@ function iy(e = {}) {
|
|
|
16809
16825
|
}
|
|
16810
16826
|
//#endregion
|
|
16811
16827
|
//#region src/core/sdk/createChatSdk.ts
|
|
16812
|
-
var
|
|
16828
|
+
var oy = [
|
|
16813
16829
|
"你是一个页面操作助手。宿主页面在 window 对象上注册了可操作的属性,你通过专用工具安全地读写这些属性来操作页面。",
|
|
16814
16830
|
"所有写操作都经范围控制(仅注册表内)与 schema 校验(不合法会返回结构化错误而非写入),并自动留快照可回退。",
|
|
16815
16831
|
"大对象/数组优先用增量 patch(只发改动)而非整体重传,避免输出被截断。",
|
|
16816
|
-
|
|
16817
|
-
].join("\n\n"),
|
|
16818
|
-
function sy(e) {
|
|
16819
|
-
return e === void 0 || e === !1 ? null : typeof e == "string" ? iy({ backend: e }) : e.enabled === !1 ? null : iy(e);
|
|
16820
|
-
}
|
|
16832
|
+
R_.reliableWriteRules
|
|
16833
|
+
].join("\n\n"), sy = 50;
|
|
16821
16834
|
function cy(e) {
|
|
16835
|
+
return e === void 0 || e === !1 ? null : typeof e == "string" ? ay({ backend: e }) : e.enabled === !1 ? null : ay(e);
|
|
16836
|
+
}
|
|
16837
|
+
function ly(e) {
|
|
16822
16838
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
16823
16839
|
}
|
|
16824
|
-
var
|
|
16825
|
-
function
|
|
16840
|
+
var uy = /* @__PURE__ */ new Map();
|
|
16841
|
+
function dy(e) {
|
|
16826
16842
|
let t = e.content;
|
|
16827
16843
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
16828
16844
|
}
|
|
16829
|
-
function
|
|
16845
|
+
function fy(e) {
|
|
16830
16846
|
let t = e.summaryLlm ?? e.llm;
|
|
16831
16847
|
if (!t) return;
|
|
16832
16848
|
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, o = e.summaryTimeoutMs ?? 15e3, c;
|
|
16833
|
-
if (
|
|
16849
|
+
if (ly(t)) c = t;
|
|
16834
16850
|
else {
|
|
16835
16851
|
let i = t;
|
|
16836
16852
|
if (!i.apiKey) {
|
|
@@ -16848,16 +16864,16 @@ function dy(e) {
|
|
|
16848
16864
|
return async (e) => {
|
|
16849
16865
|
let t = new AbortController(), n = setTimeout(() => t.abort(), o);
|
|
16850
16866
|
try {
|
|
16851
|
-
return
|
|
16867
|
+
return dy(await c.invoke([new a("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new i(e)], { signal: t.signal })).trim();
|
|
16852
16868
|
} finally {
|
|
16853
16869
|
clearTimeout(n);
|
|
16854
16870
|
}
|
|
16855
16871
|
};
|
|
16856
16872
|
}
|
|
16857
|
-
function
|
|
16873
|
+
function py(e) {
|
|
16858
16874
|
return e === "set_window_prop" ? "set" : e === "edit_window_prop" ? "edit" : e === "delete_window_prop" ? "delete" : e === "restore_window_snapshot" ? "restore" : null;
|
|
16859
16875
|
}
|
|
16860
|
-
function
|
|
16876
|
+
function my(e) {
|
|
16861
16877
|
let t = e.split("."), n = globalThis.window;
|
|
16862
16878
|
for (let e of t) {
|
|
16863
16879
|
if (n == null) return;
|
|
@@ -16865,18 +16881,18 @@ function py(e) {
|
|
|
16865
16881
|
}
|
|
16866
16882
|
return n;
|
|
16867
16883
|
}
|
|
16868
|
-
function
|
|
16884
|
+
function hy(e, t) {
|
|
16869
16885
|
return {
|
|
16870
16886
|
name: "sdk-events",
|
|
16871
16887
|
wrapToolCall: async (t, n) => {
|
|
16872
|
-
let r = await n(t), i =
|
|
16888
|
+
let r = await n(t), i = py(t.name);
|
|
16873
16889
|
if (i) {
|
|
16874
16890
|
let n = String(t.args?.path ?? "");
|
|
16875
16891
|
e({
|
|
16876
16892
|
type: "window_prop_change",
|
|
16877
16893
|
path: n,
|
|
16878
16894
|
operation: i,
|
|
16879
|
-
value: n ?
|
|
16895
|
+
value: n ? my(n) : void 0
|
|
16880
16896
|
});
|
|
16881
16897
|
}
|
|
16882
16898
|
return r;
|
|
@@ -16889,18 +16905,20 @@ function my(e, t) {
|
|
|
16889
16905
|
}
|
|
16890
16906
|
};
|
|
16891
16907
|
}
|
|
16892
|
-
function
|
|
16908
|
+
function gy(e, r) {
|
|
16893
16909
|
let i = /* @__PURE__ */ fn(null), a = 0;
|
|
16894
16910
|
function o(e) {
|
|
16895
16911
|
return new Promise((t) => {
|
|
16896
|
-
let n =
|
|
16912
|
+
let n = i.value;
|
|
16913
|
+
n && n.resolve({ action: "keep_external" });
|
|
16914
|
+
let r = {
|
|
16897
16915
|
...e,
|
|
16898
16916
|
id: ++a,
|
|
16899
16917
|
resolve: t
|
|
16900
16918
|
};
|
|
16901
|
-
i.value =
|
|
16919
|
+
i.value = r, de({
|
|
16902
16920
|
type: "conflict",
|
|
16903
|
-
conflict:
|
|
16921
|
+
conflict: r
|
|
16904
16922
|
});
|
|
16905
16923
|
});
|
|
16906
16924
|
}
|
|
@@ -16908,38 +16926,38 @@ function hy(e, r) {
|
|
|
16908
16926
|
let t = i.value;
|
|
16909
16927
|
t && (i.value = null, t.resolve({ action: e }));
|
|
16910
16928
|
}
|
|
16911
|
-
let c =
|
|
16929
|
+
let c = cy(e.storage);
|
|
16912
16930
|
e.debug && c && c.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
16913
|
-
let l =
|
|
16931
|
+
let l = ly(e.llm) ? void 0 : e.llm, u = ng({
|
|
16914
16932
|
model: l?.model,
|
|
16915
16933
|
contextWindow: e.contextWindow ?? l?.contextWindow,
|
|
16916
16934
|
maxOutputTokens: e.maxOutputTokens ?? l?.maxOutputTokens
|
|
16917
16935
|
});
|
|
16918
16936
|
e.debug && console.log("[page-agent-sdk][modelCaps]", u);
|
|
16919
|
-
let d =
|
|
16937
|
+
let d = fy(e);
|
|
16920
16938
|
e.debug && !d && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
16921
|
-
let f = /* @__PURE__ */ Qt([]), p =
|
|
16939
|
+
let f = /* @__PURE__ */ Qt([]), p = G_(e.vfs?.initialFiles, {
|
|
16922
16940
|
persist: c ? { save: (e) => {
|
|
16923
16941
|
B.sessionId && c && c.save(r, B.sessionId, { vfs: e });
|
|
16924
16942
|
} } : void 0,
|
|
16925
16943
|
maxBytes: e.vfs?.maxBytes
|
|
16926
|
-
}), m =
|
|
16944
|
+
}), m = Sg(), h = Ag(e.memory || ""), g = { current: null }, _ = e.checkpoint, v = _ !== void 0 && _ !== !1, y = v ? qg({
|
|
16927
16945
|
windowPaths: (e.windowProps ?? []).map((e) => e.path),
|
|
16928
16946
|
vfsStore: p,
|
|
16929
16947
|
todosMw: m,
|
|
16930
16948
|
getTodos: () => g.current?.getState?.()?.todos ?? [],
|
|
16931
16949
|
messages: f,
|
|
16932
16950
|
maxCheckpoints: _ && typeof _ == "object" ? _.maxCheckpoints : void 0
|
|
16933
|
-
}) : null, b = !_ || typeof _ != "object" || _.auto !== !1, x = e.capabilities, S = x?.windowOps !== !1, C = S ?
|
|
16951
|
+
}) : null, b = !_ || typeof _ != "object" || _.auto !== !1, x = e.capabilities, S = x?.windowOps !== !1, C = S ? Dv(e.windowProps || [], {
|
|
16934
16952
|
onAudit: e.debug ? (e) => console.log("[page-agent-sdk][window audit]", e) : void 0,
|
|
16935
16953
|
maxSnapshots: e.maxSnapshots,
|
|
16936
16954
|
onConflict: o
|
|
16937
|
-
}) : [], w = S ? C.controller ?? null : null, T = () => w?.list() ?? e.windowProps ?? [], E = /* @__PURE__ */ new Map(), D =
|
|
16955
|
+
}) : [], w = S ? C.controller ?? null : null, T = () => w?.list() ?? e.windowProps ?? [], E = /* @__PURE__ */ new Map(), D = Mv(x, C, kv);
|
|
16938
16956
|
D.forEach((e) => E.set(e.name, "builtin"));
|
|
16939
16957
|
let O = [...e.tools || []];
|
|
16940
16958
|
O.forEach((e) => E.set(e.name, "user"));
|
|
16941
|
-
let k = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), A = k ?
|
|
16942
|
-
A && E.set(
|
|
16959
|
+
let k = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), A = k ? zg() : null;
|
|
16960
|
+
A && E.set(Lg, "builtin");
|
|
16943
16961
|
let j = v && y ? [n(async () => {
|
|
16944
16962
|
let e = y.list();
|
|
16945
16963
|
return e.length ? y.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、window 注册属性、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
@@ -16963,7 +16981,7 @@ function hy(e, r) {
|
|
|
16963
16981
|
...j
|
|
16964
16982
|
], N = x?.planning !== !1, P = x?.skills !== !1, F = x?.vfs !== !1, I = x?.summarization !== !1, L = x?.memory !== !1, ee = x?.subagent !== !1, R = e.verify?.maxAttempts ?? 2, z = x?.verify === !0 && e.verify?.enabled !== !1 && R > 0;
|
|
16965
16983
|
e.verify?.check && x?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
|
|
16966
|
-
let te = e.subagent, ne = te?.allowedTools ?? [], re = !ee || te?.enabled === !1 ? void 0 :
|
|
16984
|
+
let te = e.subagent, ne = te?.allowedTools ?? [], re = !ee || te?.enabled === !1 ? void 0 : n_({
|
|
16967
16985
|
llm: te?.llm ?? e.llm,
|
|
16968
16986
|
allTools: M,
|
|
16969
16987
|
allowedTools: ne.length ? ne : void 0,
|
|
@@ -16974,7 +16992,7 @@ function hy(e, r) {
|
|
|
16974
16992
|
maxDepth: te?.maxDepth,
|
|
16975
16993
|
maxParallel: te?.maxParallel,
|
|
16976
16994
|
debug: e.debug
|
|
16977
|
-
}), ie = e.subagents?.length ?
|
|
16995
|
+
}), ie = e.subagents?.length ? a_(e.subagents, {
|
|
16978
16996
|
llm: e.llm,
|
|
16979
16997
|
allTools: M,
|
|
16980
16998
|
debug: e.debug
|
|
@@ -16984,13 +17002,13 @@ function hy(e, r) {
|
|
|
16984
17002
|
"list_window_props",
|
|
16985
17003
|
"describe_window_prop",
|
|
16986
17004
|
"fetch_document"
|
|
16987
|
-
], oe = M.filter((e) => ae.includes(e.name)), se = z ?
|
|
16988
|
-
check: e.verify.check ??
|
|
17005
|
+
], oe = M.filter((e) => ae.includes(e.name)), se = z ? o_({
|
|
17006
|
+
check: e.verify.check ?? f_({ schemas: () => Object.fromEntries(T().map((e) => [e.path, e.schema])) }),
|
|
16989
17007
|
adversarial: e.verify?.adversarial ? {
|
|
16990
17008
|
llm: e.llm,
|
|
16991
17009
|
tools: oe
|
|
16992
17010
|
} : void 0
|
|
16993
|
-
}) : void 0, ce =
|
|
17011
|
+
}) : void 0, ce = Pv({
|
|
16994
17012
|
...x,
|
|
16995
17013
|
humanConfirm: k,
|
|
16996
17014
|
subagents: e.subagents?.map((e) => ({
|
|
@@ -17010,10 +17028,10 @@ function hy(e, r) {
|
|
|
17010
17028
|
}, fe = [
|
|
17011
17029
|
ce,
|
|
17012
17030
|
...N ? [m] : [],
|
|
17013
|
-
...P ? [
|
|
17014
|
-
...F ? [
|
|
17015
|
-
...I ? [
|
|
17016
|
-
...
|
|
17031
|
+
...P ? [kg(e.skills || [], { readVfs: F ? (e) => p.files[e]?.content : void 0 })] : [],
|
|
17032
|
+
...F ? [Q_(p)] : [],
|
|
17033
|
+
...I ? [I_({
|
|
17034
|
+
...B_(e, u.contextWindow),
|
|
17017
17035
|
llmInvoke: d,
|
|
17018
17036
|
getRegisteredProps: () => T().map((e) => ({
|
|
17019
17037
|
path: e.path,
|
|
@@ -17022,16 +17040,16 @@ function hy(e, r) {
|
|
|
17022
17040
|
preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? ["describe_window_prop", "list_window_props"]
|
|
17023
17041
|
})] : [],
|
|
17024
17042
|
...L ? [h] : [],
|
|
17025
|
-
...e.permissions?.length ? [
|
|
17026
|
-
...v && b && y ? [
|
|
17027
|
-
...k ? [
|
|
17028
|
-
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [
|
|
17043
|
+
...e.permissions?.length ? [Fg(e.permissions)] : [],
|
|
17044
|
+
...v && b && y ? [Jg(y)] : [],
|
|
17045
|
+
...k ? [Bg()] : [],
|
|
17046
|
+
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [Ig(e.approval)] : [],
|
|
17029
17047
|
...se ? [se] : [],
|
|
17030
17048
|
...re ? [re] : [],
|
|
17031
17049
|
...ie ? [ie] : [],
|
|
17032
17050
|
...e.middleware || [],
|
|
17033
|
-
|
|
17034
|
-
], pe = e.maxMemoryRounds ??
|
|
17051
|
+
hy(de, f)
|
|
17052
|
+
], pe = e.maxMemoryRounds ?? sy, B = {
|
|
17035
17053
|
agentId: r,
|
|
17036
17054
|
store: c,
|
|
17037
17055
|
messages: f,
|
|
@@ -17096,15 +17114,15 @@ function hy(e, r) {
|
|
|
17096
17114
|
if (B.refCount--, B.refCount <= 0) {
|
|
17097
17115
|
c && (p.flush?.(), c.flush(), c.dispose());
|
|
17098
17116
|
let e = B.mcpClosers.splice(0);
|
|
17099
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
17117
|
+
e.length && Promise.allSettled(e.map((e) => e())), uy.delete(r);
|
|
17100
17118
|
}
|
|
17101
17119
|
},
|
|
17102
17120
|
resolveConflict: s,
|
|
17103
17121
|
getInfo() {
|
|
17104
17122
|
return {
|
|
17105
17123
|
id: r,
|
|
17106
|
-
model:
|
|
17107
|
-
systemPrompt: e.systemPrompt ??
|
|
17124
|
+
model: ly(e.llm) ? e.llm.model ?? e.llm.modelName : e.llm.model,
|
|
17125
|
+
systemPrompt: e.systemPrompt ?? oy,
|
|
17108
17126
|
tools: M.map((e) => ({
|
|
17109
17127
|
name: e.name,
|
|
17110
17128
|
description: e.description,
|
|
@@ -17166,7 +17184,7 @@ function hy(e, r) {
|
|
|
17166
17184
|
e.memory && c.save(r, B.sessionId, { memory: e.memory });
|
|
17167
17185
|
}
|
|
17168
17186
|
function he() {
|
|
17169
|
-
let e =
|
|
17187
|
+
let e = E_(f, pe);
|
|
17170
17188
|
e.trimmed && f.splice(e.deleteFrom, e.deleteCount, e.summary);
|
|
17171
17189
|
}
|
|
17172
17190
|
function ge() {
|
|
@@ -17178,7 +17196,7 @@ function hy(e, r) {
|
|
|
17178
17196
|
}
|
|
17179
17197
|
return B.initDone = (async () => {
|
|
17180
17198
|
if (await me(), e.mcp?.length) {
|
|
17181
|
-
let t = await Promise.allSettled(e.mcp.map((e) =>
|
|
17199
|
+
let t = await Promise.allSettled(e.mcp.map((e) => S_(e)));
|
|
17182
17200
|
B.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), B.mcpServers = [];
|
|
17183
17201
|
let n = [];
|
|
17184
17202
|
t.forEach((t, r) => {
|
|
@@ -17190,15 +17208,15 @@ function hy(e, r) {
|
|
|
17190
17208
|
}), t.value.tools.forEach((e) => E.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
|
|
17191
17209
|
}), M.push(...n), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${B.mcpServers.length} 个 server`);
|
|
17192
17210
|
}
|
|
17193
|
-
B.agent =
|
|
17194
|
-
...
|
|
17211
|
+
B.agent = bg({
|
|
17212
|
+
...ly(e.llm) ? { llm: e.llm } : {
|
|
17195
17213
|
apiKey: e.llm.apiKey,
|
|
17196
17214
|
baseUrl: e.llm.baseUrl,
|
|
17197
17215
|
model: e.llm.model,
|
|
17198
17216
|
temperature: e.llm.temperature,
|
|
17199
17217
|
maxTokens: e.llm.maxTokens
|
|
17200
17218
|
},
|
|
17201
|
-
systemPrompt: e.systemPrompt ??
|
|
17219
|
+
systemPrompt: e.systemPrompt ?? oy,
|
|
17202
17220
|
tools: M,
|
|
17203
17221
|
middleware: fe,
|
|
17204
17222
|
maxToolRounds: e.maxToolRounds,
|
|
@@ -17211,11 +17229,11 @@ function hy(e, r) {
|
|
|
17211
17229
|
}), g.current = B.agent;
|
|
17212
17230
|
})(), B;
|
|
17213
17231
|
}
|
|
17214
|
-
function
|
|
17215
|
-
let t = e.id ??
|
|
17232
|
+
function _y(e) {
|
|
17233
|
+
let t = e.id ?? Fv();
|
|
17216
17234
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${t}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
17217
|
-
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ?
|
|
17218
|
-
a ? i = a : (i =
|
|
17235
|
+
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ? uy.get(t) : void 0;
|
|
17236
|
+
a ? i = a : (i = gy(e, t), e.shareContext && uy.set(t, i)), i.refCount++;
|
|
17219
17237
|
let o = null, s = null, c = null;
|
|
17220
17238
|
async function l() {
|
|
17221
17239
|
if (await i.initDone, r === !1) {
|
|
@@ -17230,7 +17248,7 @@ function gy(e) {
|
|
|
17230
17248
|
if (!t) throw Error(`createChatSdk: 挂载点未找到(${e.container})`);
|
|
17231
17249
|
let a = i.agent.debugLogs;
|
|
17232
17250
|
o = ul(/* @__PURE__ */ wi({ setup() {
|
|
17233
|
-
return () => Bs(
|
|
17251
|
+
return () => Bs(Xh, {
|
|
17234
17252
|
fetchStream: n ? i.agent.stream : void 0,
|
|
17235
17253
|
fetchResponse: n ? void 0 : (e, t) => {
|
|
17236
17254
|
if (t) {
|
|
@@ -17250,7 +17268,7 @@ function gy(e) {
|
|
|
17250
17268
|
i.afterRound(), i.store && await i.store.flush();
|
|
17251
17269
|
},
|
|
17252
17270
|
onClear: () => {
|
|
17253
|
-
i.store && (i.sessionId =
|
|
17271
|
+
i.store && (i.sessionId = Fv(), i.vfsStore.clear?.(), i.todosMw.reset([]), e.memory || i.memoryMw.reset(""), i.agent.debugLogs.value = [], i.store.createSession(i.agentId, e.session?.title, i.sessionId));
|
|
17254
17272
|
},
|
|
17255
17273
|
pendingConflict: i.pendingConflict.value,
|
|
17256
17274
|
onResolveConflict: (e) => i.resolveConflict(e)
|
|
@@ -17290,7 +17308,7 @@ function gy(e) {
|
|
|
17290
17308
|
}
|
|
17291
17309
|
//#endregion
|
|
17292
17310
|
//#region src/core/sdk/defineTool.ts
|
|
17293
|
-
function
|
|
17311
|
+
function vy(e) {
|
|
17294
17312
|
return n(async (t) => {
|
|
17295
17313
|
let n = await e.handler(t);
|
|
17296
17314
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -17301,4 +17319,4 @@ function _y(e) {
|
|
|
17301
17319
|
});
|
|
17302
17320
|
}
|
|
17303
17321
|
//#endregion
|
|
17304
|
-
export {
|
|
17322
|
+
export { z_ as CONTEXT_PRESETS, Xh as ChatDialog, ef as CodePreview, Lg as HUMAN_CONFIRM_TOOL_NAME, nf as MessageContent, S_ as connectMcp, Sl as copyText, bg as createAgent, Ig as createApprovalMiddleware, _y as createChatSdk, qg as createCheckpointManager, Jg as createCheckpointMiddleware, Bg as createHumanConfirmMiddleware, zg as createHumanConfirmTool, ty as createMemoryBackend, ay as createSessionStore, n_ as createSubagentMiddleware, a_ as createSubagentsMiddleware, Pv as createUsageHintsMiddleware, o_ as createVerifyMiddleware, G_ as createVfs, ry as createWebStorageBackend, Dv as createWindowOps, f_ as createWriteBackCheck, Cg as defineSkill, vy as defineTool, jv as defineWindowToolset, hg as detectGarbledToolCall, rg as estimateTokens, y_ as extractText, kv as fetchDocTools, Av as fetchTools, V_ as formatZodIssues, qv as isQuotaError, cv as jpEval, U_ as jsonParseError, ag as offloadPassThroughChars, ig as offloadThresholdChars, L_ as presets, B_ as resolveContextOptions, ng as resolveModelCaps, pv as runSandboxedScript, uv as searchJson, Mv as selectBuiltinTools, R_ as systemPromptHelpers, $ as toolError, xl as useChat, e as z, H_ as zodError };
|