@exaudeus/workrail 0.0.2-beta.0

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 (147) hide show
  1. package/README.md +223 -0
  2. package/dist/application/app.d.ts +32 -0
  3. package/dist/application/app.d.ts.map +1 -0
  4. package/dist/application/app.js +133 -0
  5. package/dist/application/app.js.map +1 -0
  6. package/dist/application/services/validation-engine.d.ts +102 -0
  7. package/dist/application/services/validation-engine.d.ts.map +1 -0
  8. package/dist/application/services/validation-engine.js +293 -0
  9. package/dist/application/services/validation-engine.js.map +1 -0
  10. package/dist/application/services/workflow-service.d.ts +47 -0
  11. package/dist/application/services/workflow-service.d.ts.map +1 -0
  12. package/dist/application/services/workflow-service.js +80 -0
  13. package/dist/application/services/workflow-service.js.map +1 -0
  14. package/dist/application/use-cases/get-next-step.d.ts +22 -0
  15. package/dist/application/use-cases/get-next-step.d.ts.map +1 -0
  16. package/dist/application/use-cases/get-next-step.js +21 -0
  17. package/dist/application/use-cases/get-next-step.js.map +1 -0
  18. package/dist/application/use-cases/get-workflow.d.ts +13 -0
  19. package/dist/application/use-cases/get-workflow.d.ts.map +1 -0
  20. package/dist/application/use-cases/get-workflow.js +26 -0
  21. package/dist/application/use-cases/get-workflow.js.map +1 -0
  22. package/dist/application/use-cases/list-workflows.d.ts +13 -0
  23. package/dist/application/use-cases/list-workflows.d.ts.map +1 -0
  24. package/dist/application/use-cases/list-workflows.js +21 -0
  25. package/dist/application/use-cases/list-workflows.js.map +1 -0
  26. package/dist/application/use-cases/validate-step-output.d.ts +20 -0
  27. package/dist/application/use-cases/validate-step-output.d.ts.map +1 -0
  28. package/dist/application/use-cases/validate-step-output.js +21 -0
  29. package/dist/application/use-cases/validate-step-output.js.map +1 -0
  30. package/dist/application/validation.d.ts +6 -0
  31. package/dist/application/validation.d.ts.map +1 -0
  32. package/dist/application/validation.js +19 -0
  33. package/dist/application/validation.js.map +1 -0
  34. package/dist/cli.d.ts +3 -0
  35. package/dist/cli.d.ts.map +1 -0
  36. package/dist/cli.js +106 -0
  37. package/dist/cli.js.map +1 -0
  38. package/dist/container.d.ts +22 -0
  39. package/dist/container.d.ts.map +1 -0
  40. package/dist/container.js +25 -0
  41. package/dist/container.js.map +1 -0
  42. package/dist/core/error-handler.d.ts +93 -0
  43. package/dist/core/error-handler.d.ts.map +1 -0
  44. package/dist/core/error-handler.js +336 -0
  45. package/dist/core/error-handler.js.map +1 -0
  46. package/dist/domain/index.d.ts +3 -0
  47. package/dist/domain/index.d.ts.map +1 -0
  48. package/dist/domain/index.js +6 -0
  49. package/dist/domain/index.js.map +1 -0
  50. package/dist/index.d.ts +3 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +30 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/infrastructure/index.d.ts +3 -0
  55. package/dist/infrastructure/index.d.ts.map +1 -0
  56. package/dist/infrastructure/index.js +6 -0
  57. package/dist/infrastructure/index.js.map +1 -0
  58. package/dist/infrastructure/rpc/handler.d.ts +26 -0
  59. package/dist/infrastructure/rpc/handler.d.ts.map +1 -0
  60. package/dist/infrastructure/rpc/handler.js +91 -0
  61. package/dist/infrastructure/rpc/handler.js.map +1 -0
  62. package/dist/infrastructure/rpc/index.d.ts +2 -0
  63. package/dist/infrastructure/rpc/index.d.ts.map +1 -0
  64. package/dist/infrastructure/rpc/index.js +5 -0
  65. package/dist/infrastructure/rpc/index.js.map +1 -0
  66. package/dist/infrastructure/rpc/server.d.ts +4 -0
  67. package/dist/infrastructure/rpc/server.d.ts.map +1 -0
  68. package/dist/infrastructure/rpc/server.js +40 -0
  69. package/dist/infrastructure/rpc/server.js.map +1 -0
  70. package/dist/infrastructure/storage/caching-workflow-storage.d.ts +22 -0
  71. package/dist/infrastructure/storage/caching-workflow-storage.d.ts.map +1 -0
  72. package/dist/infrastructure/storage/caching-workflow-storage.js +61 -0
  73. package/dist/infrastructure/storage/caching-workflow-storage.js.map +1 -0
  74. package/dist/infrastructure/storage/file-workflow-storage.d.ts +56 -0
  75. package/dist/infrastructure/storage/file-workflow-storage.d.ts.map +1 -0
  76. package/dist/infrastructure/storage/file-workflow-storage.js +206 -0
  77. package/dist/infrastructure/storage/file-workflow-storage.js.map +1 -0
  78. package/dist/infrastructure/storage/in-memory-storage.d.ts +17 -0
  79. package/dist/infrastructure/storage/in-memory-storage.d.ts.map +1 -0
  80. package/dist/infrastructure/storage/in-memory-storage.js +43 -0
  81. package/dist/infrastructure/storage/in-memory-storage.js.map +1 -0
  82. package/dist/infrastructure/storage/index.d.ts +6 -0
  83. package/dist/infrastructure/storage/index.d.ts.map +1 -0
  84. package/dist/infrastructure/storage/index.js +9 -0
  85. package/dist/infrastructure/storage/index.js.map +1 -0
  86. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts +23 -0
  87. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts.map +1 -0
  88. package/dist/infrastructure/storage/schema-validating-workflow-storage.js +70 -0
  89. package/dist/infrastructure/storage/schema-validating-workflow-storage.js.map +1 -0
  90. package/dist/infrastructure/storage/storage.d.ts +16 -0
  91. package/dist/infrastructure/storage/storage.d.ts.map +1 -0
  92. package/dist/infrastructure/storage/storage.js +32 -0
  93. package/dist/infrastructure/storage/storage.js.map +1 -0
  94. package/dist/mcp-server-simple.js +391 -0
  95. package/dist/mcp-server.d.ts +3 -0
  96. package/dist/mcp-server.d.ts.map +1 -0
  97. package/dist/mcp-server.js +223 -0
  98. package/dist/mcp-server.js.map +1 -0
  99. package/dist/tools/mcp_initialize.d.ts +3 -0
  100. package/dist/tools/mcp_initialize.d.ts.map +1 -0
  101. package/dist/tools/mcp_initialize.js +52 -0
  102. package/dist/tools/mcp_initialize.js.map +1 -0
  103. package/dist/tools/mcp_shutdown.d.ts +3 -0
  104. package/dist/tools/mcp_shutdown.d.ts.map +1 -0
  105. package/dist/tools/mcp_shutdown.js +11 -0
  106. package/dist/tools/mcp_shutdown.js.map +1 -0
  107. package/dist/tools/mcp_tools_list.d.ts +3 -0
  108. package/dist/tools/mcp_tools_list.d.ts.map +1 -0
  109. package/dist/tools/mcp_tools_list.js +61 -0
  110. package/dist/tools/mcp_tools_list.js.map +1 -0
  111. package/dist/types/mcp-types.d.ts +251 -0
  112. package/dist/types/mcp-types.d.ts.map +1 -0
  113. package/dist/types/mcp-types.js +27 -0
  114. package/dist/types/mcp-types.js.map +1 -0
  115. package/dist/types/server.d.ts +5 -0
  116. package/dist/types/server.d.ts.map +1 -0
  117. package/dist/types/server.js +3 -0
  118. package/dist/types/server.js.map +1 -0
  119. package/dist/types/storage.d.ts +27 -0
  120. package/dist/types/storage.d.ts.map +1 -0
  121. package/dist/types/storage.js +6 -0
  122. package/dist/types/storage.js.map +1 -0
  123. package/dist/types/workflow-types.d.ts +251 -0
  124. package/dist/types/workflow-types.d.ts.map +1 -0
  125. package/dist/types/workflow-types.js +5 -0
  126. package/dist/types/workflow-types.js.map +1 -0
  127. package/dist/utils/condition-evaluator.d.ts +32 -0
  128. package/dist/utils/condition-evaluator.d.ts.map +1 -0
  129. package/dist/utils/condition-evaluator.js +105 -0
  130. package/dist/utils/condition-evaluator.js.map +1 -0
  131. package/dist/utils/config.d.ts +195 -0
  132. package/dist/utils/config.d.ts.map +1 -0
  133. package/dist/utils/config.js +332 -0
  134. package/dist/utils/config.js.map +1 -0
  135. package/dist/validation/request-validator.d.ts +9 -0
  136. package/dist/validation/request-validator.d.ts.map +1 -0
  137. package/dist/validation/request-validator.js +32 -0
  138. package/dist/validation/request-validator.js.map +1 -0
  139. package/dist/validation/response-validator.d.ts +9 -0
  140. package/dist/validation/response-validator.d.ts.map +1 -0
  141. package/dist/validation/response-validator.js +83 -0
  142. package/dist/validation/response-validator.js.map +1 -0
  143. package/dist/validation/schemas.d.ts +6 -0
  144. package/dist/validation/schemas.d.ts.map +1 -0
  145. package/dist/validation/schemas.js +52 -0
  146. package/dist/validation/schemas.js.map +1 -0
  147. package/package.json +48 -0
@@ -0,0 +1 @@
1
+ {"version":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AACL,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Workflow, WorkflowSummary } from '../../types/mcp-types';
2
+ import { IWorkflowStorage } from '../../types/storage';
3
+ /**
4
+ * Very lightweight, non-persistent storage implementation for unit tests
5
+ * or ephemeral execution. Workflows are injected at construction time.
6
+ */
7
+ export declare class InMemoryWorkflowStorage implements IWorkflowStorage {
8
+ private workflows;
9
+ constructor(workflows?: Workflow[]);
10
+ /** Replace the internal workflow list (useful for tests). */
11
+ setWorkflows(workflows: Workflow[]): void;
12
+ loadAllWorkflows(): Promise<Workflow[]>;
13
+ getWorkflowById(id: string): Promise<Workflow | null>;
14
+ listWorkflowSummaries(): Promise<WorkflowSummary[]>;
15
+ save(workflow: Workflow): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=in-memory-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-storage.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/storage/in-memory-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAC9D,OAAO,CAAC,SAAS,CAAa;gBAElB,SAAS,GAAE,QAAQ,EAAO;IAItC,6DAA6D;IACtD,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI;IAInC,gBAAgB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIvC,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAIrD,qBAAqB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAUnD,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAQrD"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InMemoryWorkflowStorage = void 0;
4
+ /**
5
+ * Very lightweight, non-persistent storage implementation for unit tests
6
+ * or ephemeral execution. Workflows are injected at construction time.
7
+ */
8
+ class InMemoryWorkflowStorage {
9
+ workflows;
10
+ constructor(workflows = []) {
11
+ this.workflows = [...workflows];
12
+ }
13
+ /** Replace the internal workflow list (useful for tests). */
14
+ setWorkflows(workflows) {
15
+ this.workflows = [...workflows];
16
+ }
17
+ async loadAllWorkflows() {
18
+ return [...this.workflows];
19
+ }
20
+ async getWorkflowById(id) {
21
+ return this.workflows.find((wf) => wf.id === id) || null;
22
+ }
23
+ async listWorkflowSummaries() {
24
+ return this.workflows.map((workflow) => ({
25
+ id: workflow.id,
26
+ name: workflow.name,
27
+ description: workflow.description,
28
+ category: 'default',
29
+ version: workflow.version
30
+ }));
31
+ }
32
+ async save(workflow) {
33
+ const index = this.workflows.findIndex((w) => w.id === workflow.id);
34
+ if (index >= 0) {
35
+ this.workflows[index] = workflow;
36
+ }
37
+ else {
38
+ this.workflows.push(workflow);
39
+ }
40
+ }
41
+ }
42
+ exports.InMemoryWorkflowStorage = InMemoryWorkflowStorage;
43
+ //# sourceMappingURL=in-memory-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-storage.js","sourceRoot":"","sources":["../../../src/infrastructure/storage/in-memory-storage.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH,MAAa,uBAAuB;IAC1B,SAAS,CAAa;IAE9B,YAAY,YAAwB,EAAE;QACpC,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;IAClC,CAAC;IAED,6DAA6D;IACtD,YAAY,CAAC,SAAqB;QACvC,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;IAClC,CAAC;IAEM,KAAK,CAAC,gBAAgB;QAC3B,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,EAAU;QACrC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC;IAC3D,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACvC,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;SAC1B,CAAC,CAAC,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,QAAkB;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpE,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;CACF;AAtCD,0DAsCC"}
@@ -0,0 +1,6 @@
1
+ export * from './storage';
2
+ export * from './file-workflow-storage';
3
+ export * from './in-memory-storage';
4
+ export * from './schema-validating-workflow-storage';
5
+ export * from './caching-workflow-storage';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./storage"), exports);
5
+ tslib_1.__exportStar(require("./file-workflow-storage"), exports);
6
+ tslib_1.__exportStar(require("./in-memory-storage"), exports);
7
+ tslib_1.__exportStar(require("./schema-validating-workflow-storage"), exports);
8
+ tslib_1.__exportStar(require("./caching-workflow-storage"), exports);
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/storage/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,kEAAwC;AACxC,8DAAoC;AACpC,+EAAqD;AACrD,qEAA2C"}
@@ -0,0 +1,23 @@
1
+ import { IWorkflowStorage } from '../../types/storage';
2
+ import { Workflow } from '../../types/mcp-types';
3
+ /**
4
+ * Decorator that filters or throws when underlying storage returns workflows
5
+ * that do not conform to the JSON schema.
6
+ */
7
+ export declare class SchemaValidatingWorkflowStorage implements IWorkflowStorage {
8
+ private readonly inner;
9
+ private validator;
10
+ constructor(inner: IWorkflowStorage);
11
+ private ensureValid;
12
+ loadAllWorkflows(): Promise<Workflow[]>;
13
+ getWorkflowById(id: string): Promise<Workflow | null>;
14
+ listWorkflowSummaries(): Promise<{
15
+ id: string;
16
+ name: string;
17
+ description: string;
18
+ category: string;
19
+ version: string;
20
+ }[]>;
21
+ save?(workflow: Workflow): Promise<void>;
22
+ }
23
+ //# sourceMappingURL=schema-validating-workflow-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-validating-workflow-storage.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/storage/schema-validating-workflow-storage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;;GAGG;AACH,qBAAa,+BAAgC,YAAW,gBAAgB;IAG1D,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,OAAO,CAAC,SAAS,CAAmB;gBAEP,KAAK,EAAE,gBAAgB;IAOpD,OAAO,CAAC,WAAW;IAWb,gBAAgB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAWvC,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAWrD,qBAAqB;;;;;;;IAWrB,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAK/C"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaValidatingWorkflowStorage = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
+ const ajv_1 = tslib_1.__importDefault(require("ajv"));
8
+ const error_handler_1 = require("../../core/error-handler");
9
+ /**
10
+ * Decorator that filters or throws when underlying storage returns workflows
11
+ * that do not conform to the JSON schema.
12
+ */
13
+ class SchemaValidatingWorkflowStorage {
14
+ inner;
15
+ validator;
16
+ constructor(inner) {
17
+ this.inner = inner;
18
+ const schemaPath = path_1.default.resolve(__dirname, '../../../spec/workflow.schema.json');
19
+ const schema = JSON.parse(fs_1.default.readFileSync(schemaPath, 'utf-8'));
20
+ const ajv = new ajv_1.default({ allErrors: true, strict: false });
21
+ this.validator = ajv.compile(schema);
22
+ }
23
+ ensureValid(workflow) {
24
+ const isValid = this.validator(workflow);
25
+ if (!isValid) {
26
+ throw new error_handler_1.InvalidWorkflowError(workflow.id ?? 'unknown', JSON.stringify(this.validator.errors));
27
+ }
28
+ return true;
29
+ }
30
+ async loadAllWorkflows() {
31
+ const raw = await this.inner.loadAllWorkflows();
32
+ return raw.filter((wf) => {
33
+ try {
34
+ return this.ensureValid(wf);
35
+ }
36
+ catch {
37
+ return false; // Skip invalid workflows
38
+ }
39
+ });
40
+ }
41
+ async getWorkflowById(id) {
42
+ const wf = await this.inner.getWorkflowById(id);
43
+ if (!wf)
44
+ return null;
45
+ try {
46
+ this.ensureValid(wf);
47
+ return wf;
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ async listWorkflowSummaries() {
54
+ const workflows = await this.loadAllWorkflows();
55
+ return workflows.map((wf) => ({
56
+ id: wf.id,
57
+ name: wf.name,
58
+ description: wf.description,
59
+ category: 'default',
60
+ version: wf.version
61
+ }));
62
+ }
63
+ async save(workflow) {
64
+ if (typeof this.inner.save === 'function') {
65
+ return this.inner.save(workflow);
66
+ }
67
+ }
68
+ }
69
+ exports.SchemaValidatingWorkflowStorage = SchemaValidatingWorkflowStorage;
70
+ //# sourceMappingURL=schema-validating-workflow-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-validating-workflow-storage.js","sourceRoot":"","sources":["../../../src/infrastructure/storage/schema-validating-workflow-storage.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AACpB,wDAAwB;AACxB,sDAA4C;AAG5C,4DAAgE;AAEhE;;;GAGG;AACH,MAAa,+BAA+B;IAGb;IAFrB,SAAS,CAAmB;IAEpC,YAA6B,KAAuB;QAAvB,UAAK,GAAL,KAAK,CAAkB;QAClD,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,oCAAoC,CAAC,CAAC;QACjF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;QAChE,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC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I,EAAE,EAAE,CAAC,IAAI;YACb,WAAW,EAAE,EAAE,CAAC,WAAW;YAC3B,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,EAAE,CAAC,OAAO;SACpB,CAAC,CAAC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,IAAI,CAAE,QAAkB;QAC5B,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF;AA3DD,0EA2DC"}
@@ -0,0 +1,16 @@
1
+ import { FileWorkflowStorage } from './file-workflow-storage';
2
+ import { SchemaValidatingWorkflowStorage } from './schema-validating-workflow-storage';
3
+ import { CachingWorkflowStorage } from './caching-workflow-storage';
4
+ /**
5
+ * Create the default, production-grade storage stack consisting of:
6
+ * 1. File-system backed storage
7
+ * 2. JSON-Schema validation decorator
8
+ * 3. In-memory TTL cache decorator
9
+ *
10
+ * The function is intentionally side-effect-free – each invocation returns a
11
+ * brand-new, fully-composed instance so that callers can choose whether to
12
+ * share or isolate storage state.
13
+ */
14
+ export declare function createDefaultWorkflowStorage(): CachingWorkflowStorage;
15
+ export { FileWorkflowStorage, SchemaValidatingWorkflowStorage, CachingWorkflowStorage };
16
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/storage/storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAoC,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAOpE;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,IAAI,sBAAsB,CAKrE;AAGD,OAAO,EACL,mBAAmB,EACnB,+BAA+B,EAC/B,sBAAsB,EACvB,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // Re-export new modular storage pieces and compose them to keep backward compatibility
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CachingWorkflowStorage = exports.SchemaValidatingWorkflowStorage = exports.FileWorkflowStorage = void 0;
5
+ exports.createDefaultWorkflowStorage = createDefaultWorkflowStorage;
6
+ const file_workflow_storage_1 = require("./file-workflow-storage");
7
+ Object.defineProperty(exports, "FileWorkflowStorage", { enumerable: true, get: function () { return file_workflow_storage_1.FileWorkflowStorage; } });
8
+ const schema_validating_workflow_storage_1 = require("./schema-validating-workflow-storage");
9
+ Object.defineProperty(exports, "SchemaValidatingWorkflowStorage", { enumerable: true, get: function () { return schema_validating_workflow_storage_1.SchemaValidatingWorkflowStorage; } });
10
+ const caching_workflow_storage_1 = require("./caching-workflow-storage");
11
+ Object.defineProperty(exports, "CachingWorkflowStorage", { enumerable: true, get: function () { return caching_workflow_storage_1.CachingWorkflowStorage; } });
12
+ // (intentionally left blank – no direct dependency on Workflow types here)
13
+ // -----------------------------------------------------------------------------
14
+ // Default composition helper – now exposed as a factory for DI friendliness
15
+ // -----------------------------------------------------------------------------
16
+ /**
17
+ * Create the default, production-grade storage stack consisting of:
18
+ * 1. File-system backed storage
19
+ * 2. JSON-Schema validation decorator
20
+ * 3. In-memory TTL cache decorator
21
+ *
22
+ * The function is intentionally side-effect-free – each invocation returns a
23
+ * brand-new, fully-composed instance so that callers can choose whether to
24
+ * share or isolate storage state.
25
+ */
26
+ function createDefaultWorkflowStorage() {
27
+ const baseStorage = (0, file_workflow_storage_1.createDefaultFileWorkflowStorage)();
28
+ const validatingStorage = new schema_validating_workflow_storage_1.SchemaValidatingWorkflowStorage(baseStorage);
29
+ const cacheTtlMs = Number(process.env['CACHE_TTL'] ?? 300_000); // 5 minutes default
30
+ return new caching_workflow_storage_1.CachingWorkflowStorage(validatingStorage, cacheTtlMs);
31
+ }
32
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/infrastructure/storage/storage.ts"],"names":[],"mappings":";AAAA,uFAAuF;;;AAqBvF,oEAKC;AAxBD,mEAAgG;AA4B9F,oGA5BO,2CAAmB,OA4BP;AA3BrB,6FAAuF;AA4BrF,gHA5BO,oEAA+B,OA4BP;AA3BjC,yEAAoE;AA4BlE,uGA5BO,iDAAsB,OA4BP;AA3BxB,2EAA2E;AAE3E,gFAAgF;AAChF,4EAA4E;AAC5E,gFAAgF;AAEhF;;;;;;;;;GASG;AACH,SAAgB,4BAA4B;IAC1C,MAAM,WAAW,GAAG,IAAA,wDAAgC,GAAE,CAAC;IACvD,MAAM,iBAAiB,GAAG,IAAI,oEAA+B,CAAC,WAAW,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,oBAAoB;IACpF,OAAO,IAAI,iDAAsB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,391 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
+ import { readFileSync, readdirSync } from "fs";
6
+ import { join } from "path";
7
+ class SimpleWorkflowServer {
8
+ workflows = new Map();
9
+ constructor() {
10
+ this.loadWorkflows();
11
+ }
12
+ loadWorkflows() {
13
+ try {
14
+ const specDir = join(process.cwd(), 'spec', 'examples');
15
+ const files = readdirSync(specDir).filter(f => f.endsWith('.json'));
16
+ for (const file of files) {
17
+ if (file.includes('invalid') || file.includes('schema'))
18
+ continue;
19
+ try {
20
+ const content = readFileSync(join(specDir, file), 'utf8');
21
+ const workflow = JSON.parse(content);
22
+ this.workflows.set(workflow.id, workflow);
23
+ console.error(`Loaded workflow: ${workflow.id}`);
24
+ }
25
+ catch (error) {
26
+ console.error(`Error loading workflow ${file}:`, error);
27
+ }
28
+ }
29
+ }
30
+ catch (error) {
31
+ console.error('Error loading workflows:', error);
32
+ }
33
+ }
34
+ async listWorkflows() {
35
+ try {
36
+ const workflows = Array.from(this.workflows.values()).map(w => ({
37
+ id: w.id,
38
+ name: w.name,
39
+ description: w.description,
40
+ stepCount: w.steps.length,
41
+ metadata: w.metadata
42
+ }));
43
+ return {
44
+ content: [{
45
+ type: "text",
46
+ text: JSON.stringify({ workflows }, null, 2)
47
+ }]
48
+ };
49
+ }
50
+ catch (error) {
51
+ return {
52
+ content: [{
53
+ type: "text",
54
+ text: JSON.stringify({ error: error instanceof Error ? error.message : String(error) }, null, 2)
55
+ }],
56
+ isError: true
57
+ };
58
+ }
59
+ }
60
+ async getWorkflow(workflowId) {
61
+ try {
62
+ const workflow = this.workflows.get(workflowId);
63
+ if (!workflow) {
64
+ return {
65
+ content: [{
66
+ type: "text",
67
+ text: JSON.stringify({ error: `Workflow not found: ${workflowId}` }, null, 2)
68
+ }],
69
+ isError: true
70
+ };
71
+ }
72
+ return {
73
+ content: [{
74
+ type: "text",
75
+ text: JSON.stringify(workflow, null, 2)
76
+ }]
77
+ };
78
+ }
79
+ catch (error) {
80
+ return {
81
+ content: [{
82
+ type: "text",
83
+ text: JSON.stringify({ error: error instanceof Error ? error.message : String(error) }, null, 2)
84
+ }],
85
+ isError: true
86
+ };
87
+ }
88
+ }
89
+ async getNextStep(workflowId, completedSteps = []) {
90
+ try {
91
+ const workflow = this.workflows.get(workflowId);
92
+ if (!workflow) {
93
+ return {
94
+ content: [{
95
+ type: "text",
96
+ text: JSON.stringify({ error: `Workflow not found: ${workflowId}` }, null, 2)
97
+ }],
98
+ isError: true
99
+ };
100
+ }
101
+ // Find next step that isn't completed and has all dependencies met
102
+ const nextStep = workflow.steps.find(step => {
103
+ if (completedSteps.includes(step.id))
104
+ return false;
105
+ if (step.dependencies) {
106
+ return step.dependencies.every(dep => completedSteps.includes(dep));
107
+ }
108
+ return true;
109
+ });
110
+ if (!nextStep) {
111
+ const allStepsCompleted = workflow.steps.every(step => completedSteps.includes(step.id));
112
+ return {
113
+ content: [{
114
+ type: "text",
115
+ text: JSON.stringify({
116
+ isComplete: allStepsCompleted,
117
+ message: allStepsCompleted ? "Workflow completed successfully!" : "No available next step",
118
+ totalSteps: workflow.steps.length,
119
+ completedSteps: completedSteps.length
120
+ }, null, 2)
121
+ }]
122
+ };
123
+ }
124
+ return {
125
+ content: [{
126
+ type: "text",
127
+ text: JSON.stringify({
128
+ nextStep,
129
+ progress: {
130
+ current: completedSteps.length + 1,
131
+ total: workflow.steps.length,
132
+ percentage: Math.round(((completedSteps.length + 1) / workflow.steps.length) * 100)
133
+ }
134
+ }, null, 2)
135
+ }]
136
+ };
137
+ }
138
+ catch (error) {
139
+ return {
140
+ content: [{
141
+ type: "text",
142
+ text: JSON.stringify({ error: error instanceof Error ? error.message : String(error) }, null, 2)
143
+ }],
144
+ isError: true
145
+ };
146
+ }
147
+ }
148
+ async validateStep(workflowId, stepId, output) {
149
+ try {
150
+ const workflow = this.workflows.get(workflowId);
151
+ if (!workflow) {
152
+ return {
153
+ content: [{
154
+ type: "text",
155
+ text: JSON.stringify({ error: `Workflow not found: ${workflowId}` }, null, 2)
156
+ }],
157
+ isError: true
158
+ };
159
+ }
160
+ const step = workflow.steps.find(s => s.id === stepId);
161
+ if (!step) {
162
+ return {
163
+ content: [{
164
+ type: "text",
165
+ text: JSON.stringify({ error: `Step not found: ${stepId}` }, null, 2)
166
+ }],
167
+ isError: true
168
+ };
169
+ }
170
+ // Basic validation
171
+ const validationResult = {
172
+ stepId,
173
+ isValid: true,
174
+ feedback: [],
175
+ suggestions: []
176
+ };
177
+ // Check if output is provided
178
+ if (!output || output.trim().length === 0) {
179
+ validationResult.isValid = false;
180
+ validationResult.feedback.push("Output is required for step validation");
181
+ }
182
+ // Check minimum length for meaningful output
183
+ if (output.trim().length < 10) {
184
+ validationResult.isValid = false;
185
+ validationResult.feedback.push("Output seems too brief - please provide more detail");
186
+ }
187
+ // Check for common error patterns if defined
188
+ if (step.validation?.errorPatterns) {
189
+ for (const pattern of step.validation.errorPatterns) {
190
+ if (output.toLowerCase().includes(pattern.toLowerCase())) {
191
+ validationResult.isValid = false;
192
+ validationResult.feedback.push(`Potential issue detected: ${pattern}`);
193
+ }
194
+ }
195
+ }
196
+ // Add positive feedback for valid steps
197
+ if (validationResult.isValid) {
198
+ validationResult.feedback.push("Step output looks good!");
199
+ validationResult.suggestions.push("Consider documenting any key decisions or findings");
200
+ }
201
+ return {
202
+ content: [{
203
+ type: "text",
204
+ text: JSON.stringify(validationResult, null, 2)
205
+ }]
206
+ };
207
+ }
208
+ catch (error) {
209
+ return {
210
+ content: [{
211
+ type: "text",
212
+ text: JSON.stringify({ error: error instanceof Error ? error.message : String(error) }, null, 2)
213
+ }],
214
+ isError: true
215
+ };
216
+ }
217
+ }
218
+ }
219
+ // Define the workflow orchestration tools
220
+ const WORKFLOW_LIST_TOOL = {
221
+ name: "workflow_list",
222
+ description: `List all available workflows in the system.
223
+
224
+ Returns a comprehensive list of workflow definitions that can be used to guide structured task completion. Each workflow includes metadata like name, description, and step count.
225
+
226
+ Use this tool to:
227
+ - Discover available workflows for different types of tasks
228
+ - Get an overview of workflow options before starting a task
229
+ - Browse workflow catalogs for specific domains (auth, API development, etc.)`,
230
+ inputSchema: {
231
+ type: "object",
232
+ properties: {},
233
+ additionalProperties: false
234
+ }
235
+ };
236
+ const WORKFLOW_GET_TOOL = {
237
+ name: "workflow_get",
238
+ description: `Get detailed information about a specific workflow.
239
+
240
+ Retrieves the complete workflow definition including all steps, preconditions, guidance, and metadata. This provides the full blueprint for executing a structured task.
241
+
242
+ Use this tool to:
243
+ - Get the complete step-by-step instructions for a workflow
244
+ - Understand preconditions and requirements before starting
245
+ - Review clarification prompts and meta-guidance
246
+ - Plan the execution of a complex task`,
247
+ inputSchema: {
248
+ type: "object",
249
+ properties: {
250
+ workflowId: {
251
+ type: "string",
252
+ description: "The unique identifier of the workflow to retrieve",
253
+ pattern: "^[A-Za-z0-9_-]+$"
254
+ }
255
+ },
256
+ required: ["workflowId"],
257
+ additionalProperties: false
258
+ }
259
+ };
260
+ const WORKFLOW_NEXT_TOOL = {
261
+ name: "workflow_next",
262
+ description: `Get the next step in a workflow progression.
263
+
264
+ Determines what step should be executed next based on the workflow definition and currently completed steps. Provides intelligent step sequencing and completion detection.
265
+
266
+ Use this tool to:
267
+ - Get the next actionable step in a workflow
268
+ - Understand step dependencies and prerequisites
269
+ - Determine if a workflow is complete
270
+ - Receive contextual guidance for the current stage`,
271
+ inputSchema: {
272
+ type: "object",
273
+ properties: {
274
+ workflowId: {
275
+ type: "string",
276
+ description: "The unique identifier of the workflow",
277
+ pattern: "^[A-Za-z0-9_-]+$"
278
+ },
279
+ completedSteps: {
280
+ type: "array",
281
+ items: {
282
+ type: "string",
283
+ pattern: "^[A-Za-z0-9_-]+$"
284
+ },
285
+ description: "Array of step IDs that have been completed",
286
+ default: []
287
+ }
288
+ },
289
+ required: ["workflowId"],
290
+ additionalProperties: false
291
+ }
292
+ };
293
+ const WORKFLOW_VALIDATE_TOOL = {
294
+ name: "workflow_validate",
295
+ description: `Validate the completion of a workflow step.
296
+
297
+ Checks if a step has been properly completed based on the step requirements and provided output. Provides feedback and validation results to ensure quality execution.
298
+
299
+ Use this tool to:
300
+ - Verify that a step meets its completion criteria
301
+ - Get feedback on step output quality
302
+ - Ensure proper progression through workflow steps
303
+ - Validate deliverables before moving to next step`,
304
+ inputSchema: {
305
+ type: "object",
306
+ properties: {
307
+ workflowId: {
308
+ type: "string",
309
+ description: "The unique identifier of the workflow",
310
+ pattern: "^[A-Za-z0-9_-]+$"
311
+ },
312
+ stepId: {
313
+ type: "string",
314
+ description: "The unique identifier of the step to validate",
315
+ pattern: "^[A-Za-z0-9_-]+$"
316
+ },
317
+ output: {
318
+ type: "string",
319
+ description: "The output or result produced for this step",
320
+ maxLength: 10000
321
+ }
322
+ },
323
+ required: ["workflowId", "stepId", "output"],
324
+ additionalProperties: false
325
+ }
326
+ };
327
+ // Create and configure the MCP server
328
+ const server = new Server({
329
+ name: "workflow-orchestration-server",
330
+ version: "1.2.0",
331
+ }, {
332
+ capabilities: {
333
+ tools: {},
334
+ },
335
+ });
336
+ const workflowServer = new SimpleWorkflowServer();
337
+ // Register request handlers
338
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
339
+ tools: [
340
+ WORKFLOW_LIST_TOOL,
341
+ WORKFLOW_GET_TOOL,
342
+ WORKFLOW_NEXT_TOOL,
343
+ WORKFLOW_VALIDATE_TOOL
344
+ ],
345
+ }));
346
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
347
+ const { name, arguments: args } = request.params;
348
+ switch (name) {
349
+ case "workflow_list":
350
+ return await workflowServer.listWorkflows();
351
+ case "workflow_get":
352
+ if (!args?.['workflowId']) {
353
+ return {
354
+ content: [{ type: "text", text: "Error: workflowId parameter is required" }],
355
+ isError: true
356
+ };
357
+ }
358
+ return await workflowServer.getWorkflow(args['workflowId']);
359
+ case "workflow_next":
360
+ if (!args?.['workflowId']) {
361
+ return {
362
+ content: [{ type: "text", text: "Error: workflowId parameter is required" }],
363
+ isError: true
364
+ };
365
+ }
366
+ return await workflowServer.getNextStep(args['workflowId'], args['completedSteps'] || []);
367
+ case "workflow_validate":
368
+ if (!args?.['workflowId'] || !args?.['stepId'] || !args?.['output']) {
369
+ return {
370
+ content: [{ type: "text", text: "Error: workflowId, stepId, and output parameters are required" }],
371
+ isError: true
372
+ };
373
+ }
374
+ return await workflowServer.validateStep(args['workflowId'], args['stepId'], args['output']);
375
+ default:
376
+ return {
377
+ content: [{ type: "text", text: `Unknown tool: ${name}` }],
378
+ isError: true
379
+ };
380
+ }
381
+ });
382
+ // Start the server
383
+ async function runServer() {
384
+ const transport = new StdioServerTransport();
385
+ await server.connect(transport);
386
+ console.error("Workflow Orchestration MCP Server running on stdio");
387
+ }
388
+ runServer().catch((error) => {
389
+ console.error("Fatal error running server:", error);
390
+ process.exit(1);
391
+ });