page-agent-sdk 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/page-agent-sdk.headless.js +410 -372
- package/dist/page-agent-sdk.iife.js +108 -95
- package/dist/page-agent-sdk.js +1189 -1133
- package/dist/page-agent-sdk.umd.cjs +74 -61
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/types/headless.d.ts +1 -1
- package/types/index.d.ts +1 -1
|
@@ -5696,7 +5696,26 @@ function Zs(e, t, n) {
|
|
|
5696
5696
|
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && typeof e.__pgId == "string" && n(e, r);
|
|
5697
5697
|
}
|
|
5698
5698
|
}
|
|
5699
|
-
function Qs(e) {
|
|
5699
|
+
function Qs(e, t, n) {
|
|
5700
|
+
let r = /* @__PURE__ */ new Set();
|
|
5701
|
+
if (!e || typeof e != "object") return r;
|
|
5702
|
+
for (let i of t) {
|
|
5703
|
+
let t = Z(e, i);
|
|
5704
|
+
if (Array.isArray(t)) for (let e = 0; e < t.length; e++) {
|
|
5705
|
+
let a = t[e];
|
|
5706
|
+
if (!a || typeof a != "object") continue;
|
|
5707
|
+
let o = a.__pgId;
|
|
5708
|
+
if (typeof o != "string") continue;
|
|
5709
|
+
let s = `${i}.${e}`;
|
|
5710
|
+
for (let e of n) if (e.path === s || e.path.startsWith(s + ".")) {
|
|
5711
|
+
r.add(o);
|
|
5712
|
+
break;
|
|
5713
|
+
}
|
|
5714
|
+
}
|
|
5715
|
+
}
|
|
5716
|
+
return r;
|
|
5717
|
+
}
|
|
5718
|
+
function $s(e) {
|
|
5700
5719
|
let { writablePaths: t, codeVfsPrefix: n, ext: r, getController: i, vfsStore: a } = e;
|
|
5701
5720
|
return {
|
|
5702
5721
|
name: "code-asset-checkout-commit",
|
|
@@ -5715,19 +5734,34 @@ function Qs(e) {
|
|
|
5715
5734
|
[Ys]: /* @__PURE__ */ new Set()
|
|
5716
5735
|
};
|
|
5717
5736
|
},
|
|
5718
|
-
|
|
5719
|
-
let
|
|
5720
|
-
if (e
|
|
5721
|
-
let t = e.
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5737
|
+
augmentPrompt: () => {
|
|
5738
|
+
let e = i()?.get?.().bind, o = [];
|
|
5739
|
+
if (Zs(e, t, (e) => {
|
|
5740
|
+
let t = typeof e.name == "string" && e.name ? e.name : "(未命名)", i = `${n}${e.__pgId}.${r}`, s = !!a.files[i];
|
|
5741
|
+
o.push(`- ${t} → ${i}${s ? "" : "(尚未检出,先 vfs_write 创建)"}`);
|
|
5742
|
+
}), o.length) return `## 组件代码文件地图(改组件时按 name 直接改对应 vfs 文件;框架自动 checkout/commit)\n${o.join("\n")}`;
|
|
5743
|
+
},
|
|
5744
|
+
wrapToolCall: async (e, a) => {
|
|
5745
|
+
let o = e.name === "vfs_write" || e.name === "vfs_edit" || e.name === "vfs_rm" ? e.args?.path : void 0, s = typeof o == "string" ? Us(o) : void 0, c = typeof s == "string" && s.startsWith(n);
|
|
5746
|
+
if (c) {
|
|
5747
|
+
let a = e.state.focuses;
|
|
5748
|
+
if (a && a.length) {
|
|
5749
|
+
let e = Qs(i()?.get?.().bind, t, a);
|
|
5750
|
+
if (e.size) {
|
|
5751
|
+
let t = Xs(s, n);
|
|
5752
|
+
if (t && !e.has(t)) return {
|
|
5753
|
+
content: `PATH_DENIED · vfs 越界:当前聚焦代码文件 [${[...e].map((e) => `${n}${e}.${r}`).join(", ")}],你要改的 "${s}" 不在其中。请只改焦点组件的代码文件;如需改其他组件,请让主 agent clear_focus / 换焦点后重试。`,
|
|
5754
|
+
status: "error"
|
|
5755
|
+
};
|
|
5727
5756
|
}
|
|
5728
5757
|
}
|
|
5729
5758
|
}
|
|
5730
|
-
|
|
5759
|
+
let l = await a(e);
|
|
5760
|
+
if (c) {
|
|
5761
|
+
let t = e.state[Ys];
|
|
5762
|
+
t && t.add(s);
|
|
5763
|
+
}
|
|
5764
|
+
return l;
|
|
5731
5765
|
},
|
|
5732
5766
|
afterAgent: (e) => {
|
|
5733
5767
|
let o = i(), s = o?.get?.().bind, c = e[Ys];
|
|
@@ -5752,7 +5786,7 @@ function Qs(e) {
|
|
|
5752
5786
|
}
|
|
5753
5787
|
//#endregion
|
|
5754
5788
|
//#region src/core/sdk/defineTool.ts
|
|
5755
|
-
function
|
|
5789
|
+
function ec(e) {
|
|
5756
5790
|
return r(async (t) => {
|
|
5757
5791
|
let n = await e.handler(t);
|
|
5758
5792
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -5764,7 +5798,7 @@ function $s(e) {
|
|
|
5764
5798
|
}
|
|
5765
5799
|
//#endregion
|
|
5766
5800
|
//#region src/core/sdk/inspectContextTool.ts
|
|
5767
|
-
var
|
|
5801
|
+
var tc = t.object({
|
|
5768
5802
|
path: t.string().optional().describe("分类 key 过滤(如 toolResults/history/systemPrompt/dataHint);不传=全部分类"),
|
|
5769
5803
|
role: t.enum([
|
|
5770
5804
|
"user",
|
|
@@ -5774,11 +5808,11 @@ var ec = t.object({
|
|
|
5774
5808
|
]).optional().describe("聚焦每轮首句的角色(assistant→回复摘要,user→问题摘要);不影响工具列表"),
|
|
5775
5809
|
limit: t.number().int().min(1).max(50).optional().describe("返回最近 N 轮(默认全部;超 50 自动截最近 50 防返回过大)")
|
|
5776
5810
|
});
|
|
5777
|
-
function
|
|
5778
|
-
return
|
|
5811
|
+
function nc(e) {
|
|
5812
|
+
return ec({
|
|
5779
5813
|
name: "inspect_context",
|
|
5780
5814
|
description: "查看当前对话上下文的构成(供压缩决策)。返回:totalTokens(历史轮次 token 总和,与触发判断同口径)、occupancy(窗口占用比)、contextWindow、categories(分类占用)、rounds(每轮 token/工具/首句)。先调用本工具查看构成,再决定压缩策略。",
|
|
5781
|
-
schema:
|
|
5815
|
+
schema: tc,
|
|
5782
5816
|
handler: (t) => {
|
|
5783
5817
|
let n = so(e.getMessages()), r = n.length > 50 ? n.slice(n.length - 50) : n, i = (t.limit && r.length > t.limit ? r.slice(r.length - t.limit) : r).map((e) => {
|
|
5784
5818
|
let n = bo(e), r = lo(e), i = t.role === "assistant" ? e.assistantMsgs[0] ?? e.userMsg : e.userMsg, a = co(typeof i.content == "string" ? i.content : "", 60);
|
|
@@ -5801,7 +5835,7 @@ function tc(e) {
|
|
|
5801
5835
|
}
|
|
5802
5836
|
//#endregion
|
|
5803
5837
|
//#region src/core/sdk/compressDecision.ts
|
|
5804
|
-
var
|
|
5838
|
+
var rc = t.object({
|
|
5805
5839
|
keepRounds: t.number().int().min(0).max(50).optional(),
|
|
5806
5840
|
windowRatio: t.number().min(0).max(1).optional(),
|
|
5807
5841
|
summarize: t.object({ mode: t.enum(["index", "llm"]) }),
|
|
@@ -5811,23 +5845,23 @@ var nc = t.object({
|
|
|
5811
5845
|
}).refine((e) => e.keepRounds !== void 0 || e.windowRatio !== void 0, { message: "keepRounds 与 windowRatio 至少填一个(按当前触发模式)" });
|
|
5812
5846
|
//#endregion
|
|
5813
5847
|
//#region src/core/sdk/llmResolver.ts
|
|
5814
|
-
function
|
|
5848
|
+
function ic(e) {
|
|
5815
5849
|
let t = e.find((e) => e.role === "user");
|
|
5816
5850
|
if (!t) return;
|
|
5817
5851
|
let n = t.content, r = (typeof n == "string" ? n : Array.isArray(n) ? n.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(n ?? "")).trim().replace(/[\n\r]+/g, " ");
|
|
5818
5852
|
if (r) return r.length > 30 ? r.slice(0, 30) + "…" : r;
|
|
5819
5853
|
}
|
|
5820
|
-
function
|
|
5854
|
+
function ac(e) {
|
|
5821
5855
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
5822
5856
|
}
|
|
5823
|
-
function
|
|
5857
|
+
function oc(e) {
|
|
5824
5858
|
let t = e.content;
|
|
5825
5859
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
5826
5860
|
}
|
|
5827
|
-
function
|
|
5861
|
+
function sc(e) {
|
|
5828
5862
|
let t = e.summaryLlm ?? e.llm;
|
|
5829
5863
|
if (!t) return;
|
|
5830
|
-
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s =
|
|
5864
|
+
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s = ac(t) ? t : null, c = ac(t) ? null : t;
|
|
5831
5865
|
if (c && !c.apiKey) {
|
|
5832
5866
|
e.summaryLlm && console.warn("[page-agent-sdk][summarization] summaryLlm 已配置但缺 apiKey,摘要回退主 agent 模型或零成本索引摘要");
|
|
5833
5867
|
return;
|
|
@@ -5839,16 +5873,16 @@ function oc(e) {
|
|
|
5839
5873
|
return !l && c && (l = await f(c, {
|
|
5840
5874
|
temperature: n,
|
|
5841
5875
|
maxTokens: r
|
|
5842
|
-
})),
|
|
5876
|
+
})), oc(await l.invoke([new o("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new a(e)], { signal: t.signal })).trim();
|
|
5843
5877
|
} finally {
|
|
5844
5878
|
clearTimeout(s);
|
|
5845
5879
|
}
|
|
5846
5880
|
};
|
|
5847
5881
|
}
|
|
5848
|
-
function
|
|
5882
|
+
function cc(e) {
|
|
5849
5883
|
let t = e.titleLlm ?? e.summaryLlm ?? e.llm;
|
|
5850
5884
|
if (!t) return;
|
|
5851
|
-
let n =
|
|
5885
|
+
let n = ac(t) ? t : null, r = ac(t) ? null : t;
|
|
5852
5886
|
if (r && !r.apiKey) return;
|
|
5853
5887
|
let i = n;
|
|
5854
5888
|
return async (e) => {
|
|
@@ -5857,7 +5891,7 @@ function sc(e) {
|
|
|
5857
5891
|
return !i && r && (i = await f(r, {
|
|
5858
5892
|
temperature: 0,
|
|
5859
5893
|
maxTokens: 30
|
|
5860
|
-
})),
|
|
5894
|
+
})), oc(await i.invoke([new o("根据以下对话的主旨,生成一个简短的中文标题(不超过15个字,不要标点和引号,直接输出标题文字)。"), new a(t)], { signal: n.signal })).trim().replace(/^["'""「『]|["'""」』]$/g, "").split("\n")[0].slice(0, 20);
|
|
5861
5895
|
} catch {
|
|
5862
5896
|
return "";
|
|
5863
5897
|
} finally {
|
|
@@ -5865,10 +5899,10 @@ function sc(e) {
|
|
|
5865
5899
|
}
|
|
5866
5900
|
};
|
|
5867
5901
|
}
|
|
5868
|
-
function
|
|
5902
|
+
function lc() {
|
|
5869
5903
|
return `call_dec_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
5870
5904
|
}
|
|
5871
|
-
function
|
|
5905
|
+
function uc(e) {
|
|
5872
5906
|
let t = e.match(/```(?:json)?\s*([\s\S]*?)```/), n = t ? t[1] : e, r = n.indexOf("{"), i = n.lastIndexOf("}");
|
|
5873
5907
|
if (r < 0 || i < 0 || i <= r) return null;
|
|
5874
5908
|
try {
|
|
@@ -5877,21 +5911,21 @@ function lc(e) {
|
|
|
5877
5911
|
return null;
|
|
5878
5912
|
}
|
|
5879
5913
|
}
|
|
5880
|
-
function
|
|
5914
|
+
function dc(e) {
|
|
5881
5915
|
if (!e) return null;
|
|
5882
|
-
let t =
|
|
5916
|
+
let t = uc(e);
|
|
5883
5917
|
if (t == null) return null;
|
|
5884
|
-
let n =
|
|
5918
|
+
let n = rc.safeParse(t);
|
|
5885
5919
|
return n.success ? n.data : null;
|
|
5886
5920
|
}
|
|
5887
|
-
async function
|
|
5921
|
+
async function fc(e, t, n, r) {
|
|
5888
5922
|
let i = [...n];
|
|
5889
5923
|
for (let n = 0; n < 3; n++) {
|
|
5890
5924
|
let n = await e.invoke(i, { signal: r }), a = n?.tool_calls ?? [];
|
|
5891
|
-
if (!a.length) return
|
|
5925
|
+
if (!a.length) return oc(n).trim();
|
|
5892
5926
|
i = [...i, n];
|
|
5893
5927
|
for (let e of a) {
|
|
5894
|
-
let n = e.id ??
|
|
5928
|
+
let n = e.id ?? lc();
|
|
5895
5929
|
try {
|
|
5896
5930
|
let r = await t.invoke(e.args ?? {}), a = typeof r == "string" ? r : r?.content ?? JSON.stringify(r);
|
|
5897
5931
|
i = [...i, new s({
|
|
@@ -5908,10 +5942,10 @@ async function dc(e, t, n, r) {
|
|
|
5908
5942
|
}
|
|
5909
5943
|
return "";
|
|
5910
5944
|
}
|
|
5911
|
-
function
|
|
5945
|
+
function pc(e) {
|
|
5912
5946
|
let t = e.summaryLlm ?? e.llm;
|
|
5913
5947
|
if (!t) return;
|
|
5914
|
-
let n =
|
|
5948
|
+
let n = ac(t) ? t : null, r = ac(t) ? null : t;
|
|
5915
5949
|
if (r && !r.apiKey) return;
|
|
5916
5950
|
let i = e.decisionTimeoutMs ?? 6e3, s = e.decisionMaxTokens ?? 2048, c = n;
|
|
5917
5951
|
return async (e) => {
|
|
@@ -5923,12 +5957,12 @@ function fc(e) {
|
|
|
5923
5957
|
}));
|
|
5924
5958
|
let n = c;
|
|
5925
5959
|
if (typeof n.bindTools != "function") return null;
|
|
5926
|
-
let i =
|
|
5960
|
+
let i = nc({
|
|
5927
5961
|
getMessages: e.getMessages,
|
|
5928
5962
|
getSnapshot: e.getSnapshot,
|
|
5929
5963
|
contextWindow: e.contextWindow
|
|
5930
5964
|
}), l = n.bindTools([i]), u = e.triggerMode === "token" ? "token 模式:必填 windowRatio(0~1 保留窗口预算比例,如 0.4);keepRounds 可选" : "轮数模式:必填 keepRounds(保留最近几轮,如 6);windowRatio 可选", d = [new o(`你是对话历史压缩决策助手。当前触发模式 = ${e.triggerMode}(${e.triggerReason})。先调用 inspect_context 查看上下文构成,再输出压缩决策 JSON。${u}。仅输出 JSON,不要多余文字/markdown。schema:{keepRounds?(int 0-50), windowRatio?(0-1), summarize:{mode:"index"|"llm"}, recallTopK?(int 0-10), preserveTools?(string[]≤10), reason?(≤200字)}。keepRounds/windowRatio 至少填一个。`), new a(`触发原因:${e.triggerReason}\n上下文窗口:${e.contextWindow ?? "未知"} tokens\n阈值比例:${e.thresholdRatio ?? "未知"}\n\n请决策压缩策略(先 inspect_context 查看,再输出 JSON)。`)];
|
|
5931
|
-
return
|
|
5965
|
+
return dc(await fc(l, i, d, t.signal)) || dc(await fc(l, i, [...d, new a("上一次输出无效(JSON 解析失败或 schema 校验不通过)。请只输出符合 schema 的压缩决策 JSON,不要多余文字/markdown 代码块。")], t.signal));
|
|
5932
5966
|
} catch {
|
|
5933
5967
|
return null;
|
|
5934
5968
|
} finally {
|
|
@@ -5936,22 +5970,22 @@ function fc(e) {
|
|
|
5936
5970
|
}
|
|
5937
5971
|
};
|
|
5938
5972
|
}
|
|
5939
|
-
function
|
|
5940
|
-
let t = e.llm, n =
|
|
5973
|
+
function mc(e) {
|
|
5974
|
+
let t = e.llm, n = ac(e.llm) ? void 0 : e.llm;
|
|
5941
5975
|
return {
|
|
5942
5976
|
modelCaps: ri({
|
|
5943
5977
|
model: n?.model ?? t?.model ?? t?.modelName,
|
|
5944
5978
|
contextWindow: e.contextWindow ?? n?.contextWindow ?? t?.contextWindow,
|
|
5945
5979
|
maxOutputTokens: e.maxOutputTokens ?? n?.maxOutputTokens ?? t?.maxOutputTokens
|
|
5946
5980
|
}),
|
|
5947
|
-
summaryLlmInvoke:
|
|
5948
|
-
titleLlmInvoke:
|
|
5949
|
-
compressDecisionInvoke:
|
|
5981
|
+
summaryLlmInvoke: sc(e),
|
|
5982
|
+
titleLlmInvoke: cc(e),
|
|
5983
|
+
compressDecisionInvoke: pc(e)
|
|
5950
5984
|
};
|
|
5951
5985
|
}
|
|
5952
5986
|
//#endregion
|
|
5953
5987
|
//#region src/core/sdk/conflictManager.ts
|
|
5954
|
-
function
|
|
5988
|
+
function hc(e) {
|
|
5955
5989
|
let t = /* @__PURE__ */ Ot(null), n = 0;
|
|
5956
5990
|
function r(r) {
|
|
5957
5991
|
return new Promise((i) => {
|
|
@@ -5982,7 +6016,7 @@ function mc(e) {
|
|
|
5982
6016
|
}
|
|
5983
6017
|
//#endregion
|
|
5984
6018
|
//#region src/core/utils/id.ts
|
|
5985
|
-
function
|
|
6019
|
+
function gc() {
|
|
5986
6020
|
try {
|
|
5987
6021
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
5988
6022
|
} catch {}
|
|
@@ -5990,7 +6024,7 @@ function hc() {
|
|
|
5990
6024
|
}
|
|
5991
6025
|
//#endregion
|
|
5992
6026
|
//#region src/core/backends/storage.ts
|
|
5993
|
-
var
|
|
6027
|
+
var _c = "chat-sdk", vc = 50 * 1024 * 1024, yc = 4 * 1024 * 1024, bc = 10 * 1024 * 1024, xc = .9, Sc = 500, Cc = 300, wc = "__meta__", Tc = "v:1", Ec = [
|
|
5994
6028
|
"messages",
|
|
5995
6029
|
"vfs",
|
|
5996
6030
|
"todos",
|
|
@@ -6001,51 +6035,51 @@ var gc = "chat-sdk", _c = 50 * 1024 * 1024, vc = 4 * 1024 * 1024, yc = 10 * 1024
|
|
|
6001
6035
|
"workingMemory",
|
|
6002
6036
|
"focus"
|
|
6003
6037
|
];
|
|
6004
|
-
function Ec(e) {
|
|
6005
|
-
return e === "local" || e === "session" ? vc : _c;
|
|
6006
|
-
}
|
|
6007
6038
|
function Dc(e) {
|
|
6039
|
+
return e === "local" || e === "session" ? yc : vc;
|
|
6040
|
+
}
|
|
6041
|
+
function Oc(e) {
|
|
6008
6042
|
if (typeof e != "object" || !e) return !1;
|
|
6009
6043
|
let t = e;
|
|
6010
6044
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
6011
6045
|
}
|
|
6012
|
-
function
|
|
6046
|
+
function kc(e, t, n, r) {
|
|
6013
6047
|
return [
|
|
6014
|
-
|
|
6048
|
+
Tc,
|
|
6015
6049
|
e,
|
|
6016
6050
|
t,
|
|
6017
6051
|
n,
|
|
6018
6052
|
r
|
|
6019
6053
|
].join("::");
|
|
6020
6054
|
}
|
|
6021
|
-
function
|
|
6055
|
+
function Ac(e, t, n) {
|
|
6022
6056
|
return [
|
|
6023
|
-
|
|
6057
|
+
Tc,
|
|
6024
6058
|
e,
|
|
6025
6059
|
t,
|
|
6026
6060
|
n
|
|
6027
6061
|
].join("::") + "::";
|
|
6028
6062
|
}
|
|
6029
|
-
function
|
|
6063
|
+
function jc(e, t) {
|
|
6030
6064
|
return [
|
|
6031
|
-
|
|
6065
|
+
Tc,
|
|
6032
6066
|
e,
|
|
6033
6067
|
t
|
|
6034
6068
|
].join("::") + "::";
|
|
6035
6069
|
}
|
|
6036
|
-
function
|
|
6037
|
-
return [
|
|
6070
|
+
function Mc(e) {
|
|
6071
|
+
return [Tc, e].join("::") + "::";
|
|
6038
6072
|
}
|
|
6039
|
-
var
|
|
6040
|
-
function
|
|
6041
|
-
|
|
6073
|
+
var Nc = null;
|
|
6074
|
+
function Pc(e) {
|
|
6075
|
+
Nc ||= new TextEncoder();
|
|
6042
6076
|
try {
|
|
6043
|
-
return
|
|
6077
|
+
return Nc.encode(JSON.stringify(e)).length;
|
|
6044
6078
|
} catch {
|
|
6045
6079
|
return 0;
|
|
6046
6080
|
}
|
|
6047
6081
|
}
|
|
6048
|
-
function
|
|
6082
|
+
function Fc(e, t, n) {
|
|
6049
6083
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
6050
6084
|
if (r <= t) return [];
|
|
6051
6085
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -6055,7 +6089,7 @@ function Pc(e, t, n) {
|
|
|
6055
6089
|
}
|
|
6056
6090
|
return o;
|
|
6057
6091
|
}
|
|
6058
|
-
function
|
|
6092
|
+
function Ic() {
|
|
6059
6093
|
let e = /* @__PURE__ */ new Map();
|
|
6060
6094
|
return {
|
|
6061
6095
|
async get(t) {
|
|
@@ -6075,7 +6109,7 @@ function Fc() {
|
|
|
6075
6109
|
}
|
|
6076
6110
|
};
|
|
6077
6111
|
}
|
|
6078
|
-
function
|
|
6112
|
+
function Lc(e) {
|
|
6079
6113
|
return new Promise((t, n) => {
|
|
6080
6114
|
if (typeof indexedDB > "u") {
|
|
6081
6115
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -6136,7 +6170,7 @@ function Ic(e) {
|
|
|
6136
6170
|
}, r.onerror = () => n(r.error);
|
|
6137
6171
|
});
|
|
6138
6172
|
}
|
|
6139
|
-
function
|
|
6173
|
+
function Rc(e) {
|
|
6140
6174
|
return {
|
|
6141
6175
|
async get(t) {
|
|
6142
6176
|
let n = e.getItem(t);
|
|
@@ -6181,12 +6215,12 @@ function Lc(e) {
|
|
|
6181
6215
|
}
|
|
6182
6216
|
};
|
|
6183
6217
|
}
|
|
6184
|
-
function
|
|
6218
|
+
function zc(e, t, n) {
|
|
6185
6219
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
6186
6220
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
6187
6221
|
}
|
|
6188
|
-
function
|
|
6189
|
-
let t = e.dbName ??
|
|
6222
|
+
function Bc(e = {}) {
|
|
6223
|
+
let t = e.dbName ?? _c, n = e.backend ?? "indexed", r = e.maxBytes ?? Dc(n), i = e.maxBytesPerSession ?? bc, a = e.evictionWatermark ?? xc, o = e.debounceMs ?? Sc, s = /* @__PURE__ */ new Set();
|
|
6190
6224
|
function c(e) {
|
|
6191
6225
|
for (let t of s) try {
|
|
6192
6226
|
t(e);
|
|
@@ -6199,16 +6233,16 @@ function zc(e = {}) {
|
|
|
6199
6233
|
try {
|
|
6200
6234
|
if (n === "indexed") {
|
|
6201
6235
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
6202
|
-
l = await
|
|
6236
|
+
l = await Lc(t), d(!0);
|
|
6203
6237
|
} else if (n === "session") {
|
|
6204
6238
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
6205
|
-
l =
|
|
6239
|
+
l = Rc(sessionStorage), d(!0);
|
|
6206
6240
|
} else if (n === "local") {
|
|
6207
6241
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
6208
|
-
l =
|
|
6209
|
-
} else l =
|
|
6242
|
+
l = Rc(localStorage), d(!0);
|
|
6243
|
+
} else l = Ic(), d(!1);
|
|
6210
6244
|
} catch (e) {
|
|
6211
|
-
l =
|
|
6245
|
+
l = Ic();
|
|
6212
6246
|
let t = e instanceof Error ? e.message : String(e);
|
|
6213
6247
|
d(!1), Promise.resolve().then(() => c({
|
|
6214
6248
|
type: "degraded",
|
|
@@ -6218,10 +6252,10 @@ function zc(e = {}) {
|
|
|
6218
6252
|
})();
|
|
6219
6253
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
6220
6254
|
function g(e, n, r, a) {
|
|
6221
|
-
let o =
|
|
6222
|
-
return
|
|
6255
|
+
let o = kc(t, r, a, wc);
|
|
6256
|
+
return zc(h, o, async () => {
|
|
6223
6257
|
let t = async () => {
|
|
6224
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
6258
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : Pc(s), d = Pc(n), f = (t?.bytes ?? 0) + (d - u);
|
|
6225
6259
|
if (f > i) {
|
|
6226
6260
|
c({
|
|
6227
6261
|
type: "quota",
|
|
@@ -6243,12 +6277,12 @@ function zc(e = {}) {
|
|
|
6243
6277
|
try {
|
|
6244
6278
|
await t();
|
|
6245
6279
|
} catch (e) {
|
|
6246
|
-
if (
|
|
6280
|
+
if (Oc(e) && !u) {
|
|
6247
6281
|
u = !0;
|
|
6248
6282
|
try {
|
|
6249
6283
|
await b();
|
|
6250
6284
|
} catch {}
|
|
6251
|
-
l =
|
|
6285
|
+
l = Ic(), Promise.resolve().then(() => c({
|
|
6252
6286
|
type: "degraded",
|
|
6253
6287
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
6254
6288
|
}));
|
|
@@ -6260,7 +6294,7 @@ function zc(e = {}) {
|
|
|
6260
6294
|
});
|
|
6261
6295
|
}
|
|
6262
6296
|
function _(e, n, r, i) {
|
|
6263
|
-
let a =
|
|
6297
|
+
let a = kc(t, e, n, r), s = p.get(a);
|
|
6264
6298
|
s && s.resolve();
|
|
6265
6299
|
let c = m.get(a);
|
|
6266
6300
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -6287,15 +6321,15 @@ function zc(e = {}) {
|
|
|
6287
6321
|
function y() {
|
|
6288
6322
|
v ||= setTimeout(() => {
|
|
6289
6323
|
v = null, b();
|
|
6290
|
-
},
|
|
6324
|
+
}, Cc);
|
|
6291
6325
|
}
|
|
6292
6326
|
async function b() {
|
|
6293
6327
|
let e = [];
|
|
6294
|
-
await l.scan(
|
|
6328
|
+
await l.scan(Mc(t), (t, n) => {
|
|
6295
6329
|
t.endsWith("::__meta__") && e.push(n);
|
|
6296
6330
|
});
|
|
6297
|
-
let n =
|
|
6298
|
-
for (let e of n) await l.clearPrefix(
|
|
6331
|
+
let n = Fc(e, r, a);
|
|
6332
|
+
for (let e of n) await l.clearPrefix(Ac(t, e.agentId, e.sessionId)), c({
|
|
6299
6333
|
type: "evicted",
|
|
6300
6334
|
agentId: e.agentId,
|
|
6301
6335
|
sessionId: e.sessionId,
|
|
@@ -6306,13 +6340,13 @@ function zc(e = {}) {
|
|
|
6306
6340
|
ready: f,
|
|
6307
6341
|
async listSessions(e) {
|
|
6308
6342
|
let n = [];
|
|
6309
|
-
return await l.scan(
|
|
6343
|
+
return await l.scan(jc(t, e), (e, t) => {
|
|
6310
6344
|
e.endsWith("::__meta__") && n.push(t);
|
|
6311
6345
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
6312
6346
|
},
|
|
6313
6347
|
async load(e, n) {
|
|
6314
|
-
let r =
|
|
6315
|
-
return await
|
|
6348
|
+
let r = kc(t, e, n, wc);
|
|
6349
|
+
return await zc(h, r, async () => {
|
|
6316
6350
|
let i = await l.get(r);
|
|
6317
6351
|
if (!i) return;
|
|
6318
6352
|
let a = {
|
|
@@ -6321,8 +6355,8 @@ function zc(e = {}) {
|
|
|
6321
6355
|
todos: [],
|
|
6322
6356
|
memory: ""
|
|
6323
6357
|
};
|
|
6324
|
-
for (let r of
|
|
6325
|
-
let i = await l.get(
|
|
6358
|
+
for (let r of Ec) {
|
|
6359
|
+
let i = await l.get(kc(t, e, n, r));
|
|
6326
6360
|
i != null && (a[r] = i);
|
|
6327
6361
|
}
|
|
6328
6362
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -6330,12 +6364,12 @@ function zc(e = {}) {
|
|
|
6330
6364
|
},
|
|
6331
6365
|
async save(e, t, n) {
|
|
6332
6366
|
let r = [];
|
|
6333
|
-
for (let i of
|
|
6367
|
+
for (let i of Ec) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
6334
6368
|
await Promise.all(r);
|
|
6335
6369
|
},
|
|
6336
6370
|
async updateTitle(e, n, r) {
|
|
6337
|
-
let i =
|
|
6338
|
-
return
|
|
6371
|
+
let i = kc(t, e, n, wc);
|
|
6372
|
+
return zc(h, i, async () => {
|
|
6339
6373
|
let e = await l.get(i);
|
|
6340
6374
|
e && (e.title = r, e.lastAccessed = Date.now(), await l.set(i, e));
|
|
6341
6375
|
});
|
|
@@ -6351,10 +6385,10 @@ function zc(e = {}) {
|
|
|
6351
6385
|
})), c({ type: "flush" }), await b();
|
|
6352
6386
|
},
|
|
6353
6387
|
async deleteSession(e, n) {
|
|
6354
|
-
await l.clearPrefix(
|
|
6388
|
+
await l.clearPrefix(Ac(t, e, n));
|
|
6355
6389
|
},
|
|
6356
6390
|
async createSession(e, n, r) {
|
|
6357
|
-
let i = r ??
|
|
6391
|
+
let i = r ?? gc(), a = Date.now(), o = {
|
|
6358
6392
|
agentId: e,
|
|
6359
6393
|
sessionId: i,
|
|
6360
6394
|
createdAt: a,
|
|
@@ -6362,7 +6396,7 @@ function zc(e = {}) {
|
|
|
6362
6396
|
bytes: 0,
|
|
6363
6397
|
title: n
|
|
6364
6398
|
};
|
|
6365
|
-
return await l.set(
|
|
6399
|
+
return await l.set(kc(t, e, i, wc), o), i;
|
|
6366
6400
|
},
|
|
6367
6401
|
onEvent(e) {
|
|
6368
6402
|
s.add(e);
|
|
@@ -6377,15 +6411,15 @@ function zc(e = {}) {
|
|
|
6377
6411
|
}
|
|
6378
6412
|
//#endregion
|
|
6379
6413
|
//#region src/core/sdk/optionsResolver.ts
|
|
6380
|
-
function Bc(e) {
|
|
6381
|
-
return e === void 0 || e === !1 ? null : typeof e == "string" ? zc({ backend: e }) : e.enabled === !1 ? null : zc(e);
|
|
6382
|
-
}
|
|
6383
6414
|
function Vc(e) {
|
|
6415
|
+
return e === void 0 || e === !1 ? null : typeof e == "string" ? Bc({ backend: e }) : e.enabled === !1 ? null : Bc(e);
|
|
6416
|
+
}
|
|
6417
|
+
function Hc(e) {
|
|
6384
6418
|
return e.dialog ?? {};
|
|
6385
6419
|
}
|
|
6386
6420
|
//#endregion
|
|
6387
6421
|
//#region src/core/capabilities.ts
|
|
6388
|
-
var
|
|
6422
|
+
var Uc = [
|
|
6389
6423
|
{
|
|
6390
6424
|
name: "dataOps",
|
|
6391
6425
|
defaultOn: !0
|
|
@@ -6474,13 +6508,13 @@ var Hc = [
|
|
|
6474
6508
|
requires: ["summarization"]
|
|
6475
6509
|
}
|
|
6476
6510
|
];
|
|
6477
|
-
function
|
|
6511
|
+
function Wc(e) {
|
|
6478
6512
|
let t = {};
|
|
6479
|
-
for (let n of
|
|
6513
|
+
for (let n of Uc) {
|
|
6480
6514
|
let r = e?.[n.name];
|
|
6481
6515
|
t[n.name] = n.defaultOn ? r !== !1 : r === !0;
|
|
6482
6516
|
}
|
|
6483
|
-
for (let e of
|
|
6517
|
+
for (let e of Uc) if (e.requires && t[e.name]) {
|
|
6484
6518
|
for (let n of e.requires) if (!t[n]) {
|
|
6485
6519
|
t[e.name] = !1;
|
|
6486
6520
|
break;
|
|
@@ -6490,7 +6524,7 @@ function Uc(e) {
|
|
|
6490
6524
|
}
|
|
6491
6525
|
//#endregion
|
|
6492
6526
|
//#region src/core/sdk/events.ts
|
|
6493
|
-
function
|
|
6527
|
+
function Gc(e) {
|
|
6494
6528
|
let t = /* @__PURE__ */ new Set(), n = (n) => {
|
|
6495
6529
|
if (n.type !== "approval_request") {
|
|
6496
6530
|
if (e) try {
|
|
@@ -6516,7 +6550,7 @@ function Wc(e) {
|
|
|
6516
6550
|
}
|
|
6517
6551
|
//#endregion
|
|
6518
6552
|
//#region src/core/sdk/contextPreset.ts
|
|
6519
|
-
var
|
|
6553
|
+
var Kc = {
|
|
6520
6554
|
auto: {
|
|
6521
6555
|
summaryThresholdRatio: .5,
|
|
6522
6556
|
windowRatio: .4,
|
|
@@ -6544,7 +6578,7 @@ var Gc = {
|
|
|
6544
6578
|
enableRecall: !0,
|
|
6545
6579
|
enableLLMSummary: !0
|
|
6546
6580
|
}
|
|
6547
|
-
},
|
|
6581
|
+
}, qc = {
|
|
6548
6582
|
auto: ["describe_data", "read"],
|
|
6549
6583
|
conservative: ["describe_data"],
|
|
6550
6584
|
aggressive: ["describe_data", "read"],
|
|
@@ -6555,8 +6589,8 @@ var Gc = {
|
|
|
6555
6589
|
"search_data"
|
|
6556
6590
|
]
|
|
6557
6591
|
};
|
|
6558
|
-
function
|
|
6559
|
-
let n =
|
|
6592
|
+
function Jc(e, t) {
|
|
6593
|
+
let n = Kc[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
6560
6594
|
return {
|
|
6561
6595
|
...n,
|
|
6562
6596
|
...r,
|
|
@@ -6566,7 +6600,7 @@ function qc(e, t) {
|
|
|
6566
6600
|
}
|
|
6567
6601
|
//#endregion
|
|
6568
6602
|
//#region src/core/sdk/middlewareStack.ts
|
|
6569
|
-
var
|
|
6603
|
+
var Yc = {
|
|
6570
6604
|
dataHint: 10,
|
|
6571
6605
|
usageHints: 20,
|
|
6572
6606
|
todos: 30,
|
|
@@ -6583,17 +6617,17 @@ var Jc = {
|
|
|
6583
6617
|
subagents: 140,
|
|
6584
6618
|
augmentSystem: 150
|
|
6585
6619
|
};
|
|
6586
|
-
function
|
|
6620
|
+
function Xc(e) {
|
|
6587
6621
|
return e.map((e, t) => ({
|
|
6588
6622
|
m: e,
|
|
6589
6623
|
i: t,
|
|
6590
|
-
p:
|
|
6624
|
+
p: Yc[e.name] ?? Infinity
|
|
6591
6625
|
})).sort((e, t) => e.p - t.p || e.i - t.i).map((e) => e.m);
|
|
6592
6626
|
}
|
|
6593
6627
|
//#endregion
|
|
6594
6628
|
//#region src/core/tools/dataSlotQuery.ts
|
|
6595
|
-
var
|
|
6596
|
-
function
|
|
6629
|
+
var Zc = /[\w$-]/;
|
|
6630
|
+
function Qc(e) {
|
|
6597
6631
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
6598
6632
|
for (; r < n.length;) {
|
|
6599
6633
|
let e = n[r];
|
|
@@ -6604,7 +6638,7 @@ function Zc(e) {
|
|
|
6604
6638
|
continue;
|
|
6605
6639
|
}
|
|
6606
6640
|
let e = "";
|
|
6607
|
-
for (; r < n.length &&
|
|
6641
|
+
for (; r < n.length && Zc.test(n[r]);) e += n[r++];
|
|
6608
6642
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
6609
6643
|
t.push({
|
|
6610
6644
|
type: "descendKey",
|
|
@@ -6617,7 +6651,7 @@ function Zc(e) {
|
|
|
6617
6651
|
continue;
|
|
6618
6652
|
}
|
|
6619
6653
|
let e = "";
|
|
6620
|
-
for (; r < n.length &&
|
|
6654
|
+
for (; r < n.length && Zc.test(n[r]);) e += n[r++];
|
|
6621
6655
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
6622
6656
|
t.push({
|
|
6623
6657
|
type: "key",
|
|
@@ -6673,7 +6707,7 @@ function Zc(e) {
|
|
|
6673
6707
|
}
|
|
6674
6708
|
return t;
|
|
6675
6709
|
}
|
|
6676
|
-
function
|
|
6710
|
+
function $c(e) {
|
|
6677
6711
|
let t = [], n = 0, r = e.trim();
|
|
6678
6712
|
for (; n < r.length;) {
|
|
6679
6713
|
let e = r[n];
|
|
@@ -6718,7 +6752,7 @@ function Qc(e) {
|
|
|
6718
6752
|
}
|
|
6719
6753
|
return t;
|
|
6720
6754
|
}
|
|
6721
|
-
var
|
|
6755
|
+
var el = class {
|
|
6722
6756
|
toks;
|
|
6723
6757
|
item;
|
|
6724
6758
|
pos = 0;
|
|
@@ -6754,12 +6788,12 @@ var $c = class {
|
|
|
6754
6788
|
return this.next(), e;
|
|
6755
6789
|
}
|
|
6756
6790
|
let e = this.operand(), t = this.peek();
|
|
6757
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
6791
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), rl(t, e, this.operand())) : tl(e);
|
|
6758
6792
|
}
|
|
6759
6793
|
operand() {
|
|
6760
6794
|
let e = this.next();
|
|
6761
6795
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
6762
|
-
if (e.startsWith("@")) return
|
|
6796
|
+
if (e.startsWith("@")) return nl(e, this.item);
|
|
6763
6797
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
6764
6798
|
if (e === "true") return !0;
|
|
6765
6799
|
if (e === "false") return !1;
|
|
@@ -6769,10 +6803,10 @@ var $c = class {
|
|
|
6769
6803
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
6770
6804
|
}
|
|
6771
6805
|
};
|
|
6772
|
-
function
|
|
6806
|
+
function tl(e) {
|
|
6773
6807
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
6774
6808
|
}
|
|
6775
|
-
function
|
|
6809
|
+
function nl(e, t) {
|
|
6776
6810
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
6777
6811
|
for (let e of n) {
|
|
6778
6812
|
if (typeof r != "object" || !r) return;
|
|
@@ -6780,7 +6814,7 @@ function tl(e, t) {
|
|
|
6780
6814
|
}
|
|
6781
6815
|
return r;
|
|
6782
6816
|
}
|
|
6783
|
-
function
|
|
6817
|
+
function rl(e, t, n) {
|
|
6784
6818
|
switch (e) {
|
|
6785
6819
|
case "==": return t === n;
|
|
6786
6820
|
case "!=": return t !== n;
|
|
@@ -6791,47 +6825,47 @@ function nl(e, t, n) {
|
|
|
6791
6825
|
default: return !1;
|
|
6792
6826
|
}
|
|
6793
6827
|
}
|
|
6794
|
-
function rl(e, t) {
|
|
6795
|
-
return new $c(Qc(e), t).parse();
|
|
6796
|
-
}
|
|
6797
6828
|
function il(e, t) {
|
|
6798
|
-
return
|
|
6829
|
+
return new el($c(e), t).parse();
|
|
6799
6830
|
}
|
|
6800
6831
|
function al(e, t) {
|
|
6832
|
+
return e ? `${e}.${t}` : String(t);
|
|
6833
|
+
}
|
|
6834
|
+
function ol(e, t) {
|
|
6801
6835
|
let n = [{
|
|
6802
6836
|
path: "",
|
|
6803
6837
|
value: e
|
|
6804
6838
|
}];
|
|
6805
|
-
for (let e of
|
|
6839
|
+
for (let e of Qc(t)) {
|
|
6806
6840
|
let t = [];
|
|
6807
6841
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
6808
|
-
path:
|
|
6842
|
+
path: al(r.path, e.key),
|
|
6809
6843
|
value: r.value[e.key]
|
|
6810
6844
|
});
|
|
6811
6845
|
else if (e.type === "index") {
|
|
6812
6846
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
6813
6847
|
let n = r.value[e.index];
|
|
6814
6848
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
6815
|
-
path:
|
|
6849
|
+
path: al(r.path, e.index),
|
|
6816
6850
|
value: n,
|
|
6817
6851
|
index: e.index
|
|
6818
6852
|
});
|
|
6819
6853
|
}
|
|
6820
6854
|
} else if (e.type === "wildcard") {
|
|
6821
6855
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
6822
|
-
path:
|
|
6856
|
+
path: al(e.path, r),
|
|
6823
6857
|
value: n,
|
|
6824
6858
|
index: r
|
|
6825
6859
|
}));
|
|
6826
6860
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
6827
|
-
path:
|
|
6861
|
+
path: al(e.path, n),
|
|
6828
6862
|
value: e.value[n]
|
|
6829
6863
|
});
|
|
6830
6864
|
} else if (e.type === "descendKey") {
|
|
6831
6865
|
let r = e.key, i = (e) => {
|
|
6832
6866
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
6833
6867
|
let a = {
|
|
6834
|
-
path:
|
|
6868
|
+
path: al(e.path, n),
|
|
6835
6869
|
value: e.value[n]
|
|
6836
6870
|
};
|
|
6837
6871
|
n === r && t.push(a), i(a);
|
|
@@ -6842,7 +6876,7 @@ function al(e, t) {
|
|
|
6842
6876
|
let e = (n) => {
|
|
6843
6877
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
6844
6878
|
let i = {
|
|
6845
|
-
path:
|
|
6879
|
+
path: al(n.path, r),
|
|
6846
6880
|
value: n.value[r]
|
|
6847
6881
|
};
|
|
6848
6882
|
t.push(i), e(i);
|
|
@@ -6851,16 +6885,16 @@ function al(e, t) {
|
|
|
6851
6885
|
for (let t of n) e(t);
|
|
6852
6886
|
} else if (e.type === "filter") {
|
|
6853
6887
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
6854
|
-
|
|
6855
|
-
path:
|
|
6888
|
+
il(e.filter, n) && t.push({
|
|
6889
|
+
path: al(r.path, i),
|
|
6856
6890
|
value: n,
|
|
6857
6891
|
index: i
|
|
6858
6892
|
});
|
|
6859
6893
|
});
|
|
6860
6894
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
6861
6895
|
let i = r.value[n];
|
|
6862
|
-
|
|
6863
|
-
path:
|
|
6896
|
+
il(e.filter, i) && t.push({
|
|
6897
|
+
path: al(r.path, n),
|
|
6864
6898
|
value: i
|
|
6865
6899
|
});
|
|
6866
6900
|
}
|
|
@@ -6869,7 +6903,7 @@ function al(e, t) {
|
|
|
6869
6903
|
}
|
|
6870
6904
|
return n;
|
|
6871
6905
|
}
|
|
6872
|
-
function
|
|
6906
|
+
function sl(e, t) {
|
|
6873
6907
|
let n = e.length, r = t.length;
|
|
6874
6908
|
if (!n) return r;
|
|
6875
6909
|
if (!r) return n;
|
|
@@ -6885,7 +6919,7 @@ function ol(e, t) {
|
|
|
6885
6919
|
}
|
|
6886
6920
|
return i[r];
|
|
6887
6921
|
}
|
|
6888
|
-
function
|
|
6922
|
+
function cl(e, t, n = {}) {
|
|
6889
6923
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
6890
6924
|
if (r === "regex") try {
|
|
6891
6925
|
s = new RegExp(t, "i");
|
|
@@ -6895,11 +6929,11 @@ function sl(e, t, n = {}) {
|
|
|
6895
6929
|
let c = (e, l, u) => {
|
|
6896
6930
|
if (o.length >= i || e == null) return;
|
|
6897
6931
|
if (typeof e == "object") {
|
|
6898
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
6899
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
6932
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, al(l, t), String(t)));
|
|
6933
|
+
else for (let t of Object.keys(e)) c(e[t], al(l, t), t);
|
|
6900
6934
|
return;
|
|
6901
6935
|
}
|
|
6902
|
-
let d = String(e), f =
|
|
6936
|
+
let d = String(e), f = ll(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
6903
6937
|
if (f) {
|
|
6904
6938
|
o.push({
|
|
6905
6939
|
path: l,
|
|
@@ -6910,7 +6944,7 @@ function sl(e, t, n = {}) {
|
|
|
6910
6944
|
return;
|
|
6911
6945
|
}
|
|
6912
6946
|
if (a && u) {
|
|
6913
|
-
let e =
|
|
6947
|
+
let e = ll(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
6914
6948
|
e && o.push({
|
|
6915
6949
|
path: l,
|
|
6916
6950
|
key: u,
|
|
@@ -6921,51 +6955,51 @@ function sl(e, t, n = {}) {
|
|
|
6921
6955
|
};
|
|
6922
6956
|
return c(e, ""), o;
|
|
6923
6957
|
}
|
|
6924
|
-
function
|
|
6958
|
+
function ll(e, t, n, r, i) {
|
|
6925
6959
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
6926
6960
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
6927
6961
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
6928
6962
|
if (n === "fuzzy") {
|
|
6929
6963
|
if (a.includes(o)) return 2;
|
|
6930
|
-
let e =
|
|
6964
|
+
let e = sl(a, o);
|
|
6931
6965
|
return e <= r ? r - e + 1 : null;
|
|
6932
6966
|
}
|
|
6933
6967
|
return null;
|
|
6934
6968
|
}
|
|
6935
|
-
function
|
|
6969
|
+
function ul(e, t, n = 3e3) {
|
|
6936
6970
|
return Ta(t, n)(e);
|
|
6937
6971
|
}
|
|
6938
6972
|
//#endregion
|
|
6939
6973
|
//#region src/core/tools/resources.ts
|
|
6940
|
-
var
|
|
6941
|
-
function pl(e) {
|
|
6942
|
-
return `${ul}${e}${fl}`;
|
|
6943
|
-
}
|
|
6974
|
+
var dl = "⟦frozen:", fl = "⟦res:", pl = "⟧";
|
|
6944
6975
|
function ml(e) {
|
|
6945
|
-
return `${dl}${e}${
|
|
6976
|
+
return `${dl}${e}${pl}`;
|
|
6946
6977
|
}
|
|
6947
6978
|
function hl(e) {
|
|
6948
|
-
return
|
|
6979
|
+
return `${fl}${e}${pl}`;
|
|
6980
|
+
}
|
|
6981
|
+
function gl(e) {
|
|
6982
|
+
return typeof e == "string" ? e.startsWith(dl) && e.endsWith(pl) ? {
|
|
6949
6983
|
type: "frozen",
|
|
6950
6984
|
path: e.slice(8, e.length - 1)
|
|
6951
|
-
} : e.startsWith(
|
|
6985
|
+
} : e.startsWith(fl) && e.endsWith(pl) ? {
|
|
6952
6986
|
type: "res",
|
|
6953
6987
|
handle: e.slice(5, e.length - 1)
|
|
6954
6988
|
} : null : null;
|
|
6955
6989
|
}
|
|
6956
|
-
function
|
|
6990
|
+
function _l(e) {
|
|
6957
6991
|
return String(e ?? "").trim().replace(/^\.+/, "");
|
|
6958
6992
|
}
|
|
6959
|
-
function
|
|
6993
|
+
function vl(e) {
|
|
6960
6994
|
let t = 5381;
|
|
6961
6995
|
for (let n = 0; n < e.length; n++) t = (t * 33 ^ e.charCodeAt(n)) >>> 0;
|
|
6962
6996
|
return (t >>> 0).toString(16).padStart(8, "0").slice(0, 8);
|
|
6963
6997
|
}
|
|
6964
|
-
function
|
|
6998
|
+
function yl(e, t) {
|
|
6965
6999
|
return e === t ? !0 : e && t && typeof e == "object" && typeof t == "object" ? JSON.stringify(e) === JSON.stringify(t) : !1;
|
|
6966
7000
|
}
|
|
6967
|
-
function
|
|
6968
|
-
let n =
|
|
7001
|
+
function bl(e, t) {
|
|
7002
|
+
let n = _l(e);
|
|
6969
7003
|
if (!n) return;
|
|
6970
7004
|
let r = t.get(n);
|
|
6971
7005
|
if (r) return {
|
|
@@ -6985,7 +7019,7 @@ function yl(e, t) {
|
|
|
6985
7019
|
}));
|
|
6986
7020
|
return i;
|
|
6987
7021
|
}
|
|
6988
|
-
var
|
|
7022
|
+
var xl = class {
|
|
6989
7023
|
vfs;
|
|
6990
7024
|
constructor(e) {
|
|
6991
7025
|
this.vfs = e;
|
|
@@ -6994,7 +7028,7 @@ var bl = class {
|
|
|
6994
7028
|
return `resources/${e}.json`;
|
|
6995
7029
|
}
|
|
6996
7030
|
ensure(e, t, n) {
|
|
6997
|
-
let r =
|
|
7031
|
+
let r = vl(e), i = {
|
|
6998
7032
|
path: e,
|
|
6999
7033
|
mode: n,
|
|
7000
7034
|
value: t,
|
|
@@ -7006,7 +7040,7 @@ var bl = class {
|
|
|
7006
7040
|
}, r;
|
|
7007
7041
|
}
|
|
7008
7042
|
get(e) {
|
|
7009
|
-
return this.readEntry(this.key(e)) || this.readEntry(this.key(
|
|
7043
|
+
return this.readEntry(this.key(e)) || this.readEntry(this.key(vl(e)));
|
|
7010
7044
|
}
|
|
7011
7045
|
readEntry(e) {
|
|
7012
7046
|
let t = this.vfs.files[e];
|
|
@@ -7022,7 +7056,7 @@ var bl = class {
|
|
|
7022
7056
|
this.ensure(e, t, n?.mode ?? "verbatim");
|
|
7023
7057
|
}
|
|
7024
7058
|
delete(e) {
|
|
7025
|
-
let t = this.get(e)?.handle ??
|
|
7059
|
+
let t = this.get(e)?.handle ?? vl(e), n = this.key(t), r = !!this.vfs.files[n];
|
|
7026
7060
|
return r && delete this.vfs.files[n], r;
|
|
7027
7061
|
}
|
|
7028
7062
|
list() {
|
|
@@ -7042,7 +7076,7 @@ var bl = class {
|
|
|
7042
7076
|
for (let e of Object.keys(this.vfs.files)) e.startsWith("resources/") && delete this.vfs.files[e];
|
|
7043
7077
|
}
|
|
7044
7078
|
};
|
|
7045
|
-
function
|
|
7079
|
+
function Sl(e) {
|
|
7046
7080
|
let { jp: t, resolved: n, resourcesByPath: r, resourceStore: i } = e;
|
|
7047
7081
|
if (!r.size) return n;
|
|
7048
7082
|
let a = !1;
|
|
@@ -7056,14 +7090,14 @@ function xl(e) {
|
|
|
7056
7090
|
if (t !== "" && e !== t && !e.startsWith(t + ".")) continue;
|
|
7057
7091
|
if (e === t) {
|
|
7058
7092
|
if (o === void 0) continue;
|
|
7059
|
-
return n.mode === "freeze" ?
|
|
7093
|
+
return n.mode === "freeze" ? ml(e) : i ? hl(i.ensure(e, o, "verbatim")) : o;
|
|
7060
7094
|
}
|
|
7061
7095
|
let r = t === "" ? e : e.slice(t.length + 1), a = Z(o, r);
|
|
7062
|
-
a !== void 0 && (n.mode === "freeze" ? ws(o, r,
|
|
7096
|
+
a !== void 0 && (n.mode === "freeze" ? ws(o, r, ml(e)) : i && ws(o, r, hl(i.ensure(e, a, "verbatim"))));
|
|
7063
7097
|
}
|
|
7064
7098
|
return o;
|
|
7065
7099
|
}
|
|
7066
|
-
function
|
|
7100
|
+
function Cl(e, t, n, r) {
|
|
7067
7101
|
if (!r) return {
|
|
7068
7102
|
code: "RESOURCE_NOT_FOUND",
|
|
7069
7103
|
message: `句柄 "${e}" 无法展开(资源池未启用)`,
|
|
@@ -7074,7 +7108,7 @@ function Sl(e, t, n, r) {
|
|
|
7074
7108
|
code: "RESOURCE_NOT_FOUND",
|
|
7075
7109
|
message: `字段 "${t}" 在 bind 中已不存在,无法展开句柄 "${e}"`,
|
|
7076
7110
|
hint: "该字段可能已被删除或 restore 到不含此字段的快照;重新 read 确认当前结构"
|
|
7077
|
-
} :
|
|
7111
|
+
} : yl(i.value, n) ? { value: i.value } : (r.update(t, n), { value: n }) : n === void 0 ? {
|
|
7078
7112
|
code: "RESOURCE_NOT_FOUND",
|
|
7079
7113
|
message: `句柄 "${e}" 不存在(字段 "${t}" 可能未注册或已被删除)`,
|
|
7080
7114
|
hint: "重新 read 该字段触发懒注册"
|
|
@@ -7084,7 +7118,7 @@ function Sl(e, t, n, r) {
|
|
|
7084
7118
|
hint: "重新 read 该字段触发懒注册重建句柄,再写回新句柄 ⟦res:<handle>⟧"
|
|
7085
7119
|
};
|
|
7086
7120
|
}
|
|
7087
|
-
function
|
|
7121
|
+
function wl(e, t) {
|
|
7088
7122
|
let n = t.getBind();
|
|
7089
7123
|
for (let [r, i] of t.resourcesByPath) {
|
|
7090
7124
|
let a = Z(n, r), o = Z(e, r);
|
|
@@ -7093,11 +7127,11 @@ function Cl(e, t) {
|
|
|
7093
7127
|
continue;
|
|
7094
7128
|
}
|
|
7095
7129
|
if (i.mode === "freeze") {
|
|
7096
|
-
if (o ===
|
|
7130
|
+
if (o === ml(r)) {
|
|
7097
7131
|
ws(e, r, a);
|
|
7098
7132
|
continue;
|
|
7099
7133
|
}
|
|
7100
|
-
if (!
|
|
7134
|
+
if (!yl(o, a)) return {
|
|
7101
7135
|
ok: !1,
|
|
7102
7136
|
code: "FROZEN_FIELD",
|
|
7103
7137
|
path: r,
|
|
@@ -7105,9 +7139,9 @@ function Cl(e, t) {
|
|
|
7105
7139
|
hint: "该字段由系统/集成方维护,LLM 不得改动。如需展示其值用 resource_get({path}) 取真值"
|
|
7106
7140
|
};
|
|
7107
7141
|
} else {
|
|
7108
|
-
let n =
|
|
7142
|
+
let n = gl(o);
|
|
7109
7143
|
if (n && n.type === "res") {
|
|
7110
|
-
let i =
|
|
7144
|
+
let i = Cl(n.handle, r, a, t.resourceStore);
|
|
7111
7145
|
if ("value" in i) {
|
|
7112
7146
|
ws(e, r, i.value);
|
|
7113
7147
|
continue;
|
|
@@ -7120,7 +7154,7 @@ function Cl(e, t) {
|
|
|
7120
7154
|
hint: i.hint
|
|
7121
7155
|
};
|
|
7122
7156
|
}
|
|
7123
|
-
if (!
|
|
7157
|
+
if (!yl(o, a)) return {
|
|
7124
7158
|
ok: !1,
|
|
7125
7159
|
code: "VERBATIM_MISMATCH",
|
|
7126
7160
|
path: r,
|
|
@@ -7131,7 +7165,7 @@ function Cl(e, t) {
|
|
|
7131
7165
|
}
|
|
7132
7166
|
return { ok: !0 };
|
|
7133
7167
|
}
|
|
7134
|
-
function
|
|
7168
|
+
function Tl(e, t, n) {
|
|
7135
7169
|
let r = t === void 0 ? e.message : `patches[${t}]${n ? ` @ "${n}"` : ""}: ${e.message}`;
|
|
7136
7170
|
return Y({
|
|
7137
7171
|
code: e.code,
|
|
@@ -7144,28 +7178,28 @@ function wl(e, t, n) {
|
|
|
7144
7178
|
} }
|
|
7145
7179
|
});
|
|
7146
7180
|
}
|
|
7147
|
-
function
|
|
7181
|
+
function El(e) {
|
|
7148
7182
|
let { value: t, ctx: n } = e;
|
|
7149
7183
|
if (!n || !n.resourcesByPath.size) return {
|
|
7150
7184
|
ok: !0,
|
|
7151
7185
|
value: t
|
|
7152
7186
|
};
|
|
7153
|
-
let r = Es(t), i =
|
|
7187
|
+
let r = Es(t), i = wl(r, n);
|
|
7154
7188
|
return i.ok ? {
|
|
7155
7189
|
ok: !0,
|
|
7156
7190
|
value: r
|
|
7157
7191
|
} : {
|
|
7158
7192
|
ok: !1,
|
|
7159
|
-
error:
|
|
7193
|
+
error: Tl(i)
|
|
7160
7194
|
};
|
|
7161
7195
|
}
|
|
7162
|
-
function
|
|
7196
|
+
function Dl(e) {
|
|
7163
7197
|
let { patches: t, clone: n, ctx: r } = e;
|
|
7164
7198
|
if (!r || !r.resourcesByPath.size) return { ok: !0 };
|
|
7165
7199
|
for (let e = 0; e < t.length; e++) {
|
|
7166
7200
|
let n = t[e];
|
|
7167
7201
|
if (n.op === "remove") {
|
|
7168
|
-
let t =
|
|
7202
|
+
let t = bl(n.jsonPath || "", r.resourcesByPath);
|
|
7169
7203
|
if (t) {
|
|
7170
7204
|
let r = t.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED", i = t.spec.mode === "freeze" ? "冻结字段不可删。如需移除请联系集成方调整 data.resources 配置" : "verbatim 字段不可直接删;先 resource_delete({path}) 释放资源保护后再删";
|
|
7171
7205
|
return {
|
|
@@ -7184,27 +7218,27 @@ function El(e) {
|
|
|
7184
7218
|
}
|
|
7185
7219
|
}
|
|
7186
7220
|
}
|
|
7187
|
-
let i =
|
|
7221
|
+
let i = wl(n, r);
|
|
7188
7222
|
if (!i.ok) {
|
|
7189
|
-
let e =
|
|
7223
|
+
let e = Ol(i.path, t);
|
|
7190
7224
|
return {
|
|
7191
7225
|
ok: !1,
|
|
7192
|
-
error:
|
|
7226
|
+
error: Tl(i, e >= 0 ? e : void 0, e >= 0 ? t[e].jsonPath : void 0)
|
|
7193
7227
|
};
|
|
7194
7228
|
}
|
|
7195
7229
|
return { ok: !0 };
|
|
7196
7230
|
}
|
|
7197
|
-
function
|
|
7198
|
-
let n =
|
|
7231
|
+
function Ol(e, t) {
|
|
7232
|
+
let n = _l(e);
|
|
7199
7233
|
for (let e = 0; e < t.length; e++) {
|
|
7200
|
-
let r =
|
|
7234
|
+
let r = _l(t[e].jsonPath || "");
|
|
7201
7235
|
if (r && (r === n || n.startsWith(r + ".") || r.startsWith(n + "."))) return e;
|
|
7202
7236
|
}
|
|
7203
7237
|
return -1;
|
|
7204
7238
|
}
|
|
7205
7239
|
//#endregion
|
|
7206
7240
|
//#region src/core/tools/dataOps.ts
|
|
7207
|
-
var
|
|
7241
|
+
var kl = /* @__PURE__ */ new Set([
|
|
7208
7242
|
"describe_data",
|
|
7209
7243
|
"get_data",
|
|
7210
7244
|
"set_data",
|
|
@@ -7218,14 +7252,14 @@ var Ol = /* @__PURE__ */ new Set([
|
|
|
7218
7252
|
"resource_update",
|
|
7219
7253
|
"resource_list",
|
|
7220
7254
|
"resource_delete"
|
|
7221
|
-
]),
|
|
7222
|
-
function
|
|
7223
|
-
return t === "advanced" ? e : t === "minimal" ? e.filter((e) =>
|
|
7255
|
+
]), Al = /* @__PURE__ */ new Set(["read", "write"]);
|
|
7256
|
+
function jl(e, t = "simple") {
|
|
7257
|
+
return t === "advanced" ? e : t === "minimal" ? e.filter((e) => Al.has(e.name)) : e.filter((e) => !kl.has(e.name));
|
|
7224
7258
|
}
|
|
7225
|
-
function
|
|
7259
|
+
function Ml(e) {
|
|
7226
7260
|
let { bindRef: t, schema: n, allowKeys: r, snapshots: i, maxSnapshots: a, audit: o, dryRun: s, op: c = "set", protectedCtx: l } = e, u = e.value;
|
|
7227
7261
|
if (l) {
|
|
7228
|
-
let e =
|
|
7262
|
+
let e = El({
|
|
7229
7263
|
value: u,
|
|
7230
7264
|
ctx: l
|
|
7231
7265
|
});
|
|
@@ -7270,7 +7304,7 @@ function jl(e) {
|
|
|
7270
7304
|
data: d.data
|
|
7271
7305
|
};
|
|
7272
7306
|
}
|
|
7273
|
-
function
|
|
7307
|
+
function Nl(e) {
|
|
7274
7308
|
let { bindRef: t, patches: n, schema: r, allowKeys: i, snapshots: a, maxSnapshots: o, markDataDirty: s, schemaErrorMode: c = "zod", snapshotLabel: l, dryRun: u, protectedCtx: d } = e, f = Es(t), p = [];
|
|
7275
7309
|
for (let e = 0; e < n.length; e++) {
|
|
7276
7310
|
let t = n[e], a = t.jsonPath || "";
|
|
@@ -7323,7 +7357,7 @@ function Ml(e) {
|
|
|
7323
7357
|
});
|
|
7324
7358
|
}
|
|
7325
7359
|
if (d) {
|
|
7326
|
-
let e =
|
|
7360
|
+
let e = Dl({
|
|
7327
7361
|
patches: n,
|
|
7328
7362
|
clone: f,
|
|
7329
7363
|
ctx: d
|
|
@@ -7363,41 +7397,41 @@ function Ml(e) {
|
|
|
7363
7397
|
clone: f
|
|
7364
7398
|
};
|
|
7365
7399
|
}
|
|
7366
|
-
function
|
|
7400
|
+
function Pl(e) {
|
|
7367
7401
|
return e < 1024 ? `${e}B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)}KB` : `${(e / (1024 * 1024)).toFixed(1)}MB`;
|
|
7368
7402
|
}
|
|
7369
|
-
function
|
|
7403
|
+
function Fl(e, t, n, r) {
|
|
7370
7404
|
if (!t || !n.length || typeof e != "object" || !e) return e;
|
|
7371
7405
|
let i = new Set(n.map((e) => e.field)), a = Es(e);
|
|
7372
7406
|
return (function e(t) {
|
|
7373
7407
|
if (Array.isArray(t)) for (let n of t) e(n);
|
|
7374
7408
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) {
|
|
7375
7409
|
let a = t[n];
|
|
7376
|
-
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${
|
|
7410
|
+
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${Pl(a.length)}>` : e(a);
|
|
7377
7411
|
}
|
|
7378
7412
|
})(a), a;
|
|
7379
7413
|
}
|
|
7380
|
-
var
|
|
7381
|
-
function
|
|
7382
|
-
return
|
|
7414
|
+
var Il = 0;
|
|
7415
|
+
function Ll() {
|
|
7416
|
+
return Il++, "c_" + Math.random().toString(36).slice(2, 8) + Il.toString(36);
|
|
7383
7417
|
}
|
|
7384
|
-
function
|
|
7418
|
+
function Rl(e, t) {
|
|
7385
7419
|
if (!(!e || typeof e != "object")) for (let n of t) {
|
|
7386
7420
|
let t = Z(e, n);
|
|
7387
|
-
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId =
|
|
7421
|
+
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId = Ll());
|
|
7388
7422
|
}
|
|
7389
7423
|
}
|
|
7390
|
-
function
|
|
7424
|
+
function zl(e) {
|
|
7391
7425
|
(function e(t) {
|
|
7392
7426
|
if (Array.isArray(t)) t.forEach(e);
|
|
7393
7427
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) n.startsWith("__pg") ? delete t[n] : e(t[n]);
|
|
7394
7428
|
})(e);
|
|
7395
7429
|
}
|
|
7396
|
-
function
|
|
7397
|
-
let i = n.pgIdPaths ?? [], a = i.length ? (e) =>
|
|
7430
|
+
function Bl(e, n = {}) {
|
|
7431
|
+
let i = n.pgIdPaths ?? [], a = i.length ? (e) => Rl(e, i) : void 0, o = i.length ? Qi(e.schema, i).schema : e.schema, s = e.bind, c = e.description ?? "主数据对象", l = Ii(o), u = /* @__PURE__ */ new Map(), d = n.vfsStore ? new xl(n.vfsStore) : void 0;
|
|
7398
7432
|
function f(e) {
|
|
7399
7433
|
if (u.clear(), e) for (let t of e) {
|
|
7400
|
-
let e =
|
|
7434
|
+
let e = _l(t.path);
|
|
7401
7435
|
u.set(e, {
|
|
7402
7436
|
path: e,
|
|
7403
7437
|
mode: t.mode
|
|
@@ -7469,7 +7503,7 @@ function zl(e, n = {}) {
|
|
|
7469
7503
|
return e;
|
|
7470
7504
|
},
|
|
7471
7505
|
createResource: d ? (e, t) => {
|
|
7472
|
-
let n =
|
|
7506
|
+
let n = _l(e), r = u.get(n), i = t === void 0 ? Z(s, n) : t;
|
|
7473
7507
|
return d.ensure(n, i, r?.mode ?? "verbatim");
|
|
7474
7508
|
} : void 0,
|
|
7475
7509
|
getResource: d ? (e) => {
|
|
@@ -7482,7 +7516,7 @@ function zl(e, n = {}) {
|
|
|
7482
7516
|
} : void 0;
|
|
7483
7517
|
} : void 0,
|
|
7484
7518
|
updateResource: d ? (e, t) => {
|
|
7485
|
-
let n =
|
|
7519
|
+
let n = _l(e);
|
|
7486
7520
|
d.update(n, t), ws(s, n, t), w();
|
|
7487
7521
|
} : void 0,
|
|
7488
7522
|
deleteResource: d ? (e) => d.delete(e) : void 0,
|
|
@@ -7543,7 +7577,7 @@ function zl(e, n = {}) {
|
|
|
7543
7577
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
7544
7578
|
});
|
|
7545
7579
|
let n = t ? Z(s, t) : s;
|
|
7546
|
-
!t && l && (n = Bi(n, o)), p && (n =
|
|
7580
|
+
!t && l && (n = Bi(n, o)), p && (n = Sl({
|
|
7547
7581
|
jp: t,
|
|
7548
7582
|
resolved: n,
|
|
7549
7583
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -7560,7 +7594,7 @@ function zl(e, n = {}) {
|
|
|
7560
7594
|
if (n !== null) return n;
|
|
7561
7595
|
let r = Ds(e);
|
|
7562
7596
|
if (r.parseError) return Kr("", e, r.parseError);
|
|
7563
|
-
let i =
|
|
7597
|
+
let i = Ml({
|
|
7564
7598
|
bindRef: s,
|
|
7565
7599
|
value: r.parsed,
|
|
7566
7600
|
schema: o,
|
|
@@ -7604,7 +7638,7 @@ function zl(e, n = {}) {
|
|
|
7604
7638
|
message: `edit 仅适用于对象/数组主数据,当前是 ${s === void 0 ? "undefined" : typeof s}`,
|
|
7605
7639
|
hint: "叶子(原始类型)请用 set_data 整体设置"
|
|
7606
7640
|
});
|
|
7607
|
-
let u =
|
|
7641
|
+
let u = Nl({
|
|
7608
7642
|
bindRef: s,
|
|
7609
7643
|
patches: [{
|
|
7610
7644
|
op: t,
|
|
@@ -7668,7 +7702,7 @@ function zl(e, n = {}) {
|
|
|
7668
7702
|
hint: "仅 schema 声明的 key 可删"
|
|
7669
7703
|
});
|
|
7670
7704
|
if (p) {
|
|
7671
|
-
let t =
|
|
7705
|
+
let t = bl(e, p.resourcesByPath);
|
|
7672
7706
|
if (t) return Y({
|
|
7673
7707
|
code: t.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED",
|
|
7674
7708
|
message: `delete_data @ "${e}" 命中受保护字段 "${t.protectedPath}"(${t.spec.mode}),不可删除`,
|
|
@@ -7771,7 +7805,7 @@ function zl(e, n = {}) {
|
|
|
7771
7805
|
});
|
|
7772
7806
|
let n = l ? Bi(s, o) : s, r;
|
|
7773
7807
|
try {
|
|
7774
|
-
r =
|
|
7808
|
+
r = ol(n, e);
|
|
7775
7809
|
} catch (t) {
|
|
7776
7810
|
return Y({
|
|
7777
7811
|
code: "JSONPATH_SYNTAX",
|
|
@@ -7795,7 +7829,7 @@ function zl(e, n = {}) {
|
|
|
7795
7829
|
message: "主数据为空,无可搜索内容"
|
|
7796
7830
|
});
|
|
7797
7831
|
try {
|
|
7798
|
-
let a =
|
|
7832
|
+
let a = cl(l ? Bi(s, o) : s, e, {
|
|
7799
7833
|
mode: t,
|
|
7800
7834
|
fuzzyThreshold: n,
|
|
7801
7835
|
matchKey: r,
|
|
@@ -7845,7 +7879,7 @@ function zl(e, n = {}) {
|
|
|
7845
7879
|
e && (i = Bi(i, e));
|
|
7846
7880
|
}
|
|
7847
7881
|
} else i = l ? Bi(s, o) : s;
|
|
7848
|
-
let a = Es(i), c = await
|
|
7882
|
+
let a = Es(i), c = await ul(a, e, r && JSON.stringify(a).length > 1e5 ? 8e3 : 3e3);
|
|
7849
7883
|
if (!c.ok) {
|
|
7850
7884
|
let t = /超时/.test(c.error || "");
|
|
7851
7885
|
return Y({
|
|
@@ -7861,7 +7895,7 @@ function zl(e, n = {}) {
|
|
|
7861
7895
|
if (t === "transform") {
|
|
7862
7896
|
let e = c.result;
|
|
7863
7897
|
if (r) {
|
|
7864
|
-
let t =
|
|
7898
|
+
let t = Nl({
|
|
7865
7899
|
bindRef: s,
|
|
7866
7900
|
patches: [{
|
|
7867
7901
|
op: "set",
|
|
@@ -7889,7 +7923,7 @@ function zl(e, n = {}) {
|
|
|
7889
7923
|
message: `主数据 bind 为原始类型(${s === null ? "null" : typeof s}),eval transform(patches) 无法就地替换`,
|
|
7890
7924
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
7891
7925
|
});
|
|
7892
|
-
let t =
|
|
7926
|
+
let t = Nl({
|
|
7893
7927
|
bindRef: s,
|
|
7894
7928
|
patches: e.patches,
|
|
7895
7929
|
schema: o,
|
|
@@ -7909,7 +7943,7 @@ function zl(e, n = {}) {
|
|
|
7909
7943
|
}
|
|
7910
7944
|
let t = e;
|
|
7911
7945
|
if (p) {
|
|
7912
|
-
let e =
|
|
7946
|
+
let e = El({
|
|
7913
7947
|
value: t,
|
|
7914
7948
|
ctx: p
|
|
7915
7949
|
});
|
|
@@ -7958,7 +7992,7 @@ function zl(e, n = {}) {
|
|
|
7958
7992
|
e && (a = Bi(a, e));
|
|
7959
7993
|
}
|
|
7960
7994
|
let c = a;
|
|
7961
|
-
if (p && (c =
|
|
7995
|
+
if (p && (c = Sl({
|
|
7962
7996
|
jp: t,
|
|
7963
7997
|
resolved: c,
|
|
7964
7998
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -7968,7 +8002,7 @@ function zl(e, n = {}) {
|
|
|
7968
8002
|
} catch (e) {
|
|
7969
8003
|
return `- ${t}: [READ_INTERCEPT: ${e.message}]`;
|
|
7970
8004
|
}
|
|
7971
|
-
return r && r.length && (c = Os(c, r)), i != null && (c = ks(c, i)), c =
|
|
8005
|
+
return r && r.length && (c = Os(c, r)), i != null && (c = ks(c, i)), c = Fl(c, _ === "", S, x), c === void 0 ? `- ${t} = (undefined)` : `- ${t} = ${Q(c)}`;
|
|
7972
8006
|
});
|
|
7973
8007
|
return `多路径读取(共 ${t.length} 项,hash=${d}):\n${e.join("\n")}`;
|
|
7974
8008
|
}
|
|
@@ -7990,7 +8024,7 @@ function zl(e, n = {}) {
|
|
|
7990
8024
|
e && (m = Bi(m, e));
|
|
7991
8025
|
}
|
|
7992
8026
|
let h = m;
|
|
7993
|
-
if (p && (h =
|
|
8027
|
+
if (p && (h = Sl({
|
|
7994
8028
|
jp: f,
|
|
7995
8029
|
resolved: h,
|
|
7996
8030
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -8003,7 +8037,7 @@ function zl(e, n = {}) {
|
|
|
8003
8037
|
message: `read 拦截器抛错: ${e.message}`
|
|
8004
8038
|
});
|
|
8005
8039
|
}
|
|
8006
|
-
r && r.length && (h = Os(h, r)), i != null && (h = ks(h, i)), h =
|
|
8040
|
+
r && r.length && (h = Os(h, r)), i != null && (h = ks(h, i)), h = Fl(h, _ === "", S, x);
|
|
8007
8041
|
let g = e ? "" : `主数据说明: ${c}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。字段约束(类型/min/max/enum/必填/默认)见 systemPrompt「可操作数据」段,或用 schema_data({ jsonPath }) 按需查。\n\n`, v = r && r.length ? `(字段裁剪:${r.join(",")})` : "", b = i == null ? "" : `(深度≤${i})`, C = v || b ? ` ${v}${b}` : "";
|
|
8008
8042
|
if ((a !== void 0 || u !== void 0) && Array.isArray(h)) {
|
|
8009
8043
|
let e = h.length, t = Math.max(0, a ?? 0), n = Math.min(200, Math.max(1, u ?? 50)), r = h.slice(t, t + n), i = t + n < e;
|
|
@@ -8076,7 +8110,7 @@ function zl(e, n = {}) {
|
|
|
8076
8110
|
hint: "仅 schema 声明的 key 可删"
|
|
8077
8111
|
});
|
|
8078
8112
|
if (p) {
|
|
8079
|
-
let e =
|
|
8113
|
+
let e = bl(t.jsonPath, p.resourcesByPath);
|
|
8080
8114
|
if (e) return Y({
|
|
8081
8115
|
code: e.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED",
|
|
8082
8116
|
message: `write delete @ "${t.jsonPath}" 命中受保护字段 "${e.protectedPath}"(${e.spec.mode}),不可删除`,
|
|
@@ -8109,7 +8143,7 @@ function zl(e, n = {}) {
|
|
|
8109
8143
|
op: t.op ?? "set",
|
|
8110
8144
|
jsonPath: t.jsonPath || "",
|
|
8111
8145
|
value: d
|
|
8112
|
-
}]), i =
|
|
8146
|
+
}]), i = Nl({
|
|
8113
8147
|
bindRef: s,
|
|
8114
8148
|
patches: n,
|
|
8115
8149
|
schema: o,
|
|
@@ -8126,13 +8160,13 @@ function zl(e, n = {}) {
|
|
|
8126
8160
|
detail: `${i.applied.length} 个 patch${i.applied.length > 1 ? "(批量)" : ""}`,
|
|
8127
8161
|
value: i.applied.map((e) => `${e.op}@${e.jp}`),
|
|
8128
8162
|
timestamp: Date.now()
|
|
8129
|
-
}), a && (a(s), w()), y($(s)),
|
|
8163
|
+
}), a && (a(s), w()), y($(s)), zl(i.clone), `已 write(edit) 主数据(${i.applied.length} 个 patch)。当前值:${Q(i.clone, 600)} (新 hash=${$(s)})`) : i.error;
|
|
8130
8164
|
}
|
|
8131
8165
|
let _ = Ds(d);
|
|
8132
8166
|
if (_.parseError) return Kr("", d, _.parseError);
|
|
8133
8167
|
let x = await O("set", g);
|
|
8134
8168
|
if (x !== null) return x;
|
|
8135
|
-
let S =
|
|
8169
|
+
let S = Ml({
|
|
8136
8170
|
bindRef: s,
|
|
8137
8171
|
value: _.parsed,
|
|
8138
8172
|
schema: o,
|
|
@@ -8148,7 +8182,7 @@ function zl(e, n = {}) {
|
|
|
8148
8182
|
if (c) return `dryRun(set): schema 校验通过。预览新值:${Q(S.data, 600)}。未实际写入、未入快照。`;
|
|
8149
8183
|
a && (a(s), w());
|
|
8150
8184
|
let C = $(s);
|
|
8151
|
-
return y(C),
|
|
8185
|
+
return y(C), zl(S.data), `已 write(set) 主数据 = ${Q(S.data, 600)} (新 hash=${C})${l ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`;
|
|
8152
8186
|
}, {
|
|
8153
8187
|
name: "write",
|
|
8154
8188
|
description: "写入主数据(高层入口,合并 set/edit/delete + 自动乐观锁 + 自动快照)。四种意图:① 整体替换 write({ value }) value 为整个 JSON 对象(推荐)或字符串;② 单个增量 patch write({ patch:{op,jsonPath,value} }) op=set/remove/merge/append,jsonPath 相对主数据根(如 components.0.props.title),patch.value 是该 patch 的值(自带,与 patches 一致——string/number 直传该字段新值,勿包成 {字段:值} 对象);也兼容 write({ value, patch:{op,jsonPath} }) 顶层 value 形式(向后兼容,但优先用 patch.value 避免与①整体 set 的 value 语义混淆);③ 批量增量 write({ patches:[{op,jsonPath,value},...] }) 一次原子应用多个 patch(任一失败整体不写入,适合一次改多处);④ 删除 write({ patch:{jsonPath}, del:true })。写入自动经 schema 校验(失败不写)+ 自动存快照(可 restore_data 回退)+ 自动乐观锁(autoLock,用你最后 read 到的 hash 比对,冲突则 VERSION_CONFLICT)。集成方可能经 write 拦截器校验/转换/拒绝(批量模式拦截器收到 {patches},返回新 patches 数组或 {error})。dryRun(可选):预检模式,走完整校验链(schema + 白名单 + patch 应用到 clone)但不落盘/入快照,返回预览(四意图均支持,复杂改动先看会改成啥、能否过 schema)。",
|
|
@@ -8263,7 +8297,7 @@ function zl(e, n = {}) {
|
|
|
8263
8297
|
}
|
|
8264
8298
|
let u = await O("set", n || (b ? v() : void 0));
|
|
8265
8299
|
if (u !== null) return u;
|
|
8266
|
-
let d =
|
|
8300
|
+
let d = Ml({
|
|
8267
8301
|
bindRef: s,
|
|
8268
8302
|
value: c,
|
|
8269
8303
|
schema: o,
|
|
@@ -8295,7 +8329,7 @@ function zl(e, n = {}) {
|
|
|
8295
8329
|
message: "未提供 path 或有效 handle",
|
|
8296
8330
|
hint: "传 path(受保护字段)或 handle(占位符 ⟦res:handle⟧ 里的句柄)"
|
|
8297
8331
|
});
|
|
8298
|
-
let r =
|
|
8332
|
+
let r = _l(n);
|
|
8299
8333
|
if (!u.has(r)) return Y({
|
|
8300
8334
|
code: "RESOURCE_NOT_FOUND",
|
|
8301
8335
|
message: `"${n}" 不是受保护字段`,
|
|
@@ -8334,7 +8368,7 @@ function zl(e, n = {}) {
|
|
|
8334
8368
|
message: "resource_update 需要 path",
|
|
8335
8369
|
hint: "传要更新的 verbatim 受保护字段路径"
|
|
8336
8370
|
});
|
|
8337
|
-
let n =
|
|
8371
|
+
let n = _l(e), r = u.get(n);
|
|
8338
8372
|
if (!r) return Y({
|
|
8339
8373
|
code: "RESOURCE_NOT_FOUND",
|
|
8340
8374
|
message: `"${e}" 不是受保护字段`,
|
|
@@ -8422,8 +8456,8 @@ function zl(e, n = {}) {
|
|
|
8422
8456
|
}
|
|
8423
8457
|
//#endregion
|
|
8424
8458
|
//#region src/core/tools/fetchDoc.ts
|
|
8425
|
-
var
|
|
8426
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
8459
|
+
var Vl = 3e4, Hl = [r(async ({ url: e, as: t }) => {
|
|
8460
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), Vl);
|
|
8427
8461
|
try {
|
|
8428
8462
|
let r = await fetch(e, {
|
|
8429
8463
|
method: "GET",
|
|
@@ -8440,7 +8474,7 @@ var Bl = 3e4, Vl = [r(async ({ url: e, as: t }) => {
|
|
|
8440
8474
|
].join("\n");
|
|
8441
8475
|
} catch (t) {
|
|
8442
8476
|
let r = t?.message || String(t);
|
|
8443
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
8477
|
+
return n.signal.aborted ? `获取失败:请求超时(${Vl}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
8444
8478
|
} finally {
|
|
8445
8479
|
clearTimeout(r);
|
|
8446
8480
|
}
|
|
@@ -8451,7 +8485,7 @@ var Bl = 3e4, Vl = [r(async ({ url: e, as: t }) => {
|
|
|
8451
8485
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
8452
8486
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
8453
8487
|
})
|
|
8454
|
-
})],
|
|
8488
|
+
})], Ul = [
|
|
8455
8489
|
"id",
|
|
8456
8490
|
"class",
|
|
8457
8491
|
"href",
|
|
@@ -8463,12 +8497,12 @@ var Bl = 3e4, Vl = [r(async ({ url: e, as: t }) => {
|
|
|
8463
8497
|
"aria-label",
|
|
8464
8498
|
"name",
|
|
8465
8499
|
"type"
|
|
8466
|
-
],
|
|
8467
|
-
function
|
|
8500
|
+
], Wl = /^(value|srcdoc|formaction|on\w+)$/i, Gl = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session/i;
|
|
8501
|
+
function Kl(e, t) {
|
|
8468
8502
|
if (!e) return null;
|
|
8469
|
-
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ??
|
|
8503
|
+
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ?? Ul, s = (e) => {
|
|
8470
8504
|
let t = {};
|
|
8471
|
-
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (
|
|
8505
|
+
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (Wl.test(n.name) || Gl.test(n.name) || (t[n.name] = n.value));
|
|
8472
8506
|
return t;
|
|
8473
8507
|
}, c = (e, t) => {
|
|
8474
8508
|
let n = {
|
|
@@ -8484,10 +8518,10 @@ function Gl(e, t) {
|
|
|
8484
8518
|
};
|
|
8485
8519
|
return c(e, n);
|
|
8486
8520
|
}
|
|
8487
|
-
var
|
|
8521
|
+
var ql = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
8488
8522
|
let i = e ? document.querySelector(e) : document.body;
|
|
8489
8523
|
if (!i) return `未找到匹配元素:selector="${e}"`;
|
|
8490
|
-
let a =
|
|
8524
|
+
let a = Kl(i, {
|
|
8491
8525
|
depth: t ?? 3,
|
|
8492
8526
|
attrs: n,
|
|
8493
8527
|
includeText: r ?? !0
|
|
@@ -8502,14 +8536,14 @@ var Kl = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
8502
8536
|
attrs: t.array(t.string()).optional().describe("属性白名单(传了 = 严格白名单;不传 = 默认常用 + data-*)"),
|
|
8503
8537
|
includeText: t.boolean().optional().describe("是否包含直接文本(默认 true)")
|
|
8504
8538
|
})
|
|
8505
|
-
}),
|
|
8539
|
+
}), Jl = [ql];
|
|
8506
8540
|
//#endregion
|
|
8507
8541
|
//#region src/core/tools/envTool.ts
|
|
8508
|
-
function
|
|
8542
|
+
function Yl(e) {
|
|
8509
8543
|
let t = e;
|
|
8510
8544
|
return typeof t.tagName == "string" || typeof t.nodeType == "number" && typeof t.nodeName == "string";
|
|
8511
8545
|
}
|
|
8512
|
-
function
|
|
8546
|
+
function Xl(e, t = 3, n = 2e3, r) {
|
|
8513
8547
|
if (e == null) return e;
|
|
8514
8548
|
if (typeof e == "string") return e.length > n ? e.slice(0, n) + "…(已截断)" : e;
|
|
8515
8549
|
if (typeof e == "number" || typeof e == "boolean") return e;
|
|
@@ -8518,14 +8552,14 @@ function Yl(e, t = 3, n = 2e3, r) {
|
|
|
8518
8552
|
if (typeof e == "bigint") return `${e.toString()}n`;
|
|
8519
8553
|
if (typeof e != "object") return String(e);
|
|
8520
8554
|
let i = e;
|
|
8521
|
-
if (
|
|
8555
|
+
if (Yl(i)) {
|
|
8522
8556
|
let e = i;
|
|
8523
8557
|
return e.tagName ? `[Element: <${e.tagName.toLowerCase()}>]` : `[Node: ${e.nodeName}]`;
|
|
8524
8558
|
}
|
|
8525
8559
|
if (r?.has(i)) return "[Circular]";
|
|
8526
8560
|
let a = r ?? /* @__PURE__ */ new WeakSet();
|
|
8527
8561
|
if (a.add(i), Array.isArray(e)) {
|
|
8528
|
-
let r = e.slice(0, 100).map((e) =>
|
|
8562
|
+
let r = e.slice(0, 100).map((e) => Xl(e, t - 1, n, a));
|
|
8529
8563
|
return e.length > 100 && r.push(`…(共 ${e.length} 项,已截断)`), r;
|
|
8530
8564
|
}
|
|
8531
8565
|
if (t < 0) return "(对象,已截断)";
|
|
@@ -8537,14 +8571,14 @@ function Yl(e, t = 3, n = 2e3, r) {
|
|
|
8537
8571
|
break;
|
|
8538
8572
|
}
|
|
8539
8573
|
try {
|
|
8540
|
-
o[r] =
|
|
8574
|
+
o[r] = Xl(i[r], t - 1, n, a);
|
|
8541
8575
|
} catch {
|
|
8542
8576
|
o[r] = "(getter 抛错)";
|
|
8543
8577
|
}
|
|
8544
8578
|
}
|
|
8545
8579
|
return o;
|
|
8546
8580
|
}
|
|
8547
|
-
function
|
|
8581
|
+
function Zl(e) {
|
|
8548
8582
|
let t = e ?? (typeof window < "u" ? window : {}), n = t.navigator, r = t.location, i = t.document;
|
|
8549
8583
|
return {
|
|
8550
8584
|
location: {
|
|
@@ -8577,9 +8611,9 @@ function Xl(e) {
|
|
|
8577
8611
|
} : "(无 document)"
|
|
8578
8612
|
};
|
|
8579
8613
|
}
|
|
8580
|
-
var
|
|
8614
|
+
var Ql = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|opener|parent|top|self|window|globalThis|closed|history|navigation|trustedTypes|origin|crossOriginIsolated)$/, $l = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session|ticket/i, eu = r(({ key: e }) => {
|
|
8581
8615
|
if (e) {
|
|
8582
|
-
if (
|
|
8616
|
+
if (Ql.test(e) || $l.test(e)) return JSON.stringify({
|
|
8583
8617
|
key: e,
|
|
8584
8618
|
denied: !0,
|
|
8585
8619
|
reason: "安全:该 key 在 denylist(localStorage/sessionStorage/cookie/document 或敏感命名 token/secret/key/auth),不读取防泄漏"
|
|
@@ -8589,18 +8623,18 @@ var Zl = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|open
|
|
|
8589
8623
|
key: e,
|
|
8590
8624
|
exists: t !== void 0,
|
|
8591
8625
|
type: typeof t,
|
|
8592
|
-
value:
|
|
8626
|
+
value: Xl(t)
|
|
8593
8627
|
}, null, 2);
|
|
8594
8628
|
}
|
|
8595
|
-
return JSON.stringify(
|
|
8629
|
+
return JSON.stringify(Zl(), null, 2);
|
|
8596
8630
|
}, {
|
|
8597
8631
|
name: "inspect_env",
|
|
8598
8632
|
description: "读取宿主页面环境信息(排查调试用,默认开启)。不传参 = 返回环境摘要(location 的 URL/origin/path、navigator 的浏览器/语言、viewport 视口尺寸、document 的 title/readyState);传 key = 读取指定 window 属性值(如 inspect_env({key:\"appConfig\"}) 读集成方挂的调试变量 window.appConfig)。用于排查「当前页面在哪/什么浏览器/视口多大/调试变量值是什么」。轻量只读,大结果自动外存 vfs。",
|
|
8599
8633
|
schema: t.object({ key: t.string().optional().describe("要读取的 window 属性名(如 \"appConfig\"/\"__DEBUG__\");不传 = 返回环境摘要") })
|
|
8600
|
-
}),
|
|
8634
|
+
}), tu = [eu];
|
|
8601
8635
|
//#endregion
|
|
8602
8636
|
//#region src/core/harness/budget.ts
|
|
8603
|
-
function
|
|
8637
|
+
function nu(e, t, n) {
|
|
8604
8638
|
let r = 0;
|
|
8605
8639
|
return {
|
|
8606
8640
|
name: "budget",
|
|
@@ -8625,12 +8659,12 @@ function tu(e, t, n) {
|
|
|
8625
8659
|
}
|
|
8626
8660
|
//#endregion
|
|
8627
8661
|
//#region src/core/sdk/actions.ts
|
|
8628
|
-
var
|
|
8629
|
-
function
|
|
8662
|
+
var ru = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
8663
|
+
function iu(e) {
|
|
8630
8664
|
let n = [];
|
|
8631
8665
|
for (let [i, a] of Object.entries(e)) {
|
|
8632
|
-
if (!
|
|
8633
|
-
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${
|
|
8666
|
+
if (!ru.test(i)) {
|
|
8667
|
+
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${ru}),已跳过`);
|
|
8634
8668
|
continue;
|
|
8635
8669
|
}
|
|
8636
8670
|
let e = a.description || `宿主动作 ${i}`;
|
|
@@ -8650,9 +8684,9 @@ function ru(e) {
|
|
|
8650
8684
|
}
|
|
8651
8685
|
return n;
|
|
8652
8686
|
}
|
|
8653
|
-
function
|
|
8687
|
+
function au(e) {
|
|
8654
8688
|
let t = {};
|
|
8655
|
-
for (let [n, r] of Object.entries(e))
|
|
8689
|
+
for (let [n, r] of Object.entries(e)) ru.test(n) && (t[n] = {
|
|
8656
8690
|
description: r.description,
|
|
8657
8691
|
hasParams: !!r.params
|
|
8658
8692
|
});
|
|
@@ -8660,12 +8694,12 @@ function iu(e) {
|
|
|
8660
8694
|
}
|
|
8661
8695
|
//#endregion
|
|
8662
8696
|
//#region src/core/toolsets.ts
|
|
8663
|
-
var
|
|
8664
|
-
function
|
|
8665
|
-
return
|
|
8697
|
+
var ou = Hl, su = Jl;
|
|
8698
|
+
function cu(e, t) {
|
|
8699
|
+
return Bl(e, t);
|
|
8666
8700
|
}
|
|
8667
|
-
function
|
|
8668
|
-
let a =
|
|
8701
|
+
function lu(e, t, n, r, i) {
|
|
8702
|
+
let a = Wc(e);
|
|
8669
8703
|
return [
|
|
8670
8704
|
...a.dataOps ? t : [],
|
|
8671
8705
|
...a.fetch ? n : [],
|
|
@@ -8675,7 +8709,7 @@ function cu(e, t, n, r, i) {
|
|
|
8675
8709
|
}
|
|
8676
8710
|
//#endregion
|
|
8677
8711
|
//#region src/core/sdk/toolRegistry.ts
|
|
8678
|
-
function
|
|
8712
|
+
function uu(e) {
|
|
8679
8713
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
8680
8714
|
for (let r of e) for (let e of r.tools) {
|
|
8681
8715
|
let i = t.get(e.name);
|
|
@@ -8695,15 +8729,15 @@ function lu(e) {
|
|
|
8695
8729
|
}
|
|
8696
8730
|
//#endregion
|
|
8697
8731
|
//#region src/core/harness/usageHints.ts
|
|
8698
|
-
var
|
|
8699
|
-
function
|
|
8700
|
-
let i =
|
|
8732
|
+
var du = .7;
|
|
8733
|
+
function fu(e, t, n = "simple", r = !1) {
|
|
8734
|
+
let i = Wc(e), a = n !== "advanced";
|
|
8701
8735
|
return {
|
|
8702
8736
|
name: "usageHints",
|
|
8703
8737
|
augmentPrompt: () => {
|
|
8704
8738
|
let n = [];
|
|
8705
8739
|
if (i.planning && (n.push("【自适应规划】按任务复杂度决定是否先规划,不要对简单任务过度编排:"), n.push(" · 简单/明确任务(改单字段、调样式、查值)→ 直接 read/write 执行,不必 write_todos。"), n.push(" · 复杂任务(多步、大改、有歧义、不可逆)→ 先 write_todos 拆解,首个任务标 in_progress,逐项推进。"), n.push(" · 执行中发现步骤要改/补/细分 → 用 update_todo({id, content?, status?}) 按 id 增量改单项,不必重传整个清单。"), n.push(" · 规划出多步方案若需用户拍板 → 先 request_human_confirmation 给方案选项,确认后再执行。"), n.push(" · 规划阶段有轮次预算(maxPlanRevisions,默认 5):勿反复调研/改计划而不执行,规划充分后即开始 write 落地。")), t && (a ? (n.push("读写主数据用 read/write(高层入口,自动乐观锁 + 自动快照)。read({jsonPath}) 读子路径当前值(返回含 hash,write 时自动比对,无需手动传);read() 不传读整个主数据 + 说明。write 改值两姿势:① 改单个字段/子路径用 write({patch:{op:\"set\", jsonPath:\"路径.字段\", value:新值}})——patch.value 就是该字段的新值(类型匹配:string 直传字符串、number 传数字、对象传对象),不要包成 {字段:值} 对象(字段名已在 jsonPath);也兼容 write({value:新值, patch:{op,jsonPath}}) 顶层 value(向后兼容,但优先 patch.value,避免与整体 set 的 value 混淆);② 替换整个对象用 write({value:{整个新对象}})。op:set 设值 / remove 删 / merge 合并对象 / append 追加数组;批量多改动 write({patches:[{op,jsonPath,value},...]});删子路径 write({patch:{jsonPath:\"路径\"}, del:true})。写入自动经 schema 校验(失败不写,按错误提示改值类型/形状后重试)+ 自动存快照(出错可用 restore_data 回退)。"), n.push("修改大对象/数组优先用 write 的 patch 增量(只发改动部分),避免整体重传被 max_tokens 截断致 JSON 不完整。"), n.push("读大数组(read 返回 hasMore=true)用 read({jsonPath,offset,limit}) 分页(offset+=limit 续读,默认 limit=50);一次读多个不相关子路径用 read({jsonPaths:[...]}) 省轮次;复杂 patches 改动先 write({patches,dryRun:true}) 预检(走完整校验不落盘)。"), n.push("read/describe 返回按 schema 投影:仅 schema 声明的字段可见(未声明字段自动隐藏,防误操作);要操作某字段需集成方在 schema 声明,查任意路径完整约束用 schema_data({jsonPath})。"), n.push("查历史快照值(看上一版长啥样 / 冲突诊断 / 用户问\"刚才改了啥\")用 history_data({id?,jsonPath?})(只读不改当前);对比当前与历史快照的差异需切 advanced 用 diff_data(返回结构化 path→from/to)。"), n.push("在大数组里按条件筛选用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素 path/index;定位后用 write patch 改。找名字记不清的元素用 search_data(substring/regex/fuzzy)。批量过滤/映射/聚合/重写大数组用 eval_script(沙箱脚本,mode=query 只读/transform 落地)。")) : (n.push("改主数据前先 get_data({jsonPath}) 读其当前真实值与 hash(返回末尾 hash=xxx),基于真实值改,不要凭记忆。写入(set/edit/delete)时回传 expectedHash=该 hash 启用乐观锁——若主数据在你 get 之后被外部代码/其他 agent/用户手动改过,会触发冲突:集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值与 hash 再改。"), n.push("不确定主数据字段结构时用 describe_data 查看说明。"), n.push("修改大对象/数组优先用 edit_data 增量 patch(只发改动部分),避免 set_data 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), n.push("修改主数据出错时可用 restore_data 回退最近一次。"), n.push("在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_data 改。"), n.push("找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。"), n.push("需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。"), n.push("读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。"), n.push("对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/\"刚才改了啥\");只读查历史快照值用 history_data({id?,jsonPath?})。"))), i.subagent && n.push("独立子任务可 spawn_agent 委派(只读工具,过程不占主上下文)。"), i.inspectEnv && n.push("排查页面环境(当前 URL/浏览器/视口/集成方调试变量)用 inspect_env——不传参返回环境摘要(location/navigator/viewport/document),传 key 读特定 window 属性(如 inspect_env({key:\"appConfig\"}) 读 window.appConfig)。改完数据看渲染、定位\"为何没生效\"时用它(只读,不改数据)。"), i.domInspect && n.push("改完数据想确认渲染是否生效(或定位元素/辅助 UI 设计问答)用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。配合宿主 actions(save_draft/publish 等)形成\"改数据→get_dom 看渲染→触发动作\"闭环。"), i.draftWrite && n.push("生成超大 JSON(如 50+ 组件页面,单次 write 受 max_tokens 限制装不下)用 draft_write 分块构建 → draft_commit 原子提交:draft_write({draftId, chunk, mode}) mode:\"start\" 新建/\"append\" 追加(拼 JSON 片段到 drafts 池);累积完 draft_commit({draftId}) 合并 + schema 校验 + 写主数据(失败草稿保留可修后重试,成功自动清草稿)。小改仍用 write patch,只在大 JSON 从零生成时用 draft。"), i.draftWrite && n.push("⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=10 可能触顶被 while 截断导致草稿写不完;目标组件数大时集成方应在 createChatSdk 配 maxToolRounds ≥ 20(或按 N+5 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。"), i.todoDeps && n.push("复杂任务可用 todos 层级依赖:write_todos 时给 todo 传 parentId(父任务 id,表达层级)+ deps(依赖的 todo id 数组,必须先完成)。有依赖的任务,deps 全 completed 后再标 in_progress;完成时 update_todo({id, status:\"completed\", evidence:\"完成证据\"}) 记证据。无依赖关系的任务不传 parentId/deps(扁平)。"), i.focus && !a && (n.push("【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:"), n.push(" · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:\"该子树路径\"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。"), n.push(" · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。"), n.push(" · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。"), n.push(" · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。"), n.push(" · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read/describe_data 查。")), r && (n.push("【受保护资源·精确值保护】部分字段被 freeze/verbatim 保护(集成方在 data.resources 声明):"), n.push(" · read 受保护路径返回占位符 ⟦frozen:path⟧(freeze,精确值不入消息流)或 ⟦res:handle⟧(verbatim,原值在资源池),非真值。"), n.push(" · 确需真值用 resource_get({path})(仅受保护路径);freeze 字段完全不可改,撞 FROZEN_FIELD 即放弃该字段改动。"), n.push(" · verbatim 字段改新值:先 resource_update({path,value}) 更新资源池(同步 bind),再 write 写回句柄 ⟦res:handle⟧;直接写新值 → VERBATIM_MISMATCH。"), n.push(" · 撞 RESOURCE_EVICTED(资源被池淘汰)→ 重新 read 该字段懒注册重建句柄;撞 RESOURCE_NOT_FOUND → 重新 read。")), e?.subagents?.length) {
|
|
8706
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
8740
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= du || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), r = e.subagents.filter((e) => (e.temperature ?? 0) < du && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
8707
8741
|
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(a ? " · 方案定稿后,由你(主 agent)用 write 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。" : " · 方案定稿后,由你(主 agent)用 edit_data 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), n.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
8708
8742
|
}
|
|
8709
8743
|
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(" 4) 规划出多步方案需用户确认时:把整个方案(或关键分步)作为 option 调 request_human_confirmation,确认后再执行。"), 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;
|
|
@@ -8712,7 +8746,7 @@ function du(e, t, n = "simple", r = !1) {
|
|
|
8712
8746
|
}
|
|
8713
8747
|
//#endregion
|
|
8714
8748
|
//#region src/core/harness/resourcesPin.ts
|
|
8715
|
-
function
|
|
8749
|
+
function pu(e) {
|
|
8716
8750
|
return {
|
|
8717
8751
|
name: "resourcesPin",
|
|
8718
8752
|
augmentPrompt: () => {
|
|
@@ -8726,78 +8760,78 @@ function fu(e) {
|
|
|
8726
8760
|
}
|
|
8727
8761
|
//#endregion
|
|
8728
8762
|
//#region src/core/backends/skillStore.ts
|
|
8729
|
-
var
|
|
8730
|
-
function
|
|
8731
|
-
return `${
|
|
8763
|
+
var mu = "v:1::skill-store", hu = "chat-sdk";
|
|
8764
|
+
function gu(e, t, n) {
|
|
8765
|
+
return `${mu}::${e}::${t}::${n}`;
|
|
8732
8766
|
}
|
|
8733
|
-
function
|
|
8734
|
-
return `${
|
|
8767
|
+
function _u(e, t) {
|
|
8768
|
+
return `${mu}::${e}::${t}::`;
|
|
8735
8769
|
}
|
|
8736
|
-
function
|
|
8737
|
-
let t = e.dbName ??
|
|
8770
|
+
function vu(e = {}) {
|
|
8771
|
+
let t = e.dbName ?? hu, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
8738
8772
|
a = e;
|
|
8739
8773
|
});
|
|
8740
8774
|
return (async () => {
|
|
8741
8775
|
try {
|
|
8742
8776
|
if (n === "indexed") {
|
|
8743
8777
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
8744
|
-
i = await
|
|
8778
|
+
i = await Lc(t), a(!0);
|
|
8745
8779
|
} else if (n === "session") {
|
|
8746
8780
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
8747
|
-
i =
|
|
8781
|
+
i = Rc(sessionStorage), a(!0);
|
|
8748
8782
|
} else if (n === "local") {
|
|
8749
8783
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
8750
|
-
i =
|
|
8751
|
-
} else i =
|
|
8784
|
+
i = Rc(localStorage), a(!0);
|
|
8785
|
+
} else i = Ic(), a(!1);
|
|
8752
8786
|
} catch {
|
|
8753
|
-
i =
|
|
8787
|
+
i = Ic(), a(!1);
|
|
8754
8788
|
}
|
|
8755
8789
|
})(), {
|
|
8756
8790
|
ready: o,
|
|
8757
8791
|
async list() {
|
|
8758
8792
|
let e = [];
|
|
8759
|
-
return await i.scan(
|
|
8793
|
+
return await i.scan(_u(t, r), (t, n) => {
|
|
8760
8794
|
e.push(n);
|
|
8761
8795
|
}), e;
|
|
8762
8796
|
},
|
|
8763
8797
|
async get(e) {
|
|
8764
|
-
return await i.get(
|
|
8798
|
+
return await i.get(gu(t, r, e));
|
|
8765
8799
|
},
|
|
8766
8800
|
async put(e) {
|
|
8767
8801
|
try {
|
|
8768
|
-
await i.set(
|
|
8802
|
+
await i.set(gu(t, r, e.name), e);
|
|
8769
8803
|
} catch (e) {
|
|
8770
|
-
|
|
8804
|
+
Oc(e) && (i = Ic());
|
|
8771
8805
|
}
|
|
8772
8806
|
},
|
|
8773
8807
|
async remove(e) {
|
|
8774
|
-
let n =
|
|
8808
|
+
let n = gu(t, r, e);
|
|
8775
8809
|
return await i.get(n) == null ? !1 : (await i.del(n), !0);
|
|
8776
8810
|
},
|
|
8777
8811
|
async clear() {
|
|
8778
|
-
await i.clearPrefix(
|
|
8812
|
+
await i.clearPrefix(_u(t, r));
|
|
8779
8813
|
},
|
|
8780
8814
|
dispose() {}
|
|
8781
8815
|
};
|
|
8782
8816
|
}
|
|
8783
|
-
var
|
|
8784
|
-
function
|
|
8817
|
+
var yu = /large_results\/[^\s"'`),]+\.txt/g;
|
|
8818
|
+
function bu(e) {
|
|
8785
8819
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
8786
8820
|
if (typeof e != "string" || !e) return;
|
|
8787
8821
|
let n;
|
|
8788
|
-
for (
|
|
8822
|
+
for (yu.lastIndex = 0; (n = yu.exec(e)) !== null;) t.add(n[0]);
|
|
8789
8823
|
};
|
|
8790
8824
|
for (let t of e) if (n(t.content), t.steps) for (let e of t.steps) n(e.result);
|
|
8791
8825
|
return t;
|
|
8792
8826
|
}
|
|
8793
|
-
function
|
|
8827
|
+
function xu(e, t) {
|
|
8794
8828
|
let n = [];
|
|
8795
8829
|
for (let r of Object.keys(e)) r.startsWith("large_results/") && !t.has(r) && n.push(r);
|
|
8796
8830
|
return n;
|
|
8797
8831
|
}
|
|
8798
8832
|
//#endregion
|
|
8799
8833
|
//#region src/core/utils/serialRunner.ts
|
|
8800
|
-
function
|
|
8834
|
+
function Su() {
|
|
8801
8835
|
let e = Promise.resolve();
|
|
8802
8836
|
return function(t) {
|
|
8803
8837
|
let n = e.then(t, t);
|
|
@@ -8806,16 +8840,16 @@ function xu() {
|
|
|
8806
8840
|
}
|
|
8807
8841
|
//#endregion
|
|
8808
8842
|
//#region src/core/sdk/createChatSdk.ts
|
|
8809
|
-
var
|
|
8810
|
-
function
|
|
8843
|
+
var Cu = 30, wu = /* @__PURE__ */ new Map();
|
|
8844
|
+
function Tu(e, t) {
|
|
8811
8845
|
return e === "set_data" ? "set" : e === "edit_data" ? "edit" : e === "delete_data" ? "delete" : e === "restore_data" ? "restore" : e === "write" ? t?.del ? "delete" : t?.patch ? "edit" : "set" : null;
|
|
8812
8846
|
}
|
|
8813
|
-
function
|
|
8847
|
+
function Eu(e, t, n, r) {
|
|
8814
8848
|
let i = 0;
|
|
8815
8849
|
return {
|
|
8816
8850
|
name: "sdk-events",
|
|
8817
8851
|
wrapToolCall: async (t, r) => {
|
|
8818
|
-
let i = await r(t), a =
|
|
8852
|
+
let i = await r(t), a = Tu(t.name, t.args);
|
|
8819
8853
|
return a && e({
|
|
8820
8854
|
type: "data_change",
|
|
8821
8855
|
operation: a,
|
|
@@ -8843,7 +8877,7 @@ function Tu(e, t, n, r) {
|
|
|
8843
8877
|
}
|
|
8844
8878
|
};
|
|
8845
8879
|
}
|
|
8846
|
-
function
|
|
8880
|
+
function Du(e, t, n, r, i) {
|
|
8847
8881
|
if (!n) return i && console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`), {
|
|
8848
8882
|
ok: !1,
|
|
8849
8883
|
error: "capabilities.focus 关闭"
|
|
@@ -8861,16 +8895,16 @@ function Eu(e, t, n, r, i) {
|
|
|
8861
8895
|
error: "当前无主数据 schema,无法聚焦"
|
|
8862
8896
|
});
|
|
8863
8897
|
}
|
|
8864
|
-
function
|
|
8898
|
+
function Ou(e, n) {
|
|
8865
8899
|
let i = {
|
|
8866
8900
|
prompt_tokens: 0,
|
|
8867
8901
|
completion_tokens: 0,
|
|
8868
8902
|
total_tokens: 0
|
|
8869
|
-
}, a =
|
|
8903
|
+
}, a = hc(() => W), o = /* @__PURE__ */ Ot(0), s = Vc(e.storage);
|
|
8870
8904
|
e.debug && s && s.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
8871
|
-
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: p } =
|
|
8905
|
+
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: p } = mc(e), m = c;
|
|
8872
8906
|
if (e.debug && console.log("[page-agent-sdk][modelCaps]", m), m.contextWindow < 2e5) throw Error(`[page-agent-sdk] 模型上下文窗口 ${m.contextWindow} 小于最小支持 ${ni}(需 ≥200K 窗口模型,如 GLM-5.2/Claude/Kimi/Qwen-1M/DeepSeek-v4)`);
|
|
8873
|
-
let h =
|
|
8907
|
+
let h = Jc(e, m.contextWindow), g = h.enableLLMSummary !== !1, _ = (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? qc[e.contextPreset ?? "auto"], v = new Set(_), y = e.llm;
|
|
8874
8908
|
e.debug && !l && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
8875
8909
|
let b = /* @__PURE__ */ _t([]), x = zs(e.vfs?.initialFiles, {
|
|
8876
8910
|
persist: s ? { save: (e) => {
|
|
@@ -8892,7 +8926,7 @@ function Du(e, n) {
|
|
|
8892
8926
|
getTodos: () => D.current?.getState?.()?.todos ?? [],
|
|
8893
8927
|
messages: b,
|
|
8894
8928
|
maxCheckpoints: ne && typeof ne == "object" ? ne.maxCheckpoints : void 0
|
|
8895
|
-
}) : null, ie = !ne || typeof ne != "object" || ne.auto !== !1, M =
|
|
8929
|
+
}) : null, ie = !ne || typeof ne != "object" || ne.auto !== !1, M = Wc(e.capabilities), N = M.dataOps, ae = M.draftWrite, P = M.tracing, oe = M.automation, se = bs(e), ce = N && O ? Bl(O, {
|
|
8896
8930
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
8897
8931
|
maxSnapshots: e.maxSnapshots,
|
|
8898
8932
|
onConflict: a.set,
|
|
@@ -8901,11 +8935,11 @@ function Du(e, n) {
|
|
|
8901
8935
|
vfsStore: ae || O?.resources?.length ? x : void 0,
|
|
8902
8936
|
...te.length ? { pgIdPaths: te } : {},
|
|
8903
8937
|
...A.length ? { largeTextPaths: A } : {}
|
|
8904
|
-
}) : [], le = N ?
|
|
8938
|
+
}) : [], le = N ? jl(ce, e.toolMode) : [], F = N && O ? ce.controller ?? null : null, ue = N && O?.resources?.length && F?.getResourcesSnapshot ? pu({ getResourcesSnapshot: () => F?.getResourcesSnapshot?.() ?? [] }) : void 0, I = () => F?.get() ?? O, L = /* @__PURE__ */ new Map(), R = lu(M, le, Hl, Jl, tu);
|
|
8905
8939
|
R.forEach((e) => L.set(e.name, "builtin"));
|
|
8906
8940
|
let z = [...e.tools || []];
|
|
8907
8941
|
z.forEach((e) => L.set(e.name, "user"));
|
|
8908
|
-
let de =
|
|
8942
|
+
let de = iu(e.actions ?? {});
|
|
8909
8943
|
de.forEach((e) => L.set(e.name, "action"));
|
|
8910
8944
|
let fe = [], B = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), pe = B ? Za() : null;
|
|
8911
8945
|
pe && L.set(Ya, "builtin");
|
|
@@ -8977,7 +9011,7 @@ function Du(e, n) {
|
|
|
8977
9011
|
ye.forEach((e) => L.set(e.name, "builtin"));
|
|
8978
9012
|
let be = [], xe = /* @__PURE__ */ new Map(), H = Se();
|
|
8979
9013
|
function Se() {
|
|
8980
|
-
let { tools: e, collisions: t } =
|
|
9014
|
+
let { tools: e, collisions: t } = uu([
|
|
8981
9015
|
{
|
|
8982
9016
|
label: "builtin",
|
|
8983
9017
|
tools: R
|
|
@@ -9044,7 +9078,7 @@ function Du(e, n) {
|
|
|
9044
9078
|
timeoutMs: Ie?.timeoutMs
|
|
9045
9079
|
}), Ve = e.subagents?.map((e) => {
|
|
9046
9080
|
if (!e._codeAsset) return e;
|
|
9047
|
-
let t = e._codeAsset, n =
|
|
9081
|
+
let t = e._codeAsset, n = $s({
|
|
9048
9082
|
writablePaths: t.writablePaths,
|
|
9049
9083
|
codeVfsPrefix: t.codeVfsPrefix,
|
|
9050
9084
|
ext: t.ext,
|
|
@@ -9086,8 +9120,8 @@ function Du(e, n) {
|
|
|
9086
9120
|
} : void 0
|
|
9087
9121
|
}) : void 0, qe = Fe ? ps({
|
|
9088
9122
|
contextWindow: m.contextWindow,
|
|
9089
|
-
thresholdRatio:
|
|
9090
|
-
}) : void 0, Je =
|
|
9123
|
+
thresholdRatio: Jc(e, m.contextWindow).summaryThresholdRatio
|
|
9124
|
+
}) : void 0, Je = fu({
|
|
9091
9125
|
...M,
|
|
9092
9126
|
humanConfirm: B,
|
|
9093
9127
|
subagents: e.subagents?.map((e) => ({
|
|
@@ -9111,7 +9145,7 @@ function Du(e, n) {
|
|
|
9111
9145
|
return;
|
|
9112
9146
|
}
|
|
9113
9147
|
}
|
|
9114
|
-
} : null, Ze =
|
|
9148
|
+
} : null, Ze = Gc(e.onEvent), W = Ze.emit, Qe, $e = [], et = (e) => ({
|
|
9115
9149
|
name: e.name,
|
|
9116
9150
|
description: e.description,
|
|
9117
9151
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
@@ -9119,7 +9153,7 @@ function Du(e, n) {
|
|
|
9119
9153
|
name: e.name,
|
|
9120
9154
|
description: e.description,
|
|
9121
9155
|
getContent: () => e.content
|
|
9122
|
-
}), nt = e.skillStorage === !1 ? null :
|
|
9156
|
+
}), nt = e.skillStorage === !1 ? null : vu({
|
|
9123
9157
|
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
9124
9158
|
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
|
|
9125
9159
|
}), rt = () => {
|
|
@@ -9151,7 +9185,7 @@ function Du(e, n) {
|
|
|
9151
9185
|
decideInvoke: p,
|
|
9152
9186
|
getSnapshot: () => qe?.getSnapshot()
|
|
9153
9187
|
} : {}
|
|
9154
|
-
}) : void 0, ot =
|
|
9188
|
+
}) : void 0, ot = Xc([
|
|
9155
9189
|
...Ye ? [Ye] : [],
|
|
9156
9190
|
Je,
|
|
9157
9191
|
...we ? [C] : [],
|
|
@@ -9183,12 +9217,12 @@ function Du(e, n) {
|
|
|
9183
9217
|
...Xe ? [Xe] : [],
|
|
9184
9218
|
...qe ? [qe] : [],
|
|
9185
9219
|
...e.middleware || [],
|
|
9186
|
-
...oe ? [
|
|
9220
|
+
...oe ? [nu(i, {
|
|
9187
9221
|
tokenBudget: e.tokenBudget,
|
|
9188
9222
|
timeBudgetMs: e.timeBudgetMs
|
|
9189
9223
|
}, W)] : [],
|
|
9190
|
-
|
|
9191
|
-
]), st = e.maxMemoryRounds ??
|
|
9224
|
+
Eu(W, b, I, i)
|
|
9225
|
+
]), st = e.maxMemoryRounds ?? Cu, ct = e.approval?.timeoutMs, lt = ct === void 0 || ct === 0 ? 3e4 : !Number.isFinite(ct) || ct < 0 ? 0 : ct;
|
|
9192
9226
|
function ut(e) {
|
|
9193
9227
|
if (lt) return (t) => {
|
|
9194
9228
|
if (t.type !== "approval_request") return;
|
|
@@ -9211,7 +9245,7 @@ function Du(e, n) {
|
|
|
9211
9245
|
async function ft() {
|
|
9212
9246
|
s && (dt.value = (await s.listSessions(n)).sort((e, t) => t.lastAccessed - e.lastAccessed));
|
|
9213
9247
|
}
|
|
9214
|
-
let pt =
|
|
9248
|
+
let pt = Su(), mt = /* @__PURE__ */ new Set();
|
|
9215
9249
|
function ht(e) {
|
|
9216
9250
|
let t = new AbortController();
|
|
9217
9251
|
return e && (e.aborted ? t.abort() : e.addEventListener("abort", () => t.abort(), { once: !0 })), mt.add(t), {
|
|
@@ -9454,7 +9488,7 @@ function Du(e, n) {
|
|
|
9454
9488
|
})), e.memory && s.save(n, G.sessionId, { memory: E.get() || (typeof e.memory == "string" ? e.memory : "") }), ft(), K = void 0, Ct = !1, r;
|
|
9455
9489
|
},
|
|
9456
9490
|
resetSession: () => {
|
|
9457
|
-
gt(), a.resolve("keep_external"), G.sessionId =
|
|
9491
|
+
gt(), a.resolve("keep_external"), G.sessionId = gc(), b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || E.reset(""), C.reset(), T.reset(), w.reset(), j && j.importStack([]), G.agent && (G.agent.debugLogs.value = []), s && s.createSession(G.agentId, e.session?.title, G.sessionId), W({
|
|
9458
9492
|
type: "session_restored",
|
|
9459
9493
|
sessionId: G.sessionId,
|
|
9460
9494
|
rounds: 0
|
|
@@ -9462,7 +9496,7 @@ function Du(e, n) {
|
|
|
9462
9496
|
},
|
|
9463
9497
|
stream: (e, t, n) => {
|
|
9464
9498
|
if (!G.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
9465
|
-
x?.setProtectedRefs?.(
|
|
9499
|
+
x?.setProtectedRefs?.(bu(e));
|
|
9466
9500
|
let r = (e) => {
|
|
9467
9501
|
t?.(e), W(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && G.infoTick.value++;
|
|
9468
9502
|
};
|
|
@@ -9477,7 +9511,7 @@ function Du(e, n) {
|
|
|
9477
9511
|
if (G.refCount--, G.refCount <= 0) {
|
|
9478
9512
|
gt(), s && (x.flush?.(), s.flush(), s.dispose()), nt && nt.dispose();
|
|
9479
9513
|
let e = G.mcpClosers.splice(0);
|
|
9480
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
9514
|
+
e.length && Promise.allSettled(e.map((e) => e())), wu.delete(n);
|
|
9481
9515
|
}
|
|
9482
9516
|
},
|
|
9483
9517
|
resolveConflict: a.resolve,
|
|
@@ -9497,14 +9531,14 @@ function Du(e, n) {
|
|
|
9497
9531
|
},
|
|
9498
9532
|
setLlm(t) {
|
|
9499
9533
|
let n;
|
|
9500
|
-
if (
|
|
9534
|
+
if (ac(t)) n = t;
|
|
9501
9535
|
else {
|
|
9502
9536
|
let e = t;
|
|
9503
9537
|
if ((e.provider ?? "openai") === "anthropic") throw Error("[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import(\"@langchain/anthropic\") 构造实例后传入");
|
|
9504
9538
|
n = d(e);
|
|
9505
9539
|
}
|
|
9506
9540
|
typeof n.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"), y = t;
|
|
9507
|
-
let r =
|
|
9541
|
+
let r = ac(t) ? void 0 : t;
|
|
9508
9542
|
if (m = ri({
|
|
9509
9543
|
model: r?.model ?? t.model ?? t.modelName,
|
|
9510
9544
|
contextWindow: e.contextWindow ?? r?.contextWindow,
|
|
@@ -9547,7 +9581,7 @@ function Du(e, n) {
|
|
|
9547
9581
|
return {
|
|
9548
9582
|
id: n,
|
|
9549
9583
|
sessionId: G.sessionId,
|
|
9550
|
-
model:
|
|
9584
|
+
model: ac(y) ? y.model ?? y.modelName : y.model,
|
|
9551
9585
|
systemPrompt: G.agent?.getEffectiveSystemPrompt?.() ?? se + ys(I(), e.schemaHint),
|
|
9552
9586
|
tools: (G.agent?.allTools ?? H).map((e) => ({
|
|
9553
9587
|
name: e.name,
|
|
@@ -9584,7 +9618,7 @@ function Du(e, n) {
|
|
|
9584
9618
|
spans: G.agent.spans.value,
|
|
9585
9619
|
metrics: oi(G.agent.spans.value)
|
|
9586
9620
|
} : void 0,
|
|
9587
|
-
actions:
|
|
9621
|
+
actions: au(e.actions ?? {}),
|
|
9588
9622
|
subagent: {
|
|
9589
9623
|
enabled: !!Be,
|
|
9590
9624
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
@@ -9633,11 +9667,11 @@ function Du(e, n) {
|
|
|
9633
9667
|
return V ? w.getFocuses() : [];
|
|
9634
9668
|
},
|
|
9635
9669
|
setFocus(t) {
|
|
9636
|
-
let n =
|
|
9670
|
+
let n = Du(t, "setFocus", V, () => I()?.schema, e.debug);
|
|
9637
9671
|
return n.ok ? (w.setFocus(t), G.infoTick.value++, { ok: !0 }) : n;
|
|
9638
9672
|
},
|
|
9639
9673
|
addFocus(t) {
|
|
9640
|
-
let n =
|
|
9674
|
+
let n = Du(t, "addFocus", V, () => I()?.schema, e.debug);
|
|
9641
9675
|
return n.ok ? w.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
9642
9676
|
ok: !1,
|
|
9643
9677
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
@@ -9681,14 +9715,14 @@ function Du(e, n) {
|
|
|
9681
9715
|
}
|
|
9682
9716
|
function bt(e) {
|
|
9683
9717
|
let t = {};
|
|
9684
|
-
for (let n of
|
|
9718
|
+
for (let n of bu(e)) {
|
|
9685
9719
|
let e = x.files[n];
|
|
9686
9720
|
e && (t[n] = e.content);
|
|
9687
9721
|
}
|
|
9688
9722
|
return t;
|
|
9689
9723
|
}
|
|
9690
9724
|
function xt() {
|
|
9691
|
-
let e =
|
|
9725
|
+
let e = xu(x.files, bu(b));
|
|
9692
9726
|
for (let t of e) delete x.files[t];
|
|
9693
9727
|
}
|
|
9694
9728
|
function St() {
|
|
@@ -9736,7 +9770,7 @@ function Du(e, n) {
|
|
|
9736
9770
|
s.save(n, G.sessionId, { focus: e.length ? e : null });
|
|
9737
9771
|
}
|
|
9738
9772
|
oe && j && (s.save(n, G.sessionId, { checkpoints: j.exportStack() }), s.save(n, G.sessionId, { usage: i }));
|
|
9739
|
-
let a =
|
|
9773
|
+
let a = ic(b);
|
|
9740
9774
|
a && a !== K && (K = a, s.updateTitle(n, G.sessionId, a)), e.autoTitle !== !1 && u && !Ct && b.some((e) => e.role === "user") && b.some((e) => e.role === "assistant") && (Ct = !0, (async () => {
|
|
9741
9775
|
let e = await u(b);
|
|
9742
9776
|
e && (await s.updateTitle(n, G.sessionId, e), await ft());
|
|
@@ -9754,7 +9788,7 @@ function Du(e, n) {
|
|
|
9754
9788
|
}), t.value.tools.forEach((e) => L.set(e.name, `mcp:${i}`)), fe.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${i} 连接失败:`, t.reason);
|
|
9755
9789
|
}), H = Se(), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${fe.length} 个工具,${G.mcpServers.length} 个 server`);
|
|
9756
9790
|
}
|
|
9757
|
-
let t =
|
|
9791
|
+
let t = ac(e.llm) ? e.llm : await f(e.llm);
|
|
9758
9792
|
G.agent = Fi({
|
|
9759
9793
|
llm: t,
|
|
9760
9794
|
systemPrompt: se,
|
|
@@ -9785,12 +9819,12 @@ function Du(e, n) {
|
|
|
9785
9819
|
});
|
|
9786
9820
|
})(), G;
|
|
9787
9821
|
}
|
|
9788
|
-
function
|
|
9789
|
-
let n = e.id ??
|
|
9822
|
+
function ku(e, t) {
|
|
9823
|
+
let n = e.id ?? gc();
|
|
9790
9824
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
9791
|
-
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ?
|
|
9792
|
-
o ? a = o : (a =
|
|
9793
|
-
let s = null, c =
|
|
9825
|
+
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ? wu.get(n) : void 0;
|
|
9826
|
+
o ? a = o : (a = Ou(e, n), e.shareContext && wu.set(n, a)), a.refCount++;
|
|
9827
|
+
let s = null, c = Hc(e), l = null, u = null;
|
|
9794
9828
|
async function d(n) {
|
|
9795
9829
|
if (await a.initDone, s) {
|
|
9796
9830
|
s.show();
|
|
@@ -10006,12 +10040,12 @@ function Ou(e, t) {
|
|
|
10006
10040
|
}
|
|
10007
10041
|
//#endregion
|
|
10008
10042
|
//#region src/core/sdk/ragSubagent.ts
|
|
10009
|
-
var
|
|
10043
|
+
var Au = "你是知识检索专家。可用工具:search_docs(语义检索)/ load_doc(按 source 加载)/ vfs_grep+vfs_read(搜预注入文档)/ fetch_document(公网 URL)。\n\n工作方式:\n1. 分析任务,拆出需查证的要点(如:需要哪些组件、各自的 props 约束、UI 规范要求);\n2. 多源检索:先 vfs_grep 搜预注入文档(快、静态)→ 不够用 search_docs 语义检索 → 需特定文档用 load_doc → 公网用 fetch_document;\n3. 检索结果不足时换关键词、扩大 topK、或换源重试;\n4. 综合成结构化、可执行结论(不堆原文,提炼成可直接用于决策/配置的信息);\n5. 标注关键信息来源(文档名/段落),便于溯源;检索不到明确说「未检索到」,不编造。\n\n你是只读检索角色,不要尝试修改任何数据。", ju = "# 知识检索策略(RAG)\n\n## 多源决策树\n- vfs_grep / vfs_read:搜集成方预注入 vfs 的文档(组件文档 / UI 规范)—— 快、静态,先查\n- search_docs:语义检索(retriever 向量库)—— 模糊匹配,关键词不确定 / 语义相似时用\n- load_doc:按 source 精确加载(已知文档 id / URL / key)—— 精确取特定文档\n- fetch_document:公网 URL —— 查公开资料\n\n## 综合规范\n- 多源交叉验证(关键结论优先 ≥2 源印证,或单一权威源)\n- 标注来源(文档名 / URL / 段落),便于溯源\n- 结构化、可执行结论(组件清单 + 各自 props 约束 + 适用场景),不堆原文\n- 未检索到明确说「未检索到」,不编造;建议替代方案(改关键词 / 建议写代码组件等)\n\n## 何时用何源\n- 静态文档(组件库文档 / UI 规范):vfs_grep\n- 语义相似(「瀑布流组件」「倒计时」「拼团」):search_docs\n- 已知文档 id / URL:load_doc\n- 公开 URL(设计规范网站 / 第三方文档):fetch_document", Mu = {
|
|
10010
10044
|
name: "rag-search",
|
|
10011
10045
|
description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
|
|
10012
|
-
getContent: () =>
|
|
10046
|
+
getContent: () => ju
|
|
10013
10047
|
};
|
|
10014
|
-
function
|
|
10048
|
+
function Nu(e, n, i) {
|
|
10015
10049
|
return r(async ({ query: e, topK: t }) => {
|
|
10016
10050
|
try {
|
|
10017
10051
|
let r = await n(e, { topK: t ?? i });
|
|
@@ -10028,7 +10062,7 @@ function Mu(e, n, i) {
|
|
|
10028
10062
|
})
|
|
10029
10063
|
});
|
|
10030
10064
|
}
|
|
10031
|
-
function
|
|
10065
|
+
function Pu(e, n) {
|
|
10032
10066
|
return r(async ({ source: e }) => {
|
|
10033
10067
|
try {
|
|
10034
10068
|
let t = await n(e), r = Array.isArray(t) ? t : [t];
|
|
@@ -10042,11 +10076,11 @@ function Nu(e, n) {
|
|
|
10042
10076
|
schema: t.object({ source: t.string().describe("文档标识(id/URL/key)") })
|
|
10043
10077
|
});
|
|
10044
10078
|
}
|
|
10045
|
-
function
|
|
10079
|
+
function Fu(e) {
|
|
10046
10080
|
let { retriever: t, loader: n, useVfs: r = !0, id: i = "rag", description: a, topK: o = 5, searchToolName: s = "search_docs", loadToolName: c = "load_doc", maxToolRounds: l = 8, summarization: u, skills: d, extraTools: f } = e;
|
|
10047
10081
|
if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
|
|
10048
10082
|
let p = [];
|
|
10049
|
-
t && p.push(
|
|
10083
|
+
t && p.push(Nu(s, t, o)), n && p.push(Pu(c, n)), f && p.push(...f);
|
|
10050
10084
|
let m = r ? [
|
|
10051
10085
|
"vfs_grep",
|
|
10052
10086
|
"vfs_read",
|
|
@@ -10055,17 +10089,17 @@ function Pu(e) {
|
|
|
10055
10089
|
return {
|
|
10056
10090
|
id: i,
|
|
10057
10091
|
description: a ?? "检索知识库(组件文档/UI 规范/业务规则),返回有依据的结构化结论。需要查阅文档才能回答或决定如何配置时委派",
|
|
10058
|
-
systemPrompt:
|
|
10092
|
+
systemPrompt: Au,
|
|
10059
10093
|
tools: p.length ? p : void 0,
|
|
10060
10094
|
allowedTools: m,
|
|
10061
|
-
skills: d ?? [
|
|
10095
|
+
skills: d ?? [Mu],
|
|
10062
10096
|
maxToolRounds: l,
|
|
10063
10097
|
...u === void 0 ? {} : { summarization: u }
|
|
10064
10098
|
};
|
|
10065
10099
|
}
|
|
10066
10100
|
//#endregion
|
|
10067
10101
|
//#region src/core/tools/htmlValidate.ts
|
|
10068
|
-
var
|
|
10102
|
+
var Iu = /* @__PURE__ */ new Set([
|
|
10069
10103
|
"area",
|
|
10070
10104
|
"base",
|
|
10071
10105
|
"br",
|
|
@@ -10080,12 +10114,12 @@ var Fu = /* @__PURE__ */ new Set([
|
|
|
10080
10114
|
"source",
|
|
10081
10115
|
"track",
|
|
10082
10116
|
"wbr"
|
|
10083
|
-
]),
|
|
10117
|
+
]), Lu = /* @__PURE__ */ new Set(["script", "style"]), Ru = /* @__PURE__ */ new Set([
|
|
10084
10118
|
"html",
|
|
10085
10119
|
"head",
|
|
10086
10120
|
"body"
|
|
10087
10121
|
]);
|
|
10088
|
-
function
|
|
10122
|
+
function zu(e, t = {}) {
|
|
10089
10123
|
let n = t.sfc === !0, r = [], i = e.length;
|
|
10090
10124
|
if (!e.trim()) return r;
|
|
10091
10125
|
let a = [0];
|
|
@@ -10166,12 +10200,12 @@ function Ru(e, t = {}) {
|
|
|
10166
10200
|
}
|
|
10167
10201
|
continue;
|
|
10168
10202
|
}
|
|
10169
|
-
if (
|
|
10203
|
+
if (Ru.has(m) && r.push({
|
|
10170
10204
|
line: o(t),
|
|
10171
10205
|
code: "DOC_TAG_IN_FRAGMENT",
|
|
10172
10206
|
message: `<${m}> 不应出现(v-html 注入场景只输出内容片段,不要 html/head/body 外围)`
|
|
10173
|
-
}), !(
|
|
10174
|
-
if (
|
|
10207
|
+
}), !(Iu.has(m) || h)) {
|
|
10208
|
+
if (Lu.has(m)) {
|
|
10175
10209
|
m === "script" && !n && r.push({
|
|
10176
10210
|
line: o(t),
|
|
10177
10211
|
code: "SCRIPT_IN_FRAGMENT",
|
|
@@ -10205,7 +10239,7 @@ function Ru(e, t = {}) {
|
|
|
10205
10239
|
}
|
|
10206
10240
|
//#endregion
|
|
10207
10241
|
//#region src/core/sdk/htmlSubagent.ts
|
|
10208
|
-
function
|
|
10242
|
+
function Bu(e, t) {
|
|
10209
10243
|
let n = t === "html" ? "html" : "vue";
|
|
10210
10244
|
return `你是纯代码组件生成专家。可用工具:vfs_write / vfs_edit / vfs_rm(写/改/删代码工作副本 vfs ${e}) / vfs_read + vfs_grep(读 vfs) / validate_code(代码格式自检) / write + set(写 data,writablePaths 限定) / read / write_todos + update_todo(规划)。
|
|
10211
10245
|
|
|
@@ -10215,9 +10249,13 @@ function zu(e, t) {
|
|
|
10215
10249
|
- __pgId 是框架管的内部字段(组件稳定映射键):read 看不到、write 写不进,你别碰
|
|
10216
10250
|
|
|
10217
10251
|
两条工作路径:
|
|
10218
|
-
- **修改已有组件**(改颜色/文案/布局等):必经 vfs ——
|
|
10252
|
+
- **修改已有组件**(改颜色/文案/布局等):必经 vfs —— 上下文有「组件代码文件地图」(name → vfs 路径),按 name 找到对应文件直接 vfs_edit 增量改目标片段 → validate_code 自检;框架自动回写 data.code。勿直接 write data.code 改已有组件(绕过 vfs/verify,且无增量友好);文件未检出时先 vfs_write 创建
|
|
10219
10253
|
- **新建组件**:write({ patch:{ op:'set', jsonPath:'components.N', value:{ name, code:<正文>, props } } }) —— code 作为字段值直接进 data,框架自动补 __pgId
|
|
10220
10254
|
|
|
10255
|
+
焦点精修(若继承到主 agent 焦点):
|
|
10256
|
+
- 上下文若提示「当前精修目标」(如 components.2(banner)),说明主 agent 聚焦了某组件 → 你**只能改该焦点组件**的代码文件(vfs 文件 ${e}<焦点组件 __pgId>.${n});改其他组件的代码文件会被 PATH_DENIED 硬拦
|
|
10257
|
+
- 直接改焦点组件文件,不要尝试改其他组件(浪费轮次);聚焦模式下也不能新建组件(数据写被拦)—— 若 task 要新建,反馈主 agent 需先取消焦点
|
|
10258
|
+
|
|
10221
10259
|
代码形态规则:
|
|
10222
10260
|
${t === "html" ? `- 输出纯 HTML 片段(.${n}):结构 + 内联 <style>(class 加统一前缀防样式冲突);交互交给宿主(不写 JS)
|
|
10223
10261
|
- 单根元素包裹(如 <section class="...">…</section>),语义化标签` : `- 输出 Vue SFC(.${n}):<template> + <script setup>(组合式),defineProps 接外部数据
|
|
@@ -10235,16 +10273,16 @@ ${t === "html" ? `- 输出纯 HTML 片段(.${n}):结构 + 内联 <style>(class
|
|
|
10235
10273
|
5. 生成/修改完成后必须调 validate_code 自检(标签闭合 + 片段契约),报错用 vfs_edit 修正后复查,直到通过;
|
|
10236
10274
|
6. 最后 read(vfs + data)确认结构正确;只写 writablePaths 内 data + ${e} 下 vfs。`;
|
|
10237
10275
|
}
|
|
10238
|
-
var
|
|
10276
|
+
var Vu = "# 纯代码组件生成规范\n\n## 代码资产模型(重要)\n- 代码正文是 data 的 code 字段(资产,随 data json 进服务端 DB);UI 绑 data.code 渲染\n- vfs 是编辑工作副本:框架自动 checkout(data.code→vfs)/ commit(vfs→data.code),你只改 vfs\n- __pgId 框架管(read 看不到、write 写不进),别碰\n\n## 两条工作路径\n- 修改已有组件:必经 vfs —— 按上下文「组件代码文件地图」(name → vfs 路径)定位文件,vfs_edit 增量改 → validate_code;勿直接 write data.code;文件未检出先 vfs_write 创建\n- 新建组件:write({patch:{op:'set',jsonPath:'components.N',value:{name,code,props}}}) —— code 直接进 data,框架补 __pgId\n\n## 焦点精修(继承主 agent 焦点时)\n- 上下文提示「当前精修目标」(如 components.2(banner))→ 只改该焦点组件的代码文件;改其他组件会被 PATH_DENIED 硬拦\n- 聚焦模式不能新建组件(数据写被拦),要新建先反馈主 agent 取消焦点\n\n## 何时写代码组件\n- 组件库无对应类型(高度定制交互 / 一次性特效 / 特殊布局)→ 写 custom 代码组件\n- 组件库已有(按钮 / 卡片 / 列表)→ 用现有组件配置,不重造\n\n## Vue SFC 规范\n- Vue 3 <template> + <script setup>(组合式)\n- props 用 defineProps;事件用 defineEmits\n- 只渲染 UI,不做副作用(不发请求 / 不读写 storage)\n\n## 输出契约(必须)\n- 渲染产物经 v-html 等方式注入宿主:<template> 内不要 <!DOCTYPE> / <html> / <head> / <body> 外围标签,只输出内容片段\n- <template> 内不写 <script>;不引入外部脚本 / CDN\n- 每次生成/修改后调 validate_code 自检,报错修正直到通过\n\n## props 定义\n- 代码组件 defineProps 接受外部 data 传入(集成方渲染时按 data 的 props 字段传)\n\n## 组件库引用\n- 代码内可 import 组件库组件(如 <Button>);所用依赖以集成方渲染层已注入为准,不重复造\n\n## 安全底线(必须)\n- 禁 eval / new Function / Function 构造器\n- 禁访问 window 敏感属性(document.cookie / apiKey / token)\n- 不引入外部脚本 / CDN\n\n## 可访问性 + 语义化\n- 语义化标签(button / nav / section);图片 alt;交互可键盘聚焦\n- 颜色对比达标;不只用颜色传达信息", Hu = "# HTML 片段生成规范\n\n## 代码资产模型(重要)\n- 代码正文是 data 的 code 字段(资产,随 data json 进服务端 DB);UI 绑 data.code 渲染\n- vfs 是编辑工作副本:框架自动 checkout(data.code→vfs)/ commit(vfs→data.code),你只改 vfs\n- __pgId 框架管(read 看不到、write 写不进),别碰\n\n## 两条工作路径\n- 修改已有组件:必经 vfs —— 按上下文「组件代码文件地图」(name → vfs 路径)定位文件,vfs_edit 增量改 → validate_code;勿直接 write data.code;文件未检出先 vfs_write 创建\n- 新建组件:write({patch:{op:'set',jsonPath:'components.N',value:{name,code,props}}}) —— code 直接进 data,框架补 __pgId\n\n## 焦点精修(继承主 agent 焦点时)\n- 上下文提示「当前精修目标」(如 components.2(banner))→ 只改该焦点组件的代码文件;改其他组件会被 PATH_DENIED 硬拦\n- 聚焦模式不能新建组件(数据写被拦),要新建先反馈主 agent 取消焦点\n\n## 输出契约(必须)\n- 输出经 v-html 注入宿主的 HTML 片段:不要 <!DOCTYPE>,不要 <html> / <head> / <body> 外围标签\n- 单根元素包裹(如 <section class=\"hero\">…</section>)\n- 不写 <script>(v-html 注入不执行脚本);交互交宿主页面已有机制\n- 样式用片段内 <style>,class 统一加前缀防冲突(如 .pg-hero-…)\n- 不引入外部脚本 / CDN / 外链样式\n\n## 标签闭合(必须)\n- 非自闭合标签必须成对闭合(<img> / <br> / <input> 等 void 元素除外)\n- 每次生成/修改后调 validate_code 自检,报错用 vfs_edit 修正直到通过\n\n## 何时写代码组件\n- 组件库无对应类型(高度定制布局 / 一次性专题页 / 特殊视觉效果)→ 写 HTML 片段\n- 组件库已有(按钮 / 卡片 / 列表)→ 用现有组件配置,不重造\n\n## 安全底线(必须)\n- 禁 eval / new Function / Function 构造器\n- 禁访问 window 敏感属性(document.cookie / apiKey / token)\n- 不引入外部脚本 / CDN\n\n## 可访问性 + 语义化\n- 语义化标签(button / nav / section);图片 alt;交互可键盘聚焦\n- 颜色对比达标;不只用颜色传达信息", Uu = {
|
|
10239
10277
|
name: "html-builder",
|
|
10240
10278
|
description: "纯代码组件(custom Vue SFC)生成规范:代码作为 data 资产 / vfs 工作副本 / SFC 规范 / 输出契约 / props / 组件库引用 / 可访问性",
|
|
10241
|
-
getContent: () =>
|
|
10242
|
-
},
|
|
10279
|
+
getContent: () => Vu
|
|
10280
|
+
}, Wu = {
|
|
10243
10281
|
name: "html-fragment",
|
|
10244
10282
|
description: "纯 HTML 片段(v-html 注入)生成规范:代码作为 data 资产 / vfs 工作副本 / 无外围标签 / 单根元素 / 标签闭合 / validate_code 自检 / 安全底线 / 可访问性",
|
|
10245
|
-
getContent: () =>
|
|
10283
|
+
getContent: () => Hu
|
|
10246
10284
|
};
|
|
10247
|
-
function
|
|
10285
|
+
function Gu(e = {}) {
|
|
10248
10286
|
let t = e.vfsPrefix ?? "html/";
|
|
10249
10287
|
return ({ state: e }) => {
|
|
10250
10288
|
let n = e.files;
|
|
@@ -10252,7 +10290,7 @@ function Wu(e = {}) {
|
|
|
10252
10290
|
let r = [];
|
|
10253
10291
|
for (let [e, i] of Object.entries(n)) {
|
|
10254
10292
|
if (!e.startsWith(t)) continue;
|
|
10255
|
-
let n =
|
|
10293
|
+
let n = zu(i.content, { sfc: e.endsWith(".vue") });
|
|
10256
10294
|
for (let t of n) r.push(`${e} 第 ${t.line} 行:${t.message}(${t.code})`);
|
|
10257
10295
|
}
|
|
10258
10296
|
return r.length ? {
|
|
@@ -10261,7 +10299,7 @@ function Wu(e = {}) {
|
|
|
10261
10299
|
} : { ok: !0 };
|
|
10262
10300
|
};
|
|
10263
10301
|
}
|
|
10264
|
-
function
|
|
10302
|
+
function Ku(e) {
|
|
10265
10303
|
let n;
|
|
10266
10304
|
return {
|
|
10267
10305
|
name: "html-validate-tools",
|
|
@@ -10290,7 +10328,7 @@ function Gu(e) {
|
|
|
10290
10328
|
}
|
|
10291
10329
|
let a = [];
|
|
10292
10330
|
for (let e of i) {
|
|
10293
|
-
let t =
|
|
10331
|
+
let t = zu(e.content, { sfc: e.path.endsWith(".vue") });
|
|
10294
10332
|
t.length && a.push(`${e.path}:\n${t.map((e) => ` 第 ${e.line} 行 ${e.message}(${e.code})`).join("\n")}`);
|
|
10295
10333
|
}
|
|
10296
10334
|
return a.length ? `❌ 格式校验未通过:\n${a.join("\n")}\n请用 vfs_edit 修正后重新调用 validate_code 复查。` : `✅ 格式校验通过(${i.map((e) => e.path).join(", ")}:标签闭合、片段契约)。`;
|
|
@@ -10304,17 +10342,17 @@ function Gu(e) {
|
|
|
10304
10342
|
})]
|
|
10305
10343
|
};
|
|
10306
10344
|
}
|
|
10307
|
-
var
|
|
10308
|
-
function
|
|
10345
|
+
var qu = 2;
|
|
10346
|
+
function Ju(e) {
|
|
10309
10347
|
let { writablePaths: t, codeVfsPrefix: n = "html/", id: r = "html", description: i, planning: a = !0, summarization: o = !0, maxToolRounds: s = 12, temperature: c = .4, skills: l, extraTools: u, codeKind: d = "sfc", formatCheck: f = !0 } = e;
|
|
10310
10348
|
if (!t?.length) throw Error("[page-agent-sdk][createHtmlSubagent] writablePaths 必填(代码组件 data 区,如 [\"components\"])");
|
|
10311
10349
|
let p = d === "html" ? "html" : "vue", m = [];
|
|
10312
|
-
a && m.push(ra()), f && (m.push(
|
|
10350
|
+
a && m.push(ra()), f && (m.push(Ku(n)), m.push(qo({ check: Gu({ vfsPrefix: n }) })));
|
|
10313
10351
|
let h = u ?? [];
|
|
10314
10352
|
return {
|
|
10315
10353
|
id: r,
|
|
10316
10354
|
description: i ?? "生成/修改纯代码组件(custom 代码)。代码作为 data 资产(code 字段进 DB),vfs 作工作副本;能规划(write_todos)+ 执行。需写代码组件或灵活定制时委派",
|
|
10317
|
-
systemPrompt:
|
|
10355
|
+
systemPrompt: Bu(n, d),
|
|
10318
10356
|
writablePaths: t,
|
|
10319
10357
|
allowedTools: [
|
|
10320
10358
|
"vfs_write",
|
|
@@ -10325,9 +10363,9 @@ function qu(e) {
|
|
|
10325
10363
|
],
|
|
10326
10364
|
middleware: m.length ? m : void 0,
|
|
10327
10365
|
summarization: o === !1 ? void 0 : o,
|
|
10328
|
-
maxVerifyAttempts: f ?
|
|
10366
|
+
maxVerifyAttempts: f ? qu : void 0,
|
|
10329
10367
|
temperature: c,
|
|
10330
|
-
skills: l ?? (d === "html" ? [
|
|
10368
|
+
skills: l ?? (d === "html" ? [Wu] : [Uu]),
|
|
10331
10369
|
maxToolRounds: s,
|
|
10332
10370
|
tools: h.length ? h : void 0,
|
|
10333
10371
|
_codeAsset: {
|
|
@@ -10339,7 +10377,7 @@ function qu(e) {
|
|
|
10339
10377
|
}
|
|
10340
10378
|
//#endregion
|
|
10341
10379
|
//#region src/core/utils/clipboard.ts
|
|
10342
|
-
async function
|
|
10380
|
+
async function Yu(e) {
|
|
10343
10381
|
try {
|
|
10344
10382
|
let t = globalThis.navigator?.clipboard;
|
|
10345
10383
|
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
@@ -10357,7 +10395,7 @@ async function Ju(e) {
|
|
|
10357
10395
|
}
|
|
10358
10396
|
//#endregion
|
|
10359
10397
|
//#region src/core/composables/useChat.ts
|
|
10360
|
-
function
|
|
10398
|
+
function Xu(e = {}) {
|
|
10361
10399
|
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a } = e, o = /* @__PURE__ */ _t({
|
|
10362
10400
|
messages: e.messages ?? [],
|
|
10363
10401
|
loading: !1,
|
|
@@ -10542,9 +10580,9 @@ function Yu(e = {}) {
|
|
|
10542
10580
|
}
|
|
10543
10581
|
//#endregion
|
|
10544
10582
|
//#region src/core/composables/chatContext.ts
|
|
10545
|
-
var
|
|
10546
|
-
function
|
|
10547
|
-
let t =
|
|
10583
|
+
var Zu = Symbol("chatContext");
|
|
10584
|
+
function Qu(e = {}) {
|
|
10585
|
+
let t = Xu({
|
|
10548
10586
|
fetchResponse: e.fetchResponse,
|
|
10549
10587
|
fetchStream: e.fetchStream,
|
|
10550
10588
|
messages: e.messages,
|
|
@@ -10564,7 +10602,7 @@ function Zu(e = {}) {
|
|
|
10564
10602
|
}, h = /* @__PURE__ */ Ot({}), g = (e) => h.value[e] !== !1, _ = (e) => {
|
|
10565
10603
|
h.value[e] = !g(e);
|
|
10566
10604
|
}, v = /* @__PURE__ */ Ot(!1), y = (e) => {
|
|
10567
|
-
|
|
10605
|
+
Yu(e).then((e) => {
|
|
10568
10606
|
e && (v.value = !0, setTimeout(() => {
|
|
10569
10607
|
v.value = !1;
|
|
10570
10608
|
}, 1500));
|
|
@@ -10632,15 +10670,15 @@ function Zu(e = {}) {
|
|
|
10632
10670
|
}
|
|
10633
10671
|
};
|
|
10634
10672
|
}
|
|
10635
|
-
function
|
|
10636
|
-
let e = Fn(
|
|
10673
|
+
function $u() {
|
|
10674
|
+
let e = Fn(Zu);
|
|
10637
10675
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
10638
10676
|
return e;
|
|
10639
10677
|
}
|
|
10640
10678
|
//#endregion
|
|
10641
10679
|
//#region src/core/index.headless.ts
|
|
10642
|
-
function
|
|
10643
|
-
return
|
|
10680
|
+
function ed(e) {
|
|
10681
|
+
return ku(e);
|
|
10644
10682
|
}
|
|
10645
10683
|
//#endregion
|
|
10646
|
-
export {
|
|
10684
|
+
export { Uc as CAPABILITIES, Kc as CONTEXT_PRESETS, rc as CompressDecisionSchema, vs as DEFAULT_SYSTEM_PROMPT, Iu as HTML_VOID_TAGS, Ya as HUMAN_CONFIRM_TOOL_NAME, ni as MIN_CONTEXT_WINDOW, _o as STOP_WORDS, xs as UNSAFE_KEYS, au as actionsToInspectInfo, iu as actionsToTools, Yr as agentError, fs as analyzeContext, js as applyPatchToClone, Ms as applyPatchToLive, Jr as asAgentError, ys as buildDataPrompt, bs as buildSystemPrompt, Zu as chatContextKey, Ml as commitSetToBind, _s as connectMcp, f as constructLlmFromConfig, d as constructOpenLlmSync, Yu as copyText, Fi as createAgent, Ja as createApprovalMiddleware, Qu as createChatContext, ed as createChatSdk, ao as createCheckpointManager, oo as createCheckpointMiddleware, hc as createConflictManager, ps as createContextInspectorMiddleware, Bl as createDataOps, Gu as createHtmlFormatCheck, Ju as createHtmlSubagent, Qa as createHumanConfirmMiddleware, Za as createHumanConfirmTool, Ic as createMemoryBackend, Va as createMemoryMiddleware, u as createProxyLlm, Fu as createRagSubagent, Ta as createSandboxRunner, Gc as createSdkEvents, Su as createSerialRunner, Bc as createSessionStore, vu as createSkillStore, Uo as createSubagentMiddleware, Do as createSubagentTracker, Ko as createSubagentsMiddleware, fu as createUsageHintsMiddleware, qo as createVerifyMiddleware, zs as createVfs, Rc as createWebStorageBackend, $o as createWriteBackCheck, Es as deepClone, cu as defineDataToolset, Da as defineSkill, ec as defineTool, Ts as deleteByPath, ic as deriveTitle, qi as describeSchemaNode, Ti as detectGarbledToolCall, Fs as diffObjects, Kl as domToStructure, Jl as domTools, su as domToolsStatic, yo as estimateMessageTokens, bo as estimateRoundTokens, X as estimateTokens, m as extractReasoningDelta, pa as extractSchemaHint, ms as extractText, p as extractTextDelta, h as extractUsage, Hl as fetchDocTools, ou as fetchTools, jl as filterByToolMode, Ji as formatConstraints, Wr as formatZodIssues, Z as getByPath, ql as getDomTool, Zl as getEnvSummary, zi as getSchemaAtPath, Ii as getSchemaTopKeys, oi as getTraceMetrics, $ as hashValue, xo as indexSummarize, eu as inspectEnvTool, tu as inspectTools, ac as isChatModel, gi as isContextLengthError, Li as isPathAllowed, Oc as isQuotaError, Ss as isUnsafePath, ol as jpEval, Kr as jsonParseError, ks as limitDepth, Ds as maybeParseValue, g as normalizeUsage, ai as offloadPassThroughChars, ii as offloadThresholdChars, ca as presets, Vi as projectBySchema, Bi as projectBySchemaDeep, Os as projectFields, So as recallRounds, Yi as renderSchemaHint, Xi as renderSchemaOverview, $i as renderSchemaShallow, Wc as resolveCapabilities, Jc as resolveContextOptions, Hc as resolveDialogConfig, mc as resolveLlm, ri as resolveModelCaps, Vc as resolveStorage, Ps as restoreInPlace, Ns as restoreLive, qr as routeError, Ea as runHostScript, ul as runSandboxedScript, Cs as safeMerge, Xl as safeSerialize, Q as safeStringify, cl as searchJson, lu as selectBuiltinTools, ws as setByPath, Co as shouldTriggerCompression, la as systemPromptHelpers, vo as tokenize, Y as toolError, Ri as unwrapSchema, Xu as useChat, $u as useChatContext, zu as validateHtmlFormat, e as z, Gr as zodError };
|