@freecallai/pro 0.0.13 → 0.0.15

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.
Files changed (47) hide show
  1. package/README.md +1 -1
  2. package/dist/{FkpRichText.vue_vue_type_script_setup_true_lang-D-SOdFra.js → FkpRichText.vue_vue_type_script_setup_true_lang-DaSKjAe7.js} +246 -244
  3. package/dist/{KnowledgeArea-ClZoLiaZ.js → KnowledgeArea-BV2T5ecq.js} +1 -1
  4. package/dist/{KnowledgeArea.vue_vue_type_script_setup_true_lang-CoFF-WCe.js → KnowledgeArea.vue_vue_type_script_setup_true_lang-QJZNyAnH.js} +221 -223
  5. package/dist/{ToolForm-BK9epxdr.js → ToolForm-CJRw9QhZ.js} +1 -1
  6. package/dist/agent-prompt-editor/index.js +198 -179
  7. package/dist/agent-prompt-editor/legacy-converter/index.js +188 -162
  8. package/dist/{choice-UgePgrSl.js → choice-BZa68Gpl.js} +1 -1
  9. package/dist/{guard-DPwe4mCm.js → guard-CZOoBb3d.js} +271 -213
  10. package/dist/index-9-vUHS0W.js +15 -0
  11. package/dist/index-B4oT1Q9u.js +5 -0
  12. package/dist/index-BHgHsPrz.js +5 -0
  13. package/dist/index-Bd2S6qOP.js +19 -0
  14. package/dist/{index-CaA13lC9.js → index-BdSClCaD.js} +1 -1
  15. package/dist/{index-BIi3k45j.js → index-BwkcWrL6.js} +1 -1
  16. package/dist/{index-ChuzFuNm.js → index-Cn_sllKh.js} +1 -1
  17. package/dist/{index-DiLMgNEe.js → index-DvDbrMvv.js} +1 -1
  18. package/dist/{index-DfKH-RZq.js → index-OMoExOaa.js} +2 -2
  19. package/dist/{index-RHu4JIw7.js → index-WExTogRL.js} +1 -1
  20. package/dist/{index-v1UD08i6.js → index-w2M63UAJ.js} +1 -1
  21. package/dist/index.js +3 -3
  22. package/dist/{inline-CVF1zEsG.js → inline-BJJy0svW.js} +1 -1
  23. package/dist/{knowledge-DWM6tWnP.js → knowledge-B3aTxExW.js} +1 -1
  24. package/dist/media-extensions-CpwsEWCD.js +338 -0
  25. package/dist/{media-migration-BctCLEuT.js → media-migration-3-xnOp0T.js} +1 -1
  26. package/dist/{media-policy-B1UuSN2e.js → media-policy-BqquGDH1.js} +36 -36
  27. package/dist/{media-upload-DtH-oCtw.js → media-upload-AunEWyNv.js} +1 -1
  28. package/dist/{model-VLLhEQfn.js → model-aED-32GY.js} +10 -6
  29. package/dist/rich-text/index.js +6 -6
  30. package/dist/rich-text/legacy-converter/index.js +905 -842
  31. package/dist/style.css +1 -1
  32. package/dist/types/agent-prompt-editor/model.d.ts +1 -1
  33. package/dist/types/rich-text/config/descriptor.d.ts +2 -0
  34. package/dist/types/rich-text/model/qianniu-video.d.ts +1 -0
  35. package/dist/types/rich-text/plugins/noFollow/descriptor.d.ts +2 -0
  36. package/dist/types/rich-text/plugins/noFollow/index.d.ts +2 -0
  37. package/dist/types/rich-text/plugins/noFollow/token.d.ts +2 -0
  38. package/dist/types/rich-text/plugins/reasoningMarker/descriptor.d.ts +2 -0
  39. package/dist/types/rich-text/plugins/reasoningMarker/index.d.ts +2 -0
  40. package/dist/types/rich-text/plugins/reasoningMarker/token.d.ts +2 -0
  41. package/dist/types/rich-text/plugins/token-catalog.d.ts +2 -0
  42. package/dist/types/rich-text/public/types.d.ts +1 -1
  43. package/dist/types/rich-text/ui/MediaSourceControls.vue.d.ts +6 -6
  44. package/package.json +3 -3
  45. package/dist/index-BMHUPL5x.js +0 -5
  46. package/dist/index-DJLfgC4v.js +0 -5
  47. package/dist/media-extensions-YYbGuUQa.js +0 -341
@@ -1,5 +1,5 @@
1
- import { i as St, h as Ht, j as Ot, k as Ft, l as Lt, f as Dt, m as Tt, n as Kt } from "../../guard-DPwe4mCm.js";
2
- import { a as It } from "../../media-migration-BctCLEuT.js";
1
+ import { i as St, h as Pt, j as Et, k as Ht, l as Lt, f as Ot, m as Tt, n as Kt } from "../../guard-CZOoBb3d.js";
2
+ import { a as jt } from "../../media-migration-3-xnOp0T.js";
3
3
  const Jt = [
4
4
  { id: 1, key: "focus_goods_name", name: "焦点商品名称" },
5
5
  { id: 2, key: "focus_goods_info", name: "焦点商品信息" },
@@ -8,22 +8,22 @@ const Jt = [
8
8
  { id: 5, key: "focus_order_status", name: "焦点订单状态" },
9
9
  { id: 6, key: "shop_name", name: "店铺名称" }
10
10
  ];
11
- function Mt(t) {
11
+ function Dt(t) {
12
12
  if (!Array.isArray(t)) return !1;
13
- const r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), $ = /* @__PURE__ */ new Set();
14
- return t.every((a) => !a || !(typeof a.id == "string" && a.id.trim() === a.id && a.id || typeof a.id == "number" && Number.isSafeInteger(a.id) && a.id > 0) || typeof a.key != "string" || !a.key || a.key.trim() !== a.key || typeof a.name != "string" || !a.name || a.name.trim() !== a.name || /[{}<>\r\n]/u.test(a.name) || r.has(String(a.id)) || s.has(a.key) || $.has(a.name) ? !1 : (r.add(String(a.id)), s.add(a.key), $.add(a.name), !0));
13
+ const r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set();
14
+ return t.every((n) => !n || !(typeof n.id == "string" && n.id.trim() === n.id && n.id || typeof n.id == "number" && Number.isSafeInteger(n.id) && n.id > 0) || typeof n.key != "string" || !n.key || n.key.trim() !== n.key || typeof n.name != "string" || !n.name || n.name.trim() !== n.name || /[{}<>\r\n]/u.test(n.name) || r.has(String(n.id)) || o.has(n.key) || x.has(n.name) ? !1 : (r.add(String(n.id)), o.add(n.key), x.add(n.name), !0));
15
15
  }
16
16
  const vt = Object.freeze(Jt.map((t) => Object.freeze({ ...t })));
17
17
  function Rt(t, r = vt) {
18
- return r.find((s) => s.name === t);
18
+ return r.find((o) => o.name === t);
19
19
  }
20
- function Ut(t, r = vt) {
21
- return r.find((s) => s.key === t);
20
+ function Vt(t, r = vt) {
21
+ return r.find((o) => o.key === t);
22
22
  }
23
23
  function qt(t) {
24
24
  return `{业务属性@${t}}`;
25
25
  }
26
- const Vt = /* @__PURE__ */ new Set([
26
+ const Ut = /* @__PURE__ */ new Set([
27
27
  "todo",
28
28
  "cdp_tag",
29
29
  "separator",
@@ -52,48 +52,48 @@ function Yt(t) {
52
52
  return t.startsWith("#@") ? "size_chart" : t.startsWith("##") ? "table_knowledge" : t.startsWith("$$") ? "small_payment" : t.startsWith("^^") ? "order_remark" : t.startsWith("{自定义Agent}") ? "custom_agent" : t.startsWith("#") ? "variable" : t.startsWith("{业务属性@") || t.startsWith("{属性@") ? "biz_attribute" : t.startsWith("{外部方法@") ? "external_method" : t.startsWith("{智能建单@") || t.startsWith("{智能工单@") ? "ticket" : t.startsWith("{待办") ? "todo" : t.startsWith("{记忆触发点") ? "memory_trigger" : t.startsWith("{分隔符") ? "separator" : t.startsWith("{原话复述") ? "original_repeat" : t.startsWith("{推理") ? "reasoning" : t.startsWith("{顾客标签") || t.startsWith("{意图标签") ? "cdp_tag" : "tool";
53
53
  }
54
54
  function ie(t, r) {
55
- var o;
56
- const s = [], $ = () => {
57
- s.length && s[s.length - 1].type !== "break" && s.push({ type: "break" });
58
- }, a = (d) => {
59
- let m = 0;
60
- for (const c of d.matchAll(Qt))
61
- c.index > m && s.push({ type: "text", text: d.slice(m, c.index) }), s.push({ type: "tag", kind: Yt(c[0]), label: c[0] }), m = c.index + c[0].length;
62
- m < d.length && s.push({ type: "text", text: d.slice(m) });
55
+ var i;
56
+ const o = [], x = () => {
57
+ o.length && o[o.length - 1].type !== "break" && o.push({ type: "break" });
58
+ }, n = (u) => {
59
+ let f = 0;
60
+ for (const d of u.matchAll(Qt))
61
+ d.index > f && o.push({ type: "text", text: u.slice(f, d.index) }), o.push({ type: "tag", kind: Yt(d[0]), label: d[0] }), f = d.index + d[0].length;
62
+ f < u.length && o.push({ type: "text", text: u.slice(f) });
63
63
  };
64
64
  if (t != null && t.trim() && typeof DOMParser < "u") {
65
- const d = new DOMParser().parseFromString(
65
+ const u = new DOMParser().parseFromString(
66
66
  Xt(t),
67
67
  "text/html"
68
- ), m = (c) => {
69
- var e, i;
70
- if (c.nodeType === Node.TEXT_NODE) {
71
- a(c.textContent || "");
68
+ ), f = (d) => {
69
+ var e, y;
70
+ if (d.nodeType === Node.TEXT_NODE) {
71
+ n(d.textContent || "");
72
72
  return;
73
73
  }
74
- if (!(c instanceof Element)) return;
75
- const h = c.tagName.toLowerCase();
74
+ if (!(d instanceof Element)) return;
75
+ const h = d.tagName.toLowerCase();
76
76
  if (["script", "style", "svg", "iframe", "object"].includes(h))
77
77
  return;
78
78
  if (h === "br") {
79
- $();
79
+ x();
80
80
  return;
81
81
  }
82
- if (h === "img" && c.getAttribute("data-tag-icon") === "true")
82
+ if (h === "img" && d.getAttribute("data-tag-icon") === "true")
83
83
  return;
84
84
  if (h === "img" || h === "video") {
85
- const g = c.getAttribute("src") || (h === "video" ? (e = c.querySelector("source[src]")) == null ? void 0 : e.getAttribute("src") : null);
86
- St(g) && s.push({
85
+ const k = d.getAttribute("src") || (h === "video" ? (e = d.querySelector("source[src]")) == null ? void 0 : e.getAttribute("src") : null);
86
+ St(k) && o.push({
87
87
  type: "media",
88
88
  kind: h === "img" ? "image" : "video",
89
- url: g
89
+ url: k
90
90
  });
91
91
  return;
92
92
  }
93
- const k = c.getAttribute("data-tag-type") || (c.getAttribute("data-size") === "true" ? "size_chart" : "") || (c.getAttribute("data-tableKnowledge") === "true" ? "table_knowledge" : "") || (c.getAttribute("data-variable") === "true" ? "variable" : "") || (c.getAttribute("data-divider") === "true" ? "separator" : "");
94
- if (Vt.has(k)) {
95
- const g = (i = c.textContent) == null ? void 0 : i.trim();
96
- g && s.push({ type: "tag", kind: k, label: g });
93
+ const m = d.getAttribute("data-tag-type") || (d.getAttribute("data-size") === "true" ? "size_chart" : "") || (d.getAttribute("data-tableKnowledge") === "true" ? "table_knowledge" : "") || (d.getAttribute("data-variable") === "true" ? "variable" : "") || (d.getAttribute("data-divider") === "true" ? "separator" : "");
94
+ if (Ut.has(m)) {
95
+ const k = (y = d.textContent) == null ? void 0 : y.trim();
96
+ k && o.push({ type: "tag", kind: m, label: k });
97
97
  return;
98
98
  }
99
99
  const l = [
@@ -106,18 +106,18 @@ function ie(t, r) {
106
106
  "blockquote",
107
107
  "pre"
108
108
  ].includes(h);
109
- l && s.length && $(), c.childNodes.forEach(m), l && $();
109
+ l && o.length && x(), d.childNodes.forEach(f), l && x();
110
110
  };
111
- for (d.body.childNodes.forEach(m); ((o = s[s.length - 1]) == null ? void 0 : o.type) === "break"; ) s.pop();
111
+ for (u.body.childNodes.forEach(f); ((i = o[o.length - 1]) == null ? void 0 : i.type) === "break"; ) o.pop();
112
112
  }
113
- return s.some(
114
- (d) => d.type === "tag" || d.type === "media" || d.type === "text" && !!d.text.trim()
115
- ) || (s.length = 0, r != null && r.trim() && a(r)), s;
113
+ return o.some(
114
+ (u) => u.type === "tag" || u.type === "media" || u.type === "text" && !!u.text.trim()
115
+ ) || (o.length = 0, r != null && r.trim() && n(r)), o;
116
116
  }
117
- function p(t, r, s) {
118
- return { ok: !1, issues: [{ path: r, message: s }], raw: t };
117
+ function c(t, r, o) {
118
+ return { ok: !1, issues: [{ path: r, message: o }], raw: t };
119
119
  }
120
- function w(t) {
120
+ function S(t) {
121
121
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
122
122
  }
123
123
  function xt(t) {
@@ -132,10 +132,10 @@ function Zt(t) {
132
132
  xt(t),
133
133
  "text/html"
134
134
  );
135
- return r.querySelectorAll("video").forEach((s) => {
136
- var a;
137
- const $ = s.getAttribute("src") || ((a = s.querySelector("source[src]")) == null ? void 0 : a.getAttribute("src"));
138
- $ && s.setAttribute("src", $), s.replaceChildren();
135
+ return r.querySelectorAll("video").forEach((o) => {
136
+ var n;
137
+ const x = o.getAttribute("src") || ((n = o.querySelector("source[src]")) == null ? void 0 : n.getAttribute("src"));
138
+ x && o.setAttribute("src", x), o.replaceChildren();
139
139
  }), r.body.innerHTML.replace(
140
140
  /<video\b((?:[^"'<>]|"[^"]*"|'[^']*')*)><\/video>/giu,
141
141
  "<video$1/>"
@@ -149,196 +149,209 @@ function lt(t) {
149
149
  return t.getAttribute("data-tag-type") || (t.getAttribute("data-tag") === "no_send_follow_order" ? "no_send_follow_order" : "") || (t.getAttribute("data-divider") === "true" ? "separator" : "") || (t.getAttribute("data-retelling") === "true" ? "original_repeat" : "") || (t.getAttribute("data-size") === "true" ? "size_chart" : "") || (t.getAttribute("data-tableKnowledge") === "true" ? "table_knowledge" : "") || (t.getAttribute("data-variable") === "true" ? "variable" : "") || (t.getAttribute("data-agent") === "true" ? "custom_agent" : "") || (t.getAttribute("data-reasoning") === "true" ? "reasoning" : "") || (t.getAttribute("data-memory-trigger") === "true" ? "memory_trigger" : "") || (/^\{(?:智能建单|智能工单)@/u.test((t.textContent || "").trim()) ? "ticket" : "") || ((t.textContent || "").trim().startsWith("{外部方法@") ? "external_method" : "") || (t.getAttribute("data-tag") === "true" ? "todo" : "");
150
150
  }
151
151
  function Ct(t) {
152
- let r = "", s = 0;
153
- const $ = /<\{原话复述\}|<(?:img|video|hr)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/gu;
154
- for (; s < t.length; ) {
155
- $.lastIndex = s;
156
- const a = $.exec(t);
157
- if (!a) break;
158
- if (r += w(t.slice(s, a.index)), a[0] !== "<{原话复述}") {
159
- r += a[0], s = $.lastIndex;
152
+ let r = "", o = 0;
153
+ const x = /<不发送跟单>|<\{原话复述\}|<(?:img|video|hr)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/gu;
154
+ for (; o < t.length; ) {
155
+ x.lastIndex = o;
156
+ const n = x.exec(t);
157
+ if (!n) break;
158
+ if (r += S(t.slice(o, n.index)), n[0] !== "<{原话复述}") {
159
+ r += n[0] === "<不发送跟单>" ? '<span data-tag="no_send_follow_order">不跟单</span>' : n[0], o = x.lastIndex;
160
160
  continue;
161
161
  }
162
- const o = $.lastIndex;
163
- let d = -1, m = -1;
164
- for (let c = o; c < t.length && !t.startsWith("<{原话复述}", c); c++) {
165
- const h = t[c] === "<" && t.slice(c).match(/^<(?:img|video)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/u);
162
+ const i = x.lastIndex;
163
+ let u = -1, f = -1;
164
+ for (let d = i; d < t.length && !t.startsWith("<{原话复述}", d); d++) {
165
+ const h = t[d] === "<" && t.slice(d).match(/^<(?:img|video)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/u);
166
166
  if (h) {
167
- c += h[0].length - 1;
167
+ d += h[0].length - 1;
168
168
  continue;
169
169
  }
170
- if (t[c] === ">" && (m < 0 && (m = c), /^(?:[ \t]*(?:\r?\n|$)|<\{原话复述\})/u.test(t.slice(c + 1)))) {
171
- d = c;
170
+ if (t[d] === ">" && (f < 0 && (f = d), /^(?:[ \t]*(?:\r?\n|$)|<\{原话复述\})/u.test(t.slice(d + 1)))) {
171
+ u = d;
172
172
  break;
173
173
  }
174
174
  }
175
- if (d < 0 && (d = m), d < 0) {
176
- r += w(a[0]), s = o;
175
+ if (u < 0 && (u = f), u < 0) {
176
+ r += S(n[0]), o = i;
177
177
  continue;
178
178
  }
179
179
  r += `<span data-tag-type="original_repeat" data-original-repeat-template="true"><span data-original-repeat-input="true">${Ct(
180
- t.slice(o, d)
181
- )}</span></span>`, s = d + 1;
180
+ t.slice(i, u)
181
+ )}</span></span>`, o = u + 1;
182
182
  }
183
- return r + w(t.slice(s));
183
+ return r + S(t.slice(o));
184
184
  }
185
- function _t(t, r = !1, s = vt) {
185
+ function _t(t, r = !1, o = vt) {
186
186
  if (typeof DOMParser > "u")
187
- return p(t, "web_content", "当前环境不支持 HTML 解析");
188
- const $ = new DOMParser().parseFromString(
187
+ return c(t, "web_content", "当前环境不支持 HTML 解析");
188
+ const x = new DOMParser().parseFromString(
189
189
  xt(t),
190
190
  "text/html"
191
- ), a = [[]];
192
- let o = null, d = [];
193
- const m = (k) => a[a.length - 1].push(
194
- k.kind === "text" && d.length ? { ...k, marks: [...d] } : k
195
- ), c = (k = !1) => {
196
- (k || a[a.length - 1].length) && a.push([]);
197
- }, h = (k, l) => {
198
- var E, H, M, A, I, F, K, G, tt, O, Z, z, Y, C, et, X;
199
- if (o) return;
200
- if (k.nodeType === 3) {
201
- (k.textContent || "").replace(/\r\n?/g, `
191
+ ), n = [[]];
192
+ let i = null, u = [];
193
+ const f = (m) => n[n.length - 1].push(
194
+ m.kind === "text" && u.length ? { ...m, marks: [...u] } : m
195
+ ), d = (m = !1) => {
196
+ (m || n[n.length - 1].length) && n.push([]);
197
+ }, h = (m, l) => {
198
+ var C, F, j, _, O, K, J, G, tt, D, Z, P, Y, M, et, z;
199
+ if (i) return;
200
+ if (m.nodeType === 3) {
201
+ (m.textContent || "").replace(/\r\n?/g, `
202
202
  `).replace(
203
203
  /\^\^订单备注-[\s\S]*?\^\^|<\{原话复述\}[^<>]*>/gu,
204
- (L) => L.replace(/\n/g, "")
204
+ (W) => W.replace(/\n/g, "")
205
205
  ).split(`
206
- `).forEach((L, V) => {
207
- V && c(!0), L = L.replace(/\uE000/g, `
206
+ `).forEach((W, Q) => {
207
+ Q && d(!0), W = W.replace(/\uE000/g, `
208
208
  `);
209
- let x = 0;
210
- for (const b of L.matchAll(
209
+ let w = 0;
210
+ for (const b of W.matchAll(
211
211
  /<\{原话复述\}([^<>]*)>|\{待办(?:@([^{}]+))?\}/gu
212
212
  )) {
213
213
  if (b[1] === void 0 && !r) continue;
214
- const S = b.index || 0;
215
- S > x && m({ kind: "text", value: L.slice(x, S) }), m(
216
- b[1] !== void 0 ? { kind: "originalReply", html: w(b[1]) } : { kind: "todo", value: b[0] }
217
- ), x = S + b[0].length;
214
+ const N = b.index || 0;
215
+ N > w && f({ kind: "text", value: W.slice(w, N) }), f(
216
+ b[1] !== void 0 ? { kind: "originalReply", html: S(b[1]) } : { kind: "todo", value: b[0] }
217
+ ), w = N + b[0].length;
218
218
  }
219
- x < L.length && m({ kind: "text", value: L.slice(x) });
219
+ w < W.length && f({ kind: "text", value: W.slice(w) });
220
220
  });
221
221
  return;
222
222
  }
223
- if (k.nodeType !== 1) return;
224
- const e = k, i = e.tagName.toLowerCase(), g = lt(e);
225
- if (i === "span" && g === "original_repeat" && e.getAttribute("data-original-repeat-template") === "true") {
226
- const D = e.querySelectorAll('[data-original-repeat-input="true"]');
227
- if (D.length !== 1) {
228
- o = { path: l, message: "原话模板缺少唯一的回复输入区" };
223
+ if (m.nodeType !== 1) return;
224
+ const e = m, y = e.tagName.toLowerCase(), k = lt(e);
225
+ if (y === "span" && k === "original_repeat" && e.getAttribute("data-original-repeat-template") === "true") {
226
+ const R = e.querySelectorAll('[data-original-repeat-input="true"]');
227
+ if (R.length !== 1) {
228
+ i = { path: l, message: "原话模板缺少唯一的回复输入区" };
229
229
  return;
230
230
  }
231
- m({ kind: "originalReply", html: D[0].innerHTML });
231
+ f({ kind: "originalReply", html: R[0].innerHTML });
232
232
  return;
233
233
  }
234
- if (i === "span" && g) {
235
- if (g === "ticket") {
236
- const x = (e.textContent || "").trim(), b = Lt(x);
237
- !b || e.hasAttribute("data-ticket-id") && e.getAttribute("data-ticket-id") !== b.key || e.hasAttribute("data-ticket-name") && e.getAttribute("data-ticket-name") !== b.label || e.hasAttribute("data-ticket-protocol") && e.getAttribute("data-ticket-protocol") !== (((E = b.params) == null ? void 0 : E.protocol) || "current") || e.getAttribute("data-invalid") === "true" ? o = {
234
+ if (y === "span" && k) {
235
+ if (k === "ticket") {
236
+ const w = (e.textContent || "").trim(), b = Lt(w);
237
+ !b || e.hasAttribute("data-ticket-id") && e.getAttribute("data-ticket-id") !== b.key || e.hasAttribute("data-ticket-name") && e.getAttribute("data-ticket-name") !== b.label || e.hasAttribute("data-ticket-protocol") && e.getAttribute("data-ticket-protocol") !== (((C = b.params) == null ? void 0 : C.protocol) || "current") || e.getAttribute("data-invalid") === "true" ? i = {
238
238
  path: l,
239
239
  message: "工单标签格式无效、引用已失效或属性与内容不一致"
240
- } : m({ kind: "text", value: x });
240
+ } : f({ kind: "text", value: w });
241
241
  return;
242
242
  }
243
- if (g === "external_method") {
244
- const x = (e.textContent || "").trim(), b = Tt(x);
245
- !b || ((H = b.attrs) == null ? void 0 : H.key) !== "external_method" || e.hasAttribute("data-scene-id") && e.getAttribute("data-scene-id") !== b.attrs.params.sceneId || e.hasAttribute("data-scene-name") && e.getAttribute("data-scene-name") !== b.attrs.params.sceneName || e.getAttribute("data-invalid") === "true" ? o = { path: l, message: "外部方法引用无效或属性与内容不一致" } : m({ kind: "text", value: x });
243
+ if (k === "external_method") {
244
+ const w = (e.textContent || "").trim(), b = Tt(w);
245
+ !b || ((F = b.attrs) == null ? void 0 : F.key) !== "external_method" || e.hasAttribute("data-scene-id") && e.getAttribute("data-scene-id") !== b.attrs.params.sceneId || e.hasAttribute("data-scene-name") && e.getAttribute("data-scene-name") !== b.attrs.params.sceneName || e.getAttribute("data-invalid") === "true" ? i = { path: l, message: "外部方法引用无效或属性与内容不一致" } : f({ kind: "text", value: w });
246
246
  return;
247
247
  }
248
- if (g === "no_send_follow_order") {
249
- o = { path: l, message: "旧不发送跟单标签尚无新知识节点承载" };
248
+ if (k === "no_send_follow_order") {
249
+ ["不跟单", "不发送跟单", "<不发送跟单>"].includes(
250
+ (e.textContent || "").trim()
251
+ ) ? f({ kind: "noFollow", value: "<不发送跟单>" }) : i = { path: l, message: "不跟单标签内容无效" };
250
252
  return;
251
253
  }
252
- if (g === "table_knowledge") {
253
- const x = (e.textContent || "").trim(), b = e.getAttribute("data-table-name") || ((M = x.match(/^##([^#\r\n]+)##$/u)) == null ? void 0 : M[1]) || "";
254
- !b.trim() || /[#\r\n]/u.test(b) || x && x !== `##${b}##` || e.getAttribute("data-invalid") === "true" ? o = {
254
+ if (k === "table_knowledge") {
255
+ const w = (e.textContent || "").trim(), b = e.getAttribute("data-table-name") || ((j = w.match(/^##([^#\r\n]+)##$/u)) == null ? void 0 : j[1]) || "";
256
+ !b.trim() || /[#\r\n]/u.test(b) || w && w !== `##${b}##` || e.getAttribute("data-invalid") === "true" ? i = {
255
257
  path: l,
256
258
  message: "表格知识名称无效、与标签不一致或引用已失效"
257
- } : m({
259
+ } : f({
258
260
  kind: "tableKnowledge",
259
261
  name: b,
260
262
  key: e.getAttribute("data-table-id") || b
261
263
  });
262
264
  return;
263
265
  }
264
- if (g === "size_chart") {
265
- o = { path: l, message: `旧${g}标签尚无新知识节点承载` };
266
+ if (k === "size_chart") {
267
+ i = { path: l, message: `旧${k}标签尚无新知识节点承载` };
266
268
  return;
267
269
  }
268
- if (g === "biz_attribute") {
269
- const x = (e.textContent || "").trim(), b = (A = x.match(
270
+ if (k === "biz_attribute") {
271
+ const w = (e.textContent || "").trim(), b = (_ = w.match(
270
272
  /^\{业务属性@([^{}<>\r\n]+)\}$/u
271
- )) == null ? void 0 : A[1], S = ((I = e.getAttribute("data-attr-name")) == null ? void 0 : I.trim()) || b, Q = S && Rt(S, s);
272
- !Q || x !== S && x !== qt(S) || e.hasAttribute("data-attr-key") && e.getAttribute("data-attr-key") !== Q.key || e.hasAttribute("data-attr-id") && e.getAttribute("data-attr-id") !== String(Q.id) ? o = { path: l, message: "业务属性标签名称、ID 或 key 无效" } : m({ kind: "attribute", name: S, key: Q.key });
273
+ )) == null ? void 0 : _[1], N = ((O = e.getAttribute("data-attr-name")) == null ? void 0 : O.trim()) || b, X = N && Rt(N, o);
274
+ !X || w !== N && w !== qt(N) || e.hasAttribute("data-attr-key") && e.getAttribute("data-attr-key") !== X.key || e.hasAttribute("data-attr-id") && e.getAttribute("data-attr-id") !== String(X.id) ? i = { path: l, message: "业务属性标签名称、ID 或 key 无效" } : f({ kind: "attribute", name: N, key: X.key });
273
275
  return;
274
276
  }
275
- if (g === "small_payment" || g === "order_remark") {
276
- if (g === "order_remark" && e.hasAttribute("data-order-remark")) {
277
+ if (k === "small_payment" || k === "order_remark") {
278
+ if (k === "order_remark" && e.hasAttribute("data-order-remark")) {
277
279
  const it = Kt(
278
280
  e.getAttribute("data-order-remark") || ""
279
- ), ot = it && Dt(it);
280
- ot ? m({ kind: "text", value: ot }) : o = { path: l, message: "旧订单备注数据无效" };
281
+ ), ot = it && Ot(it);
282
+ ot ? f({ kind: "text", value: ot }) : i = { path: l, message: "旧订单备注数据无效" };
281
283
  return;
282
284
  }
283
- const x = e.textContent || "", b = Tt(x), S = (F = b == null ? void 0 : b.attrs) == null ? void 0 : F.params;
284
- (g === "small_payment" ? ((K = b == null ? void 0 : b.attrs) == null ? void 0 : K.key) === "small_payment" && e.getAttribute("data-max-amount-cent") === String(Number(S == null ? void 0 : S.amount) * 100) : ((G = b == null ? void 0 : b.attrs) == null ? void 0 : G.key) === "order_note" && e.getAttribute("data-remark-id") === (S == null ? void 0 : S.id) && e.getAttribute("data-remark-mode") === ((S == null ? void 0 : S.contentMode) === "fixed" ? "fixed" : "extract") && e.getAttribute("data-remark-flag") === (S == null ? void 0 : S.flag) && e.getAttribute("data-remark-keep-flag") === (S != null && S.preserveFlag ? "1" : "0") && e.getAttribute("data-remark-position") === (S == null ? void 0 : S.position) && e.getAttribute("data-remark-content") === (S == null ? void 0 : S.content)) ? m({ kind: "text", value: x }) : o = { path: l, message: `${g} 标签属性与内容不一致` };
285
+ const w = e.textContent || "", b = Tt(w), N = (K = b == null ? void 0 : b.attrs) == null ? void 0 : K.params;
286
+ (k === "small_payment" ? ((J = b == null ? void 0 : b.attrs) == null ? void 0 : J.key) === "small_payment" && e.getAttribute("data-max-amount-cent") === String(Number(N == null ? void 0 : N.amount) * 100) : ((G = b == null ? void 0 : b.attrs) == null ? void 0 : G.key) === "order_note" && e.getAttribute("data-remark-id") === (N == null ? void 0 : N.id) && e.getAttribute("data-remark-mode") === ((N == null ? void 0 : N.contentMode) === "fixed" ? "fixed" : "extract") && e.getAttribute("data-remark-flag") === (N == null ? void 0 : N.flag) && e.getAttribute("data-remark-keep-flag") === (N != null && N.preserveFlag ? "1" : "0") && e.getAttribute("data-remark-position") === (N == null ? void 0 : N.position) && e.getAttribute("data-remark-content") === (N == null ? void 0 : N.content)) ? f({ kind: "text", value: w }) : i = { path: l, message: `${k} 标签属性与内容不一致` };
285
287
  return;
286
288
  }
287
- if (g === "variable") {
288
- const x = (e.textContent || "").trim(), b = (O = (tt = x.match(/^#([^#\r\n]+)#$/u)) == null ? void 0 : tt[1]) == null ? void 0 : O.trim(), Q = ((Z = e.getAttribute("data-variable-name")) == null ? void 0 : Z.trim()) || b;
289
- !Q || !b || b !== Q ? o = { path: l, message: "变量标签名称与显示内容不一致" } : m({
289
+ if (k === "variable") {
290
+ const w = (e.textContent || "").trim(), b = (D = (tt = w.match(/^#([^#\r\n]+)#$/u)) == null ? void 0 : tt[1]) == null ? void 0 : D.trim(), X = ((Z = e.getAttribute("data-variable-name")) == null ? void 0 : Z.trim()) || b;
291
+ !X || !b || b !== X ? i = { path: l, message: "变量标签名称与显示内容不一致" } : f({
290
292
  kind: "text",
291
- value: Q === "订单链接" ? "{订单链接}" : x
293
+ value: X === "订单链接" ? "{订单链接}" : w
292
294
  });
293
295
  return;
294
296
  }
295
- const D = e.getAttribute("data-tag-name") || e.getAttribute("data-variable-name") || e.getAttribute("data-agent-name") || "", L = e.textContent || "";
296
- if (g === "cdp_tag" && (!e.getAttribute("data-tag-id") || /已失效/u.test(L))) {
297
- o = { path: l, message: "失效顾客标签需要只读保全" };
297
+ const R = e.getAttribute("data-tag-name") || e.getAttribute("data-variable-name") || e.getAttribute("data-agent-name") || "", W = e.textContent || "";
298
+ if (k === "cdp_tag" && (!e.getAttribute("data-tag-id") || /已失效/u.test(W))) {
299
+ i = { path: l, message: "失效顾客标签需要只读保全" };
298
300
  return;
299
301
  }
300
- if (g === "todo" || g === "cdp_tag") {
301
- const x = g === "todo" ? Nt(L) : (z = L.match(/\{(?:顾客标签|意图标签)@([^{}]+)\}/u)) == null ? void 0 : z[1], b = e.getAttribute("data-tag-name");
302
- if (x && b && x !== b) {
303
- o = { path: l, message: `${g} 标签名称与显示内容不一致` };
302
+ if (k === "todo" || k === "cdp_tag") {
303
+ const w = k === "todo" ? Nt(W) : (P = W.match(/\{(?:顾客标签|意图标签)@([^{}]+)\}/u)) == null ? void 0 : P[1], b = e.getAttribute("data-tag-name");
304
+ if (w && b && w !== b) {
305
+ i = { path: l, message: `${k} 标签名称与显示内容不一致` };
304
306
  return;
305
307
  }
306
308
  }
307
- const V = {
308
- todo: ((Y = L.match(/\{待办(?:@[^{}]+)?\}/u)) == null ? void 0 : Y[0]) || (D ? `{待办@${D}}` : ""),
309
- cdp_tag: ((C = L.match(/\{(?:顾客标签|意图标签)@[^{}]+\}/u)) == null ? void 0 : C[0]) || (D ? `{顾客标签@${D}}` : ""),
309
+ const Q = {
310
+ todo: ((Y = W.match(/\{待办(?:@[^{}]+)?\}/u)) == null ? void 0 : Y[0]) || (R ? `{待办@${R}}` : ""),
311
+ cdp_tag: ((M = W.match(/\{(?:顾客标签|意图标签)@[^{}]+\}/u)) == null ? void 0 : M[0]) || (R ? `{顾客标签@${R}}` : ""),
310
312
  separator: "{分隔符}",
311
313
  original_repeat: "{原话复述}",
312
- custom_agent: ((et = L.match(/\{自定义Agent\}@[\s\S]+/u)) == null ? void 0 : et[0]) || (D ? `{自定义Agent}@${D}` : ""),
314
+ custom_agent: ((et = W.match(/\{自定义Agent\}@[\s\S]+/u)) == null ? void 0 : et[0]) || (R ? `{自定义Agent}@${R}` : ""),
313
315
  reasoning: "{推理}",
314
316
  memory_trigger: "{记忆触发点}"
315
317
  };
316
- V[g] ? m({
317
- kind: g === "todo" ? "todo" : "text",
318
- value: V[g]
319
- }) : o = { path: l, message: `旧标签 ${g} 无法映射到新模型` };
318
+ if (k === "reasoning") {
319
+ f({
320
+ kind: "reasoningMarker",
321
+ value: "{推理}",
322
+ inline: e.getAttribute("data-fkp-reasoning-inline") === "true"
323
+ });
324
+ return;
325
+ }
326
+ Q[k] ? f({
327
+ kind: k === "todo" ? "todo" : "text",
328
+ value: Q[k]
329
+ }) : i = { path: l, message: `旧标签 ${k} 无法映射到新模型` };
320
330
  return;
321
331
  }
322
- if (i === "img" && e.getAttribute("data-tag-icon") === "true") return;
323
- if (i === "img" || i === "video") {
324
- const D = e.getAttribute("src") || (i === "video" ? (X = e.querySelector("source[src]")) == null ? void 0 : X.getAttribute("src") : null) || "";
325
- St(D) ? m({
332
+ if (y === "img" && e.getAttribute("data-tag-icon") === "true") return;
333
+ if (y === "img" || y === "video") {
334
+ const R = e.getAttribute("src") || (y === "video" ? (z = e.querySelector("source[src]")) == null ? void 0 : z.getAttribute("src") : null) || "";
335
+ St(R) ? f({
326
336
  kind: "media",
327
- media: i === "img" ? "image" : "video",
328
- src: D,
337
+ media: y === "img" ? "image" : "video",
338
+ src: R,
329
339
  path: l,
330
340
  metadata: Object.fromEntries(
331
341
  [
332
- ["assetId", e.getAttribute("data-asset-id")],
342
+ [
343
+ "assetId",
344
+ e.getAttribute("data-asset-id") || e.getAttribute("data-video-id") || (e.getAttribute("data-source-type") === "qianniuVideo" ? e.getAttribute("id") : null)
345
+ ],
333
346
  ["name", e.getAttribute("data-media-name")],
334
347
  ["poster", e.getAttribute("poster")],
335
348
  ["sourceType", e.getAttribute("data-source-type")]
336
- ].filter((L) => L[1] !== null)
349
+ ].filter((W) => W[1] !== null)
337
350
  )
338
- }) : o = { path: l, message: "媒体地址无效" };
351
+ }) : i = { path: l, message: "媒体地址无效" };
339
352
  return;
340
353
  }
341
- const j = {
354
+ const $ = {
342
355
  b: "bold",
343
356
  strong: "bold",
344
357
  i: "italic",
@@ -348,83 +361,83 @@ function _t(t, r = !1, s = vt) {
348
361
  strike: "strike",
349
362
  del: "strike",
350
363
  code: "code"
351
- }[i];
352
- if (j || i === "a") {
353
- const D = d, L = e.getAttribute("href");
354
- if (i === "a" && L && !St(L)) {
355
- o = { path: l, message: "链接地址无效" };
364
+ }[y];
365
+ if ($ || y === "a") {
366
+ const R = u, W = e.getAttribute("href");
367
+ if (y === "a" && W && !St(W)) {
368
+ i = { path: l, message: "链接地址无效" };
356
369
  return;
357
370
  }
358
- const V = j ? { type: j } : L ? {
371
+ const Q = $ ? { type: $ } : W ? {
359
372
  type: "link",
360
373
  attrs: Object.fromEntries(
361
- ["href", "target", "rel", "title", "class"].filter((x) => e.hasAttribute(x)).map((x) => [x, e.getAttribute(x)])
374
+ ["href", "target", "rel", "title", "class"].filter((w) => e.hasAttribute(w)).map((w) => [w, e.getAttribute(w)])
362
375
  )
363
376
  } : null;
364
- V && !d.some((x) => x.type === V.type) && (d = [...d, V]), Array.from(e.childNodes).forEach(
365
- (x, b) => h(x, `${l}.childNodes[${b}]`)
366
- ), d = D;
377
+ Q && !u.some((w) => w.type === Q.type) && (u = [...u, Q]), Array.from(e.childNodes).forEach(
378
+ (w, b) => h(w, `${l}.childNodes[${b}]`)
379
+ ), u = R;
367
380
  return;
368
381
  }
369
- if (["ul", "ol", "blockquote", "pre", "hr"].includes(i)) {
370
- c(), m({ kind: "block", tag: i, html: e.outerHTML }), c(!0);
382
+ if (["ul", "ol", "blockquote", "pre", "hr"].includes(y)) {
383
+ d(), f({ kind: "block", tag: y, html: e.outerHTML }), d(!0);
371
384
  return;
372
385
  }
373
- if (i === "br") {
386
+ if (y === "br") {
374
387
  if (e.getAttribute("data-hard-break") === "true") {
375
- m({ kind: "hardBreak" });
388
+ f({ kind: "hardBreak" });
376
389
  return;
377
390
  }
378
- c(!0);
391
+ d(!0);
379
392
  return;
380
393
  }
381
- if (!["p", "div", "span"].includes(i) || i === "span" && e.attributes.length > 0) {
382
- o = { path: l, message: `HTML 标签 ${i} 无法无损转换` };
394
+ if (!["p", "div", "span"].includes(y) || y === "span" && e.attributes.length > 0) {
395
+ i = { path: l, message: `HTML 标签 ${y} 无法无损转换` };
383
396
  return;
384
397
  }
385
- (i === "p" || i === "div") && c();
386
- const R = a.length;
398
+ (y === "p" || y === "div") && d();
399
+ const T = n.length;
387
400
  Array.from(e.childNodes).forEach(
388
- (D, L) => h(D, `${l}.childNodes[${L}]`)
389
- ), (i === "p" || i === "div") && (a.length === R || a[a.length - 1].length) && c(!0);
401
+ (R, W) => h(R, `${l}.childNodes[${W}]`)
402
+ ), (y === "p" || y === "div") && (n.length === T || n[n.length - 1].length) && d(!0);
390
403
  };
391
- return Array.from($.body.childNodes).forEach(
392
- (k, l) => h(k, `web_content.childNodes[${l}]`)
393
- ), o ? { ok: !1, issues: [o], raw: t } : (a.length > 1 && !a[a.length - 1].length && !t.endsWith(`
394
- `) && a.pop(), { ok: !0, value: a });
404
+ return Array.from(x.body.childNodes).forEach(
405
+ (m, l) => h(m, `web_content.childNodes[${l}]`)
406
+ ), i ? { ok: !1, issues: [i], raw: t } : (n.length > 1 && !n[n.length - 1].length && !t.endsWith(`
407
+ `) && n.pop(), { ok: !0, value: n });
395
408
  }
396
409
  function ht(t) {
397
410
  return t.every(
398
- (r) => r.kind === "text" || r.kind === "todo" || r.kind === "attribute" || r.kind === "tableKnowledge"
411
+ (r) => r.kind === "text" || r.kind === "todo" || r.kind === "noFollow" || r.kind === "reasoningMarker" || r.kind === "attribute" || r.kind === "tableKnowledge"
399
412
  ) ? t.map(
400
413
  (r) => r.kind === "tableKnowledge" ? `##${r.name}##` : r.kind === "attribute" ? qt(r.name) : r.value
401
414
  ).join("") : null;
402
415
  }
403
- function Gt(t, r, s, $) {
404
- var m, c;
405
- const a = [], o = /(#@[^#]+@#|##[^#]+##|#[^#\r\n]+#|\{[^{}]+\}|\[sep\]|\$\$小额打款@[^$\r\n]*\$\$|\^\^订单备注-[\s\S]*?\^\^)/gu;
406
- let d = 0;
407
- for (const h of t.matchAll(o)) {
408
- const k = h.index || 0;
409
- if (k > d) {
410
- const e = t.slice(d, k);
416
+ function Gt(t, r, o, x) {
417
+ var f, d;
418
+ const n = [], i = /(#@[^#]+@#|##[^#]+##|#[^#\r\n]+#|\{[^{}]+\}|\[sep\]|\$\$小额打款@[^$\r\n]*\$\$|\^\^订单备注-[\s\S]*?\^\^)/gu;
419
+ let u = 0;
420
+ for (const h of t.matchAll(i)) {
421
+ const m = h.index || 0;
422
+ if (m > u) {
423
+ const e = t.slice(u, m);
411
424
  if (/\$\$小额打款|\^\^订单备注-|\{业务属性@|\{(?:智能建单|智能工单|外部方法)@|<不发送跟单>/u.test(
412
425
  e
413
426
  ))
414
- return p(t, r, "工具、业务属性或不发送跟单标记格式错误");
415
- a.push({ type: "text", text: e });
427
+ return c(t, r, "工具、业务属性或不发送跟单标记格式错误");
428
+ n.push({ type: "text", text: e });
416
429
  }
417
430
  const l = h[0];
418
431
  if (/^\{智能(?:建单|工单)/u.test(l)) {
419
432
  const e = Lt(l);
420
- if (!e) return p(t, r, `工单标记 ${l} 格式错误`);
421
- a.push({ type: "businessToken", attrs: { kind: "ticket", ...e } });
433
+ if (!e) return c(t, r, `工单标记 ${l} 格式错误`);
434
+ n.push({ type: "businessToken", attrs: { kind: "ticket", ...e } });
422
435
  } else if (l.startsWith("$$小额打款@") || l.startsWith("^^订单备注-") || l.startsWith("{外部方法")) {
423
436
  const e = Tt(l);
424
- if (!e) return p(t, r, `工具标记 ${l} 格式错误`);
425
- a.push(e);
437
+ if (!e) return c(t, r, `工具标记 ${l} 格式错误`);
438
+ n.push(e);
426
439
  } else if (l === "{分隔符}" || l === "[sep]")
427
- a.push({
440
+ n.push({
428
441
  type: "businessToken",
429
442
  attrs: {
430
443
  kind: "separator",
@@ -435,90 +448,90 @@ function Gt(t, r, s, $) {
435
448
  });
436
449
  else if (/^##[^#\r\n]+##$/u.test(l)) {
437
450
  const e = l.slice(2, -2);
438
- if (!e.trim()) return p(t, r, "表格知识名称不能为空");
439
- a.push({
451
+ if (!e.trim()) return c(t, r, "表格知识名称不能为空");
452
+ n.push({
440
453
  type: "businessToken",
441
454
  attrs: { kind: "tableKnowledge", key: e, label: e }
442
455
  });
443
456
  } else if (l === "{订单链接}" || /^#[^#\r\n]+#$/u.test(l)) {
444
- const e = l === "{订单链接}" ? "订单链接" : l.slice(1, -1).trim(), i = (m = s.variable) == null ? void 0 : m.call(s, e);
445
- if (!e || !(i != null && i.key) || i.label !== e)
446
- return p(t, r, `变量 ${e} 缺少可解析的引用`);
447
- a.push({
457
+ const e = l === "{订单链接}" ? "订单链接" : l.slice(1, -1).trim(), y = (f = o.variable) == null ? void 0 : f.call(o, e);
458
+ if (!e || !(y != null && y.key) || y.label !== e)
459
+ return c(t, r, `变量 ${e} 缺少可解析的引用`);
460
+ n.push({
448
461
  type: "businessToken",
449
- attrs: { kind: "variable", key: i.key, label: i.label, token: l }
462
+ attrs: { kind: "variable", key: y.key, label: y.label, token: l }
450
463
  });
451
464
  } else if (l.startsWith("{业务属性@")) {
452
- const e = (c = l.match(/^\{业务属性@([^{}<>\r\n]+)\}$/u)) == null ? void 0 : c[1], i = e && Rt(e, $);
453
- if (!i)
454
- return p(t, r, `业务属性 ${e || l} 不在旧目录中`);
455
- a.push({
465
+ const e = (d = l.match(/^\{业务属性@([^{}<>\r\n]+)\}$/u)) == null ? void 0 : d[1], y = e && Rt(e, x);
466
+ if (!y)
467
+ return c(t, r, `业务属性 ${e || l} 不在旧目录中`);
468
+ n.push({
456
469
  type: "businessToken",
457
- attrs: { kind: "attribute", key: i.key, label: i.name }
470
+ attrs: { kind: "attribute", key: y.key, label: y.name }
458
471
  });
459
472
  } else {
460
473
  if (/^\{(?:待办|原话复述|推理|记忆触发点|顾客标签|意图标签|自定义Agent)/u.test(
461
474
  l
462
475
  ) || l.startsWith("#@"))
463
- return p(t, r, `正文标记 ${l} 无法在当前位置转换`);
464
- a.push({ type: "text", text: l });
476
+ return c(t, r, `正文标记 ${l} 无法在当前位置转换`);
477
+ n.push({ type: "text", text: l });
465
478
  }
466
- d = k + l.length;
479
+ u = m + l.length;
467
480
  }
468
- if (d < t.length) {
469
- const h = t.slice(d);
481
+ if (u < t.length) {
482
+ const h = t.slice(u);
470
483
  if (/\$\$小额打款|\^\^订单备注-|\{业务属性@|\{(?:智能建单|智能工单|外部方法)@|<不发送跟单>/u.test(
471
484
  h
472
485
  ))
473
- return p(t, r, "工具、业务属性或不发送跟单标记格式错误");
474
- a.push({ type: "text", text: h });
486
+ return c(t, r, "工具、业务属性或不发送跟单标记格式错误");
487
+ n.push({ type: "text", text: h });
475
488
  }
476
- return { ok: !0, value: a };
489
+ return { ok: !0, value: n };
477
490
  }
478
491
  function zt(t, r) {
479
- const s = /* @__PURE__ */ new Set();
480
- let $ = 0, a = null;
481
- const o = (d, m) => {
482
- var c, h, k;
483
- if (d.type === "businessToken" && ((c = d.attrs) == null ? void 0 : c.kind) === "tool" && (d.attrs.key === "small_payment" && ++$ > 1 && (a = m), d.attrs.key === "order_note")) {
484
- const l = String(((h = d.attrs.params) == null ? void 0 : h.id) || "");
485
- s.has(l) && (a = m), s.add(l);
492
+ const o = /* @__PURE__ */ new Set();
493
+ let x = 0, n = null;
494
+ const i = (u, f) => {
495
+ var d, h, m;
496
+ if (u.type === "businessToken" && ((d = u.attrs) == null ? void 0 : d.kind) === "tool" && (u.attrs.key === "small_payment" && ++x > 1 && (n = f), u.attrs.key === "order_note")) {
497
+ const l = String(((h = u.attrs.params) == null ? void 0 : h.id) || "");
498
+ o.has(l) && (n = f), o.add(l);
486
499
  }
487
- (k = d.content) == null || k.forEach(
488
- (l, e) => o(l, `${m}.content[${e}]`)
500
+ (m = u.content) == null || m.forEach(
501
+ (l, e) => i(l, `${f}.content[${e}]`)
489
502
  );
490
503
  };
491
- return t.forEach((d, m) => o(d, `${r}[${m}]`)), a;
504
+ return t.forEach((u, f) => i(u, `${r}[${f}]`)), n;
492
505
  }
493
506
  function te(t) {
494
- var r, s, $, a, o;
495
- for (let d = 0; d < t.length; d++) {
496
- const m = t[d], c = (r = m.content) == null ? void 0 : r[0];
497
- if (m.type !== "paragraph" || ((s = m.content) == null ? void 0 : s.length) !== 1 || (c == null ? void 0 : c.type) !== "businessToken" || (($ = c.attrs) == null ? void 0 : $.kind) !== "separator")
507
+ var r, o, x, n, i;
508
+ for (let u = 0; u < t.length; u++) {
509
+ const f = t[u], d = (r = f.content) == null ? void 0 : r[0];
510
+ if (f.type !== "paragraph" || ((o = f.content) == null ? void 0 : o.length) !== 1 || (d == null ? void 0 : d.type) !== "businessToken" || ((x = d.attrs) == null ? void 0 : x.kind) !== "separator")
498
511
  continue;
499
- const h = t[d - 1], k = t[d + 1];
500
- if ((h == null ? void 0 : h.type) === "paragraph" && ((a = h.content) != null && a.length))
501
- h.content.push(c);
502
- else if ((k == null ? void 0 : k.type) === "paragraph" && ((o = k.content) != null && o.length))
503
- k.content.unshift(c);
512
+ const h = t[u - 1], m = t[u + 1];
513
+ if ((h == null ? void 0 : h.type) === "paragraph" && ((n = h.content) != null && n.length))
514
+ h.content.push(d);
515
+ else if ((m == null ? void 0 : m.type) === "paragraph" && ((i = m.content) != null && i.length))
516
+ m.content.unshift(d);
504
517
  else continue;
505
- t.splice(d--, 1);
518
+ t.splice(u--, 1);
506
519
  }
507
520
  }
508
521
  function wt(t) {
509
- var $;
510
- const r = (($ = /^\s*/u.exec(t)) == null ? void 0 : $[0].length) || 0;
522
+ var x;
523
+ const r = ((x = /^\s*/u.exec(t)) == null ? void 0 : x[0].length) || 0;
511
524
  if (t[r] !== "【") return null;
512
- let s = 0;
513
- for (let a = r; a < t.length; a++) {
514
- const o = t[a];
515
- if (o === "\r" || o === `
525
+ let o = 0;
526
+ for (let n = r; n < t.length; n++) {
527
+ const i = t[n];
528
+ if (i === "\r" || i === `
516
529
  `) return null;
517
- if (o === "【") s++;
518
- else if (o === "】" && --s === 0)
530
+ if (i === "【") o++;
531
+ else if (i === "】" && --o === 0)
519
532
  return {
520
- question: t.slice(r + 1, a),
521
- suffix: t.slice(a + 1)
533
+ question: t.slice(r + 1, n),
534
+ suffix: t.slice(n + 1)
522
535
  };
523
536
  }
524
537
  return null;
@@ -526,184 +539,184 @@ function wt(t) {
526
539
  function ee(t) {
527
540
  return wt(t.replace(/^\s*<(?:div|p)>\s*/iu, ""));
528
541
  }
529
- function Et(t, r, s = {}, $ = {}) {
542
+ function Mt(t, r, o = {}, x = {}) {
530
543
  var gt, ct, ft, pt, yt, mt, kt, bt;
531
544
  if (!t || typeof t != "object" || Array.isArray(t))
532
- return p(t, "item", "旧知识记录格式不正确");
545
+ return c(t, "item", "旧知识记录格式不正确");
533
546
  if (!(r != null && r.trim()))
534
- return p(t, "sourceRecordKey", "需要稳定的来源记录键");
535
- const a = $.businessAttributes ?? vt;
536
- if (!Mt(a))
537
- return p(
547
+ return c(t, "sourceRecordKey", "需要稳定的来源记录键");
548
+ const n = x.businessAttributes ?? vt;
549
+ if (!Dt(n))
550
+ return c(
538
551
  t,
539
552
  "businessAttributes",
540
553
  "业务属性目录格式无效或存在重复引用"
541
554
  );
542
- const o = typeof t.web_content == "string" && t.web_content ? "web_content" : "content", d = t[o];
543
- if (typeof d != "string") return p(t, o, "旧知识缺少内容");
544
- const m = !!String(t.todo_plan_id || "").trim() || !!t.todo_tag_metas, c = o === "content" ? Ct(d) : d, h = _t(c, m, a);
555
+ const i = typeof t.web_content == "string" && t.web_content ? "web_content" : "content", u = t[i];
556
+ if (typeof u != "string") return c(t, i, "旧知识缺少内容");
557
+ const f = !!String(t.todo_plan_id || "").trim() || !!t.todo_tag_metas, d = i === "content" ? Ct(u) : u, h = _t(d, f, n);
545
558
  if (!h.ok) return { ...h, raw: t };
546
- const k = h.value, l = k[0] || [], e = l.findIndex(
547
- (n) => n.kind === "originalReply" || n.kind === "media" || n.kind === "tableKnowledge"
548
- ), i = ht(
559
+ const m = h.value, l = m[0] || [], e = l.findIndex(
560
+ (a) => a.kind === "originalReply" || a.kind === "media" || a.kind === "tableKnowledge"
561
+ ), y = ht(
549
562
  e >= 0 ? l.slice(0, e) : l
550
- ), g = wt(i || "");
551
- if (!g && (i != null && i.trimStart().startsWith("【")))
552
- return p(t, o, "内嵌问法的【】没有正确配对");
553
- const j = g ? g.question : $.questionText ?? "";
554
- if (Ht(j))
555
- return p(t, "questionText", "顾客问法包含保留分隔符");
556
- const R = new DOMParser().parseFromString(c, "text/html"), E = Array.from(
557
- R.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
558
- ).filter((n) => lt(n) === "todo").map(
559
- (n) => Nt(n.textContent || "") || n.getAttribute("data-tag-name") || ""
563
+ ), k = wt(y || "");
564
+ if (!k && (y != null && y.trimStart().startsWith("【")))
565
+ return c(t, i, "内嵌问法的【】没有正确配对");
566
+ const $ = k ? k.question : x.questionText ?? "";
567
+ if (Pt($))
568
+ return c(t, "questionText", "顾客问法包含保留分隔符");
569
+ const T = new DOMParser().parseFromString(d, "text/html"), C = Array.from(
570
+ T.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
571
+ ).filter((a) => lt(a) === "todo").map(
572
+ (a) => Nt(a.textContent || "") || a.getAttribute("data-tag-name") || ""
560
573
  );
561
- m && E.push(
562
- ...Array.from(d.matchAll(/\{待办@([^{}]+)\}/gu), (n) => n[1])
574
+ f && C.push(
575
+ ...Array.from(u.matchAll(/\{待办@([^{}]+)\}/gu), (a) => a[1])
563
576
  );
564
- const H = Array.from(
565
- R.querySelectorAll('span[data-tag-type="cdp_tag"]')
566
- ).map((n) => {
567
- var y;
577
+ const F = Array.from(
578
+ T.querySelectorAll('span[data-tag-type="cdp_tag"]')
579
+ ).map((a) => {
580
+ var p;
568
581
  return {
569
- name: ((y = (n.textContent || "").match(
582
+ name: ((p = (a.textContent || "").match(
570
583
  /\{(?:顾客标签|意图标签)@([^{}]+)\}/u
571
- )) == null ? void 0 : y[1]) || n.getAttribute("data-tag-name") || "",
572
- id: n.getAttribute("data-tag-id") || ""
584
+ )) == null ? void 0 : p[1]) || a.getAttribute("data-tag-name") || "",
585
+ id: a.getAttribute("data-tag-id") || ""
573
586
  };
574
587
  });
575
- if ((gt = R.body.textContent) != null && gt.includes("{待办}") && E.push("默认"), o === "content" && Array.isArray(t.tag_meta))
576
- for (const n of t.tag_meta) {
577
- const y = n;
578
- (y == null ? void 0 : y.type) === "cdp_tag" && typeof y.name == "string" && /\{(?:顾客标签|意图标签)@[^{}]+\}/u.test(d) && (d.includes(`{顾客标签@${y.name}}`) || d.includes(`{意图标签@${y.name}}`)) && H.push({ name: y.name, id: String(y.value || "") });
588
+ if ((gt = T.body.textContent) != null && gt.includes("{待办}") && C.push("默认"), i === "content" && Array.isArray(t.tag_meta))
589
+ for (const a of t.tag_meta) {
590
+ const p = a;
591
+ (p == null ? void 0 : p.type) === "cdp_tag" && typeof p.name == "string" && /\{(?:顾客标签|意图标签)@[^{}]+\}/u.test(u) && (u.includes(`{顾客标签@${p.name}}`) || u.includes(`{意图标签@${p.name}}`)) && F.push({ name: p.name, id: String(p.value || "") });
579
592
  }
580
- if (H.length > 1)
581
- return p(t, o, "新模型每条问法只能选择一个顾客标签");
582
- const M = /* @__PURE__ */ new Map();
583
- for (const [n, y] of Array.from(
584
- R.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
593
+ if (F.length > 1)
594
+ return c(t, i, "新模型每条问法只能选择一个顾客标签");
595
+ const j = /* @__PURE__ */ new Map();
596
+ for (const [a, p] of Array.from(
597
+ T.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
585
598
  ).entries()) {
586
- if (lt(y) !== "todo") continue;
587
- const _ = (ct = y.getAttribute("plan_id")) == null ? void 0 : ct.trim();
588
- if (!_) continue;
589
- const u = Nt(y.textContent || "") || y.getAttribute("data-tag-name") || "";
590
- if (!u)
591
- return p(t, `${o}.todo[${n}]`, "待办标签缺少方案名称");
592
- const f = M.get(u);
593
- if (f && f.id !== _)
594
- return p(
599
+ if (lt(p) !== "todo") continue;
600
+ const v = (ct = p.getAttribute("plan_id")) == null ? void 0 : ct.trim();
601
+ if (!v) continue;
602
+ const s = Nt(p.textContent || "") || p.getAttribute("data-tag-name") || "";
603
+ if (!s)
604
+ return c(t, `${i}.todo[${a}]`, "待办标签缺少方案名称");
605
+ const g = j.get(s);
606
+ if (g && g.id !== v)
607
+ return c(
595
608
  t,
596
- `${o}.todo[${n}]`,
609
+ `${i}.todo[${a}]`,
597
610
  "同名待办对应多个方案 ID"
598
611
  );
599
- M.set(u, { id: _, label: u });
612
+ j.set(s, { id: v, label: s });
600
613
  }
601
614
  if (t.todo_tag_metas !== void 0 && t.todo_tag_metas !== "") {
602
- let n = t.todo_tag_metas;
603
- if (typeof n == "string")
615
+ let a = t.todo_tag_metas;
616
+ if (typeof a == "string")
604
617
  try {
605
- n = JSON.parse(n);
618
+ a = JSON.parse(a);
606
619
  } catch {
607
- return p(t, "todo_tag_metas", "待办方案元数据不是有效 JSON");
620
+ return c(t, "todo_tag_metas", "待办方案元数据不是有效 JSON");
608
621
  }
609
- if (!Array.isArray(n))
610
- return p(t, "todo_tag_metas", "待办方案元数据必须为数组");
611
- for (const [y, _] of n.entries()) {
612
- if (!_ || typeof _ != "object" || typeof _.plan_id != "string" || !_.plan_id.trim() || typeof _.plan_name != "string" || !_.plan_name.trim() || _.tag_type !== void 0 && _.tag_type !== 2)
613
- return p(
622
+ if (!Array.isArray(a))
623
+ return c(t, "todo_tag_metas", "待办方案元数据必须为数组");
624
+ for (const [p, v] of a.entries()) {
625
+ if (!v || typeof v != "object" || typeof v.plan_id != "string" || !v.plan_id.trim() || typeof v.plan_name != "string" || !v.plan_name.trim() || v.tag_type !== void 0 && v.tag_type !== 2)
626
+ return c(
614
627
  t,
615
- `todo_tag_metas[${y}]`,
628
+ `todo_tag_metas[${p}]`,
616
629
  "待办方案缺少有效 ID、名称或已失效"
617
630
  );
618
- const u = M.get(_.plan_name);
619
- if (u && u.id !== _.plan_id)
620
- return p(
631
+ const s = j.get(v.plan_name);
632
+ if (s && s.id !== v.plan_id)
633
+ return c(
621
634
  t,
622
- `todo_tag_metas[${y}]`,
635
+ `todo_tag_metas[${p}]`,
623
636
  "待办方案元数据与富文本标签的 plan_id 不一致"
624
637
  );
625
- M.set(_.plan_name, {
626
- id: _.plan_id,
627
- label: _.plan_name
638
+ j.set(v.plan_name, {
639
+ id: v.plan_id,
640
+ label: v.plan_name
628
641
  });
629
642
  }
630
643
  }
631
644
  if (String(t.todo_plan_id || "").trim() && typeof t.todo_plan_name == "string") {
632
- const n = M.get(t.todo_plan_name);
633
- if (n && n.id !== String(t.todo_plan_id))
634
- return p(t, "todo_plan_id", "待办方案字段与多方案元数据不一致");
635
- M.set(t.todo_plan_name, {
645
+ const a = j.get(t.todo_plan_name);
646
+ if (a && a.id !== String(t.todo_plan_id))
647
+ return c(t, "todo_plan_id", "待办方案字段与多方案元数据不一致");
648
+ j.set(t.todo_plan_name, {
636
649
  id: String(t.todo_plan_id),
637
650
  label: t.todo_plan_name
638
651
  });
639
652
  }
640
- const A = {}, I = !g && i && /^(?:\{(?:待办|顾客标签|意图标签)@[^{}]+\}|\{(?:原话复述|记忆触发点|推理)\})+$/u.test(
641
- i.trim()
642
- ), F = [];
643
- let K = !1, G = "", tt = "", O = (g == null ? void 0 : g.suffix.trim()) || (I ? i.trim() : "");
644
- for (; O; ) {
645
- if (O.startsWith("{待办}")) {
646
- F.push({ kind: "todo", value: "{待办}" }), O = O.slice(4).trimStart();
653
+ const _ = {}, O = !k && y && /^(?:\{(?:待办|顾客标签|意图标签)@[^{}]+\}|\{(?:原话复述|记忆触发点|推理)\})+$/u.test(
654
+ y.trim()
655
+ ), K = [];
656
+ let J = !1, G = "", tt = "", D = (k == null ? void 0 : k.suffix.trim()) || (O ? y.trim() : "");
657
+ for (; D; ) {
658
+ if (D.startsWith("{待办}")) {
659
+ K.push({ kind: "todo", value: "{待办}" }), D = D.slice(4).trimStart();
647
660
  continue;
648
661
  }
649
- if (/^\{(?:智能建单|智能工单|外部方法)@/u.test(O)) {
650
- G = O;
662
+ if (/^\{(?:智能建单|智能工单|外部方法)@/u.test(D)) {
663
+ G = D;
651
664
  break;
652
665
  }
653
- if (O.startsWith("{自定义Agent}@")) {
654
- if (tt) return p(t, o, "Agent 标记重复");
655
- const y = O, u = Array.from(R.querySelectorAll("span")).filter((f) => lt(f) === "custom_agent").map((f) => (f.textContent || "").trim()).find(
656
- (f) => f.startsWith("{自定义Agent}@") && y.startsWith(f)
657
- ) || ((ft = O.match(/^\{自定义Agent\}@[^{}]+/u)) == null ? void 0 : ft[0]);
658
- if (!u) return p(t, o, "Agent 名称为空");
659
- tt = u.trim(), O = O.slice(u.length).trimStart();
666
+ if (D.startsWith("{自定义Agent}@")) {
667
+ if (tt) return c(t, i, "Agent 标记重复");
668
+ const p = D, s = Array.from(T.querySelectorAll("span")).filter((g) => lt(g) === "custom_agent").map((g) => (g.textContent || "").trim()).find(
669
+ (g) => g.startsWith("{自定义Agent}@") && p.startsWith(g)
670
+ ) || ((ft = D.match(/^\{自定义Agent\}@[^{}]+/u)) == null ? void 0 : ft[0]);
671
+ if (!s) return c(t, i, "Agent 名称为空");
672
+ tt = s.trim(), D = D.slice(s.length).trimStart();
660
673
  continue;
661
674
  }
662
- const n = O.match(
675
+ const a = D.match(
663
676
  /^\{(待办|顾客标签|意图标签)@([^{}]+)\}|^\{(原话复述|记忆触发点|推理)\}/u
664
677
  );
665
- if (!n) {
666
- if (O.startsWith("{"))
667
- return p(t, o, `问法后的标记无法转换:${O}`);
668
- G = O;
678
+ if (!a) {
679
+ if (D.startsWith("{"))
680
+ return c(t, i, `问法后的标记无法转换:${D}`);
681
+ G = D;
669
682
  break;
670
683
  }
671
- if (n[1]) {
672
- const y = n[1] === "待办" ? "todo" : "tagged", _ = y === "todo" ? E.find((v) => v === n[2]) : H.find((v) => v.name === n[2]);
673
- if (!_)
674
- return p(
684
+ if (a[1]) {
685
+ const p = a[1] === "待办" ? "todo" : "tagged", v = p === "todo" ? C.find((A) => A === a[2]) : F.find((A) => A.name === a[2]);
686
+ if (!v)
687
+ return c(
675
688
  t,
676
- o,
677
- `${n[1]} ${n[2]} 不是有效的旧版富文本标签`
689
+ i,
690
+ `${a[1]} ${a[2]} 不是有效的旧版富文本标签`
678
691
  );
679
- const u = y === "todo" && t.todo_plan_name === n[2] ? String(t.todo_plan_id || "") : y === "tagged" ? _.id : "", f = y === "todo" && M.has(n[2]) ? M.get(n[2]) : u ? { id: u, label: n[2] } : (pt = s.selection) == null ? void 0 : pt.call(s, y, n[2]);
680
- if (!(f != null && f.id) || !f.label || f.label !== n[2])
681
- return p(
692
+ const s = p === "todo" && t.todo_plan_name === a[2] ? String(t.todo_plan_id || "") : p === "tagged" ? v.id : "", g = p === "todo" && j.has(a[2]) ? j.get(a[2]) : s ? { id: s, label: a[2] } : (pt = o.selection) == null ? void 0 : pt.call(o, p, a[2]);
693
+ if (!(g != null && g.id) || !g.label || g.label !== a[2])
694
+ return c(
682
695
  t,
683
- o,
684
- `${n[1]} ${n[2]} 缺少匹配的方案 ID`
696
+ i,
697
+ `${a[1]} ${a[2]} 缺少匹配的方案 ID`
685
698
  );
686
- if (y === "todo")
687
- F.push({ kind: "todo", value: n[0] });
699
+ if (p === "todo")
700
+ K.push({ kind: "todo", value: a[0] });
688
701
  else {
689
- if (A[y]) return p(t, o, `${n[1]}重复`);
690
- A[y] = { version: 1, data: { enabled: !0, tag: f } };
702
+ if (_[p]) return c(t, i, `${a[1]}重复`);
703
+ _[p] = { version: 1, data: { enabled: !0, tag: g } };
691
704
  }
692
- } else if (n[3] === "推理") {
693
- if (K) return p(t, o, "推理标记重复");
694
- K = !0;
705
+ } else if (a[3] === "推理") {
706
+ if (J) return c(t, i, "推理标记重复");
707
+ J = !0;
695
708
  } else {
696
- const y = n[3] === "原话复述" ? "originalReply" : "memory";
697
- if (A[y]) return p(t, o, `${n[3]}重复`);
698
- A[y] = { version: 1, data: { enabled: !0 } };
709
+ const p = a[3] === "原话复述" ? "originalReply" : "memory";
710
+ if (_[p]) return c(t, i, `${a[3]}重复`);
711
+ _[p] = { version: 1, data: { enabled: !0 } };
699
712
  }
700
- O = O.slice(n[0].length).trimStart();
713
+ D = D.slice(a[0].length).trimStart();
701
714
  }
702
715
  if (Array.isArray(t.tag_meta))
703
- for (const [n, y] of t.tag_meta.entries()) {
704
- if (!y || typeof y != "object")
705
- return p(t, `tag_meta[${n}]`, "标签元数据格式错误");
706
- const _ = y;
716
+ for (const [a, p] of t.tag_meta.entries()) {
717
+ if (!p || typeof p != "object")
718
+ return c(t, `tag_meta[${a}]`, "标签元数据格式错误");
719
+ const v = p;
707
720
  if (![
708
721
  "cdp_tag",
709
722
  "todo",
@@ -714,353 +727,383 @@ function Et(t, r, s = {}, $ = {}) {
714
727
  "memory",
715
728
  "separator",
716
729
  "table_knowledge"
717
- ].includes(String(_.type)))
718
- return p(
730
+ ].includes(String(v.type)))
731
+ return c(
719
732
  t,
720
- `tag_meta[${n}]`,
733
+ `tag_meta[${a}]`,
721
734
  "旧标签元数据无法映射到新模型"
722
735
  );
723
- if (_.invalid)
724
- return p(t, `tag_meta[${n}]`, "失效标签需要只读保全");
725
- if (_.type === "cdp_tag" && (!A.tagged || A.tagged.data.tag.id !== String(_.value || "") || A.tagged.data.tag.label !== String(_.name || "")))
726
- return p(
736
+ if (v.invalid)
737
+ return c(t, `tag_meta[${a}]`, "失效标签需要只读保全");
738
+ if (v.type === "cdp_tag" && (!_.tagged || _.tagged.data.tag.id !== String(v.value || "") || _.tagged.data.tag.label !== String(v.name || "")))
739
+ return c(
727
740
  t,
728
- `tag_meta[${n}]`,
741
+ `tag_meta[${a}]`,
729
742
  "顾客标签 ID 与富文本标签不一致"
730
743
  );
731
744
  }
732
745
  const Z = t.todo_plan_id;
733
746
  if (Z != null && String(Z).trim()) {
734
- const n = t.todo_plan_name;
735
- if (typeof n != "string" || !n.trim())
736
- return p(t, "todo_plan_name", "待办方案 ID 存在但名称缺失");
737
- if (!E.includes(n))
738
- return p(t, "web_content", "待办方案字段缺少对应的富文本标签");
747
+ const a = t.todo_plan_name;
748
+ if (typeof a != "string" || !a.trim())
749
+ return c(t, "todo_plan_name", "待办方案 ID 存在但名称缺失");
750
+ if (!C.includes(a))
751
+ return c(t, "web_content", "待办方案字段缺少对应的富文本标签");
739
752
  }
740
- const z = g || I ? k.slice(1) : [...k];
741
- g && e >= 0 && z.unshift(l.slice(e)), tt && z.unshift([{ kind: "text", value: tt }]);
753
+ const P = k || O ? m.slice(1) : [...m];
754
+ k && e >= 0 && P.unshift(l.slice(e)), tt && P.unshift([{ kind: "text", value: tt }]);
742
755
  const Y = Number(t.knowledge_type || 0);
743
- let C = Y === 2 ? "reasoning" : Y === 3 ? "agent" : "normal";
756
+ let M = Y === 2 ? "reasoning" : Y === 3 ? "agent" : "normal";
744
757
  if (t.knowledge_type !== void 0 && ![0, 1, 2, 3].includes(Y))
745
- return p(t, "knowledge_type", "未知的旧知识类型");
758
+ return c(t, "knowledge_type", "未知的旧知识类型");
746
759
  if (Array.isArray(t.tag_meta)) {
747
760
  if (t.tag_meta.some(
748
- (n) => n && typeof n == "object" && n.type === "reasoning"
761
+ (a) => a && typeof a == "object" && a.type === "reasoning"
749
762
  ) && Y === 1)
750
- return p(t, "tag_meta", "推理标签与知识类型不一致");
763
+ return c(t, "tag_meta", "推理标签与知识类型不一致");
751
764
  if (t.tag_meta.some(
752
- (n) => n && typeof n == "object" && n.type === "custom_agent"
765
+ (a) => a && typeof a == "object" && a.type === "custom_agent"
753
766
  ) && (Y === 1 || Y === 2))
754
- return p(t, "tag_meta", "Agent 标签与知识类型不一致");
767
+ return c(t, "tag_meta", "Agent 标签与知识类型不一致");
755
768
  }
756
769
  let et = null;
757
- const X = (yt = z[0]) == null ? void 0 : yt[0], D = (X == null ? void 0 : X.kind) === "text" && /^\s*\{推理\}/u.test(X.value);
758
- if (K || D) {
759
- if (C === "agent")
760
- return p(t, o, "推理标记与 Agent 类型冲突");
761
- if (C = "reasoning", D && (X == null ? void 0 : X.kind) === "text") {
762
- const n = X.value.replace(/^\s*\{推理\}\s*/u, ""), y = z[0].slice(1);
763
- for (n && y.unshift({ kind: "text", value: n }); ((mt = y[0]) == null ? void 0 : mt.kind) === "text" && !y[0].value.trim(); )
764
- y.shift();
765
- y.length ? z[0] = y : z.shift();
770
+ const z = (yt = P[0]) == null ? void 0 : yt[0], R = (z == null ? void 0 : z.kind) === "reasoningMarker" && !z.inline || (z == null ? void 0 : z.kind) === "text" && /^\s*\{推理\}/u.test(z.value);
771
+ if (J || R) {
772
+ if (M === "agent")
773
+ return c(t, i, "推理标记与 Agent 类型冲突");
774
+ if (M = "reasoning", R && ((z == null ? void 0 : z.kind) === "text" || (z == null ? void 0 : z.kind) === "reasoningMarker")) {
775
+ const a = z.value.replace(/^\s*\{推理\}\s*/u, ""), p = P[0].slice(1);
776
+ for (a && p.unshift({ kind: "text", value: a }); ((mt = p[0]) == null ? void 0 : mt.kind) === "text" && !p[0].value.trim(); )
777
+ p.shift();
778
+ p.length ? P[0] = p : P.shift();
766
779
  }
767
780
  }
768
- if (z.length && ((kt = ht(z[0])) != null && kt.trim().startsWith("{自定义Agent}@"))) {
769
- if (C === "reasoning")
770
- return p(t, o, "Agent 标记与推理类型冲突");
771
- C = "agent";
772
- const n = ht(z[0]).trim().slice(11), y = (B) => B.replace(/(已失效)$/u, "").trim(), _ = y(n);
773
- if (!_) return p(t, o, "Agent 名称为空");
774
- const u = Array.isArray(t.tag_meta) ? t.tag_meta.find(
775
- (B) => B && typeof B == "object" && B.type === "custom_agent" && typeof B.agent_name == "string" && y(
776
- B.agent_name
777
- ) === _
778
- ) : void 0, f = Array.from(R.querySelectorAll("span")).find(
779
- (B) => lt(B) === "custom_agent" && ((B.textContent || "").trim() === `{自定义Agent}@${n}` || y(B.getAttribute("data-agent-name") || "") === _ || y(B.getAttribute("data-tag-name") || "") === _)
780
- ), v = n.endsWith("(已失效)") || (f == null ? void 0 : f.getAttribute("data-invalid")) === "true", W = (f == null ? void 0 : f.getAttribute("data-agent-id")) || "";
781
- if (f && ["data-agent-name", "data-tag-name"].some(
782
- (B) => f.hasAttribute(B) && y(f.getAttribute(B) || "") !== _
781
+ if (P.length && ((kt = ht(P[0])) != null && kt.trim().startsWith("{自定义Agent}@"))) {
782
+ if (M === "reasoning")
783
+ return c(t, i, "Agent 标记与推理类型冲突");
784
+ M = "agent";
785
+ const a = ht(P[0]).trim().slice(11), p = (q) => q.replace(/(已失效)$/u, "").trim(), v = p(a);
786
+ if (!v) return c(t, i, "Agent 名称为空");
787
+ const s = Array.isArray(t.tag_meta) ? t.tag_meta.find(
788
+ (q) => q && typeof q == "object" && q.type === "custom_agent" && typeof q.agent_name == "string" && p(
789
+ q.agent_name
790
+ ) === v
791
+ ) : void 0, g = Array.from(T.querySelectorAll("span")).find(
792
+ (q) => lt(q) === "custom_agent" && ((q.textContent || "").trim() === `{自定义Agent}@${a}` || p(q.getAttribute("data-agent-name") || "") === v || p(q.getAttribute("data-tag-name") || "") === v)
793
+ ), A = a.endsWith("(已失效)") || (g == null ? void 0 : g.getAttribute("data-invalid")) === "true", E = (g == null ? void 0 : g.getAttribute("data-agent-id")) || "";
794
+ if (g && ["data-agent-name", "data-tag-name"].some(
795
+ (q) => g.hasAttribute(q) && p(g.getAttribute(q) || "") !== v
783
796
  ))
784
- return p(t, o, "Agent 名称属性与显示内容不一致");
785
- if (W && (u != null && u.agent_id) && W !== u.agent_id)
786
- return p(t, "tag_meta", "Agent ID 与富文本标签不一致");
787
- const q = typeof (u == null ? void 0 : u.agent_id) == "string" && u.agent_id ? { id: u.agent_id, name: _ } : W.trim() ? { id: W, name: _ } : v ? null : (bt = s.agent) == null ? void 0 : bt.call(s, _);
797
+ return c(t, i, "Agent 名称属性与显示内容不一致");
798
+ if (E && (s != null && s.agent_id) && E !== s.agent_id)
799
+ return c(t, "tag_meta", "Agent ID 与富文本标签不一致");
800
+ const I = typeof (s == null ? void 0 : s.agent_id) == "string" && s.agent_id ? { id: s.agent_id, name: v } : E.trim() ? { id: E, name: v } : A ? null : (bt = o.agent) == null ? void 0 : bt.call(o, v);
788
801
  et = {
789
- id: (q == null ? void 0 : q.name) === _ ? q.id : "",
790
- name: _,
791
- ...v ? { invalid: !0 } : {}
792
- }, z.shift();
802
+ id: (I == null ? void 0 : I.name) === v ? I.id : "",
803
+ name: v,
804
+ ...A ? { invalid: !0 } : {}
805
+ }, P.shift();
793
806
  }
794
- if (C === "agent" && !et)
795
- return p(t, o, "Agent 知识缺少可解析的 Agent 标记");
796
- G && z.unshift([{ kind: "text", value: G }]);
797
- const L = (n, y, _ = !1, u = !1) => {
798
- var W, q;
799
- if (n.kind === "hardBreak")
807
+ if (M === "agent" && !et)
808
+ return c(t, i, "Agent 知识缺少可解析的 Agent 标记");
809
+ G && P.unshift([{ kind: "text", value: G }]);
810
+ const W = (a, p, v = !1, s = !1) => {
811
+ var E, I;
812
+ if (a.kind === "hardBreak")
800
813
  return { ok: !0, value: [{ type: "hardBreak" }] };
801
- if (n.kind === "originalReply")
802
- return p(t, y, "原话块不可嵌套原话模板");
803
- if (n.kind === "media" || n.kind === "block")
804
- return p(t, y, "块级内容不能作为行内标签转换");
805
- if (n.kind === "tableKnowledge")
814
+ if (a.kind === "originalReply")
815
+ return c(t, p, "原话块不可嵌套原话模板");
816
+ if (a.kind === "media" || a.kind === "block")
817
+ return c(t, p, "块级内容不能作为行内标签转换");
818
+ if (a.kind === "reasoningMarker")
819
+ return {
820
+ ok: !0,
821
+ value: [
822
+ {
823
+ type: "businessToken",
824
+ attrs: {
825
+ kind: "reasoningMarker",
826
+ key: "reasoningMarker",
827
+ label: "推理",
828
+ token: "{推理}"
829
+ }
830
+ }
831
+ ]
832
+ };
833
+ if (a.kind === "noFollow")
834
+ return {
835
+ ok: !0,
836
+ value: [
837
+ {
838
+ type: "businessToken",
839
+ attrs: {
840
+ kind: "noFollow",
841
+ key: "noFollow",
842
+ label: "不跟单",
843
+ token: "<不发送跟单>"
844
+ }
845
+ }
846
+ ]
847
+ };
848
+ if (a.kind === "tableKnowledge")
806
849
  return {
807
850
  ok: !0,
808
851
  value: [
809
852
  {
810
853
  type: "businessToken",
811
- attrs: { kind: "tableKnowledge", key: n.key, label: n.name }
854
+ attrs: { kind: "tableKnowledge", key: a.key, label: a.name }
812
855
  }
813
856
  ]
814
857
  };
815
- if (n.kind === "attribute")
816
- return C !== "agent" && (C !== "reasoning" || u) ? p(
858
+ if (a.kind === "attribute")
859
+ return M !== "agent" && (M !== "reasoning" || s) ? c(
817
860
  t,
818
- y,
861
+ p,
819
862
  "业务属性只能位于推理知识正文,不能放入原话"
820
863
  ) : {
821
864
  ok: !0,
822
865
  value: [
823
866
  {
824
867
  type: "businessToken",
825
- attrs: { kind: "attribute", key: n.key, label: n.name }
868
+ attrs: { kind: "attribute", key: a.key, label: a.name }
826
869
  }
827
870
  ]
828
871
  };
829
- if (n.kind !== "todo") {
830
- const B = Gt(
831
- C === "normal" ? n.value.replace(/\{(?:待办(?:@[^{}]+)?|原话复述)\}/gu, "") : n.value,
832
- y,
833
- s,
834
- a
872
+ if (a.kind !== "todo") {
873
+ const q = Gt(
874
+ M === "normal" ? a.value.replace(/\{(?:待办(?:@[^{}]+)?|原话复述)\}/gu, "") : a.value,
875
+ p,
876
+ o,
877
+ n
835
878
  );
836
- return B.ok ? C !== "agent" && (C !== "reasoning" || u) && B.value.some(
837
- (P) => {
838
- var at;
839
- return P.type === "businessToken" && ((at = P.attrs) == null ? void 0 : at.kind) === "attribute";
879
+ return q.ok ? M !== "agent" && (M !== "reasoning" || s) && q.value.some(
880
+ (H) => {
881
+ var nt;
882
+ return H.type === "businessToken" && ((nt = H.attrs) == null ? void 0 : nt.kind) === "attribute";
840
883
  }
841
- ) ? p(
884
+ ) ? c(
842
885
  t,
843
- y,
886
+ p,
844
887
  "业务属性只能位于推理知识正文,不能放入原话"
845
- ) : B.ok && ((W = n.marks) != null && W.length) ? {
888
+ ) : q.ok && ((E = a.marks) != null && E.length) ? {
846
889
  ok: !0,
847
- value: B.value.map((P) => ({
848
- ...P,
849
- marks: n.marks
890
+ value: q.value.map((H) => ({
891
+ ...H,
892
+ marks: a.marks
850
893
  }))
851
- } : B : B;
894
+ } : q : q;
852
895
  }
853
- if (C === "normal" && !_) return { ok: !0, value: [] };
854
- const f = n.value === "{待办}" ? "默认" : n.value.slice(4, -1), v = M.get(f) || ((q = s.selection) == null ? void 0 : q.call(s, "todo", f));
855
- return !(v != null && v.id) || v.label !== f ? p(t, y, `待办 ${f} 缺少匹配的方案 ID`) : C === "normal" && A.todo ? p(t, o, "待办重复") : C === "normal" ? (A.todo = { version: 1, data: { enabled: !0, tag: v } }, { ok: !0, value: [] }) : {
896
+ if (M === "normal" && !v) return { ok: !0, value: [] };
897
+ const g = a.value === "{待办}" ? "默认" : a.value.slice(4, -1), A = j.get(g) || ((I = o.selection) == null ? void 0 : I.call(o, "todo", g));
898
+ return !(A != null && A.id) || A.label !== g ? c(t, p, `待办 ${g} 缺少匹配的方案 ID`) : M === "normal" && _.todo ? c(t, i, "待办重复") : M === "normal" ? (_.todo = { version: 1, data: { enabled: !0, tag: A } }, { ok: !0, value: [] }) : {
856
899
  ok: !0,
857
900
  value: [
858
901
  {
859
902
  type: "businessToken",
860
903
  attrs: {
861
904
  kind: "todo",
862
- key: v.id,
863
- label: v.label,
864
- ...n.value === "{待办}" ? { token: "{待办}" } : {}
905
+ key: A.id,
906
+ label: A.label,
907
+ ...a.value === "{待办}" ? { token: "{待办}" } : {}
865
908
  }
866
909
  }
867
910
  ]
868
911
  };
869
912
  };
870
- if (C === "normal") {
871
- !F.length && String(Z || "").trim() && typeof t.todo_plan_name == "string" && (A.todo = {
913
+ if (M === "normal") {
914
+ !K.length && String(Z || "").trim() && typeof t.todo_plan_name == "string" && (_.todo = {
872
915
  version: 1,
873
916
  data: {
874
917
  enabled: !0,
875
918
  tag: { id: String(Z), label: t.todo_plan_name }
876
919
  }
877
920
  });
878
- for (const n of F) {
879
- const y = L(n, o, !0);
880
- if (!y.ok) return { ...y, raw: t };
921
+ for (const a of K) {
922
+ const p = W(a, i, !0);
923
+ if (!p.ok) return { ...p, raw: t };
881
924
  }
882
- } else F.length && z.unshift(F);
883
- C !== "normal" && A.originalReply && (delete A.originalReply, z.unshift([{ kind: "text", value: "{原话复述}" }]));
884
- const V = (n, y, _ = !1) => {
885
- var f;
886
- const u = [];
887
- for (let v = 0; v < n.length; v++) {
888
- const W = n[v], q = `${y}.line[${v + 2}]`, B = (f = ht(W)) == null ? void 0 : f.trim();
889
- if (B != null && B.startsWith("{原话复述}") && C === "reasoning" && !_) {
890
- const T = B.slice(6), N = T ? _t(w(T), m, a) : null;
891
- if (N && !N.ok) return N;
892
- const J = N != null && N.ok ? N.value[0] : n[++v];
893
- if (!J) return p(t, q, "原话块缺少内容");
894
- if (ht(J) === null)
895
- return p(t, q, "原话块包含无法转换的媒体");
896
- const nt = [];
897
- for (const rt of J) {
898
- const st = L(rt, q, !1, !0);
925
+ } else K.length && P.unshift(K);
926
+ M !== "normal" && _.originalReply && (delete _.originalReply, P.unshift([{ kind: "text", value: "{原话复述}" }]));
927
+ const Q = (a, p, v = !1) => {
928
+ var g;
929
+ const s = [];
930
+ for (let A = 0; A < a.length; A++) {
931
+ const E = a[A], I = `${p}.line[${A + 2}]`, q = (g = ht(E)) == null ? void 0 : g.trim();
932
+ if (q != null && q.startsWith("{原话复述}") && M === "reasoning" && !v) {
933
+ const B = q.slice(6), L = B ? _t(S(B), f, n) : null;
934
+ if (L && !L.ok) return L;
935
+ const V = L != null && L.ok ? L.value[0] : a[++A];
936
+ if (!V) return c(t, I, "原话块缺少内容");
937
+ if (ht(V) === null)
938
+ return c(t, I, "原话块包含无法转换的媒体");
939
+ const at = [];
940
+ for (const rt of V) {
941
+ const st = W(rt, I, !1, !0);
899
942
  if (!st.ok) return { ...st, raw: t };
900
- nt.push(...st.value);
943
+ at.push(...st.value);
901
944
  }
902
- u.push({
945
+ s.push({
903
946
  type: "originalReply",
904
- content: [{ type: "paragraph", content: nt }]
947
+ content: [{ type: "paragraph", content: at }]
905
948
  });
906
949
  continue;
907
950
  }
908
- let P = [];
909
- const at = () => {
910
- P.length && (u.push({ type: "paragraph", content: P }), P = []);
951
+ let H = [];
952
+ const nt = () => {
953
+ H.length && (s.push({ type: "paragraph", content: H }), H = []);
911
954
  };
912
- for (const T of W)
913
- if (T.kind === "originalReply") {
914
- P.every((U) => {
915
- var nt;
916
- return U.type === "text" && !((nt = U.text) != null && nt.trim());
917
- }) && (P = []), at();
918
- const N = _t(T.html, m, a);
919
- if (!N.ok) return { ...N, raw: t };
920
- if (_) return p(t, q, "原话块不可嵌套原话模板");
921
- const J = V(
922
- N.value,
923
- `${q}.originalReply`,
955
+ for (const B of E)
956
+ if (B.kind === "originalReply") {
957
+ H.every((U) => {
958
+ var at;
959
+ return U.type === "text" && !((at = U.text) != null && at.trim());
960
+ }) && (H = []), nt();
961
+ const L = _t(B.html, f, n);
962
+ if (!L.ok) return { ...L, raw: t };
963
+ if (v) return c(t, I, "原话块不可嵌套原话模板");
964
+ const V = Q(
965
+ L.value,
966
+ `${I}.originalReply`,
924
967
  !0
925
968
  );
926
- if (!J.ok) return J;
927
- C === "normal" ? u.push(...J.value) : u.push({
969
+ if (!V.ok) return V;
970
+ M === "normal" ? s.push(...V.value) : s.push({
928
971
  type: "originalReply",
929
- content: J.value.length ? J.value : [{ type: "paragraph" }]
972
+ content: V.value.length ? V.value : [{ type: "paragraph" }]
930
973
  });
931
- } else if (T.kind === "media")
932
- at(), u.push({
974
+ } else if (B.kind === "media")
975
+ nt(), s.push({
933
976
  type: "mediaBlock",
934
977
  attrs: {
935
- kind: T.media,
936
- src: T.src,
978
+ kind: B.media,
979
+ src: B.src,
937
980
  status: "ready",
938
- ...T.metadata
981
+ ...B.metadata
939
982
  }
940
983
  });
941
- else if (T.kind === "block") {
942
- if (at(), T.tag === "hr") {
943
- u.push({ type: "horizontalRule" });
984
+ else if (B.kind === "block") {
985
+ if (nt(), B.tag === "hr") {
986
+ s.push({ type: "horizontalRule" });
944
987
  continue;
945
988
  }
946
- if (_)
947
- return p(t, q, "原话块不支持嵌套列表或引用");
948
- const N = new DOMParser().parseFromString(T.html, "text/html").body.firstElementChild;
949
- if (T.tag === "pre") {
950
- u.push({
989
+ if (v)
990
+ return c(t, I, "原话块不支持嵌套列表或引用");
991
+ const L = new DOMParser().parseFromString(B.html, "text/html").body.firstElementChild;
992
+ if (B.tag === "pre") {
993
+ s.push({
951
994
  type: "codeBlock",
952
- ...N.hasAttribute("data-language") ? { attrs: { language: N.getAttribute("data-language") } } : {},
953
- content: N.textContent ? [{ type: "text", text: N.textContent }] : []
995
+ ...L.hasAttribute("data-language") ? { attrs: { language: L.getAttribute("data-language") } } : {},
996
+ content: L.textContent ? [{ type: "text", text: L.textContent }] : []
954
997
  });
955
998
  continue;
956
999
  }
957
- const J = T.tag === "ul" || T.tag === "ol", U = [], nt = J ? Array.from(N.children) : [N];
958
- for (const rt of nt) {
959
- if (J && rt.tagName.toLowerCase() !== "li")
960
- return p(t, q, "列表包含非列表项节点");
1000
+ const V = B.tag === "ul" || B.tag === "ol", U = [], at = V ? Array.from(L.children) : [L];
1001
+ for (const rt of at) {
1002
+ if (V && rt.tagName.toLowerCase() !== "li")
1003
+ return c(t, I, "列表包含非列表项节点");
961
1004
  const st = _t(
962
1005
  rt.innerHTML,
963
- m,
964
- a
1006
+ f,
1007
+ n
965
1008
  );
966
1009
  if (!st.ok) return { ...st, raw: t };
967
- const At = V(st.value, q);
1010
+ const At = Q(st.value, I);
968
1011
  if (!At.ok) return At;
969
- const jt = At.value.length ? At.value : [{ type: "paragraph" }];
970
- J ? U.push({ type: "listItem", content: jt }) : U.push(...jt);
1012
+ const It = At.value.length ? At.value : [{ type: "paragraph" }];
1013
+ V ? U.push({ type: "listItem", content: It }) : U.push(...It);
971
1014
  }
972
- u.push({
973
- type: T.tag === "ul" ? "bulletList" : T.tag === "ol" ? "orderedList" : "blockquote",
974
- ...T.tag === "ol" && (N.hasAttribute("start") || N.hasAttribute("type")) ? {
1015
+ s.push({
1016
+ type: B.tag === "ul" ? "bulletList" : B.tag === "ol" ? "orderedList" : "blockquote",
1017
+ ...B.tag === "ol" && (L.hasAttribute("start") || L.hasAttribute("type")) ? {
975
1018
  attrs: {
976
- ...N.hasAttribute("start") ? { start: Number(N.getAttribute("start")) } : {},
977
- ...N.hasAttribute("type") ? { type: N.getAttribute("type") } : {}
1019
+ ...L.hasAttribute("start") ? { start: Number(L.getAttribute("start")) } : {},
1020
+ ...L.hasAttribute("type") ? { type: L.getAttribute("type") } : {}
978
1021
  }
979
1022
  } : {},
980
1023
  content: U
981
1024
  });
982
1025
  } else {
983
- const N = L(T, q, !1, _);
984
- if (!N.ok) return { ...N, raw: t };
985
- P.push(...N.value);
1026
+ const L = W(B, I, !1, v);
1027
+ if (!L.ok) return { ...L, raw: t };
1028
+ H.push(...L.value);
986
1029
  }
987
- W.some((T) => T.kind === "originalReply") && P.every((T) => {
988
- var N;
989
- return T.type === "text" && !((N = T.text) != null && N.trim());
990
- }) && (P = []), (P.length || !W.length) && u.push({ type: "paragraph", content: P });
1030
+ E.some((B) => B.kind === "originalReply") && H.every((B) => {
1031
+ var L;
1032
+ return B.type === "text" && !((L = B.text) != null && L.trim());
1033
+ }) && (H = []), (H.length || !E.length) && s.push({ type: "paragraph", content: H });
991
1034
  }
992
- return { ok: !0, value: u };
993
- }, x = V(z, o);
994
- if (!x.ok) return { ...x, raw: t };
995
- const b = x.value;
1035
+ return { ok: !0, value: s };
1036
+ }, w = Q(P, i);
1037
+ if (!w.ok) return { ...w, raw: t };
1038
+ const b = w.value;
996
1039
  te(b);
997
- const S = zt(b, `${o}.block`);
998
- if (S) return p(t, S, "工具标签重复");
999
- const Q = {
1040
+ const N = zt(b, `${i}.block`);
1041
+ if (N) return c(t, N, "工具标签重复");
1042
+ const X = {
1000
1043
  type: "doc",
1001
1044
  content: b.length ? b : [{ type: "paragraph" }]
1002
- }, it = C === "agent" ? null : It(Q, r).doc, ot = b.some(
1003
- (n) => {
1004
- var y;
1005
- return n.type !== "paragraph" || ((y = n.content) == null ? void 0 : y.some(
1006
- (_) => {
1007
- var u;
1008
- return _.type !== "text" || !!((u = _.text) != null && u.trim());
1045
+ }, it = M === "agent" ? null : jt(X, r).doc, ot = b.some(
1046
+ (a) => {
1047
+ var p;
1048
+ return a.type !== "paragraph" || ((p = a.content) == null ? void 0 : p.some(
1049
+ (v) => {
1050
+ var s;
1051
+ return v.type !== "text" || !!((s = v.text) != null && s.trim());
1009
1052
  }
1010
1053
  ));
1011
1054
  }
1012
1055
  ), ut = {
1013
1056
  schemaVersion: 1,
1014
- type: C,
1015
- question: { text: j },
1057
+ type: M,
1058
+ question: { text: $ },
1016
1059
  knowledge: {
1017
1060
  doc: it,
1018
1061
  agentRef: et,
1019
- ...C === "agent" && ot ? {
1020
- agentBody: It(Q, r).doc
1062
+ ...M === "agent" && ot ? {
1063
+ agentBody: jt(X, r).doc
1021
1064
  } : {}
1022
1065
  },
1023
- extensionState: A
1024
- }, dt = Ot(ut);
1025
- return dt ? p(t, dt, "转换后的场景未通过新模型校验") : { ok: !0, value: ut };
1066
+ extensionState: _
1067
+ }, dt = Et(ut);
1068
+ return dt ? c(t, dt, "转换后的场景未通过新模型校验") : { ok: !0, value: ut };
1026
1069
  }
1027
- function Wt(t, r, s) {
1028
- var $, a, o, d, m, c, h, k, l, e;
1029
- if (($ = t.marks) != null && $.length) {
1030
- const i = Wt(
1070
+ function Wt(t, r, o) {
1071
+ var x, n, i, u, f, d, h, m, l, e, y, k;
1072
+ if ((x = t.marks) != null && x.length) {
1073
+ const $ = Wt(
1031
1074
  { ...t, marks: void 0 },
1032
1075
  r,
1033
- s
1076
+ o
1034
1077
  );
1035
- if (!i.ok) return i;
1036
- let { html: g } = i.value;
1037
- for (const j of [...t.marks].reverse()) {
1038
- const R = {
1078
+ if (!$.ok) return $;
1079
+ let { html: T } = $.value;
1080
+ for (const C of [...t.marks].reverse()) {
1081
+ const F = {
1039
1082
  bold: "b",
1040
1083
  italic: "i",
1041
1084
  underline: "u",
1042
1085
  strike: "s",
1043
1086
  code: "code",
1044
1087
  link: "a"
1045
- }[j.type];
1046
- if (!R) return p(t, r, "文字格式无法映射到旧格式");
1047
- g = `<${R}${j.type === "link" ? ["href", "target", "rel", "title", "class"].filter((E) => {
1048
- var H;
1049
- return typeof ((H = j.attrs) == null ? void 0 : H[E]) == "string";
1050
- }).map((E) => ` ${E}="${w(j.attrs[E])}"`).join("") : ""}>${g}</${R}>`;
1088
+ }[C.type];
1089
+ if (!F) return c(t, r, "文字格式无法映射到旧格式");
1090
+ T = `<${F}${C.type === "link" ? ["href", "target", "rel", "title", "class"].filter((j) => {
1091
+ var _;
1092
+ return typeof ((_ = C.attrs) == null ? void 0 : _[j]) == "string";
1093
+ }).map((j) => ` ${j}="${S(C.attrs[j])}"`).join("") : ""}>${T}</${F}>`;
1051
1094
  }
1052
- return { ok: !0, value: { html: g, text: i.value.text } };
1095
+ return { ok: !0, value: { html: T, text: $.value.text } };
1053
1096
  }
1054
1097
  if (t.type === "text" && /\{智能(?:建单|工单)@/u.test(t.text || ""))
1055
- return p(
1098
+ return c(
1056
1099
  t,
1057
1100
  r,
1058
1101
  "请通过工单入口插入工单标签,暂不支持将协议文字自动转换为标签"
1059
1102
  );
1060
- if (t.type === "text" && !((a = t.marks) != null && a.length))
1103
+ if (t.type === "text" && !((n = t.marks) != null && n.length))
1061
1104
  return {
1062
1105
  ok: !0,
1063
- value: { html: w(t.text || ""), text: t.text || "" }
1106
+ value: { html: S(t.text || ""), text: t.text || "" }
1064
1107
  };
1065
1108
  if (t.type === "hardBreak")
1066
1109
  return {
@@ -1068,79 +1111,95 @@ function Wt(t, r, s) {
1068
1111
  value: { html: '<br data-hard-break="true">', text: `
1069
1112
  ` }
1070
1113
  };
1071
- if (t.type === "businessToken" && ((o = t.attrs) == null ? void 0 : o.kind) === "ticket") {
1072
- const i = String(t.attrs.key), g = String(t.attrs.label), j = Ft(i, g, t.attrs.params);
1073
- return Lt(j) ? {
1114
+ if (t.type === "businessToken" && ((i = t.attrs) == null ? void 0 : i.kind) === "ticket") {
1115
+ const $ = String(t.attrs.key), T = String(t.attrs.label), C = Ht($, T, t.attrs.params);
1116
+ return Lt(C) ? {
1074
1117
  ok: !0,
1075
1118
  value: {
1076
- html: `<span contenteditable="false" data-tag-type="ticket" data-ticket-id="${w(
1077
- i
1078
- )}" data-ticket-name="${w(g)}"${((d = t.attrs.params) == null ? void 0 : d.protocol) === "legacy" ? ' data-ticket-protocol="legacy"' : ""}>${w(j)}</span>`,
1079
- text: j
1119
+ html: `<span contenteditable="false" data-tag-type="ticket" data-ticket-id="${S(
1120
+ $
1121
+ )}" data-ticket-name="${S(T)}"${((u = t.attrs.params) == null ? void 0 : u.protocol) === "legacy" ? ' data-ticket-protocol="legacy"' : ""}>${S(C)}</span>`,
1122
+ text: C
1080
1123
  }
1081
- } : p(t, r, "工单引用无法映射到旧格式");
1124
+ } : c(t, r, "工单引用无法映射到旧格式");
1082
1125
  }
1083
- if (t.type === "businessToken" && ((m = t.attrs) == null ? void 0 : m.kind) === "tableKnowledge") {
1084
- const i = String(t.attrs.label);
1126
+ if (t.type === "businessToken" && ((f = t.attrs) == null ? void 0 : f.kind) === "tableKnowledge") {
1127
+ const $ = String(t.attrs.label);
1085
1128
  return {
1086
1129
  ok: !0,
1087
1130
  value: {
1088
- html: `<span contenteditable="false" data-tableknowledge="true" data-tag-type="table_knowledge" data-table-name="${w(
1089
- i
1090
- )}" data-table-id="${w(
1131
+ html: `<span contenteditable="false" data-tableknowledge="true" data-tag-type="table_knowledge" data-table-name="${S(
1132
+ $
1133
+ )}" data-table-id="${S(
1091
1134
  String(t.attrs.key)
1092
- )}">##${w(i)}##</span>`,
1093
- text: `##${i}##`
1135
+ )}">##${S($)}##</span>`,
1136
+ text: `##${$}##`
1094
1137
  }
1095
1138
  };
1096
1139
  }
1097
- if (t.type === "businessToken" && ((c = t.attrs) == null ? void 0 : c.kind) === "todo") {
1098
- const i = String(t.attrs.label), g = i === "默认" && t.attrs.token === "{待办}" ? "{待办}" : `{待办@${i}}`;
1140
+ if (t.type === "businessToken" && ((d = t.attrs) == null ? void 0 : d.kind) === "todo") {
1141
+ const $ = String(t.attrs.label), T = $ === "默认" && t.attrs.token === "{待办}" ? "{待办}" : `{待办@${$}}`;
1099
1142
  return {
1100
1143
  ok: !0,
1101
1144
  value: {
1102
- html: `<span contenteditable="false" data-tag="true" data-tag-type="todo" data-tag-name="${w(
1103
- i
1104
- )}" plan_id="${w(String(t.attrs.key))}">${w(
1105
- g
1145
+ html: `<span contenteditable="false" data-tag="true" data-tag-type="todo" data-tag-name="${S(
1146
+ $
1147
+ )}" plan_id="${S(String(t.attrs.key))}">${S(
1148
+ T
1106
1149
  )}</span>`,
1107
- text: g
1150
+ text: T
1108
1151
  }
1109
1152
  };
1110
1153
  }
1111
1154
  if (t.type === "businessToken" && ((h = t.attrs) == null ? void 0 : h.kind) === "variable") {
1112
- const i = String(t.attrs.label || t.attrs.key), g = i === "订单链接" ? "{订单链接}" : `#${i}#`, j = `#${i}#`;
1155
+ const $ = String(t.attrs.label || t.attrs.key), T = $ === "订单链接" ? "{订单链接}" : `#${$}#`, C = `#${$}#`;
1113
1156
  return {
1114
1157
  ok: !0,
1115
1158
  value: {
1116
- html: `<span contenteditable="false" data-tag-type="variable" data-variable="true" data-variable-name="${w(
1117
- i
1118
- )}"${i === "客服昵称" ? ' data-customer="true"' : ""}>${w(
1119
- j
1159
+ html: `<span contenteditable="false" data-tag-type="variable" data-variable="true" data-variable-name="${S(
1160
+ $
1161
+ )}"${$ === "客服昵称" ? ' data-customer="true"' : ""}>${S(
1162
+ C
1120
1163
  )}</span>`,
1121
- text: g
1164
+ text: T
1122
1165
  }
1123
1166
  };
1124
1167
  }
1125
- if (t.type === "businessToken" && ((k = t.attrs) == null ? void 0 : k.kind) === "attribute") {
1126
- const i = Ut(
1168
+ if (t.type === "businessToken" && ((m = t.attrs) == null ? void 0 : m.kind) === "attribute") {
1169
+ const $ = Vt(
1127
1170
  String(t.attrs.key),
1128
- s
1171
+ o
1129
1172
  );
1130
- if (!i || t.attrs.label !== i.name)
1131
- return p(t, r, "业务属性不在旧目录中或名称与 key 不一致");
1132
- const g = w(i.name);
1173
+ if (!$ || t.attrs.label !== $.name)
1174
+ return c(t, r, "业务属性不在旧目录中或名称与 key 不一致");
1175
+ const T = S($.name);
1133
1176
  return {
1134
1177
  ok: !0,
1135
1178
  value: {
1136
- html: `<span contenteditable="false" data-tag="true" data-tag-type="biz_attribute" data-attr-name="${g}" data-attr-key="${w(
1137
- i.key
1138
- )}" data-attr-id="${w(String(i.id))}">${g}</span>`,
1139
- text: qt(i.name)
1179
+ html: `<span contenteditable="false" data-tag="true" data-tag-type="biz_attribute" data-attr-name="${T}" data-attr-key="${S(
1180
+ $.key
1181
+ )}" data-attr-id="${S(String($.id))}">${T}</span>`,
1182
+ text: qt($.name)
1140
1183
  }
1141
1184
  };
1142
1185
  }
1143
- if (t.type === "businessToken" && ((l = t.attrs) == null ? void 0 : l.kind) === "separator")
1186
+ if (t.type === "businessToken" && ((l = t.attrs) == null ? void 0 : l.kind) === "noFollow")
1187
+ return {
1188
+ ok: !0,
1189
+ value: {
1190
+ html: '<span data-tag="no_send_follow_order">不跟单</span>',
1191
+ text: "<不发送跟单>"
1192
+ }
1193
+ };
1194
+ if (t.type === "businessToken" && ((e = t.attrs) == null ? void 0 : e.kind) === "reasoningMarker")
1195
+ return {
1196
+ ok: !0,
1197
+ value: {
1198
+ html: '<span data-tag-type="reasoning" data-reasoning="true" data-fkp-reasoning-inline="true">推理</span>',
1199
+ text: "{推理}"
1200
+ }
1201
+ };
1202
+ if (t.type === "businessToken" && ((y = t.attrs) == null ? void 0 : y.kind) === "separator")
1144
1203
  return {
1145
1204
  ok: !0,
1146
1205
  value: {
@@ -1148,57 +1207,61 @@ function Wt(t, r, s) {
1148
1207
  text: "[sep]"
1149
1208
  }
1150
1209
  };
1151
- if (t.type === "businessToken" && ((e = t.attrs) == null ? void 0 : e.kind) === "tool") {
1152
- const i = Dt(t);
1153
- if (!i) return p(t, r, "工具参数无法映射到旧格式");
1154
- const { params: g } = t.attrs;
1155
- return { ok: !0, value: { html: t.attrs.key === "external_method" ? `<span contenteditable="false" data-tag-type="external_method" data-scene-id="${w(
1156
- g.sceneId
1157
- )}" data-scene-name="${w(g.sceneName)}">${w(
1158
- i
1159
- )}</span>` : t.attrs.key === "small_payment" ? `<span contenteditable="false" data-tag="true" data-tag-type="small_payment" data-max-amount-cent="${Number(g.amount) * 100}">${w(i)}</span>` : `<span contenteditable="false" data-tag="true" data-tag-type="order_remark" data-remark-id="${w(
1160
- g.id
1161
- )}" data-remark-mode="${g.contentMode === "fixed" ? "fixed" : "extract"}" data-remark-flag="${w(
1162
- g.flag
1163
- )}" data-remark-keep-flag="${g.preserveFlag ? "1" : "0"}" data-remark-position="${g.position}" data-remark-content="${w(g.content)}">${w(
1164
- i
1165
- )}</span>`, text: i } };
1210
+ if (t.type === "businessToken" && ((k = t.attrs) == null ? void 0 : k.kind) === "tool") {
1211
+ const $ = Ot(t);
1212
+ if (!$) return c(t, r, "工具参数无法映射到旧格式");
1213
+ const { params: T } = t.attrs;
1214
+ return { ok: !0, value: { html: t.attrs.key === "external_method" ? `<span contenteditable="false" data-tag-type="external_method" data-scene-id="${S(
1215
+ T.sceneId
1216
+ )}" data-scene-name="${S(T.sceneName)}">${S(
1217
+ $
1218
+ )}</span>` : t.attrs.key === "small_payment" ? `<span contenteditable="false" data-tag="true" data-tag-type="small_payment" data-max-amount-cent="${Number(T.amount) * 100}">${S($)}</span>` : `<span contenteditable="false" data-tag="true" data-tag-type="order_remark" data-remark-id="${S(
1219
+ T.id
1220
+ )}" data-remark-mode="${T.contentMode === "fixed" ? "fixed" : "extract"}" data-remark-flag="${S(
1221
+ T.flag
1222
+ )}" data-remark-keep-flag="${T.preserveFlag ? "1" : "0"}" data-remark-position="${T.position}" data-remark-content="${S(T.content)}">${S(
1223
+ $
1224
+ )}</span>`, text: $ } };
1166
1225
  }
1167
- return p(t, r, `节点 ${t.type} 无法映射到旧格式`);
1226
+ return c(t, r, `节点 ${t.type} 无法映射到旧格式`);
1168
1227
  }
1169
- function Pt(t) {
1170
- const r = (t.content || []).map((s) => s.type === "text" ? s.text || "" : "\0").join("");
1228
+ function Ft(t) {
1229
+ const r = (t.content || []).map((o) => o.type === "text" ? o.text || "" : "\0").join("");
1171
1230
  return /\{智能(?:建单|工单)@/u.test(r);
1172
1231
  }
1173
- function Bt(t, r, s) {
1174
- var d, m, c, h;
1175
- if (Pt(t))
1176
- return p(
1232
+ function Bt(t, r, o) {
1233
+ var u, f, d, h;
1234
+ if (Ft(t))
1235
+ return c(
1177
1236
  t,
1178
1237
  r,
1179
1238
  "请通过工单入口插入工单标签,暂不支持将协议文字自动转换为标签"
1180
1239
  );
1181
1240
  if (t.type === "horizontalRule")
1182
1241
  return { ok: !0, value: { html: "<hr>", text: "<hr/>" } };
1183
- if (t.type === "mediaBlock" && ((d = t.attrs) == null ? void 0 : d.status) === "ready") {
1184
- const k = t.attrs.kind === "image" ? "img" : "video", l = w(String(t.attrs.src)), e = [
1242
+ if (t.type === "mediaBlock" && ((u = t.attrs) == null ? void 0 : u.status) === "ready") {
1243
+ const m = t.attrs.kind === "image" ? "img" : "video", l = S(String(t.attrs.src)), e = [
1185
1244
  ["assetId", "data-asset-id"],
1186
1245
  ["name", "data-media-name"],
1187
1246
  ["poster", "poster"],
1188
- ["sourceType", "data-source-type"]
1189
- ].filter(([i]) => {
1190
- var g;
1191
- return typeof ((g = t.attrs) == null ? void 0 : g[i]) == "string";
1192
- }).map(([i, g]) => ` ${g}="${w(t.attrs[i])}"`).join("");
1247
+ ["sourceType", "data-source-type"],
1248
+ ...t.attrs.sourceType === "qianniuVideo" ? [
1249
+ ["assetId", "id"],
1250
+ ["assetId", "data-video-id"]
1251
+ ] : []
1252
+ ].filter(([y]) => {
1253
+ var k;
1254
+ return typeof ((k = t.attrs) == null ? void 0 : k[y]) == "string";
1255
+ }).map(([y, k]) => ` ${k}="${S(t.attrs[y])}"`).join("");
1193
1256
  return {
1194
1257
  ok: !0,
1195
1258
  value: {
1196
- html: `<${k} src="${l}"${e}${k === "video" ? "/>" : ">"}`,
1197
- text: t.attrs.sourceType === "qianniuVideo" ? l : `<${k} src="${l}"${e}${k === "video" ? ' width="240" controls/>' : ' width="120"/>'}`
1259
+ html: `<${m} src="${l}"${e}${m === "video" ? "/>" : ">"}`,
1260
+ text: `<${m} src="${l}"${e}${m === "video" ? ' width="240" controls/>' : ' width="120"/>'}`
1198
1261
  }
1199
1262
  };
1200
1263
  }
1201
- const a = {
1264
+ const n = {
1202
1265
  paragraph: "p",
1203
1266
  bulletList: "ul",
1204
1267
  orderedList: "ol",
@@ -1206,18 +1269,18 @@ function Bt(t, r, s) {
1206
1269
  blockquote: "blockquote",
1207
1270
  codeBlock: "pre"
1208
1271
  }[t.type || ""];
1209
- if (!a) return p(t, r, "块级节点无法映射到旧格式");
1210
- const o = [];
1211
- for (const [k, l] of (t.content || []).entries()) {
1212
- const e = `${r}.content[${k}]`, i = ["paragraph", "codeBlock"].includes(t.type || "") ? Wt(l, e, s) : Bt(l, e, s);
1213
- if (!i.ok) return i;
1214
- o.push(i.value);
1272
+ if (!n) return c(t, r, "块级节点无法映射到旧格式");
1273
+ const i = [];
1274
+ for (const [m, l] of (t.content || []).entries()) {
1275
+ const e = `${r}.content[${m}]`, y = ["paragraph", "codeBlock"].includes(t.type || "") ? Wt(l, e, o) : Bt(l, e, o);
1276
+ if (!y.ok) return y;
1277
+ i.push(y.value);
1215
1278
  }
1216
1279
  return {
1217
1280
  ok: !0,
1218
1281
  value: {
1219
- html: `<${a}${t.type === "orderedList" && ((m = t.attrs) == null ? void 0 : m.start) !== void 0 ? ` start="${w(String(t.attrs.start))}"` : t.type === "codeBlock" && ((c = t.attrs) != null && c.language) ? ` data-language="${w(t.attrs.language)}"` : ""}${t.type === "orderedList" && ((h = t.attrs) != null && h.type) ? ` type="${w(String(t.attrs.type))}"` : ""}>${o.map((k) => k.html).join("")}</${a}>`,
1220
- text: o.map((k) => k.text).join(
1282
+ html: `<${n}${t.type === "orderedList" && ((f = t.attrs) == null ? void 0 : f.start) !== void 0 ? ` start="${S(String(t.attrs.start))}"` : t.type === "codeBlock" && ((d = t.attrs) != null && d.language) ? ` data-language="${S(t.attrs.language)}"` : ""}${t.type === "orderedList" && ((h = t.attrs) != null && h.type) ? ` type="${S(String(t.attrs.type))}"` : ""}>${i.map((m) => m.html).join("")}</${n}>`,
1283
+ text: i.map((m) => m.text).join(
1221
1284
  ["paragraph", "codeBlock"].includes(t.type || "") ? "" : `
1222
1285
  `
1223
1286
  )
@@ -1225,176 +1288,176 @@ function Bt(t, r, s) {
1225
1288
  };
1226
1289
  }
1227
1290
  function $t(t, r = !1) {
1228
- const s = (a) => {
1229
- var m, c;
1230
- const o = { ...a.attrs };
1231
- delete o.id, delete o.nodeVersion, r && a.type === "businessToken" && o.kind === "tableKnowledge" && (o.key = o.label);
1232
- const d = r && a.type === "doc" ? (m = a.content) == null ? void 0 : m.filter(
1233
- (h, k, l) => {
1234
- var e, i;
1235
- return !(h.type === "paragraph" && !((e = h.content) != null && e.length) && ((i = l[k + 1]) == null ? void 0 : i.type) === "originalReply");
1291
+ const o = (n) => {
1292
+ var f, d;
1293
+ const i = { ...n.attrs };
1294
+ delete i.id, delete i.nodeVersion, r && n.type === "businessToken" && i.kind === "tableKnowledge" && (i.key = i.label);
1295
+ const u = r && n.type === "doc" ? (f = n.content) == null ? void 0 : f.filter(
1296
+ (h, m, l) => {
1297
+ var e, y;
1298
+ return !(h.type === "paragraph" && !((e = h.content) != null && e.length) && ((y = l[m + 1]) == null ? void 0 : y.type) === "originalReply");
1236
1299
  }
1237
- ) : a.content;
1300
+ ) : n.content;
1238
1301
  return {
1239
- ...a,
1302
+ ...n,
1240
1303
  ...r ? {
1241
1304
  marks: void 0,
1242
- ...a.type === "text" ? { text: (c = a.text) == null ? void 0 : c.replace(/\u00a0/g, " ") } : {}
1305
+ ...n.type === "text" ? { text: (d = n.text) == null ? void 0 : d.replace(/\u00a0/g, " ") } : {}
1243
1306
  } : {},
1244
- attrs: Object.keys(o).length ? o : void 0,
1245
- content: d != null && d.length ? d.map(s) : void 0
1307
+ attrs: Object.keys(i).length ? i : void 0,
1308
+ content: u != null && u.length ? u.map(o) : void 0
1246
1309
  };
1247
- }, $ = (a) => Array.isArray(a) ? a.map($) : a && typeof a == "object" ? Object.fromEntries(
1248
- Object.entries(a).sort(([o], [d]) => o.localeCompare(d)).map(([o, d]) => [o, $(d)])
1249
- ) : a;
1310
+ }, x = (n) => Array.isArray(n) ? n.map(x) : n && typeof n == "object" ? Object.fromEntries(
1311
+ Object.entries(n).sort(([i], [u]) => i.localeCompare(u)).map(([i, u]) => [i, x(u)])
1312
+ ) : n;
1250
1313
  return JSON.stringify(
1251
- $({
1314
+ x({
1252
1315
  type: t.type,
1253
1316
  question: t.question.text,
1254
- doc: t.knowledge.doc ? s(t.knowledge.doc) : null,
1317
+ doc: t.knowledge.doc ? o(t.knowledge.doc) : null,
1255
1318
  agentRef: t.knowledge.agentRef || null,
1256
- agentBody: t.knowledge.agentBody ? s(t.knowledge.agentBody) : null,
1257
- retainedDoc: t.knowledge.retainedDoc ? s(t.knowledge.retainedDoc) : null,
1319
+ agentBody: t.knowledge.agentBody ? o(t.knowledge.agentBody) : null,
1320
+ retainedDoc: t.knowledge.retainedDoc ? o(t.knowledge.retainedDoc) : null,
1258
1321
  extensionState: t.extensionState
1259
1322
  })
1260
1323
  );
1261
1324
  }
1262
- function ae(t, r, s, $, a) {
1263
- var j, R, E, H, M;
1325
+ function ne(t, r, o, x, n) {
1326
+ var $, T, C, F, j;
1264
1327
  if (typeof r.content != "string" || /<source\b|<\/video\s*>/iu.test(r.content)) return !1;
1265
- const o = new DOMParser().parseFromString(
1328
+ const i = new DOMParser().parseFromString(
1266
1329
  xt(
1267
- String(r.web_content || s.web_content)
1330
+ String(r.web_content || o.web_content)
1268
1331
  ),
1269
1332
  "text/html"
1270
1333
  );
1271
- if (Array.from(o.querySelectorAll("*")).some(
1272
- (A) => Array.from(A.attributes).some(
1273
- (I) => /^on/iu.test(I.name) || ["srcdoc", "srcset"].includes(I.name.toLowerCase()) || I.name.toLowerCase() === "style" && /url\s*\(|expression\s*\(|@import/iu.test(I.value)
1334
+ if (Array.from(i.querySelectorAll("*")).some(
1335
+ (_) => Array.from(_.attributes).some(
1336
+ (O) => /^on/iu.test(O.name) || ["srcdoc", "srcset"].includes(O.name.toLowerCase()) || O.name.toLowerCase() === "style" && /url\s*\(|expression\s*\(|@import/iu.test(O.value)
1274
1337
  )
1275
1338
  ))
1276
1339
  return !1;
1277
- const d = !!wt(r.content);
1278
- if (d !== ($ === "inline")) return !1;
1279
- const m = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), h = (A) => {
1280
- var I, F, K;
1281
- A.type === "businessToken" && ((I = A.attrs) == null ? void 0 : I.kind) === "variable" && m.set(String(A.attrs.label), {
1282
- key: String(A.attrs.key),
1283
- label: String(A.attrs.label)
1284
- }), A.type === "businessToken" && ((F = A.attrs) == null ? void 0 : F.kind) === "todo" && c.set(String(A.attrs.label), {
1285
- id: String(A.attrs.key),
1286
- label: String(A.attrs.label)
1287
- }), (K = A.content) == null || K.forEach(h);
1340
+ const u = !!wt(r.content);
1341
+ if (u !== (x === "inline")) return !1;
1342
+ const f = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), h = (_) => {
1343
+ var O, K, J;
1344
+ _.type === "businessToken" && ((O = _.attrs) == null ? void 0 : O.kind) === "variable" && f.set(String(_.attrs.label), {
1345
+ key: String(_.attrs.key),
1346
+ label: String(_.attrs.label)
1347
+ }), _.type === "businessToken" && ((K = _.attrs) == null ? void 0 : K.kind) === "todo" && d.set(String(_.attrs.label), {
1348
+ id: String(_.attrs.key),
1349
+ label: String(_.attrs.label)
1350
+ }), (J = _.content) == null || J.forEach(h);
1288
1351
  };
1289
- (R = (j = t.knowledge.doc) == null ? void 0 : j.content) == null || R.forEach(h), (H = (E = t.knowledge.agentBody) == null ? void 0 : E.content) == null || H.forEach(h);
1290
- const k = (M = t.extensionState.todo) == null ? void 0 : M.data;
1291
- k != null && k.tag && c.set(k.tag.label, k.tag);
1352
+ (T = ($ = t.knowledge.doc) == null ? void 0 : $.content) == null || T.forEach(h), (F = (C = t.knowledge.agentBody) == null ? void 0 : C.content) == null || F.forEach(h);
1353
+ const m = (j = t.extensionState.todo) == null ? void 0 : j.data;
1354
+ m != null && m.tag && d.set(m.tag.label, m.tag);
1292
1355
  const l = {
1293
- variable: (A) => m.get(A) || null,
1294
- selection: (A, I) => A === "todo" && c.get(I) || null
1295
- }, e = Et(
1296
- { ...r, web_content: r.web_content || s.web_content },
1356
+ variable: (_) => f.get(_) || null,
1357
+ selection: (_, O) => _ === "todo" && d.get(O) || null
1358
+ }, e = Mt(
1359
+ { ...r, web_content: r.web_content || o.web_content },
1297
1360
  "layout-proof",
1298
1361
  l,
1299
1362
  {
1300
1363
  questionText: t.question.text,
1301
- businessAttributes: a
1364
+ businessAttributes: n
1302
1365
  }
1303
- ), i = $t(t);
1304
- if (!e.ok || $t(e.value) !== i)
1366
+ ), y = $t(t);
1367
+ if (!e.ok || $t(e.value) !== y)
1305
1368
  return !1;
1306
1369
  if (t.type === "normal") {
1307
- const A = _t(
1370
+ const _ = _t(
1308
1371
  String(r.web_content || Ct(r.content))
1309
1372
  );
1310
- if (!A.ok || A.value.slice(d ? 1 : 0).some(
1311
- (I) => I.some(
1312
- (F) => F.kind === "todo" || F.kind === "text" && /\{(?:待办(?:@[^{}]*)?|原话复述)\}/u.test(F.value)
1373
+ if (!_.ok || _.value.slice(u ? 1 : 0).some(
1374
+ (O) => O.some(
1375
+ (K) => K.kind === "todo" || K.kind === "text" && /\{(?:待办(?:@[^{}]*)?|原话复述)\}/u.test(K.value)
1313
1376
  )
1314
1377
  ))
1315
1378
  return !1;
1316
1379
  }
1317
- const g = Et(
1318
- { ...s, web_content: "", content: r.content },
1380
+ const k = Mt(
1381
+ { ...o, web_content: "", content: r.content },
1319
1382
  "layout-proof",
1320
1383
  {
1321
1384
  ...l,
1322
- agent: (A) => {
1323
- var I;
1324
- return ((I = t.knowledge.agentRef) == null ? void 0 : I.name) === A ? t.knowledge.agentRef : null;
1385
+ agent: (_) => {
1386
+ var O;
1387
+ return ((O = t.knowledge.agentRef) == null ? void 0 : O.name) === _ ? t.knowledge.agentRef : null;
1325
1388
  }
1326
1389
  },
1327
- { questionText: t.question.text, businessAttributes: a }
1390
+ { questionText: t.question.text, businessAttributes: n }
1328
1391
  );
1329
- return g.ok && $t(g.value, !0) === $t(t, !0);
1392
+ return k.ok && $t(k.value, !0) === $t(t, !0);
1330
1393
  }
1331
- function oe(t, r = {}, s = {}) {
1332
- var G, tt, O, Z, z, Y, C, et, X, D, L, V, x, b, S, Q, it, ot, ut, dt, gt, ct, ft, pt, yt, mt, kt, bt, n, y, _;
1333
- const $ = s.businessAttributes ?? vt;
1334
- if (!Mt($))
1335
- return p(
1394
+ function oe(t, r = {}, o = {}) {
1395
+ var G, tt, D, Z, P, Y, M, et, z, R, W, Q, w, b, N, X, it, ot, ut, dt, gt, ct, ft, pt, yt, mt, kt, bt, a, p, v;
1396
+ const x = o.businessAttributes ?? vt;
1397
+ if (!Dt(x))
1398
+ return c(
1336
1399
  t,
1337
1400
  "businessAttributes",
1338
1401
  "业务属性目录格式无效或存在重复引用"
1339
1402
  );
1340
- const a = Ot(t);
1341
- if (a) return p(t, a, "场景未通过新模型校验");
1342
- const o = zt(
1403
+ const n = Et(t);
1404
+ if (n) return c(t, n, "场景未通过新模型校验");
1405
+ const i = zt(
1343
1406
  ((G = t.knowledge.doc || t.knowledge.agentBody || t.knowledge.retainedDoc) == null ? void 0 : G.content) || [],
1344
1407
  "knowledge.content"
1345
1408
  );
1346
- if (o) return p(t, o, "工具标签重复");
1347
- const d = `【${t.question.text}】`, m = [], c = [];
1348
- for (const [u, f] of [
1409
+ if (i) return c(t, i, "工具标签重复");
1410
+ const u = `【${t.question.text}】`, f = [], d = [];
1411
+ for (const [s, g] of [
1349
1412
  ["todo", "待办"],
1350
1413
  ["tagged", "顾客标签"]
1351
1414
  ]) {
1352
- const v = (tt = t.extensionState[u]) == null ? void 0 : tt.data;
1353
- if (v != null && v.enabled) {
1354
- const W = `{${f}@${(O = v.tag) == null ? void 0 : O.label}}`;
1355
- m.push(W), c.push(
1356
- u === "todo" ? `<span contenteditable="false" data-tag="true" data-tag-type="todo" data-tag-name="${w(
1357
- ((Z = v.tag) == null ? void 0 : Z.label) || ""
1358
- )}" plan_id="${w(((z = v.tag) == null ? void 0 : z.id) || "")}">${w(
1359
- W
1360
- )}</span>` : `<span contenteditable="false" data-tag="true" data-tag-type="cdp_tag" data-tag-name="${w(
1361
- ((Y = v.tag) == null ? void 0 : Y.label) || ""
1362
- )}" data-tag-id="${w(((C = v.tag) == null ? void 0 : C.id) || "")}">${w(
1363
- W
1415
+ const A = (tt = t.extensionState[s]) == null ? void 0 : tt.data;
1416
+ if (A != null && A.enabled) {
1417
+ const E = `{${g}@${(D = A.tag) == null ? void 0 : D.label}}`;
1418
+ f.push(E), d.push(
1419
+ s === "todo" ? `<span contenteditable="false" data-tag="true" data-tag-type="todo" data-tag-name="${S(
1420
+ ((Z = A.tag) == null ? void 0 : Z.label) || ""
1421
+ )}" plan_id="${S(((P = A.tag) == null ? void 0 : P.id) || "")}">${S(
1422
+ E
1423
+ )}</span>` : `<span contenteditable="false" data-tag="true" data-tag-type="cdp_tag" data-tag-name="${S(
1424
+ ((Y = A.tag) == null ? void 0 : Y.label) || ""
1425
+ )}" data-tag-id="${S(((M = A.tag) == null ? void 0 : M.id) || "")}">${S(
1426
+ E
1364
1427
  )}</span>`
1365
1428
  );
1366
1429
  }
1367
1430
  }
1368
- (X = (et = t.extensionState.originalReply) == null ? void 0 : et.data) != null && X.enabled && (m.push("{原话复述}"), c.push(
1431
+ (z = (et = t.extensionState.originalReply) == null ? void 0 : et.data) != null && z.enabled && (f.push("{原话复述}"), d.push(
1369
1432
  '<span data-tag-type="original_repeat" data-retelling="true">{原话复述}</span>'
1370
- )), (L = (D = t.extensionState.memory) == null ? void 0 : D.data) != null && L.enabled && (m.push("{记忆触发点}"), c.push(
1433
+ )), (W = (R = t.extensionState.memory) == null ? void 0 : R.data) != null && W.enabled && (f.push("{记忆触发点}"), d.push(
1371
1434
  '<span data-tag-type="memory_trigger" data-memory-trigger="true">{记忆触发点}</span>'
1372
1435
  ));
1373
- for (const u of Object.keys(t.extensionState))
1374
- if (!["todo", "tagged", "originalReply", "memory"].includes(u))
1375
- return p(
1436
+ for (const s of Object.keys(t.extensionState))
1437
+ if (!["todo", "tagged", "originalReply", "memory"].includes(s))
1438
+ return c(
1376
1439
  t,
1377
- `extensionState.${u}`,
1440
+ `extensionState.${s}`,
1378
1441
  "旧格式无法表示此插件状态"
1379
1442
  );
1380
- const h = s.questionStorage || (ee(String(r.web_content || "")) ? "inline" : "external"), k = h === "inline" ? [`<div>${w(d)}${c.join("")}</div>`] : c.length ? [`<div>${c.join("")}</div>`] : [], l = h === "inline" ? [d + m.join("")] : m.length ? [m.join("")] : [];
1381
- if (t.type === "reasoning" && (k.push("<div>{推理}</div>"), l.push("{推理}")), t.type === "agent") {
1443
+ const h = o.questionStorage || (ee(String(r.web_content || "")) ? "inline" : "external"), m = h === "inline" ? [`<div>${S(u)}${d.join("")}</div>`] : d.length ? [`<div>${d.join("")}</div>`] : [], l = h === "inline" ? [u + f.join("")] : f.length ? [f.join("")] : [];
1444
+ if (t.type === "reasoning" && (m.push("<div>{推理}</div>"), l.push("{推理}")), t.type === "agent") {
1382
1445
  if (!t.knowledge.agentRef)
1383
- return p(t, "knowledge.agentRef", "旧格式需要 Agent 引用");
1384
- const u = t.knowledge.agentRef, f = `{自定义Agent}@${u.name}${u.invalid ? "(已失效)" : ""}`;
1385
- k.push(
1386
- `<div><span data-tag-type="custom_agent" data-agent="true" data-agent-name="${w(
1387
- u.name
1388
- )}"${u.id ? ` data-agent-id="${w(u.id)}"` : ""}${u.invalid ? ' data-invalid="true"' : ""}>${w(f)}</span></div>`
1389
- ), l.push(f);
1446
+ return c(t, "knowledge.agentRef", "旧格式需要 Agent 引用");
1447
+ const s = t.knowledge.agentRef, g = `{自定义Agent}@${s.name}${s.invalid ? "(已失效)" : ""}`;
1448
+ m.push(
1449
+ `<div><span data-tag-type="custom_agent" data-agent="true" data-agent-name="${S(
1450
+ s.name
1451
+ )}"${s.id ? ` data-agent-id="${S(s.id)}"` : ""}${s.invalid ? ' data-invalid="true"' : ""}>${S(g)}</span></div>`
1452
+ ), l.push(g);
1390
1453
  }
1391
1454
  const e = t.type === "agent" ? t.knowledge.agentBody ? "agentBody" : "retainedDoc" : "doc";
1392
- for (const [u, f] of (((V = t.knowledge[e]) == null ? void 0 : V.content) || []).entries()) {
1393
- const v = `knowledge.${e}.content[${u}]`;
1394
- if (((b = (x = t.knowledge[e]) == null ? void 0 : x.content) == null ? void 0 : b.length) === 1 && f.type === "paragraph" && !((S = f.content) != null && S.length))
1455
+ for (const [s, g] of (((Q = t.knowledge[e]) == null ? void 0 : Q.content) || []).entries()) {
1456
+ const A = `knowledge.${e}.content[${s}]`;
1457
+ if (((b = (w = t.knowledge[e]) == null ? void 0 : w.content) == null ? void 0 : b.length) === 1 && g.type === "paragraph" && !((N = g.content) != null && N.length))
1395
1458
  continue;
1396
- if (f.type === "messageSeparator") {
1397
- k.push(
1459
+ if (g.type === "messageSeparator") {
1460
+ m.push(
1398
1461
  '<div><span data-tag-type="separator" data-divider="true">{分隔符}</span></div>'
1399
1462
  ), l.push("[sep]");
1400
1463
  continue;
@@ -1406,154 +1469,154 @@ function oe(t, r = {}, s = {}) {
1406
1469
  "orderedList",
1407
1470
  "blockquote",
1408
1471
  "codeBlock"
1409
- ].includes(f.type || "")) {
1410
- const T = Bt(f, v, $);
1411
- if (!T.ok) return { ...T, raw: t };
1412
- k.push(
1413
- f.type === "mediaBlock" ? `<div>${T.value.html}</div>` : T.value.html
1414
- ), l.push(T.value.text);
1472
+ ].includes(g.type || "")) {
1473
+ const B = Bt(g, A, x);
1474
+ if (!B.ok) return { ...B, raw: t };
1475
+ m.push(
1476
+ g.type === "mediaBlock" ? `<div>${B.value.html}</div>` : B.value.html
1477
+ ), l.push(B.value.text);
1415
1478
  continue;
1416
1479
  }
1417
- const W = f.type === "originalReply", q = W ? f.content || [] : [f];
1418
- if (!q.length || q.some(
1419
- (T) => !["paragraph", "mediaBlock", "messageSeparator"].includes(
1420
- T.type || ""
1480
+ const E = g.type === "originalReply", I = E ? g.content || [] : [g];
1481
+ if (!I.length || I.some(
1482
+ (B) => !["paragraph", "mediaBlock", "messageSeparator"].includes(
1483
+ B.type || ""
1421
1484
  )
1422
1485
  ))
1423
- return p(t, v, `节点 ${f.type} 无法映射到旧格式`);
1424
- const B = [];
1425
- for (const [T, N] of q.entries()) {
1426
- if (N.type === "mediaBlock") {
1427
- const U = Bt(N, v, $);
1486
+ return c(t, A, `节点 ${g.type} 无法映射到旧格式`);
1487
+ const q = [];
1488
+ for (const [B, L] of I.entries()) {
1489
+ if (L.type === "mediaBlock") {
1490
+ const U = Bt(L, A, x);
1428
1491
  if (!U.ok) return { ...U, raw: t };
1429
- B.push(U.value);
1492
+ q.push(U.value);
1430
1493
  continue;
1431
1494
  }
1432
- if (N.type === "messageSeparator") {
1433
- B.push({
1495
+ if (L.type === "messageSeparator") {
1496
+ q.push({
1434
1497
  html: '<span data-tag-type="separator" data-divider="true">分隔符</span>',
1435
1498
  text: "[sep]"
1436
1499
  });
1437
1500
  continue;
1438
1501
  }
1439
- if (Pt(N))
1440
- return p(
1502
+ if (Ft(L))
1503
+ return c(
1441
1504
  t,
1442
- v,
1505
+ A,
1443
1506
  "请通过工单入口插入工单标签,暂不支持将协议文字自动转换为标签"
1444
1507
  );
1445
- const J = [];
1446
- for (const [U, nt] of (N.content || []).entries()) {
1508
+ const V = [];
1509
+ for (const [U, at] of (L.content || []).entries()) {
1447
1510
  const rt = Wt(
1448
- nt,
1449
- `${v}.content[${T}].content[${U}]`,
1450
- $
1511
+ at,
1512
+ `${A}.content[${B}].content[${U}]`,
1513
+ x
1451
1514
  );
1452
1515
  if (!rt.ok) return { ...rt, raw: t };
1453
- J.push(rt.value);
1516
+ V.push(rt.value);
1454
1517
  }
1455
- B.push({
1456
- html: J.map((U) => U.html).join(""),
1457
- text: J.map((U) => U.text).join("")
1518
+ q.push({
1519
+ html: V.map((U) => U.html).join(""),
1520
+ text: V.map((U) => U.text).join("")
1458
1521
  });
1459
1522
  }
1460
- const P = B.map((T) => T.html).join("<br>"), at = B.map((T) => T.text).join(`
1523
+ const H = q.map((B) => B.html).join("<br>"), nt = q.map((B) => B.text).join(`
1461
1524
  `);
1462
- W ? (k.push(
1463
- `<div><span contenteditable="false" class="original-repeat-template" data-retelling="true" data-tag-type="original_repeat" data-original-repeat-template="true"><span>&lt;</span><span>原话复述</span><span class="original-repeat-input" contenteditable="true" data-original-repeat-input="true">${P}</span><span>&gt;</span></span></div>`
1464
- ), l.push(`<{原话复述}${at}>`)) : (k.push(`<div>${P}</div>`), l.push(at));
1525
+ E ? (m.push(
1526
+ `<div><span contenteditable="false" class="original-repeat-template" data-retelling="true" data-tag-type="original_repeat" data-original-repeat-template="true"><span>&lt;</span><span>原话复述</span><span class="original-repeat-input" contenteditable="true" data-original-repeat-input="true">${H}</span><span>&gt;</span></span></div>`
1527
+ ), l.push(`<{原话复述}${nt}>`)) : (m.push(`<div>${H}</div>`), l.push(nt));
1465
1528
  }
1466
- const i = (Q = t.extensionState.todo) == null ? void 0 : Q.data, g = [], j = (u) => {
1467
- var f, v;
1468
- u.type === "businessToken" && ((f = u.attrs) == null ? void 0 : f.kind) === "todo" && g.push({
1469
- id: String(u.attrs.key),
1470
- label: String(u.attrs.label)
1471
- }), (v = u.content) == null || v.forEach(j);
1529
+ const y = (X = t.extensionState.todo) == null ? void 0 : X.data, k = [], $ = (s) => {
1530
+ var g, A;
1531
+ s.type === "businessToken" && ((g = s.attrs) == null ? void 0 : g.kind) === "todo" && k.push({
1532
+ id: String(s.attrs.key),
1533
+ label: String(s.attrs.label)
1534
+ }), (A = s.content) == null || A.forEach($);
1472
1535
  };
1473
- (ot = (it = t.knowledge[e]) == null ? void 0 : it.content) == null || ot.forEach(j);
1474
- const R = i != null && i.enabled && i.tag ? [i.tag, ...g] : g, E = [
1536
+ (ot = (it = t.knowledge[e]) == null ? void 0 : it.content) == null || ot.forEach($);
1537
+ const T = y != null && y.enabled && y.tag ? [y.tag, ...k] : k, C = [
1475
1538
  ...new Map(
1476
- R.map((u) => [JSON.stringify([u.id, u.label]), u])
1539
+ T.map((s) => [JSON.stringify([s.id, s.label]), s])
1477
1540
  ).values()
1478
1541
  ];
1479
- if (new Set(E.map((u) => u.label)).size !== E.length)
1480
- return p(
1542
+ if (new Set(C.map((s) => s.label)).size !== C.length)
1543
+ return c(
1481
1544
  t,
1482
1545
  "knowledge.doc",
1483
1546
  "同名待办对应多个方案 ID,旧格式无法无损保存"
1484
1547
  );
1485
- const H = E.length === 1 ? E[0] : void 0, M = (ut = t.extensionState.tagged) == null ? void 0 : ut.data, A = [];
1486
- if (M != null && M.enabled) {
1487
- A.push({
1548
+ const F = C.length === 1 ? C[0] : void 0, j = (ut = t.extensionState.tagged) == null ? void 0 : ut.data, _ = [];
1549
+ if (j != null && j.enabled) {
1550
+ _.push({
1488
1551
  type: "cdp_tag",
1489
- name: (dt = M.tag) == null ? void 0 : dt.label,
1490
- value: (gt = M.tag) == null ? void 0 : gt.id
1491
- }), E.forEach((f) => A.push({ type: "todo", name: f.label })), t.type === "reasoning" && A.push({ type: "reasoning", name: "推理" }), (ft = (ct = t.extensionState.originalReply) == null ? void 0 : ct.data) != null && ft.enabled && A.push({ type: "original_repeat", name: "原话复述" });
1492
- const u = (f) => {
1493
- var v, W, q;
1494
- f.type === "businessToken" && ((v = f.attrs) == null ? void 0 : v.kind) === "tableKnowledge" && A.push({ type: "table_knowledge", name: f.attrs.label }), f.type === "businessToken" && ((W = f.attrs) == null ? void 0 : W.kind) === "variable" && A.push({
1552
+ name: (dt = j.tag) == null ? void 0 : dt.label,
1553
+ value: (gt = j.tag) == null ? void 0 : gt.id
1554
+ }), C.forEach((g) => _.push({ type: "todo", name: g.label })), t.type === "reasoning" && _.push({ type: "reasoning", name: "推理" }), (ft = (ct = t.extensionState.originalReply) == null ? void 0 : ct.data) != null && ft.enabled && _.push({ type: "original_repeat", name: "原话复述" });
1555
+ const s = (g) => {
1556
+ var A, E, I;
1557
+ g.type === "businessToken" && ((A = g.attrs) == null ? void 0 : A.kind) === "tableKnowledge" && _.push({ type: "table_knowledge", name: g.attrs.label }), g.type === "businessToken" && ((E = g.attrs) == null ? void 0 : E.kind) === "variable" && _.push({
1495
1558
  type: "variable",
1496
- variable_name: f.attrs.label || f.attrs.key
1497
- }), f.type === "originalReply" && A.push({ type: "original_repeat", name: "原话复述" }), (q = f.content) == null || q.forEach(u);
1559
+ variable_name: g.attrs.label || g.attrs.key
1560
+ }), g.type === "originalReply" && _.push({ type: "original_repeat", name: "原话复述" }), (I = g.content) == null || I.forEach(s);
1498
1561
  };
1499
- (yt = (pt = t.knowledge[e]) == null ? void 0 : pt.content) == null || yt.forEach(u);
1562
+ (yt = (pt = t.knowledge[e]) == null ? void 0 : pt.content) == null || yt.forEach(s);
1500
1563
  }
1501
- const I = ((mt = t.knowledge[e]) == null ? void 0 : mt.content) || [], F = ((kt = I.at(-1)) == null ? void 0 : kt.type) === "paragraph" && !((n = (bt = I.at(-1)) == null ? void 0 : bt.content) != null && n.length) && ((y = I.at(-2)) == null ? void 0 : y.type) === "mediaBlock", K = {
1564
+ const O = ((mt = t.knowledge[e]) == null ? void 0 : mt.content) || [], K = ((kt = O.at(-1)) == null ? void 0 : kt.type) === "paragraph" && !((a = (bt = O.at(-1)) == null ? void 0 : bt.content) != null && a.length) && ((p = O.at(-2)) == null ? void 0 : p.type) === "mediaBlock", J = {
1502
1565
  ...r,
1503
1566
  knowledge_type: t.type === "reasoning" ? 2 : t.type === "agent" ? 3 : 1,
1504
- todo_plan_id: (H == null ? void 0 : H.id) || "",
1505
- todo_tag_type: E.length ? 2 : 0,
1506
- ...R.length || Object.hasOwn(r, "todo_tag_metas") ? {
1507
- todo_tag_metas: R.length ? JSON.stringify(
1508
- R.map((u) => ({
1509
- plan_id: u.id,
1510
- plan_name: u.label,
1567
+ todo_plan_id: (F == null ? void 0 : F.id) || "",
1568
+ todo_tag_type: C.length ? 2 : 0,
1569
+ ...T.length || Object.hasOwn(r, "todo_tag_metas") ? {
1570
+ todo_tag_metas: T.length ? JSON.stringify(
1571
+ T.map((s) => ({
1572
+ plan_id: s.id,
1573
+ plan_name: s.label,
1511
1574
  tag_type: 2
1512
1575
  }))
1513
1576
  ) : ""
1514
1577
  } : {},
1515
- todo_plan_name: (H == null ? void 0 : H.label) || "",
1578
+ todo_plan_name: (F == null ? void 0 : F.label) || "",
1516
1579
  tag_meta: [
1517
1580
  ...new Map(
1518
- A.map((u) => [
1581
+ _.map((s) => [
1519
1582
  JSON.stringify([
1520
- u.type,
1521
- u.name || "",
1522
- u.value || "",
1523
- u.variable_name || ""
1583
+ s.type,
1584
+ s.name || "",
1585
+ s.value || "",
1586
+ s.variable_name || ""
1524
1587
  ]),
1525
- u
1588
+ s
1526
1589
  ])
1527
1590
  ).values()
1528
1591
  ],
1529
- web_content: k.join(""),
1530
- content: (F ? l.slice(0, -1) : l).join(`
1592
+ web_content: m.join(""),
1593
+ content: (K ? l.slice(0, -1) : l).join(`
1531
1594
  `)
1532
1595
  };
1533
- if (ae(t, r, K, h, $)) {
1534
- const u = new DOMParser().parseFromString(
1535
- xt(String(r.web_content || K.web_content)),
1596
+ if (ne(t, r, J, h, x)) {
1597
+ const s = new DOMParser().parseFromString(
1598
+ xt(String(r.web_content || J.web_content)),
1536
1599
  "text/html"
1537
1600
  );
1538
- if (!r.web_content && ((_ = wt(r.content || "")) != null && _.suffix.startsWith(
1601
+ if (!r.web_content && ((v = wt(r.content || "")) != null && v.suffix.startsWith(
1539
1602
  "{推理}"
1540
1603
  ))) {
1541
- const [f, v] = Array.from(u.body.children);
1542
- f && (v == null ? void 0 : v.textContent) === "{推理}" && (f.append(...Array.from(v.childNodes)), v.remove());
1604
+ const [g, A] = Array.from(s.body.children);
1605
+ g && (A == null ? void 0 : A.textContent) === "{推理}" && (g.append(...Array.from(A.childNodes)), A.remove());
1543
1606
  }
1544
- u.querySelectorAll("span").forEach((f) => {
1545
- var q, B;
1546
- if (lt(f) !== "todo") return;
1547
- const v = f.getAttribute("data-tag-name") || ((B = (q = f.textContent) == null ? void 0 : q.match(/\{待办@([^{}]+)\}/u)) == null ? void 0 : B[1]), W = E.find((P) => P.label === v);
1548
- W && (f.setAttribute("data-tag-type", "todo"), f.setAttribute("data-tag-name", W.label), f.setAttribute("plan_id", W.id));
1549
- }), K.web_content = u.body.innerHTML, K.content = r.content;
1607
+ s.querySelectorAll("span").forEach((g) => {
1608
+ var I, q;
1609
+ if (lt(g) !== "todo") return;
1610
+ const A = g.getAttribute("data-tag-name") || ((q = (I = g.textContent) == null ? void 0 : I.match(/\{待办@([^{}]+)\}/u)) == null ? void 0 : q[1]), E = C.find((H) => H.label === A);
1611
+ E && (g.setAttribute("data-tag-type", "todo"), g.setAttribute("data-tag-name", E.label), g.setAttribute("plan_id", E.id));
1612
+ }), J.web_content = s.body.innerHTML, J.content = r.content;
1550
1613
  }
1551
- return K.web_content = Zt(K.web_content || ""), { ok: !0, value: K };
1614
+ return J.web_content = Zt(J.web_content || ""), { ok: !0, value: J };
1552
1615
  }
1553
1616
  export {
1554
1617
  vt as LEGACY_BUSINESS_ATTRIBUTES,
1555
1618
  ie as agentPromptPreview,
1556
- Mt as isLegacyBusinessAttributeCatalog,
1557
- Et as legacyItemToScene,
1619
+ Dt as isLegacyBusinessAttributeCatalog,
1620
+ Mt as legacyItemToScene,
1558
1621
  oe as sceneToLegacyItem
1559
1622
  };