@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
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @miragon/mcp-toolkit-core
2
+
3
+ Framework runtime for MCP servers: plugin contract, step/widget registries,
4
+ pipeline executor, render-view helpers.
5
+
6
+ ## Install
7
+
8
+ Published to the public npm registry under the `@miragon` scope — no `.npmrc`
9
+ or token needed.
10
+
11
+ ```sh
12
+ pnpm add @miragon/mcp-toolkit-core @modelcontextprotocol/sdk@1.29.0 mcp-use@1.34.1 zod@4.4.3
13
+ ```
14
+
15
+ Peer versions are pinned exactly — install the versions above.
16
+
17
+ ## Import paths
18
+
19
+ | Subpath | Key exports | Constraint |
20
+ | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
21
+ | `@miragon/mcp-toolkit-core` | `executePipeline`, `renderView`, `buildSingleWidgetView`, `buildComposedView`, `StepRegistry`, `WidgetRegistry`, `uiMeta`, types | Browser-safe: no `mcp-use/server`, no `node:*`. The barrel widget bundles import from. |
22
+ | `…-core/tools` | `createFrameworkApp`, `createToolRegistrar`, `createWidgetToolRegistrar`, `registerFrameworkTools`, dashboard-store impls | Server-only — imports `mcp-use/server`. Keep out of browser bundles. |
23
+ | `…-core/rest` | `createRestClient`, `createRestTool`, `RestError` | REST tool helpers; register the resulting `ToolConfig` via `createToolRegistrar` from `/tools`. |
24
+
25
+ `createFrameworkApp` / `createToolRegistrar` live **only** in
26
+ `@miragon/mcp-toolkit-core/tools` — never in the root barrel.
27
+
28
+ ## Links
29
+
30
+ - [API reference](https://github.com/Miragon/mcp-toolkit/blob/main/docs/reference/api-core.md)
31
+ - [Getting started](https://github.com/Miragon/mcp-toolkit/blob/main/docs/getting-started.md)
32
+ - [Starter template](https://github.com/Miragon/mcp-toolkit-starter) — "Use this template" for a new server project
@@ -0,0 +1,5 @@
1
+ import type { PipelineConfig } from "../types/pipeline.js";
2
+ import type { ValidationResult } from "../types/config.js";
3
+ import type { StepRegistry } from "../registry/step-registry.js";
4
+ export declare function validatePipeline(config: PipelineConfig, registry: StepRegistry, initialKeys?: string[]): ValidationResult;
5
+ //# sourceMappingURL=context-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["../../src/engine/context-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAEhE,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,YAAY,EACtB,WAAW,CAAC,EAAE,MAAM,EAAE,GACrB,gBAAgB,CAwBlB"}
@@ -0,0 +1,22 @@
1
+ export function validatePipeline(config, registry, initialKeys) {
2
+ const availableKeys = new Set(initialKeys ?? []);
3
+ const issues = [];
4
+ for (const ref of config.steps ?? []) {
5
+ const stepDef = registry.get(ref.step);
6
+ if (!stepDef) {
7
+ if (!ref.optional)
8
+ issues.push(`Step "${ref.step}" not registered`);
9
+ continue;
10
+ }
11
+ for (const key of stepDef.requires) {
12
+ if (!availableKeys.has(key)) {
13
+ issues.push(`Step "${ref.id}" requires key "${key}" but no earlier step produces it`);
14
+ }
15
+ }
16
+ for (const key of stepDef.produces) {
17
+ availableKeys.add(key);
18
+ }
19
+ }
20
+ return { valid: issues.length === 0, issues, availableKeys: [...availableKeys] };
21
+ }
22
+ //# sourceMappingURL=context-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-builder.js","sourceRoot":"","sources":["../../src/engine/context-builder.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,gBAAgB,CAC9B,MAAsB,EACtB,QAAsB,EACtB,WAAsB;IAEtB,MAAM,aAAa,GAAG,IAAI,GAAG,CAAS,WAAW,IAAI,EAAE,CAAC,CAAA;IACxD,MAAM,MAAM,GAAa,EAAE,CAAA;IAE3B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEtC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,QAAQ;gBAAE,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,kBAAkB,CAAC,CAAA;YACnE,SAAQ;QACV,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACnC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5B,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,mBAAmB,GAAG,mCAAmC,CAAC,CAAA;YACvF,CAAC;QACH,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACnC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAA;AAClF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { PipelineContext } from "../types/context.js";
2
+ import type { PipelineConfig } from "../types/pipeline.js";
3
+ import type { StepRegistry } from "../registry/step-registry.js";
4
+ /**
5
+ * Per-request context threaded into steps. Currently only carries the
6
+ * calling user's id, which the executor uses to pre-bind a user-scoped
7
+ * `callTool` closure on the step's `appConfig` so step code stays
8
+ * synchronous and userId-free.
9
+ */
10
+ export interface PipelineExecutionContext {
11
+ userId?: string;
12
+ }
13
+ export interface ExecutePipelineOptions {
14
+ config: PipelineConfig;
15
+ initialKeys: Record<string, unknown>;
16
+ registry: StepRegistry;
17
+ appConfigs?: Record<string, unknown>;
18
+ ctx?: PipelineExecutionContext;
19
+ }
20
+ export declare function executePipeline(options: ExecutePipelineOptions): Promise<PipelineContext>;
21
+ //# sourceMappingURL=pipeline-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-executor.d.ts","sourceRoot":"","sources":["../../src/engine/pipeline-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AA2BD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,cAAc,CAAA;IACtB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,QAAQ,EAAE,YAAY,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,GAAG,CAAC,EAAE,wBAAwB,CAAA;CAC/B;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC,CAwD/F"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * If the step's appConfig contains a `callTool` function (a closure the
3
+ * plugin injects via `AppPlugin.appConfig`, e.g. a typed `callTool` bound to
4
+ * the module's own store or client), rewrap it so the step-facing call
5
+ * signature is `(name, args)` while the underlying closure receives the
6
+ * current `{ userId }` via a hidden 3rd argument — steps stay synchronous
7
+ * and userId-free while the closure can still scope data per user.
8
+ * All other keys pass through untouched.
9
+ */
10
+ function bindAppConfig(appConfig, ctx) {
11
+ if (!appConfig || typeof appConfig !== "object")
12
+ return appConfig;
13
+ const cfg = appConfig;
14
+ const callTool = cfg.callTool;
15
+ if (typeof callTool !== "function")
16
+ return appConfig;
17
+ const raw = callTool;
18
+ return {
19
+ ...cfg,
20
+ callTool: (name, args) => raw(name, args, ctx),
21
+ };
22
+ }
23
+ export async function executePipeline(options) {
24
+ const { config, initialKeys, registry, appConfigs, ctx } = options;
25
+ const context = {
26
+ steps: {},
27
+ keys: { ...initialKeys },
28
+ errors: [],
29
+ };
30
+ for (const ref of config.steps ?? []) {
31
+ const stepDef = registry.get(ref.step);
32
+ if (!stepDef) {
33
+ if (ref.optional)
34
+ continue;
35
+ context.errors.push({ stepId: ref.id, reason: `Step "${ref.step}" not registered` });
36
+ continue;
37
+ }
38
+ const missingKeys = stepDef.requires.filter((key) => !(key in context.keys));
39
+ if (missingKeys.length > 0) {
40
+ if (ref.optional)
41
+ continue;
42
+ context.errors.push({
43
+ stepId: ref.id,
44
+ reason: `Missing required keys: ${missingKeys.join(", ")}`,
45
+ });
46
+ continue;
47
+ }
48
+ try {
49
+ const colon = ref.step.indexOf(":");
50
+ const appName = colon >= 0 ? ref.step.slice(0, colon) : ref.step;
51
+ const rawConfig = appConfigs?.[appName] ?? {};
52
+ const appConfig = bindAppConfig(rawConfig, ctx);
53
+ const output = await stepDef.execute(context, appConfig);
54
+ const result = { ...output, _dataType: stepDef.dataType };
55
+ context.steps[ref.id] = result;
56
+ // Merge produced keys, but skip `undefined` values. The downstream
57
+ // `requires` gate below tests `key in context.keys`, so writing an
58
+ // `undefined` (e.g. an `outputMapping` dot-path that resolved to nothing
59
+ // because the upstream tool returned an unexpected shape) would make the
60
+ // key look "present" and let a dependent step run against missing data.
61
+ // Dropping undefineds keeps the gate honest — the dependent step is
62
+ // skipped (optional) or reported as missing-keys instead of silently
63
+ // executing with `undefined` inputs.
64
+ for (const [key, value] of Object.entries(result.keys)) {
65
+ if (value !== undefined)
66
+ context.keys[key] = value;
67
+ }
68
+ }
69
+ catch (err) {
70
+ if (ref.optional)
71
+ continue;
72
+ context.errors.push({
73
+ stepId: ref.id,
74
+ reason: err instanceof Error ? err.message : String(err),
75
+ });
76
+ }
77
+ }
78
+ return context;
79
+ }
80
+ //# sourceMappingURL=pipeline-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-executor.js","sourceRoot":"","sources":["../../src/engine/pipeline-executor.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,SAAS,aAAa,CAAC,SAAkB,EAAE,GAAyC;IAClF,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IACjE,MAAM,GAAG,GAAG,SAAoC,CAAA;IAChD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAA;IAC7B,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,OAAO,SAAS,CAAA;IACpD,MAAM,GAAG,GAAG,QAIS,CAAA;IACrB,OAAO;QACL,GAAG,GAAG;QACN,QAAQ,EAAE,CAAC,IAAY,EAAE,IAAa,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC;KAChE,CAAA;AACH,CAAC;AAUD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAA+B;IACnE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;IAClE,MAAM,OAAO,GAAoB;Q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U,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;YAC7C,MAAM,SAAS,GAAG,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;YAC/C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;YACxD,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAA;YACzD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAA;YAC9B,mEAAmE;YACnE,mEAAmE;YACnE,yEAAyE;YACzE,yEAAyE;YACzE,wEAAwE;YACxE,oEAAoE;YACpE,qEAAqE;YACrE,qCAAqC;YACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvD,IAAI,KAAK,KAAK,SAAS;oBAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;YACpD,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,CAAC,QAAQ;gBAAE,SAAQ;YAC1B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;gBAClB,MAAM,EAAE,GAAG,CAAC,EAAE;gBACd,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACzD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A parsed active-modules entry: the module `name` plus an optional
3
+ * `qualifier` that selects a named instance/variant of that module (the part
4
+ * after the first colon in a `"name:qualifier"` token, e.g. `"camunda7:prod"`).
5
+ */
6
+ export interface ActiveModuleSelection {
7
+ name: string;
8
+ qualifier?: string;
9
+ }
10
+ /**
11
+ * Parses a `MIRANUM_ACTIVE_MODULES`-style env value into structured
12
+ * selections. Empty / unset / `"all"` → every known module (no qualifier). A
13
+ * comma-separated list narrows to the matching subset; each token may carry a
14
+ * `:qualifier` suffix to pick a named instance of that module. Unknown module
15
+ * names log a warning and are dropped so a typo doesn't fail boot for every
16
+ * other module.
17
+ *
18
+ * The colon is split on first occurrence only, so qualifiers may themselves
19
+ * contain colons (e.g. a URL-shaped qualifier). Empty segments produced by
20
+ * stray commas are ignored without warning.
21
+ */
22
+ export declare function parseActiveModules(envValue: string | undefined, known: string[]): ActiveModuleSelection[];
23
+ /**
24
+ * Resolves the active-modules list to the matching module *names*, dropping
25
+ * any `:qualifier` suffixes. Thin wrapper over {@link parseActiveModules} for
26
+ * callers that only need the set of enabled modules (the common case). Empty /
27
+ * unset / `"all"` → every known module; unknown entries warn and are skipped.
28
+ */
29
+ export declare function resolveActiveModules(envValue: string | undefined, known: string[]): string[];
30
+ //# sourceMappingURL=active-modules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active-modules.d.ts","sourceRoot":"","sources":["../../src/framework/active-modules.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,EAAE,GACd,qBAAqB,EAAE,CAuBzB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAE5F"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Parses a `MIRANUM_ACTIVE_MODULES`-style env value into structured
3
+ * selections. Empty / unset / `"all"` → every known module (no qualifier). A
4
+ * comma-separated list narrows to the matching subset; each token may carry a
5
+ * `:qualifier` suffix to pick a named instance of that module. Unknown module
6
+ * names log a warning and are dropped so a typo doesn't fail boot for every
7
+ * other module.
8
+ *
9
+ * The colon is split on first occurrence only, so qualifiers may themselves
10
+ * contain colons (e.g. a URL-shaped qualifier). Empty segments produced by
11
+ * stray commas are ignored without warning.
12
+ */
13
+ export function parseActiveModules(envValue, known) {
14
+ const trimmed = envValue?.trim();
15
+ if (!trimmed || trimmed === "all")
16
+ return known.map((name) => ({ name }));
17
+ const tokens = trimmed
18
+ .split(",")
19
+ .map((s) => s.trim())
20
+ .filter(Boolean);
21
+ const knownSet = new Set(known);
22
+ const result = [];
23
+ for (const token of tokens) {
24
+ const colon = token.indexOf(":");
25
+ const name = colon === -1 ? token : token.slice(0, colon);
26
+ const qualifier = colon === -1 ? undefined : token.slice(colon + 1).trim() || undefined;
27
+ if (!knownSet.has(name)) {
28
+ console.warn(`[mcp-toolkit] unknown module "${name}" in active-modules list — skipping`);
29
+ continue;
30
+ }
31
+ result.push(qualifier === undefined ? { name } : { name, qualifier });
32
+ }
33
+ return result;
34
+ }
35
+ /**
36
+ * Resolves the active-modules list to the matching module *names*, dropping
37
+ * any `:qualifier` suffixes. Thin wrapper over {@link parseActiveModules} for
38
+ * callers that only need the set of enabled modules (the common case). Empty /
39
+ * unset / `"all"` → every known module; unknown entries warn and are skipped.
40
+ */
41
+ export function resolveActiveModules(envValue, known) {
42
+ return parseActiveModules(envValue, known).map((selection) => selection.name);
43
+ }
44
+ //# sourceMappingURL=active-modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active-modules.js","sourceRoot":"","sources":["../../src/framework/active-modules.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAA4B,EAC5B,KAAe;IAEf,MAAM,OAAO,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAA;IAChC,IAAI,CAAC,OAAO,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AC,QAA4B,EAAE,KAAe;IAChF,OAAO,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AAC/E,CAAC"}
@@ -0,0 +1,148 @@
1
+ import { type PipelineExecutionContext } from "../engine/pipeline-executor.js";
2
+ import type { StepRegistry } from "../registry/step-registry.js";
3
+ import type { WidgetRegistry } from "../registry/widget-registry.js";
4
+ import type { PipelineStepRef } from "../types/pipeline.js";
5
+ export interface CatalogueInput {
6
+ keys?: Record<string, unknown>;
7
+ steps?: PipelineStepRef[];
8
+ }
9
+ /**
10
+ * A widget whose `requires` are satisfied by the keys the pipeline
11
+ * exposes. The builder UI renders this as the palette.
12
+ */
13
+ export interface ReachableWidget {
14
+ id: string;
15
+ app: string;
16
+ requires: string[];
17
+ size: string;
18
+ /**
19
+ * JSON Schema mirrored from `WidgetDefinition.propsSchema`. Drives the
20
+ * builder's per-cell "Configure" form so a user can author scoped
21
+ * widget instances (e.g. one tab per `processDefinitionKey`) without
22
+ * dropping into raw JSON. Absent when the widget takes no props.
23
+ */
24
+ propsSchema?: Record<string, unknown>;
25
+ }
26
+ /**
27
+ * A widget that is registered but not currently satisfiable. Surfaces in
28
+ * the builder as "unreachable" with a hint about which keys are still
29
+ * missing so users know what to seed or which step to add.
30
+ */
31
+ export interface UnreachableWidget {
32
+ id: string;
33
+ app: string;
34
+ requires: string[];
35
+ size: string;
36
+ missingKeys: string[];
37
+ propsSchema?: Record<string, unknown>;
38
+ }
39
+ /**
40
+ * Manifest entry for a registered pipeline step. The builder uses this
41
+ * for its step-picker dropdown.
42
+ */
43
+ export interface AvailableStep {
44
+ id: string;
45
+ app: string;
46
+ dataType: string;
47
+ requires: string[];
48
+ produces: string[];
49
+ }
50
+ /**
51
+ * Every key the framework could see — produced by a step, consumed by a
52
+ * step, or required by a widget — with attribution and a flag for
53
+ * whether it currently lives in the pipeline context.
54
+ */
55
+ export interface KeyCatalogEntry {
56
+ key: string;
57
+ producedBySteps: string[];
58
+ consumedBySteps: string[];
59
+ consumedByWidgets: string[];
60
+ inContext: boolean;
61
+ }
62
+ export interface CataloguePayload {
63
+ context: {
64
+ keys: Record<string, unknown>;
65
+ stepIds: string[];
66
+ stepData: Record<string, {
67
+ data: unknown;
68
+ keys: Record<string, unknown>;
69
+ _app: string;
70
+ _dataType: string;
71
+ }>;
72
+ errors: {
73
+ stepId: string;
74
+ reason: string;
75
+ }[];
76
+ };
77
+ reachableWidgets: ReachableWidget[];
78
+ unreachableWidgets: UnreachableWidget[];
79
+ availableSteps: AvailableStep[];
80
+ keyCatalog: KeyCatalogEntry[];
81
+ /**
82
+ * Pipeline validation issues from `validatePipeline`. The catalogue is
83
+ * fail-soft (it still returns a usable palette even when the pipeline can't
84
+ * fully resolve), so these are surfaced here structurally — not just in the
85
+ * text summary — for the builder to show before the user commits. The same
86
+ * pipeline would fail *hard* in `render-view`, so seeing these issues in the
87
+ * builder warns the user the render path wouldn't run as configured.
88
+ */
89
+ validationIssues: string[];
90
+ }
91
+ export interface CatalogueOptions {
92
+ input: CatalogueInput;
93
+ stepRegistry: StepRegistry;
94
+ widgetRegistry: WidgetRegistry;
95
+ appConfigs?: Record<string, unknown>;
96
+ /**
97
+ * Per-request context (currently: the calling userId). Mirrors
98
+ * {@link RenderViewOptions.ctx}.
99
+ */
100
+ ctx?: PipelineExecutionContext;
101
+ }
102
+ /**
103
+ * Computes everything the in-iframe LayoutBuilder needs to know:
104
+ * the current pipeline context, the palette of reachable widgets, the
105
+ * list of unreachable widgets with the keys they're missing, the full
106
+ * step catalogue, and the key catalogue with producer/consumer
107
+ * attribution.
108
+ *
109
+ * Intentionally NOT exposed to the LLM — the matching tool registrar
110
+ * tags this with `visibility: ["app"]` so it never lands in the LLM's
111
+ * tool-call surface. The LLM uses `render-view` for its work; the user
112
+ * (via the iframe) calls this tool whenever they switch into Build mode
113
+ * or edit keys/steps.
114
+ *
115
+ * Validation issues from `validatePipeline` are surfaced in the text
116
+ * summary but don't abort — the catalogue is still useful even when
117
+ * the pipeline can't fully resolve.
118
+ */
119
+ export declare function getBuilderCatalogue(options: CatalogueOptions): Promise<{
120
+ content: {
121
+ type: "text";
122
+ text: string;
123
+ }[];
124
+ structuredContent: {
125
+ context: {
126
+ keys: Record<string, unknown>;
127
+ stepIds: string[];
128
+ stepData: {
129
+ [k: string]: {
130
+ data: unknown;
131
+ keys: Record<string, unknown>;
132
+ _app: string;
133
+ _dataType: string;
134
+ };
135
+ };
136
+ errors: {
137
+ stepId: string;
138
+ reason: string;
139
+ }[];
140
+ };
141
+ reachableWidgets: ReachableWidget[];
142
+ unreachableWidgets: UnreachableWidget[];
143
+ availableSteps: AvailableStep[];
144
+ keyCatalog: KeyCatalogEntry[];
145
+ validationIssues: string[];
146
+ };
147
+ }>;
148
+ //# sourceMappingURL=catalogue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogue.d.ts","sourceRoot":"","sources":["../../src/framework/catalogue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AAE/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,KAAK,CAAC,EAAE,eAAe,EAAE,CAAA;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;OAKG;IACH,WAAW,CAAC,EAAE,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,CAAA;IACnC,kBAAkB,EAAE,iBAAiB,EAAE,CAAA;IACvC,cAAc,EAAE,aAAa,EAAE,CAAA;IAC/B,UAAU,EAAE,eAAe,EAAE,CAAA;IAC7B;;;;;;;OAOG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,cAAc,CAAA;IACrB,YAAY,EAAE,YAAY,CAAA;IAC1B,cAAc,EAAE,cAAc,CAAA;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC;;;OAGG;IACH,GAAG,CAAC,EAAE,wBAAwB,CAAA;CAC/B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiHlE"}
@@ -0,0 +1,132 @@
1
+ import { executePipeline } from "../engine/pipeline-executor.js";
2
+ import { validatePipeline } from "../engine/context-builder.js";
3
+ /**
4
+ * Computes everything the in-iframe LayoutBuilder needs to know:
5
+ * the current pipeline context, the palette of reachable widgets, the
6
+ * list of unreachable widgets with the keys they're missing, the full
7
+ * step catalogue, and the key catalogue with producer/consumer
8
+ * attribution.
9
+ *
10
+ * Intentionally NOT exposed to the LLM — the matching tool registrar
11
+ * tags this with `visibility: ["app"]` so it never lands in the LLM's
12
+ * tool-call surface. The LLM uses `render-view` for its work; the user
13
+ * (via the iframe) calls this tool whenever they switch into Build mode
14
+ * or edit keys/steps.
15
+ *
16
+ * Validation issues from `validatePipeline` are surfaced in the text
17
+ * summary but don't abort — the catalogue is still useful even when
18
+ * the pipeline can't fully resolve.
19
+ */
20
+ export async function getBuilderCatalogue(options) {
21
+ const { input, stepRegistry, widgetRegistry, appConfigs, ctx } = options;
22
+ const initialKeys = input.keys ?? {};
23
+ const pipelineConfig = { steps: input.steps };
24
+ const validation = input.steps?.length
25
+ ? validatePipeline(pipelineConfig, stepRegistry, Object.keys(initialKeys))
26
+ : { valid: true, issues: [], availableKeys: Object.keys(initialKeys) };
27
+ const context = await executePipeline({
28
+ config: pipelineConfig,
29
+ initialKeys,
30
+ registry: stepRegistry,
31
+ appConfigs,
32
+ ctx,
33
+ });
34
+ const availableKeys = new Set([...validation.availableKeys, ...Object.keys(context.keys)]);
35
+ const allWidgets = widgetRegistry.getAll();
36
+ const reachableDefs = widgetRegistry.findByRequiredKeys([...availableKeys]);
37
+ const reachableIds = new Set(reachableDefs.map((w) => w.id));
38
+ const reachableWidgets = reachableDefs.map((w) => ({
39
+ id: w.id,
40
+ app: appOf(w.id),
41
+ requires: w.requires,
42
+ size: w.size,
43
+ ...(w.propsSchema ? { propsSchema: w.propsSchema } : {}),
44
+ }));
45
+ const unreachableWidgets = allWidgets
46
+ .filter((w) => !reachableIds.has(w.id))
47
+ .map((w) => ({
48
+ id: w.id,
49
+ app: appOf(w.id),
50
+ requires: w.requires,
51
+ size: w.size,
52
+ missingKeys: w.requires.filter((k) => !availableKeys.has(k)),
53
+ ...(w.propsSchema ? { propsSchema: w.propsSchema } : {}),
54
+ }));
55
+ const availableSteps = stepRegistry.getAll().map((s) => ({
56
+ id: s.id,
57
+ app: appOf(s.id),
58
+ dataType: s.dataType,
59
+ requires: s.requires,
60
+ produces: s.produces,
61
+ }));
62
+ const stepContracts = stepRegistry.getKeyContracts();
63
+ const keys = new Set(availableKeys);
64
+ for (const c of stepContracts)
65
+ keys.add(c.key);
66
+ const widgetConsumers = new Map();
67
+ for (const widget of allWidgets) {
68
+ for (const key of widget.requires) {
69
+ keys.add(key);
70
+ const list = widgetConsumers.get(key) ?? [];
71
+ if (!list.includes(widget.id))
72
+ list.push(widget.id);
73
+ widgetConsumers.set(key, list);
74
+ }
75
+ }
76
+ const stepContractsByKey = new Map(stepContracts.map((c) => [c.key, c]));
77
+ const keyCatalog = [...keys]
78
+ .sort((a, b) => a.localeCompare(b))
79
+ .map((key) => {
80
+ const contract = stepContractsByKey.get(key);
81
+ return {
82
+ key,
83
+ producedBySteps: contract?.producedBy ?? [],
84
+ consumedBySteps: contract?.consumedBy ?? [],
85
+ consumedByWidgets: widgetConsumers.get(key) ?? [],
86
+ inContext: availableKeys.has(key),
87
+ };
88
+ });
89
+ const textSummary = [
90
+ `Reachable widgets: ${reachableWidgets.length}`,
91
+ `Keys: ${[...availableKeys].join(", ") || "none"}`,
92
+ validation.issues.length > 0 ? `Pipeline issues: ${validation.issues.join("; ")}` : "",
93
+ context.errors.length > 0
94
+ ? `Step errors: ${context.errors.map((e) => `${e.stepId}: ${e.reason}`).join("; ")}`
95
+ : "",
96
+ ]
97
+ .filter(Boolean)
98
+ .join("\n");
99
+ return {
100
+ content: [{ type: "text", text: textSummary }],
101
+ structuredContent: {
102
+ context: {
103
+ keys: context.keys,
104
+ stepIds: Object.keys(context.steps),
105
+ stepData: Object.fromEntries(Object.entries(context.steps).map(([id, result]) => [
106
+ id,
107
+ {
108
+ data: result.data,
109
+ keys: result.keys,
110
+ _app: result._app,
111
+ _dataType: result._dataType,
112
+ },
113
+ ])),
114
+ errors: context.errors,
115
+ },
116
+ reachableWidgets,
117
+ unreachableWidgets,
118
+ availableSteps,
119
+ keyCatalog,
120
+ validationIssues: validation.issues,
121
+ },
122
+ };
123
+ }
124
+ /**
125
+ * Splits a namespaced id like `"lexoffice:load-invoice"` into the
126
+ * leading namespace. Falls back to the full id when no colon is present.
127
+ */
128
+ function appOf(id) {
129
+ const colon = id.indexOf(":");
130
+ return colon >= 0 ? id.slice(0, colon) : id;
131
+ }
132
+ //# sourceMappingURL=catalogue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogue.js","sourceRoot":"","sources":["../../src/framework/catalogue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAiC,MAAM,gCAAgC,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAwG/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,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