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