@miragon/mcp-toolkit-core 0.10.1

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.
Files changed (174) hide show
  1. package/README.md +32 -0
  2. package/dist/engine/context-builder.d.ts +5 -0
  3. package/dist/engine/context-builder.d.ts.map +1 -0
  4. package/dist/engine/context-builder.js +22 -0
  5. package/dist/engine/context-builder.js.map +1 -0
  6. package/dist/engine/pipeline-executor.d.ts +21 -0
  7. package/dist/engine/pipeline-executor.d.ts.map +1 -0
  8. package/dist/engine/pipeline-executor.js +80 -0
  9. package/dist/engine/pipeline-executor.js.map +1 -0
  10. package/dist/framework/active-modules.d.ts +30 -0
  11. package/dist/framework/active-modules.d.ts.map +1 -0
  12. package/dist/framework/active-modules.js +44 -0
  13. package/dist/framework/active-modules.js.map +1 -0
  14. package/dist/framework/catalogue.d.ts +148 -0
  15. package/dist/framework/catalogue.d.ts.map +1 -0
  16. package/dist/framework/catalogue.js +132 -0
  17. package/dist/framework/catalogue.js.map +1 -0
  18. package/dist/framework/dashboard-store.d.ts +136 -0
  19. package/dist/framework/dashboard-store.d.ts.map +1 -0
  20. package/dist/framework/dashboard-store.js +301 -0
  21. package/dist/framework/dashboard-store.js.map +1 -0
  22. package/dist/framework/layout-schemas.d.ts +106 -0
  23. package/dist/framework/layout-schemas.d.ts.map +1 -0
  24. package/dist/framework/layout-schemas.js +67 -0
  25. package/dist/framework/layout-schemas.js.map +1 -0
  26. package/dist/framework/layout-types.d.ts +25 -0
  27. package/dist/framework/layout-types.d.ts.map +1 -0
  28. package/dist/framework/layout-types.js +7 -0
  29. package/dist/framework/layout-types.js.map +1 -0
  30. package/dist/framework/manifest.d.ts +65 -0
  31. package/dist/framework/manifest.d.ts.map +1 -0
  32. package/dist/framework/manifest.js +47 -0
  33. package/dist/framework/manifest.js.map +1 -0
  34. package/dist/framework/render-view.d.ts +53 -0
  35. package/dist/framework/render-view.d.ts.map +1 -0
  36. package/dist/framework/render-view.js +73 -0
  37. package/dist/framework/render-view.js.map +1 -0
  38. package/dist/framework/view-builders.d.ts +79 -0
  39. package/dist/framework/view-builders.d.ts.map +1 -0
  40. package/dist/framework/view-builders.js +113 -0
  41. package/dist/framework/view-builders.js.map +1 -0
  42. package/dist/i18n/index.d.ts +3 -0
  43. package/dist/i18n/index.d.ts.map +1 -0
  44. package/dist/i18n/index.js +6 -0
  45. package/dist/i18n/index.js.map +1 -0
  46. package/dist/i18n/translator.d.ts +59 -0
  47. package/dist/i18n/translator.d.ts.map +1 -0
  48. package/dist/i18n/translator.js +48 -0
  49. package/dist/i18n/translator.js.map +1 -0
  50. package/dist/index.d.ts +31 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +27 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/middleware/org-gate.d.ts +22 -0
  55. package/dist/middleware/org-gate.d.ts.map +1 -0
  56. package/dist/middleware/org-gate.js +28 -0
  57. package/dist/middleware/org-gate.js.map +1 -0
  58. package/dist/middleware/role-filter.d.ts +79 -0
  59. package/dist/middleware/role-filter.d.ts.map +1 -0
  60. package/dist/middleware/role-filter.js +95 -0
  61. package/dist/middleware/role-filter.js.map +1 -0
  62. package/dist/registry/app-loader.d.ts +35 -0
  63. package/dist/registry/app-loader.d.ts.map +1 -0
  64. package/dist/registry/app-loader.js +55 -0
  65. package/dist/registry/app-loader.js.map +1 -0
  66. package/dist/registry/step-registry.d.ts +27 -0
  67. package/dist/registry/step-registry.d.ts.map +1 -0
  68. package/dist/registry/step-registry.js +53 -0
  69. package/dist/registry/step-registry.js.map +1 -0
  70. package/dist/registry/widget-registry.d.ts +15 -0
  71. package/dist/registry/widget-registry.d.ts.map +1 -0
  72. package/dist/registry/widget-registry.js +28 -0
  73. package/dist/registry/widget-registry.js.map +1 -0
  74. package/dist/rest/client.d.ts +3 -0
  75. package/dist/rest/client.d.ts.map +1 -0
  76. package/dist/rest/client.js +155 -0
  77. package/dist/rest/client.js.map +1 -0
  78. package/dist/rest/errors.d.ts +14 -0
  79. package/dist/rest/errors.d.ts.map +1 -0
  80. package/dist/rest/errors.js +21 -0
  81. package/dist/rest/errors.js.map +1 -0
  82. package/dist/rest/index.d.ts +6 -0
  83. package/dist/rest/index.d.ts.map +1 -0
  84. package/dist/rest/index.js +4 -0
  85. package/dist/rest/index.js.map +1 -0
  86. package/dist/rest/tool.d.ts +60 -0
  87. package/dist/rest/tool.d.ts.map +1 -0
  88. package/dist/rest/tool.js +81 -0
  89. package/dist/rest/tool.js.map +1 -0
  90. package/dist/rest/types.d.ts +66 -0
  91. package/dist/rest/types.d.ts.map +1 -0
  92. package/dist/rest/types.js +2 -0
  93. package/dist/rest/types.js.map +1 -0
  94. package/dist/tools/app-resource-uri.d.ts +28 -0
  95. package/dist/tools/app-resource-uri.d.ts.map +1 -0
  96. package/dist/tools/app-resource-uri.js +30 -0
  97. package/dist/tools/app-resource-uri.js.map +1 -0
  98. package/dist/tools/backend-registry.d.ts +111 -0
  99. package/dist/tools/backend-registry.d.ts.map +1 -0
  100. package/dist/tools/backend-registry.js +154 -0
  101. package/dist/tools/backend-registry.js.map +1 -0
  102. package/dist/tools/create-framework-app.d.ts +147 -0
  103. package/dist/tools/create-framework-app.d.ts.map +1 -0
  104. package/dist/tools/create-framework-app.js +111 -0
  105. package/dist/tools/create-framework-app.js.map +1 -0
  106. package/dist/tools/index.d.ts +22 -0
  107. package/dist/tools/index.d.ts.map +1 -0
  108. package/dist/tools/index.js +15 -0
  109. package/dist/tools/index.js.map +1 -0
  110. package/dist/tools/register-catalogue-tool.d.ts +22 -0
  111. package/dist/tools/register-catalogue-tool.d.ts.map +1 -0
  112. package/dist/tools/register-catalogue-tool.js +45 -0
  113. package/dist/tools/register-catalogue-tool.js.map +1 -0
  114. package/dist/tools/register-dashboard-tools.d.ts +32 -0
  115. package/dist/tools/register-dashboard-tools.d.ts.map +1 -0
  116. package/dist/tools/register-dashboard-tools.js +149 -0
  117. package/dist/tools/register-dashboard-tools.js.map +1 -0
  118. package/dist/tools/register-framework-tools.d.ts +83 -0
  119. package/dist/tools/register-framework-tools.d.ts.map +1 -0
  120. package/dist/tools/register-framework-tools.js +154 -0
  121. package/dist/tools/register-framework-tools.js.map +1 -0
  122. package/dist/tools/register-tool.d.ts +45 -0
  123. package/dist/tools/register-tool.d.ts.map +1 -0
  124. package/dist/tools/register-tool.js +82 -0
  125. package/dist/tools/register-tool.js.map +1 -0
  126. package/dist/tools/register-widget-tool.d.ts +51 -0
  127. package/dist/tools/register-widget-tool.d.ts.map +1 -0
  128. package/dist/tools/register-widget-tool.js +45 -0
  129. package/dist/tools/register-widget-tool.js.map +1 -0
  130. package/dist/tools/tool-call-name.d.ts +53 -0
  131. package/dist/tools/tool-call-name.d.ts.map +1 -0
  132. package/dist/tools/tool-call-name.js +92 -0
  133. package/dist/tools/tool-call-name.js.map +1 -0
  134. package/dist/tools/with-tool-errors.d.ts +16 -0
  135. package/dist/tools/with-tool-errors.d.ts.map +1 -0
  136. package/dist/tools/with-tool-errors.js +28 -0
  137. package/dist/tools/with-tool-errors.js.map +1 -0
  138. package/dist/types/app.d.ts +44 -0
  139. package/dist/types/app.d.ts.map +1 -0
  140. package/dist/types/app.js +2 -0
  141. package/dist/types/app.js.map +1 -0
  142. package/dist/types/config.d.ts +15 -0
  143. package/dist/types/config.d.ts.map +1 -0
  144. package/dist/types/config.js +2 -0
  145. package/dist/types/config.js.map +1 -0
  146. package/dist/types/context.d.ts +18 -0
  147. package/dist/types/context.d.ts.map +1 -0
  148. package/dist/types/context.js +2 -0
  149. package/dist/types/context.js.map +1 -0
  150. package/dist/types/index.d.ts +10 -0
  151. package/dist/types/index.d.ts.map +1 -0
  152. package/dist/types/index.js +2 -0
  153. package/dist/types/index.js.map +1 -0
  154. package/dist/types/meta.d.ts +99 -0
  155. package/dist/types/meta.d.ts.map +1 -0
  156. package/dist/types/meta.js +66 -0
  157. package/dist/types/meta.js.map +1 -0
  158. package/dist/types/pipeline.d.ts +9 -0
  159. package/dist/types/pipeline.d.ts.map +1 -0
  160. package/dist/types/pipeline.js +2 -0
  161. package/dist/types/pipeline.js.map +1 -0
  162. package/dist/types/step.d.ts +51 -0
  163. package/dist/types/step.d.ts.map +1 -0
  164. package/dist/types/step.js +2 -0
  165. package/dist/types/step.js.map +1 -0
  166. package/dist/types/view-data.d.ts +67 -0
  167. package/dist/types/view-data.d.ts.map +1 -0
  168. package/dist/types/view-data.js +2 -0
  169. package/dist/types/view-data.js.map +1 -0
  170. package/dist/types/widget.d.ts +57 -0
  171. package/dist/types/widget.d.ts.map +1 -0
  172. package/dist/types/widget.js +2 -0
  173. package/dist/types/widget.js.map +1 -0
  174. package/package.json +50 -0
@@ -0,0 +1,31 @@
1
+ export type { StepOutput, StepResult, PipelineContext, PipelineStepDefinition, OptionalKeyDeclaration, WidgetProps, WidgetSize, WidgetDefinition, AppDefinition, AppPlugin, PipelineConfig, PipelineStepRef, AppConfig, AppConfigEntry, ValidationResult, ViewStructuredContent, StepDataEntry, RefreshParams, } from "./types/index.js";
2
+ export { APP_ONLY_META, uiMeta } from "./types/index.js";
3
+ export type { UiMetaOptions } from "./types/index.js";
4
+ export { createTranslator } from "./i18n/index.js";
5
+ export type { Message, MessageCatalog, Catalogs, Translate, CreateTranslatorOptions, } from "./i18n/index.js";
6
+ export { executePipeline } from "./engine/pipeline-executor.js";
7
+ export type { PipelineExecutionContext, ExecutePipelineOptions, } from "./engine/pipeline-executor.js";
8
+ export { validatePipeline } from "./engine/context-builder.js";
9
+ export { StepRegistry } from "./registry/step-registry.js";
10
+ export type { KeyContract } from "./registry/step-registry.js";
11
+ export { WidgetRegistry } from "./registry/widget-registry.js";
12
+ export { loadApps } from "./registry/app-loader.js";
13
+ export { renderView } from "./framework/render-view.js";
14
+ export type { RenderViewInput, RenderViewOptions } from "./framework/render-view.js";
15
+ export { buildSingleWidgetView, buildComposedView, deriveItemCount, defaultSummary, collectLayoutWidgets, } from "./framework/view-builders.js";
16
+ export type { SingleWidgetViewInput, ComposedViewInput, ComposedViewEntry, ViewToolResult, } from "./framework/view-builders.js";
17
+ export { getBuilderCatalogue } from "./framework/catalogue.js";
18
+ export type { CatalogueInput, CatalogueOptions, CataloguePayload, ReachableWidget, UnreachableWidget, AvailableStep, KeyCatalogEntry, } from "./framework/catalogue.js";
19
+ export type { DashboardStore, DashboardRecord, DashboardSaveInput, DashboardSummary, DashboardListFilter, FileSystemDashboardStoreOptions, } from "./framework/dashboard-store.js";
20
+ export { getFrameworkManifest } from "./framework/manifest.js";
21
+ export type { FrameworkManifest } from "./framework/manifest.js";
22
+ export { normalizeLayout } from "./framework/layout-types.js";
23
+ export type { LayoutConfig, RowDef } from "./framework/layout-types.js";
24
+ export { layoutInputSchema, layoutSchema, rowSchema } from "./framework/layout-schemas.js";
25
+ export { resolveActiveModules, parseActiveModules } from "./framework/active-modules.js";
26
+ export type { ActiveModuleSelection } from "./framework/active-modules.js";
27
+ export { createOrgGateMiddleware } from "./middleware/org-gate.js";
28
+ export type { OrgGateMiddleware } from "./middleware/org-gate.js";
29
+ export { createRoleFilterMiddleware } from "./middleware/role-filter.js";
30
+ export type { RoleFilterMiddleware, RoleFilterMiddlewares, RoleFilterOptions, RoleFilterContext, } from "./middleware/role-filter.js";
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,cAAc,EACd,eAAe,EACf,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACxD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAOr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,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAE1F,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACxF,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAE1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AACxE,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,6BAA6B,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ export { APP_ONLY_META, uiMeta } from "./types/index.js";
2
+ // Localization engine — a dependency-free translator shared by the server (tool
3
+ // summaries) and the UI (widget strings). Browser-safe, so it belongs in the
4
+ // root barrel; ships no catalogs (the consuming app provides its own). The UI
5
+ // `LocaleProvider`/`useLocale` (in `@miragon/mcp-toolkit-ui`) consume a
6
+ // `Translate` from here.
7
+ export { createTranslator } from "./i18n/index.js";
8
+ export { executePipeline } from "./engine/pipeline-executor.js";
9
+ export { validatePipeline } from "./engine/context-builder.js";
10
+ export { StepRegistry } from "./registry/step-registry.js";
11
+ export { WidgetRegistry } from "./registry/widget-registry.js";
12
+ export { loadApps } from "./registry/app-loader.js";
13
+ export { renderView } from "./framework/render-view.js";
14
+ export { buildSingleWidgetView, buildComposedView, deriveItemCount, defaultSummary, collectLayoutWidgets, } from "./framework/view-builders.js";
15
+ export { getBuilderCatalogue } from "./framework/catalogue.js";
16
+ export { getFrameworkManifest } from "./framework/manifest.js";
17
+ export { normalizeLayout } from "./framework/layout-types.js";
18
+ export { layoutInputSchema, layoutSchema, rowSchema } from "./framework/layout-schemas.js";
19
+ export { resolveActiveModules, parseActiveModules } from "./framework/active-modules.js";
20
+ export { createOrgGateMiddleware } from "./middleware/org-gate.js";
21
+ export { createRoleFilterMiddleware } from "./middleware/role-filter.js";
22
+ // NOTE: Tool registrars (`createToolRegistrar`, `createWidgetToolRegistrar`)
23
+ // live in the `./tools` subpath export because they import from
24
+ // `mcp-use/server` at runtime. Keeping them out of the main barrel prevents
25
+ // consumers that only need the framework types and runtime (e.g. a React UI
26
+ // bundle) from pulling `mcp-use/server` into their browser graph.
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAGxD,gFAAgF;AAChF,6EAA6E;AAC7E,8EAA8E;AAC9E,wEAAwE;AACxE,yBAAyB;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AASlD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAK/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAEvD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,oBAAoB,GACrB,MAAM,8BAA8B,CAAA;AAOrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAwB9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAE7D,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAE1F,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAGxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AAQxE,6EAA6E;AAC7E,gEAAgE;AAChE,4EAA4E;AAC5E,4EAA4E;AAC5E,kEAAkE"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Organisation-scope gate for mcp-use middleware.
3
+ *
4
+ * Built for WorkOS-style tokens that carry an `organization_id` claim on the
5
+ * user object. If `orgId` is given, every inbound MCP RPC must come from a
6
+ * user whose token matches — other orgs (or tokens without any org context)
7
+ * get rejected with a thrown error.
8
+ *
9
+ * Register on an mcp-use server with `server.use("mcp:*", createOrgGateMiddleware(ORG_ID))`.
10
+ * Pass `undefined` to disable (returns a pass-through middleware) — handy so
11
+ * the caller can unconditionally wire it up and let env config decide.
12
+ */
13
+ interface OrgGateContext {
14
+ auth?: {
15
+ user?: Record<string, unknown>;
16
+ };
17
+ }
18
+ type Next = () => Promise<unknown>;
19
+ export type OrgGateMiddleware = (ctx: OrgGateContext, next: Next) => Promise<unknown>;
20
+ export declare function createOrgGateMiddleware(orgId: string | undefined): OrgGateMiddleware;
21
+ export {};
22
+ //# sourceMappingURL=org-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-gate.d.ts","sourceRoot":"","sources":["../../src/middleware/org-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAA;CAC1C;AACD,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;AAClC,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAErF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,iBAAiB,CAgBpF"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Organisation-scope gate for mcp-use middleware.
3
+ *
4
+ * Built for WorkOS-style tokens that carry an `organization_id` claim on the
5
+ * user object. If `orgId` is given, every inbound MCP RPC must come from a
6
+ * user whose token matches — other orgs (or tokens without any org context)
7
+ * get rejected with a thrown error.
8
+ *
9
+ * Register on an mcp-use server with `server.use("mcp:*", createOrgGateMiddleware(ORG_ID))`.
10
+ * Pass `undefined` to disable (returns a pass-through middleware) — handy so
11
+ * the caller can unconditionally wire it up and let env config decide.
12
+ */
13
+ export function createOrgGateMiddleware(orgId) {
14
+ if (!orgId)
15
+ return (_ctx, next) => next();
16
+ return async (ctx, next) => {
17
+ const user = ctx.auth?.user;
18
+ const tokenOrgId = user?.organization_id;
19
+ if (!tokenOrgId) {
20
+ throw new Error("Access denied: no organization context in the token. Authenticate with the correct organization.");
21
+ }
22
+ if (tokenOrgId !== orgId) {
23
+ throw new Error("Access denied: user is not a member of this organization.");
24
+ }
25
+ return next();
26
+ };
27
+ }
28
+ //# sourceMappingURL=org-gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-gate.js","sourceRoot":"","sources":["../../src/middleware/org-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,MAAM,UAAU,uBAAuB,CAAC,KAAyB;IAC/D,IAAI,CAAC,KAAK;QAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAA;QAC3B,MAAM,UAAU,GAAG,IAAI,EAAE,eAAe,CAAA;QACxC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CACb,kGAAkG,CACnG,CAAA;QACH,CAAC;QACD,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAA;QAC9E,CAAC;QACD,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Role-scoped module access for mcp-use middleware.
3
+ *
4
+ * Two middlewares are returned from a single role→modules mapping so they
5
+ * stay in sync:
6
+ *
7
+ * - `toolsList` — filters `tools/list` responses so users only see tools
8
+ * belonging to modules their role(s) can access.
9
+ * - `toolsCall` — defence-in-depth: blocks a `tools/call` for a tool whose
10
+ * module isn't allowed for the caller's role(s). Reads the tool name(s) via
11
+ * the injected `resolveToolNames`/`resolveToolName` (mcp-use 1.28 does not
12
+ * put them in `ctx.params`); a JSON-RPC batch can carry several `tools/call`
13
+ * requests, and the guard denies when *any* of them is disallowed. When no
14
+ * name can be resolved it fails *open* by default (allow) — pass
15
+ * `failClosed: true` to deny instead.
16
+ *
17
+ * Tool-to-module mapping uses the prefix convention `<module>_<tool>`.
18
+ * Tools without an underscore are always allowed (they're framework or
19
+ * app-level tools that don't belong to a specific module).
20
+ *
21
+ * Role semantics: a role listed as a key in the mapping *restricts* users
22
+ * with that role to the listed modules. A user with multiple restricted
23
+ * roles sees the *union*. A user with no role that appears as a key gets
24
+ * *unrestricted* access — this is deliberately opt-in so that adding a new
25
+ * role doesn't silently revoke anyone's tools.
26
+ */
27
+ export interface RoleFilterContext {
28
+ auth?: {
29
+ user?: {
30
+ roles?: unknown;
31
+ };
32
+ };
33
+ method?: string;
34
+ params?: {
35
+ name?: unknown;
36
+ };
37
+ }
38
+ type Next = () => Promise<unknown>;
39
+ export type RoleFilterMiddleware = (ctx: RoleFilterContext, next: Next) => Promise<unknown>;
40
+ export interface RoleFilterMiddlewares {
41
+ /** Register with `server.use("mcp:tools/list", ...)`. */
42
+ toolsList: RoleFilterMiddleware;
43
+ /** Register with `server.use("mcp:tools/call", ...)`. */
44
+ toolsCall: RoleFilterMiddleware;
45
+ }
46
+ export interface RoleFilterOptions {
47
+ /**
48
+ * Resolves the in-flight `tools/call` tool name. Required for the
49
+ * `toolsCall` guard to function: mcp-use 1.28 populates `ctx.params` with the
50
+ * tool *arguments*, not `{ name, arguments }`, so `ctx.params?.name` is never
51
+ * the tool name at runtime (and a tool argument literally called `name` —
52
+ * e.g. `save-dashboard`'s — would be misread as one). Wire this to
53
+ * `installToolCallNameCapture(server)` from the `./tools` subpath, which
54
+ * recovers the name from the JSON-RPC envelope. Falls back to
55
+ * `ctx.params?.name` when omitted (legacy behaviour).
56
+ */
57
+ resolveToolName?: () => string | undefined;
58
+ /**
59
+ * Resolves *every* `tools/call` name of the in-flight request. A JSON-RPC
60
+ * batch envelope can carry several `tools/call` requests — a guard that only
61
+ * checks one of them can be bypassed by the others, so when this resolver is
62
+ * provided the guard checks each name and denies if *any* is disallowed.
63
+ * Wire it to the `.all` of `installToolCallNameCapture(server)`'s return.
64
+ * Takes precedence over `resolveToolName` when it yields at least one name.
65
+ */
66
+ resolveToolNames?: () => string[] | undefined;
67
+ /**
68
+ * When `true`, a `tools/call` whose tool name can't be resolved is *denied*
69
+ * instead of allowed. Defaults to `false` (fail-open) to preserve the prior
70
+ * behaviour — opt in for stricter deployments where an unresolved name should
71
+ * never slip past the module guard. Only meaningful alongside
72
+ * `resolveToolName`; without a resolver the name is unavailable by design and
73
+ * enabling this would block every call.
74
+ */
75
+ failClosed?: boolean;
76
+ }
77
+ export declare function createRoleFilterMiddleware(roleToModules: Record<string, string[]>, opts?: RoleFilterOptions): RoleFilterMiddlewares;
78
+ export {};
79
+ //# sourceMappingURL=role-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-filter.d.ts","sourceRoot":"","sources":["../../src/middleware/role-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAA;IACrC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAC5B;AACD,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;AAClC,MAAM,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAE3F,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,SAAS,EAAE,oBAAoB,CAAA;IAC/B,yDAAyD;IACzD,SAAS,EAAE,oBAAoB,CAAA;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IAC1C;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,MAAM,MAAM,EAAE,GAAG,SAAS,CAAA;IAC7C;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACvC,IAAI,GAAE,iBAAsB,GAC3B,qBAAqB,CAqEvB"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Role-scoped module access for mcp-use middleware.
3
+ *
4
+ * Two middlewares are returned from a single role→modules mapping so they
5
+ * stay in sync:
6
+ *
7
+ * - `toolsList` — filters `tools/list` responses so users only see tools
8
+ * belonging to modules their role(s) can access.
9
+ * - `toolsCall` — defence-in-depth: blocks a `tools/call` for a tool whose
10
+ * module isn't allowed for the caller's role(s). Reads the tool name(s) via
11
+ * the injected `resolveToolNames`/`resolveToolName` (mcp-use 1.28 does not
12
+ * put them in `ctx.params`); a JSON-RPC batch can carry several `tools/call`
13
+ * requests, and the guard denies when *any* of them is disallowed. When no
14
+ * name can be resolved it fails *open* by default (allow) — pass
15
+ * `failClosed: true` to deny instead.
16
+ *
17
+ * Tool-to-module mapping uses the prefix convention `<module>_<tool>`.
18
+ * Tools without an underscore are always allowed (they're framework or
19
+ * app-level tools that don't belong to a specific module).
20
+ *
21
+ * Role semantics: a role listed as a key in the mapping *restricts* users
22
+ * with that role to the listed modules. A user with multiple restricted
23
+ * roles sees the *union*. A user with no role that appears as a key gets
24
+ * *unrestricted* access — this is deliberately opt-in so that adding a new
25
+ * role doesn't silently revoke anyone's tools.
26
+ */
27
+ export function createRoleFilterMiddleware(roleToModules, opts = {}) {
28
+ const resolveToolName = opts.resolveToolName;
29
+ const resolveToolNames = opts.resolveToolNames;
30
+ const failClosed = opts.failClosed ?? false;
31
+ const hasRules = Object.keys(roleToModules).length > 0;
32
+ // Returns `null` = unrestricted (full access), array = restricted.
33
+ const allowedModulesFor = (user) => {
34
+ if (!hasRules)
35
+ return null;
36
+ const roles = Array.isArray(user?.roles) ? user.roles : [];
37
+ const restrictedRoles = roles.filter((r) => r in roleToModules);
38
+ if (restrictedRoles.length === 0)
39
+ return null;
40
+ return [...new Set(restrictedRoles.flatMap((r) => roleToModules[r] ?? []))];
41
+ };
42
+ const toolsList = async (ctx, next) => {
43
+ const tools = (await next());
44
+ if (!hasRules || !Array.isArray(tools))
45
+ return tools;
46
+ const allowed = allowedModulesFor(ctx.auth?.user);
47
+ if (allowed === null)
48
+ return tools;
49
+ return tools.filter((t) => {
50
+ if (!t.name.includes("_"))
51
+ return true;
52
+ return allowed.includes(t.name.split("_")[0] ?? "");
53
+ });
54
+ };
55
+ const toolsCall = async (ctx, next) => {
56
+ if (!hasRules)
57
+ return next();
58
+ // A JSON-RPC batch can carry several tools/call requests — check them
59
+ // all; a single-name check would let the remaining batch entries through.
60
+ const resolvedNames = resolveToolNames?.();
61
+ const resolved = resolveToolName?.();
62
+ const fallbackName = typeof resolved === "string"
63
+ ? resolved
64
+ : typeof ctx.params?.name === "string"
65
+ ? ctx.params.name
66
+ : undefined;
67
+ const toolNames = resolvedNames && resolvedNames.length > 0
68
+ ? resolvedNames
69
+ : fallbackName !== undefined
70
+ ? [fallbackName]
71
+ : [];
72
+ if (toolNames.length === 0) {
73
+ if (failClosed) {
74
+ throw new Error("Access denied: unable to resolve the tool name for this call; rejecting under fail-closed policy.");
75
+ }
76
+ return next();
77
+ }
78
+ const allowed = allowedModulesFor(ctx.auth?.user);
79
+ if (allowed === null)
80
+ return next();
81
+ for (const toolName of toolNames) {
82
+ // Tools without an underscore are framework/app-level and always allowed.
83
+ if (!toolName.includes("_"))
84
+ continue;
85
+ const modulePrefix = toolName.split("_")[0] ?? "";
86
+ if (!allowed.includes(modulePrefix)) {
87
+ const userRoles = ctx.auth?.user?.roles ?? [];
88
+ throw new Error(`Access denied: role(s) "${userRoles.join(", ")}" have no access to module "${modulePrefix}".`);
89
+ }
90
+ }
91
+ return next();
92
+ };
93
+ return { toolsList, toolsCall };
94
+ }
95
+ //# sourceMappingURL=role-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-filter.js","sourceRoot":"","sources":["../../src/middleware/role-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAiDH,MAAM,UAAU,0BAA0B,CACxC,aAAuC,EACvC,OAA0B,EAAE;IAE5B,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAA;IAC5C,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAA;IAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,KAAK,CAAA;IAC3C,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC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MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;YACjD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACpC,MAAM,SAAS,GAAI,GAAG,CAAC,IAAI,EAAE,IAAyC,EAAE,KAAK,IAAI,EAAE,CAAA;gBACnF,MAAM,IAAI,KAAK,CACb,2BAA2B,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,+BAA+B,YAAY,IAAI,CAC/F,CAAA;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAA;IAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA;AACjC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { AppDefinition } from "../types/app.js";
2
+ import type { StepRegistry } from "./step-registry.js";
3
+ import type { WidgetRegistry } from "./widget-registry.js";
4
+ export interface LoadAppsOptions {
5
+ /**
6
+ * When `true`, an app whose step/widget ids collide with an already-loaded
7
+ * app is skipped (with a `console.warn`) instead of throwing — and any ids it
8
+ * did register before the collision are rolled back, so the registries never
9
+ * hold a half-loaded module. Use this for *untrusted* module sources, where
10
+ * one bad third-party definition must not brick the whole host boot. Defaults
11
+ * to `false` (throw), which is correct for first-party plugins whose ids the
12
+ * app author controls — there a collision is a real bug that should fail loud.
13
+ */
14
+ isolateFailures?: boolean;
15
+ }
16
+ export interface LoadAppsResult {
17
+ /** Apps whose steps and widgets were fully registered. */
18
+ loaded: AppDefinition[];
19
+ /** Apps skipped due to a collision (only possible with `isolateFailures`). */
20
+ skipped: Array<{
21
+ app: AppDefinition;
22
+ reason: string;
23
+ }>;
24
+ }
25
+ /**
26
+ * Registers each app's steps and widgets into the shared registries.
27
+ *
28
+ * By default a collision throws (the registry's own error), which is the right
29
+ * behaviour for first-party plugins. Pass `isolateFailures: true` for
30
+ * untrusted module sources so a single colliding third-party module is
31
+ * skipped — with its partial registrations rolled back — rather than aborting
32
+ * the entire boot.
33
+ */
34
+ export declare function loadApps(apps: AppDefinition[], stepRegistry: StepRegistry, widgetRegistry: WidgetRegistry, options?: LoadAppsOptions): LoadAppsResult;
35
+ //# sourceMappingURL=app-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-loader.d.ts","sourceRoot":"","sources":["../../src/registry/app-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,MAAM,WAAW,eAAe;IAC9B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,MAAM,EAAE,aAAa,EAAE,CAAA;IACvB,8EAA8E;IAC9E,OAAO,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,aAAa,EAAE,EACrB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,OAAO,GAAE,eAAoB,GAC5B,cAAc,CA4ChB"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Registers each app's steps and widgets into the shared registries.
3
+ *
4
+ * By default a collision throws (the registry's own error), which is the right
5
+ * behaviour for first-party plugins. Pass `isolateFailures: true` for
6
+ * untrusted module sources so a single colliding third-party module is
7
+ * skipped — with its partial registrations rolled back — rather than aborting
8
+ * the entire boot.
9
+ */
10
+ export function loadApps(apps, stepRegistry, widgetRegistry, options = {}) {
11
+ const { isolateFailures = false } = options;
12
+ const loaded = [];
13
+ const skipped = [];
14
+ for (const app of apps) {
15
+ if (!isolateFailures) {
16
+ // First-party path: register directly and let a collision throw, exactly
17
+ // as before.
18
+ for (const step of app.steps)
19
+ stepRegistry.register(step);
20
+ for (const widget of app.widgets)
21
+ widgetRegistry.register(widget);
22
+ loaded.push(app);
23
+ continue;
24
+ }
25
+ // Isolated path: track what this app registers so we can roll back cleanly
26
+ // if any of its ids collide with an already-loaded app. `register` throws
27
+ // only on ids that already exist — i.e. never on the ones we just added —
28
+ // so rollback only removes this app's own registrations.
29
+ const registeredSteps = [];
30
+ const registeredWidgets = [];
31
+ try {
32
+ for (const step of app.steps) {
33
+ stepRegistry.register(step);
34
+ registeredSteps.push(step.id);
35
+ }
36
+ for (const widget of app.widgets) {
37
+ widgetRegistry.register(widget);
38
+ registeredWidgets.push(widget.id);
39
+ }
40
+ loaded.push(app);
41
+ }
42
+ catch (err) {
43
+ for (const id of registeredSteps)
44
+ stepRegistry.unregister(id);
45
+ for (const id of registeredWidgets)
46
+ widgetRegistry.unregister(id);
47
+ const reason = err instanceof Error ? err.message : String(err);
48
+ console.warn(`[app-loader] Skipping module "${app.name}": ${reason}. ` +
49
+ `Its tools and widgets will not be available.`);
50
+ skipped.push({ app, reason });
51
+ }
52
+ }
53
+ return { loaded, skipped };
54
+ }
55
+ //# sourceMappingURL=app-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-loader.js","sourceRoot":"","sources":["../../src/registry/app-loader.ts"],"names":[],"mappings":"AAwBA;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAqB,EACrB,YAA0B,EAC1B,cAA8B,EAC9B,UAA2B,EAAE;IAE7B,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IAC3C,MAAM,MAAM,GAAoB,EAAE,CAAA;IAClC,MAAM,OAAO,GAAkD,EAAE,CAAA;IAEjE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,yEAAyE;YACz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AG,CAAC,IAAI,MAAM,MAAM,IAAI;gBACvD,8CAA8C,CACjD,CAAA;YACD,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AAC5B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { PipelineStepDefinition } from "../types/step.js";
2
+ export interface KeyContract {
3
+ key: string;
4
+ producedBy: string[];
5
+ /** Steps that hard-require this key (gate execution on it). */
6
+ consumedBy: string[];
7
+ /**
8
+ * Steps that read this key from `context.keys` opportunistically — e.g. for
9
+ * scoping or filtering — but still run without it. Mirrors
10
+ * `PipelineStepDefinition.optionalKeys`.
11
+ */
12
+ optionallyConsumedBy: string[];
13
+ }
14
+ export declare class StepRegistry {
15
+ private steps;
16
+ register(step: PipelineStepDefinition): void;
17
+ get(stepId: string): PipelineStepDefinition | undefined;
18
+ /**
19
+ * Remove a previously-registered step. Used to roll back a partially loaded
20
+ * module when isolating a collision (see `loadApps`); a no-op for
21
+ * unknown ids.
22
+ */
23
+ unregister(stepId: string): void;
24
+ getAll(): PipelineStepDefinition[];
25
+ getKeyContracts(): KeyContract[];
26
+ }
27
+ //# sourceMappingURL=step-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-registry.d.ts","sourceRoot":"","sources":["../../src/registry/step-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAE9D,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,EAAE,CAAA;CAC/B;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAA4C;IAEzD,QAAQ,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI;IAO5C,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAIvD;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIhC,MAAM,IAAI,sBAAsB,EAAE;IAIlC,eAAe,IAAI,WAAW,EAAE;CA4BjC"}
@@ -0,0 +1,53 @@
1
+ export class StepRegistry {
2
+ steps = new Map();
3
+ register(step) {
4
+ if (this.steps.has(step.id)) {
5
+ throw new Error(`Step ID collision: "${step.id}" is already registered`);
6
+ }
7
+ this.steps.set(step.id, step);
8
+ }
9
+ get(stepId) {
10
+ return this.steps.get(stepId);
11
+ }
12
+ /**
13
+ * Remove a previously-registered step. Used to roll back a partially loaded
14
+ * module when isolating a collision (see `loadApps`); a no-op for
15
+ * unknown ids.
16
+ */
17
+ unregister(stepId) {
18
+ this.steps.delete(stepId);
19
+ }
20
+ getAll() {
21
+ return [...this.steps.values()];
22
+ }
23
+ getKeyContracts() {
24
+ const producers = new Map();
25
+ const consumers = new Map();
26
+ const optionalConsumers = new Map();
27
+ for (const step of this.steps.values()) {
28
+ for (const key of step.produces) {
29
+ if (!producers.has(key))
30
+ producers.set(key, []);
31
+ producers.get(key).push(step.id);
32
+ }
33
+ for (const key of step.requires) {
34
+ if (!consumers.has(key))
35
+ consumers.set(key, []);
36
+ consumers.get(key).push(step.id);
37
+ }
38
+ for (const decl of step.optionalKeys ?? []) {
39
+ if (!optionalConsumers.has(decl.key))
40
+ optionalConsumers.set(decl.key, []);
41
+ optionalConsumers.get(decl.key).push(step.id);
42
+ }
43
+ }
44
+ const allKeys = new Set([...producers.keys(), ...consumers.keys(), ...optionalConsumers.keys()]);
45
+ return [...allKeys].map((key) => ({
46
+ key,
47
+ producedBy: producers.get(key) ?? [],
48
+ consumedBy: consumers.get(key) ?? [],
49
+ optionallyConsumedBy: optionalConsumers.get(key) ?? [],
50
+ }));
51
+ }
52
+ }
53
+ //# sourceMappingURL=step-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-registry.js","sourceRoot":"","sources":["../../src/registry/step-registry.ts"],"names":[],"mappings":"AAeA,MAAM,OAAO,YAAY;IACf,KAAK,GAAG,IAAI,GAAG,EAAkC,CAAA;IAEzD,QAAQ,CAAC,IAA4B;QACnC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,EAAE,yBAAyB,CAAC,CAAA;QAC1E,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IAC/B,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,MAAc;QACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IACjC,CAAC;IAED,eAAe;QACb,MAAM,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAA;QAC7C,MAAM,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAA;QAC7C,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAoB,CAAA;QAErD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC;oBAAE,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;gBAC/C,SAAS,CAAC,GAAG,C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1,15 @@
1
+ import type { WidgetDefinition } from "../types/widget.js";
2
+ export declare class WidgetRegistry {
3
+ private widgets;
4
+ register(widget: WidgetDefinition): void;
5
+ get(widgetId: string): WidgetDefinition | undefined;
6
+ /**
7
+ * Remove a previously-registered widget. Used to roll back a partially
8
+ * loaded module when isolating a collision (see `loadApps`); a
9
+ * no-op for unknown ids.
10
+ */
11
+ unregister(widgetId: string): void;
12
+ findByRequiredKeys(availableKeys: string[]): WidgetDefinition[];
13
+ getAll(): WidgetDefinition[];
14
+ }
15
+ //# sourceMappingURL=widget-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-registry.d.ts","sourceRoot":"","sources":["../../src/registry/widget-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAsC;IAErD,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAOxC,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAInD;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIlC,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE;IAK/D,MAAM,IAAI,gBAAgB,EAAE;CAG7B"}
@@ -0,0 +1,28 @@
1
+ export class WidgetRegistry {
2
+ widgets = new Map();
3
+ register(widget) {
4
+ if (this.widgets.has(widget.id)) {
5
+ throw new Error(`Widget ID collision: "${widget.id}" is already registered`);
6
+ }
7
+ this.widgets.set(widget.id, widget);
8
+ }
9
+ get(widgetId) {
10
+ return this.widgets.get(widgetId);
11
+ }
12
+ /**
13
+ * Remove a previously-registered widget. Used to roll back a partially
14
+ * loaded module when isolating a collision (see `loadApps`); a
15
+ * no-op for unknown ids.
16
+ */
17
+ unregister(widgetId) {
18
+ this.widgets.delete(widgetId);
19
+ }
20
+ findByRequiredKeys(availableKeys) {
21
+ const keySet = new Set(availableKeys);
22
+ return [...this.widgets.values()].filter((w) => w.requires.every((key) => keySet.has(key)));
23
+ }
24
+ getAll() {
25
+ return [...this.widgets.values()];
26
+ }
27
+ }
28
+ //# sourceMappingURL=widget-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-registry.js","sourceRoot":"","sources":["../../src/registry/widget-registry.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IACjB,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAA;IAErD,QAAQ,CAAC,MAAwB;QAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,EAAE,yBAAyB,CAAC,CAAA;QAC9E,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IACrC,CAAC;IAED,GAAG,CAAC,QAAgB;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,QAAgB;QACzB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC;IAED,kBAAkB,CAAC,aAAuB;QACxC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAA;QACrC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC7F,CAAC;IAED,MAAM;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACnC,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import type { RestClient, RestClientConfig } from "./types.js";
2
+ export declare function createRestClient(config: RestClientConfig): RestClient;
3
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/rest/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,UAAU,EACV,gBAAgB,EAEjB,MAAM,YAAY,CAAA;AAcnB,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAmErE"}