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