@trops/dash-core 0.1.612 → 0.1.613

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
@@ -46033,6 +46033,55 @@ var NewProviderPicker = function NewProviderPicker(_ref2) {
46033
46033
  });
46034
46034
  };
46035
46035
 
46036
+ /**
46037
+ * providerType.js
46038
+ *
46039
+ * Helpers for assigning a stable, UNIQUE `type` to a provider.
46040
+ *
46041
+ * A provider's identity in the widget system is its `type` string (widgets
46042
+ * declare `requiredProviders: [{ type }]`, runtime resolves by type). Catalog
46043
+ * providers each carry a unique type (`slack`, `github`, …). Hand-rolled
46044
+ * custom MCP servers historically all shared `type: "custom"`, which conflates
46045
+ * multiple customs at binding/runtime. These helpers give each NEW custom
46046
+ * provider a unique slug derived from its name so it behaves like a catalog
46047
+ * provider.
46048
+ *
46049
+ * Forward-only: existing providers are never renamed here (that would break
46050
+ * widgets already built against their type). Only the create path uses this.
46051
+ */
46052
+
46053
+ /**
46054
+ * Convert a provider name into a kebab-case type slug.
46055
+ * "My Granola Server" → "my-granola-server". Falls back to a sane default
46056
+ * when the name has no slug-able characters.
46057
+ */
46058
+ function slugifyProviderType(name) {
46059
+ var slug = String(name || "").toLowerCase().trim().replace(/[^\w\s-]/g, "") // drop punctuation/symbols
46060
+ .replace(/[\s_]+/g, "-") // whitespace/underscores → hyphen
46061
+ .replace(/-+/g, "-") // collapse repeats
46062
+ .replace(/^-+|-+$/g, ""); // trim hyphens
46063
+ return slug || "custom-provider";
46064
+ }
46065
+
46066
+ /**
46067
+ * Produce a slug type unique against the already-configured provider types.
46068
+ * Appends `-2`, `-3`, … on collision so two providers can never share a type.
46069
+ *
46070
+ * @param {string} name provider instance name
46071
+ * @param {Iterable<string>} existingTypes types already in use (e.g.
46072
+ * Object.values(providers).map(p => p.type))
46073
+ * @returns {string}
46074
+ */
46075
+ function uniqueProviderType(name) {
46076
+ var existingTypes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
46077
+ var base = slugifyProviderType(name);
46078
+ var taken = new Set(existingTypes || []);
46079
+ if (!taken.has(base)) return base;
46080
+ var i = 2;
46081
+ while (taken.has("".concat(base, "-").concat(i))) i++;
46082
+ return "".concat(base, "-").concat(i);
46083
+ }
46084
+
46036
46085
  var ProvidersSection = function ProvidersSection(_ref) {
46037
46086
  var _ref$dashApi = _ref.dashApi,
46038
46087
  dashApi = _ref$dashApi === void 0 ? null : _ref$dashApi,
@@ -46257,8 +46306,21 @@ var ProvidersSection = function ProvidersSection(_ref) {
46257
46306
  function handleMcpSave(providerName, providerType, mcpCredentials, mcpConfig) {
46258
46307
  var allowedTools = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
46259
46308
  if (!dashApi || !appId) return;
46309
+ // Forward-only unique types: a hand-rolled custom MCP server arrives with
46310
+ // the generic default type "custom", which conflates multiple customs at
46311
+ // widget-binding/runtime time. Give each NEW one a unique slug so it has a
46312
+ // distinct identity like catalog providers. Catalog installs pass a real
46313
+ // id (not "custom") and are untouched; the edit path preserves type, so no
46314
+ // existing provider is ever renamed.
46315
+ var resolvedType = providerType;
46316
+ if (resolvedType === "custom") {
46317
+ var existingTypes = Object.values(providers || {}).map(function (p) {
46318
+ return p.type;
46319
+ });
46320
+ resolvedType = uniqueProviderType(providerName, existingTypes);
46321
+ }
46260
46322
  dashApi.saveProvider(appId, providerName, {
46261
- providerType: providerType,
46323
+ providerType: resolvedType,
46262
46324
  credentials: mcpCredentials,
46263
46325
  providerClass: "mcp",
46264
46326
  mcpConfig: mcpConfig,