@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.js CHANGED
@@ -47503,68 +47503,124 @@ var BotDetail = function BotDetail(_ref) {
47503
47503
  _useState18 = _slicedToArray(_useState17, 2),
47504
47504
  sourcesLoaded = _useState18[0],
47505
47505
  setSourcesLoaded = _useState18[1];
47506
+ // Remembered approvals ("Always allow") for a saved bot:
47507
+ // { [provider]: { tools: string[], folders: string[] } }.
47508
+ var _useState19 = React.useState({}),
47509
+ _useState20 = _slicedToArray(_useState19, 2),
47510
+ grants = _useState20[0],
47511
+ setGrants = _useState20[1];
47512
+ React.useEffect(function () {
47513
+ var _api$bots;
47514
+ var alive = true;
47515
+ var api = getMainApi();
47516
+ 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;
47517
+ Promise.resolve(api.bots.getGrants(bot.id)).then(function (g) {
47518
+ if (alive && g && _typeof(g) === "object") setGrants(g);
47519
+ })["catch"](function () {});
47520
+ return function () {
47521
+ alive = false;
47522
+ };
47523
+ }, [bot === null || bot === void 0 ? void 0 : bot.id]);
47524
+ var isRemembered = function isRemembered(serverName, tool) {
47525
+ return !!(grants[serverName] && (grants[serverName].tools || []).includes(tool));
47526
+ };
47527
+ var revokeRemembered = /*#__PURE__*/function () {
47528
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(serverName, tool) {
47529
+ var _api$bots2;
47530
+ var api, next;
47531
+ return _regeneratorRuntime.wrap(function (_context) {
47532
+ while (1) switch (_context.prev = _context.next) {
47533
+ case 0:
47534
+ api = getMainApi();
47535
+ 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))) {
47536
+ _context.next = 1;
47537
+ break;
47538
+ }
47539
+ return _context.abrupt("return");
47540
+ case 1:
47541
+ _context.prev = 1;
47542
+ _context.next = 2;
47543
+ return api.bots.revokeGrant(bot.id, serverName, tool);
47544
+ case 2:
47545
+ next = _context.sent;
47546
+ setGrants(next && _typeof(next) === "object" ? next : {});
47547
+ _context.next = 4;
47548
+ break;
47549
+ case 3:
47550
+ _context.prev = 3;
47551
+ _context["catch"](1);
47552
+ case 4:
47553
+ case "end":
47554
+ return _context.stop();
47555
+ }
47556
+ }, _callee, null, [[1, 3]]);
47557
+ }));
47558
+ return function revokeRemembered(_x, _x2) {
47559
+ return _ref2.apply(this, arguments);
47560
+ };
47561
+ }();
47506
47562
 
47507
47563
  // --- Model options (fetched per provider) ---
47508
- var _useState19 = React.useState([]),
47509
- _useState20 = _slicedToArray(_useState19, 2),
47510
- modelOptions = _useState20[0],
47511
- setModelOptions = _useState20[1];
47564
+ var _useState21 = React.useState([]),
47565
+ _useState22 = _slicedToArray(_useState21, 2),
47566
+ modelOptions = _useState22[0],
47567
+ setModelOptions = _useState22[1];
47512
47568
 
47513
47569
  // --- Schedule (friendly dropdowns; raw cron behind Advanced) ---
47514
47570
  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) || "";
47515
47571
  var parsed = parseCron(initialCron);
47516
- var _useState21 = React.useState(parsed.frequency === "custom" ? "off" : parsed.frequency),
47517
- _useState22 = _slicedToArray(_useState21, 2),
47518
- frequency = _useState22[0],
47519
- setFrequency = _useState22[1];
47520
- var _useState23 = React.useState(parsed.time || DEFAULT_SCHEDULE.time),
47572
+ var _useState23 = React.useState(parsed.frequency === "custom" ? "off" : parsed.frequency),
47521
47573
  _useState24 = _slicedToArray(_useState23, 2),
47522
- time = _useState24[0],
47523
- setTime = _useState24[1];
47524
- var _useState25 = React.useState(parsed.dayOfWeek || DEFAULT_SCHEDULE.dayOfWeek),
47574
+ frequency = _useState24[0],
47575
+ setFrequency = _useState24[1];
47576
+ var _useState25 = React.useState(parsed.time || DEFAULT_SCHEDULE.time),
47525
47577
  _useState26 = _slicedToArray(_useState25, 2),
47526
- dayOfWeek = _useState26[0],
47527
- setDayOfWeek = _useState26[1];
47528
- var _useState27 = React.useState(parsed.dayOfMonth || DEFAULT_SCHEDULE.dayOfMonth),
47578
+ time = _useState26[0],
47579
+ setTime = _useState26[1];
47580
+ var _useState27 = React.useState(parsed.dayOfWeek || DEFAULT_SCHEDULE.dayOfWeek),
47529
47581
  _useState28 = _slicedToArray(_useState27, 2),
47530
- dayOfMonth = _useState28[0],
47531
- setDayOfMonth = _useState28[1];
47532
- var _useState29 = React.useState(parsed.frequency === "custom"),
47582
+ dayOfWeek = _useState28[0],
47583
+ setDayOfWeek = _useState28[1];
47584
+ var _useState29 = React.useState(parsed.dayOfMonth || DEFAULT_SCHEDULE.dayOfMonth),
47533
47585
  _useState30 = _slicedToArray(_useState29, 2),
47534
- advanced = _useState30[0],
47535
- setAdvanced = _useState30[1];
47536
- var _useState31 = React.useState(initialCron),
47586
+ dayOfMonth = _useState30[0],
47587
+ setDayOfMonth = _useState30[1];
47588
+ var _useState31 = React.useState(parsed.frequency === "custom"),
47537
47589
  _useState32 = _slicedToArray(_useState31, 2),
47538
- advancedCron = _useState32[0],
47539
- setAdvancedCron = _useState32[1];
47540
- var _useState33 = React.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) || ""),
47590
+ advanced = _useState32[0],
47591
+ setAdvanced = _useState32[1];
47592
+ var _useState33 = React.useState(initialCron),
47541
47593
  _useState34 = _slicedToArray(_useState33, 2),
47542
- schedulePrompt = _useState34[0],
47543
- setSchedulePrompt = _useState34[1];
47594
+ advancedCron = _useState34[0],
47595
+ setAdvancedCron = _useState34[1];
47596
+ var _useState35 = React.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) || ""),
47597
+ _useState36 = _slicedToArray(_useState35, 2),
47598
+ schedulePrompt = _useState36[0],
47599
+ setSchedulePrompt = _useState36[1];
47544
47600
 
47545
47601
  // --- Run-on-events (subscriptions) ---
47546
- var _useState35 = React.useState(((bot === null || bot === void 0 ? void 0 : bot.subscriptions) || []).map(function (s) {
47602
+ var _useState37 = React.useState(((bot === null || bot === void 0 ? void 0 : bot.subscriptions) || []).map(function (s) {
47547
47603
  return s && s.eventType;
47548
47604
  }).filter(Boolean)),
47549
- _useState36 = _slicedToArray(_useState35, 2),
47550
- subscriptions = _useState36[0],
47551
- setSubscriptions = _useState36[1];
47552
- var _useState37 = React.useState(""),
47553
47605
  _useState38 = _slicedToArray(_useState37, 2),
47554
- newEvent = _useState38[0],
47555
- setNewEvent = _useState38[1];
47556
- var _useState39 = React.useState([]),
47606
+ subscriptions = _useState38[0],
47607
+ setSubscriptions = _useState38[1];
47608
+ var _useState39 = React.useState(""),
47557
47609
  _useState40 = _slicedToArray(_useState39, 2),
47558
- knownEvents = _useState40[0],
47559
- setKnownEvents = _useState40[1];
47560
- var _useState41 = React.useState(false),
47610
+ newEvent = _useState40[0],
47611
+ setNewEvent = _useState40[1];
47612
+ var _useState41 = React.useState([]),
47561
47613
  _useState42 = _slicedToArray(_useState41, 2),
47562
- saving = _useState42[0],
47563
- setSaving = _useState42[1];
47564
- var _useState43 = React.useState(null),
47614
+ knownEvents = _useState42[0],
47615
+ setKnownEvents = _useState42[1];
47616
+ var _useState43 = React.useState(false),
47565
47617
  _useState44 = _slicedToArray(_useState43, 2),
47566
- error = _useState44[0],
47567
- setError = _useState44[1];
47618
+ saving = _useState44[0],
47619
+ setSaving = _useState44[1];
47620
+ var _useState45 = React.useState(null),
47621
+ _useState46 = _slicedToArray(_useState45, 2),
47622
+ error = _useState46[0],
47623
+ setError = _useState46[1];
47568
47624
 
47569
47625
  // Discover recently-seen widget event types to suggest as subscriptions.
47570
47626
  React.useEffect(function () {
@@ -47583,10 +47639,10 @@ var BotDetail = function BotDetail(_ref) {
47583
47639
  // Discover the user's configured MCP providers — running or not. The bot
47584
47640
  // starts any that aren't running when it runs.
47585
47641
  React.useEffect(function () {
47586
- var _api$bots;
47642
+ var _api$bots3;
47587
47643
  var alive = true;
47588
47644
  var api = getMainApi();
47589
- if (!(api !== null && api !== void 0 && (_api$bots = api.bots) !== null && _api$bots !== void 0 && _api$bots.listToolSources)) {
47645
+ if (!(api !== null && api !== void 0 && (_api$bots3 = api.bots) !== null && _api$bots3 !== void 0 && _api$bots3.listToolSources)) {
47590
47646
  setSourcesLoaded(true);
47591
47647
  return undefined;
47592
47648
  }
@@ -47714,10 +47770,10 @@ var BotDetail = function BotDetail(_ref) {
47714
47770
  });
47715
47771
  var canSave = name.trim() && instructions.trim() && !saving;
47716
47772
  var handleSave = /*#__PURE__*/function () {
47717
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
47718
- var cron, schedules, definition, _t;
47719
- return _regeneratorRuntime.wrap(function (_context) {
47720
- while (1) switch (_context.prev = _context.next) {
47773
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
47774
+ var cron, schedules, definition, _t2;
47775
+ return _regeneratorRuntime.wrap(function (_context2) {
47776
+ while (1) switch (_context2.prev = _context2.next) {
47721
47777
  case 0:
47722
47778
  setError(null);
47723
47779
  cron = advanced ? advancedCron.trim() : buildCron({
@@ -47741,9 +47797,9 @@ var BotDetail = function BotDetail(_ref) {
47741
47797
  approvalPolicy: approvalPolicy,
47742
47798
  mcpServers: selectedServers,
47743
47799
  // Only keep narrowing for providers the bot still uses.
47744
- toolSelections: Object.fromEntries(Object.entries(toolSelections).filter(function (_ref3) {
47745
- var _ref4 = _slicedToArray(_ref3, 1),
47746
- server = _ref4[0];
47800
+ toolSelections: Object.fromEntries(Object.entries(toolSelections).filter(function (_ref4) {
47801
+ var _ref5 = _slicedToArray(_ref4, 1),
47802
+ server = _ref5[0];
47747
47803
  return selectedServers.includes(server);
47748
47804
  })),
47749
47805
  schedules: schedules,
@@ -47754,28 +47810,28 @@ var BotDetail = function BotDetail(_ref) {
47754
47810
  })
47755
47811
  });
47756
47812
  setSaving(true);
47757
- _context.prev = 1;
47758
- _context.next = 2;
47813
+ _context2.prev = 1;
47814
+ _context2.next = 2;
47759
47815
  return onSave(definition);
47760
47816
  case 2:
47761
- _context.next = 4;
47817
+ _context2.next = 4;
47762
47818
  break;
47763
47819
  case 3:
47764
- _context.prev = 3;
47765
- _t = _context["catch"](1);
47766
- setError(_t && _t.message || "Failed to save bot");
47820
+ _context2.prev = 3;
47821
+ _t2 = _context2["catch"](1);
47822
+ setError(_t2 && _t2.message || "Failed to save bot");
47767
47823
  case 4:
47768
- _context.prev = 4;
47824
+ _context2.prev = 4;
47769
47825
  setSaving(false);
47770
- return _context.finish(4);
47826
+ return _context2.finish(4);
47771
47827
  case 5:
47772
47828
  case "end":
47773
- return _context.stop();
47829
+ return _context2.stop();
47774
47830
  }
47775
- }, _callee, null, [[1, 3, 4, 5]]);
47831
+ }, _callee2, null, [[1, 3, 4, 5]]);
47776
47832
  }));
47777
47833
  return function handleSave() {
47778
- return _ref2.apply(this, arguments);
47834
+ return _ref3.apply(this, arguments);
47779
47835
  };
47780
47836
  }();
47781
47837
  var scheduleOn = advanced || frequency !== "off";
@@ -47854,15 +47910,34 @@ var BotDetail = function BotDetail(_ref) {
47854
47910
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
47855
47911
  className: "grid grid-cols-2 gap-x-4 gap-y-1",
47856
47912
  children: s.tools.map(function (tool) {
47857
- return /*#__PURE__*/jsxRuntime.jsx(DashReact.Checkbox, {
47858
- label: prettyTool(tool),
47859
- checked: isToolOn(s.serverName, tool),
47860
- onChange: function onChange() {
47861
- return toggleTool(s.serverName, s.tools, tool);
47862
- }
47913
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
47914
+ className: "flex flex-row items-center gap-2",
47915
+ children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.Checkbox, {
47916
+ label: prettyTool(tool),
47917
+ checked: isToolOn(s.serverName, tool),
47918
+ onChange: function onChange() {
47919
+ return toggleTool(s.serverName, s.tools, tool);
47920
+ }
47921
+ }), isRemembered(s.serverName, tool) ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
47922
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
47923
+ className: "text-xs opacity-60",
47924
+ children: "Always allowed"
47925
+ }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Button3, {
47926
+ title: "Revoke",
47927
+ size: "xs",
47928
+ ariaLabel: "Revoke always-allow for ".concat(prettyTool(tool)),
47929
+ tooltip: "Ask again before this tool runs",
47930
+ onClick: function onClick() {
47931
+ return revokeRemembered(s.serverName, tool);
47932
+ }
47933
+ })]
47934
+ }) : null]
47863
47935
  }, tool);
47864
47936
  })
47865
- })]
47937
+ }), grants[s.serverName] && (grants[s.serverName].folders || []).length ? /*#__PURE__*/jsxRuntime.jsxs("span", {
47938
+ className: "text-xs opacity-50",
47939
+ children: ["Always-allowed folders:", " ", grants[s.serverName].folders.join(", ")]
47940
+ }) : null]
47866
47941
  }) : /*#__PURE__*/jsxRuntime.jsx("span", {
47867
47942
  className: "text-xs opacity-50",
47868
47943
  children: "All tools this provider offers \u2014 it has no tool limit set in Settings \u2192 Providers."