@trops/dash-core 0.1.511 → 0.1.512

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
@@ -443,6 +443,7 @@ var WidgetApi = {
443
443
  if (eApi) {
444
444
  // remove the listeners (reset)
445
445
  if ("removeAllListeners" in eApi) {
446
+ var _this$params;
446
447
  eApi.removeAllListeners(eApi.events.DATA_SAVE_TO_FILE_COMPLETE);
447
448
  eApi.removeAllListeners(eApi.events.DATA_SAVE_TO_FILE_ERROR);
448
449
  if (callbackComplete !== null) {
@@ -455,8 +456,13 @@ var WidgetApi = {
455
456
  return callbackError(response);
456
457
  });
457
458
  }
458
- // request.
459
- eApi.data.saveData(data, toFilename, append, returnEmpty, widgetId);
459
+ // Auto-thread widgetId from the singleton's per-widget
460
+ // state when the caller didn't supply one explicitly. This
461
+ // is what makes the fs gate fire for ordinary widgets that
462
+ // call `widgetApi.storeData({data, filename})` without
463
+ // knowing about widgetId.
464
+ var effectiveWidgetId = widgetId || ((_this$params = this.params) === null || _this$params === void 0 ? void 0 : _this$params.name) || null;
465
+ eApi.data.saveData(data, toFilename, append, returnEmpty, effectiveWidgetId);
460
466
  }
461
467
  }
462
468
  } catch (e) {
@@ -491,6 +497,7 @@ var WidgetApi = {
491
497
  var toFilename = filename !== null ? filename : "".concat(uuid, ".json");
492
498
  var eApi = this.electronApi();
493
499
  if ("removeAllListeners" in eApi) {
500
+ var _this$params2;
494
501
  eApi.removeAllListeners(eApi.events.DATA_READ_FROM_FILE_COMPLETE);
495
502
  eApi.removeAllListeners(eApi.events.DATA_READ_FROM_FILE_ERROR);
496
503
  if (callbackComplete !== null) {
@@ -513,7 +520,9 @@ var WidgetApi = {
513
520
  return callbackError(response);
514
521
  });
515
522
  }
516
- eApi.data.readData(toFilename, [], widgetId);
523
+ // Auto-thread widgetId from the singleton — same as storeData.
524
+ var effectiveWidgetId = widgetId || ((_this$params2 = this.params) === null || _this$params2 === void 0 ? void 0 : _this$params2.name) || null;
525
+ eApi.data.readData(toFilename, [], effectiveWidgetId);
517
526
  }
518
527
  } catch (e) {
519
528
  }
@@ -1688,12 +1697,15 @@ var ElectronDashboardApi = /*#__PURE__*/function () {
1688
1697
  value: function mcpCallTool(serverName, toolName, args, allowedTools, onSuccess, onError) {
1689
1698
  var _this22 = this;
1690
1699
  var workspaceId = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
1700
+ var widgetId = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
1691
1701
  if (this.api !== null) {
1692
1702
  try {
1693
- // widgetId is not threaded here; mcpApi.callTool defaults it to
1694
- // null. Slice 3a: workspaceId scopes the MCP server process per
1695
- // workspace.
1696
- this.api.mcp.callTool(serverName, toolName, args, allowedTools, null, workspaceId).then(function (result) {
1703
+ // widgetId is the package-level identity for the MCP gate.
1704
+ // Callers (typically `useMcpProvider`) pass `widgetData.name`
1705
+ // so the gate's `getGrant(widgetId)` lookup matches the grant
1706
+ // written at install consent. workspaceId scopes the server
1707
+ // process per workspace (Slice 3a).
1708
+ this.api.mcp.callTool(serverName, toolName, args, allowedTools, widgetId, workspaceId).then(function (result) {
1697
1709
  onSuccess(_this22.events.MCP_CALL_TOOL_COMPLETE, result);
1698
1710
  })["catch"](function (error) {
1699
1711
  onError(_this22.events.MCP_CALL_TOOL_ERROR, error);
@@ -29919,6 +29931,7 @@ var useMcpProvider = function useMcpProvider(providerType) {
29919
29931
  widgetRequiredTools,
29920
29932
  isRequired,
29921
29933
  workspaceId,
29934
+ widgetIdForGate,
29922
29935
  _args3 = arguments;
29923
29936
  return _regeneratorRuntime.wrap(function (_context3) {
29924
29937
  while (1) switch (_context3.prev = _context3.next) {
@@ -29948,7 +29961,12 @@ var useMcpProvider = function useMcpProvider(providerType) {
29948
29961
  // Slice 3a: scope the MCP server process per workspace. The
29949
29962
  // workspace UUID is the canonical "current dashboard" identity
29950
29963
  // (see useNotifications, useScheduler for the same pattern).
29951
- workspaceId = (workspace === null || workspace === void 0 || (_workspace$workspaceD5 = workspace.workspaceData) === null || _workspace$workspaceD5 === void 0 ? void 0 : _workspace$workspaceD5.id) || null;
29964
+ workspaceId = (workspace === null || workspace === void 0 || (_workspace$workspaceD5 = workspace.workspaceData) === null || _workspace$workspaceD5 === void 0 ? void 0 : _workspace$workspaceD5.id) || null; // widgetData.name is the package-level identity the MCP gate's
29965
+ // grant store keys on. Without this, the gate's per-widget
29966
+ // permissioning is silent (the legacy widgetId-null bypass
29967
+ // skips the gate entirely). Threading it here makes JIT
29968
+ // consent fire for widgets without the user-grant cached.
29969
+ widgetIdForGate = (widgetData === null || widgetData === void 0 ? void 0 : widgetData.name) || null;
29952
29970
  return _context3.abrupt("return", new Promise(function (resolve, reject) {
29953
29971
  var timeout = setTimeout(function () {
29954
29972
  reject(new Error("Tool call \"".concat(toolName, "\" timed out after 30s")));
@@ -29963,7 +29981,7 @@ var useMcpProvider = function useMcpProvider(providerType) {
29963
29981
  }, function (event, err) {
29964
29982
  clearTimeout(timeout);
29965
29983
  reject(new Error((err === null || err === void 0 ? void 0 : err.message) || "Failed to call MCP tool"));
29966
- }, workspaceId);
29984
+ }, workspaceId, widgetIdForGate);
29967
29985
  }));
29968
29986
  case 3:
29969
29987
  case "end":