@openbkn/workshop 0.2.3 → 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.
Files changed (96) hide show
  1. package/README.md +1 -1
  2. package/dist/{ActionConfirm-ITBip2Ic.js → ActionConfirm-BX1dlrAM.js} +5 -5
  3. package/dist/{ActionFailure-CWifUJ2j.js → ActionFailure-xcSfKJYC.js} +2 -2
  4. package/dist/{AgentChat-C1uyzwuA.js → AgentChat-DHdX_6W7.js} +407 -383
  5. package/dist/AppListPage-DsUvFo6B.js +1549 -0
  6. package/dist/{AskDrawer-Bw1NM5v_.js → AskDrawer-j-CR4yXP.js} +4 -4
  7. package/dist/{ComputedView-_CaPjqhY.js → ComputedView-dWFlHngu.js} +1035 -1016
  8. package/dist/{ConclusionApply-CG5wSeVp.js → ConclusionApply-BAoZpxl-.js} +4 -4
  9. package/dist/{CypherEditor-DbLHQoJJ.js → CypherEditor-CZ5Z4SGH.js} +47 -47
  10. package/dist/{LandingList-BMPCXj6K.js → LandingList-BUO6-at_.js} +5 -5
  11. package/dist/{MenuUnfoldOutlined-BoARCVho.js → MenuUnfoldOutlined-DAeIeIap.js} +3 -3
  12. package/dist/{ModelTrial-DZjC0E8E.js → ModelTrial-C7XvLVY7.js} +4 -4
  13. package/dist/{PageRenderer-Debi-U0v.js → PageRenderer-CkmvW4aO.js} +21264 -20549
  14. package/dist/{ScenarioApply-BNFfjIwR.js → ScenarioApply-COdlyvrC.js} +6 -6
  15. package/dist/{SimulateForm-CEqqMjks.js → SimulateForm-B_9laTIl.js} +4 -4
  16. package/dist/{Subgraph-C0VjOnZf.js → Subgraph-CDY3wvCA.js} +3 -3
  17. package/dist/WorkshopLabPage-BtYnBpk4.js +12020 -0
  18. package/dist/{WorkshopRunPage-BlyM18id.js → WorkshopRunPage-DHMJ3b8k.js} +24 -24
  19. package/dist/{abnfDiagram-WEYOIA3C-wqYhe75a.js → abnfDiagram-WEYOIA3C-Blje2Kbf.js} +3 -3
  20. package/dist/{action-type-tool.service-CtCfESYq.js → action-type-tool.service-BN-W_Az_.js} +1 -1
  21. package/dist/{architectureDiagram-ZHVYKT53-BYJ2H7bS.js → architectureDiagram-ZHVYKT53-B_FkRXc3.js} +3 -3
  22. package/dist/{bkn-agent-execution.service-ogW6NIAz.js → bkn-agent-execution.service-CJalMVIc.js} +1 -1
  23. package/dist/{blockDiagram-RJAE7QA3-DZfrfHRw.js → blockDiagram-RJAE7QA3-CYJLthoI.js} +3 -3
  24. package/dist/{c4Diagram-XDPPPE54--S7sRxgd.js → c4Diagram-XDPPPE54-CmMaN3M4.js} +2 -2
  25. package/dist/{channel-Ca2_7Xkz.js → channel-Dp24Bgua.js} +1 -1
  26. package/dist/{chunk-2E7WHVMD-BMnl6-jy.js → chunk-2E7WHVMD-DrnpfYKB.js} +1 -1
  27. package/dist/{chunk-2Q5K7J3B-BNVTYluA.js → chunk-2Q5K7J3B-BXqKcHlQ.js} +1 -1
  28. package/dist/{chunk-4EMNKR2T-CKorQf5z.js → chunk-4EMNKR2T-DYgY_0_y.js} +1 -1
  29. package/dist/{chunk-55XCU76K-C4xutPQ4.js → chunk-55XCU76K-Bja7bE8g.js} +1 -1
  30. package/dist/{chunk-5VM5RSS4-BM5F2WnL.js → chunk-5VM5RSS4-CGTnbRRi.js} +1 -1
  31. package/dist/{chunk-JWPE2WC7-CSU5SIs8.js → chunk-JWPE2WC7-2AyjxdJR.js} +1 -1
  32. package/dist/{chunk-VQ5W62QI-Dtk59D_l.js → chunk-VQ5W62QI-B3PGCKOg.js} +1 -1
  33. package/dist/{chunk-XXDRQBXY-DzVLFl9c.js → chunk-XXDRQBXY-RrIsI-B5.js} +1 -1
  34. package/dist/{chunk-ZCHMQSOR-cdQdJeDJ.js → chunk-ZCHMQSOR-COJTBW1i.js} +2 -2
  35. package/dist/{classDiagram-v2-4MYWR3UA-CABAzYlW.js → classDiagram-v2-4MYWR3UA-DolLxH6t.js} +5 -5
  36. package/dist/{cose-bilkent-JH36ORCC-Ca8GJbqv.js → cose-bilkent-JH36ORCC-DMSYgFxc.js} +2 -2
  37. package/dist/customComponents-DasaZ6pq.js +1 -1
  38. package/dist/customComponents.en-US-CkabuCXg.js +1 -1
  39. package/dist/{customParseFormat-H00Ur3YB.js → customParseFormat-C9WAjjqH.js} +1 -1
  40. package/dist/{cynefinDiagram-WF24UDRP-iIy_O6OH.js → cynefinDiagram-WF24UDRP-DrksRWCn.js} +2 -2
  41. package/dist/{dagre-NK4GIZVX-lW5Hra0G.js → dagre-NK4GIZVX-CFRT2dAc.js} +2 -2
  42. package/dist/{dayjs.min-C8_4Wqpb.js → dayjs.min-CziT8yW9.js} +1 -1
  43. package/dist/{diagram-CBK3MWTC-l5LVSm6X.js → diagram-CBK3MWTC-DzZ_sQCl.js} +3 -3
  44. package/dist/{diagram-I5XIIV2D-ChpwB8Wz.js → diagram-I5XIIV2D-RYNBUOF4.js} +2 -2
  45. package/dist/{diagram-ODIL2UCW-DBavGl7R.js → diagram-ODIL2UCW-DqJETE9R.js} +3 -3
  46. package/dist/{diagram-PFBEJUXE-B3fNIQm9.js → diagram-PFBEJUXE-BekIE7hh.js} +2 -2
  47. package/dist/{diagram-RJA3I4VV-Dmj0Shdh.js → diagram-RJA3I4VV-DAIwlMxl.js} +2 -2
  48. package/dist/{diagram-TYUNFSNR-D98rsKpY.js → diagram-TYUNFSNR-CLJ0Ou9i.js} +6 -6
  49. package/dist/{ebnfDiagram-V4P3TTPT-Bxr2oP9U.js → ebnfDiagram-V4P3TTPT-CRs8ppfT.js} +3 -3
  50. package/dist/{elk-QONTBCTQ-CvFT6Pst.js → elk-QONTBCTQ-Bqoh6AYY.js} +5 -5
  51. package/dist/{erDiagram-KYQIGQAA-dgeEoLzk.js → erDiagram-KYQIGQAA-BSp8Z7uQ.js} +4 -4
  52. package/dist/{flowDiagram-IUGLLWBU-ChsJgBPn.js → flowDiagram-IUGLLWBU-WKILTCDc.js} +7 -7
  53. package/dist/{ganttDiagram-R7GPNTJY-C9WcR8Tf.js → ganttDiagram-R7GPNTJY-CaTn_Mmr.js} +4 -4
  54. package/dist/generateCypher-BE_4YCWB.js +1032 -0
  55. package/dist/{gitGraphDiagram-PDYL7XHY-CeZTDs7V.js → gitGraphDiagram-PDYL7XHY-DGPs-RF6.js} +3 -3
  56. package/dist/{infoDiagram-MVDRKAX5-CzfcVWVf.js → infoDiagram-MVDRKAX5-HIQg7U3R.js} +1 -1
  57. package/dist/{ishikawaDiagram-HPEHV2GE-BK4ExPHB.js → ishikawaDiagram-HPEHV2GE-C84x8n2j.js} +2 -2
  58. package/dist/{journeyDiagram-BOSHW7O7-DXJ-ihrY.js → journeyDiagram-BOSHW7O7-CvYDNxSY.js} +4 -4
  59. package/dist/{kanban-definition-FNSA4HC5-C9rAkIZN.js → kanban-definition-FNSA4HC5-B586ryFD.js} +2 -2
  60. package/dist/{mermaid.core-uROF3Ult.js → mermaid.core-3J01L12Z.js} +5803 -5740
  61. package/dist/{mindmap-definition-6OY57UG3-DC9FfvxT.js → mindmap-definition-6OY57UG3-Donc6BMy.js} +3 -3
  62. package/dist/{models-D5Mffixi.js → models-Rf3LB8wS.js} +1 -1
  63. package/dist/{object-metric-numeric-DIgqXqB5.js → object-metric-numeric-BcgaJ6EW.js} +1 -1
  64. package/dist/{object-metric.service-B3PtIPEA.js → object-metric.service-CKiaFYcp.js} +2 -2
  65. package/dist/{pegDiagram-ECIUJNBX-CUCvcOc0.js → pegDiagram-ECIUJNBX-CYVi7x6D.js} +3 -3
  66. package/dist/{pieDiagram-GNMPY74T-DprBId-p.js → pieDiagram-GNMPY74T-4iWKYTTS.js} +2 -2
  67. package/dist/{prompt-D9VtVs5i.js → prompt-BQzBLrua.js} +110 -100
  68. package/dist/{quadrantDiagram-D57K4MC3-CcvW9eIV.js → quadrantDiagram-D57K4MC3-Bm6Cyi1I.js} +1 -1
  69. package/dist/{railroadDiagram-Y72NRBL7-DH43paGB.js → railroadDiagram-Y72NRBL7-Du6iN-Jz.js} +3 -3
  70. package/dist/{requirementDiagram-EQYSW5RA-CBY8WT39.js → requirementDiagram-EQYSW5RA-BGxpuSlc.js} +3 -3
  71. package/dist/{sankeyDiagram-SY24JHO5-DD80tYLM.js → sankeyDiagram-SY24JHO5-CsHmu__D.js} +2 -2
  72. package/dist/{sequenceDiagram-BLEHNHQU-Bo9dDD6b.js → sequenceDiagram-BLEHNHQU-DBNi943L.js} +3 -3
  73. package/dist/{sizeCapture-INFHLROL-BQTwKEEH.js → sizeCapture-INFHLROL-CcGr2ilA.js} +1 -1
  74. package/dist/{stateDiagram-v2-A6IESKWZ-um_LWxkE.js → stateDiagram-v2-A6IESKWZ-C78tVzaF.js} +4 -4
  75. package/dist/{swimlanes-B3ENRKFQ-DyYkLRSQ.js → swimlanes-B3ENRKFQ-BROc4LGM.js} +3 -3
  76. package/dist/{swimlanesDiagram-AYQRV4AK-DlAG_Vwl.js → swimlanesDiagram-AYQRV4AK-C0RDY4m2.js} +3 -3
  77. package/dist/{text-BqSVQKS6.js → text-CzC6K33E.js} +7 -3
  78. package/dist/{text.en-US-BhAxy_LE.js → text.en-US-D8mxBP0p.js} +6 -2
  79. package/dist/{timeline-definition-JXYKGLGB-DVH8Jsv4.js → timeline-definition-JXYKGLGB-C6WGe4xl.js} +1 -1
  80. package/dist/toolMatchLines-DrXpUwcl.js +4675 -0
  81. package/dist/{useLabData-fKy_tVvS.js → useLabData-B-3UW8zF.js} +8007 -7251
  82. package/dist/{usecaseDiagram-WPOLBNNX-DvsgvjCb.js → usecaseDiagram-WPOLBNNX-yMP7SDIg.js} +3 -3
  83. package/dist/{vennDiagram-Q3Y3IDCW-BQcWfjtm.js → vennDiagram-Q3Y3IDCW-bZW2LzBB.js} +2 -2
  84. package/dist/{wardleyDiagram-IVAIDKWA-M_Wv4tRx.js → wardleyDiagram-IVAIDKWA-DBbog93x.js} +2 -2
  85. package/dist/{workshop-app-wZ37Phc-.js → workshop-app-ByYXbgcn.js} +5008 -4707
  86. package/dist/workshop-app.css +1 -1
  87. package/dist/workshop-app.js +1 -1
  88. package/dist/{xychartDiagram-4URNHDU4-DBviJ7Ux.js → xychartDiagram-4URNHDU4-CVLJNXOt.js} +1 -1
  89. package/dist-cli/workshop.js +182 -140
  90. package/package.json +1 -1
  91. package/skill/SKILL.en-US.md +5 -0
  92. package/skill/SKILL.md +3 -0
  93. package/dist/AppFormModal-ByNEloW-.js +0 -4282
  94. package/dist/AppListPage-D2NVBJs7.js +0 -1465
  95. package/dist/WorkshopLabPage-C7hssyUo.js +0 -11364
  96. package/dist/generateCypher-kvNYDLY4.js +0 -399
@@ -1,118 +1,130 @@
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-wZ37Phc-.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-Debi-U0v.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-fKy_tVvS.js";
4
- import { l as Gt } from "./models-D5Mffixi.js";
5
- import { d as Qt } from "./prompt-D9VtVs5i.js";
6
- import { R as Zt } from "./MenuUnfoldOutlined-BoARCVho.js";
7
- var Z = {}, De;
8
- function es() {
9
- if (De) return Z;
10
- De = 1, Object.defineProperty(Z, "__esModule", { value: !0 });
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 ts = /* @__PURE__ */ es();
15
- const ss = /* @__PURE__ */ We(ts);
16
- function me() {
17
- return me = Object.assign ? Object.assign.bind() : function(s) {
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 f in r)
21
- Object.prototype.hasOwnProperty.call(r, f) && (s[f] = r[f]);
20
+ for (var p in r)
21
+ Object.prototype.hasOwnProperty.call(r, p) && (s[p] = r[p]);
22
22
  }
23
23
  return s;
24
- }, me.apply(this, arguments);
24
+ }, ye.apply(this, arguments);
25
25
  }
26
- const ns = (s, o) => /* @__PURE__ */ m.createElement(He, me({}, s, {
26
+ const ls = (s, o) => /* @__PURE__ */ m.createElement(Xe, ye({}, s, {
27
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 });
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 as = /* @__PURE__ */ os();
38
- const is = /* @__PURE__ */ We(as);
39
- function he() {
40
- return he = Object.assign ? Object.assign.bind() : function(s) {
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 f in r)
44
- Object.prototype.hasOwnProperty.call(r, f) && (s[f] = r[f]);
43
+ for (var p in r)
44
+ Object.prototype.hasOwnProperty.call(r, p) && (s[p] = r[p]);
45
45
  }
46
46
  return s;
47
- }, he.apply(this, arguments);
47
+ }, be.apply(this, arguments);
48
48
  }
49
- const ls = (s, o) => /* @__PURE__ */ m.createElement(He, he({}, s, {
49
+ const gs = (s, o) => /* @__PURE__ */ m.createElement(Xe, be({}, s, {
50
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;
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(f).length > 0 ? `当前筛选:${Object.entries(f).map(([c, h]) => `${c} = ${JSON.stringify(h)}`).join(";")}` : "",
60
- n && u ? `选中的对象:${u.label}(对象类 ${u.objectType})主键 ${String(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 ge = null;
66
- function us() {
67
- return ge ??= Gt({ page: 1, size: 100 }).then(({ items: s }) => {
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
- ge = null;
72
- }), ge;
71
+ fe = null;
72
+ }), fe;
73
73
  }
74
- const fe = 50, ze = 8e3, I = (s) => {
74
+ const me = 50, Ve = 8e3, I = (s) => {
75
75
  const o = JSON.stringify(s);
76
- return o.length > ze ? `${o.slice(0, ze)}…(已截断)` : o;
76
+ return o.length > Ve ? `${o.slice(0, Ve)}…(已截断)` : o;
77
77
  };
78
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})`);
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
- `${f ? `数据源 ${o} 还没读完` : `没有数据源 ${o}`};页面上的数据源 id:${c.join("、")}`
83
+ `${p ? `数据源 ${o} 还没读完` : `没有数据源 ${o}`};页面上的数据源 id:${d.join("、")}`
84
84
  );
85
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;
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 ds(s) {
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) => Ge(s.spec, r.id).filter((f) => f.variable === o.name).map((f) => ({ source: r.id, field: f.field ?? f.fields ?? null }))
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 qe(s, o) {
112
+ function Je(s, o) {
101
113
  let r = s;
102
- for (const [f, n] of Object.entries(o ?? {})) {
114
+ for (const [p, n] of Object.entries(o ?? {})) {
103
115
  const e = (Array.isArray(n) ? n : [n]).map(String);
104
- r = r.filter((u) => e.includes(String(u[f] ?? "")));
116
+ r = r.filter((c) => e.includes(String(c[p] ?? "")));
105
117
  }
106
118
  return r;
107
119
  }
108
- const Ue = {
120
+ const We = {
109
121
  type: "object",
110
- description: `字段等于某值(或属于几个值之一),进度列和计算列也可以用,比如 { "${mt.status}": ["${te.overdue.value}"] }(进度状态写代码)`,
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 ps(s, o) {
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(), 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;
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: c ?? null,
129
- object: h ?? null
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: 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)
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: Ue,
179
+ where: We,
162
180
  sort: { type: "string" },
163
181
  order: { type: "string", enum: ["asc", "desc"] },
164
- limit: { type: "number", description: `最多 ${fe} 条` },
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 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;
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: c.length,
185
- rows: c.slice(0, h).map(g)
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: Ue,
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 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, {
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((h, g) => g.value - h.value);
235
+ })).sort((f, g) => g.value - f.value);
212
236
  return I({
213
- groups: c.length,
214
- top: c.slice(0, Math.min(e.limit ?? 15, fe))
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
- }, 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("、")}` : ""})`
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: 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);
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: `建议卡:${h.name},${g.rows.length} 个对象`,
253
- missing: u.length - g.rows.length,
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((u) => ({ source: e, operation: u }))
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: u }) => `${e.id}.${u.id}(${u.label},参数 ${u.params.map((l) => `${l.name}:${l.label},${l.type}`).join("、")})`
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: u, keys: l }) => {
280
- const c = s(), h = n.find(
281
- (R) => R.source.id === e && R.operation.id === u
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 (!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)
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 k = p.filter((R) => yt(R, h.operation.when, c.asOf));
311
+ const b = h.filter((L) => kt(L, f.operation.when, d.asOf));
288
312
  return I({
289
313
  ok: !0,
290
- shown: `建议卡:${h.operation.label},${k.length} 个对象`,
291
- notEligible: p.length - k.length,
292
- missing: l.length - p.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: u }) => {
313
- const l = s(), c = l.spec.variables.find((h) => h.name === e);
314
- if (!c || c.kind === "selection" || c.kind === "set")
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(u) && c.kind !== "value")
340
+ if (Array.isArray(c) && d.kind !== "value")
317
341
  throw new Error(`筛选 ${e} 只接受一个值`);
318
- if (c.kind === "asOf" && typeof u == "string" && !Je(u))
342
+ if (d.kind === "asOf" && typeof c == "string" && !He(c))
319
343
  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)))
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
- u === null ? void 0 : c.kind === "dateRange" && typeof u == "string" ? Mt(u) : u
328
- ), I({ ok: !0, filter: c.label, value: u });
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: u }) => {
341
- const l = s(), c = l.spec.variables.find(
342
- (h) => h.kind === "selection" && (!e || h.name === e)
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 (!c) throw new Error("页面上没有可选中的对象");
345
- return l.setValue(c.name, u, { quiet: !0 }), I({ ok: !0, selected: u });
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 Je(s) {
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 gs(s) {
355
- const o = Object.values(s.regions).flatMap((r) => r ?? []).filter((r) => ht(r.type)).map((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: At(r.type).label,
381
+ component: Pt(r.type).label,
358
382
  title: r.config.title ?? null,
359
- shows: $t(r.id) ?? null
383
+ shows: It(r.id) ?? null
360
384
  }));
361
385
  return o.length > 0 ? { customComponents: o } : {};
362
386
  }
363
- const fs = "<answer>";
364
- function ms(s, o) {
387
+ const ws = "<answer>";
388
+ function ks(s, o) {
365
389
  const r = s.spec.sources.map((n) => {
366
390
  const e = [
367
- ...bt(n.progress),
391
+ ...vt(n.progress),
368
392
  ...(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("、")}` : ""})`;
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
- `), f = s.spec.variables.map((n) => `- ${n.name}:${n.label}(${n.kind})`).join(`
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
- ${f}
414
+ ${p}
391
415
  ${o.instructions ? `
392
416
  补充说明:
393
417
  ${o.instructions}
394
418
  ` : ""}
395
- ${Qt(s.kn)}
419
+ ${ns(s.kn)}
396
420
 
397
- 最终回答完整写在 ${fs} 与 </answer> 之间。`;
421
+ 最终回答完整写在 ${ws} 与 </answer> 之间。`;
398
422
  }
399
- const ye = (s) => s && typeof s == "object" && !Array.isArray(s) ? s : {};
400
- function Qe(s) {
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 ye(JSON.parse(s));
427
+ return we(JSON.parse(s));
404
428
  } catch {
405
429
  return {};
406
430
  }
407
431
  }
408
- function hs(s) {
409
- const o = Qe(s), r = o.message ?? o.error ?? o.detail;
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 ys = Object.fromEntries(
436
+ const xs = Object.fromEntries(
413
437
  Object.values(te).map((s) => [s.value, s.label])
414
438
  );
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;
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 p = Array.isArray(r.keys) ? r.keys.length : 0, k = g(f.total);
449
+ const h = Array.isArray(r.keys) ? r.keys.length : 0, b = g(p.total);
426
450
  return {
427
- key: p > 0 ? "listKeys" : k === void 0 ? "list" : "listCount",
428
- values: { source: u, total: k ?? 0, keys: p },
429
- where: h
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 p = g(f.groups);
457
+ const h = g(p.groups);
434
458
  return {
435
- key: p === void 0 ? "summarize" : "summarizeCount",
459
+ key: h === void 0 ? "summarize" : "summarizeCount",
436
460
  values: {
437
- source: u,
461
+ source: c,
438
462
  field: l(String(r.groupBy ?? "")),
439
- groups: p ?? 0
463
+ groups: h ?? 0
440
464
  },
441
- where: h
465
+ where: f
442
466
  };
443
467
  }
444
468
  case "run_cypher": {
445
- let p;
469
+ let h;
446
470
  try {
447
- const k = s.result ? JSON.parse(s.result) : void 0;
448
- Array.isArray(k) && (p = k.length);
471
+ const b = s.result ? JSON.parse(s.result) : void 0;
472
+ Array.isArray(b) && (h = b.length);
449
473
  } catch {
450
- p = void 0;
474
+ h = void 0;
451
475
  }
452
- return { key: p === void 0 ? "cypher" : "cypherCount", values: { rows: p ?? 0 } };
476
+ return { key: h === void 0 ? "cypher" : "cypherCount", values: { rows: h ?? 0 } };
453
477
  }
454
478
  case "propose_action": {
455
- const p = String(r.action ?? "");
479
+ const h = String(r.action ?? "");
456
480
  return {
457
481
  key: "propose",
458
482
  values: {
459
- name: se(o.kn, p)?.name ?? p,
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((k) => k.id === r.operation)?.label ?? String(r.operation ?? ""),
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 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) } };
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 ws = {
506
+ const $s = {
483
507
  done: "success",
484
508
  failed: "error",
485
509
  cancelled: "default",
486
510
  accepted: "processing"
487
- }, ks = ["done", "accepted", "failed", "cancelled"], vs = /DSML|<|[^>]*(calls|invoke)/, xs = 12, js = (s, o) => new Promise((r, f) => {
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), f(new DOMException("Aborted", "AbortError"));
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 Rs({
519
+ function Ms({
496
520
  config: s,
497
521
  initial: o,
498
522
  bare: r,
499
- onAsked: f
523
+ onAsked: p
500
524
  }) {
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);
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: Pt(g.spec, g.values) };
527
+ q.current = { ...g, asOf: zt(g.spec, g.values), link: h };
504
528
  }), m.useEffect(() => {
505
529
  let t = !0;
506
- return us().then((d) => {
507
- t && (Ze(d), et(!0));
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
- 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);
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
- ve(e.agent?.agentId);
540
+ je(e.agent?.agentId);
517
541
  }, [e.agent?.mcp, e.agent?.agentId]), m.useEffect(() => {
518
542
  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,
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: d ? () => Ie(d) : void 0,
526
- bkn_token: e.passToken ? Me() : void 0
549
+ workspace_id: u ? () => De(u) : void 0,
550
+ bkn_token: e.passToken ? Be() : void 0
527
551
  }).then((i) => {
528
- t && xe(i);
552
+ t && $e(i);
529
553
  }).catch(() => {
530
- t && je(!0);
554
+ t && Se(!0);
531
555
  }).finally(() => {
532
- t && ae(!1);
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
- st,
564
+ ot,
541
565
  g.appId,
542
566
  g.kn.id,
543
567
  e.passToken
544
568
  ]);
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(
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
- ), rt = m.useRef(/* @__PURE__ */ new Map()), [ot, at] = m.useState(), ue = O?.mcp, Oe = !!O?.mcpName;
571
+ ), it = m.useRef(/* @__PURE__ */ new Map()), [lt, ct] = m.useState(), de = O?.mcp, Ee = !!O?.mcpName;
548
572
  m.useEffect(() => {
549
- if (!ue || Oe) return;
573
+ if (!de || Ee) return;
550
574
  let t = !0;
551
- return Ft(ue).then(
552
- (d) => {
553
- t && at(d);
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
- }, [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(
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" && L((d) => ({ ...d, error: t.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, H = async (t, d) => {
600
+ ${t.context}` : t.text, W = async (t, u) => {
577
601
  const i = q.current;
578
- if (!i || !J || t.trim() === "" || T) return;
602
+ if (!i || !V || t.trim() === "" || T) return;
579
603
  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) }
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
- k((y) => [...y, b, { role: "assistant", text: "", tools: [] }]), D(""), F(void 0), P(!0);
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 qt({
615
+ await Ht({
592
616
  knId: i.kn.id,
593
- modelName: ne,
594
- system: ms(i, {
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: ps(() => q.current ?? i, {
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: xs,
629
+ maxSteps: Ls,
606
630
  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
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
- }, 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);
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, w = {
643
+ const y = g.appId, k = {
620
644
  question: Q($),
621
645
  context: [
622
- Ye(b, e.selection),
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: Se.current,
630
- agent_id: E,
653
+ conversation_id: Le.current,
654
+ agent_id: R,
631
655
  app_id: g.appId,
632
- kn_id: b.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 ? () => Ie(y) : void 0,
635
- bkn_token: e.passToken ? Me() : void 0
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 Jt(
664
+ const _ = await Xt(
641
665
  t,
642
- j ? { ...w, run_id: j } : w,
643
- rt.current,
666
+ j ? { ...k, run_id: j } : k,
667
+ it.current,
644
668
  S.signal
645
669
  );
646
670
  if (_.done) {
647
- L(
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 >= Wt) {
676
+ if (!_.runId || Date.now() - v >= Gt) {
653
677
  const Y = _.runId ? "gaveUp" : "notFollowed";
654
- L((ft) => ({
655
- ...ft,
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
- L((Y) => ({ ...Y, waiting: _.text })), j = _.runId, await js(Ht, S.signal);
685
+ E((Y) => ({ ...Y, waiting: _.text })), j = _.runId, await Es(Qt, S.signal);
662
686
  }
663
687
  } catch (j) {
664
- S.signal.aborted || L((_) => ({
688
+ S.signal.aborted || E((_) => ({
665
689
  ..._,
666
690
  waiting: void 0,
667
- error: j instanceof Vt ? n(`workshopLab.agent.outside.${j.reason}`, { detail: j.detail }) : String(j)
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
- }, 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);
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
- Ye(i, e.selection),
702
+ Ue(i, e.selection),
679
703
  e.instructions ? `<app_instructions>
680
704
  ${e.instructions}
681
705
  </app_instructions>` : "",
682
- Q(b)
706
+ Q(w)
683
707
  ].filter(Boolean).join(`
684
708
 
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) => ({
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: w.id, name: w.name, args: w.input }]
690
- })) : w.type === "tool_finished" && L((v) => ({
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 === w.id ? w.status === "succeeded" ? { ...j, result: JSON.stringify(w.output) } : { ...j, error: JSON.stringify(w.error ?? w.output) } : j
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 w = (j) => Kt({
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 w(W.current);
731
+ v = await k(J.current);
708
732
  } catch (j) {
709
- if (!(!!j?.unknownThread && !!W.current)) throw j;
710
- W.current = void 0, v = await w();
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" && L((j) => ({ ...j, error: v.error ?? "" }));
713
- } catch (w) {
714
- $.signal.aborted || L((v) => ({ ...v, error: Xt(w) }));
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
- ce.current = void 0, N.current === $ && P(!1);
740
+ ue.current = void 0, N.current === $ && P(!1);
717
741
  }
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));
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: b.id,
747
+ action: w.id,
724
748
  source: $.source,
725
- objects: $.rows.slice(0, Be),
726
- ...$.rows.length > Be ? { total: $.rows.length } : {},
749
+ objects: $.rows.slice(0, Ye),
750
+ ...$.rows.length > Ye ? { total: $.rows.length } : {},
727
751
  params: {},
728
- inputs: b.inputs.map((y) => ({ name: y.name, label: y.label ?? y.name })),
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) => we((w) => ({ ...w, [d]: y }))
758
+ onDone: (y) => ve((k) => ({ ...k, [u]: y }))
735
759
  });
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))),
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
- d.asOf
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
- }, pt = () => {
776
+ }, mt = () => {
753
777
  N.current?.abort();
754
- const t = ce.current;
755
- e.provider === "bknAgent" && t && Ut(t).catch(() => {
778
+ const t = ue.current;
779
+ e.provider === "bknAgent" && t && Kt(t).catch(() => {
756
780
  });
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)}`;
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), de();
785
+ N.current?.abort(), P(!1), pe();
762
786
  }, [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);
787
+ const [B, _e] = m.useState(o ?? null), Re = m.useRef(W), Ne = m.useRef(p);
764
788
  m.useEffect(() => {
765
- _e.current = H, Ee.current = f;
789
+ Re.current = W, Ne.current = p;
766
790
  }), m.useEffect(() => {
767
791
  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));
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", d), () => t.removeEventListener("ask", d);
773
- }, [g.asks, le]), m.useEffect(() => {
774
- if (!B || e.provider === "frontend" && !ke || ie) return;
775
- Le(null);
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" && 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"))
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.${d.key}`, {
784
- ...d.values,
785
- name: Re(t.name),
807
+ return n(`workshopLab.agent.steps.${u.key}`, {
808
+ ...u.values,
809
+ name: Te(t.name),
786
810
  where: i
787
811
  });
788
- }, pe = /* @__PURE__ */ a.jsxs(
812
+ }, ge = /* @__PURE__ */ a.jsxs(
789
813
  "div",
790
814
  {
791
815
  className: x.agent,
792
- style: r || u !== "inline" ? void 0 : { height: e.height },
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
- kt,
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: oe,
807
- disabled: T || oe,
808
- value: E,
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
- ...E && !U?.some((t) => t.id === E) ? [
838
+ ...R && !U?.some((t) => t.id === R) ? [
815
839
  {
816
- value: E,
817
- label: G ? n("workshopLab.agent.outside.agentUnavailable") : e.agent?.agentName || E,
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
- de(), ve(t);
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
- tt && /* @__PURE__ */ a.jsx(
829
- K,
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: () => nt((t) => t + 1), children: n("workshopLab.agent.outside.retry") })
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: re, className: x.agentLog, children: [
838
- e.provider === "mcp" && !O && /* @__PURE__ */ a.jsx(K, { type: "warning", showIcon: !0, message: n("workshopLab.agent.outside.notPicked") }),
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
- K,
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
- 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, {}) }),
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 || !J,
879
+ disabled: T || !V,
856
880
  onClick: () => {
857
- H(t.text);
881
+ W(t.text);
858
882
  },
859
883
  children: t.text
860
884
  },
861
885
  t.text
862
886
  )) })
863
887
  ] }),
864
- p.map(
865
- (t, d) => t.role === "user" ? /* @__PURE__ */ a.jsxs("div", { className: x.agentUser, title: t.context, children: [
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
- ] }, d) : /* @__PURE__ */ a.jsxs("div", { className: x.agentAnswer, children: [
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: gt(i) }),
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 b = i.args, $ = se(g.kn, b.action), S = `${d}:${i.id}`, y = R[S], w = !y || y.every((v) => v.status === "failed");
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 ?? b.action,
895
- count: b.keys.length
918
+ name: $?.name ?? w.action,
919
+ count: w.keys.length
896
920
  }) }),
897
- /* @__PURE__ */ a.jsx("span", { className: x.muted, children: b.reason }),
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
- ks.map((v) => {
924
+ Ss.map((v) => {
901
925
  const j = y.filter((_) => _.status === v).length;
902
- return j > 0 ? /* @__PURE__ */ a.jsxs(Yt, { color: ws[v], children: [
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
- w && /* @__PURE__ */ a.jsx(
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: () => ut(b, S),
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 b = i.args, $ = g.spec.sources.find((S) => S.id === b.source)?.operations?.find((S) => S.id === b.operation);
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 ?? b.operation,
926
- count: b.keys.length
949
+ name: $?.label ?? w.operation,
950
+ count: w.keys.length
927
951
  }) }),
928
- /* @__PURE__ */ a.jsx("span", { className: x.muted, children: b.reason }),
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: () => dt(b),
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 === E)?.name || (E === e.agent?.agentId ? e.agent?.agentName : void 0) || O.mcpName || ot || O.mcp
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(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)
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(K, { type: "warning", showIcon: !0, message: t.notice }),
948
- t.error && /* @__PURE__ */ a.jsx(K, { type: "error", showIcon: !0, message: t.error })
949
- ] }, d)
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
- vt.TextArea,
982
+ $t.TextArea,
959
983
  {
960
984
  variant: "borderless",
961
985
  autoSize: { minRows: 1, maxRows: 4 },
962
- value: V,
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(), H(V, X));
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(cs, {}),
1000
+ icon: /* @__PURE__ */ a.jsx(fs, {}),
977
1001
  "aria-label": n("workshopLab.agent.stop"),
978
1002
  title: n("workshopLab.agent.stop"),
979
- onClick: pt
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(Lt, {}),
1011
+ icon: /* @__PURE__ */ a.jsx(_t, {}),
988
1012
  "aria-label": n("workshopLab.agent.send"),
989
1013
  title: n("workshopLab.agent.send"),
990
- disabled: !J || V.trim() === "",
1014
+ disabled: !V || K.trim() === "",
991
1015
  onClick: () => {
992
- H(V, X);
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 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(
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(zt, {}),
1030
+ icon: /* @__PURE__ */ a.jsx(Wt, {}),
1007
1031
  "aria-label": n("workshopLab.agent.newChat"),
1008
- disabled: T || p.length === 0,
1009
- onClick: de
1032
+ disabled: T || b.length === 0,
1033
+ onClick: pe
1010
1034
  }
1011
1035
  ) });
1012
- return u === "inline" ? /* @__PURE__ */ a.jsx(
1013
- Ce,
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
- Ne,
1018
- Te
1041
+ Ae,
1042
+ Ce
1019
1043
  ] }),
1020
- children: pe
1044
+ children: ge
1021
1045
  }
1022
- ) : /* @__PURE__ */ a.jsxs("div", { className: x.agentDock, "data-mode": u, "data-open": l, children: [
1046
+ ) : /* @__PURE__ */ a.jsxs("div", { className: x.agentDock, "data-mode": c, "data-open": l, children: [
1023
1047
  l ? /* @__PURE__ */ a.jsx(
1024
- Ce,
1048
+ Ie,
1025
1049
  {
1026
1050
  title: e.title,
1027
1051
  extra: /* @__PURE__ */ a.jsxs("span", { className: x.agentMeta, children: [
1028
- Ne,
1029
- Te,
1052
+ Ae,
1053
+ Ce,
1030
1054
  /* @__PURE__ */ a.jsx(
1031
1055
  M,
1032
1056
  {
1033
1057
  size: "small",
1034
1058
  type: "text",
1035
- icon: u === "side" ? /* @__PURE__ */ a.jsx(Zt, {}) : /* @__PURE__ */ a.jsx(rs, {}),
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: () => c(!1)
1062
+ onClick: () => d(!1)
1039
1063
  }
1040
1064
  )
1041
1065
  ] }),
1042
- children: pe
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: () => c(!0),
1075
+ onClick: () => d(!0),
1052
1076
  children: [
1053
- /* @__PURE__ */ a.jsx(Pe, {}),
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
- Rs as AgentChat
1085
+ Ms as AgentChat
1062
1086
  };