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