@openbkn/workshop 0.2.2 → 0.3.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{ActionConfirm-DJ91X3ml.js → ActionConfirm-BX1dlrAM.js} +5 -5
- package/dist/{ActionFailure-ZgPt_3B-.js → ActionFailure-xcSfKJYC.js} +2 -2
- package/dist/{AgentChat-CRYai8ge.js → AgentChat-DHdX_6W7.js} +407 -383
- package/dist/AppListPage-DsUvFo6B.js +1549 -0
- package/dist/{AskDrawer-BUMYsRnt.js → AskDrawer-j-CR4yXP.js} +4 -4
- package/dist/{ComputedView-CgYrDbx1.js → ComputedView-dWFlHngu.js} +1035 -1016
- package/dist/{ConclusionApply-sjGfoEBY.js → ConclusionApply-BAoZpxl-.js} +4 -4
- package/dist/{CypherEditor-lus6FA5L.js → CypherEditor-CZ5Z4SGH.js} +47 -47
- package/dist/{LandingList-6JI6864C.js → LandingList-BUO6-at_.js} +5 -5
- package/dist/{MenuUnfoldOutlined-Cdg24l2h.js → MenuUnfoldOutlined-DAeIeIap.js} +3 -3
- package/dist/{ModelTrial-ClHFGTpQ.js → ModelTrial-C7XvLVY7.js} +4 -4
- package/dist/{PageRenderer-DBd_g6mN.js → PageRenderer-CkmvW4aO.js} +21264 -20549
- package/dist/{ScenarioApply-DtW_hh47.js → ScenarioApply-COdlyvrC.js} +6 -6
- package/dist/{SimulateForm-C-i08Jjd.js → SimulateForm-B_9laTIl.js} +4 -4
- package/dist/{Subgraph-CnrkH9AN.js → Subgraph-CDY3wvCA.js} +3 -3
- package/dist/WorkshopLabPage-BtYnBpk4.js +12020 -0
- package/dist/{WorkshopRunPage-6hjRUf64.js → WorkshopRunPage-DHMJ3b8k.js} +24 -24
- package/dist/{abnfDiagram-WEYOIA3C-beRNhN3c.js → abnfDiagram-WEYOIA3C-Blje2Kbf.js} +3 -3
- package/dist/{action-type-tool.service-B2B74fKC.js → action-type-tool.service-BN-W_Az_.js} +1 -1
- package/dist/{architectureDiagram-ZHVYKT53-DY2l1qxx.js → architectureDiagram-ZHVYKT53-B_FkRXc3.js} +3 -3
- package/dist/{bkn-agent-execution.service-DVh-SHyl.js → bkn-agent-execution.service-CJalMVIc.js} +1 -1
- package/dist/{blockDiagram-RJAE7QA3-DR0mjN2h.js → blockDiagram-RJAE7QA3-CYJLthoI.js} +3 -3
- package/dist/{c4Diagram-XDPPPE54-DH5zsGug.js → c4Diagram-XDPPPE54-CmMaN3M4.js} +2 -2
- package/dist/{channel-B034hcOF.js → channel-Dp24Bgua.js} +1 -1
- package/dist/{chunk-2E7WHVMD-Ba3svxgx.js → chunk-2E7WHVMD-DrnpfYKB.js} +1 -1
- package/dist/{chunk-2Q5K7J3B-rT4eU6_y.js → chunk-2Q5K7J3B-BXqKcHlQ.js} +1 -1
- package/dist/{chunk-4EMNKR2T-C1kQZYHK.js → chunk-4EMNKR2T-DYgY_0_y.js} +1 -1
- package/dist/{chunk-55XCU76K-dcpLOktb.js → chunk-55XCU76K-Bja7bE8g.js} +1 -1
- package/dist/{chunk-5VM5RSS4-BdpQuzmO.js → chunk-5VM5RSS4-CGTnbRRi.js} +1 -1
- package/dist/{chunk-JWPE2WC7-CDBrSjU7.js → chunk-JWPE2WC7-2AyjxdJR.js} +1 -1
- package/dist/{chunk-VQ5W62QI-BiVKc40w.js → chunk-VQ5W62QI-B3PGCKOg.js} +1 -1
- package/dist/{chunk-XXDRQBXY-CPYrcdVW.js → chunk-XXDRQBXY-RrIsI-B5.js} +1 -1
- package/dist/{chunk-ZCHMQSOR-BG8OLpvb.js → chunk-ZCHMQSOR-COJTBW1i.js} +2 -2
- package/dist/{classDiagram-v2-4MYWR3UA-DqbpQpwI.js → classDiagram-v2-4MYWR3UA-DolLxH6t.js} +5 -5
- package/dist/{cose-bilkent-JH36ORCC-CdXk4sPf.js → cose-bilkent-JH36ORCC-DMSYgFxc.js} +2 -2
- package/dist/customComponents-DasaZ6pq.js +1 -1
- package/dist/customComponents.en-US-CkabuCXg.js +1 -1
- package/dist/{customParseFormat-C0uLEpdq.js → customParseFormat-C9WAjjqH.js} +1 -1
- package/dist/{cynefinDiagram-WF24UDRP-BYT_KpDL.js → cynefinDiagram-WF24UDRP-DrksRWCn.js} +2 -2
- package/dist/{dagre-NK4GIZVX-l-ghPdM8.js → dagre-NK4GIZVX-CFRT2dAc.js} +2 -2
- package/dist/{dayjs.min-DZ-YV8Mv.js → dayjs.min-CziT8yW9.js} +1 -1
- package/dist/{diagram-CBK3MWTC-Bt3HiwvA.js → diagram-CBK3MWTC-DzZ_sQCl.js} +3 -3
- package/dist/{diagram-I5XIIV2D-DcbqfBjx.js → diagram-I5XIIV2D-RYNBUOF4.js} +2 -2
- package/dist/{diagram-ODIL2UCW-9PC1n3n5.js → diagram-ODIL2UCW-DqJETE9R.js} +3 -3
- package/dist/{diagram-PFBEJUXE-DGhr2kc7.js → diagram-PFBEJUXE-BekIE7hh.js} +2 -2
- package/dist/{diagram-RJA3I4VV-DwzpOjZ_.js → diagram-RJA3I4VV-DAIwlMxl.js} +2 -2
- package/dist/{diagram-TYUNFSNR-B3Bd3TDU.js → diagram-TYUNFSNR-CLJ0Ou9i.js} +6 -6
- package/dist/{ebnfDiagram-V4P3TTPT-E5NN2oKc.js → ebnfDiagram-V4P3TTPT-CRs8ppfT.js} +3 -3
- package/dist/{elk-QONTBCTQ-dFjcujl_.js → elk-QONTBCTQ-Bqoh6AYY.js} +5 -5
- package/dist/{erDiagram-KYQIGQAA-BMrasBzB.js → erDiagram-KYQIGQAA-BSp8Z7uQ.js} +4 -4
- package/dist/{flowDiagram-IUGLLWBU-BGIBH0q0.js → flowDiagram-IUGLLWBU-WKILTCDc.js} +7 -7
- package/dist/{ganttDiagram-R7GPNTJY-C0tb1Lpp.js → ganttDiagram-R7GPNTJY-CaTn_Mmr.js} +4 -4
- package/dist/generateCypher-BE_4YCWB.js +1032 -0
- package/dist/{gitGraphDiagram-PDYL7XHY-DBqcOa-c.js → gitGraphDiagram-PDYL7XHY-DGPs-RF6.js} +3 -3
- package/dist/{infoDiagram-MVDRKAX5-Bwuki4JA.js → infoDiagram-MVDRKAX5-HIQg7U3R.js} +1 -1
- package/dist/{ishikawaDiagram-HPEHV2GE-Dz4d6ygx.js → ishikawaDiagram-HPEHV2GE-C84x8n2j.js} +2 -2
- package/dist/{journeyDiagram-BOSHW7O7-C99m34Bb.js → journeyDiagram-BOSHW7O7-CvYDNxSY.js} +4 -4
- package/dist/{kanban-definition-FNSA4HC5-mdqjODsT.js → kanban-definition-FNSA4HC5-B586ryFD.js} +2 -2
- package/dist/{mermaid.core-yQghUlIz.js → mermaid.core-3J01L12Z.js} +5803 -5740
- package/dist/{mindmap-definition-6OY57UG3-BZhO2wX4.js → mindmap-definition-6OY57UG3-Donc6BMy.js} +3 -3
- package/dist/{models-DekiCOuZ.js → models-Rf3LB8wS.js} +1 -1
- package/dist/{object-metric-numeric-vs3BeDkH.js → object-metric-numeric-BcgaJ6EW.js} +1 -1
- package/dist/{object-metric.service-flZgBMRX.js → object-metric.service-CKiaFYcp.js} +2 -2
- package/dist/{pegDiagram-ECIUJNBX-BDa5RfZt.js → pegDiagram-ECIUJNBX-CYVi7x6D.js} +3 -3
- package/dist/{pieDiagram-GNMPY74T-DNVtzXPv.js → pieDiagram-GNMPY74T-4iWKYTTS.js} +2 -2
- package/dist/{prompt-DYrjlEFr.js → prompt-BQzBLrua.js} +110 -100
- package/dist/{quadrantDiagram-D57K4MC3-vK0f2OvQ.js → quadrantDiagram-D57K4MC3-Bm6Cyi1I.js} +1 -1
- package/dist/{railroadDiagram-Y72NRBL7-j6ZrTmRp.js → railroadDiagram-Y72NRBL7-Du6iN-Jz.js} +3 -3
- package/dist/{requirementDiagram-EQYSW5RA-DgfEyljA.js → requirementDiagram-EQYSW5RA-BGxpuSlc.js} +3 -3
- package/dist/{sankeyDiagram-SY24JHO5-CImx-IX0.js → sankeyDiagram-SY24JHO5-CsHmu__D.js} +2 -2
- package/dist/{sequenceDiagram-BLEHNHQU-nWmjd1ci.js → sequenceDiagram-BLEHNHQU-DBNi943L.js} +3 -3
- package/dist/{sizeCapture-INFHLROL-D3jlbt7h.js → sizeCapture-INFHLROL-CcGr2ilA.js} +1 -1
- package/dist/{stateDiagram-v2-A6IESKWZ-DG1ZetEu.js → stateDiagram-v2-A6IESKWZ-C78tVzaF.js} +4 -4
- package/dist/{swimlanes-B3ENRKFQ-cCmJE8AU.js → swimlanes-B3ENRKFQ-BROc4LGM.js} +3 -3
- package/dist/{swimlanesDiagram-AYQRV4AK-CtuhyguU.js → swimlanesDiagram-AYQRV4AK-C0RDY4m2.js} +3 -3
- package/dist/{text-BqSVQKS6.js → text-CzC6K33E.js} +7 -3
- package/dist/{text.en-US-BhAxy_LE.js → text.en-US-D8mxBP0p.js} +6 -2
- package/dist/{timeline-definition-JXYKGLGB-Cc-INsOv.js → timeline-definition-JXYKGLGB-C6WGe4xl.js} +1 -1
- package/dist/toolMatchLines-DrXpUwcl.js +4675 -0
- package/dist/{useLabData-Df-jEHKs.js → useLabData-B-3UW8zF.js} +8008 -7251
- package/dist/{usecaseDiagram-WPOLBNNX-r8wVjopm.js → usecaseDiagram-WPOLBNNX-yMP7SDIg.js} +3 -3
- package/dist/{vennDiagram-Q3Y3IDCW-BZiOcgrj.js → vennDiagram-Q3Y3IDCW-bZW2LzBB.js} +2 -2
- package/dist/{wardleyDiagram-IVAIDKWA-16jd07C_.js → wardleyDiagram-IVAIDKWA-DBbog93x.js} +2 -2
- package/dist/{workshop-app-DnHNjBqy.js → workshop-app-ByYXbgcn.js} +5060 -4721
- package/dist/workshop-app.css +1 -1
- package/dist/workshop-app.js +1 -1
- package/dist/{xychartDiagram-4URNHDU4-C8DwWQNh.js → xychartDiagram-4URNHDU4-CVLJNXOt.js} +1 -1
- package/dist-cli/workshop.js +182 -140
- package/package.json +1 -1
- package/skill/SKILL.en-US.md +5 -0
- package/skill/SKILL.md +3 -0
- package/dist/AppFormModal-D73ucaHK.js +0 -4282
- package/dist/AppListPage-D87piiOw.js +0 -1364
- package/dist/WorkshopLabPage-DiVXQL9e.js +0 -11364
- package/dist/generateCypher-Ch9_lQa6.js +0 -399
|
@@ -1,118 +1,130 @@
|
|
|
1
|
-
import { N as
|
|
2
|
-
import { ag as
|
|
3
|
-
import { r as
|
|
4
|
-
import { l as
|
|
5
|
-
import { d as
|
|
6
|
-
import { R as
|
|
7
|
-
var Z = {},
|
|
8
|
-
function
|
|
9
|
-
if (
|
|
10
|
-
|
|
1
|
+
import { N as Ke, r as m, O as Xe, am as A, an as C, aa as bt, z as te, c as Ge, U as Qe, ao as wt, h as kt, a9 as vt, u as xt, j as a, i as jt, a as M, I as $t, Y as St } from "./workshop-app-ByYXbgcn.js";
|
|
2
|
+
import { ag as Ot, ah as Ze, ai as Lt, aj as Me, b as x, ak as Et, al as _t, C as Ie } from "./PageRenderer-CkmvW4aO.js";
|
|
3
|
+
import { r as ne, a as se, aW as Rt, aX as Nt, aY as Tt, aZ as Pe, a8 as At, a_ as Ct, a$ as ke, b0 as Mt, b1 as It, b2 as Pt, b3 as Bt, b4 as Dt, u as Ft, b5 as Yt, b as zt, b6 as qt, b7 as Ut, b8 as Be, b9 as De, ba as Vt, A as H, R as Fe, T as Jt, p as Wt, bb as Ht, bc as Ye, bd as Kt, be as Xt, bf as Gt, bg as Qt, bh as Zt, bi as es, bj as ts } from "./useLabData-B-3UW8zF.js";
|
|
4
|
+
import { l as ss } from "./models-Rf3LB8wS.js";
|
|
5
|
+
import { d as ns } from "./prompt-BQzBLrua.js";
|
|
6
|
+
import { R as rs } from "./MenuUnfoldOutlined-DAeIeIap.js";
|
|
7
|
+
var Z = {}, ze;
|
|
8
|
+
function os() {
|
|
9
|
+
if (ze) return Z;
|
|
10
|
+
ze = 1, Object.defineProperty(Z, "__esModule", { value: !0 });
|
|
11
11
|
var s = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M872 474H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h720c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z" } }] }, name: "minus", theme: "outlined" };
|
|
12
12
|
return Z.default = s, Z;
|
|
13
13
|
}
|
|
14
|
-
var
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
return
|
|
14
|
+
var as = /* @__PURE__ */ os();
|
|
15
|
+
const is = /* @__PURE__ */ Ke(as);
|
|
16
|
+
function ye() {
|
|
17
|
+
return ye = Object.assign ? Object.assign.bind() : function(s) {
|
|
18
18
|
for (var o = 1; o < arguments.length; o++) {
|
|
19
19
|
var r = arguments[o];
|
|
20
|
-
for (var
|
|
21
|
-
Object.prototype.hasOwnProperty.call(r,
|
|
20
|
+
for (var p in r)
|
|
21
|
+
Object.prototype.hasOwnProperty.call(r, p) && (s[p] = r[p]);
|
|
22
22
|
}
|
|
23
23
|
return s;
|
|
24
|
-
},
|
|
24
|
+
}, ye.apply(this, arguments);
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const ls = (s, o) => /* @__PURE__ */ m.createElement(Xe, ye({}, s, {
|
|
27
27
|
ref: o,
|
|
28
|
-
icon:
|
|
29
|
-
})),
|
|
30
|
-
var ee = {},
|
|
31
|
-
function
|
|
32
|
-
if (
|
|
33
|
-
|
|
28
|
+
icon: is
|
|
29
|
+
})), cs = /* @__PURE__ */ m.forwardRef(ls);
|
|
30
|
+
var ee = {}, qe;
|
|
31
|
+
function us() {
|
|
32
|
+
if (qe) return ee;
|
|
33
|
+
qe = 1, Object.defineProperty(ee, "__esModule", { value: !0 });
|
|
34
34
|
var s = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M304 176h80v672h-80zm408 0h-64c-4.4 0-8 3.6-8 8v656c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V184c0-4.4-3.6-8-8-8z" } }] }, name: "pause", theme: "outlined" };
|
|
35
35
|
return ee.default = s, ee;
|
|
36
36
|
}
|
|
37
|
-
var
|
|
38
|
-
const
|
|
39
|
-
function
|
|
40
|
-
return
|
|
37
|
+
var ds = /* @__PURE__ */ us();
|
|
38
|
+
const ps = /* @__PURE__ */ Ke(ds);
|
|
39
|
+
function be() {
|
|
40
|
+
return be = Object.assign ? Object.assign.bind() : function(s) {
|
|
41
41
|
for (var o = 1; o < arguments.length; o++) {
|
|
42
42
|
var r = arguments[o];
|
|
43
|
-
for (var
|
|
44
|
-
Object.prototype.hasOwnProperty.call(r,
|
|
43
|
+
for (var p in r)
|
|
44
|
+
Object.prototype.hasOwnProperty.call(r, p) && (s[p] = r[p]);
|
|
45
45
|
}
|
|
46
46
|
return s;
|
|
47
|
-
},
|
|
47
|
+
}, be.apply(this, arguments);
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const gs = (s, o) => /* @__PURE__ */ m.createElement(Xe, be({}, s, {
|
|
50
50
|
ref: o,
|
|
51
|
-
icon:
|
|
52
|
-
})),
|
|
53
|
-
function
|
|
54
|
-
const r = s.spec.sources.filter((
|
|
51
|
+
icon: ps
|
|
52
|
+
})), fs = /* @__PURE__ */ m.forwardRef(gs);
|
|
53
|
+
function Ue(s, o) {
|
|
54
|
+
const r = s.spec.sources.filter((d) => !d.events).map((d) => `${d.label}(对象类 ${d.objectType})`), p = Ot(s.spec, s.values), n = o ? s.values[o] : void 0, e = o ? s.spec.variables.find((d) => d.name === o) : void 0, c = e && "source" in e ? ne(s.spec, e.source) : void 0;
|
|
55
55
|
return `<page_context>
|
|
56
56
|
${[
|
|
57
57
|
`应用页面:${s.spec.title};基准日期 ${s.asOf}`,
|
|
58
58
|
r.length > 0 ? `页面上的数据:${r.join("、")}` : "",
|
|
59
|
-
Object.keys(
|
|
60
|
-
n &&
|
|
59
|
+
Object.keys(p).length > 0 ? `当前筛选:${Object.entries(p).map(([d, f]) => `${d} = ${JSON.stringify(f)}`).join(";")}` : "",
|
|
60
|
+
n && c ? `选中的对象:${c.label}(对象类 ${c.objectType})主键 ${String(n)};用户说“这个”时指它` : ""
|
|
61
61
|
].filter(Boolean).join(`
|
|
62
62
|
`)}
|
|
63
63
|
</page_context>`;
|
|
64
64
|
}
|
|
65
|
-
let
|
|
66
|
-
function
|
|
67
|
-
return
|
|
65
|
+
let fe = null;
|
|
66
|
+
function ms() {
|
|
67
|
+
return fe ??= ss({ page: 1, size: 100 }).then(({ items: s }) => {
|
|
68
68
|
const o = s.filter((r) => r.modelType === "llm" || r.modelType === "rlm");
|
|
69
69
|
return (o.find((r) => r.default) ?? o[0])?.modelName;
|
|
70
70
|
}).catch(() => {
|
|
71
|
-
|
|
72
|
-
}),
|
|
71
|
+
fe = null;
|
|
72
|
+
}), fe;
|
|
73
73
|
}
|
|
74
|
-
const
|
|
74
|
+
const me = 50, Ve = 8e3, I = (s) => {
|
|
75
75
|
const o = JSON.stringify(s);
|
|
76
|
-
return o.length >
|
|
76
|
+
return o.length > Ve ? `${o.slice(0, Ve)}…(已截断)` : o;
|
|
77
77
|
};
|
|
78
78
|
function z(s, o, r) {
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const
|
|
79
|
+
const p = ne(s.spec, o), n = s.sources[o] ?? s.sources[p?.from?.source ?? ""];
|
|
80
|
+
if (!p || n?.status !== "ready") {
|
|
81
|
+
const d = s.spec.sources.filter((f) => !f.events).map((f) => `${f.id}(${f.label})`);
|
|
82
82
|
throw new Error(
|
|
83
|
-
`${
|
|
83
|
+
`${p ? `数据源 ${o} 还没读完` : `没有数据源 ${o}`};页面上的数据源 id:${d.join("、")}`
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
|
-
const e = s.overlay?.rows[
|
|
87
|
-
return r ?
|
|
86
|
+
const e = s.overlay?.rows[p.from?.source ?? p.id] ?? n.rows, c = Qe(e, p, s.asOf), l = p.from ? At(c, p.from, s.spec.variables, s.values, s.asOf) : c;
|
|
87
|
+
return r ? Ct(l, ke(s.spec, p.id), s.spec.variables, s.values) : l;
|
|
88
|
+
}
|
|
89
|
+
async function he(s, o) {
|
|
90
|
+
const r = z(s, o, !0), p = ne(s.spec, o);
|
|
91
|
+
if (!s.link || !p) return r;
|
|
92
|
+
const n = await Mt(
|
|
93
|
+
ke(s.spec, p.id),
|
|
94
|
+
p,
|
|
95
|
+
s.spec.sources,
|
|
96
|
+
s.kn,
|
|
97
|
+
s.link
|
|
98
|
+
);
|
|
99
|
+
return n.test ? r.filter(n.test) : r;
|
|
88
100
|
}
|
|
89
|
-
function
|
|
101
|
+
function hs(s) {
|
|
90
102
|
return s.spec.variables.map((o) => ({
|
|
91
103
|
name: o.name,
|
|
92
104
|
label: o.label,
|
|
93
105
|
kind: o.kind,
|
|
94
106
|
value: o.kind === "asOf" ? s.asOf : s.values[o.name] ?? null,
|
|
95
107
|
followedBy: s.spec.sources.flatMap(
|
|
96
|
-
(r) =>
|
|
108
|
+
(r) => ke(s.spec, r.id).filter((p) => p.variable === o.name).map((p) => ({ source: r.id, field: p.field ?? p.fields ?? null }))
|
|
97
109
|
)
|
|
98
110
|
}));
|
|
99
111
|
}
|
|
100
|
-
function
|
|
112
|
+
function Je(s, o) {
|
|
101
113
|
let r = s;
|
|
102
|
-
for (const [
|
|
114
|
+
for (const [p, n] of Object.entries(o ?? {})) {
|
|
103
115
|
const e = (Array.isArray(n) ? n : [n]).map(String);
|
|
104
|
-
r = r.filter((
|
|
116
|
+
r = r.filter((c) => e.includes(String(c[p] ?? "")));
|
|
105
117
|
}
|
|
106
118
|
return r;
|
|
107
119
|
}
|
|
108
|
-
const
|
|
120
|
+
const We = {
|
|
109
121
|
type: "object",
|
|
110
|
-
description: `字段等于某值(或属于几个值之一),进度列和计算列也可以用,比如 { "${
|
|
122
|
+
description: `字段等于某值(或属于几个值之一),进度列和计算列也可以用,比如 { "${bt.status}": ["${te.overdue.value}"] }(进度状态写代码)`,
|
|
111
123
|
additionalProperties: {
|
|
112
124
|
anyOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
113
125
|
}
|
|
114
126
|
};
|
|
115
|
-
function
|
|
127
|
+
function ys(s, o) {
|
|
116
128
|
const r = {
|
|
117
129
|
page_context: A({
|
|
118
130
|
description: "读取页面现状:基准日期、各筛选的当前值和谁跟随它、选中的对象,以及每个数据源的进度定义、计算列规则、在当前筛选下和全部的对象数。回答前先调用它。",
|
|
@@ -121,34 +133,40 @@ function ps(s, o) {
|
|
|
121
133
|
properties: {}
|
|
122
134
|
}),
|
|
123
135
|
execute: async () => {
|
|
124
|
-
const e = s(),
|
|
125
|
-
const
|
|
136
|
+
const e = s(), c = e.spec.variables.filter((l) => l.kind === "selection" && !Pe(l.name)).map((l) => {
|
|
137
|
+
const d = e.values[l.name], f = typeof d == "string" && "source" in l ? z(e, l.source, !1).find((g) => g.$key === d) : void 0;
|
|
126
138
|
return {
|
|
127
139
|
filter: l.name,
|
|
128
|
-
key:
|
|
129
|
-
object:
|
|
140
|
+
key: d ?? null,
|
|
141
|
+
object: f ?? null
|
|
130
142
|
};
|
|
131
143
|
});
|
|
132
144
|
return I({
|
|
133
145
|
title: e.spec.title,
|
|
134
146
|
asOf: e.asOf,
|
|
135
|
-
filters:
|
|
136
|
-
selected:
|
|
137
|
-
sources:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
filters: hs(e),
|
|
148
|
+
selected: c,
|
|
149
|
+
sources: await Promise.all(
|
|
150
|
+
e.spec.sources.map(async (l) => ({
|
|
151
|
+
id: l.id,
|
|
152
|
+
label: l.label,
|
|
153
|
+
objectType: l.objectType,
|
|
154
|
+
fields: Ge(l, e.kn).map((d) => `${d.name}:${d.type}`),
|
|
155
|
+
progress: l.progress ?? null,
|
|
156
|
+
computed: (l.computed ?? []).map((d) => ({
|
|
157
|
+
name: d.name,
|
|
158
|
+
label: d.label,
|
|
159
|
+
rule: d
|
|
160
|
+
})),
|
|
161
|
+
// Not known yet, as while it loads, where the objects reached are slow to read.
|
|
162
|
+
inView: e.sources[l.id]?.status === "ready" ? await he(e, l.id).then(
|
|
163
|
+
(d) => d.length,
|
|
164
|
+
() => null
|
|
165
|
+
) : null,
|
|
166
|
+
total: e.sources[l.id]?.status === "ready" ? z(e, l.id, !1).length : null
|
|
167
|
+
}))
|
|
168
|
+
),
|
|
169
|
+
...bs(e.spec)
|
|
152
170
|
});
|
|
153
171
|
}
|
|
154
172
|
}),
|
|
@@ -158,10 +176,10 @@ function ps(s, o) {
|
|
|
158
176
|
type: "object",
|
|
159
177
|
properties: {
|
|
160
178
|
source: { type: "string", description: "数据源 id" },
|
|
161
|
-
where:
|
|
179
|
+
where: We,
|
|
162
180
|
sort: { type: "string" },
|
|
163
181
|
order: { type: "string", enum: ["asc", "desc"] },
|
|
164
|
-
limit: { type: "number", description: `最多 ${
|
|
182
|
+
limit: { type: "number", description: `最多 ${me} 条` },
|
|
165
183
|
fields: { type: "array", items: { type: "string" } },
|
|
166
184
|
ignoreFilters: {
|
|
167
185
|
type: "boolean",
|
|
@@ -176,13 +194,16 @@ function ps(s, o) {
|
|
|
176
194
|
required: ["source"]
|
|
177
195
|
}),
|
|
178
196
|
execute: async (e) => {
|
|
179
|
-
const
|
|
180
|
-
let
|
|
181
|
-
|
|
182
|
-
|
|
197
|
+
const c = s(), l = e.keys?.length ? new Set(e.keys.map(String)) : null, d = !e.ignoreFilters && !l;
|
|
198
|
+
let f = Je(
|
|
199
|
+
d ? await he(c, e.source) : z(c, e.source, !1),
|
|
200
|
+
e.where
|
|
201
|
+
);
|
|
202
|
+
l && (f = f.filter((b) => l.has(String(b.$key)))), e.sort && (f = [...f].sort(Tt(e.sort, e.order ?? "desc")));
|
|
203
|
+
const g = Math.min(e.limit ?? 20, me), h = (b) => e.fields?.length ? Object.fromEntries([["$key", b.$key], ...e.fields.map((L) => [L, b[L]])]) : b;
|
|
183
204
|
return I({
|
|
184
|
-
total:
|
|
185
|
-
rows:
|
|
205
|
+
total: f.length,
|
|
206
|
+
rows: f.slice(0, g).map(h)
|
|
186
207
|
});
|
|
187
208
|
}
|
|
188
209
|
}),
|
|
@@ -193,7 +214,7 @@ function ps(s, o) {
|
|
|
193
214
|
properties: {
|
|
194
215
|
source: { type: "string" },
|
|
195
216
|
groupBy: { type: "string" },
|
|
196
|
-
where:
|
|
217
|
+
where: We,
|
|
197
218
|
sumField: { type: "string" },
|
|
198
219
|
avgField: { type: "string" },
|
|
199
220
|
limit: { type: "number" },
|
|
@@ -202,16 +223,19 @@ function ps(s, o) {
|
|
|
202
223
|
required: ["source", "groupBy"]
|
|
203
224
|
}),
|
|
204
225
|
execute: async (e) => {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
226
|
+
const c = s(), l = Je(
|
|
227
|
+
e.ignoreFilters ? z(c, e.source, !1) : await he(c, e.source),
|
|
228
|
+
e.where
|
|
229
|
+
), d = [...Rt(l, e.groupBy)].map(([f, g]) => ({
|
|
230
|
+
[e.groupBy]: f,
|
|
231
|
+
value: Nt(g, {
|
|
208
232
|
aggregate: e.avgField ? "avg" : e.sumField ? "sum" : "count",
|
|
209
233
|
valueField: e.avgField ?? e.sumField
|
|
210
234
|
}) ?? 0
|
|
211
|
-
})).sort((
|
|
235
|
+
})).sort((f, g) => g.value - f.value);
|
|
212
236
|
return I({
|
|
213
|
-
groups:
|
|
214
|
-
top:
|
|
237
|
+
groups: d.length,
|
|
238
|
+
top: d.slice(0, Math.min(e.limit ?? 15, me))
|
|
215
239
|
});
|
|
216
240
|
}
|
|
217
241
|
}),
|
|
@@ -224,10 +248,10 @@ function ps(s, o) {
|
|
|
224
248
|
}),
|
|
225
249
|
execute: async ({ query: e }) => I(await s().run(e))
|
|
226
250
|
})
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
description: `向用户建议执行知识网络里的一个行动。这只是建议:页面会显示一张建议卡,用户点“执行”并确认后才会执行,你自己不能执行,也不要说已经执行。只能建议这些行动:${
|
|
230
|
-
(e) => `${e.id}(${e.name},作用于对象类 ${e.objectType}${e.inputs.length > 0 ? `,要填 ${e.inputs.map((
|
|
251
|
+
}, p = (o.actions ?? []).map((e) => se(s().kn, e)).filter((e) => e !== void 0);
|
|
252
|
+
p.length > 0 && (r.propose_action = A({
|
|
253
|
+
description: `向用户建议执行知识网络里的一个行动。这只是建议:页面会显示一张建议卡,用户点“执行”并确认后才会执行,你自己不能执行,也不要说已经执行。只能建议这些行动:${p.map(
|
|
254
|
+
(e) => `${e.id}(${e.name},作用于对象类 ${e.objectType}${e.inputs.length > 0 ? `,要填 ${e.inputs.map((c) => c.name).join("、")}` : ""})`
|
|
231
255
|
).join(
|
|
232
256
|
";"
|
|
233
257
|
)}。keys 为要执行的对象的 $key(取自 list_objects 的结果),params 为你建议的参数值(用户可以改),reason 说明为什么建议。`,
|
|
@@ -241,27 +265,27 @@ function ps(s, o) {
|
|
|
241
265
|
},
|
|
242
266
|
required: ["action", "keys", "reason"]
|
|
243
267
|
}),
|
|
244
|
-
execute: async ({ action: e, keys:
|
|
245
|
-
const
|
|
246
|
-
if (!
|
|
247
|
-
const g =
|
|
268
|
+
execute: async ({ action: e, keys: c, reason: l }) => {
|
|
269
|
+
const d = s(), f = p.find((h) => h.id === e);
|
|
270
|
+
if (!f) throw new Error(`不能建议这个行动:${e}`);
|
|
271
|
+
const g = Ze(d, f.objectType, c);
|
|
248
272
|
if (!g)
|
|
249
273
|
throw new Error("页面上的数据里找不到这些对象;先用 list_objects 找到它们的 $key");
|
|
250
274
|
return I({
|
|
251
275
|
ok: !0,
|
|
252
|
-
shown: `建议卡:${
|
|
253
|
-
missing:
|
|
276
|
+
shown: `建议卡:${f.name},${g.rows.length} 个对象`,
|
|
277
|
+
missing: c.length - g.rows.length,
|
|
254
278
|
reason: l,
|
|
255
279
|
note: "等用户确认,尚未执行"
|
|
256
280
|
});
|
|
257
281
|
}
|
|
258
282
|
}));
|
|
259
283
|
const n = s().spec.sources.flatMap(
|
|
260
|
-
(e) => e.from || e.cypher || e.events ? [] : (e.operations ?? []).map((
|
|
284
|
+
(e) => e.from || e.cypher || e.events ? [] : (e.operations ?? []).map((c) => ({ source: e, operation: c }))
|
|
261
285
|
);
|
|
262
286
|
return o.simulate && n.length > 0 && (r.propose_scenario = A({
|
|
263
287
|
description: `向用户建议在方案中做一个推演(假设),用来回答“如果这样会怎样”。这只是建议:页面会显示一张建议卡,用户确认后才加入方案;推演不执行行动,也不改知识网络,你不要说已经加入或已经执行。只能用这些推演操作(数据源 id.操作 id):${n.map(
|
|
264
|
-
({ source: e, operation:
|
|
288
|
+
({ source: e, operation: c }) => `${e.id}.${c.id}(${c.label},参数 ${c.params.map((l) => `${l.name}:${l.label},${l.type}`).join("、")})`
|
|
265
289
|
).join(
|
|
266
290
|
";"
|
|
267
291
|
)}。keys 为对象的 $key(取自 list_objects),params 为你建议的参数值(用户可以改),reason 说明为什么这样假设。`,
|
|
@@ -276,20 +300,20 @@ function ps(s, o) {
|
|
|
276
300
|
},
|
|
277
301
|
required: ["source", "operation", "keys", "reason"]
|
|
278
302
|
}),
|
|
279
|
-
execute: async ({ source: e, operation:
|
|
280
|
-
const
|
|
281
|
-
(
|
|
303
|
+
execute: async ({ source: e, operation: c, keys: l }) => {
|
|
304
|
+
const d = s(), f = n.find(
|
|
305
|
+
(L) => L.source.id === e && L.operation.id === c
|
|
282
306
|
);
|
|
283
|
-
if (!
|
|
284
|
-
const g = new Set(l.map(String)),
|
|
285
|
-
if (
|
|
307
|
+
if (!f) throw new Error(`没有这个推演操作:${e}.${c}`);
|
|
308
|
+
const g = new Set(l.map(String)), h = z(d, e, !1).filter((L) => g.has(String(L.$key)));
|
|
309
|
+
if (h.length === 0)
|
|
286
310
|
throw new Error("页面上的数据里找不到这些对象;先用 list_objects 找到它们的 $key");
|
|
287
|
-
const
|
|
311
|
+
const b = h.filter((L) => kt(L, f.operation.when, d.asOf));
|
|
288
312
|
return I({
|
|
289
313
|
ok: !0,
|
|
290
|
-
shown: `建议卡:${
|
|
291
|
-
notEligible:
|
|
292
|
-
missing: l.length -
|
|
314
|
+
shown: `建议卡:${f.operation.label},${b.length} 个对象`,
|
|
315
|
+
notEligible: h.length - b.length,
|
|
316
|
+
missing: l.length - h.length,
|
|
293
317
|
note: "等用户确认,尚未加入方案"
|
|
294
318
|
});
|
|
295
319
|
}
|
|
@@ -309,23 +333,23 @@ function ps(s, o) {
|
|
|
309
333
|
},
|
|
310
334
|
required: ["name", "value"]
|
|
311
335
|
}),
|
|
312
|
-
execute: async ({ name: e, value:
|
|
313
|
-
const l = s(),
|
|
314
|
-
if (!
|
|
336
|
+
execute: async ({ name: e, value: c }) => {
|
|
337
|
+
const l = s(), d = l.spec.variables.find((f) => f.name === e);
|
|
338
|
+
if (!d || d.kind === "selection" || d.kind === "set")
|
|
315
339
|
throw new Error(`筛选 ${e} 不存在或不能这样设置`);
|
|
316
|
-
if (Array.isArray(
|
|
340
|
+
if (Array.isArray(c) && d.kind !== "value")
|
|
317
341
|
throw new Error(`筛选 ${e} 只接受一个值`);
|
|
318
|
-
if (
|
|
342
|
+
if (d.kind === "asOf" && typeof c == "string" && !He(c))
|
|
319
343
|
throw new Error(`筛选 ${e} 要写成 YYYY-MM-DD 的日期`);
|
|
320
|
-
if (
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
344
|
+
if (d.kind === "dateRange" && typeof c == "string") {
|
|
345
|
+
const f = c.split(Bt);
|
|
346
|
+
if (f.length !== 2 || f.every((g) => g === "") || !f.every((g) => g === "" || He(g)))
|
|
323
347
|
throw new Error(`筛选 ${e} 要写成 YYYY-MM-DD..YYYY-MM-DD(可省略一端)`);
|
|
324
348
|
}
|
|
325
349
|
return l.setValue(
|
|
326
350
|
e,
|
|
327
|
-
|
|
328
|
-
), I({ ok: !0, filter:
|
|
351
|
+
c === null ? void 0 : d.kind === "dateRange" && typeof c == "string" ? Dt(c) : c
|
|
352
|
+
), I({ ok: !0, filter: d.label, value: c });
|
|
329
353
|
}
|
|
330
354
|
}), r.select_object = A({
|
|
331
355
|
description: "在页面上选中一个对象(按它的标识),关系子图等跟随选中的组件会显示它,详情抽屉不会弹出(用户点它才打开);key 为 null 时取消选中。",
|
|
@@ -337,39 +361,39 @@ function ps(s, o) {
|
|
|
337
361
|
},
|
|
338
362
|
required: ["key"]
|
|
339
363
|
}),
|
|
340
|
-
execute: async ({ filter: e, key:
|
|
341
|
-
const l = s(),
|
|
342
|
-
(
|
|
364
|
+
execute: async ({ filter: e, key: c }) => {
|
|
365
|
+
const l = s(), d = l.spec.variables.find(
|
|
366
|
+
(f) => f.kind === "selection" && !Pe(f.name) && (!e || f.name === e)
|
|
343
367
|
);
|
|
344
|
-
if (!
|
|
345
|
-
return l.setValue(
|
|
368
|
+
if (!d) throw new Error("页面上没有可选中的对象");
|
|
369
|
+
return l.setValue(d.name, c, { quiet: !0 }), I({ ok: !0, selected: c });
|
|
346
370
|
}
|
|
347
371
|
})), r;
|
|
348
372
|
}
|
|
349
|
-
function
|
|
373
|
+
function He(s) {
|
|
350
374
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(s)) return !1;
|
|
351
375
|
const o = Date.parse(s);
|
|
352
376
|
return !Number.isNaN(o) && new Date(o).toISOString().slice(0, 10) === s;
|
|
353
377
|
}
|
|
354
|
-
function
|
|
355
|
-
const o = Object.values(s.regions).flatMap((r) => r ?? []).filter((r) =>
|
|
378
|
+
function bs(s) {
|
|
379
|
+
const o = Object.values(s.regions).flatMap((r) => r ?? []).filter((r) => wt(r.type)).map((r) => ({
|
|
356
380
|
id: r.id,
|
|
357
|
-
component:
|
|
381
|
+
component: Pt(r.type).label,
|
|
358
382
|
title: r.config.title ?? null,
|
|
359
|
-
shows:
|
|
383
|
+
shows: It(r.id) ?? null
|
|
360
384
|
}));
|
|
361
385
|
return o.length > 0 ? { customComponents: o } : {};
|
|
362
386
|
}
|
|
363
|
-
const
|
|
364
|
-
function
|
|
387
|
+
const ws = "<answer>";
|
|
388
|
+
function ks(s, o) {
|
|
365
389
|
const r = s.spec.sources.map((n) => {
|
|
366
390
|
const e = [
|
|
367
|
-
...
|
|
391
|
+
...vt(n.progress),
|
|
368
392
|
...(n.computed ?? []).map((l) => ({ name: l.name, label: l.label }))
|
|
369
|
-
].map((l) => `${l.name}(${l.label})`),
|
|
370
|
-
return `- ${n.id}:${n.label}(对象类 ${n.objectType}${
|
|
393
|
+
].map((l) => `${l.name}(${l.label})`), c = n.progress ? `;进度 ${n.progress.steps.map((l) => l.label).join(" → ")}` : "";
|
|
394
|
+
return `- ${n.id}:${n.label}(对象类 ${n.objectType}${c}${e.length > 0 ? `;算出的列 ${e.join("、")}` : ""})`;
|
|
371
395
|
}).join(`
|
|
372
|
-
`),
|
|
396
|
+
`), p = s.spec.variables.map((n) => `- ${n.name}:${n.label}(${n.kind})`).join(`
|
|
373
397
|
`);
|
|
374
398
|
return `你是「${s.spec.title}」应用里的业务助手,帮用户看懂页面上的数据、找出问题并给出判断。
|
|
375
399
|
|
|
@@ -387,76 +411,76 @@ function ms(s, o) {
|
|
|
387
411
|
页面数据源:
|
|
388
412
|
${r}
|
|
389
413
|
筛选(谁按哪个字段跟随,见 page_context 的 followedBy):
|
|
390
|
-
${
|
|
414
|
+
${p}
|
|
391
415
|
${o.instructions ? `
|
|
392
416
|
补充说明:
|
|
393
417
|
${o.instructions}
|
|
394
418
|
` : ""}
|
|
395
|
-
${
|
|
419
|
+
${ns(s.kn)}
|
|
396
420
|
|
|
397
|
-
最终回答完整写在 ${
|
|
421
|
+
最终回答完整写在 ${ws} 与 </answer> 之间。`;
|
|
398
422
|
}
|
|
399
|
-
const
|
|
400
|
-
function
|
|
423
|
+
const we = (s) => s && typeof s == "object" && !Array.isArray(s) ? s : {};
|
|
424
|
+
function et(s) {
|
|
401
425
|
if (!s) return {};
|
|
402
426
|
try {
|
|
403
|
-
return
|
|
427
|
+
return we(JSON.parse(s));
|
|
404
428
|
} catch {
|
|
405
429
|
return {};
|
|
406
430
|
}
|
|
407
431
|
}
|
|
408
|
-
function
|
|
409
|
-
const o =
|
|
432
|
+
function vs(s) {
|
|
433
|
+
const o = et(s), r = o.message ?? o.error ?? o.detail;
|
|
410
434
|
return (typeof r == "string" ? r : s).slice(0, 200);
|
|
411
435
|
}
|
|
412
|
-
const
|
|
436
|
+
const xs = Object.fromEntries(
|
|
413
437
|
Object.values(te).map((s) => [s.value, s.label])
|
|
414
438
|
);
|
|
415
|
-
function
|
|
416
|
-
const r =
|
|
417
|
-
if (s.error) return { key: "failed", values: { error:
|
|
418
|
-
const
|
|
419
|
-
([
|
|
420
|
-
), g = (
|
|
439
|
+
function js(s, o) {
|
|
440
|
+
const r = we(s.args);
|
|
441
|
+
if (s.error) return { key: "failed", values: { error: vs(s.error) } };
|
|
442
|
+
const p = et(s.result), n = s.result !== void 0, e = typeof r.source == "string" ? ne(o.spec, r.source) : void 0, c = e?.label ?? String(r.source ?? ""), l = (h) => e && Ge(e, o.kn).find((b) => b.name === h)?.label || h, d = (h) => (Array.isArray(h) ? h : [h]).map((b) => xs[String(b)] ?? String(b)).join(" / "), f = Object.entries(we(r.where)).map(
|
|
443
|
+
([h, b]) => `${l(h)} = ${d(b)}`
|
|
444
|
+
), g = (h) => typeof h == "number" ? h : void 0;
|
|
421
445
|
switch (s.name) {
|
|
422
446
|
case "page_context":
|
|
423
447
|
return { key: "pageContext", values: {} };
|
|
424
448
|
case "list_objects": {
|
|
425
|
-
const
|
|
449
|
+
const h = Array.isArray(r.keys) ? r.keys.length : 0, b = g(p.total);
|
|
426
450
|
return {
|
|
427
|
-
key:
|
|
428
|
-
values: { source:
|
|
429
|
-
where:
|
|
451
|
+
key: h > 0 ? "listKeys" : b === void 0 ? "list" : "listCount",
|
|
452
|
+
values: { source: c, total: b ?? 0, keys: h },
|
|
453
|
+
where: f
|
|
430
454
|
};
|
|
431
455
|
}
|
|
432
456
|
case "summarize": {
|
|
433
|
-
const
|
|
457
|
+
const h = g(p.groups);
|
|
434
458
|
return {
|
|
435
|
-
key:
|
|
459
|
+
key: h === void 0 ? "summarize" : "summarizeCount",
|
|
436
460
|
values: {
|
|
437
|
-
source:
|
|
461
|
+
source: c,
|
|
438
462
|
field: l(String(r.groupBy ?? "")),
|
|
439
|
-
groups:
|
|
463
|
+
groups: h ?? 0
|
|
440
464
|
},
|
|
441
|
-
where:
|
|
465
|
+
where: f
|
|
442
466
|
};
|
|
443
467
|
}
|
|
444
468
|
case "run_cypher": {
|
|
445
|
-
let
|
|
469
|
+
let h;
|
|
446
470
|
try {
|
|
447
|
-
const
|
|
448
|
-
Array.isArray(
|
|
471
|
+
const b = s.result ? JSON.parse(s.result) : void 0;
|
|
472
|
+
Array.isArray(b) && (h = b.length);
|
|
449
473
|
} catch {
|
|
450
|
-
|
|
474
|
+
h = void 0;
|
|
451
475
|
}
|
|
452
|
-
return { key:
|
|
476
|
+
return { key: h === void 0 ? "cypher" : "cypherCount", values: { rows: h ?? 0 } };
|
|
453
477
|
}
|
|
454
478
|
case "propose_action": {
|
|
455
|
-
const
|
|
479
|
+
const h = String(r.action ?? "");
|
|
456
480
|
return {
|
|
457
481
|
key: "propose",
|
|
458
482
|
values: {
|
|
459
|
-
name: se(o.kn,
|
|
483
|
+
name: se(o.kn, h)?.name ?? h,
|
|
460
484
|
count: Array.isArray(r.keys) ? r.keys.length : 0
|
|
461
485
|
}
|
|
462
486
|
};
|
|
@@ -465,13 +489,13 @@ function bs(s, o) {
|
|
|
465
489
|
return {
|
|
466
490
|
key: "proposeScenario",
|
|
467
491
|
values: {
|
|
468
|
-
name: e?.operations?.find((
|
|
492
|
+
name: e?.operations?.find((b) => b.id === r.operation)?.label ?? String(r.operation ?? ""),
|
|
469
493
|
count: Array.isArray(r.keys) ? r.keys.length : 0
|
|
470
494
|
}
|
|
471
495
|
};
|
|
472
496
|
case "set_filter": {
|
|
473
|
-
const
|
|
474
|
-
return r.value === null || r.value === void 0 ? { key: "clearFilter", values: { label:
|
|
497
|
+
const b = o.spec.variables.find((L) => L.name === r.name)?.label ?? String(r.name ?? "");
|
|
498
|
+
return r.value === null || r.value === void 0 ? { key: "clearFilter", values: { label: b } } : { key: "setFilter", values: { label: b, value: d(r.value) } };
|
|
475
499
|
}
|
|
476
500
|
case "select_object":
|
|
477
501
|
return r.key === null || r.key === void 0 ? { key: "unselect", values: {} } : { key: "select", values: { key: String(r.key) } };
|
|
@@ -479,57 +503,57 @@ function bs(s, o) {
|
|
|
479
503
|
return { key: n ? "other" : "otherRunning", values: {} };
|
|
480
504
|
}
|
|
481
505
|
}
|
|
482
|
-
const
|
|
506
|
+
const $s = {
|
|
483
507
|
done: "success",
|
|
484
508
|
failed: "error",
|
|
485
509
|
cancelled: "default",
|
|
486
510
|
accepted: "processing"
|
|
487
|
-
},
|
|
511
|
+
}, Ss = ["done", "accepted", "failed", "cancelled"], Os = /DSML|<|[^>]*(calls|invoke)/, Ls = 12, Es = (s, o) => new Promise((r, p) => {
|
|
488
512
|
const n = () => {
|
|
489
|
-
clearTimeout(e),
|
|
513
|
+
clearTimeout(e), p(new DOMException("Aborted", "AbortError"));
|
|
490
514
|
}, e = setTimeout(() => {
|
|
491
515
|
o.removeEventListener("abort", n), r();
|
|
492
516
|
}, s);
|
|
493
517
|
o.aborted ? n() : o.addEventListener("abort", n, { once: !0 });
|
|
494
518
|
});
|
|
495
|
-
function
|
|
519
|
+
function Ms({
|
|
496
520
|
config: s,
|
|
497
521
|
initial: o,
|
|
498
522
|
bare: r,
|
|
499
|
-
onAsked:
|
|
523
|
+
onAsked: p
|
|
500
524
|
}) {
|
|
501
|
-
const { t: n } =
|
|
525
|
+
const { t: n } = xt(), e = s, c = e.mode ?? "inline", [l, d] = m.useState(c !== "float"), f = m.useContext(Lt), g = Ft(), h = Yt(), [b, L] = m.useState([]), [tt, ve] = m.useState({}), [K, D] = m.useState(""), [X, F] = m.useState(), [T, P] = m.useState(!1), [re, st] = m.useState(), [xe, nt] = m.useState(!1), N = m.useRef(null), oe = m.useRef(null), q = m.useRef(null);
|
|
502
526
|
m.useEffect(() => {
|
|
503
|
-
q.current = { ...g, asOf:
|
|
527
|
+
q.current = { ...g, asOf: zt(g.spec, g.values), link: h };
|
|
504
528
|
}), m.useEffect(() => {
|
|
505
529
|
let t = !0;
|
|
506
|
-
return
|
|
507
|
-
t && (
|
|
530
|
+
return ms().then((u) => {
|
|
531
|
+
t && (st(u), nt(!0));
|
|
508
532
|
}), () => {
|
|
509
533
|
t = !1, N.current?.abort();
|
|
510
534
|
};
|
|
511
535
|
}, []), m.useEffect(() => {
|
|
512
|
-
|
|
513
|
-
}, [
|
|
514
|
-
const O = e.provider === "mcp" &&
|
|
536
|
+
oe.current?.scrollTo({ top: oe.current.scrollHeight });
|
|
537
|
+
}, [b]);
|
|
538
|
+
const O = e.provider === "mcp" && qt(e.agent) && e.agent.mcp && e.agent.tool ? e.agent : void 0, [R, je] = m.useState(e.agent?.agentId), [U, $e] = m.useState(null), [ae, ie] = m.useState(!1), [rt, Se] = m.useState(!1), [ot, at] = m.useState(0);
|
|
515
539
|
m.useEffect(() => {
|
|
516
|
-
|
|
540
|
+
je(e.agent?.agentId);
|
|
517
541
|
}, [e.agent?.mcp, e.agent?.agentId]), m.useEffect(() => {
|
|
518
542
|
let t = !0;
|
|
519
|
-
if (
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
return
|
|
523
|
-
app_id:
|
|
543
|
+
if ($e(null), Se(!1), ie(!1), !O || !e.allowAgentSwitch && !O.agentId) return;
|
|
544
|
+
ie(!0);
|
|
545
|
+
const u = g.appId;
|
|
546
|
+
return Ut(O.mcp, {
|
|
547
|
+
app_id: u,
|
|
524
548
|
kn_id: g.kn.id,
|
|
525
|
-
workspace_id:
|
|
526
|
-
bkn_token: e.passToken ?
|
|
549
|
+
workspace_id: u ? () => De(u) : void 0,
|
|
550
|
+
bkn_token: e.passToken ? Be() : void 0
|
|
527
551
|
}).then((i) => {
|
|
528
|
-
t &&
|
|
552
|
+
t && $e(i);
|
|
529
553
|
}).catch(() => {
|
|
530
|
-
t &&
|
|
554
|
+
t && Se(!0);
|
|
531
555
|
}).finally(() => {
|
|
532
|
-
t &&
|
|
556
|
+
t && ie(!1);
|
|
533
557
|
}), () => {
|
|
534
558
|
t = !1;
|
|
535
559
|
};
|
|
@@ -537,165 +561,165 @@ function Rs({
|
|
|
537
561
|
O?.mcp,
|
|
538
562
|
O?.agentId,
|
|
539
563
|
e.allowAgentSwitch,
|
|
540
|
-
|
|
564
|
+
ot,
|
|
541
565
|
g.appId,
|
|
542
566
|
g.kn.id,
|
|
543
567
|
e.passToken
|
|
544
568
|
]);
|
|
545
|
-
const G = !!(O &&
|
|
569
|
+
const G = !!(O && R && U && !U.some((t) => t.id === R)), le = !!(O && R && ae), ce = e.provider !== "mcp" || !!O && !G, V = !G && !le && (e.provider === "bknAgent" || !!O || !!re), Oe = e.selection ? g.values[e.selection] : void 0, J = m.useRef(void 0), ue = m.useRef(void 0), Le = m.useRef(
|
|
546
570
|
`ws-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`
|
|
547
|
-
),
|
|
571
|
+
), it = m.useRef(/* @__PURE__ */ new Map()), [lt, ct] = m.useState(), de = O?.mcp, Ee = !!O?.mcpName;
|
|
548
572
|
m.useEffect(() => {
|
|
549
|
-
if (!
|
|
573
|
+
if (!de || Ee) return;
|
|
550
574
|
let t = !0;
|
|
551
|
-
return
|
|
552
|
-
(
|
|
553
|
-
t &&
|
|
575
|
+
return Vt(de).then(
|
|
576
|
+
(u) => {
|
|
577
|
+
t && ct(u);
|
|
554
578
|
},
|
|
555
579
|
() => {
|
|
556
580
|
}
|
|
557
581
|
), () => {
|
|
558
582
|
t = !1;
|
|
559
583
|
};
|
|
560
|
-
}, [
|
|
561
|
-
const
|
|
562
|
-
const i =
|
|
563
|
-
return i?.role === "assistant" ? [...
|
|
564
|
-
}),
|
|
565
|
-
t.type === "text" ?
|
|
566
|
-
...
|
|
567
|
-
tools: [...
|
|
568
|
-
})) : t.type === "tool-result" || t.type === "tool-error" ?
|
|
569
|
-
...
|
|
570
|
-
tools:
|
|
584
|
+
}, [de, Ee]);
|
|
585
|
+
const E = (t) => L((u) => {
|
|
586
|
+
const i = u[u.length - 1];
|
|
587
|
+
return i?.role === "assistant" ? [...u.slice(0, -1), t(i)] : u;
|
|
588
|
+
}), ut = (t) => {
|
|
589
|
+
t.type === "text" ? E((u) => ({ ...u, text: u.text + t.delta })) : t.type === "tool-call" ? E((u) => ({
|
|
590
|
+
...u,
|
|
591
|
+
tools: [...u.tools, { id: t.id, name: t.name, args: t.args }]
|
|
592
|
+
})) : t.type === "tool-result" || t.type === "tool-error" ? E((u) => ({
|
|
593
|
+
...u,
|
|
594
|
+
tools: u.tools.map(
|
|
571
595
|
(i) => i.id === t.id ? t.type === "tool-result" ? { ...i, result: t.result } : { ...i, error: t.error } : i
|
|
572
596
|
)
|
|
573
|
-
})) : t.type === "error" &&
|
|
597
|
+
})) : t.type === "error" && E((u) => ({ ...u, error: t.error }));
|
|
574
598
|
}, Q = (t) => t.role === "user" && t.context ? `${t.text}
|
|
575
599
|
|
|
576
|
-
${t.context}` : t.text,
|
|
600
|
+
${t.context}` : t.text, W = async (t, u) => {
|
|
577
601
|
const i = q.current;
|
|
578
|
-
if (!i || !
|
|
602
|
+
if (!i || !V || t.trim() === "" || T) return;
|
|
579
603
|
if (e.provider === "mcp")
|
|
580
|
-
return O ?
|
|
581
|
-
if (e.provider === "bknAgent") return
|
|
582
|
-
if (!
|
|
583
|
-
const
|
|
584
|
-
...
|
|
585
|
-
{ role: "user", content: Q(
|
|
604
|
+
return O ? dt(O, t.trim(), u, i) : void 0;
|
|
605
|
+
if (e.provider === "bknAgent") return pt(t.trim(), u, i);
|
|
606
|
+
if (!re) return;
|
|
607
|
+
const w = { role: "user", text: t.trim(), ...u ? { context: u } : {} }, $ = [
|
|
608
|
+
...b.filter((y) => y.text.trim() !== "").map((y) => ({ role: y.role, content: Q(y) })),
|
|
609
|
+
{ role: "user", content: Q(w) }
|
|
586
610
|
];
|
|
587
|
-
|
|
611
|
+
L((y) => [...y, w, { role: "assistant", text: "", tools: [] }]), D(""), F(void 0), P(!0);
|
|
588
612
|
const S = new AbortController();
|
|
589
613
|
N.current = S;
|
|
590
614
|
try {
|
|
591
|
-
await
|
|
615
|
+
await Ht({
|
|
592
616
|
knId: i.kn.id,
|
|
593
|
-
modelName:
|
|
594
|
-
system:
|
|
617
|
+
modelName: re,
|
|
618
|
+
system: ks(i, {
|
|
595
619
|
instructions: e.instructions,
|
|
596
620
|
canFilter: e.canFilter,
|
|
597
621
|
actions: e.actions
|
|
598
622
|
}),
|
|
599
623
|
history: $,
|
|
600
|
-
tools:
|
|
624
|
+
tools: ys(() => q.current ?? i, {
|
|
601
625
|
canFilter: e.canFilter,
|
|
602
626
|
actions: e.actions,
|
|
603
627
|
simulate: !!g.simulate
|
|
604
628
|
}),
|
|
605
|
-
maxSteps:
|
|
629
|
+
maxSteps: Ls,
|
|
606
630
|
signal: S.signal,
|
|
607
|
-
onChunk:
|
|
608
|
-
}),
|
|
609
|
-
(y) => y.role === "assistant" &&
|
|
631
|
+
onChunk: ut
|
|
632
|
+
}), E(
|
|
633
|
+
(y) => y.role === "assistant" && Os.test(y.text) ? { ...y, text: "", error: n("workshopLab.agent.leakedCall") } : y
|
|
610
634
|
);
|
|
611
635
|
} finally {
|
|
612
636
|
N.current === S && P(!1);
|
|
613
637
|
}
|
|
614
|
-
},
|
|
615
|
-
const $ = { role: "user", text:
|
|
616
|
-
|
|
638
|
+
}, dt = async (t, u, i, w) => {
|
|
639
|
+
const $ = { role: "user", text: u, ...i ? { context: i } : {} };
|
|
640
|
+
L((j) => [...j, $, { role: "assistant", text: "", tools: [] }]), D(""), F(void 0), P(!0);
|
|
617
641
|
const S = new AbortController();
|
|
618
642
|
N.current = S;
|
|
619
|
-
const y = g.appId,
|
|
643
|
+
const y = g.appId, k = {
|
|
620
644
|
question: Q($),
|
|
621
645
|
context: [
|
|
622
|
-
|
|
646
|
+
Ue(w, e.selection),
|
|
623
647
|
e.instructions ? `<app_instructions>
|
|
624
648
|
${e.instructions}
|
|
625
649
|
</app_instructions>` : ""
|
|
626
650
|
].filter(Boolean).join(`
|
|
627
651
|
|
|
628
652
|
`),
|
|
629
|
-
conversation_id:
|
|
630
|
-
agent_id:
|
|
653
|
+
conversation_id: Le.current,
|
|
654
|
+
agent_id: R,
|
|
631
655
|
app_id: g.appId,
|
|
632
|
-
kn_id:
|
|
656
|
+
kn_id: w.kn.id,
|
|
633
657
|
// Where the asker put the app, read only for a tool that takes it.
|
|
634
|
-
workspace_id: y ? () =>
|
|
635
|
-
bkn_token: e.passToken ?
|
|
658
|
+
workspace_id: y ? () => De(y) : void 0,
|
|
659
|
+
bkn_token: e.passToken ? Be() : void 0
|
|
636
660
|
}, v = Date.now();
|
|
637
661
|
try {
|
|
638
662
|
let j;
|
|
639
663
|
for (; ; ) {
|
|
640
|
-
const _ = await
|
|
664
|
+
const _ = await Xt(
|
|
641
665
|
t,
|
|
642
|
-
j ? { ...
|
|
643
|
-
|
|
666
|
+
j ? { ...k, run_id: j } : k,
|
|
667
|
+
it.current,
|
|
644
668
|
S.signal
|
|
645
669
|
);
|
|
646
670
|
if (_.done) {
|
|
647
|
-
|
|
671
|
+
E(
|
|
648
672
|
(Y) => _.text.trim() ? { ...Y, text: _.text, waiting: void 0 } : { ...Y, waiting: void 0, error: n("workshopLab.agent.outside.empty") }
|
|
649
673
|
);
|
|
650
674
|
break;
|
|
651
675
|
}
|
|
652
|
-
if (!_.runId || Date.now() - v >=
|
|
676
|
+
if (!_.runId || Date.now() - v >= Gt) {
|
|
653
677
|
const Y = _.runId ? "gaveUp" : "notFollowed";
|
|
654
|
-
|
|
655
|
-
...
|
|
678
|
+
E((yt) => ({
|
|
679
|
+
...yt,
|
|
656
680
|
waiting: void 0,
|
|
657
681
|
notice: n(`workshopLab.agent.outside.${Y}`, { detail: _.text })
|
|
658
682
|
}));
|
|
659
683
|
break;
|
|
660
684
|
}
|
|
661
|
-
|
|
685
|
+
E((Y) => ({ ...Y, waiting: _.text })), j = _.runId, await Es(Qt, S.signal);
|
|
662
686
|
}
|
|
663
687
|
} catch (j) {
|
|
664
|
-
S.signal.aborted ||
|
|
688
|
+
S.signal.aborted || E((_) => ({
|
|
665
689
|
..._,
|
|
666
690
|
waiting: void 0,
|
|
667
|
-
error: j instanceof
|
|
691
|
+
error: j instanceof es ? n(`workshopLab.agent.outside.${j.reason}`, { detail: j.detail }) : String(j)
|
|
668
692
|
}));
|
|
669
693
|
} finally {
|
|
670
694
|
N.current === S && P(!1);
|
|
671
695
|
}
|
|
672
|
-
},
|
|
673
|
-
const
|
|
674
|
-
|
|
696
|
+
}, pt = async (t, u, i) => {
|
|
697
|
+
const w = { role: "user", text: t, ...u ? { context: u } : {} };
|
|
698
|
+
L((k) => [...k, w, { role: "assistant", text: "", tools: [] }]), D(""), F(void 0), P(!0);
|
|
675
699
|
const $ = new AbortController();
|
|
676
700
|
N.current = $;
|
|
677
701
|
const S = [
|
|
678
|
-
|
|
702
|
+
Ue(i, e.selection),
|
|
679
703
|
e.instructions ? `<app_instructions>
|
|
680
704
|
${e.instructions}
|
|
681
705
|
</app_instructions>` : "",
|
|
682
|
-
Q(
|
|
706
|
+
Q(w)
|
|
683
707
|
].filter(Boolean).join(`
|
|
684
708
|
|
|
685
|
-
`), y = (
|
|
686
|
-
|
|
709
|
+
`), y = (k) => {
|
|
710
|
+
k.type === "meta" ? (J.current = k.threadId, ue.current = k.runId) : k.type === "token" ? E((v) => ({ ...v, text: v.text + k.content })) : k.type === "result" ? E((v) => ({ ...v, text: k.answer })) : k.type === "tool_started" ? E((v) => ({
|
|
687
711
|
...v,
|
|
688
712
|
text: "",
|
|
689
|
-
tools: [...v.tools, { id:
|
|
690
|
-
})) :
|
|
713
|
+
tools: [...v.tools, { id: k.id, name: k.name, args: k.input }]
|
|
714
|
+
})) : k.type === "tool_finished" && E((v) => ({
|
|
691
715
|
...v,
|
|
692
716
|
tools: v.tools.map(
|
|
693
|
-
(j) => j.id ===
|
|
717
|
+
(j) => j.id === k.id ? k.status === "succeeded" ? { ...j, result: JSON.stringify(k.output) } : { ...j, error: JSON.stringify(k.error ?? k.output) } : j
|
|
694
718
|
)
|
|
695
719
|
}));
|
|
696
720
|
};
|
|
697
721
|
try {
|
|
698
|
-
const
|
|
722
|
+
const k = (j) => Zt({
|
|
699
723
|
knId: i.kn.id,
|
|
700
724
|
message: S,
|
|
701
725
|
...j ? { threadId: j } : {},
|
|
@@ -704,42 +728,42 @@ ${e.instructions}
|
|
|
704
728
|
});
|
|
705
729
|
let v;
|
|
706
730
|
try {
|
|
707
|
-
v = await
|
|
731
|
+
v = await k(J.current);
|
|
708
732
|
} catch (j) {
|
|
709
|
-
if (!(!!j?.unknownThread && !!
|
|
710
|
-
|
|
733
|
+
if (!(!!j?.unknownThread && !!J.current)) throw j;
|
|
734
|
+
J.current = void 0, v = await k();
|
|
711
735
|
}
|
|
712
|
-
v && v.status !== "succeeded" && v.status !== "cancelled" &&
|
|
713
|
-
} catch (
|
|
714
|
-
$.signal.aborted ||
|
|
736
|
+
v && v.status !== "succeeded" && v.status !== "cancelled" && E((j) => ({ ...j, error: v.error ?? "" }));
|
|
737
|
+
} catch (k) {
|
|
738
|
+
$.signal.aborted || E((v) => ({ ...v, error: ts(k) }));
|
|
715
739
|
} finally {
|
|
716
|
-
|
|
740
|
+
ue.current = void 0, N.current === $ && P(!1);
|
|
717
741
|
}
|
|
718
|
-
},
|
|
719
|
-
const i = q.current,
|
|
720
|
-
if (!
|
|
721
|
-
const S = new Set(
|
|
742
|
+
}, gt = (t, u) => {
|
|
743
|
+
const i = q.current, w = i && se(i.kn, t.action), $ = i && w && Ze(i, w.objectType, t.keys);
|
|
744
|
+
if (!w || !$ || !g.act) return;
|
|
745
|
+
const S = new Set(w.inputs.map((y) => y.name));
|
|
722
746
|
g.act({
|
|
723
|
-
action:
|
|
747
|
+
action: w.id,
|
|
724
748
|
source: $.source,
|
|
725
|
-
objects: $.rows.slice(0,
|
|
726
|
-
...$.rows.length >
|
|
749
|
+
objects: $.rows.slice(0, Ye),
|
|
750
|
+
...$.rows.length > Ye ? { total: $.rows.length } : {},
|
|
727
751
|
params: {},
|
|
728
|
-
inputs:
|
|
752
|
+
inputs: w.inputs.map((y) => ({ name: y.name, label: y.label ?? y.name })),
|
|
729
753
|
defaults: Object.fromEntries(
|
|
730
754
|
Object.entries(t.params ?? {}).filter(([y]) => S.has(y))
|
|
731
755
|
),
|
|
732
756
|
origin: "agent",
|
|
733
757
|
reason: t.reason,
|
|
734
|
-
onDone: (y) =>
|
|
758
|
+
onDone: (y) => ve((k) => ({ ...k, [u]: y }))
|
|
735
759
|
});
|
|
736
|
-
},
|
|
737
|
-
const
|
|
738
|
-
if (!
|
|
739
|
-
const $ = new Set(t.keys.map(String)), S =
|
|
740
|
-
|
|
760
|
+
}, ft = (t) => {
|
|
761
|
+
const u = q.current, i = u?.spec.sources.find((y) => y.id === t.source), w = i && u?.sources[i.id];
|
|
762
|
+
if (!u || !i || w?.status !== "ready" || !g.simulate) return;
|
|
763
|
+
const $ = new Set(t.keys.map(String)), S = Qe(
|
|
764
|
+
w.rows.filter((y) => $.has(String(y.$key))),
|
|
741
765
|
i,
|
|
742
|
-
|
|
766
|
+
u.asOf
|
|
743
767
|
);
|
|
744
768
|
g.simulate({
|
|
745
769
|
operation: t.operation,
|
|
@@ -749,53 +773,53 @@ ${e.instructions}
|
|
|
749
773
|
...t.params ? { defaults: t.params } : {},
|
|
750
774
|
reason: t.reason
|
|
751
775
|
});
|
|
752
|
-
},
|
|
776
|
+
}, mt = () => {
|
|
753
777
|
N.current?.abort();
|
|
754
|
-
const t =
|
|
755
|
-
e.provider === "bknAgent" && t &&
|
|
778
|
+
const t = ue.current;
|
|
779
|
+
e.provider === "bknAgent" && t && Kt(t).catch(() => {
|
|
756
780
|
});
|
|
757
|
-
},
|
|
758
|
-
|
|
781
|
+
}, pe = () => {
|
|
782
|
+
L([]), D(""), ve({}), F(void 0), J.current = void 0, Le.current = `ws-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
759
783
|
};
|
|
760
784
|
m.useEffect(() => {
|
|
761
|
-
N.current?.abort(), P(!1),
|
|
785
|
+
N.current?.abort(), P(!1), pe();
|
|
762
786
|
}, [e.agent?.mcp, e.agent?.tool, e.agent?.agentId]);
|
|
763
|
-
const [B,
|
|
787
|
+
const [B, _e] = m.useState(o ?? null), Re = m.useRef(W), Ne = m.useRef(p);
|
|
764
788
|
m.useEffect(() => {
|
|
765
|
-
|
|
789
|
+
Re.current = W, Ne.current = p;
|
|
766
790
|
}), m.useEffect(() => {
|
|
767
791
|
const t = g.asks;
|
|
768
|
-
if (!
|
|
769
|
-
const
|
|
770
|
-
i.defaultPrevented || (i.preventDefault(),
|
|
792
|
+
if (!ce || !t) return;
|
|
793
|
+
const u = (i) => {
|
|
794
|
+
i.defaultPrevented || (i.preventDefault(), d(!0), Ne.current?.(), _e(i.detail));
|
|
771
795
|
};
|
|
772
|
-
return t.addEventListener("ask",
|
|
773
|
-
}, [g.asks,
|
|
774
|
-
if (!B || e.provider === "frontend" && !
|
|
775
|
-
|
|
796
|
+
return t.addEventListener("ask", u), () => t.removeEventListener("ask", u);
|
|
797
|
+
}, [g.asks, ce]), m.useEffect(() => {
|
|
798
|
+
if (!B || e.provider === "frontend" && !xe || le) return;
|
|
799
|
+
_e(null);
|
|
776
800
|
const t = e.provider === "frontend";
|
|
777
|
-
B.send === "auto" &&
|
|
778
|
-
}, [B,
|
|
779
|
-
const
|
|
780
|
-
const
|
|
781
|
-
conditions:
|
|
801
|
+
B.send === "auto" && V && !T ? Re.current(B.question, Me(B, { pageTools: t })) : (D(B.question), F(Me(B, { pageTools: t })));
|
|
802
|
+
}, [B, V, T, xe, le, e.provider]);
|
|
803
|
+
const Te = (t) => n(`workshopLab.agent.toolNames.${t}`, { defaultValue: t }), ht = (t) => {
|
|
804
|
+
const u = js(t, g), i = u.where?.length ? n("workshopLab.agent.steps.where", {
|
|
805
|
+
conditions: u.where.join(n("workshopLab.agent.steps.and"))
|
|
782
806
|
}) : "";
|
|
783
|
-
return n(`workshopLab.agent.steps.${
|
|
784
|
-
...
|
|
785
|
-
name:
|
|
807
|
+
return n(`workshopLab.agent.steps.${u.key}`, {
|
|
808
|
+
...u.values,
|
|
809
|
+
name: Te(t.name),
|
|
786
810
|
where: i
|
|
787
811
|
});
|
|
788
|
-
},
|
|
812
|
+
}, ge = /* @__PURE__ */ a.jsxs(
|
|
789
813
|
"div",
|
|
790
814
|
{
|
|
791
815
|
className: x.agent,
|
|
792
|
-
style: r ||
|
|
816
|
+
style: r || c !== "inline" ? void 0 : { height: e.height },
|
|
793
817
|
"data-fill": !0,
|
|
794
818
|
"data-bare": r || void 0,
|
|
795
819
|
children: [
|
|
796
820
|
O && e.allowAgentSwitch && /* @__PURE__ */ a.jsxs("div", { style: { padding: "8px 12px", display: "grid", gap: 6 }, children: [
|
|
797
821
|
/* @__PURE__ */ a.jsx(
|
|
798
|
-
|
|
822
|
+
jt,
|
|
799
823
|
{
|
|
800
824
|
"aria-label": n("workshopLab.agent.outside.selectAgent"),
|
|
801
825
|
placeholder: n("workshopLab.agent.outside.defaultAgent"),
|
|
@@ -803,69 +827,69 @@ ${e.instructions}
|
|
|
803
827
|
showSearch: !0,
|
|
804
828
|
optionFilterProp: "label",
|
|
805
829
|
allowClear: !0,
|
|
806
|
-
loading:
|
|
807
|
-
disabled: T ||
|
|
808
|
-
value:
|
|
830
|
+
loading: ae,
|
|
831
|
+
disabled: T || ae,
|
|
832
|
+
value: R,
|
|
809
833
|
options: [
|
|
810
834
|
...(U ?? []).map((t) => ({
|
|
811
835
|
value: t.id,
|
|
812
836
|
label: t.name
|
|
813
837
|
})),
|
|
814
|
-
...
|
|
838
|
+
...R && !U?.some((t) => t.id === R) ? [
|
|
815
839
|
{
|
|
816
|
-
value:
|
|
817
|
-
label: G ? n("workshopLab.agent.outside.agentUnavailable") : e.agent?.agentName ||
|
|
840
|
+
value: R,
|
|
841
|
+
label: G ? n("workshopLab.agent.outside.agentUnavailable") : e.agent?.agentName || R,
|
|
818
842
|
disabled: !0
|
|
819
843
|
}
|
|
820
844
|
] : []
|
|
821
845
|
],
|
|
822
846
|
onChange: (t) => {
|
|
823
|
-
|
|
847
|
+
pe(), je(t);
|
|
824
848
|
}
|
|
825
849
|
}
|
|
826
850
|
),
|
|
827
851
|
/* @__PURE__ */ a.jsx("span", { className: x.muted, children: n("workshopLab.agent.outside.switchHint") }),
|
|
828
|
-
|
|
829
|
-
|
|
852
|
+
rt && /* @__PURE__ */ a.jsx(
|
|
853
|
+
H,
|
|
830
854
|
{
|
|
831
855
|
type: "warning",
|
|
832
856
|
message: n("workshopLab.agent.outside.catalogError"),
|
|
833
|
-
action: /* @__PURE__ */ a.jsx(M, { size: "small", onClick: () =>
|
|
857
|
+
action: /* @__PURE__ */ a.jsx(M, { size: "small", onClick: () => at((t) => t + 1), children: n("workshopLab.agent.outside.retry") })
|
|
834
858
|
}
|
|
835
859
|
)
|
|
836
860
|
] }),
|
|
837
|
-
/* @__PURE__ */ a.jsxs("div", { ref:
|
|
838
|
-
e.provider === "mcp" && !O && /* @__PURE__ */ a.jsx(
|
|
861
|
+
/* @__PURE__ */ a.jsxs("div", { ref: oe, className: x.agentLog, children: [
|
|
862
|
+
e.provider === "mcp" && !O && /* @__PURE__ */ a.jsx(H, { type: "warning", showIcon: !0, message: n("workshopLab.agent.outside.notPicked") }),
|
|
839
863
|
G && /* @__PURE__ */ a.jsx(
|
|
840
|
-
|
|
864
|
+
H,
|
|
841
865
|
{
|
|
842
866
|
type: "warning",
|
|
843
867
|
showIcon: !0,
|
|
844
868
|
message: n("workshopLab.agent.outside.agentUnavailable")
|
|
845
869
|
}
|
|
846
870
|
),
|
|
847
|
-
|
|
848
|
-
/* @__PURE__ */ a.jsx("span", { className: x.agentEmptyIcon, "aria-hidden": !0, children: /* @__PURE__ */ a.jsx(
|
|
871
|
+
ce && b.length === 0 && /* @__PURE__ */ a.jsxs("div", { className: x.agentEmpty, children: [
|
|
872
|
+
/* @__PURE__ */ a.jsx("span", { className: x.agentEmptyIcon, "aria-hidden": !0, children: /* @__PURE__ */ a.jsx(Fe, {}) }),
|
|
849
873
|
/* @__PURE__ */ a.jsx("p", { children: n("workshopLab.agent.welcome") }),
|
|
850
874
|
(e.suggestions ?? []).length > 0 && /* @__PURE__ */ a.jsx("div", { className: x.agentSuggestions, children: (e.suggestions ?? []).map((t) => /* @__PURE__ */ a.jsx(
|
|
851
875
|
"button",
|
|
852
876
|
{
|
|
853
877
|
type: "button",
|
|
854
878
|
className: x.agentSuggestion,
|
|
855
|
-
disabled: T || !
|
|
879
|
+
disabled: T || !V,
|
|
856
880
|
onClick: () => {
|
|
857
|
-
|
|
881
|
+
W(t.text);
|
|
858
882
|
},
|
|
859
883
|
children: t.text
|
|
860
884
|
},
|
|
861
885
|
t.text
|
|
862
886
|
)) })
|
|
863
887
|
] }),
|
|
864
|
-
|
|
865
|
-
(t,
|
|
888
|
+
b.map(
|
|
889
|
+
(t, u) => t.role === "user" ? /* @__PURE__ */ a.jsxs("div", { className: x.agentUser, title: t.context, children: [
|
|
866
890
|
t.text,
|
|
867
891
|
t.context && /* @__PURE__ */ a.jsx("span", { className: x.agentCarried, children: n("workshopLab.ask.carried") })
|
|
868
|
-
] },
|
|
892
|
+
] }, u) : /* @__PURE__ */ a.jsxs("div", { className: x.agentAnswer, children: [
|
|
869
893
|
t.tools.length > 0 && /* @__PURE__ */ a.jsxs("details", { className: x.agentTools, children: [
|
|
870
894
|
/* @__PURE__ */ a.jsx("summary", { children: n("workshopLab.agent.tools", {
|
|
871
895
|
count: t.tools.length
|
|
@@ -876,7 +900,7 @@ ${e.instructions}
|
|
|
876
900
|
className: x.agentTool,
|
|
877
901
|
"data-state": i.error ? "failed" : i.result === void 0 ? "running" : "done",
|
|
878
902
|
children: [
|
|
879
|
-
/* @__PURE__ */ a.jsx("span", { children:
|
|
903
|
+
/* @__PURE__ */ a.jsx("span", { children: ht(i) }),
|
|
880
904
|
/* @__PURE__ */ a.jsxs("details", { className: x.agentToolRaw, children: [
|
|
881
905
|
/* @__PURE__ */ a.jsx("summary", { children: n("workshopLab.agent.steps.raw") }),
|
|
882
906
|
/* @__PURE__ */ a.jsx("code", { children: JSON.stringify(i.args) }),
|
|
@@ -888,65 +912,65 @@ ${e.instructions}
|
|
|
888
912
|
))
|
|
889
913
|
] }),
|
|
890
914
|
t.tools.filter((i) => i.name === "propose_action" && i.result && !i.error).map((i) => {
|
|
891
|
-
const
|
|
915
|
+
const w = i.args, $ = se(g.kn, w.action), S = `${u}:${i.id}`, y = tt[S], k = !y || y.every((v) => v.status === "failed");
|
|
892
916
|
return /* @__PURE__ */ a.jsxs("div", { className: x.agentProposal, children: [
|
|
893
917
|
/* @__PURE__ */ a.jsx("span", { children: n("workshopLab.agent.proposal", {
|
|
894
|
-
name: $?.name ??
|
|
895
|
-
count:
|
|
918
|
+
name: $?.name ?? w.action,
|
|
919
|
+
count: w.keys.length
|
|
896
920
|
}) }),
|
|
897
|
-
/* @__PURE__ */ a.jsx("span", { className: x.muted, children:
|
|
921
|
+
/* @__PURE__ */ a.jsx("span", { className: x.muted, children: w.reason }),
|
|
898
922
|
y && /* @__PURE__ */ a.jsxs("span", { className: x.agentProposalRan, children: [
|
|
899
923
|
n("workshopLab.agent.proposalRan"),
|
|
900
|
-
|
|
924
|
+
Ss.map((v) => {
|
|
901
925
|
const j = y.filter((_) => _.status === v).length;
|
|
902
|
-
return j > 0 ? /* @__PURE__ */ a.jsxs(
|
|
926
|
+
return j > 0 ? /* @__PURE__ */ a.jsxs(Jt, { color: $s[v], children: [
|
|
903
927
|
n(`workshopLab.act.status.${v}`),
|
|
904
928
|
" ",
|
|
905
929
|
j
|
|
906
930
|
] }, v) : null;
|
|
907
931
|
})
|
|
908
932
|
] }),
|
|
909
|
-
|
|
933
|
+
k && /* @__PURE__ */ a.jsx(
|
|
910
934
|
M,
|
|
911
935
|
{
|
|
912
936
|
size: "small",
|
|
913
937
|
type: "primary",
|
|
914
938
|
disabled: !$ || !g.act,
|
|
915
|
-
onClick: () =>
|
|
939
|
+
onClick: () => gt(w, S),
|
|
916
940
|
children: n("workshopLab.agent.runProposal")
|
|
917
941
|
}
|
|
918
942
|
)
|
|
919
943
|
] }, i.id);
|
|
920
944
|
}),
|
|
921
945
|
t.tools.filter((i) => i.name === "propose_scenario" && i.result && !i.error).map((i) => {
|
|
922
|
-
const
|
|
946
|
+
const w = i.args, $ = g.spec.sources.find((S) => S.id === w.source)?.operations?.find((S) => S.id === w.operation);
|
|
923
947
|
return /* @__PURE__ */ a.jsxs("div", { className: x.agentProposal, children: [
|
|
924
948
|
/* @__PURE__ */ a.jsx("span", { children: n("workshopLab.agent.scenarioProposal", {
|
|
925
|
-
name: $?.label ??
|
|
926
|
-
count:
|
|
949
|
+
name: $?.label ?? w.operation,
|
|
950
|
+
count: w.keys.length
|
|
927
951
|
}) }),
|
|
928
|
-
/* @__PURE__ */ a.jsx("span", { className: x.muted, children:
|
|
952
|
+
/* @__PURE__ */ a.jsx("span", { className: x.muted, children: w.reason }),
|
|
929
953
|
/* @__PURE__ */ a.jsx(
|
|
930
954
|
M,
|
|
931
955
|
{
|
|
932
956
|
size: "small",
|
|
933
957
|
type: "primary",
|
|
934
958
|
disabled: !$ || !g.simulate,
|
|
935
|
-
onClick: () =>
|
|
959
|
+
onClick: () => ft(w),
|
|
936
960
|
children: n("workshopLab.agent.addToScenario")
|
|
937
961
|
}
|
|
938
962
|
)
|
|
939
963
|
] }, i.id);
|
|
940
964
|
}),
|
|
941
965
|
O && t.text && /* @__PURE__ */ a.jsx("span", { className: x.muted, children: n("workshopLab.agent.outside.by", {
|
|
942
|
-
name: U?.find((i) => i.id ===
|
|
966
|
+
name: U?.find((i) => i.id === R)?.name || (R === e.agent?.agentId ? e.agent?.agentName : void 0) || O.mcpName || lt || O.mcp
|
|
943
967
|
}) }),
|
|
944
|
-
t.text ? /* @__PURE__ */ a.jsx(
|
|
945
|
-
name:
|
|
968
|
+
t.text ? /* @__PURE__ */ a.jsx(Et, { text: t.text, tone: f.mode === "dark" ? "dark" : "light" }) : !t.error && T && u === b.length - 1 && /* @__PURE__ */ a.jsx("span", { className: x.agentWorking, children: t.tools.length > 0 ? n("workshopLab.agent.calling", {
|
|
969
|
+
name: Te(t.tools[t.tools.length - 1].name)
|
|
946
970
|
}) : O ? t.waiting ? n("workshopLab.agent.outside.waiting", { detail: t.waiting }) : n("workshopLab.agent.outside.working") : n("workshopLab.agent.thinking") }),
|
|
947
|
-
t.notice && /* @__PURE__ */ a.jsx(
|
|
948
|
-
t.error && /* @__PURE__ */ a.jsx(
|
|
949
|
-
] },
|
|
971
|
+
t.notice && /* @__PURE__ */ a.jsx(H, { type: "warning", showIcon: !0, message: t.notice }),
|
|
972
|
+
t.error && /* @__PURE__ */ a.jsx(H, { type: "error", showIcon: !0, message: t.error })
|
|
973
|
+
] }, u)
|
|
950
974
|
)
|
|
951
975
|
] }),
|
|
952
976
|
X && /* @__PURE__ */ a.jsxs("div", { className: x.agentPending, children: [
|
|
@@ -955,16 +979,16 @@ ${e.instructions}
|
|
|
955
979
|
] }),
|
|
956
980
|
/* @__PURE__ */ a.jsx("div", { className: x.agentInput, children: /* @__PURE__ */ a.jsxs("div", { className: x.agentComposer, children: [
|
|
957
981
|
/* @__PURE__ */ a.jsx(
|
|
958
|
-
|
|
982
|
+
$t.TextArea,
|
|
959
983
|
{
|
|
960
984
|
variant: "borderless",
|
|
961
985
|
autoSize: { minRows: 1, maxRows: 4 },
|
|
962
|
-
value:
|
|
986
|
+
value: K,
|
|
963
987
|
"aria-label": n("workshopLab.agent.placeholder"),
|
|
964
988
|
placeholder: n("workshopLab.agent.placeholder"),
|
|
965
989
|
onChange: (t) => D(t.target.value),
|
|
966
990
|
onPressEnter: (t) => {
|
|
967
|
-
!t.shiftKey && !t.nativeEvent.isComposing && (t.preventDefault(),
|
|
991
|
+
!t.shiftKey && !t.nativeEvent.isComposing && (t.preventDefault(), W(K, X));
|
|
968
992
|
}
|
|
969
993
|
}
|
|
970
994
|
),
|
|
@@ -973,10 +997,10 @@ ${e.instructions}
|
|
|
973
997
|
{
|
|
974
998
|
size: "small",
|
|
975
999
|
shape: "circle",
|
|
976
|
-
icon: /* @__PURE__ */ a.jsx(
|
|
1000
|
+
icon: /* @__PURE__ */ a.jsx(fs, {}),
|
|
977
1001
|
"aria-label": n("workshopLab.agent.stop"),
|
|
978
1002
|
title: n("workshopLab.agent.stop"),
|
|
979
|
-
onClick:
|
|
1003
|
+
onClick: mt
|
|
980
1004
|
}
|
|
981
1005
|
) : /* @__PURE__ */ a.jsx(
|
|
982
1006
|
M,
|
|
@@ -984,12 +1008,12 @@ ${e.instructions}
|
|
|
984
1008
|
size: "small",
|
|
985
1009
|
shape: "circle",
|
|
986
1010
|
type: "primary",
|
|
987
|
-
icon: /* @__PURE__ */ a.jsx(
|
|
1011
|
+
icon: /* @__PURE__ */ a.jsx(_t, {}),
|
|
988
1012
|
"aria-label": n("workshopLab.agent.send"),
|
|
989
1013
|
title: n("workshopLab.agent.send"),
|
|
990
|
-
disabled: !
|
|
1014
|
+
disabled: !V || K.trim() === "",
|
|
991
1015
|
onClick: () => {
|
|
992
|
-
|
|
1016
|
+
W(K, X);
|
|
993
1017
|
}
|
|
994
1018
|
}
|
|
995
1019
|
)
|
|
@@ -997,49 +1021,49 @@ ${e.instructions}
|
|
|
997
1021
|
]
|
|
998
1022
|
}
|
|
999
1023
|
);
|
|
1000
|
-
if (r) return
|
|
1001
|
-
const
|
|
1024
|
+
if (r) return ge;
|
|
1025
|
+
const Ae = Oe ? /* @__PURE__ */ a.jsx("span", { className: x.muted, children: n("workshopLab.agent.current", { key: String(Oe) }) }) : null, Ce = /* @__PURE__ */ a.jsx(St, { title: n("workshopLab.agent.newChat"), children: /* @__PURE__ */ a.jsx(
|
|
1002
1026
|
M,
|
|
1003
1027
|
{
|
|
1004
1028
|
size: "small",
|
|
1005
1029
|
type: "text",
|
|
1006
|
-
icon: /* @__PURE__ */ a.jsx(
|
|
1030
|
+
icon: /* @__PURE__ */ a.jsx(Wt, {}),
|
|
1007
1031
|
"aria-label": n("workshopLab.agent.newChat"),
|
|
1008
|
-
disabled: T ||
|
|
1009
|
-
onClick:
|
|
1032
|
+
disabled: T || b.length === 0,
|
|
1033
|
+
onClick: pe
|
|
1010
1034
|
}
|
|
1011
1035
|
) });
|
|
1012
|
-
return
|
|
1013
|
-
|
|
1036
|
+
return c === "inline" ? /* @__PURE__ */ a.jsx(
|
|
1037
|
+
Ie,
|
|
1014
1038
|
{
|
|
1015
1039
|
title: e.title,
|
|
1016
1040
|
extra: /* @__PURE__ */ a.jsxs("span", { className: x.agentMeta, children: [
|
|
1017
|
-
|
|
1018
|
-
|
|
1041
|
+
Ae,
|
|
1042
|
+
Ce
|
|
1019
1043
|
] }),
|
|
1020
|
-
children:
|
|
1044
|
+
children: ge
|
|
1021
1045
|
}
|
|
1022
|
-
) : /* @__PURE__ */ a.jsxs("div", { className: x.agentDock, "data-mode":
|
|
1046
|
+
) : /* @__PURE__ */ a.jsxs("div", { className: x.agentDock, "data-mode": c, "data-open": l, children: [
|
|
1023
1047
|
l ? /* @__PURE__ */ a.jsx(
|
|
1024
|
-
|
|
1048
|
+
Ie,
|
|
1025
1049
|
{
|
|
1026
1050
|
title: e.title,
|
|
1027
1051
|
extra: /* @__PURE__ */ a.jsxs("span", { className: x.agentMeta, children: [
|
|
1028
|
-
|
|
1029
|
-
|
|
1052
|
+
Ae,
|
|
1053
|
+
Ce,
|
|
1030
1054
|
/* @__PURE__ */ a.jsx(
|
|
1031
1055
|
M,
|
|
1032
1056
|
{
|
|
1033
1057
|
size: "small",
|
|
1034
1058
|
type: "text",
|
|
1035
|
-
icon:
|
|
1059
|
+
icon: c === "side" ? /* @__PURE__ */ a.jsx(rs, {}) : /* @__PURE__ */ a.jsx(cs, {}),
|
|
1036
1060
|
"aria-label": n("workshopLab.agent.fold"),
|
|
1037
1061
|
title: n("workshopLab.agent.fold"),
|
|
1038
|
-
onClick: () =>
|
|
1062
|
+
onClick: () => d(!1)
|
|
1039
1063
|
}
|
|
1040
1064
|
)
|
|
1041
1065
|
] }),
|
|
1042
|
-
children:
|
|
1066
|
+
children: ge
|
|
1043
1067
|
}
|
|
1044
1068
|
) : null,
|
|
1045
1069
|
/* @__PURE__ */ a.jsx("div", { hidden: l, children: /* @__PURE__ */ a.jsxs(
|
|
@@ -1048,9 +1072,9 @@ ${e.instructions}
|
|
|
1048
1072
|
type: "button",
|
|
1049
1073
|
className: x.agentSideTab,
|
|
1050
1074
|
"aria-label": e.title || n("workshopLab.agent.open"),
|
|
1051
|
-
onClick: () =>
|
|
1075
|
+
onClick: () => d(!0),
|
|
1052
1076
|
children: [
|
|
1053
|
-
/* @__PURE__ */ a.jsx(
|
|
1077
|
+
/* @__PURE__ */ a.jsx(Fe, {}),
|
|
1054
1078
|
/* @__PURE__ */ a.jsx("span", { children: e.title || n("workshopLab.agent.open") })
|
|
1055
1079
|
]
|
|
1056
1080
|
}
|
|
@@ -1058,5 +1082,5 @@ ${e.instructions}
|
|
|
1058
1082
|
] });
|
|
1059
1083
|
}
|
|
1060
1084
|
export {
|
|
1061
|
-
|
|
1085
|
+
Ms as AgentChat
|
|
1062
1086
|
};
|