@freecallai/pro 0.0.1 → 0.0.2
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/dist/FkpRichText.vue_vue_type_script_setup_true_lang-BuMz8Tyy.js +4416 -0
- package/dist/KnowledgeArea-BkRVWFrg.js +1224 -0
- package/dist/{ToolForm-CWpUIVTl.js → ToolForm-BSJxTJ7U.js} +1 -1
- package/dist/index-BVHYCLDv.js +5 -0
- package/dist/{index-DOEijEGU.js → index-BnFTr8u9.js} +1 -1
- package/dist/{index-5a9mHHzg.js → index-CG2j9Znw.js} +1 -1
- package/dist/index-kOPLn4DD.js +5 -0
- package/dist/index.js +3 -3
- package/dist/{media-migration-CGOFwdYm.js → media-migration-Cj-3xrxd.js} +1 -1
- package/dist/{media-upload-Dx45yv6a.js → media-upload-D7DpMJYx.js} +1 -1
- package/dist/rich-text/index.js +5 -5
- package/dist/rich-text/legacy-converter/index.js +766 -321
- package/dist/{guard-BCatAeT4.js → rules-CC6NoltX.js} +252 -190
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/rich-text/FkpRichText.vue.d.ts +16 -5
- package/dist/types/rich-text/__demo__/reasoning-template-examples.d.ts +12 -0
- package/dist/types/rich-text/index.d.ts +1 -1
- package/dist/types/rich-text/legacy-converter/business-attribute.d.ts +32 -0
- package/dist/types/rich-text/legacy-converter/index.d.ts +1 -0
- package/dist/types/rich-text/legacy-converter/tool-contract.d.ts +5 -0
- package/dist/types/rich-text/plugins/tool/rules.d.ts +34 -0
- package/dist/types/rich-text/public/types.d.ts +10 -0
- package/dist/types/rich-text/runtime/file-drop-guard.d.ts +2 -0
- package/dist/types/rich-text/runtime/media-policy.d.ts +15 -0
- package/dist/types/rich-text/runtime/media-target.d.ts +1 -0
- package/dist/types/rich-text/runtime/media-upload-session.d.ts +5 -1
- package/dist/types/rich-text/runtime/media-upload-slots.d.ts +4 -0
- package/dist/types/rich-text/ui/KnowledgeArea.vue.d.ts +7 -0
- package/package.json +1 -1
- package/dist/FkpRichText.vue_vue_type_script_setup_true_lang-DnknqQTh.js +0 -4115
- package/dist/KnowledgeArea-OPR7smbt.js +0 -923
- package/dist/index-BsQLwz91.js +0 -5
- package/dist/index-xAjlBylT.js +0 -5
|
@@ -0,0 +1,4416 @@
|
|
|
1
|
+
import { ref as H, shallowRef as fn, defineComponent as jt, openBlock as I, createElementBlock as _, normalizeClass as Be, createElementVNode as O, toDisplayString as Z, createBlock as fe, unref as b, withCtx as K, createVNode as P, createTextVNode as me, createCommentVNode as U, computed as le, watch as ye, Fragment as Ne, renderList as Ye, defineAsyncComponent as No, nextTick as Fe, onMounted as Vi, onBeforeUnmount as $i, withKeys as Rt, withModifiers as ft, normalizeStyle as Co, createSlots as Dt, isRef as Bi } from "vue";
|
|
2
|
+
import { Button as ee, Popover as Dn, Switch as _o, Input as Ui, Drawer as Fi, Popconfirm as ji, Modal as Lt, Textarea as zi, Message as Po } from "@freecallai/ui";
|
|
3
|
+
import ke from "@freecallai/icons";
|
|
4
|
+
import { IconExclamationCircleFill as Gi, IconClose as Ji, IconDelete as Wi } from "@freecallai/ui/es/icon/index.js";
|
|
5
|
+
import { c as qn, o as Fo, f as An, i as Hi, d as jo, h as zt, b as et, e as Yi, g as Gt, j as xo, k as Xi, l as Qi, m as Zi, M as ea, B as na, n as ta, p as oa } from "./rules-CC6NoltX.js";
|
|
6
|
+
function nt(t, o) {
|
|
7
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
8
|
+
const a = t;
|
|
9
|
+
return Object.keys(a).some((i) => !["maxBytes", "mimeTypes"].includes(i)) || a.maxBytes !== void 0 && (!Number.isSafeInteger(a.maxBytes) || a.maxBytes <= 0) || a.mimeTypes !== void 0 && (!Array.isArray(a.mimeTypes) || !a.mimeTypes.every(
|
|
10
|
+
(i) => typeof i == "string" && new RegExp(`^${o}/[a-z0-9.+-]+$`, "i").test(i)
|
|
11
|
+
)) ? null : {
|
|
12
|
+
...a.maxBytes !== void 0 ? { maxBytes: a.maxBytes } : {},
|
|
13
|
+
...a.mimeTypes !== void 0 ? {
|
|
14
|
+
mimeTypes: [...new Set(a.mimeTypes)].sort()
|
|
15
|
+
} : {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function ia(t, o) {
|
|
19
|
+
let a, i;
|
|
20
|
+
for (const c of t)
|
|
21
|
+
if (c && (c.maxBytes !== void 0 && (a !== void 0 && c.maxBytes > a && o(), a = Math.min(a ?? c.maxBytes, c.maxBytes)), c.mimeTypes !== void 0)) {
|
|
22
|
+
const p = i, v = c.mimeTypes;
|
|
23
|
+
p && v.some((y) => !p.includes(y)) && o(), i = p ? p.filter((y) => v.includes(y)) : v;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...a !== void 0 ? { maxBytes: a } : {},
|
|
27
|
+
...i !== void 0 ? { mimeTypes: i } : {}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function Ft(t) {
|
|
31
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
32
|
+
const o = t;
|
|
33
|
+
return Object.keys(o).some((a) => a !== "pageSize") || o.pageSize !== void 0 && (!Number.isSafeInteger(o.pageSize) || o.pageSize < 1 || o.pageSize > 100) ? null : o.pageSize === void 0 ? {} : { pageSize: o.pageSize };
|
|
34
|
+
}
|
|
35
|
+
function aa(t, o) {
|
|
36
|
+
let a;
|
|
37
|
+
for (const i of t)
|
|
38
|
+
(i == null ? void 0 : i.pageSize) !== void 0 && (a !== void 0 && i.pageSize > a && o(), a = Math.min(a ?? i.pageSize, i.pageSize));
|
|
39
|
+
return { pageSize: a ?? 30 };
|
|
40
|
+
}
|
|
41
|
+
const be = (t) => `${t.id}:${t.slot}`, hn = (t, o) => !!t && typeof t == "object" && !Array.isArray(t) && Object.keys(t).every((a) => o.includes(a)), la = (t) => {
|
|
42
|
+
if (!t || typeof t != "object") return !1;
|
|
43
|
+
const o = t;
|
|
44
|
+
return hn(o, [
|
|
45
|
+
"id",
|
|
46
|
+
"slot",
|
|
47
|
+
"enabled",
|
|
48
|
+
"visible",
|
|
49
|
+
"label",
|
|
50
|
+
"order",
|
|
51
|
+
"options"
|
|
52
|
+
]) && typeof o.id == "string" && typeof o.slot == "string" && (o.enabled === void 0 || typeof o.enabled == "boolean") && (o.visible === void 0 || typeof o.visible == "boolean") && (o.label === void 0 || typeof o.label == "string" && !!o.label.trim()) && (o.order === void 0 || typeof o.order == "number" && Number.isFinite(o.order)) && (o.options === void 0 || typeof o.options == "object");
|
|
53
|
+
};
|
|
54
|
+
function Zn(t, o, a = Date.now()) {
|
|
55
|
+
var F, Ie, re, W, pe, ue, se, Ee, Ce, tn, Ke;
|
|
56
|
+
const i = [], c = qn.filter((S) => S.types.includes(t)), p = (S) => S === void 0 ? null : !S || typeof S != "object" || Array.isArray(S) ? "snapshot" : An(S), v = p(o.config), y = v === null && !!o.config && (!hn(o.config, ["remote", "page"]) || Object.prototype.hasOwnProperty.call(o.config, "page") && !hn(o.config.page, [
|
|
57
|
+
"schemaVersion",
|
|
58
|
+
"revision",
|
|
59
|
+
"rules"
|
|
60
|
+
]) || ((F = o.config.page) == null ? void 0 : F.revision) !== void 0 && typeof o.config.page.revision != "string" || Object.prototype.hasOwnProperty.call(o.config, "remote") && !hn(o.config.remote, [
|
|
61
|
+
"status",
|
|
62
|
+
"required",
|
|
63
|
+
"snapshot",
|
|
64
|
+
"expiresAt"
|
|
65
|
+
]) || ((Ie = o.config.remote) == null ? void 0 : Ie.status) === "unavailable" && (Object.prototype.hasOwnProperty.call(
|
|
66
|
+
o.config.remote,
|
|
67
|
+
"snapshot"
|
|
68
|
+
) || Object.prototype.hasOwnProperty.call(
|
|
69
|
+
o.config.remote,
|
|
70
|
+
"expiresAt"
|
|
71
|
+
)) || ((re = o.config.remote) == null ? void 0 : re.status) === "ready" && !!o.config.remote.snapshot && (!hn(o.config.remote.snapshot, [
|
|
72
|
+
"schemaVersion",
|
|
73
|
+
"revision",
|
|
74
|
+
"rules"
|
|
75
|
+
]) || o.config.remote.snapshot.revision !== void 0 && typeof o.config.remote.snapshot.revision != "string")), k = v !== null || y, T = p(o.policy) !== null;
|
|
76
|
+
if (k || T)
|
|
77
|
+
return k && i.push({
|
|
78
|
+
code: v != null && v.includes("rules") ? "CONFIG_RULES_INVALID" : "CONFIG_INVALID",
|
|
79
|
+
severity: "error",
|
|
80
|
+
source: "config",
|
|
81
|
+
message: "能力配置包含不可安全读取的数据,当前知识只能查看"
|
|
82
|
+
}), T && i.push({
|
|
83
|
+
code: "POLICY_INVALID",
|
|
84
|
+
severity: "error",
|
|
85
|
+
source: "config",
|
|
86
|
+
message: "权限快照无效,当前知识只能查看"
|
|
87
|
+
}), {
|
|
88
|
+
type: t,
|
|
89
|
+
mode: "readonly",
|
|
90
|
+
capabilities: c.map((S) => ({
|
|
91
|
+
...S,
|
|
92
|
+
canInsert: !1,
|
|
93
|
+
visible: !1
|
|
94
|
+
})),
|
|
95
|
+
diagnostics: i,
|
|
96
|
+
fingerprint: Mo({
|
|
97
|
+
type: t,
|
|
98
|
+
invalidConfigInput: k,
|
|
99
|
+
invalidPolicyInput: T
|
|
100
|
+
})
|
|
101
|
+
};
|
|
102
|
+
const { remote: g } = o.config || {}, N = new Set(qn.map(be)), { policy: l } = o, A = (S) => qn.find((x) => be(x) === be(S)), C = (S) => {
|
|
103
|
+
if (S.options === void 0) return !0;
|
|
104
|
+
const x = A(S);
|
|
105
|
+
return (x == null ? void 0 : x.optionKind) === "media" ? nt(S.options, x.id) !== null : (x == null ? void 0 : x.optionKind) === "selection" ? Ft(S.options) !== null : !1;
|
|
106
|
+
}, w = !!l && (!hn(l, ["revision", "expiresAt", "allowed"]) || typeof l.revision != "string" || !l.revision || !Number.isFinite(l.expiresAt) || !Array.isArray(l.allowed) || !l.allowed.every(
|
|
107
|
+
(S) => hn(S, ["id", "slot", "options"]) && typeof S.id == "string" && typeof S.slot == "string" && N.has(be(S)) && C(S)
|
|
108
|
+
) || new Set(l.allowed.map(be)).size !== l.allowed.length), E = l && !w ? l.allowed : [], r = !!g && (g.status !== "ready" && g.status !== "unavailable" || typeof g.required != "boolean" || g.status === "ready" && !Number.isFinite(g.expiresAt)), D = (g == null ? void 0 : g.status) === "ready" && ((W = g.snapshot) == null ? void 0 : W.schemaVersion) !== 1, z = !!((pe = o.config) != null && pe.page) && o.config.page.schemaVersion !== 1, M = (S) => Array.isArray(S) && S.every(
|
|
109
|
+
(x) => la(x) && N.has(be(x)) && C(x)
|
|
110
|
+
), ne = (g == null ? void 0 : g.status) === "ready" && !M((ue = g.snapshot) == null ? void 0 : ue.rules), he = !!((se = o.config) != null && se.page) && !M(o.config.page.rules), J = (g == null ? void 0 : g.status) === "ready" && !ne && !D ? g.snapshot.rules : [], oe = (Ee = o.config) != null && Ee.page && !he && !z ? o.config.page.rules : [], V = (S) => new Set(S.map(be)).size !== S.length, ae = V(J) || V(oe), ie = !!o.readonly || !!o.disabled || w || r || !!o.policy && o.policy.expiresAt <= a || D || z || ne || he || ae || (g == null ? void 0 : g.status) === "ready" && g.expiresAt <= a || (g == null ? void 0 : g.status) === "unavailable";
|
|
111
|
+
o.policy && o.policy.expiresAt <= a && i.push({
|
|
112
|
+
code: "POLICY_EXPIRED",
|
|
113
|
+
severity: "error",
|
|
114
|
+
source: "config",
|
|
115
|
+
message: "权限已过期,当前知识只能查看"
|
|
116
|
+
}), w && i.push({
|
|
117
|
+
code: "POLICY_INVALID",
|
|
118
|
+
severity: "error",
|
|
119
|
+
source: "config",
|
|
120
|
+
message: "权限快照无效,当前知识只能查看"
|
|
121
|
+
}), r && i.push({
|
|
122
|
+
code: "CONFIG_INVALID",
|
|
123
|
+
severity: "error",
|
|
124
|
+
source: "config",
|
|
125
|
+
message: "远端配置快照无效,当前知识只能查看"
|
|
126
|
+
}), D && i.push({
|
|
127
|
+
code: "CONFIG_VERSION_INVALID",
|
|
128
|
+
severity: "error",
|
|
129
|
+
source: "config",
|
|
130
|
+
message: "配置版本不兼容,当前知识只能查看"
|
|
131
|
+
}), z && i.push({
|
|
132
|
+
code: "CONFIG_VERSION_INVALID",
|
|
133
|
+
severity: "error",
|
|
134
|
+
source: "config",
|
|
135
|
+
message: "页面配置版本不兼容,当前知识只能查看"
|
|
136
|
+
}), (ne || he) && i.push({
|
|
137
|
+
code: "CONFIG_RULES_INVALID",
|
|
138
|
+
severity: "error",
|
|
139
|
+
source: "config",
|
|
140
|
+
message: "能力配置无效,当前知识只能查看"
|
|
141
|
+
}), (g == null ? void 0 : g.status) === "unavailable" && i.push({
|
|
142
|
+
code: "CONFIG_UNAVAILABLE",
|
|
143
|
+
severity: "error",
|
|
144
|
+
source: "config",
|
|
145
|
+
message: "配置不可用,当前知识只能查看"
|
|
146
|
+
}), (g == null ? void 0 : g.status) === "ready" && g.expiresAt <= a && i.push({
|
|
147
|
+
code: "CONFIG_EXPIRED",
|
|
148
|
+
severity: "error",
|
|
149
|
+
source: "config",
|
|
150
|
+
message: "配置已过期,当前知识只能查看"
|
|
151
|
+
});
|
|
152
|
+
for (const [S, x] of [
|
|
153
|
+
["remote", J],
|
|
154
|
+
["page", oe]
|
|
155
|
+
]) {
|
|
156
|
+
const Y = /* @__PURE__ */ new Set();
|
|
157
|
+
for (const we of x)
|
|
158
|
+
Y.has(be(we)) && i.push({
|
|
159
|
+
code: "DUPLICATE_RULE",
|
|
160
|
+
severity: "error",
|
|
161
|
+
source: "config",
|
|
162
|
+
message: `${S} 配置重复:${be(we)}`,
|
|
163
|
+
capabilityId: we.id
|
|
164
|
+
}), Y.add(be(we));
|
|
165
|
+
}
|
|
166
|
+
const Se = (S, x) => S == null ? void 0 : S.find((Y) => be(Y) === be(x)), $ = c.map((S) => {
|
|
167
|
+
var on;
|
|
168
|
+
const x = (g == null ? void 0 : g.status) === "ready" && g.expiresAt > a ? Se(J, S) : void 0, Y = Se(oe, S), we = !o.policy || E.some((B) => be(B) === be(S)), G = (on = S.actions) == null ? void 0 : on.find(
|
|
169
|
+
(B) => B.id === S.primaryActionId
|
|
170
|
+
), Pe = [
|
|
171
|
+
...S.optionKind === "selection" && S.optionSource ? [] : (G == null ? void 0 : G.requiredPorts) || [],
|
|
172
|
+
...S.optionSource ? [Fo[S.optionSource]] : [],
|
|
173
|
+
...S.uiPorts || []
|
|
174
|
+
], _e = (() => {
|
|
175
|
+
if (S.primaryActionId && !G) return !1;
|
|
176
|
+
try {
|
|
177
|
+
return Pe.every(
|
|
178
|
+
(B) => {
|
|
179
|
+
var Oe;
|
|
180
|
+
return typeof ((Oe = o.ports) == null ? void 0 : Oe[B]) == "function";
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
} catch {
|
|
184
|
+
return i.push({
|
|
185
|
+
code: "PORT_INVALID",
|
|
186
|
+
severity: "warning",
|
|
187
|
+
source: "config",
|
|
188
|
+
message: `${S.id} 的宿主接口不可安全读取,该能力已禁用`,
|
|
189
|
+
capabilityId: S.id
|
|
190
|
+
}), !1;
|
|
191
|
+
}
|
|
192
|
+
})(), xe = E.find(
|
|
193
|
+
(B) => be(B) === be(S)
|
|
194
|
+
), qe = S.optionKind === "media" ? ia(
|
|
195
|
+
[
|
|
196
|
+
nt(
|
|
197
|
+
xe == null ? void 0 : xe.options,
|
|
198
|
+
S.id
|
|
199
|
+
) || void 0,
|
|
200
|
+
nt(
|
|
201
|
+
x == null ? void 0 : x.options,
|
|
202
|
+
S.id
|
|
203
|
+
) || void 0,
|
|
204
|
+
nt(
|
|
205
|
+
Y == null ? void 0 : Y.options,
|
|
206
|
+
S.id
|
|
207
|
+
) || void 0
|
|
208
|
+
],
|
|
209
|
+
() => i.push({
|
|
210
|
+
code: "OPTION_WIDEN_ATTEMPT",
|
|
211
|
+
severity: "warning",
|
|
212
|
+
source: "config",
|
|
213
|
+
message: `${S.id} 的后续配置试图放宽媒体限制,已按较严格值处理`,
|
|
214
|
+
capabilityId: S.id
|
|
215
|
+
})
|
|
216
|
+
) : void 0, Xe = S.optionKind === "selection" ? aa(
|
|
217
|
+
[xe == null ? void 0 : xe.options, x == null ? void 0 : x.options, Y == null ? void 0 : Y.options].map(
|
|
218
|
+
(B) => B === void 0 ? void 0 : Ft(B) || void 0
|
|
219
|
+
),
|
|
220
|
+
() => i.push({
|
|
221
|
+
code: "OPTION_WIDEN_ATTEMPT",
|
|
222
|
+
severity: "warning",
|
|
223
|
+
source: "config",
|
|
224
|
+
message: `${S.id} 的后续配置试图放宽查询分页限制,已按较严格值处理`,
|
|
225
|
+
capabilityId: S.id
|
|
226
|
+
})
|
|
227
|
+
) : void 0, In = qe || Xe, ze = !!(qe != null && qe.mimeTypes) && !qe.mimeTypes.length;
|
|
228
|
+
ze && i.push({
|
|
229
|
+
code: "OPTION_SET_EMPTY",
|
|
230
|
+
severity: "warning",
|
|
231
|
+
source: "config",
|
|
232
|
+
message: `${S.id} 的可用媒体类型交集为空`,
|
|
233
|
+
capabilityId: S.id
|
|
234
|
+
});
|
|
235
|
+
const $n = !ie && we && _e && !ze && (x == null ? void 0 : x.enabled) !== !1 && (Y == null ? void 0 : Y.enabled) !== !1;
|
|
236
|
+
return {
|
|
237
|
+
...S,
|
|
238
|
+
label: (Y == null ? void 0 : Y.label) || (x == null ? void 0 : x.label) || S.label,
|
|
239
|
+
order: (Y == null ? void 0 : Y.order) ?? (x == null ? void 0 : x.order) ?? S.order,
|
|
240
|
+
canInsert: $n,
|
|
241
|
+
options: In,
|
|
242
|
+
visible: (x == null ? void 0 : x.visible) !== !1 && (Y == null ? void 0 : Y.visible) !== !1 && ($n || !_e)
|
|
243
|
+
};
|
|
244
|
+
}).sort(
|
|
245
|
+
(S, x) => S.order - x.order || S.id.localeCompare(x.id) || S.slot.localeCompare(x.slot)
|
|
246
|
+
);
|
|
247
|
+
return {
|
|
248
|
+
type: t,
|
|
249
|
+
mode: ie ? "readonly" : "editable",
|
|
250
|
+
capabilities: $,
|
|
251
|
+
diagnostics: i,
|
|
252
|
+
fingerprint: Mo({
|
|
253
|
+
type: t,
|
|
254
|
+
mode: ie ? "readonly" : "editable",
|
|
255
|
+
policyRevision: l == null ? void 0 : l.revision,
|
|
256
|
+
remoteRevision: (g == null ? void 0 : g.status) === "ready" ? (Ce = g.snapshot) == null ? void 0 : Ce.revision : g == null ? void 0 : g.status,
|
|
257
|
+
pageRevision: (Ke = (tn = o.config) == null ? void 0 : tn.page) == null ? void 0 : Ke.revision,
|
|
258
|
+
policyAllowed: Kt(E),
|
|
259
|
+
remoteRules: Kt(J),
|
|
260
|
+
pageRules: Kt(oe),
|
|
261
|
+
options: $.map((S) => ({
|
|
262
|
+
id: S.id,
|
|
263
|
+
slot: S.slot,
|
|
264
|
+
apiVersion: S.apiVersion,
|
|
265
|
+
dataVersion: S.dataVersion,
|
|
266
|
+
options: S.options
|
|
267
|
+
}))
|
|
268
|
+
})
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function Kt(t) {
|
|
272
|
+
return t.map((o) => {
|
|
273
|
+
var a;
|
|
274
|
+
return {
|
|
275
|
+
id: o.id,
|
|
276
|
+
slot: o.slot,
|
|
277
|
+
enabled: o.enabled,
|
|
278
|
+
visible: o.visible,
|
|
279
|
+
label: o.label,
|
|
280
|
+
order: o.order,
|
|
281
|
+
options: o.options === void 0 ? void 0 : o.id === "image" || o.id === "video" ? nt(o.options, o.id) : ((a = qn.find((i) => be(i) === be(o))) == null ? void 0 : a.optionKind) === "selection" ? Ft(o.options) : o.options
|
|
282
|
+
};
|
|
283
|
+
}).sort((o, a) => be(o).localeCompare(be(a)));
|
|
284
|
+
}
|
|
285
|
+
function Mo(t) {
|
|
286
|
+
const o = (c) => Array.isArray(c) ? `[${c.map(o).join(",")}]` : c && typeof c == "object" ? `{${Object.entries(c).sort(([p], [v]) => p.localeCompare(v)).map(([p, v]) => `${JSON.stringify(p)}:${o(v)}`).join(",")}}` : JSON.stringify(c) ?? "null", a = o(t);
|
|
287
|
+
let i = 2166136261;
|
|
288
|
+
for (let c = 0; c < a.length; c++)
|
|
289
|
+
i = Math.imul(i ^ a.charCodeAt(c), 16777619);
|
|
290
|
+
return (i >>> 0).toString(16).padStart(8, "0");
|
|
291
|
+
}
|
|
292
|
+
function sa(t) {
|
|
293
|
+
const o = t.attrs || {};
|
|
294
|
+
return t.type === "businessToken" && ["todo", "ticket", "variable", "attribute", "tool", "separator"].includes(
|
|
295
|
+
String(o.kind)
|
|
296
|
+
) ? {
|
|
297
|
+
id: o.kind,
|
|
298
|
+
slot: "knowledgeInline",
|
|
299
|
+
identity: JSON.stringify([o.key, o.label, o.token])
|
|
300
|
+
} : t.type === "mediaBlock" && ["image", "video"].includes(String(o.kind)) ? {
|
|
301
|
+
id: o.kind,
|
|
302
|
+
slot: "knowledgeBlock",
|
|
303
|
+
identity: String(o.id || "")
|
|
304
|
+
} : t.type === "originalReply" ? { id: "originalReply", slot: "knowledgeBlock", identity: "block" } : t.type === "messageSeparator" ? { id: "separator", slot: "knowledgeBlock", identity: "block" } : null;
|
|
305
|
+
}
|
|
306
|
+
function Ro(t) {
|
|
307
|
+
const o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new WeakSet(), i = (c) => {
|
|
308
|
+
if (!c || typeof c != "object") return;
|
|
309
|
+
const p = c;
|
|
310
|
+
if (a.has(p)) return;
|
|
311
|
+
a.add(p);
|
|
312
|
+
const v = sa(p);
|
|
313
|
+
if (v) {
|
|
314
|
+
const y = `${v.id}:${v.slot}`, k = o.get(y) || {
|
|
315
|
+
use: { id: v.id, slot: v.slot },
|
|
316
|
+
instances: /* @__PURE__ */ new Map()
|
|
317
|
+
};
|
|
318
|
+
k.instances.set(
|
|
319
|
+
v.identity,
|
|
320
|
+
(k.instances.get(v.identity) || 0) + 1
|
|
321
|
+
), o.set(y, k);
|
|
322
|
+
}
|
|
323
|
+
Array.isArray(p.content) && p.content.forEach(i);
|
|
324
|
+
};
|
|
325
|
+
return t && i(t), o;
|
|
326
|
+
}
|
|
327
|
+
function Do(t, o, a) {
|
|
328
|
+
var p;
|
|
329
|
+
const i = Ro(t), c = Ro(o);
|
|
330
|
+
for (const [v, y] of c) {
|
|
331
|
+
if (a.some(
|
|
332
|
+
(T) => T.id === y.use.id && T.slot === y.use.slot && T.canInsert
|
|
333
|
+
))
|
|
334
|
+
continue;
|
|
335
|
+
const k = (p = i.get(v)) == null ? void 0 : p.instances;
|
|
336
|
+
for (const [T, g] of y.instances)
|
|
337
|
+
if (g > ((k == null ? void 0 : k.get(T)) || 0)) return y.use;
|
|
338
|
+
}
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
const wn = () => ({
|
|
342
|
+
type: "doc",
|
|
343
|
+
content: [{ type: "paragraph" }]
|
|
344
|
+
}), Ln = (t = "normal") => ({
|
|
345
|
+
schemaVersion: 1,
|
|
346
|
+
type: t,
|
|
347
|
+
question: { text: "" },
|
|
348
|
+
knowledge: { doc: t === "agent" ? null : wn(), agentRef: null },
|
|
349
|
+
extensionState: {}
|
|
350
|
+
});
|
|
351
|
+
function ra(t, o) {
|
|
352
|
+
const a = JSON.parse(JSON.stringify(t));
|
|
353
|
+
if (t.type === o) return { scene: a, removed: [] };
|
|
354
|
+
const i = /* @__PURE__ */ new Set(), c = {
|
|
355
|
+
todo: "待办",
|
|
356
|
+
originalReply: "原话复述",
|
|
357
|
+
attribute: "属性",
|
|
358
|
+
tool: "工具"
|
|
359
|
+
};
|
|
360
|
+
if (a.extensionState = Object.fromEntries(
|
|
361
|
+
Object.entries(a.extensionState).filter(([v]) => {
|
|
362
|
+
const y = c[v];
|
|
363
|
+
return y ? (i.add(y), !1) : !0;
|
|
364
|
+
})
|
|
365
|
+
), t.knowledge.agentRef && i.add("Agent 引用"), o === "agent") {
|
|
366
|
+
const v = t.knowledge.doc || t.knowledge.retainedDoc;
|
|
367
|
+
a.knowledge = {
|
|
368
|
+
doc: null,
|
|
369
|
+
...v ? {
|
|
370
|
+
retainedDoc: Lo(
|
|
371
|
+
v,
|
|
372
|
+
t.type,
|
|
373
|
+
o,
|
|
374
|
+
i
|
|
375
|
+
)
|
|
376
|
+
} : {},
|
|
377
|
+
agentRef: null
|
|
378
|
+
};
|
|
379
|
+
} else
|
|
380
|
+
a.knowledge = {
|
|
381
|
+
doc: Lo(
|
|
382
|
+
a.knowledge.doc || a.knowledge.retainedDoc || wn(),
|
|
383
|
+
t.type,
|
|
384
|
+
o,
|
|
385
|
+
i
|
|
386
|
+
),
|
|
387
|
+
agentRef: null
|
|
388
|
+
};
|
|
389
|
+
a.type = o;
|
|
390
|
+
const p = ["待办", "原话复述", "工单", "属性", "工具", "Agent 引用"];
|
|
391
|
+
return {
|
|
392
|
+
scene: a,
|
|
393
|
+
removed: [...i].sort((v, y) => p.indexOf(v) - p.indexOf(y))
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
function Lo(t, o, a, i) {
|
|
397
|
+
const c = (p) => {
|
|
398
|
+
var v;
|
|
399
|
+
if (o === "reasoning" && a !== "reasoning") {
|
|
400
|
+
if (p.type === "originalReply")
|
|
401
|
+
return i.add("原话复述"), null;
|
|
402
|
+
if (p.type === "businessToken") {
|
|
403
|
+
const k = {
|
|
404
|
+
todo: "待办",
|
|
405
|
+
ticket: "工单",
|
|
406
|
+
attribute: "属性",
|
|
407
|
+
tool: "工具"
|
|
408
|
+
}[String((v = p.attrs) == null ? void 0 : v.kind)];
|
|
409
|
+
if (k)
|
|
410
|
+
return i.add(k), null;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return p.content ? {
|
|
414
|
+
...p,
|
|
415
|
+
content: p.content.map(c).filter((y) => y !== null)
|
|
416
|
+
} : p;
|
|
417
|
+
};
|
|
418
|
+
return c(t) || wn();
|
|
419
|
+
}
|
|
420
|
+
function qt(t) {
|
|
421
|
+
const o = [], a = /* @__PURE__ */ new WeakSet();
|
|
422
|
+
let i = 0;
|
|
423
|
+
const c = 2e4, p = (T) => {
|
|
424
|
+
if (i >= c) return;
|
|
425
|
+
const g = T.slice(0, c - i);
|
|
426
|
+
o.push(g), i += g.length;
|
|
427
|
+
}, v = (T, g) => {
|
|
428
|
+
if (!T || typeof T != "object" || g > 32) return;
|
|
429
|
+
const N = T;
|
|
430
|
+
if (a.has(N)) return;
|
|
431
|
+
a.add(N);
|
|
432
|
+
const l = typeof N.type == "string" ? N.type : "未知类型", A = N.attrs && typeof N.attrs == "object" ? N.attrs : {};
|
|
433
|
+
if (l === "text") {
|
|
434
|
+
typeof N.text == "string" && p(N.text);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
if (l === "hardBreak") {
|
|
438
|
+
p(`
|
|
439
|
+
`);
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
if (l === "businessToken") {
|
|
443
|
+
const C = A.token || A.label || A.key;
|
|
444
|
+
p(typeof C == "string" ? C : "[引用]");
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (l === "mediaBlock") {
|
|
448
|
+
const C = A.kind === "video" ? "视频" : "图片", w = typeof A.name == "string" && A.name ? `:${A.name}` : "";
|
|
449
|
+
p(`
|
|
450
|
+
[${C}${w}]
|
|
451
|
+
`);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (l === "messageSeparator") {
|
|
455
|
+
p(`
|
|
456
|
+
────
|
|
457
|
+
`);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
Hi(l) || p(`
|
|
461
|
+
[未识别内容:${l.slice(0, 80)}]
|
|
462
|
+
`), typeof N.text == "string" && p(N.text), Array.isArray(N.content) && N.content.forEach((C) => v(C, g + 1)), ["paragraph", "listItem", "blockquote", "originalReply"].includes(l) && p(`
|
|
463
|
+
`);
|
|
464
|
+
};
|
|
465
|
+
let y = !1;
|
|
466
|
+
try {
|
|
467
|
+
v(t, 0);
|
|
468
|
+
} catch {
|
|
469
|
+
y = !0;
|
|
470
|
+
}
|
|
471
|
+
const k = o.join("").replace(/\n{3,}/g, `
|
|
472
|
+
|
|
473
|
+
`).trim();
|
|
474
|
+
return y ? k ? `${k}
|
|
475
|
+
部分内容无法读取,原始数据仍保留。` : "内容无法安全预览;原始数据仍保留。" : k ? `${k}${i >= c ? `
|
|
476
|
+
…内容已截断,原始数据仍保留` : ""}` : "没有可提取的文本;原始数据仍保留。";
|
|
477
|
+
}
|
|
478
|
+
function Tn(t) {
|
|
479
|
+
const o = (a) => Array.isArray(a) ? `[${a.map((i) => o(i)).join(",")}]` : a && typeof a == "object" ? `{${Object.keys(a).filter((i) => a[i] !== void 0).sort().map(
|
|
480
|
+
(i) => `${JSON.stringify(i)}:${o(
|
|
481
|
+
a[i]
|
|
482
|
+
)}`
|
|
483
|
+
).join(",")}}` : JSON.stringify(a) ?? "null";
|
|
484
|
+
return o(t);
|
|
485
|
+
}
|
|
486
|
+
function Le(t) {
|
|
487
|
+
return Tn(t);
|
|
488
|
+
}
|
|
489
|
+
const gt = (t) => Array.from(t.replace(/\s/gu, "")).length;
|
|
490
|
+
function tt(t) {
|
|
491
|
+
let o = "", a = !1, i = !1, c = !1, p = !1;
|
|
492
|
+
const v = /* @__PURE__ */ new WeakSet(), y = (k) => {
|
|
493
|
+
var g, N, l, A, C;
|
|
494
|
+
if (!k || typeof k != "object") return;
|
|
495
|
+
const T = k;
|
|
496
|
+
if (!v.has(T)) {
|
|
497
|
+
if (v.add(T), typeof T.type == "string" && Yi(T.type) && (typeof ((g = T.attrs) == null ? void 0 : g.id) != "string" || !T.attrs.id.trim() || !Number.isSafeInteger(T.attrs.nodeVersion) || T.attrs.nodeVersion < 0) && (p = !0), T.type === "mediaBlock") {
|
|
498
|
+
a = !0, (((N = T.attrs) == null ? void 0 : N.status) === "uploading" || ((l = T.attrs) == null ? void 0 : l.status) === "error") && (i = !0);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
if (T.type === "businessToken") {
|
|
502
|
+
a = !0, ((A = T.attrs) == null ? void 0 : A.kind) === "tool" && ((C = T.attrs) == null ? void 0 : C.params) == null && (c = !0);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
if (T.type === "text" && typeof T.text == "string" && (o += T.text, gt(T.text) > 0 && (a = !0)), Array.isArray(T.content))
|
|
506
|
+
for (const w of T.content) y(w);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
return t && y(t), {
|
|
510
|
+
text: o,
|
|
511
|
+
hasContent: a,
|
|
512
|
+
pendingMedia: i,
|
|
513
|
+
missingToolParams: c,
|
|
514
|
+
incompleteNodeIdentity: p
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
function yt(t) {
|
|
518
|
+
return tt(t.knowledge.doc).pendingMedia || tt(t.knowledge.retainedDoc || null).pendingMedia;
|
|
519
|
+
}
|
|
520
|
+
function ua(t) {
|
|
521
|
+
return tt(t).hasContent;
|
|
522
|
+
}
|
|
523
|
+
function Xl(t, o = {}) {
|
|
524
|
+
if (!Array.isArray(t) || t.length === 0)
|
|
525
|
+
return {
|
|
526
|
+
ok: !1,
|
|
527
|
+
characterCount: 0,
|
|
528
|
+
issues: [
|
|
529
|
+
{
|
|
530
|
+
code: Array.isArray(t) ? "EMPTY_CONTENT" : "UNSUPPORTED_CONTENT",
|
|
531
|
+
sceneIndex: null,
|
|
532
|
+
message: Array.isArray(t) ? "请至少添加一条知识场景" : "知识场景列表格式不正确"
|
|
533
|
+
}
|
|
534
|
+
]
|
|
535
|
+
};
|
|
536
|
+
const a = o.maxCharacters, i = typeof a == "number" && Number.isSafeInteger(a) && a > 0 ? Math.min(a, 2e3) : 2e3, c = [], p = /* @__PURE__ */ new Set();
|
|
537
|
+
let v = 0;
|
|
538
|
+
return t.forEach((y, k) => {
|
|
539
|
+
var r, D;
|
|
540
|
+
let T;
|
|
541
|
+
try {
|
|
542
|
+
if (An(y) !== null)
|
|
543
|
+
throw new Error("Non-JSON scene");
|
|
544
|
+
T = JSON.parse(JSON.stringify(y));
|
|
545
|
+
} catch {
|
|
546
|
+
c.push({
|
|
547
|
+
code: "UNSUPPORTED_CONTENT",
|
|
548
|
+
sceneIndex: k,
|
|
549
|
+
message: "知识包含当前版本不支持的内容"
|
|
550
|
+
});
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
if (!jo(T)) {
|
|
554
|
+
c.push({
|
|
555
|
+
code: "UNSUPPORTED_CONTENT",
|
|
556
|
+
sceneIndex: k,
|
|
557
|
+
message: "知识包含当前版本不支持的内容"
|
|
558
|
+
});
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
T.schemaVersion !== 1 && c.push({
|
|
562
|
+
code: "SCHEMA_VERSION",
|
|
563
|
+
sceneIndex: k,
|
|
564
|
+
message: "知识数据版本不兼容"
|
|
565
|
+
});
|
|
566
|
+
const g = ((r = T.question) == null ? void 0 : r.text) || "", N = tt(
|
|
567
|
+
T.type === "agent" ? null : T.knowledge.doc
|
|
568
|
+
), l = tt(T.knowledge.retainedDoc || null);
|
|
569
|
+
v += gt(g) + gt(N.text);
|
|
570
|
+
const A = gt(g) > 0;
|
|
571
|
+
zt(g) && c.push({
|
|
572
|
+
code: "INVALID_INTENT_BRACKET",
|
|
573
|
+
sceneIndex: k,
|
|
574
|
+
message: "意图文字中不可填写方括号或换行,请修改"
|
|
575
|
+
});
|
|
576
|
+
const C = !!((D = T.knowledge.agentRef) != null && D.id);
|
|
577
|
+
T.type === "agent" && !C ? c.push({
|
|
578
|
+
code: A ? "AGENT_REQUIRED" : "EMPTY_CONTENT_AND_AGENT",
|
|
579
|
+
sceneIndex: k,
|
|
580
|
+
message: A ? "请选择Agent" : "请填写顾客意图或知识内容,并选择Agent"
|
|
581
|
+
}) : T.type !== "agent" && !A && !N.hasContent && c.push({
|
|
582
|
+
code: "EMPTY_CONTENT",
|
|
583
|
+
sceneIndex: k,
|
|
584
|
+
message: "请填写顾客意图或知识内容"
|
|
585
|
+
});
|
|
586
|
+
const w = g.split("/").map((z) => z.trim()).filter(Boolean);
|
|
587
|
+
w.some((z) => p.has(z)) && c.push({
|
|
588
|
+
code: "DUPLICATE_INTENT",
|
|
589
|
+
sceneIndex: k,
|
|
590
|
+
message: "已存在相同意图的知识场景"
|
|
591
|
+
}), w.forEach((z) => p.add(z)), yt(T) && c.push({
|
|
592
|
+
code: "MEDIA_PENDING",
|
|
593
|
+
sceneIndex: k,
|
|
594
|
+
message: "请等待媒体上传完成或移除失败的媒体"
|
|
595
|
+
}), N.missingToolParams && c.push({
|
|
596
|
+
code: "UNSUPPORTED_CONTENT",
|
|
597
|
+
sceneIndex: k,
|
|
598
|
+
message: "工具配置缺失,请迁移后保存"
|
|
599
|
+
});
|
|
600
|
+
const E = et(T);
|
|
601
|
+
!E && (N.incompleteNodeIdentity || l.incompleteNodeIdentity) && c.push({
|
|
602
|
+
code: "UNSUPPORTED_CONTENT",
|
|
603
|
+
sceneIndex: k,
|
|
604
|
+
message: "引用节点缺少稳定 ID 或版本,请迁移后保存"
|
|
605
|
+
}), E && c.push({
|
|
606
|
+
code: "UNSUPPORTED_CONTENT",
|
|
607
|
+
sceneIndex: k,
|
|
608
|
+
message: "知识包含当前版本不支持的内容"
|
|
609
|
+
});
|
|
610
|
+
}), v > i && c.push({
|
|
611
|
+
code: "TOO_LONG",
|
|
612
|
+
sceneIndex: null,
|
|
613
|
+
message: `内容不能超过${i}字`
|
|
614
|
+
}), { ok: c.length === 0, characterCount: v, issues: c };
|
|
615
|
+
}
|
|
616
|
+
const ca = {
|
|
617
|
+
"todo:questionAction": () => import("./question-DGC6JHy5.js"),
|
|
618
|
+
"todo:knowledgeInline": () => import("./knowledge-BZCmalF_.js"),
|
|
619
|
+
"ticket:knowledgeInline": () => import("./index-DxxX09iY.js"),
|
|
620
|
+
"originalReply:questionAction": () => import("./question-D1--acV8.js"),
|
|
621
|
+
"originalReply:knowledgeBlock": () => import("./knowledge-DnYGicjn.js"),
|
|
622
|
+
"memory:questionAction": () => import("./index-D8bcFtWR.js"),
|
|
623
|
+
"tagged:questionAction": () => import("./index-DSgEWJGP.js"),
|
|
624
|
+
"attribute:knowledgeInline": () => import("./index-CzpY61Qj.js"),
|
|
625
|
+
"tool:knowledgeInline": () => import("./index-nnvfy5q0.js"),
|
|
626
|
+
"variable:knowledgeInline": () => import("./index-urNonkMH.js"),
|
|
627
|
+
"separator:knowledgeInline": () => import("./index-CJlAseSN.js"),
|
|
628
|
+
"image:knowledgeBlock": () => import("./index-BVHYCLDv.js"),
|
|
629
|
+
"video:knowledgeBlock": () => import("./index-kOPLn4DD.js"),
|
|
630
|
+
"reasoningPolish:sceneAction": () => import("./index-CG2j9Znw.js"),
|
|
631
|
+
"reasoningTemplate:sceneAction": () => import("./index-BnFTr8u9.js")
|
|
632
|
+
};
|
|
633
|
+
function da(t, o) {
|
|
634
|
+
if (!o || typeof o != "object") return !1;
|
|
635
|
+
const a = o, { actions: i } = t, c = a.actions;
|
|
636
|
+
if (t.implementation !== "plugin" || !(i != null && i.length) || new Set(i.map((v) => v.id)).size !== i.length || !c || typeof c != "object" || Array.isArray(c))
|
|
637
|
+
return !1;
|
|
638
|
+
const p = c;
|
|
639
|
+
return Object.keys(p).length !== i.length || i.some((v) => {
|
|
640
|
+
const y = p[v.id];
|
|
641
|
+
return !Object.prototype.hasOwnProperty.call(p, v.id) || !y || typeof y != "object" || typeof y.execute != "function";
|
|
642
|
+
}) ? !1 : a.id === t.id && a.slot === t.slot && a.apiVersion === t.apiVersion && a.dataVersion === t.dataVersion;
|
|
643
|
+
}
|
|
644
|
+
async function zo(t) {
|
|
645
|
+
if (t.implementation !== "plugin")
|
|
646
|
+
return { ok: !1, reason: "NOT_REGISTERED" };
|
|
647
|
+
const o = ca[`${t.id}:${t.slot}`];
|
|
648
|
+
if (!o) return { ok: !1, reason: "NOT_REGISTERED" };
|
|
649
|
+
const a = await o();
|
|
650
|
+
return da(t, a.default) ? { ok: !0, module: a.default } : { ok: !1, reason: "VERSION_MISMATCH" };
|
|
651
|
+
}
|
|
652
|
+
function Go(t, o) {
|
|
653
|
+
if (!Array.isArray(t) || new Set(t).size !== t.length)
|
|
654
|
+
return null;
|
|
655
|
+
const a = t, i = {};
|
|
656
|
+
try {
|
|
657
|
+
for (const c of a) {
|
|
658
|
+
const p = o == null ? void 0 : o[c];
|
|
659
|
+
if (typeof p != "function") return null;
|
|
660
|
+
i[c] = p;
|
|
661
|
+
}
|
|
662
|
+
} catch {
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
return i;
|
|
666
|
+
}
|
|
667
|
+
function Jt(t, o, a) {
|
|
668
|
+
var c;
|
|
669
|
+
const i = (c = t.actions) == null ? void 0 : c.filter((p) => p.id === o);
|
|
670
|
+
return !i || i.length !== 1 ? null : Go(i[0].requiredPorts, a);
|
|
671
|
+
}
|
|
672
|
+
function fa(t, o) {
|
|
673
|
+
return Go(t.readPorts, o);
|
|
674
|
+
}
|
|
675
|
+
function pa(t, o) {
|
|
676
|
+
const a = qn.filter(
|
|
677
|
+
(i) => {
|
|
678
|
+
var c;
|
|
679
|
+
return (c = i.actions) == null ? void 0 : c.some((p) => p.id === t);
|
|
680
|
+
}
|
|
681
|
+
);
|
|
682
|
+
return a.length !== 1 ? null : Jt(
|
|
683
|
+
a[0],
|
|
684
|
+
t,
|
|
685
|
+
o
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
let Ko = 0;
|
|
689
|
+
function pt(t) {
|
|
690
|
+
var o, a;
|
|
691
|
+
t.target instanceof Element && t.target.closest('input[type="file"]') || (Array.from(((o = t.dataTransfer) == null ? void 0 : o.types) || []).includes("Files") || (a = t.dataTransfer) != null && a.files.length) && t.preventDefault();
|
|
692
|
+
}
|
|
693
|
+
function va() {
|
|
694
|
+
Ko++ === 0 && (window.addEventListener("dragover", pt), window.addEventListener("drop", pt));
|
|
695
|
+
let t = !1;
|
|
696
|
+
return () => {
|
|
697
|
+
t || (t = !0, --Ko === 0 && (window.removeEventListener("dragover", pt), window.removeEventListener("drop", pt)));
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
const ga = 10, Vt = {
|
|
701
|
+
image: 5 * 1024 * 1024,
|
|
702
|
+
video: 100 * 1024 * 1024
|
|
703
|
+
}, qo = {
|
|
704
|
+
image: ["image/png", "image/jpeg", "image/gif"],
|
|
705
|
+
video: ["video/mp4"]
|
|
706
|
+
}, Vo = {
|
|
707
|
+
png: { kind: "image", mime: "image/png" },
|
|
708
|
+
jpg: { kind: "image", mime: "image/jpeg" },
|
|
709
|
+
jpeg: { kind: "image", mime: "image/jpeg" },
|
|
710
|
+
gif: { kind: "image", mime: "image/gif" },
|
|
711
|
+
mp4: { kind: "video", mime: "video/mp4" }
|
|
712
|
+
};
|
|
713
|
+
function mt(t) {
|
|
714
|
+
const o = t.name.lastIndexOf("."), a = o < 0 ? "" : t.name.slice(o + 1).toLowerCase(), i = Object.prototype.hasOwnProperty.call(Vo, a) ? Vo[a] : void 0;
|
|
715
|
+
return !i || t.type && t.type.toLowerCase() !== i.mime ? null : i;
|
|
716
|
+
}
|
|
717
|
+
const ya = /* @__PURE__ */ new Set([
|
|
718
|
+
"ABORTED",
|
|
719
|
+
"UNAVAILABLE",
|
|
720
|
+
"FORBIDDEN",
|
|
721
|
+
"INVALID_RESPONSE",
|
|
722
|
+
"CONFLICT",
|
|
723
|
+
"TIMEOUT",
|
|
724
|
+
"NETWORK",
|
|
725
|
+
"UNKNOWN"
|
|
726
|
+
]), dn = () => ({
|
|
727
|
+
ok: !1,
|
|
728
|
+
error: {
|
|
729
|
+
code: "INVALID_RESPONSE",
|
|
730
|
+
message: "宿主接口返回格式不正确",
|
|
731
|
+
retryable: !1
|
|
732
|
+
}
|
|
733
|
+
}), ge = (t) => !!t && typeof t == "object" && !Array.isArray(t), Vn = (t) => typeof t == "string" && t.length > 0, je = (t) => typeof t == "string" && t.trim().length > 0, vt = (t, o) => Object.keys(t).every((a) => o.includes(a)), ma = /* @__PURE__ */ new Set([
|
|
734
|
+
"config",
|
|
735
|
+
"plugin",
|
|
736
|
+
"port",
|
|
737
|
+
"validation",
|
|
738
|
+
"migration"
|
|
739
|
+
]), ka = /* @__PURE__ */ new Set([
|
|
740
|
+
"info",
|
|
741
|
+
"warning",
|
|
742
|
+
"error"
|
|
743
|
+
]), ba = new Set(qn.map((t) => t.id)), ha = /* @__PURE__ */ new Set([
|
|
744
|
+
"questionAction",
|
|
745
|
+
"knowledgeInline",
|
|
746
|
+
"knowledgeBlock",
|
|
747
|
+
"sceneAction",
|
|
748
|
+
"toolbarOnly"
|
|
749
|
+
]);
|
|
750
|
+
function wa(t) {
|
|
751
|
+
return ge(t) ? Object.keys(t).every(
|
|
752
|
+
(o) => [
|
|
753
|
+
"code",
|
|
754
|
+
"severity",
|
|
755
|
+
"source",
|
|
756
|
+
"message",
|
|
757
|
+
"sceneKey",
|
|
758
|
+
"capabilityId",
|
|
759
|
+
"slot",
|
|
760
|
+
"path",
|
|
761
|
+
"retryable"
|
|
762
|
+
].includes(o)
|
|
763
|
+
) && Vn(t.code) && ka.has(t.severity) && ma.has(t.source) && typeof t.message == "string" && (t.sceneKey === void 0 || typeof t.sceneKey == "string") && (t.capabilityId === void 0 || ba.has(t.capabilityId)) && (t.slot === void 0 || ha.has(t.slot)) && (t.path === void 0 || typeof t.path == "string") && (t.retryable === void 0 || typeof t.retryable == "boolean") : !1;
|
|
764
|
+
}
|
|
765
|
+
function Sn(t, o) {
|
|
766
|
+
try {
|
|
767
|
+
if (!ge(t)) return dn();
|
|
768
|
+
if (t.ok === !0) {
|
|
769
|
+
const k = t.data;
|
|
770
|
+
if (k !== void 0 && An(k) !== null)
|
|
771
|
+
return dn();
|
|
772
|
+
const T = k === void 0 ? void 0 : JSON.parse(JSON.stringify(k));
|
|
773
|
+
return o(T) ? { ok: !0, data: T } : dn();
|
|
774
|
+
}
|
|
775
|
+
if (t.ok !== !1 || !ge(t.error)) return dn();
|
|
776
|
+
const { code: a, message: i, retryable: c, traceId: p, issues: v } = t.error;
|
|
777
|
+
let y;
|
|
778
|
+
if (v !== void 0) {
|
|
779
|
+
if (An(v) !== null) return dn();
|
|
780
|
+
const k = JSON.parse(JSON.stringify(v));
|
|
781
|
+
if (!Array.isArray(k) || !k.every(wa))
|
|
782
|
+
return dn();
|
|
783
|
+
y = k;
|
|
784
|
+
}
|
|
785
|
+
return ya.has(a) && Vn(i) && typeof c == "boolean" && (p === void 0 || typeof p == "string") ? {
|
|
786
|
+
ok: !1,
|
|
787
|
+
error: {
|
|
788
|
+
code: a,
|
|
789
|
+
message: i,
|
|
790
|
+
retryable: c,
|
|
791
|
+
...typeof p == "string" ? { traceId: p } : {},
|
|
792
|
+
...y ? { issues: y } : {}
|
|
793
|
+
}
|
|
794
|
+
} : dn();
|
|
795
|
+
} catch {
|
|
796
|
+
return dn();
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
function Wt(t, o) {
|
|
800
|
+
if (!ge(t) || !Array.isArray(t.items)) return !1;
|
|
801
|
+
const { items: a } = t;
|
|
802
|
+
return a.every(o) ? new Set(a.map((i) => i.id)).size === a.length && (t.nextCursor === void 0 || Vn(t.nextCursor)) : !1;
|
|
803
|
+
}
|
|
804
|
+
const Sa = (t) => Wt(
|
|
805
|
+
t,
|
|
806
|
+
(o) => ge(o) && je(o.id) && je(o.label) && je(o.token) && (o.group === void 0 || typeof o.group == "string") && (o.disabled === void 0 || typeof o.disabled == "boolean")
|
|
807
|
+
), Aa = (t) => Wt(
|
|
808
|
+
t,
|
|
809
|
+
(o) => ge(o) && je(o.id) && je(o.name)
|
|
810
|
+
), Jo = (t) => Wt(
|
|
811
|
+
t,
|
|
812
|
+
(o) => ge(o) && je(o.id) && je(o.label) && (o.disabled === void 0 || typeof o.disabled == "boolean") && (o.hasChildren === void 0 || typeof o.hasChildren == "boolean") && (o.preview === void 0 || typeof o.preview == "string")
|
|
813
|
+
), Ta = (t) => Jo(t) && t.items.every(
|
|
814
|
+
(o) => !!o.label.trim() && !o.hasChildren && !Xi(o.label)
|
|
815
|
+
), $o = (t, o) => ge(o) && vt(o, ["toolId", "permitted", "fields"]) && o.toolId === t && typeof o.permitted == "boolean" && Array.isArray(o.fields) && o.fields.length <= 20 && new Set(
|
|
816
|
+
o.fields.map((a) => ge(a) ? a.id : null)
|
|
817
|
+
).size === o.fields.length && o.fields.every(
|
|
818
|
+
(a) => ge(a) && vt(a, [
|
|
819
|
+
"id",
|
|
820
|
+
"label",
|
|
821
|
+
"kind",
|
|
822
|
+
"required",
|
|
823
|
+
"placeholder",
|
|
824
|
+
"min",
|
|
825
|
+
"max",
|
|
826
|
+
"maxLength",
|
|
827
|
+
"options",
|
|
828
|
+
"defaultValue",
|
|
829
|
+
"hideLabel",
|
|
830
|
+
"appearance",
|
|
831
|
+
"visibleWhen"
|
|
832
|
+
]) && typeof a.id == "string" && /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(a.id) && !["constructor", "prototype"].includes(a.id) && je(a.label) && ["text", "number", "switch", "textarea", "radio", "checkbox"].includes(
|
|
833
|
+
String(a.kind)
|
|
834
|
+
) && (a.required === void 0 || typeof a.required == "boolean") && (a.placeholder === void 0 || typeof a.placeholder == "string") && (a.hideLabel === void 0 || typeof a.hideLabel == "boolean") && (a.appearance === void 0 || a.kind === "radio" && a.appearance === "flag") && (a.maxLength === void 0 || (a.kind === "text" || a.kind === "textarea") && typeof a.maxLength == "number" && Number.isInteger(a.maxLength) && a.maxLength > 0) && (a.options === void 0 || a.kind === "radio" && Array.isArray(a.options) && a.options.length > 0 && a.options.every(
|
|
835
|
+
(i) => ge(i) && vt(i, ["value", "label", "color"]) && Vn(i.value) && i.value.trim() === i.value && je(i.label) && (i.color === void 0 || a.appearance === "flag" && typeof i.color == "string" && /^#[0-9a-fA-F]{6}$/.test(i.color))
|
|
836
|
+
)) && (a.kind !== "radio" || a.options !== void 0) && (a.defaultValue === void 0 || (["switch", "checkbox"].includes(String(a.kind)) ? typeof a.defaultValue == "boolean" : typeof a.defaultValue == "string" && a.defaultValue.trim() === a.defaultValue)) && (a.visibleWhen === void 0 || ge(a.visibleWhen) && vt(a.visibleWhen, ["fieldId", "equals"]) && Vn(a.visibleWhen.fieldId) && (typeof a.visibleWhen.equals == "string" || typeof a.visibleWhen.equals == "boolean")) && (a.min === void 0 || typeof a.min == "number" && Number.isFinite(a.min)) && (a.max === void 0 || typeof a.max == "number" && Number.isFinite(a.max)) && (a.kind === "number" || a.min === void 0 && a.max === void 0) && (a.min === void 0 || a.max === void 0 || a.min <= a.max)
|
|
837
|
+
) && o.fields.every((a, i) => {
|
|
838
|
+
if (!ge(a)) return !1;
|
|
839
|
+
if (a.kind === "radio") {
|
|
840
|
+
const y = a.options.map((k) => k.value);
|
|
841
|
+
if (new Set(y).size !== y.length || a.defaultValue !== void 0 && !y.includes(a.defaultValue))
|
|
842
|
+
return !1;
|
|
843
|
+
}
|
|
844
|
+
if (a.visibleWhen === void 0) return !0;
|
|
845
|
+
const c = a.visibleWhen, p = o.fields.slice(0, i).find(
|
|
846
|
+
(v) => ge(v) ? v.id === c.fieldId : !1
|
|
847
|
+
);
|
|
848
|
+
return ge(p) ? p.kind === "radio" ? p.options.some(
|
|
849
|
+
(v) => v.value === c.equals
|
|
850
|
+
) : ["switch", "checkbox"].includes(String(p.kind)) ? typeof c.equals == "boolean" : typeof c.equals == "string" : !1;
|
|
851
|
+
}), Ql = (t) => ge(t) && Object.keys(t).every(
|
|
852
|
+
(o) => ["proposedDoc", "explanation"].includes(o)
|
|
853
|
+
) && ge(t.proposedDoc) && t.proposedDoc.type === "doc" && !Gt(t.proposedDoc) && (t.explanation === void 0 || typeof t.explanation == "string"), Zl = (t) => ge(t) && Object.keys(t).length === 2 && typeof t.question == "string" && !zt(t.question) && ge(t.doc) && t.doc.type === "doc" && !Gt(t.doc), Ia = (t, o) => ge(o) && je(t) && o.id === t && je(o.name) && typeof o.prompt == "string" && (o.revision === void 0 || typeof o.revision == "string"), es = (t, o) => ge(o) && o.kind === t && xo(o.url) && (o.id === void 0 || Vn(o.id)) && (o.posterUrl === void 0 || xo(o.posterUrl)), Wo = () => ({
|
|
854
|
+
ok: !1,
|
|
855
|
+
error: {
|
|
856
|
+
code: "INVALID_RESPONSE",
|
|
857
|
+
message: "选项页数量超过请求上限",
|
|
858
|
+
retryable: !1
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
function Ea(t, o) {
|
|
862
|
+
if (!t || typeof t != "object") return !1;
|
|
863
|
+
try {
|
|
864
|
+
const a = Object.getOwnPropertyDescriptor(t, "ok"), i = Object.getOwnPropertyDescriptor(t, "data");
|
|
865
|
+
if ((a == null ? void 0 : a.value) !== !0 || !i || !("value" in i) || !i.value || typeof i.value != "object")
|
|
866
|
+
return !1;
|
|
867
|
+
const c = Object.getOwnPropertyDescriptor(i.value, "items");
|
|
868
|
+
return !!c && "value" in c && Array.isArray(c.value) && c.value.length > o;
|
|
869
|
+
} catch {
|
|
870
|
+
return !1;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
function Oa(t, o) {
|
|
874
|
+
return !t.ok || t.data.items.length <= o ? t : Wo();
|
|
875
|
+
}
|
|
876
|
+
function $t(t, o, a) {
|
|
877
|
+
return Ea(t, a) ? Wo() : Oa(Sn(t, o), a);
|
|
878
|
+
}
|
|
879
|
+
async function Na(t, o, a, i) {
|
|
880
|
+
const { search: c, cursor: p, parentId: v, limit: y } = o;
|
|
881
|
+
if (t.optionKind !== "selection") return null;
|
|
882
|
+
if (t.optionSource === "agents") {
|
|
883
|
+
const k = a == null ? void 0 : a.searchAgents;
|
|
884
|
+
if (typeof k != "function") return null;
|
|
885
|
+
const T = $t(
|
|
886
|
+
await k(
|
|
887
|
+
{
|
|
888
|
+
...c !== void 0 ? { search: c } : {},
|
|
889
|
+
...p !== void 0 ? { cursor: p } : {},
|
|
890
|
+
limit: y
|
|
891
|
+
},
|
|
892
|
+
i
|
|
893
|
+
),
|
|
894
|
+
Aa,
|
|
895
|
+
y
|
|
896
|
+
);
|
|
897
|
+
return T.ok ? {
|
|
898
|
+
ok: !0,
|
|
899
|
+
data: {
|
|
900
|
+
...T.data,
|
|
901
|
+
items: T.data.items.map(({ id: g, name: N }) => ({ id: g, label: N }))
|
|
902
|
+
}
|
|
903
|
+
} : T;
|
|
904
|
+
}
|
|
905
|
+
if (t.optionSource === "variables") {
|
|
906
|
+
const k = a == null ? void 0 : a.listVariables;
|
|
907
|
+
return typeof k != "function" ? null : $t(
|
|
908
|
+
await k(
|
|
909
|
+
{
|
|
910
|
+
...c !== void 0 ? { search: c } : {},
|
|
911
|
+
...p !== void 0 ? { cursor: p } : {},
|
|
912
|
+
limit: y
|
|
913
|
+
},
|
|
914
|
+
i
|
|
915
|
+
),
|
|
916
|
+
Sa,
|
|
917
|
+
y
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
if (t.optionSource === "flatTags" || t.optionSource === "capabilities") {
|
|
921
|
+
const k = a == null ? void 0 : a.listCapabilityOptions;
|
|
922
|
+
if (typeof k != "function") return null;
|
|
923
|
+
const T = await k(
|
|
924
|
+
{
|
|
925
|
+
capabilityId: t.id,
|
|
926
|
+
...v !== void 0 ? { parentId: v } : {},
|
|
927
|
+
...c !== void 0 ? { search: c } : {},
|
|
928
|
+
...p !== void 0 ? { cursor: p } : {},
|
|
929
|
+
limit: y
|
|
930
|
+
},
|
|
931
|
+
i
|
|
932
|
+
), g = $t(
|
|
933
|
+
T,
|
|
934
|
+
t.optionSource === "flatTags" ? Ta : Jo,
|
|
935
|
+
y
|
|
936
|
+
);
|
|
937
|
+
return g.ok && t.optionHierarchy !== "tree" && g.data.items.some((N) => N.hasChildren) ? {
|
|
938
|
+
ok: !1,
|
|
939
|
+
error: {
|
|
940
|
+
code: "INVALID_RESPONSE",
|
|
941
|
+
message: "当前能力不支持分类选项",
|
|
942
|
+
retryable: !1
|
|
943
|
+
}
|
|
944
|
+
} : g;
|
|
945
|
+
}
|
|
946
|
+
return null;
|
|
947
|
+
}
|
|
948
|
+
function Ca(t) {
|
|
949
|
+
const o = H(""), a = fn([]), i = fn([]), c = H(null), p = H(!1), v = /* @__PURE__ */ new Set();
|
|
950
|
+
let y = null, k = 0;
|
|
951
|
+
function T() {
|
|
952
|
+
if (!y) return;
|
|
953
|
+
const C = y;
|
|
954
|
+
y = null, C.abort(), t.track(C, !1), p.value = !1;
|
|
955
|
+
}
|
|
956
|
+
function g() {
|
|
957
|
+
T(), o.value = "", a.value = [], i.value = [], c.value = null, v.clear();
|
|
958
|
+
}
|
|
959
|
+
function N(C) {
|
|
960
|
+
T(), i.value = [...i.value, C], o.value = "", a.value = [], c.value = null, v.clear();
|
|
961
|
+
}
|
|
962
|
+
function l() {
|
|
963
|
+
return i.value.length ? (T(), i.value = i.value.slice(0, -1), o.value = "", a.value = [], c.value = null, v.clear(), !0) : !1;
|
|
964
|
+
}
|
|
965
|
+
async function A(C, w = !1) {
|
|
966
|
+
var oe;
|
|
967
|
+
const E = w ? c.value : null;
|
|
968
|
+
if (w && !E) return;
|
|
969
|
+
w || (a.value = [], c.value = null, v.clear()), T();
|
|
970
|
+
const r = new AbortController();
|
|
971
|
+
y = r;
|
|
972
|
+
const D = ++k, z = o.value, M = (oe = i.value.at(-1)) == null ? void 0 : oe.id, ne = t.descriptor(C), he = ne == null ? void 0 : ne.options, J = he && "pageSize" in he ? he.pageSize ?? 30 : 30;
|
|
973
|
+
t.track(r, !0), p.value = !0;
|
|
974
|
+
try {
|
|
975
|
+
const V = ne ? await Na(
|
|
976
|
+
ne,
|
|
977
|
+
{
|
|
978
|
+
search: z,
|
|
979
|
+
...M ? { parentId: M } : {},
|
|
980
|
+
...E ? { cursor: E } : {},
|
|
981
|
+
limit: J
|
|
982
|
+
},
|
|
983
|
+
t.ports(),
|
|
984
|
+
t.context(C, r)
|
|
985
|
+
) : null;
|
|
986
|
+
if (r.signal.aborted || D !== k || !t.isCurrent(C))
|
|
987
|
+
return;
|
|
988
|
+
if (!V) {
|
|
989
|
+
t.diagnostic("PORT_MISSING", "宿主未提供所需的数据接口", C);
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
if (!V.ok) {
|
|
993
|
+
t.portDiagnostic(V.error, C);
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
const ae = V.data.items, ie = w ? a.value : [], Se = new Set(ie.map((F) => F.id));
|
|
997
|
+
if (ae.some((F) => Se.has(F.id))) {
|
|
998
|
+
c.value = null, t.diagnostic("INVALID_RESPONSE", "选项分页返回了重复的 ID", C);
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
const $ = V.data.nextCursor || null;
|
|
1002
|
+
if ($ && ($ === E || v.has($))) {
|
|
1003
|
+
c.value = null, t.diagnostic("INVALID_RESPONSE", "选项分页游标未前进", C);
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
E && v.add(E), a.value = [...ie, ...ae], c.value = $;
|
|
1007
|
+
} catch (V) {
|
|
1008
|
+
r.signal.aborted || t.diagnostic(
|
|
1009
|
+
"PORT_FAILED",
|
|
1010
|
+
V instanceof Error ? V.message : "请求失败",
|
|
1011
|
+
C
|
|
1012
|
+
);
|
|
1013
|
+
} finally {
|
|
1014
|
+
t.track(r, !1), y === r && (y = null, p.value = !1);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return {
|
|
1018
|
+
query: o,
|
|
1019
|
+
options: a,
|
|
1020
|
+
path: i,
|
|
1021
|
+
nextCursor: c,
|
|
1022
|
+
loading: p,
|
|
1023
|
+
abort: T,
|
|
1024
|
+
reset: g,
|
|
1025
|
+
enter: N,
|
|
1026
|
+
back: l,
|
|
1027
|
+
fetch: A
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
const Bo = 3;
|
|
1031
|
+
function _a() {
|
|
1032
|
+
let t = 0;
|
|
1033
|
+
const o = /* @__PURE__ */ new Set();
|
|
1034
|
+
function a() {
|
|
1035
|
+
var i, c;
|
|
1036
|
+
for (; t < Bo && o.size; )
|
|
1037
|
+
(c = (i = o.values().next()).value) == null || c.call(i);
|
|
1038
|
+
}
|
|
1039
|
+
return {
|
|
1040
|
+
acquire(i) {
|
|
1041
|
+
return new Promise((c) => {
|
|
1042
|
+
let p = !1;
|
|
1043
|
+
function v() {
|
|
1044
|
+
p && (p = !1, i.removeEventListener("abort", y), t--, a());
|
|
1045
|
+
}
|
|
1046
|
+
function y() {
|
|
1047
|
+
p ? v() : (o.delete(k), i.removeEventListener("abort", y), c(null));
|
|
1048
|
+
}
|
|
1049
|
+
function k() {
|
|
1050
|
+
if (i.aborted) {
|
|
1051
|
+
y();
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
1054
|
+
t >= Bo || (o.delete(k), t++, p = !0, c(v));
|
|
1055
|
+
}
|
|
1056
|
+
i.addEventListener("abort", y, { once: !0 }), o.add(k), k();
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
function Uo(t) {
|
|
1062
|
+
return Number.isSafeInteger(t) && t >= 0 && t < Number.MAX_SAFE_INTEGER;
|
|
1063
|
+
}
|
|
1064
|
+
function Pa(t) {
|
|
1065
|
+
const o = {
|
|
1066
|
+
type: "doc",
|
|
1067
|
+
content: t.type === "businessToken" ? [{ type: "paragraph", content: [t] }] : [t]
|
|
1068
|
+
};
|
|
1069
|
+
return !Gt(o);
|
|
1070
|
+
}
|
|
1071
|
+
function xa(t, o) {
|
|
1072
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
1073
|
+
try {
|
|
1074
|
+
if (An(t) !== null) return null;
|
|
1075
|
+
const a = JSON.parse(JSON.stringify(t));
|
|
1076
|
+
return !o || typeof a.enabled == "boolean" ? a : null;
|
|
1077
|
+
} catch {
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
function Kn(t, o) {
|
|
1082
|
+
return Object.keys(t).some((a) => !o.includes(a));
|
|
1083
|
+
}
|
|
1084
|
+
function Ho(t, o) {
|
|
1085
|
+
var T, g, N;
|
|
1086
|
+
if (!Array.isArray(o))
|
|
1087
|
+
return { ok: !1, reason: "扩展返回值不是操作列表" };
|
|
1088
|
+
if (!o.length) return { ok: !0, kind: "none" };
|
|
1089
|
+
if (An(o) !== null)
|
|
1090
|
+
return { ok: !1, reason: "扩展操作包含不可序列化参数" };
|
|
1091
|
+
const a = [];
|
|
1092
|
+
let i = null, c = null, p;
|
|
1093
|
+
const v = [];
|
|
1094
|
+
let y = "";
|
|
1095
|
+
for (const l of o) {
|
|
1096
|
+
if (!l || l.capabilityId !== t.id)
|
|
1097
|
+
return { ok: !1, reason: "操作能力与扩展不匹配" };
|
|
1098
|
+
if (l.kind === "setOwnState") {
|
|
1099
|
+
if (t.implementation !== "plugin" || i || Kn(l, ["kind", "capabilityId", "data"]))
|
|
1100
|
+
return { ok: !1, reason: "扩展状态操作无效" };
|
|
1101
|
+
const A = xa(
|
|
1102
|
+
l.data,
|
|
1103
|
+
t.slot === "questionAction"
|
|
1104
|
+
);
|
|
1105
|
+
if (!A) return { ok: !1, reason: "扩展状态操作无效" };
|
|
1106
|
+
i = A;
|
|
1107
|
+
} else if (l.kind === "insertOwnToken") {
|
|
1108
|
+
if (t.slot !== "knowledgeInline" || v.length || c || Kn(l, [
|
|
1109
|
+
"kind",
|
|
1110
|
+
"capabilityId",
|
|
1111
|
+
"key",
|
|
1112
|
+
"label",
|
|
1113
|
+
"token",
|
|
1114
|
+
"params"
|
|
1115
|
+
]) || typeof l.key != "string" || !l.key || typeof l.label != "string" || l.token !== void 0 && (typeof l.token != "string" || !l.token) || l.params !== void 0 && (t.id !== "tool" || !l.params || typeof l.params != "object" || Array.isArray(l.params) || JSON.stringify(l.params).length > 8192) || t.id === "variable" && (typeof l.token != "string" || !l.token))
|
|
1116
|
+
return { ok: !1, reason: "扩展引用操作无效" };
|
|
1117
|
+
a.push(
|
|
1118
|
+
{
|
|
1119
|
+
type: "businessToken",
|
|
1120
|
+
attrs: {
|
|
1121
|
+
kind: t.id,
|
|
1122
|
+
key: l.key,
|
|
1123
|
+
label: l.label,
|
|
1124
|
+
...l.token ? { token: l.token } : {},
|
|
1125
|
+
...l.params ? { params: l.params } : {}
|
|
1126
|
+
}
|
|
1127
|
+
},
|
|
1128
|
+
{ type: "text", text: " " }
|
|
1129
|
+
);
|
|
1130
|
+
} else if (l.kind === "insertOwnBlock") {
|
|
1131
|
+
if (t.slot !== "knowledgeBlock" || l.block !== "originalReply" || v.length || c || Kn(l, ["kind", "capabilityId", "block"]) || l.block !== t.id)
|
|
1132
|
+
return { ok: !1, reason: "扩展块操作无效" };
|
|
1133
|
+
a.push({
|
|
1134
|
+
type: "originalReply",
|
|
1135
|
+
content: [{ type: "paragraph" }]
|
|
1136
|
+
});
|
|
1137
|
+
} else if (l.kind === "replaceSceneDoc") {
|
|
1138
|
+
if (t.slot !== "sceneAction" || t.implementation !== "plugin" || a.length || v.length || c || Kn(l, [
|
|
1139
|
+
"kind",
|
|
1140
|
+
"capabilityId",
|
|
1141
|
+
"doc",
|
|
1142
|
+
"question",
|
|
1143
|
+
"confirmation"
|
|
1144
|
+
]) || l.question !== void 0 && (typeof l.question != "string" || zt(l.question)) || typeof l.confirmation != "string" || !l.confirmation.trim() || l.confirmation.length > 160 || !l.doc || typeof l.doc != "object" || Array.isArray(l.doc) || l.doc.type !== "doc")
|
|
1145
|
+
return { ok: !1, reason: "扩展正文替换操作无效" };
|
|
1146
|
+
c = JSON.parse(JSON.stringify(l.doc)), p = l.question, y = l.confirmation;
|
|
1147
|
+
} else if (l.kind === "updateOwnNode") {
|
|
1148
|
+
const { node: A, nodeId: C, expectedNodeVersion: w } = l;
|
|
1149
|
+
if (!["knowledgeInline", "knowledgeBlock"].includes(t.slot) || ["image", "video"].includes(t.id) && o.length !== 1 || a.length || c || v.some((E) => E.nodeId === C) || Kn(l, [
|
|
1150
|
+
"kind",
|
|
1151
|
+
"capabilityId",
|
|
1152
|
+
"nodeId",
|
|
1153
|
+
"expectedNodeVersion",
|
|
1154
|
+
"node"
|
|
1155
|
+
]) || typeof C != "string" || !C || !Uo(w) || !A || typeof A != "object" || Array.isArray(A) || A.type !== "originalReply" && Object.keys(A).some((E) => !["type", "attrs"].includes(E)) || A.type === "originalReply" && Object.keys(A).some(
|
|
1156
|
+
(E) => !["type", "attrs", "content"].includes(E)
|
|
1157
|
+
) || Qi(A.type || "", A.attrs) !== t.id || t.slot === "knowledgeInline" != (A.type === "businessToken") || ((T = A.attrs) == null ? void 0 : T.id) !== C || ((g = A.attrs) == null ? void 0 : g.nodeVersion) !== w + 1 || A.type === "mediaBlock" && ((N = A.attrs) == null ? void 0 : N.status) !== "ready" || A.type === "originalReply" && Zi(A) || !Pa(A))
|
|
1158
|
+
return { ok: !1, reason: "扩展节点更新操作无效" };
|
|
1159
|
+
v.push({
|
|
1160
|
+
ok: !0,
|
|
1161
|
+
kind: "updateNode",
|
|
1162
|
+
nodeId: C,
|
|
1163
|
+
expectedNodeVersion: w,
|
|
1164
|
+
node: JSON.parse(JSON.stringify(A))
|
|
1165
|
+
});
|
|
1166
|
+
} else if (l.kind === "removeOwnNode") {
|
|
1167
|
+
const { nodeId: A, expectedNodeVersion: C } = l;
|
|
1168
|
+
if (!["knowledgeInline", "knowledgeBlock"].includes(t.slot) || ["image", "video"].includes(t.id) && o.length !== 1 || a.length || c || v.some((w) => w.nodeId === A) || Kn(l, [
|
|
1169
|
+
"kind",
|
|
1170
|
+
"capabilityId",
|
|
1171
|
+
"nodeId",
|
|
1172
|
+
"expectedNodeVersion"
|
|
1173
|
+
]) || typeof A != "string" || !A || !Uo(C))
|
|
1174
|
+
return { ok: !1, reason: "扩展节点删除操作无效" };
|
|
1175
|
+
v.push({
|
|
1176
|
+
ok: !0,
|
|
1177
|
+
kind: "removeNode",
|
|
1178
|
+
nodeId: A,
|
|
1179
|
+
expectedNodeVersion: C
|
|
1180
|
+
});
|
|
1181
|
+
} else
|
|
1182
|
+
return { ok: !1, reason: "扩展操作类型无效" };
|
|
1183
|
+
}
|
|
1184
|
+
let k = null;
|
|
1185
|
+
if (v.length === 1) {
|
|
1186
|
+
const [l] = v;
|
|
1187
|
+
k = l;
|
|
1188
|
+
} else v.length > 1 ? k = { ok: !0, kind: "batchNodes", operations: v } : c ? k = {
|
|
1189
|
+
ok: !0,
|
|
1190
|
+
kind: "replaceDoc",
|
|
1191
|
+
doc: c,
|
|
1192
|
+
...p !== void 0 ? { question: p } : {},
|
|
1193
|
+
confirmation: y
|
|
1194
|
+
} : a.length && (k = { ok: !0, kind: "doc", content: a });
|
|
1195
|
+
return i && k ? { ok: !0, kind: "compound", data: i, document: k } : i ? { ok: !0, kind: "state", data: i } : k || { ok: !0, kind: "none" };
|
|
1196
|
+
}
|
|
1197
|
+
function Bt(t, o, a, i) {
|
|
1198
|
+
const c = a == null ? void 0 : a.options, p = mt(t);
|
|
1199
|
+
if (i !== "size" && (!p || p.kind !== o))
|
|
1200
|
+
return {
|
|
1201
|
+
code: "INVALID_MEDIA",
|
|
1202
|
+
message: "仅支持 png、jpg、jpeg、gif 图片和 mp4 视频"
|
|
1203
|
+
};
|
|
1204
|
+
if (i !== "size" && c && "mimeTypes" in c && c.mimeTypes && !c.mimeTypes.includes((p == null ? void 0 : p.mime) || t.type))
|
|
1205
|
+
return {
|
|
1206
|
+
code: "INVALID_MEDIA",
|
|
1207
|
+
message: `文件类型不符合${o === "image" ? "图片" : "视频"}配置`
|
|
1208
|
+
};
|
|
1209
|
+
const v = c && "maxBytes" in c ? c.maxBytes : void 0, y = Math.min(
|
|
1210
|
+
Vt[o],
|
|
1211
|
+
v ?? Vt[o]
|
|
1212
|
+
);
|
|
1213
|
+
return i !== "format" && t.size > y ? {
|
|
1214
|
+
code: "MEDIA_TOO_LARGE",
|
|
1215
|
+
message: y === Vt[o] ? `${o === "image" ? "图片不能超过 5MB" : "视频不能超过 100MB"}` : `文件不能超过 ${y} 字节`
|
|
1216
|
+
} : null;
|
|
1217
|
+
}
|
|
1218
|
+
function Ma(t) {
|
|
1219
|
+
const o = /* @__PURE__ */ new Map(), a = _a();
|
|
1220
|
+
let i = null;
|
|
1221
|
+
function c(w) {
|
|
1222
|
+
i == null || i.dispose(), i = w;
|
|
1223
|
+
}
|
|
1224
|
+
function p() {
|
|
1225
|
+
const w = i;
|
|
1226
|
+
return i = null, w;
|
|
1227
|
+
}
|
|
1228
|
+
function v() {
|
|
1229
|
+
c(null);
|
|
1230
|
+
}
|
|
1231
|
+
function y(w) {
|
|
1232
|
+
return o.has(w);
|
|
1233
|
+
}
|
|
1234
|
+
function k(w) {
|
|
1235
|
+
var E;
|
|
1236
|
+
for (const [r, D] of o)
|
|
1237
|
+
w.has(r) || ((E = D.controller) == null || E.abort(), o.delete(r));
|
|
1238
|
+
}
|
|
1239
|
+
function T(w, E) {
|
|
1240
|
+
var he, J, oe;
|
|
1241
|
+
const r = {
|
|
1242
|
+
active: /* @__PURE__ */ new Set(),
|
|
1243
|
+
files: /* @__PURE__ */ new Set(),
|
|
1244
|
+
markFailed: []
|
|
1245
|
+
};
|
|
1246
|
+
if (E.id !== w.id) return r;
|
|
1247
|
+
const D = new Set(o.keys()), z = (V) => {
|
|
1248
|
+
const ae = /* @__PURE__ */ new Map(), ie = /* @__PURE__ */ new Set(), Se = ($) => {
|
|
1249
|
+
var Ie, re;
|
|
1250
|
+
const F = (Ie = $.attrs) == null ? void 0 : Ie.id;
|
|
1251
|
+
$.type === "mediaBlock" && typeof F == "string" && D.has(F) && (ae.has(F) ? ie.add(F) : ae.set(F, $)), (re = $.content) == null || re.forEach(Se);
|
|
1252
|
+
};
|
|
1253
|
+
return V && Se(V), ie.forEach(($) => ae.delete($)), ae;
|
|
1254
|
+
}, M = z(w.knowledge.doc), ne = z(E.knowledge.doc);
|
|
1255
|
+
for (const [V, ae] of o) {
|
|
1256
|
+
const ie = (he = t.editor()) == null ? void 0 : he.getMediaState(V), Se = M.get(V), $ = ne.get(V);
|
|
1257
|
+
!ie || !Se || !$ || ie.kind !== ae.kind || ((J = $.attrs) == null ? void 0 : J.kind) !== ae.kind || !Number.isSafeInteger((oe = $.attrs) == null ? void 0 : oe.nodeVersion) || $.attrs.nodeVersion < 0 || $.attrs.status !== "uploading" && $.attrs.status !== "error" || (r.files.add(V), ie.status === $.attrs.status && Tn(Se) === Tn($) ? r.active.add(V) : $.attrs.status === "uploading" && r.markFailed.push({
|
|
1258
|
+
id: V,
|
|
1259
|
+
nodeVersion: $.attrs.nodeVersion
|
|
1260
|
+
}));
|
|
1261
|
+
}
|
|
1262
|
+
return r;
|
|
1263
|
+
}
|
|
1264
|
+
function g(w) {
|
|
1265
|
+
return new Set(
|
|
1266
|
+
[...o].filter(([E]) => w.has(E)).map(([, E]) => E.controller).filter((E) => !!E)
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
function N(w) {
|
|
1270
|
+
for (const [E, r] of o)
|
|
1271
|
+
w != null && w.files.has(E) ? w.active.has(E) || (r.controller = void 0) : o.delete(E);
|
|
1272
|
+
}
|
|
1273
|
+
async function l(w, E, r, D = !1) {
|
|
1274
|
+
var oe, V, ae, ie, Se, $;
|
|
1275
|
+
const z = [];
|
|
1276
|
+
try {
|
|
1277
|
+
if (!w.length) return;
|
|
1278
|
+
const F = (W, pe, ue) => {
|
|
1279
|
+
var se;
|
|
1280
|
+
t.diagnostic(W, pe, "validation", ue), (se = t.notify) == null || se.call(t, "error", pe);
|
|
1281
|
+
};
|
|
1282
|
+
if (w.length > ga) {
|
|
1283
|
+
F("TOO_MANY_MEDIA", "一次最多上传 10 个文件");
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
for (const W of ["format", "size"])
|
|
1287
|
+
for (const pe of w) {
|
|
1288
|
+
const ue = (oe = mt(pe)) == null ? void 0 : oe.kind;
|
|
1289
|
+
if (!ue || r && ue !== r) {
|
|
1290
|
+
F(
|
|
1291
|
+
"INVALID_MEDIA",
|
|
1292
|
+
"仅支持 png、jpg、jpeg、gif 图片和 mp4 视频",
|
|
1293
|
+
r
|
|
1294
|
+
);
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
const se = Bt(
|
|
1298
|
+
pe,
|
|
1299
|
+
ue,
|
|
1300
|
+
t.capability(ue),
|
|
1301
|
+
W
|
|
1302
|
+
);
|
|
1303
|
+
if (se) {
|
|
1304
|
+
F(se.code, se.message, ue);
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
for (const W of w) {
|
|
1309
|
+
const { kind: pe } = mt(W);
|
|
1310
|
+
if (!t.canUse(pe)) {
|
|
1311
|
+
F("CAPABILITY_REVOKED", "此媒体能力当前不可用", pe);
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
const Ie = w.map((W) => ({
|
|
1316
|
+
file: W,
|
|
1317
|
+
kind: mt(W).kind
|
|
1318
|
+
})), re = (V = t.editor()) == null ? void 0 : V.insertPendingMediaBatch(Ie, E);
|
|
1319
|
+
if (!re) {
|
|
1320
|
+
const W = E.status() !== "ready";
|
|
1321
|
+
F(
|
|
1322
|
+
W ? "INSERT_TARGET_LOST" : "INSERT_FAILED",
|
|
1323
|
+
W ? "原始插入位置已失效,媒体未写入" : "媒体未能插入知识区"
|
|
1324
|
+
);
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
re.forEach((W, pe) => {
|
|
1328
|
+
o.set(W, Ie[pe]), z.push(W);
|
|
1329
|
+
});
|
|
1330
|
+
} finally {
|
|
1331
|
+
E.dispose();
|
|
1332
|
+
}
|
|
1333
|
+
if (z.length && D && ((ae = t.editor()) == null || ae.focus()), !z.length) return;
|
|
1334
|
+
const M = t.sceneKey();
|
|
1335
|
+
if ((ie = t.notify) == null || ie.call(t, "info", `正在上传 ${z.length} 个文件`), await Promise.all(z.map(A)), M !== t.sceneKey()) return;
|
|
1336
|
+
const ne = z.map((F) => {
|
|
1337
|
+
var Ie;
|
|
1338
|
+
return (Ie = t.editor()) == null ? void 0 : Ie.getMediaState(F);
|
|
1339
|
+
}), he = ne.filter((F) => (F == null ? void 0 : F.status) === "error").length, J = ne.filter((F) => (F == null ? void 0 : F.status) === "ready").length;
|
|
1340
|
+
he ? (Se = t.notify) == null || Se.call(
|
|
1341
|
+
t,
|
|
1342
|
+
"error",
|
|
1343
|
+
`${J} 个文件上传成功,${he} 个上传失败,可在失败项重试`
|
|
1344
|
+
) : J && (($ = t.notify) == null || $.call(t, "success", `${J} 个文件上传成功`));
|
|
1345
|
+
}
|
|
1346
|
+
async function A(w) {
|
|
1347
|
+
var ie, Se, $, F, Ie, re, W, pe, ue;
|
|
1348
|
+
const E = o.get(w), r = t.editor(), D = r == null ? void 0 : r.getMediaState(w);
|
|
1349
|
+
if (!E || E.controller || (D == null ? void 0 : D.status) !== "uploading" || D.kind !== E.kind)
|
|
1350
|
+
return;
|
|
1351
|
+
const { file: z, kind: M } = E, ne = t.capability(M), he = ne == null ? void 0 : ne.primaryActionId, J = D.nodeVersion;
|
|
1352
|
+
if (!ne || !he) {
|
|
1353
|
+
r != null && r.failMedia(w, "宿主未提供媒体上传接口", J) && t.diagnostic("PORT_MISSING", "宿主未提供媒体上传接口", "port", M);
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
const oe = t.sceneKey(), V = new AbortController();
|
|
1357
|
+
E.controller = V, t.track(V, !0);
|
|
1358
|
+
let ae = null;
|
|
1359
|
+
try {
|
|
1360
|
+
if (ae = await a.acquire(V.signal), !ae || V.signal.aborted) return;
|
|
1361
|
+
const se = await zo(ne);
|
|
1362
|
+
if (V.signal.aborted || oe !== t.sceneKey() || o.get(w) !== E)
|
|
1363
|
+
return;
|
|
1364
|
+
if (!t.canUse(M)) {
|
|
1365
|
+
(ie = t.editor()) == null || ie.failMedia(w, "媒体能力已失效,请删除后重试", J);
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
const Ee = t.capability(M), Ce = Bt(z, M, Ee);
|
|
1369
|
+
if (Ce) {
|
|
1370
|
+
(Se = t.editor()) != null && Se.failMedia(w, Ce.message, J) && t.diagnostic(
|
|
1371
|
+
Ce.code,
|
|
1372
|
+
Ce.message,
|
|
1373
|
+
"validation",
|
|
1374
|
+
M
|
|
1375
|
+
);
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
const tn = Ee ? Jt(Ee, he, t.ports()) : null;
|
|
1379
|
+
if (!tn) {
|
|
1380
|
+
($ = t.editor()) != null && $.failMedia(w, "宿主未提供媒体上传接口", J) && t.diagnostic(
|
|
1381
|
+
"PORT_MISSING",
|
|
1382
|
+
"宿主未提供媒体上传接口",
|
|
1383
|
+
"port",
|
|
1384
|
+
M
|
|
1385
|
+
);
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
const Ke = se.ok ? se.module.actions[he] : null;
|
|
1389
|
+
if (!Ke) {
|
|
1390
|
+
(F = t.editor()) != null && F.failMedia(w, "媒体上传扩展不可用", J) && t.diagnostic(
|
|
1391
|
+
"PLUGIN_UNAVAILABLE",
|
|
1392
|
+
"媒体上传扩展不可用",
|
|
1393
|
+
"plugin",
|
|
1394
|
+
M
|
|
1395
|
+
);
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1398
|
+
const S = t.context(M, V);
|
|
1399
|
+
S.reportProgress = (_e) => {
|
|
1400
|
+
var xe;
|
|
1401
|
+
!V.signal.aborted && oe === t.sceneKey() && o.get(w) === E && t.canUse(M) && ((xe = t.editor()) == null || xe.reportMediaProgress(w, J, _e));
|
|
1402
|
+
};
|
|
1403
|
+
const x = t.scene(), Y = await Ke.execute(
|
|
1404
|
+
{ upload: { file: z, nodeId: w, expectedNodeVersion: J } },
|
|
1405
|
+
{
|
|
1406
|
+
scene: JSON.parse(JSON.stringify(x.scene)),
|
|
1407
|
+
sceneKey: oe,
|
|
1408
|
+
revision: x.revision,
|
|
1409
|
+
options: Ee == null ? void 0 : Ee.options,
|
|
1410
|
+
request: S,
|
|
1411
|
+
ports: tn
|
|
1412
|
+
}
|
|
1413
|
+
);
|
|
1414
|
+
if (V.signal.aborted || oe !== t.sceneKey() || o.get(w) !== E)
|
|
1415
|
+
return;
|
|
1416
|
+
if (!t.canUse(M)) {
|
|
1417
|
+
(Ie = t.editor()) == null || Ie.failMedia(w, "媒体能力已失效,请删除后重试", J);
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
const we = Bt(
|
|
1421
|
+
z,
|
|
1422
|
+
M,
|
|
1423
|
+
t.capability(M)
|
|
1424
|
+
);
|
|
1425
|
+
if (we) {
|
|
1426
|
+
(re = t.editor()) != null && re.failMedia(w, we.message, J) && t.diagnostic(
|
|
1427
|
+
we.code,
|
|
1428
|
+
we.message,
|
|
1429
|
+
"validation",
|
|
1430
|
+
M
|
|
1431
|
+
);
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
const G = Sn(
|
|
1435
|
+
Y,
|
|
1436
|
+
(_e) => Array.isArray(_e)
|
|
1437
|
+
);
|
|
1438
|
+
if (!G.ok) {
|
|
1439
|
+
(W = t.editor()) != null && W.failMedia(w, G.error.message, J) && t.portDiagnostic(G.error, M);
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
const Pe = Ho(ne, G.data);
|
|
1443
|
+
if (!Pe.ok || Pe.kind !== "updateNode") {
|
|
1444
|
+
(pe = t.editor()) != null && pe.failMedia(w, "媒体扩展返回的节点更新无效", J) && t.diagnostic(
|
|
1445
|
+
"PLUGIN_OPERATION_REJECTED",
|
|
1446
|
+
Pe.ok ? "媒体扩展未返回节点更新" : Pe.reason,
|
|
1447
|
+
"plugin",
|
|
1448
|
+
M
|
|
1449
|
+
);
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
t.applyNodeUpdate(Pe, M) && o.delete(w);
|
|
1453
|
+
} catch (se) {
|
|
1454
|
+
if (!V.signal.aborted) {
|
|
1455
|
+
const Ee = se instanceof Error ? se.message : "上传失败";
|
|
1456
|
+
(ue = t.editor()) != null && ue.failMedia(w, Ee, J) && t.diagnostic("PORT_FAILED", Ee, "port", M);
|
|
1457
|
+
}
|
|
1458
|
+
} finally {
|
|
1459
|
+
ae == null || ae(), E.controller === V && (E.controller = void 0), t.track(V, !1);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
function C(w) {
|
|
1463
|
+
var D, z;
|
|
1464
|
+
const E = o.get(w), r = (D = t.editor()) == null ? void 0 : D.getMediaState(w);
|
|
1465
|
+
!E || E.controller || (r == null ? void 0 : r.status) !== "error" || r.kind !== E.kind || !t.canUse(E.kind) || (z = t.editor()) != null && z.retryMedia(w, r.nodeVersion) && A(w);
|
|
1466
|
+
}
|
|
1467
|
+
return {
|
|
1468
|
+
selectTarget: c,
|
|
1469
|
+
takeTarget: p,
|
|
1470
|
+
clearTarget: v,
|
|
1471
|
+
has: y,
|
|
1472
|
+
removeAbsent: k,
|
|
1473
|
+
classify: T,
|
|
1474
|
+
activeControllers: g,
|
|
1475
|
+
retain: N,
|
|
1476
|
+
enqueue: l,
|
|
1477
|
+
retry: C
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
function Ra(t, o) {
|
|
1481
|
+
var i, c, p;
|
|
1482
|
+
const a = Object.prototype.hasOwnProperty.call(o, t.id) ? o[t.id] : t.defaultValue;
|
|
1483
|
+
if (t.kind === "switch" || t.kind === "checkbox")
|
|
1484
|
+
return a === !0;
|
|
1485
|
+
if (t.kind === "radio") {
|
|
1486
|
+
const v = String(a ?? "");
|
|
1487
|
+
return (i = t.options) != null && i.some((y) => y.value === v) ? v : ((p = (c = t.options) == null ? void 0 : c[0]) == null ? void 0 : p.value) || "";
|
|
1488
|
+
}
|
|
1489
|
+
return String(a ?? "");
|
|
1490
|
+
}
|
|
1491
|
+
function Da(t, o) {
|
|
1492
|
+
var i;
|
|
1493
|
+
const a = new Map(o.fields.map((c) => [c.id, c]));
|
|
1494
|
+
for (const [c, p] of Object.entries(t)) {
|
|
1495
|
+
if (o.toolId === "order_note" && c === "id" && typeof p == "string" && /^rmk_[a-z0-9]{8}$/.test(p))
|
|
1496
|
+
continue;
|
|
1497
|
+
const v = a.get(c);
|
|
1498
|
+
if (!v) return c;
|
|
1499
|
+
if (v.visibleWhen) {
|
|
1500
|
+
const y = a.get(v.visibleWhen.fieldId);
|
|
1501
|
+
if (!y || Ra(y, t) !== v.visibleWhen.equals)
|
|
1502
|
+
return c;
|
|
1503
|
+
}
|
|
1504
|
+
if (v.kind === "switch" || v.kind === "checkbox") {
|
|
1505
|
+
if (typeof p != "boolean") return c;
|
|
1506
|
+
continue;
|
|
1507
|
+
}
|
|
1508
|
+
if (typeof p != "string" || p.trim() !== p || v.kind === "radio" && !((i = v.options) != null && i.some((y) => y.value === p)))
|
|
1509
|
+
return c;
|
|
1510
|
+
}
|
|
1511
|
+
return null;
|
|
1512
|
+
}
|
|
1513
|
+
function La(t) {
|
|
1514
|
+
const o = fn(null), a = fn(null);
|
|
1515
|
+
let i = null;
|
|
1516
|
+
function c() {
|
|
1517
|
+
if (!i) return;
|
|
1518
|
+
const g = i;
|
|
1519
|
+
i = null, g.abort(), t.track(g, !1);
|
|
1520
|
+
}
|
|
1521
|
+
function p() {
|
|
1522
|
+
var g, N;
|
|
1523
|
+
c(), (N = (g = o.value) == null ? void 0 : g.target) == null || N.dispose(), o.value = null, a.value = null;
|
|
1524
|
+
}
|
|
1525
|
+
function v(g, N) {
|
|
1526
|
+
g === N || !o.value || (p(), t.diagnostic(
|
|
1527
|
+
"TOOL_FORM_CHANGED",
|
|
1528
|
+
"工具配置接口已更新,请重新打开",
|
|
1529
|
+
"port"
|
|
1530
|
+
));
|
|
1531
|
+
}
|
|
1532
|
+
async function y(g) {
|
|
1533
|
+
var A, C;
|
|
1534
|
+
if (p(), !t.canUse()) {
|
|
1535
|
+
(A = g.target) == null || A.dispose();
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
const N = t.getPort();
|
|
1539
|
+
if (typeof N != "function") {
|
|
1540
|
+
(C = g.target) == null || C.dispose(), t.diagnostic("PORT_MISSING", "宿主未提供工具配置接口", "port");
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1543
|
+
o.value = g;
|
|
1544
|
+
const l = new AbortController();
|
|
1545
|
+
i = l, t.track(l, !0);
|
|
1546
|
+
try {
|
|
1547
|
+
const w = await N({ toolId: g.key }, t.context(l)), E = t.getScene();
|
|
1548
|
+
if (l.signal.aborted || i !== l || g.sceneKey !== E.sceneKey || g.type !== E.type)
|
|
1549
|
+
return;
|
|
1550
|
+
const r = Sn(
|
|
1551
|
+
w,
|
|
1552
|
+
(D) => $o(g.key, D)
|
|
1553
|
+
);
|
|
1554
|
+
if (!r.ok) {
|
|
1555
|
+
t.portDiagnostic(r.error), p();
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
if (!r.data.permitted) {
|
|
1559
|
+
t.diagnostic("CAPABILITY_REVOKED", "当前无权使用此工具", "config"), p();
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
if (g.nodeId) {
|
|
1563
|
+
const D = Da(
|
|
1564
|
+
g.params,
|
|
1565
|
+
r.data
|
|
1566
|
+
);
|
|
1567
|
+
if (D !== null) {
|
|
1568
|
+
t.diagnostic(
|
|
1569
|
+
"TOOL_PARAMS_UNSUPPORTED",
|
|
1570
|
+
`当前工具表单无法编辑旧参数:${D}`,
|
|
1571
|
+
"validation"
|
|
1572
|
+
), p();
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
a.value = r.data;
|
|
1577
|
+
} catch (w) {
|
|
1578
|
+
l.signal.aborted || (t.diagnostic(
|
|
1579
|
+
"PORT_FAILED",
|
|
1580
|
+
w instanceof Error ? w.message : "工具配置读取失败",
|
|
1581
|
+
"port"
|
|
1582
|
+
), p());
|
|
1583
|
+
} finally {
|
|
1584
|
+
t.track(l, !1), i === l && (i = null);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
async function k(g, N) {
|
|
1588
|
+
if (i || o.value !== g || a.value !== N)
|
|
1589
|
+
return !1;
|
|
1590
|
+
const l = t.getPort();
|
|
1591
|
+
if (typeof l != "function")
|
|
1592
|
+
return t.diagnostic("PORT_MISSING", "宿主未提供工具配置接口", "port"), p(), !1;
|
|
1593
|
+
const A = new AbortController();
|
|
1594
|
+
i = A, t.track(A, !0);
|
|
1595
|
+
try {
|
|
1596
|
+
const C = await l({ toolId: g.key }, t.context(A));
|
|
1597
|
+
if (A.signal.aborted || i !== A || o.value !== g || a.value !== N)
|
|
1598
|
+
return !1;
|
|
1599
|
+
const w = t.getScene();
|
|
1600
|
+
if (g.sceneKey !== w.sceneKey || g.type !== w.type || !t.canUse())
|
|
1601
|
+
return p(), !1;
|
|
1602
|
+
if (t.getPort() !== l)
|
|
1603
|
+
return t.diagnostic(
|
|
1604
|
+
"TOOL_FORM_CHANGED",
|
|
1605
|
+
"工具配置接口已更新,请重新打开",
|
|
1606
|
+
"port"
|
|
1607
|
+
), p(), !1;
|
|
1608
|
+
const E = Sn(
|
|
1609
|
+
C,
|
|
1610
|
+
(r) => $o(g.key, r)
|
|
1611
|
+
);
|
|
1612
|
+
return E.ok ? E.data.permitted ? Tn(E.data.fields) !== Tn(N.fields) ? (t.diagnostic(
|
|
1613
|
+
"TOOL_FORM_CHANGED",
|
|
1614
|
+
"工具配置已更新,请重新打开",
|
|
1615
|
+
"port"
|
|
1616
|
+
), p(), !1) : !0 : (t.diagnostic("CAPABILITY_REVOKED", "当前无权使用此工具", "config"), p(), !1) : (t.portDiagnostic(E.error), !1);
|
|
1617
|
+
} catch (C) {
|
|
1618
|
+
return A.signal.aborted || t.diagnostic(
|
|
1619
|
+
"PORT_FAILED",
|
|
1620
|
+
C instanceof Error ? C.message : "工具配置读取失败",
|
|
1621
|
+
"port"
|
|
1622
|
+
), !1;
|
|
1623
|
+
} finally {
|
|
1624
|
+
t.track(A, !1), i === A && (i = null);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
function T() {
|
|
1628
|
+
o.value = null, a.value = null;
|
|
1629
|
+
}
|
|
1630
|
+
return {
|
|
1631
|
+
edit: o,
|
|
1632
|
+
definition: a,
|
|
1633
|
+
cancel: p,
|
|
1634
|
+
portChanged: v,
|
|
1635
|
+
open: y,
|
|
1636
|
+
recheck: k,
|
|
1637
|
+
releaseForInsert: T
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1640
|
+
function Ka(t, o) {
|
|
1641
|
+
const a = (y, k) => t.some(
|
|
1642
|
+
(T) => T.slot === k && T.canInsert && y.includes(T.id)
|
|
1643
|
+
), i = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new WeakSet(), p = (y) => {
|
|
1644
|
+
if (!y || typeof y != "object") return;
|
|
1645
|
+
const k = y;
|
|
1646
|
+
c.has(k) || (c.add(k), typeof k.type == "string" && i.add(k.type), Array.isArray(k.content) && k.content.forEach(p));
|
|
1647
|
+
};
|
|
1648
|
+
p(o);
|
|
1649
|
+
const v = a(["originalReply"], "knowledgeBlock") || i.has("originalReply");
|
|
1650
|
+
return {
|
|
1651
|
+
businessToken: a(na, "knowledgeInline") || i.has("businessToken"),
|
|
1652
|
+
originalReply: v,
|
|
1653
|
+
// OriginalReply's content expression references both node types.
|
|
1654
|
+
separator: v || i.has("messageSeparator"),
|
|
1655
|
+
mediaBlock: v || a(ea, "knowledgeBlock") || i.has("mediaBlock")
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1658
|
+
function qa(t) {
|
|
1659
|
+
return [
|
|
1660
|
+
t.businessToken,
|
|
1661
|
+
t.originalReply,
|
|
1662
|
+
t.separator,
|
|
1663
|
+
t.mediaBlock
|
|
1664
|
+
].map((o) => o ? "1" : "0").join("");
|
|
1665
|
+
}
|
|
1666
|
+
const Va = { class: "fkp-capability-help-head" }, Ut = /* @__PURE__ */ jt({
|
|
1667
|
+
__name: "CapabilityHelp",
|
|
1668
|
+
props: {
|
|
1669
|
+
capabilityId: {}
|
|
1670
|
+
},
|
|
1671
|
+
emits: ["help"],
|
|
1672
|
+
setup(t, { emit: o }) {
|
|
1673
|
+
const a = t, i = o, c = {
|
|
1674
|
+
originalReply: {
|
|
1675
|
+
title: "原话复述",
|
|
1676
|
+
description: "支持普通知识,开启此标签;或在推理知识的回复话术末尾双引号前添加此标签;各模态命中即自动发送配置的原话术;启用后若用户多次触发将重复发送,可能触发平台风控,请谨慎使用。"
|
|
1677
|
+
},
|
|
1678
|
+
memory: {
|
|
1679
|
+
title: "记忆触发点",
|
|
1680
|
+
description: "顾客消息命中此场景后,系统将刷新记忆画像,供后续AI回复参考"
|
|
1681
|
+
},
|
|
1682
|
+
separator: {
|
|
1683
|
+
title: "分隔符",
|
|
1684
|
+
description: "分隔符前后内容将被分成两条消息发出"
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
return (p, v) => (I(), _("div", {
|
|
1688
|
+
class: Be(["fkp-capability-help", {
|
|
1689
|
+
"fkp-memory-help": a.capabilityId === "memory",
|
|
1690
|
+
"fkp-original-help": a.capabilityId === "originalReply",
|
|
1691
|
+
"fkp-separator-help": a.capabilityId === "separator"
|
|
1692
|
+
}])
|
|
1693
|
+
}, [
|
|
1694
|
+
O("div", Va, [
|
|
1695
|
+
O("strong", null, Z(c[a.capabilityId].title), 1),
|
|
1696
|
+
a.capabilityId !== "separator" ? (I(), fe(b(ee), {
|
|
1697
|
+
key: 0,
|
|
1698
|
+
class: "fkp-capability-help-link",
|
|
1699
|
+
type: "text",
|
|
1700
|
+
onClick: v[0] || (v[0] = (y) => i("help"))
|
|
1701
|
+
}, {
|
|
1702
|
+
default: K(() => [
|
|
1703
|
+
P(b(ke), {
|
|
1704
|
+
name: "book",
|
|
1705
|
+
size: 14
|
|
1706
|
+
}),
|
|
1707
|
+
v[1] || (v[1] = me("我该怎么配? "))
|
|
1708
|
+
]),
|
|
1709
|
+
_: 1
|
|
1710
|
+
})) : U("", !0)
|
|
1711
|
+
]),
|
|
1712
|
+
O("p", null, Z(c[a.capabilityId].description), 1)
|
|
1713
|
+
], 2));
|
|
1714
|
+
}
|
|
1715
|
+
}), $a = { class: "fkp-variable-columns" }, Ba = {
|
|
1716
|
+
class: "fkp-variable-root",
|
|
1717
|
+
"aria-label": "变量分类"
|
|
1718
|
+
}, Ua = {
|
|
1719
|
+
key: 0,
|
|
1720
|
+
class: "fkp-menu-empty"
|
|
1721
|
+
}, Fa = {
|
|
1722
|
+
key: 1,
|
|
1723
|
+
class: "fkp-menu-empty"
|
|
1724
|
+
}, ja = { class: "fkp-variable-label" }, za = { class: "fkp-variable-label" }, Ga = {
|
|
1725
|
+
class: "fkp-variable-children",
|
|
1726
|
+
"aria-label": "分组变量"
|
|
1727
|
+
}, Ja = { class: "fkp-variable-label" }, Wa = /* @__PURE__ */ jt({
|
|
1728
|
+
__name: "VariableOptionList",
|
|
1729
|
+
props: {
|
|
1730
|
+
options: {},
|
|
1731
|
+
loading: { type: Boolean },
|
|
1732
|
+
nextCursor: {},
|
|
1733
|
+
query: {}
|
|
1734
|
+
},
|
|
1735
|
+
emits: ["choose", "loadMore"],
|
|
1736
|
+
setup(t, { emit: o }) {
|
|
1737
|
+
const a = t, i = o;
|
|
1738
|
+
function c(g) {
|
|
1739
|
+
return "group" in g && typeof g.group == "string" ? g.group.trim() : "";
|
|
1740
|
+
}
|
|
1741
|
+
const p = le(() => {
|
|
1742
|
+
const g = [], N = /* @__PURE__ */ new Set();
|
|
1743
|
+
for (const l of a.options) {
|
|
1744
|
+
const A = c(l);
|
|
1745
|
+
A ? N.has(A) || (g.push({ kind: "group", label: A }), N.add(A)) : g.push({ kind: "option", option: l });
|
|
1746
|
+
}
|
|
1747
|
+
return g;
|
|
1748
|
+
}), v = H(""), y = le(
|
|
1749
|
+
() => p.value.flatMap(
|
|
1750
|
+
(g) => g.kind === "group" ? [g.label] : []
|
|
1751
|
+
)
|
|
1752
|
+
), k = le(
|
|
1753
|
+
() => y.value.includes(v.value) ? v.value : y.value[0] || ""
|
|
1754
|
+
), T = le(
|
|
1755
|
+
() => k.value ? a.options.filter((g) => c(g) === k.value) : []
|
|
1756
|
+
);
|
|
1757
|
+
return ye(
|
|
1758
|
+
() => a.query,
|
|
1759
|
+
() => {
|
|
1760
|
+
v.value = "";
|
|
1761
|
+
}
|
|
1762
|
+
), (g, N) => (I(), _("div", $a, [
|
|
1763
|
+
O("div", Ba, [
|
|
1764
|
+
g.loading && !p.value.length ? (I(), _("p", Ua, [
|
|
1765
|
+
P(b(ke), {
|
|
1766
|
+
name: "sync",
|
|
1767
|
+
size: 15,
|
|
1768
|
+
class: "fkp-spin"
|
|
1769
|
+
}),
|
|
1770
|
+
N[1] || (N[1] = me("加载中… "))
|
|
1771
|
+
])) : !g.loading && !p.value.length ? (I(), _("p", Fa, " 暂无可选项 ")) : U("", !0),
|
|
1772
|
+
(I(!0), _(Ne, null, Ye(p.value, (l) => (I(), _(Ne, {
|
|
1773
|
+
key: l.kind === "group" ? `group:${l.label}` : `option:${l.option.id}`
|
|
1774
|
+
}, [
|
|
1775
|
+
l.kind === "group" ? (I(), fe(b(ee), {
|
|
1776
|
+
key: 0,
|
|
1777
|
+
class: "fkp-variable-group",
|
|
1778
|
+
type: "text",
|
|
1779
|
+
"aria-label": l.label,
|
|
1780
|
+
title: l.label,
|
|
1781
|
+
"aria-pressed": k.value === l.label,
|
|
1782
|
+
onMouseenter: (A) => v.value = l.label,
|
|
1783
|
+
onFocus: (A) => v.value = l.label,
|
|
1784
|
+
onClick: (A) => v.value = l.label
|
|
1785
|
+
}, {
|
|
1786
|
+
default: K(() => [
|
|
1787
|
+
O("span", ja, Z(l.label), 1),
|
|
1788
|
+
P(b(ke), {
|
|
1789
|
+
class: "fkp-variable-group-arrow",
|
|
1790
|
+
name: "arrow-down",
|
|
1791
|
+
size: 14
|
|
1792
|
+
})
|
|
1793
|
+
]),
|
|
1794
|
+
_: 2
|
|
1795
|
+
}, 1032, ["aria-label", "title", "aria-pressed", "onMouseenter", "onFocus", "onClick"])) : (I(), fe(b(ee), {
|
|
1796
|
+
key: 1,
|
|
1797
|
+
type: "text",
|
|
1798
|
+
"aria-label": l.option.label,
|
|
1799
|
+
title: l.option.label,
|
|
1800
|
+
disabled: l.option.disabled,
|
|
1801
|
+
onClick: (A) => i("choose", l.option, A)
|
|
1802
|
+
}, {
|
|
1803
|
+
default: K(() => [
|
|
1804
|
+
O("span", za, Z(l.option.label), 1)
|
|
1805
|
+
]),
|
|
1806
|
+
_: 2
|
|
1807
|
+
}, 1032, ["aria-label", "title", "disabled", "onClick"]))
|
|
1808
|
+
], 64))), 128)),
|
|
1809
|
+
g.nextCursor ? (I(), fe(b(ee), {
|
|
1810
|
+
key: 2,
|
|
1811
|
+
class: "fkp-menu-more",
|
|
1812
|
+
type: "text",
|
|
1813
|
+
disabled: g.loading,
|
|
1814
|
+
onClick: N[0] || (N[0] = (l) => i("loadMore"))
|
|
1815
|
+
}, {
|
|
1816
|
+
default: K(() => N[2] || (N[2] = [
|
|
1817
|
+
me("加载更多")
|
|
1818
|
+
])),
|
|
1819
|
+
_: 1
|
|
1820
|
+
}, 8, ["disabled"])) : U("", !0)
|
|
1821
|
+
]),
|
|
1822
|
+
O("div", Ga, [
|
|
1823
|
+
(I(!0), _(Ne, null, Ye(T.value, (l) => (I(), fe(b(ee), {
|
|
1824
|
+
key: l.id,
|
|
1825
|
+
type: "text",
|
|
1826
|
+
"aria-label": l.label,
|
|
1827
|
+
title: l.label,
|
|
1828
|
+
disabled: l.disabled,
|
|
1829
|
+
onClick: (A) => i("choose", l, A)
|
|
1830
|
+
}, {
|
|
1831
|
+
default: K(() => [
|
|
1832
|
+
O("span", Ja, Z(l.label), 1)
|
|
1833
|
+
]),
|
|
1834
|
+
_: 2
|
|
1835
|
+
}, 1032, ["aria-label", "title", "disabled", "onClick"]))), 128))
|
|
1836
|
+
])
|
|
1837
|
+
]));
|
|
1838
|
+
}
|
|
1839
|
+
}), Ha = {
|
|
1840
|
+
key: 0,
|
|
1841
|
+
class: "fkp-type-menu-arrow",
|
|
1842
|
+
"aria-hidden": "true"
|
|
1843
|
+
}, Ya = {
|
|
1844
|
+
key: 1,
|
|
1845
|
+
class: "fkp-menu fkp-type-menu",
|
|
1846
|
+
"aria-label": "选择知识类型"
|
|
1847
|
+
}, Xa = { class: "fkp-type-option-copy" }, Qa = { class: "fkp-type-confirm-message" }, Za = { class: "fkp-type-confirm-actions" }, el = { class: "fkp-toolbar-group" }, nl = ["data-fkp-menu-trigger", "onMouseenter", "onPointerdownCapture"], tl = { key: 0 }, ol = {
|
|
1848
|
+
key: 0,
|
|
1849
|
+
class: "fkp-menu fkp-more-menu"
|
|
1850
|
+
}, il = ["data-fkp-menu-trigger", "onMouseenter", "onPointerdownCapture"], al = {
|
|
1851
|
+
key: 1,
|
|
1852
|
+
class: "fkp-toolbar-right"
|
|
1853
|
+
}, ll = {
|
|
1854
|
+
key: 0,
|
|
1855
|
+
class: "fkp-agent-menu-arrow",
|
|
1856
|
+
"aria-hidden": "true"
|
|
1857
|
+
}, sl = { class: "fkp-menu-head" }, rl = {
|
|
1858
|
+
key: 0,
|
|
1859
|
+
class: "fkp-ticket-heading"
|
|
1860
|
+
}, ul = { key: 1 }, cl = {
|
|
1861
|
+
key: 1,
|
|
1862
|
+
class: "fkp-todo-guidance"
|
|
1863
|
+
}, dl = {
|
|
1864
|
+
key: 2,
|
|
1865
|
+
class: "fkp-ticket-guidance"
|
|
1866
|
+
}, fl = {
|
|
1867
|
+
key: 3,
|
|
1868
|
+
class: "fkp-reference-guidance"
|
|
1869
|
+
}, pl = {
|
|
1870
|
+
key: 4,
|
|
1871
|
+
class: "fkp-tagged-guidance"
|
|
1872
|
+
}, vl = {
|
|
1873
|
+
key: 5,
|
|
1874
|
+
class: "fkp-variable-guidance"
|
|
1875
|
+
}, gl = {
|
|
1876
|
+
key: 6,
|
|
1877
|
+
class: "fkp-agent-guidance"
|
|
1878
|
+
}, yl = {
|
|
1879
|
+
key: 7,
|
|
1880
|
+
class: "fkp-menu-path"
|
|
1881
|
+
}, ml = {
|
|
1882
|
+
key: 9,
|
|
1883
|
+
class: "fkp-option-list"
|
|
1884
|
+
}, kl = {
|
|
1885
|
+
key: 0,
|
|
1886
|
+
class: "fkp-menu-empty"
|
|
1887
|
+
}, bl = {
|
|
1888
|
+
key: 1,
|
|
1889
|
+
class: "fkp-menu-empty"
|
|
1890
|
+
}, hl = { class: "fkp-template-drawer" }, wl = {
|
|
1891
|
+
key: 0,
|
|
1892
|
+
class: "fkp-menu-empty"
|
|
1893
|
+
}, Sl = {
|
|
1894
|
+
key: 1,
|
|
1895
|
+
class: "fkp-menu-empty"
|
|
1896
|
+
}, Al = {
|
|
1897
|
+
key: 0,
|
|
1898
|
+
class: "fkp-template-example"
|
|
1899
|
+
}, Tl = {
|
|
1900
|
+
key: 0,
|
|
1901
|
+
class: "fkp-template-preview"
|
|
1902
|
+
}, Il = {
|
|
1903
|
+
key: 0,
|
|
1904
|
+
class: "fkp-polish-wait",
|
|
1905
|
+
role: "status"
|
|
1906
|
+
}, El = {
|
|
1907
|
+
key: 1,
|
|
1908
|
+
class: "fkp-polish-compare"
|
|
1909
|
+
}, Ol = { class: "fkp-polish-panel fkp-polish-panel--original" }, Nl = { class: "fkp-polish-text" }, Cl = { class: "fkp-polish-panel fkp-polish-panel--proposed" }, _l = { class: "fkp-polish-text" }, Pl = {
|
|
1910
|
+
key: 2,
|
|
1911
|
+
class: "fkp-polish-wait fkp-polish-error",
|
|
1912
|
+
role: "alert"
|
|
1913
|
+
}, xl = { class: "fkp-question-row" }, Ml = {
|
|
1914
|
+
"aria-hidden": "true",
|
|
1915
|
+
class: "fkp-question-measure"
|
|
1916
|
+
}, Rl = {
|
|
1917
|
+
key: 0,
|
|
1918
|
+
class: "fkp-question-tags"
|
|
1919
|
+
}, Dl = { class: "fkp-question-tag-label" }, Ll = { class: "fkp-knowledge-row" }, Kl = {
|
|
1920
|
+
key: 0,
|
|
1921
|
+
class: "fkp-unsupported"
|
|
1922
|
+
}, ql = { class: "fkp-safe-preview" }, Vl = { class: "fkp-safe-preview fkp-safe-state" }, $l = {
|
|
1923
|
+
key: 2,
|
|
1924
|
+
class: "fkp-agent-preview"
|
|
1925
|
+
}, Bl = {
|
|
1926
|
+
key: 0,
|
|
1927
|
+
class: "fkp-agent-preview-name"
|
|
1928
|
+
}, Ul = ["accept"], Fl = `填写不同情况的判断条件和处理规则,例如:
|
|
1929
|
+
1、如果顾客询问要求换货,判断顾客是否提供了要更换的商品信息(例如换成XX):
|
|
1930
|
+
-如果顾客提供了要更换的商品信息,回复:“好的稍等,这边为您备注哦”
|
|
1931
|
+
-如果顾客没有提供要更换的商品信息,回复:“亲,请您提供下需要更换的商品信息” ……`, jl = 2147483647, ns = /* @__PURE__ */ jt({
|
|
1932
|
+
name: "FkpRichText",
|
|
1933
|
+
__name: "FkpRichText",
|
|
1934
|
+
props: {
|
|
1935
|
+
sceneKey: { default: "default" },
|
|
1936
|
+
modelValue: { default: () => Ln() },
|
|
1937
|
+
config: {},
|
|
1938
|
+
policy: {},
|
|
1939
|
+
ports: {},
|
|
1940
|
+
ackRevision: { default: 0 },
|
|
1941
|
+
readonly: { type: Boolean, default: !1 },
|
|
1942
|
+
disabled: { type: Boolean, default: !1 },
|
|
1943
|
+
typeSelectionMode: { default: "switch" }
|
|
1944
|
+
},
|
|
1945
|
+
emits: ["change", "update:modelValue", "diagnostic", "busy-change", "help", "add-scene"],
|
|
1946
|
+
setup(t, { expose: o, emit: a }) {
|
|
1947
|
+
const i = t, c = (e) => JSON.parse(JSON.stringify(e));
|
|
1948
|
+
function p(e) {
|
|
1949
|
+
const n = An(e);
|
|
1950
|
+
if (n !== null)
|
|
1951
|
+
return {
|
|
1952
|
+
scene: Ln(),
|
|
1953
|
+
invalid: { path: n || "modelValue", raw: e }
|
|
1954
|
+
};
|
|
1955
|
+
try {
|
|
1956
|
+
const s = JSON.parse(JSON.stringify(e));
|
|
1957
|
+
if (jo(s)) return { scene: s, invalid: null };
|
|
1958
|
+
const d = et(s) || "modelValue";
|
|
1959
|
+
return { scene: Ln(), invalid: { path: d, raw: s } };
|
|
1960
|
+
} catch {
|
|
1961
|
+
return { scene: Ln(), invalid: { path: "modelValue", raw: e } };
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
function v(e) {
|
|
1965
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return e;
|
|
1966
|
+
try {
|
|
1967
|
+
const { knowledge: n } = e;
|
|
1968
|
+
if (!n || typeof n != "object" || Array.isArray(n))
|
|
1969
|
+
return e;
|
|
1970
|
+
const s = n;
|
|
1971
|
+
return s.doc ?? s.retainedDoc ?? e;
|
|
1972
|
+
} catch {
|
|
1973
|
+
return e;
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
const y = a, k = (e) => e === "originalReply" || e === "memory" || e === "separator", T = No(
|
|
1977
|
+
() => import("./KnowledgeArea-BkRVWFrg.js")
|
|
1978
|
+
), g = No(() => import("./ToolForm-BSJxTJ7U.js")), N = p(i.modelValue), l = H(N.scene), A = fn(N.invalid), C = H(0), w = H([]), E = /* @__PURE__ */ new Map(), r = H(null), D = fn(null), z = H(0), M = H(null), ne = H(null), he = Ca({
|
|
1979
|
+
descriptor: (e) => te.value.capabilities.find(
|
|
1980
|
+
(n) => n.id === e && n.optionKind === "selection"
|
|
1981
|
+
),
|
|
1982
|
+
ports: () => i.ports,
|
|
1983
|
+
context: xn,
|
|
1984
|
+
isCurrent: (e) => r.value === e && De(e, bn(e)),
|
|
1985
|
+
track: (e, n) => {
|
|
1986
|
+
(n || Oe.has(e)) && He(e, "requesting", n);
|
|
1987
|
+
},
|
|
1988
|
+
diagnostic: (e, n, s) => j(e, n, "port", s),
|
|
1989
|
+
portDiagnostic: (e, n) => _n(e, n)
|
|
1990
|
+
}), {
|
|
1991
|
+
query: J,
|
|
1992
|
+
options: oe,
|
|
1993
|
+
path: V,
|
|
1994
|
+
nextCursor: ae,
|
|
1995
|
+
loading: ie,
|
|
1996
|
+
abort: Se,
|
|
1997
|
+
reset: $,
|
|
1998
|
+
enter: F,
|
|
1999
|
+
back: Ie,
|
|
2000
|
+
fetch: re
|
|
2001
|
+
} = he, W = H(!1), pe = H(""), ue = H("idle");
|
|
2002
|
+
function se() {
|
|
2003
|
+
pe.value = "", ue.value = "idle";
|
|
2004
|
+
}
|
|
2005
|
+
const Ee = H(!1), Ce = H({ uploading: 0, requesting: 0 }), tn = H(), Ke = H(), S = H(), x = H(), Y = H(), we = H(Number.MAX_SAFE_INTEGER), G = H(!1);
|
|
2006
|
+
let Pe = !1;
|
|
2007
|
+
const _e = H(null);
|
|
2008
|
+
let xe = !1;
|
|
2009
|
+
ye([r, oe], ([e, n], [s]) => {
|
|
2010
|
+
var d;
|
|
2011
|
+
if (e !== "reasoningTemplate") {
|
|
2012
|
+
xe = !1, _e.value = null;
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
s !== e && (xe = !1), !xe && n.length && (_e.value = ((d = n.find((m) => !m.disabled)) == null ? void 0 : d.id) ?? null, xe = !0);
|
|
2016
|
+
});
|
|
2017
|
+
const qe = La({
|
|
2018
|
+
getPort: () => {
|
|
2019
|
+
var e;
|
|
2020
|
+
return (e = i.ports) == null ? void 0 : e.getToolForm;
|
|
2021
|
+
},
|
|
2022
|
+
getScene: () => ({ sceneKey: i.sceneKey, type: l.value.type }),
|
|
2023
|
+
canUse: () => De("tool", "knowledgeInline"),
|
|
2024
|
+
context: (e) => xn("tool", e),
|
|
2025
|
+
track: (e, n) => {
|
|
2026
|
+
(n || Oe.has(e)) && He(e, "requesting", n);
|
|
2027
|
+
},
|
|
2028
|
+
diagnostic: (e, n, s) => j(e, n, s, "tool"),
|
|
2029
|
+
portDiagnostic: (e) => _n(e, "tool")
|
|
2030
|
+
}), { edit: Xe, definition: In } = qe, ze = qe.cancel, $n = qe.open, on = H("image"), B = H(), Oe = /* @__PURE__ */ new Map(), Bn = /* @__PURE__ */ new Set(), pn = fn(null), Qe = H(!1), an = H("loading"), Ht = H(""), kt = H(""), En = fn(null);
|
|
2031
|
+
function Ge() {
|
|
2032
|
+
var e;
|
|
2033
|
+
(e = gn.get("reasoningPolish:sceneAction")) == null || e.abort(), Qe.value = !1, kt.value = "", En.value = null;
|
|
2034
|
+
}
|
|
2035
|
+
function Yo() {
|
|
2036
|
+
const e = En.value;
|
|
2037
|
+
if (!Qe.value || an.value !== "ready" || !e || e.sceneKey !== i.sceneKey || e.snapshot !== Le(l.value) || Q.value || !Cn.value) {
|
|
2038
|
+
Ge();
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
e.apply(), Ge();
|
|
2042
|
+
}
|
|
2043
|
+
ye(
|
|
2044
|
+
() => Qe.value ? [i.sceneKey, Le(l.value), Q.value] : null,
|
|
2045
|
+
() => {
|
|
2046
|
+
Qe.value && (kt.value !== Le(l.value) || Q.value) && Ge();
|
|
2047
|
+
},
|
|
2048
|
+
{ flush: "sync" }
|
|
2049
|
+
), ye(r, (e) => {
|
|
2050
|
+
e !== "reasoningTemplate" && (pn.value = null);
|
|
2051
|
+
});
|
|
2052
|
+
const Me = Ma({
|
|
2053
|
+
editor: () => B.value,
|
|
2054
|
+
capability: (e) => te.value.capabilities.find(
|
|
2055
|
+
(n) => n.id === e && n.slot === "knowledgeBlock"
|
|
2056
|
+
),
|
|
2057
|
+
canUse: (e) => De(e, "knowledgeBlock"),
|
|
2058
|
+
scene: () => ({
|
|
2059
|
+
scene: l.value,
|
|
2060
|
+
sceneKey: i.sceneKey,
|
|
2061
|
+
revision: C.value
|
|
2062
|
+
}),
|
|
2063
|
+
sceneKey: () => i.sceneKey,
|
|
2064
|
+
ports: () => i.ports,
|
|
2065
|
+
context: xn,
|
|
2066
|
+
track: (e, n) => {
|
|
2067
|
+
(n || Oe.has(e)) && He(e, "uploading", n);
|
|
2068
|
+
},
|
|
2069
|
+
diagnostic: j,
|
|
2070
|
+
portDiagnostic: _n,
|
|
2071
|
+
notify: (e, n) => {
|
|
2072
|
+
Po[e]({ content: n, position: "top" });
|
|
2073
|
+
},
|
|
2074
|
+
applyNodeUpdate: (e, n) => {
|
|
2075
|
+
var s;
|
|
2076
|
+
Pn = n;
|
|
2077
|
+
try {
|
|
2078
|
+
return ((s = B.value) == null ? void 0 : s.applyNodeUpdate(e, n)) || !1;
|
|
2079
|
+
} finally {
|
|
2080
|
+
Pn = null;
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
let Ze = null, On = null, ln = null;
|
|
2085
|
+
const vn = /* @__PURE__ */ new Set(), Nn = /* @__PURE__ */ new Set(), gn = /* @__PURE__ */ new Map();
|
|
2086
|
+
let Xo = 0, yn = null, Je, ce = !1, en = null, Re = null, nn = null;
|
|
2087
|
+
const Un = {
|
|
2088
|
+
todo: "Followup",
|
|
2089
|
+
ticket: "AI-ticket",
|
|
2090
|
+
original: "quote",
|
|
2091
|
+
memory: "memory",
|
|
2092
|
+
tag: "tag",
|
|
2093
|
+
variable: "variate",
|
|
2094
|
+
image: "pic",
|
|
2095
|
+
video: "video2",
|
|
2096
|
+
separator: "sep",
|
|
2097
|
+
attribute: "data",
|
|
2098
|
+
tool: "tool",
|
|
2099
|
+
agent: "Agent",
|
|
2100
|
+
polish: "AI",
|
|
2101
|
+
template: "tabs"
|
|
2102
|
+
}, Yt = {
|
|
2103
|
+
normal: "常规知识",
|
|
2104
|
+
reasoning: "推理知识",
|
|
2105
|
+
agent: "Agent 知识"
|
|
2106
|
+
}, Qo = {
|
|
2107
|
+
normal: "填写可直接用于回复顾客的知识内容,命中后 AI 将参考内容生成回复。",
|
|
2108
|
+
reasoning: "填写不同情况的判断条件和处理规则,命中后 AI 将先判断,再按对应规则回复。",
|
|
2109
|
+
agent: "引用已配置的自定义 Agent,命中后 AI 将按照该 Agent 的提示词和步骤执行。"
|
|
2110
|
+
}, Xt = {
|
|
2111
|
+
normal: "regular",
|
|
2112
|
+
reasoning: "thinking",
|
|
2113
|
+
agent: "robot"
|
|
2114
|
+
}, ot = H(Date.now());
|
|
2115
|
+
let Fn;
|
|
2116
|
+
function Qt() {
|
|
2117
|
+
var n, s, d;
|
|
2118
|
+
Fn && clearTimeout(Fn), ot.value = Date.now();
|
|
2119
|
+
const e = [
|
|
2120
|
+
(n = i.policy) == null ? void 0 : n.expiresAt,
|
|
2121
|
+
((d = (s = i.config) == null ? void 0 : s.remote) == null ? void 0 : d.status) === "ready" ? i.config.remote.expiresAt : void 0
|
|
2122
|
+
].filter(
|
|
2123
|
+
(m) => typeof m == "number" && m > ot.value
|
|
2124
|
+
);
|
|
2125
|
+
e.length && (Fn = setTimeout(
|
|
2126
|
+
Qt,
|
|
2127
|
+
Math.min(Math.min(...e) - ot.value + 1, jl)
|
|
2128
|
+
));
|
|
2129
|
+
}
|
|
2130
|
+
ye(
|
|
2131
|
+
() => {
|
|
2132
|
+
var e, n, s;
|
|
2133
|
+
return [
|
|
2134
|
+
(e = i.policy) == null ? void 0 : e.expiresAt,
|
|
2135
|
+
((s = (n = i.config) == null ? void 0 : n.remote) == null ? void 0 : s.status) === "ready" ? i.config.remote.expiresAt : void 0
|
|
2136
|
+
];
|
|
2137
|
+
},
|
|
2138
|
+
Qt,
|
|
2139
|
+
{ immediate: !0 }
|
|
2140
|
+
);
|
|
2141
|
+
const te = le(
|
|
2142
|
+
() => Zn(l.value.type, i, ot.value)
|
|
2143
|
+
), Zt = le(
|
|
2144
|
+
() => Ka(te.value.capabilities, l.value.knowledge.doc)
|
|
2145
|
+
), eo = le(
|
|
2146
|
+
() => qa(Zt.value)
|
|
2147
|
+
);
|
|
2148
|
+
ye(
|
|
2149
|
+
() => [i.sceneKey, l.value.type, eo.value],
|
|
2150
|
+
(e, n) => {
|
|
2151
|
+
var d;
|
|
2152
|
+
if (Ee.value = !1, !n || e[0] !== n[0] || e[1] !== n[1] || e[2] === n[2])
|
|
2153
|
+
return;
|
|
2154
|
+
const s = (d = B.value) == null ? void 0 : d.captureSelection();
|
|
2155
|
+
Yn(), rt(), Me.clearTarget(), vn.forEach((m) => m.dispose()), vn.clear(), Nn.forEach((m) => m.abort()), Nn.clear(), gn.clear(), s && Fe(() => {
|
|
2156
|
+
var m;
|
|
2157
|
+
return (m = B.value) == null ? void 0 : m.restoreSelection(s);
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
);
|
|
2161
|
+
const jn = le(
|
|
2162
|
+
() => {
|
|
2163
|
+
var e;
|
|
2164
|
+
return ((e = A.value) == null ? void 0 : e.path) || et(l.value);
|
|
2165
|
+
}
|
|
2166
|
+
), Zo = le(
|
|
2167
|
+
() => qt(
|
|
2168
|
+
A.value ? v(A.value.raw) : l.value.knowledge.doc || l.value.knowledge.retainedDoc
|
|
2169
|
+
)
|
|
2170
|
+
), no = le(() => {
|
|
2171
|
+
var e;
|
|
2172
|
+
if (A.value || !((e = jn.value) != null && e.startsWith("extensionState")))
|
|
2173
|
+
return null;
|
|
2174
|
+
try {
|
|
2175
|
+
return JSON.stringify(l.value.extensionState, null, 2);
|
|
2176
|
+
} catch {
|
|
2177
|
+
return "扩展状态无法安全预览;原始数据仍保留。";
|
|
2178
|
+
}
|
|
2179
|
+
}), Q = le(
|
|
2180
|
+
() => te.value.mode === "readonly" || !!jn.value || Ee.value
|
|
2181
|
+
), bt = le(
|
|
2182
|
+
() => te.value.capabilities.filter(
|
|
2183
|
+
(e) => e.slot === "questionAction" && e.visible
|
|
2184
|
+
)
|
|
2185
|
+
), ht = le(
|
|
2186
|
+
() => te.value.capabilities.filter(
|
|
2187
|
+
(e) => (e.slot === "knowledgeInline" || e.slot === "knowledgeBlock") && e.visible
|
|
2188
|
+
)
|
|
2189
|
+
), it = le(
|
|
2190
|
+
() => te.value.capabilities.filter(
|
|
2191
|
+
(e) => e.slot === "sceneAction" && e.visible
|
|
2192
|
+
)
|
|
2193
|
+
), to = le(() => {
|
|
2194
|
+
const e = [];
|
|
2195
|
+
let n = 0;
|
|
2196
|
+
const s = (d, m, u, f = !1) => {
|
|
2197
|
+
u.length && e.push({
|
|
2198
|
+
key: d,
|
|
2199
|
+
actions: u.map((h) => ({
|
|
2200
|
+
key: `${h.id}:${h.slot}`,
|
|
2201
|
+
kind: m,
|
|
2202
|
+
index: n++,
|
|
2203
|
+
item: h,
|
|
2204
|
+
showLabel: f
|
|
2205
|
+
}))
|
|
2206
|
+
});
|
|
2207
|
+
};
|
|
2208
|
+
return l.value.type === "normal" ? (s("questions", "question", bt.value), s("insert", "knowledge", ht.value)) : (l.value.type === "reasoning" && (s(
|
|
2209
|
+
"references",
|
|
2210
|
+
"knowledge",
|
|
2211
|
+
ht.value.filter((d) => d.order <= 40),
|
|
2212
|
+
!0
|
|
2213
|
+
), s(
|
|
2214
|
+
"media",
|
|
2215
|
+
"knowledge",
|
|
2216
|
+
ht.value.filter((d) => d.order > 40)
|
|
2217
|
+
)), s("questions", "question", bt.value)), e;
|
|
2218
|
+
}), wt = le(() => l.value.type === "reasoning" ? it.value.map((e, n) => ({
|
|
2219
|
+
key: `${e.id}:${e.slot}`,
|
|
2220
|
+
kind: "scene",
|
|
2221
|
+
index: n,
|
|
2222
|
+
item: e
|
|
2223
|
+
})) : l.value.type === "agent" ? [{ key: "agentOpen", kind: "agentOpen", index: 0 }] : []), St = le(
|
|
2224
|
+
() => to.value.flatMap((e) => e.actions)
|
|
2225
|
+
), At = le(
|
|
2226
|
+
() => St.value.slice(we.value)
|
|
2227
|
+
);
|
|
2228
|
+
let zn, oo = 0;
|
|
2229
|
+
function io() {
|
|
2230
|
+
at(), ao();
|
|
2231
|
+
}
|
|
2232
|
+
function ao() {
|
|
2233
|
+
var s;
|
|
2234
|
+
const e = (s = Ke.value) == null ? void 0 : s.getBoundingClientRect();
|
|
2235
|
+
if (!e) return;
|
|
2236
|
+
const n = Math.min(320, window.innerWidth - 24);
|
|
2237
|
+
z.value = Math.max(
|
|
2238
|
+
12 - e.left,
|
|
2239
|
+
Math.min(0, window.innerWidth - 12 - e.left - n)
|
|
2240
|
+
);
|
|
2241
|
+
}
|
|
2242
|
+
async function at() {
|
|
2243
|
+
const e = ++oo;
|
|
2244
|
+
we.value = St.value.length, await Fe();
|
|
2245
|
+
const n = x.value;
|
|
2246
|
+
if (n) {
|
|
2247
|
+
for (; e === oo && (n.scrollWidth > n.clientWidth || Y.value !== void 0 && Y.value.scrollWidth > Y.value.clientWidth) && we.value > 0; )
|
|
2248
|
+
we.value--, await Fe();
|
|
2249
|
+
At.value.length || (G.value = !1);
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
let lt;
|
|
2253
|
+
Vi(() => {
|
|
2254
|
+
lt = va(), window.addEventListener("resize", io), document.addEventListener("click", yo), typeof ResizeObserver < "u" && (zn = new ResizeObserver(() => void at()), x.value && zn.observe(x.value)), at();
|
|
2255
|
+
}), ye(
|
|
2256
|
+
() => {
|
|
2257
|
+
var e;
|
|
2258
|
+
return [...St.value, ...wt.value].map((n) => {
|
|
2259
|
+
var s;
|
|
2260
|
+
return `${n.key}:${((s = n.item) == null ? void 0 : s.label) || ""}`;
|
|
2261
|
+
}).concat(((e = l.value.knowledge.agentRef) == null ? void 0 : e.name) || "").join("|");
|
|
2262
|
+
},
|
|
2263
|
+
() => void at()
|
|
2264
|
+
);
|
|
2265
|
+
function Gn(e, n) {
|
|
2266
|
+
e.kind === "knowledge" && e.item && (n == null ? void 0 : n.currentTarget) instanceof Element && n.currentTarget.closest(".fkp-more-menu") && ut(e.item), G.value = !1, e.kind === "agentOpen" ? Di() : e.item && (e.kind === "question" ? mn(e.item.id) ? Xn(e.item, n) : Ot(e.item) : Xn(e.item, n));
|
|
2267
|
+
}
|
|
2268
|
+
function lo(e) {
|
|
2269
|
+
Ve(e) && ut(e);
|
|
2270
|
+
}
|
|
2271
|
+
function ei(e, n) {
|
|
2272
|
+
e.item && (e.kind === "question" ? It(e.item, n) : e.kind === "knowledge" && lo(e.item));
|
|
2273
|
+
}
|
|
2274
|
+
function so(e, n, s) {
|
|
2275
|
+
const d = te.value.capabilities.find(
|
|
2276
|
+
(m) => m.id === e && m.slot === "questionAction"
|
|
2277
|
+
);
|
|
2278
|
+
d && (s ? Qn(d, n) : Xn(d, n));
|
|
2279
|
+
}
|
|
2280
|
+
function ni(e, n) {
|
|
2281
|
+
const s = te.value.capabilities.find(
|
|
2282
|
+
(d) => d.id === e && d.slot === "questionAction"
|
|
2283
|
+
);
|
|
2284
|
+
s && It(s, n);
|
|
2285
|
+
}
|
|
2286
|
+
const We = le(() => l.value.knowledge.agentRef), Cn = le(
|
|
2287
|
+
() => ua(l.value.knowledge.doc)
|
|
2288
|
+
);
|
|
2289
|
+
function mn(e) {
|
|
2290
|
+
return e === "todo" || e === "tagged";
|
|
2291
|
+
}
|
|
2292
|
+
function Jn(e) {
|
|
2293
|
+
return te.value.capabilities.some(
|
|
2294
|
+
(n) => n.id === e && n.optionKind === "selection" && n.optionTrigger === "hover"
|
|
2295
|
+
);
|
|
2296
|
+
}
|
|
2297
|
+
const Tt = (e) => ta(l.value, e), ro = le(() => {
|
|
2298
|
+
const e = [], n = te.value.capabilities.filter((s) => s.slot === "questionAction").sort((s, d) => s.order - d.order);
|
|
2299
|
+
for (const s of n) {
|
|
2300
|
+
const d = s.questionTag;
|
|
2301
|
+
if (!d || !kn(s.id) || !mn(s.id)) continue;
|
|
2302
|
+
const m = Tt(s.id);
|
|
2303
|
+
m && e.push({
|
|
2304
|
+
id: s.id,
|
|
2305
|
+
kind: d.kind,
|
|
2306
|
+
label: m.label,
|
|
2307
|
+
icon: s.icon
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
return e;
|
|
2311
|
+
}), uo = le(
|
|
2312
|
+
() => {
|
|
2313
|
+
var e;
|
|
2314
|
+
return (r.value === "todo" ? "待办标签" : r.value === "tagged" ? "顾客标签" : r.value === "agentSelect" ? "自定义Agent" : void 0) || ((e = te.value.capabilities.find((n) => n.id === r.value)) == null ? void 0 : e.label) || "选择内容";
|
|
2315
|
+
}
|
|
2316
|
+
), ti = le(() => {
|
|
2317
|
+
var n, s;
|
|
2318
|
+
const e = (n = te.value.capabilities.find(
|
|
2319
|
+
(d) => d.id === on.value && d.slot === "knowledgeBlock"
|
|
2320
|
+
)) == null ? void 0 : n.options;
|
|
2321
|
+
return e && "mimeTypes" in e && ((s = e.mimeTypes) != null && s.length) ? e.mimeTypes.filter(
|
|
2322
|
+
(d) => qo[on.value].includes(d)
|
|
2323
|
+
).join(",") : qo[on.value].join(",");
|
|
2324
|
+
});
|
|
2325
|
+
ye(
|
|
2326
|
+
() => i.sceneKey,
|
|
2327
|
+
() => {
|
|
2328
|
+
Ge(), D.value = null, un();
|
|
2329
|
+
const e = p(i.modelValue);
|
|
2330
|
+
l.value = e.scene, A.value = e.invalid, C.value = 0, E.clear(), w.value = [], se(), W.value = !1;
|
|
2331
|
+
}
|
|
2332
|
+
), ye(
|
|
2333
|
+
() => p(i.modelValue),
|
|
2334
|
+
(e) => {
|
|
2335
|
+
if (e.invalid) {
|
|
2336
|
+
Ge(), D.value = null, un(), A.value = e.invalid, E.clear(), w.value = [];
|
|
2337
|
+
return;
|
|
2338
|
+
}
|
|
2339
|
+
const n = Le(e.scene);
|
|
2340
|
+
if (A.value) {
|
|
2341
|
+
Ge(), un(), l.value = e.scene, A.value = null, E.clear(), w.value = [], se(), W.value = !1;
|
|
2342
|
+
return;
|
|
2343
|
+
}
|
|
2344
|
+
if (n === Le(l.value) || i.ackRevision > 0 && E.get(i.ackRevision) === n)
|
|
2345
|
+
return;
|
|
2346
|
+
if (i.ackRevision < C.value && C.value > 0) {
|
|
2347
|
+
j(
|
|
2348
|
+
"STALE_EXTERNAL_VALUE",
|
|
2349
|
+
"外部更新与当前编辑冲突,已保留当前草稿",
|
|
2350
|
+
"validation"
|
|
2351
|
+
);
|
|
2352
|
+
return;
|
|
2353
|
+
}
|
|
2354
|
+
const s = l.value.type !== e.scene.type, d = s ? void 0 : Ai(e.scene);
|
|
2355
|
+
if (un(d), Ge(), D.value = null, l.value = e.scene, E.clear(), w.value = [], se(), s && (W.value = !1), d != null && d.markFailed.length) {
|
|
2356
|
+
const { sceneKey: m } = i;
|
|
2357
|
+
Fe(() => {
|
|
2358
|
+
var u, f, h;
|
|
2359
|
+
if (!(m !== i.sceneKey || l.value.id !== e.scene.id || l.value.type !== e.scene.type))
|
|
2360
|
+
for (const { id: R, nodeVersion: L } of d.markFailed)
|
|
2361
|
+
Me.has(R) && ((f = (u = B.value) == null ? void 0 : u.getMediaState(R)) == null ? void 0 : f.status) === "uploading" && ((h = B.value) == null || h.failMedia(
|
|
2362
|
+
R,
|
|
2363
|
+
"媒体占位已被外部更新,请重试上传",
|
|
2364
|
+
L
|
|
2365
|
+
));
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
), ye(
|
|
2370
|
+
() => te.value.diagnostics,
|
|
2371
|
+
(e) => e.forEach(
|
|
2372
|
+
(n) => y("diagnostic", { ...n, sceneKey: i.sceneKey })
|
|
2373
|
+
),
|
|
2374
|
+
{ immediate: !0 }
|
|
2375
|
+
), ye(
|
|
2376
|
+
jn,
|
|
2377
|
+
(e) => {
|
|
2378
|
+
e && y("diagnostic", {
|
|
2379
|
+
code: "UNSUPPORTED_CONTENT",
|
|
2380
|
+
severity: "error",
|
|
2381
|
+
source: "migration",
|
|
2382
|
+
message: "文档包含当前版本不认识的内容,已进入只读保护",
|
|
2383
|
+
sceneKey: i.sceneKey,
|
|
2384
|
+
path: e
|
|
2385
|
+
});
|
|
2386
|
+
},
|
|
2387
|
+
{ immediate: !0 }
|
|
2388
|
+
);
|
|
2389
|
+
function j(e, n, s, d) {
|
|
2390
|
+
y("diagnostic", {
|
|
2391
|
+
code: e,
|
|
2392
|
+
message: n,
|
|
2393
|
+
source: s,
|
|
2394
|
+
capabilityId: d,
|
|
2395
|
+
sceneKey: i.sceneKey,
|
|
2396
|
+
severity: "warning"
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
2399
|
+
function _n(e, n, s = "port") {
|
|
2400
|
+
if (e.code !== "ABORTED") {
|
|
2401
|
+
y("diagnostic", {
|
|
2402
|
+
code: e.code,
|
|
2403
|
+
message: e.message,
|
|
2404
|
+
source: s,
|
|
2405
|
+
severity: "warning",
|
|
2406
|
+
capabilityId: n,
|
|
2407
|
+
sceneKey: i.sceneKey,
|
|
2408
|
+
retryable: e.retryable
|
|
2409
|
+
});
|
|
2410
|
+
for (const d of e.issues || [])
|
|
2411
|
+
y("diagnostic", {
|
|
2412
|
+
...d,
|
|
2413
|
+
sceneKey: i.sceneKey,
|
|
2414
|
+
capabilityId: d.capabilityId || n,
|
|
2415
|
+
retryable: d.retryable ?? e.retryable
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
function sn(e, n, s) {
|
|
2420
|
+
if (Q.value || Zn(l.value.type, i).mode === "readonly" || et(e))
|
|
2421
|
+
return !1;
|
|
2422
|
+
D.value = null;
|
|
2423
|
+
const d = n === "typeSwitch" ? c(l.value) : null;
|
|
2424
|
+
l.value = e, d ? w.value = [
|
|
2425
|
+
...w.value.slice(-19),
|
|
2426
|
+
d
|
|
2427
|
+
] : n !== "undo" && (w.value = []);
|
|
2428
|
+
const m = {
|
|
2429
|
+
sceneKey: i.sceneKey,
|
|
2430
|
+
revision: ++C.value,
|
|
2431
|
+
origin: n,
|
|
2432
|
+
capabilityId: s
|
|
2433
|
+
};
|
|
2434
|
+
return E.set(m.revision, Le(e)), E.size > 32 && E.delete(E.keys().next().value), y("change", e, m), y("update:modelValue", e), !0;
|
|
2435
|
+
}
|
|
2436
|
+
function co(e, n) {
|
|
2437
|
+
const { sceneKey: s } = i, d = Le(l.value), m = Lt.confirm({
|
|
2438
|
+
title: "确认操作",
|
|
2439
|
+
content: e,
|
|
2440
|
+
onOk: () => {
|
|
2441
|
+
Bn.delete(m), !(i.sceneKey !== s || Le(l.value) !== d || Q.value) && n();
|
|
2442
|
+
},
|
|
2443
|
+
onClose: () => Bn.delete(m)
|
|
2444
|
+
});
|
|
2445
|
+
Bn.add(m);
|
|
2446
|
+
}
|
|
2447
|
+
function fo(e, n, s) {
|
|
2448
|
+
pn.value = {
|
|
2449
|
+
optionId: e,
|
|
2450
|
+
sceneKey: i.sceneKey,
|
|
2451
|
+
snapshot: Le(l.value),
|
|
2452
|
+
content: n,
|
|
2453
|
+
apply: s
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
function st() {
|
|
2457
|
+
pn.value = null;
|
|
2458
|
+
}
|
|
2459
|
+
function oi() {
|
|
2460
|
+
const e = pn.value;
|
|
2461
|
+
pn.value = null, !(!e || r.value !== "reasoningTemplate" || i.sceneKey !== e.sceneKey || Le(l.value) !== e.snapshot || Q.value) && e.apply();
|
|
2462
|
+
}
|
|
2463
|
+
function ii(e) {
|
|
2464
|
+
sn(
|
|
2465
|
+
{ ...l.value, question: { text: e.replace(/[\r\n]+/g, " ") } },
|
|
2466
|
+
"user"
|
|
2467
|
+
);
|
|
2468
|
+
}
|
|
2469
|
+
function ai() {
|
|
2470
|
+
W.value = !1, go(), en = null, nn = null;
|
|
2471
|
+
}
|
|
2472
|
+
function li(e) {
|
|
2473
|
+
var d;
|
|
2474
|
+
if (Q.value || e.target instanceof HTMLTextAreaElement) return;
|
|
2475
|
+
const n = (d = S.value) == null ? void 0 : d.querySelector(
|
|
2476
|
+
'[aria-label="顾客问法"]'
|
|
2477
|
+
);
|
|
2478
|
+
if (!n) return;
|
|
2479
|
+
n.focus();
|
|
2480
|
+
const s = n.value.length;
|
|
2481
|
+
n.setSelectionRange(s, s);
|
|
2482
|
+
}
|
|
2483
|
+
function si(e) {
|
|
2484
|
+
const n = e.target;
|
|
2485
|
+
n instanceof HTMLTextAreaElement && (en = {
|
|
2486
|
+
sceneKey: i.sceneKey,
|
|
2487
|
+
from: n.selectionStart,
|
|
2488
|
+
to: n.selectionEnd,
|
|
2489
|
+
next: e.relatedTarget
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
function It(e, n) {
|
|
2493
|
+
var d;
|
|
2494
|
+
const s = (d = S.value) == null ? void 0 : d.querySelector(
|
|
2495
|
+
'[aria-label="顾客问法"]'
|
|
2496
|
+
);
|
|
2497
|
+
s && document.activeElement === s && Et(e, n);
|
|
2498
|
+
}
|
|
2499
|
+
function po() {
|
|
2500
|
+
var n, s;
|
|
2501
|
+
rt(), W.value && (ln = ((n = B.value) == null ? void 0 : n.captureMediaTarget()) || null);
|
|
2502
|
+
const e = (s = S.value) == null ? void 0 : s.querySelector(
|
|
2503
|
+
'[aria-label="顾客问法"]'
|
|
2504
|
+
);
|
|
2505
|
+
e && document.activeElement === e && (nn = {
|
|
2506
|
+
sceneKey: i.sceneKey,
|
|
2507
|
+
from: e.selectionStart,
|
|
2508
|
+
to: e.selectionEnd
|
|
2509
|
+
});
|
|
2510
|
+
}
|
|
2511
|
+
function Et(e, n) {
|
|
2512
|
+
var u;
|
|
2513
|
+
if (e.slot !== "questionAction" || !mn(e.id)) {
|
|
2514
|
+
Re = null;
|
|
2515
|
+
return;
|
|
2516
|
+
}
|
|
2517
|
+
const s = (u = S.value) == null ? void 0 : u.querySelector(
|
|
2518
|
+
'[aria-label="顾客问法"]'
|
|
2519
|
+
), d = (n == null ? void 0 : n.currentTarget) instanceof Element ? !!n.currentTarget.closest(".fkp-more-menu") : !!(Re != null && Re.fromMore);
|
|
2520
|
+
let m = null;
|
|
2521
|
+
if (s && document.activeElement === s)
|
|
2522
|
+
m = {
|
|
2523
|
+
sceneKey: i.sceneKey,
|
|
2524
|
+
from: s.selectionStart,
|
|
2525
|
+
to: s.selectionEnd
|
|
2526
|
+
};
|
|
2527
|
+
else if ((en == null ? void 0 : en.sceneKey) === i.sceneKey) {
|
|
2528
|
+
const { next: f } = en, h = n == null ? void 0 : n.currentTarget;
|
|
2529
|
+
f instanceof Element && (h instanceof Node ? h === f || h.contains(f) || f.contains(h) || d && f.closest('[data-fkp-menu-trigger="more"]') : f.closest(`[data-fkp-menu-trigger="${e.id}"]`)) && (m = en);
|
|
2530
|
+
}
|
|
2531
|
+
!m && (n == null ? void 0 : n.currentTarget) instanceof Element && n.currentTarget.closest(".fkp-more-menu") && (nn == null ? void 0 : nn.sceneKey) === i.sceneKey && (m = nn), !m && (Re == null ? void 0 : Re.sceneKey) === i.sceneKey && Re.capabilityId === e.id && (m = Re), Re = m ? { ...m, capabilityId: e.id, fromMore: d } : null, en = null, nn = null;
|
|
2532
|
+
}
|
|
2533
|
+
ye(r, (e) => {
|
|
2534
|
+
var n;
|
|
2535
|
+
e || (Re = null), e !== ((n = M.value) == null ? void 0 : n.kind) && (M.value = null);
|
|
2536
|
+
}), ye(G, (e) => {
|
|
2537
|
+
e || (Pe = !1, nn = null, rt());
|
|
2538
|
+
});
|
|
2539
|
+
function ri() {
|
|
2540
|
+
G.value || (po(), Pe = !0, G.value = !0, r.value = null);
|
|
2541
|
+
}
|
|
2542
|
+
function ui() {
|
|
2543
|
+
if (G.value && Pe) {
|
|
2544
|
+
Pe = !1;
|
|
2545
|
+
return;
|
|
2546
|
+
}
|
|
2547
|
+
Pe = !1, G.value = !G.value, r.value = null;
|
|
2548
|
+
}
|
|
2549
|
+
function ci() {
|
|
2550
|
+
Pe && (G.value = !1);
|
|
2551
|
+
}
|
|
2552
|
+
async function di(e, n) {
|
|
2553
|
+
var m;
|
|
2554
|
+
if (!e || e.capabilityId !== n || e.sceneKey !== i.sceneKey)
|
|
2555
|
+
return;
|
|
2556
|
+
await Fe();
|
|
2557
|
+
const s = (m = S.value) == null ? void 0 : m.querySelector(
|
|
2558
|
+
'[aria-label="顾客问法"]'
|
|
2559
|
+
);
|
|
2560
|
+
if (!s || s.disabled) return;
|
|
2561
|
+
const d = document.activeElement;
|
|
2562
|
+
d !== s && d !== document.body && !(d instanceof Element && (d.closest(".fkp-option-menu") || d.closest(`[data-fkp-menu-trigger="${n}"]`) || e.fromMore && d.closest('[data-fkp-menu-trigger="more"]'))) || (s.focus(), s.setSelectionRange(e.from, e.to));
|
|
2563
|
+
}
|
|
2564
|
+
function Wn(e, n = "user", s, d = l.value.extensionState, m) {
|
|
2565
|
+
var L, de;
|
|
2566
|
+
const u = Do(
|
|
2567
|
+
l.value.knowledge.doc,
|
|
2568
|
+
e,
|
|
2569
|
+
te.value.capabilities
|
|
2570
|
+
);
|
|
2571
|
+
if (u) {
|
|
2572
|
+
j(
|
|
2573
|
+
"CAPABILITY_REVOKED",
|
|
2574
|
+
"此能力当前不可插入新内容",
|
|
2575
|
+
"config",
|
|
2576
|
+
u.id
|
|
2577
|
+
), (L = B.value) == null || L.restoreDoc(l.value.knowledge.doc || wn());
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
if (!sn(
|
|
2581
|
+
{
|
|
2582
|
+
...l.value,
|
|
2583
|
+
question: m === void 0 ? l.value.question : { text: m },
|
|
2584
|
+
knowledge: { ...l.value.knowledge, doc: e },
|
|
2585
|
+
extensionState: d
|
|
2586
|
+
},
|
|
2587
|
+
n,
|
|
2588
|
+
s
|
|
2589
|
+
)) {
|
|
2590
|
+
(de = B.value) == null || de.restoreDoc(l.value.knowledge.doc || wn());
|
|
2591
|
+
return;
|
|
2592
|
+
}
|
|
2593
|
+
const h = /* @__PURE__ */ new Set(), R = (q) => {
|
|
2594
|
+
var X, Ae;
|
|
2595
|
+
q.type === "mediaBlock" && typeof ((X = q.attrs) == null ? void 0 : X.id) == "string" && h.add(q.attrs.id), (Ae = q.content) == null || Ae.forEach(R);
|
|
2596
|
+
};
|
|
2597
|
+
R(e), Me.removeAbsent(h);
|
|
2598
|
+
}
|
|
2599
|
+
let Pn = null;
|
|
2600
|
+
function fi(e) {
|
|
2601
|
+
Wn(
|
|
2602
|
+
e,
|
|
2603
|
+
Pn ? "plugin" : "user",
|
|
2604
|
+
Pn || void 0
|
|
2605
|
+
);
|
|
2606
|
+
}
|
|
2607
|
+
function vo(e, n, s = l.value.extensionState, d) {
|
|
2608
|
+
const m = {
|
|
2609
|
+
...l.value,
|
|
2610
|
+
question: d === void 0 ? l.value.question : { text: d },
|
|
2611
|
+
knowledge: { ...l.value.knowledge, doc: e },
|
|
2612
|
+
extensionState: s
|
|
2613
|
+
};
|
|
2614
|
+
return et(m) || Do(
|
|
2615
|
+
l.value.knowledge.doc,
|
|
2616
|
+
e,
|
|
2617
|
+
te.value.capabilities
|
|
2618
|
+
) ? (j(
|
|
2619
|
+
"INVALID_RESPONSE",
|
|
2620
|
+
"接口返回的文档包含当前场景不可用的内容",
|
|
2621
|
+
"port",
|
|
2622
|
+
n
|
|
2623
|
+
), !1) : !0;
|
|
2624
|
+
}
|
|
2625
|
+
function kn(e) {
|
|
2626
|
+
var n, s;
|
|
2627
|
+
return !!((s = (n = l.value.extensionState[e]) == null ? void 0 : n.data) != null && s.enabled);
|
|
2628
|
+
}
|
|
2629
|
+
function Ot(e) {
|
|
2630
|
+
if (mn(e.id) && !kn(e.id) && !Tt(e.id)) {
|
|
2631
|
+
Xn(e);
|
|
2632
|
+
return;
|
|
2633
|
+
}
|
|
2634
|
+
rn(e);
|
|
2635
|
+
}
|
|
2636
|
+
function bn(e) {
|
|
2637
|
+
const n = te.value.capabilities.find(
|
|
2638
|
+
(s) => s.id === e && s.optionKind === "selection"
|
|
2639
|
+
);
|
|
2640
|
+
return n ? n.slot : "knowledgeInline";
|
|
2641
|
+
}
|
|
2642
|
+
function De(e, n) {
|
|
2643
|
+
return !Q.value && Zn(l.value.type, i).capabilities.some(
|
|
2644
|
+
(s) => s.id === e && s.slot === n && s.canInsert
|
|
2645
|
+
);
|
|
2646
|
+
}
|
|
2647
|
+
ye(
|
|
2648
|
+
() => De("tool", "knowledgeInline"),
|
|
2649
|
+
(e) => {
|
|
2650
|
+
!e && Xe.value && ze();
|
|
2651
|
+
}
|
|
2652
|
+
), ye(
|
|
2653
|
+
() => {
|
|
2654
|
+
const e = r.value;
|
|
2655
|
+
return {
|
|
2656
|
+
opened: e,
|
|
2657
|
+
locked: Q.value,
|
|
2658
|
+
usable: !e || e === "type" || te.value.capabilities.some(
|
|
2659
|
+
(n) => n.id === e && n.slot === bn(e) && n.canInsert
|
|
2660
|
+
)
|
|
2661
|
+
};
|
|
2662
|
+
},
|
|
2663
|
+
({ opened: e, locked: n, usable: s }) => {
|
|
2664
|
+
!e || !n && s || (ce = !1, $e(), r.value = null);
|
|
2665
|
+
},
|
|
2666
|
+
{ flush: "sync" }
|
|
2667
|
+
);
|
|
2668
|
+
function Ve(e) {
|
|
2669
|
+
var n;
|
|
2670
|
+
return !Q.value && e.canInsert && (e.id !== "reasoningPolish" || Cn.value) && (e.id !== "attribute" || !((n = B.value) != null && n.isSelectionInsideOriginalReply())) && (e.slot !== "knowledgeInline" && e.slot !== "knowledgeBlock" || W.value && !!B.value);
|
|
2671
|
+
}
|
|
2672
|
+
function pi(e) {
|
|
2673
|
+
const { target: n } = e;
|
|
2674
|
+
n instanceof Element && n.closest('.fkp-knowledge-document[contenteditable="true"]') && (W.value = !0);
|
|
2675
|
+
}
|
|
2676
|
+
function vi(e) {
|
|
2677
|
+
Ee.value = !0, j("MEDIA_EXTENSION_UNAVAILABLE", e, "plugin");
|
|
2678
|
+
}
|
|
2679
|
+
function gi(e) {
|
|
2680
|
+
const n = e.relatedTarget;
|
|
2681
|
+
(!(n instanceof Node) || !e.currentTarget.contains(n)) && (W.value = !1, n instanceof HTMLElement && n !== document.body && go());
|
|
2682
|
+
}
|
|
2683
|
+
function go() {
|
|
2684
|
+
if (!r.value) return;
|
|
2685
|
+
const e = r.value;
|
|
2686
|
+
te.value.capabilities.some(
|
|
2687
|
+
(n) => n.id === e && (n.slot === "knowledgeInline" || n.slot === "knowledgeBlock")
|
|
2688
|
+
) && ($e(), ce = !1, r.value = null);
|
|
2689
|
+
}
|
|
2690
|
+
async function rn(e, n = {}, s, d, m) {
|
|
2691
|
+
var ho, wo, So, Ao, To, Io;
|
|
2692
|
+
const u = !!n.edit;
|
|
2693
|
+
let f = Ve(e);
|
|
2694
|
+
if (u ? f = De(e.id, e.slot) : s && (f = De(e.id, e.slot) && (e.id !== "attribute" || !((ho = B.value) != null && ho.isSelectionInsideOriginalReply()))), !f || Q.value || !Zn(l.value.type, i).capabilities.some(
|
|
2695
|
+
(Te) => Te.id === e.id && Te.slot === e.slot && Te.canInsert
|
|
2696
|
+
)) {
|
|
2697
|
+
s == null || s.dispose();
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2700
|
+
const h = e.slot === "knowledgeInline" || e.slot === "knowledgeBlock", R = h && !u, L = R ? s || ((wo = B.value) == null ? void 0 : wo.captureMediaTarget()) : null;
|
|
2701
|
+
if (R && !L) {
|
|
2702
|
+
j(
|
|
2703
|
+
"INSERT_TARGET_LOST",
|
|
2704
|
+
"原始插入位置已失效,扩展内容未写入",
|
|
2705
|
+
"plugin",
|
|
2706
|
+
e.id
|
|
2707
|
+
);
|
|
2708
|
+
return;
|
|
2709
|
+
}
|
|
2710
|
+
L && vn.add(L);
|
|
2711
|
+
const de = h ? null : `${e.id}:${e.slot}`;
|
|
2712
|
+
de && ((So = gn.get(de)) == null || So.abort());
|
|
2713
|
+
const q = new AbortController();
|
|
2714
|
+
Nn.add(q), de && gn.set(de, q);
|
|
2715
|
+
const X = C.value, Ae = i.sceneKey, { type: Ue } = l.value, ve = c(l.value), Mn = document.activeElement, bo = d instanceof HTMLElement ? d : Mn;
|
|
2716
|
+
let dt = !1;
|
|
2717
|
+
const Pt = () => !q.signal.aborted && (!m || m()) && Ae === i.sceneKey && Ue === l.value.type && (!L || vn.has(L)) && (h || X === C.value) && te.value.capabilities.some(
|
|
2718
|
+
(Te) => Te.id === e.id && Te.slot === e.slot && Te.canInsert
|
|
2719
|
+
) && Zn(l.value.type, i).capabilities.some(
|
|
2720
|
+
(Te) => Te.id === e.id && Te.slot === e.slot && Te.canInsert
|
|
2721
|
+
);
|
|
2722
|
+
try {
|
|
2723
|
+
const Te = await zo(e);
|
|
2724
|
+
if (!Pt()) return;
|
|
2725
|
+
if (!Te.ok) {
|
|
2726
|
+
j(
|
|
2727
|
+
"PLUGIN_UNAVAILABLE",
|
|
2728
|
+
Te.reason === "VERSION_MISMATCH" ? "扩展身份或版本不匹配" : "扩展未安装",
|
|
2729
|
+
"plugin",
|
|
2730
|
+
e.id
|
|
2731
|
+
);
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
const Rn = (Ao = e.actions) == null ? void 0 : Ao.find(
|
|
2735
|
+
(Mt) => Mt.id === (e.primaryActionId || `${e.id}.${e.slot}.apply`)
|
|
2736
|
+
), Eo = Rn && Te.module.actions[Rn.id];
|
|
2737
|
+
if (!Rn || !Eo) {
|
|
2738
|
+
j("PLUGIN_UNAVAILABLE", "扩展动作不可用", "plugin", e.id);
|
|
2739
|
+
return;
|
|
2740
|
+
}
|
|
2741
|
+
const Oo = Jt(e, Rn.id, i.ports);
|
|
2742
|
+
if (!Oo) {
|
|
2743
|
+
j("PORT_MISSING", "宿主未提供扩展所需的接口", "port", e.id);
|
|
2744
|
+
return;
|
|
2745
|
+
}
|
|
2746
|
+
Rn.requiredPorts.length && (He(q, "requesting", !0), dt = !0);
|
|
2747
|
+
const Ki = await Eo.execute(n, {
|
|
2748
|
+
scene: ve,
|
|
2749
|
+
sceneKey: Ae,
|
|
2750
|
+
revision: X,
|
|
2751
|
+
options: e.options,
|
|
2752
|
+
request: xn(e.id, q),
|
|
2753
|
+
ports: Oo
|
|
2754
|
+
});
|
|
2755
|
+
if (!Pt()) return;
|
|
2756
|
+
const xt = Sn(
|
|
2757
|
+
Ki,
|
|
2758
|
+
(Mt) => Array.isArray(Mt)
|
|
2759
|
+
);
|
|
2760
|
+
if (!xt.ok) {
|
|
2761
|
+
_n(
|
|
2762
|
+
xt.error,
|
|
2763
|
+
e.id,
|
|
2764
|
+
Rn.requiredPorts.length ? "port" : "plugin"
|
|
2765
|
+
);
|
|
2766
|
+
return;
|
|
2767
|
+
}
|
|
2768
|
+
const qi = Ho(e, xt.data);
|
|
2769
|
+
yi(
|
|
2770
|
+
e,
|
|
2771
|
+
qi,
|
|
2772
|
+
L,
|
|
2773
|
+
!u && bo instanceof HTMLElement && (document.activeElement === bo || document.activeElement instanceof Element && !!((To = S.value) != null && To.contains(document.activeElement)) && !!document.activeElement.closest('[role="toolbar"]') || document.activeElement === document.body),
|
|
2774
|
+
ve.extensionState[e.id],
|
|
2775
|
+
(Io = n.option) == null ? void 0 : Io.id
|
|
2776
|
+
);
|
|
2777
|
+
} catch (Te) {
|
|
2778
|
+
Pt() && j(
|
|
2779
|
+
dt ? "PORT_FAILED" : "PLUGIN_FAILED",
|
|
2780
|
+
Te instanceof Error ? Te.message : "扩展执行失败",
|
|
2781
|
+
dt ? "port" : "plugin",
|
|
2782
|
+
e.id
|
|
2783
|
+
);
|
|
2784
|
+
} finally {
|
|
2785
|
+
e.id === "reasoningPolish" && Qe.value && an.value === "loading" && (an.value = "error"), dt && Oe.has(q) && He(q, "requesting", !1), q.abort(), Nn.delete(q), de && gn.get(de) === q && gn.delete(de), L == null || L.dispose(), L && vn.delete(L);
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
function yi(e, n, s, d, m, u) {
|
|
2789
|
+
var f, h, R, L, de;
|
|
2790
|
+
if (!n.ok) {
|
|
2791
|
+
j("PLUGIN_OPERATION_REJECTED", n.reason, "plugin", e.id);
|
|
2792
|
+
return;
|
|
2793
|
+
}
|
|
2794
|
+
if (n.kind !== "none") {
|
|
2795
|
+
if (!De(e.id, e.slot)) {
|
|
2796
|
+
j(
|
|
2797
|
+
"PLUGIN_OPERATION_REJECTED",
|
|
2798
|
+
"扩展操作未通过权限校验",
|
|
2799
|
+
"plugin",
|
|
2800
|
+
e.id
|
|
2801
|
+
);
|
|
2802
|
+
return;
|
|
2803
|
+
}
|
|
2804
|
+
if ((n.kind === "state" || n.kind === "compound") && Tn(m ?? null) !== Tn(l.value.extensionState[e.id] ?? null)) {
|
|
2805
|
+
j(
|
|
2806
|
+
"PLUGIN_OPERATION_REJECTED",
|
|
2807
|
+
"扩展状态已变化,本次过期操作未写入",
|
|
2808
|
+
"plugin",
|
|
2809
|
+
e.id
|
|
2810
|
+
);
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
if (n.kind === "compound") {
|
|
2814
|
+
const q = {
|
|
2815
|
+
...l.value.extensionState,
|
|
2816
|
+
[e.id]: { version: e.dataVersion, data: n.data }
|
|
2817
|
+
}, { document: X } = n;
|
|
2818
|
+
if (X.kind === "replaceDoc") {
|
|
2819
|
+
if (!vo(
|
|
2820
|
+
X.doc,
|
|
2821
|
+
e.id,
|
|
2822
|
+
q,
|
|
2823
|
+
X.question
|
|
2824
|
+
))
|
|
2825
|
+
return;
|
|
2826
|
+
const ve = () => {
|
|
2827
|
+
if (De(e.id, e.slot)) {
|
|
2828
|
+
const Mn = C.value;
|
|
2829
|
+
Wn(
|
|
2830
|
+
X.doc,
|
|
2831
|
+
"plugin",
|
|
2832
|
+
e.id,
|
|
2833
|
+
q,
|
|
2834
|
+
X.question
|
|
2835
|
+
), e.id === "reasoningTemplate" && C.value !== Mn && (r.value = null);
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
e.id === "reasoningTemplate" && !l.value.question.text.trim() && !Cn.value ? ve() : e.id === "reasoningTemplate" && u ? fo(u, X.confirmation, ve) : co(X.confirmation, ve);
|
|
2839
|
+
return;
|
|
2840
|
+
}
|
|
2841
|
+
if (X.kind === "doc") {
|
|
2842
|
+
const ve = s ? (f = B.value) == null ? void 0 : f.insertBatch(X.content, s, d) : null;
|
|
2843
|
+
if (!ve) {
|
|
2844
|
+
j(
|
|
2845
|
+
s && s.status() !== "ready" ? "INSERT_TARGET_LOST" : "INSERT_FAILED",
|
|
2846
|
+
"扩展内容未能插入知识区",
|
|
2847
|
+
"plugin",
|
|
2848
|
+
e.id
|
|
2849
|
+
);
|
|
2850
|
+
return;
|
|
2851
|
+
}
|
|
2852
|
+
Wn(ve, "plugin", e.id, q);
|
|
2853
|
+
return;
|
|
2854
|
+
}
|
|
2855
|
+
const Ae = X.kind === "batchNodes" ? X.operations : [X], Ue = (h = B.value) == null ? void 0 : h.previewPluginNodeOperations(Ae, e.id);
|
|
2856
|
+
if (!Ue) {
|
|
2857
|
+
j(
|
|
2858
|
+
"PLUGIN_OPERATION_REJECTED",
|
|
2859
|
+
"目标节点不存在、归属不符或版本已变化",
|
|
2860
|
+
"plugin",
|
|
2861
|
+
e.id
|
|
2862
|
+
);
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
Wn(Ue, "plugin", e.id, q);
|
|
2866
|
+
return;
|
|
2867
|
+
}
|
|
2868
|
+
if (n.kind === "replaceDoc") {
|
|
2869
|
+
if (!vo(
|
|
2870
|
+
n.doc,
|
|
2871
|
+
e.id,
|
|
2872
|
+
l.value.extensionState,
|
|
2873
|
+
n.question
|
|
2874
|
+
))
|
|
2875
|
+
return;
|
|
2876
|
+
const q = () => {
|
|
2877
|
+
if (De(e.id, e.slot)) {
|
|
2878
|
+
const X = C.value;
|
|
2879
|
+
Wn(
|
|
2880
|
+
n.doc,
|
|
2881
|
+
"plugin",
|
|
2882
|
+
e.id,
|
|
2883
|
+
l.value.extensionState,
|
|
2884
|
+
n.question
|
|
2885
|
+
), e.id === "reasoningTemplate" && C.value !== X && (r.value = null);
|
|
2886
|
+
}
|
|
2887
|
+
};
|
|
2888
|
+
e.id === "reasoningPolish" ? (En.value = {
|
|
2889
|
+
sceneKey: i.sceneKey,
|
|
2890
|
+
snapshot: Le(l.value),
|
|
2891
|
+
proposed: qt(n.doc),
|
|
2892
|
+
apply: q
|
|
2893
|
+
}, an.value = "ready") : e.id === "reasoningTemplate" && !l.value.question.text.trim() && !Cn.value ? q() : e.id === "reasoningTemplate" && u ? fo(u, n.confirmation, q) : co(n.confirmation, q);
|
|
2894
|
+
return;
|
|
2895
|
+
}
|
|
2896
|
+
if (n.kind === "updateNode" || n.kind === "removeNode" || n.kind === "batchNodes") {
|
|
2897
|
+
const q = n.kind === "batchNodes" ? n.operations : [n];
|
|
2898
|
+
if (["image", "video"].includes(e.id) && q.some((Ae) => Ae.kind === "updateNode")) {
|
|
2899
|
+
j(
|
|
2900
|
+
"PLUGIN_OPERATION_REJECTED",
|
|
2901
|
+
"媒体节点更新只能由对应节点的异步生命周期提交",
|
|
2902
|
+
"plugin",
|
|
2903
|
+
e.id
|
|
2904
|
+
);
|
|
2905
|
+
return;
|
|
2906
|
+
}
|
|
2907
|
+
Pn = e.id;
|
|
2908
|
+
let X = !1;
|
|
2909
|
+
try {
|
|
2910
|
+
X = ((R = B.value) == null ? void 0 : R.applyPluginNodeOperations(q, e.id)) || !1;
|
|
2911
|
+
} finally {
|
|
2912
|
+
Pn = null;
|
|
2913
|
+
}
|
|
2914
|
+
X || j(
|
|
2915
|
+
"PLUGIN_OPERATION_REJECTED",
|
|
2916
|
+
"目标节点不存在、归属不符或版本已变化",
|
|
2917
|
+
"plugin",
|
|
2918
|
+
e.id
|
|
2919
|
+
);
|
|
2920
|
+
return;
|
|
2921
|
+
}
|
|
2922
|
+
if (n.kind === "state")
|
|
2923
|
+
sn(
|
|
2924
|
+
{
|
|
2925
|
+
...l.value,
|
|
2926
|
+
extensionState: {
|
|
2927
|
+
...l.value.extensionState,
|
|
2928
|
+
[e.id]: { version: e.dataVersion, data: n.data }
|
|
2929
|
+
}
|
|
2930
|
+
},
|
|
2931
|
+
"plugin",
|
|
2932
|
+
e.id
|
|
2933
|
+
);
|
|
2934
|
+
else {
|
|
2935
|
+
const q = s ? (L = B.value) == null ? void 0 : L.insertBatch(n.content, s, d) : null;
|
|
2936
|
+
if (!q) {
|
|
2937
|
+
const Ae = !!s && s.status() !== "ready";
|
|
2938
|
+
j(
|
|
2939
|
+
Ae ? "INSERT_TARGET_LOST" : "INSERT_FAILED",
|
|
2940
|
+
Ae ? "原始插入位置已失效,扩展内容未写入" : "扩展内容未能插入知识区",
|
|
2941
|
+
"plugin",
|
|
2942
|
+
e.id
|
|
2943
|
+
);
|
|
2944
|
+
return;
|
|
2945
|
+
}
|
|
2946
|
+
sn(
|
|
2947
|
+
{ ...l.value, knowledge: { ...l.value.knowledge, doc: q } },
|
|
2948
|
+
"plugin",
|
|
2949
|
+
e.id
|
|
2950
|
+
) || (de = B.value) == null || de.restoreDoc(l.value.knowledge.doc || wn());
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
function mi(e) {
|
|
2955
|
+
if (r.value = null, ce = !1, $e(), Q.value) return;
|
|
2956
|
+
if (i.typeSelectionMode === "add") {
|
|
2957
|
+
y("add-scene", { type: e, scene: Ln(e), position: "start" });
|
|
2958
|
+
return;
|
|
2959
|
+
}
|
|
2960
|
+
if (e === l.value.type) return;
|
|
2961
|
+
if (Ce.value.uploading > 0 || yt(l.value)) {
|
|
2962
|
+
j(
|
|
2963
|
+
"UPLOAD_PENDING",
|
|
2964
|
+
"请先完成或移除未成功的媒体后切换知识类型",
|
|
2965
|
+
"validation"
|
|
2966
|
+
);
|
|
2967
|
+
return;
|
|
2968
|
+
}
|
|
2969
|
+
const { scene: n } = ra(l.value, e);
|
|
2970
|
+
D.value = {
|
|
2971
|
+
sceneKey: i.sceneKey,
|
|
2972
|
+
snapshot: Le(l.value),
|
|
2973
|
+
scene: n
|
|
2974
|
+
}, ao(), Fe(
|
|
2975
|
+
() => {
|
|
2976
|
+
var s, d;
|
|
2977
|
+
return (d = (s = Ke.value) == null ? void 0 : s.querySelector(".fkp-type-confirm-cancel")) == null ? void 0 : d.focus();
|
|
2978
|
+
}
|
|
2979
|
+
);
|
|
2980
|
+
}
|
|
2981
|
+
function ki(e) {
|
|
2982
|
+
un(), se(), W.value = !1, sn(e, "typeSwitch") && Fe(() => {
|
|
2983
|
+
var n, s;
|
|
2984
|
+
return (s = (n = Ke.value) == null ? void 0 : n.querySelector("button")) == null ? void 0 : s.focus();
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2987
|
+
function Nt(e = !1) {
|
|
2988
|
+
D.value = null, e && Fe(() => {
|
|
2989
|
+
var n, s;
|
|
2990
|
+
return (s = (n = Ke.value) == null ? void 0 : n.querySelector("button")) == null ? void 0 : s.focus();
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
function bi() {
|
|
2994
|
+
const e = D.value;
|
|
2995
|
+
D.value = null, !(!e || e.sceneKey !== i.sceneKey || e.snapshot !== Le(l.value) || Q.value || Ce.value.uploading > 0 || yt(l.value)) && ki(e.scene);
|
|
2996
|
+
}
|
|
2997
|
+
function hi() {
|
|
2998
|
+
Q.value || D.value || r.value === "type" || ($e(), G.value = !1, ce = !0, r.value = "type");
|
|
2999
|
+
}
|
|
3000
|
+
function wi() {
|
|
3001
|
+
if (D.value = null, G.value = !1, $e(), r.value === "type" && ce) {
|
|
3002
|
+
ce = !1;
|
|
3003
|
+
return;
|
|
3004
|
+
}
|
|
3005
|
+
ce = !1, r.value = r.value === "type" ? null : "type";
|
|
3006
|
+
}
|
|
3007
|
+
function yo(e) {
|
|
3008
|
+
const n = S.value;
|
|
3009
|
+
if (!n || !r.value && !G.value && !D.value)
|
|
3010
|
+
return;
|
|
3011
|
+
const s = e.composedPath(), d = s.includes(n), m = (f) => d && s.some((h) => h instanceof Element && h.matches(f)), u = d ? s.find(
|
|
3012
|
+
(f) => f instanceof HTMLElement && f.hasAttribute("data-fkp-menu-trigger")
|
|
3013
|
+
) : void 0;
|
|
3014
|
+
r.value && r.value !== "reasoningTemplate" && !m(".fkp-type-menu, .fkp-option-menu") && (u == null ? void 0 : u.dataset.fkpMenuTrigger) !== r.value && (r.value = null, ce = !1, $e()), G.value && !m(".fkp-more-menu") && (u == null ? void 0 : u.dataset.fkpMenuTrigger) !== "more" && (G.value = !1), D.value && !m(".fkp-type-menu, .fkp-type-confirm") && (u == null ? void 0 : u.dataset.fkpMenuTrigger) !== "type" && Nt();
|
|
3015
|
+
}
|
|
3016
|
+
function mo() {
|
|
3017
|
+
const e = w.value.at(-1);
|
|
3018
|
+
return !e || Q.value || Ce.value.uploading > 0 || yt(l.value) || !sn(c(e), "undo") ? !1 : (w.value = w.value.slice(0, -1), un(), se(), W.value = !1, r.value = null, Fe(() => {
|
|
3019
|
+
var n, s;
|
|
3020
|
+
return (s = (n = Ke.value) == null ? void 0 : n.querySelector("button")) == null ? void 0 : s.focus();
|
|
3021
|
+
}), !0);
|
|
3022
|
+
}
|
|
3023
|
+
function Si(e) {
|
|
3024
|
+
e.key.toLowerCase() !== "z" || !(e.ctrlKey || e.metaKey) || e.altKey || e.shiftKey || e.target instanceof Element && e.target.closest('input, textarea, [contenteditable="true"]') || mo() && e.preventDefault();
|
|
3025
|
+
}
|
|
3026
|
+
o({ undoTypeSwitch: mo });
|
|
3027
|
+
function xn(e, n) {
|
|
3028
|
+
return {
|
|
3029
|
+
sceneKey: i.sceneKey,
|
|
3030
|
+
capabilityId: e,
|
|
3031
|
+
requestId: `${i.sceneKey}:${++Xo}`,
|
|
3032
|
+
signal: n.signal
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
3035
|
+
function He(e, n, s) {
|
|
3036
|
+
s ? Oe.set(e, n) : Oe.delete(e), Ce.value = {
|
|
3037
|
+
requesting: [...Oe.values()].filter(
|
|
3038
|
+
(d) => d === "requesting"
|
|
3039
|
+
).length,
|
|
3040
|
+
uploading: [...Oe.values()].filter(
|
|
3041
|
+
(d) => d === "uploading"
|
|
3042
|
+
).length
|
|
3043
|
+
}, y("busy-change", Ce.value);
|
|
3044
|
+
}
|
|
3045
|
+
ye(
|
|
3046
|
+
r,
|
|
3047
|
+
(e, n) => {
|
|
3048
|
+
e !== n && n && n !== "type" && Se();
|
|
3049
|
+
},
|
|
3050
|
+
{ flush: "sync" }
|
|
3051
|
+
);
|
|
3052
|
+
function Ai(e) {
|
|
3053
|
+
return Me.classify(l.value, e);
|
|
3054
|
+
}
|
|
3055
|
+
function un(e) {
|
|
3056
|
+
ze(), Yn(), rt(), Je && clearTimeout(Je), ce = !1, Nn.forEach((s) => s.abort()), Nn.clear(), gn.clear();
|
|
3057
|
+
const n = Me.activeControllers(
|
|
3058
|
+
(e == null ? void 0 : e.active) || /* @__PURE__ */ new Set()
|
|
3059
|
+
);
|
|
3060
|
+
Oe.forEach((s, d) => {
|
|
3061
|
+
s === "uploading" && n.has(d) || (d.abort(), Oe.delete(d));
|
|
3062
|
+
}), Ce.value = {
|
|
3063
|
+
requesting: 0,
|
|
3064
|
+
uploading: [...Oe.values()].filter((s) => s === "uploading").length
|
|
3065
|
+
}, y("busy-change", Ce.value), Me.clearTarget(), vn.forEach((s) => s.dispose()), vn.clear(), Me.retain(e), r.value = null, $(), yn = null;
|
|
3066
|
+
}
|
|
3067
|
+
function Hn(e, n = "start", s, d = "scene") {
|
|
3068
|
+
var Mn;
|
|
3069
|
+
if (!(e instanceof HTMLElement) || !S.value) {
|
|
3070
|
+
ne.value = null;
|
|
3071
|
+
return;
|
|
3072
|
+
}
|
|
3073
|
+
const m = s === "todo" || s === "tagged" ? e.closest(".fkp-action-toggle") : null, u = e.closest(".fkp-more-menu") ? S.value.querySelector(".fkp-more-button") || e : m || e, f = S.value.getBoundingClientRect(), h = u.getBoundingClientRect(), R = s === "variable" ? 426 : s === "tagged" ? 336 : s === "todo" ? 296 : n === "center" ? 320 : 296, L = d === "viewport" ? Math.min(
|
|
3074
|
+
R,
|
|
3075
|
+
Math.max(0, f.width - 32),
|
|
3076
|
+
Math.max(0, window.innerWidth - 32)
|
|
3077
|
+
) : R, de = h.left - f.left + h.width / 2, q = n === "center" ? de - L / 2 : h.left - f.left, X = d === "viewport" ? 8 - f.left : 8, Ae = d === "viewport" ? window.innerWidth - f.left - L - 8 : f.width - L - 8, Ue = Math.max(
|
|
3078
|
+
X,
|
|
3079
|
+
Math.min(q, Math.max(X, Ae))
|
|
3080
|
+
), ve = (Mn = u.closest(".fkp-scene-toolbar")) == null ? void 0 : Mn.getBoundingClientRect().bottom;
|
|
3081
|
+
ne.value = {
|
|
3082
|
+
left: `${Ue}px`,
|
|
3083
|
+
top: `${Math.max(h.bottom, ve ?? h.bottom) - f.top + 4}px`,
|
|
3084
|
+
...n === "center" ? { "--fkp-agent-arrow-left": `${de - Ue}px` } : {},
|
|
3085
|
+
...s === "variable" || s === "ticket" || s === "attribute" || s === "tool" || s === "todo" || s === "tagged" ? { "--fkp-choice-arrow-left": `${de - Ue}px` } : {}
|
|
3086
|
+
};
|
|
3087
|
+
}
|
|
3088
|
+
function Yn() {
|
|
3089
|
+
Ze == null || Ze.dispose(), Ze = null, On = null;
|
|
3090
|
+
}
|
|
3091
|
+
function rt() {
|
|
3092
|
+
ln == null || ln.dispose(), ln = null;
|
|
3093
|
+
}
|
|
3094
|
+
function ut(e) {
|
|
3095
|
+
var n;
|
|
3096
|
+
e.slot !== "knowledgeInline" && e.slot !== "knowledgeBlock" || On === e.id && Ze || (Yn(), Ze = G.value && ln || ((n = B.value) == null ? void 0 : n.captureMediaTarget()) || null, Ze === ln && (ln = null), On = e.id);
|
|
3097
|
+
}
|
|
3098
|
+
function ct(e) {
|
|
3099
|
+
if (On !== e) return null;
|
|
3100
|
+
const n = Ze;
|
|
3101
|
+
return Ze = null, On = null, n;
|
|
3102
|
+
}
|
|
3103
|
+
ye(
|
|
3104
|
+
r,
|
|
3105
|
+
(e) => {
|
|
3106
|
+
e !== On && Yn();
|
|
3107
|
+
},
|
|
3108
|
+
{ flush: "sync" }
|
|
3109
|
+
);
|
|
3110
|
+
async function Xn(e, n) {
|
|
3111
|
+
var s, d, m;
|
|
3112
|
+
if (e.id === ((s = M.value) == null ? void 0 : s.kind) && (M.value = null, r.value = null, ce = !1), !!Ve(e)) {
|
|
3113
|
+
if (r.value !== e.id && Et(e, n), e.id === "image" || e.id === "video") {
|
|
3114
|
+
Me.clearTarget();
|
|
3115
|
+
const u = ct(e.id) || ((d = B.value) == null ? void 0 : d.captureMediaTarget()) || null;
|
|
3116
|
+
if (!u) {
|
|
3117
|
+
j(
|
|
3118
|
+
"EDITOR_UNAVAILABLE",
|
|
3119
|
+
"知识区尚未就绪,无法选择媒体",
|
|
3120
|
+
"validation",
|
|
3121
|
+
e.id
|
|
3122
|
+
);
|
|
3123
|
+
return;
|
|
3124
|
+
}
|
|
3125
|
+
Me.selectTarget(u), on.value = e.id, (m = tn.value) == null || m.click();
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
if (e.id === "separator" || e.id === "originalReply" && e.slot === "knowledgeBlock") {
|
|
3129
|
+
await rn(
|
|
3130
|
+
e,
|
|
3131
|
+
{},
|
|
3132
|
+
ct(e.id) || void 0,
|
|
3133
|
+
n == null ? void 0 : n.currentTarget
|
|
3134
|
+
);
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
if (e.id === "reasoningPolish") {
|
|
3138
|
+
if (Qe.value || !Cn.value) return;
|
|
3139
|
+
Ht.value = qt(l.value.knowledge.doc), En.value = null, an.value = "loading", kt.value = Le(l.value), Qe.value = !0, await rn(e, {}, void 0, void 0, () => Qe.value);
|
|
3140
|
+
return;
|
|
3141
|
+
}
|
|
3142
|
+
if (r.value !== e.id && ut(e), Je && clearTimeout(Je), e.id === "agentSelect" ? Hn(n == null ? void 0 : n.currentTarget, "center") : e.id === "variable" || e.id === "ticket" || e.id === "attribute" || e.id === "tool" ? Hn(n == null ? void 0 : n.currentTarget, "center", e.id) : Jn(e.id) ? n != null && n.currentTarget ? Hn(n.currentTarget, "center", e.id) : (r.value !== e.id || !ce) && (ne.value = null) : ne.value = null, r.value === e.id && ce) {
|
|
3143
|
+
ce = !1;
|
|
3144
|
+
return;
|
|
3145
|
+
}
|
|
3146
|
+
ce = !1, r.value = r.value === e.id ? null : e.id, _e.value = null, $(), r.value && await re(e.id);
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
function Qn(e, n) {
|
|
3150
|
+
var s;
|
|
3151
|
+
e.id === ((s = M.value) == null ? void 0 : s.kind) && (M.value = null, r.value = null, ce = !1), !(!Jn(e.id) || !Ve(e) || r.value === e.id) && (Et(e, n), ut(e), Je && clearTimeout(Je), Hn(n.currentTarget, "center", e.id), (!(n.currentTarget instanceof Element) || !n.currentTarget.closest(".fkp-more-menu")) && (G.value = !1), ce = !0, r.value = e.id, $(), re(e.id));
|
|
3152
|
+
}
|
|
3153
|
+
function Ti(e) {
|
|
3154
|
+
var s;
|
|
3155
|
+
if (Q.value || !De(e.kind, "knowledgeInline"))
|
|
3156
|
+
return;
|
|
3157
|
+
const n = r.value === e.kind && ((s = M.value) == null ? void 0 : s.nodeId) === e.nodeId && M.value.sceneKey === i.sceneKey;
|
|
3158
|
+
$e(), Yn(), G.value = !1, Hn(e.anchor, "center", e.kind, "viewport"), ce = !0, !n && (M.value = {
|
|
3159
|
+
nodeId: e.nodeId,
|
|
3160
|
+
nodeVersion: e.nodeVersion,
|
|
3161
|
+
key: e.key,
|
|
3162
|
+
kind: e.kind,
|
|
3163
|
+
sceneKey: i.sceneKey,
|
|
3164
|
+
type: l.value.type
|
|
3165
|
+
}, r.value = e.kind, $(), re(e.kind));
|
|
3166
|
+
}
|
|
3167
|
+
function $e() {
|
|
3168
|
+
Je && clearTimeout(Je), Je = void 0;
|
|
3169
|
+
}
|
|
3170
|
+
function cn() {
|
|
3171
|
+
ce && ($e(), Je = setTimeout(() => {
|
|
3172
|
+
ce && (r.value === "type" || Jn(r.value)) && (r.value = null), ce = !1;
|
|
3173
|
+
}, 180));
|
|
3174
|
+
}
|
|
3175
|
+
ye(
|
|
3176
|
+
() => {
|
|
3177
|
+
var m, u;
|
|
3178
|
+
const e = r.value, n = te.value, s = (m = n.capabilities.find(
|
|
3179
|
+
(f) => f.id === e && f.optionKind === "selection"
|
|
3180
|
+
)) == null ? void 0 : m.optionSource, d = s ? (u = i.ports) == null ? void 0 : u[Fo[s]] : void 0;
|
|
3181
|
+
return [e, d, n.fingerprint];
|
|
3182
|
+
},
|
|
3183
|
+
([e, n, s], [d, m, u]) => {
|
|
3184
|
+
!e || e === "type" || e !== d || n === m && s === u || ($(), De(e, bn(e)) && re(e));
|
|
3185
|
+
},
|
|
3186
|
+
{ flush: "sync" }
|
|
3187
|
+
);
|
|
3188
|
+
function Ii(e) {
|
|
3189
|
+
Ie() && re(e);
|
|
3190
|
+
}
|
|
3191
|
+
async function Ct(e, n, s) {
|
|
3192
|
+
var f;
|
|
3193
|
+
if (n.disabled) return;
|
|
3194
|
+
if (!De(e, bn(e))) {
|
|
3195
|
+
j("CAPABILITY_REVOKED", "此能力当前不可用", "config", e);
|
|
3196
|
+
return;
|
|
3197
|
+
}
|
|
3198
|
+
const d = te.value.capabilities.find(
|
|
3199
|
+
(h) => h.id === e && h.optionKind === "selection"
|
|
3200
|
+
);
|
|
3201
|
+
if ((d == null ? void 0 : d.optionHierarchy) === "tree" && n.hasChildren) {
|
|
3202
|
+
F(n), await re(e);
|
|
3203
|
+
return;
|
|
3204
|
+
}
|
|
3205
|
+
if (e === "tool") {
|
|
3206
|
+
const h = ct(e);
|
|
3207
|
+
if (!h) {
|
|
3208
|
+
j("INSERT_TARGET_LOST", "工具插入位置已失效", "plugin", "tool");
|
|
3209
|
+
return;
|
|
3210
|
+
}
|
|
3211
|
+
r.value = null, await $n({
|
|
3212
|
+
key: n.id,
|
|
3213
|
+
label: n.label,
|
|
3214
|
+
params: {},
|
|
3215
|
+
target: h,
|
|
3216
|
+
sceneKey: i.sceneKey,
|
|
3217
|
+
type: l.value.type
|
|
3218
|
+
});
|
|
3219
|
+
return;
|
|
3220
|
+
}
|
|
3221
|
+
if (e === ((f = M.value) == null ? void 0 : f.kind)) {
|
|
3222
|
+
const h = M.value;
|
|
3223
|
+
if (r.value = null, M.value = null, ce = !1, $e(), h.sceneKey !== i.sceneKey || h.type !== l.value.type) {
|
|
3224
|
+
j("INSERT_TARGET_LOST", "引用标签所属场景已变化", "plugin", e);
|
|
3225
|
+
return;
|
|
3226
|
+
}
|
|
3227
|
+
const R = te.value.capabilities.find(
|
|
3228
|
+
(L) => L.id === e && L.slot === "knowledgeInline"
|
|
3229
|
+
);
|
|
3230
|
+
if (!R) return;
|
|
3231
|
+
await rn(R, {
|
|
3232
|
+
option: n,
|
|
3233
|
+
edit: { nodeId: h.nodeId, nodeVersion: h.nodeVersion }
|
|
3234
|
+
});
|
|
3235
|
+
return;
|
|
3236
|
+
}
|
|
3237
|
+
const m = bn(e) === "knowledgeInline" ? ct(e) : null;
|
|
3238
|
+
e === "reasoningTemplate" ? st() : r.value = null, ce = !1, $e();
|
|
3239
|
+
const u = Re;
|
|
3240
|
+
if (Re = null, mn(e) && bn(e) === "questionAction") {
|
|
3241
|
+
const h = te.value.capabilities.find(
|
|
3242
|
+
(R) => R.id === e && R.slot === "questionAction"
|
|
3243
|
+
);
|
|
3244
|
+
h && await rn(h, { option: n }), await di(u, e);
|
|
3245
|
+
} else if (e === "agentSelect")
|
|
3246
|
+
sn(
|
|
3247
|
+
{
|
|
3248
|
+
...l.value,
|
|
3249
|
+
knowledge: {
|
|
3250
|
+
...l.value.knowledge,
|
|
3251
|
+
agentRef: { id: n.id, name: n.label }
|
|
3252
|
+
}
|
|
3253
|
+
},
|
|
3254
|
+
"plugin",
|
|
3255
|
+
e
|
|
3256
|
+
);
|
|
3257
|
+
else {
|
|
3258
|
+
const h = te.value.capabilities.find(
|
|
3259
|
+
(R) => R.id === e && (R.slot === "knowledgeInline" || R.slot === "sceneAction")
|
|
3260
|
+
);
|
|
3261
|
+
if (h) {
|
|
3262
|
+
if (h.slot === "knowledgeInline" && !m) {
|
|
3263
|
+
j("INSERT_TARGET_LOST", "原始插入位置已失效", "plugin", e);
|
|
3264
|
+
return;
|
|
3265
|
+
}
|
|
3266
|
+
h.slot !== "knowledgeInline" && (m == null || m.dispose()), await rn(
|
|
3267
|
+
h,
|
|
3268
|
+
{ option: n },
|
|
3269
|
+
m || void 0,
|
|
3270
|
+
s == null ? void 0 : s.currentTarget,
|
|
3271
|
+
e === "reasoningTemplate" ? () => r.value === "reasoningTemplate" : void 0
|
|
3272
|
+
);
|
|
3273
|
+
} else m == null || m.dispose();
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
ye(
|
|
3277
|
+
() => {
|
|
3278
|
+
var e;
|
|
3279
|
+
try {
|
|
3280
|
+
return (e = i.ports) == null ? void 0 : e.getToolForm;
|
|
3281
|
+
} catch {
|
|
3282
|
+
return;
|
|
3283
|
+
}
|
|
3284
|
+
},
|
|
3285
|
+
(e, n) => qe.portChanged(e, n),
|
|
3286
|
+
{ flush: "sync" }
|
|
3287
|
+
);
|
|
3288
|
+
function Ei(e) {
|
|
3289
|
+
if (!De("tool", "knowledgeInline")) return;
|
|
3290
|
+
const { params: n } = e;
|
|
3291
|
+
if (n === null) {
|
|
3292
|
+
j(
|
|
3293
|
+
"TOOL_PARAMS_UNSUPPORTED",
|
|
3294
|
+
"当前工具标签缺少配置参数,请先迁移旧数据",
|
|
3295
|
+
"validation",
|
|
3296
|
+
"tool"
|
|
3297
|
+
);
|
|
3298
|
+
return;
|
|
3299
|
+
}
|
|
3300
|
+
$n({
|
|
3301
|
+
...e,
|
|
3302
|
+
params: n,
|
|
3303
|
+
sceneKey: i.sceneKey,
|
|
3304
|
+
type: l.value.type
|
|
3305
|
+
});
|
|
3306
|
+
}
|
|
3307
|
+
async function Oi(e, n) {
|
|
3308
|
+
var R;
|
|
3309
|
+
const s = document.activeElement, d = Xe.value, m = In.value;
|
|
3310
|
+
if (!d || !m || !De("tool", "knowledgeInline"))
|
|
3311
|
+
return;
|
|
3312
|
+
if (d.sceneKey !== i.sceneKey || d.type !== l.value.type) {
|
|
3313
|
+
ze();
|
|
3314
|
+
return;
|
|
3315
|
+
}
|
|
3316
|
+
if (!await qe.recheck(d, m)) return;
|
|
3317
|
+
const u = oa(
|
|
3318
|
+
d.key,
|
|
3319
|
+
e,
|
|
3320
|
+
d.params,
|
|
3321
|
+
l.value.knowledge.doc,
|
|
3322
|
+
d.nodeId
|
|
3323
|
+
);
|
|
3324
|
+
if (!u.ok) {
|
|
3325
|
+
j(u.code, u.message, "validation", "tool");
|
|
3326
|
+
return;
|
|
3327
|
+
}
|
|
3328
|
+
e = u.params;
|
|
3329
|
+
const f = te.value.capabilities.find(
|
|
3330
|
+
(L) => L.id === "tool" && L.slot === "knowledgeInline"
|
|
3331
|
+
);
|
|
3332
|
+
if (!f) return;
|
|
3333
|
+
if (d.nodeId !== void 0 && d.nodeVersion !== void 0) {
|
|
3334
|
+
const L = document.activeElement, de = L === document.body || L instanceof Element && !!L.closest(".fkp-tool-modal") && (L === s || L === n);
|
|
3335
|
+
if (await rn(
|
|
3336
|
+
f,
|
|
3337
|
+
{
|
|
3338
|
+
option: { id: d.key, label: d.label, params: e },
|
|
3339
|
+
edit: { nodeId: d.nodeId, nodeVersion: d.nodeVersion }
|
|
3340
|
+
},
|
|
3341
|
+
void 0,
|
|
3342
|
+
n,
|
|
3343
|
+
() => Xe.value === d && In.value === m
|
|
3344
|
+
), Xe.value !== d) return;
|
|
3345
|
+
ze(), await Fe();
|
|
3346
|
+
const q = document.activeElement;
|
|
3347
|
+
de && d.sceneKey === i.sceneKey && d.type === l.value.type && (q === document.body || q === s || q === n) && ((R = B.value) == null || R.focus());
|
|
3348
|
+
return;
|
|
3349
|
+
}
|
|
3350
|
+
const { target: h } = d;
|
|
3351
|
+
if (!h || h.status() !== "ready") {
|
|
3352
|
+
j("INSERT_TARGET_LOST", "工具插入位置已失效", "plugin", "tool"), ze();
|
|
3353
|
+
return;
|
|
3354
|
+
}
|
|
3355
|
+
qe.releaseForInsert(), await rn(
|
|
3356
|
+
f,
|
|
3357
|
+
{ option: { id: d.key, label: d.label, params: e } },
|
|
3358
|
+
h,
|
|
3359
|
+
n
|
|
3360
|
+
);
|
|
3361
|
+
}
|
|
3362
|
+
function Ni() {
|
|
3363
|
+
const e = yn;
|
|
3364
|
+
e && (yn = null, e.abort(), Oe.has(e) && He(e, "requesting", !1));
|
|
3365
|
+
}
|
|
3366
|
+
async function Ci(e) {
|
|
3367
|
+
const n = _t.value;
|
|
3368
|
+
if (!n) return;
|
|
3369
|
+
const s = new AbortController();
|
|
3370
|
+
yn = s;
|
|
3371
|
+
const { sceneKey: d } = i, m = () => {
|
|
3372
|
+
var u;
|
|
3373
|
+
return !s.signal.aborted && yn === s && d === i.sceneKey && ((u = l.value.knowledge.agentRef) == null ? void 0 : u.id) === e;
|
|
3374
|
+
};
|
|
3375
|
+
ue.value = "loading", He(s, "requesting", !0);
|
|
3376
|
+
try {
|
|
3377
|
+
const u = await n({ agentId: e }, xn("agentSelect", s));
|
|
3378
|
+
if (!m()) return;
|
|
3379
|
+
const f = Sn(
|
|
3380
|
+
u,
|
|
3381
|
+
(h) => Ia(e, h)
|
|
3382
|
+
);
|
|
3383
|
+
f.ok ? (pe.value = f.data.prompt, ue.value = "ready") : (ue.value = "error", _n(f.error, "agentSelect"));
|
|
3384
|
+
} catch (u) {
|
|
3385
|
+
m() && (ue.value = "error", j(
|
|
3386
|
+
"PORT_FAILED",
|
|
3387
|
+
u instanceof Error ? u.message : "读取 Agent 失败",
|
|
3388
|
+
"port",
|
|
3389
|
+
"agentSelect"
|
|
3390
|
+
));
|
|
3391
|
+
} finally {
|
|
3392
|
+
yn === s && (yn = null), Oe.has(s) && He(s, "requesting", !1);
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
const _t = le(() => {
|
|
3396
|
+
var n;
|
|
3397
|
+
const e = te.value.capabilities.find(
|
|
3398
|
+
(s) => s.id === "agentSelect" && s.slot === "sceneAction"
|
|
3399
|
+
);
|
|
3400
|
+
return e ? (n = fa(e, i.ports)) == null ? void 0 : n.getAgentPrompt : void 0;
|
|
3401
|
+
}), ko = le(() => We.value ? _t.value ? ue.value === "error" ? "Agent 提示词读取失败" : ue.value === "ready" ? pe.value || "Agent 提示词为空" : "正在读取 Agent 提示词…" : "" : "选择 Agent 后,将在此处显示 Agent 提示词内容");
|
|
3402
|
+
ye(
|
|
3403
|
+
() => {
|
|
3404
|
+
var e;
|
|
3405
|
+
return [i.sceneKey, (e = We.value) == null ? void 0 : e.id, _t.value];
|
|
3406
|
+
},
|
|
3407
|
+
([, e]) => {
|
|
3408
|
+
Ni(), se(), e && Ci(e);
|
|
3409
|
+
},
|
|
3410
|
+
{ immediate: !0 }
|
|
3411
|
+
);
|
|
3412
|
+
async function _i(e) {
|
|
3413
|
+
const n = e.target, s = Array.from(n.files || []);
|
|
3414
|
+
n.value = "";
|
|
3415
|
+
const d = Me.takeTarget(), m = document.activeElement, u = m === document.body || m === n || m instanceof Element && !!m.closest(
|
|
3416
|
+
'[data-fkp-menu-trigger="image"], [data-fkp-menu-trigger="video"]'
|
|
3417
|
+
);
|
|
3418
|
+
d && await Me.enqueue(
|
|
3419
|
+
s,
|
|
3420
|
+
d,
|
|
3421
|
+
on.value,
|
|
3422
|
+
u
|
|
3423
|
+
);
|
|
3424
|
+
}
|
|
3425
|
+
function Pi(e) {
|
|
3426
|
+
var d, m, u;
|
|
3427
|
+
const n = Array.from(((d = e.clipboardData) == null ? void 0 : d.files) || []);
|
|
3428
|
+
if (!n.length || (e.preventDefault(), Q.value)) return;
|
|
3429
|
+
(m = B.value) == null || m.pasteFileText(e);
|
|
3430
|
+
const s = (u = B.value) == null ? void 0 : u.captureMediaTarget();
|
|
3431
|
+
if (!s) {
|
|
3432
|
+
j(
|
|
3433
|
+
"EDITOR_UNAVAILABLE",
|
|
3434
|
+
"知识区尚未就绪,无法粘贴媒体",
|
|
3435
|
+
"validation"
|
|
3436
|
+
);
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
Me.enqueue(n, s);
|
|
3440
|
+
}
|
|
3441
|
+
function xi(e) {
|
|
3442
|
+
var n;
|
|
3443
|
+
Array.from(((n = e.dataTransfer) == null ? void 0 : n.types) || []).includes("Files") && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = Q.value ? "none" : "copy"));
|
|
3444
|
+
}
|
|
3445
|
+
function Mi(e) {
|
|
3446
|
+
var d, m, u;
|
|
3447
|
+
if (Array.from(((d = e.dataTransfer) == null ? void 0 : d.items) || []).some(
|
|
3448
|
+
(f) => {
|
|
3449
|
+
var h, R;
|
|
3450
|
+
return (R = (h = f.webkitGetAsEntry) == null ? void 0 : h.call(f)) == null ? void 0 : R.isDirectory;
|
|
3451
|
+
}
|
|
3452
|
+
)) {
|
|
3453
|
+
e.preventDefault(), Po.error({
|
|
3454
|
+
content: "不支持上传文件夹,请选择图片或视频文件",
|
|
3455
|
+
position: "top"
|
|
3456
|
+
});
|
|
3457
|
+
return;
|
|
3458
|
+
}
|
|
3459
|
+
const n = Array.from(((m = e.dataTransfer) == null ? void 0 : m.files) || []);
|
|
3460
|
+
if (!n.length || (e.preventDefault(), Q.value)) return;
|
|
3461
|
+
const s = (u = B.value) == null ? void 0 : u.captureMediaTargetAt(e.clientX, e.clientY);
|
|
3462
|
+
if (!s) {
|
|
3463
|
+
j("INSERT_TARGET_LOST", "拖放位置无效,媒体未写入", "validation");
|
|
3464
|
+
return;
|
|
3465
|
+
}
|
|
3466
|
+
Me.enqueue(n, s);
|
|
3467
|
+
}
|
|
3468
|
+
const Ri = Me.retry;
|
|
3469
|
+
async function Di() {
|
|
3470
|
+
var u, f;
|
|
3471
|
+
const e = (u = We.value) == null ? void 0 : u.id, n = (f = pa(
|
|
3472
|
+
"agentSelect.openConfig",
|
|
3473
|
+
i.ports
|
|
3474
|
+
)) == null ? void 0 : f.openAgentConfig;
|
|
3475
|
+
if (!e || !n) return;
|
|
3476
|
+
const s = new AbortController(), { sceneKey: d } = i, m = () => {
|
|
3477
|
+
var h;
|
|
3478
|
+
return !s.signal.aborted && d === i.sceneKey && ((h = We.value) == null ? void 0 : h.id) === e;
|
|
3479
|
+
};
|
|
3480
|
+
He(s, "requesting", !0);
|
|
3481
|
+
try {
|
|
3482
|
+
const h = await n(
|
|
3483
|
+
{ agentId: e, target: "_blank" },
|
|
3484
|
+
xn("agentSelect", s)
|
|
3485
|
+
);
|
|
3486
|
+
if (!m()) return;
|
|
3487
|
+
const R = Sn(
|
|
3488
|
+
h,
|
|
3489
|
+
(L) => L === void 0
|
|
3490
|
+
);
|
|
3491
|
+
R.ok || _n(R.error, "agentSelect");
|
|
3492
|
+
} catch (h) {
|
|
3493
|
+
m() && j(
|
|
3494
|
+
"PORT_FAILED",
|
|
3495
|
+
h instanceof Error ? h.message : "打开 Agent 失败",
|
|
3496
|
+
"port",
|
|
3497
|
+
"agentSelect"
|
|
3498
|
+
);
|
|
3499
|
+
} finally {
|
|
3500
|
+
He(s, "requesting", !1);
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
function Li() {
|
|
3504
|
+
if (Q.value) return;
|
|
3505
|
+
const { sceneKey: e } = i, n = Ln(l.value.type);
|
|
3506
|
+
un(), se(), G.value = !1, M.value = null, _e.value = null, en = null, Re = null, nn = null, sn(
|
|
3507
|
+
{
|
|
3508
|
+
...l.value,
|
|
3509
|
+
question: n.question,
|
|
3510
|
+
knowledge: n.knowledge,
|
|
3511
|
+
extensionState: n.extensionState
|
|
3512
|
+
},
|
|
3513
|
+
"user"
|
|
3514
|
+
) && Fe(() => {
|
|
3515
|
+
var m;
|
|
3516
|
+
if (e !== i.sceneKey || Q.value) return;
|
|
3517
|
+
const d = (m = S.value) == null ? void 0 : m.querySelector(
|
|
3518
|
+
'[aria-label="顾客问法"]'
|
|
3519
|
+
);
|
|
3520
|
+
!d || d.disabled || (d.focus(), d.setSelectionRange(0, 0));
|
|
3521
|
+
});
|
|
3522
|
+
}
|
|
3523
|
+
return $i(() => {
|
|
3524
|
+
Ge(), lt == null || lt(), zn == null || zn.disconnect(), window.removeEventListener("resize", io), document.removeEventListener("click", yo), Bn.forEach((e) => e.close()), Bn.clear(), un(), Fn && clearTimeout(Fn);
|
|
3525
|
+
}), (e, n) => {
|
|
3526
|
+
var s, d, m;
|
|
3527
|
+
return I(), _("section", {
|
|
3528
|
+
ref_key: "sceneRoot",
|
|
3529
|
+
ref: S,
|
|
3530
|
+
class: Be(["fkp-rich-text", [
|
|
3531
|
+
`fkp-type-${l.value.type}`,
|
|
3532
|
+
{
|
|
3533
|
+
"is-readonly": Q.value,
|
|
3534
|
+
"has-open-menu": !!r.value || G.value || !!D.value
|
|
3535
|
+
}
|
|
3536
|
+
]]),
|
|
3537
|
+
onKeydown: [
|
|
3538
|
+
n[18] || (n[18] = Rt((u) => {
|
|
3539
|
+
r.value = null, G.value = !1, D.value = null;
|
|
3540
|
+
}, ["esc"])),
|
|
3541
|
+
Si
|
|
3542
|
+
],
|
|
3543
|
+
onFocusout: gi
|
|
3544
|
+
}, [
|
|
3545
|
+
O("div", {
|
|
3546
|
+
ref_key: "toolbar",
|
|
3547
|
+
ref: x,
|
|
3548
|
+
class: "fkp-scene-toolbar",
|
|
3549
|
+
role: "toolbar",
|
|
3550
|
+
"aria-label": "知识编辑工具栏"
|
|
3551
|
+
}, [
|
|
3552
|
+
O("div", {
|
|
3553
|
+
ref_key: "typeWrap",
|
|
3554
|
+
ref: Ke,
|
|
3555
|
+
class: "fkp-type-wrap",
|
|
3556
|
+
onMouseenter: $e,
|
|
3557
|
+
onMouseleave: cn
|
|
3558
|
+
}, [
|
|
3559
|
+
P(b(ee), {
|
|
3560
|
+
class: "fkp-type-button",
|
|
3561
|
+
type: "text",
|
|
3562
|
+
"data-fkp-menu-trigger": "type",
|
|
3563
|
+
disabled: Q.value,
|
|
3564
|
+
"aria-label": e.typeSelectionMode === "add" ? "添加知识场景" : "选择知识类型",
|
|
3565
|
+
"aria-keyshortcuts": w.value.length ? "Control+Z Meta+Z" : void 0,
|
|
3566
|
+
onMouseenter: hi,
|
|
3567
|
+
onClick: wi
|
|
3568
|
+
}, {
|
|
3569
|
+
default: K(() => [
|
|
3570
|
+
P(b(ke), {
|
|
3571
|
+
name: Xt[l.value.type],
|
|
3572
|
+
size: 16
|
|
3573
|
+
}, null, 8, ["name"]),
|
|
3574
|
+
O("strong", null, Z(Yt[l.value.type]), 1),
|
|
3575
|
+
P(b(ke), {
|
|
3576
|
+
name: "arrow-down",
|
|
3577
|
+
size: 12
|
|
3578
|
+
})
|
|
3579
|
+
]),
|
|
3580
|
+
_: 1
|
|
3581
|
+
}, 8, ["disabled", "aria-label", "aria-keyshortcuts"]),
|
|
3582
|
+
r.value === "type" ? (I(), _("span", Ha)) : U("", !0),
|
|
3583
|
+
r.value === "type" ? (I(), _("div", Ya, [
|
|
3584
|
+
n[19] || (n[19] = O("strong", { class: "fkp-type-menu-title" }, "选择要添加的知识类型:", -1)),
|
|
3585
|
+
(I(), _(Ne, null, Ye(["normal", "reasoning", "agent"], (u) => P(b(ee), {
|
|
3586
|
+
key: u,
|
|
3587
|
+
class: "fkp-type-option",
|
|
3588
|
+
type: "text",
|
|
3589
|
+
"aria-pressed": e.typeSelectionMode === "switch" ? l.value.type === u : void 0,
|
|
3590
|
+
onClick: (f) => mi(u)
|
|
3591
|
+
}, {
|
|
3592
|
+
default: K(() => [
|
|
3593
|
+
O("span", {
|
|
3594
|
+
class: Be(["fkp-type-option-icon", `is-${u}`])
|
|
3595
|
+
}, [
|
|
3596
|
+
P(b(ke), {
|
|
3597
|
+
name: Xt[u],
|
|
3598
|
+
size: 16
|
|
3599
|
+
}, null, 8, ["name"])
|
|
3600
|
+
], 2),
|
|
3601
|
+
O("span", Xa, [
|
|
3602
|
+
O("strong", null, Z(Yt[u]), 1),
|
|
3603
|
+
O("span", null, Z(Qo[u]), 1)
|
|
3604
|
+
])
|
|
3605
|
+
]),
|
|
3606
|
+
_: 2
|
|
3607
|
+
}, 1032, ["aria-pressed", "onClick"])), 64))
|
|
3608
|
+
])) : U("", !0),
|
|
3609
|
+
D.value ? (I(), _("div", {
|
|
3610
|
+
key: 2,
|
|
3611
|
+
class: "fkp-type-confirm",
|
|
3612
|
+
role: "alertdialog",
|
|
3613
|
+
"aria-label": "确认切换知识类型",
|
|
3614
|
+
style: Co({
|
|
3615
|
+
left: `${z.value}px`,
|
|
3616
|
+
"--fkp-type-confirm-arrow-left": `${48 - z.value}px`
|
|
3617
|
+
}),
|
|
3618
|
+
onKeydown: n[1] || (n[1] = Rt(ft((u) => Nt(!0), ["stop", "prevent"]), ["esc"]))
|
|
3619
|
+
}, [
|
|
3620
|
+
n[23] || (n[23] = O("span", {
|
|
3621
|
+
class: "fkp-type-confirm-arrow",
|
|
3622
|
+
"aria-hidden": "true"
|
|
3623
|
+
}, null, -1)),
|
|
3624
|
+
O("div", Qa, [
|
|
3625
|
+
P(b(Gi), { "aria-hidden": "true" }),
|
|
3626
|
+
n[20] || (n[20] = O("span", null, "切换后将移除不适配标签,其余知识内容不变,是否确认切换?", -1))
|
|
3627
|
+
]),
|
|
3628
|
+
O("div", Za, [
|
|
3629
|
+
P(b(ee), {
|
|
3630
|
+
class: "fkp-type-confirm-cancel",
|
|
3631
|
+
onClick: n[0] || (n[0] = (u) => Nt(!0))
|
|
3632
|
+
}, {
|
|
3633
|
+
default: K(() => n[21] || (n[21] = [
|
|
3634
|
+
me("取消")
|
|
3635
|
+
])),
|
|
3636
|
+
_: 1
|
|
3637
|
+
}),
|
|
3638
|
+
P(b(ee), {
|
|
3639
|
+
type: "primary",
|
|
3640
|
+
onClick: bi
|
|
3641
|
+
}, {
|
|
3642
|
+
default: K(() => n[22] || (n[22] = [
|
|
3643
|
+
me("确认")
|
|
3644
|
+
])),
|
|
3645
|
+
_: 1
|
|
3646
|
+
})
|
|
3647
|
+
])
|
|
3648
|
+
], 36)) : U("", !0)
|
|
3649
|
+
], 544),
|
|
3650
|
+
n[27] || (n[27] = O("span", { class: "fkp-toolbar-divider" }, null, -1)),
|
|
3651
|
+
l.value.type === "agent" ? (I(), fe(b(Dn), {
|
|
3652
|
+
key: 0,
|
|
3653
|
+
trigger: "hover",
|
|
3654
|
+
position: "bottom",
|
|
3655
|
+
content: "选择 Agent",
|
|
3656
|
+
"popup-visible": !1
|
|
3657
|
+
}, {
|
|
3658
|
+
default: K(() => {
|
|
3659
|
+
var u;
|
|
3660
|
+
return [
|
|
3661
|
+
P(b(ee), {
|
|
3662
|
+
class: "fkp-agent-picker",
|
|
3663
|
+
type: "text",
|
|
3664
|
+
"data-fkp-menu-trigger": "agentSelect",
|
|
3665
|
+
disabled: Q.value || !((u = it.value.find((f) => f.id === "agentSelect")) != null && u.canInsert),
|
|
3666
|
+
onMouseenter: n[2] || (n[2] = (f) => Qn(
|
|
3667
|
+
it.value.find((h) => h.id === "agentSelect"),
|
|
3668
|
+
f
|
|
3669
|
+
)),
|
|
3670
|
+
onMouseleave: cn,
|
|
3671
|
+
onClick: n[3] || (n[3] = (f) => Xn(
|
|
3672
|
+
it.value.find((h) => h.id === "agentSelect"),
|
|
3673
|
+
f
|
|
3674
|
+
))
|
|
3675
|
+
}, {
|
|
3676
|
+
default: K(() => {
|
|
3677
|
+
var f;
|
|
3678
|
+
return [
|
|
3679
|
+
me(Z(((f = We.value) == null ? void 0 : f.name) || "选择 Agent") + " ", 1),
|
|
3680
|
+
P(b(ke), {
|
|
3681
|
+
name: "arrow-down",
|
|
3682
|
+
size: 12
|
|
3683
|
+
})
|
|
3684
|
+
];
|
|
3685
|
+
}),
|
|
3686
|
+
_: 1
|
|
3687
|
+
}, 8, ["disabled"])
|
|
3688
|
+
];
|
|
3689
|
+
}),
|
|
3690
|
+
_: 1
|
|
3691
|
+
})) : U("", !0),
|
|
3692
|
+
O("div", {
|
|
3693
|
+
ref_key: "toolbarLeft",
|
|
3694
|
+
ref: Y,
|
|
3695
|
+
class: "fkp-toolbar-groups"
|
|
3696
|
+
}, [
|
|
3697
|
+
(I(!0), _(Ne, null, Ye(to.value, (u) => (I(), _(Ne, {
|
|
3698
|
+
key: u.key
|
|
3699
|
+
}, [
|
|
3700
|
+
u.actions.some((f) => f.index < we.value) ? (I(), _(Ne, { key: 0 }, [
|
|
3701
|
+
n[24] || (n[24] = O("span", { class: "fkp-toolbar-divider" }, null, -1)),
|
|
3702
|
+
O("div", el, [
|
|
3703
|
+
(I(!0), _(Ne, null, Ye(u.actions, (f) => (I(), _(Ne, {
|
|
3704
|
+
key: f.key
|
|
3705
|
+
}, [
|
|
3706
|
+
f.index < we.value && f.kind === "question" && f.item ? (I(), fe(b(Dn), {
|
|
3707
|
+
key: 0,
|
|
3708
|
+
trigger: "hover",
|
|
3709
|
+
position: "bottom",
|
|
3710
|
+
content: k(f.item.id) ? void 0 : `${f.item.label}开关`,
|
|
3711
|
+
"content-class": k(f.item.id) ? "fkp-capability-help-popover" : void 0,
|
|
3712
|
+
"popup-visible": mn(f.item.id) ? !1 : void 0
|
|
3713
|
+
}, Dt({
|
|
3714
|
+
default: K(() => [
|
|
3715
|
+
O("div", {
|
|
3716
|
+
class: Be(["fkp-action-toggle", {
|
|
3717
|
+
"is-disabled": !Ve(f.item),
|
|
3718
|
+
"is-todo-active": f.item.id === "todo" && kn("todo"),
|
|
3719
|
+
"is-question-active": f.item.id !== "todo" && kn(f.item.id)
|
|
3720
|
+
}]),
|
|
3721
|
+
"data-fkp-menu-trigger": mn(f.item.id) ? f.item.id : void 0,
|
|
3722
|
+
onMouseenter: (h) => Qn(f.item, h),
|
|
3723
|
+
onPointerdownCapture: (h) => It(f.item, h),
|
|
3724
|
+
onMouseleave: cn
|
|
3725
|
+
}, [
|
|
3726
|
+
P(b(ee), {
|
|
3727
|
+
class: "fkp-action-label",
|
|
3728
|
+
type: "text",
|
|
3729
|
+
disabled: !Ve(f.item),
|
|
3730
|
+
"aria-label": f.item.label,
|
|
3731
|
+
"aria-pressed": kn(f.item.id),
|
|
3732
|
+
onClick: (h) => Gn(f, h)
|
|
3733
|
+
}, {
|
|
3734
|
+
default: K(() => [
|
|
3735
|
+
P(b(ke), {
|
|
3736
|
+
name: Un[f.item.icon] || "book",
|
|
3737
|
+
size: 16
|
|
3738
|
+
}, null, 8, ["name"]),
|
|
3739
|
+
me(Z(f.item.label), 1)
|
|
3740
|
+
]),
|
|
3741
|
+
_: 2
|
|
3742
|
+
}, 1032, ["disabled", "aria-label", "aria-pressed", "onClick"]),
|
|
3743
|
+
P(b(_o), {
|
|
3744
|
+
class: "fkp-action-switch",
|
|
3745
|
+
size: "small",
|
|
3746
|
+
"model-value": kn(f.item.id),
|
|
3747
|
+
disabled: !Ve(f.item),
|
|
3748
|
+
"aria-label": `${f.item.label}开关`,
|
|
3749
|
+
onMousedown: n[4] || (n[4] = ft(() => {
|
|
3750
|
+
}, ["prevent"])),
|
|
3751
|
+
onChange: (h) => Ot(f.item)
|
|
3752
|
+
}, null, 8, ["model-value", "disabled", "aria-label", "onChange"])
|
|
3753
|
+
], 42, nl)
|
|
3754
|
+
]),
|
|
3755
|
+
_: 2
|
|
3756
|
+
}, [
|
|
3757
|
+
k(f.item.id) ? {
|
|
3758
|
+
name: "content",
|
|
3759
|
+
fn: K(() => [
|
|
3760
|
+
P(Ut, {
|
|
3761
|
+
"capability-id": f.item.id,
|
|
3762
|
+
onHelp: (h) => y("help", { capabilityId: f.item.id })
|
|
3763
|
+
}, null, 8, ["capability-id", "onHelp"])
|
|
3764
|
+
]),
|
|
3765
|
+
key: "0"
|
|
3766
|
+
} : void 0
|
|
3767
|
+
]), 1032, ["content", "content-class", "popup-visible"])) : f.index < we.value && f.kind === "knowledge" && f.item ? (I(), fe(b(Dn), {
|
|
3768
|
+
key: 1,
|
|
3769
|
+
trigger: "hover",
|
|
3770
|
+
position: "bottom",
|
|
3771
|
+
content: k(f.item.id) ? void 0 : `${f.item.label}:在知识区光标处插入`,
|
|
3772
|
+
"content-class": k(f.item.id) ? "fkp-capability-help-popover" : void 0,
|
|
3773
|
+
"popup-visible": Jn(f.item.id) || r.value === f.item.id ? !1 : void 0
|
|
3774
|
+
}, Dt({
|
|
3775
|
+
default: K(() => [
|
|
3776
|
+
P(b(ee), {
|
|
3777
|
+
class: "fkp-tool-button",
|
|
3778
|
+
type: "text",
|
|
3779
|
+
"data-fkp-menu-trigger": f.item.id,
|
|
3780
|
+
disabled: !Ve(f.item),
|
|
3781
|
+
"aria-label": f.item.label,
|
|
3782
|
+
onMouseenter: (h) => Qn(f.item, h),
|
|
3783
|
+
onPointerdownCapture: (h) => lo(f.item),
|
|
3784
|
+
onMouseleave: cn,
|
|
3785
|
+
onClick: (h) => Gn(f, h)
|
|
3786
|
+
}, {
|
|
3787
|
+
default: K(() => [
|
|
3788
|
+
P(b(ke), {
|
|
3789
|
+
name: Un[f.item.icon] || "book",
|
|
3790
|
+
size: 16
|
|
3791
|
+
}, null, 8, ["name"]),
|
|
3792
|
+
f.showLabel ? (I(), _("span", tl, Z(f.item.label), 1)) : U("", !0)
|
|
3793
|
+
]),
|
|
3794
|
+
_: 2
|
|
3795
|
+
}, 1032, ["data-fkp-menu-trigger", "disabled", "aria-label", "onMouseenter", "onPointerdownCapture", "onClick"])
|
|
3796
|
+
]),
|
|
3797
|
+
_: 2
|
|
3798
|
+
}, [
|
|
3799
|
+
k(f.item.id) ? {
|
|
3800
|
+
name: "content",
|
|
3801
|
+
fn: K(() => [
|
|
3802
|
+
P(Ut, {
|
|
3803
|
+
"capability-id": f.item.id,
|
|
3804
|
+
onHelp: (h) => y("help", { capabilityId: f.item.id })
|
|
3805
|
+
}, null, 8, ["capability-id", "onHelp"])
|
|
3806
|
+
]),
|
|
3807
|
+
key: "0"
|
|
3808
|
+
} : void 0
|
|
3809
|
+
]), 1032, ["content", "content-class", "popup-visible"])) : U("", !0)
|
|
3810
|
+
], 64))), 128))
|
|
3811
|
+
])
|
|
3812
|
+
], 64)) : U("", !0)
|
|
3813
|
+
], 64))), 128)),
|
|
3814
|
+
At.value.length ? (I(), _("div", {
|
|
3815
|
+
key: 0,
|
|
3816
|
+
class: "fkp-more-wrap",
|
|
3817
|
+
onMouseleave: ci
|
|
3818
|
+
}, [
|
|
3819
|
+
P(b(ee), {
|
|
3820
|
+
class: "fkp-more-button",
|
|
3821
|
+
type: "text",
|
|
3822
|
+
"data-fkp-menu-trigger": "more",
|
|
3823
|
+
"aria-label": "更多操作",
|
|
3824
|
+
"aria-expanded": G.value,
|
|
3825
|
+
onMouseenter: ri,
|
|
3826
|
+
onPointerdownCapture: po,
|
|
3827
|
+
onClick: ui
|
|
3828
|
+
}, {
|
|
3829
|
+
default: K(() => [
|
|
3830
|
+
P(b(ke), {
|
|
3831
|
+
name: "more",
|
|
3832
|
+
size: 16
|
|
3833
|
+
})
|
|
3834
|
+
]),
|
|
3835
|
+
_: 1
|
|
3836
|
+
}, 8, ["aria-expanded"]),
|
|
3837
|
+
G.value ? (I(), _("div", ol, [
|
|
3838
|
+
(I(!0), _(Ne, null, Ye(At.value, (u) => {
|
|
3839
|
+
var f, h, R, L, de, q, X;
|
|
3840
|
+
return I(), fe(b(Dn), {
|
|
3841
|
+
key: u.key,
|
|
3842
|
+
class: "fkp-more-popover",
|
|
3843
|
+
trigger: "hover",
|
|
3844
|
+
position: k((f = u.item) == null ? void 0 : f.id) ? "bottom" : "right",
|
|
3845
|
+
content: k((h = u.item) == null ? void 0 : h.id) ? void 0 : u.kind === "knowledge" ? `${(R = u.item) == null ? void 0 : R.label}:在知识区光标处插入` : u.kind === "question" ? `${(L = u.item) == null ? void 0 : L.label}开关` : ((de = u.item) == null ? void 0 : de.label) || "前往编辑 Agent",
|
|
3846
|
+
"content-class": k((q = u.item) == null ? void 0 : q.id) ? "fkp-capability-help-popover fkp-capability-help-popover--more" : void 0,
|
|
3847
|
+
"popup-visible": u.item && Jn(u.item.id) ? !1 : void 0
|
|
3848
|
+
}, Dt({
|
|
3849
|
+
default: K(() => {
|
|
3850
|
+
var Ae, Ue;
|
|
3851
|
+
return [
|
|
3852
|
+
O("div", {
|
|
3853
|
+
class: Be(["fkp-more-row", {
|
|
3854
|
+
"fkp-more-row--question": u.kind === "question",
|
|
3855
|
+
"is-disabled": u.item && !Ve(u.item)
|
|
3856
|
+
}]),
|
|
3857
|
+
"data-fkp-menu-trigger": (Ae = u.item) == null ? void 0 : Ae.id,
|
|
3858
|
+
onMouseenter: (ve) => u.item && Qn(u.item, ve),
|
|
3859
|
+
onPointerdownCapture: (ve) => ei(u, ve),
|
|
3860
|
+
onMouseleave: cn
|
|
3861
|
+
}, [
|
|
3862
|
+
P(b(ee), {
|
|
3863
|
+
type: "text",
|
|
3864
|
+
disabled: u.kind === "agentOpen" ? !We.value || !((Ue = e.ports) != null && Ue.openAgentConfig) : !u.item || !Ve(u.item),
|
|
3865
|
+
onClick: (ve) => Gn(u, ve)
|
|
3866
|
+
}, {
|
|
3867
|
+
default: K(() => {
|
|
3868
|
+
var ve;
|
|
3869
|
+
return [
|
|
3870
|
+
P(b(ke), {
|
|
3871
|
+
name: u.item ? Un[u.item.icon] || "book" : "open",
|
|
3872
|
+
size: 16
|
|
3873
|
+
}, null, 8, ["name"]),
|
|
3874
|
+
me(Z(((ve = u.item) == null ? void 0 : ve.label) || "前往编辑 Agent"), 1)
|
|
3875
|
+
];
|
|
3876
|
+
}),
|
|
3877
|
+
_: 2
|
|
3878
|
+
}, 1032, ["disabled", "onClick"]),
|
|
3879
|
+
u.kind === "question" && u.item ? (I(), fe(b(_o), {
|
|
3880
|
+
key: 0,
|
|
3881
|
+
class: "fkp-action-switch",
|
|
3882
|
+
size: "small",
|
|
3883
|
+
"model-value": kn(u.item.id),
|
|
3884
|
+
disabled: !Ve(u.item),
|
|
3885
|
+
"aria-label": `${u.item.label}开关`,
|
|
3886
|
+
onMousedown: n[5] || (n[5] = ft(() => {
|
|
3887
|
+
}, ["prevent"])),
|
|
3888
|
+
onChange: (ve) => Ot(u.item)
|
|
3889
|
+
}, null, 8, ["model-value", "disabled", "aria-label", "onChange"])) : U("", !0)
|
|
3890
|
+
], 42, il)
|
|
3891
|
+
];
|
|
3892
|
+
}),
|
|
3893
|
+
_: 2
|
|
3894
|
+
}, [
|
|
3895
|
+
k((X = u.item) == null ? void 0 : X.id) ? {
|
|
3896
|
+
name: "content",
|
|
3897
|
+
fn: K(() => [
|
|
3898
|
+
P(Ut, {
|
|
3899
|
+
"capability-id": u.item.id,
|
|
3900
|
+
onHelp: (Ae) => y("help", { capabilityId: u.item.id })
|
|
3901
|
+
}, null, 8, ["capability-id", "onHelp"])
|
|
3902
|
+
]),
|
|
3903
|
+
key: "0"
|
|
3904
|
+
} : void 0
|
|
3905
|
+
]), 1032, ["position", "content", "content-class", "popup-visible"]);
|
|
3906
|
+
}), 128))
|
|
3907
|
+
])) : U("", !0)
|
|
3908
|
+
], 32)) : U("", !0)
|
|
3909
|
+
], 512),
|
|
3910
|
+
wt.value.length ? (I(), _("div", al, [
|
|
3911
|
+
n[26] || (n[26] = O("span", { class: "fkp-toolbar-divider" }, null, -1)),
|
|
3912
|
+
(I(!0), _(Ne, null, Ye(wt.value, (u) => (I(), _(Ne, {
|
|
3913
|
+
key: u.key
|
|
3914
|
+
}, [
|
|
3915
|
+
u.kind === "scene" && u.item ? (I(), fe(b(Dn), {
|
|
3916
|
+
key: 0,
|
|
3917
|
+
trigger: "hover",
|
|
3918
|
+
position: "bottom",
|
|
3919
|
+
content: u.item.label
|
|
3920
|
+
}, {
|
|
3921
|
+
default: K(() => [
|
|
3922
|
+
P(b(ee), {
|
|
3923
|
+
class: "fkp-scene-action",
|
|
3924
|
+
type: "text",
|
|
3925
|
+
"data-fkp-menu-trigger": u.item.id === "reasoningTemplate" ? "reasoningTemplate" : void 0,
|
|
3926
|
+
disabled: !Ve(u.item),
|
|
3927
|
+
onClick: (f) => Gn(u)
|
|
3928
|
+
}, {
|
|
3929
|
+
default: K(() => [
|
|
3930
|
+
P(b(ke), {
|
|
3931
|
+
name: Un[u.item.icon] || "book",
|
|
3932
|
+
size: 12
|
|
3933
|
+
}, null, 8, ["name"]),
|
|
3934
|
+
me(Z(u.item.label), 1)
|
|
3935
|
+
]),
|
|
3936
|
+
_: 2
|
|
3937
|
+
}, 1032, ["data-fkp-menu-trigger", "disabled", "onClick"])
|
|
3938
|
+
]),
|
|
3939
|
+
_: 2
|
|
3940
|
+
}, 1032, ["content"])) : u.kind === "agentOpen" ? (I(), fe(b(Dn), {
|
|
3941
|
+
key: 1,
|
|
3942
|
+
trigger: "hover",
|
|
3943
|
+
position: "bottom",
|
|
3944
|
+
content: "前往编辑 Agent"
|
|
3945
|
+
}, {
|
|
3946
|
+
default: K(() => {
|
|
3947
|
+
var f;
|
|
3948
|
+
return [
|
|
3949
|
+
P(b(ee), {
|
|
3950
|
+
class: "fkp-open-agent",
|
|
3951
|
+
type: "text",
|
|
3952
|
+
disabled: !We.value || !((f = e.ports) != null && f.openAgentConfig),
|
|
3953
|
+
onClick: (h) => Gn(u)
|
|
3954
|
+
}, {
|
|
3955
|
+
default: K(() => [
|
|
3956
|
+
P(b(ke), {
|
|
3957
|
+
name: "open",
|
|
3958
|
+
size: 12
|
|
3959
|
+
}),
|
|
3960
|
+
n[25] || (n[25] = me("前往编辑 Agent "))
|
|
3961
|
+
]),
|
|
3962
|
+
_: 2
|
|
3963
|
+
}, 1032, ["disabled", "onClick"])
|
|
3964
|
+
];
|
|
3965
|
+
}),
|
|
3966
|
+
_: 2
|
|
3967
|
+
}, 1024)) : U("", !0)
|
|
3968
|
+
], 64))), 128))
|
|
3969
|
+
])) : U("", !0)
|
|
3970
|
+
], 512),
|
|
3971
|
+
r.value && r.value !== "type" && r.value !== "reasoningTemplate" ? (I(), _("div", {
|
|
3972
|
+
key: 0,
|
|
3973
|
+
class: Be(["fkp-menu fkp-option-menu", {
|
|
3974
|
+
"is-choice-menu": r.value === "todo" || r.value === "ticket" || r.value === "tagged" || r.value === "variable" || r.value === "attribute" || r.value === "tool",
|
|
3975
|
+
"is-todo-menu": r.value === "todo" || r.value === "tagged",
|
|
3976
|
+
"is-ticket-menu": r.value === "ticket",
|
|
3977
|
+
"is-attribute-menu": r.value === "attribute",
|
|
3978
|
+
"is-tool-menu": r.value === "tool",
|
|
3979
|
+
"is-tagged-menu": r.value === "tagged",
|
|
3980
|
+
"is-variable-menu": r.value === "variable",
|
|
3981
|
+
"is-agent-menu": r.value === "agentSelect",
|
|
3982
|
+
"fkp-agent-menu": r.value === "agentSelect"
|
|
3983
|
+
}]),
|
|
3984
|
+
style: Co(ne.value || void 0),
|
|
3985
|
+
onMouseenter: $e,
|
|
3986
|
+
onMouseleave: cn
|
|
3987
|
+
}, [
|
|
3988
|
+
r.value === "agentSelect" ? (I(), _("span", ll)) : U("", !0),
|
|
3989
|
+
O("div", sl, [
|
|
3990
|
+
r.value === "ticket" ? (I(), _("span", rl, [
|
|
3991
|
+
O("strong", null, Z(uo.value), 1),
|
|
3992
|
+
n[28] || (n[28] = O("span", { class: "fkp-ticket-badge" }, "限免", -1)),
|
|
3993
|
+
n[29] || (n[29] = O("span", {
|
|
3994
|
+
class: "fkp-ticket-dot",
|
|
3995
|
+
"aria-hidden": "true"
|
|
3996
|
+
}, null, -1))
|
|
3997
|
+
])) : (I(), _("strong", ul, Z(uo.value), 1)),
|
|
3998
|
+
r.value === "todo" || r.value === "ticket" || r.value === "tagged" || r.value === "variable" || r.value === "attribute" || r.value === "tool" || r.value === "agentSelect" ? (I(), fe(b(ee), {
|
|
3999
|
+
key: 2,
|
|
4000
|
+
class: Be(
|
|
4001
|
+
r.value === "agentSelect" ? "fkp-agent-help" : r.value === "variable" ? "fkp-variable-help" : r.value === "ticket" ? "fkp-ticket-help" : r.value === "attribute" || r.value === "tool" ? "fkp-reference-help" : "fkp-todo-help"
|
|
4002
|
+
),
|
|
4003
|
+
type: "text",
|
|
4004
|
+
onClick: n[6] || (n[6] = (u) => y("help", { capabilityId: r.value }))
|
|
4005
|
+
}, {
|
|
4006
|
+
default: K(() => [
|
|
4007
|
+
P(b(ke), {
|
|
4008
|
+
name: "book",
|
|
4009
|
+
size: 14
|
|
4010
|
+
}),
|
|
4011
|
+
n[30] || (n[30] = me("我该怎么配?"))
|
|
4012
|
+
]),
|
|
4013
|
+
_: 1
|
|
4014
|
+
}, 8, ["class"])) : (I(), fe(b(ee), {
|
|
4015
|
+
key: 3,
|
|
4016
|
+
type: "text",
|
|
4017
|
+
"aria-label": "关闭菜单",
|
|
4018
|
+
onClick: n[7] || (n[7] = (u) => r.value = null)
|
|
4019
|
+
}, {
|
|
4020
|
+
default: K(() => [
|
|
4021
|
+
P(b(Ji), { size: 15 })
|
|
4022
|
+
]),
|
|
4023
|
+
_: 1
|
|
4024
|
+
}))
|
|
4025
|
+
]),
|
|
4026
|
+
r.value === "todo" ? (I(), _("div", cl, n[31] || (n[31] = [
|
|
4027
|
+
O("p", null, "普通知识可直接开启待办标签;", -1),
|
|
4028
|
+
O("p", null, "推理知识需在回复话术末尾双引号前添加该标签;", -1),
|
|
4029
|
+
O("p", null, "触发后,「人机协同」「仅提示/夜间值守」会进入待办,「智能转接」会按所选方案转接", -1)
|
|
4030
|
+
]))) : U("", !0),
|
|
4031
|
+
r.value === "ticket" ? (I(), _("p", dl, "可将工单场景添加至目标客服回复话术的引号“”内,命中后将自动创建工单")) : U("", !0),
|
|
4032
|
+
r.value === "attribute" || r.value === "tool" ? (I(), _("p", fl, "支持在推理知识下,引用以下工具辅助 AI 回复")) : U("", !0),
|
|
4033
|
+
r.value === "tagged" ? (I(), _("p", pl, "顾客问题命中此知识内容时,当前顾客打上对应顾客标签")) : U("", !0),
|
|
4034
|
+
r.value === "variable" ? (I(), _("p", vl, "可插入客服昵称,或您在变量管理中配置的变量")) : U("", !0),
|
|
4035
|
+
r.value === "agentSelect" ? (I(), _("p", gl, "若顾客消息命中此场景,AI将根据对话进行多轮推理,给出贴合场景逻辑、有效解决问题的回复")) : U("", !0),
|
|
4036
|
+
b(V).length && r.value !== "variable" ? (I(), _("div", yl, [
|
|
4037
|
+
P(b(ee), {
|
|
4038
|
+
type: "text",
|
|
4039
|
+
onClick: n[8] || (n[8] = (u) => Ii(r.value))
|
|
4040
|
+
}, {
|
|
4041
|
+
default: K(() => n[32] || (n[32] = [
|
|
4042
|
+
me("返回")
|
|
4043
|
+
])),
|
|
4044
|
+
_: 1
|
|
4045
|
+
}),
|
|
4046
|
+
O("span", null, Z(b(V).map((u) => u.label).join(" / ")), 1)
|
|
4047
|
+
])) : U("", !0),
|
|
4048
|
+
O("div", {
|
|
4049
|
+
class: Be(["fkp-menu-search", {
|
|
4050
|
+
"is-todo-search": r.value === "todo" || r.value === "ticket" || r.value === "tagged" || r.value === "variable" || r.value === "attribute" || r.value === "tool",
|
|
4051
|
+
"is-agent-search": r.value === "agentSelect"
|
|
4052
|
+
}])
|
|
4053
|
+
}, [
|
|
4054
|
+
P(b(ke), {
|
|
4055
|
+
name: "search",
|
|
4056
|
+
size: 15
|
|
4057
|
+
}),
|
|
4058
|
+
P(b(Ui), {
|
|
4059
|
+
modelValue: b(J),
|
|
4060
|
+
"onUpdate:modelValue": n[9] || (n[9] = (u) => Bi(J) ? J.value = u : null),
|
|
4061
|
+
"input-attrs": {
|
|
4062
|
+
"aria-label": r.value === "variable" ? "搜索变量名称" : r.value === "ticket" ? "搜索工单名称" : r.value === "attribute" ? "搜索属性名称" : r.value === "tool" ? "搜索工具名称" : r.value === "todo" || r.value === "tagged" || r.value === "agentSelect" ? "搜索标签名称" : "搜索选项"
|
|
4063
|
+
},
|
|
4064
|
+
placeholder: r.value === "variable" ? "搜索变量名称" : r.value === "ticket" ? "搜索工单名称" : r.value === "attribute" ? "搜索属性名称" : r.value === "tool" ? "搜索工具名称" : r.value === "todo" || r.value === "tagged" || r.value === "agentSelect" ? "搜索标签名称" : "搜索选项",
|
|
4065
|
+
onInput: n[10] || (n[10] = (u) => b(re)(r.value))
|
|
4066
|
+
}, null, 8, ["modelValue", "input-attrs", "placeholder"])
|
|
4067
|
+
], 2),
|
|
4068
|
+
r.value === "variable" ? (I(), fe(Wa, {
|
|
4069
|
+
key: 8,
|
|
4070
|
+
options: b(oe),
|
|
4071
|
+
loading: b(ie),
|
|
4072
|
+
"next-cursor": b(ae),
|
|
4073
|
+
query: b(J),
|
|
4074
|
+
onChoose: n[11] || (n[11] = (u, f) => Ct("variable", u, f)),
|
|
4075
|
+
onLoadMore: n[12] || (n[12] = (u) => b(re)("variable", !0))
|
|
4076
|
+
}, null, 8, ["options", "loading", "next-cursor", "query"])) : (I(), _("div", ml, [
|
|
4077
|
+
b(ie) && !b(oe).length ? (I(), _("p", kl, [
|
|
4078
|
+
P(b(ke), {
|
|
4079
|
+
name: "sync",
|
|
4080
|
+
size: 15,
|
|
4081
|
+
class: "fkp-spin"
|
|
4082
|
+
}),
|
|
4083
|
+
n[33] || (n[33] = me("加载中…"))
|
|
4084
|
+
])) : !b(ie) && !b(oe).length ? (I(), _("p", bl, "暂无可选项")) : U("", !0),
|
|
4085
|
+
(I(!0), _(Ne, null, Ye(b(oe), (u) => {
|
|
4086
|
+
var f, h, R;
|
|
4087
|
+
return I(), fe(b(ee), {
|
|
4088
|
+
key: u.id,
|
|
4089
|
+
type: "text",
|
|
4090
|
+
"aria-label": u.label,
|
|
4091
|
+
"aria-pressed": r.value === ((f = M.value) == null ? void 0 : f.kind) ? M.value.key === u.id : r.value === "agentSelect" ? ((h = We.value) == null ? void 0 : h.id) === u.id : (r.value === "todo" || r.value === "tagged") && bn(r.value) === "questionAction" ? ((R = Tt(r.value)) == null ? void 0 : R.id) === u.id : void 0,
|
|
4092
|
+
disabled: u.disabled,
|
|
4093
|
+
onClick: (L) => Ct(r.value, u, L)
|
|
4094
|
+
}, {
|
|
4095
|
+
default: K(() => [
|
|
4096
|
+
me(Z(u.label), 1),
|
|
4097
|
+
u.hasChildren ? (I(), fe(b(ke), {
|
|
4098
|
+
key: 0,
|
|
4099
|
+
class: "fkp-option-child-icon",
|
|
4100
|
+
name: "arrow-down",
|
|
4101
|
+
size: 14
|
|
4102
|
+
})) : U("", !0)
|
|
4103
|
+
]),
|
|
4104
|
+
_: 2
|
|
4105
|
+
}, 1032, ["aria-label", "aria-pressed", "disabled", "onClick"]);
|
|
4106
|
+
}), 128)),
|
|
4107
|
+
b(ae) ? (I(), fe(b(ee), {
|
|
4108
|
+
key: 2,
|
|
4109
|
+
type: "text",
|
|
4110
|
+
class: "fkp-menu-more",
|
|
4111
|
+
disabled: b(ie),
|
|
4112
|
+
onClick: n[13] || (n[13] = (u) => b(re)(r.value, !0))
|
|
4113
|
+
}, {
|
|
4114
|
+
default: K(() => n[34] || (n[34] = [
|
|
4115
|
+
me("加载更多")
|
|
4116
|
+
])),
|
|
4117
|
+
_: 1
|
|
4118
|
+
}, 8, ["disabled"])) : U("", !0)
|
|
4119
|
+
]))
|
|
4120
|
+
], 38)) : U("", !0),
|
|
4121
|
+
P(b(Fi), {
|
|
4122
|
+
visible: r.value === "reasoningTemplate",
|
|
4123
|
+
title: "推理模板",
|
|
4124
|
+
width: 600,
|
|
4125
|
+
footer: !1,
|
|
4126
|
+
onCancel: n[16] || (n[16] = (u) => {
|
|
4127
|
+
st(), r.value = null;
|
|
4128
|
+
})
|
|
4129
|
+
}, {
|
|
4130
|
+
default: K(() => [
|
|
4131
|
+
O("div", hl, [
|
|
4132
|
+
n[37] || (n[37] = O("div", { class: "fkp-template-intro" }, [
|
|
4133
|
+
O("h3", null, "说明"),
|
|
4134
|
+
O("p", null, " 推理适用于需要根据不同情况判断条件和对应处理规则的业务场景,AI 命中知识后会选择对应流程并结合实际信息进行回复或执行动作。 "),
|
|
4135
|
+
O("p", null, "您可以参考以下示例进行推理内容的配置:")
|
|
4136
|
+
], -1)),
|
|
4137
|
+
b(ie) ? (I(), _("p", wl, "加载中…")) : b(oe).length ? U("", !0) : (I(), _("p", Sl, "暂无可用模板")),
|
|
4138
|
+
(I(!0), _(Ne, null, Ye(b(oe), (u) => {
|
|
4139
|
+
var f, h;
|
|
4140
|
+
return I(), _("div", {
|
|
4141
|
+
key: u.id,
|
|
4142
|
+
class: "fkp-template-card"
|
|
4143
|
+
}, [
|
|
4144
|
+
P(b(ee), {
|
|
4145
|
+
type: "text",
|
|
4146
|
+
class: "fkp-template-title",
|
|
4147
|
+
"aria-label": u.label,
|
|
4148
|
+
"aria-expanded": _e.value === u.id,
|
|
4149
|
+
disabled: u.disabled,
|
|
4150
|
+
onClick: (R) => _e.value = _e.value === u.id ? null : u.id
|
|
4151
|
+
}, {
|
|
4152
|
+
default: K(() => [
|
|
4153
|
+
me(Z(u.label), 1),
|
|
4154
|
+
P(b(ke), {
|
|
4155
|
+
name: "arrow-down",
|
|
4156
|
+
size: 14
|
|
4157
|
+
})
|
|
4158
|
+
]),
|
|
4159
|
+
_: 2
|
|
4160
|
+
}, 1032, ["aria-label", "aria-expanded", "disabled", "onClick"]),
|
|
4161
|
+
_e.value === u.id ? (I(), _("div", Al, [
|
|
4162
|
+
u.preview ? (I(), _("p", Tl, Z(u.preview), 1)) : U("", !0),
|
|
4163
|
+
P(b(ji), {
|
|
4164
|
+
type: "warning",
|
|
4165
|
+
position: "bottom",
|
|
4166
|
+
content: (f = pn.value) == null ? void 0 : f.content,
|
|
4167
|
+
"popup-visible": ((h = pn.value) == null ? void 0 : h.optionId) === u.id,
|
|
4168
|
+
"content-class": "fkp-template-confirm",
|
|
4169
|
+
onPopupVisibleChange: n[14] || (n[14] = (R) => {
|
|
4170
|
+
R || st();
|
|
4171
|
+
}),
|
|
4172
|
+
onOk: oi,
|
|
4173
|
+
onCancel: st
|
|
4174
|
+
}, {
|
|
4175
|
+
default: K(() => [
|
|
4176
|
+
P(b(ee), {
|
|
4177
|
+
type: "primary",
|
|
4178
|
+
disabled: u.disabled,
|
|
4179
|
+
onClick: (R) => Ct("reasoningTemplate", u, R)
|
|
4180
|
+
}, {
|
|
4181
|
+
default: K(() => n[35] || (n[35] = [
|
|
4182
|
+
me("使用模板")
|
|
4183
|
+
])),
|
|
4184
|
+
_: 2
|
|
4185
|
+
}, 1032, ["disabled", "onClick"])
|
|
4186
|
+
]),
|
|
4187
|
+
_: 2
|
|
4188
|
+
}, 1032, ["content", "popup-visible"])
|
|
4189
|
+
])) : U("", !0)
|
|
4190
|
+
]);
|
|
4191
|
+
}), 128)),
|
|
4192
|
+
b(ae) ? (I(), fe(b(ee), {
|
|
4193
|
+
key: 2,
|
|
4194
|
+
type: "text",
|
|
4195
|
+
disabled: b(ie),
|
|
4196
|
+
onClick: n[15] || (n[15] = (u) => b(re)("reasoningTemplate", !0))
|
|
4197
|
+
}, {
|
|
4198
|
+
default: K(() => n[36] || (n[36] = [
|
|
4199
|
+
me("加载更多")
|
|
4200
|
+
])),
|
|
4201
|
+
_: 1
|
|
4202
|
+
}, 8, ["disabled"])) : U("", !0)
|
|
4203
|
+
])
|
|
4204
|
+
]),
|
|
4205
|
+
_: 1
|
|
4206
|
+
}, 8, ["visible"]),
|
|
4207
|
+
P(b(Lt), {
|
|
4208
|
+
visible: Qe.value,
|
|
4209
|
+
title: "话术润色",
|
|
4210
|
+
width: 1200,
|
|
4211
|
+
"modal-class": "fkp-polish-modal",
|
|
4212
|
+
"mask-closable": !1,
|
|
4213
|
+
"unmount-on-close": !0,
|
|
4214
|
+
onCancel: Ge
|
|
4215
|
+
}, {
|
|
4216
|
+
footer: K(() => [
|
|
4217
|
+
P(b(ee), { onClick: Ge }, {
|
|
4218
|
+
default: K(() => n[41] || (n[41] = [
|
|
4219
|
+
me("取消")
|
|
4220
|
+
])),
|
|
4221
|
+
_: 1
|
|
4222
|
+
}),
|
|
4223
|
+
P(b(ee), {
|
|
4224
|
+
type: "primary",
|
|
4225
|
+
disabled: an.value !== "ready",
|
|
4226
|
+
onClick: Yo
|
|
4227
|
+
}, {
|
|
4228
|
+
default: K(() => n[42] || (n[42] = [
|
|
4229
|
+
me("采用")
|
|
4230
|
+
])),
|
|
4231
|
+
_: 1
|
|
4232
|
+
}, 8, ["disabled"])
|
|
4233
|
+
]),
|
|
4234
|
+
default: K(() => [
|
|
4235
|
+
an.value === "loading" ? (I(), _("div", Il, n[38] || (n[38] = [
|
|
4236
|
+
O("span", {
|
|
4237
|
+
class: "fkp-polish-dot",
|
|
4238
|
+
"aria-hidden": "true"
|
|
4239
|
+
}, null, -1),
|
|
4240
|
+
O("strong", null, "话术润色中...", -1),
|
|
4241
|
+
O("p", null, "系统将分析话术内容,可能需要几十秒时间", -1)
|
|
4242
|
+
]))) : an.value === "ready" && En.value ? (I(), _("div", El, [
|
|
4243
|
+
O("section", Ol, [
|
|
4244
|
+
n[39] || (n[39] = O("h3", null, "原文", -1)),
|
|
4245
|
+
O("div", Nl, Z(Ht.value), 1)
|
|
4246
|
+
]),
|
|
4247
|
+
O("section", Cl, [
|
|
4248
|
+
n[40] || (n[40] = O("h3", null, "润色后", -1)),
|
|
4249
|
+
O("div", _l, Z(En.value.proposed), 1)
|
|
4250
|
+
])
|
|
4251
|
+
])) : (I(), _("div", Pl, "润色失败,请稍后重试"))
|
|
4252
|
+
]),
|
|
4253
|
+
_: 1
|
|
4254
|
+
}, 8, ["visible"]),
|
|
4255
|
+
b(In) ? (I(), fe(b(Lt), {
|
|
4256
|
+
key: 1,
|
|
4257
|
+
visible: !0,
|
|
4258
|
+
title: ((s = b(Xe)) == null ? void 0 : s.label) || "工具配置",
|
|
4259
|
+
width: 500,
|
|
4260
|
+
"modal-class": "fkp-tool-modal",
|
|
4261
|
+
footer: !1,
|
|
4262
|
+
onCancel: b(ze)
|
|
4263
|
+
}, {
|
|
4264
|
+
default: K(() => {
|
|
4265
|
+
var u, f;
|
|
4266
|
+
return [
|
|
4267
|
+
P(b(g), {
|
|
4268
|
+
definition: b(In),
|
|
4269
|
+
"initial-params": ((u = b(Xe)) == null ? void 0 : u.params) || {},
|
|
4270
|
+
"submit-label": (f = b(Xe)) != null && f.nodeId ? "保存" : "插入",
|
|
4271
|
+
onSubmit: Oi,
|
|
4272
|
+
onCancel: b(ze)
|
|
4273
|
+
}, null, 8, ["definition", "initial-params", "submit-label", "onCancel"])
|
|
4274
|
+
];
|
|
4275
|
+
}),
|
|
4276
|
+
_: 1
|
|
4277
|
+
}, 8, ["title", "onCancel"])) : U("", !0),
|
|
4278
|
+
O("div", {
|
|
4279
|
+
class: Be(["fkp-scene-body", { "has-knowledge-content": Cn.value }])
|
|
4280
|
+
}, [
|
|
4281
|
+
O("div", xl, [
|
|
4282
|
+
O("span", {
|
|
4283
|
+
class: "fkp-question-prompt",
|
|
4284
|
+
onClick: li
|
|
4285
|
+
}, [
|
|
4286
|
+
n[43] || (n[43] = O("span", { "aria-hidden": "true" }, "[", -1)),
|
|
4287
|
+
O("span", {
|
|
4288
|
+
class: Be(["fkp-question-field", { "is-filled": !!l.value.question.text }])
|
|
4289
|
+
}, [
|
|
4290
|
+
O("span", Ml, Z(l.value.question.text || "填写顾客咨询意图,多种意图使用 / 分隔"), 1),
|
|
4291
|
+
P(b(zi), {
|
|
4292
|
+
"model-value": l.value.question.text,
|
|
4293
|
+
disabled: Q.value,
|
|
4294
|
+
"textarea-attrs": { "aria-label": "顾客问法", rows: 1 },
|
|
4295
|
+
placeholder: "填写顾客咨询意图,多种意图使用 / 分隔",
|
|
4296
|
+
onFocus: ai,
|
|
4297
|
+
onBlur: si,
|
|
4298
|
+
onKeydown: n[17] || (n[17] = Rt(ft(() => {
|
|
4299
|
+
}, ["prevent"]), ["enter"])),
|
|
4300
|
+
onInput: ii
|
|
4301
|
+
}, null, 8, ["model-value", "disabled"])
|
|
4302
|
+
], 2),
|
|
4303
|
+
n[44] || (n[44] = O("span", {
|
|
4304
|
+
"aria-hidden": "true",
|
|
4305
|
+
class: "fkp-question-close"
|
|
4306
|
+
}, "]", -1))
|
|
4307
|
+
]),
|
|
4308
|
+
ro.value.length ? (I(), _("span", Rl, [
|
|
4309
|
+
(I(!0), _(Ne, null, Ye(ro.value, (u) => (I(), fe(b(ee), {
|
|
4310
|
+
key: u.id,
|
|
4311
|
+
class: Be(["fkp-question-tag", `fkp-question-tag--${u.kind}`]),
|
|
4312
|
+
"data-fkp-menu-trigger": u.id,
|
|
4313
|
+
type: "text",
|
|
4314
|
+
disabled: Q.value,
|
|
4315
|
+
"aria-label": `${u.id === "todo" ? "待办" : "顾客标签"}方案:${u.label}`,
|
|
4316
|
+
"aria-expanded": r.value === u.id,
|
|
4317
|
+
onMouseenter: (f) => so(u.id, f, !0),
|
|
4318
|
+
onPointerdownCapture: (f) => ni(u.id, f),
|
|
4319
|
+
onMouseleave: cn,
|
|
4320
|
+
onClick: (f) => so(u.id, f, !1)
|
|
4321
|
+
}, {
|
|
4322
|
+
default: K(() => [
|
|
4323
|
+
P(b(ke), {
|
|
4324
|
+
class: "fkp-question-tag-icon",
|
|
4325
|
+
name: Un[u.icon] || "book",
|
|
4326
|
+
size: 16
|
|
4327
|
+
}, null, 8, ["name"]),
|
|
4328
|
+
O("span", Dl, Z(u.label), 1),
|
|
4329
|
+
P(b(ke), {
|
|
4330
|
+
name: "arrow-down",
|
|
4331
|
+
size: 12
|
|
4332
|
+
})
|
|
4333
|
+
]),
|
|
4334
|
+
_: 2
|
|
4335
|
+
}, 1032, ["data-fkp-menu-trigger", "class", "disabled", "aria-label", "aria-expanded", "onMouseenter", "onPointerdownCapture", "onClick"]))), 128))
|
|
4336
|
+
])) : U("", !0)
|
|
4337
|
+
]),
|
|
4338
|
+
O("div", Ll, [
|
|
4339
|
+
jn.value ? (I(), _("div", Kl, [
|
|
4340
|
+
O("p", null, "此知识包含当前版本无法编辑的内容:" + Z(jn.value) + "。请升级扩展后编辑。", 1),
|
|
4341
|
+
O("pre", ql, Z(Zo.value), 1),
|
|
4342
|
+
no.value ? (I(), _(Ne, { key: 0 }, [
|
|
4343
|
+
n[45] || (n[45] = O("p", null, "扩展状态(只读)", -1)),
|
|
4344
|
+
O("pre", Vl, Z(no.value), 1)
|
|
4345
|
+
], 64)) : U("", !0)
|
|
4346
|
+
])) : l.value.type !== "agent" ? (I(), fe(b(T), {
|
|
4347
|
+
ref_key: "area",
|
|
4348
|
+
ref: B,
|
|
4349
|
+
key: e.sceneKey + ":" + l.value.type + ":" + eo.value,
|
|
4350
|
+
"model-value": l.value.knowledge.doc || b(wn)(),
|
|
4351
|
+
editable: !Q.value,
|
|
4352
|
+
"schema-plan": Zt.value,
|
|
4353
|
+
"active-choice-id": r.value === ((d = M.value) == null ? void 0 : d.kind) ? (m = M.value) == null ? void 0 : m.nodeId : null,
|
|
4354
|
+
placeholder: l.value.type === "reasoning" ? Fl : "填写知识内容",
|
|
4355
|
+
onFocusin: pi,
|
|
4356
|
+
onPasteCapture: Pi,
|
|
4357
|
+
onDragoverCapture: xi,
|
|
4358
|
+
onDropCapture: Mi,
|
|
4359
|
+
"onUpdate:modelValue": fi,
|
|
4360
|
+
onRetryMedia: b(Ri),
|
|
4361
|
+
onLoadError: vi,
|
|
4362
|
+
onEditTool: Ei,
|
|
4363
|
+
onChoiceMenu: Ti,
|
|
4364
|
+
onLeaveChoice: cn
|
|
4365
|
+
}, null, 8, ["model-value", "editable", "schema-plan", "active-choice-id", "placeholder", "onRetryMedia"])) : (I(), _("div", $l, [
|
|
4366
|
+
We.value ? (I(), _("div", Bl, Z(We.value.name), 1)) : U("", !0),
|
|
4367
|
+
ko.value ? (I(), _("div", {
|
|
4368
|
+
key: 1,
|
|
4369
|
+
class: Be({
|
|
4370
|
+
placeholder: ue.value !== "ready" || !pe.value
|
|
4371
|
+
})
|
|
4372
|
+
}, Z(ko.value), 3)) : U("", !0)
|
|
4373
|
+
]))
|
|
4374
|
+
]),
|
|
4375
|
+
P(b(ee), {
|
|
4376
|
+
class: "fkp-delete",
|
|
4377
|
+
type: "text",
|
|
4378
|
+
"aria-label": "清空行为与知识",
|
|
4379
|
+
disabled: Q.value,
|
|
4380
|
+
onClick: Li
|
|
4381
|
+
}, {
|
|
4382
|
+
default: K(() => [
|
|
4383
|
+
P(b(Wi), { size: 19 })
|
|
4384
|
+
]),
|
|
4385
|
+
_: 1
|
|
4386
|
+
}, 8, ["disabled"])
|
|
4387
|
+
], 2),
|
|
4388
|
+
O("input", {
|
|
4389
|
+
ref_key: "fileInput",
|
|
4390
|
+
ref: tn,
|
|
4391
|
+
type: "file",
|
|
4392
|
+
accept: ti.value,
|
|
4393
|
+
multiple: "",
|
|
4394
|
+
hidden: "",
|
|
4395
|
+
"aria-label": "选择媒体文件",
|
|
4396
|
+
onChange: _i
|
|
4397
|
+
}, null, 40, Ul)
|
|
4398
|
+
], 34);
|
|
4399
|
+
};
|
|
4400
|
+
}
|
|
4401
|
+
});
|
|
4402
|
+
export {
|
|
4403
|
+
ns as _,
|
|
4404
|
+
wn as a,
|
|
4405
|
+
Tn as b,
|
|
4406
|
+
Le as c,
|
|
4407
|
+
Ra as d,
|
|
4408
|
+
Ln as e,
|
|
4409
|
+
es as f,
|
|
4410
|
+
Ql as g,
|
|
4411
|
+
Zl as h,
|
|
4412
|
+
wa as i,
|
|
4413
|
+
Sn as p,
|
|
4414
|
+
Zn as r,
|
|
4415
|
+
Xl as v
|
|
4416
|
+
};
|