page-agent-sdk 3.19.1 → 3.21.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 +4 -2
- package/README.zh-CN.md +4 -2
- package/dist/page-agent-sdk.headless.js +995 -496
- package/dist/page-agent-sdk.iife.js +147 -145
- package/dist/page-agent-sdk.js +3808 -3261
- package/dist/page-agent-sdk.umd.cjs +78 -76
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +247 -1
|
@@ -3327,6 +3327,15 @@ var ga = {
|
|
|
3327
3327
|
"5. 优先用 write 的 patch 增量改(只发改动,如 write({ value, patch:{ op, jsonPath } })),避免整体重传大 JSON 被截断;",
|
|
3328
3328
|
"6. 写入若触发乐观锁冲突(返回 VERSION_CONFLICT 或工具挂起等用户决定):等工具返回结果后按其指示继续(保留外部值 → 重新 read 再改;已覆盖/已回退 → 基于结果重写),不要放弃任务。"
|
|
3329
3329
|
].join("\n"),
|
|
3330
|
+
reliableWriteRulesEn: [
|
|
3331
|
+
"[Reliable write rules]",
|
|
3332
|
+
"1. Before changing any field, read its current real value with read({ jsonPath }) and edit based on that value, never from memory;",
|
|
3333
|
+
"2. If unsure which fields are operable, call read() without jsonPath first to see the data description + schema-declared fields (the integrator can replace the schema at runtime via sdk.setData; trust the tool response over stale memory);",
|
|
3334
|
+
"3. When unsure about a field structure, the read({ jsonPath }) response includes a format description; treat the response as the source of truth;",
|
|
3335
|
+
"4. If a write is rejected by schema validation (the structured error names the field and expected type), fix it per the error and retry; do not give up;",
|
|
3336
|
+
"5. Prefer incremental write patches (send only the change, e.g. write({ value, patch:{ op, jsonPath } })) over resending the whole large JSON, which risks truncation;",
|
|
3337
|
+
"6. If a write hits an optimistic-lock conflict (VERSION_CONFLICT returned, or the tool suspends awaiting the user decision): after the tool returns, follow its instruction (keep external → re-read then edit; overwritten/restored → continue from the result); do not abandon the task."
|
|
3338
|
+
].join("\n"),
|
|
3330
3339
|
htmlPageOrchestrator: ha("html"),
|
|
3331
3340
|
htmlPageProposeFirst: ["【新建/创意类请求】先用简短文字给出 2~3 套方案(每套一两句风格/配色/结构要点),询问用户选哪套;选定前不要委派生成代码、不要写 components。", "【方案切换】已生成某套方案后改选另一套:不重新罗列,直接依据之前描述重新委派生成并覆盖相应组件(委派工具见编排段 use_<id>)。"].join("\n"),
|
|
3332
3341
|
htmlDirectWriteFallback: [
|
|
@@ -3780,7 +3789,8 @@ function Qa(e) {
|
|
|
3780
3789
|
let n = [
|
|
3781
3790
|
"## 当前精修目标",
|
|
3782
3791
|
t.map((e) => `· ${e.path}${e.label ? `(${e.label})` : ""}`).join("\n"),
|
|
3783
|
-
`仅操作上述 ${t.length} 个聚焦子树${t.length > 1 ? "之一" : ""},用户未指明目标的指令默认作用于聚焦组件;不要改动其他组件;${i}
|
|
3792
|
+
`仅操作上述 ${t.length} 个聚焦子树${t.length > 1 ? "之一" : ""},用户未指明目标的指令默认作用于聚焦组件;不要改动其他组件;${i}`,
|
|
3793
|
+
"read 不带路径时默认只返回聚焦子树;需要全量主数据时显式列顶层键(read({jsonPaths:[...]}) )"
|
|
3784
3794
|
], r = e.getSchema();
|
|
3785
3795
|
if (r) {
|
|
3786
3796
|
let e = t.map((e) => {
|
|
@@ -3809,6 +3819,22 @@ function Qa(e) {
|
|
|
3809
3819
|
if (!r.length) return o("(整体数据)");
|
|
3810
3820
|
for (let n of r) if (!t.some((e) => Xa(n, e.path)) && !Za(n, e.getBind?.())) return o(n);
|
|
3811
3821
|
}
|
|
3822
|
+
if (n.name === "read") {
|
|
3823
|
+
let e = n.args;
|
|
3824
|
+
if (!e?.jsonPath && !e?.jsonPaths) {
|
|
3825
|
+
let i = t.map((e) => e.path), a = await r({
|
|
3826
|
+
...n,
|
|
3827
|
+
args: {
|
|
3828
|
+
...e,
|
|
3829
|
+
jsonPaths: i
|
|
3830
|
+
}
|
|
3831
|
+
}), o = `【聚焦模式】read 未带路径 → 默认返回聚焦子树(${i.join(", ")});需要全量主数据时显式列顶层键,如 read({jsonPaths:['<顶层键1>','<顶层键2>']})\n`;
|
|
3832
|
+
return {
|
|
3833
|
+
...a,
|
|
3834
|
+
content: o + a.content
|
|
3835
|
+
};
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3812
3838
|
}
|
|
3813
3839
|
return r(n);
|
|
3814
3840
|
},
|
|
@@ -5720,58 +5746,65 @@ var nc = [
|
|
|
5720
5746
|
"大对象/数组优先用增量 patch(只发改动)而非整体重传,避免输出被截断。",
|
|
5721
5747
|
"---",
|
|
5722
5748
|
ga.reliableWriteRules
|
|
5749
|
+
].join("\n\n"), rc = [
|
|
5750
|
+
"You are a JSON operations assistant. The integrator declared a main data object (with zod schema validation); you complete tasks by reading and writing it safely through dedicated tools.",
|
|
5751
|
+
"All writes go through scope control (only schema-declared fields) and schema validation (invalid writes return a structured error instead of being applied), with automatic snapshots for rollback.",
|
|
5752
|
+
"For large objects/arrays prefer incremental patches (send only the change) over resending the whole value, to avoid output truncation.",
|
|
5753
|
+
"Respond in English.",
|
|
5754
|
+
"---",
|
|
5755
|
+
ga.reliableWriteRulesEn
|
|
5723
5756
|
].join("\n\n");
|
|
5724
|
-
function
|
|
5757
|
+
function ic(e, t) {
|
|
5725
5758
|
if (!e) return "";
|
|
5726
5759
|
let n = ba(e.schema, t);
|
|
5727
5760
|
return `\n\n## 可操作数据(字段以 read 工具返回的实际值为准)\n${e.description ? e.description + "\n" : ""}${n}`;
|
|
5728
5761
|
}
|
|
5729
|
-
function
|
|
5730
|
-
let t = e.appendReliableWriteRules !== !1;
|
|
5731
|
-
return e.systemPrompt ?
|
|
5762
|
+
function ac(e) {
|
|
5763
|
+
let t = e.locale === "en-US", n = t ? ga.reliableWriteRulesEn : ga.reliableWriteRules, r = e.appendReliableWriteRules !== !1;
|
|
5764
|
+
return e.systemPrompt ? r ? e.systemPrompt + "\n\n---\n\n" + n : e.systemPrompt : t ? rc : nc;
|
|
5732
5765
|
}
|
|
5733
|
-
var
|
|
5766
|
+
var oc = {
|
|
5734
5767
|
largeResults: 4 * 1024 * 1024,
|
|
5735
5768
|
drafts: 2 * 1024 * 1024,
|
|
5736
5769
|
userFiles: 2 * 1024 * 1024,
|
|
5737
5770
|
resources: 4 * 1024 * 1024
|
|
5738
|
-
},
|
|
5771
|
+
}, sc = [
|
|
5739
5772
|
"largeResults",
|
|
5740
5773
|
"drafts",
|
|
5741
5774
|
"userFiles",
|
|
5742
5775
|
"resources"
|
|
5743
|
-
],
|
|
5744
|
-
function
|
|
5776
|
+
], cc = .9;
|
|
5777
|
+
function lc(e, t = {}) {
|
|
5745
5778
|
let n = Object.create(null);
|
|
5746
|
-
if (e) for (let [t, r] of Object.entries(e)) n[
|
|
5779
|
+
if (e) for (let [t, r] of Object.entries(e)) n[pc(t)] = {
|
|
5747
5780
|
content: r,
|
|
5748
|
-
updatedAt:
|
|
5781
|
+
updatedAt: hc()
|
|
5749
5782
|
};
|
|
5750
5783
|
let { persist: r } = t, i = t.maxBytes ?? 8388608, a = {
|
|
5751
|
-
...
|
|
5784
|
+
...oc,
|
|
5752
5785
|
...t.poolBytes ?? {}
|
|
5753
5786
|
};
|
|
5754
5787
|
function o(e) {
|
|
5755
|
-
let t =
|
|
5788
|
+
let t = pc(e);
|
|
5756
5789
|
return t.startsWith("large_results/") ? "largeResults" : t.startsWith("drafts/") ? "drafts" : t.startsWith("resources/") ? "resources" : "userFiles";
|
|
5757
5790
|
}
|
|
5758
5791
|
function s(e) {
|
|
5759
5792
|
let t = 0;
|
|
5760
|
-
for (let [r, i] of Object.entries(n)) o(r) === e && (t +=
|
|
5793
|
+
for (let [r, i] of Object.entries(n)) o(r) === e && (t += dc(i.content));
|
|
5761
5794
|
return t;
|
|
5762
5795
|
}
|
|
5763
5796
|
function c() {
|
|
5764
|
-
for (let e of
|
|
5797
|
+
for (let e of sc) {
|
|
5765
5798
|
let t = a[e];
|
|
5766
5799
|
if (s(e) <= t) continue;
|
|
5767
|
-
let r = t *
|
|
5800
|
+
let r = t * cc, i = e === "largeResults", c = i && s(e) > t * 1.5;
|
|
5768
5801
|
c && console.warn(`[page-agent-sdk] vfs large_results 池 ${s(e)} > ${Math.round(t * 1.5)}(被引用撑爆)→ 无视 protectedRefs 强制删`);
|
|
5769
5802
|
let l = Object.entries(n).filter(([t]) => o(t) === e).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
5770
5803
|
for (let [t] of l) if (!(i && !c && u.has(t)) && (delete n[t], s(e) <= r)) break;
|
|
5771
5804
|
}
|
|
5772
|
-
if (
|
|
5773
|
-
let e = i *
|
|
5774
|
-
for (let [i] of r) if (!(o(i) === "largeResults" && !t && u.has(i)) && (delete n[i],
|
|
5805
|
+
if (fc(n) > i) {
|
|
5806
|
+
let e = i * cc, t = fc(n) > i * 1.5, r = Object.entries(n).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
5807
|
+
for (let [i] of r) if (!(o(i) === "largeResults" && !t && u.has(i)) && (delete n[i], fc(n) <= e)) break;
|
|
5775
5808
|
}
|
|
5776
5809
|
}
|
|
5777
5810
|
let l = !0, u = /* @__PURE__ */ new Set(), d = null;
|
|
@@ -5806,10 +5839,10 @@ function cc(e, t = {}) {
|
|
|
5806
5839
|
u = e;
|
|
5807
5840
|
},
|
|
5808
5841
|
getPoolOf: (e) => o(e),
|
|
5809
|
-
getPoolLimit: (e) => a[e] ??
|
|
5842
|
+
getPoolLimit: (e) => a[e] ?? oc.userFiles
|
|
5810
5843
|
};
|
|
5811
5844
|
return r && (m.hydrate = (e) => {
|
|
5812
|
-
for (let [t, r] of Object.entries(e)) n[
|
|
5845
|
+
for (let [t, r] of Object.entries(e)) n[pc(t)] = r;
|
|
5813
5846
|
c(), l = !0;
|
|
5814
5847
|
}, m.flush = () => {
|
|
5815
5848
|
d &&= (clearTimeout(d), null), f();
|
|
@@ -5818,19 +5851,19 @@ function cc(e, t = {}) {
|
|
|
5818
5851
|
p(), l = !0;
|
|
5819
5852
|
}), m;
|
|
5820
5853
|
}
|
|
5821
|
-
var
|
|
5822
|
-
function uc(e) {
|
|
5823
|
-
return lc ||= new TextEncoder(), lc.encode(e).length;
|
|
5824
|
-
}
|
|
5854
|
+
var uc = null;
|
|
5825
5855
|
function dc(e) {
|
|
5856
|
+
return uc ||= new TextEncoder(), uc.encode(e).length;
|
|
5857
|
+
}
|
|
5858
|
+
function fc(e) {
|
|
5826
5859
|
let t = 0;
|
|
5827
|
-
for (let n of Object.values(e)) t +=
|
|
5860
|
+
for (let n of Object.values(e)) t += dc(n.content);
|
|
5828
5861
|
return t;
|
|
5829
5862
|
}
|
|
5830
|
-
function
|
|
5863
|
+
function pc(e) {
|
|
5831
5864
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
5832
5865
|
}
|
|
5833
|
-
function
|
|
5866
|
+
function mc(e) {
|
|
5834
5867
|
let t = "";
|
|
5835
5868
|
for (let n = 0; n < e.length; n++) {
|
|
5836
5869
|
let r = e[n];
|
|
@@ -5838,10 +5871,10 @@ function pc(e) {
|
|
|
5838
5871
|
}
|
|
5839
5872
|
return RegExp("^" + t + "$");
|
|
5840
5873
|
}
|
|
5841
|
-
function
|
|
5874
|
+
function hc() {
|
|
5842
5875
|
return Date.now();
|
|
5843
5876
|
}
|
|
5844
|
-
var
|
|
5877
|
+
var gc = [
|
|
5845
5878
|
"vfs_read",
|
|
5846
5879
|
"vfs_write",
|
|
5847
5880
|
"vfs_edit",
|
|
@@ -5852,10 +5885,10 @@ var hc = [
|
|
|
5852
5885
|
"vfs_json_patch",
|
|
5853
5886
|
"vfs_rm"
|
|
5854
5887
|
];
|
|
5855
|
-
function
|
|
5888
|
+
function _c(e) {
|
|
5856
5889
|
return [
|
|
5857
5890
|
r(async ({ path: t, offset: n, limit: r }) => {
|
|
5858
|
-
let i = e.files[
|
|
5891
|
+
let i = e.files[pc(t)];
|
|
5859
5892
|
if (!i) return Y({
|
|
5860
5893
|
code: "NOT_FOUND",
|
|
5861
5894
|
path: t,
|
|
@@ -5874,7 +5907,7 @@ function gc(e) {
|
|
|
5874
5907
|
})
|
|
5875
5908
|
}),
|
|
5876
5909
|
r(async ({ path: t, content: n, jsonString: r }) => {
|
|
5877
|
-
let i =
|
|
5910
|
+
let i = pc(t), a = e.getPoolLimit?.(e.getPoolOf?.(i) ?? "userFiles") ?? 2 * 1024 * 1024, o = dc(n);
|
|
5878
5911
|
if (o > a) {
|
|
5879
5912
|
let n = e.getPoolOf?.(i) ?? "userFiles";
|
|
5880
5913
|
return Y({
|
|
@@ -5896,7 +5929,7 @@ function gc(e) {
|
|
|
5896
5929
|
}
|
|
5897
5930
|
return e.files[i] = {
|
|
5898
5931
|
content: n,
|
|
5899
|
-
updatedAt:
|
|
5932
|
+
updatedAt: hc()
|
|
5900
5933
|
}, `已写入 ${t}(${n.length} 字符)${r ? "(JSON 校验通过)" : ""}`;
|
|
5901
5934
|
}, {
|
|
5902
5935
|
name: "vfs_write",
|
|
@@ -5908,7 +5941,7 @@ function gc(e) {
|
|
|
5908
5941
|
})
|
|
5909
5942
|
}),
|
|
5910
5943
|
r(async ({ path: t, oldString: n, newString: r }) => {
|
|
5911
|
-
let i =
|
|
5944
|
+
let i = pc(t), a = e.files[i];
|
|
5912
5945
|
if (!a) return Y({
|
|
5913
5946
|
code: "NOT_FOUND",
|
|
5914
5947
|
path: t,
|
|
@@ -5938,7 +5971,7 @@ function gc(e) {
|
|
|
5938
5971
|
}
|
|
5939
5972
|
return e.files[i] = {
|
|
5940
5973
|
content: a.content.replace(n, r),
|
|
5941
|
-
updatedAt:
|
|
5974
|
+
updatedAt: hc()
|
|
5942
5975
|
}, `已替换 ${t} 中 1 处。`;
|
|
5943
5976
|
}, {
|
|
5944
5977
|
name: "vfs_edit",
|
|
@@ -5960,7 +5993,7 @@ function gc(e) {
|
|
|
5960
5993
|
r(async ({ pattern: t }) => {
|
|
5961
5994
|
let n;
|
|
5962
5995
|
try {
|
|
5963
|
-
n =
|
|
5996
|
+
n = mc(t);
|
|
5964
5997
|
} catch (e) {
|
|
5965
5998
|
return Y({
|
|
5966
5999
|
code: "GLOB_INVALID",
|
|
@@ -5989,7 +6022,7 @@ function gc(e) {
|
|
|
5989
6022
|
details: { pattern: t }
|
|
5990
6023
|
});
|
|
5991
6024
|
}
|
|
5992
|
-
let i = n ? [
|
|
6025
|
+
let i = n ? [pc(n)] : Object.keys(e.files), a = [];
|
|
5993
6026
|
for (let t of i) {
|
|
5994
6027
|
let n = e.files[t];
|
|
5995
6028
|
n && n.content.split("\n").forEach((e, n) => {
|
|
@@ -6006,7 +6039,7 @@ function gc(e) {
|
|
|
6006
6039
|
})
|
|
6007
6040
|
}),
|
|
6008
6041
|
r(async ({ path: t, jsonPath: n }) => {
|
|
6009
|
-
let r =
|
|
6042
|
+
let r = pc(t), i = e.files[r];
|
|
6010
6043
|
if (!i) return Y({
|
|
6011
6044
|
code: "NOT_FOUND",
|
|
6012
6045
|
path: t,
|
|
@@ -6043,7 +6076,7 @@ function gc(e) {
|
|
|
6043
6076
|
})
|
|
6044
6077
|
}),
|
|
6045
6078
|
r(async ({ path: t, patches: n }) => {
|
|
6046
|
-
let r =
|
|
6079
|
+
let r = pc(t), i = e.files[r];
|
|
6047
6080
|
if (!i) return Y({
|
|
6048
6081
|
code: "NOT_FOUND",
|
|
6049
6082
|
path: t,
|
|
@@ -6076,7 +6109,7 @@ function gc(e) {
|
|
|
6076
6109
|
let c = JSON.stringify(o);
|
|
6077
6110
|
return e.files[r] = {
|
|
6078
6111
|
content: c,
|
|
6079
|
-
updatedAt:
|
|
6112
|
+
updatedAt: hc()
|
|
6080
6113
|
}, `已对 ${t} 应用 ${n.length} 个 patch(影响 ${s.length} 处:${s.join(", ")}),文件现 ${c.length} 字符`;
|
|
6081
6114
|
}, {
|
|
6082
6115
|
name: "vfs_json_patch",
|
|
@@ -6096,7 +6129,7 @@ function gc(e) {
|
|
|
6096
6129
|
})
|
|
6097
6130
|
}),
|
|
6098
6131
|
r(async ({ path: t }) => {
|
|
6099
|
-
let n =
|
|
6132
|
+
let n = pc(t);
|
|
6100
6133
|
return e.files[n] ? (delete e.files[n], `已删除 ${t}`) : Y({
|
|
6101
6134
|
code: "NOT_FOUND",
|
|
6102
6135
|
path: t,
|
|
@@ -6110,16 +6143,16 @@ function gc(e) {
|
|
|
6110
6143
|
})
|
|
6111
6144
|
];
|
|
6112
6145
|
}
|
|
6113
|
-
function
|
|
6146
|
+
function vc(e) {
|
|
6114
6147
|
return {
|
|
6115
6148
|
name: "vfs",
|
|
6116
|
-
tools:
|
|
6149
|
+
tools: _c(e),
|
|
6117
6150
|
beforeAgent: () => ({ files: e.files })
|
|
6118
6151
|
};
|
|
6119
6152
|
}
|
|
6120
6153
|
//#endregion
|
|
6121
6154
|
//#region src/core/tools/htmlValidate.ts
|
|
6122
|
-
var
|
|
6155
|
+
var yc = /* @__PURE__ */ new Set([
|
|
6123
6156
|
"area",
|
|
6124
6157
|
"base",
|
|
6125
6158
|
"br",
|
|
@@ -6134,8 +6167,8 @@ var vc = /* @__PURE__ */ new Set([
|
|
|
6134
6167
|
"source",
|
|
6135
6168
|
"track",
|
|
6136
6169
|
"wbr"
|
|
6137
|
-
]),
|
|
6138
|
-
function
|
|
6170
|
+
]), bc = /* @__PURE__ */ new Set(["script", "style"]);
|
|
6171
|
+
function xc(e) {
|
|
6139
6172
|
let t = [], n = e.length;
|
|
6140
6173
|
if (!e.trim()) return t;
|
|
6141
6174
|
let r = [0];
|
|
@@ -6212,8 +6245,8 @@ function bc(e) {
|
|
|
6212
6245
|
}
|
|
6213
6246
|
continue;
|
|
6214
6247
|
}
|
|
6215
|
-
if (!(
|
|
6216
|
-
if (
|
|
6248
|
+
if (!(yc.has(p) || m)) {
|
|
6249
|
+
if (bc.has(p)) {
|
|
6217
6250
|
let n = RegExp(`</${p}\\s*>`, "i").exec(e.slice(o));
|
|
6218
6251
|
if (!n) {
|
|
6219
6252
|
t.push({
|
|
@@ -6242,8 +6275,8 @@ function bc(e) {
|
|
|
6242
6275
|
}
|
|
6243
6276
|
//#endregion
|
|
6244
6277
|
//#region src/core/sdk/codeAssetMiddleware.ts
|
|
6245
|
-
var
|
|
6246
|
-
function
|
|
6278
|
+
var Sc = "__pgTouched", Cc = "__pgFinalText", wc = "__pgCodeHashes", Tc = "__pgNotes", Ec = 200;
|
|
6279
|
+
function Dc(e) {
|
|
6247
6280
|
let t = [];
|
|
6248
6281
|
for (let n of e.split("\n")) {
|
|
6249
6282
|
let e = n.match(/^\s*[-*]?\s*\[note\]\s*(.*)$/i);
|
|
@@ -6251,27 +6284,27 @@ function Ec(e) {
|
|
|
6251
6284
|
}
|
|
6252
6285
|
return [...new Set(t)];
|
|
6253
6286
|
}
|
|
6254
|
-
function
|
|
6255
|
-
let n = Array.isArray(e[
|
|
6256
|
-
e[
|
|
6287
|
+
function Oc(e, t) {
|
|
6288
|
+
let n = Array.isArray(e[Tc]) ? e[Tc].filter((e) => typeof e == "string") : [];
|
|
6289
|
+
e[Tc] = [.../* @__PURE__ */ new Set([...n, ...t])].map((e) => e.length > Ec ? e.slice(0, Ec) + "…" : e).slice(-5);
|
|
6257
6290
|
}
|
|
6258
|
-
function
|
|
6291
|
+
function kc(e) {
|
|
6259
6292
|
let t = 5381;
|
|
6260
6293
|
for (let n = 0; n < e.length; n++) t = (t << 5) + t + e.charCodeAt(n) | 0;
|
|
6261
6294
|
return (t >>> 0).toString(16);
|
|
6262
6295
|
}
|
|
6263
|
-
function
|
|
6296
|
+
function Ac(e, t) {
|
|
6264
6297
|
let n = [];
|
|
6265
|
-
return
|
|
6298
|
+
return Mc(e, t, (e) => {
|
|
6266
6299
|
typeof e.name == "string" && e.name && n.push(e.name);
|
|
6267
6300
|
}), n;
|
|
6268
6301
|
}
|
|
6269
|
-
function
|
|
6302
|
+
function jc(e, t) {
|
|
6270
6303
|
if (!e.startsWith(t)) return null;
|
|
6271
6304
|
let n = e.slice(t.length), r = n.lastIndexOf(".");
|
|
6272
6305
|
return (r > 0 ? n.slice(0, r) : r === 0 ? "" : n) || null;
|
|
6273
6306
|
}
|
|
6274
|
-
function
|
|
6307
|
+
function Mc(e, t, n) {
|
|
6275
6308
|
if (!(!e || typeof e != "object")) for (let r of t) {
|
|
6276
6309
|
let t = Z(e, r);
|
|
6277
6310
|
if (Array.isArray(t)) for (let e = 0; e < t.length; e++) {
|
|
@@ -6280,7 +6313,7 @@ function jc(e, t, n) {
|
|
|
6280
6313
|
}
|
|
6281
6314
|
}
|
|
6282
6315
|
}
|
|
6283
|
-
function
|
|
6316
|
+
function Nc(e, t, n) {
|
|
6284
6317
|
let r = /* @__PURE__ */ new Set();
|
|
6285
6318
|
if (!e || typeof e != "object") return r;
|
|
6286
6319
|
for (let i of t) {
|
|
@@ -6299,17 +6332,17 @@ function Mc(e, t, n) {
|
|
|
6299
6332
|
}
|
|
6300
6333
|
return r;
|
|
6301
6334
|
}
|
|
6302
|
-
function
|
|
6335
|
+
function Pc(e) {
|
|
6303
6336
|
let { writablePaths: t, codeVfsPrefix: n, ext: r, codeField: i = "code", onWarning: a, getController: o, vfsStore: s, craftNotes: c = !0 } = e;
|
|
6304
6337
|
return {
|
|
6305
6338
|
name: "code-asset-checkout-commit",
|
|
6306
6339
|
beforeAgent: (e) => {
|
|
6307
6340
|
let c = o()?.get?.().bind, l = 0, u = 0, d = /* @__PURE__ */ new Map();
|
|
6308
|
-
if (
|
|
6341
|
+
if (Mc(c, t, (e) => {
|
|
6309
6342
|
l++;
|
|
6310
6343
|
let t = Z(e, i);
|
|
6311
6344
|
if (typeof t == "string") {
|
|
6312
|
-
u++, d.set(e.__pgId,
|
|
6345
|
+
u++, d.set(e.__pgId, kc(t));
|
|
6313
6346
|
let i = `${n}${e.__pgId}.${r}`;
|
|
6314
6347
|
s.files[i] = {
|
|
6315
6348
|
content: t,
|
|
@@ -6329,22 +6362,22 @@ function Nc(e) {
|
|
|
6329
6362
|
}
|
|
6330
6363
|
return {
|
|
6331
6364
|
files: s.files,
|
|
6332
|
-
[
|
|
6333
|
-
[
|
|
6334
|
-
[
|
|
6365
|
+
[Sc]: /* @__PURE__ */ new Set(),
|
|
6366
|
+
[Cc]: { text: "" },
|
|
6367
|
+
[wc]: d
|
|
6335
6368
|
};
|
|
6336
6369
|
},
|
|
6337
6370
|
wrapModelCall: async (e, t) => {
|
|
6338
|
-
let n = await t(e), r = e.state[
|
|
6371
|
+
let n = await t(e), r = e.state[Cc];
|
|
6339
6372
|
return r && !(n.toolCalls && n.toolCalls.length) && typeof n.content == "string" && n.content && (r.text = n.content), n;
|
|
6340
6373
|
},
|
|
6341
6374
|
augmentPrompt: () => {
|
|
6342
6375
|
let e = o()?.get?.().bind, i = [], a = 0;
|
|
6343
|
-
if (
|
|
6376
|
+
if (Mc(e, t, (e, t, o) => {
|
|
6344
6377
|
a++;
|
|
6345
6378
|
let l = typeof e.name == "string" && e.name ? e.name : "", u = l ? `${l} [${o}]` : `(未命名 [${o}])`, d = `${n}${e.__pgId}.${r}`, f = !!s.files[d];
|
|
6346
6379
|
if (i.push(`- ${u} → ${d}${f ? "" : "(尚未检出,先 vfs_write 创建)"}`), c) {
|
|
6347
|
-
let t = Array.isArray(e[
|
|
6380
|
+
let t = Array.isArray(e[Tc]) ? e[Tc].filter((e) => typeof e == "string") : [];
|
|
6348
6381
|
if (t.length) {
|
|
6349
6382
|
let e = t[t.length - 1];
|
|
6350
6383
|
i.push(` 📝 笔记×${t.length}(最近):${e.length > 120 ? e.slice(0, 120) + "…" : e}`);
|
|
@@ -6362,13 +6395,13 @@ function Nc(e) {
|
|
|
6362
6395
|
return `## 组件代码文件地图(改组件时按 name 直接改对应 vfs 文件;框架自动 checkout/commit)${c ? "\n📝 笔记 = 前任维护者交接(设计决策/用户反馈/踩坑),改该组件时遵循;收口回复末行必须附一行 [note] 交接笔记(本组件本次的实现要点),框架存进组件转交下任" : ""}\n${i.join("\n")}${l}`;
|
|
6363
6396
|
},
|
|
6364
6397
|
wrapToolCall: async (e, i) => {
|
|
6365
|
-
let a = e.name === "vfs_write" || e.name === "vfs_edit" || e.name === "vfs_rm" ? e.args?.path : void 0, s = typeof a == "string" ?
|
|
6398
|
+
let a = e.name === "vfs_write" || e.name === "vfs_edit" || e.name === "vfs_rm" ? e.args?.path : void 0, s = typeof a == "string" ? pc(a) : void 0, c = typeof s == "string" && s.startsWith(n);
|
|
6366
6399
|
if (c) {
|
|
6367
6400
|
let i = e.state.focuses;
|
|
6368
6401
|
if (i && i.length) {
|
|
6369
|
-
let e =
|
|
6402
|
+
let e = Nc(o()?.get?.().bind, t, i);
|
|
6370
6403
|
if (e.size) {
|
|
6371
|
-
let t =
|
|
6404
|
+
let t = jc(s, n);
|
|
6372
6405
|
if (t && !e.has(t)) return {
|
|
6373
6406
|
content: `PATH_DENIED · vfs 越界:当前聚焦代码文件 [${[...e].map((e) => `${n}${e}.${r}`).join(", ")}],你要改的 "${s}" 不在其中。请只改焦点组件的代码文件;如需改其他组件,请在收口回复中说明需先取消聚焦(焦点由主会话/用户管理,你无 focus 工具)后重试。`,
|
|
6374
6407
|
status: "error"
|
|
@@ -6378,7 +6411,7 @@ function Nc(e) {
|
|
|
6378
6411
|
}
|
|
6379
6412
|
let l = await i(e);
|
|
6380
6413
|
if (c) {
|
|
6381
|
-
let t = e.state[
|
|
6414
|
+
let t = e.state[Sc];
|
|
6382
6415
|
t && t.add(s);
|
|
6383
6416
|
}
|
|
6384
6417
|
return l;
|
|
@@ -6386,10 +6419,10 @@ function Nc(e) {
|
|
|
6386
6419
|
afterAgent: (e) => {
|
|
6387
6420
|
let a = o(), l = a?.get?.().bind;
|
|
6388
6421
|
if (!l) return;
|
|
6389
|
-
let u = e[
|
|
6422
|
+
let u = e[Sc] ?? /* @__PURE__ */ new Set();
|
|
6390
6423
|
if (u.size) {
|
|
6391
|
-
let o = e[
|
|
6392
|
-
|
|
6424
|
+
let o = e[wc] ?? /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set();
|
|
6425
|
+
Mc(l, t, (e) => {
|
|
6393
6426
|
let t = e.__pgId;
|
|
6394
6427
|
c.add(t);
|
|
6395
6428
|
let a = `${n}${t}.${r}`;
|
|
@@ -6399,12 +6432,12 @@ function Nc(e) {
|
|
|
6399
6432
|
let r = o.get(t);
|
|
6400
6433
|
if (r !== void 0) {
|
|
6401
6434
|
let n = Z(e, i);
|
|
6402
|
-
if (typeof n != "string" ||
|
|
6435
|
+
if (typeof n != "string" || kc(n) !== r) {
|
|
6403
6436
|
console.warn(`[page-agent-sdk][code-asset] 组件 ${e.name ?? t}(${a})在修改期间被外部更新,已保留外部版本(keep_external),本次子 agent 修改未提交`);
|
|
6404
6437
|
return;
|
|
6405
6438
|
}
|
|
6406
6439
|
}
|
|
6407
|
-
let s =
|
|
6440
|
+
let s = xc(n.content);
|
|
6408
6441
|
if (s.length) {
|
|
6409
6442
|
console.warn(`[page-agent-sdk][code-asset] 跳过 commit 未通过校验的半成品(可能 abort/timeout 未跑完 verify):${a} - ${s[0].message}(${s[0].code})`);
|
|
6410
6443
|
return;
|
|
@@ -6416,22 +6449,22 @@ function Nc(e) {
|
|
|
6416
6449
|
}
|
|
6417
6450
|
});
|
|
6418
6451
|
for (let e of u) {
|
|
6419
|
-
let t =
|
|
6452
|
+
let t = jc(e, n);
|
|
6420
6453
|
t && !c.has(t) && (console.warn(`[page-agent-sdk][code-asset] 组件 ${t}(${e})已被外部删除,放弃 commit 并清理 vfs 工作副本(不复活组件)`), delete s.files[e]);
|
|
6421
6454
|
}
|
|
6422
6455
|
a?.markDataDirty?.(), a?.recomputeBaseline?.();
|
|
6423
6456
|
}
|
|
6424
6457
|
if (!c) return;
|
|
6425
|
-
let d =
|
|
6458
|
+
let d = Dc(e[Cc]?.text ?? "");
|
|
6426
6459
|
if (!d.length) return;
|
|
6427
6460
|
let f = [];
|
|
6428
|
-
if (
|
|
6461
|
+
if (Mc(l, t, (e) => {
|
|
6429
6462
|
(u.size === 0 || u.has(`${n}${e.__pgId}.${r}`)) && f.push(e);
|
|
6430
6463
|
}), !f.length) return;
|
|
6431
6464
|
let p = !1;
|
|
6432
6465
|
for (let e of d) {
|
|
6433
6466
|
let t = f.length === 1 ? f[0] : f.find((t) => typeof t.name == "string" && !!t.name && e.includes(t.name));
|
|
6434
|
-
t && (
|
|
6467
|
+
t && (Oc(t, [e]), p = !0);
|
|
6435
6468
|
}
|
|
6436
6469
|
p && a?.markDataDirty?.();
|
|
6437
6470
|
}
|
|
@@ -6439,7 +6472,7 @@ function Nc(e) {
|
|
|
6439
6472
|
}
|
|
6440
6473
|
//#endregion
|
|
6441
6474
|
//#region src/core/sdk/componentLock.ts
|
|
6442
|
-
function
|
|
6475
|
+
function Fc() {
|
|
6443
6476
|
let e = /* @__PURE__ */ new Map();
|
|
6444
6477
|
return {
|
|
6445
6478
|
async acquire(t, n) {
|
|
@@ -6478,7 +6511,7 @@ function Pc() {
|
|
|
6478
6511
|
}
|
|
6479
6512
|
};
|
|
6480
6513
|
}
|
|
6481
|
-
function
|
|
6514
|
+
function Ic(e, t) {
|
|
6482
6515
|
if (Array.isArray(e.components) && e.components.length) {
|
|
6483
6516
|
let n = new Set(t), r = [...new Set(e.components.filter((e) => typeof e == "string" && e && n.has(e)))];
|
|
6484
6517
|
if (r.length) return {
|
|
@@ -6495,12 +6528,12 @@ function Fc(e, t) {
|
|
|
6495
6528
|
via: "none"
|
|
6496
6529
|
};
|
|
6497
6530
|
}
|
|
6498
|
-
function
|
|
6531
|
+
function Lc(e, t, n) {
|
|
6499
6532
|
let r = new Set(n);
|
|
6500
6533
|
if (!r.size || !e || typeof e != "object") return [];
|
|
6501
6534
|
let i = [];
|
|
6502
6535
|
for (let n of t) {
|
|
6503
|
-
let t =
|
|
6536
|
+
let t = Rc(e, n);
|
|
6504
6537
|
if (Array.isArray(t)) for (let e = 0; e < t.length; e++) {
|
|
6505
6538
|
let a = t[e];
|
|
6506
6539
|
a && typeof a == "object" && typeof a.name == "string" && r.has(a.name) && i.push(`${n}.${e}`);
|
|
@@ -6508,7 +6541,7 @@ function Ic(e, t, n) {
|
|
|
6508
6541
|
}
|
|
6509
6542
|
return i;
|
|
6510
6543
|
}
|
|
6511
|
-
function
|
|
6544
|
+
function Rc(e, t) {
|
|
6512
6545
|
let n = e;
|
|
6513
6546
|
for (let e of t.split(".")) {
|
|
6514
6547
|
if (!n || typeof n != "object") return;
|
|
@@ -6516,15 +6549,15 @@ function Lc(e, t) {
|
|
|
6516
6549
|
}
|
|
6517
6550
|
return n;
|
|
6518
6551
|
}
|
|
6519
|
-
function
|
|
6552
|
+
function zc(e, t) {
|
|
6520
6553
|
return t.some((t) => e === t || e.startsWith(t + "."));
|
|
6521
6554
|
}
|
|
6522
|
-
function
|
|
6555
|
+
function Bc(e) {
|
|
6523
6556
|
let t = e ?? {}, n = /* @__PURE__ */ new Set();
|
|
6524
6557
|
if (typeof t.jsonPath == "string" && t.jsonPath && n.add(t.jsonPath), typeof t.path == "string" && t.path && n.add(t.path), t.patch && typeof t.patch.jsonPath == "string" && t.patch.jsonPath && n.add(t.patch.jsonPath), Array.isArray(t.patches)) for (let e of t.patches) e && typeof e.jsonPath == "string" && e.jsonPath && n.add(e.jsonPath);
|
|
6525
6558
|
return [...n];
|
|
6526
6559
|
}
|
|
6527
|
-
function
|
|
6560
|
+
function Vc(e) {
|
|
6528
6561
|
return {
|
|
6529
6562
|
name: "component-write-guard",
|
|
6530
6563
|
wrapToolCall: async (t, n) => {
|
|
@@ -6545,9 +6578,9 @@ function Bc(e) {
|
|
|
6545
6578
|
}
|
|
6546
6579
|
let a = e.getLocked(), o = Object.keys(a);
|
|
6547
6580
|
if (!o.length) return n(t);
|
|
6548
|
-
let s =
|
|
6581
|
+
let s = Lc(e.getBind(), e.writablePaths, o);
|
|
6549
6582
|
if (!s.length) return n(t);
|
|
6550
|
-
let c =
|
|
6583
|
+
let c = Bc(i);
|
|
6551
6584
|
if (!c.length) return e.onReject?.({
|
|
6552
6585
|
paths: ["(整体 set)"],
|
|
6553
6586
|
lockedPrefixes: s,
|
|
@@ -6556,7 +6589,7 @@ function Bc(e) {
|
|
|
6556
6589
|
content: `COMPONENT_LOCKED · 组件 [${o.join(", ")}] 正在被子 agent 修改,整体写入会触碰它们。请改用增量 patch(write({patch:{jsonPath,...}}))只写未锁定组件,或等委派结束后再整体操作。`,
|
|
6557
6590
|
status: "error"
|
|
6558
6591
|
};
|
|
6559
|
-
let l = c.filter((e) =>
|
|
6592
|
+
let l = c.filter((e) => zc(e, s));
|
|
6560
6593
|
return l.length ? (e.onReject?.({
|
|
6561
6594
|
paths: l,
|
|
6562
6595
|
lockedPrefixes: s,
|
|
@@ -6570,7 +6603,7 @@ function Bc(e) {
|
|
|
6570
6603
|
}
|
|
6571
6604
|
//#endregion
|
|
6572
6605
|
//#region src/core/sdk/htmlSubagent.ts
|
|
6573
|
-
function
|
|
6606
|
+
function Hc(e, t, n) {
|
|
6574
6607
|
let r = "html";
|
|
6575
6608
|
return `你是纯代码组件生成专家。可用工具:vfs_write / vfs_edit / vfs_rm(写/改/删代码工作副本 vfs ${e}) / vfs_read + vfs_grep(读 vfs) / validate_code(代码格式自检) / write(写 data,writablePaths 限定;set/patch 增量或整体) / read / write_todos + update_todo(规划)。
|
|
6576
6609
|
|
|
@@ -6623,7 +6656,7 @@ ${`- 输出形态:完整、自包含的 HTML 页面(.${r},可独立成页)`}
|
|
|
6623
6656
|
- 一次想清楚 → 动手 → 验证 → 收口。**思考是手段不是目的,产出代码才是**。
|
|
6624
6657
|
8. **收口格式(必守,最后一行)**:收口回复 = 简短结果总结 + **末行交接笔记** \`[note] <一句话实现要点>\` —— 关键设计决策 / 用户偏好 / 踩坑(如「[note] 液面用 height keyframes 4.2s 循环;装饰仅灯串+光斑 2 类」)。框架只识别末尾 [note] 行存进组件、自动转交下次维护该组件的子 agent;**漏写 = 下任失去交接**(真 LLM 实测漏写率 3/4,务必末行带上)。一行内,只写可复用结论。`;
|
|
6625
6658
|
}
|
|
6626
|
-
function
|
|
6659
|
+
function Uc(e, t) {
|
|
6627
6660
|
return `# HTML 完整页面生成规范
|
|
6628
6661
|
|
|
6629
6662
|
## 代码资产模型(重要)
|
|
@@ -6661,14 +6694,14 @@ function Hc(e, t) {
|
|
|
6661
6694
|
- 语义化标签(button / nav / section);图片 alt;交互可键盘聚焦
|
|
6662
6695
|
- 颜色对比达标;不只用颜色传达信息`;
|
|
6663
6696
|
}
|
|
6664
|
-
function
|
|
6697
|
+
function Wc(e = "components", t = "code") {
|
|
6665
6698
|
return {
|
|
6666
6699
|
name: "html-fragment",
|
|
6667
6700
|
description: "完整 HTML 页面生成规范:代码作为 data 资产 / vfs 工作副本 / 完整自包含可独立成页 / script+CSS 集中放置 / 可引外部 JS/CSS / validate_code 自检 / 安全底线 / 可访问性",
|
|
6668
|
-
getContent: () =>
|
|
6701
|
+
getContent: () => Uc(e, t)
|
|
6669
6702
|
};
|
|
6670
6703
|
}
|
|
6671
|
-
function
|
|
6704
|
+
function Gc(e = {}) {
|
|
6672
6705
|
let t = e.vfsPrefix ?? "html/";
|
|
6673
6706
|
return ({ state: e }) => {
|
|
6674
6707
|
let n = e.files;
|
|
@@ -6676,7 +6709,7 @@ function Wc(e = {}) {
|
|
|
6676
6709
|
let r = [];
|
|
6677
6710
|
for (let [e, i] of Object.entries(n)) {
|
|
6678
6711
|
if (!e.startsWith(t)) continue;
|
|
6679
|
-
let n =
|
|
6712
|
+
let n = xc(i.content);
|
|
6680
6713
|
for (let t of n) r.push(`${e} 第 ${t.line} 行:${t.message}(${t.code})`);
|
|
6681
6714
|
}
|
|
6682
6715
|
return r.length ? {
|
|
@@ -6685,7 +6718,7 @@ function Wc(e = {}) {
|
|
|
6685
6718
|
} : { ok: !0 };
|
|
6686
6719
|
};
|
|
6687
6720
|
}
|
|
6688
|
-
function
|
|
6721
|
+
function Kc(e) {
|
|
6689
6722
|
let n, i, a = {
|
|
6690
6723
|
name: "html-validate-tools",
|
|
6691
6724
|
beforeAgent: (e) => {
|
|
@@ -6720,7 +6753,7 @@ function Gc(e) {
|
|
|
6720
6753
|
}
|
|
6721
6754
|
let s = [];
|
|
6722
6755
|
for (let e of o) {
|
|
6723
|
-
let t =
|
|
6756
|
+
let t = xc(e.content);
|
|
6724
6757
|
t.length && s.push(`${e.path}:\n${t.map((e) => ` 第 ${e.line} 行 ${e.message}(${e.code})`).join("\n")}`);
|
|
6725
6758
|
}
|
|
6726
6759
|
return s.length ? `❌ 格式校验未通过:\n${s.join("\n")}\n请用 vfs_edit 修正后重新调用 validate_code 复查。` : `✅ 格式校验通过(${o.map((e) => e.path).join(", ")}:标签闭合等结构合法)。`;
|
|
@@ -6738,16 +6771,16 @@ function Gc(e) {
|
|
|
6738
6771
|
i = e;
|
|
6739
6772
|
}, a;
|
|
6740
6773
|
}
|
|
6741
|
-
var
|
|
6742
|
-
function
|
|
6774
|
+
var qc = 2;
|
|
6775
|
+
function Jc(e = {}) {
|
|
6743
6776
|
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, formatCheck: d = !0, codeField: f = "code", orchestratorPrompt: p = !0, craftNotes: m = !0 } = e;
|
|
6744
6777
|
if (t !== void 0 && !Array.isArray(t)) throw Error("[page-agent-sdk][createHtmlSubagent] writablePaths 须为字符串数组(代码组件 data 区,如 [\"components\"])/ 省略以从 schema 自动推断");
|
|
6745
6778
|
let h = [];
|
|
6746
|
-
a && h.push(Ta()), d && (h.push(
|
|
6779
|
+
a && h.push(Ta()), d && (h.push(Kc(n)), h.push(As({ check: Gc({ vfsPrefix: n }) })));
|
|
6747
6780
|
let g = u ?? [], _ = t?.[0] ?? "components", v = l === void 0, y = {
|
|
6748
6781
|
id: r,
|
|
6749
6782
|
description: i ?? `生成/修改纯代码组件(代码作为 data 资产,代码字段 ${f} 随 data 持久化;vfs 作工作副本;能规划(write_todos)+ 执行)。需写代码组件或灵活定制时委派`,
|
|
6750
|
-
systemPrompt:
|
|
6783
|
+
systemPrompt: Hc(n, f, _),
|
|
6751
6784
|
writablePaths: t ?? [],
|
|
6752
6785
|
allowedTools: [
|
|
6753
6786
|
"vfs_write",
|
|
@@ -6758,9 +6791,9 @@ function qc(e = {}) {
|
|
|
6758
6791
|
],
|
|
6759
6792
|
middleware: h.length ? h : void 0,
|
|
6760
6793
|
summarization: o === !1 ? void 0 : o,
|
|
6761
|
-
maxVerifyAttempts: d ?
|
|
6794
|
+
maxVerifyAttempts: d ? qc : void 0,
|
|
6762
6795
|
temperature: c,
|
|
6763
|
-
skills: v ? [
|
|
6796
|
+
skills: v ? [Wc(_, f)] : l,
|
|
6764
6797
|
maxToolRounds: s,
|
|
6765
6798
|
tools: g.length ? g : void 0,
|
|
6766
6799
|
_codeAsset: {
|
|
@@ -6773,12 +6806,12 @@ function qc(e = {}) {
|
|
|
6773
6806
|
}
|
|
6774
6807
|
};
|
|
6775
6808
|
return y._rebuildCodeAssetPaths = (e) => {
|
|
6776
|
-
y.systemPrompt =
|
|
6809
|
+
y.systemPrompt = Hc(n, f, e), v && (y.skills = [Wc(e, f)]);
|
|
6777
6810
|
}, y;
|
|
6778
6811
|
}
|
|
6779
6812
|
//#endregion
|
|
6780
6813
|
//#region src/core/sdk/defineTool.ts
|
|
6781
|
-
function
|
|
6814
|
+
function Yc(e) {
|
|
6782
6815
|
return r(async (t) => {
|
|
6783
6816
|
let n = await e.handler(t);
|
|
6784
6817
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -6790,7 +6823,7 @@ function Jc(e) {
|
|
|
6790
6823
|
}
|
|
6791
6824
|
//#endregion
|
|
6792
6825
|
//#region src/core/sdk/inspectContextTool.ts
|
|
6793
|
-
var
|
|
6826
|
+
var Xc = t.object({
|
|
6794
6827
|
path: t.string().optional().describe("分类 key 过滤(如 toolResults/history/systemPrompt/dataHint);不传=全部分类"),
|
|
6795
6828
|
role: t.enum([
|
|
6796
6829
|
"user",
|
|
@@ -6800,11 +6833,11 @@ var Yc = t.object({
|
|
|
6800
6833
|
]).optional().describe("聚焦每轮首句的角色(assistant→回复摘要,user→问题摘要);不影响工具列表"),
|
|
6801
6834
|
limit: t.number().int().min(1).max(50).optional().describe("返回最近 N 轮(默认全部;超 50 自动截最近 50 防返回过大)")
|
|
6802
6835
|
});
|
|
6803
|
-
function
|
|
6804
|
-
return
|
|
6836
|
+
function Zc(e) {
|
|
6837
|
+
return Yc({
|
|
6805
6838
|
name: "inspect_context",
|
|
6806
6839
|
description: "查看当前对话上下文的构成(供压缩决策)。返回:totalTokens(历史轮次 token 总和,与触发判断同口径)、occupancy(窗口占用比)、contextWindow、categories(分类占用)、rounds(每轮 token/工具/首句)。先调用本工具查看构成,再决定压缩策略。",
|
|
6807
|
-
schema:
|
|
6840
|
+
schema: Xc,
|
|
6808
6841
|
handler: (t) => {
|
|
6809
6842
|
let n = Ho(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) => {
|
|
6810
6843
|
let n = es(e), r = Wo(e), i = t.role === "assistant" ? e.assistantMsgs[0] ?? e.userMsg : e.userMsg, a = Uo(typeof i.content == "string" ? i.content : "", 60);
|
|
@@ -6827,7 +6860,7 @@ function Xc(e) {
|
|
|
6827
6860
|
}
|
|
6828
6861
|
//#endregion
|
|
6829
6862
|
//#region src/core/sdk/compressDecision.ts
|
|
6830
|
-
var
|
|
6863
|
+
var Qc = t.object({
|
|
6831
6864
|
keepRounds: t.number().int().min(0).max(50).optional(),
|
|
6832
6865
|
windowRatio: t.number().min(0).max(1).optional(),
|
|
6833
6866
|
summarize: t.object({ mode: t.enum(["index", "llm"]) }),
|
|
@@ -6837,23 +6870,23 @@ var Zc = t.object({
|
|
|
6837
6870
|
}).refine((e) => e.keepRounds !== void 0 || e.windowRatio !== void 0, { message: "keepRounds 与 windowRatio 至少填一个(按当前触发模式)" });
|
|
6838
6871
|
//#endregion
|
|
6839
6872
|
//#region src/core/sdk/llmResolver.ts
|
|
6840
|
-
function
|
|
6873
|
+
function $c(e) {
|
|
6841
6874
|
let t = e.find((e) => e.role === "user");
|
|
6842
6875
|
if (!t) return;
|
|
6843
6876
|
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, " ");
|
|
6844
6877
|
if (r) return r.length > 30 ? r.slice(0, 30) + "…" : r;
|
|
6845
6878
|
}
|
|
6846
|
-
function
|
|
6879
|
+
function el(e) {
|
|
6847
6880
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
6848
6881
|
}
|
|
6849
|
-
function
|
|
6882
|
+
function tl(e) {
|
|
6850
6883
|
let t = e.content;
|
|
6851
6884
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
6852
6885
|
}
|
|
6853
|
-
function
|
|
6886
|
+
function nl(e) {
|
|
6854
6887
|
let t = e.summaryLlm ?? e.llm;
|
|
6855
6888
|
if (!t) return;
|
|
6856
|
-
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s =
|
|
6889
|
+
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s = el(t) ? t : null, c = el(t) ? null : t;
|
|
6857
6890
|
if (c && !c.apiKey) {
|
|
6858
6891
|
e.summaryLlm && console.warn("[page-agent-sdk][summarization] summaryLlm 已配置但缺 apiKey,摘要回退主 agent 模型或零成本索引摘要");
|
|
6859
6892
|
return;
|
|
@@ -6865,36 +6898,38 @@ function tl(e) {
|
|
|
6865
6898
|
return !l && c && (l = await m(c, {
|
|
6866
6899
|
temperature: n,
|
|
6867
6900
|
maxTokens: r
|
|
6868
|
-
})),
|
|
6901
|
+
})), tl(await l.invoke([new o("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new a(e)], { signal: t.signal })).trim();
|
|
6869
6902
|
} finally {
|
|
6870
6903
|
clearTimeout(s);
|
|
6871
6904
|
}
|
|
6872
6905
|
};
|
|
6873
6906
|
}
|
|
6874
|
-
function
|
|
6907
|
+
function rl(e) {
|
|
6875
6908
|
let t = e.titleLlm ?? e.summaryLlm ?? e.llm;
|
|
6876
6909
|
if (!t) return;
|
|
6877
|
-
let n =
|
|
6910
|
+
let n = el(t) ? t : null, r = el(t) ? null : t;
|
|
6878
6911
|
if (r && !r.apiKey) return;
|
|
6879
6912
|
let i = n;
|
|
6880
|
-
return async (
|
|
6881
|
-
let
|
|
6913
|
+
return async (t) => {
|
|
6914
|
+
let n = t.filter((e) => e.role === "user" || e.role === "assistant").map((e) => `${e.role === "user" ? "用户" : "助手"}: ${e.content}`).join("\n").slice(0, 800), s = new AbortController(), c = setTimeout(() => s.abort(), 1e4);
|
|
6882
6915
|
try {
|
|
6883
|
-
|
|
6916
|
+
!i && r && (i = await m(r, {
|
|
6884
6917
|
temperature: 0,
|
|
6885
6918
|
maxTokens: 30
|
|
6886
|
-
}))
|
|
6919
|
+
}));
|
|
6920
|
+
let t = await i.invoke([new o(e.dialog?.locale === "en-US" ? "Generate a short English title (max 10 words) summarizing the conversation below. Output the title text only, no quotes or punctuation." : "根据以下对话的主旨,生成一个简短的中文标题(不超过15个字,不要标点和引号,直接输出标题文字)。"), new a(n)], { signal: s.signal }), c = e.dialog?.locale === "en-US" ? 60 : 20;
|
|
6921
|
+
return tl(t).trim().replace(/^["'""「『]|["'""」』]$/g, "").split("\n")[0].slice(0, c);
|
|
6887
6922
|
} catch {
|
|
6888
6923
|
return "";
|
|
6889
6924
|
} finally {
|
|
6890
|
-
clearTimeout(
|
|
6925
|
+
clearTimeout(c);
|
|
6891
6926
|
}
|
|
6892
6927
|
};
|
|
6893
6928
|
}
|
|
6894
|
-
function
|
|
6929
|
+
function il() {
|
|
6895
6930
|
return `call_dec_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
6896
6931
|
}
|
|
6897
|
-
function
|
|
6932
|
+
function al(e) {
|
|
6898
6933
|
let t = e.match(/```(?:json)?\s*([\s\S]*?)```/), n = t ? t[1] : e, r = n.indexOf("{"), i = n.lastIndexOf("}");
|
|
6899
6934
|
if (r < 0 || i < 0 || i <= r) return null;
|
|
6900
6935
|
try {
|
|
@@ -6903,21 +6938,21 @@ function il(e) {
|
|
|
6903
6938
|
return null;
|
|
6904
6939
|
}
|
|
6905
6940
|
}
|
|
6906
|
-
function
|
|
6941
|
+
function ol(e) {
|
|
6907
6942
|
if (!e) return null;
|
|
6908
|
-
let t =
|
|
6943
|
+
let t = al(e);
|
|
6909
6944
|
if (t == null) return null;
|
|
6910
|
-
let n =
|
|
6945
|
+
let n = Qc.safeParse(t);
|
|
6911
6946
|
return n.success ? n.data : null;
|
|
6912
6947
|
}
|
|
6913
|
-
async function
|
|
6948
|
+
async function sl(e, t, n, r) {
|
|
6914
6949
|
let i = [...n];
|
|
6915
6950
|
for (let n = 0; n < 3; n++) {
|
|
6916
6951
|
let n = await e.invoke(i, { signal: r }), a = n?.tool_calls ?? [];
|
|
6917
|
-
if (!a.length) return
|
|
6952
|
+
if (!a.length) return tl(n).trim();
|
|
6918
6953
|
i = [...i, n];
|
|
6919
6954
|
for (let e of a) {
|
|
6920
|
-
let n = e.id ??
|
|
6955
|
+
let n = e.id ?? il();
|
|
6921
6956
|
try {
|
|
6922
6957
|
let r = await t.invoke(e.args ?? {}), a = typeof r == "string" ? r : r?.content ?? JSON.stringify(r);
|
|
6923
6958
|
i = [...i, new s({
|
|
@@ -6934,10 +6969,10 @@ async function ol(e, t, n, r) {
|
|
|
6934
6969
|
}
|
|
6935
6970
|
return "";
|
|
6936
6971
|
}
|
|
6937
|
-
function
|
|
6972
|
+
function cl(e) {
|
|
6938
6973
|
let t = e.summaryLlm ?? e.llm;
|
|
6939
6974
|
if (!t) return;
|
|
6940
|
-
let n =
|
|
6975
|
+
let n = el(t) ? t : null, r = el(t) ? null : t;
|
|
6941
6976
|
if (r && !r.apiKey) return;
|
|
6942
6977
|
let i = e.decisionTimeoutMs ?? 6e3, s = e.decisionMaxTokens ?? 2048, c = n;
|
|
6943
6978
|
return async (e) => {
|
|
@@ -6949,12 +6984,12 @@ function sl(e) {
|
|
|
6949
6984
|
}));
|
|
6950
6985
|
let n = c;
|
|
6951
6986
|
if (typeof n.bindTools != "function") return null;
|
|
6952
|
-
let i =
|
|
6987
|
+
let i = Zc({
|
|
6953
6988
|
getMessages: e.getMessages,
|
|
6954
6989
|
getSnapshot: e.getSnapshot,
|
|
6955
6990
|
contextWindow: e.contextWindow
|
|
6956
6991
|
}), 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)。`)];
|
|
6957
|
-
return
|
|
6992
|
+
return ol(await sl(l, i, d, t.signal)) || ol(await sl(l, i, [...d, new a("上一次输出无效(JSON 解析失败或 schema 校验不通过)。请只输出符合 schema 的压缩决策 JSON,不要多余文字/markdown 代码块。")], t.signal));
|
|
6958
6993
|
} catch {
|
|
6959
6994
|
return null;
|
|
6960
6995
|
} finally {
|
|
@@ -6962,22 +6997,22 @@ function sl(e) {
|
|
|
6962
6997
|
}
|
|
6963
6998
|
};
|
|
6964
6999
|
}
|
|
6965
|
-
function
|
|
6966
|
-
let t = e.llm, n =
|
|
7000
|
+
function ll(e) {
|
|
7001
|
+
let t = e.llm, n = el(e.llm) ? void 0 : e.llm;
|
|
6967
7002
|
return {
|
|
6968
7003
|
modelCaps: oi({
|
|
6969
7004
|
model: n?.model ?? t?.model ?? t?.modelName,
|
|
6970
7005
|
contextWindow: e.contextWindow ?? n?.contextWindow ?? t?.contextWindow,
|
|
6971
7006
|
maxOutputTokens: e.maxOutputTokens ?? n?.maxOutputTokens ?? t?.maxOutputTokens
|
|
6972
7007
|
}),
|
|
6973
|
-
summaryLlmInvoke:
|
|
6974
|
-
titleLlmInvoke:
|
|
6975
|
-
compressDecisionInvoke:
|
|
7008
|
+
summaryLlmInvoke: nl(e),
|
|
7009
|
+
titleLlmInvoke: rl(e),
|
|
7010
|
+
compressDecisionInvoke: cl(e)
|
|
6976
7011
|
};
|
|
6977
7012
|
}
|
|
6978
7013
|
//#endregion
|
|
6979
7014
|
//#region src/core/sdk/conflictManager.ts
|
|
6980
|
-
function
|
|
7015
|
+
function ul(e) {
|
|
6981
7016
|
let t = /* @__PURE__ */ At(null), n = 0;
|
|
6982
7017
|
function r(r) {
|
|
6983
7018
|
return new Promise((i) => {
|
|
@@ -7008,7 +7043,7 @@ function ll(e) {
|
|
|
7008
7043
|
}
|
|
7009
7044
|
//#endregion
|
|
7010
7045
|
//#region src/core/utils/id.ts
|
|
7011
|
-
function
|
|
7046
|
+
function dl() {
|
|
7012
7047
|
try {
|
|
7013
7048
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
7014
7049
|
} catch {}
|
|
@@ -7016,7 +7051,7 @@ function ul() {
|
|
|
7016
7051
|
}
|
|
7017
7052
|
//#endregion
|
|
7018
7053
|
//#region src/core/backends/storage.ts
|
|
7019
|
-
var
|
|
7054
|
+
var fl = "chat-sdk", pl = 50 * 1024 * 1024, ml = 4 * 1024 * 1024, hl = 10 * 1024 * 1024, gl = .9, _l = 500, vl = 300, yl = "__meta__", bl = "v:1", xl = [
|
|
7020
7055
|
"messages",
|
|
7021
7056
|
"vfs",
|
|
7022
7057
|
"todos",
|
|
@@ -7027,51 +7062,51 @@ var dl = "chat-sdk", fl = 50 * 1024 * 1024, pl = 4 * 1024 * 1024, ml = 10 * 1024
|
|
|
7027
7062
|
"workingMemory",
|
|
7028
7063
|
"focus"
|
|
7029
7064
|
];
|
|
7030
|
-
function xl(e) {
|
|
7031
|
-
return e === "local" || e === "session" ? pl : fl;
|
|
7032
|
-
}
|
|
7033
7065
|
function Sl(e) {
|
|
7066
|
+
return e === "local" || e === "session" ? ml : pl;
|
|
7067
|
+
}
|
|
7068
|
+
function Cl(e) {
|
|
7034
7069
|
if (typeof e != "object" || !e) return !1;
|
|
7035
7070
|
let t = e;
|
|
7036
7071
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
7037
7072
|
}
|
|
7038
|
-
function
|
|
7073
|
+
function wl(e, t, n, r) {
|
|
7039
7074
|
return [
|
|
7040
|
-
|
|
7075
|
+
bl,
|
|
7041
7076
|
e,
|
|
7042
7077
|
t,
|
|
7043
7078
|
n,
|
|
7044
7079
|
r
|
|
7045
7080
|
].join("::");
|
|
7046
7081
|
}
|
|
7047
|
-
function
|
|
7082
|
+
function Tl(e, t, n) {
|
|
7048
7083
|
return [
|
|
7049
|
-
|
|
7084
|
+
bl,
|
|
7050
7085
|
e,
|
|
7051
7086
|
t,
|
|
7052
7087
|
n
|
|
7053
7088
|
].join("::") + "::";
|
|
7054
7089
|
}
|
|
7055
|
-
function
|
|
7090
|
+
function El(e, t) {
|
|
7056
7091
|
return [
|
|
7057
|
-
|
|
7092
|
+
bl,
|
|
7058
7093
|
e,
|
|
7059
7094
|
t
|
|
7060
7095
|
].join("::") + "::";
|
|
7061
7096
|
}
|
|
7062
|
-
function
|
|
7063
|
-
return [
|
|
7097
|
+
function Dl(e) {
|
|
7098
|
+
return [bl, e].join("::") + "::";
|
|
7064
7099
|
}
|
|
7065
|
-
var
|
|
7066
|
-
function
|
|
7067
|
-
|
|
7100
|
+
var Ol = null;
|
|
7101
|
+
function kl(e) {
|
|
7102
|
+
Ol ||= new TextEncoder();
|
|
7068
7103
|
try {
|
|
7069
|
-
return
|
|
7104
|
+
return Ol.encode(JSON.stringify(e)).length;
|
|
7070
7105
|
} catch {
|
|
7071
7106
|
return 0;
|
|
7072
7107
|
}
|
|
7073
7108
|
}
|
|
7074
|
-
function
|
|
7109
|
+
function Al(e, t, n) {
|
|
7075
7110
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
7076
7111
|
if (r <= t) return [];
|
|
7077
7112
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -7081,7 +7116,7 @@ function kl(e, t, n) {
|
|
|
7081
7116
|
}
|
|
7082
7117
|
return o;
|
|
7083
7118
|
}
|
|
7084
|
-
function
|
|
7119
|
+
function jl() {
|
|
7085
7120
|
let e = /* @__PURE__ */ new Map();
|
|
7086
7121
|
return {
|
|
7087
7122
|
async get(t) {
|
|
@@ -7101,7 +7136,7 @@ function Al() {
|
|
|
7101
7136
|
}
|
|
7102
7137
|
};
|
|
7103
7138
|
}
|
|
7104
|
-
function
|
|
7139
|
+
function Ml(e) {
|
|
7105
7140
|
return new Promise((t, n) => {
|
|
7106
7141
|
if (typeof indexedDB > "u") {
|
|
7107
7142
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -7162,7 +7197,7 @@ function jl(e) {
|
|
|
7162
7197
|
}, r.onerror = () => n(r.error);
|
|
7163
7198
|
});
|
|
7164
7199
|
}
|
|
7165
|
-
function
|
|
7200
|
+
function Nl(e) {
|
|
7166
7201
|
return {
|
|
7167
7202
|
async get(t) {
|
|
7168
7203
|
let n = e.getItem(t);
|
|
@@ -7207,12 +7242,12 @@ function Ml(e) {
|
|
|
7207
7242
|
}
|
|
7208
7243
|
};
|
|
7209
7244
|
}
|
|
7210
|
-
function
|
|
7245
|
+
function Pl(e, t, n) {
|
|
7211
7246
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
7212
7247
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
7213
7248
|
}
|
|
7214
|
-
function
|
|
7215
|
-
let t = e.dbName ??
|
|
7249
|
+
function Fl(e = {}) {
|
|
7250
|
+
let t = e.dbName ?? fl, n = e.backend ?? "indexed", r = e.maxBytes ?? Sl(n), i = e.maxBytesPerSession ?? hl, a = e.evictionWatermark ?? gl, o = e.debounceMs ?? _l, s = /* @__PURE__ */ new Set();
|
|
7216
7251
|
function c(e) {
|
|
7217
7252
|
for (let t of s) try {
|
|
7218
7253
|
t(e);
|
|
@@ -7225,16 +7260,16 @@ function Pl(e = {}) {
|
|
|
7225
7260
|
try {
|
|
7226
7261
|
if (n === "indexed") {
|
|
7227
7262
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
7228
|
-
l = await
|
|
7263
|
+
l = await Ml(t), d(!0);
|
|
7229
7264
|
} else if (n === "session") {
|
|
7230
7265
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
7231
|
-
l =
|
|
7266
|
+
l = Nl(sessionStorage), d(!0);
|
|
7232
7267
|
} else if (n === "local") {
|
|
7233
7268
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
7234
|
-
l =
|
|
7235
|
-
} else l =
|
|
7269
|
+
l = Nl(localStorage), d(!0);
|
|
7270
|
+
} else l = jl(), d(!1);
|
|
7236
7271
|
} catch (e) {
|
|
7237
|
-
l =
|
|
7272
|
+
l = jl();
|
|
7238
7273
|
let t = e instanceof Error ? e.message : String(e);
|
|
7239
7274
|
d(!1), Promise.resolve().then(() => c({
|
|
7240
7275
|
type: "degraded",
|
|
@@ -7244,10 +7279,10 @@ function Pl(e = {}) {
|
|
|
7244
7279
|
})();
|
|
7245
7280
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
7246
7281
|
function g(e, n, r, a) {
|
|
7247
|
-
let o =
|
|
7248
|
-
return
|
|
7282
|
+
let o = wl(t, r, a, yl);
|
|
7283
|
+
return Pl(h, o, async () => {
|
|
7249
7284
|
let t = async () => {
|
|
7250
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
7285
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : kl(s), d = kl(n), f = (t?.bytes ?? 0) + (d - u);
|
|
7251
7286
|
if (f > i) {
|
|
7252
7287
|
c({
|
|
7253
7288
|
type: "quota",
|
|
@@ -7269,12 +7304,12 @@ function Pl(e = {}) {
|
|
|
7269
7304
|
try {
|
|
7270
7305
|
await t();
|
|
7271
7306
|
} catch (e) {
|
|
7272
|
-
if (
|
|
7307
|
+
if (Cl(e) && !u) {
|
|
7273
7308
|
u = !0;
|
|
7274
7309
|
try {
|
|
7275
7310
|
await b();
|
|
7276
7311
|
} catch {}
|
|
7277
|
-
l =
|
|
7312
|
+
l = jl(), Promise.resolve().then(() => c({
|
|
7278
7313
|
type: "degraded",
|
|
7279
7314
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
7280
7315
|
}));
|
|
@@ -7286,7 +7321,7 @@ function Pl(e = {}) {
|
|
|
7286
7321
|
});
|
|
7287
7322
|
}
|
|
7288
7323
|
function _(e, n, r, i) {
|
|
7289
|
-
let a =
|
|
7324
|
+
let a = wl(t, e, n, r), s = p.get(a);
|
|
7290
7325
|
s && s.resolve();
|
|
7291
7326
|
let c = m.get(a);
|
|
7292
7327
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -7313,15 +7348,15 @@ function Pl(e = {}) {
|
|
|
7313
7348
|
function y() {
|
|
7314
7349
|
v ||= setTimeout(() => {
|
|
7315
7350
|
v = null, b();
|
|
7316
|
-
},
|
|
7351
|
+
}, vl);
|
|
7317
7352
|
}
|
|
7318
7353
|
async function b() {
|
|
7319
7354
|
let e = [];
|
|
7320
|
-
await l.scan(
|
|
7355
|
+
await l.scan(Dl(t), (t, n) => {
|
|
7321
7356
|
t.endsWith("::__meta__") && e.push(n);
|
|
7322
7357
|
});
|
|
7323
|
-
let n =
|
|
7324
|
-
for (let e of n) await l.clearPrefix(
|
|
7358
|
+
let n = Al(e, r, a);
|
|
7359
|
+
for (let e of n) await l.clearPrefix(Tl(t, e.agentId, e.sessionId)), c({
|
|
7325
7360
|
type: "evicted",
|
|
7326
7361
|
agentId: e.agentId,
|
|
7327
7362
|
sessionId: e.sessionId,
|
|
@@ -7332,13 +7367,13 @@ function Pl(e = {}) {
|
|
|
7332
7367
|
ready: f,
|
|
7333
7368
|
async listSessions(e) {
|
|
7334
7369
|
let n = [];
|
|
7335
|
-
return await l.scan(
|
|
7370
|
+
return await l.scan(El(t, e), (e, t) => {
|
|
7336
7371
|
e.endsWith("::__meta__") && n.push(t);
|
|
7337
7372
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
7338
7373
|
},
|
|
7339
7374
|
async load(e, n) {
|
|
7340
|
-
let r =
|
|
7341
|
-
return await
|
|
7375
|
+
let r = wl(t, e, n, yl);
|
|
7376
|
+
return await Pl(h, r, async () => {
|
|
7342
7377
|
let i = await l.get(r);
|
|
7343
7378
|
if (!i) return;
|
|
7344
7379
|
let a = {
|
|
@@ -7347,8 +7382,8 @@ function Pl(e = {}) {
|
|
|
7347
7382
|
todos: [],
|
|
7348
7383
|
memory: ""
|
|
7349
7384
|
};
|
|
7350
|
-
for (let r of
|
|
7351
|
-
let i = await l.get(
|
|
7385
|
+
for (let r of xl) {
|
|
7386
|
+
let i = await l.get(wl(t, e, n, r));
|
|
7352
7387
|
i != null && (a[r] = i);
|
|
7353
7388
|
}
|
|
7354
7389
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -7356,12 +7391,12 @@ function Pl(e = {}) {
|
|
|
7356
7391
|
},
|
|
7357
7392
|
async save(e, t, n) {
|
|
7358
7393
|
let r = [];
|
|
7359
|
-
for (let i of
|
|
7394
|
+
for (let i of xl) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
7360
7395
|
await Promise.all(r);
|
|
7361
7396
|
},
|
|
7362
7397
|
async updateTitle(e, n, r) {
|
|
7363
|
-
let i =
|
|
7364
|
-
return
|
|
7398
|
+
let i = wl(t, e, n, yl);
|
|
7399
|
+
return Pl(h, i, async () => {
|
|
7365
7400
|
let e = await l.get(i);
|
|
7366
7401
|
e && (e.title = r, e.lastAccessed = Date.now(), await l.set(i, e));
|
|
7367
7402
|
});
|
|
@@ -7377,13 +7412,13 @@ function Pl(e = {}) {
|
|
|
7377
7412
|
})), c({ type: "flush" }), await b();
|
|
7378
7413
|
},
|
|
7379
7414
|
async deleteSession(e, n) {
|
|
7380
|
-
let r =
|
|
7415
|
+
let r = Tl(t, e, n);
|
|
7381
7416
|
for (let [e, t] of p.entries()) e.startsWith(r) && (t.resolve(), p.delete(e));
|
|
7382
7417
|
for (let [e, t] of m.entries()) e.startsWith(r) && (clearTimeout(t), m.delete(e));
|
|
7383
7418
|
await l.clearPrefix(r);
|
|
7384
7419
|
},
|
|
7385
7420
|
async createSession(e, n, r) {
|
|
7386
|
-
let i = r ??
|
|
7421
|
+
let i = r ?? dl(), a = Date.now(), o = {
|
|
7387
7422
|
agentId: e,
|
|
7388
7423
|
sessionId: i,
|
|
7389
7424
|
createdAt: a,
|
|
@@ -7391,7 +7426,7 @@ function Pl(e = {}) {
|
|
|
7391
7426
|
bytes: 0,
|
|
7392
7427
|
title: n
|
|
7393
7428
|
};
|
|
7394
|
-
return await l.set(
|
|
7429
|
+
return await l.set(wl(t, e, i, yl), o), i;
|
|
7395
7430
|
},
|
|
7396
7431
|
onEvent(e) {
|
|
7397
7432
|
s.add(e);
|
|
@@ -7406,15 +7441,15 @@ function Pl(e = {}) {
|
|
|
7406
7441
|
}
|
|
7407
7442
|
//#endregion
|
|
7408
7443
|
//#region src/core/sdk/optionsResolver.ts
|
|
7409
|
-
function Fl(e) {
|
|
7410
|
-
return e === void 0 ? Pl({ backend: "memory" }) : e === !1 ? null : typeof e == "string" ? Pl({ backend: e }) : e.enabled === !1 ? null : Pl(e);
|
|
7411
|
-
}
|
|
7412
7444
|
function Il(e) {
|
|
7445
|
+
return e === void 0 ? Fl({ backend: "memory" }) : e === !1 ? null : typeof e == "string" ? Fl({ backend: e }) : e.enabled === !1 ? null : Fl(e);
|
|
7446
|
+
}
|
|
7447
|
+
function Ll(e) {
|
|
7413
7448
|
return e.dialog ?? {};
|
|
7414
7449
|
}
|
|
7415
7450
|
//#endregion
|
|
7416
7451
|
//#region src/core/capabilities.ts
|
|
7417
|
-
var
|
|
7452
|
+
var Rl = [
|
|
7418
7453
|
{
|
|
7419
7454
|
name: "dataOps",
|
|
7420
7455
|
defaultOn: !0
|
|
@@ -7503,13 +7538,13 @@ var Ll = [
|
|
|
7503
7538
|
requires: ["summarization"]
|
|
7504
7539
|
}
|
|
7505
7540
|
];
|
|
7506
|
-
function
|
|
7541
|
+
function zl(e) {
|
|
7507
7542
|
let t = {};
|
|
7508
|
-
for (let n of
|
|
7543
|
+
for (let n of Rl) {
|
|
7509
7544
|
let r = e?.[n.name];
|
|
7510
7545
|
t[n.name] = n.defaultOn ? r !== !1 : r === !0;
|
|
7511
7546
|
}
|
|
7512
|
-
for (let e of
|
|
7547
|
+
for (let e of Rl) if (e.requires && t[e.name]) {
|
|
7513
7548
|
for (let n of e.requires) if (!t[n]) {
|
|
7514
7549
|
t[e.name] = !1;
|
|
7515
7550
|
break;
|
|
@@ -7519,7 +7554,7 @@ function Rl(e) {
|
|
|
7519
7554
|
}
|
|
7520
7555
|
//#endregion
|
|
7521
7556
|
//#region src/core/sdk/events.ts
|
|
7522
|
-
function
|
|
7557
|
+
function Bl(e) {
|
|
7523
7558
|
let t = /* @__PURE__ */ new Set(), n = (n) => {
|
|
7524
7559
|
if (n.type !== "approval_request") {
|
|
7525
7560
|
if (e) try {
|
|
@@ -7545,7 +7580,7 @@ function zl(e) {
|
|
|
7545
7580
|
}
|
|
7546
7581
|
//#endregion
|
|
7547
7582
|
//#region src/core/sdk/contextPreset.ts
|
|
7548
|
-
var
|
|
7583
|
+
var Vl = {
|
|
7549
7584
|
auto: {
|
|
7550
7585
|
summaryThresholdRatio: .5,
|
|
7551
7586
|
windowRatio: .4,
|
|
@@ -7573,7 +7608,7 @@ var Bl = {
|
|
|
7573
7608
|
enableRecall: !0,
|
|
7574
7609
|
enableLLMSummary: !0
|
|
7575
7610
|
}
|
|
7576
|
-
},
|
|
7611
|
+
}, Hl = {
|
|
7577
7612
|
auto: ["describe_data", "read"],
|
|
7578
7613
|
conservative: ["describe_data"],
|
|
7579
7614
|
aggressive: ["describe_data", "read"],
|
|
@@ -7584,8 +7619,8 @@ var Bl = {
|
|
|
7584
7619
|
"search_data"
|
|
7585
7620
|
]
|
|
7586
7621
|
};
|
|
7587
|
-
function
|
|
7588
|
-
let n =
|
|
7622
|
+
function Ul(e, t) {
|
|
7623
|
+
let n = Vl[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
7589
7624
|
return {
|
|
7590
7625
|
...n,
|
|
7591
7626
|
...r,
|
|
@@ -7595,7 +7630,7 @@ function Hl(e, t) {
|
|
|
7595
7630
|
}
|
|
7596
7631
|
//#endregion
|
|
7597
7632
|
//#region src/core/sdk/middlewareStack.ts
|
|
7598
|
-
var
|
|
7633
|
+
var Wl = {
|
|
7599
7634
|
dataHint: 10,
|
|
7600
7635
|
usageHints: 20,
|
|
7601
7636
|
todos: 30,
|
|
@@ -7612,17 +7647,17 @@ var Ul = {
|
|
|
7612
7647
|
subagents: 140,
|
|
7613
7648
|
augmentSystem: 150
|
|
7614
7649
|
};
|
|
7615
|
-
function
|
|
7650
|
+
function Gl(e) {
|
|
7616
7651
|
return e.map((e, t) => ({
|
|
7617
7652
|
m: e,
|
|
7618
7653
|
i: t,
|
|
7619
|
-
p:
|
|
7654
|
+
p: Wl[e.name] ?? Infinity
|
|
7620
7655
|
})).sort((e, t) => e.p - t.p || e.i - t.i).map((e) => e.m);
|
|
7621
7656
|
}
|
|
7622
7657
|
//#endregion
|
|
7623
7658
|
//#region src/core/tools/dataSlotQuery.ts
|
|
7624
|
-
var
|
|
7625
|
-
function
|
|
7659
|
+
var Kl = /[\w$-]/;
|
|
7660
|
+
function ql(e) {
|
|
7626
7661
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
7627
7662
|
for (; r < n.length;) {
|
|
7628
7663
|
let e = n[r];
|
|
@@ -7633,7 +7668,7 @@ function Kl(e) {
|
|
|
7633
7668
|
continue;
|
|
7634
7669
|
}
|
|
7635
7670
|
let e = "";
|
|
7636
|
-
for (; r < n.length &&
|
|
7671
|
+
for (; r < n.length && Kl.test(n[r]);) e += n[r++];
|
|
7637
7672
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
7638
7673
|
t.push({
|
|
7639
7674
|
type: "descendKey",
|
|
@@ -7646,7 +7681,7 @@ function Kl(e) {
|
|
|
7646
7681
|
continue;
|
|
7647
7682
|
}
|
|
7648
7683
|
let e = "";
|
|
7649
|
-
for (; r < n.length &&
|
|
7684
|
+
for (; r < n.length && Kl.test(n[r]);) e += n[r++];
|
|
7650
7685
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
7651
7686
|
t.push({
|
|
7652
7687
|
type: "key",
|
|
@@ -7702,7 +7737,7 @@ function Kl(e) {
|
|
|
7702
7737
|
}
|
|
7703
7738
|
return t;
|
|
7704
7739
|
}
|
|
7705
|
-
function
|
|
7740
|
+
function Jl(e) {
|
|
7706
7741
|
let t = [], n = 0, r = e.trim();
|
|
7707
7742
|
for (; n < r.length;) {
|
|
7708
7743
|
let e = r[n];
|
|
@@ -7747,7 +7782,7 @@ function ql(e) {
|
|
|
7747
7782
|
}
|
|
7748
7783
|
return t;
|
|
7749
7784
|
}
|
|
7750
|
-
var
|
|
7785
|
+
var Yl = class {
|
|
7751
7786
|
toks;
|
|
7752
7787
|
item;
|
|
7753
7788
|
pos = 0;
|
|
@@ -7783,12 +7818,12 @@ var Jl = class {
|
|
|
7783
7818
|
return this.next(), e;
|
|
7784
7819
|
}
|
|
7785
7820
|
let e = this.operand(), t = this.peek();
|
|
7786
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
7821
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), Ql(t, e, this.operand())) : Xl(e);
|
|
7787
7822
|
}
|
|
7788
7823
|
operand() {
|
|
7789
7824
|
let e = this.next();
|
|
7790
7825
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
7791
|
-
if (e.startsWith("@")) return
|
|
7826
|
+
if (e.startsWith("@")) return Zl(e, this.item);
|
|
7792
7827
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
7793
7828
|
if (e === "true") return !0;
|
|
7794
7829
|
if (e === "false") return !1;
|
|
@@ -7798,10 +7833,10 @@ var Jl = class {
|
|
|
7798
7833
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
7799
7834
|
}
|
|
7800
7835
|
};
|
|
7801
|
-
function
|
|
7836
|
+
function Xl(e) {
|
|
7802
7837
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
7803
7838
|
}
|
|
7804
|
-
function
|
|
7839
|
+
function Zl(e, t) {
|
|
7805
7840
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
7806
7841
|
for (let e of n) {
|
|
7807
7842
|
if (typeof r != "object" || !r) return;
|
|
@@ -7809,7 +7844,7 @@ function Xl(e, t) {
|
|
|
7809
7844
|
}
|
|
7810
7845
|
return r;
|
|
7811
7846
|
}
|
|
7812
|
-
function
|
|
7847
|
+
function Ql(e, t, n) {
|
|
7813
7848
|
switch (e) {
|
|
7814
7849
|
case "==": return t === n;
|
|
7815
7850
|
case "!=": return t !== n;
|
|
@@ -7820,47 +7855,47 @@ function Zl(e, t, n) {
|
|
|
7820
7855
|
default: return !1;
|
|
7821
7856
|
}
|
|
7822
7857
|
}
|
|
7823
|
-
function Ql(e, t) {
|
|
7824
|
-
return new Jl(ql(e), t).parse();
|
|
7825
|
-
}
|
|
7826
7858
|
function $l(e, t) {
|
|
7827
|
-
return
|
|
7859
|
+
return new Yl(Jl(e), t).parse();
|
|
7828
7860
|
}
|
|
7829
7861
|
function eu(e, t) {
|
|
7862
|
+
return e ? `${e}.${t}` : String(t);
|
|
7863
|
+
}
|
|
7864
|
+
function tu(e, t) {
|
|
7830
7865
|
let n = [{
|
|
7831
7866
|
path: "",
|
|
7832
7867
|
value: e
|
|
7833
7868
|
}];
|
|
7834
|
-
for (let e of
|
|
7869
|
+
for (let e of ql(t)) {
|
|
7835
7870
|
let t = [];
|
|
7836
7871
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
7837
|
-
path:
|
|
7872
|
+
path: eu(r.path, e.key),
|
|
7838
7873
|
value: r.value[e.key]
|
|
7839
7874
|
});
|
|
7840
7875
|
else if (e.type === "index") {
|
|
7841
7876
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
7842
7877
|
let n = r.value[e.index];
|
|
7843
7878
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
7844
|
-
path:
|
|
7879
|
+
path: eu(r.path, e.index),
|
|
7845
7880
|
value: n,
|
|
7846
7881
|
index: e.index
|
|
7847
7882
|
});
|
|
7848
7883
|
}
|
|
7849
7884
|
} else if (e.type === "wildcard") {
|
|
7850
7885
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
7851
|
-
path:
|
|
7886
|
+
path: eu(e.path, r),
|
|
7852
7887
|
value: n,
|
|
7853
7888
|
index: r
|
|
7854
7889
|
}));
|
|
7855
7890
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
7856
|
-
path:
|
|
7891
|
+
path: eu(e.path, n),
|
|
7857
7892
|
value: e.value[n]
|
|
7858
7893
|
});
|
|
7859
7894
|
} else if (e.type === "descendKey") {
|
|
7860
7895
|
let r = e.key, i = (e) => {
|
|
7861
7896
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
7862
7897
|
let a = {
|
|
7863
|
-
path:
|
|
7898
|
+
path: eu(e.path, n),
|
|
7864
7899
|
value: e.value[n]
|
|
7865
7900
|
};
|
|
7866
7901
|
n === r && t.push(a), i(a);
|
|
@@ -7871,7 +7906,7 @@ function eu(e, t) {
|
|
|
7871
7906
|
let e = (n) => {
|
|
7872
7907
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
7873
7908
|
let i = {
|
|
7874
|
-
path:
|
|
7909
|
+
path: eu(n.path, r),
|
|
7875
7910
|
value: n.value[r]
|
|
7876
7911
|
};
|
|
7877
7912
|
t.push(i), e(i);
|
|
@@ -7880,16 +7915,16 @@ function eu(e, t) {
|
|
|
7880
7915
|
for (let t of n) e(t);
|
|
7881
7916
|
} else if (e.type === "filter") {
|
|
7882
7917
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
7883
|
-
|
|
7884
|
-
path:
|
|
7918
|
+
$l(e.filter, n) && t.push({
|
|
7919
|
+
path: eu(r.path, i),
|
|
7885
7920
|
value: n,
|
|
7886
7921
|
index: i
|
|
7887
7922
|
});
|
|
7888
7923
|
});
|
|
7889
7924
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
7890
7925
|
let i = r.value[n];
|
|
7891
|
-
|
|
7892
|
-
path:
|
|
7926
|
+
$l(e.filter, i) && t.push({
|
|
7927
|
+
path: eu(r.path, n),
|
|
7893
7928
|
value: i
|
|
7894
7929
|
});
|
|
7895
7930
|
}
|
|
@@ -7898,7 +7933,7 @@ function eu(e, t) {
|
|
|
7898
7933
|
}
|
|
7899
7934
|
return n;
|
|
7900
7935
|
}
|
|
7901
|
-
function
|
|
7936
|
+
function nu(e, t) {
|
|
7902
7937
|
let n = e.length, r = t.length;
|
|
7903
7938
|
if (!n) return r;
|
|
7904
7939
|
if (!r) return n;
|
|
@@ -7914,7 +7949,7 @@ function tu(e, t) {
|
|
|
7914
7949
|
}
|
|
7915
7950
|
return i[r];
|
|
7916
7951
|
}
|
|
7917
|
-
function
|
|
7952
|
+
function ru(e, t, n = {}) {
|
|
7918
7953
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
7919
7954
|
if (r === "regex") try {
|
|
7920
7955
|
s = new RegExp(t, "i");
|
|
@@ -7924,11 +7959,11 @@ function nu(e, t, n = {}) {
|
|
|
7924
7959
|
let c = (e, l, u) => {
|
|
7925
7960
|
if (o.length >= i || e == null) return;
|
|
7926
7961
|
if (typeof e == "object") {
|
|
7927
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
7928
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
7962
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, eu(l, t), String(t)));
|
|
7963
|
+
else for (let t of Object.keys(e)) c(e[t], eu(l, t), t);
|
|
7929
7964
|
return;
|
|
7930
7965
|
}
|
|
7931
|
-
let d = String(e), f =
|
|
7966
|
+
let d = String(e), f = iu(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
7932
7967
|
if (f) {
|
|
7933
7968
|
o.push({
|
|
7934
7969
|
path: l,
|
|
@@ -7939,7 +7974,7 @@ function nu(e, t, n = {}) {
|
|
|
7939
7974
|
return;
|
|
7940
7975
|
}
|
|
7941
7976
|
if (a && u) {
|
|
7942
|
-
let e =
|
|
7977
|
+
let e = iu(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
7943
7978
|
e && o.push({
|
|
7944
7979
|
path: l,
|
|
7945
7980
|
key: u,
|
|
@@ -7950,51 +7985,51 @@ function nu(e, t, n = {}) {
|
|
|
7950
7985
|
};
|
|
7951
7986
|
return c(e, ""), o;
|
|
7952
7987
|
}
|
|
7953
|
-
function
|
|
7988
|
+
function iu(e, t, n, r, i) {
|
|
7954
7989
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
7955
7990
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
7956
7991
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
7957
7992
|
if (n === "fuzzy") {
|
|
7958
7993
|
if (a.includes(o)) return 2;
|
|
7959
|
-
let e =
|
|
7994
|
+
let e = nu(a, o);
|
|
7960
7995
|
return e <= r ? r - e + 1 : null;
|
|
7961
7996
|
}
|
|
7962
7997
|
return null;
|
|
7963
7998
|
}
|
|
7964
|
-
function
|
|
7999
|
+
function au(e, t, n = 3e3) {
|
|
7965
8000
|
return ao(t, n)(e);
|
|
7966
8001
|
}
|
|
7967
8002
|
//#endregion
|
|
7968
8003
|
//#region src/core/tools/resources.ts
|
|
7969
|
-
var
|
|
7970
|
-
function cu(e) {
|
|
7971
|
-
return `${au}${e}${su}`;
|
|
7972
|
-
}
|
|
8004
|
+
var ou = "⟦frozen:", su = "⟦res:", cu = "⟧";
|
|
7973
8005
|
function lu(e) {
|
|
7974
|
-
return `${ou}${e}${
|
|
8006
|
+
return `${ou}${e}${cu}`;
|
|
7975
8007
|
}
|
|
7976
8008
|
function uu(e) {
|
|
7977
|
-
return
|
|
8009
|
+
return `${su}${e}${cu}`;
|
|
8010
|
+
}
|
|
8011
|
+
function du(e) {
|
|
8012
|
+
return typeof e == "string" ? e.startsWith(ou) && e.endsWith(cu) ? {
|
|
7978
8013
|
type: "frozen",
|
|
7979
8014
|
path: e.slice(8, e.length - 1)
|
|
7980
|
-
} : e.startsWith(
|
|
8015
|
+
} : e.startsWith(su) && e.endsWith(cu) ? {
|
|
7981
8016
|
type: "res",
|
|
7982
8017
|
handle: e.slice(5, e.length - 1)
|
|
7983
8018
|
} : null : null;
|
|
7984
8019
|
}
|
|
7985
|
-
function
|
|
8020
|
+
function fu(e) {
|
|
7986
8021
|
return String(e ?? "").trim().replace(/^\.+/, "");
|
|
7987
8022
|
}
|
|
7988
|
-
function
|
|
8023
|
+
function pu(e) {
|
|
7989
8024
|
let t = 5381;
|
|
7990
8025
|
for (let n = 0; n < e.length; n++) t = (t * 33 ^ e.charCodeAt(n)) >>> 0;
|
|
7991
8026
|
return (t >>> 0).toString(16).padStart(8, "0").slice(0, 8);
|
|
7992
8027
|
}
|
|
7993
|
-
function
|
|
8028
|
+
function mu(e, t) {
|
|
7994
8029
|
return e === t ? !0 : e && t && typeof e == "object" && typeof t == "object" ? JSON.stringify(e) === JSON.stringify(t) : !1;
|
|
7995
8030
|
}
|
|
7996
|
-
function
|
|
7997
|
-
let n =
|
|
8031
|
+
function hu(e, t) {
|
|
8032
|
+
let n = fu(e);
|
|
7998
8033
|
if (!n) return;
|
|
7999
8034
|
let r = t.get(n);
|
|
8000
8035
|
if (r) return {
|
|
@@ -8014,7 +8049,7 @@ function mu(e, t) {
|
|
|
8014
8049
|
}));
|
|
8015
8050
|
return i;
|
|
8016
8051
|
}
|
|
8017
|
-
var
|
|
8052
|
+
var gu = class {
|
|
8018
8053
|
vfs;
|
|
8019
8054
|
constructor(e) {
|
|
8020
8055
|
this.vfs = e;
|
|
@@ -8023,7 +8058,7 @@ var hu = class {
|
|
|
8023
8058
|
return `resources/${e}.json`;
|
|
8024
8059
|
}
|
|
8025
8060
|
ensure(e, t, n) {
|
|
8026
|
-
let r =
|
|
8061
|
+
let r = pu(e), i = {
|
|
8027
8062
|
path: e,
|
|
8028
8063
|
mode: n,
|
|
8029
8064
|
value: t,
|
|
@@ -8035,7 +8070,7 @@ var hu = class {
|
|
|
8035
8070
|
}, r;
|
|
8036
8071
|
}
|
|
8037
8072
|
get(e) {
|
|
8038
|
-
return this.readEntry(this.key(e)) || this.readEntry(this.key(
|
|
8073
|
+
return this.readEntry(this.key(e)) || this.readEntry(this.key(pu(e)));
|
|
8039
8074
|
}
|
|
8040
8075
|
readEntry(e) {
|
|
8041
8076
|
let t = this.vfs.files[e];
|
|
@@ -8051,7 +8086,7 @@ var hu = class {
|
|
|
8051
8086
|
this.ensure(e, t, n?.mode ?? "verbatim");
|
|
8052
8087
|
}
|
|
8053
8088
|
delete(e) {
|
|
8054
|
-
let t = this.get(e)?.handle ??
|
|
8089
|
+
let t = this.get(e)?.handle ?? pu(e), n = this.key(t), r = !!this.vfs.files[n];
|
|
8055
8090
|
return r && delete this.vfs.files[n], r;
|
|
8056
8091
|
}
|
|
8057
8092
|
list() {
|
|
@@ -8071,7 +8106,7 @@ var hu = class {
|
|
|
8071
8106
|
for (let e of Object.keys(this.vfs.files)) e.startsWith("resources/") && delete this.vfs.files[e];
|
|
8072
8107
|
}
|
|
8073
8108
|
};
|
|
8074
|
-
function
|
|
8109
|
+
function _u(e) {
|
|
8075
8110
|
let { jp: t, resolved: n, resourcesByPath: r, resourceStore: i } = e;
|
|
8076
8111
|
if (!r.size) return n;
|
|
8077
8112
|
let a = !1;
|
|
@@ -8085,14 +8120,14 @@ function gu(e) {
|
|
|
8085
8120
|
if (t !== "" && e !== t && !e.startsWith(t + ".")) continue;
|
|
8086
8121
|
if (e === t) {
|
|
8087
8122
|
if (o === void 0) continue;
|
|
8088
|
-
return n.mode === "freeze" ?
|
|
8123
|
+
return n.mode === "freeze" ? lu(e) : i ? uu(i.ensure(e, o, "verbatim")) : o;
|
|
8089
8124
|
}
|
|
8090
8125
|
let r = t === "" ? e : e.slice(t.length + 1), a = Z(o, r);
|
|
8091
|
-
a !== void 0 && (n.mode === "freeze" ? Na(o, r,
|
|
8126
|
+
a !== void 0 && (n.mode === "freeze" ? Na(o, r, lu(e)) : i && Na(o, r, uu(i.ensure(e, a, "verbatim"))));
|
|
8092
8127
|
}
|
|
8093
8128
|
return o;
|
|
8094
8129
|
}
|
|
8095
|
-
function
|
|
8130
|
+
function vu(e, t, n, r) {
|
|
8096
8131
|
if (!r) return {
|
|
8097
8132
|
code: "RESOURCE_NOT_FOUND",
|
|
8098
8133
|
message: `句柄 "${e}" 无法展开(资源池未启用)`,
|
|
@@ -8103,7 +8138,7 @@ function _u(e, t, n, r) {
|
|
|
8103
8138
|
code: "RESOURCE_NOT_FOUND",
|
|
8104
8139
|
message: `字段 "${t}" 在 bind 中已不存在,无法展开句柄 "${e}"`,
|
|
8105
8140
|
hint: "该字段可能已被删除或 restore 到不含此字段的快照;重新 read 确认当前结构"
|
|
8106
|
-
} :
|
|
8141
|
+
} : mu(i.value, n) ? { value: i.value } : (r.update(t, n), { value: n }) : n === void 0 ? {
|
|
8107
8142
|
code: "RESOURCE_NOT_FOUND",
|
|
8108
8143
|
message: `句柄 "${e}" 不存在(字段 "${t}" 可能未注册或已被删除)`,
|
|
8109
8144
|
hint: "重新 read 该字段触发懒注册"
|
|
@@ -8113,7 +8148,7 @@ function _u(e, t, n, r) {
|
|
|
8113
8148
|
hint: "重新 read 该字段触发懒注册重建句柄,再写回新句柄 ⟦res:<handle>⟧"
|
|
8114
8149
|
};
|
|
8115
8150
|
}
|
|
8116
|
-
function
|
|
8151
|
+
function yu(e, t) {
|
|
8117
8152
|
let n = t.getBind();
|
|
8118
8153
|
for (let [r, i] of t.resourcesByPath) {
|
|
8119
8154
|
let a = Z(n, r), o = Z(e, r);
|
|
@@ -8122,11 +8157,11 @@ function vu(e, t) {
|
|
|
8122
8157
|
continue;
|
|
8123
8158
|
}
|
|
8124
8159
|
if (i.mode === "freeze") {
|
|
8125
|
-
if (o ===
|
|
8160
|
+
if (o === lu(r)) {
|
|
8126
8161
|
Na(e, r, a);
|
|
8127
8162
|
continue;
|
|
8128
8163
|
}
|
|
8129
|
-
if (!
|
|
8164
|
+
if (!mu(o, a)) return {
|
|
8130
8165
|
ok: !1,
|
|
8131
8166
|
code: "FROZEN_FIELD",
|
|
8132
8167
|
path: r,
|
|
@@ -8134,9 +8169,9 @@ function vu(e, t) {
|
|
|
8134
8169
|
hint: "该字段由系统/集成方维护,LLM 不得改动。如需展示其值用 resource_get({path}) 取真值"
|
|
8135
8170
|
};
|
|
8136
8171
|
} else {
|
|
8137
|
-
let n =
|
|
8172
|
+
let n = du(o);
|
|
8138
8173
|
if (n && n.type === "res") {
|
|
8139
|
-
let i =
|
|
8174
|
+
let i = vu(n.handle, r, a, t.resourceStore);
|
|
8140
8175
|
if ("value" in i) {
|
|
8141
8176
|
Na(e, r, i.value);
|
|
8142
8177
|
continue;
|
|
@@ -8149,7 +8184,7 @@ function vu(e, t) {
|
|
|
8149
8184
|
hint: i.hint
|
|
8150
8185
|
};
|
|
8151
8186
|
}
|
|
8152
|
-
if (!
|
|
8187
|
+
if (!mu(o, a)) return {
|
|
8153
8188
|
ok: !1,
|
|
8154
8189
|
code: "VERBATIM_MISMATCH",
|
|
8155
8190
|
path: r,
|
|
@@ -8160,7 +8195,7 @@ function vu(e, t) {
|
|
|
8160
8195
|
}
|
|
8161
8196
|
return { ok: !0 };
|
|
8162
8197
|
}
|
|
8163
|
-
function
|
|
8198
|
+
function bu(e, t, n) {
|
|
8164
8199
|
let r = t === void 0 ? e.message : `patches[${t}]${n ? ` @ "${n}"` : ""}: ${e.message}`;
|
|
8165
8200
|
return Y({
|
|
8166
8201
|
code: e.code,
|
|
@@ -8173,28 +8208,28 @@ function yu(e, t, n) {
|
|
|
8173
8208
|
} }
|
|
8174
8209
|
});
|
|
8175
8210
|
}
|
|
8176
|
-
function
|
|
8211
|
+
function xu(e) {
|
|
8177
8212
|
let { value: t, ctx: n } = e;
|
|
8178
8213
|
if (!n || !n.resourcesByPath.size) return {
|
|
8179
8214
|
ok: !0,
|
|
8180
8215
|
value: t
|
|
8181
8216
|
};
|
|
8182
|
-
let r = Fa(t), i =
|
|
8217
|
+
let r = Fa(t), i = yu(r, n);
|
|
8183
8218
|
return i.ok ? {
|
|
8184
8219
|
ok: !0,
|
|
8185
8220
|
value: r
|
|
8186
8221
|
} : {
|
|
8187
8222
|
ok: !1,
|
|
8188
|
-
error:
|
|
8223
|
+
error: bu(i)
|
|
8189
8224
|
};
|
|
8190
8225
|
}
|
|
8191
|
-
function
|
|
8226
|
+
function Su(e) {
|
|
8192
8227
|
let { patches: t, clone: n, ctx: r } = e;
|
|
8193
8228
|
if (!r || !r.resourcesByPath.size) return { ok: !0 };
|
|
8194
8229
|
for (let e = 0; e < t.length; e++) {
|
|
8195
8230
|
let n = t[e];
|
|
8196
8231
|
if (n.op === "remove") {
|
|
8197
|
-
let t =
|
|
8232
|
+
let t = hu(n.jsonPath || "", r.resourcesByPath);
|
|
8198
8233
|
if (t) {
|
|
8199
8234
|
let r = t.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED", i = t.spec.mode === "freeze" ? "冻结字段不可删。如需移除请联系集成方调整 data.resources 配置" : "verbatim 字段不可直接删;先 resource_delete({path}) 释放资源保护后再删";
|
|
8200
8235
|
return {
|
|
@@ -8213,27 +8248,27 @@ function xu(e) {
|
|
|
8213
8248
|
}
|
|
8214
8249
|
}
|
|
8215
8250
|
}
|
|
8216
|
-
let i =
|
|
8251
|
+
let i = yu(n, r);
|
|
8217
8252
|
if (!i.ok) {
|
|
8218
|
-
let e =
|
|
8253
|
+
let e = Cu(i.path, t);
|
|
8219
8254
|
return {
|
|
8220
8255
|
ok: !1,
|
|
8221
|
-
error:
|
|
8256
|
+
error: bu(i, e >= 0 ? e : void 0, e >= 0 ? t[e].jsonPath : void 0)
|
|
8222
8257
|
};
|
|
8223
8258
|
}
|
|
8224
8259
|
return { ok: !0 };
|
|
8225
8260
|
}
|
|
8226
|
-
function
|
|
8227
|
-
let n =
|
|
8261
|
+
function Cu(e, t) {
|
|
8262
|
+
let n = fu(e);
|
|
8228
8263
|
for (let e = 0; e < t.length; e++) {
|
|
8229
|
-
let r =
|
|
8264
|
+
let r = fu(t[e].jsonPath || "");
|
|
8230
8265
|
if (r && (r === n || n.startsWith(r + ".") || r.startsWith(n + "."))) return e;
|
|
8231
8266
|
}
|
|
8232
8267
|
return -1;
|
|
8233
8268
|
}
|
|
8234
8269
|
//#endregion
|
|
8235
8270
|
//#region src/core/tools/dataOps.ts
|
|
8236
|
-
var
|
|
8271
|
+
var wu = /* @__PURE__ */ new Set([
|
|
8237
8272
|
"describe_data",
|
|
8238
8273
|
"get_data",
|
|
8239
8274
|
"set_data",
|
|
@@ -8247,14 +8282,14 @@ var Cu = /* @__PURE__ */ new Set([
|
|
|
8247
8282
|
"resource_update",
|
|
8248
8283
|
"resource_list",
|
|
8249
8284
|
"resource_delete"
|
|
8250
|
-
]),
|
|
8251
|
-
function
|
|
8252
|
-
return t === "advanced" ? e : t === "minimal" ? e.filter((e) =>
|
|
8285
|
+
]), Tu = /* @__PURE__ */ new Set(["read", "write"]);
|
|
8286
|
+
function Eu(e, t = "simple") {
|
|
8287
|
+
return t === "advanced" ? e : t === "minimal" ? e.filter((e) => Tu.has(e.name)) : e.filter((e) => !wu.has(e.name));
|
|
8253
8288
|
}
|
|
8254
|
-
function
|
|
8289
|
+
function Du(e) {
|
|
8255
8290
|
let { bindRef: t, schema: n, allowKeys: r, snapshots: i, maxSnapshots: a, audit: o, dryRun: s, op: c = "set", protectedCtx: l } = e, u = e.value, d = e.internalAfterWrite ? Fa(t) : null;
|
|
8256
8291
|
if (l) {
|
|
8257
|
-
let e =
|
|
8292
|
+
let e = xu({
|
|
8258
8293
|
value: u,
|
|
8259
8294
|
ctx: l
|
|
8260
8295
|
});
|
|
@@ -8310,7 +8345,7 @@ function Eu(e) {
|
|
|
8310
8345
|
data: f.data
|
|
8311
8346
|
};
|
|
8312
8347
|
}
|
|
8313
|
-
function
|
|
8348
|
+
function Ou(e) {
|
|
8314
8349
|
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 = e.internalAfterWrite ? Fa(t) : null, p = Fa(t), m = [];
|
|
8315
8350
|
for (let e = 0; e < n.length; e++) {
|
|
8316
8351
|
let t = n[e], a = t.jsonPath || "";
|
|
@@ -8370,7 +8405,7 @@ function Du(e) {
|
|
|
8370
8405
|
});
|
|
8371
8406
|
}
|
|
8372
8407
|
if (d) {
|
|
8373
|
-
let e =
|
|
8408
|
+
let e = Su({
|
|
8374
8409
|
patches: n,
|
|
8375
8410
|
clone: p,
|
|
8376
8411
|
ctx: d
|
|
@@ -8421,37 +8456,37 @@ function Du(e) {
|
|
|
8421
8456
|
clone: p
|
|
8422
8457
|
};
|
|
8423
8458
|
}
|
|
8424
|
-
function
|
|
8459
|
+
function ku(e) {
|
|
8425
8460
|
return e < 1024 ? `${e}B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)}KB` : `${(e / (1024 * 1024)).toFixed(1)}MB`;
|
|
8426
8461
|
}
|
|
8427
|
-
function
|
|
8462
|
+
function Au(e, t, n, r) {
|
|
8428
8463
|
if (!t || !n.length || typeof e != "object" || !e) return e;
|
|
8429
8464
|
let i = new Set(n.map((e) => e.field)), a = Fa(e);
|
|
8430
8465
|
return (function e(t) {
|
|
8431
8466
|
if (Array.isArray(t)) for (let n of t) e(n);
|
|
8432
8467
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) {
|
|
8433
8468
|
let a = t[n];
|
|
8434
|
-
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${
|
|
8469
|
+
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${ku(a.length)}>` : e(a);
|
|
8435
8470
|
}
|
|
8436
8471
|
})(a), a;
|
|
8437
8472
|
}
|
|
8438
|
-
var
|
|
8439
|
-
function
|
|
8440
|
-
return
|
|
8473
|
+
var ju = 0;
|
|
8474
|
+
function Mu() {
|
|
8475
|
+
return ju++, "c_" + Math.random().toString(36).slice(2, 8) + ju.toString(36);
|
|
8441
8476
|
}
|
|
8442
|
-
function
|
|
8477
|
+
function Nu(e, t) {
|
|
8443
8478
|
if (!(!e || typeof e != "object")) for (let n of t) {
|
|
8444
8479
|
let t = Z(e, n);
|
|
8445
|
-
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId =
|
|
8480
|
+
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId = Mu());
|
|
8446
8481
|
}
|
|
8447
8482
|
}
|
|
8448
|
-
function
|
|
8483
|
+
function Pu(e) {
|
|
8449
8484
|
(function e(t) {
|
|
8450
8485
|
if (Array.isArray(t)) t.forEach(e);
|
|
8451
8486
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) n.startsWith("__pg") ? delete t[n] : e(t[n]);
|
|
8452
8487
|
})(e);
|
|
8453
8488
|
}
|
|
8454
|
-
function
|
|
8489
|
+
function Fu(e, n = {}) {
|
|
8455
8490
|
let i = n.pgIdPaths ?? [], a = i.length ? (e, t) => {
|
|
8456
8491
|
if (t && typeof t == "object") for (let n of i) {
|
|
8457
8492
|
let r = Z(t, n), i = Z(e, n);
|
|
@@ -8466,7 +8501,7 @@ function Pu(e, n = {}) {
|
|
|
8466
8501
|
if (!(!t || typeof t != "object" || "__pgId" in t)) for (let e = 0; e < r.length; e++) {
|
|
8467
8502
|
if (o.has(e)) continue;
|
|
8468
8503
|
let n = r[e];
|
|
8469
|
-
if (!(!n || typeof n != "object" || !n.__pgId) &&
|
|
8504
|
+
if (!(!n || typeof n != "object" || !n.__pgId) && mu(a(n), a(t))) {
|
|
8470
8505
|
t.__pgId = n.__pgId, o.add(e);
|
|
8471
8506
|
break;
|
|
8472
8507
|
}
|
|
@@ -8478,11 +8513,11 @@ function Pu(e, n = {}) {
|
|
|
8478
8513
|
t && n && typeof n == "object" && !("__pgId" in n) && (n.__pgId = t, o.add(e));
|
|
8479
8514
|
}
|
|
8480
8515
|
}
|
|
8481
|
-
|
|
8482
|
-
} : void 0, o = i.length ? fa(e.schema, i).schema : e.schema, s = e.bind, c = e.description ?? "主数据对象", l = Gi(o), u = /* @__PURE__ */ new Map(), d = n.vfsStore ? new
|
|
8516
|
+
Nu(e, i);
|
|
8517
|
+
} : void 0, o = i.length ? fa(e.schema, i).schema : e.schema, s = e.bind, c = e.description ?? "主数据对象", l = Gi(o), u = /* @__PURE__ */ new Map(), d = n.vfsStore ? new gu(n.vfsStore) : void 0;
|
|
8483
8518
|
function f(e) {
|
|
8484
8519
|
if (u.clear(), e) for (let t of e) {
|
|
8485
|
-
let e =
|
|
8520
|
+
let e = fu(t.path);
|
|
8486
8521
|
u.set(e, {
|
|
8487
8522
|
path: e,
|
|
8488
8523
|
mode: t.mode
|
|
@@ -8555,7 +8590,7 @@ function Pu(e, n = {}) {
|
|
|
8555
8590
|
return e;
|
|
8556
8591
|
},
|
|
8557
8592
|
createResource: d ? (e, t) => {
|
|
8558
|
-
let n =
|
|
8593
|
+
let n = fu(e), r = u.get(n), i = t === void 0 ? Z(s, n) : t;
|
|
8559
8594
|
return d.ensure(n, i, r?.mode ?? "verbatim");
|
|
8560
8595
|
} : void 0,
|
|
8561
8596
|
getResource: d ? (e) => {
|
|
@@ -8568,7 +8603,7 @@ function Pu(e, n = {}) {
|
|
|
8568
8603
|
} : void 0;
|
|
8569
8604
|
} : void 0,
|
|
8570
8605
|
updateResource: d ? (e, t) => {
|
|
8571
|
-
let n =
|
|
8606
|
+
let n = fu(e);
|
|
8572
8607
|
d.update(n, t), Na(s, n, t), T();
|
|
8573
8608
|
} : void 0,
|
|
8574
8609
|
deleteResource: d ? (e) => d.delete(e) : void 0,
|
|
@@ -8631,14 +8666,14 @@ function Pu(e, n = {}) {
|
|
|
8631
8666
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
8632
8667
|
});
|
|
8633
8668
|
let i = r ? Z(s, r) : s;
|
|
8634
|
-
!r && l && (i = ea(i, o)), p && (i =
|
|
8669
|
+
!r && l && (i = ea(i, o)), p && (i = _u({
|
|
8635
8670
|
jp: r,
|
|
8636
8671
|
resolved: i,
|
|
8637
8672
|
resourcesByPath: p.resourcesByPath,
|
|
8638
8673
|
resourceStore: p.resourceStore
|
|
8639
8674
|
}));
|
|
8640
8675
|
let a = $(s);
|
|
8641
|
-
return b(a, n), i === void 0 ? `主数据${r ? ` @ ${r}` : ""} = (undefined) (hash=${a})` : (i =
|
|
8676
|
+
return b(a, n), i === void 0 ? `主数据${r ? ` @ ${r}` : ""} = (undefined) (hash=${a})` : (i = Au(i, n === "", C, S), `主数据${r ? ` @ ${r}` : ""} = ${Q(i)} (hash=${a})`);
|
|
8642
8677
|
}, {
|
|
8643
8678
|
name: "get_data",
|
|
8644
8679
|
description: "@deprecated(改用 read,等价且支持 fields/depth/分页)。读取主数据当前值(返回含 hash 供乐观锁);jsonPath 可选读子路径。大结果自动外存 vfs。",
|
|
@@ -8648,7 +8683,7 @@ function Pu(e, n = {}) {
|
|
|
8648
8683
|
if (i !== null) return i;
|
|
8649
8684
|
let c = Ia(e);
|
|
8650
8685
|
if (c.parseError) return Yr("", e, c.parseError);
|
|
8651
|
-
let u =
|
|
8686
|
+
let u = Du({
|
|
8652
8687
|
bindRef: s,
|
|
8653
8688
|
value: c.parsed,
|
|
8654
8689
|
schema: o,
|
|
@@ -8695,7 +8730,7 @@ function Pu(e, n = {}) {
|
|
|
8695
8730
|
message: `edit 仅适用于对象/数组主数据,当前是 ${s === void 0 ? "undefined" : typeof s}`,
|
|
8696
8731
|
hint: "叶子(原始类型)请用 set_data 整体设置"
|
|
8697
8732
|
});
|
|
8698
|
-
let g =
|
|
8733
|
+
let g = Ou({
|
|
8699
8734
|
bindRef: s,
|
|
8700
8735
|
patches: [{
|
|
8701
8736
|
op: r,
|
|
@@ -8764,7 +8799,7 @@ function Pu(e, n = {}) {
|
|
|
8764
8799
|
hint: "仅 schema 声明的 key 可删"
|
|
8765
8800
|
});
|
|
8766
8801
|
if (p) {
|
|
8767
|
-
let t =
|
|
8802
|
+
let t = hu(e, p.resourcesByPath);
|
|
8768
8803
|
if (t) return Y({
|
|
8769
8804
|
code: t.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED",
|
|
8770
8805
|
message: `delete_data @ "${e}" 命中受保护字段 "${t.protectedPath}"(${t.spec.mode}),不可删除`,
|
|
@@ -8873,7 +8908,7 @@ function Pu(e, n = {}) {
|
|
|
8873
8908
|
});
|
|
8874
8909
|
let i = l ? ea(s, o) : s, a;
|
|
8875
8910
|
try {
|
|
8876
|
-
a =
|
|
8911
|
+
a = tu(i, e);
|
|
8877
8912
|
} catch (t) {
|
|
8878
8913
|
return Y({
|
|
8879
8914
|
code: "JSONPATH_SYNTAX",
|
|
@@ -8882,7 +8917,7 @@ function Pu(e, n = {}) {
|
|
|
8882
8917
|
details: { expr: e }
|
|
8883
8918
|
});
|
|
8884
8919
|
}
|
|
8885
|
-
let c = t ?? 50, u = a.slice(0, c), d = u.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${Q(
|
|
8920
|
+
let c = t ?? 50, u = a.slice(0, c), d = u.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${Q(Au(e.value, r === "", C, S))}}`);
|
|
8886
8921
|
return `{"matched":${a.length},"returned":${u.length},"truncated":${a.length > c},"results":[${d.join(",")}]}`;
|
|
8887
8922
|
}, {
|
|
8888
8923
|
name: "query_data",
|
|
@@ -8897,7 +8932,7 @@ function Pu(e, n = {}) {
|
|
|
8897
8932
|
message: "主数据为空,无可搜索内容"
|
|
8898
8933
|
});
|
|
8899
8934
|
try {
|
|
8900
|
-
let a =
|
|
8935
|
+
let a = ru(l ? ea(s, o) : s, e, {
|
|
8901
8936
|
mode: t,
|
|
8902
8937
|
fuzzyThreshold: n,
|
|
8903
8938
|
matchKey: r,
|
|
@@ -8948,7 +8983,7 @@ function Pu(e, n = {}) {
|
|
|
8948
8983
|
e && (u = ea(u, e));
|
|
8949
8984
|
}
|
|
8950
8985
|
} else u = l ? ea(s, o) : s;
|
|
8951
|
-
let d = Fa(u), f = await
|
|
8986
|
+
let d = Fa(u), f = await au(d, e, c && JSON.stringify(d).length > 1e5 ? 8e3 : 3e3);
|
|
8952
8987
|
if (!f.ok) {
|
|
8953
8988
|
let t = /超时/.test(f.error || "");
|
|
8954
8989
|
return Y({
|
|
@@ -8964,7 +8999,7 @@ function Pu(e, n = {}) {
|
|
|
8964
8999
|
if (t === "transform") {
|
|
8965
9000
|
let e = f.result;
|
|
8966
9001
|
if (c) {
|
|
8967
|
-
let t =
|
|
9002
|
+
let t = Ou({
|
|
8968
9003
|
bindRef: s,
|
|
8969
9004
|
patches: [{
|
|
8970
9005
|
op: "set",
|
|
@@ -8993,7 +9028,7 @@ function Pu(e, n = {}) {
|
|
|
8993
9028
|
message: `主数据 bind 为原始类型(${s === null ? "null" : typeof s}),eval transform(patches) 无法就地替换`,
|
|
8994
9029
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
8995
9030
|
});
|
|
8996
|
-
let t =
|
|
9031
|
+
let t = Ou({
|
|
8997
9032
|
bindRef: s,
|
|
8998
9033
|
patches: e.patches,
|
|
8999
9034
|
schema: o,
|
|
@@ -9014,7 +9049,7 @@ function Pu(e, n = {}) {
|
|
|
9014
9049
|
}
|
|
9015
9050
|
let t = e;
|
|
9016
9051
|
if (p) {
|
|
9017
|
-
let e =
|
|
9052
|
+
let e = xu({
|
|
9018
9053
|
value: t,
|
|
9019
9054
|
ctx: p
|
|
9020
9055
|
});
|
|
@@ -9066,7 +9101,7 @@ function Pu(e, n = {}) {
|
|
|
9066
9101
|
e && (c = ea(c, e));
|
|
9067
9102
|
}
|
|
9068
9103
|
let u = c;
|
|
9069
|
-
if (p && (u =
|
|
9104
|
+
if (p && (u = _u({
|
|
9070
9105
|
jp: a,
|
|
9071
9106
|
resolved: u,
|
|
9072
9107
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -9076,7 +9111,7 @@ function Pu(e, n = {}) {
|
|
|
9076
9111
|
} catch (e) {
|
|
9077
9112
|
return `- ${a}: [READ_INTERCEPT: ${e.message}]`;
|
|
9078
9113
|
}
|
|
9079
|
-
return r && r.length && (u = La(u, r)), i != null && (u = Ra(u, i)), u =
|
|
9114
|
+
return r && r.length && (u = La(u, r)), i != null && (u = Ra(u, i)), u = Au(u, f === "", C, S), u === void 0 ? `- ${a} = (undefined)` : `- ${a} = ${Q(u)}`;
|
|
9080
9115
|
});
|
|
9081
9116
|
return e && b(m, f), `多路径读取(共 ${t.length} 项,hash=${m}):\n${a.join("\n")}`;
|
|
9082
9117
|
}
|
|
@@ -9098,7 +9133,7 @@ function Pu(e, n = {}) {
|
|
|
9098
9133
|
e && (g = ea(g, e));
|
|
9099
9134
|
}
|
|
9100
9135
|
let _ = g;
|
|
9101
|
-
if (p && (_ =
|
|
9136
|
+
if (p && (_ = _u({
|
|
9102
9137
|
jp: h,
|
|
9103
9138
|
resolved: _,
|
|
9104
9139
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -9111,7 +9146,7 @@ function Pu(e, n = {}) {
|
|
|
9111
9146
|
message: `read 拦截器抛错: ${e.message}`
|
|
9112
9147
|
});
|
|
9113
9148
|
}
|
|
9114
|
-
b(m, f), r && r.length && (_ = La(_, r)), i != null && (_ = Ra(_, i)), _ =
|
|
9149
|
+
b(m, f), r && r.length && (_ = La(_, r)), i != null && (_ = Ra(_, i)), _ = Au(_, f === "", C, S);
|
|
9115
9150
|
let y = e ? "" : `主数据说明: ${c}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。字段约束(类型/min/max/enum/必填/默认)见 systemPrompt「可操作数据」段,或用 schema_data({ jsonPath }) 按需查。\n\n`, x = r && r.length ? `(字段裁剪:${r.join(",")})` : "", w = i == null ? "" : `(深度≤${i})`, T = x || w ? ` ${x}${w}` : "";
|
|
9116
9151
|
if ((a !== void 0 || u !== void 0) && Array.isArray(_)) {
|
|
9117
9152
|
let e = _.length, t = Math.max(0, a ?? 0), n = Math.min(200, Math.max(1, u ?? 50)), r = _.slice(t, t + n), i = t + n < e;
|
|
@@ -9184,7 +9219,7 @@ function Pu(e, n = {}) {
|
|
|
9184
9219
|
hint: "仅 schema 声明的 key 可删"
|
|
9185
9220
|
});
|
|
9186
9221
|
if (p) {
|
|
9187
|
-
let e =
|
|
9222
|
+
let e = hu(t.jsonPath, p.resourcesByPath);
|
|
9188
9223
|
if (e) return Y({
|
|
9189
9224
|
code: e.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED",
|
|
9190
9225
|
message: `write delete @ "${t.jsonPath}" 命中受保护字段 "${e.protectedPath}"(${e.spec.mode}),不可删除`,
|
|
@@ -9217,7 +9252,7 @@ function Pu(e, n = {}) {
|
|
|
9217
9252
|
op: t.op ?? "set",
|
|
9218
9253
|
jsonPath: t.jsonPath || "",
|
|
9219
9254
|
value: g
|
|
9220
|
-
}]), i =
|
|
9255
|
+
}]), i = Ou({
|
|
9221
9256
|
bindRef: s,
|
|
9222
9257
|
patches: n,
|
|
9223
9258
|
schema: o,
|
|
@@ -9235,13 +9270,13 @@ function Pu(e, n = {}) {
|
|
|
9235
9270
|
detail: `${i.applied.length} 个 patch${i.applied.length > 1 ? "(批量)" : ""}`,
|
|
9236
9271
|
value: i.applied.map((e) => `${e.op}@${e.jp}`),
|
|
9237
9272
|
timestamp: Date.now()
|
|
9238
|
-
}), b($(s), d),
|
|
9273
|
+
}), b($(s), d), Pu(i.clone), `已 write(edit) 主数据(${i.applied.length} 个 patch)。当前值:${Q(i.clone, 600)} (新 hash=${$(s)})`) : i.error;
|
|
9239
9274
|
}
|
|
9240
9275
|
let C = Ia(g);
|
|
9241
9276
|
if (C.parseError) return Yr("", g, C.parseError);
|
|
9242
9277
|
let w = await k("set", S);
|
|
9243
9278
|
if (w !== null) return w;
|
|
9244
|
-
let E =
|
|
9279
|
+
let E = Du({
|
|
9245
9280
|
bindRef: s,
|
|
9246
9281
|
value: C.parsed,
|
|
9247
9282
|
schema: o,
|
|
@@ -9257,7 +9292,7 @@ function Pu(e, n = {}) {
|
|
|
9257
9292
|
if (!E.ok) return E.error;
|
|
9258
9293
|
if (c) return `dryRun(set): schema 校验通过。预览新值:${Q(E.data, 600)}。未实际写入、未入快照。`;
|
|
9259
9294
|
let A = $(s);
|
|
9260
|
-
return b(A, d),
|
|
9295
|
+
return b(A, d), Pu(E.data), `已 write(set) 主数据 = ${Q(E.data, 600)} (新 hash=${A})${l ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`;
|
|
9261
9296
|
}, {
|
|
9262
9297
|
name: "write",
|
|
9263
9298
|
description: "写入主数据(高层入口,合并 set/edit/delete + 自动乐观锁 + 自动快照)。四意图:① 整体替换 write({value:整个对象});② 增量 write({patch:{op,jsonPath,value}}) op=set/remove/merge/append/move(move 的 value=目标路径字符串);③ 批量原子 write({patches:[...]})(任一失败整批回滚);④ 删子路径 write({patch:{jsonPath},del:true})。dryRun:true 预检不落盘。写入自动 schema 校验(失败不写,按错误修正重试)+ 自动快照。详细用法见系统提示「能力使用提示」。",
|
|
@@ -9376,7 +9411,7 @@ function Pu(e, n = {}) {
|
|
|
9376
9411
|
}
|
|
9377
9412
|
let g = await k("set", n || (x ? y(c) : void 0));
|
|
9378
9413
|
if (g !== null) return g;
|
|
9379
|
-
let _ =
|
|
9414
|
+
let _ = Du({
|
|
9380
9415
|
bindRef: s,
|
|
9381
9416
|
value: f,
|
|
9382
9417
|
schema: o,
|
|
@@ -9409,7 +9444,7 @@ function Pu(e, n = {}) {
|
|
|
9409
9444
|
message: "未提供 path 或有效 handle",
|
|
9410
9445
|
hint: "传 path(受保护字段)或 handle(占位符 ⟦res:handle⟧ 里的句柄)"
|
|
9411
9446
|
});
|
|
9412
|
-
let r =
|
|
9447
|
+
let r = fu(n);
|
|
9413
9448
|
if (!u.has(r)) return Y({
|
|
9414
9449
|
code: "RESOURCE_NOT_FOUND",
|
|
9415
9450
|
message: `"${n}" 不是受保护字段`,
|
|
@@ -9449,7 +9484,7 @@ function Pu(e, n = {}) {
|
|
|
9449
9484
|
message: "resource_update 需要 path",
|
|
9450
9485
|
hint: "传要更新的 verbatim 受保护字段路径"
|
|
9451
9486
|
});
|
|
9452
|
-
let i =
|
|
9487
|
+
let i = fu(e), a = u.get(i);
|
|
9453
9488
|
if (!a) return Y({
|
|
9454
9489
|
code: "RESOURCE_NOT_FOUND",
|
|
9455
9490
|
message: `"${e}" 不是受保护字段`,
|
|
@@ -9539,8 +9574,8 @@ function Pu(e, n = {}) {
|
|
|
9539
9574
|
}
|
|
9540
9575
|
//#endregion
|
|
9541
9576
|
//#region src/core/tools/fetchDoc.ts
|
|
9542
|
-
var
|
|
9543
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
9577
|
+
var Iu = 3e4, Lu = [r(async ({ url: e, as: t }) => {
|
|
9578
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), Iu);
|
|
9544
9579
|
try {
|
|
9545
9580
|
let r = await fetch(e, {
|
|
9546
9581
|
method: "GET",
|
|
@@ -9557,7 +9592,7 @@ var Fu = 3e4, Iu = [r(async ({ url: e, as: t }) => {
|
|
|
9557
9592
|
].join("\n");
|
|
9558
9593
|
} catch (t) {
|
|
9559
9594
|
let r = t?.message || String(t);
|
|
9560
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
9595
|
+
return n.signal.aborted ? `获取失败:请求超时(${Iu}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
9561
9596
|
} finally {
|
|
9562
9597
|
clearTimeout(r);
|
|
9563
9598
|
}
|
|
@@ -9568,7 +9603,7 @@ var Fu = 3e4, Iu = [r(async ({ url: e, as: t }) => {
|
|
|
9568
9603
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
9569
9604
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
9570
9605
|
})
|
|
9571
|
-
})],
|
|
9606
|
+
})], Ru = [
|
|
9572
9607
|
"id",
|
|
9573
9608
|
"class",
|
|
9574
9609
|
"href",
|
|
@@ -9580,12 +9615,12 @@ var Fu = 3e4, Iu = [r(async ({ url: e, as: t }) => {
|
|
|
9580
9615
|
"aria-label",
|
|
9581
9616
|
"name",
|
|
9582
9617
|
"type"
|
|
9583
|
-
],
|
|
9584
|
-
function
|
|
9618
|
+
], zu = /^(value|srcdoc|formaction|on\w+)$/i, Bu = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session/i;
|
|
9619
|
+
function Vu(e, t) {
|
|
9585
9620
|
if (!e) return null;
|
|
9586
|
-
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ??
|
|
9621
|
+
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ?? Ru, s = (e) => {
|
|
9587
9622
|
let t = {};
|
|
9588
|
-
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (
|
|
9623
|
+
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (zu.test(n.name) || Bu.test(n.name) || (t[n.name] = n.value));
|
|
9589
9624
|
return t;
|
|
9590
9625
|
}, c = (e, t) => {
|
|
9591
9626
|
let n = {
|
|
@@ -9601,10 +9636,10 @@ function Bu(e, t) {
|
|
|
9601
9636
|
};
|
|
9602
9637
|
return c(e, n);
|
|
9603
9638
|
}
|
|
9604
|
-
var
|
|
9639
|
+
var Hu = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
9605
9640
|
let i = e ? document.querySelector(e) : document.body;
|
|
9606
9641
|
if (!i) return `未找到匹配元素:selector="${e}"`;
|
|
9607
|
-
let a =
|
|
9642
|
+
let a = Vu(i, {
|
|
9608
9643
|
depth: t ?? 3,
|
|
9609
9644
|
attrs: n,
|
|
9610
9645
|
includeText: r ?? !0
|
|
@@ -9619,14 +9654,14 @@ var Vu = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
9619
9654
|
attrs: t.array(t.string()).optional().describe("属性白名单(传了 = 严格白名单;不传 = 默认常用 + data-*)"),
|
|
9620
9655
|
includeText: t.boolean().optional().describe("是否包含直接文本(默认 true)")
|
|
9621
9656
|
})
|
|
9622
|
-
}),
|
|
9657
|
+
}), Uu = [Hu];
|
|
9623
9658
|
//#endregion
|
|
9624
9659
|
//#region src/core/tools/envTool.ts
|
|
9625
|
-
function
|
|
9660
|
+
function Wu(e) {
|
|
9626
9661
|
let t = e;
|
|
9627
9662
|
return typeof t.tagName == "string" || typeof t.nodeType == "number" && typeof t.nodeName == "string";
|
|
9628
9663
|
}
|
|
9629
|
-
function
|
|
9664
|
+
function Gu(e, t = 3, n = 2e3, r, i) {
|
|
9630
9665
|
if (e == null) return e;
|
|
9631
9666
|
if (typeof e == "string") return e.length > n ? e.slice(0, n) + "…(已截断)" : e;
|
|
9632
9667
|
if (typeof e == "number" || typeof e == "boolean") return e;
|
|
@@ -9635,14 +9670,14 @@ function Wu(e, t = 3, n = 2e3, r, i) {
|
|
|
9635
9670
|
if (typeof e == "bigint") return `${e.toString()}n`;
|
|
9636
9671
|
if (typeof e != "object") return String(e);
|
|
9637
9672
|
let a = e;
|
|
9638
|
-
if (
|
|
9673
|
+
if (Wu(a)) {
|
|
9639
9674
|
let e = a;
|
|
9640
9675
|
return e.tagName ? `[Element: <${e.tagName.toLowerCase()}>]` : `[Node: ${e.nodeName}]`;
|
|
9641
9676
|
}
|
|
9642
9677
|
if (r?.has(a)) return "[Circular]";
|
|
9643
9678
|
let o = r ?? /* @__PURE__ */ new WeakSet();
|
|
9644
9679
|
if (o.add(a), Array.isArray(e)) {
|
|
9645
|
-
let r = e.slice(0, 100).map((e) =>
|
|
9680
|
+
let r = e.slice(0, 100).map((e) => Gu(e, t - 1, n, o, i));
|
|
9646
9681
|
return e.length > 100 && r.push(`…(共 ${e.length} 项,已截断)`), r;
|
|
9647
9682
|
}
|
|
9648
9683
|
if (t < 0) return "(对象,已截断)";
|
|
@@ -9655,14 +9690,14 @@ function Wu(e, t = 3, n = 2e3, r, i) {
|
|
|
9655
9690
|
}
|
|
9656
9691
|
try {
|
|
9657
9692
|
let e = a[r];
|
|
9658
|
-
i?.test(r) ? s[r] = "[REDACTED]" : s[r] =
|
|
9693
|
+
i?.test(r) ? s[r] = "[REDACTED]" : s[r] = Gu(e, t - 1, n, o, i);
|
|
9659
9694
|
} catch {
|
|
9660
9695
|
s[r] = "(getter 抛错)";
|
|
9661
9696
|
}
|
|
9662
9697
|
}
|
|
9663
9698
|
return s;
|
|
9664
9699
|
}
|
|
9665
|
-
function
|
|
9700
|
+
function Ku(e) {
|
|
9666
9701
|
let t = e ?? (typeof window < "u" ? window : {}), n = t.navigator, r = t.location, i = t.document;
|
|
9667
9702
|
return {
|
|
9668
9703
|
location: {
|
|
@@ -9695,9 +9730,9 @@ function Gu(e) {
|
|
|
9695
9730
|
} : "(无 document)"
|
|
9696
9731
|
};
|
|
9697
9732
|
}
|
|
9698
|
-
var
|
|
9733
|
+
var qu = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|opener|parent|top|self|window|globalThis|closed|history|navigation|trustedTypes|origin|crossOriginIsolated)$/, Ju = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session|ticket/i, Yu = r(({ key: e }) => {
|
|
9699
9734
|
if (e) {
|
|
9700
|
-
if (
|
|
9735
|
+
if (qu.test(e) || Ju.test(e)) return JSON.stringify({
|
|
9701
9736
|
key: e,
|
|
9702
9737
|
denied: !0,
|
|
9703
9738
|
reason: "安全:该 key 在 denylist(localStorage/sessionStorage/cookie/document 或敏感命名 token/secret/key/auth),不读取防泄漏"
|
|
@@ -9707,18 +9742,18 @@ var Ku = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|open
|
|
|
9707
9742
|
key: e,
|
|
9708
9743
|
exists: t !== void 0,
|
|
9709
9744
|
type: typeof t,
|
|
9710
|
-
value:
|
|
9745
|
+
value: Gu(t, 3, 2e3, void 0, Ju)
|
|
9711
9746
|
}, null, 2);
|
|
9712
9747
|
}
|
|
9713
|
-
return JSON.stringify(
|
|
9748
|
+
return JSON.stringify(Ku(), null, 2);
|
|
9714
9749
|
}, {
|
|
9715
9750
|
name: "inspect_env",
|
|
9716
9751
|
description: "读宿主页面环境信息(排查调试)。不传参返回摘要(URL/origin、浏览器/语言、viewport、title/readyState);传 key 读指定 window 属性值(如 key:\"appConfig\")。只读,大结果自动外存 vfs。",
|
|
9717
9752
|
schema: t.object({ key: t.string().optional().describe("要读取的 window 属性名(如 \"appConfig\"/\"__DEBUG__\");不传 = 返回环境摘要") })
|
|
9718
|
-
}),
|
|
9753
|
+
}), Xu = [Yu];
|
|
9719
9754
|
//#endregion
|
|
9720
9755
|
//#region src/core/harness/budget.ts
|
|
9721
|
-
function
|
|
9756
|
+
function Zu(e, t, n) {
|
|
9722
9757
|
let r = 0;
|
|
9723
9758
|
return {
|
|
9724
9759
|
name: "budget",
|
|
@@ -9743,12 +9778,12 @@ function Xu(e, t, n) {
|
|
|
9743
9778
|
}
|
|
9744
9779
|
//#endregion
|
|
9745
9780
|
//#region src/core/sdk/actions.ts
|
|
9746
|
-
var
|
|
9747
|
-
function
|
|
9781
|
+
var Qu = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
9782
|
+
function $u(e) {
|
|
9748
9783
|
let n = [];
|
|
9749
9784
|
for (let [i, a] of Object.entries(e)) {
|
|
9750
|
-
if (!
|
|
9751
|
-
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${
|
|
9785
|
+
if (!Qu.test(i)) {
|
|
9786
|
+
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${Qu}),已跳过`);
|
|
9752
9787
|
continue;
|
|
9753
9788
|
}
|
|
9754
9789
|
let e = a.description || `宿主动作 ${i}`;
|
|
@@ -9768,9 +9803,9 @@ function Qu(e) {
|
|
|
9768
9803
|
}
|
|
9769
9804
|
return n;
|
|
9770
9805
|
}
|
|
9771
|
-
function
|
|
9806
|
+
function ed(e) {
|
|
9772
9807
|
let t = {};
|
|
9773
|
-
for (let [n, r] of Object.entries(e))
|
|
9808
|
+
for (let [n, r] of Object.entries(e)) Qu.test(n) && (t[n] = {
|
|
9774
9809
|
description: r.description,
|
|
9775
9810
|
hasParams: !!r.params
|
|
9776
9811
|
});
|
|
@@ -9778,12 +9813,12 @@ function $u(e) {
|
|
|
9778
9813
|
}
|
|
9779
9814
|
//#endregion
|
|
9780
9815
|
//#region src/core/toolsets.ts
|
|
9781
|
-
var
|
|
9782
|
-
function
|
|
9783
|
-
return
|
|
9816
|
+
var td = Lu, nd = Uu;
|
|
9817
|
+
function rd(e, t) {
|
|
9818
|
+
return Fu(e, t);
|
|
9784
9819
|
}
|
|
9785
|
-
function
|
|
9786
|
-
let a =
|
|
9820
|
+
function id(e, t, n, r, i) {
|
|
9821
|
+
let a = zl(e);
|
|
9787
9822
|
return [
|
|
9788
9823
|
...a.dataOps ? t : [],
|
|
9789
9824
|
...a.fetch ? n : [],
|
|
@@ -9793,7 +9828,7 @@ function rd(e, t, n, r, i) {
|
|
|
9793
9828
|
}
|
|
9794
9829
|
//#endregion
|
|
9795
9830
|
//#region src/core/sdk/toolRegistry.ts
|
|
9796
|
-
function
|
|
9831
|
+
function ad(e) {
|
|
9797
9832
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
9798
9833
|
for (let r of e) for (let e of r.tools) {
|
|
9799
9834
|
let i = t.get(e.name);
|
|
@@ -9813,15 +9848,15 @@ function id(e) {
|
|
|
9813
9848
|
}
|
|
9814
9849
|
//#endregion
|
|
9815
9850
|
//#region src/core/harness/usageHints.ts
|
|
9816
|
-
var
|
|
9817
|
-
function
|
|
9818
|
-
let a =
|
|
9851
|
+
var od = .7;
|
|
9852
|
+
function sd(e, t, n = "simple", r, i) {
|
|
9853
|
+
let a = zl(e), o = n !== "advanced", s = n === "minimal";
|
|
9819
9854
|
return {
|
|
9820
9855
|
name: "usageHints",
|
|
9821
9856
|
augmentPrompt: (n) => {
|
|
9822
9857
|
let r = [];
|
|
9823
9858
|
if (a.planning && (r.push("【自适应规划】按任务复杂度决定是否先规划,不要对简单任务过度编排:"), r.push(" · 简单/明确任务(改单字段、调样式、查值)→ 直接 read/write 执行,不必 write_todos。"), r.push(" · 复杂任务(多步、大改、有歧义、不可逆)→ 先 write_todos 拆解,首个任务标 in_progress,逐项推进。"), r.push(" · 执行中发现步骤要改/补/细分 → 用 update_todo({id, content?, status?}) 按 id 增量改单项,不必重传整个清单。"), e?.humanConfirm ? r.push(" · 规划出多步方案若需用户拍板 → 先 request_human_confirmation 给方案选项,确认后再执行。") : r.push(" · 规划出多步方案若需用户拍板 → 以文字列出方案选项等用户回复,勿自行拍板。"), r.push(" · 规划阶段有轮次预算(maxPlanRevisions,默认 5):勿反复调研/改计划而不执行,规划充分后即开始 write 落地。")), t && (o ? (r.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 追加数组 / move 移动数组元素(value=目标路径字符串:数组本身=追加到末尾、数组内下标=插到该位置;同数组即重排如组件调序,目标下标按移除源后解释,一步完成免双 set 交换);批量多改动 write({patches:[{op,jsonPath,value},...]});删子路径 write({patch:{jsonPath:\"路径\"}, del:true})。写入自动经 schema 校验(失败不写,按错误提示改值类型/形状后重试)+ 自动存快照" + (s ? "。" : "(出错可用 restore_data 回退)。")), r.push("修改大对象/数组优先用 write 的 patch 增量(只发改动部分),避免整体重传被 max_tokens 截断致 JSON 不完整。"), r.push("读大数组(read 返回 hasMore=true)用 read({jsonPath,offset,limit}) 分页(offset+=limit 续读,默认 limit=50);一次读多个不相关子路径用 read({jsonPaths:[...]}) 省轮次;复杂 patches 改动先 write({patches,dryRun:true}) 预检(走完整校验不落盘)。"), r.push("read/describe 返回按 schema 投影:仅 schema 声明的字段可见(未声明字段自动隐藏,防误操作);要操作某字段需集成方在 schema 声明。"), s || (r.push("查任意路径完整约束或对比快照差异需切 advanced 工具模式(schema_data/diff_data,当前未装载勿调用);查历史快照值(只读不改当前)用 history_data({id?,jsonPath?})。"), r.push("在大数组里按条件筛选用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素 path/index;定位后用 write patch 改。找名字记不清的元素用 search_data(substring/regex/fuzzy)。批量过滤/映射/聚合/重写大数组用 eval_script(沙箱脚本,mode=query 只读/transform 落地)。"))) : (r.push("改主数据前先 get_data({jsonPath}) 读其当前真实值与 hash(返回末尾 hash=xxx),基于真实值改,不要凭记忆。写入(set/edit/delete)时回传 expectedHash=该 hash 启用乐观锁——若主数据在你 get 之后被外部代码/其他 agent/用户手动改过,会触发冲突:集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值与 hash 再改。"), r.push("不确定主数据字段结构时用 describe_data 查看说明。"), r.push("修改大对象/数组优先用 edit_data 增量 patch(只发改动部分),避免 set_data 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), r.push("修改主数据出错时可用 restore_data 回退最近一次。"), r.push("在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_data 改。"), r.push("找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。"), r.push("需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。"), r.push("读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。"), r.push("对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/\"刚才改了啥\");只读查历史快照值用 history_data({id?,jsonPath?})。"))), a.subagent && r.push("独立子任务可 spawn_agent 委派(过程隔离,不占主上下文):默认只读,需要子 agent 写数据时传 writablePaths(路径前缀白名单,越界 PATH_OUT_OF_SCOPE)。多个独立子任务可 spawn_agents 并行委派(各子互不通信,结论由你汇总;并行委派不可授写权限,写操作由你收尾执行)。"), a.inspectEnv && r.push("排查页面环境(当前 URL/浏览器/视口/集成方调试变量)用 inspect_env——不传参返回环境摘要(location/navigator/viewport/document),传 key 读特定 window 属性(如 inspect_env({key:\"appConfig\"}) 读 window.appConfig)。改完数据看渲染、定位\"为何没生效\"时用它(只读,不改数据)。"), a.domInspect && r.push("改完数据想确认渲染是否生效(或定位元素/辅助 UI 设计问答)用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。配合宿主 actions(save_draft/publish 等)形成\"改数据→get_dom 看渲染→触发动作\"闭环。"), a.draftWrite && !o && (r.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。"), r.push("⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=10 可能触顶被 while 截断导致草稿写不完;目标组件数大时集成方应在 createChatSdk 配 maxToolRounds ≥ 20(或按 N+5 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。")), a.todoDeps && r.push("复杂任务可用 todos 层级依赖:write_todos 时给 todo 传 parentId(父任务 id,表达层级)+ deps(依赖的 todo id 数组,必须先完成)。有依赖的任务,deps 全 completed 后再标 in_progress;完成时 update_todo({id, status:\"completed\", evidence:\"完成证据\"}) 记证据。无依赖关系的任务不传 parentId/deps(扁平)。"), a.focus && !o && (r.push("【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:"), r.push(" · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:\"该子树路径\"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。"), r.push(" · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。"), r.push(" · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。"), r.push(" · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。"), r.push(" · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read/describe_data 查。")), e?.subagents?.length) {
|
|
9824
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
9859
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= od || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), n = e.subagents.filter((e) => (e.temperature ?? 0) < od && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
9825
9860
|
r.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (r.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), r.push(e?.humanConfirm ? " 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。" : " 不要自己拍板;拿到方案后以文字列出选项等用户回复(humanConfirm 未开,勿调不存在工具)。")), n.length && r.push(` · 严谨/易错/校验类 → 可先调 ${n.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), r.push(o ? " · 方案定稿后,由你(主 agent)用 write 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。" : " · 方案定稿后,由你(主 agent)用 edit_data 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), r.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
9826
9861
|
}
|
|
9827
9862
|
e?.humanConfirm && (r.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), r.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), r.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), r.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), r.push(" 4) 规划出多步方案需用户确认时:把整个方案(或关键分步)作为 option 调 request_human_confirmation,确认后再执行。"), r.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。"));
|
|
@@ -9841,7 +9876,7 @@ function od(e, t, n = "simple", r, i) {
|
|
|
9841
9876
|
}
|
|
9842
9877
|
//#endregion
|
|
9843
9878
|
//#region src/core/harness/resourcesPin.ts
|
|
9844
|
-
function
|
|
9879
|
+
function cd(e) {
|
|
9845
9880
|
let t = e.toolsExposed === !1 ? "读到 ⟦frozen:path⟧/⟦res:handle⟧ 占位符 = 精确值在冻结区/资源池(不入消息流);resource_get/resource_update 为 advanced 工具,当前模式未装载,勿尝试调用;freeze 字段不可写(撞 FROZEN_FIELD 即放弃);verbatim 字段保持原值,勿在当前模式下尝试改写(直接写新值会 VERBATIM_MISMATCH);撞 RESOURCE_EVICTED/RESOURCE_NOT_FOUND 重新 read 懒注册。" : "读到 ⟦frozen:path⟧/⟦res:handle⟧ 占位符 = 精确值在冻结区/资源池(不入消息流);需真值用 resource_get({path});freeze 字段不可写(撞 FROZEN_FIELD 即放弃);verbatim 直接写新值会 VERBATIM_MISMATCH,先 resource_update 再写回句柄;撞 RESOURCE_EVICTED/RESOURCE_NOT_FOUND 重新 read 懒注册。";
|
|
9846
9881
|
return {
|
|
9847
9882
|
name: "resourcesPin",
|
|
@@ -9856,78 +9891,78 @@ function sd(e) {
|
|
|
9856
9891
|
}
|
|
9857
9892
|
//#endregion
|
|
9858
9893
|
//#region src/core/backends/skillStore.ts
|
|
9859
|
-
var
|
|
9860
|
-
function
|
|
9861
|
-
return `${
|
|
9894
|
+
var ld = "v:1::skill-store", ud = "chat-sdk";
|
|
9895
|
+
function dd(e, t, n) {
|
|
9896
|
+
return `${ld}::${e}::${t}::${n}`;
|
|
9862
9897
|
}
|
|
9863
|
-
function
|
|
9864
|
-
return `${
|
|
9898
|
+
function fd(e, t) {
|
|
9899
|
+
return `${ld}::${e}::${t}::`;
|
|
9865
9900
|
}
|
|
9866
|
-
function
|
|
9867
|
-
let t = e.dbName ??
|
|
9901
|
+
function pd(e = {}) {
|
|
9902
|
+
let t = e.dbName ?? ud, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
9868
9903
|
a = e;
|
|
9869
9904
|
});
|
|
9870
9905
|
return (async () => {
|
|
9871
9906
|
try {
|
|
9872
9907
|
if (n === "indexed") {
|
|
9873
9908
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
9874
|
-
i = await
|
|
9909
|
+
i = await Ml(t), a(!0);
|
|
9875
9910
|
} else if (n === "session") {
|
|
9876
9911
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
9877
|
-
i =
|
|
9912
|
+
i = Nl(sessionStorage), a(!0);
|
|
9878
9913
|
} else if (n === "local") {
|
|
9879
9914
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
9880
|
-
i =
|
|
9881
|
-
} else i =
|
|
9915
|
+
i = Nl(localStorage), a(!0);
|
|
9916
|
+
} else i = jl(), a(!1);
|
|
9882
9917
|
} catch {
|
|
9883
|
-
i =
|
|
9918
|
+
i = jl(), a(!1);
|
|
9884
9919
|
}
|
|
9885
9920
|
})(), {
|
|
9886
9921
|
ready: o,
|
|
9887
9922
|
async list() {
|
|
9888
9923
|
let e = [];
|
|
9889
|
-
return await i.scan(
|
|
9924
|
+
return await i.scan(fd(t, r), (t, n) => {
|
|
9890
9925
|
e.push(n);
|
|
9891
9926
|
}), e;
|
|
9892
9927
|
},
|
|
9893
9928
|
async get(e) {
|
|
9894
|
-
return await i.get(
|
|
9929
|
+
return await i.get(dd(t, r, e));
|
|
9895
9930
|
},
|
|
9896
9931
|
async put(e) {
|
|
9897
9932
|
try {
|
|
9898
|
-
await i.set(
|
|
9933
|
+
await i.set(dd(t, r, e.name), e);
|
|
9899
9934
|
} catch (e) {
|
|
9900
|
-
|
|
9935
|
+
Cl(e) && (i = jl());
|
|
9901
9936
|
}
|
|
9902
9937
|
},
|
|
9903
9938
|
async remove(e) {
|
|
9904
|
-
let n =
|
|
9939
|
+
let n = dd(t, r, e);
|
|
9905
9940
|
return await i.get(n) == null ? !1 : (await i.del(n), !0);
|
|
9906
9941
|
},
|
|
9907
9942
|
async clear() {
|
|
9908
|
-
await i.clearPrefix(
|
|
9943
|
+
await i.clearPrefix(fd(t, r));
|
|
9909
9944
|
},
|
|
9910
9945
|
dispose() {}
|
|
9911
9946
|
};
|
|
9912
9947
|
}
|
|
9913
|
-
var
|
|
9914
|
-
function
|
|
9948
|
+
var md = /large_results\/[^\s"'`),]+\.txt/g;
|
|
9949
|
+
function hd(e) {
|
|
9915
9950
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
9916
9951
|
if (typeof e != "string" || !e) return;
|
|
9917
9952
|
let n;
|
|
9918
|
-
for (
|
|
9953
|
+
for (md.lastIndex = 0; (n = md.exec(e)) !== null;) t.add(n[0]);
|
|
9919
9954
|
};
|
|
9920
9955
|
for (let t of e) if (n(t.content), t.steps) for (let e of t.steps) n(e.result);
|
|
9921
9956
|
return t;
|
|
9922
9957
|
}
|
|
9923
|
-
function
|
|
9958
|
+
function gd(e, t) {
|
|
9924
9959
|
let n = [];
|
|
9925
9960
|
for (let r of Object.keys(e)) r.startsWith("large_results/") && !t.has(r) && n.push(r);
|
|
9926
9961
|
return n;
|
|
9927
9962
|
}
|
|
9928
9963
|
//#endregion
|
|
9929
9964
|
//#region src/core/utils/serialRunner.ts
|
|
9930
|
-
function
|
|
9965
|
+
function _d() {
|
|
9931
9966
|
let e = Promise.resolve();
|
|
9932
9967
|
return function(t) {
|
|
9933
9968
|
let n = e.then(t, t);
|
|
@@ -9936,24 +9971,24 @@ function gd() {
|
|
|
9936
9971
|
}
|
|
9937
9972
|
//#endregion
|
|
9938
9973
|
//#region src/core/sdk/createChatSdk.ts
|
|
9939
|
-
var
|
|
9940
|
-
function
|
|
9974
|
+
var vd = 30, yd = /* @__PURE__ */ new Map();
|
|
9975
|
+
function bd(e, t) {
|
|
9941
9976
|
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;
|
|
9942
9977
|
}
|
|
9943
|
-
function
|
|
9978
|
+
function xd(e) {
|
|
9944
9979
|
return e === "spawn_agent" || e === "spawn_agents" || e.startsWith("use_");
|
|
9945
9980
|
}
|
|
9946
|
-
function
|
|
9981
|
+
function Sd(e, t, n, r) {
|
|
9947
9982
|
let i = 0;
|
|
9948
9983
|
return {
|
|
9949
9984
|
name: "sdk-events",
|
|
9950
9985
|
wrapToolCall: async (t, r) => {
|
|
9951
|
-
let i = await r(t), a =
|
|
9986
|
+
let i = await r(t), a = bd(t.name, t.args);
|
|
9952
9987
|
return a ? e({
|
|
9953
9988
|
type: "data_change",
|
|
9954
9989
|
operation: a,
|
|
9955
9990
|
value: n()?.bind
|
|
9956
|
-
}) : i.status === "done" &&
|
|
9991
|
+
}) : i.status === "done" && xd(t.name) && e({
|
|
9957
9992
|
type: "data_change",
|
|
9958
9993
|
operation: "edit",
|
|
9959
9994
|
value: n()?.bind
|
|
@@ -9980,7 +10015,7 @@ function xd(e, t, n, r) {
|
|
|
9980
10015
|
}
|
|
9981
10016
|
};
|
|
9982
10017
|
}
|
|
9983
|
-
function
|
|
10018
|
+
function Cd(e, t, n, r, i) {
|
|
9984
10019
|
if (!n) return i && console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`), {
|
|
9985
10020
|
ok: !1,
|
|
9986
10021
|
error: "capabilities.focus 关闭"
|
|
@@ -9998,18 +10033,18 @@ function Sd(e, t, n, r, i) {
|
|
|
9998
10033
|
error: "当前无主数据 schema,无法聚焦"
|
|
9999
10034
|
});
|
|
10000
10035
|
}
|
|
10001
|
-
function
|
|
10036
|
+
function wd(e, n) {
|
|
10002
10037
|
let i = {
|
|
10003
10038
|
prompt_tokens: 0,
|
|
10004
10039
|
completion_tokens: 0,
|
|
10005
10040
|
total_tokens: 0
|
|
10006
|
-
}, a =
|
|
10041
|
+
}, a = ul(() => q), o = /* @__PURE__ */ At(0), s = Il(e.storage);
|
|
10007
10042
|
e.debug && s && s.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
10008
|
-
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: d } =
|
|
10043
|
+
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: d } = ll(e), f = c;
|
|
10009
10044
|
if (e.debug && console.log("[page-agent-sdk][modelCaps]", f), f.contextWindow < 2e5) throw Error(`[page-agent-sdk] 模型上下文窗口 ${f.contextWindow} 小于最小支持 ${ai}(需 ≥200K 窗口模型,如 GLM-5.2/Claude/Kimi/Qwen-1M/DeepSeek-v4)`);
|
|
10010
|
-
let h =
|
|
10045
|
+
let h = Ul(e, f.contextWindow), g = h.enableLLMSummary !== !1, _ = (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? Hl[e.contextPreset ?? "auto"], v = new Set(_), y = e.llm;
|
|
10011
10046
|
e.debug && !l && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
10012
|
-
let b = /* @__PURE__ */ vt([]), x =
|
|
10047
|
+
let b = /* @__PURE__ */ vt([]), x = lc(e.vfs?.initialFiles, {
|
|
10013
10048
|
persist: s ? { save: (e) => {
|
|
10014
10049
|
Ft({ vfs: e });
|
|
10015
10050
|
} } : void 0,
|
|
@@ -10028,8 +10063,8 @@ function Cd(e, n) {
|
|
|
10028
10063
|
let D = { current: null }, O = e.data ? {
|
|
10029
10064
|
...e.data,
|
|
10030
10065
|
description: e.data.description ?? "主数据对象"
|
|
10031
|
-
} : void 0, k = !(e.subagents ?? []).some((e) => e._codeAsset) &&
|
|
10032
|
-
k && O?.schema && $i(O.schema).length && (A = [...e.subagents ?? [],
|
|
10066
|
+
} : void 0, k = !(e.subagents ?? []).some((e) => e._codeAsset) && zl(e.capabilities).subagent, A = e.subagents;
|
|
10067
|
+
k && O?.schema && $i(O.schema).length && (A = [...e.subagents ?? [], Jc()], console.info("[page-agent-sdk] 检测到 schema 含代码组件数组(如 components[].code),已自动装配 HTML 代码子 agent(委派编排 + vfs 工作副本 + 格式校验 + 增量 commit)。需定制(codeField/formatCheck/craftNotes 等)请显式传 createHtmlSubagent(...)"));
|
|
10033
10068
|
let ee = (A ?? []).filter((e) => !!e._codeAsset), j = /* @__PURE__ */ new Set();
|
|
10034
10069
|
for (let e of ee) {
|
|
10035
10070
|
if (e._codeAsset.writablePaths.length) continue;
|
|
@@ -10045,12 +10080,15 @@ function Cd(e, n) {
|
|
|
10045
10080
|
getTodos: () => D.current?.getState?.()?.todos ?? [],
|
|
10046
10081
|
messages: b,
|
|
10047
10082
|
maxCheckpoints: re && typeof re == "object" ? re.maxCheckpoints : void 0
|
|
10048
|
-
}) : null, I = !re || typeof re != "object" || re.auto !== !1, L =
|
|
10083
|
+
}) : null, I = !re || typeof re != "object" || re.auto !== !1, L = zl(e.capabilities), R = L.dataOps, ae = L.draftWrite, oe = L.tracing, se = L.automation, ce = ac({
|
|
10084
|
+
...e,
|
|
10085
|
+
locale: e.dialog?.locale
|
|
10086
|
+
});
|
|
10049
10087
|
if (N) {
|
|
10050
10088
|
let e = M.map((e) => e._codeAsset.orchestratorPrompt).filter(Boolean).join("\n\n");
|
|
10051
10089
|
e && (ce += "\n\n" + e);
|
|
10052
10090
|
} else O?.schema && Qi(O.schema) && (ce += "\n\n" + ga.htmlDirectWriteFallback, console.warn("[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。"));
|
|
10053
|
-
let le = R && O ?
|
|
10091
|
+
let le = R && O ? Fu(O, {
|
|
10054
10092
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
10055
10093
|
maxSnapshots: e.maxSnapshots,
|
|
10056
10094
|
onConflict: a.set,
|
|
@@ -10059,14 +10097,14 @@ function Cd(e, n) {
|
|
|
10059
10097
|
vfsStore: ae || O?.resources?.length ? x : void 0,
|
|
10060
10098
|
...P.length ? { pgIdPaths: P } : {},
|
|
10061
10099
|
...ne.length ? { largeTextPaths: ne } : {}
|
|
10062
|
-
}) : [], ue = R ?
|
|
10100
|
+
}) : [], ue = R ? Eu(le, e.toolMode) : [], z = R && O ? le.controller ?? null : null, de = R && O?.resources?.length && z?.getResourcesSnapshot ? cd({
|
|
10063
10101
|
getResourcesSnapshot: () => z?.getResourcesSnapshot?.() ?? [],
|
|
10064
10102
|
toolsExposed: e.toolMode === "advanced"
|
|
10065
|
-
}) : void 0, B = () => z?.get() ?? O, V = /* @__PURE__ */ new Map(), fe =
|
|
10103
|
+
}) : void 0, B = () => z?.get() ?? O, V = /* @__PURE__ */ new Map(), fe = id(L, ue, Lu, Uu, Xu);
|
|
10066
10104
|
fe.forEach((e) => V.set(e.name, "builtin"));
|
|
10067
10105
|
let pe = [...e.tools || []];
|
|
10068
10106
|
pe.forEach((e) => V.set(e.name, "user"));
|
|
10069
|
-
let H =
|
|
10107
|
+
let H = $u(e.actions ?? {});
|
|
10070
10108
|
H.forEach((e) => V.set(e.name, "action"));
|
|
10071
10109
|
let me = [], he = !1, ge = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), _e = ge ? Mo() : null;
|
|
10072
10110
|
_e && V.set(Ao, "builtin");
|
|
@@ -10138,7 +10176,7 @@ function Cd(e, n) {
|
|
|
10138
10176
|
Ce.forEach((e) => V.set(e.name, "builtin"));
|
|
10139
10177
|
let we = [], Te = /* @__PURE__ */ new Map(), W = G();
|
|
10140
10178
|
function G() {
|
|
10141
|
-
let { tools: e, collisions: t } =
|
|
10179
|
+
let { tools: e, collisions: t } = ad([
|
|
10142
10180
|
{
|
|
10143
10181
|
label: "builtin",
|
|
10144
10182
|
tools: fe
|
|
@@ -10175,7 +10213,7 @@ function Cd(e, n) {
|
|
|
10175
10213
|
return t.length && console.warn("[page-agent-sdk] 工具重名,后注册覆盖先注册:", t.map((e) => `${e.name}(${e.loser}→${e.winner})`).join(", ")), e;
|
|
10176
10214
|
}
|
|
10177
10215
|
let Ee = L.planning, De = L.missionAnchor, Oe = L.workingMemory, ke = L.skills, Ae = L.vfs || N;
|
|
10178
|
-
if (Ae) for (let e of
|
|
10216
|
+
if (Ae) for (let e of gc) V.set(e, "builtin");
|
|
10179
10217
|
if (Ee) for (let e of S.tools ?? []) V.set(e.name, "builtin");
|
|
10180
10218
|
let je = L.summarization, Me = L.agentCompression && !!d;
|
|
10181
10219
|
e.debug && L.agentCompression && !d && console.warn("[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩");
|
|
@@ -10205,7 +10243,7 @@ function Cd(e, n) {
|
|
|
10205
10243
|
timeoutMs: Be?.timeoutMs
|
|
10206
10244
|
}), Ke = te?.map((e) => {
|
|
10207
10245
|
if (!e._codeAsset) return e;
|
|
10208
|
-
let t = e._codeAsset, n =
|
|
10246
|
+
let t = e._codeAsset, n = Pc({
|
|
10209
10247
|
writablePaths: t.writablePaths,
|
|
10210
10248
|
codeVfsPrefix: t.codeVfsPrefix,
|
|
10211
10249
|
ext: t.ext,
|
|
@@ -10220,7 +10258,7 @@ function Cd(e, n) {
|
|
|
10220
10258
|
...e,
|
|
10221
10259
|
middleware: r
|
|
10222
10260
|
};
|
|
10223
|
-
}), qe = N && Pe ?
|
|
10261
|
+
}), qe = N && Pe ? Fc() : void 0, Je = qe ? Vc({
|
|
10224
10262
|
getBind: () => B()?.bind,
|
|
10225
10263
|
writablePaths: P,
|
|
10226
10264
|
getLocked: () => qe.locked(),
|
|
@@ -10243,7 +10281,7 @@ function Cd(e, n) {
|
|
|
10243
10281
|
timeoutMs: e.subagent?.timeoutMs,
|
|
10244
10282
|
...qe ? {
|
|
10245
10283
|
componentLock: qe,
|
|
10246
|
-
resolveComponents: (e) =>
|
|
10284
|
+
resolveComponents: (e) => Ic(e, Ac(B()?.bind, P))
|
|
10247
10285
|
} : {}
|
|
10248
10286
|
}) : void 0, Xe = Ye ? Ye.controller : null, Ze = [
|
|
10249
10287
|
"get_data",
|
|
@@ -10261,8 +10299,8 @@ function Cd(e, n) {
|
|
|
10261
10299
|
} : void 0
|
|
10262
10300
|
}) : void 0, et = ze ? Xs({
|
|
10263
10301
|
contextWindow: f.contextWindow,
|
|
10264
|
-
thresholdRatio:
|
|
10265
|
-
}) : void 0, tt =
|
|
10302
|
+
thresholdRatio: Ul(e, f.contextWindow).summaryThresholdRatio
|
|
10303
|
+
}) : void 0, tt = sd({
|
|
10266
10304
|
...L,
|
|
10267
10305
|
humanConfirm: ge,
|
|
10268
10306
|
subagents: te?.map((e) => ({
|
|
@@ -10272,7 +10310,7 @@ function Cd(e, n) {
|
|
|
10272
10310
|
}))
|
|
10273
10311
|
}, R && !!O, e.toolMode, !!O?.resources?.length, { promptSoftCap: as(f.contextWindow, h.promptSoftCapTokens) }), nt = O ? {
|
|
10274
10312
|
name: "dataHint",
|
|
10275
|
-
augmentPrompt: () =>
|
|
10313
|
+
augmentPrompt: () => ic(B(), e.schemaHint) || void 0
|
|
10276
10314
|
} : null, rt = e.augmentSystem ? {
|
|
10277
10315
|
name: "augmentSystem",
|
|
10278
10316
|
augmentPrompt: (t) => {
|
|
@@ -10286,7 +10324,7 @@ function Cd(e, n) {
|
|
|
10286
10324
|
return;
|
|
10287
10325
|
}
|
|
10288
10326
|
}
|
|
10289
|
-
} : null, it =
|
|
10327
|
+
} : null, it = Bl(e.onEvent), q = it.emit, at, ot = [], st = (e) => ({
|
|
10290
10328
|
name: e.name,
|
|
10291
10329
|
description: e.description,
|
|
10292
10330
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
@@ -10294,7 +10332,7 @@ function Cd(e, n) {
|
|
|
10294
10332
|
name: e.name,
|
|
10295
10333
|
description: e.description,
|
|
10296
10334
|
getContent: () => e.content
|
|
10297
|
-
}), lt = e.skillStorage === !1 ? null :
|
|
10335
|
+
}), lt = e.skillStorage === !1 ? null : pd({
|
|
10298
10336
|
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
10299
10337
|
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
|
|
10300
10338
|
}), ut = () => {
|
|
@@ -10326,7 +10364,7 @@ function Cd(e, n) {
|
|
|
10326
10364
|
decideInvoke: d,
|
|
10327
10365
|
getSnapshot: () => et?.getSnapshot()
|
|
10328
10366
|
} : {}
|
|
10329
|
-
}) : void 0, pt =
|
|
10367
|
+
}) : void 0, pt = Gl([
|
|
10330
10368
|
...nt ? [nt] : [],
|
|
10331
10369
|
tt,
|
|
10332
10370
|
...De ? [C] : [],
|
|
@@ -10342,7 +10380,7 @@ function Cd(e, n) {
|
|
|
10342
10380
|
W = G(), J.agent && J.agent.setTools(W), J.infoTick.value++;
|
|
10343
10381
|
}
|
|
10344
10382
|
})] : [],
|
|
10345
|
-
...Ae ? [
|
|
10383
|
+
...Ae ? [vc(x)] : [],
|
|
10346
10384
|
...ft ? [ft] : [],
|
|
10347
10385
|
...Oe ? [T] : [],
|
|
10348
10386
|
...U ? [w] : [],
|
|
@@ -10359,12 +10397,12 @@ function Cd(e, n) {
|
|
|
10359
10397
|
...rt ? [rt] : [],
|
|
10360
10398
|
...et ? [et] : [],
|
|
10361
10399
|
...e.middleware || [],
|
|
10362
|
-
...se ? [
|
|
10400
|
+
...se ? [Zu(i, {
|
|
10363
10401
|
tokenBudget: e.tokenBudget,
|
|
10364
10402
|
timeBudgetMs: e.timeBudgetMs
|
|
10365
10403
|
}, q)] : [],
|
|
10366
|
-
|
|
10367
|
-
]), mt = e.maxMemoryRounds ??
|
|
10404
|
+
Sd(q, b, B, i)
|
|
10405
|
+
]), mt = e.maxMemoryRounds ?? vd, ht = e.approval?.timeoutMs, gt = ht === void 0 || ht === 0 ? 3e4 : !Number.isFinite(ht) || ht < 0 ? 0 : ht;
|
|
10368
10406
|
function _t(e) {
|
|
10369
10407
|
if (gt) return (t) => {
|
|
10370
10408
|
if (t.type !== "approval_request") return;
|
|
@@ -10397,7 +10435,7 @@ function Cd(e, n) {
|
|
|
10397
10435
|
e.debug && console.warn("[page-agent-sdk][persist] refreshSessions 失败(已吞):", t);
|
|
10398
10436
|
}
|
|
10399
10437
|
}
|
|
10400
|
-
let St =
|
|
10438
|
+
let St = _d(), Ct = /* @__PURE__ */ new Set();
|
|
10401
10439
|
function wt(e) {
|
|
10402
10440
|
let t = new AbortController(), n = () => t.abort();
|
|
10403
10441
|
return e && (e.aborted ? t.abort() : e.addEventListener("abort", n, { once: !0 })), Ct.add(t), {
|
|
@@ -10654,7 +10692,7 @@ function Cd(e, n) {
|
|
|
10654
10692
|
})), e.memory && Ft({ memory: E.get() || (typeof e.memory == "string" ? e.memory : "") }), xt(), Mt = void 0, Nt = !1, J.infoTick.value++, r;
|
|
10655
10693
|
},
|
|
10656
10694
|
resetSession: () => {
|
|
10657
|
-
Tt(), a.resolve("keep_external"), J.sessionId =
|
|
10695
|
+
Tt(), a.resolve("keep_external"), J.sessionId = dl(), b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || E.reset(""), C.reset(), T.reset(), w.reset(), F && F.importStack([]), J.agent && (J.agent.debugLogs.value = []), s && s.createSession(J.agentId, e.session?.title, J.sessionId).catch((t) => {
|
|
10658
10696
|
e.debug && console.warn("[page-agent-sdk][persist] createSession 失败(已吞):", t);
|
|
10659
10697
|
}), q({
|
|
10660
10698
|
type: "session_restored",
|
|
@@ -10664,7 +10702,7 @@ function Cd(e, n) {
|
|
|
10664
10702
|
},
|
|
10665
10703
|
stream: (e, t, n) => {
|
|
10666
10704
|
if (!J.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
10667
|
-
x?.setProtectedRefs?.(
|
|
10705
|
+
x?.setProtectedRefs?.(hd(e));
|
|
10668
10706
|
let r = (e) => {
|
|
10669
10707
|
t?.(e), q(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && J.infoTick.value++;
|
|
10670
10708
|
};
|
|
@@ -10679,7 +10717,7 @@ function Cd(e, n) {
|
|
|
10679
10717
|
if (J.refCount--, J.refCount <= 0) {
|
|
10680
10718
|
Tt(), he = !0, s && (x.flush?.(), s.flush(), s.dispose()), lt && lt.dispose();
|
|
10681
10719
|
let e = J.mcpClosers.splice(0);
|
|
10682
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
10720
|
+
e.length && Promise.allSettled(e.map((e) => e())), yd.delete(n);
|
|
10683
10721
|
}
|
|
10684
10722
|
},
|
|
10685
10723
|
resolveConflict: a.resolve,
|
|
@@ -10699,14 +10737,14 @@ function Cd(e, n) {
|
|
|
10699
10737
|
},
|
|
10700
10738
|
setLlm(t) {
|
|
10701
10739
|
let n;
|
|
10702
|
-
if (
|
|
10740
|
+
if (el(t)) n = t;
|
|
10703
10741
|
else {
|
|
10704
10742
|
let e = t;
|
|
10705
10743
|
if ((e.provider ?? "openai") === "anthropic") throw Error("[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import(\"@langchain/anthropic\") 构造实例后传入");
|
|
10706
10744
|
n = p(e);
|
|
10707
10745
|
}
|
|
10708
10746
|
typeof n.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"), y = t;
|
|
10709
|
-
let r =
|
|
10747
|
+
let r = el(t) ? void 0 : t;
|
|
10710
10748
|
if (f = oi({
|
|
10711
10749
|
model: r?.model ?? t.model ?? t.modelName,
|
|
10712
10750
|
contextWindow: e.contextWindow ?? r?.contextWindow,
|
|
@@ -10749,8 +10787,8 @@ function Cd(e, n) {
|
|
|
10749
10787
|
return {
|
|
10750
10788
|
id: n,
|
|
10751
10789
|
sessionId: J.sessionId,
|
|
10752
|
-
model:
|
|
10753
|
-
systemPrompt: J.agent?.getEffectiveSystemPrompt?.() ?? ce +
|
|
10790
|
+
model: el(y) ? y.model ?? y.modelName : y.model,
|
|
10791
|
+
systemPrompt: J.agent?.getEffectiveSystemPrompt?.() ?? ce + ic(B(), e.schemaHint),
|
|
10754
10792
|
tools: (J.agent?.allTools ?? W).map((e) => ({
|
|
10755
10793
|
name: e.name,
|
|
10756
10794
|
description: e.description,
|
|
@@ -10791,7 +10829,7 @@ function Cd(e, n) {
|
|
|
10791
10829
|
spans: J.agent.spans.value,
|
|
10792
10830
|
metrics: li(J.agent.spans.value)
|
|
10793
10831
|
} : void 0,
|
|
10794
|
-
actions:
|
|
10832
|
+
actions: ed(e.actions ?? {}),
|
|
10795
10833
|
subagent: {
|
|
10796
10834
|
enabled: !!Ge,
|
|
10797
10835
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
@@ -10841,11 +10879,11 @@ function Cd(e, n) {
|
|
|
10841
10879
|
return U ? w.getFocuses() : [];
|
|
10842
10880
|
},
|
|
10843
10881
|
setFocus(t) {
|
|
10844
|
-
let n =
|
|
10882
|
+
let n = Cd(t, "setFocus", U, () => B()?.schema, e.debug);
|
|
10845
10883
|
return n.ok ? (w.setFocus(t), J.infoTick.value++, { ok: !0 }) : n;
|
|
10846
10884
|
},
|
|
10847
10885
|
addFocus(t) {
|
|
10848
|
-
let n =
|
|
10886
|
+
let n = Cd(t, "addFocus", U, () => B()?.schema, e.debug);
|
|
10849
10887
|
return n.ok ? w.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
10850
10888
|
ok: !1,
|
|
10851
10889
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
@@ -10889,14 +10927,14 @@ function Cd(e, n) {
|
|
|
10889
10927
|
}
|
|
10890
10928
|
function Ot(e) {
|
|
10891
10929
|
let t = {};
|
|
10892
|
-
for (let n of
|
|
10930
|
+
for (let n of hd(e)) {
|
|
10893
10931
|
let e = x.files[n];
|
|
10894
10932
|
e && (t[n] = e.content);
|
|
10895
10933
|
}
|
|
10896
10934
|
return t;
|
|
10897
10935
|
}
|
|
10898
10936
|
function kt() {
|
|
10899
|
-
let e =
|
|
10937
|
+
let e = gd(x.files, hd(b));
|
|
10900
10938
|
for (let t of e) delete x.files[t];
|
|
10901
10939
|
}
|
|
10902
10940
|
function jt() {
|
|
@@ -10960,7 +10998,7 @@ function Cd(e, n) {
|
|
|
10960
10998
|
Ft({ focus: e.length ? e : null });
|
|
10961
10999
|
}
|
|
10962
11000
|
se && F && (Ft({ checkpoints: F.exportStack() }), Ft({ usage: i }));
|
|
10963
|
-
let t =
|
|
11001
|
+
let t = $c(b);
|
|
10964
11002
|
if (t && t !== Mt && (Mt = t, It(J.sessionId, t)), e.autoTitle !== !1 && u && !Nt && b.some((e) => e.role === "user") && b.some((e) => e.role === "assistant")) {
|
|
10965
11003
|
Nt = !0;
|
|
10966
11004
|
let e = J.sessionId;
|
|
@@ -11008,7 +11046,7 @@ function Cd(e, n) {
|
|
|
11008
11046
|
})) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
|
|
11009
11047
|
}), me.length && (W = G(), J.agent && J.agent.setTools(W), J.infoTick.value++), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${me.length} 个工具,${J.mcpServers.length} 个 server`);
|
|
11010
11048
|
})();
|
|
11011
|
-
let t =
|
|
11049
|
+
let t = el(e.llm) ? e.llm : await m(e.llm);
|
|
11012
11050
|
J.agent = Wi({
|
|
11013
11051
|
llm: t,
|
|
11014
11052
|
systemPrompt: ce,
|
|
@@ -11040,12 +11078,12 @@ function Cd(e, n) {
|
|
|
11040
11078
|
});
|
|
11041
11079
|
})(), J;
|
|
11042
11080
|
}
|
|
11043
|
-
function
|
|
11044
|
-
let n = e.id ??
|
|
11081
|
+
function Td(e, t) {
|
|
11082
|
+
let n = e.id ?? dl();
|
|
11045
11083
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
11046
|
-
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ?
|
|
11047
|
-
o ? a = o : (a =
|
|
11048
|
-
let s = null, c =
|
|
11084
|
+
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ? yd.get(n) : void 0;
|
|
11085
|
+
o ? a = o : (a = wd(e, n), e.shareContext && yd.set(n, a)), a.refCount++;
|
|
11086
|
+
let s = null, c = Ll(e), l = null, u = null;
|
|
11049
11087
|
async function d(n) {
|
|
11050
11088
|
if (await a.initDone, s) {
|
|
11051
11089
|
s.show();
|
|
@@ -11216,12 +11254,12 @@ function wd(e, t) {
|
|
|
11216
11254
|
},
|
|
11217
11255
|
vfsWrite: (e, t) => {
|
|
11218
11256
|
let n = typeof t == "string" ? t : JSON.stringify(t);
|
|
11219
|
-
a.vfsStore.files[
|
|
11257
|
+
a.vfsStore.files[pc(e)] = {
|
|
11220
11258
|
content: n,
|
|
11221
11259
|
updatedAt: Date.now()
|
|
11222
11260
|
};
|
|
11223
11261
|
},
|
|
11224
|
-
vfsRead: (e) => a.vfsStore.files[
|
|
11262
|
+
vfsRead: (e) => a.vfsStore.files[pc(e)]?.content,
|
|
11225
11263
|
createResource: (e, t) => {
|
|
11226
11264
|
let n = a.dataOpsController;
|
|
11227
11265
|
if (!n?.createResource) throw Error("[page-agent-sdk] createResource 不可用:需配 data.resources + vfsStore(capabilities.vfs 默认开)");
|
|
@@ -11260,7 +11298,7 @@ function wd(e, t) {
|
|
|
11260
11298
|
}
|
|
11261
11299
|
//#endregion
|
|
11262
11300
|
//#region src/core/sdk/ragSubagent.ts
|
|
11263
|
-
function
|
|
11301
|
+
function Ed(e, t, n, r, i) {
|
|
11264
11302
|
let a = [];
|
|
11265
11303
|
e && a.push("vfs_grep + vfs_read(搜预注入文档)"), t && a.push(`${r}(语义检索)`), n && a.push(`${i}(按 source 加载)`), a.push("fetch_document(公网 URL)");
|
|
11266
11304
|
let o = [];
|
|
@@ -11275,7 +11313,7 @@ function Td(e, t, n, r, i) {
|
|
|
11275
11313
|
|
|
11276
11314
|
你是只读检索角色,不要尝试修改任何数据。不要尝试上面未列出的工具。`;
|
|
11277
11315
|
}
|
|
11278
|
-
function
|
|
11316
|
+
function Dd(e, t, n, r, i) {
|
|
11279
11317
|
let a = [], o = [];
|
|
11280
11318
|
return e && (a.push("- vfs_grep / vfs_read:搜集成方预注入 vfs 的文档(组件文档 / UI 规范)—— 快、静态,先查"), o.push("- 静态文档(组件库文档 / UI 规范):vfs_grep")), t && (a.push(`- ${r}:语义检索(retriever 向量库)—— 模糊匹配,关键词不确定 / 语义相似时用`), o.push(`- 语义相似(「瀑布流组件」「倒计时」「拼团」):${r}`)), n && (a.push(`- ${i}:按 source 精确加载(已知文档 id / URL / key)—— 精确取特定文档`), o.push(`- 已知文档 id / URL:${i}`)), a.push("- fetch_document:公网 URL —— 查公开资料"), o.push("- 公开 URL(设计规范网站 / 第三方文档):fetch_document"), `# 知识检索策略(RAG)
|
|
11281
11319
|
|
|
@@ -11292,12 +11330,12 @@ ${a.join("\n")}
|
|
|
11292
11330
|
## 何时用何源
|
|
11293
11331
|
${o.join("\n")}`;
|
|
11294
11332
|
}
|
|
11295
|
-
var
|
|
11333
|
+
var Od = {
|
|
11296
11334
|
name: "rag-search",
|
|
11297
11335
|
description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
|
|
11298
|
-
getContent: () =>
|
|
11336
|
+
getContent: () => Dd(!0, !0, !0, "search_docs", "load_doc")
|
|
11299
11337
|
};
|
|
11300
|
-
function
|
|
11338
|
+
function kd(e, n, i) {
|
|
11301
11339
|
return r(async ({ query: e, topK: t }) => {
|
|
11302
11340
|
try {
|
|
11303
11341
|
let r = await n(e, { topK: t ?? i });
|
|
@@ -11314,7 +11352,7 @@ function Od(e, n, i) {
|
|
|
11314
11352
|
})
|
|
11315
11353
|
});
|
|
11316
11354
|
}
|
|
11317
|
-
function
|
|
11355
|
+
function Ad(e, n) {
|
|
11318
11356
|
return r(async ({ source: e }) => {
|
|
11319
11357
|
try {
|
|
11320
11358
|
let t = await n(e), r = Array.isArray(t) ? t : [t];
|
|
@@ -11328,19 +11366,19 @@ function kd(e, n) {
|
|
|
11328
11366
|
schema: t.object({ source: t.string().describe("文档标识(id/URL/key)") })
|
|
11329
11367
|
});
|
|
11330
11368
|
}
|
|
11331
|
-
function
|
|
11369
|
+
function jd(e) {
|
|
11332
11370
|
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;
|
|
11333
11371
|
if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
|
|
11334
11372
|
let p = [];
|
|
11335
|
-
t && p.push(
|
|
11373
|
+
t && p.push(kd(s, t, o)), n && p.push(Ad(c, n)), f && p.push(...f);
|
|
11336
11374
|
let m = r ? [
|
|
11337
11375
|
"vfs_grep",
|
|
11338
11376
|
"vfs_read",
|
|
11339
11377
|
"vfs_json_read"
|
|
11340
|
-
] : void 0, h =
|
|
11378
|
+
] : void 0, h = Ed(r, !!t, !!n, s, c), g = {
|
|
11341
11379
|
name: "rag-search",
|
|
11342
|
-
description:
|
|
11343
|
-
getContent: () =>
|
|
11380
|
+
description: Od.description,
|
|
11381
|
+
getContent: () => Dd(r, !!t, !!n, s, c)
|
|
11344
11382
|
};
|
|
11345
11383
|
return {
|
|
11346
11384
|
id: i,
|
|
@@ -11355,7 +11393,7 @@ function Ad(e) {
|
|
|
11355
11393
|
}
|
|
11356
11394
|
//#endregion
|
|
11357
11395
|
//#region src/core/utils/clipboard.ts
|
|
11358
|
-
async function
|
|
11396
|
+
async function Md(e) {
|
|
11359
11397
|
try {
|
|
11360
11398
|
let t = globalThis.navigator?.clipboard;
|
|
11361
11399
|
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
@@ -11373,8 +11411,8 @@ async function jd(e) {
|
|
|
11373
11411
|
}
|
|
11374
11412
|
//#endregion
|
|
11375
11413
|
//#region src/core/composables/useChat.ts
|
|
11376
|
-
var
|
|
11377
|
-
function
|
|
11414
|
+
var Nd = 4e3;
|
|
11415
|
+
function Pd(e = {}) {
|
|
11378
11416
|
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a } = e, o = /* @__PURE__ */ vt({
|
|
11379
11417
|
messages: e.messages ?? [],
|
|
11380
11418
|
loading: !1,
|
|
@@ -11443,7 +11481,7 @@ function Nd(e = {}) {
|
|
|
11443
11481
|
let t = e.delta || "";
|
|
11444
11482
|
n.subReasonFull = (n.subReasonFull || "") + t;
|
|
11445
11483
|
let r = (n.subReason || "") + t;
|
|
11446
|
-
n.subReason = r.length >
|
|
11484
|
+
n.subReason = r.length > Nd ? r.slice(-4e3) : r;
|
|
11447
11485
|
break;
|
|
11448
11486
|
}
|
|
11449
11487
|
n.children ||= [];
|
|
@@ -11572,7 +11610,7 @@ function Nd(e = {}) {
|
|
|
11572
11610
|
}
|
|
11573
11611
|
//#endregion
|
|
11574
11612
|
//#region src/core/components/icons.ts
|
|
11575
|
-
var
|
|
11613
|
+
var Fd = {
|
|
11576
11614
|
header: "🤖",
|
|
11577
11615
|
subagent: "🤖",
|
|
11578
11616
|
subagentProgress: "🧬",
|
|
@@ -11583,21 +11621,480 @@ var Pd = {
|
|
|
11583
11621
|
recommend: "💡",
|
|
11584
11622
|
conflict: "⚠️"
|
|
11585
11623
|
};
|
|
11586
|
-
function
|
|
11587
|
-
let t = { ...
|
|
11624
|
+
function Id(e) {
|
|
11625
|
+
let t = { ...Fd };
|
|
11588
11626
|
if (!e) return t;
|
|
11589
|
-
let n = Object.keys(
|
|
11627
|
+
let n = Object.keys(Fd);
|
|
11590
11628
|
for (let r of n) {
|
|
11591
11629
|
let n = e[r];
|
|
11592
11630
|
typeof n == "string" && (t[r] = n);
|
|
11593
11631
|
}
|
|
11594
|
-
return e.assistantAvatar && (t.assistantAvatar = e.assistantAvatar), e.userAvatar && (t.userAvatar = e.userAvatar), t;
|
|
11632
|
+
return e.assistantAvatar && (t.assistantAvatar = e.assistantAvatar), e.userAvatar && (t.userAvatar = e.userAvatar), e.send && (t.send = e.send), t;
|
|
11633
|
+
}
|
|
11634
|
+
//#endregion
|
|
11635
|
+
//#region src/core/components/messages.ts
|
|
11636
|
+
var Ld = {
|
|
11637
|
+
defaultTitle: "AI 助手",
|
|
11638
|
+
inputPlaceholder: "输入消息,Enter 发送...",
|
|
11639
|
+
newSession: "新建会话",
|
|
11640
|
+
history: "历史记录",
|
|
11641
|
+
more: "更多",
|
|
11642
|
+
close: "关闭",
|
|
11643
|
+
debugMenu: "调试 / 日志",
|
|
11644
|
+
debugMenuTitle: "日志 / 执行流程 / Agent 信息",
|
|
11645
|
+
skillMenu: "Skill 管理",
|
|
11646
|
+
skillMenuTitle: "创建 / 管理自定义 Skill",
|
|
11647
|
+
clearChat: "清空对话",
|
|
11648
|
+
sessionFallbackPrefix: "会话 ",
|
|
11649
|
+
justNow: "刚刚",
|
|
11650
|
+
minutesAgoSuffix: "分钟前",
|
|
11651
|
+
emptyGreeting: "有什么可以帮你的?",
|
|
11652
|
+
retry: "重试",
|
|
11653
|
+
undo: "↩ 回退",
|
|
11654
|
+
undoTitle: "回退到上次正常状态(还原对话历史 + 页面属性 + 工作区)",
|
|
11655
|
+
thinking: "思考中...",
|
|
11656
|
+
statusRunning: "执行中",
|
|
11657
|
+
statusDone: "成功",
|
|
11658
|
+
statusError: "失败",
|
|
11659
|
+
subagentBadge: "子",
|
|
11660
|
+
subagentBadgeTitle: "子 agent 委派(独立上下文,只回结论)",
|
|
11661
|
+
subagentProgress: "子 agent 进度",
|
|
11662
|
+
nthCallPrefix: "第 ",
|
|
11663
|
+
nthCallSuffix: " 次",
|
|
11664
|
+
argsLabel: "入参",
|
|
11665
|
+
resultLabel: "返回值",
|
|
11666
|
+
copy: "复制",
|
|
11667
|
+
copied: "已复制",
|
|
11668
|
+
regenerate: "重新生成",
|
|
11669
|
+
expand: "展开",
|
|
11670
|
+
collapse: "收起",
|
|
11671
|
+
noResult: "(无返回值)",
|
|
11672
|
+
displayTruncatedSuffix: "\n…(展示截断,复制可得全量)",
|
|
11673
|
+
thinkingCountPrefix: "思考中… ",
|
|
11674
|
+
charCountSuffix: "字",
|
|
11675
|
+
reasoningTitle: "思考过程",
|
|
11676
|
+
truncatedNotePrefix: "(仅显最近 ",
|
|
11677
|
+
truncatedNoteSuffix: " 字)",
|
|
11678
|
+
copyThinking: "复制完整思考内容",
|
|
11679
|
+
copyThinkingTruncTitle: "复制完整思考(渲染已截尾,复制取全量)",
|
|
11680
|
+
focusChipTitlePrefix: "精修中:",
|
|
11681
|
+
focusChipTitleHint: "(点击回看 · ✕ 移除)",
|
|
11682
|
+
historyFocusChipTitlePrefix: "回看 ",
|
|
11683
|
+
removeFocus: "移除此焦点",
|
|
11684
|
+
sendHint: "Enter 发送 · Shift+Enter 换行",
|
|
11685
|
+
sendTitle: "发送",
|
|
11686
|
+
stopTitle: "停止生成",
|
|
11687
|
+
queuedTitle: "排队中 · 生成完后自动执行",
|
|
11688
|
+
queuedEditTitle: "修改(填回输入框编辑)",
|
|
11689
|
+
removeQueuedTitle: "撤销该任务",
|
|
11690
|
+
humanConfirmTitle: "AI 需要你确认",
|
|
11691
|
+
recommendPrefix: " 推荐:",
|
|
11692
|
+
approve: "允许",
|
|
11693
|
+
deny: "拒绝",
|
|
11694
|
+
toolConfirmPrefix: "需确认工具调用:",
|
|
11695
|
+
viewArgs: "查看参数",
|
|
11696
|
+
collapseArgs: "收起参数",
|
|
11697
|
+
argsTruncatedSuffix: "\n…(已截断)",
|
|
11698
|
+
conflictTitlePrefix: "写入冲突:",
|
|
11699
|
+
conflictTitleSuffix: " 已被外部修改",
|
|
11700
|
+
conflictDetailTemplate: "AI 基于「读取时的旧值」准备{op},但该属性在你读取之后被外部代码/其他 agent/手动改过。",
|
|
11701
|
+
conflictOpWrite: "写入",
|
|
11702
|
+
conflictOpDelete: "删除",
|
|
11703
|
+
viewDiff: "查看值对比",
|
|
11704
|
+
collapseDiff: "收起对比",
|
|
11705
|
+
agentValueLabel: "AI 想写的值",
|
|
11706
|
+
currentValueLabel: "外部改后的当前值",
|
|
11707
|
+
deleteNoValue: "(delete 操作无值)",
|
|
11708
|
+
keepExternal: "保留外部",
|
|
11709
|
+
keepExternalTitle: "不写入,保留外部修改后的值,AI 重新读取再改",
|
|
11710
|
+
overwrite: "强制覆盖",
|
|
11711
|
+
overwriteTitle: "用 AI 的值覆盖外部修改",
|
|
11712
|
+
restore: "回退",
|
|
11713
|
+
restoreTitle: "回退到最近一次历史快照(agent 之前操作的检查点),撤销外部修改 + AI 不写入",
|
|
11714
|
+
switchFocusTitle: "切换聚焦路径",
|
|
11715
|
+
exitFocusTitle: "退出精修",
|
|
11716
|
+
focusPathPlaceholder: "jsonPath,如 components.3",
|
|
11717
|
+
focusLabelPlaceholder: "标签(可选)",
|
|
11718
|
+
focusSubmit: "聚焦",
|
|
11719
|
+
debugTabLogs: "日志",
|
|
11720
|
+
debugTabFlow: "流程",
|
|
11721
|
+
debugTabContext: "上下文",
|
|
11722
|
+
debugTabSubagent: "子 agent",
|
|
11723
|
+
debugTabInfo: "Agent 信息",
|
|
11724
|
+
debugClearLogs: "清空日志",
|
|
11725
|
+
debugTypeContext: "上下文",
|
|
11726
|
+
debugTypeLlmRequest: "LLM请求",
|
|
11727
|
+
debugTypeLlmResponse: "LLM响应",
|
|
11728
|
+
debugTypeToolCall: "工具调用",
|
|
11729
|
+
debugTypeToolResult: "工具结果",
|
|
11730
|
+
debugTypeError: "错误",
|
|
11731
|
+
debugTypeMiddleware: "中间件",
|
|
11732
|
+
debugFilterAll: "全部",
|
|
11733
|
+
debugFlowPrep: "准备 / 其他",
|
|
11734
|
+
debugLogsEmpty: "暂无日志,发送消息后这里会显示 Agent 的完整上下文、工具调用等信息",
|
|
11735
|
+
debugFlowEmpty: "暂无日志,发送消息后这里按轮次展示执行流程",
|
|
11736
|
+
debugNoInfo: "暂无信息",
|
|
11737
|
+
debugCardView: "🗂 卡片视图",
|
|
11738
|
+
debugRequestBody: "📋 请求体",
|
|
11739
|
+
debugViewRawJson: "查看原始 JSON",
|
|
11740
|
+
debugCollapseRawJson: "收起原始 JSON",
|
|
11741
|
+
debugModel: "模型",
|
|
11742
|
+
debugTemperature: "温度",
|
|
11743
|
+
debugMessageCount: "消息数",
|
|
11744
|
+
debugToolsLabel: "工具",
|
|
11745
|
+
debugContextMessages: "上下文消息",
|
|
11746
|
+
debugRoundPrefix: "第 ",
|
|
11747
|
+
debugRoundSuffix: " 轮",
|
|
11748
|
+
debugMsgCountSuffix: " 条消息",
|
|
11749
|
+
debugToolCountSuffix: " 工具",
|
|
11750
|
+
debugToolCallsSuffix: " 个工具调用",
|
|
11751
|
+
debugResultSuffix: " 结果",
|
|
11752
|
+
debugTodoPending: "待办",
|
|
11753
|
+
debugTodoInProgress: "进行中",
|
|
11754
|
+
debugTodoCompleted: "完成",
|
|
11755
|
+
debugSubRunning: "运行中",
|
|
11756
|
+
debugSubDone: "完成",
|
|
11757
|
+
debugSubError: "错误",
|
|
11758
|
+
debugLocksTitle: "组件锁",
|
|
11759
|
+
debugSubagentEmpty: "尚未委派子 agent。主 agent 调用 use_<id> 或 spawn_agent 后,这里展示运行状态与委派历史。",
|
|
11760
|
+
debugSubRunningTitle: "运行中",
|
|
11761
|
+
debugSubHistoryTitle: "历史",
|
|
11762
|
+
debugStepsBtn: "步骤",
|
|
11763
|
+
debugStepsCountSuffix: " 步",
|
|
11764
|
+
debugTraceEmpty: "未开启 tracing(capabilities.tracing:true)或暂无 trace。跑一轮 agent 后刷新。",
|
|
11765
|
+
debugMetricRounds: "轮次",
|
|
11766
|
+
debugMetricTotal: "总耗时",
|
|
11767
|
+
debugMetricAvg: "平均/轮",
|
|
11768
|
+
debugMetricTools: "工具",
|
|
11769
|
+
debugMetricCompressions: "压缩",
|
|
11770
|
+
debugCtxEmpty: "未开启 contextInspector(默认开)或暂无快照。跑一轮 agent 后切回刷新。",
|
|
11771
|
+
debugCtxOccupancy: "占用",
|
|
11772
|
+
debugCtxThreshold: "压缩阈值",
|
|
11773
|
+
debugCtxTokens: "估算",
|
|
11774
|
+
debugCtxWindow: "窗口",
|
|
11775
|
+
debugCtxThresholdPct: "阈值",
|
|
11776
|
+
debugCtxCategories: "分类构成(近似)",
|
|
11777
|
+
debugCtxLastCompression: "最近压缩",
|
|
11778
|
+
debugCtxSummarized: "摘要",
|
|
11779
|
+
debugCtxRoundsSuffix: " 轮",
|
|
11780
|
+
debugCtxRecalled: "召回",
|
|
11781
|
+
debugCtxAgentDecision: "agent 决策:",
|
|
11782
|
+
debugInfoBasic: "基本信息",
|
|
11783
|
+
debugToolCount: "工具数",
|
|
11784
|
+
debugMiddleware: "中间件",
|
|
11785
|
+
debugMiddlewareStack: "中间件栈",
|
|
11786
|
+
debugSkillsTitle: "技能",
|
|
11787
|
+
debugSkillsHint: "点击展开查看全文",
|
|
11788
|
+
debugLoading: "加载中…",
|
|
11789
|
+
debugDataTitle: "可操作数据",
|
|
11790
|
+
debugDataFallback: "主数据对象",
|
|
11791
|
+
debugSchemaPrefix: "schema: ",
|
|
11792
|
+
debugSchemaDeclared: "已声明",
|
|
11793
|
+
debugSchemaMissing: "未声明",
|
|
11794
|
+
debugSubagentTitle: "子 Agent",
|
|
11795
|
+
debugEnabled: "启用",
|
|
11796
|
+
debugYes: "是",
|
|
11797
|
+
debugNo: "否",
|
|
11798
|
+
debugMaxDepth: "最大递归",
|
|
11799
|
+
debugMaxParallel: "并行上限",
|
|
11800
|
+
debugExtraTools: "额外工具",
|
|
11801
|
+
debugDefaultReadonly: "默认只读",
|
|
11802
|
+
debugVerifyTitle: "Verify 自检",
|
|
11803
|
+
debugMaxAttempts: "自纠上限",
|
|
11804
|
+
debugAdversarial: "对抗验证",
|
|
11805
|
+
debugOn: "开启",
|
|
11806
|
+
debugOff: "关闭",
|
|
11807
|
+
debugAdversarialModel: "对抗模型",
|
|
11808
|
+
debugSameAsMain: "(同主)",
|
|
11809
|
+
debugTodosTitle: "任务清单",
|
|
11810
|
+
debugMemoryTitle: "持久指令 (memory)",
|
|
11811
|
+
debugLastCompTitle: "上轮压缩",
|
|
11812
|
+
debugTriggered: "触发",
|
|
11813
|
+
debugNotTriggered: "✗(未达阈值)",
|
|
11814
|
+
debugRoundsSummarized: "摘要轮次",
|
|
11815
|
+
debugCountSuffix: " 条",
|
|
11816
|
+
debugStrategy: "策略",
|
|
11817
|
+
debugDecision: "压缩决策",
|
|
11818
|
+
debugSummaryMode: "摘要",
|
|
11819
|
+
debugSkillNoReader: "当前 SDK 未注入 getSkillContent,无法查看 skill 全文",
|
|
11820
|
+
debugSkillEmpty: "skill 无内容或读取失败",
|
|
11821
|
+
skillPanelTitle: "🧩 Skill 管理",
|
|
11822
|
+
skillEditingPrefix: "编辑 Skill: ",
|
|
11823
|
+
skillCreateNew: "创建新 Skill",
|
|
11824
|
+
skillCancelEdit: "取消编辑",
|
|
11825
|
+
skillNameLabel: "名称",
|
|
11826
|
+
skillNamePlaceholder: "如:my-writer",
|
|
11827
|
+
skillDescLabel: "描述",
|
|
11828
|
+
skillDescPlaceholder: "一句话说明用途与触发时机",
|
|
11829
|
+
skillContentLabel: "内容",
|
|
11830
|
+
skillContentPlaceholder: "skill 全文指令(支持 Markdown)",
|
|
11831
|
+
skillSave: "保存修改",
|
|
11832
|
+
skillAdd: "添加 Skill",
|
|
11833
|
+
skillCreatedTitle: "已创建 Skill",
|
|
11834
|
+
skillEmpty: "暂无用户创建的 skill",
|
|
11835
|
+
skillEditBtn: "编辑",
|
|
11836
|
+
skillEditTitle: "加载到表单编辑",
|
|
11837
|
+
skillDeleteBtn: "删除",
|
|
11838
|
+
skillDeleteTitle: "删除该用户 skill",
|
|
11839
|
+
skillErrName: "skill 名不能为空",
|
|
11840
|
+
skillErrDesc: "描述不能为空",
|
|
11841
|
+
skillErrContent: "内容不能为空",
|
|
11842
|
+
skillDupWarnPrefix: "已存在同名用户 skill \"",
|
|
11843
|
+
skillDupWarnSuffix: "\",将覆盖",
|
|
11844
|
+
skillHintA: "创建/编辑的 skill 会自动加入 agent(下轮 system prompt 索引可见),agent 经",
|
|
11845
|
+
skillHintB: "按需加载全文;持久化由独立 SkillStore 管理(默认 indexedDB,与 storage 选项分离),跨刷新自动恢复;可经",
|
|
11846
|
+
skillHintC: "跨页面复用。",
|
|
11847
|
+
codeCopyTitle: "复制代码",
|
|
11848
|
+
codeOpenTitle: "新窗口打开",
|
|
11849
|
+
codePreviewTitlePrefix: "代码预览 · ",
|
|
11850
|
+
codePreviewTab: "预览",
|
|
11851
|
+
codeSourceTab: "源码",
|
|
11852
|
+
codeDemoTitle: "CSS 预览",
|
|
11853
|
+
codeDemoText: "这是一段示例文字,用于展示 CSS 效果。",
|
|
11854
|
+
codeDemoButton: "按钮",
|
|
11855
|
+
codeDemoInput: "输入框"
|
|
11856
|
+
}, Rd = {
|
|
11857
|
+
"zh-CN": Ld,
|
|
11858
|
+
"en-US": {
|
|
11859
|
+
defaultTitle: "AI Assistant",
|
|
11860
|
+
inputPlaceholder: "Type a message, Enter to send...",
|
|
11861
|
+
newSession: "New chat",
|
|
11862
|
+
history: "History",
|
|
11863
|
+
more: "More",
|
|
11864
|
+
close: "Close",
|
|
11865
|
+
debugMenu: "Debug / Logs",
|
|
11866
|
+
debugMenuTitle: "Logs / execution flow / agent info",
|
|
11867
|
+
skillMenu: "Skills",
|
|
11868
|
+
skillMenuTitle: "Create / manage custom skills",
|
|
11869
|
+
clearChat: "Clear conversation",
|
|
11870
|
+
sessionFallbackPrefix: "Session ",
|
|
11871
|
+
justNow: "just now",
|
|
11872
|
+
minutesAgoSuffix: " min ago",
|
|
11873
|
+
emptyGreeting: "How can I help you?",
|
|
11874
|
+
retry: "Retry",
|
|
11875
|
+
undo: "↩ Undo",
|
|
11876
|
+
undoTitle: "Restore the last good state (conversation + page data + workspace)",
|
|
11877
|
+
thinking: "Thinking...",
|
|
11878
|
+
statusRunning: "Running",
|
|
11879
|
+
statusDone: "Success",
|
|
11880
|
+
statusError: "Failed",
|
|
11881
|
+
subagentBadge: "sub",
|
|
11882
|
+
subagentBadgeTitle: "Sub-agent delegation (isolated context, conclusion only)",
|
|
11883
|
+
subagentProgress: "Sub-agent progress",
|
|
11884
|
+
nthCallPrefix: "Call #",
|
|
11885
|
+
nthCallSuffix: "",
|
|
11886
|
+
argsLabel: "Args",
|
|
11887
|
+
resultLabel: "Result",
|
|
11888
|
+
copy: "Copy",
|
|
11889
|
+
copied: "Copied",
|
|
11890
|
+
regenerate: "Regenerate",
|
|
11891
|
+
expand: "Expand",
|
|
11892
|
+
collapse: "Collapse",
|
|
11893
|
+
noResult: "(no result)",
|
|
11894
|
+
displayTruncatedSuffix: "\n…(truncated for display, copy for full)",
|
|
11895
|
+
thinkingCountPrefix: "Thinking… ",
|
|
11896
|
+
charCountSuffix: " chars",
|
|
11897
|
+
reasoningTitle: "Reasoning",
|
|
11898
|
+
truncatedNotePrefix: "(last ",
|
|
11899
|
+
truncatedNoteSuffix: " chars only)",
|
|
11900
|
+
copyThinking: "Copy full reasoning",
|
|
11901
|
+
copyThinkingTruncTitle: "Copy full reasoning (display truncated, copy gets all)",
|
|
11902
|
+
focusChipTitlePrefix: "Focus:",
|
|
11903
|
+
focusChipTitleHint: "(click to view · ✕ remove)",
|
|
11904
|
+
historyFocusChipTitlePrefix: "View ",
|
|
11905
|
+
removeFocus: "Remove this focus",
|
|
11906
|
+
sendHint: "Enter to send · Shift+Enter for newline",
|
|
11907
|
+
sendTitle: "Send",
|
|
11908
|
+
stopTitle: "Stop generating",
|
|
11909
|
+
queuedTitle: "Queued · runs when current finishes",
|
|
11910
|
+
queuedEditTitle: "Edit (fill back into input)",
|
|
11911
|
+
removeQueuedTitle: "Drop this task",
|
|
11912
|
+
humanConfirmTitle: "AI needs your confirmation",
|
|
11913
|
+
recommendPrefix: " Recommend:",
|
|
11914
|
+
approve: "Allow",
|
|
11915
|
+
deny: "Deny",
|
|
11916
|
+
toolConfirmPrefix: "Confirm tool call:",
|
|
11917
|
+
viewArgs: "View args",
|
|
11918
|
+
collapseArgs: "Collapse args",
|
|
11919
|
+
argsTruncatedSuffix: "\n…(truncated)",
|
|
11920
|
+
conflictTitlePrefix: "Write conflict:",
|
|
11921
|
+
conflictTitleSuffix: " was modified externally",
|
|
11922
|
+
conflictDetailTemplate: "The AI prepared to {op} based on the stale value it read, but the property was changed afterwards by external code / another agent / manual edit.",
|
|
11923
|
+
conflictOpWrite: "write",
|
|
11924
|
+
conflictOpDelete: "delete",
|
|
11925
|
+
viewDiff: "View diff",
|
|
11926
|
+
collapseDiff: "Collapse diff",
|
|
11927
|
+
agentValueLabel: "Value AI wants to write",
|
|
11928
|
+
currentValueLabel: "Current value (external)",
|
|
11929
|
+
deleteNoValue: "(delete op has no value)",
|
|
11930
|
+
keepExternal: "Keep external",
|
|
11931
|
+
keepExternalTitle: "Skip the write, keep the external value; AI re-reads then retries",
|
|
11932
|
+
overwrite: "Overwrite",
|
|
11933
|
+
overwriteTitle: "Overwrite external changes with the AI value",
|
|
11934
|
+
restore: "Restore",
|
|
11935
|
+
restoreTitle: "Restore the latest snapshot (checkpoint before the agent op); undo external change, AI does not write",
|
|
11936
|
+
switchFocusTitle: "Switch focus path",
|
|
11937
|
+
exitFocusTitle: "Exit focus",
|
|
11938
|
+
focusPathPlaceholder: "jsonPath, e.g. components.3",
|
|
11939
|
+
focusLabelPlaceholder: "Label (optional)",
|
|
11940
|
+
focusSubmit: "Focus",
|
|
11941
|
+
debugTabLogs: "Logs",
|
|
11942
|
+
debugTabFlow: "Flow",
|
|
11943
|
+
debugTabContext: "Context",
|
|
11944
|
+
debugTabSubagent: "Sub-agents",
|
|
11945
|
+
debugTabInfo: "Agent info",
|
|
11946
|
+
debugClearLogs: "Clear logs",
|
|
11947
|
+
debugTypeContext: "Context",
|
|
11948
|
+
debugTypeLlmRequest: "LLM request",
|
|
11949
|
+
debugTypeLlmResponse: "LLM response",
|
|
11950
|
+
debugTypeToolCall: "Tool call",
|
|
11951
|
+
debugTypeToolResult: "Tool result",
|
|
11952
|
+
debugTypeError: "Error",
|
|
11953
|
+
debugTypeMiddleware: "Middleware",
|
|
11954
|
+
debugFilterAll: "All",
|
|
11955
|
+
debugFlowPrep: "Preparation / other",
|
|
11956
|
+
debugLogsEmpty: "No logs yet. After you send a message, the full agent context and tool calls appear here.",
|
|
11957
|
+
debugFlowEmpty: "No logs yet. After you send a message, the execution flow appears here by round.",
|
|
11958
|
+
debugNoInfo: "No info",
|
|
11959
|
+
debugCardView: "🗂 Cards",
|
|
11960
|
+
debugRequestBody: "📋 Request body",
|
|
11961
|
+
debugViewRawJson: "View raw JSON",
|
|
11962
|
+
debugCollapseRawJson: "Collapse raw JSON",
|
|
11963
|
+
debugModel: "Model",
|
|
11964
|
+
debugTemperature: "Temp",
|
|
11965
|
+
debugMessageCount: "Messages",
|
|
11966
|
+
debugToolsLabel: "Tools",
|
|
11967
|
+
debugContextMessages: "Context messages",
|
|
11968
|
+
debugRoundPrefix: "Round ",
|
|
11969
|
+
debugRoundSuffix: "",
|
|
11970
|
+
debugMsgCountSuffix: " messages",
|
|
11971
|
+
debugToolCountSuffix: " tools",
|
|
11972
|
+
debugToolCallsSuffix: " tool calls",
|
|
11973
|
+
debugResultSuffix: " result",
|
|
11974
|
+
debugTodoPending: "Pending",
|
|
11975
|
+
debugTodoInProgress: "In progress",
|
|
11976
|
+
debugTodoCompleted: "Done",
|
|
11977
|
+
debugSubRunning: "Running",
|
|
11978
|
+
debugSubDone: "Done",
|
|
11979
|
+
debugSubError: "Error",
|
|
11980
|
+
debugLocksTitle: "Component locks",
|
|
11981
|
+
debugSubagentEmpty: "No sub-agents yet. Once the main agent calls use_<id> or spawn_agent, run status and delegation history appear here.",
|
|
11982
|
+
debugSubRunningTitle: "Running",
|
|
11983
|
+
debugSubHistoryTitle: "History",
|
|
11984
|
+
debugStepsBtn: "Steps",
|
|
11985
|
+
debugStepsCountSuffix: " steps",
|
|
11986
|
+
debugTraceEmpty: "Tracing not enabled (capabilities.tracing:true) or no trace yet. Run a round then refresh.",
|
|
11987
|
+
debugMetricRounds: "Rounds",
|
|
11988
|
+
debugMetricTotal: "Total",
|
|
11989
|
+
debugMetricAvg: "Avg/round",
|
|
11990
|
+
debugMetricTools: "Tools",
|
|
11991
|
+
debugMetricCompressions: "Compressions",
|
|
11992
|
+
debugCtxEmpty: "contextInspector not enabled (on by default) or no snapshot yet. Run a round then switch back.",
|
|
11993
|
+
debugCtxOccupancy: "Occupancy",
|
|
11994
|
+
debugCtxThreshold: "compress threshold",
|
|
11995
|
+
debugCtxTokens: "est.",
|
|
11996
|
+
debugCtxWindow: "window",
|
|
11997
|
+
debugCtxThresholdPct: "threshold",
|
|
11998
|
+
debugCtxCategories: "Categories (approx.)",
|
|
11999
|
+
debugCtxLastCompression: "Last compression",
|
|
12000
|
+
debugCtxSummarized: "summarized",
|
|
12001
|
+
debugCtxRoundsSuffix: " rounds",
|
|
12002
|
+
debugCtxRecalled: "recalled",
|
|
12003
|
+
debugCtxAgentDecision: "agent decision: ",
|
|
12004
|
+
debugInfoBasic: "Basics",
|
|
12005
|
+
debugToolCount: "Tools",
|
|
12006
|
+
debugMiddleware: "Middleware",
|
|
12007
|
+
debugMiddlewareStack: "Middleware stack",
|
|
12008
|
+
debugSkillsTitle: "Skills",
|
|
12009
|
+
debugSkillsHint: "click to expand",
|
|
12010
|
+
debugLoading: "Loading…",
|
|
12011
|
+
debugDataTitle: "Operable data",
|
|
12012
|
+
debugDataFallback: "main data object",
|
|
12013
|
+
debugSchemaPrefix: "schema: ",
|
|
12014
|
+
debugSchemaDeclared: "declared",
|
|
12015
|
+
debugSchemaMissing: "not declared",
|
|
12016
|
+
debugSubagentTitle: "Sub-agents",
|
|
12017
|
+
debugEnabled: "Enabled",
|
|
12018
|
+
debugYes: "Yes",
|
|
12019
|
+
debugNo: "No",
|
|
12020
|
+
debugMaxDepth: "Max depth",
|
|
12021
|
+
debugMaxParallel: "Max parallel",
|
|
12022
|
+
debugExtraTools: "Extra tools",
|
|
12023
|
+
debugDefaultReadonly: "read-only by default",
|
|
12024
|
+
debugVerifyTitle: "Verify self-check",
|
|
12025
|
+
debugMaxAttempts: "Max attempts",
|
|
12026
|
+
debugAdversarial: "Adversarial",
|
|
12027
|
+
debugOn: "On",
|
|
12028
|
+
debugOff: "Off",
|
|
12029
|
+
debugAdversarialModel: "Adversarial model",
|
|
12030
|
+
debugSameAsMain: " (same as main)",
|
|
12031
|
+
debugTodosTitle: "Todos",
|
|
12032
|
+
debugMemoryTitle: "Persistent instructions (memory)",
|
|
12033
|
+
debugLastCompTitle: "Last compression",
|
|
12034
|
+
debugTriggered: "Triggered",
|
|
12035
|
+
debugNotTriggered: "✗ (below threshold)",
|
|
12036
|
+
debugRoundsSummarized: "Rounds summarized",
|
|
12037
|
+
debugCountSuffix: "",
|
|
12038
|
+
debugStrategy: "Strategy",
|
|
12039
|
+
debugDecision: "Decision",
|
|
12040
|
+
debugSummaryMode: "summary",
|
|
12041
|
+
debugSkillNoReader: "getSkillContent is not injected in this SDK build; cannot view skill content",
|
|
12042
|
+
debugSkillEmpty: "skill has no content or the read failed",
|
|
12043
|
+
skillPanelTitle: "🧩 Skills",
|
|
12044
|
+
skillEditingPrefix: "Edit skill: ",
|
|
12045
|
+
skillCreateNew: "Create new skill",
|
|
12046
|
+
skillCancelEdit: "Cancel editing",
|
|
12047
|
+
skillNameLabel: "Name",
|
|
12048
|
+
skillNamePlaceholder: "e.g. my-writer",
|
|
12049
|
+
skillDescLabel: "Description",
|
|
12050
|
+
skillDescPlaceholder: "One line: what it does and when to trigger",
|
|
12051
|
+
skillContentLabel: "Content",
|
|
12052
|
+
skillContentPlaceholder: "Full skill instructions (Markdown supported)",
|
|
12053
|
+
skillSave: "Save changes",
|
|
12054
|
+
skillAdd: "Add skill",
|
|
12055
|
+
skillCreatedTitle: "Created skills",
|
|
12056
|
+
skillEmpty: "No user-created skills yet",
|
|
12057
|
+
skillEditBtn: "Edit",
|
|
12058
|
+
skillEditTitle: "Load into the form to edit",
|
|
12059
|
+
skillDeleteBtn: "Delete",
|
|
12060
|
+
skillDeleteTitle: "Delete this user skill",
|
|
12061
|
+
skillErrName: "Skill name cannot be empty",
|
|
12062
|
+
skillErrDesc: "Description cannot be empty",
|
|
12063
|
+
skillErrContent: "Content cannot be empty",
|
|
12064
|
+
skillDupWarnPrefix: "User skill \"",
|
|
12065
|
+
skillDupWarnSuffix: "\" already exists and will be overwritten",
|
|
12066
|
+
skillHintA: "Created/edited skills are automatically added to the agent (visible in the next system prompt index); the agent loads the full text via",
|
|
12067
|
+
skillHintB: "on demand. Persistence is handled by a separate SkillStore (indexedDB by default, independent of the storage option) and survives refreshes; share across pages via",
|
|
12068
|
+
skillHintC: "cross-page reuse.",
|
|
12069
|
+
codeCopyTitle: "Copy code",
|
|
12070
|
+
codeOpenTitle: "Open in new tab",
|
|
12071
|
+
codePreviewTitlePrefix: "Code preview · ",
|
|
12072
|
+
codePreviewTab: "Preview",
|
|
12073
|
+
codeSourceTab: "Source",
|
|
12074
|
+
codeDemoTitle: "CSS Preview",
|
|
12075
|
+
codeDemoText: "Sample text to demonstrate the CSS effect.",
|
|
12076
|
+
codeDemoButton: "Button",
|
|
12077
|
+
codeDemoInput: "Input"
|
|
12078
|
+
}
|
|
12079
|
+
};
|
|
12080
|
+
function zd(e = "zh-CN", t) {
|
|
12081
|
+
let n = {
|
|
12082
|
+
...Ld,
|
|
12083
|
+
...Rd[e]
|
|
12084
|
+
};
|
|
12085
|
+
if (!t) return n;
|
|
12086
|
+
let r = { ...n };
|
|
12087
|
+
for (let e of Object.keys(n)) {
|
|
12088
|
+
let n = t[e];
|
|
12089
|
+
typeof n == "string" && (r[e] = n);
|
|
12090
|
+
}
|
|
12091
|
+
return r;
|
|
11595
12092
|
}
|
|
11596
12093
|
//#endregion
|
|
11597
12094
|
//#region src/core/composables/chatContext.ts
|
|
11598
|
-
var
|
|
11599
|
-
function
|
|
11600
|
-
let t =
|
|
12095
|
+
var Bd = Symbol("chatContext");
|
|
12096
|
+
function Vd(e = {}) {
|
|
12097
|
+
let t = Pd({
|
|
11601
12098
|
fetchResponse: e.fetchResponse,
|
|
11602
12099
|
fetchStream: e.fetchStream,
|
|
11603
12100
|
messages: e.messages,
|
|
@@ -11617,7 +12114,7 @@ function Ld(e = {}) {
|
|
|
11617
12114
|
}, h = /* @__PURE__ */ At({}), g = (e) => h.value[e] === !0, _ = (e) => {
|
|
11618
12115
|
h.value[e] = !g(e);
|
|
11619
12116
|
}, v = /* @__PURE__ */ At(!1), y = (e) => {
|
|
11620
|
-
|
|
12117
|
+
Md(e).then((e) => {
|
|
11621
12118
|
e && (v.value = !0, setTimeout(() => {
|
|
11622
12119
|
v.value = !1;
|
|
11623
12120
|
}, 1500));
|
|
@@ -11630,7 +12127,7 @@ function Ld(e = {}) {
|
|
|
11630
12127
|
};
|
|
11631
12128
|
}), x = Wr(() => (n.messages.length, typeof e.canUndo == "function" && !!e.canUndo())), S = () => {
|
|
11632
12129
|
e.onUndo?.() && (n.error = null);
|
|
11633
|
-
}, C = (e) => new Date(e).toLocaleTimeString(
|
|
12130
|
+
}, C = (e) => new Date(e).toLocaleTimeString(te, {
|
|
11634
12131
|
hour: "2-digit",
|
|
11635
12132
|
minute: "2-digit"
|
|
11636
12133
|
}), w = () => {
|
|
@@ -11644,7 +12141,16 @@ function Ld(e = {}) {
|
|
|
11644
12141
|
if (!r || r.role !== "assistant") return !1;
|
|
11645
12142
|
let i = "reasoning" in r ? r.reasoning : void 0;
|
|
11646
12143
|
return n.loading && e === t.length - 1 && !r.content && !i;
|
|
11647
|
-
}, O = Wr(() => (e.infoTick?.value, e.getFocuses?.() ?? []))
|
|
12144
|
+
}, O = Wr(() => (e.infoTick?.value, e.getFocuses?.() ?? [])), k = (t) => e.onAddFocus ? e.onAddFocus(t) : {
|
|
12145
|
+
ok: !1,
|
|
12146
|
+
error: "focus 未启用"
|
|
12147
|
+
}, A = (t) => {
|
|
12148
|
+
e.onRemoveFocus?.(t);
|
|
12149
|
+
}, ee = () => {
|
|
12150
|
+
e.onClearFocus?.();
|
|
12151
|
+
}, j = (t) => {
|
|
12152
|
+
e.onFocusChipClick?.(t);
|
|
12153
|
+
}, M = Id(e.icons), te = e.locale ?? "zh-CN";
|
|
11648
12154
|
return {
|
|
11649
12155
|
chat: t,
|
|
11650
12156
|
inputText: o,
|
|
@@ -11670,31 +12176,24 @@ function Ld(e = {}) {
|
|
|
11670
12176
|
editQueued: E,
|
|
11671
12177
|
isPendingAssistant: D,
|
|
11672
12178
|
focuses: O,
|
|
11673
|
-
addFocus:
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
clearFocus: () => {
|
|
11681
|
-
e.onClearFocus?.();
|
|
11682
|
-
},
|
|
11683
|
-
focusChipClick: (t) => {
|
|
11684
|
-
e.onFocusChipClick?.(t);
|
|
11685
|
-
},
|
|
11686
|
-
icons: Fd(e.icons)
|
|
12179
|
+
addFocus: k,
|
|
12180
|
+
removeFocus: A,
|
|
12181
|
+
clearFocus: ee,
|
|
12182
|
+
focusChipClick: j,
|
|
12183
|
+
icons: M,
|
|
12184
|
+
locale: te,
|
|
12185
|
+
messages: zd(te, e.dialogMessages)
|
|
11687
12186
|
};
|
|
11688
12187
|
}
|
|
11689
|
-
function
|
|
11690
|
-
let e = Rn(
|
|
12188
|
+
function Hd() {
|
|
12189
|
+
let e = Rn(Bd);
|
|
11691
12190
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
11692
12191
|
return e;
|
|
11693
12192
|
}
|
|
11694
12193
|
//#endregion
|
|
11695
12194
|
//#region src/core/index.headless.ts
|
|
11696
|
-
function
|
|
11697
|
-
return
|
|
12195
|
+
function Ud(e) {
|
|
12196
|
+
return Td(e);
|
|
11698
12197
|
}
|
|
11699
12198
|
//#endregion
|
|
11700
|
-
export {
|
|
12199
|
+
export { Rl as CAPABILITIES, Vl as CONTEXT_PRESETS, Qc as CompressDecisionSchema, is as DEFAULT_PROMPT_SOFT_CAP, nc as DEFAULT_SYSTEM_PROMPT, yc as HTML_VOID_TAGS, Ao as HUMAN_CONFIRM_TOOL_NAME, ai as MIN_CONTEXT_WINDOW, rs as SOFT_CAP_MIN_WINDOW, Zo as STOP_WORDS, Aa as UNSAFE_KEYS, ed as actionsToInspectInfo, $u as actionsToTools, Qr as agentError, Ys as analyzeContext, Ba as applyPatchToClone, Ua as applyPatchToLive, Zr as asAgentError, ic as buildDataPrompt, ac as buildSystemPrompt, Bd as chatContextKey, Du as commitSetToBind, tc as connectMcp, m as constructLlmFromConfig, p as constructOpenLlmSync, Md as copyText, Wi as createAgent, ko as createApprovalMiddleware, Vd as createChatContext, Ud as createChatSdk, Bo as createCheckpointManager, Vo as createCheckpointMiddleware, ul as createConflictManager, Xs as createContextInspectorMiddleware, Fu as createDataOps, Gc as createHtmlFormatCheck, Jc as createHtmlSubagent, No as createHumanConfirmMiddleware, Mo as createHumanConfirmTool, jl as createMemoryBackend, So as createMemoryMiddleware, u as createProxyLlm, jd as createRagSubagent, ao as createSandboxRunner, Bl as createSdkEvents, _d as createSerialRunner, Fl as createSessionStore, pd as createSkillStore, Es as createSubagentMiddleware, us as createSubagentTracker, ks as createSubagentsMiddleware, sd as createUsageHintsMiddleware, As as createVerifyMiddleware, lc as createVfs, Nl as createWebStorageBackend, Is as createWriteBackCheck, Fa as deepClone, rd as defineDataToolset, so as defineSkill, Yc as defineTool, Pa as deleteByPath, $c as deriveTitle, sa as describeSchemaNode, Oi as detectGarbledToolCall, qa as diffObjects, Vu as domToStructure, Uu as domTools, nd as domToolsStatic, $o as estimateMessageTokens, es as estimateRoundTokens, X as estimateTokens, g as extractReasoningDelta, ba as extractSchemaHint, Zs as extractText, h as extractTextDelta, _ as extractUsage, Lu as fetchDocTools, td as fetchTools, Eu as filterByToolMode, Ka as findStrippedKeys, ca as formatConstraints, qr as formatZodIssues, Z as getByPath, Hu as getDomTool, Ku as getEnvSummary, Ji as getSchemaAtPath, Gi as getSchemaTopKeys, li as getTraceMetrics, $ as hashValue, ha as htmlOrchestratorPrompt, ts as indexSummarize, Yu as inspectEnvTool, Xu as inspectTools, el as isChatModel, yi as isContextLengthError, Ki as isPathAllowed, Cl as isQuotaError, ja as isUnsafePath, tu as jpEval, Yr as jsonParseError, Ra as limitDepth, Ia as maybeParseValue, y as normalizeUsage, ci as offloadPassThroughChars, si as offloadThresholdChars, ma as presets, ta as projectBySchema, ea as projectBySchemaDeep, La as projectFields, ns as recallRounds, la as renderSchemaHint, ua as renderSchemaOverview, pa as renderSchemaShallow, zl as resolveCapabilities, Ul as resolveContextOptions, Ll as resolveDialogConfig, ll as resolveLlm, oi as resolveModelCaps, as as resolvePromptSoftCap, Il as resolveStorage, Ga as restoreInPlace, Wa as restoreLive, Xr as routeError, oo as runHostScript, au as runSandboxedScript, Ma as safeMerge, Gu as safeSerialize, Q as safeStringify, ru as searchJson, id as selectBuiltinTools, Na as setByPath, os as shouldTriggerCompression, ga as systemPromptHelpers, Qo as tokenize, Y as toolError, qi as unwrapSchema, Pd as useChat, Hd as useChatContext, xc as validateHtmlFormat, e as z, Jr as zodError };
|