@trops/dash-core 0.1.638 → 0.1.639

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.esm.js CHANGED
@@ -47485,68 +47485,124 @@ var BotDetail = function BotDetail(_ref) {
47485
47485
  _useState18 = _slicedToArray(_useState17, 2),
47486
47486
  sourcesLoaded = _useState18[0],
47487
47487
  setSourcesLoaded = _useState18[1];
47488
+ // Remembered approvals ("Always allow") for a saved bot:
47489
+ // { [provider]: { tools: string[], folders: string[] } }.
47490
+ var _useState19 = useState({}),
47491
+ _useState20 = _slicedToArray(_useState19, 2),
47492
+ grants = _useState20[0],
47493
+ setGrants = _useState20[1];
47494
+ useEffect(function () {
47495
+ var _api$bots;
47496
+ var alive = true;
47497
+ var api = getMainApi();
47498
+ if (!(bot !== null && bot !== void 0 && bot.id) || !(api !== null && api !== void 0 && (_api$bots = api.bots) !== null && _api$bots !== void 0 && _api$bots.getGrants)) return undefined;
47499
+ Promise.resolve(api.bots.getGrants(bot.id)).then(function (g) {
47500
+ if (alive && g && _typeof(g) === "object") setGrants(g);
47501
+ })["catch"](function () {});
47502
+ return function () {
47503
+ alive = false;
47504
+ };
47505
+ }, [bot === null || bot === void 0 ? void 0 : bot.id]);
47506
+ var isRemembered = function isRemembered(serverName, tool) {
47507
+ return !!(grants[serverName] && (grants[serverName].tools || []).includes(tool));
47508
+ };
47509
+ var revokeRemembered = /*#__PURE__*/function () {
47510
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(serverName, tool) {
47511
+ var _api$bots2;
47512
+ var api, next;
47513
+ return _regeneratorRuntime.wrap(function (_context) {
47514
+ while (1) switch (_context.prev = _context.next) {
47515
+ case 0:
47516
+ api = getMainApi();
47517
+ if (!(!(bot !== null && bot !== void 0 && bot.id) || !(api !== null && api !== void 0 && (_api$bots2 = api.bots) !== null && _api$bots2 !== void 0 && _api$bots2.revokeGrant))) {
47518
+ _context.next = 1;
47519
+ break;
47520
+ }
47521
+ return _context.abrupt("return");
47522
+ case 1:
47523
+ _context.prev = 1;
47524
+ _context.next = 2;
47525
+ return api.bots.revokeGrant(bot.id, serverName, tool);
47526
+ case 2:
47527
+ next = _context.sent;
47528
+ setGrants(next && _typeof(next) === "object" ? next : {});
47529
+ _context.next = 4;
47530
+ break;
47531
+ case 3:
47532
+ _context.prev = 3;
47533
+ _context["catch"](1);
47534
+ case 4:
47535
+ case "end":
47536
+ return _context.stop();
47537
+ }
47538
+ }, _callee, null, [[1, 3]]);
47539
+ }));
47540
+ return function revokeRemembered(_x, _x2) {
47541
+ return _ref2.apply(this, arguments);
47542
+ };
47543
+ }();
47488
47544
 
47489
47545
  // --- Model options (fetched per provider) ---
47490
- var _useState19 = useState([]),
47491
- _useState20 = _slicedToArray(_useState19, 2),
47492
- modelOptions = _useState20[0],
47493
- setModelOptions = _useState20[1];
47546
+ var _useState21 = useState([]),
47547
+ _useState22 = _slicedToArray(_useState21, 2),
47548
+ modelOptions = _useState22[0],
47549
+ setModelOptions = _useState22[1];
47494
47550
 
47495
47551
  // --- Schedule (friendly dropdowns; raw cron behind Advanced) ---
47496
47552
  var initialCron = (bot === null || bot === void 0 || (_bot$schedules = bot.schedules) === null || _bot$schedules === void 0 || (_bot$schedules = _bot$schedules[0]) === null || _bot$schedules === void 0 ? void 0 : _bot$schedules.cron) || "";
47497
47553
  var parsed = parseCron(initialCron);
47498
- var _useState21 = useState(parsed.frequency === "custom" ? "off" : parsed.frequency),
47499
- _useState22 = _slicedToArray(_useState21, 2),
47500
- frequency = _useState22[0],
47501
- setFrequency = _useState22[1];
47502
- var _useState23 = useState(parsed.time || DEFAULT_SCHEDULE.time),
47554
+ var _useState23 = useState(parsed.frequency === "custom" ? "off" : parsed.frequency),
47503
47555
  _useState24 = _slicedToArray(_useState23, 2),
47504
- time = _useState24[0],
47505
- setTime = _useState24[1];
47506
- var _useState25 = useState(parsed.dayOfWeek || DEFAULT_SCHEDULE.dayOfWeek),
47556
+ frequency = _useState24[0],
47557
+ setFrequency = _useState24[1];
47558
+ var _useState25 = useState(parsed.time || DEFAULT_SCHEDULE.time),
47507
47559
  _useState26 = _slicedToArray(_useState25, 2),
47508
- dayOfWeek = _useState26[0],
47509
- setDayOfWeek = _useState26[1];
47510
- var _useState27 = useState(parsed.dayOfMonth || DEFAULT_SCHEDULE.dayOfMonth),
47560
+ time = _useState26[0],
47561
+ setTime = _useState26[1];
47562
+ var _useState27 = useState(parsed.dayOfWeek || DEFAULT_SCHEDULE.dayOfWeek),
47511
47563
  _useState28 = _slicedToArray(_useState27, 2),
47512
- dayOfMonth = _useState28[0],
47513
- setDayOfMonth = _useState28[1];
47514
- var _useState29 = useState(parsed.frequency === "custom"),
47564
+ dayOfWeek = _useState28[0],
47565
+ setDayOfWeek = _useState28[1];
47566
+ var _useState29 = useState(parsed.dayOfMonth || DEFAULT_SCHEDULE.dayOfMonth),
47515
47567
  _useState30 = _slicedToArray(_useState29, 2),
47516
- advanced = _useState30[0],
47517
- setAdvanced = _useState30[1];
47518
- var _useState31 = useState(initialCron),
47568
+ dayOfMonth = _useState30[0],
47569
+ setDayOfMonth = _useState30[1];
47570
+ var _useState31 = useState(parsed.frequency === "custom"),
47519
47571
  _useState32 = _slicedToArray(_useState31, 2),
47520
- advancedCron = _useState32[0],
47521
- setAdvancedCron = _useState32[1];
47522
- var _useState33 = useState((bot === null || bot === void 0 || (_bot$schedules2 = bot.schedules) === null || _bot$schedules2 === void 0 || (_bot$schedules2 = _bot$schedules2[0]) === null || _bot$schedules2 === void 0 ? void 0 : _bot$schedules2.prompt) || ""),
47572
+ advanced = _useState32[0],
47573
+ setAdvanced = _useState32[1];
47574
+ var _useState33 = useState(initialCron),
47523
47575
  _useState34 = _slicedToArray(_useState33, 2),
47524
- schedulePrompt = _useState34[0],
47525
- setSchedulePrompt = _useState34[1];
47576
+ advancedCron = _useState34[0],
47577
+ setAdvancedCron = _useState34[1];
47578
+ var _useState35 = useState((bot === null || bot === void 0 || (_bot$schedules2 = bot.schedules) === null || _bot$schedules2 === void 0 || (_bot$schedules2 = _bot$schedules2[0]) === null || _bot$schedules2 === void 0 ? void 0 : _bot$schedules2.prompt) || ""),
47579
+ _useState36 = _slicedToArray(_useState35, 2),
47580
+ schedulePrompt = _useState36[0],
47581
+ setSchedulePrompt = _useState36[1];
47526
47582
 
47527
47583
  // --- Run-on-events (subscriptions) ---
47528
- var _useState35 = useState(((bot === null || bot === void 0 ? void 0 : bot.subscriptions) || []).map(function (s) {
47584
+ var _useState37 = useState(((bot === null || bot === void 0 ? void 0 : bot.subscriptions) || []).map(function (s) {
47529
47585
  return s && s.eventType;
47530
47586
  }).filter(Boolean)),
47531
- _useState36 = _slicedToArray(_useState35, 2),
47532
- subscriptions = _useState36[0],
47533
- setSubscriptions = _useState36[1];
47534
- var _useState37 = useState(""),
47535
47587
  _useState38 = _slicedToArray(_useState37, 2),
47536
- newEvent = _useState38[0],
47537
- setNewEvent = _useState38[1];
47538
- var _useState39 = useState([]),
47588
+ subscriptions = _useState38[0],
47589
+ setSubscriptions = _useState38[1];
47590
+ var _useState39 = useState(""),
47539
47591
  _useState40 = _slicedToArray(_useState39, 2),
47540
- knownEvents = _useState40[0],
47541
- setKnownEvents = _useState40[1];
47542
- var _useState41 = useState(false),
47592
+ newEvent = _useState40[0],
47593
+ setNewEvent = _useState40[1];
47594
+ var _useState41 = useState([]),
47543
47595
  _useState42 = _slicedToArray(_useState41, 2),
47544
- saving = _useState42[0],
47545
- setSaving = _useState42[1];
47546
- var _useState43 = useState(null),
47596
+ knownEvents = _useState42[0],
47597
+ setKnownEvents = _useState42[1];
47598
+ var _useState43 = useState(false),
47547
47599
  _useState44 = _slicedToArray(_useState43, 2),
47548
- error = _useState44[0],
47549
- setError = _useState44[1];
47600
+ saving = _useState44[0],
47601
+ setSaving = _useState44[1];
47602
+ var _useState45 = useState(null),
47603
+ _useState46 = _slicedToArray(_useState45, 2),
47604
+ error = _useState46[0],
47605
+ setError = _useState46[1];
47550
47606
 
47551
47607
  // Discover recently-seen widget event types to suggest as subscriptions.
47552
47608
  useEffect(function () {
@@ -47565,10 +47621,10 @@ var BotDetail = function BotDetail(_ref) {
47565
47621
  // Discover the user's configured MCP providers — running or not. The bot
47566
47622
  // starts any that aren't running when it runs.
47567
47623
  useEffect(function () {
47568
- var _api$bots;
47624
+ var _api$bots3;
47569
47625
  var alive = true;
47570
47626
  var api = getMainApi();
47571
- if (!(api !== null && api !== void 0 && (_api$bots = api.bots) !== null && _api$bots !== void 0 && _api$bots.listToolSources)) {
47627
+ if (!(api !== null && api !== void 0 && (_api$bots3 = api.bots) !== null && _api$bots3 !== void 0 && _api$bots3.listToolSources)) {
47572
47628
  setSourcesLoaded(true);
47573
47629
  return undefined;
47574
47630
  }
@@ -47696,10 +47752,10 @@ var BotDetail = function BotDetail(_ref) {
47696
47752
  });
47697
47753
  var canSave = name.trim() && instructions.trim() && !saving;
47698
47754
  var handleSave = /*#__PURE__*/function () {
47699
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
47700
- var cron, schedules, definition, _t;
47701
- return _regeneratorRuntime.wrap(function (_context) {
47702
- while (1) switch (_context.prev = _context.next) {
47755
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
47756
+ var cron, schedules, definition, _t2;
47757
+ return _regeneratorRuntime.wrap(function (_context2) {
47758
+ while (1) switch (_context2.prev = _context2.next) {
47703
47759
  case 0:
47704
47760
  setError(null);
47705
47761
  cron = advanced ? advancedCron.trim() : buildCron({
@@ -47723,9 +47779,9 @@ var BotDetail = function BotDetail(_ref) {
47723
47779
  approvalPolicy: approvalPolicy,
47724
47780
  mcpServers: selectedServers,
47725
47781
  // Only keep narrowing for providers the bot still uses.
47726
- toolSelections: Object.fromEntries(Object.entries(toolSelections).filter(function (_ref3) {
47727
- var _ref4 = _slicedToArray(_ref3, 1),
47728
- server = _ref4[0];
47782
+ toolSelections: Object.fromEntries(Object.entries(toolSelections).filter(function (_ref4) {
47783
+ var _ref5 = _slicedToArray(_ref4, 1),
47784
+ server = _ref5[0];
47729
47785
  return selectedServers.includes(server);
47730
47786
  })),
47731
47787
  schedules: schedules,
@@ -47736,28 +47792,28 @@ var BotDetail = function BotDetail(_ref) {
47736
47792
  })
47737
47793
  });
47738
47794
  setSaving(true);
47739
- _context.prev = 1;
47740
- _context.next = 2;
47795
+ _context2.prev = 1;
47796
+ _context2.next = 2;
47741
47797
  return onSave(definition);
47742
47798
  case 2:
47743
- _context.next = 4;
47799
+ _context2.next = 4;
47744
47800
  break;
47745
47801
  case 3:
47746
- _context.prev = 3;
47747
- _t = _context["catch"](1);
47748
- setError(_t && _t.message || "Failed to save bot");
47802
+ _context2.prev = 3;
47803
+ _t2 = _context2["catch"](1);
47804
+ setError(_t2 && _t2.message || "Failed to save bot");
47749
47805
  case 4:
47750
- _context.prev = 4;
47806
+ _context2.prev = 4;
47751
47807
  setSaving(false);
47752
- return _context.finish(4);
47808
+ return _context2.finish(4);
47753
47809
  case 5:
47754
47810
  case "end":
47755
- return _context.stop();
47811
+ return _context2.stop();
47756
47812
  }
47757
- }, _callee, null, [[1, 3, 4, 5]]);
47813
+ }, _callee2, null, [[1, 3, 4, 5]]);
47758
47814
  }));
47759
47815
  return function handleSave() {
47760
- return _ref2.apply(this, arguments);
47816
+ return _ref3.apply(this, arguments);
47761
47817
  };
47762
47818
  }();
47763
47819
  var scheduleOn = advanced || frequency !== "off";
@@ -47836,15 +47892,34 @@ var BotDetail = function BotDetail(_ref) {
47836
47892
  }), /*#__PURE__*/jsx("div", {
47837
47893
  className: "grid grid-cols-2 gap-x-4 gap-y-1",
47838
47894
  children: s.tools.map(function (tool) {
47839
- return /*#__PURE__*/jsx(Checkbox, {
47840
- label: prettyTool(tool),
47841
- checked: isToolOn(s.serverName, tool),
47842
- onChange: function onChange() {
47843
- return toggleTool(s.serverName, s.tools, tool);
47844
- }
47895
+ return /*#__PURE__*/jsxs("div", {
47896
+ className: "flex flex-row items-center gap-2",
47897
+ children: [/*#__PURE__*/jsx(Checkbox, {
47898
+ label: prettyTool(tool),
47899
+ checked: isToolOn(s.serverName, tool),
47900
+ onChange: function onChange() {
47901
+ return toggleTool(s.serverName, s.tools, tool);
47902
+ }
47903
+ }), isRemembered(s.serverName, tool) ? /*#__PURE__*/jsxs(Fragment, {
47904
+ children: [/*#__PURE__*/jsx("span", {
47905
+ className: "text-xs opacity-60",
47906
+ children: "Always allowed"
47907
+ }), /*#__PURE__*/jsx(Button3, {
47908
+ title: "Revoke",
47909
+ size: "xs",
47910
+ ariaLabel: "Revoke always-allow for ".concat(prettyTool(tool)),
47911
+ tooltip: "Ask again before this tool runs",
47912
+ onClick: function onClick() {
47913
+ return revokeRemembered(s.serverName, tool);
47914
+ }
47915
+ })]
47916
+ }) : null]
47845
47917
  }, tool);
47846
47918
  })
47847
- })]
47919
+ }), grants[s.serverName] && (grants[s.serverName].folders || []).length ? /*#__PURE__*/jsxs("span", {
47920
+ className: "text-xs opacity-50",
47921
+ children: ["Always-allowed folders:", " ", grants[s.serverName].folders.join(", ")]
47922
+ }) : null]
47848
47923
  }) : /*#__PURE__*/jsx("span", {
47849
47924
  className: "text-xs opacity-50",
47850
47925
  children: "All tools this provider offers \u2014 it has no tool limit set in Settings \u2192 Providers."