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