@trops/dash-core 0.1.682 → 0.1.683

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -13863,6 +13863,13 @@ function parseEventString(eventString) {
13863
13863
  }
13864
13864
 
13865
13865
  /** Build an event string in the canonical runtime format. */
13866
+ /**
13867
+ * Bots publish on the same bus (`bot:<ref>[<botId>].<event>`); as listener
13868
+ * sources they aren't widgets in the layout (bot-teams TEAM-012).
13869
+ */
13870
+ function isBotSource(component) {
13871
+ return typeof component === "string" && component.startsWith("bot:");
13872
+ }
13866
13873
  function formatEventString(component, itemId, event) {
13867
13874
  return "".concat(component, "[").concat(itemId, "].").concat(event);
13868
13875
  }
@@ -14052,6 +14059,7 @@ function getCurrentWiring(workspace) {
14052
14059
  * message.
14053
14060
  */
14054
14061
  function getOrphanedListeners(workspace, getWidgetConfig) {
14062
+ var botEmitters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
14055
14063
  var wiring = getCurrentWiring(workspace);
14056
14064
  if (wiring.length === 0) return [];
14057
14065
 
@@ -14083,34 +14091,55 @@ function getOrphanedListeners(workspace, getWidgetConfig) {
14083
14091
  var _iterator2 = _createForOfIteratorHelper$O(wiring),
14084
14092
  _step2;
14085
14093
  try {
14094
+ var _loop = function _loop() {
14095
+ var w = _step2.value;
14096
+ // Bot sources (TEAM-012): judged against the dashboard's bots once they
14097
+ // are known (`botEmitters`); before that, left alone.
14098
+ if (isBotSource(w.sourceComponent)) {
14099
+ if (!Array.isArray(botEmitters)) return 0; // continue
14100
+ var bot = botEmitters.find(function (b) {
14101
+ return b.component === w.sourceComponent && String(b.itemId) === String(w.sourceItemId);
14102
+ });
14103
+ if (!bot) orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14104
+ reason: "bot-missing"
14105
+ }));else if (!bot.events.includes(w.eventName)) {
14106
+ orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14107
+ reason: "event-not-emitted"
14108
+ }));
14109
+ }
14110
+ return 0; // continue
14111
+ }
14112
+ var srcKey = "".concat(w.sourceComponent, "|").concat(w.sourceItemId);
14113
+ var src = byCompositeKey.get(srcKey);
14114
+ if (!src) {
14115
+ // No (component, id) match. If some OTHER widget still owns
14116
+ // this id, the source component changed; otherwise it's truly
14117
+ // missing. Preserves the user's ability to see whether a
14118
+ // rename happened vs. a delete.
14119
+ var fallback = byItemId.get(String(w.sourceItemId));
14120
+ orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14121
+ reason: fallback ? "source-component-mismatch" : "source-missing"
14122
+ }));
14123
+ return 0; // continue
14124
+ }
14125
+ if (!src.events.includes(w.eventName)) {
14126
+ orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14127
+ reason: "event-not-emitted"
14128
+ }));
14129
+ return 0; // continue
14130
+ }
14131
+ var receiverKey = "".concat(w.receiverComponent, "|").concat(w.receiverItemId);
14132
+ var receiver = byCompositeKey.get(receiverKey);
14133
+ if (receiver && !receiver.eventHandlers.includes(w.handlerName)) {
14134
+ orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14135
+ reason: "handler-not-declared"
14136
+ }));
14137
+ }
14138
+ },
14139
+ _ret;
14086
14140
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
14087
- var w = _step2.value;
14088
- var srcKey = "".concat(w.sourceComponent, "|").concat(w.sourceItemId);
14089
- var src = byCompositeKey.get(srcKey);
14090
- if (!src) {
14091
- // No (component, id) match. If some OTHER widget still owns
14092
- // this id, the source component changed; otherwise it's truly
14093
- // missing. Preserves the user's ability to see whether a
14094
- // rename happened vs. a delete.
14095
- var fallback = byItemId.get(String(w.sourceItemId));
14096
- orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14097
- reason: fallback ? "source-component-mismatch" : "source-missing"
14098
- }));
14099
- continue;
14100
- }
14101
- if (!src.events.includes(w.eventName)) {
14102
- orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14103
- reason: "event-not-emitted"
14104
- }));
14105
- continue;
14106
- }
14107
- var receiverKey = "".concat(w.receiverComponent, "|").concat(w.receiverItemId);
14108
- var receiver = byCompositeKey.get(receiverKey);
14109
- if (receiver && !receiver.eventHandlers.includes(w.handlerName)) {
14110
- orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14111
- reason: "handler-not-declared"
14112
- }));
14113
- }
14141
+ _ret = _loop();
14142
+ if (_ret === 0) continue;
14114
14143
  }
14115
14144
  } catch (err) {
14116
14145
  _iterator2.e(err);
@@ -14202,7 +14231,9 @@ function pruneDeadListenerReferences(workspace) {
14202
14231
  for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
14203
14232
  var raw = _step6.value;
14204
14233
  var parsed = parseEventString(raw);
14205
- if (parsed && liveKeys.has("".concat(parsed.component, "|").concat(parsed.itemId))) {
14234
+ if (parsed && (
14235
+ // Bot sources live outside the layout — never pruned here.
14236
+ isBotSource(parsed.component) || liveKeys.has("".concat(parsed.component, "|").concat(parsed.itemId)))) {
14206
14237
  kept.push(raw);
14207
14238
  } else {
14208
14239
  removed += 1;
@@ -14365,7 +14396,7 @@ function applyToItem(listeners, _ref2) {
14365
14396
  var _iterator0 = _createForOfIteratorHelper$O(removes),
14366
14397
  _step0;
14367
14398
  try {
14368
- var _loop = function _loop() {
14399
+ var _loop2 = function _loop2() {
14369
14400
  var r = _step0.value;
14370
14401
  var target = r.handlerName;
14371
14402
  if (!target) return 0; // continue
@@ -14381,10 +14412,10 @@ function applyToItem(listeners, _ref2) {
14381
14412
  next[target] = filtered;
14382
14413
  }
14383
14414
  },
14384
- _ret;
14415
+ _ret2;
14385
14416
  for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
14386
- _ret = _loop();
14387
- if (_ret === 0) continue;
14417
+ _ret2 = _loop2();
14418
+ if (_ret2 === 0) continue;
14388
14419
  }
14389
14420
  } catch (err) {
14390
14421
  _iterator0.e(err);
@@ -48511,6 +48542,443 @@ function SharedFieldRow(_ref6) {
48511
48542
  function _createForOfIteratorHelper$q(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$q(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
48512
48543
  function _unsupportedIterableToArray$q(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$q(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$q(r, a) : void 0; } }
48513
48544
  function _arrayLikeToArray$q(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
48545
+
48546
+ /**
48547
+ * @param {Array<object>} workspaces dashboards (each with id, name, layout/pages)
48548
+ * @param {(component: string) => object|null} getWidgetConfig
48549
+ * @returns {Array<{ workspaceId: string, name: string,
48550
+ * widgets: Array<{ ref: string, instanceId: string, label: string, events: string[] }> }>}
48551
+ * dashboards with at least one event-emitting widget
48552
+ */
48553
+ function buildWidgetEventCatalog(workspaces, getWidgetConfig) {
48554
+ if (!Array.isArray(workspaces)) return [];
48555
+ var out = [];
48556
+ var _iterator = _createForOfIteratorHelper$q(workspaces),
48557
+ _step;
48558
+ try {
48559
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
48560
+ var ws = _step.value;
48561
+ if (!ws || ws.id === undefined || ws.id === null) continue;
48562
+ var widgets = getEmitters(ws, getWidgetConfig).filter(function (e) {
48563
+ return e.itemId != null && e.events.length;
48564
+ }).map(function (e) {
48565
+ return {
48566
+ ref: e.component,
48567
+ instanceId: String(e.itemId),
48568
+ label: e.label || e.component,
48569
+ events: e.events
48570
+ };
48571
+ });
48572
+ if (!widgets.length) continue;
48573
+ out.push({
48574
+ workspaceId: String(ws.id),
48575
+ name: ws.name || "Dashboard ".concat(ws.id),
48576
+ widgets: widgets
48577
+ });
48578
+ }
48579
+ // Dashboards can share a name (e.g. copies of "Kitchen Sink"); number the
48580
+ // duplicates so each picker entry is distinguishable.
48581
+ } catch (err) {
48582
+ _iterator.e(err);
48583
+ } finally {
48584
+ _iterator.f();
48585
+ }
48586
+ var totals = {};
48587
+ for (var _i = 0, _out = out; _i < _out.length; _i++) {
48588
+ var w = _out[_i];
48589
+ totals[w.name] = (totals[w.name] || 0) + 1;
48590
+ }
48591
+ var seen = {};
48592
+ for (var _i2 = 0, _out2 = out; _i2 < _out2.length; _i2++) {
48593
+ var _w = _out2[_i2];
48594
+ if (totals[_w.name] > 1) {
48595
+ seen[_w.name] = (seen[_w.name] || 0) + 1;
48596
+ _w.name = "".concat(_w.name, " (").concat(seen[_w.name], ")");
48597
+ }
48598
+ }
48599
+ return out;
48600
+ }
48601
+
48602
+ /** A subscription to one widget event, picked from the catalog. */
48603
+ function widgetSubscription(workspace, widget, event) {
48604
+ return {
48605
+ eventType: formatEventString(widget.ref, widget.instanceId, event),
48606
+ source: {
48607
+ kind: "widget",
48608
+ ref: widget.ref,
48609
+ instanceId: widget.instanceId,
48610
+ event: event,
48611
+ workspaceId: workspace.workspaceId
48612
+ },
48613
+ label: "".concat(workspace.name, " \u203A ").concat(widget.label, " \u203A ").concat(event)
48614
+ };
48615
+ }
48616
+
48617
+ /**
48618
+ * How to show a saved subscription: its label from the live catalog, and
48619
+ * whether its widget/event is gone (`missing`). Subscriptions saved before
48620
+ * the picker (bare eventType) get a friendly label when they still resolve;
48621
+ * otherwise they show as typed.
48622
+ */
48623
+ function describeSubscription(sub, catalog) {
48624
+ var botCatalog = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
48625
+ var eventType = sub && sub.eventType;
48626
+ // Bot subscriptions resolve against the bot catalog; `kind` lets the form
48627
+ // say "bot missing" instead of "widget missing".
48628
+ if (sub && sub.source && sub.source.kind === "bot") {
48629
+ var _iterator2 = _createForOfIteratorHelper$q(botCatalog || []),
48630
+ _step2;
48631
+ try {
48632
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
48633
+ var b = _step2.value;
48634
+ var _iterator3 = _createForOfIteratorHelper$q(b.events),
48635
+ _step3;
48636
+ try {
48637
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
48638
+ var ev = _step3.value;
48639
+ var s = botSubscription(b, ev);
48640
+ if (s.eventType === eventType) {
48641
+ return {
48642
+ label: s.label,
48643
+ missing: false,
48644
+ kind: "bot"
48645
+ };
48646
+ }
48647
+ }
48648
+ } catch (err) {
48649
+ _iterator3.e(err);
48650
+ } finally {
48651
+ _iterator3.f();
48652
+ }
48653
+ }
48654
+ } catch (err) {
48655
+ _iterator2.e(err);
48656
+ } finally {
48657
+ _iterator2.f();
48658
+ }
48659
+ return {
48660
+ label: sub.label || eventType,
48661
+ missing: true,
48662
+ kind: "bot"
48663
+ };
48664
+ }
48665
+ var _iterator4 = _createForOfIteratorHelper$q(catalog || []),
48666
+ _step4;
48667
+ try {
48668
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
48669
+ var ws = _step4.value;
48670
+ var _iterator5 = _createForOfIteratorHelper$q(ws.widgets),
48671
+ _step5;
48672
+ try {
48673
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
48674
+ var w = _step5.value;
48675
+ var _iterator6 = _createForOfIteratorHelper$q(w.events),
48676
+ _step6;
48677
+ try {
48678
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
48679
+ var _ev = _step6.value;
48680
+ if (formatEventString(w.ref, w.instanceId, _ev) === eventType) {
48681
+ return {
48682
+ label: widgetSubscription(ws, w, _ev).label,
48683
+ missing: false
48684
+ };
48685
+ }
48686
+ }
48687
+ } catch (err) {
48688
+ _iterator6.e(err);
48689
+ } finally {
48690
+ _iterator6.f();
48691
+ }
48692
+ }
48693
+ } catch (err) {
48694
+ _iterator5.e(err);
48695
+ } finally {
48696
+ _iterator5.f();
48697
+ }
48698
+ }
48699
+ } catch (err) {
48700
+ _iterator4.e(err);
48701
+ } finally {
48702
+ _iterator4.f();
48703
+ }
48704
+ if (sub && sub.source) {
48705
+ return {
48706
+ label: sub.label || eventType,
48707
+ missing: true
48708
+ };
48709
+ }
48710
+ return {
48711
+ label: eventType || "",
48712
+ missing: false
48713
+ };
48714
+ }
48715
+
48716
+ /**
48717
+ * Events other bots publish (bot:<ref>[<botId>].<event>, PRD US-010), for the
48718
+ * "Another bot" side of the picker. Derived from each bot's settings — never
48719
+ * hand-declared: Completed, Failed, and one `tool.<providerType>.<tool>` per
48720
+ * tool the bot may use (the provider's tools, narrowed by the bot's
48721
+ * selection). Providers with no known type or tool list are skipped.
48722
+ *
48723
+ * @param {Array<object>} bots
48724
+ * @param {Array<{name, type, tools}>} toolSources bots.listToolSources()
48725
+ * @param {string} [excludeBotId] the bot being edited — can't trigger itself
48726
+ */
48727
+ function buildBotEventCatalog(bots, toolSources) {
48728
+ var excludeBotId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
48729
+ if (!Array.isArray(bots)) return [];
48730
+ var sources = Array.isArray(toolSources) ? toolSources : [];
48731
+ var out = [];
48732
+ var _iterator7 = _createForOfIteratorHelper$q(bots),
48733
+ _step7;
48734
+ try {
48735
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
48736
+ var bot = _step7.value;
48737
+ if (!bot || !bot.id || !bot.ref || bot.id === excludeBotId) continue;
48738
+ var events = [{
48739
+ event: "completed",
48740
+ label: "Completed"
48741
+ }, {
48742
+ event: "failed",
48743
+ label: "Failed"
48744
+ }];
48745
+ var _iterator8 = _createForOfIteratorHelper$q(bot.mcpServers || []),
48746
+ _step8;
48747
+ try {
48748
+ var _loop = function _loop() {
48749
+ var provider = _step8.value;
48750
+ var src = sources.find(function (s) {
48751
+ return s && s.name === provider;
48752
+ });
48753
+ if (!src || !src.type || !Array.isArray(src.tools)) return 1; // continue
48754
+ var sel = bot.toolSelections && bot.toolSelections[provider];
48755
+ var tools = Array.isArray(sel) ? src.tools.filter(function (t) {
48756
+ return sel.includes(t);
48757
+ }) : src.tools;
48758
+ var _iterator9 = _createForOfIteratorHelper$q(tools),
48759
+ _step9;
48760
+ try {
48761
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
48762
+ var tool = _step9.value;
48763
+ events.push({
48764
+ event: "tool.".concat(src.type, ".").concat(tool),
48765
+ label: "".concat(provider, " \u203A ").concat(tool)
48766
+ });
48767
+ }
48768
+ } catch (err) {
48769
+ _iterator9.e(err);
48770
+ } finally {
48771
+ _iterator9.f();
48772
+ }
48773
+ };
48774
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
48775
+ if (_loop()) continue;
48776
+ }
48777
+ } catch (err) {
48778
+ _iterator8.e(err);
48779
+ } finally {
48780
+ _iterator8.f();
48781
+ }
48782
+ out.push({
48783
+ botId: bot.id,
48784
+ ref: bot.ref,
48785
+ name: bot.name || bot.id,
48786
+ events: events
48787
+ });
48788
+ }
48789
+ } catch (err) {
48790
+ _iterator7.e(err);
48791
+ } finally {
48792
+ _iterator7.f();
48793
+ }
48794
+ return out;
48795
+ }
48796
+
48797
+ /** A subscription to one bot event, picked from the bot catalog. */
48798
+ function botSubscription(botEntry, ev) {
48799
+ return {
48800
+ eventType: "bot:".concat(botEntry.ref, "[").concat(botEntry.botId, "].").concat(ev.event),
48801
+ source: {
48802
+ kind: "bot",
48803
+ ref: botEntry.ref,
48804
+ instanceId: botEntry.botId,
48805
+ event: ev.event
48806
+ },
48807
+ label: "".concat(botEntry.name, " \u203A ").concat(ev.label)
48808
+ };
48809
+ }
48810
+ function botEventLabel(ev) {
48811
+ if (!ev.event.startsWith("tool.")) return ev.label;
48812
+ // Tool events are labelled "<provider> › <tool>" in the catalog.
48813
+ var _String$split = String(ev.label).split(" › "),
48814
+ _String$split2 = _slicedToArray(_String$split, 2),
48815
+ provider = _String$split2[0],
48816
+ tool = _String$split2[1];
48817
+ return tool ? "uses ".concat(tool, " (").concat(provider, ")") : ev.label;
48818
+ }
48819
+
48820
+ /**
48821
+ * Everything that can trigger a bot, flattened for one "Runs when…" picker
48822
+ * (bot-teams TEAM-012): `{ value, label, group, subscription }`, value = the
48823
+ * subscription's eventType.
48824
+ *
48825
+ * A team bot only runs on its own dashboard's events, so it's offered that
48826
+ * dashboard's widgets ("Widgets on <dashboard>") and its teammates ("Bots on
48827
+ * this team"). An unassigned bot is offered every dashboard's widgets and
48828
+ * every bot ("Bots", labelled with their dashboard). The bot itself and
48829
+ * triggers it already has are left out; two copies of one widget are
48830
+ * numbered.
48831
+ *
48832
+ * @param {{ team: string|null, workspaces: object[], getWidgetConfig: Function,
48833
+ * bots: object[], toolSources: object[], botId?: string,
48834
+ * existing?: string[] }} input
48835
+ */
48836
+ function buildTriggerOptions(_ref) {
48837
+ var _ref$team = _ref.team,
48838
+ team = _ref$team === void 0 ? null : _ref$team,
48839
+ _ref$workspaces = _ref.workspaces,
48840
+ workspaces = _ref$workspaces === void 0 ? [] : _ref$workspaces,
48841
+ _ref$getWidgetConfig = _ref.getWidgetConfig,
48842
+ getWidgetConfig = _ref$getWidgetConfig === void 0 ? null : _ref$getWidgetConfig,
48843
+ _ref$bots = _ref.bots,
48844
+ bots = _ref$bots === void 0 ? [] : _ref$bots,
48845
+ _ref$toolSources = _ref.toolSources,
48846
+ toolSources = _ref$toolSources === void 0 ? [] : _ref$toolSources,
48847
+ _ref$botId = _ref.botId,
48848
+ botId = _ref$botId === void 0 ? null : _ref$botId,
48849
+ _ref$existing = _ref.existing,
48850
+ existing = _ref$existing === void 0 ? [] : _ref$existing;
48851
+ var teamKey = team === null || team === undefined || team === "" ? null : String(team);
48852
+ var taken = new Set(existing || []);
48853
+ var out = [];
48854
+
48855
+ // Widgets.
48856
+ var wsList = (Array.isArray(workspaces) ? workspaces : []).filter(function (ws) {
48857
+ return ws && (teamKey === null || String(ws.id) === teamKey);
48858
+ });
48859
+ var _iterator0 = _createForOfIteratorHelper$q(buildWidgetEventCatalog(wsList, getWidgetConfig)),
48860
+ _step0;
48861
+ try {
48862
+ for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
48863
+ var ws = _step0.value;
48864
+ var group = "Widgets on ".concat(ws.name);
48865
+ var seen = {};
48866
+ var _iterator10 = _createForOfIteratorHelper$q(ws.widgets),
48867
+ _step10;
48868
+ try {
48869
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
48870
+ var widget = _step10.value;
48871
+ seen[widget.label] = (seen[widget.label] || 0) + 1;
48872
+ var name = seen[widget.label] > 1 ? "".concat(widget.label, " (").concat(seen[widget.label], ")") : widget.label;
48873
+ var _iterator11 = _createForOfIteratorHelper$q(widget.events),
48874
+ _step11;
48875
+ try {
48876
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
48877
+ var event = _step11.value;
48878
+ var subscription = widgetSubscription(ws, widget, event);
48879
+ if (taken.has(subscription.eventType)) continue;
48880
+ out.push({
48881
+ value: subscription.eventType,
48882
+ label: "".concat(name, " \u203A ").concat(event),
48883
+ group: group,
48884
+ subscription: subscription
48885
+ });
48886
+ }
48887
+ } catch (err) {
48888
+ _iterator11.e(err);
48889
+ } finally {
48890
+ _iterator11.f();
48891
+ }
48892
+ }
48893
+ } catch (err) {
48894
+ _iterator10.e(err);
48895
+ } finally {
48896
+ _iterator10.f();
48897
+ }
48898
+ }
48899
+
48900
+ // Bots.
48901
+ } catch (err) {
48902
+ _iterator0.e(err);
48903
+ } finally {
48904
+ _iterator0.f();
48905
+ }
48906
+ var nameOfWs = new Map((Array.isArray(workspaces) ? workspaces : []).filter(Boolean).map(function (ws) {
48907
+ return [String(ws.id), ws.name || "Dashboard ".concat(ws.id)];
48908
+ }));
48909
+ var candidates = (Array.isArray(bots) ? bots : []).filter(function (b) {
48910
+ return b && (teamKey === null || b.workspaceId !== null && b.workspaceId !== undefined && String(b.workspaceId) === teamKey);
48911
+ });
48912
+ var wsOf = new Map(candidates.map(function (b) {
48913
+ return [b.id, b.workspaceId];
48914
+ }));
48915
+ var _iterator1 = _createForOfIteratorHelper$q(buildBotEventCatalog(candidates, toolSources, botId)),
48916
+ _step1;
48917
+ try {
48918
+ for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
48919
+ var entry = _step1.value;
48920
+ var where = teamKey === null && wsOf.get(entry.botId) !== null && wsOf.get(entry.botId) !== undefined ? " (".concat(nameOfWs.get(String(wsOf.get(entry.botId))) || "another dashboard", ")") : "";
48921
+ var _iterator12 = _createForOfIteratorHelper$q(entry.events),
48922
+ _step12;
48923
+ try {
48924
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
48925
+ var ev = _step12.value;
48926
+ var _subscription = botSubscription(entry, ev);
48927
+ if (taken.has(_subscription.eventType)) continue;
48928
+ out.push({
48929
+ value: _subscription.eventType,
48930
+ label: "".concat(entry.name).concat(where, " \u203A ").concat(botEventLabel(ev)),
48931
+ group: teamKey === null ? "Bots" : "Bots on this team",
48932
+ subscription: _subscription
48933
+ });
48934
+ }
48935
+ } catch (err) {
48936
+ _iterator12.e(err);
48937
+ } finally {
48938
+ _iterator12.f();
48939
+ }
48940
+ }
48941
+ } catch (err) {
48942
+ _iterator1.e(err);
48943
+ } finally {
48944
+ _iterator1.f();
48945
+ }
48946
+ return out;
48947
+ }
48948
+
48949
+ /**
48950
+ * A dashboard's bots as Dashboard Config › Listeners sources (bot-teams
48951
+ * TEAM-012), shaped like getEmitters() entries: component `bot:<ref>`,
48952
+ * itemId = bot id, so a wired handler stores `bot:<ref>[<botId>].<event>` —
48953
+ * exactly what bots publish on the bus.
48954
+ *
48955
+ * @param {object[]} bots
48956
+ * @param {object[]} toolSources bots.listToolSources()
48957
+ * @param {string|number} workspaceId
48958
+ */
48959
+ function getBotEmitters(bots, toolSources, workspaceId) {
48960
+ if (workspaceId === null || workspaceId === undefined || workspaceId === "") {
48961
+ return [];
48962
+ }
48963
+ var team = (Array.isArray(bots) ? bots : []).filter(function (b) {
48964
+ return b && b.workspaceId !== null && b.workspaceId !== undefined && String(b.workspaceId) === String(workspaceId);
48965
+ });
48966
+ return buildBotEventCatalog(team, toolSources).map(function (entry) {
48967
+ return {
48968
+ key: "bot:".concat(entry.ref, "|").concat(entry.botId),
48969
+ component: "bot:".concat(entry.ref),
48970
+ itemId: entry.botId,
48971
+ label: "".concat(entry.name, " (bot)"),
48972
+ events: entry.events.map(function (e) {
48973
+ return e.event;
48974
+ })
48975
+ };
48976
+ });
48977
+ }
48978
+
48979
+ function _createForOfIteratorHelper$p(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$p(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
48980
+ function _unsupportedIterableToArray$p(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$p(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$p(r, a) : void 0; } }
48981
+ function _arrayLikeToArray$p(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
48514
48982
  var PermissionsTab = function PermissionsTab(_ref) {
48515
48983
  var workspace = _ref.workspace;
48516
48984
  var _React$useContext = React.useContext(AppContext),
@@ -48737,7 +49205,7 @@ var PermissionsTab = function PermissionsTab(_ref) {
48737
49205
  return _context4.abrupt("return");
48738
49206
  case 3:
48739
49207
  next = currentGrant;
48740
- _iterator = _createForOfIteratorHelper$q(declaredTools);
49208
+ _iterator = _createForOfIteratorHelper$p(declaredTools);
48741
49209
  try {
48742
49210
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
48743
49211
  tool = _step.value;
@@ -48897,7 +49365,7 @@ var PermissionsTab = function PermissionsTab(_ref) {
48897
49365
  }
48898
49366
  }
48899
49367
  targets = labels.length > 0 ? labels : [serverName];
48900
- _iterator2 = _createForOfIteratorHelper$q(targets);
49368
+ _iterator2 = _createForOfIteratorHelper$p(targets);
48901
49369
  _context8.prev = 1;
48902
49370
  _iterator2.s();
48903
49371
  case 2:
@@ -48953,7 +49421,7 @@ var PermissionsTab = function PermissionsTab(_ref) {
48953
49421
  case 0:
48954
49422
  setBusy(true);
48955
49423
  _context9.prev = 1;
48956
- _iterator3 = _createForOfIteratorHelper$q(filteredRows);
49424
+ _iterator3 = _createForOfIteratorHelper$p(filteredRows);
48957
49425
  _context9.prev = 2;
48958
49426
  _iterator3.s();
48959
49427
  case 3:
@@ -49012,7 +49480,7 @@ var PermissionsTab = function PermissionsTab(_ref) {
49012
49480
  case 0:
49013
49481
  setBusy(true);
49014
49482
  _context0.prev = 1;
49015
- _iterator4 = _createForOfIteratorHelper$q(filteredRows);
49483
+ _iterator4 = _createForOfIteratorHelper$p(filteredRows);
49016
49484
  _context0.prev = 2;
49017
49485
  _iterator4.s();
49018
49486
  case 3:
@@ -49172,9 +49640,9 @@ var PermissionsTab = function PermissionsTab(_ref) {
49172
49640
  });
49173
49641
  };
49174
49642
 
49175
- function _createForOfIteratorHelper$p(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$p(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
49176
- function _unsupportedIterableToArray$p(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$p(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$p(r, a) : void 0; } }
49177
- function _arrayLikeToArray$p(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
49643
+ function _createForOfIteratorHelper$o(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$o(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
49644
+ function _unsupportedIterableToArray$o(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$o(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$o(r, a) : void 0; } }
49645
+ function _arrayLikeToArray$o(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
49178
49646
  /**
49179
49647
  * teamUtils.js
49180
49648
  *
@@ -49207,7 +49675,7 @@ function dashboardOptions(workspaces) {
49207
49675
  return w && norm(w.id) !== null;
49208
49676
  });
49209
49677
  var totals = {};
49210
- var _iterator = _createForOfIteratorHelper$p(list),
49678
+ var _iterator = _createForOfIteratorHelper$o(list),
49211
49679
  _step;
49212
49680
  try {
49213
49681
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -49254,7 +49722,7 @@ function groupBotsByTeam(bots, workspaces) {
49254
49722
  label: "Unassigned",
49255
49723
  bots: []
49256
49724
  };
49257
- var _iterator2 = _createForOfIteratorHelper$p(list),
49725
+ var _iterator2 = _createForOfIteratorHelper$o(list),
49258
49726
  _step2;
49259
49727
  try {
49260
49728
  var _loop = function _loop() {
@@ -49995,9 +50463,9 @@ var BotsTab = function BotsTab(_ref2) {
49995
50463
  });
49996
50464
  };
49997
50465
 
49998
- function _createForOfIteratorHelper$o(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$o(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
49999
- function _unsupportedIterableToArray$o(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$o(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$o(r, a) : void 0; } }
50000
- function _arrayLikeToArray$o(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
50466
+ function _createForOfIteratorHelper$n(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$n(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
50467
+ function _unsupportedIterableToArray$n(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$n(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$n(r, a) : void 0; } }
50468
+ function _arrayLikeToArray$n(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
50001
50469
  function ownKeys$A(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
50002
50470
  function _objectSpread$A(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$A(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$A(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
50003
50471
  var ConfigTab = function ConfigTab(_ref) {
@@ -50156,7 +50624,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50156
50624
  };
50157
50625
  if (!appProviders) return byType;
50158
50626
  if (Array.isArray(appProviders)) {
50159
- var _iterator = _createForOfIteratorHelper$o(appProviders),
50627
+ var _iterator = _createForOfIteratorHelper$n(appProviders),
50160
50628
  _step;
50161
50629
  try {
50162
50630
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -50222,7 +50690,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50222
50690
  });
50223
50691
  }
50224
50692
  if (Array.isArray(workspace === null || workspace === void 0 ? void 0 : workspace.pages)) {
50225
- var _iterator2 = _createForOfIteratorHelper$o(workspace.pages),
50693
+ var _iterator2 = _createForOfIteratorHelper$n(workspace.pages),
50226
50694
  _step2;
50227
50695
  try {
50228
50696
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -50249,7 +50717,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50249
50717
  var visitedByLocation = new WeakSet();
50250
50718
  var _collect = function collect(items, location) {
50251
50719
  if (!Array.isArray(items)) return;
50252
- var _iterator3 = _createForOfIteratorHelper$o(items),
50720
+ var _iterator3 = _createForOfIteratorHelper$n(items),
50253
50721
  _step3;
50254
50722
  try {
50255
50723
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
@@ -50320,9 +50788,33 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50320
50788
  return null;
50321
50789
  };
50322
50790
  }, [getWidgetConfig]);
50791
+ // This dashboard's bots as Listeners sources (TEAM-012); null until
50792
+ // loaded so their wiring isn't judged before the bots are known.
50793
+ var _useState9 = React.useState(null),
50794
+ _useState0 = _slicedToArray(_useState9, 2),
50795
+ botEmitters = _useState0[0],
50796
+ setBotEmitters = _useState0[1];
50797
+ var workspaceId = workspace ? workspace.id : null;
50798
+ React.useEffect(function () {
50799
+ var _window$mainApi;
50800
+ var bots = typeof window !== "undefined" && ((_window$mainApi = window.mainApi) === null || _window$mainApi === void 0 ? void 0 : _window$mainApi.bots);
50801
+ if (!isOpen || !bots || !bots.list || workspaceId == null) return undefined;
50802
+ var alive = true;
50803
+ Promise.all([bots.list(), bots.listToolSources ? bots.listToolSources() : Promise.resolve([])]).then(function (_ref5) {
50804
+ var _ref6 = _slicedToArray(_ref5, 2),
50805
+ list = _ref6[0],
50806
+ sources = _ref6[1];
50807
+ if (alive) setBotEmitters(getBotEmitters(list, sources, workspaceId));
50808
+ })["catch"](function () {
50809
+ if (alive) setBotEmitters([]);
50810
+ });
50811
+ return function () {
50812
+ alive = false;
50813
+ };
50814
+ }, [isOpen, workspaceId]);
50323
50815
  var emitters = React.useMemo(function () {
50324
- return getEmitters(workspace, wConfig);
50325
- }, [workspace, wConfig]);
50816
+ return [].concat(_toConsumableArray(getEmitters(workspace, wConfig)), _toConsumableArray(botEmitters || []));
50817
+ }, [workspace, wConfig, botEmitters]);
50326
50818
  var receivers = React.useMemo(function () {
50327
50819
  return getReceivers(workspace, wConfig);
50328
50820
  }, [workspace, wConfig]);
@@ -50330,8 +50822,8 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50330
50822
  return getCurrentWiring(workspace);
50331
50823
  }, [workspace]);
50332
50824
  var orphans = React.useMemo(function () {
50333
- return getOrphanedListeners(workspace, wConfig);
50334
- }, [workspace, wConfig]);
50825
+ return getOrphanedListeners(workspace, wConfig, botEmitters);
50826
+ }, [workspace, wConfig, botEmitters]);
50335
50827
  var effectiveWiring = React.useMemo(function () {
50336
50828
  // Apply staged removes/adds to the persisted wiring for an
50337
50829
  // accurate "what will be there after save" view, then annotate
@@ -50347,7 +50839,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50347
50839
  }
50348
50840
  if (stagedListeners.adds.length > 0) {
50349
50841
  // Append; avoid duplicates against current state.
50350
- var _iterator4 = _createForOfIteratorHelper$o(stagedListeners.adds),
50842
+ var _iterator4 = _createForOfIteratorHelper$n(stagedListeners.adds),
50351
50843
  _step4;
50352
50844
  try {
50353
50845
  var _loop = function _loop() {
@@ -50371,7 +50863,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50371
50863
  }
50372
50864
  if (orphans.length === 0) return next;
50373
50865
  var orphanIndex = new Map();
50374
- var _iterator5 = _createForOfIteratorHelper$o(orphans),
50866
+ var _iterator5 = _createForOfIteratorHelper$n(orphans),
50375
50867
  _step5;
50376
50868
  try {
50377
50869
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
@@ -50413,7 +50905,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50413
50905
  function stagePrefFieldForAll(targetWidgets, key, value) {
50414
50906
  setStagedPrefs(function (prev) {
50415
50907
  var next = _objectSpread$A({}, prev);
50416
- var _iterator6 = _createForOfIteratorHelper$o(targetWidgets),
50908
+ var _iterator6 = _createForOfIteratorHelper$n(targetWidgets),
50417
50909
  _step6;
50418
50910
  try {
50419
50911
  for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
@@ -50458,7 +50950,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50458
50950
  });
50459
50951
  setStaged(function (prev) {
50460
50952
  var next = _objectSpread$A({}, prev);
50461
- var _iterator7 = _createForOfIteratorHelper$o(affected),
50953
+ var _iterator7 = _createForOfIteratorHelper$n(affected),
50462
50954
  _step7;
50463
50955
  try {
50464
50956
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
@@ -50759,29 +51251,29 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50759
51251
  * write fails the user can re-toggle. No staging — the bulk modal
50760
51252
  * doesn't gate the user behind a Save button for boolean prefs.
50761
51253
  */
50762
- function NotificationsTab(_ref5) {
50763
- var workspace = _ref5.workspace;
51254
+ function NotificationsTab(_ref7) {
51255
+ var workspace = _ref7.workspace;
50764
51256
  var _useConfigTokens3 = useConfigTokens(),
50765
51257
  muted = _useConfigTokens3.muted,
50766
51258
  hairline = _useConfigTokens3.hairline;
50767
- var _useState9 = React.useState(""),
50768
- _useState0 = _slicedToArray(_useState9, 2),
50769
- searchQuery = _useState0[0],
50770
- setSearchQuery = _useState0[1];
51259
+ var _useState1 = React.useState(""),
51260
+ _useState10 = _slicedToArray(_useState1, 2),
51261
+ searchQuery = _useState10[0],
51262
+ setSearchQuery = _useState10[1];
50771
51263
  // Local mirror of widgetUuid -> { typeKey: bool }. Seeded from the
50772
51264
  // main process on mount; updated optimistically on toggle.
50773
- var _useState1 = React.useState({}),
50774
- _useState10 = _slicedToArray(_useState1, 2),
50775
- prefs = _useState10[0],
50776
- setPrefs = _useState10[1];
50777
- var _useState11 = React.useState(false),
51265
+ var _useState11 = React.useState({}),
50778
51266
  _useState12 = _slicedToArray(_useState11, 2),
50779
- loaded = _useState12[0],
50780
- setLoaded = _useState12[1];
51267
+ prefs = _useState12[0],
51268
+ setPrefs = _useState12[1];
51269
+ var _useState13 = React.useState(false),
51270
+ _useState14 = _slicedToArray(_useState13, 2),
51271
+ loaded = _useState14[0],
51272
+ setLoaded = _useState14[1];
50781
51273
  React.useEffect(function () {
50782
- var _window$mainApi;
51274
+ var _window$mainApi2;
50783
51275
  var cancelled = false;
50784
- if (!((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && (_window$mainApi = _window$mainApi.notifications) !== null && _window$mainApi !== void 0 && _window$mainApi.getPreferences)) {
51276
+ if (!((_window$mainApi2 = window.mainApi) !== null && _window$mainApi2 !== void 0 && (_window$mainApi2 = _window$mainApi2.notifications) !== null && _window$mainApi2 !== void 0 && _window$mainApi2.getPreferences)) {
50785
51277
  setLoaded(true);
50786
51278
  return function () {
50787
51279
  cancelled = true;
@@ -50875,11 +51367,11 @@ function NotificationsTab(_ref5) {
50875
51367
  return !!defaultEnabled;
50876
51368
  };
50877
51369
  var setOne = function setOne(uuid, typeKey, value) {
50878
- var _window$mainApi2;
51370
+ var _window$mainApi3;
50879
51371
  setPrefs(function (prev) {
50880
51372
  return _objectSpread$A(_objectSpread$A({}, prev), {}, _defineProperty({}, uuid, _objectSpread$A(_objectSpread$A({}, prev[uuid] || {}), {}, _defineProperty({}, typeKey, value))));
50881
51373
  });
50882
- (_window$mainApi2 = window.mainApi) === null || _window$mainApi2 === void 0 || (_window$mainApi2 = _window$mainApi2.notifications) === null || _window$mainApi2 === void 0 || _window$mainApi2.setPreferences(uuid, _defineProperty({}, typeKey, value));
51374
+ (_window$mainApi3 = window.mainApi) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.notifications) === null || _window$mainApi3 === void 0 || _window$mainApi3.setPreferences(uuid, _defineProperty({}, typeKey, value));
50883
51375
  };
50884
51376
  var setAllVisible = function setAllVisible(value) {
50885
51377
  // Update local state in one pass + fire one IPC per widget.
@@ -50895,12 +51387,12 @@ function NotificationsTab(_ref5) {
50895
51387
  return next;
50896
51388
  });
50897
51389
  filtered.forEach(function (wi) {
50898
- var _window$mainApi3;
51390
+ var _window$mainApi4;
50899
51391
  var update = {};
50900
51392
  wi.notifications.forEach(function (n) {
50901
51393
  update[n.key] = value;
50902
51394
  });
50903
- (_window$mainApi3 = window.mainApi) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.notifications) === null || _window$mainApi3 === void 0 || _window$mainApi3.setPreferences(wi.uuid, update);
51395
+ (_window$mainApi4 = window.mainApi) === null || _window$mainApi4 === void 0 || (_window$mainApi4 = _window$mainApi4.notifications) === null || _window$mainApi4 === void 0 || _window$mainApi4.setPreferences(wi.uuid, update);
50904
51396
  });
50905
51397
  };
50906
51398
  if (!loaded) {
@@ -51004,12 +51496,12 @@ function NotificationsTab(_ref5) {
51004
51496
  * dot per-type when any widget of that type is unresolved). Column 2
51005
51497
  * shows the selected type's bulk dropdown + per-widget dropdowns.
51006
51498
  */
51007
- function ProvidersTab(_ref6) {
51499
+ function ProvidersTab(_ref8) {
51008
51500
  var _typeEntries$, _selectedRows$;
51009
- var grouped = _ref6.grouped,
51010
- providersByType = _ref6.providersByType,
51011
- onBulk = _ref6.onBulk,
51012
- onPerWidget = _ref6.onPerWidget;
51501
+ var grouped = _ref8.grouped,
51502
+ providersByType = _ref8.providersByType,
51503
+ onBulk = _ref8.onBulk,
51504
+ onPerWidget = _ref8.onPerWidget;
51013
51505
  var _useConfigTokens4 = useConfigTokens(),
51014
51506
  muted = _useConfigTokens4.muted,
51015
51507
  hairline = _useConfigTokens4.hairline,
@@ -51017,10 +51509,10 @@ function ProvidersTab(_ref6) {
51017
51509
  var typeEntries = React.useMemo(function () {
51018
51510
  return Array.from(grouped.entries());
51019
51511
  }, [grouped]);
51020
- var _useState13 = React.useState(((_typeEntries$ = typeEntries[0]) === null || _typeEntries$ === void 0 ? void 0 : _typeEntries$[0]) || null),
51021
- _useState14 = _slicedToArray(_useState13, 2),
51022
- selectedType = _useState14[0],
51023
- setSelectedType = _useState14[1];
51512
+ var _useState15 = React.useState(((_typeEntries$ = typeEntries[0]) === null || _typeEntries$ === void 0 ? void 0 : _typeEntries$[0]) || null),
51513
+ _useState16 = _slicedToArray(_useState15, 2),
51514
+ selectedType = _useState16[0],
51515
+ setSelectedType = _useState16[1];
51024
51516
 
51025
51517
  // If the selected type disappears (workspace changed), fall back.
51026
51518
  React.useMemo(function () {
@@ -51050,10 +51542,10 @@ function ProvidersTab(_ref6) {
51050
51542
  children: "Provider Types"
51051
51543
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
51052
51544
  className: "overflow-y-auto flex-1 flex flex-col gap-1",
51053
- children: typeEntries.map(function (_ref7) {
51054
- var _ref8 = _slicedToArray(_ref7, 2),
51055
- providerType = _ref8[0],
51056
- rows = _ref8[1];
51545
+ children: typeEntries.map(function (_ref9) {
51546
+ var _ref0 = _slicedToArray(_ref9, 2),
51547
+ providerType = _ref0[0],
51548
+ rows = _ref0[1];
51057
51549
  var unresolvedHere = rows.filter(function (r) {
51058
51550
  return r.required && !r.resolvedProviderName;
51059
51551
  }).length;
@@ -51196,8 +51688,8 @@ function ProvidersTab(_ref6) {
51196
51688
  * package (no `config.id` / `config.package` / item.workspace hint).
51197
51689
  * Usually this is a stale layout item whose widget got uninstalled.
51198
51690
  */
51199
- function DependenciesTab(_ref0) {
51200
- var dependencies = _ref0.dependencies;
51691
+ function DependenciesTab(_ref10) {
51692
+ var dependencies = _ref10.dependencies;
51201
51693
  var _useConfigTokens5 = useConfigTokens(),
51202
51694
  muted = _useConfigTokens5.muted,
51203
51695
  hairline = _useConfigTokens5.hairline;
@@ -51274,24 +51766,24 @@ function sameWiringEntry(a, b) {
51274
51766
  * adjusts wiring per handler from a single dropdown of all emitters'
51275
51767
  * (widget × event) pairs.
51276
51768
  */
51277
- function ListenersTab(_ref1) {
51769
+ function ListenersTab(_ref11) {
51278
51770
  var _receivers$;
51279
- var emitters = _ref1.emitters,
51280
- receivers = _ref1.receivers,
51281
- wiring = _ref1.wiring,
51282
- onAdd = _ref1.onAdd,
51283
- onRemove = _ref1.onRemove;
51771
+ var emitters = _ref11.emitters,
51772
+ receivers = _ref11.receivers,
51773
+ wiring = _ref11.wiring,
51774
+ onAdd = _ref11.onAdd,
51775
+ onRemove = _ref11.onRemove;
51284
51776
  var _useConfigTokens6 = useConfigTokens(),
51285
51777
  muted = _useConfigTokens6.muted,
51286
51778
  hairline = _useConfigTokens6.hairline;
51287
- var _useState17 = React.useState(((_receivers$ = receivers[0]) === null || _receivers$ === void 0 ? void 0 : _receivers$.key) || null),
51288
- _useState18 = _slicedToArray(_useState17, 2),
51289
- selectedReceiverKey = _useState18[0],
51290
- setSelectedReceiverKey = _useState18[1];
51291
- var _useState19 = React.useState(null),
51779
+ var _useState19 = React.useState(((_receivers$ = receivers[0]) === null || _receivers$ === void 0 ? void 0 : _receivers$.key) || null),
51292
51780
  _useState20 = _slicedToArray(_useState19, 2),
51293
- selectedHandler = _useState20[0],
51294
- setSelectedHandler = _useState20[1];
51781
+ selectedReceiverKey = _useState20[0],
51782
+ setSelectedReceiverKey = _useState20[1];
51783
+ var _useState21 = React.useState(null),
51784
+ _useState22 = _slicedToArray(_useState21, 2),
51785
+ selectedHandler = _useState22[0],
51786
+ setSelectedHandler = _useState22[1];
51295
51787
 
51296
51788
  // Re-anchor selection if the previously-selected widget disappeared
51297
51789
  // (workspace switched, widget deleted, etc.).
@@ -51307,7 +51799,7 @@ function ListenersTab(_ref1) {
51307
51799
  // Receiver lookup (by composite key) for label resolution in chips.
51308
51800
  var receiverByKey = React.useMemo(function () {
51309
51801
  var m = new Map();
51310
- var _iterator8 = _createForOfIteratorHelper$o(receivers),
51802
+ var _iterator8 = _createForOfIteratorHelper$n(receivers),
51311
51803
  _step8;
51312
51804
  try {
51313
51805
  for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
@@ -51390,14 +51882,14 @@ function ListenersTab(_ref1) {
51390
51882
  * third column. Matches the left-column look from
51391
51883
  * PanelEditItemHandlers.
51392
51884
  */
51393
- function HandlersColumn(_ref11) {
51394
- var receiver = _ref11.receiver,
51395
- myWiring = _ref11.myWiring,
51396
- selectedHandler = _ref11.selectedHandler,
51397
- onSelectHandler = _ref11.onSelectHandler;
51885
+ function HandlersColumn(_ref13) {
51886
+ var receiver = _ref13.receiver,
51887
+ myWiring = _ref13.myWiring,
51888
+ selectedHandler = _ref13.selectedHandler,
51889
+ onSelectHandler = _ref13.onSelectHandler;
51398
51890
  var countsByHandler = React.useMemo(function () {
51399
51891
  var m = new Map();
51400
- var _iterator9 = _createForOfIteratorHelper$o(myWiring),
51892
+ var _iterator9 = _createForOfIteratorHelper$n(myWiring),
51401
51893
  _step9;
51402
51894
  try {
51403
51895
  for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
@@ -51459,13 +51951,13 @@ function HandlersColumn(_ref11) {
51459
51951
  * Checked = wired; toggling commits an add/remove. Mirrors the
51460
51952
  * right-column UX of PanelEditItemHandlers.
51461
51953
  */
51462
- function EventsColumn(_ref12) {
51463
- var receiver = _ref12.receiver,
51464
- handlerName = _ref12.handlerName,
51465
- myWiring = _ref12.myWiring,
51466
- emitters = _ref12.emitters,
51467
- onAdd = _ref12.onAdd,
51468
- onRemove = _ref12.onRemove;
51954
+ function EventsColumn(_ref14) {
51955
+ var receiver = _ref14.receiver,
51956
+ handlerName = _ref14.handlerName,
51957
+ myWiring = _ref14.myWiring,
51958
+ emitters = _ref14.emitters,
51959
+ onAdd = _ref14.onAdd,
51960
+ onRemove = _ref14.onRemove;
51469
51961
  var _useConfigTokens8 = useConfigTokens(),
51470
51962
  muted = _useConfigTokens8.muted,
51471
51963
  hairline = _useConfigTokens8.hairline;
@@ -51474,7 +51966,7 @@ function EventsColumn(_ref12) {
51474
51966
  var wiredHere = React.useMemo(function () {
51475
51967
  var seen = new Set();
51476
51968
  var out = [];
51477
- var _iterator0 = _createForOfIteratorHelper$o(myWiring),
51969
+ var _iterator0 = _createForOfIteratorHelper$n(myWiring),
51478
51970
  _step0;
51479
51971
  try {
51480
51972
  for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
@@ -51551,7 +52043,7 @@ function EventsColumn(_ref12) {
51551
52043
  className: "flex-1 overflow-y-auto p-4 flex flex-col gap-3",
51552
52044
  children: emittersForList.length === 0 ? /*#__PURE__*/jsxRuntime.jsx("div", {
51553
52045
  className: "text-sm ".concat(muted),
51554
- children: "No other widgets in this dashboard emit events."
52046
+ children: "Nothing else on this dashboard emits events \u2014 no widgets or bots."
51555
52047
  }) : emittersForList.map(function (e) {
51556
52048
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
51557
52049
  className: "rounded-lg border px-3 py-2 flex flex-col gap-1 ".concat(hairline),
@@ -52529,296 +53021,8 @@ function parseCron(cron) {
52529
53021
  };
52530
53022
  }
52531
53023
 
52532
- function _createForOfIteratorHelper$n(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$n(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
52533
- function _unsupportedIterableToArray$n(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$n(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$n(r, a) : void 0; } }
52534
- function _arrayLikeToArray$n(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
52535
-
52536
- /**
52537
- * @param {Array<object>} workspaces dashboards (each with id, name, layout/pages)
52538
- * @param {(component: string) => object|null} getWidgetConfig
52539
- * @returns {Array<{ workspaceId: string, name: string,
52540
- * widgets: Array<{ ref: string, instanceId: string, label: string, events: string[] }> }>}
52541
- * dashboards with at least one event-emitting widget
52542
- */
52543
- function buildWidgetEventCatalog(workspaces, getWidgetConfig) {
52544
- if (!Array.isArray(workspaces)) return [];
52545
- var out = [];
52546
- var _iterator = _createForOfIteratorHelper$n(workspaces),
52547
- _step;
52548
- try {
52549
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
52550
- var ws = _step.value;
52551
- if (!ws || ws.id === undefined || ws.id === null) continue;
52552
- var widgets = getEmitters(ws, getWidgetConfig).filter(function (e) {
52553
- return e.itemId != null && e.events.length;
52554
- }).map(function (e) {
52555
- return {
52556
- ref: e.component,
52557
- instanceId: String(e.itemId),
52558
- label: e.label || e.component,
52559
- events: e.events
52560
- };
52561
- });
52562
- if (!widgets.length) continue;
52563
- out.push({
52564
- workspaceId: String(ws.id),
52565
- name: ws.name || "Dashboard ".concat(ws.id),
52566
- widgets: widgets
52567
- });
52568
- }
52569
- // Dashboards can share a name (e.g. copies of "Kitchen Sink"); number the
52570
- // duplicates so each picker entry is distinguishable.
52571
- } catch (err) {
52572
- _iterator.e(err);
52573
- } finally {
52574
- _iterator.f();
52575
- }
52576
- var totals = {};
52577
- for (var _i = 0, _out = out; _i < _out.length; _i++) {
52578
- var w = _out[_i];
52579
- totals[w.name] = (totals[w.name] || 0) + 1;
52580
- }
52581
- var seen = {};
52582
- for (var _i2 = 0, _out2 = out; _i2 < _out2.length; _i2++) {
52583
- var _w = _out2[_i2];
52584
- if (totals[_w.name] > 1) {
52585
- seen[_w.name] = (seen[_w.name] || 0) + 1;
52586
- _w.name = "".concat(_w.name, " (").concat(seen[_w.name], ")");
52587
- }
52588
- }
52589
- return out;
52590
- }
52591
-
52592
- /** A subscription to one widget event, picked from the catalog. */
52593
- function widgetSubscription(workspace, widget, event) {
52594
- return {
52595
- eventType: formatEventString(widget.ref, widget.instanceId, event),
52596
- source: {
52597
- kind: "widget",
52598
- ref: widget.ref,
52599
- instanceId: widget.instanceId,
52600
- event: event,
52601
- workspaceId: workspace.workspaceId
52602
- },
52603
- label: "".concat(workspace.name, " \u203A ").concat(widget.label, " \u203A ").concat(event)
52604
- };
52605
- }
52606
-
52607
- /**
52608
- * How to show a saved subscription: its label from the live catalog, and
52609
- * whether its widget/event is gone (`missing`). Subscriptions saved before
52610
- * the picker (bare eventType) get a friendly label when they still resolve;
52611
- * otherwise they show as typed.
52612
- */
52613
- function describeSubscription(sub, catalog) {
52614
- var botCatalog = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
52615
- var eventType = sub && sub.eventType;
52616
- // Bot subscriptions resolve against the bot catalog; `kind` lets the form
52617
- // say "bot missing" instead of "widget missing".
52618
- if (sub && sub.source && sub.source.kind === "bot") {
52619
- var _iterator2 = _createForOfIteratorHelper$n(botCatalog || []),
52620
- _step2;
52621
- try {
52622
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
52623
- var b = _step2.value;
52624
- var _iterator3 = _createForOfIteratorHelper$n(b.events),
52625
- _step3;
52626
- try {
52627
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
52628
- var ev = _step3.value;
52629
- var s = botSubscription(b, ev);
52630
- if (s.eventType === eventType) {
52631
- return {
52632
- label: s.label,
52633
- missing: false,
52634
- kind: "bot"
52635
- };
52636
- }
52637
- }
52638
- } catch (err) {
52639
- _iterator3.e(err);
52640
- } finally {
52641
- _iterator3.f();
52642
- }
52643
- }
52644
- } catch (err) {
52645
- _iterator2.e(err);
52646
- } finally {
52647
- _iterator2.f();
52648
- }
52649
- return {
52650
- label: sub.label || eventType,
52651
- missing: true,
52652
- kind: "bot"
52653
- };
52654
- }
52655
- var _iterator4 = _createForOfIteratorHelper$n(catalog || []),
52656
- _step4;
52657
- try {
52658
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
52659
- var ws = _step4.value;
52660
- var _iterator5 = _createForOfIteratorHelper$n(ws.widgets),
52661
- _step5;
52662
- try {
52663
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
52664
- var w = _step5.value;
52665
- var _iterator6 = _createForOfIteratorHelper$n(w.events),
52666
- _step6;
52667
- try {
52668
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
52669
- var _ev = _step6.value;
52670
- if (formatEventString(w.ref, w.instanceId, _ev) === eventType) {
52671
- return {
52672
- label: widgetSubscription(ws, w, _ev).label,
52673
- missing: false
52674
- };
52675
- }
52676
- }
52677
- } catch (err) {
52678
- _iterator6.e(err);
52679
- } finally {
52680
- _iterator6.f();
52681
- }
52682
- }
52683
- } catch (err) {
52684
- _iterator5.e(err);
52685
- } finally {
52686
- _iterator5.f();
52687
- }
52688
- }
52689
- } catch (err) {
52690
- _iterator4.e(err);
52691
- } finally {
52692
- _iterator4.f();
52693
- }
52694
- if (sub && sub.source) {
52695
- return {
52696
- label: sub.label || eventType,
52697
- missing: true
52698
- };
52699
- }
52700
- return {
52701
- label: eventType || "",
52702
- missing: false
52703
- };
52704
- }
52705
-
52706
- /**
52707
- * Events other bots publish (bot:<ref>[<botId>].<event>, PRD US-010), for the
52708
- * "Another bot" side of the picker. Derived from each bot's settings — never
52709
- * hand-declared: Completed, Failed, and one `tool.<providerType>.<tool>` per
52710
- * tool the bot may use (the provider's tools, narrowed by the bot's
52711
- * selection). Providers with no known type or tool list are skipped.
52712
- *
52713
- * @param {Array<object>} bots
52714
- * @param {Array<{name, type, tools}>} toolSources bots.listToolSources()
52715
- * @param {string} [excludeBotId] the bot being edited — can't trigger itself
52716
- */
52717
- function buildBotEventCatalog(bots, toolSources) {
52718
- var excludeBotId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
52719
- if (!Array.isArray(bots)) return [];
52720
- var sources = Array.isArray(toolSources) ? toolSources : [];
52721
- var out = [];
52722
- var _iterator7 = _createForOfIteratorHelper$n(bots),
52723
- _step7;
52724
- try {
52725
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
52726
- var bot = _step7.value;
52727
- if (!bot || !bot.id || !bot.ref || bot.id === excludeBotId) continue;
52728
- var events = [{
52729
- event: "completed",
52730
- label: "Completed"
52731
- }, {
52732
- event: "failed",
52733
- label: "Failed"
52734
- }];
52735
- var _iterator8 = _createForOfIteratorHelper$n(bot.mcpServers || []),
52736
- _step8;
52737
- try {
52738
- var _loop = function _loop() {
52739
- var provider = _step8.value;
52740
- var src = sources.find(function (s) {
52741
- return s && s.name === provider;
52742
- });
52743
- if (!src || !src.type || !Array.isArray(src.tools)) return 1; // continue
52744
- var sel = bot.toolSelections && bot.toolSelections[provider];
52745
- var tools = Array.isArray(sel) ? src.tools.filter(function (t) {
52746
- return sel.includes(t);
52747
- }) : src.tools;
52748
- var _iterator9 = _createForOfIteratorHelper$n(tools),
52749
- _step9;
52750
- try {
52751
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
52752
- var tool = _step9.value;
52753
- events.push({
52754
- event: "tool.".concat(src.type, ".").concat(tool),
52755
- label: "".concat(provider, " \u203A ").concat(tool)
52756
- });
52757
- }
52758
- } catch (err) {
52759
- _iterator9.e(err);
52760
- } finally {
52761
- _iterator9.f();
52762
- }
52763
- };
52764
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
52765
- if (_loop()) continue;
52766
- }
52767
- } catch (err) {
52768
- _iterator8.e(err);
52769
- } finally {
52770
- _iterator8.f();
52771
- }
52772
- out.push({
52773
- botId: bot.id,
52774
- ref: bot.ref,
52775
- name: bot.name || bot.id,
52776
- events: events
52777
- });
52778
- }
52779
- } catch (err) {
52780
- _iterator7.e(err);
52781
- } finally {
52782
- _iterator7.f();
52783
- }
52784
- return out;
52785
- }
52786
-
52787
- /** A subscription to one bot event, picked from the bot catalog. */
52788
- function botSubscription(botEntry, ev) {
52789
- return {
52790
- eventType: "bot:".concat(botEntry.ref, "[").concat(botEntry.botId, "].").concat(ev.event),
52791
- source: {
52792
- kind: "bot",
52793
- ref: botEntry.ref,
52794
- instanceId: botEntry.botId,
52795
- event: ev.event
52796
- },
52797
- label: "".concat(botEntry.name, " \u203A ").concat(ev.label)
52798
- };
52799
- }
52800
-
52801
53024
  function ownKeys$y(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
52802
53025
  function _objectSpread$y(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$y(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$y(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
52803
- var EVENT_FROM_OPTIONS = [{
52804
- value: "widget",
52805
- label: "A dashboard widget"
52806
- }, {
52807
- value: "bot",
52808
- label: "Another bot"
52809
- }];
52810
-
52811
- /**
52812
- * BotDetail — create/edit form for a Bot Factory bot (Settings → Bots).
52813
- *
52814
- * Built for a non-technical user: Providers (the user's Dash MCP providers —
52815
- * what the bot can use), the AI model, and the schedule are all
52816
- * pick-from-a-list, never free text. "Provider" always means a Dash provider;
52817
- * the LLM choice is labelled "Model source". The raw cron lives behind an "Advanced"
52818
- * toggle for power users. All inputs are @trops/dash-react primitives.
52819
- */
52820
-
52821
- // Friendly, Title-case provider labels for the dropdown.
52822
53026
  var PROVIDER_LABELS = {
52823
53027
  anthropic: "Anthropic",
52824
53028
  openai: "OpenAI",
@@ -53128,19 +53332,15 @@ var BotDetail = function BotDetail(_ref) {
53128
53332
  var eventCatalog = React.useMemo(function () {
53129
53333
  return buildWidgetEventCatalog(workspaces, getWidgetConfig);
53130
53334
  }, [workspaces, getWidgetConfig]);
53131
- var _useState41 = React.useState("widget"),
53132
- _useState42 = _slicedToArray(_useState41, 2),
53133
- pickFrom = _useState42[0],
53134
- setPickFrom = _useState42[1];
53135
53335
  // Team = the dashboard this bot belongs to ("" = Unassigned). A bot on a
53136
53336
  // team only hears its own dashboard's events (bot-teams TEAM-001).
53137
- var _useState43 = React.useState(function () {
53337
+ var _useState41 = React.useState(function () {
53138
53338
  var id = bot ? bot.workspaceId : defaultWorkspaceId;
53139
53339
  return id === undefined || id === null || id === "" ? "" : String(id);
53140
53340
  }),
53141
- _useState44 = _slicedToArray(_useState43, 2),
53142
- team = _useState44[0],
53143
- setTeam = _useState44[1];
53341
+ _useState42 = _slicedToArray(_useState41, 2),
53342
+ team = _useState42[0],
53343
+ setTeam = _useState42[1];
53144
53344
  var teamOptions = React.useMemo(function () {
53145
53345
  return [{
53146
53346
  value: "",
@@ -53148,40 +53348,33 @@ var BotDetail = function BotDetail(_ref) {
53148
53348
  }].concat(_toConsumableArray(dashboardOptions(workspaces)));
53149
53349
  }, [workspaces]);
53150
53350
  var offTeam = offTeamSubscriptions(subscriptions, team);
53151
- // The event picker opens on the bot's own dashboard.
53152
- var _useState45 = React.useState(team),
53351
+ // "Runs when…" (TEAM-012): one picker of everything that can trigger the
53352
+ // bot; a just-added trigger reminds the user to Save.
53353
+ var _useState43 = React.useState(""),
53354
+ _useState44 = _slicedToArray(_useState43, 2),
53355
+ pickTrigger = _useState44[0],
53356
+ setPickTrigger = _useState44[1];
53357
+ var _useState45 = React.useState(false),
53153
53358
  _useState46 = _slicedToArray(_useState45, 2),
53154
- pickWorkspace = _useState46[0],
53155
- setPickWorkspace = _useState46[1];
53156
- var _useState47 = React.useState(""),
53157
- _useState48 = _slicedToArray(_useState47, 2),
53158
- pickWidget = _useState48[0],
53159
- setPickWidget = _useState48[1];
53160
- var _useState49 = React.useState(""),
53161
- _useState50 = _slicedToArray(_useState49, 2),
53162
- pickBot = _useState50[0],
53163
- setPickBot = _useState50[1];
53164
- var _useState51 = React.useState(""),
53165
- _useState52 = _slicedToArray(_useState51, 2),
53166
- pickEvent = _useState52[0],
53167
- setPickEvent = _useState52[1];
53359
+ triggerAdded = _useState46[0],
53360
+ setTriggerAdded = _useState46[1];
53168
53361
  var _ref3 = React.useContext(DashReact.ThemeContext) || {},
53169
53362
  _ref3$currentTheme = _ref3.currentTheme,
53170
53363
  currentTheme = _ref3$currentTheme === void 0 ? {} : _ref3$currentTheme;
53171
53364
  var hairline = currentTheme["border-neutral-dark"] || "border-gray-700";
53172
- var _useState53 = React.useState(false),
53173
- _useState54 = _slicedToArray(_useState53, 2),
53174
- saving = _useState54[0],
53175
- setSaving = _useState54[1];
53176
- var _useState55 = React.useState(null),
53177
- _useState56 = _slicedToArray(_useState55, 2),
53178
- error = _useState56[0],
53179
- setError = _useState56[1];
53365
+ var _useState47 = React.useState(false),
53366
+ _useState48 = _slicedToArray(_useState47, 2),
53367
+ saving = _useState48[0],
53368
+ setSaving = _useState48[1];
53369
+ var _useState49 = React.useState(null),
53370
+ _useState50 = _slicedToArray(_useState49, 2),
53371
+ error = _useState50[0],
53372
+ setError = _useState50[1];
53180
53373
  // "Saved" shows after a successful save until the next edit.
53181
- var _useState57 = React.useState(false),
53182
- _useState58 = _slicedToArray(_useState57, 2),
53183
- justSaved = _useState58[0],
53184
- setJustSaved = _useState58[1];
53374
+ var _useState51 = React.useState(false),
53375
+ _useState52 = _slicedToArray(_useState51, 2),
53376
+ justSaved = _useState52[0],
53377
+ setJustSaved = _useState52[1];
53185
53378
 
53186
53379
  // Unsaved changes: the editable fields now vs. when the form opened (or
53187
53380
  // last saved).
@@ -53204,10 +53397,10 @@ var BotDetail = function BotDetail(_ref) {
53204
53397
  subscriptions: subscriptions,
53205
53398
  team: team
53206
53399
  });
53207
- var _useState59 = React.useState(snapshot),
53208
- _useState60 = _slicedToArray(_useState59, 2),
53209
- baseline = _useState60[0],
53210
- setBaseline = _useState60[1];
53400
+ var _useState53 = React.useState(snapshot),
53401
+ _useState54 = _slicedToArray(_useState53, 2),
53402
+ baseline = _useState54[0],
53403
+ setBaseline = _useState54[1];
53211
53404
  var dirty = snapshot !== baseline;
53212
53405
  React.useEffect(function () {
53213
53406
  if (dirty) setJustSaved(false);
@@ -53367,35 +53560,39 @@ var BotDetail = function BotDetail(_ref) {
53367
53560
  });
53368
53561
  };
53369
53562
 
53370
- // Cascading picker options. A widget's option value is "ref|instanceId".
53371
- var pickedWs = eventCatalog.find(function (w) {
53372
- return w.workspaceId === pickWorkspace;
53373
- });
53374
- var pickedWidget = pickedWs ? pickedWs.widgets.find(function (w) {
53375
- return "".concat(w.ref, "|").concat(w.instanceId) === pickWidget;
53376
- }) : null;
53377
-
53378
- // Other bots' events, derived from their providers + tools (this bot
53379
- // excluded — it can't trigger itself).
53563
+ // Other bots' events (this bot excluded — it can't trigger itself), for
53564
+ // labelling the triggers already on the bot.
53380
53565
  var botCatalog = React.useMemo(function () {
53381
53566
  return buildBotEventCatalog(bots, toolSources, (bot === null || bot === void 0 ? void 0 : bot.id) || null);
53382
53567
  }, [bots, toolSources, bot === null || bot === void 0 ? void 0 : bot.id]);
53383
- var pickedBot = botCatalog.find(function (b) {
53384
- return b.botId === pickBot;
53568
+
53569
+ // Everything that can trigger this bot, grouped (TEAM-012).
53570
+ var triggerOptions = React.useMemo(function () {
53571
+ return buildTriggerOptions({
53572
+ team: team || null,
53573
+ workspaces: workspaces,
53574
+ getWidgetConfig: getWidgetConfig,
53575
+ bots: bots,
53576
+ toolSources: toolSources,
53577
+ botId: (bot === null || bot === void 0 ? void 0 : bot.id) || null,
53578
+ existing: subscriptions.map(function (s) {
53579
+ return s.eventType;
53580
+ })
53581
+ });
53582
+ }, [team, workspaces, getWidgetConfig, bots, toolSources, bot === null || bot === void 0 ? void 0 : bot.id, subscriptions]);
53583
+ var pickedTrigger = triggerOptions.find(function (o) {
53584
+ return o.value === pickTrigger;
53385
53585
  }) || null;
53386
- var pickedBotEvent = pickedBot ? pickedBot.events.find(function (e) {
53387
- return e.event === pickEvent;
53388
- }) || null : null;
53389
- var canAddEvent = pickFrom === "bot" ? !!pickedBotEvent : !!(pickedWidget && pickEvent);
53390
53586
  var addSubscription = function addSubscription() {
53391
- if (!canAddEvent) return;
53392
- var sub = pickFrom === "bot" ? botSubscription(pickedBot, pickedBotEvent) : widgetSubscription(pickedWs, pickedWidget, pickEvent);
53587
+ if (!pickedTrigger) return;
53588
+ var sub = pickedTrigger.subscription;
53393
53589
  setSubscriptions(function (prev) {
53394
53590
  return prev.some(function (s) {
53395
53591
  return s.eventType === sub.eventType;
53396
53592
  }) ? prev : [].concat(_toConsumableArray(prev), [sub]);
53397
53593
  });
53398
- setPickEvent("");
53594
+ setPickTrigger("");
53595
+ setTriggerAdded(true);
53399
53596
  };
53400
53597
  var removeSubscription = function removeSubscription(eventType) {
53401
53598
  setSubscriptions(function (prev) {
@@ -53767,101 +53964,32 @@ var BotDetail = function BotDetail(_ref) {
53767
53964
  }) : /*#__PURE__*/jsxRuntime.jsx("span", {
53768
53965
  className: "text-xs opacity-50",
53769
53966
  children: "This bot doesn't run on any events yet."
53770
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.SelectInput, {
53771
- label: "From",
53772
- value: pickFrom,
53773
- onChange: function onChange(v) {
53774
- setPickFrom(v);
53775
- setPickEvent("");
53776
- },
53777
- options: EVENT_FROM_OPTIONS
53778
- }), pickFrom === "bot" ? botCatalog.length ? /*#__PURE__*/jsxRuntime.jsxs("div", {
53967
+ }), triggerOptions.length ? /*#__PURE__*/jsxRuntime.jsxs("div", {
53779
53968
  className: "flex flex-col gap-2",
53780
53969
  children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.SelectInput, {
53781
- label: "Bot",
53782
- value: pickBot,
53783
- onChange: function onChange(v) {
53784
- setPickBot(v);
53785
- setPickEvent("");
53786
- },
53787
- placeholder: "Choose a bot\u2026",
53788
- options: botCatalog.map(function (b) {
53789
- return {
53790
- value: b.botId,
53791
- label: b.name
53792
- };
53793
- })
53794
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.SelectInput, {
53795
- label: "Event",
53796
- value: pickEvent,
53797
- onChange: setPickEvent,
53798
- placeholder: "Choose an event\u2026",
53799
- options: (pickedBot ? pickedBot.events : []).map(function (e) {
53970
+ label: "Runs when\u2026",
53971
+ value: pickTrigger,
53972
+ onChange: setPickTrigger,
53973
+ placeholder: "Choose what triggers this bot\u2026",
53974
+ options: triggerOptions.map(function (o) {
53800
53975
  return {
53801
- value: e.event,
53802
- label: e.label
53976
+ value: o.value,
53977
+ label: o.label,
53978
+ group: o.group
53803
53979
  };
53804
53980
  })
53805
53981
  }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
53806
- title: "Add event",
53982
+ title: "Add trigger",
53807
53983
  onClick: addSubscription,
53808
53984
  size: "sm",
53809
- disabled: !canAddEvent
53810
- })]
53811
- }) : /*#__PURE__*/jsxRuntime.jsx("span", {
53812
- className: "text-xs opacity-50",
53813
- children: "No other bots yet. Create another bot to trigger this one when it finishes or uses a tool."
53814
- }) : eventCatalog.length ? /*#__PURE__*/jsxRuntime.jsxs("div", {
53815
- className: "flex flex-col gap-2",
53816
- children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.SelectInput, {
53817
- label: "Dashboard",
53818
- value: pickWorkspace,
53819
- onChange: function onChange(v) {
53820
- setPickWorkspace(v);
53821
- setPickWidget("");
53822
- setPickEvent("");
53823
- },
53824
- placeholder: "Choose a dashboard\u2026",
53825
- options: eventCatalog.map(function (w) {
53826
- return {
53827
- value: w.workspaceId,
53828
- label: w.name
53829
- };
53830
- })
53831
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.SelectInput, {
53832
- label: "Widget",
53833
- value: pickWidget,
53834
- onChange: function onChange(v) {
53835
- setPickWidget(v);
53836
- setPickEvent("");
53837
- },
53838
- placeholder: "Choose a widget\u2026",
53839
- options: (pickedWs ? pickedWs.widgets : []).map(function (w) {
53840
- return {
53841
- value: "".concat(w.ref, "|").concat(w.instanceId),
53842
- label: w.label
53843
- };
53844
- })
53845
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.SelectInput, {
53846
- label: "Event",
53847
- value: pickEvent,
53848
- onChange: setPickEvent,
53849
- placeholder: "Choose an event\u2026",
53850
- options: (pickedWidget ? pickedWidget.events : []).map(function (ev) {
53851
- return {
53852
- value: ev,
53853
- label: ev
53854
- };
53855
- })
53856
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
53857
- title: "Add event",
53858
- onClick: addSubscription,
53859
- size: "sm",
53860
- disabled: !pickedWidget || !pickEvent
53861
- })]
53985
+ disabled: !pickedTrigger
53986
+ }), triggerAdded && dirty ? /*#__PURE__*/jsxRuntime.jsx("span", {
53987
+ className: "text-xs opacity-70",
53988
+ children: "Save to keep this trigger."
53989
+ }) : null]
53862
53990
  }) : /*#__PURE__*/jsxRuntime.jsx("span", {
53863
53991
  className: "text-xs opacity-50",
53864
- children: "No widgets on your dashboards publish events yet. Add a widget that publishes events to a dashboard to trigger this bot from it."
53992
+ children: team ? "Nothing can trigger this bot yet. Add a widget that publishes events to this dashboard, or another bot to its team." : "Nothing can trigger this bot yet. Add a widget that publishes events to a dashboard, or create another bot."
53865
53993
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
53866
53994
  className: "text-xs opacity-50",
53867
53995
  children: "The bot runs automatically when one of these events fires."
@@ -70520,6 +70648,11 @@ function pruneListeners(listeners, liveCanonicalKeys) {
70520
70648
  continue;
70521
70649
  }
70522
70650
  var kept = value.filter(function (eventStr) {
70651
+ var _parseEventString;
70652
+ // Bots aren't layout widgets, so they never appear in
70653
+ // liveCanonicalKeys. Their wiring is checked against the bot list
70654
+ // in the Listeners tab instead.
70655
+ if (isBotSource((_parseEventString = parseEventString(eventStr)) === null || _parseEventString === void 0 ? void 0 : _parseEventString.component)) return true;
70523
70656
  var key = eventStringToCanonicalKey(eventStr);
70524
70657
  if (!key) return true; // unparseable — leave alone
70525
70658
  return liveCanonicalKeys.has(key);