@freecallai/pro 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{FkpRichText.vue_vue_type_script_setup_true_lang-D2sgT7XP.js → FkpRichText.vue_vue_type_script_setup_true_lang-DiS7CZdc.js} +1470 -1455
- package/dist/{KnowledgeArea-Sbfs_E0C.js → KnowledgeArea-FGgCcubh.js} +1 -1
- package/dist/{KnowledgeArea.vue_vue_type_script_setup_true_lang-BNDRTWXW.js → KnowledgeArea.vue_vue_type_script_setup_true_lang-JH_F4CFe.js} +523 -519
- package/dist/{ToolForm-_ZTW7lwU.js → ToolForm-CHmdyhjh.js} +1 -1
- package/dist/agent-prompt-editor/index.js +304 -293
- package/dist/agent-prompt-editor/legacy-converter/index.js +98 -94
- package/dist/{choice-BqjECVyx.js → choice-CUCsR2dN.js} +1 -1
- package/dist/edition-info/index.js +1 -1
- package/dist/{guard-BmLOamCj.js → guard-DgExtfXo.js} +199 -185
- package/dist/{index-7x1OTv0m.js → index-B2CCZeff.js} +4 -4
- package/dist/{index-BDinNJn_.js → index-BwZXmefJ.js} +1 -1
- package/dist/{index-6VSUucFX.js → index-C54ce9Tn.js} +1 -1
- package/dist/index-CMl5mgFR.js +5 -0
- package/dist/index-CbmRr3rH.js +949 -0
- package/dist/index-Cs38tTe4.js +5 -0
- package/dist/{index-CCwmXuSJ.js → index-DIMONp3g.js} +1 -1
- package/dist/{index-CN2knQcE.js → index-DaGfiqBX.js} +1 -1
- package/dist/{index-gS1h8iW8.js → index-DqJvaPTD.js} +1 -1
- package/dist/{index-0BXLYaKG.js → index-dnsGFj0F.js} +2 -2
- package/dist/{index-B1rTu0jX.js → index-pdr6mUf0.js} +1 -1
- package/dist/index.js +7 -7
- package/dist/{inline-CRGzAti7.js → inline-BpwAryXp.js} +1 -1
- package/dist/{knowledge-DNDouB-s.js → knowledge-DIzYk2iM.js} +1 -1
- package/dist/media-extensions-YYbGuUQa.js +341 -0
- package/dist/{media-migration-D1KoHKoP.js → media-migration-Bnfn27i9.js} +1 -1
- package/dist/media-policy-tG5OHWSj.js +215 -0
- package/dist/{media-upload-C5N6YWHu.js → media-upload-_xeZtn3i.js} +1 -1
- package/dist/{model-BVh9EZ9G.js → model-DlAjlPai.js} +1 -1
- package/dist/navigation/index.js +1 -1
- package/dist/rich-text/index.js +6 -6
- package/dist/rich-text/legacy-converter/index.js +357 -355
- package/dist/style.css +1 -1
- package/dist/types/agent-prompt-editor/FkpAgentPromptEditor.vue.d.ts +4 -0
- package/dist/types/navigation/FkpNavigation.vue.d.ts +12 -3
- package/dist/types/navigation/NavigationGroup.vue.d.ts +1 -0
- package/dist/types/navigation/NavigationNodes.vue.d.ts +9 -2
- package/dist/types/navigation/{use-navigation-tree.d.ts → hooks/use-navigation-tree.d.ts} +1 -1
- package/dist/types/navigation/hooks/use-submenu-indicator.d.ts +10 -0
- package/dist/types/navigation/index.d.ts +1 -1
- package/dist/types/navigation/types.d.ts +11 -0
- package/dist/types/rich-text/FkpRichText.vue.d.ts +2 -0
- package/dist/types/rich-text/model/qianniu-video.d.ts +2 -0
- package/dist/types/rich-text/public/types.d.ts +2 -2
- package/dist/types/rich-text/runtime/media-sources.d.ts +1 -1
- package/dist/types/rich-text/ui/KnowledgeArea.vue.d.ts +1 -0
- package/dist/types/rich-text/ui/MediaSourceControls.vue.d.ts +11 -2
- package/package.json +4 -4
- package/dist/index-CAczgwau.js +0 -5
- package/dist/index-Ck8RYpuE.js +0 -816
- package/dist/index-faGbB8v6.js +0 -5
- package/dist/media-extensions-wlcCEdtg.js +0 -324
- package/dist/media-policy-D3-Qglzz.js +0 -158
|
@@ -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-
|
|
2
|
-
import { a as It } from "../../media-migration-
|
|
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-DgExtfXo.js";
|
|
2
|
+
import { a as It } from "../../media-migration-Bnfn27i9.js";
|
|
3
3
|
const Jt = [
|
|
4
4
|
{ id: 1, key: "focus_goods_name", name: "焦点商品名称" },
|
|
5
5
|
{ id: 2, key: "focus_goods_info", name: "焦点商品信息" },
|
|
@@ -11,7 +11,7 @@ const Jt = [
|
|
|
11
11
|
function Mt(t) {
|
|
12
12
|
if (!Array.isArray(t)) return !1;
|
|
13
13
|
const r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), $ = /* @__PURE__ */ new Set();
|
|
14
|
-
return t.every((
|
|
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));
|
|
15
15
|
}
|
|
16
16
|
const vt = Object.freeze(Jt.map((t) => Object.freeze({ ...t })));
|
|
17
17
|
function Rt(t, r = vt) {
|
|
@@ -20,10 +20,10 @@ function Rt(t, r = vt) {
|
|
|
20
20
|
function Ut(t, r = vt) {
|
|
21
21
|
return r.find((s) => s.key === t);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function qt(t) {
|
|
24
24
|
return `{业务属性@${t}}`;
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const Vt = /* @__PURE__ */ new Set([
|
|
27
27
|
"todo",
|
|
28
28
|
"cdp_tag",
|
|
29
29
|
"separator",
|
|
@@ -41,7 +41,7 @@ const Qt = /* @__PURE__ */ new Set([
|
|
|
41
41
|
"external_method",
|
|
42
42
|
"ticket",
|
|
43
43
|
"tool"
|
|
44
|
-
]),
|
|
44
|
+
]), Qt = /#@[^#\n]+?@#|##[^#\n]+?##|\$\$小额打款@[^$\n]+?\$\$|\^\^订单备注[^\n]+?\^\^|\{自定义Agent\}@[^^\s\n{}]+|\{(?:业务属性|属性|外部方法|智能建单|智能工单|待办|记忆触发点|分隔符|原话复述|顾客标签|意图标签|工具|推理)@?[^}\n]*\}|#[^#\n]+?#/gu;
|
|
45
45
|
function Xt(t) {
|
|
46
46
|
return t.replace(
|
|
47
47
|
/<video\b((?:[^"'<>]|"[^"]*"|'[^']*')*)\/>/giu,
|
|
@@ -55,9 +55,9 @@ function ie(t, r) {
|
|
|
55
55
|
var o;
|
|
56
56
|
const s = [], $ = () => {
|
|
57
57
|
s.length && s[s.length - 1].type !== "break" && s.push({ type: "break" });
|
|
58
|
-
},
|
|
58
|
+
}, a = (d) => {
|
|
59
59
|
let m = 0;
|
|
60
|
-
for (const c of d.matchAll(
|
|
60
|
+
for (const c of d.matchAll(Qt))
|
|
61
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
62
|
m < d.length && s.push({ type: "text", text: d.slice(m) });
|
|
63
63
|
};
|
|
@@ -68,7 +68,7 @@ function ie(t, r) {
|
|
|
68
68
|
), m = (c) => {
|
|
69
69
|
var e, i;
|
|
70
70
|
if (c.nodeType === Node.TEXT_NODE) {
|
|
71
|
-
|
|
71
|
+
a(c.textContent || "");
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
if (!(c instanceof Element)) return;
|
|
@@ -91,12 +91,12 @@ function ie(t, r) {
|
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
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 (
|
|
94
|
+
if (Vt.has(k)) {
|
|
95
95
|
const g = (i = c.textContent) == null ? void 0 : i.trim();
|
|
96
96
|
g && s.push({ type: "tag", kind: k, label: g });
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
const
|
|
99
|
+
const l = [
|
|
100
100
|
"div",
|
|
101
101
|
"p",
|
|
102
102
|
"li",
|
|
@@ -106,13 +106,13 @@ function ie(t, r) {
|
|
|
106
106
|
"blockquote",
|
|
107
107
|
"pre"
|
|
108
108
|
].includes(h);
|
|
109
|
-
|
|
109
|
+
l && s.length && $(), c.childNodes.forEach(m), l && $();
|
|
110
110
|
};
|
|
111
111
|
for (d.body.childNodes.forEach(m); ((o = s[s.length - 1]) == null ? void 0 : o.type) === "break"; ) s.pop();
|
|
112
112
|
}
|
|
113
113
|
return s.some(
|
|
114
114
|
(d) => d.type === "tag" || d.type === "media" || d.type === "text" && !!d.text.trim()
|
|
115
|
-
) || (s.length = 0, r != null && r.trim() &&
|
|
115
|
+
) || (s.length = 0, r != null && r.trim() && a(r)), s;
|
|
116
116
|
}
|
|
117
117
|
function p(t, r, s) {
|
|
118
118
|
return { ok: !1, issues: [{ path: r, message: s }], raw: t };
|
|
@@ -133,8 +133,8 @@ function Zt(t) {
|
|
|
133
133
|
"text/html"
|
|
134
134
|
);
|
|
135
135
|
return r.querySelectorAll("video").forEach((s) => {
|
|
136
|
-
var
|
|
137
|
-
const $ = s.getAttribute("src") || ((
|
|
136
|
+
var a;
|
|
137
|
+
const $ = s.getAttribute("src") || ((a = s.querySelector("source[src]")) == null ? void 0 : a.getAttribute("src"));
|
|
138
138
|
$ && s.setAttribute("src", $), s.replaceChildren();
|
|
139
139
|
}), r.body.innerHTML.replace(
|
|
140
140
|
/<video\b((?:[^"'<>]|"[^"]*"|'[^']*')*)><\/video>/giu,
|
|
@@ -148,15 +148,15 @@ function Nt(t) {
|
|
|
148
148
|
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
|
-
function
|
|
151
|
+
function Ct(t) {
|
|
152
152
|
let r = "", s = 0;
|
|
153
153
|
const $ = /<\{原话复述\}|<(?:img|video|hr)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/gu;
|
|
154
154
|
for (; s < t.length; ) {
|
|
155
155
|
$.lastIndex = s;
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
158
|
-
if (r += w(t.slice(s,
|
|
159
|
-
r +=
|
|
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;
|
|
160
160
|
continue;
|
|
161
161
|
}
|
|
162
162
|
const o = $.lastIndex;
|
|
@@ -173,10 +173,10 @@ function Wt(t) {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
if (d < 0 && (d = m), d < 0) {
|
|
176
|
-
r += w(
|
|
176
|
+
r += w(a[0]), s = o;
|
|
177
177
|
continue;
|
|
178
178
|
}
|
|
179
|
-
r += `<span data-tag-type="original_repeat" data-original-repeat-template="true"><span data-original-repeat-input="true">${
|
|
179
|
+
r += `<span data-tag-type="original_repeat" data-original-repeat-template="true"><span data-original-repeat-input="true">${Ct(
|
|
180
180
|
t.slice(o, d)
|
|
181
181
|
)}</span></span>`, s = d + 1;
|
|
182
182
|
}
|
|
@@ -188,14 +188,14 @@ function _t(t, r = !1, s = vt) {
|
|
|
188
188
|
const $ = new DOMParser().parseFromString(
|
|
189
189
|
xt(t),
|
|
190
190
|
"text/html"
|
|
191
|
-
),
|
|
191
|
+
), a = [[]];
|
|
192
192
|
let o = null, d = [];
|
|
193
|
-
const m = (k) =>
|
|
193
|
+
const m = (k) => a[a.length - 1].push(
|
|
194
194
|
k.kind === "text" && d.length ? { ...k, marks: [...d] } : k
|
|
195
195
|
), c = (k = !1) => {
|
|
196
|
-
(k ||
|
|
197
|
-
}, h = (k,
|
|
198
|
-
var E, H, M, A, I, F, K, G, tt, O, Z, z, Y,
|
|
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
199
|
if (o) return;
|
|
200
200
|
if (k.nodeType === 3) {
|
|
201
201
|
(k.textContent || "").replace(/\r\n?/g, `
|
|
@@ -203,8 +203,8 @@ function _t(t, r = !1, s = vt) {
|
|
|
203
203
|
/\^\^订单备注-[\s\S]*?\^\^|<\{原话复述\}[^<>]*>/gu,
|
|
204
204
|
(L) => L.replace(/\n/g, "")
|
|
205
205
|
).split(`
|
|
206
|
-
`).forEach((L,
|
|
207
|
-
|
|
206
|
+
`).forEach((L, V) => {
|
|
207
|
+
V && c(!0), L = L.replace(/\uE000/g, `
|
|
208
208
|
`);
|
|
209
209
|
let x = 0;
|
|
210
210
|
for (const b of L.matchAll(
|
|
@@ -225,7 +225,7 @@ function _t(t, r = !1, s = vt) {
|
|
|
225
225
|
if (i === "span" && g === "original_repeat" && e.getAttribute("data-original-repeat-template") === "true") {
|
|
226
226
|
const D = e.querySelectorAll('[data-original-repeat-input="true"]');
|
|
227
227
|
if (D.length !== 1) {
|
|
228
|
-
o = { path:
|
|
228
|
+
o = { path: l, message: "原话模板缺少唯一的回复输入区" };
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
m({ kind: "originalReply", html: D[0].innerHTML });
|
|
@@ -235,24 +235,24 @@ function _t(t, r = !1, s = vt) {
|
|
|
235
235
|
if (g === "ticket") {
|
|
236
236
|
const x = (e.textContent || "").trim(), b = Lt(x);
|
|
237
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 = {
|
|
238
|
-
path:
|
|
238
|
+
path: l,
|
|
239
239
|
message: "工单标签格式无效、引用已失效或属性与内容不一致"
|
|
240
240
|
} : m({ kind: "text", value: x });
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
243
|
if (g === "external_method") {
|
|
244
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:
|
|
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 });
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
248
|
if (g === "no_send_follow_order") {
|
|
249
|
-
o = { path:
|
|
249
|
+
o = { path: l, message: "旧不发送跟单标签尚无新知识节点承载" };
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
if (g === "table_knowledge") {
|
|
253
253
|
const x = (e.textContent || "").trim(), b = e.getAttribute("data-table-name") || ((M = x.match(/^##([^#\r\n]+)##$/u)) == null ? void 0 : M[1]) || "";
|
|
254
254
|
!b.trim() || /[#\r\n]/u.test(b) || x && x !== `##${b}##` || e.getAttribute("data-invalid") === "true" ? o = {
|
|
255
|
-
path:
|
|
255
|
+
path: l,
|
|
256
256
|
message: "表格知识名称无效、与标签不一致或引用已失效"
|
|
257
257
|
} : m({
|
|
258
258
|
kind: "tableKnowledge",
|
|
@@ -262,14 +262,14 @@ function _t(t, r = !1, s = vt) {
|
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
264
|
if (g === "size_chart") {
|
|
265
|
-
o = { path:
|
|
265
|
+
o = { path: l, message: `旧${g}标签尚无新知识节点承载` };
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
268
|
if (g === "biz_attribute") {
|
|
269
269
|
const x = (e.textContent || "").trim(), b = (A = x.match(
|
|
270
270
|
/^\{业务属性@([^{}<>\r\n]+)\}$/u
|
|
271
|
-
)) == null ? void 0 : A[1], S = ((I = e.getAttribute("data-attr-name")) == null ? void 0 : I.trim()) || b,
|
|
272
|
-
!
|
|
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
273
|
return;
|
|
274
274
|
}
|
|
275
275
|
if (g === "small_payment" || g === "order_remark") {
|
|
@@ -277,46 +277,46 @@ function _t(t, r = !1, s = vt) {
|
|
|
277
277
|
const it = Kt(
|
|
278
278
|
e.getAttribute("data-order-remark") || ""
|
|
279
279
|
), ot = it && Dt(it);
|
|
280
|
-
ot ? m({ kind: "text", value: ot }) : o = { path:
|
|
280
|
+
ot ? m({ kind: "text", value: ot }) : o = { path: l, message: "旧订单备注数据无效" };
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
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:
|
|
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
285
|
return;
|
|
286
286
|
}
|
|
287
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(),
|
|
289
|
-
!
|
|
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({
|
|
290
290
|
kind: "text",
|
|
291
|
-
value:
|
|
291
|
+
value: Q === "订单链接" ? "{订单链接}" : x
|
|
292
292
|
});
|
|
293
293
|
return;
|
|
294
294
|
}
|
|
295
295
|
const D = e.getAttribute("data-tag-name") || e.getAttribute("data-variable-name") || e.getAttribute("data-agent-name") || "", L = e.textContent || "";
|
|
296
296
|
if (g === "cdp_tag" && (!e.getAttribute("data-tag-id") || /已失效/u.test(L))) {
|
|
297
|
-
o = { path:
|
|
297
|
+
o = { path: l, message: "失效顾客标签需要只读保全" };
|
|
298
298
|
return;
|
|
299
299
|
}
|
|
300
300
|
if (g === "todo" || g === "cdp_tag") {
|
|
301
301
|
const x = g === "todo" ? Nt(L) : (z = L.match(/\{(?:顾客标签|意图标签)@([^{}]+)\}/u)) == null ? void 0 : z[1], b = e.getAttribute("data-tag-name");
|
|
302
302
|
if (x && b && x !== b) {
|
|
303
|
-
o = { path:
|
|
303
|
+
o = { path: l, message: `${g} 标签名称与显示内容不一致` };
|
|
304
304
|
return;
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
const
|
|
307
|
+
const V = {
|
|
308
308
|
todo: ((Y = L.match(/\{待办(?:@[^{}]+)?\}/u)) == null ? void 0 : Y[0]) || (D ? `{待办@${D}}` : ""),
|
|
309
|
-
cdp_tag: ((
|
|
309
|
+
cdp_tag: ((C = L.match(/\{(?:顾客标签|意图标签)@[^{}]+\}/u)) == null ? void 0 : C[0]) || (D ? `{顾客标签@${D}}` : ""),
|
|
310
310
|
separator: "{分隔符}",
|
|
311
311
|
original_repeat: "{原话复述}",
|
|
312
312
|
custom_agent: ((et = L.match(/\{自定义Agent\}@[\s\S]+/u)) == null ? void 0 : et[0]) || (D ? `{自定义Agent}@${D}` : ""),
|
|
313
313
|
reasoning: "{推理}",
|
|
314
314
|
memory_trigger: "{记忆触发点}"
|
|
315
315
|
};
|
|
316
|
-
|
|
316
|
+
V[g] ? m({
|
|
317
317
|
kind: g === "todo" ? "todo" : "text",
|
|
318
|
-
value:
|
|
319
|
-
}) : o = { path:
|
|
318
|
+
value: V[g]
|
|
319
|
+
}) : o = { path: l, message: `旧标签 ${g} 无法映射到新模型` };
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
322
|
if (i === "img" && e.getAttribute("data-tag-icon") === "true") return;
|
|
@@ -326,15 +326,16 @@ function _t(t, r = !1, s = vt) {
|
|
|
326
326
|
kind: "media",
|
|
327
327
|
media: i === "img" ? "image" : "video",
|
|
328
328
|
src: D,
|
|
329
|
-
path:
|
|
329
|
+
path: l,
|
|
330
330
|
metadata: Object.fromEntries(
|
|
331
331
|
[
|
|
332
332
|
["assetId", e.getAttribute("data-asset-id")],
|
|
333
333
|
["name", e.getAttribute("data-media-name")],
|
|
334
|
-
["poster", e.getAttribute("poster")]
|
|
334
|
+
["poster", e.getAttribute("poster")],
|
|
335
|
+
["sourceType", e.getAttribute("data-source-type")]
|
|
335
336
|
].filter((L) => L[1] !== null)
|
|
336
337
|
)
|
|
337
|
-
}) : o = { path:
|
|
338
|
+
}) : o = { path: l, message: "媒体地址无效" };
|
|
338
339
|
return;
|
|
339
340
|
}
|
|
340
341
|
const j = {
|
|
@@ -351,17 +352,17 @@ function _t(t, r = !1, s = vt) {
|
|
|
351
352
|
if (j || i === "a") {
|
|
352
353
|
const D = d, L = e.getAttribute("href");
|
|
353
354
|
if (i === "a" && L && !St(L)) {
|
|
354
|
-
o = { path:
|
|
355
|
+
o = { path: l, message: "链接地址无效" };
|
|
355
356
|
return;
|
|
356
357
|
}
|
|
357
|
-
const
|
|
358
|
+
const V = j ? { type: j } : L ? {
|
|
358
359
|
type: "link",
|
|
359
360
|
attrs: Object.fromEntries(
|
|
360
361
|
["href", "target", "rel", "title", "class"].filter((x) => e.hasAttribute(x)).map((x) => [x, e.getAttribute(x)])
|
|
361
362
|
)
|
|
362
363
|
} : null;
|
|
363
|
-
|
|
364
|
-
(x, b) => h(x, `${
|
|
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}]`)
|
|
365
366
|
), d = D;
|
|
366
367
|
return;
|
|
367
368
|
}
|
|
@@ -378,30 +379,30 @@ function _t(t, r = !1, s = vt) {
|
|
|
378
379
|
return;
|
|
379
380
|
}
|
|
380
381
|
if (!["p", "div", "span"].includes(i) || i === "span" && e.attributes.length > 0) {
|
|
381
|
-
o = { path:
|
|
382
|
+
o = { path: l, message: `HTML 标签 ${i} 无法无损转换` };
|
|
382
383
|
return;
|
|
383
384
|
}
|
|
384
385
|
(i === "p" || i === "div") && c();
|
|
385
|
-
const R =
|
|
386
|
+
const R = a.length;
|
|
386
387
|
Array.from(e.childNodes).forEach(
|
|
387
|
-
(D, L) => h(D, `${
|
|
388
|
-
), (i === "p" || i === "div") && (
|
|
388
|
+
(D, L) => h(D, `${l}.childNodes[${L}]`)
|
|
389
|
+
), (i === "p" || i === "div") && (a.length === R || a[a.length - 1].length) && c(!0);
|
|
389
390
|
};
|
|
390
391
|
return Array.from($.body.childNodes).forEach(
|
|
391
|
-
(k,
|
|
392
|
-
), o ? { ok: !1, issues: [o], raw: t } : (
|
|
393
|
-
`) &&
|
|
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 });
|
|
394
395
|
}
|
|
395
396
|
function ht(t) {
|
|
396
397
|
return t.every(
|
|
397
398
|
(r) => r.kind === "text" || r.kind === "todo" || r.kind === "attribute" || r.kind === "tableKnowledge"
|
|
398
399
|
) ? t.map(
|
|
399
|
-
(r) => r.kind === "tableKnowledge" ? `##${r.name}##` : r.kind === "attribute" ?
|
|
400
|
+
(r) => r.kind === "tableKnowledge" ? `##${r.name}##` : r.kind === "attribute" ? qt(r.name) : r.value
|
|
400
401
|
).join("") : null;
|
|
401
402
|
}
|
|
402
403
|
function Gt(t, r, s, $) {
|
|
403
404
|
var m, c;
|
|
404
|
-
const
|
|
405
|
+
const a = [], o = /(#@[^#]+@#|##[^#]+##|#[^#\r\n]+#|\{[^{}]+\}|\[sep\]|\$\$小额打款@[^$\r\n]*\$\$|\^\^订单备注-[\s\S]*?\^\^)/gu;
|
|
405
406
|
let d = 0;
|
|
406
407
|
for (const h of t.matchAll(o)) {
|
|
407
408
|
const k = h.index || 0;
|
|
@@ -411,19 +412,19 @@ function Gt(t, r, s, $) {
|
|
|
411
412
|
e
|
|
412
413
|
))
|
|
413
414
|
return p(t, r, "工具、业务属性或不发送跟单标记格式错误");
|
|
414
|
-
|
|
415
|
+
a.push({ type: "text", text: e });
|
|
415
416
|
}
|
|
416
|
-
const
|
|
417
|
-
if (/^\{智能(?:建单|工单)/u.test(
|
|
418
|
-
const e = Lt(
|
|
419
|
-
if (!e) return p(t, r, `工单标记 ${
|
|
420
|
-
|
|
421
|
-
} else if (
|
|
422
|
-
const e = Tt(
|
|
423
|
-
if (!e) return p(t, r, `工具标记 ${
|
|
424
|
-
|
|
425
|
-
} else if (
|
|
426
|
-
|
|
417
|
+
const l = h[0];
|
|
418
|
+
if (/^\{智能(?:建单|工单)/u.test(l)) {
|
|
419
|
+
const e = Lt(l);
|
|
420
|
+
if (!e) return p(t, r, `工单标记 ${l} 格式错误`);
|
|
421
|
+
a.push({ type: "businessToken", attrs: { kind: "ticket", ...e } });
|
|
422
|
+
} else if (l.startsWith("$$小额打款@") || l.startsWith("^^订单备注-") || l.startsWith("{外部方法")) {
|
|
423
|
+
const e = Tt(l);
|
|
424
|
+
if (!e) return p(t, r, `工具标记 ${l} 格式错误`);
|
|
425
|
+
a.push(e);
|
|
426
|
+
} else if (l === "{分隔符}" || l === "[sep]")
|
|
427
|
+
a.push({
|
|
427
428
|
type: "businessToken",
|
|
428
429
|
attrs: {
|
|
429
430
|
kind: "separator",
|
|
@@ -432,37 +433,37 @@ function Gt(t, r, s, $) {
|
|
|
432
433
|
token: "{分隔符}"
|
|
433
434
|
}
|
|
434
435
|
});
|
|
435
|
-
else if (/^##[^#\r\n]+##$/u.test(
|
|
436
|
-
const e =
|
|
436
|
+
else if (/^##[^#\r\n]+##$/u.test(l)) {
|
|
437
|
+
const e = l.slice(2, -2);
|
|
437
438
|
if (!e.trim()) return p(t, r, "表格知识名称不能为空");
|
|
438
|
-
|
|
439
|
+
a.push({
|
|
439
440
|
type: "businessToken",
|
|
440
441
|
attrs: { kind: "tableKnowledge", key: e, label: e }
|
|
441
442
|
});
|
|
442
|
-
} else if (
|
|
443
|
-
const e =
|
|
443
|
+
} 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);
|
|
444
445
|
if (!e || !(i != null && i.key) || i.label !== e)
|
|
445
446
|
return p(t, r, `变量 ${e} 缺少可解析的引用`);
|
|
446
|
-
|
|
447
|
+
a.push({
|
|
447
448
|
type: "businessToken",
|
|
448
|
-
attrs: { kind: "variable", key: i.key, label: i.label, token:
|
|
449
|
+
attrs: { kind: "variable", key: i.key, label: i.label, token: l }
|
|
449
450
|
});
|
|
450
|
-
} else if (
|
|
451
|
-
const e = (c =
|
|
451
|
+
} else if (l.startsWith("{业务属性@")) {
|
|
452
|
+
const e = (c = l.match(/^\{业务属性@([^{}<>\r\n]+)\}$/u)) == null ? void 0 : c[1], i = e && Rt(e, $);
|
|
452
453
|
if (!i)
|
|
453
|
-
return p(t, r, `业务属性 ${e ||
|
|
454
|
-
|
|
454
|
+
return p(t, r, `业务属性 ${e || l} 不在旧目录中`);
|
|
455
|
+
a.push({
|
|
455
456
|
type: "businessToken",
|
|
456
457
|
attrs: { kind: "attribute", key: i.key, label: i.name }
|
|
457
458
|
});
|
|
458
459
|
} else {
|
|
459
460
|
if (/^\{(?:待办|原话复述|推理|记忆触发点|顾客标签|意图标签|自定义Agent)/u.test(
|
|
460
|
-
|
|
461
|
-
) ||
|
|
462
|
-
return p(t, r, `正文标记 ${
|
|
463
|
-
|
|
461
|
+
l
|
|
462
|
+
) || l.startsWith("#@"))
|
|
463
|
+
return p(t, r, `正文标记 ${l} 无法在当前位置转换`);
|
|
464
|
+
a.push({ type: "text", text: l });
|
|
464
465
|
}
|
|
465
|
-
d = k +
|
|
466
|
+
d = k + l.length;
|
|
466
467
|
}
|
|
467
468
|
if (d < t.length) {
|
|
468
469
|
const h = t.slice(d);
|
|
@@ -470,33 +471,33 @@ function Gt(t, r, s, $) {
|
|
|
470
471
|
h
|
|
471
472
|
))
|
|
472
473
|
return p(t, r, "工具、业务属性或不发送跟单标记格式错误");
|
|
473
|
-
|
|
474
|
+
a.push({ type: "text", text: h });
|
|
474
475
|
}
|
|
475
|
-
return { ok: !0, value:
|
|
476
|
+
return { ok: !0, value: a };
|
|
476
477
|
}
|
|
477
478
|
function zt(t, r) {
|
|
478
479
|
const s = /* @__PURE__ */ new Set();
|
|
479
|
-
let $ = 0,
|
|
480
|
+
let $ = 0, a = null;
|
|
480
481
|
const o = (d, m) => {
|
|
481
482
|
var c, h, k;
|
|
482
|
-
if (d.type === "businessToken" && ((c = d.attrs) == null ? void 0 : c.kind) === "tool" && (d.attrs.key === "small_payment" && ++$ > 1 && (
|
|
483
|
-
const
|
|
484
|
-
s.has(
|
|
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);
|
|
485
486
|
}
|
|
486
487
|
(k = d.content) == null || k.forEach(
|
|
487
|
-
(
|
|
488
|
+
(l, e) => o(l, `${m}.content[${e}]`)
|
|
488
489
|
);
|
|
489
490
|
};
|
|
490
|
-
return t.forEach((d, m) => o(d, `${r}[${m}]`)),
|
|
491
|
+
return t.forEach((d, m) => o(d, `${r}[${m}]`)), a;
|
|
491
492
|
}
|
|
492
493
|
function te(t) {
|
|
493
|
-
var r, s, $,
|
|
494
|
+
var r, s, $, a, o;
|
|
494
495
|
for (let d = 0; d < t.length; d++) {
|
|
495
496
|
const m = t[d], c = (r = m.content) == null ? void 0 : r[0];
|
|
496
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")
|
|
497
498
|
continue;
|
|
498
499
|
const h = t[d - 1], k = t[d + 1];
|
|
499
|
-
if ((h == null ? void 0 : h.type) === "paragraph" && ((
|
|
500
|
+
if ((h == null ? void 0 : h.type) === "paragraph" && ((a = h.content) != null && a.length))
|
|
500
501
|
h.content.push(c);
|
|
501
502
|
else if ((k == null ? void 0 : k.type) === "paragraph" && ((o = k.content) != null && o.length))
|
|
502
503
|
k.content.unshift(c);
|
|
@@ -509,15 +510,15 @@ function wt(t) {
|
|
|
509
510
|
const r = (($ = /^\s*/u.exec(t)) == null ? void 0 : $[0].length) || 0;
|
|
510
511
|
if (t[r] !== "【") return null;
|
|
511
512
|
let s = 0;
|
|
512
|
-
for (let
|
|
513
|
-
const o = t[
|
|
513
|
+
for (let a = r; a < t.length; a++) {
|
|
514
|
+
const o = t[a];
|
|
514
515
|
if (o === "\r" || o === `
|
|
515
516
|
`) return null;
|
|
516
517
|
if (o === "【") s++;
|
|
517
518
|
else if (o === "】" && --s === 0)
|
|
518
519
|
return {
|
|
519
|
-
question: t.slice(r + 1,
|
|
520
|
-
suffix: t.slice(
|
|
520
|
+
question: t.slice(r + 1, a),
|
|
521
|
+
suffix: t.slice(a + 1)
|
|
521
522
|
};
|
|
522
523
|
}
|
|
523
524
|
return null;
|
|
@@ -531,8 +532,8 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
531
532
|
return p(t, "item", "旧知识记录格式不正确");
|
|
532
533
|
if (!(r != null && r.trim()))
|
|
533
534
|
return p(t, "sourceRecordKey", "需要稳定的来源记录键");
|
|
534
|
-
const
|
|
535
|
-
if (!Mt(
|
|
535
|
+
const a = $.businessAttributes ?? vt;
|
|
536
|
+
if (!Mt(a))
|
|
536
537
|
return p(
|
|
537
538
|
t,
|
|
538
539
|
"businessAttributes",
|
|
@@ -540,12 +541,12 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
540
541
|
);
|
|
541
542
|
const o = typeof t.web_content == "string" && t.web_content ? "web_content" : "content", d = t[o];
|
|
542
543
|
if (typeof d != "string") return p(t, o, "旧知识缺少内容");
|
|
543
|
-
const m = !!String(t.todo_plan_id || "").trim() || !!t.todo_tag_metas, c = o === "content" ?
|
|
544
|
+
const m = !!String(t.todo_plan_id || "").trim() || !!t.todo_tag_metas, c = o === "content" ? Ct(d) : d, h = _t(c, m, a);
|
|
544
545
|
if (!h.ok) return { ...h, raw: t };
|
|
545
|
-
const k = h.value,
|
|
546
|
-
(
|
|
546
|
+
const k = h.value, l = k[0] || [], e = l.findIndex(
|
|
547
|
+
(n) => n.kind === "originalReply" || n.kind === "media" || n.kind === "tableKnowledge"
|
|
547
548
|
), i = ht(
|
|
548
|
-
e >= 0 ?
|
|
549
|
+
e >= 0 ? l.slice(0, e) : l
|
|
549
550
|
), g = wt(i || "");
|
|
550
551
|
if (!g && (i != null && i.trimStart().startsWith("【")))
|
|
551
552
|
return p(t, o, "内嵌问法的【】没有正确配对");
|
|
@@ -554,68 +555,68 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
554
555
|
return p(t, "questionText", "顾客问法包含保留分隔符");
|
|
555
556
|
const R = new DOMParser().parseFromString(c, "text/html"), E = Array.from(
|
|
556
557
|
R.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
|
|
557
|
-
).filter((
|
|
558
|
-
(
|
|
558
|
+
).filter((n) => lt(n) === "todo").map(
|
|
559
|
+
(n) => Nt(n.textContent || "") || n.getAttribute("data-tag-name") || ""
|
|
559
560
|
);
|
|
560
561
|
m && E.push(
|
|
561
|
-
...Array.from(d.matchAll(/\{待办@([^{}]+)\}/gu), (
|
|
562
|
+
...Array.from(d.matchAll(/\{待办@([^{}]+)\}/gu), (n) => n[1])
|
|
562
563
|
);
|
|
563
564
|
const H = Array.from(
|
|
564
565
|
R.querySelectorAll('span[data-tag-type="cdp_tag"]')
|
|
565
|
-
).map((
|
|
566
|
+
).map((n) => {
|
|
566
567
|
var y;
|
|
567
568
|
return {
|
|
568
|
-
name: ((y = (
|
|
569
|
+
name: ((y = (n.textContent || "").match(
|
|
569
570
|
/\{(?:顾客标签|意图标签)@([^{}]+)\}/u
|
|
570
|
-
)) == null ? void 0 : y[1]) ||
|
|
571
|
-
id:
|
|
571
|
+
)) == null ? void 0 : y[1]) || n.getAttribute("data-tag-name") || "",
|
|
572
|
+
id: n.getAttribute("data-tag-id") || ""
|
|
572
573
|
};
|
|
573
574
|
});
|
|
574
575
|
if ((gt = R.body.textContent) != null && gt.includes("{待办}") && E.push("默认"), o === "content" && Array.isArray(t.tag_meta))
|
|
575
|
-
for (const
|
|
576
|
-
const y =
|
|
576
|
+
for (const n of t.tag_meta) {
|
|
577
|
+
const y = n;
|
|
577
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 || "") });
|
|
578
579
|
}
|
|
579
580
|
if (H.length > 1)
|
|
580
581
|
return p(t, o, "新模型每条问法只能选择一个顾客标签");
|
|
581
582
|
const M = /* @__PURE__ */ new Map();
|
|
582
|
-
for (const [
|
|
583
|
+
for (const [n, y] of Array.from(
|
|
583
584
|
R.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
|
|
584
585
|
).entries()) {
|
|
585
586
|
if (lt(y) !== "todo") continue;
|
|
586
587
|
const _ = (ct = y.getAttribute("plan_id")) == null ? void 0 : ct.trim();
|
|
587
588
|
if (!_) continue;
|
|
588
|
-
const
|
|
589
|
-
if (!
|
|
590
|
-
return p(t, `${o}.todo[${
|
|
591
|
-
const f = M.get(
|
|
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);
|
|
592
593
|
if (f && f.id !== _)
|
|
593
594
|
return p(
|
|
594
595
|
t,
|
|
595
|
-
`${o}.todo[${
|
|
596
|
+
`${o}.todo[${n}]`,
|
|
596
597
|
"同名待办对应多个方案 ID"
|
|
597
598
|
);
|
|
598
|
-
M.set(
|
|
599
|
+
M.set(u, { id: _, label: u });
|
|
599
600
|
}
|
|
600
601
|
if (t.todo_tag_metas !== void 0 && t.todo_tag_metas !== "") {
|
|
601
|
-
let
|
|
602
|
-
if (typeof
|
|
602
|
+
let n = t.todo_tag_metas;
|
|
603
|
+
if (typeof n == "string")
|
|
603
604
|
try {
|
|
604
|
-
|
|
605
|
+
n = JSON.parse(n);
|
|
605
606
|
} catch {
|
|
606
607
|
return p(t, "todo_tag_metas", "待办方案元数据不是有效 JSON");
|
|
607
608
|
}
|
|
608
|
-
if (!Array.isArray(
|
|
609
|
+
if (!Array.isArray(n))
|
|
609
610
|
return p(t, "todo_tag_metas", "待办方案元数据必须为数组");
|
|
610
|
-
for (const [y, _] of
|
|
611
|
+
for (const [y, _] of n.entries()) {
|
|
611
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)
|
|
612
613
|
return p(
|
|
613
614
|
t,
|
|
614
615
|
`todo_tag_metas[${y}]`,
|
|
615
616
|
"待办方案缺少有效 ID、名称或已失效"
|
|
616
617
|
);
|
|
617
|
-
const
|
|
618
|
-
if (
|
|
618
|
+
const u = M.get(_.plan_name);
|
|
619
|
+
if (u && u.id !== _.plan_id)
|
|
619
620
|
return p(
|
|
620
621
|
t,
|
|
621
622
|
`todo_tag_metas[${y}]`,
|
|
@@ -628,8 +629,8 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
628
629
|
}
|
|
629
630
|
}
|
|
630
631
|
if (String(t.todo_plan_id || "").trim() && typeof t.todo_plan_name == "string") {
|
|
631
|
-
const
|
|
632
|
-
if (
|
|
632
|
+
const n = M.get(t.todo_plan_name);
|
|
633
|
+
if (n && n.id !== String(t.todo_plan_id))
|
|
633
634
|
return p(t, "todo_plan_id", "待办方案字段与多方案元数据不一致");
|
|
634
635
|
M.set(t.todo_plan_name, {
|
|
635
636
|
id: String(t.todo_plan_id),
|
|
@@ -651,57 +652,57 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
651
652
|
}
|
|
652
653
|
if (O.startsWith("{自定义Agent}@")) {
|
|
653
654
|
if (tt) return p(t, o, "Agent 标记重复");
|
|
654
|
-
const y = O,
|
|
655
|
+
const y = O, u = Array.from(R.querySelectorAll("span")).filter((f) => lt(f) === "custom_agent").map((f) => (f.textContent || "").trim()).find(
|
|
655
656
|
(f) => f.startsWith("{自定义Agent}@") && y.startsWith(f)
|
|
656
657
|
) || ((ft = O.match(/^\{自定义Agent\}@[^{}]+/u)) == null ? void 0 : ft[0]);
|
|
657
|
-
if (!
|
|
658
|
-
tt =
|
|
658
|
+
if (!u) return p(t, o, "Agent 名称为空");
|
|
659
|
+
tt = u.trim(), O = O.slice(u.length).trimStart();
|
|
659
660
|
continue;
|
|
660
661
|
}
|
|
661
|
-
const
|
|
662
|
+
const n = O.match(
|
|
662
663
|
/^\{(待办|顾客标签|意图标签)@([^{}]+)\}|^\{(原话复述|记忆触发点|推理)\}/u
|
|
663
664
|
);
|
|
664
|
-
if (!
|
|
665
|
+
if (!n) {
|
|
665
666
|
if (O.startsWith("{"))
|
|
666
667
|
return p(t, o, `问法后的标记无法转换:${O}`);
|
|
667
668
|
G = O;
|
|
668
669
|
break;
|
|
669
670
|
}
|
|
670
|
-
if (
|
|
671
|
-
const y =
|
|
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]);
|
|
672
673
|
if (!_)
|
|
673
674
|
return p(
|
|
674
675
|
t,
|
|
675
676
|
o,
|
|
676
|
-
`${
|
|
677
|
+
`${n[1]} ${n[2]} 不是有效的旧版富文本标签`
|
|
677
678
|
);
|
|
678
|
-
const
|
|
679
|
-
if (!(f != null && f.id) || !f.label || f.label !==
|
|
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])
|
|
680
681
|
return p(
|
|
681
682
|
t,
|
|
682
683
|
o,
|
|
683
|
-
`${
|
|
684
|
+
`${n[1]} ${n[2]} 缺少匹配的方案 ID`
|
|
684
685
|
);
|
|
685
686
|
if (y === "todo")
|
|
686
|
-
F.push({ kind: "todo", value:
|
|
687
|
+
F.push({ kind: "todo", value: n[0] });
|
|
687
688
|
else {
|
|
688
|
-
if (A[y]) return p(t, o, `${
|
|
689
|
+
if (A[y]) return p(t, o, `${n[1]}重复`);
|
|
689
690
|
A[y] = { version: 1, data: { enabled: !0, tag: f } };
|
|
690
691
|
}
|
|
691
|
-
} else if (
|
|
692
|
+
} else if (n[3] === "推理") {
|
|
692
693
|
if (K) return p(t, o, "推理标记重复");
|
|
693
694
|
K = !0;
|
|
694
695
|
} else {
|
|
695
|
-
const y =
|
|
696
|
-
if (A[y]) return p(t, o, `${
|
|
696
|
+
const y = n[3] === "原话复述" ? "originalReply" : "memory";
|
|
697
|
+
if (A[y]) return p(t, o, `${n[3]}重复`);
|
|
697
698
|
A[y] = { version: 1, data: { enabled: !0 } };
|
|
698
699
|
}
|
|
699
|
-
O = O.slice(
|
|
700
|
+
O = O.slice(n[0].length).trimStart();
|
|
700
701
|
}
|
|
701
702
|
if (Array.isArray(t.tag_meta))
|
|
702
|
-
for (const [
|
|
703
|
+
for (const [n, y] of t.tag_meta.entries()) {
|
|
703
704
|
if (!y || typeof y != "object")
|
|
704
|
-
return p(t, `tag_meta[${
|
|
705
|
+
return p(t, `tag_meta[${n}]`, "标签元数据格式错误");
|
|
705
706
|
const _ = y;
|
|
706
707
|
if (![
|
|
707
708
|
"cdp_tag",
|
|
@@ -716,103 +717,103 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
716
717
|
].includes(String(_.type)))
|
|
717
718
|
return p(
|
|
718
719
|
t,
|
|
719
|
-
`tag_meta[${
|
|
720
|
+
`tag_meta[${n}]`,
|
|
720
721
|
"旧标签元数据无法映射到新模型"
|
|
721
722
|
);
|
|
722
723
|
if (_.invalid)
|
|
723
|
-
return p(t, `tag_meta[${
|
|
724
|
+
return p(t, `tag_meta[${n}]`, "失效标签需要只读保全");
|
|
724
725
|
if (_.type === "cdp_tag" && (!A.tagged || A.tagged.data.tag.id !== String(_.value || "") || A.tagged.data.tag.label !== String(_.name || "")))
|
|
725
726
|
return p(
|
|
726
727
|
t,
|
|
727
|
-
`tag_meta[${
|
|
728
|
+
`tag_meta[${n}]`,
|
|
728
729
|
"顾客标签 ID 与富文本标签不一致"
|
|
729
730
|
);
|
|
730
731
|
}
|
|
731
732
|
const Z = t.todo_plan_id;
|
|
732
733
|
if (Z != null && String(Z).trim()) {
|
|
733
|
-
const
|
|
734
|
-
if (typeof
|
|
734
|
+
const n = t.todo_plan_name;
|
|
735
|
+
if (typeof n != "string" || !n.trim())
|
|
735
736
|
return p(t, "todo_plan_name", "待办方案 ID 存在但名称缺失");
|
|
736
|
-
if (!E.includes(
|
|
737
|
+
if (!E.includes(n))
|
|
737
738
|
return p(t, "web_content", "待办方案字段缺少对应的富文本标签");
|
|
738
739
|
}
|
|
739
740
|
const z = g || I ? k.slice(1) : [...k];
|
|
740
|
-
g && e >= 0 && z.unshift(
|
|
741
|
+
g && e >= 0 && z.unshift(l.slice(e)), tt && z.unshift([{ kind: "text", value: tt }]);
|
|
741
742
|
const Y = Number(t.knowledge_type || 0);
|
|
742
|
-
let
|
|
743
|
+
let C = Y === 2 ? "reasoning" : Y === 3 ? "agent" : "normal";
|
|
743
744
|
if (t.knowledge_type !== void 0 && ![0, 1, 2, 3].includes(Y))
|
|
744
745
|
return p(t, "knowledge_type", "未知的旧知识类型");
|
|
745
746
|
if (Array.isArray(t.tag_meta)) {
|
|
746
747
|
if (t.tag_meta.some(
|
|
747
|
-
(
|
|
748
|
+
(n) => n && typeof n == "object" && n.type === "reasoning"
|
|
748
749
|
) && Y === 1)
|
|
749
750
|
return p(t, "tag_meta", "推理标签与知识类型不一致");
|
|
750
751
|
if (t.tag_meta.some(
|
|
751
|
-
(
|
|
752
|
+
(n) => n && typeof n == "object" && n.type === "custom_agent"
|
|
752
753
|
) && (Y === 1 || Y === 2))
|
|
753
754
|
return p(t, "tag_meta", "Agent 标签与知识类型不一致");
|
|
754
755
|
}
|
|
755
756
|
let et = null;
|
|
756
757
|
const X = (yt = z[0]) == null ? void 0 : yt[0], D = (X == null ? void 0 : X.kind) === "text" && /^\s*\{推理\}/u.test(X.value);
|
|
757
758
|
if (K || D) {
|
|
758
|
-
if (
|
|
759
|
+
if (C === "agent")
|
|
759
760
|
return p(t, o, "推理标记与 Agent 类型冲突");
|
|
760
|
-
if (
|
|
761
|
-
const
|
|
762
|
-
for (
|
|
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(); )
|
|
763
764
|
y.shift();
|
|
764
765
|
y.length ? z[0] = y : z.shift();
|
|
765
766
|
}
|
|
766
767
|
}
|
|
767
768
|
if (z.length && ((kt = ht(z[0])) != null && kt.trim().startsWith("{自定义Agent}@"))) {
|
|
768
|
-
if (
|
|
769
|
+
if (C === "reasoning")
|
|
769
770
|
return p(t, o, "Agent 标记与推理类型冲突");
|
|
770
|
-
|
|
771
|
-
const
|
|
771
|
+
C = "agent";
|
|
772
|
+
const n = ht(z[0]).trim().slice(11), y = (B) => B.replace(/(已失效)$/u, "").trim(), _ = y(n);
|
|
772
773
|
if (!_) return p(t, o, "Agent 名称为空");
|
|
773
|
-
const
|
|
774
|
+
const u = Array.isArray(t.tag_meta) ? t.tag_meta.find(
|
|
774
775
|
(B) => B && typeof B == "object" && B.type === "custom_agent" && typeof B.agent_name == "string" && y(
|
|
775
776
|
B.agent_name
|
|
776
777
|
) === _
|
|
777
778
|
) : void 0, f = Array.from(R.querySelectorAll("span")).find(
|
|
778
|
-
(B) => lt(B) === "custom_agent" && ((B.textContent || "").trim() === `{自定义Agent}@${
|
|
779
|
-
), v =
|
|
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")) || "";
|
|
780
781
|
if (f && ["data-agent-name", "data-tag-name"].some(
|
|
781
782
|
(B) => f.hasAttribute(B) && y(f.getAttribute(B) || "") !== _
|
|
782
783
|
))
|
|
783
784
|
return p(t, o, "Agent 名称属性与显示内容不一致");
|
|
784
|
-
if (
|
|
785
|
+
if (W && (u != null && u.agent_id) && W !== u.agent_id)
|
|
785
786
|
return p(t, "tag_meta", "Agent ID 与富文本标签不一致");
|
|
786
|
-
const
|
|
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, _);
|
|
787
788
|
et = {
|
|
788
|
-
id: (
|
|
789
|
+
id: (q == null ? void 0 : q.name) === _ ? q.id : "",
|
|
789
790
|
name: _,
|
|
790
791
|
...v ? { invalid: !0 } : {}
|
|
791
792
|
}, z.shift();
|
|
792
793
|
}
|
|
793
|
-
if (
|
|
794
|
+
if (C === "agent" && !et)
|
|
794
795
|
return p(t, o, "Agent 知识缺少可解析的 Agent 标记");
|
|
795
796
|
G && z.unshift([{ kind: "text", value: G }]);
|
|
796
|
-
const L = (
|
|
797
|
-
var
|
|
798
|
-
if (
|
|
797
|
+
const L = (n, y, _ = !1, u = !1) => {
|
|
798
|
+
var W, q;
|
|
799
|
+
if (n.kind === "hardBreak")
|
|
799
800
|
return { ok: !0, value: [{ type: "hardBreak" }] };
|
|
800
|
-
if (
|
|
801
|
+
if (n.kind === "originalReply")
|
|
801
802
|
return p(t, y, "原话块不可嵌套原话模板");
|
|
802
|
-
if (
|
|
803
|
+
if (n.kind === "media" || n.kind === "block")
|
|
803
804
|
return p(t, y, "块级内容不能作为行内标签转换");
|
|
804
|
-
if (
|
|
805
|
+
if (n.kind === "tableKnowledge")
|
|
805
806
|
return {
|
|
806
807
|
ok: !0,
|
|
807
808
|
value: [
|
|
808
809
|
{
|
|
809
810
|
type: "businessToken",
|
|
810
|
-
attrs: { kind: "tableKnowledge", key:
|
|
811
|
+
attrs: { kind: "tableKnowledge", key: n.key, label: n.name }
|
|
811
812
|
}
|
|
812
813
|
]
|
|
813
814
|
};
|
|
814
|
-
if (
|
|
815
|
-
return
|
|
815
|
+
if (n.kind === "attribute")
|
|
816
|
+
return C !== "agent" && (C !== "reasoning" || u) ? p(
|
|
816
817
|
t,
|
|
817
818
|
y,
|
|
818
819
|
"业务属性只能位于推理知识正文,不能放入原话"
|
|
@@ -821,37 +822,37 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
821
822
|
value: [
|
|
822
823
|
{
|
|
823
824
|
type: "businessToken",
|
|
824
|
-
attrs: { kind: "attribute", key:
|
|
825
|
+
attrs: { kind: "attribute", key: n.key, label: n.name }
|
|
825
826
|
}
|
|
826
827
|
]
|
|
827
828
|
};
|
|
828
|
-
if (
|
|
829
|
+
if (n.kind !== "todo") {
|
|
829
830
|
const B = Gt(
|
|
830
|
-
|
|
831
|
+
C === "normal" ? n.value.replace(/\{(?:待办(?:@[^{}]+)?|原话复述)\}/gu, "") : n.value,
|
|
831
832
|
y,
|
|
832
833
|
s,
|
|
833
|
-
|
|
834
|
+
a
|
|
834
835
|
);
|
|
835
|
-
return B.ok ?
|
|
836
|
+
return B.ok ? C !== "agent" && (C !== "reasoning" || u) && B.value.some(
|
|
836
837
|
(P) => {
|
|
837
|
-
var
|
|
838
|
-
return P.type === "businessToken" && ((
|
|
838
|
+
var at;
|
|
839
|
+
return P.type === "businessToken" && ((at = P.attrs) == null ? void 0 : at.kind) === "attribute";
|
|
839
840
|
}
|
|
840
841
|
) ? p(
|
|
841
842
|
t,
|
|
842
843
|
y,
|
|
843
844
|
"业务属性只能位于推理知识正文,不能放入原话"
|
|
844
|
-
) : B.ok && ((
|
|
845
|
+
) : B.ok && ((W = n.marks) != null && W.length) ? {
|
|
845
846
|
ok: !0,
|
|
846
847
|
value: B.value.map((P) => ({
|
|
847
848
|
...P,
|
|
848
|
-
marks:
|
|
849
|
+
marks: n.marks
|
|
849
850
|
}))
|
|
850
851
|
} : B : B;
|
|
851
852
|
}
|
|
852
|
-
if (
|
|
853
|
-
const f =
|
|
854
|
-
return !(v != null && v.id) || v.label !== f ? p(t, y, `待办 ${f} 缺少匹配的方案 ID`) :
|
|
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: [] }) : {
|
|
855
856
|
ok: !0,
|
|
856
857
|
value: [
|
|
857
858
|
{
|
|
@@ -860,13 +861,13 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
860
861
|
kind: "todo",
|
|
861
862
|
key: v.id,
|
|
862
863
|
label: v.label,
|
|
863
|
-
...
|
|
864
|
+
...n.value === "{待办}" ? { token: "{待办}" } : {}
|
|
864
865
|
}
|
|
865
866
|
}
|
|
866
867
|
]
|
|
867
868
|
};
|
|
868
869
|
};
|
|
869
|
-
if (
|
|
870
|
+
if (C === "normal") {
|
|
870
871
|
!F.length && String(Z || "").trim() && typeof t.todo_plan_name == "string" && (A.todo = {
|
|
871
872
|
version: 1,
|
|
872
873
|
data: {
|
|
@@ -874,61 +875,61 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
874
875
|
tag: { id: String(Z), label: t.todo_plan_name }
|
|
875
876
|
}
|
|
876
877
|
});
|
|
877
|
-
for (const
|
|
878
|
-
const y = L(
|
|
878
|
+
for (const n of F) {
|
|
879
|
+
const y = L(n, o, !0);
|
|
879
880
|
if (!y.ok) return { ...y, raw: t };
|
|
880
881
|
}
|
|
881
882
|
} else F.length && z.unshift(F);
|
|
882
|
-
|
|
883
|
-
const
|
|
883
|
+
C !== "normal" && A.originalReply && (delete A.originalReply, z.unshift([{ kind: "text", value: "{原话复述}" }]));
|
|
884
|
+
const V = (n, y, _ = !1) => {
|
|
884
885
|
var f;
|
|
885
|
-
const
|
|
886
|
-
for (let v = 0; v <
|
|
887
|
-
const
|
|
888
|
-
if (B != null && B.startsWith("{原话复述}") &&
|
|
889
|
-
const T = B.slice(6), N = T ? _t(w(T), m,
|
|
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;
|
|
890
891
|
if (N && !N.ok) return N;
|
|
891
|
-
const J = N != null && N.ok ? N.value[0] :
|
|
892
|
-
if (!J) return p(t,
|
|
892
|
+
const J = N != null && N.ok ? N.value[0] : n[++v];
|
|
893
|
+
if (!J) return p(t, q, "原话块缺少内容");
|
|
893
894
|
if (ht(J) === null)
|
|
894
|
-
return p(t,
|
|
895
|
-
const
|
|
895
|
+
return p(t, q, "原话块包含无法转换的媒体");
|
|
896
|
+
const nt = [];
|
|
896
897
|
for (const rt of J) {
|
|
897
|
-
const st = L(rt,
|
|
898
|
+
const st = L(rt, q, !1, !0);
|
|
898
899
|
if (!st.ok) return { ...st, raw: t };
|
|
899
|
-
|
|
900
|
+
nt.push(...st.value);
|
|
900
901
|
}
|
|
901
|
-
|
|
902
|
+
u.push({
|
|
902
903
|
type: "originalReply",
|
|
903
|
-
content: [{ type: "paragraph", content:
|
|
904
|
+
content: [{ type: "paragraph", content: nt }]
|
|
904
905
|
});
|
|
905
906
|
continue;
|
|
906
907
|
}
|
|
907
908
|
let P = [];
|
|
908
|
-
const
|
|
909
|
-
P.length && (
|
|
909
|
+
const at = () => {
|
|
910
|
+
P.length && (u.push({ type: "paragraph", content: P }), P = []);
|
|
910
911
|
};
|
|
911
|
-
for (const T of
|
|
912
|
+
for (const T of W)
|
|
912
913
|
if (T.kind === "originalReply") {
|
|
913
914
|
P.every((U) => {
|
|
914
|
-
var
|
|
915
|
-
return U.type === "text" && !((
|
|
916
|
-
}) && (P = []),
|
|
917
|
-
const N = _t(T.html, m,
|
|
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);
|
|
918
919
|
if (!N.ok) return { ...N, raw: t };
|
|
919
|
-
if (_) return p(t,
|
|
920
|
-
const J =
|
|
920
|
+
if (_) return p(t, q, "原话块不可嵌套原话模板");
|
|
921
|
+
const J = V(
|
|
921
922
|
N.value,
|
|
922
|
-
`${
|
|
923
|
+
`${q}.originalReply`,
|
|
923
924
|
!0
|
|
924
925
|
);
|
|
925
926
|
if (!J.ok) return J;
|
|
926
|
-
|
|
927
|
+
C === "normal" ? u.push(...J.value) : u.push({
|
|
927
928
|
type: "originalReply",
|
|
928
929
|
content: J.value.length ? J.value : [{ type: "paragraph" }]
|
|
929
930
|
});
|
|
930
931
|
} else if (T.kind === "media")
|
|
931
|
-
|
|
932
|
+
at(), u.push({
|
|
932
933
|
type: "mediaBlock",
|
|
933
934
|
attrs: {
|
|
934
935
|
kind: T.media,
|
|
@@ -938,37 +939,37 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
938
939
|
}
|
|
939
940
|
});
|
|
940
941
|
else if (T.kind === "block") {
|
|
941
|
-
if (
|
|
942
|
-
|
|
942
|
+
if (at(), T.tag === "hr") {
|
|
943
|
+
u.push({ type: "horizontalRule" });
|
|
943
944
|
continue;
|
|
944
945
|
}
|
|
945
946
|
if (_)
|
|
946
|
-
return p(t,
|
|
947
|
+
return p(t, q, "原话块不支持嵌套列表或引用");
|
|
947
948
|
const N = new DOMParser().parseFromString(T.html, "text/html").body.firstElementChild;
|
|
948
949
|
if (T.tag === "pre") {
|
|
949
|
-
|
|
950
|
+
u.push({
|
|
950
951
|
type: "codeBlock",
|
|
951
952
|
...N.hasAttribute("data-language") ? { attrs: { language: N.getAttribute("data-language") } } : {},
|
|
952
953
|
content: N.textContent ? [{ type: "text", text: N.textContent }] : []
|
|
953
954
|
});
|
|
954
955
|
continue;
|
|
955
956
|
}
|
|
956
|
-
const J = T.tag === "ul" || T.tag === "ol", U = [],
|
|
957
|
-
for (const rt of
|
|
957
|
+
const J = T.tag === "ul" || T.tag === "ol", U = [], nt = J ? Array.from(N.children) : [N];
|
|
958
|
+
for (const rt of nt) {
|
|
958
959
|
if (J && rt.tagName.toLowerCase() !== "li")
|
|
959
|
-
return p(t,
|
|
960
|
+
return p(t, q, "列表包含非列表项节点");
|
|
960
961
|
const st = _t(
|
|
961
962
|
rt.innerHTML,
|
|
962
963
|
m,
|
|
963
|
-
|
|
964
|
+
a
|
|
964
965
|
);
|
|
965
966
|
if (!st.ok) return { ...st, raw: t };
|
|
966
|
-
const At =
|
|
967
|
+
const At = V(st.value, q);
|
|
967
968
|
if (!At.ok) return At;
|
|
968
969
|
const jt = At.value.length ? At.value : [{ type: "paragraph" }];
|
|
969
970
|
J ? U.push({ type: "listItem", content: jt }) : U.push(...jt);
|
|
970
971
|
}
|
|
971
|
-
|
|
972
|
+
u.push({
|
|
972
973
|
type: T.tag === "ul" ? "bulletList" : T.tag === "ol" ? "orderedList" : "blockquote",
|
|
973
974
|
...T.tag === "ol" && (N.hasAttribute("start") || N.hasAttribute("type")) ? {
|
|
974
975
|
attrs: {
|
|
@@ -979,54 +980,54 @@ function Et(t, r, s = {}, $ = {}) {
|
|
|
979
980
|
content: U
|
|
980
981
|
});
|
|
981
982
|
} else {
|
|
982
|
-
const N = L(T,
|
|
983
|
+
const N = L(T, q, !1, _);
|
|
983
984
|
if (!N.ok) return { ...N, raw: t };
|
|
984
985
|
P.push(...N.value);
|
|
985
986
|
}
|
|
986
|
-
|
|
987
|
+
W.some((T) => T.kind === "originalReply") && P.every((T) => {
|
|
987
988
|
var N;
|
|
988
989
|
return T.type === "text" && !((N = T.text) != null && N.trim());
|
|
989
|
-
}) && (P = []), (P.length || !
|
|
990
|
+
}) && (P = []), (P.length || !W.length) && u.push({ type: "paragraph", content: P });
|
|
990
991
|
}
|
|
991
|
-
return { ok: !0, value:
|
|
992
|
-
}, x =
|
|
992
|
+
return { ok: !0, value: u };
|
|
993
|
+
}, x = V(z, o);
|
|
993
994
|
if (!x.ok) return { ...x, raw: t };
|
|
994
995
|
const b = x.value;
|
|
995
996
|
te(b);
|
|
996
997
|
const S = zt(b, `${o}.block`);
|
|
997
998
|
if (S) return p(t, S, "工具标签重复");
|
|
998
|
-
const
|
|
999
|
+
const Q = {
|
|
999
1000
|
type: "doc",
|
|
1000
1001
|
content: b.length ? b : [{ type: "paragraph" }]
|
|
1001
|
-
}, it =
|
|
1002
|
-
(
|
|
1002
|
+
}, it = C === "agent" ? null : It(Q, r).doc, ot = b.some(
|
|
1003
|
+
(n) => {
|
|
1003
1004
|
var y;
|
|
1004
|
-
return
|
|
1005
|
+
return n.type !== "paragraph" || ((y = n.content) == null ? void 0 : y.some(
|
|
1005
1006
|
(_) => {
|
|
1006
|
-
var
|
|
1007
|
-
return _.type !== "text" || !!((
|
|
1007
|
+
var u;
|
|
1008
|
+
return _.type !== "text" || !!((u = _.text) != null && u.trim());
|
|
1008
1009
|
}
|
|
1009
1010
|
));
|
|
1010
1011
|
}
|
|
1011
1012
|
), ut = {
|
|
1012
1013
|
schemaVersion: 1,
|
|
1013
|
-
type:
|
|
1014
|
+
type: C,
|
|
1014
1015
|
question: { text: j },
|
|
1015
1016
|
knowledge: {
|
|
1016
1017
|
doc: it,
|
|
1017
1018
|
agentRef: et,
|
|
1018
|
-
...
|
|
1019
|
-
agentBody: It(
|
|
1019
|
+
...C === "agent" && ot ? {
|
|
1020
|
+
agentBody: It(Q, r).doc
|
|
1020
1021
|
} : {}
|
|
1021
1022
|
},
|
|
1022
1023
|
extensionState: A
|
|
1023
1024
|
}, dt = Ot(ut);
|
|
1024
1025
|
return dt ? p(t, dt, "转换后的场景未通过新模型校验") : { ok: !0, value: ut };
|
|
1025
1026
|
}
|
|
1026
|
-
function
|
|
1027
|
-
var $,
|
|
1027
|
+
function Wt(t, r, s) {
|
|
1028
|
+
var $, a, o, d, m, c, h, k, l, e;
|
|
1028
1029
|
if (($ = t.marks) != null && $.length) {
|
|
1029
|
-
const i =
|
|
1030
|
+
const i = Wt(
|
|
1030
1031
|
{ ...t, marks: void 0 },
|
|
1031
1032
|
r,
|
|
1032
1033
|
s
|
|
@@ -1056,7 +1057,7 @@ function qt(t, r, s) {
|
|
|
1056
1057
|
r,
|
|
1057
1058
|
"请通过工单入口插入工单标签,暂不支持将协议文字自动转换为标签"
|
|
1058
1059
|
);
|
|
1059
|
-
if (t.type === "text" && !((
|
|
1060
|
+
if (t.type === "text" && !((a = t.marks) != null && a.length))
|
|
1060
1061
|
return {
|
|
1061
1062
|
ok: !0,
|
|
1062
1063
|
value: { html: w(t.text || ""), text: t.text || "" }
|
|
@@ -1135,11 +1136,11 @@ function qt(t, r, s) {
|
|
|
1135
1136
|
html: `<span contenteditable="false" data-tag="true" data-tag-type="biz_attribute" data-attr-name="${g}" data-attr-key="${w(
|
|
1136
1137
|
i.key
|
|
1137
1138
|
)}" data-attr-id="${w(String(i.id))}">${g}</span>`,
|
|
1138
|
-
text:
|
|
1139
|
+
text: qt(i.name)
|
|
1139
1140
|
}
|
|
1140
1141
|
};
|
|
1141
1142
|
}
|
|
1142
|
-
if (t.type === "businessToken" && ((
|
|
1143
|
+
if (t.type === "businessToken" && ((l = t.attrs) == null ? void 0 : l.kind) === "separator")
|
|
1143
1144
|
return {
|
|
1144
1145
|
ok: !0,
|
|
1145
1146
|
value: {
|
|
@@ -1180,10 +1181,11 @@ function Bt(t, r, s) {
|
|
|
1180
1181
|
if (t.type === "horizontalRule")
|
|
1181
1182
|
return { ok: !0, value: { html: "<hr>", text: "<hr/>" } };
|
|
1182
1183
|
if (t.type === "mediaBlock" && ((d = t.attrs) == null ? void 0 : d.status) === "ready") {
|
|
1183
|
-
const k = t.attrs.kind === "image" ? "img" : "video",
|
|
1184
|
+
const k = t.attrs.kind === "image" ? "img" : "video", l = w(String(t.attrs.src)), e = [
|
|
1184
1185
|
["assetId", "data-asset-id"],
|
|
1185
1186
|
["name", "data-media-name"],
|
|
1186
|
-
["poster", "poster"]
|
|
1187
|
+
["poster", "poster"],
|
|
1188
|
+
["sourceType", "data-source-type"]
|
|
1187
1189
|
].filter(([i]) => {
|
|
1188
1190
|
var g;
|
|
1189
1191
|
return typeof ((g = t.attrs) == null ? void 0 : g[i]) == "string";
|
|
@@ -1191,12 +1193,12 @@ function Bt(t, r, s) {
|
|
|
1191
1193
|
return {
|
|
1192
1194
|
ok: !0,
|
|
1193
1195
|
value: {
|
|
1194
|
-
html: `<${k} src="${
|
|
1195
|
-
text: `<${k} src="${
|
|
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"/>'}`
|
|
1196
1198
|
}
|
|
1197
1199
|
};
|
|
1198
1200
|
}
|
|
1199
|
-
const
|
|
1201
|
+
const a = {
|
|
1200
1202
|
paragraph: "p",
|
|
1201
1203
|
bulletList: "ul",
|
|
1202
1204
|
orderedList: "ol",
|
|
@@ -1204,17 +1206,17 @@ function Bt(t, r, s) {
|
|
|
1204
1206
|
blockquote: "blockquote",
|
|
1205
1207
|
codeBlock: "pre"
|
|
1206
1208
|
}[t.type || ""];
|
|
1207
|
-
if (!
|
|
1209
|
+
if (!a) return p(t, r, "块级节点无法映射到旧格式");
|
|
1208
1210
|
const o = [];
|
|
1209
|
-
for (const [k,
|
|
1210
|
-
const e = `${r}.content[${k}]`, i = ["paragraph", "codeBlock"].includes(t.type || "") ?
|
|
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);
|
|
1211
1213
|
if (!i.ok) return i;
|
|
1212
1214
|
o.push(i.value);
|
|
1213
1215
|
}
|
|
1214
1216
|
return {
|
|
1215
1217
|
ok: !0,
|
|
1216
1218
|
value: {
|
|
1217
|
-
html: `<${
|
|
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}>`,
|
|
1218
1220
|
text: o.map((k) => k.text).join(
|
|
1219
1221
|
["paragraph", "codeBlock"].includes(t.type || "") ? "" : `
|
|
1220
1222
|
`
|
|
@@ -1223,28 +1225,28 @@ function Bt(t, r, s) {
|
|
|
1223
1225
|
};
|
|
1224
1226
|
}
|
|
1225
1227
|
function $t(t, r = !1) {
|
|
1226
|
-
const s = (
|
|
1228
|
+
const s = (a) => {
|
|
1227
1229
|
var m, c;
|
|
1228
|
-
const o = { ...
|
|
1229
|
-
delete o.id, delete o.nodeVersion, r &&
|
|
1230
|
-
const d = r &&
|
|
1231
|
-
(h, k,
|
|
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) => {
|
|
1232
1234
|
var e, i;
|
|
1233
|
-
return !(h.type === "paragraph" && !((e = h.content) != null && e.length) && ((i =
|
|
1235
|
+
return !(h.type === "paragraph" && !((e = h.content) != null && e.length) && ((i = l[k + 1]) == null ? void 0 : i.type) === "originalReply");
|
|
1234
1236
|
}
|
|
1235
|
-
) :
|
|
1237
|
+
) : a.content;
|
|
1236
1238
|
return {
|
|
1237
|
-
...
|
|
1239
|
+
...a,
|
|
1238
1240
|
...r ? {
|
|
1239
1241
|
marks: void 0,
|
|
1240
|
-
...
|
|
1242
|
+
...a.type === "text" ? { text: (c = a.text) == null ? void 0 : c.replace(/\u00a0/g, " ") } : {}
|
|
1241
1243
|
} : {},
|
|
1242
1244
|
attrs: Object.keys(o).length ? o : void 0,
|
|
1243
1245
|
content: d != null && d.length ? d.map(s) : void 0
|
|
1244
1246
|
};
|
|
1245
|
-
}, $ = (
|
|
1246
|
-
Object.entries(
|
|
1247
|
-
) :
|
|
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;
|
|
1248
1250
|
return JSON.stringify(
|
|
1249
1251
|
$({
|
|
1250
1252
|
type: t.type,
|
|
@@ -1257,7 +1259,7 @@ function $t(t, r = !1) {
|
|
|
1257
1259
|
})
|
|
1258
1260
|
);
|
|
1259
1261
|
}
|
|
1260
|
-
function
|
|
1262
|
+
function ae(t, r, s, $, a) {
|
|
1261
1263
|
var j, R, E, H, M;
|
|
1262
1264
|
if (typeof r.content != "string" || /<source\b|<\/video\s*>/iu.test(r.content)) return !1;
|
|
1263
1265
|
const o = new DOMParser().parseFromString(
|
|
@@ -1287,23 +1289,23 @@ function ne(t, r, s, $, n) {
|
|
|
1287
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);
|
|
1288
1290
|
const k = (M = t.extensionState.todo) == null ? void 0 : M.data;
|
|
1289
1291
|
k != null && k.tag && c.set(k.tag.label, k.tag);
|
|
1290
|
-
const
|
|
1292
|
+
const l = {
|
|
1291
1293
|
variable: (A) => m.get(A) || null,
|
|
1292
1294
|
selection: (A, I) => A === "todo" && c.get(I) || null
|
|
1293
1295
|
}, e = Et(
|
|
1294
1296
|
{ ...r, web_content: r.web_content || s.web_content },
|
|
1295
1297
|
"layout-proof",
|
|
1296
|
-
|
|
1298
|
+
l,
|
|
1297
1299
|
{
|
|
1298
1300
|
questionText: t.question.text,
|
|
1299
|
-
businessAttributes:
|
|
1301
|
+
businessAttributes: a
|
|
1300
1302
|
}
|
|
1301
1303
|
), i = $t(t);
|
|
1302
1304
|
if (!e.ok || $t(e.value) !== i)
|
|
1303
1305
|
return !1;
|
|
1304
1306
|
if (t.type === "normal") {
|
|
1305
1307
|
const A = _t(
|
|
1306
|
-
String(r.web_content ||
|
|
1308
|
+
String(r.web_content || Ct(r.content))
|
|
1307
1309
|
);
|
|
1308
1310
|
if (!A.ok || A.value.slice(d ? 1 : 0).some(
|
|
1309
1311
|
(I) => I.some(
|
|
@@ -1316,18 +1318,18 @@ function ne(t, r, s, $, n) {
|
|
|
1316
1318
|
{ ...s, web_content: "", content: r.content },
|
|
1317
1319
|
"layout-proof",
|
|
1318
1320
|
{
|
|
1319
|
-
...
|
|
1321
|
+
...l,
|
|
1320
1322
|
agent: (A) => {
|
|
1321
1323
|
var I;
|
|
1322
1324
|
return ((I = t.knowledge.agentRef) == null ? void 0 : I.name) === A ? t.knowledge.agentRef : null;
|
|
1323
1325
|
}
|
|
1324
1326
|
},
|
|
1325
|
-
{ questionText: t.question.text, businessAttributes:
|
|
1327
|
+
{ questionText: t.question.text, businessAttributes: a }
|
|
1326
1328
|
);
|
|
1327
1329
|
return g.ok && $t(g.value, !0) === $t(t, !0);
|
|
1328
1330
|
}
|
|
1329
1331
|
function oe(t, r = {}, s = {}) {
|
|
1330
|
-
var G, tt, O, Z, z, Y,
|
|
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, _;
|
|
1331
1333
|
const $ = s.businessAttributes ?? vt;
|
|
1332
1334
|
if (!Mt($))
|
|
1333
1335
|
return p(
|
|
@@ -1335,30 +1337,30 @@ function oe(t, r = {}, s = {}) {
|
|
|
1335
1337
|
"businessAttributes",
|
|
1336
1338
|
"业务属性目录格式无效或存在重复引用"
|
|
1337
1339
|
);
|
|
1338
|
-
const
|
|
1339
|
-
if (
|
|
1340
|
+
const a = Ot(t);
|
|
1341
|
+
if (a) return p(t, a, "场景未通过新模型校验");
|
|
1340
1342
|
const o = zt(
|
|
1341
1343
|
((G = t.knowledge.doc || t.knowledge.agentBody || t.knowledge.retainedDoc) == null ? void 0 : G.content) || [],
|
|
1342
1344
|
"knowledge.content"
|
|
1343
1345
|
);
|
|
1344
1346
|
if (o) return p(t, o, "工具标签重复");
|
|
1345
1347
|
const d = `【${t.question.text}】`, m = [], c = [];
|
|
1346
|
-
for (const [
|
|
1348
|
+
for (const [u, f] of [
|
|
1347
1349
|
["todo", "待办"],
|
|
1348
1350
|
["tagged", "顾客标签"]
|
|
1349
1351
|
]) {
|
|
1350
|
-
const v = (tt = t.extensionState[
|
|
1352
|
+
const v = (tt = t.extensionState[u]) == null ? void 0 : tt.data;
|
|
1351
1353
|
if (v != null && v.enabled) {
|
|
1352
|
-
const
|
|
1353
|
-
m.push(
|
|
1354
|
-
|
|
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(
|
|
1355
1357
|
((Z = v.tag) == null ? void 0 : Z.label) || ""
|
|
1356
1358
|
)}" plan_id="${w(((z = v.tag) == null ? void 0 : z.id) || "")}">${w(
|
|
1357
|
-
|
|
1359
|
+
W
|
|
1358
1360
|
)}</span>` : `<span contenteditable="false" data-tag="true" data-tag-type="cdp_tag" data-tag-name="${w(
|
|
1359
1361
|
((Y = v.tag) == null ? void 0 : Y.label) || ""
|
|
1360
|
-
)}" data-tag-id="${w(((
|
|
1361
|
-
|
|
1362
|
+
)}" data-tag-id="${w(((C = v.tag) == null ? void 0 : C.id) || "")}">${w(
|
|
1363
|
+
W
|
|
1362
1364
|
)}</span>`
|
|
1363
1365
|
);
|
|
1364
1366
|
}
|
|
@@ -1368,33 +1370,33 @@ function oe(t, r = {}, s = {}) {
|
|
|
1368
1370
|
)), (L = (D = t.extensionState.memory) == null ? void 0 : D.data) != null && L.enabled && (m.push("{记忆触发点}"), c.push(
|
|
1369
1371
|
'<span data-tag-type="memory_trigger" data-memory-trigger="true">{记忆触发点}</span>'
|
|
1370
1372
|
));
|
|
1371
|
-
for (const
|
|
1372
|
-
if (!["todo", "tagged", "originalReply", "memory"].includes(
|
|
1373
|
+
for (const u of Object.keys(t.extensionState))
|
|
1374
|
+
if (!["todo", "tagged", "originalReply", "memory"].includes(u))
|
|
1373
1375
|
return p(
|
|
1374
1376
|
t,
|
|
1375
|
-
`extensionState.${
|
|
1377
|
+
`extensionState.${u}`,
|
|
1376
1378
|
"旧格式无法表示此插件状态"
|
|
1377
1379
|
);
|
|
1378
|
-
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>`] : [],
|
|
1379
|
-
if (t.type === "reasoning" && (k.push("<div>{推理}</div>"),
|
|
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") {
|
|
1380
1382
|
if (!t.knowledge.agentRef)
|
|
1381
1383
|
return p(t, "knowledge.agentRef", "旧格式需要 Agent 引用");
|
|
1382
|
-
const
|
|
1384
|
+
const u = t.knowledge.agentRef, f = `{自定义Agent}@${u.name}${u.invalid ? "(已失效)" : ""}`;
|
|
1383
1385
|
k.push(
|
|
1384
1386
|
`<div><span data-tag-type="custom_agent" data-agent="true" data-agent-name="${w(
|
|
1385
|
-
|
|
1386
|
-
)}"${
|
|
1387
|
-
),
|
|
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);
|
|
1388
1390
|
}
|
|
1389
1391
|
const e = t.type === "agent" ? t.knowledge.agentBody ? "agentBody" : "retainedDoc" : "doc";
|
|
1390
|
-
for (const [
|
|
1391
|
-
const v = `knowledge.${e}.content[${
|
|
1392
|
+
for (const [u, f] of (((V = t.knowledge[e]) == null ? void 0 : V.content) || []).entries()) {
|
|
1393
|
+
const v = `knowledge.${e}.content[${u}]`;
|
|
1392
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))
|
|
1393
1395
|
continue;
|
|
1394
1396
|
if (f.type === "messageSeparator") {
|
|
1395
1397
|
k.push(
|
|
1396
1398
|
'<div><span data-tag-type="separator" data-divider="true">{分隔符}</span></div>'
|
|
1397
|
-
),
|
|
1399
|
+
), l.push("[sep]");
|
|
1398
1400
|
continue;
|
|
1399
1401
|
}
|
|
1400
1402
|
if ([
|
|
@@ -1409,18 +1411,18 @@ function oe(t, r = {}, s = {}) {
|
|
|
1409
1411
|
if (!T.ok) return { ...T, raw: t };
|
|
1410
1412
|
k.push(
|
|
1411
1413
|
f.type === "mediaBlock" ? `<div>${T.value.html}</div>` : T.value.html
|
|
1412
|
-
),
|
|
1414
|
+
), l.push(T.value.text);
|
|
1413
1415
|
continue;
|
|
1414
1416
|
}
|
|
1415
|
-
const
|
|
1416
|
-
if (!
|
|
1417
|
+
const W = f.type === "originalReply", q = W ? f.content || [] : [f];
|
|
1418
|
+
if (!q.length || q.some(
|
|
1417
1419
|
(T) => !["paragraph", "mediaBlock", "messageSeparator"].includes(
|
|
1418
1420
|
T.type || ""
|
|
1419
1421
|
)
|
|
1420
1422
|
))
|
|
1421
1423
|
return p(t, v, `节点 ${f.type} 无法映射到旧格式`);
|
|
1422
1424
|
const B = [];
|
|
1423
|
-
for (const [T, N] of
|
|
1425
|
+
for (const [T, N] of q.entries()) {
|
|
1424
1426
|
if (N.type === "mediaBlock") {
|
|
1425
1427
|
const U = Bt(N, v, $);
|
|
1426
1428
|
if (!U.ok) return { ...U, raw: t };
|
|
@@ -1441,9 +1443,9 @@ function oe(t, r = {}, s = {}) {
|
|
|
1441
1443
|
"请通过工单入口插入工单标签,暂不支持将协议文字自动转换为标签"
|
|
1442
1444
|
);
|
|
1443
1445
|
const J = [];
|
|
1444
|
-
for (const [U,
|
|
1445
|
-
const rt =
|
|
1446
|
-
|
|
1446
|
+
for (const [U, nt] of (N.content || []).entries()) {
|
|
1447
|
+
const rt = Wt(
|
|
1448
|
+
nt,
|
|
1447
1449
|
`${v}.content[${T}].content[${U}]`,
|
|
1448
1450
|
$
|
|
1449
1451
|
);
|
|
@@ -1455,26 +1457,26 @@ function oe(t, r = {}, s = {}) {
|
|
|
1455
1457
|
text: J.map((U) => U.text).join("")
|
|
1456
1458
|
});
|
|
1457
1459
|
}
|
|
1458
|
-
const P = B.map((T) => T.html).join("<br>"),
|
|
1460
|
+
const P = B.map((T) => T.html).join("<br>"), at = B.map((T) => T.text).join(`
|
|
1459
1461
|
`);
|
|
1460
|
-
|
|
1462
|
+
W ? (k.push(
|
|
1461
1463
|
`<div><span contenteditable="false" class="original-repeat-template" data-retelling="true" data-tag-type="original_repeat" data-original-repeat-template="true"><span><</span><span>原话复述</span><span class="original-repeat-input" contenteditable="true" data-original-repeat-input="true">${P}</span><span>></span></span></div>`
|
|
1462
|
-
),
|
|
1464
|
+
), l.push(`<{原话复述}${at}>`)) : (k.push(`<div>${P}</div>`), l.push(at));
|
|
1463
1465
|
}
|
|
1464
|
-
const i = (
|
|
1466
|
+
const i = (Q = t.extensionState.todo) == null ? void 0 : Q.data, g = [], j = (u) => {
|
|
1465
1467
|
var f, v;
|
|
1466
|
-
|
|
1467
|
-
id: String(
|
|
1468
|
-
label: String(
|
|
1469
|
-
}), (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);
|
|
1470
1472
|
};
|
|
1471
1473
|
(ot = (it = t.knowledge[e]) == null ? void 0 : it.content) == null || ot.forEach(j);
|
|
1472
1474
|
const R = i != null && i.enabled && i.tag ? [i.tag, ...g] : g, E = [
|
|
1473
1475
|
...new Map(
|
|
1474
|
-
R.map((
|
|
1476
|
+
R.map((u) => [JSON.stringify([u.id, u.label]), u])
|
|
1475
1477
|
).values()
|
|
1476
1478
|
];
|
|
1477
|
-
if (new Set(E.map((
|
|
1479
|
+
if (new Set(E.map((u) => u.label)).size !== E.length)
|
|
1478
1480
|
return p(
|
|
1479
1481
|
t,
|
|
1480
1482
|
"knowledge.doc",
|
|
@@ -1487,25 +1489,25 @@ function oe(t, r = {}, s = {}) {
|
|
|
1487
1489
|
name: (dt = M.tag) == null ? void 0 : dt.label,
|
|
1488
1490
|
value: (gt = M.tag) == null ? void 0 : gt.id
|
|
1489
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: "原话复述" });
|
|
1490
|
-
const
|
|
1491
|
-
var v,
|
|
1492
|
-
f.type === "businessToken" && ((v = f.attrs) == null ? void 0 : v.kind) === "tableKnowledge" && A.push({ type: "table_knowledge", name: f.attrs.label }), f.type === "businessToken" && ((
|
|
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({
|
|
1493
1495
|
type: "variable",
|
|
1494
1496
|
variable_name: f.attrs.label || f.attrs.key
|
|
1495
|
-
}), f.type === "originalReply" && A.push({ type: "original_repeat", name: "原话复述" }), (
|
|
1497
|
+
}), f.type === "originalReply" && A.push({ type: "original_repeat", name: "原话复述" }), (q = f.content) == null || q.forEach(u);
|
|
1496
1498
|
};
|
|
1497
|
-
(yt = (pt = t.knowledge[e]) == null ? void 0 : pt.content) == null || yt.forEach(
|
|
1499
|
+
(yt = (pt = t.knowledge[e]) == null ? void 0 : pt.content) == null || yt.forEach(u);
|
|
1498
1500
|
}
|
|
1499
|
-
const I = ((mt = t.knowledge[e]) == null ? void 0 : mt.content) || [], F = ((kt = I.at(-1)) == null ? void 0 : kt.type) === "paragraph" && !((
|
|
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 = {
|
|
1500
1502
|
...r,
|
|
1501
1503
|
knowledge_type: t.type === "reasoning" ? 2 : t.type === "agent" ? 3 : 1,
|
|
1502
1504
|
todo_plan_id: (H == null ? void 0 : H.id) || "",
|
|
1503
1505
|
todo_tag_type: E.length ? 2 : 0,
|
|
1504
1506
|
...R.length || Object.hasOwn(r, "todo_tag_metas") ? {
|
|
1505
1507
|
todo_tag_metas: R.length ? JSON.stringify(
|
|
1506
|
-
R.map((
|
|
1507
|
-
plan_id:
|
|
1508
|
-
plan_name:
|
|
1508
|
+
R.map((u) => ({
|
|
1509
|
+
plan_id: u.id,
|
|
1510
|
+
plan_name: u.label,
|
|
1509
1511
|
tag_type: 2
|
|
1510
1512
|
}))
|
|
1511
1513
|
) : ""
|
|
@@ -1513,38 +1515,38 @@ function oe(t, r = {}, s = {}) {
|
|
|
1513
1515
|
todo_plan_name: (H == null ? void 0 : H.label) || "",
|
|
1514
1516
|
tag_meta: [
|
|
1515
1517
|
...new Map(
|
|
1516
|
-
A.map((
|
|
1518
|
+
A.map((u) => [
|
|
1517
1519
|
JSON.stringify([
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1520
|
+
u.type,
|
|
1521
|
+
u.name || "",
|
|
1522
|
+
u.value || "",
|
|
1523
|
+
u.variable_name || ""
|
|
1522
1524
|
]),
|
|
1523
|
-
|
|
1525
|
+
u
|
|
1524
1526
|
])
|
|
1525
1527
|
).values()
|
|
1526
1528
|
],
|
|
1527
1529
|
web_content: k.join(""),
|
|
1528
|
-
content: (F ?
|
|
1530
|
+
content: (F ? l.slice(0, -1) : l).join(`
|
|
1529
1531
|
`)
|
|
1530
1532
|
};
|
|
1531
|
-
if (
|
|
1532
|
-
const
|
|
1533
|
+
if (ae(t, r, K, h, $)) {
|
|
1534
|
+
const u = new DOMParser().parseFromString(
|
|
1533
1535
|
xt(String(r.web_content || K.web_content)),
|
|
1534
1536
|
"text/html"
|
|
1535
1537
|
);
|
|
1536
1538
|
if (!r.web_content && ((_ = wt(r.content || "")) != null && _.suffix.startsWith(
|
|
1537
1539
|
"{推理}"
|
|
1538
1540
|
))) {
|
|
1539
|
-
const [f, v] = Array.from(
|
|
1541
|
+
const [f, v] = Array.from(u.body.children);
|
|
1540
1542
|
f && (v == null ? void 0 : v.textContent) === "{推理}" && (f.append(...Array.from(v.childNodes)), v.remove());
|
|
1541
1543
|
}
|
|
1542
|
-
|
|
1543
|
-
var
|
|
1544
|
+
u.querySelectorAll("span").forEach((f) => {
|
|
1545
|
+
var q, B;
|
|
1544
1546
|
if (lt(f) !== "todo") return;
|
|
1545
|
-
const v = f.getAttribute("data-tag-name") || ((B = (
|
|
1546
|
-
|
|
1547
|
-
}), K.web_content =
|
|
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;
|
|
1548
1550
|
}
|
|
1549
1551
|
return K.web_content = Zt(K.web_content || ""), { ok: !0, value: K };
|
|
1550
1552
|
}
|