page-agent-sdk 3.0.0 → 3.2.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 +433 -374
- package/dist/page-agent-sdk.iife.js +139 -127
- package/dist/page-agent-sdk.js +1271 -1197
- package/dist/page-agent-sdk.umd.cjs +72 -60
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -4465,7 +4465,7 @@ async function Ho(e, t, n, r, i, a) {
|
|
|
4465
4465
|
a?.(e);
|
|
4466
4466
|
return;
|
|
4467
4467
|
}
|
|
4468
|
-
r && (e.type === "tool_call" || e.type === "tool_result") && r(e);
|
|
4468
|
+
r && (e.type === "tool_call" || e.type === "tool_result" || e.type === "reasoning") && r(e);
|
|
4469
4469
|
}, x.signal);
|
|
4470
4470
|
if (!t.timeoutMs || t.timeoutMs <= 0) try {
|
|
4471
4471
|
return await w;
|
|
@@ -4486,6 +4486,17 @@ async function Ho(e, t, n, r, i, a) {
|
|
|
4486
4486
|
}
|
|
4487
4487
|
function Uo(e) {
|
|
4488
4488
|
let n = e.maxParallel ?? jo, i, a, o, s = (t, n) => (r) => {
|
|
4489
|
+
if (r.type === "reasoning") {
|
|
4490
|
+
a?.({
|
|
4491
|
+
type: "subagent",
|
|
4492
|
+
taskId: t,
|
|
4493
|
+
label: n,
|
|
4494
|
+
kind: "reasoning",
|
|
4495
|
+
name: "",
|
|
4496
|
+
delta: r.delta
|
|
4497
|
+
});
|
|
4498
|
+
return;
|
|
4499
|
+
}
|
|
4489
4500
|
e.tracker?.pushStep(t, {
|
|
4490
4501
|
kind: r.type,
|
|
4491
4502
|
name: r.name,
|
|
@@ -4594,6 +4605,17 @@ function Go(e, t) {
|
|
|
4594
4605
|
}
|
|
4595
4606
|
function Ko(e, n) {
|
|
4596
4607
|
let i, a, o, s = (e, t) => (n) => {
|
|
4608
|
+
if (n.type === "reasoning") {
|
|
4609
|
+
a?.({
|
|
4610
|
+
type: "subagent",
|
|
4611
|
+
taskId: e,
|
|
4612
|
+
label: t,
|
|
4613
|
+
kind: "reasoning",
|
|
4614
|
+
name: "",
|
|
4615
|
+
delta: n.delta
|
|
4616
|
+
});
|
|
4617
|
+
return;
|
|
4618
|
+
}
|
|
4597
4619
|
a && a({
|
|
4598
4620
|
type: "subagent",
|
|
4599
4621
|
taskId: e,
|
|
@@ -4622,7 +4644,7 @@ function Ko(e, n) {
|
|
|
4622
4644
|
...e,
|
|
4623
4645
|
source: `子:${d.id}`
|
|
4624
4646
|
}), c = n.tracker, l = c ? `use_${d.id}-${Math.random().toString(36).slice(2, 6)}` : `use_${d.id}`, u = s(`use_${d.id}`, d.id), f = c ? (e) => {
|
|
4625
|
-
c.pushStep(l, {
|
|
4647
|
+
e.type !== "reasoning" && c.pushStep(l, {
|
|
4626
4648
|
kind: e.type,
|
|
4627
4649
|
name: e.name,
|
|
4628
4650
|
ts: Date.now()
|
|
@@ -5674,7 +5696,26 @@ function Zs(e, t, n) {
|
|
|
5674
5696
|
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && typeof e.__pgId == "string" && n(e, r);
|
|
5675
5697
|
}
|
|
5676
5698
|
}
|
|
5677
|
-
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) {
|
|
5678
5719
|
let { writablePaths: t, codeVfsPrefix: n, ext: r, getController: i, vfsStore: a } = e;
|
|
5679
5720
|
return {
|
|
5680
5721
|
name: "code-asset-checkout-commit",
|
|
@@ -5693,19 +5734,27 @@ function Qs(e) {
|
|
|
5693
5734
|
[Ys]: /* @__PURE__ */ new Set()
|
|
5694
5735
|
};
|
|
5695
5736
|
},
|
|
5696
|
-
wrapToolCall: async (e,
|
|
5697
|
-
let
|
|
5698
|
-
if (
|
|
5699
|
-
let
|
|
5700
|
-
if (
|
|
5701
|
-
let
|
|
5702
|
-
if (
|
|
5703
|
-
let t =
|
|
5704
|
-
t &&
|
|
5737
|
+
wrapToolCall: async (e, a) => {
|
|
5738
|
+
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);
|
|
5739
|
+
if (c) {
|
|
5740
|
+
let a = e.state.focuses;
|
|
5741
|
+
if (a && a.length) {
|
|
5742
|
+
let e = Qs(i()?.get?.().bind, t, a);
|
|
5743
|
+
if (e.size) {
|
|
5744
|
+
let t = Xs(s, n);
|
|
5745
|
+
if (t && !e.has(t)) return {
|
|
5746
|
+
content: `PATH_DENIED · vfs 越界:当前聚焦代码文件 [${[...e].map((e) => `${n}${e}.${r}`).join(", ")}],你要改的 "${s}" 不在其中。请只改焦点组件的代码文件;如需改其他组件,请让主 agent clear_focus / 换焦点后重试。`,
|
|
5747
|
+
status: "error"
|
|
5748
|
+
};
|
|
5705
5749
|
}
|
|
5706
5750
|
}
|
|
5707
5751
|
}
|
|
5708
|
-
|
|
5752
|
+
let l = await a(e);
|
|
5753
|
+
if (c) {
|
|
5754
|
+
let t = e.state[Ys];
|
|
5755
|
+
t && t.add(s);
|
|
5756
|
+
}
|
|
5757
|
+
return l;
|
|
5709
5758
|
},
|
|
5710
5759
|
afterAgent: (e) => {
|
|
5711
5760
|
let o = i(), s = o?.get?.().bind, c = e[Ys];
|
|
@@ -5730,7 +5779,7 @@ function Qs(e) {
|
|
|
5730
5779
|
}
|
|
5731
5780
|
//#endregion
|
|
5732
5781
|
//#region src/core/sdk/defineTool.ts
|
|
5733
|
-
function
|
|
5782
|
+
function ec(e) {
|
|
5734
5783
|
return r(async (t) => {
|
|
5735
5784
|
let n = await e.handler(t);
|
|
5736
5785
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -5742,7 +5791,7 @@ function $s(e) {
|
|
|
5742
5791
|
}
|
|
5743
5792
|
//#endregion
|
|
5744
5793
|
//#region src/core/sdk/inspectContextTool.ts
|
|
5745
|
-
var
|
|
5794
|
+
var tc = t.object({
|
|
5746
5795
|
path: t.string().optional().describe("分类 key 过滤(如 toolResults/history/systemPrompt/dataHint);不传=全部分类"),
|
|
5747
5796
|
role: t.enum([
|
|
5748
5797
|
"user",
|
|
@@ -5752,11 +5801,11 @@ var ec = t.object({
|
|
|
5752
5801
|
]).optional().describe("聚焦每轮首句的角色(assistant→回复摘要,user→问题摘要);不影响工具列表"),
|
|
5753
5802
|
limit: t.number().int().min(1).max(50).optional().describe("返回最近 N 轮(默认全部;超 50 自动截最近 50 防返回过大)")
|
|
5754
5803
|
});
|
|
5755
|
-
function
|
|
5756
|
-
return
|
|
5804
|
+
function nc(e) {
|
|
5805
|
+
return ec({
|
|
5757
5806
|
name: "inspect_context",
|
|
5758
5807
|
description: "查看当前对话上下文的构成(供压缩决策)。返回:totalTokens(历史轮次 token 总和,与触发判断同口径)、occupancy(窗口占用比)、contextWindow、categories(分类占用)、rounds(每轮 token/工具/首句)。先调用本工具查看构成,再决定压缩策略。",
|
|
5759
|
-
schema:
|
|
5808
|
+
schema: tc,
|
|
5760
5809
|
handler: (t) => {
|
|
5761
5810
|
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) => {
|
|
5762
5811
|
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);
|
|
@@ -5779,7 +5828,7 @@ function tc(e) {
|
|
|
5779
5828
|
}
|
|
5780
5829
|
//#endregion
|
|
5781
5830
|
//#region src/core/sdk/compressDecision.ts
|
|
5782
|
-
var
|
|
5831
|
+
var rc = t.object({
|
|
5783
5832
|
keepRounds: t.number().int().min(0).max(50).optional(),
|
|
5784
5833
|
windowRatio: t.number().min(0).max(1).optional(),
|
|
5785
5834
|
summarize: t.object({ mode: t.enum(["index", "llm"]) }),
|
|
@@ -5789,23 +5838,23 @@ var nc = t.object({
|
|
|
5789
5838
|
}).refine((e) => e.keepRounds !== void 0 || e.windowRatio !== void 0, { message: "keepRounds 与 windowRatio 至少填一个(按当前触发模式)" });
|
|
5790
5839
|
//#endregion
|
|
5791
5840
|
//#region src/core/sdk/llmResolver.ts
|
|
5792
|
-
function
|
|
5841
|
+
function ic(e) {
|
|
5793
5842
|
let t = e.find((e) => e.role === "user");
|
|
5794
5843
|
if (!t) return;
|
|
5795
5844
|
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, " ");
|
|
5796
5845
|
if (r) return r.length > 30 ? r.slice(0, 30) + "…" : r;
|
|
5797
5846
|
}
|
|
5798
|
-
function
|
|
5847
|
+
function ac(e) {
|
|
5799
5848
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
5800
5849
|
}
|
|
5801
|
-
function
|
|
5850
|
+
function oc(e) {
|
|
5802
5851
|
let t = e.content;
|
|
5803
5852
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
5804
5853
|
}
|
|
5805
|
-
function
|
|
5854
|
+
function sc(e) {
|
|
5806
5855
|
let t = e.summaryLlm ?? e.llm;
|
|
5807
5856
|
if (!t) return;
|
|
5808
|
-
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s =
|
|
5857
|
+
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s = ac(t) ? t : null, c = ac(t) ? null : t;
|
|
5809
5858
|
if (c && !c.apiKey) {
|
|
5810
5859
|
e.summaryLlm && console.warn("[page-agent-sdk][summarization] summaryLlm 已配置但缺 apiKey,摘要回退主 agent 模型或零成本索引摘要");
|
|
5811
5860
|
return;
|
|
@@ -5817,16 +5866,16 @@ function oc(e) {
|
|
|
5817
5866
|
return !l && c && (l = await f(c, {
|
|
5818
5867
|
temperature: n,
|
|
5819
5868
|
maxTokens: r
|
|
5820
|
-
})),
|
|
5869
|
+
})), oc(await l.invoke([new o("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new a(e)], { signal: t.signal })).trim();
|
|
5821
5870
|
} finally {
|
|
5822
5871
|
clearTimeout(s);
|
|
5823
5872
|
}
|
|
5824
5873
|
};
|
|
5825
5874
|
}
|
|
5826
|
-
function
|
|
5875
|
+
function cc(e) {
|
|
5827
5876
|
let t = e.titleLlm ?? e.summaryLlm ?? e.llm;
|
|
5828
5877
|
if (!t) return;
|
|
5829
|
-
let n =
|
|
5878
|
+
let n = ac(t) ? t : null, r = ac(t) ? null : t;
|
|
5830
5879
|
if (r && !r.apiKey) return;
|
|
5831
5880
|
let i = n;
|
|
5832
5881
|
return async (e) => {
|
|
@@ -5835,7 +5884,7 @@ function sc(e) {
|
|
|
5835
5884
|
return !i && r && (i = await f(r, {
|
|
5836
5885
|
temperature: 0,
|
|
5837
5886
|
maxTokens: 30
|
|
5838
|
-
})),
|
|
5887
|
+
})), oc(await i.invoke([new o("根据以下对话的主旨,生成一个简短的中文标题(不超过15个字,不要标点和引号,直接输出标题文字)。"), new a(t)], { signal: n.signal })).trim().replace(/^["'""「『]|["'""」』]$/g, "").split("\n")[0].slice(0, 20);
|
|
5839
5888
|
} catch {
|
|
5840
5889
|
return "";
|
|
5841
5890
|
} finally {
|
|
@@ -5843,10 +5892,10 @@ function sc(e) {
|
|
|
5843
5892
|
}
|
|
5844
5893
|
};
|
|
5845
5894
|
}
|
|
5846
|
-
function
|
|
5895
|
+
function lc() {
|
|
5847
5896
|
return `call_dec_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
5848
5897
|
}
|
|
5849
|
-
function
|
|
5898
|
+
function uc(e) {
|
|
5850
5899
|
let t = e.match(/```(?:json)?\s*([\s\S]*?)```/), n = t ? t[1] : e, r = n.indexOf("{"), i = n.lastIndexOf("}");
|
|
5851
5900
|
if (r < 0 || i < 0 || i <= r) return null;
|
|
5852
5901
|
try {
|
|
@@ -5855,21 +5904,21 @@ function lc(e) {
|
|
|
5855
5904
|
return null;
|
|
5856
5905
|
}
|
|
5857
5906
|
}
|
|
5858
|
-
function
|
|
5907
|
+
function dc(e) {
|
|
5859
5908
|
if (!e) return null;
|
|
5860
|
-
let t =
|
|
5909
|
+
let t = uc(e);
|
|
5861
5910
|
if (t == null) return null;
|
|
5862
|
-
let n =
|
|
5911
|
+
let n = rc.safeParse(t);
|
|
5863
5912
|
return n.success ? n.data : null;
|
|
5864
5913
|
}
|
|
5865
|
-
async function
|
|
5914
|
+
async function fc(e, t, n, r) {
|
|
5866
5915
|
let i = [...n];
|
|
5867
5916
|
for (let n = 0; n < 3; n++) {
|
|
5868
5917
|
let n = await e.invoke(i, { signal: r }), a = n?.tool_calls ?? [];
|
|
5869
|
-
if (!a.length) return
|
|
5918
|
+
if (!a.length) return oc(n).trim();
|
|
5870
5919
|
i = [...i, n];
|
|
5871
5920
|
for (let e of a) {
|
|
5872
|
-
let n = e.id ??
|
|
5921
|
+
let n = e.id ?? lc();
|
|
5873
5922
|
try {
|
|
5874
5923
|
let r = await t.invoke(e.args ?? {}), a = typeof r == "string" ? r : r?.content ?? JSON.stringify(r);
|
|
5875
5924
|
i = [...i, new s({
|
|
@@ -5886,10 +5935,10 @@ async function dc(e, t, n, r) {
|
|
|
5886
5935
|
}
|
|
5887
5936
|
return "";
|
|
5888
5937
|
}
|
|
5889
|
-
function
|
|
5938
|
+
function pc(e) {
|
|
5890
5939
|
let t = e.summaryLlm ?? e.llm;
|
|
5891
5940
|
if (!t) return;
|
|
5892
|
-
let n =
|
|
5941
|
+
let n = ac(t) ? t : null, r = ac(t) ? null : t;
|
|
5893
5942
|
if (r && !r.apiKey) return;
|
|
5894
5943
|
let i = e.decisionTimeoutMs ?? 6e3, s = e.decisionMaxTokens ?? 2048, c = n;
|
|
5895
5944
|
return async (e) => {
|
|
@@ -5901,12 +5950,12 @@ function fc(e) {
|
|
|
5901
5950
|
}));
|
|
5902
5951
|
let n = c;
|
|
5903
5952
|
if (typeof n.bindTools != "function") return null;
|
|
5904
|
-
let i =
|
|
5953
|
+
let i = nc({
|
|
5905
5954
|
getMessages: e.getMessages,
|
|
5906
5955
|
getSnapshot: e.getSnapshot,
|
|
5907
5956
|
contextWindow: e.contextWindow
|
|
5908
5957
|
}), 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)。`)];
|
|
5909
|
-
return
|
|
5958
|
+
return dc(await fc(l, i, d, t.signal)) || dc(await fc(l, i, [...d, new a("上一次输出无效(JSON 解析失败或 schema 校验不通过)。请只输出符合 schema 的压缩决策 JSON,不要多余文字/markdown 代码块。")], t.signal));
|
|
5910
5959
|
} catch {
|
|
5911
5960
|
return null;
|
|
5912
5961
|
} finally {
|
|
@@ -5914,22 +5963,22 @@ function fc(e) {
|
|
|
5914
5963
|
}
|
|
5915
5964
|
};
|
|
5916
5965
|
}
|
|
5917
|
-
function
|
|
5918
|
-
let t = e.llm, n =
|
|
5966
|
+
function mc(e) {
|
|
5967
|
+
let t = e.llm, n = ac(e.llm) ? void 0 : e.llm;
|
|
5919
5968
|
return {
|
|
5920
5969
|
modelCaps: ri({
|
|
5921
5970
|
model: n?.model ?? t?.model ?? t?.modelName,
|
|
5922
5971
|
contextWindow: e.contextWindow ?? n?.contextWindow ?? t?.contextWindow,
|
|
5923
5972
|
maxOutputTokens: e.maxOutputTokens ?? n?.maxOutputTokens ?? t?.maxOutputTokens
|
|
5924
5973
|
}),
|
|
5925
|
-
summaryLlmInvoke:
|
|
5926
|
-
titleLlmInvoke:
|
|
5927
|
-
compressDecisionInvoke:
|
|
5974
|
+
summaryLlmInvoke: sc(e),
|
|
5975
|
+
titleLlmInvoke: cc(e),
|
|
5976
|
+
compressDecisionInvoke: pc(e)
|
|
5928
5977
|
};
|
|
5929
5978
|
}
|
|
5930
5979
|
//#endregion
|
|
5931
5980
|
//#region src/core/sdk/conflictManager.ts
|
|
5932
|
-
function
|
|
5981
|
+
function hc(e) {
|
|
5933
5982
|
let t = /* @__PURE__ */ Ot(null), n = 0;
|
|
5934
5983
|
function r(r) {
|
|
5935
5984
|
return new Promise((i) => {
|
|
@@ -5960,7 +6009,7 @@ function mc(e) {
|
|
|
5960
6009
|
}
|
|
5961
6010
|
//#endregion
|
|
5962
6011
|
//#region src/core/utils/id.ts
|
|
5963
|
-
function
|
|
6012
|
+
function gc() {
|
|
5964
6013
|
try {
|
|
5965
6014
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
5966
6015
|
} catch {}
|
|
@@ -5968,7 +6017,7 @@ function hc() {
|
|
|
5968
6017
|
}
|
|
5969
6018
|
//#endregion
|
|
5970
6019
|
//#region src/core/backends/storage.ts
|
|
5971
|
-
var
|
|
6020
|
+
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 = [
|
|
5972
6021
|
"messages",
|
|
5973
6022
|
"vfs",
|
|
5974
6023
|
"todos",
|
|
@@ -5979,51 +6028,51 @@ var gc = "chat-sdk", _c = 50 * 1024 * 1024, vc = 4 * 1024 * 1024, yc = 10 * 1024
|
|
|
5979
6028
|
"workingMemory",
|
|
5980
6029
|
"focus"
|
|
5981
6030
|
];
|
|
5982
|
-
function Ec(e) {
|
|
5983
|
-
return e === "local" || e === "session" ? vc : _c;
|
|
5984
|
-
}
|
|
5985
6031
|
function Dc(e) {
|
|
6032
|
+
return e === "local" || e === "session" ? yc : vc;
|
|
6033
|
+
}
|
|
6034
|
+
function Oc(e) {
|
|
5986
6035
|
if (typeof e != "object" || !e) return !1;
|
|
5987
6036
|
let t = e;
|
|
5988
6037
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
5989
6038
|
}
|
|
5990
|
-
function
|
|
6039
|
+
function kc(e, t, n, r) {
|
|
5991
6040
|
return [
|
|
5992
|
-
|
|
6041
|
+
Tc,
|
|
5993
6042
|
e,
|
|
5994
6043
|
t,
|
|
5995
6044
|
n,
|
|
5996
6045
|
r
|
|
5997
6046
|
].join("::");
|
|
5998
6047
|
}
|
|
5999
|
-
function
|
|
6048
|
+
function Ac(e, t, n) {
|
|
6000
6049
|
return [
|
|
6001
|
-
|
|
6050
|
+
Tc,
|
|
6002
6051
|
e,
|
|
6003
6052
|
t,
|
|
6004
6053
|
n
|
|
6005
6054
|
].join("::") + "::";
|
|
6006
6055
|
}
|
|
6007
|
-
function
|
|
6056
|
+
function jc(e, t) {
|
|
6008
6057
|
return [
|
|
6009
|
-
|
|
6058
|
+
Tc,
|
|
6010
6059
|
e,
|
|
6011
6060
|
t
|
|
6012
6061
|
].join("::") + "::";
|
|
6013
6062
|
}
|
|
6014
|
-
function
|
|
6015
|
-
return [
|
|
6063
|
+
function Mc(e) {
|
|
6064
|
+
return [Tc, e].join("::") + "::";
|
|
6016
6065
|
}
|
|
6017
|
-
var
|
|
6018
|
-
function
|
|
6019
|
-
|
|
6066
|
+
var Nc = null;
|
|
6067
|
+
function Pc(e) {
|
|
6068
|
+
Nc ||= new TextEncoder();
|
|
6020
6069
|
try {
|
|
6021
|
-
return
|
|
6070
|
+
return Nc.encode(JSON.stringify(e)).length;
|
|
6022
6071
|
} catch {
|
|
6023
6072
|
return 0;
|
|
6024
6073
|
}
|
|
6025
6074
|
}
|
|
6026
|
-
function
|
|
6075
|
+
function Fc(e, t, n) {
|
|
6027
6076
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
6028
6077
|
if (r <= t) return [];
|
|
6029
6078
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -6033,7 +6082,7 @@ function Pc(e, t, n) {
|
|
|
6033
6082
|
}
|
|
6034
6083
|
return o;
|
|
6035
6084
|
}
|
|
6036
|
-
function
|
|
6085
|
+
function Ic() {
|
|
6037
6086
|
let e = /* @__PURE__ */ new Map();
|
|
6038
6087
|
return {
|
|
6039
6088
|
async get(t) {
|
|
@@ -6053,7 +6102,7 @@ function Fc() {
|
|
|
6053
6102
|
}
|
|
6054
6103
|
};
|
|
6055
6104
|
}
|
|
6056
|
-
function
|
|
6105
|
+
function Lc(e) {
|
|
6057
6106
|
return new Promise((t, n) => {
|
|
6058
6107
|
if (typeof indexedDB > "u") {
|
|
6059
6108
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -6114,7 +6163,7 @@ function Ic(e) {
|
|
|
6114
6163
|
}, r.onerror = () => n(r.error);
|
|
6115
6164
|
});
|
|
6116
6165
|
}
|
|
6117
|
-
function
|
|
6166
|
+
function Rc(e) {
|
|
6118
6167
|
return {
|
|
6119
6168
|
async get(t) {
|
|
6120
6169
|
let n = e.getItem(t);
|
|
@@ -6159,12 +6208,12 @@ function Lc(e) {
|
|
|
6159
6208
|
}
|
|
6160
6209
|
};
|
|
6161
6210
|
}
|
|
6162
|
-
function
|
|
6211
|
+
function zc(e, t, n) {
|
|
6163
6212
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
6164
6213
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
6165
6214
|
}
|
|
6166
|
-
function
|
|
6167
|
-
let t = e.dbName ??
|
|
6215
|
+
function Bc(e = {}) {
|
|
6216
|
+
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();
|
|
6168
6217
|
function c(e) {
|
|
6169
6218
|
for (let t of s) try {
|
|
6170
6219
|
t(e);
|
|
@@ -6177,16 +6226,16 @@ function zc(e = {}) {
|
|
|
6177
6226
|
try {
|
|
6178
6227
|
if (n === "indexed") {
|
|
6179
6228
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
6180
|
-
l = await
|
|
6229
|
+
l = await Lc(t), d(!0);
|
|
6181
6230
|
} else if (n === "session") {
|
|
6182
6231
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
6183
|
-
l =
|
|
6232
|
+
l = Rc(sessionStorage), d(!0);
|
|
6184
6233
|
} else if (n === "local") {
|
|
6185
6234
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
6186
|
-
l =
|
|
6187
|
-
} else l =
|
|
6235
|
+
l = Rc(localStorage), d(!0);
|
|
6236
|
+
} else l = Ic(), d(!1);
|
|
6188
6237
|
} catch (e) {
|
|
6189
|
-
l =
|
|
6238
|
+
l = Ic();
|
|
6190
6239
|
let t = e instanceof Error ? e.message : String(e);
|
|
6191
6240
|
d(!1), Promise.resolve().then(() => c({
|
|
6192
6241
|
type: "degraded",
|
|
@@ -6196,10 +6245,10 @@ function zc(e = {}) {
|
|
|
6196
6245
|
})();
|
|
6197
6246
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
6198
6247
|
function g(e, n, r, a) {
|
|
6199
|
-
let o =
|
|
6200
|
-
return
|
|
6248
|
+
let o = kc(t, r, a, wc);
|
|
6249
|
+
return zc(h, o, async () => {
|
|
6201
6250
|
let t = async () => {
|
|
6202
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
6251
|
+
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);
|
|
6203
6252
|
if (f > i) {
|
|
6204
6253
|
c({
|
|
6205
6254
|
type: "quota",
|
|
@@ -6221,12 +6270,12 @@ function zc(e = {}) {
|
|
|
6221
6270
|
try {
|
|
6222
6271
|
await t();
|
|
6223
6272
|
} catch (e) {
|
|
6224
|
-
if (
|
|
6273
|
+
if (Oc(e) && !u) {
|
|
6225
6274
|
u = !0;
|
|
6226
6275
|
try {
|
|
6227
6276
|
await b();
|
|
6228
6277
|
} catch {}
|
|
6229
|
-
l =
|
|
6278
|
+
l = Ic(), Promise.resolve().then(() => c({
|
|
6230
6279
|
type: "degraded",
|
|
6231
6280
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
6232
6281
|
}));
|
|
@@ -6238,7 +6287,7 @@ function zc(e = {}) {
|
|
|
6238
6287
|
});
|
|
6239
6288
|
}
|
|
6240
6289
|
function _(e, n, r, i) {
|
|
6241
|
-
let a =
|
|
6290
|
+
let a = kc(t, e, n, r), s = p.get(a);
|
|
6242
6291
|
s && s.resolve();
|
|
6243
6292
|
let c = m.get(a);
|
|
6244
6293
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -6265,15 +6314,15 @@ function zc(e = {}) {
|
|
|
6265
6314
|
function y() {
|
|
6266
6315
|
v ||= setTimeout(() => {
|
|
6267
6316
|
v = null, b();
|
|
6268
|
-
},
|
|
6317
|
+
}, Cc);
|
|
6269
6318
|
}
|
|
6270
6319
|
async function b() {
|
|
6271
6320
|
let e = [];
|
|
6272
|
-
await l.scan(
|
|
6321
|
+
await l.scan(Mc(t), (t, n) => {
|
|
6273
6322
|
t.endsWith("::__meta__") && e.push(n);
|
|
6274
6323
|
});
|
|
6275
|
-
let n =
|
|
6276
|
-
for (let e of n) await l.clearPrefix(
|
|
6324
|
+
let n = Fc(e, r, a);
|
|
6325
|
+
for (let e of n) await l.clearPrefix(Ac(t, e.agentId, e.sessionId)), c({
|
|
6277
6326
|
type: "evicted",
|
|
6278
6327
|
agentId: e.agentId,
|
|
6279
6328
|
sessionId: e.sessionId,
|
|
@@ -6284,13 +6333,13 @@ function zc(e = {}) {
|
|
|
6284
6333
|
ready: f,
|
|
6285
6334
|
async listSessions(e) {
|
|
6286
6335
|
let n = [];
|
|
6287
|
-
return await l.scan(
|
|
6336
|
+
return await l.scan(jc(t, e), (e, t) => {
|
|
6288
6337
|
e.endsWith("::__meta__") && n.push(t);
|
|
6289
6338
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
6290
6339
|
},
|
|
6291
6340
|
async load(e, n) {
|
|
6292
|
-
let r =
|
|
6293
|
-
return await
|
|
6341
|
+
let r = kc(t, e, n, wc);
|
|
6342
|
+
return await zc(h, r, async () => {
|
|
6294
6343
|
let i = await l.get(r);
|
|
6295
6344
|
if (!i) return;
|
|
6296
6345
|
let a = {
|
|
@@ -6299,8 +6348,8 @@ function zc(e = {}) {
|
|
|
6299
6348
|
todos: [],
|
|
6300
6349
|
memory: ""
|
|
6301
6350
|
};
|
|
6302
|
-
for (let r of
|
|
6303
|
-
let i = await l.get(
|
|
6351
|
+
for (let r of Ec) {
|
|
6352
|
+
let i = await l.get(kc(t, e, n, r));
|
|
6304
6353
|
i != null && (a[r] = i);
|
|
6305
6354
|
}
|
|
6306
6355
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -6308,12 +6357,12 @@ function zc(e = {}) {
|
|
|
6308
6357
|
},
|
|
6309
6358
|
async save(e, t, n) {
|
|
6310
6359
|
let r = [];
|
|
6311
|
-
for (let i of
|
|
6360
|
+
for (let i of Ec) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
6312
6361
|
await Promise.all(r);
|
|
6313
6362
|
},
|
|
6314
6363
|
async updateTitle(e, n, r) {
|
|
6315
|
-
let i =
|
|
6316
|
-
return
|
|
6364
|
+
let i = kc(t, e, n, wc);
|
|
6365
|
+
return zc(h, i, async () => {
|
|
6317
6366
|
let e = await l.get(i);
|
|
6318
6367
|
e && (e.title = r, e.lastAccessed = Date.now(), await l.set(i, e));
|
|
6319
6368
|
});
|
|
@@ -6329,10 +6378,10 @@ function zc(e = {}) {
|
|
|
6329
6378
|
})), c({ type: "flush" }), await b();
|
|
6330
6379
|
},
|
|
6331
6380
|
async deleteSession(e, n) {
|
|
6332
|
-
await l.clearPrefix(
|
|
6381
|
+
await l.clearPrefix(Ac(t, e, n));
|
|
6333
6382
|
},
|
|
6334
6383
|
async createSession(e, n, r) {
|
|
6335
|
-
let i = r ??
|
|
6384
|
+
let i = r ?? gc(), a = Date.now(), o = {
|
|
6336
6385
|
agentId: e,
|
|
6337
6386
|
sessionId: i,
|
|
6338
6387
|
createdAt: a,
|
|
@@ -6340,7 +6389,7 @@ function zc(e = {}) {
|
|
|
6340
6389
|
bytes: 0,
|
|
6341
6390
|
title: n
|
|
6342
6391
|
};
|
|
6343
|
-
return await l.set(
|
|
6392
|
+
return await l.set(kc(t, e, i, wc), o), i;
|
|
6344
6393
|
},
|
|
6345
6394
|
onEvent(e) {
|
|
6346
6395
|
s.add(e);
|
|
@@ -6355,15 +6404,15 @@ function zc(e = {}) {
|
|
|
6355
6404
|
}
|
|
6356
6405
|
//#endregion
|
|
6357
6406
|
//#region src/core/sdk/optionsResolver.ts
|
|
6358
|
-
function Bc(e) {
|
|
6359
|
-
return e === void 0 || e === !1 ? null : typeof e == "string" ? zc({ backend: e }) : e.enabled === !1 ? null : zc(e);
|
|
6360
|
-
}
|
|
6361
6407
|
function Vc(e) {
|
|
6408
|
+
return e === void 0 || e === !1 ? null : typeof e == "string" ? Bc({ backend: e }) : e.enabled === !1 ? null : Bc(e);
|
|
6409
|
+
}
|
|
6410
|
+
function Hc(e) {
|
|
6362
6411
|
return e.dialog ?? {};
|
|
6363
6412
|
}
|
|
6364
6413
|
//#endregion
|
|
6365
6414
|
//#region src/core/capabilities.ts
|
|
6366
|
-
var
|
|
6415
|
+
var Uc = [
|
|
6367
6416
|
{
|
|
6368
6417
|
name: "dataOps",
|
|
6369
6418
|
defaultOn: !0
|
|
@@ -6452,13 +6501,13 @@ var Hc = [
|
|
|
6452
6501
|
requires: ["summarization"]
|
|
6453
6502
|
}
|
|
6454
6503
|
];
|
|
6455
|
-
function
|
|
6504
|
+
function Wc(e) {
|
|
6456
6505
|
let t = {};
|
|
6457
|
-
for (let n of
|
|
6506
|
+
for (let n of Uc) {
|
|
6458
6507
|
let r = e?.[n.name];
|
|
6459
6508
|
t[n.name] = n.defaultOn ? r !== !1 : r === !0;
|
|
6460
6509
|
}
|
|
6461
|
-
for (let e of
|
|
6510
|
+
for (let e of Uc) if (e.requires && t[e.name]) {
|
|
6462
6511
|
for (let n of e.requires) if (!t[n]) {
|
|
6463
6512
|
t[e.name] = !1;
|
|
6464
6513
|
break;
|
|
@@ -6468,7 +6517,7 @@ function Uc(e) {
|
|
|
6468
6517
|
}
|
|
6469
6518
|
//#endregion
|
|
6470
6519
|
//#region src/core/sdk/events.ts
|
|
6471
|
-
function
|
|
6520
|
+
function Gc(e) {
|
|
6472
6521
|
let t = /* @__PURE__ */ new Set(), n = (n) => {
|
|
6473
6522
|
if (n.type !== "approval_request") {
|
|
6474
6523
|
if (e) try {
|
|
@@ -6494,7 +6543,7 @@ function Wc(e) {
|
|
|
6494
6543
|
}
|
|
6495
6544
|
//#endregion
|
|
6496
6545
|
//#region src/core/sdk/contextPreset.ts
|
|
6497
|
-
var
|
|
6546
|
+
var Kc = {
|
|
6498
6547
|
auto: {
|
|
6499
6548
|
summaryThresholdRatio: .5,
|
|
6500
6549
|
windowRatio: .4,
|
|
@@ -6522,7 +6571,7 @@ var Gc = {
|
|
|
6522
6571
|
enableRecall: !0,
|
|
6523
6572
|
enableLLMSummary: !0
|
|
6524
6573
|
}
|
|
6525
|
-
},
|
|
6574
|
+
}, qc = {
|
|
6526
6575
|
auto: ["describe_data", "read"],
|
|
6527
6576
|
conservative: ["describe_data"],
|
|
6528
6577
|
aggressive: ["describe_data", "read"],
|
|
@@ -6533,8 +6582,8 @@ var Gc = {
|
|
|
6533
6582
|
"search_data"
|
|
6534
6583
|
]
|
|
6535
6584
|
};
|
|
6536
|
-
function
|
|
6537
|
-
let n =
|
|
6585
|
+
function Jc(e, t) {
|
|
6586
|
+
let n = Kc[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
6538
6587
|
return {
|
|
6539
6588
|
...n,
|
|
6540
6589
|
...r,
|
|
@@ -6544,7 +6593,7 @@ function qc(e, t) {
|
|
|
6544
6593
|
}
|
|
6545
6594
|
//#endregion
|
|
6546
6595
|
//#region src/core/sdk/middlewareStack.ts
|
|
6547
|
-
var
|
|
6596
|
+
var Yc = {
|
|
6548
6597
|
dataHint: 10,
|
|
6549
6598
|
usageHints: 20,
|
|
6550
6599
|
todos: 30,
|
|
@@ -6561,17 +6610,17 @@ var Jc = {
|
|
|
6561
6610
|
subagents: 140,
|
|
6562
6611
|
augmentSystem: 150
|
|
6563
6612
|
};
|
|
6564
|
-
function
|
|
6613
|
+
function Xc(e) {
|
|
6565
6614
|
return e.map((e, t) => ({
|
|
6566
6615
|
m: e,
|
|
6567
6616
|
i: t,
|
|
6568
|
-
p:
|
|
6617
|
+
p: Yc[e.name] ?? Infinity
|
|
6569
6618
|
})).sort((e, t) => e.p - t.p || e.i - t.i).map((e) => e.m);
|
|
6570
6619
|
}
|
|
6571
6620
|
//#endregion
|
|
6572
6621
|
//#region src/core/tools/dataSlotQuery.ts
|
|
6573
|
-
var
|
|
6574
|
-
function
|
|
6622
|
+
var Zc = /[\w$-]/;
|
|
6623
|
+
function Qc(e) {
|
|
6575
6624
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
6576
6625
|
for (; r < n.length;) {
|
|
6577
6626
|
let e = n[r];
|
|
@@ -6582,7 +6631,7 @@ function Zc(e) {
|
|
|
6582
6631
|
continue;
|
|
6583
6632
|
}
|
|
6584
6633
|
let e = "";
|
|
6585
|
-
for (; r < n.length &&
|
|
6634
|
+
for (; r < n.length && Zc.test(n[r]);) e += n[r++];
|
|
6586
6635
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
6587
6636
|
t.push({
|
|
6588
6637
|
type: "descendKey",
|
|
@@ -6595,7 +6644,7 @@ function Zc(e) {
|
|
|
6595
6644
|
continue;
|
|
6596
6645
|
}
|
|
6597
6646
|
let e = "";
|
|
6598
|
-
for (; r < n.length &&
|
|
6647
|
+
for (; r < n.length && Zc.test(n[r]);) e += n[r++];
|
|
6599
6648
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
6600
6649
|
t.push({
|
|
6601
6650
|
type: "key",
|
|
@@ -6651,7 +6700,7 @@ function Zc(e) {
|
|
|
6651
6700
|
}
|
|
6652
6701
|
return t;
|
|
6653
6702
|
}
|
|
6654
|
-
function
|
|
6703
|
+
function $c(e) {
|
|
6655
6704
|
let t = [], n = 0, r = e.trim();
|
|
6656
6705
|
for (; n < r.length;) {
|
|
6657
6706
|
let e = r[n];
|
|
@@ -6696,7 +6745,7 @@ function Qc(e) {
|
|
|
6696
6745
|
}
|
|
6697
6746
|
return t;
|
|
6698
6747
|
}
|
|
6699
|
-
var
|
|
6748
|
+
var el = class {
|
|
6700
6749
|
toks;
|
|
6701
6750
|
item;
|
|
6702
6751
|
pos = 0;
|
|
@@ -6732,12 +6781,12 @@ var $c = class {
|
|
|
6732
6781
|
return this.next(), e;
|
|
6733
6782
|
}
|
|
6734
6783
|
let e = this.operand(), t = this.peek();
|
|
6735
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
6784
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), rl(t, e, this.operand())) : tl(e);
|
|
6736
6785
|
}
|
|
6737
6786
|
operand() {
|
|
6738
6787
|
let e = this.next();
|
|
6739
6788
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
6740
|
-
if (e.startsWith("@")) return
|
|
6789
|
+
if (e.startsWith("@")) return nl(e, this.item);
|
|
6741
6790
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
6742
6791
|
if (e === "true") return !0;
|
|
6743
6792
|
if (e === "false") return !1;
|
|
@@ -6747,10 +6796,10 @@ var $c = class {
|
|
|
6747
6796
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
6748
6797
|
}
|
|
6749
6798
|
};
|
|
6750
|
-
function
|
|
6799
|
+
function tl(e) {
|
|
6751
6800
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
6752
6801
|
}
|
|
6753
|
-
function
|
|
6802
|
+
function nl(e, t) {
|
|
6754
6803
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
6755
6804
|
for (let e of n) {
|
|
6756
6805
|
if (typeof r != "object" || !r) return;
|
|
@@ -6758,7 +6807,7 @@ function tl(e, t) {
|
|
|
6758
6807
|
}
|
|
6759
6808
|
return r;
|
|
6760
6809
|
}
|
|
6761
|
-
function
|
|
6810
|
+
function rl(e, t, n) {
|
|
6762
6811
|
switch (e) {
|
|
6763
6812
|
case "==": return t === n;
|
|
6764
6813
|
case "!=": return t !== n;
|
|
@@ -6769,47 +6818,47 @@ function nl(e, t, n) {
|
|
|
6769
6818
|
default: return !1;
|
|
6770
6819
|
}
|
|
6771
6820
|
}
|
|
6772
|
-
function rl(e, t) {
|
|
6773
|
-
return new $c(Qc(e), t).parse();
|
|
6774
|
-
}
|
|
6775
6821
|
function il(e, t) {
|
|
6776
|
-
return
|
|
6822
|
+
return new el($c(e), t).parse();
|
|
6777
6823
|
}
|
|
6778
6824
|
function al(e, t) {
|
|
6825
|
+
return e ? `${e}.${t}` : String(t);
|
|
6826
|
+
}
|
|
6827
|
+
function ol(e, t) {
|
|
6779
6828
|
let n = [{
|
|
6780
6829
|
path: "",
|
|
6781
6830
|
value: e
|
|
6782
6831
|
}];
|
|
6783
|
-
for (let e of
|
|
6832
|
+
for (let e of Qc(t)) {
|
|
6784
6833
|
let t = [];
|
|
6785
6834
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
6786
|
-
path:
|
|
6835
|
+
path: al(r.path, e.key),
|
|
6787
6836
|
value: r.value[e.key]
|
|
6788
6837
|
});
|
|
6789
6838
|
else if (e.type === "index") {
|
|
6790
6839
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
6791
6840
|
let n = r.value[e.index];
|
|
6792
6841
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
6793
|
-
path:
|
|
6842
|
+
path: al(r.path, e.index),
|
|
6794
6843
|
value: n,
|
|
6795
6844
|
index: e.index
|
|
6796
6845
|
});
|
|
6797
6846
|
}
|
|
6798
6847
|
} else if (e.type === "wildcard") {
|
|
6799
6848
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
6800
|
-
path:
|
|
6849
|
+
path: al(e.path, r),
|
|
6801
6850
|
value: n,
|
|
6802
6851
|
index: r
|
|
6803
6852
|
}));
|
|
6804
6853
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
6805
|
-
path:
|
|
6854
|
+
path: al(e.path, n),
|
|
6806
6855
|
value: e.value[n]
|
|
6807
6856
|
});
|
|
6808
6857
|
} else if (e.type === "descendKey") {
|
|
6809
6858
|
let r = e.key, i = (e) => {
|
|
6810
6859
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
6811
6860
|
let a = {
|
|
6812
|
-
path:
|
|
6861
|
+
path: al(e.path, n),
|
|
6813
6862
|
value: e.value[n]
|
|
6814
6863
|
};
|
|
6815
6864
|
n === r && t.push(a), i(a);
|
|
@@ -6820,7 +6869,7 @@ function al(e, t) {
|
|
|
6820
6869
|
let e = (n) => {
|
|
6821
6870
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
6822
6871
|
let i = {
|
|
6823
|
-
path:
|
|
6872
|
+
path: al(n.path, r),
|
|
6824
6873
|
value: n.value[r]
|
|
6825
6874
|
};
|
|
6826
6875
|
t.push(i), e(i);
|
|
@@ -6829,16 +6878,16 @@ function al(e, t) {
|
|
|
6829
6878
|
for (let t of n) e(t);
|
|
6830
6879
|
} else if (e.type === "filter") {
|
|
6831
6880
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
6832
|
-
|
|
6833
|
-
path:
|
|
6881
|
+
il(e.filter, n) && t.push({
|
|
6882
|
+
path: al(r.path, i),
|
|
6834
6883
|
value: n,
|
|
6835
6884
|
index: i
|
|
6836
6885
|
});
|
|
6837
6886
|
});
|
|
6838
6887
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
6839
6888
|
let i = r.value[n];
|
|
6840
|
-
|
|
6841
|
-
path:
|
|
6889
|
+
il(e.filter, i) && t.push({
|
|
6890
|
+
path: al(r.path, n),
|
|
6842
6891
|
value: i
|
|
6843
6892
|
});
|
|
6844
6893
|
}
|
|
@@ -6847,7 +6896,7 @@ function al(e, t) {
|
|
|
6847
6896
|
}
|
|
6848
6897
|
return n;
|
|
6849
6898
|
}
|
|
6850
|
-
function
|
|
6899
|
+
function sl(e, t) {
|
|
6851
6900
|
let n = e.length, r = t.length;
|
|
6852
6901
|
if (!n) return r;
|
|
6853
6902
|
if (!r) return n;
|
|
@@ -6863,7 +6912,7 @@ function ol(e, t) {
|
|
|
6863
6912
|
}
|
|
6864
6913
|
return i[r];
|
|
6865
6914
|
}
|
|
6866
|
-
function
|
|
6915
|
+
function cl(e, t, n = {}) {
|
|
6867
6916
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
6868
6917
|
if (r === "regex") try {
|
|
6869
6918
|
s = new RegExp(t, "i");
|
|
@@ -6873,11 +6922,11 @@ function sl(e, t, n = {}) {
|
|
|
6873
6922
|
let c = (e, l, u) => {
|
|
6874
6923
|
if (o.length >= i || e == null) return;
|
|
6875
6924
|
if (typeof e == "object") {
|
|
6876
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
6877
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
6925
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, al(l, t), String(t)));
|
|
6926
|
+
else for (let t of Object.keys(e)) c(e[t], al(l, t), t);
|
|
6878
6927
|
return;
|
|
6879
6928
|
}
|
|
6880
|
-
let d = String(e), f =
|
|
6929
|
+
let d = String(e), f = ll(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
6881
6930
|
if (f) {
|
|
6882
6931
|
o.push({
|
|
6883
6932
|
path: l,
|
|
@@ -6888,7 +6937,7 @@ function sl(e, t, n = {}) {
|
|
|
6888
6937
|
return;
|
|
6889
6938
|
}
|
|
6890
6939
|
if (a && u) {
|
|
6891
|
-
let e =
|
|
6940
|
+
let e = ll(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
6892
6941
|
e && o.push({
|
|
6893
6942
|
path: l,
|
|
6894
6943
|
key: u,
|
|
@@ -6899,51 +6948,51 @@ function sl(e, t, n = {}) {
|
|
|
6899
6948
|
};
|
|
6900
6949
|
return c(e, ""), o;
|
|
6901
6950
|
}
|
|
6902
|
-
function
|
|
6951
|
+
function ll(e, t, n, r, i) {
|
|
6903
6952
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
6904
6953
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
6905
6954
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
6906
6955
|
if (n === "fuzzy") {
|
|
6907
6956
|
if (a.includes(o)) return 2;
|
|
6908
|
-
let e =
|
|
6957
|
+
let e = sl(a, o);
|
|
6909
6958
|
return e <= r ? r - e + 1 : null;
|
|
6910
6959
|
}
|
|
6911
6960
|
return null;
|
|
6912
6961
|
}
|
|
6913
|
-
function
|
|
6962
|
+
function ul(e, t, n = 3e3) {
|
|
6914
6963
|
return Ta(t, n)(e);
|
|
6915
6964
|
}
|
|
6916
6965
|
//#endregion
|
|
6917
6966
|
//#region src/core/tools/resources.ts
|
|
6918
|
-
var
|
|
6919
|
-
function pl(e) {
|
|
6920
|
-
return `${ul}${e}${fl}`;
|
|
6921
|
-
}
|
|
6967
|
+
var dl = "⟦frozen:", fl = "⟦res:", pl = "⟧";
|
|
6922
6968
|
function ml(e) {
|
|
6923
|
-
return `${dl}${e}${
|
|
6969
|
+
return `${dl}${e}${pl}`;
|
|
6924
6970
|
}
|
|
6925
6971
|
function hl(e) {
|
|
6926
|
-
return
|
|
6972
|
+
return `${fl}${e}${pl}`;
|
|
6973
|
+
}
|
|
6974
|
+
function gl(e) {
|
|
6975
|
+
return typeof e == "string" ? e.startsWith(dl) && e.endsWith(pl) ? {
|
|
6927
6976
|
type: "frozen",
|
|
6928
6977
|
path: e.slice(8, e.length - 1)
|
|
6929
|
-
} : e.startsWith(
|
|
6978
|
+
} : e.startsWith(fl) && e.endsWith(pl) ? {
|
|
6930
6979
|
type: "res",
|
|
6931
6980
|
handle: e.slice(5, e.length - 1)
|
|
6932
6981
|
} : null : null;
|
|
6933
6982
|
}
|
|
6934
|
-
function
|
|
6983
|
+
function _l(e) {
|
|
6935
6984
|
return String(e ?? "").trim().replace(/^\.+/, "");
|
|
6936
6985
|
}
|
|
6937
|
-
function
|
|
6986
|
+
function vl(e) {
|
|
6938
6987
|
let t = 5381;
|
|
6939
6988
|
for (let n = 0; n < e.length; n++) t = (t * 33 ^ e.charCodeAt(n)) >>> 0;
|
|
6940
6989
|
return (t >>> 0).toString(16).padStart(8, "0").slice(0, 8);
|
|
6941
6990
|
}
|
|
6942
|
-
function
|
|
6991
|
+
function yl(e, t) {
|
|
6943
6992
|
return e === t ? !0 : e && t && typeof e == "object" && typeof t == "object" ? JSON.stringify(e) === JSON.stringify(t) : !1;
|
|
6944
6993
|
}
|
|
6945
|
-
function
|
|
6946
|
-
let n =
|
|
6994
|
+
function bl(e, t) {
|
|
6995
|
+
let n = _l(e);
|
|
6947
6996
|
if (!n) return;
|
|
6948
6997
|
let r = t.get(n);
|
|
6949
6998
|
if (r) return {
|
|
@@ -6963,7 +7012,7 @@ function yl(e, t) {
|
|
|
6963
7012
|
}));
|
|
6964
7013
|
return i;
|
|
6965
7014
|
}
|
|
6966
|
-
var
|
|
7015
|
+
var xl = class {
|
|
6967
7016
|
vfs;
|
|
6968
7017
|
constructor(e) {
|
|
6969
7018
|
this.vfs = e;
|
|
@@ -6972,7 +7021,7 @@ var bl = class {
|
|
|
6972
7021
|
return `resources/${e}.json`;
|
|
6973
7022
|
}
|
|
6974
7023
|
ensure(e, t, n) {
|
|
6975
|
-
let r =
|
|
7024
|
+
let r = vl(e), i = {
|
|
6976
7025
|
path: e,
|
|
6977
7026
|
mode: n,
|
|
6978
7027
|
value: t,
|
|
@@ -6984,7 +7033,7 @@ var bl = class {
|
|
|
6984
7033
|
}, r;
|
|
6985
7034
|
}
|
|
6986
7035
|
get(e) {
|
|
6987
|
-
return this.readEntry(this.key(e)) || this.readEntry(this.key(
|
|
7036
|
+
return this.readEntry(this.key(e)) || this.readEntry(this.key(vl(e)));
|
|
6988
7037
|
}
|
|
6989
7038
|
readEntry(e) {
|
|
6990
7039
|
let t = this.vfs.files[e];
|
|
@@ -7000,7 +7049,7 @@ var bl = class {
|
|
|
7000
7049
|
this.ensure(e, t, n?.mode ?? "verbatim");
|
|
7001
7050
|
}
|
|
7002
7051
|
delete(e) {
|
|
7003
|
-
let t = this.get(e)?.handle ??
|
|
7052
|
+
let t = this.get(e)?.handle ?? vl(e), n = this.key(t), r = !!this.vfs.files[n];
|
|
7004
7053
|
return r && delete this.vfs.files[n], r;
|
|
7005
7054
|
}
|
|
7006
7055
|
list() {
|
|
@@ -7020,7 +7069,7 @@ var bl = class {
|
|
|
7020
7069
|
for (let e of Object.keys(this.vfs.files)) e.startsWith("resources/") && delete this.vfs.files[e];
|
|
7021
7070
|
}
|
|
7022
7071
|
};
|
|
7023
|
-
function
|
|
7072
|
+
function Sl(e) {
|
|
7024
7073
|
let { jp: t, resolved: n, resourcesByPath: r, resourceStore: i } = e;
|
|
7025
7074
|
if (!r.size) return n;
|
|
7026
7075
|
let a = !1;
|
|
@@ -7034,14 +7083,14 @@ function xl(e) {
|
|
|
7034
7083
|
if (t !== "" && e !== t && !e.startsWith(t + ".")) continue;
|
|
7035
7084
|
if (e === t) {
|
|
7036
7085
|
if (o === void 0) continue;
|
|
7037
|
-
return n.mode === "freeze" ?
|
|
7086
|
+
return n.mode === "freeze" ? ml(e) : i ? hl(i.ensure(e, o, "verbatim")) : o;
|
|
7038
7087
|
}
|
|
7039
7088
|
let r = t === "" ? e : e.slice(t.length + 1), a = Z(o, r);
|
|
7040
|
-
a !== void 0 && (n.mode === "freeze" ? ws(o, r,
|
|
7089
|
+
a !== void 0 && (n.mode === "freeze" ? ws(o, r, ml(e)) : i && ws(o, r, hl(i.ensure(e, a, "verbatim"))));
|
|
7041
7090
|
}
|
|
7042
7091
|
return o;
|
|
7043
7092
|
}
|
|
7044
|
-
function
|
|
7093
|
+
function Cl(e, t, n, r) {
|
|
7045
7094
|
if (!r) return {
|
|
7046
7095
|
code: "RESOURCE_NOT_FOUND",
|
|
7047
7096
|
message: `句柄 "${e}" 无法展开(资源池未启用)`,
|
|
@@ -7052,7 +7101,7 @@ function Sl(e, t, n, r) {
|
|
|
7052
7101
|
code: "RESOURCE_NOT_FOUND",
|
|
7053
7102
|
message: `字段 "${t}" 在 bind 中已不存在,无法展开句柄 "${e}"`,
|
|
7054
7103
|
hint: "该字段可能已被删除或 restore 到不含此字段的快照;重新 read 确认当前结构"
|
|
7055
|
-
} :
|
|
7104
|
+
} : yl(i.value, n) ? { value: i.value } : (r.update(t, n), { value: n }) : n === void 0 ? {
|
|
7056
7105
|
code: "RESOURCE_NOT_FOUND",
|
|
7057
7106
|
message: `句柄 "${e}" 不存在(字段 "${t}" 可能未注册或已被删除)`,
|
|
7058
7107
|
hint: "重新 read 该字段触发懒注册"
|
|
@@ -7062,7 +7111,7 @@ function Sl(e, t, n, r) {
|
|
|
7062
7111
|
hint: "重新 read 该字段触发懒注册重建句柄,再写回新句柄 ⟦res:<handle>⟧"
|
|
7063
7112
|
};
|
|
7064
7113
|
}
|
|
7065
|
-
function
|
|
7114
|
+
function wl(e, t) {
|
|
7066
7115
|
let n = t.getBind();
|
|
7067
7116
|
for (let [r, i] of t.resourcesByPath) {
|
|
7068
7117
|
let a = Z(n, r), o = Z(e, r);
|
|
@@ -7071,11 +7120,11 @@ function Cl(e, t) {
|
|
|
7071
7120
|
continue;
|
|
7072
7121
|
}
|
|
7073
7122
|
if (i.mode === "freeze") {
|
|
7074
|
-
if (o ===
|
|
7123
|
+
if (o === ml(r)) {
|
|
7075
7124
|
ws(e, r, a);
|
|
7076
7125
|
continue;
|
|
7077
7126
|
}
|
|
7078
|
-
if (!
|
|
7127
|
+
if (!yl(o, a)) return {
|
|
7079
7128
|
ok: !1,
|
|
7080
7129
|
code: "FROZEN_FIELD",
|
|
7081
7130
|
path: r,
|
|
@@ -7083,9 +7132,9 @@ function Cl(e, t) {
|
|
|
7083
7132
|
hint: "该字段由系统/集成方维护,LLM 不得改动。如需展示其值用 resource_get({path}) 取真值"
|
|
7084
7133
|
};
|
|
7085
7134
|
} else {
|
|
7086
|
-
let n =
|
|
7135
|
+
let n = gl(o);
|
|
7087
7136
|
if (n && n.type === "res") {
|
|
7088
|
-
let i =
|
|
7137
|
+
let i = Cl(n.handle, r, a, t.resourceStore);
|
|
7089
7138
|
if ("value" in i) {
|
|
7090
7139
|
ws(e, r, i.value);
|
|
7091
7140
|
continue;
|
|
@@ -7098,7 +7147,7 @@ function Cl(e, t) {
|
|
|
7098
7147
|
hint: i.hint
|
|
7099
7148
|
};
|
|
7100
7149
|
}
|
|
7101
|
-
if (!
|
|
7150
|
+
if (!yl(o, a)) return {
|
|
7102
7151
|
ok: !1,
|
|
7103
7152
|
code: "VERBATIM_MISMATCH",
|
|
7104
7153
|
path: r,
|
|
@@ -7109,7 +7158,7 @@ function Cl(e, t) {
|
|
|
7109
7158
|
}
|
|
7110
7159
|
return { ok: !0 };
|
|
7111
7160
|
}
|
|
7112
|
-
function
|
|
7161
|
+
function Tl(e, t, n) {
|
|
7113
7162
|
let r = t === void 0 ? e.message : `patches[${t}]${n ? ` @ "${n}"` : ""}: ${e.message}`;
|
|
7114
7163
|
return Y({
|
|
7115
7164
|
code: e.code,
|
|
@@ -7122,28 +7171,28 @@ function wl(e, t, n) {
|
|
|
7122
7171
|
} }
|
|
7123
7172
|
});
|
|
7124
7173
|
}
|
|
7125
|
-
function
|
|
7174
|
+
function El(e) {
|
|
7126
7175
|
let { value: t, ctx: n } = e;
|
|
7127
7176
|
if (!n || !n.resourcesByPath.size) return {
|
|
7128
7177
|
ok: !0,
|
|
7129
7178
|
value: t
|
|
7130
7179
|
};
|
|
7131
|
-
let r = Es(t), i =
|
|
7180
|
+
let r = Es(t), i = wl(r, n);
|
|
7132
7181
|
return i.ok ? {
|
|
7133
7182
|
ok: !0,
|
|
7134
7183
|
value: r
|
|
7135
7184
|
} : {
|
|
7136
7185
|
ok: !1,
|
|
7137
|
-
error:
|
|
7186
|
+
error: Tl(i)
|
|
7138
7187
|
};
|
|
7139
7188
|
}
|
|
7140
|
-
function
|
|
7189
|
+
function Dl(e) {
|
|
7141
7190
|
let { patches: t, clone: n, ctx: r } = e;
|
|
7142
7191
|
if (!r || !r.resourcesByPath.size) return { ok: !0 };
|
|
7143
7192
|
for (let e = 0; e < t.length; e++) {
|
|
7144
7193
|
let n = t[e];
|
|
7145
7194
|
if (n.op === "remove") {
|
|
7146
|
-
let t =
|
|
7195
|
+
let t = bl(n.jsonPath || "", r.resourcesByPath);
|
|
7147
7196
|
if (t) {
|
|
7148
7197
|
let r = t.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED", i = t.spec.mode === "freeze" ? "冻结字段不可删。如需移除请联系集成方调整 data.resources 配置" : "verbatim 字段不可直接删;先 resource_delete({path}) 释放资源保护后再删";
|
|
7149
7198
|
return {
|
|
@@ -7162,27 +7211,27 @@ function El(e) {
|
|
|
7162
7211
|
}
|
|
7163
7212
|
}
|
|
7164
7213
|
}
|
|
7165
|
-
let i =
|
|
7214
|
+
let i = wl(n, r);
|
|
7166
7215
|
if (!i.ok) {
|
|
7167
|
-
let e =
|
|
7216
|
+
let e = Ol(i.path, t);
|
|
7168
7217
|
return {
|
|
7169
7218
|
ok: !1,
|
|
7170
|
-
error:
|
|
7219
|
+
error: Tl(i, e >= 0 ? e : void 0, e >= 0 ? t[e].jsonPath : void 0)
|
|
7171
7220
|
};
|
|
7172
7221
|
}
|
|
7173
7222
|
return { ok: !0 };
|
|
7174
7223
|
}
|
|
7175
|
-
function
|
|
7176
|
-
let n =
|
|
7224
|
+
function Ol(e, t) {
|
|
7225
|
+
let n = _l(e);
|
|
7177
7226
|
for (let e = 0; e < t.length; e++) {
|
|
7178
|
-
let r =
|
|
7227
|
+
let r = _l(t[e].jsonPath || "");
|
|
7179
7228
|
if (r && (r === n || n.startsWith(r + ".") || r.startsWith(n + "."))) return e;
|
|
7180
7229
|
}
|
|
7181
7230
|
return -1;
|
|
7182
7231
|
}
|
|
7183
7232
|
//#endregion
|
|
7184
7233
|
//#region src/core/tools/dataOps.ts
|
|
7185
|
-
var
|
|
7234
|
+
var kl = /* @__PURE__ */ new Set([
|
|
7186
7235
|
"describe_data",
|
|
7187
7236
|
"get_data",
|
|
7188
7237
|
"set_data",
|
|
@@ -7196,14 +7245,14 @@ var Ol = /* @__PURE__ */ new Set([
|
|
|
7196
7245
|
"resource_update",
|
|
7197
7246
|
"resource_list",
|
|
7198
7247
|
"resource_delete"
|
|
7199
|
-
]),
|
|
7200
|
-
function
|
|
7201
|
-
return t === "advanced" ? e : t === "minimal" ? e.filter((e) =>
|
|
7248
|
+
]), Al = /* @__PURE__ */ new Set(["read", "write"]);
|
|
7249
|
+
function jl(e, t = "simple") {
|
|
7250
|
+
return t === "advanced" ? e : t === "minimal" ? e.filter((e) => Al.has(e.name)) : e.filter((e) => !kl.has(e.name));
|
|
7202
7251
|
}
|
|
7203
|
-
function
|
|
7252
|
+
function Ml(e) {
|
|
7204
7253
|
let { bindRef: t, schema: n, allowKeys: r, snapshots: i, maxSnapshots: a, audit: o, dryRun: s, op: c = "set", protectedCtx: l } = e, u = e.value;
|
|
7205
7254
|
if (l) {
|
|
7206
|
-
let e =
|
|
7255
|
+
let e = El({
|
|
7207
7256
|
value: u,
|
|
7208
7257
|
ctx: l
|
|
7209
7258
|
});
|
|
@@ -7248,7 +7297,7 @@ function jl(e) {
|
|
|
7248
7297
|
data: d.data
|
|
7249
7298
|
};
|
|
7250
7299
|
}
|
|
7251
|
-
function
|
|
7300
|
+
function Nl(e) {
|
|
7252
7301
|
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 = [];
|
|
7253
7302
|
for (let e = 0; e < n.length; e++) {
|
|
7254
7303
|
let t = n[e], a = t.jsonPath || "";
|
|
@@ -7301,7 +7350,7 @@ function Ml(e) {
|
|
|
7301
7350
|
});
|
|
7302
7351
|
}
|
|
7303
7352
|
if (d) {
|
|
7304
|
-
let e =
|
|
7353
|
+
let e = Dl({
|
|
7305
7354
|
patches: n,
|
|
7306
7355
|
clone: f,
|
|
7307
7356
|
ctx: d
|
|
@@ -7341,41 +7390,41 @@ function Ml(e) {
|
|
|
7341
7390
|
clone: f
|
|
7342
7391
|
};
|
|
7343
7392
|
}
|
|
7344
|
-
function
|
|
7393
|
+
function Pl(e) {
|
|
7345
7394
|
return e < 1024 ? `${e}B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)}KB` : `${(e / (1024 * 1024)).toFixed(1)}MB`;
|
|
7346
7395
|
}
|
|
7347
|
-
function
|
|
7396
|
+
function Fl(e, t, n, r) {
|
|
7348
7397
|
if (!t || !n.length || typeof e != "object" || !e) return e;
|
|
7349
7398
|
let i = new Set(n.map((e) => e.field)), a = Es(e);
|
|
7350
7399
|
return (function e(t) {
|
|
7351
7400
|
if (Array.isArray(t)) for (let n of t) e(n);
|
|
7352
7401
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) {
|
|
7353
7402
|
let a = t[n];
|
|
7354
|
-
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${
|
|
7403
|
+
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${Pl(a.length)}>` : e(a);
|
|
7355
7404
|
}
|
|
7356
7405
|
})(a), a;
|
|
7357
7406
|
}
|
|
7358
|
-
var
|
|
7359
|
-
function
|
|
7360
|
-
return
|
|
7407
|
+
var Il = 0;
|
|
7408
|
+
function Ll() {
|
|
7409
|
+
return Il++, "c_" + Math.random().toString(36).slice(2, 8) + Il.toString(36);
|
|
7361
7410
|
}
|
|
7362
|
-
function
|
|
7411
|
+
function Rl(e, t) {
|
|
7363
7412
|
if (!(!e || typeof e != "object")) for (let n of t) {
|
|
7364
7413
|
let t = Z(e, n);
|
|
7365
|
-
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId =
|
|
7414
|
+
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId = Ll());
|
|
7366
7415
|
}
|
|
7367
7416
|
}
|
|
7368
|
-
function
|
|
7417
|
+
function zl(e) {
|
|
7369
7418
|
(function e(t) {
|
|
7370
7419
|
if (Array.isArray(t)) t.forEach(e);
|
|
7371
7420
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) n.startsWith("__pg") ? delete t[n] : e(t[n]);
|
|
7372
7421
|
})(e);
|
|
7373
7422
|
}
|
|
7374
|
-
function
|
|
7375
|
-
let i = n.pgIdPaths ?? [], a = i.length ? (e) =>
|
|
7423
|
+
function Bl(e, n = {}) {
|
|
7424
|
+
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;
|
|
7376
7425
|
function f(e) {
|
|
7377
7426
|
if (u.clear(), e) for (let t of e) {
|
|
7378
|
-
let e =
|
|
7427
|
+
let e = _l(t.path);
|
|
7379
7428
|
u.set(e, {
|
|
7380
7429
|
path: e,
|
|
7381
7430
|
mode: t.mode
|
|
@@ -7447,7 +7496,7 @@ function zl(e, n = {}) {
|
|
|
7447
7496
|
return e;
|
|
7448
7497
|
},
|
|
7449
7498
|
createResource: d ? (e, t) => {
|
|
7450
|
-
let n =
|
|
7499
|
+
let n = _l(e), r = u.get(n), i = t === void 0 ? Z(s, n) : t;
|
|
7451
7500
|
return d.ensure(n, i, r?.mode ?? "verbatim");
|
|
7452
7501
|
} : void 0,
|
|
7453
7502
|
getResource: d ? (e) => {
|
|
@@ -7460,7 +7509,7 @@ function zl(e, n = {}) {
|
|
|
7460
7509
|
} : void 0;
|
|
7461
7510
|
} : void 0,
|
|
7462
7511
|
updateResource: d ? (e, t) => {
|
|
7463
|
-
let n =
|
|
7512
|
+
let n = _l(e);
|
|
7464
7513
|
d.update(n, t), ws(s, n, t), w();
|
|
7465
7514
|
} : void 0,
|
|
7466
7515
|
deleteResource: d ? (e) => d.delete(e) : void 0,
|
|
@@ -7521,7 +7570,7 @@ function zl(e, n = {}) {
|
|
|
7521
7570
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
7522
7571
|
});
|
|
7523
7572
|
let n = t ? Z(s, t) : s;
|
|
7524
|
-
!t && l && (n = Bi(n, o)), p && (n =
|
|
7573
|
+
!t && l && (n = Bi(n, o)), p && (n = Sl({
|
|
7525
7574
|
jp: t,
|
|
7526
7575
|
resolved: n,
|
|
7527
7576
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -7538,7 +7587,7 @@ function zl(e, n = {}) {
|
|
|
7538
7587
|
if (n !== null) return n;
|
|
7539
7588
|
let r = Ds(e);
|
|
7540
7589
|
if (r.parseError) return Kr("", e, r.parseError);
|
|
7541
|
-
let i =
|
|
7590
|
+
let i = Ml({
|
|
7542
7591
|
bindRef: s,
|
|
7543
7592
|
value: r.parsed,
|
|
7544
7593
|
schema: o,
|
|
@@ -7582,7 +7631,7 @@ function zl(e, n = {}) {
|
|
|
7582
7631
|
message: `edit 仅适用于对象/数组主数据,当前是 ${s === void 0 ? "undefined" : typeof s}`,
|
|
7583
7632
|
hint: "叶子(原始类型)请用 set_data 整体设置"
|
|
7584
7633
|
});
|
|
7585
|
-
let u =
|
|
7634
|
+
let u = Nl({
|
|
7586
7635
|
bindRef: s,
|
|
7587
7636
|
patches: [{
|
|
7588
7637
|
op: t,
|
|
@@ -7646,7 +7695,7 @@ function zl(e, n = {}) {
|
|
|
7646
7695
|
hint: "仅 schema 声明的 key 可删"
|
|
7647
7696
|
});
|
|
7648
7697
|
if (p) {
|
|
7649
|
-
let t =
|
|
7698
|
+
let t = bl(e, p.resourcesByPath);
|
|
7650
7699
|
if (t) return Y({
|
|
7651
7700
|
code: t.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED",
|
|
7652
7701
|
message: `delete_data @ "${e}" 命中受保护字段 "${t.protectedPath}"(${t.spec.mode}),不可删除`,
|
|
@@ -7749,7 +7798,7 @@ function zl(e, n = {}) {
|
|
|
7749
7798
|
});
|
|
7750
7799
|
let n = l ? Bi(s, o) : s, r;
|
|
7751
7800
|
try {
|
|
7752
|
-
r =
|
|
7801
|
+
r = ol(n, e);
|
|
7753
7802
|
} catch (t) {
|
|
7754
7803
|
return Y({
|
|
7755
7804
|
code: "JSONPATH_SYNTAX",
|
|
@@ -7773,7 +7822,7 @@ function zl(e, n = {}) {
|
|
|
7773
7822
|
message: "主数据为空,无可搜索内容"
|
|
7774
7823
|
});
|
|
7775
7824
|
try {
|
|
7776
|
-
let a =
|
|
7825
|
+
let a = cl(l ? Bi(s, o) : s, e, {
|
|
7777
7826
|
mode: t,
|
|
7778
7827
|
fuzzyThreshold: n,
|
|
7779
7828
|
matchKey: r,
|
|
@@ -7823,7 +7872,7 @@ function zl(e, n = {}) {
|
|
|
7823
7872
|
e && (i = Bi(i, e));
|
|
7824
7873
|
}
|
|
7825
7874
|
} else i = l ? Bi(s, o) : s;
|
|
7826
|
-
let a = Es(i), c = await
|
|
7875
|
+
let a = Es(i), c = await ul(a, e, r && JSON.stringify(a).length > 1e5 ? 8e3 : 3e3);
|
|
7827
7876
|
if (!c.ok) {
|
|
7828
7877
|
let t = /超时/.test(c.error || "");
|
|
7829
7878
|
return Y({
|
|
@@ -7839,7 +7888,7 @@ function zl(e, n = {}) {
|
|
|
7839
7888
|
if (t === "transform") {
|
|
7840
7889
|
let e = c.result;
|
|
7841
7890
|
if (r) {
|
|
7842
|
-
let t =
|
|
7891
|
+
let t = Nl({
|
|
7843
7892
|
bindRef: s,
|
|
7844
7893
|
patches: [{
|
|
7845
7894
|
op: "set",
|
|
@@ -7867,7 +7916,7 @@ function zl(e, n = {}) {
|
|
|
7867
7916
|
message: `主数据 bind 为原始类型(${s === null ? "null" : typeof s}),eval transform(patches) 无法就地替换`,
|
|
7868
7917
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
7869
7918
|
});
|
|
7870
|
-
let t =
|
|
7919
|
+
let t = Nl({
|
|
7871
7920
|
bindRef: s,
|
|
7872
7921
|
patches: e.patches,
|
|
7873
7922
|
schema: o,
|
|
@@ -7887,7 +7936,7 @@ function zl(e, n = {}) {
|
|
|
7887
7936
|
}
|
|
7888
7937
|
let t = e;
|
|
7889
7938
|
if (p) {
|
|
7890
|
-
let e =
|
|
7939
|
+
let e = El({
|
|
7891
7940
|
value: t,
|
|
7892
7941
|
ctx: p
|
|
7893
7942
|
});
|
|
@@ -7936,7 +7985,7 @@ function zl(e, n = {}) {
|
|
|
7936
7985
|
e && (a = Bi(a, e));
|
|
7937
7986
|
}
|
|
7938
7987
|
let c = a;
|
|
7939
|
-
if (p && (c =
|
|
7988
|
+
if (p && (c = Sl({
|
|
7940
7989
|
jp: t,
|
|
7941
7990
|
resolved: c,
|
|
7942
7991
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -7946,7 +7995,7 @@ function zl(e, n = {}) {
|
|
|
7946
7995
|
} catch (e) {
|
|
7947
7996
|
return `- ${t}: [READ_INTERCEPT: ${e.message}]`;
|
|
7948
7997
|
}
|
|
7949
|
-
return r && r.length && (c = Os(c, r)), i != null && (c = ks(c, i)), c =
|
|
7998
|
+
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)}`;
|
|
7950
7999
|
});
|
|
7951
8000
|
return `多路径读取(共 ${t.length} 项,hash=${d}):\n${e.join("\n")}`;
|
|
7952
8001
|
}
|
|
@@ -7968,7 +8017,7 @@ function zl(e, n = {}) {
|
|
|
7968
8017
|
e && (m = Bi(m, e));
|
|
7969
8018
|
}
|
|
7970
8019
|
let h = m;
|
|
7971
|
-
if (p && (h =
|
|
8020
|
+
if (p && (h = Sl({
|
|
7972
8021
|
jp: f,
|
|
7973
8022
|
resolved: h,
|
|
7974
8023
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -7981,7 +8030,7 @@ function zl(e, n = {}) {
|
|
|
7981
8030
|
message: `read 拦截器抛错: ${e.message}`
|
|
7982
8031
|
});
|
|
7983
8032
|
}
|
|
7984
|
-
r && r.length && (h = Os(h, r)), i != null && (h = ks(h, i)), h =
|
|
8033
|
+
r && r.length && (h = Os(h, r)), i != null && (h = ks(h, i)), h = Fl(h, _ === "", S, x);
|
|
7985
8034
|
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}` : "";
|
|
7986
8035
|
if ((a !== void 0 || u !== void 0) && Array.isArray(h)) {
|
|
7987
8036
|
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;
|
|
@@ -8054,7 +8103,7 @@ function zl(e, n = {}) {
|
|
|
8054
8103
|
hint: "仅 schema 声明的 key 可删"
|
|
8055
8104
|
});
|
|
8056
8105
|
if (p) {
|
|
8057
|
-
let e =
|
|
8106
|
+
let e = bl(t.jsonPath, p.resourcesByPath);
|
|
8058
8107
|
if (e) return Y({
|
|
8059
8108
|
code: e.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED",
|
|
8060
8109
|
message: `write delete @ "${t.jsonPath}" 命中受保护字段 "${e.protectedPath}"(${e.spec.mode}),不可删除`,
|
|
@@ -8087,7 +8136,7 @@ function zl(e, n = {}) {
|
|
|
8087
8136
|
op: t.op ?? "set",
|
|
8088
8137
|
jsonPath: t.jsonPath || "",
|
|
8089
8138
|
value: d
|
|
8090
|
-
}]), i =
|
|
8139
|
+
}]), i = Nl({
|
|
8091
8140
|
bindRef: s,
|
|
8092
8141
|
patches: n,
|
|
8093
8142
|
schema: o,
|
|
@@ -8104,13 +8153,13 @@ function zl(e, n = {}) {
|
|
|
8104
8153
|
detail: `${i.applied.length} 个 patch${i.applied.length > 1 ? "(批量)" : ""}`,
|
|
8105
8154
|
value: i.applied.map((e) => `${e.op}@${e.jp}`),
|
|
8106
8155
|
timestamp: Date.now()
|
|
8107
|
-
}), a && (a(s), w()), y($(s)),
|
|
8156
|
+
}), a && (a(s), w()), y($(s)), zl(i.clone), `已 write(edit) 主数据(${i.applied.length} 个 patch)。当前值:${Q(i.clone, 600)} (新 hash=${$(s)})`) : i.error;
|
|
8108
8157
|
}
|
|
8109
8158
|
let _ = Ds(d);
|
|
8110
8159
|
if (_.parseError) return Kr("", d, _.parseError);
|
|
8111
8160
|
let x = await O("set", g);
|
|
8112
8161
|
if (x !== null) return x;
|
|
8113
|
-
let S =
|
|
8162
|
+
let S = Ml({
|
|
8114
8163
|
bindRef: s,
|
|
8115
8164
|
value: _.parsed,
|
|
8116
8165
|
schema: o,
|
|
@@ -8126,7 +8175,7 @@ function zl(e, n = {}) {
|
|
|
8126
8175
|
if (c) return `dryRun(set): schema 校验通过。预览新值:${Q(S.data, 600)}。未实际写入、未入快照。`;
|
|
8127
8176
|
a && (a(s), w());
|
|
8128
8177
|
let C = $(s);
|
|
8129
|
-
return y(C),
|
|
8178
|
+
return y(C), zl(S.data), `已 write(set) 主数据 = ${Q(S.data, 600)} (新 hash=${C})${l ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`;
|
|
8130
8179
|
}, {
|
|
8131
8180
|
name: "write",
|
|
8132
8181
|
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)。",
|
|
@@ -8241,7 +8290,7 @@ function zl(e, n = {}) {
|
|
|
8241
8290
|
}
|
|
8242
8291
|
let u = await O("set", n || (b ? v() : void 0));
|
|
8243
8292
|
if (u !== null) return u;
|
|
8244
|
-
let d =
|
|
8293
|
+
let d = Ml({
|
|
8245
8294
|
bindRef: s,
|
|
8246
8295
|
value: c,
|
|
8247
8296
|
schema: o,
|
|
@@ -8273,7 +8322,7 @@ function zl(e, n = {}) {
|
|
|
8273
8322
|
message: "未提供 path 或有效 handle",
|
|
8274
8323
|
hint: "传 path(受保护字段)或 handle(占位符 ⟦res:handle⟧ 里的句柄)"
|
|
8275
8324
|
});
|
|
8276
|
-
let r =
|
|
8325
|
+
let r = _l(n);
|
|
8277
8326
|
if (!u.has(r)) return Y({
|
|
8278
8327
|
code: "RESOURCE_NOT_FOUND",
|
|
8279
8328
|
message: `"${n}" 不是受保护字段`,
|
|
@@ -8312,7 +8361,7 @@ function zl(e, n = {}) {
|
|
|
8312
8361
|
message: "resource_update 需要 path",
|
|
8313
8362
|
hint: "传要更新的 verbatim 受保护字段路径"
|
|
8314
8363
|
});
|
|
8315
|
-
let n =
|
|
8364
|
+
let n = _l(e), r = u.get(n);
|
|
8316
8365
|
if (!r) return Y({
|
|
8317
8366
|
code: "RESOURCE_NOT_FOUND",
|
|
8318
8367
|
message: `"${e}" 不是受保护字段`,
|
|
@@ -8400,8 +8449,8 @@ function zl(e, n = {}) {
|
|
|
8400
8449
|
}
|
|
8401
8450
|
//#endregion
|
|
8402
8451
|
//#region src/core/tools/fetchDoc.ts
|
|
8403
|
-
var
|
|
8404
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
8452
|
+
var Vl = 3e4, Hl = [r(async ({ url: e, as: t }) => {
|
|
8453
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), Vl);
|
|
8405
8454
|
try {
|
|
8406
8455
|
let r = await fetch(e, {
|
|
8407
8456
|
method: "GET",
|
|
@@ -8418,7 +8467,7 @@ var Bl = 3e4, Vl = [r(async ({ url: e, as: t }) => {
|
|
|
8418
8467
|
].join("\n");
|
|
8419
8468
|
} catch (t) {
|
|
8420
8469
|
let r = t?.message || String(t);
|
|
8421
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
8470
|
+
return n.signal.aborted ? `获取失败:请求超时(${Vl}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
8422
8471
|
} finally {
|
|
8423
8472
|
clearTimeout(r);
|
|
8424
8473
|
}
|
|
@@ -8429,7 +8478,7 @@ var Bl = 3e4, Vl = [r(async ({ url: e, as: t }) => {
|
|
|
8429
8478
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
8430
8479
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
8431
8480
|
})
|
|
8432
|
-
})],
|
|
8481
|
+
})], Ul = [
|
|
8433
8482
|
"id",
|
|
8434
8483
|
"class",
|
|
8435
8484
|
"href",
|
|
@@ -8441,12 +8490,12 @@ var Bl = 3e4, Vl = [r(async ({ url: e, as: t }) => {
|
|
|
8441
8490
|
"aria-label",
|
|
8442
8491
|
"name",
|
|
8443
8492
|
"type"
|
|
8444
|
-
],
|
|
8445
|
-
function
|
|
8493
|
+
], Wl = /^(value|srcdoc|formaction|on\w+)$/i, Gl = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session/i;
|
|
8494
|
+
function Kl(e, t) {
|
|
8446
8495
|
if (!e) return null;
|
|
8447
|
-
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ??
|
|
8496
|
+
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ?? Ul, s = (e) => {
|
|
8448
8497
|
let t = {};
|
|
8449
|
-
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (
|
|
8498
|
+
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));
|
|
8450
8499
|
return t;
|
|
8451
8500
|
}, c = (e, t) => {
|
|
8452
8501
|
let n = {
|
|
@@ -8462,10 +8511,10 @@ function Gl(e, t) {
|
|
|
8462
8511
|
};
|
|
8463
8512
|
return c(e, n);
|
|
8464
8513
|
}
|
|
8465
|
-
var
|
|
8514
|
+
var ql = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
8466
8515
|
let i = e ? document.querySelector(e) : document.body;
|
|
8467
8516
|
if (!i) return `未找到匹配元素:selector="${e}"`;
|
|
8468
|
-
let a =
|
|
8517
|
+
let a = Kl(i, {
|
|
8469
8518
|
depth: t ?? 3,
|
|
8470
8519
|
attrs: n,
|
|
8471
8520
|
includeText: r ?? !0
|
|
@@ -8480,14 +8529,14 @@ var Kl = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
8480
8529
|
attrs: t.array(t.string()).optional().describe("属性白名单(传了 = 严格白名单;不传 = 默认常用 + data-*)"),
|
|
8481
8530
|
includeText: t.boolean().optional().describe("是否包含直接文本(默认 true)")
|
|
8482
8531
|
})
|
|
8483
|
-
}),
|
|
8532
|
+
}), Jl = [ql];
|
|
8484
8533
|
//#endregion
|
|
8485
8534
|
//#region src/core/tools/envTool.ts
|
|
8486
|
-
function
|
|
8535
|
+
function Yl(e) {
|
|
8487
8536
|
let t = e;
|
|
8488
8537
|
return typeof t.tagName == "string" || typeof t.nodeType == "number" && typeof t.nodeName == "string";
|
|
8489
8538
|
}
|
|
8490
|
-
function
|
|
8539
|
+
function Xl(e, t = 3, n = 2e3, r) {
|
|
8491
8540
|
if (e == null) return e;
|
|
8492
8541
|
if (typeof e == "string") return e.length > n ? e.slice(0, n) + "…(已截断)" : e;
|
|
8493
8542
|
if (typeof e == "number" || typeof e == "boolean") return e;
|
|
@@ -8496,14 +8545,14 @@ function Yl(e, t = 3, n = 2e3, r) {
|
|
|
8496
8545
|
if (typeof e == "bigint") return `${e.toString()}n`;
|
|
8497
8546
|
if (typeof e != "object") return String(e);
|
|
8498
8547
|
let i = e;
|
|
8499
|
-
if (
|
|
8548
|
+
if (Yl(i)) {
|
|
8500
8549
|
let e = i;
|
|
8501
8550
|
return e.tagName ? `[Element: <${e.tagName.toLowerCase()}>]` : `[Node: ${e.nodeName}]`;
|
|
8502
8551
|
}
|
|
8503
8552
|
if (r?.has(i)) return "[Circular]";
|
|
8504
8553
|
let a = r ?? /* @__PURE__ */ new WeakSet();
|
|
8505
8554
|
if (a.add(i), Array.isArray(e)) {
|
|
8506
|
-
let r = e.slice(0, 100).map((e) =>
|
|
8555
|
+
let r = e.slice(0, 100).map((e) => Xl(e, t - 1, n, a));
|
|
8507
8556
|
return e.length > 100 && r.push(`…(共 ${e.length} 项,已截断)`), r;
|
|
8508
8557
|
}
|
|
8509
8558
|
if (t < 0) return "(对象,已截断)";
|
|
@@ -8515,14 +8564,14 @@ function Yl(e, t = 3, n = 2e3, r) {
|
|
|
8515
8564
|
break;
|
|
8516
8565
|
}
|
|
8517
8566
|
try {
|
|
8518
|
-
o[r] =
|
|
8567
|
+
o[r] = Xl(i[r], t - 1, n, a);
|
|
8519
8568
|
} catch {
|
|
8520
8569
|
o[r] = "(getter 抛错)";
|
|
8521
8570
|
}
|
|
8522
8571
|
}
|
|
8523
8572
|
return o;
|
|
8524
8573
|
}
|
|
8525
|
-
function
|
|
8574
|
+
function Zl(e) {
|
|
8526
8575
|
let t = e ?? (typeof window < "u" ? window : {}), n = t.navigator, r = t.location, i = t.document;
|
|
8527
8576
|
return {
|
|
8528
8577
|
location: {
|
|
@@ -8555,9 +8604,9 @@ function Xl(e) {
|
|
|
8555
8604
|
} : "(无 document)"
|
|
8556
8605
|
};
|
|
8557
8606
|
}
|
|
8558
|
-
var
|
|
8607
|
+
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 }) => {
|
|
8559
8608
|
if (e) {
|
|
8560
|
-
if (
|
|
8609
|
+
if (Ql.test(e) || $l.test(e)) return JSON.stringify({
|
|
8561
8610
|
key: e,
|
|
8562
8611
|
denied: !0,
|
|
8563
8612
|
reason: "安全:该 key 在 denylist(localStorage/sessionStorage/cookie/document 或敏感命名 token/secret/key/auth),不读取防泄漏"
|
|
@@ -8567,18 +8616,18 @@ var Zl = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|open
|
|
|
8567
8616
|
key: e,
|
|
8568
8617
|
exists: t !== void 0,
|
|
8569
8618
|
type: typeof t,
|
|
8570
|
-
value:
|
|
8619
|
+
value: Xl(t)
|
|
8571
8620
|
}, null, 2);
|
|
8572
8621
|
}
|
|
8573
|
-
return JSON.stringify(
|
|
8622
|
+
return JSON.stringify(Zl(), null, 2);
|
|
8574
8623
|
}, {
|
|
8575
8624
|
name: "inspect_env",
|
|
8576
8625
|
description: "读取宿主页面环境信息(排查调试用,默认开启)。不传参 = 返回环境摘要(location 的 URL/origin/path、navigator 的浏览器/语言、viewport 视口尺寸、document 的 title/readyState);传 key = 读取指定 window 属性值(如 inspect_env({key:\"appConfig\"}) 读集成方挂的调试变量 window.appConfig)。用于排查「当前页面在哪/什么浏览器/视口多大/调试变量值是什么」。轻量只读,大结果自动外存 vfs。",
|
|
8577
8626
|
schema: t.object({ key: t.string().optional().describe("要读取的 window 属性名(如 \"appConfig\"/\"__DEBUG__\");不传 = 返回环境摘要") })
|
|
8578
|
-
}),
|
|
8627
|
+
}), tu = [eu];
|
|
8579
8628
|
//#endregion
|
|
8580
8629
|
//#region src/core/harness/budget.ts
|
|
8581
|
-
function
|
|
8630
|
+
function nu(e, t, n) {
|
|
8582
8631
|
let r = 0;
|
|
8583
8632
|
return {
|
|
8584
8633
|
name: "budget",
|
|
@@ -8603,12 +8652,12 @@ function tu(e, t, n) {
|
|
|
8603
8652
|
}
|
|
8604
8653
|
//#endregion
|
|
8605
8654
|
//#region src/core/sdk/actions.ts
|
|
8606
|
-
var
|
|
8607
|
-
function
|
|
8655
|
+
var ru = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
8656
|
+
function iu(e) {
|
|
8608
8657
|
let n = [];
|
|
8609
8658
|
for (let [i, a] of Object.entries(e)) {
|
|
8610
|
-
if (!
|
|
8611
|
-
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${
|
|
8659
|
+
if (!ru.test(i)) {
|
|
8660
|
+
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${ru}),已跳过`);
|
|
8612
8661
|
continue;
|
|
8613
8662
|
}
|
|
8614
8663
|
let e = a.description || `宿主动作 ${i}`;
|
|
@@ -8628,9 +8677,9 @@ function ru(e) {
|
|
|
8628
8677
|
}
|
|
8629
8678
|
return n;
|
|
8630
8679
|
}
|
|
8631
|
-
function
|
|
8680
|
+
function au(e) {
|
|
8632
8681
|
let t = {};
|
|
8633
|
-
for (let [n, r] of Object.entries(e))
|
|
8682
|
+
for (let [n, r] of Object.entries(e)) ru.test(n) && (t[n] = {
|
|
8634
8683
|
description: r.description,
|
|
8635
8684
|
hasParams: !!r.params
|
|
8636
8685
|
});
|
|
@@ -8638,12 +8687,12 @@ function iu(e) {
|
|
|
8638
8687
|
}
|
|
8639
8688
|
//#endregion
|
|
8640
8689
|
//#region src/core/toolsets.ts
|
|
8641
|
-
var
|
|
8642
|
-
function
|
|
8643
|
-
return
|
|
8690
|
+
var ou = Hl, su = Jl;
|
|
8691
|
+
function cu(e, t) {
|
|
8692
|
+
return Bl(e, t);
|
|
8644
8693
|
}
|
|
8645
|
-
function
|
|
8646
|
-
let a =
|
|
8694
|
+
function lu(e, t, n, r, i) {
|
|
8695
|
+
let a = Wc(e);
|
|
8647
8696
|
return [
|
|
8648
8697
|
...a.dataOps ? t : [],
|
|
8649
8698
|
...a.fetch ? n : [],
|
|
@@ -8653,7 +8702,7 @@ function cu(e, t, n, r, i) {
|
|
|
8653
8702
|
}
|
|
8654
8703
|
//#endregion
|
|
8655
8704
|
//#region src/core/sdk/toolRegistry.ts
|
|
8656
|
-
function
|
|
8705
|
+
function uu(e) {
|
|
8657
8706
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
8658
8707
|
for (let r of e) for (let e of r.tools) {
|
|
8659
8708
|
let i = t.get(e.name);
|
|
@@ -8673,15 +8722,15 @@ function lu(e) {
|
|
|
8673
8722
|
}
|
|
8674
8723
|
//#endregion
|
|
8675
8724
|
//#region src/core/harness/usageHints.ts
|
|
8676
|
-
var
|
|
8677
|
-
function
|
|
8678
|
-
let i =
|
|
8725
|
+
var du = .7;
|
|
8726
|
+
function fu(e, t, n = "simple", r = !1) {
|
|
8727
|
+
let i = Wc(e), a = n !== "advanced";
|
|
8679
8728
|
return {
|
|
8680
8729
|
name: "usageHints",
|
|
8681
8730
|
augmentPrompt: () => {
|
|
8682
8731
|
let n = [];
|
|
8683
8732
|
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) {
|
|
8684
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
8733
|
+
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));
|
|
8685
8734
|
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(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
8686
8735
|
}
|
|
8687
8736
|
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;
|
|
@@ -8690,7 +8739,7 @@ function du(e, t, n = "simple", r = !1) {
|
|
|
8690
8739
|
}
|
|
8691
8740
|
//#endregion
|
|
8692
8741
|
//#region src/core/harness/resourcesPin.ts
|
|
8693
|
-
function
|
|
8742
|
+
function pu(e) {
|
|
8694
8743
|
return {
|
|
8695
8744
|
name: "resourcesPin",
|
|
8696
8745
|
augmentPrompt: () => {
|
|
@@ -8704,78 +8753,78 @@ function fu(e) {
|
|
|
8704
8753
|
}
|
|
8705
8754
|
//#endregion
|
|
8706
8755
|
//#region src/core/backends/skillStore.ts
|
|
8707
|
-
var
|
|
8708
|
-
function
|
|
8709
|
-
return `${
|
|
8756
|
+
var mu = "v:1::skill-store", hu = "chat-sdk";
|
|
8757
|
+
function gu(e, t, n) {
|
|
8758
|
+
return `${mu}::${e}::${t}::${n}`;
|
|
8710
8759
|
}
|
|
8711
|
-
function
|
|
8712
|
-
return `${
|
|
8760
|
+
function _u(e, t) {
|
|
8761
|
+
return `${mu}::${e}::${t}::`;
|
|
8713
8762
|
}
|
|
8714
|
-
function
|
|
8715
|
-
let t = e.dbName ??
|
|
8763
|
+
function vu(e = {}) {
|
|
8764
|
+
let t = e.dbName ?? hu, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
8716
8765
|
a = e;
|
|
8717
8766
|
});
|
|
8718
8767
|
return (async () => {
|
|
8719
8768
|
try {
|
|
8720
8769
|
if (n === "indexed") {
|
|
8721
8770
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
8722
|
-
i = await
|
|
8771
|
+
i = await Lc(t), a(!0);
|
|
8723
8772
|
} else if (n === "session") {
|
|
8724
8773
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
8725
|
-
i =
|
|
8774
|
+
i = Rc(sessionStorage), a(!0);
|
|
8726
8775
|
} else if (n === "local") {
|
|
8727
8776
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
8728
|
-
i =
|
|
8729
|
-
} else i =
|
|
8777
|
+
i = Rc(localStorage), a(!0);
|
|
8778
|
+
} else i = Ic(), a(!1);
|
|
8730
8779
|
} catch {
|
|
8731
|
-
i =
|
|
8780
|
+
i = Ic(), a(!1);
|
|
8732
8781
|
}
|
|
8733
8782
|
})(), {
|
|
8734
8783
|
ready: o,
|
|
8735
8784
|
async list() {
|
|
8736
8785
|
let e = [];
|
|
8737
|
-
return await i.scan(
|
|
8786
|
+
return await i.scan(_u(t, r), (t, n) => {
|
|
8738
8787
|
e.push(n);
|
|
8739
8788
|
}), e;
|
|
8740
8789
|
},
|
|
8741
8790
|
async get(e) {
|
|
8742
|
-
return await i.get(
|
|
8791
|
+
return await i.get(gu(t, r, e));
|
|
8743
8792
|
},
|
|
8744
8793
|
async put(e) {
|
|
8745
8794
|
try {
|
|
8746
|
-
await i.set(
|
|
8795
|
+
await i.set(gu(t, r, e.name), e);
|
|
8747
8796
|
} catch (e) {
|
|
8748
|
-
|
|
8797
|
+
Oc(e) && (i = Ic());
|
|
8749
8798
|
}
|
|
8750
8799
|
},
|
|
8751
8800
|
async remove(e) {
|
|
8752
|
-
let n =
|
|
8801
|
+
let n = gu(t, r, e);
|
|
8753
8802
|
return await i.get(n) == null ? !1 : (await i.del(n), !0);
|
|
8754
8803
|
},
|
|
8755
8804
|
async clear() {
|
|
8756
|
-
await i.clearPrefix(
|
|
8805
|
+
await i.clearPrefix(_u(t, r));
|
|
8757
8806
|
},
|
|
8758
8807
|
dispose() {}
|
|
8759
8808
|
};
|
|
8760
8809
|
}
|
|
8761
|
-
var
|
|
8762
|
-
function
|
|
8810
|
+
var yu = /large_results\/[^\s"'`),]+\.txt/g;
|
|
8811
|
+
function bu(e) {
|
|
8763
8812
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
8764
8813
|
if (typeof e != "string" || !e) return;
|
|
8765
8814
|
let n;
|
|
8766
|
-
for (
|
|
8815
|
+
for (yu.lastIndex = 0; (n = yu.exec(e)) !== null;) t.add(n[0]);
|
|
8767
8816
|
};
|
|
8768
8817
|
for (let t of e) if (n(t.content), t.steps) for (let e of t.steps) n(e.result);
|
|
8769
8818
|
return t;
|
|
8770
8819
|
}
|
|
8771
|
-
function
|
|
8820
|
+
function xu(e, t) {
|
|
8772
8821
|
let n = [];
|
|
8773
8822
|
for (let r of Object.keys(e)) r.startsWith("large_results/") && !t.has(r) && n.push(r);
|
|
8774
8823
|
return n;
|
|
8775
8824
|
}
|
|
8776
8825
|
//#endregion
|
|
8777
8826
|
//#region src/core/utils/serialRunner.ts
|
|
8778
|
-
function
|
|
8827
|
+
function Su() {
|
|
8779
8828
|
let e = Promise.resolve();
|
|
8780
8829
|
return function(t) {
|
|
8781
8830
|
let n = e.then(t, t);
|
|
@@ -8784,16 +8833,16 @@ function xu() {
|
|
|
8784
8833
|
}
|
|
8785
8834
|
//#endregion
|
|
8786
8835
|
//#region src/core/sdk/createChatSdk.ts
|
|
8787
|
-
var
|
|
8788
|
-
function
|
|
8836
|
+
var Cu = 30, wu = /* @__PURE__ */ new Map();
|
|
8837
|
+
function Tu(e, t) {
|
|
8789
8838
|
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;
|
|
8790
8839
|
}
|
|
8791
|
-
function
|
|
8840
|
+
function Eu(e, t, n, r) {
|
|
8792
8841
|
let i = 0;
|
|
8793
8842
|
return {
|
|
8794
8843
|
name: "sdk-events",
|
|
8795
8844
|
wrapToolCall: async (t, r) => {
|
|
8796
|
-
let i = await r(t), a =
|
|
8845
|
+
let i = await r(t), a = Tu(t.name, t.args);
|
|
8797
8846
|
return a && e({
|
|
8798
8847
|
type: "data_change",
|
|
8799
8848
|
operation: a,
|
|
@@ -8821,7 +8870,7 @@ function Tu(e, t, n, r) {
|
|
|
8821
8870
|
}
|
|
8822
8871
|
};
|
|
8823
8872
|
}
|
|
8824
|
-
function
|
|
8873
|
+
function Du(e, t, n, r, i) {
|
|
8825
8874
|
if (!n) return i && console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`), {
|
|
8826
8875
|
ok: !1,
|
|
8827
8876
|
error: "capabilities.focus 关闭"
|
|
@@ -8839,16 +8888,16 @@ function Eu(e, t, n, r, i) {
|
|
|
8839
8888
|
error: "当前无主数据 schema,无法聚焦"
|
|
8840
8889
|
});
|
|
8841
8890
|
}
|
|
8842
|
-
function
|
|
8891
|
+
function Ou(e, n) {
|
|
8843
8892
|
let i = {
|
|
8844
8893
|
prompt_tokens: 0,
|
|
8845
8894
|
completion_tokens: 0,
|
|
8846
8895
|
total_tokens: 0
|
|
8847
|
-
}, a =
|
|
8896
|
+
}, a = hc(() => W), o = /* @__PURE__ */ Ot(0), s = Vc(e.storage);
|
|
8848
8897
|
e.debug && s && s.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
8849
|
-
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: p } =
|
|
8898
|
+
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: p } = mc(e), m = c;
|
|
8850
8899
|
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)`);
|
|
8851
|
-
let h =
|
|
8900
|
+
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;
|
|
8852
8901
|
e.debug && !l && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
8853
8902
|
let b = /* @__PURE__ */ _t([]), x = zs(e.vfs?.initialFiles, {
|
|
8854
8903
|
persist: s ? { save: (e) => {
|
|
@@ -8870,7 +8919,7 @@ function Du(e, n) {
|
|
|
8870
8919
|
getTodos: () => D.current?.getState?.()?.todos ?? [],
|
|
8871
8920
|
messages: b,
|
|
8872
8921
|
maxCheckpoints: ne && typeof ne == "object" ? ne.maxCheckpoints : void 0
|
|
8873
|
-
}) : null, ie = !ne || typeof ne != "object" || ne.auto !== !1, M =
|
|
8922
|
+
}) : 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, {
|
|
8874
8923
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
8875
8924
|
maxSnapshots: e.maxSnapshots,
|
|
8876
8925
|
onConflict: a.set,
|
|
@@ -8879,11 +8928,11 @@ function Du(e, n) {
|
|
|
8879
8928
|
vfsStore: ae || O?.resources?.length ? x : void 0,
|
|
8880
8929
|
...te.length ? { pgIdPaths: te } : {},
|
|
8881
8930
|
...A.length ? { largeTextPaths: A } : {}
|
|
8882
|
-
}) : [], le = N ?
|
|
8931
|
+
}) : [], 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);
|
|
8883
8932
|
R.forEach((e) => L.set(e.name, "builtin"));
|
|
8884
8933
|
let z = [...e.tools || []];
|
|
8885
8934
|
z.forEach((e) => L.set(e.name, "user"));
|
|
8886
|
-
let de =
|
|
8935
|
+
let de = iu(e.actions ?? {});
|
|
8887
8936
|
de.forEach((e) => L.set(e.name, "action"));
|
|
8888
8937
|
let fe = [], B = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), pe = B ? Za() : null;
|
|
8889
8938
|
pe && L.set(Ya, "builtin");
|
|
@@ -8955,7 +9004,7 @@ function Du(e, n) {
|
|
|
8955
9004
|
ye.forEach((e) => L.set(e.name, "builtin"));
|
|
8956
9005
|
let be = [], xe = /* @__PURE__ */ new Map(), H = Se();
|
|
8957
9006
|
function Se() {
|
|
8958
|
-
let { tools: e, collisions: t } =
|
|
9007
|
+
let { tools: e, collisions: t } = uu([
|
|
8959
9008
|
{
|
|
8960
9009
|
label: "builtin",
|
|
8961
9010
|
tools: R
|
|
@@ -9022,7 +9071,7 @@ function Du(e, n) {
|
|
|
9022
9071
|
timeoutMs: Ie?.timeoutMs
|
|
9023
9072
|
}), Ve = e.subagents?.map((e) => {
|
|
9024
9073
|
if (!e._codeAsset) return e;
|
|
9025
|
-
let t = e._codeAsset, n =
|
|
9074
|
+
let t = e._codeAsset, n = $s({
|
|
9026
9075
|
writablePaths: t.writablePaths,
|
|
9027
9076
|
codeVfsPrefix: t.codeVfsPrefix,
|
|
9028
9077
|
ext: t.ext,
|
|
@@ -9064,8 +9113,8 @@ function Du(e, n) {
|
|
|
9064
9113
|
} : void 0
|
|
9065
9114
|
}) : void 0, qe = Fe ? ps({
|
|
9066
9115
|
contextWindow: m.contextWindow,
|
|
9067
|
-
thresholdRatio:
|
|
9068
|
-
}) : void 0, Je =
|
|
9116
|
+
thresholdRatio: Jc(e, m.contextWindow).summaryThresholdRatio
|
|
9117
|
+
}) : void 0, Je = fu({
|
|
9069
9118
|
...M,
|
|
9070
9119
|
humanConfirm: B,
|
|
9071
9120
|
subagents: e.subagents?.map((e) => ({
|
|
@@ -9089,7 +9138,7 @@ function Du(e, n) {
|
|
|
9089
9138
|
return;
|
|
9090
9139
|
}
|
|
9091
9140
|
}
|
|
9092
|
-
} : null, Ze =
|
|
9141
|
+
} : null, Ze = Gc(e.onEvent), W = Ze.emit, Qe, $e = [], et = (e) => ({
|
|
9093
9142
|
name: e.name,
|
|
9094
9143
|
description: e.description,
|
|
9095
9144
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
@@ -9097,7 +9146,7 @@ function Du(e, n) {
|
|
|
9097
9146
|
name: e.name,
|
|
9098
9147
|
description: e.description,
|
|
9099
9148
|
getContent: () => e.content
|
|
9100
|
-
}), nt = e.skillStorage === !1 ? null :
|
|
9149
|
+
}), nt = e.skillStorage === !1 ? null : vu({
|
|
9101
9150
|
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
9102
9151
|
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
|
|
9103
9152
|
}), rt = () => {
|
|
@@ -9129,7 +9178,7 @@ function Du(e, n) {
|
|
|
9129
9178
|
decideInvoke: p,
|
|
9130
9179
|
getSnapshot: () => qe?.getSnapshot()
|
|
9131
9180
|
} : {}
|
|
9132
|
-
}) : void 0, ot =
|
|
9181
|
+
}) : void 0, ot = Xc([
|
|
9133
9182
|
...Ye ? [Ye] : [],
|
|
9134
9183
|
Je,
|
|
9135
9184
|
...we ? [C] : [],
|
|
@@ -9161,12 +9210,12 @@ function Du(e, n) {
|
|
|
9161
9210
|
...Xe ? [Xe] : [],
|
|
9162
9211
|
...qe ? [qe] : [],
|
|
9163
9212
|
...e.middleware || [],
|
|
9164
|
-
...oe ? [
|
|
9213
|
+
...oe ? [nu(i, {
|
|
9165
9214
|
tokenBudget: e.tokenBudget,
|
|
9166
9215
|
timeBudgetMs: e.timeBudgetMs
|
|
9167
9216
|
}, W)] : [],
|
|
9168
|
-
|
|
9169
|
-
]), st = e.maxMemoryRounds ??
|
|
9217
|
+
Eu(W, b, I, i)
|
|
9218
|
+
]), st = e.maxMemoryRounds ?? Cu, ct = e.approval?.timeoutMs, lt = ct === void 0 || ct === 0 ? 3e4 : !Number.isFinite(ct) || ct < 0 ? 0 : ct;
|
|
9170
9219
|
function ut(e) {
|
|
9171
9220
|
if (lt) return (t) => {
|
|
9172
9221
|
if (t.type !== "approval_request") return;
|
|
@@ -9189,7 +9238,7 @@ function Du(e, n) {
|
|
|
9189
9238
|
async function ft() {
|
|
9190
9239
|
s && (dt.value = (await s.listSessions(n)).sort((e, t) => t.lastAccessed - e.lastAccessed));
|
|
9191
9240
|
}
|
|
9192
|
-
let pt =
|
|
9241
|
+
let pt = Su(), mt = /* @__PURE__ */ new Set();
|
|
9193
9242
|
function ht(e) {
|
|
9194
9243
|
let t = new AbortController();
|
|
9195
9244
|
return e && (e.aborted ? t.abort() : e.addEventListener("abort", () => t.abort(), { once: !0 })), mt.add(t), {
|
|
@@ -9432,7 +9481,7 @@ function Du(e, n) {
|
|
|
9432
9481
|
})), e.memory && s.save(n, G.sessionId, { memory: E.get() || (typeof e.memory == "string" ? e.memory : "") }), ft(), K = void 0, Ct = !1, r;
|
|
9433
9482
|
},
|
|
9434
9483
|
resetSession: () => {
|
|
9435
|
-
gt(), a.resolve("keep_external"), G.sessionId =
|
|
9484
|
+
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({
|
|
9436
9485
|
type: "session_restored",
|
|
9437
9486
|
sessionId: G.sessionId,
|
|
9438
9487
|
rounds: 0
|
|
@@ -9440,9 +9489,9 @@ function Du(e, n) {
|
|
|
9440
9489
|
},
|
|
9441
9490
|
stream: (e, t, n) => {
|
|
9442
9491
|
if (!G.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
9443
|
-
x?.setProtectedRefs?.(
|
|
9492
|
+
x?.setProtectedRefs?.(bu(e));
|
|
9444
9493
|
let r = (e) => {
|
|
9445
|
-
t?.(e), W(e)
|
|
9494
|
+
t?.(e), W(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && G.infoTick.value++;
|
|
9446
9495
|
};
|
|
9447
9496
|
if (n) {
|
|
9448
9497
|
let e = () => a.resolve("keep_external");
|
|
@@ -9455,7 +9504,7 @@ function Du(e, n) {
|
|
|
9455
9504
|
if (G.refCount--, G.refCount <= 0) {
|
|
9456
9505
|
gt(), s && (x.flush?.(), s.flush(), s.dispose()), nt && nt.dispose();
|
|
9457
9506
|
let e = G.mcpClosers.splice(0);
|
|
9458
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
9507
|
+
e.length && Promise.allSettled(e.map((e) => e())), wu.delete(n);
|
|
9459
9508
|
}
|
|
9460
9509
|
},
|
|
9461
9510
|
resolveConflict: a.resolve,
|
|
@@ -9475,14 +9524,14 @@ function Du(e, n) {
|
|
|
9475
9524
|
},
|
|
9476
9525
|
setLlm(t) {
|
|
9477
9526
|
let n;
|
|
9478
|
-
if (
|
|
9527
|
+
if (ac(t)) n = t;
|
|
9479
9528
|
else {
|
|
9480
9529
|
let e = t;
|
|
9481
9530
|
if ((e.provider ?? "openai") === "anthropic") throw Error("[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import(\"@langchain/anthropic\") 构造实例后传入");
|
|
9482
9531
|
n = d(e);
|
|
9483
9532
|
}
|
|
9484
9533
|
typeof n.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"), y = t;
|
|
9485
|
-
let r =
|
|
9534
|
+
let r = ac(t) ? void 0 : t;
|
|
9486
9535
|
if (m = ri({
|
|
9487
9536
|
model: r?.model ?? t.model ?? t.modelName,
|
|
9488
9537
|
contextWindow: e.contextWindow ?? r?.contextWindow,
|
|
@@ -9525,7 +9574,7 @@ function Du(e, n) {
|
|
|
9525
9574
|
return {
|
|
9526
9575
|
id: n,
|
|
9527
9576
|
sessionId: G.sessionId,
|
|
9528
|
-
model:
|
|
9577
|
+
model: ac(y) ? y.model ?? y.modelName : y.model,
|
|
9529
9578
|
systemPrompt: G.agent?.getEffectiveSystemPrompt?.() ?? se + ys(I(), e.schemaHint),
|
|
9530
9579
|
tools: (G.agent?.allTools ?? H).map((e) => ({
|
|
9531
9580
|
name: e.name,
|
|
@@ -9562,7 +9611,7 @@ function Du(e, n) {
|
|
|
9562
9611
|
spans: G.agent.spans.value,
|
|
9563
9612
|
metrics: oi(G.agent.spans.value)
|
|
9564
9613
|
} : void 0,
|
|
9565
|
-
actions:
|
|
9614
|
+
actions: au(e.actions ?? {}),
|
|
9566
9615
|
subagent: {
|
|
9567
9616
|
enabled: !!Be,
|
|
9568
9617
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
@@ -9611,11 +9660,11 @@ function Du(e, n) {
|
|
|
9611
9660
|
return V ? w.getFocuses() : [];
|
|
9612
9661
|
},
|
|
9613
9662
|
setFocus(t) {
|
|
9614
|
-
let n =
|
|
9663
|
+
let n = Du(t, "setFocus", V, () => I()?.schema, e.debug);
|
|
9615
9664
|
return n.ok ? (w.setFocus(t), G.infoTick.value++, { ok: !0 }) : n;
|
|
9616
9665
|
},
|
|
9617
9666
|
addFocus(t) {
|
|
9618
|
-
let n =
|
|
9667
|
+
let n = Du(t, "addFocus", V, () => I()?.schema, e.debug);
|
|
9619
9668
|
return n.ok ? w.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
9620
9669
|
ok: !1,
|
|
9621
9670
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
@@ -9659,14 +9708,14 @@ function Du(e, n) {
|
|
|
9659
9708
|
}
|
|
9660
9709
|
function bt(e) {
|
|
9661
9710
|
let t = {};
|
|
9662
|
-
for (let n of
|
|
9711
|
+
for (let n of bu(e)) {
|
|
9663
9712
|
let e = x.files[n];
|
|
9664
9713
|
e && (t[n] = e.content);
|
|
9665
9714
|
}
|
|
9666
9715
|
return t;
|
|
9667
9716
|
}
|
|
9668
9717
|
function xt() {
|
|
9669
|
-
let e =
|
|
9718
|
+
let e = xu(x.files, bu(b));
|
|
9670
9719
|
for (let t of e) delete x.files[t];
|
|
9671
9720
|
}
|
|
9672
9721
|
function St() {
|
|
@@ -9714,7 +9763,7 @@ function Du(e, n) {
|
|
|
9714
9763
|
s.save(n, G.sessionId, { focus: e.length ? e : null });
|
|
9715
9764
|
}
|
|
9716
9765
|
oe && j && (s.save(n, G.sessionId, { checkpoints: j.exportStack() }), s.save(n, G.sessionId, { usage: i }));
|
|
9717
|
-
let a =
|
|
9766
|
+
let a = ic(b);
|
|
9718
9767
|
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 () => {
|
|
9719
9768
|
let e = await u(b);
|
|
9720
9769
|
e && (await s.updateTitle(n, G.sessionId, e), await ft());
|
|
@@ -9732,7 +9781,7 @@ function Du(e, n) {
|
|
|
9732
9781
|
}), 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);
|
|
9733
9782
|
}), H = Se(), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${fe.length} 个工具,${G.mcpServers.length} 个 server`);
|
|
9734
9783
|
}
|
|
9735
|
-
let t =
|
|
9784
|
+
let t = ac(e.llm) ? e.llm : await f(e.llm);
|
|
9736
9785
|
G.agent = Fi({
|
|
9737
9786
|
llm: t,
|
|
9738
9787
|
systemPrompt: se,
|
|
@@ -9763,12 +9812,12 @@ function Du(e, n) {
|
|
|
9763
9812
|
});
|
|
9764
9813
|
})(), G;
|
|
9765
9814
|
}
|
|
9766
|
-
function
|
|
9767
|
-
let n = e.id ??
|
|
9815
|
+
function ku(e, t) {
|
|
9816
|
+
let n = e.id ?? gc();
|
|
9768
9817
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
9769
|
-
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ?
|
|
9770
|
-
o ? a = o : (a =
|
|
9771
|
-
let s = null, c =
|
|
9818
|
+
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ? wu.get(n) : void 0;
|
|
9819
|
+
o ? a = o : (a = Ou(e, n), e.shareContext && wu.set(n, a)), a.refCount++;
|
|
9820
|
+
let s = null, c = Hc(e), l = null, u = null;
|
|
9772
9821
|
async function d(n) {
|
|
9773
9822
|
if (await a.initDone, s) {
|
|
9774
9823
|
s.show();
|
|
@@ -9984,12 +10033,12 @@ function Ou(e, t) {
|
|
|
9984
10033
|
}
|
|
9985
10034
|
//#endregion
|
|
9986
10035
|
//#region src/core/sdk/ragSubagent.ts
|
|
9987
|
-
var
|
|
10036
|
+
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 = {
|
|
9988
10037
|
name: "rag-search",
|
|
9989
10038
|
description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
|
|
9990
|
-
getContent: () =>
|
|
10039
|
+
getContent: () => ju
|
|
9991
10040
|
};
|
|
9992
|
-
function
|
|
10041
|
+
function Nu(e, n, i) {
|
|
9993
10042
|
return r(async ({ query: e, topK: t }) => {
|
|
9994
10043
|
try {
|
|
9995
10044
|
let r = await n(e, { topK: t ?? i });
|
|
@@ -10006,7 +10055,7 @@ function Mu(e, n, i) {
|
|
|
10006
10055
|
})
|
|
10007
10056
|
});
|
|
10008
10057
|
}
|
|
10009
|
-
function
|
|
10058
|
+
function Pu(e, n) {
|
|
10010
10059
|
return r(async ({ source: e }) => {
|
|
10011
10060
|
try {
|
|
10012
10061
|
let t = await n(e), r = Array.isArray(t) ? t : [t];
|
|
@@ -10020,11 +10069,11 @@ function Nu(e, n) {
|
|
|
10020
10069
|
schema: t.object({ source: t.string().describe("文档标识(id/URL/key)") })
|
|
10021
10070
|
});
|
|
10022
10071
|
}
|
|
10023
|
-
function
|
|
10072
|
+
function Fu(e) {
|
|
10024
10073
|
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;
|
|
10025
10074
|
if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
|
|
10026
10075
|
let p = [];
|
|
10027
|
-
t && p.push(
|
|
10076
|
+
t && p.push(Nu(s, t, o)), n && p.push(Pu(c, n)), f && p.push(...f);
|
|
10028
10077
|
let m = r ? [
|
|
10029
10078
|
"vfs_grep",
|
|
10030
10079
|
"vfs_read",
|
|
@@ -10033,17 +10082,17 @@ function Pu(e) {
|
|
|
10033
10082
|
return {
|
|
10034
10083
|
id: i,
|
|
10035
10084
|
description: a ?? "检索知识库(组件文档/UI 规范/业务规则),返回有依据的结构化结论。需要查阅文档才能回答或决定如何配置时委派",
|
|
10036
|
-
systemPrompt:
|
|
10085
|
+
systemPrompt: Au,
|
|
10037
10086
|
tools: p.length ? p : void 0,
|
|
10038
10087
|
allowedTools: m,
|
|
10039
|
-
skills: d ?? [
|
|
10088
|
+
skills: d ?? [Mu],
|
|
10040
10089
|
maxToolRounds: l,
|
|
10041
10090
|
...u === void 0 ? {} : { summarization: u }
|
|
10042
10091
|
};
|
|
10043
10092
|
}
|
|
10044
10093
|
//#endregion
|
|
10045
10094
|
//#region src/core/tools/htmlValidate.ts
|
|
10046
|
-
var
|
|
10095
|
+
var Iu = /* @__PURE__ */ new Set([
|
|
10047
10096
|
"area",
|
|
10048
10097
|
"base",
|
|
10049
10098
|
"br",
|
|
@@ -10058,12 +10107,12 @@ var Fu = /* @__PURE__ */ new Set([
|
|
|
10058
10107
|
"source",
|
|
10059
10108
|
"track",
|
|
10060
10109
|
"wbr"
|
|
10061
|
-
]),
|
|
10110
|
+
]), Lu = /* @__PURE__ */ new Set(["script", "style"]), Ru = /* @__PURE__ */ new Set([
|
|
10062
10111
|
"html",
|
|
10063
10112
|
"head",
|
|
10064
10113
|
"body"
|
|
10065
10114
|
]);
|
|
10066
|
-
function
|
|
10115
|
+
function zu(e, t = {}) {
|
|
10067
10116
|
let n = t.sfc === !0, r = [], i = e.length;
|
|
10068
10117
|
if (!e.trim()) return r;
|
|
10069
10118
|
let a = [0];
|
|
@@ -10144,12 +10193,12 @@ function Ru(e, t = {}) {
|
|
|
10144
10193
|
}
|
|
10145
10194
|
continue;
|
|
10146
10195
|
}
|
|
10147
|
-
if (
|
|
10196
|
+
if (Ru.has(m) && r.push({
|
|
10148
10197
|
line: o(t),
|
|
10149
10198
|
code: "DOC_TAG_IN_FRAGMENT",
|
|
10150
10199
|
message: `<${m}> 不应出现(v-html 注入场景只输出内容片段,不要 html/head/body 外围)`
|
|
10151
|
-
}), !(
|
|
10152
|
-
if (
|
|
10200
|
+
}), !(Iu.has(m) || h)) {
|
|
10201
|
+
if (Lu.has(m)) {
|
|
10153
10202
|
m === "script" && !n && r.push({
|
|
10154
10203
|
line: o(t),
|
|
10155
10204
|
code: "SCRIPT_IN_FRAGMENT",
|
|
@@ -10183,7 +10232,7 @@ function Ru(e, t = {}) {
|
|
|
10183
10232
|
}
|
|
10184
10233
|
//#endregion
|
|
10185
10234
|
//#region src/core/sdk/htmlSubagent.ts
|
|
10186
|
-
function
|
|
10235
|
+
function Bu(e, t) {
|
|
10187
10236
|
let n = t === "html" ? "html" : "vue";
|
|
10188
10237
|
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(规划)。
|
|
10189
10238
|
|
|
@@ -10196,6 +10245,10 @@ function zu(e, t) {
|
|
|
10196
10245
|
- **修改已有组件**(改颜色/文案/布局等):必经 vfs —— vfs_read 看现状 → vfs_edit 增量改目标片段 → validate_code 自检;框架自动回写 data.code。勿直接 write data.code 改已有组件(绕过 vfs/verify,且无增量友好)
|
|
10197
10246
|
- **新建组件**:write({ patch:{ op:'set', jsonPath:'components.N', value:{ name, code:<正文>, props } } }) —— code 作为字段值直接进 data,框架自动补 __pgId
|
|
10198
10247
|
|
|
10248
|
+
焦点精修(若继承到主 agent 焦点):
|
|
10249
|
+
- 上下文若提示「当前精修目标」(如 components.2(banner)),说明主 agent 聚焦了某组件 → 你**只能改该焦点组件**的代码文件(vfs 文件 ${e}<焦点组件 __pgId>.${n});改其他组件的代码文件会被 PATH_DENIED 硬拦
|
|
10250
|
+
- 直接改焦点组件文件,不要尝试改其他组件(浪费轮次);聚焦模式下也不能新建组件(数据写被拦)—— 若 task 要新建,反馈主 agent 需先取消焦点
|
|
10251
|
+
|
|
10199
10252
|
代码形态规则:
|
|
10200
10253
|
${t === "html" ? `- 输出纯 HTML 片段(.${n}):结构 + 内联 <style>(class 加统一前缀防样式冲突);交互交给宿主(不写 JS)
|
|
10201
10254
|
- 单根元素包裹(如 <section class="...">…</section>),语义化标签` : `- 输出 Vue SFC(.${n}):<template> + <script setup>(组合式),defineProps 接外部数据
|
|
@@ -10213,16 +10266,16 @@ ${t === "html" ? `- 输出纯 HTML 片段(.${n}):结构 + 内联 <style>(class
|
|
|
10213
10266
|
5. 生成/修改完成后必须调 validate_code 自检(标签闭合 + 片段契约),报错用 vfs_edit 修正后复查,直到通过;
|
|
10214
10267
|
6. 最后 read(vfs + data)确认结构正确;只写 writablePaths 内 data + ${e} 下 vfs。`;
|
|
10215
10268
|
}
|
|
10216
|
-
var
|
|
10269
|
+
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(vfs_read → vfs_edit 增量改 → validate_code);勿直接 write data.code\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(vfs_read → vfs_edit 增量改 → validate_code);勿直接 write data.code\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 = {
|
|
10217
10270
|
name: "html-builder",
|
|
10218
10271
|
description: "纯代码组件(custom Vue SFC)生成规范:代码作为 data 资产 / vfs 工作副本 / SFC 规范 / 输出契约 / props / 组件库引用 / 可访问性",
|
|
10219
|
-
getContent: () =>
|
|
10220
|
-
},
|
|
10272
|
+
getContent: () => Vu
|
|
10273
|
+
}, Wu = {
|
|
10221
10274
|
name: "html-fragment",
|
|
10222
10275
|
description: "纯 HTML 片段(v-html 注入)生成规范:代码作为 data 资产 / vfs 工作副本 / 无外围标签 / 单根元素 / 标签闭合 / validate_code 自检 / 安全底线 / 可访问性",
|
|
10223
|
-
getContent: () =>
|
|
10276
|
+
getContent: () => Hu
|
|
10224
10277
|
};
|
|
10225
|
-
function
|
|
10278
|
+
function Gu(e = {}) {
|
|
10226
10279
|
let t = e.vfsPrefix ?? "html/";
|
|
10227
10280
|
return ({ state: e }) => {
|
|
10228
10281
|
let n = e.files;
|
|
@@ -10230,7 +10283,7 @@ function Wu(e = {}) {
|
|
|
10230
10283
|
let r = [];
|
|
10231
10284
|
for (let [e, i] of Object.entries(n)) {
|
|
10232
10285
|
if (!e.startsWith(t)) continue;
|
|
10233
|
-
let n =
|
|
10286
|
+
let n = zu(i.content, { sfc: e.endsWith(".vue") });
|
|
10234
10287
|
for (let t of n) r.push(`${e} 第 ${t.line} 行:${t.message}(${t.code})`);
|
|
10235
10288
|
}
|
|
10236
10289
|
return r.length ? {
|
|
@@ -10239,7 +10292,7 @@ function Wu(e = {}) {
|
|
|
10239
10292
|
} : { ok: !0 };
|
|
10240
10293
|
};
|
|
10241
10294
|
}
|
|
10242
|
-
function
|
|
10295
|
+
function Ku(e) {
|
|
10243
10296
|
let n;
|
|
10244
10297
|
return {
|
|
10245
10298
|
name: "html-validate-tools",
|
|
@@ -10268,7 +10321,7 @@ function Gu(e) {
|
|
|
10268
10321
|
}
|
|
10269
10322
|
let a = [];
|
|
10270
10323
|
for (let e of i) {
|
|
10271
|
-
let t =
|
|
10324
|
+
let t = zu(e.content, { sfc: e.path.endsWith(".vue") });
|
|
10272
10325
|
t.length && a.push(`${e.path}:\n${t.map((e) => ` 第 ${e.line} 行 ${e.message}(${e.code})`).join("\n")}`);
|
|
10273
10326
|
}
|
|
10274
10327
|
return a.length ? `❌ 格式校验未通过:\n${a.join("\n")}\n请用 vfs_edit 修正后重新调用 validate_code 复查。` : `✅ 格式校验通过(${i.map((e) => e.path).join(", ")}:标签闭合、片段契约)。`;
|
|
@@ -10282,17 +10335,17 @@ function Gu(e) {
|
|
|
10282
10335
|
})]
|
|
10283
10336
|
};
|
|
10284
10337
|
}
|
|
10285
|
-
var
|
|
10286
|
-
function
|
|
10338
|
+
var qu = 2;
|
|
10339
|
+
function Ju(e) {
|
|
10287
10340
|
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;
|
|
10288
10341
|
if (!t?.length) throw Error("[page-agent-sdk][createHtmlSubagent] writablePaths 必填(代码组件 data 区,如 [\"components\"])");
|
|
10289
10342
|
let p = d === "html" ? "html" : "vue", m = [];
|
|
10290
|
-
a && m.push(ra()), f && (m.push(
|
|
10343
|
+
a && m.push(ra()), f && (m.push(Ku(n)), m.push(qo({ check: Gu({ vfsPrefix: n }) })));
|
|
10291
10344
|
let h = u ?? [];
|
|
10292
10345
|
return {
|
|
10293
10346
|
id: r,
|
|
10294
10347
|
description: i ?? "生成/修改纯代码组件(custom 代码)。代码作为 data 资产(code 字段进 DB),vfs 作工作副本;能规划(write_todos)+ 执行。需写代码组件或灵活定制时委派",
|
|
10295
|
-
systemPrompt:
|
|
10348
|
+
systemPrompt: Bu(n, d),
|
|
10296
10349
|
writablePaths: t,
|
|
10297
10350
|
allowedTools: [
|
|
10298
10351
|
"vfs_write",
|
|
@@ -10303,9 +10356,9 @@ function qu(e) {
|
|
|
10303
10356
|
],
|
|
10304
10357
|
middleware: m.length ? m : void 0,
|
|
10305
10358
|
summarization: o === !1 ? void 0 : o,
|
|
10306
|
-
maxVerifyAttempts: f ?
|
|
10359
|
+
maxVerifyAttempts: f ? qu : void 0,
|
|
10307
10360
|
temperature: c,
|
|
10308
|
-
skills: l ?? (d === "html" ? [
|
|
10361
|
+
skills: l ?? (d === "html" ? [Wu] : [Uu]),
|
|
10309
10362
|
maxToolRounds: s,
|
|
10310
10363
|
tools: h.length ? h : void 0,
|
|
10311
10364
|
_codeAsset: {
|
|
@@ -10317,7 +10370,7 @@ function qu(e) {
|
|
|
10317
10370
|
}
|
|
10318
10371
|
//#endregion
|
|
10319
10372
|
//#region src/core/utils/clipboard.ts
|
|
10320
|
-
async function
|
|
10373
|
+
async function Yu(e) {
|
|
10321
10374
|
try {
|
|
10322
10375
|
let t = globalThis.navigator?.clipboard;
|
|
10323
10376
|
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
@@ -10335,7 +10388,7 @@ async function Ju(e) {
|
|
|
10335
10388
|
}
|
|
10336
10389
|
//#endregion
|
|
10337
10390
|
//#region src/core/composables/useChat.ts
|
|
10338
|
-
function
|
|
10391
|
+
function Xu(e = {}) {
|
|
10339
10392
|
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a } = e, o = /* @__PURE__ */ _t({
|
|
10340
10393
|
messages: e.messages ?? [],
|
|
10341
10394
|
loading: !1,
|
|
@@ -10392,12 +10445,18 @@ function Yu(e = {}) {
|
|
|
10392
10445
|
case "tool_result":
|
|
10393
10446
|
for (let n = t.steps.length - 1; n >= 0; n--) if (t.steps[n].name === e.name && t.steps[n].status === "running") {
|
|
10394
10447
|
t.steps[n].result = e.result, t.steps[n].status = e.status, t.steps[n].durationMs = e.durationMs;
|
|
10448
|
+
let r = t.steps[n].subReason;
|
|
10449
|
+
r && r.length > 80 && (t.steps[n].subReason = r.slice(0, 80) + "…");
|
|
10395
10450
|
break;
|
|
10396
10451
|
}
|
|
10397
10452
|
break;
|
|
10398
10453
|
case "subagent": {
|
|
10399
10454
|
let n = t.steps[t.steps.length - 1];
|
|
10400
10455
|
if (!n) break;
|
|
10456
|
+
if (e.kind === "reasoning") {
|
|
10457
|
+
n.subReason = (n.subReason || "") + (e.delta || "");
|
|
10458
|
+
break;
|
|
10459
|
+
}
|
|
10401
10460
|
n.children ||= [];
|
|
10402
10461
|
let r = e.label ? `[${e.label}] ${e.name}` : e.name;
|
|
10403
10462
|
if (e.kind === "tool_call") n.children.push({
|
|
@@ -10514,9 +10573,9 @@ function Yu(e = {}) {
|
|
|
10514
10573
|
}
|
|
10515
10574
|
//#endregion
|
|
10516
10575
|
//#region src/core/composables/chatContext.ts
|
|
10517
|
-
var
|
|
10518
|
-
function
|
|
10519
|
-
let t =
|
|
10576
|
+
var Zu = Symbol("chatContext");
|
|
10577
|
+
function Qu(e = {}) {
|
|
10578
|
+
let t = Xu({
|
|
10520
10579
|
fetchResponse: e.fetchResponse,
|
|
10521
10580
|
fetchStream: e.fetchStream,
|
|
10522
10581
|
messages: e.messages,
|
|
@@ -10536,7 +10595,7 @@ function Zu(e = {}) {
|
|
|
10536
10595
|
}, h = /* @__PURE__ */ Ot({}), g = (e) => h.value[e] !== !1, _ = (e) => {
|
|
10537
10596
|
h.value[e] = !g(e);
|
|
10538
10597
|
}, v = /* @__PURE__ */ Ot(!1), y = (e) => {
|
|
10539
|
-
|
|
10598
|
+
Yu(e).then((e) => {
|
|
10540
10599
|
e && (v.value = !0, setTimeout(() => {
|
|
10541
10600
|
v.value = !1;
|
|
10542
10601
|
}, 1500));
|
|
@@ -10604,15 +10663,15 @@ function Zu(e = {}) {
|
|
|
10604
10663
|
}
|
|
10605
10664
|
};
|
|
10606
10665
|
}
|
|
10607
|
-
function
|
|
10608
|
-
let e = Fn(
|
|
10666
|
+
function $u() {
|
|
10667
|
+
let e = Fn(Zu);
|
|
10609
10668
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
10610
10669
|
return e;
|
|
10611
10670
|
}
|
|
10612
10671
|
//#endregion
|
|
10613
10672
|
//#region src/core/index.headless.ts
|
|
10614
|
-
function
|
|
10615
|
-
return
|
|
10673
|
+
function ed(e) {
|
|
10674
|
+
return ku(e);
|
|
10616
10675
|
}
|
|
10617
10676
|
//#endregion
|
|
10618
|
-
export {
|
|
10677
|
+
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 };
|