@trops/dash-core 0.1.525 → 0.1.527

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.
@@ -3549,17 +3549,42 @@ function parseManifestPermissions(packageJson) {
3549
3549
  return { servers };
3550
3550
  }
3551
3551
 
3552
+ /**
3553
+ * Translate a dotted component widget id into the npm package id whose
3554
+ * package.json holds the manifest. Mirrors the construction logic in
3555
+ * `src/Components/Dashboard/WidgetsTab.js` (`<scope>.<pkg>.<comp>`):
3556
+ *
3557
+ * "@trops/gmail" → "@trops/gmail"
3558
+ * "trops.gmail.GmailCompose" → "@trops/gmail"
3559
+ * "ai-built.pipeline.ProspectWorkspace" → "@ai-built/pipeline"
3560
+ * "pipeline.AutomationHub" → "pipeline" (bare, no scope)
3561
+ * "legacy-bare-package" → "legacy-bare-package"
3562
+ *
3563
+ * The grant store keys grants by the dotted form; the on-disk widget
3564
+ * folder is keyed by the npm form. This bridges the two.
3565
+ */
3566
+ function dottedComponentIdToPackageId(widgetId) {
3567
+ if (typeof widgetId !== "string" || !widgetId) return null;
3568
+ if (widgetId.startsWith("@")) return widgetId;
3569
+ const parts = widgetId.split(".");
3570
+ if (parts.length >= 3) return `@${parts[0]}/${parts[1]}`;
3571
+ if (parts.length === 2) return parts[0];
3572
+ return widgetId;
3573
+ }
3574
+
3552
3575
  /**
3553
3576
  * Find a widget's installed package.json on disk. Widgets live under
3554
3577
  * userData/widgets/<scope>/<name>/ for scoped packages or
3555
- * userData/widgets/<name>/ for unscoped. The widgetId is the npm
3556
- * package name (e.g. "@trops/notes-summarizer" or "notes-summarizer").
3578
+ * userData/widgets/<name>/ for unscoped. Accepts either npm package
3579
+ * ids ("@trops/gmail") or dotted component ids
3580
+ * ("trops.gmail.GmailCompose") — the latter is translated first.
3557
3581
  */
3558
3582
  function resolveWidgetPackagePath(widgetId) {
3559
- if (typeof widgetId !== "string" || !widgetId) return null;
3583
+ const packageId = dottedComponentIdToPackageId(widgetId);
3584
+ if (typeof packageId !== "string" || !packageId) return null;
3560
3585
  const widgetsRoot = path$f.join(app$a.getPath("userData"), "widgets");
3561
3586
  // Split scope from name for "@scope/name" form.
3562
- const parts = widgetId.startsWith("@") ? widgetId.split("/") : [widgetId];
3587
+ const parts = packageId.startsWith("@") ? packageId.split("/") : [packageId];
3563
3588
  return path$f.join(widgetsRoot, ...parts, "package.json");
3564
3589
  }
3565
3590
 
@@ -3603,6 +3628,7 @@ function clearCache() {
3603
3628
  var widgetPermissions = {
3604
3629
  getWidgetMcpPermissions: getWidgetMcpPermissions$1,
3605
3630
  parseManifestPermissions,
3631
+ dottedComponentIdToPackageId,
3606
3632
  expandHome,
3607
3633
  clearCache,
3608
3634
  };
@@ -4000,11 +4026,39 @@ function requireScanWidgetPackagePermissions () {
4000
4026
  return merged;
4001
4027
  }
4002
4028
 
4029
+ /**
4030
+ * Run `applyScanToPackageJson` over a list of widget package paths.
4031
+ * Used at registry boot to backfill `dash.permissions.mcp` for widgets
4032
+ * installed before the publish/install scanner hooks existed (or that
4033
+ * have since updated their tool set without re-publishing). Idempotent
4034
+ * — additive merge means repeated boots produce no further writes.
4035
+ *
4036
+ * @param {string[]} packagePaths
4037
+ * @returns {{scanned: number, modified: number, errors: Array<{path: string, error: string}>}}
4038
+ */
4039
+ function backfillPackagePermissions(packagePaths) {
4040
+ const summary = { scanned: 0, modified: 0, errors: [] };
4041
+ if (!Array.isArray(packagePaths)) return summary;
4042
+ for (const pkgPath of packagePaths) {
4043
+ if (typeof pkgPath !== "string" || !pkgPath) continue;
4044
+ if (!fs.existsSync(pkgPath)) continue;
4045
+ summary.scanned += 1;
4046
+ try {
4047
+ const merged = applyScanToPackageJson(pkgPath);
4048
+ if (merged) summary.modified += 1;
4049
+ } catch (e) {
4050
+ summary.errors.push({ path: pkgPath, error: e.message });
4051
+ }
4052
+ }
4053
+ return summary;
4054
+ }
4055
+
4003
4056
  scanWidgetPackagePermissions_1 = {
4004
4057
  scanFileForMcpUsage,
4005
4058
  scanWidgetPackagePermissions,
4006
4059
  mergePermissions,
4007
4060
  applyScanToPackageJson,
4061
+ backfillPackagePermissions,
4008
4062
  };
4009
4063
  return scanWidgetPackagePermissions_1;
4010
4064
  }
@@ -4795,6 +4849,33 @@ var schedulerController_1 = schedulerController$2;
4795
4849
 
4796
4850
  // Reconcile: re-register orphaned widget packages found on disk
4797
4851
  this.reconcileWithDisk();
4852
+
4853
+ // Slice 13b: backfill `dash.permissions.mcp` for any registered
4854
+ // widget that was installed before the publish/install scanner
4855
+ // hooks existed (or that has since updated tools without
4856
+ // re-publishing). Additive merge — idempotent across boots.
4857
+ try {
4858
+ const {
4859
+ backfillPackagePermissions,
4860
+ } = requireScanWidgetPackagePermissions();
4861
+ const paths = Array.from(this.widgets.values())
4862
+ .map((w) => w.path)
4863
+ .filter(Boolean);
4864
+ const summary = backfillPackagePermissions(paths);
4865
+ if (summary.modified > 0) {
4866
+ console.log(
4867
+ `[WidgetRegistry] Backfilled MCP permissions for ${summary.modified}/${summary.scanned} widget(s)`,
4868
+ );
4869
+ }
4870
+ if (summary.errors.length) {
4871
+ console.warn(`[WidgetRegistry] MCP backfill errors:`, summary.errors);
4872
+ }
4873
+ } catch (e) {
4874
+ console.warn(
4875
+ "[WidgetRegistry] MCP permissions backfill failed:",
4876
+ e.message,
4877
+ );
4878
+ }
4798
4879
  }
4799
4880
 
4800
4881
  /**