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