@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.js CHANGED
@@ -46051,6 +46051,55 @@ var NewProviderPicker = function NewProviderPicker(_ref2) {
46051
46051
  });
46052
46052
  };
46053
46053
 
46054
+ /**
46055
+ * providerType.js
46056
+ *
46057
+ * Helpers for assigning a stable, UNIQUE `type` to a provider.
46058
+ *
46059
+ * A provider's identity in the widget system is its `type` string (widgets
46060
+ * declare `requiredProviders: [{ type }]`, runtime resolves by type). Catalog
46061
+ * providers each carry a unique type (`slack`, `github`, …). Hand-rolled
46062
+ * custom MCP servers historically all shared `type: "custom"`, which conflates
46063
+ * multiple customs at binding/runtime. These helpers give each NEW custom
46064
+ * provider a unique slug derived from its name so it behaves like a catalog
46065
+ * provider.
46066
+ *
46067
+ * Forward-only: existing providers are never renamed here (that would break
46068
+ * widgets already built against their type). Only the create path uses this.
46069
+ */
46070
+
46071
+ /**
46072
+ * Convert a provider name into a kebab-case type slug.
46073
+ * "My Granola Server" → "my-granola-server". Falls back to a sane default
46074
+ * when the name has no slug-able characters.
46075
+ */
46076
+ function slugifyProviderType(name) {
46077
+ var slug = String(name || "").toLowerCase().trim().replace(/[^\w\s-]/g, "") // drop punctuation/symbols
46078
+ .replace(/[\s_]+/g, "-") // whitespace/underscores → hyphen
46079
+ .replace(/-+/g, "-") // collapse repeats
46080
+ .replace(/^-+|-+$/g, ""); // trim hyphens
46081
+ return slug || "custom-provider";
46082
+ }
46083
+
46084
+ /**
46085
+ * Produce a slug type unique against the already-configured provider types.
46086
+ * Appends `-2`, `-3`, … on collision so two providers can never share a type.
46087
+ *
46088
+ * @param {string} name provider instance name
46089
+ * @param {Iterable<string>} existingTypes types already in use (e.g.
46090
+ * Object.values(providers).map(p => p.type))
46091
+ * @returns {string}
46092
+ */
46093
+ function uniqueProviderType(name) {
46094
+ var existingTypes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
46095
+ var base = slugifyProviderType(name);
46096
+ var taken = new Set(existingTypes || []);
46097
+ if (!taken.has(base)) return base;
46098
+ var i = 2;
46099
+ while (taken.has("".concat(base, "-").concat(i))) i++;
46100
+ return "".concat(base, "-").concat(i);
46101
+ }
46102
+
46054
46103
  var ProvidersSection = function ProvidersSection(_ref) {
46055
46104
  var _ref$dashApi = _ref.dashApi,
46056
46105
  dashApi = _ref$dashApi === void 0 ? null : _ref$dashApi,
@@ -46275,8 +46324,21 @@ var ProvidersSection = function ProvidersSection(_ref) {
46275
46324
  function handleMcpSave(providerName, providerType, mcpCredentials, mcpConfig) {
46276
46325
  var allowedTools = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
46277
46326
  if (!dashApi || !appId) return;
46327
+ // Forward-only unique types: a hand-rolled custom MCP server arrives with
46328
+ // the generic default type "custom", which conflates multiple customs at
46329
+ // widget-binding/runtime time. Give each NEW one a unique slug so it has a
46330
+ // distinct identity like catalog providers. Catalog installs pass a real
46331
+ // id (not "custom") and are untouched; the edit path preserves type, so no
46332
+ // existing provider is ever renamed.
46333
+ var resolvedType = providerType;
46334
+ if (resolvedType === "custom") {
46335
+ var existingTypes = Object.values(providers || {}).map(function (p) {
46336
+ return p.type;
46337
+ });
46338
+ resolvedType = uniqueProviderType(providerName, existingTypes);
46339
+ }
46278
46340
  dashApi.saveProvider(appId, providerName, {
46279
- providerType: providerType,
46341
+ providerType: resolvedType,
46280
46342
  credentials: mcpCredentials,
46281
46343
  providerClass: "mcp",
46282
46344
  mcpConfig: mcpConfig,