@exaudeus/workrail 0.8.6 → 0.9.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 (422) hide show
  1. package/README.md +157 -403
  2. package/dist/application/services/enhanced-loop-validator.d.ts +2 -2
  3. package/dist/application/services/enhanced-loop-validator.js +12 -2
  4. package/dist/application/services/validation-engine.d.ts +8 -29
  5. package/dist/application/services/validation-engine.js +38 -21
  6. package/dist/application/services/workflow-compiler.d.ts +18 -0
  7. package/dist/application/services/workflow-compiler.js +79 -0
  8. package/dist/application/services/workflow-interpreter.d.ts +31 -0
  9. package/dist/application/services/workflow-interpreter.js +280 -0
  10. package/dist/application/services/workflow-service.d.ts +34 -32
  11. package/dist/application/services/workflow-service.js +93 -425
  12. package/dist/application/use-cases/get-next-step.d.ts +6 -10
  13. package/dist/application/use-cases/get-next-step.js +2 -6
  14. package/dist/application/use-cases/get-workflow.d.ts +8 -6
  15. package/dist/application/use-cases/get-workflow.js +42 -33
  16. package/dist/application/use-cases/list-workflows.d.ts +3 -3
  17. package/dist/application/use-cases/validate-step-output.d.ts +4 -4
  18. package/dist/application/use-cases/validate-workflow-file.d.ts +46 -0
  19. package/dist/application/use-cases/validate-workflow-file.js +57 -0
  20. package/dist/cli/commands/cleanup.d.ts +8 -0
  21. package/dist/cli/commands/cleanup.js +20 -0
  22. package/dist/cli/commands/index.d.ts +7 -0
  23. package/dist/cli/commands/index.js +21 -0
  24. package/dist/cli/commands/init.d.ts +11 -0
  25. package/dist/cli/commands/init.js +49 -0
  26. package/dist/cli/commands/list.d.ts +9 -0
  27. package/dist/cli/commands/list.js +34 -0
  28. package/dist/cli/commands/migrate.d.ts +78 -0
  29. package/dist/cli/commands/migrate.js +248 -0
  30. package/dist/cli/commands/sources.d.ts +21 -0
  31. package/dist/cli/commands/sources.js +87 -0
  32. package/dist/cli/commands/start.d.ts +8 -0
  33. package/dist/cli/commands/start.js +16 -0
  34. package/dist/cli/commands/validate.d.ts +6 -0
  35. package/dist/cli/commands/validate.js +55 -0
  36. package/dist/cli/interpret-result.d.ts +4 -0
  37. package/dist/cli/interpret-result.js +24 -0
  38. package/dist/cli/output-formatter.d.ts +10 -0
  39. package/dist/cli/output-formatter.js +97 -0
  40. package/dist/cli/types/cli-result.d.ts +23 -0
  41. package/dist/cli/types/cli-result.js +30 -0
  42. package/dist/cli/types/exit-code.d.ts +13 -0
  43. package/dist/cli/types/exit-code.js +23 -0
  44. package/dist/cli/types/index.d.ts +4 -0
  45. package/dist/cli/types/index.js +11 -0
  46. package/dist/cli.js +84 -278
  47. package/dist/config/app-config.d.ts +40 -0
  48. package/dist/config/app-config.js +58 -0
  49. package/dist/config/feature-flags.d.ts +10 -2
  50. package/dist/config/feature-flags.js +74 -12
  51. package/dist/core/error-handler.d.ts +18 -27
  52. package/dist/core/error-handler.js +24 -218
  53. package/dist/di/container.d.ts +12 -0
  54. package/dist/di/container.js +244 -0
  55. package/dist/di/tokens.d.ts +40 -0
  56. package/dist/di/tokens.js +42 -0
  57. package/dist/domain/execution/error.d.ts +32 -0
  58. package/dist/domain/execution/error.js +24 -0
  59. package/dist/domain/execution/event.d.ts +7 -0
  60. package/dist/domain/execution/event.js +11 -0
  61. package/dist/domain/execution/ids.d.ts +9 -0
  62. package/dist/domain/execution/ids.js +9 -0
  63. package/dist/domain/execution/result.d.ts +3 -0
  64. package/dist/domain/execution/result.js +10 -0
  65. package/dist/domain/execution/state.d.ts +57 -0
  66. package/dist/domain/execution/state.js +28 -0
  67. package/dist/errors/app-error.d.ts +23 -0
  68. package/dist/errors/factories.d.ts +6 -0
  69. package/dist/errors/factories.js +21 -0
  70. package/dist/errors/formatter.d.ts +2 -0
  71. package/dist/errors/formatter.js +32 -0
  72. package/dist/errors/index.d.ts +3 -0
  73. package/dist/errors/index.js +7 -0
  74. package/dist/index.d.ts +6 -1
  75. package/dist/index.js +10 -25
  76. package/dist/infrastructure/index.d.ts +0 -1
  77. package/dist/infrastructure/index.js +0 -1
  78. package/dist/infrastructure/session/DashboardHeartbeat.d.ts +8 -0
  79. package/dist/infrastructure/session/DashboardHeartbeat.js +39 -0
  80. package/dist/infrastructure/session/DashboardLockRelease.d.ts +2 -0
  81. package/dist/infrastructure/session/DashboardLockRelease.js +29 -0
  82. package/dist/infrastructure/session/HttpServer.d.ts +25 -6
  83. package/dist/infrastructure/session/HttpServer.js +245 -90
  84. package/dist/infrastructure/session/SessionDataNormalizer.js +12 -2
  85. package/dist/infrastructure/session/SessionDataValidator.js +12 -2
  86. package/dist/infrastructure/session/SessionManager.d.ts +5 -3
  87. package/dist/infrastructure/session/SessionManager.js +52 -6
  88. package/dist/infrastructure/storage/caching-workflow-storage.d.ts +30 -6
  89. package/dist/infrastructure/storage/caching-workflow-storage.js +105 -23
  90. package/dist/infrastructure/storage/enhanced-multi-source-workflow-storage.d.ts +13 -9
  91. package/dist/infrastructure/storage/enhanced-multi-source-workflow-storage.js +45 -39
  92. package/dist/infrastructure/storage/file-workflow-storage.d.ts +10 -8
  93. package/dist/infrastructure/storage/file-workflow-storage.js +48 -56
  94. package/dist/infrastructure/storage/git-workflow-storage.d.ts +7 -22
  95. package/dist/infrastructure/storage/git-workflow-storage.js +48 -103
  96. package/dist/infrastructure/storage/in-memory-storage.d.ts +10 -6
  97. package/dist/infrastructure/storage/in-memory-storage.js +18 -13
  98. package/dist/infrastructure/storage/plugin-workflow-storage.d.ts +6 -18
  99. package/dist/infrastructure/storage/plugin-workflow-storage.js +29 -51
  100. package/dist/infrastructure/storage/remote-workflow-storage.d.ts +8 -17
  101. package/dist/infrastructure/storage/remote-workflow-storage.js +33 -156
  102. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts +21 -13
  103. package/dist/infrastructure/storage/schema-validating-workflow-storage.js +86 -24
  104. package/dist/infrastructure/storage/storage.d.ts +7 -5
  105. package/dist/infrastructure/storage/storage.js +7 -6
  106. package/dist/manifest.json +1093 -0
  107. package/dist/mcp/error-mapper.d.ts +9 -0
  108. package/dist/mcp/error-mapper.js +66 -0
  109. package/dist/mcp/handlers/session.d.ts +34 -0
  110. package/dist/mcp/handlers/session.js +135 -0
  111. package/dist/mcp/handlers/v2-workflow.d.ts +4 -0
  112. package/dist/mcp/handlers/v2-workflow.js +112 -0
  113. package/dist/mcp/handlers/workflow.d.ts +45 -0
  114. package/dist/mcp/handlers/workflow.js +167 -0
  115. package/dist/mcp/index.d.ts +16 -0
  116. package/dist/mcp/index.js +51 -0
  117. package/dist/mcp/output-schemas.d.ts +317 -0
  118. package/dist/mcp/output-schemas.js +91 -0
  119. package/dist/mcp/server.d.ts +3 -0
  120. package/dist/mcp/server.js +258 -0
  121. package/dist/mcp/tool-description-provider.d.ts +16 -0
  122. package/dist/mcp/tool-description-provider.js +43 -0
  123. package/dist/mcp/tool-descriptions.d.ts +2 -0
  124. package/dist/mcp/tool-descriptions.js +109 -0
  125. package/dist/mcp/tool-factory.d.ts +23 -0
  126. package/dist/mcp/tool-factory.js +14 -0
  127. package/dist/mcp/tools.d.ts +156 -0
  128. package/dist/mcp/tools.js +196 -0
  129. package/dist/mcp/types/tool-description-types.d.ts +8 -0
  130. package/dist/mcp/types/tool-description-types.js +24 -0
  131. package/dist/mcp/types.d.ts +25 -0
  132. package/dist/mcp/types.js +15 -0
  133. package/dist/mcp/v2/tool-registry.d.ts +11 -0
  134. package/dist/mcp/v2/tool-registry.js +26 -0
  135. package/dist/mcp/v2/tools.d.ts +20 -0
  136. package/dist/mcp/v2/tools.js +17 -0
  137. package/dist/mcp/validation/bounded-json.d.ts +3 -0
  138. package/dist/mcp/validation/bounded-json.js +22 -0
  139. package/dist/mcp/validation/workflow-next-prevalidate.d.ts +9 -0
  140. package/dist/mcp/validation/workflow-next-prevalidate.js +83 -0
  141. package/dist/mcp/zod-to-json-schema.d.ts +17 -0
  142. package/dist/mcp/zod-to-json-schema.js +134 -0
  143. package/dist/mcp-server.d.ts +1 -1
  144. package/dist/mcp-server.js +6 -424
  145. package/dist/runtime/adapters/in-memory-shutdown-events.d.ts +6 -0
  146. package/dist/runtime/adapters/in-memory-shutdown-events.js +20 -0
  147. package/dist/runtime/adapters/node-process-signals.d.ts +4 -0
  148. package/dist/runtime/adapters/node-process-signals.js +11 -0
  149. package/dist/runtime/adapters/node-process-terminator.d.ts +4 -0
  150. package/dist/runtime/adapters/node-process-terminator.js +17 -0
  151. package/dist/runtime/adapters/noop-process-signals.d.ts +4 -0
  152. package/dist/runtime/adapters/noop-process-signals.js +8 -0
  153. package/dist/runtime/adapters/throwing-process-terminator.d.ts +4 -0
  154. package/dist/runtime/adapters/throwing-process-terminator.js +9 -0
  155. package/dist/runtime/assert-never.d.ts +1 -0
  156. package/dist/runtime/assert-never.js +6 -0
  157. package/dist/runtime/brand.d.ts +5 -0
  158. package/dist/runtime/ports/process-signals.d.ts +4 -0
  159. package/dist/runtime/ports/process-signals.js +2 -0
  160. package/dist/runtime/ports/process-terminator.d.ts +8 -0
  161. package/dist/runtime/ports/process-terminator.js +2 -0
  162. package/dist/runtime/ports/shutdown-events.d.ts +11 -0
  163. package/dist/runtime/ports/shutdown-events.js +2 -0
  164. package/dist/runtime/process-lifecycle-policy.d.ts +5 -0
  165. package/dist/runtime/process-lifecycle-policy.js +2 -0
  166. package/dist/runtime/result.d.ts +17 -0
  167. package/dist/runtime/result.js +31 -0
  168. package/dist/runtime/runtime-mode.d.ts +9 -0
  169. package/dist/runtime/runtime-mode.js +2 -0
  170. package/dist/types/storage.d.ts +16 -5
  171. package/dist/types/storage.js +8 -0
  172. package/dist/types/validation.d.ts +27 -0
  173. package/dist/types/validation.js +10 -0
  174. package/dist/types/workflow-definition.d.ts +63 -0
  175. package/dist/types/workflow-definition.js +33 -0
  176. package/dist/types/workflow-source.d.ts +51 -0
  177. package/dist/types/workflow-source.js +128 -0
  178. package/dist/types/workflow.d.ts +28 -0
  179. package/dist/types/workflow.js +96 -0
  180. package/dist/utils/workflow-init.d.ts +1 -0
  181. package/dist/utils/workflow-init.js +38 -0
  182. package/dist/v2/durable-core/canonical/hashing.d.ts +11 -0
  183. package/dist/v2/durable-core/canonical/hashing.js +13 -0
  184. package/dist/v2/durable-core/canonical/jcs.d.ts +11 -0
  185. package/dist/v2/durable-core/canonical/jcs.js +65 -0
  186. package/dist/v2/durable-core/canonical/json-types.d.ts +6 -0
  187. package/dist/v2/durable-core/canonical/json-types.js +2 -0
  188. package/dist/v2/durable-core/canonical/json-zod.d.ts +2 -0
  189. package/dist/v2/durable-core/canonical/json-zod.js +7 -0
  190. package/dist/v2/durable-core/canonical/jsonl.d.ts +4 -0
  191. package/dist/v2/durable-core/canonical/jsonl.js +13 -0
  192. package/dist/v2/durable-core/ids/index.d.ts +23 -0
  193. package/dist/v2/durable-core/ids/index.js +46 -0
  194. package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +47 -0
  195. package/dist/v2/durable-core/schemas/compiled-workflow/index.js +17 -0
  196. package/dist/v2/durable-core/schemas/session/events.d.ts +1812 -0
  197. package/dist/v2/durable-core/schemas/session/events.js +328 -0
  198. package/dist/v2/durable-core/schemas/session/index.d.ts +2 -0
  199. package/dist/v2/durable-core/schemas/session/index.js +8 -0
  200. package/dist/v2/durable-core/schemas/session/manifest.d.ts +57 -0
  201. package/dist/v2/durable-core/schemas/session/manifest.js +30 -0
  202. package/dist/v2/infra/local/crypto/index.d.ts +5 -0
  203. package/dist/v2/infra/local/crypto/index.js +12 -0
  204. package/dist/v2/infra/local/data-dir/index.d.ts +13 -0
  205. package/dist/v2/infra/local/data-dir/index.js +69 -0
  206. package/dist/v2/infra/local/fs/index.d.ts +26 -0
  207. package/dist/v2/infra/local/fs/index.js +156 -0
  208. package/dist/v2/infra/local/pinned-workflow-store/index.d.ts +11 -0
  209. package/dist/v2/infra/local/pinned-workflow-store/index.js +85 -0
  210. package/dist/v2/infra/local/session-lock/index.d.ts +12 -0
  211. package/dist/v2/infra/local/session-lock/index.js +44 -0
  212. package/dist/v2/infra/local/session-store/index.d.ts +22 -0
  213. package/dist/v2/infra/local/session-store/index.js +358 -0
  214. package/dist/v2/infra/local/sha256/index.d.ts +5 -0
  215. package/dist/v2/infra/local/sha256/index.js +12 -0
  216. package/dist/v2/ports/data-dir.port.d.ts +9 -0
  217. package/dist/v2/ports/data-dir.port.js +2 -0
  218. package/dist/v2/ports/fs.port.d.ts +41 -0
  219. package/dist/v2/ports/fs.port.js +2 -0
  220. package/dist/v2/ports/pinned-workflow-store.port.d.ts +11 -0
  221. package/dist/v2/ports/pinned-workflow-store.port.js +2 -0
  222. package/dist/v2/ports/session-event-log-store.port.d.ts +37 -0
  223. package/dist/v2/ports/session-event-log-store.port.js +2 -0
  224. package/dist/v2/ports/session-lock.port.d.ts +23 -0
  225. package/dist/v2/ports/session-lock.port.js +2 -0
  226. package/dist/v2/ports/sha256.port.d.ts +4 -0
  227. package/dist/v2/ports/sha256.port.js +2 -0
  228. package/dist/v2/projections/advance-outcomes.d.ts +23 -0
  229. package/dist/v2/projections/advance-outcomes.js +23 -0
  230. package/dist/v2/projections/capabilities.d.ts +27 -0
  231. package/dist/v2/projections/capabilities.js +33 -0
  232. package/dist/v2/projections/gaps.d.ts +29 -0
  233. package/dist/v2/projections/gaps.js +49 -0
  234. package/dist/v2/projections/node-outputs.d.ts +34 -0
  235. package/dist/v2/projections/node-outputs.js +73 -0
  236. package/dist/v2/projections/preferences.d.ts +28 -0
  237. package/dist/v2/projections/preferences.js +50 -0
  238. package/dist/v2/projections/run-dag.d.ts +42 -0
  239. package/dist/v2/projections/run-dag.js +186 -0
  240. package/dist/v2/projections/run-status-signals.d.ts +26 -0
  241. package/dist/v2/projections/run-status-signals.js +49 -0
  242. package/dist/v2/projections/session-health.d.ts +18 -0
  243. package/dist/v2/projections/session-health.js +15 -0
  244. package/dist/v2/read-only/v1-to-v2-shim.d.ts +3 -0
  245. package/dist/v2/read-only/v1-to-v2-shim.js +38 -0
  246. package/package.json +35 -10
  247. package/spec/mcp-api-v1.0.md +5 -5
  248. package/web/assets/services/data-normalizer.js +17 -2
  249. package/web/assets/services/pattern-recognizer.js +3 -1
  250. package/web/assets/services/session-data.js +13 -8
  251. package/web/assets/utils/formatters.js +34 -23
  252. package/workflows/CHANGELOG-bug-investigation.md +4 -4
  253. package/workflows/coding-task-workflow-agentic.json +262 -0
  254. package/workflows/design-thinking-workflow-autonomous.agentic.json +215 -0
  255. package/workflows/design-thinking-workflow.json +198 -0
  256. package/workflows/mr-review-workflow.agentic.json +538 -0
  257. package/workflows/routines/context-gathering.json +0 -4
  258. package/dist/application/app.d.ts +0 -29
  259. package/dist/application/app.d.ts.map +0 -1
  260. package/dist/application/app.js +0 -114
  261. package/dist/application/app.js.map +0 -1
  262. package/dist/application/decorators/simple-output-decorator.d.ts +0 -8
  263. package/dist/application/decorators/simple-output-decorator.js +0 -89
  264. package/dist/application/services/classification-engine.d.ts +0 -33
  265. package/dist/application/services/classification-engine.js +0 -258
  266. package/dist/application/services/compression-service.d.ts +0 -20
  267. package/dist/application/services/compression-service.js +0 -312
  268. package/dist/application/services/context-management-service.d.ts +0 -38
  269. package/dist/application/services/context-management-service.js +0 -301
  270. package/dist/application/services/context-optimizer.d.ts +0 -11
  271. package/dist/application/services/context-optimizer.js +0 -62
  272. package/dist/application/services/context-persistence-service.d.ts +0 -45
  273. package/dist/application/services/context-persistence-service.js +0 -273
  274. package/dist/application/services/documentation-service.d.ts +0 -20
  275. package/dist/application/services/documentation-service.js +0 -155
  276. package/dist/application/services/enhanced-error-service.d.ts.map +0 -1
  277. package/dist/application/services/enhanced-error-service.js.map +0 -1
  278. package/dist/application/services/loop-context-optimizer.d.ts +0 -8
  279. package/dist/application/services/loop-context-optimizer.js +0 -114
  280. package/dist/application/services/loop-execution-context.d.ts +0 -23
  281. package/dist/application/services/loop-execution-context.js +0 -188
  282. package/dist/application/services/loop-step-resolver.d.ts +0 -11
  283. package/dist/application/services/loop-step-resolver.js +0 -70
  284. package/dist/application/services/validation-engine.d.ts.map +0 -1
  285. package/dist/application/services/validation-engine.js.map +0 -1
  286. package/dist/application/services/workflow-service.d.ts.map +0 -1
  287. package/dist/application/services/workflow-service.js.map +0 -1
  288. package/dist/application/use-cases/get-next-step.d.ts.map +0 -1
  289. package/dist/application/use-cases/get-next-step.js.map +0 -1
  290. package/dist/application/use-cases/get-workflow-docs.d.ts +0 -4
  291. package/dist/application/use-cases/get-workflow-docs.js +0 -12
  292. package/dist/application/use-cases/get-workflow.d.ts.map +0 -1
  293. package/dist/application/use-cases/get-workflow.js.map +0 -1
  294. package/dist/application/use-cases/get-workrail-help.d.ts +0 -4
  295. package/dist/application/use-cases/get-workrail-help.js +0 -12
  296. package/dist/application/use-cases/list-workflows.d.ts.map +0 -1
  297. package/dist/application/use-cases/list-workflows.js.map +0 -1
  298. package/dist/application/use-cases/validate-step-output.d.ts.map +0 -1
  299. package/dist/application/use-cases/validate-step-output.js.map +0 -1
  300. package/dist/application/use-cases/validate-workflow-json.d.ts.map +0 -1
  301. package/dist/application/use-cases/validate-workflow-json.js.map +0 -1
  302. package/dist/application/validation.d.ts.map +0 -1
  303. package/dist/application/validation.js.map +0 -1
  304. package/dist/cli/migrate-workflow.d.ts +0 -22
  305. package/dist/cli/migrate-workflow.js +0 -196
  306. package/dist/cli.d.ts.map +0 -1
  307. package/dist/cli.js.map +0 -1
  308. package/dist/container.d.ts +0 -15
  309. package/dist/container.d.ts.map +0 -1
  310. package/dist/container.js +0 -25
  311. package/dist/container.js.map +0 -1
  312. package/dist/core/error-handler.d.ts.map +0 -1
  313. package/dist/core/error-handler.js.map +0 -1
  314. package/dist/domain/index.d.ts +0 -2
  315. package/dist/domain/index.d.ts.map +0 -1
  316. package/dist/domain/index.js +0 -18
  317. package/dist/domain/index.js.map +0 -1
  318. package/dist/index.d.ts.map +0 -1
  319. package/dist/index.js.map +0 -1
  320. package/dist/infrastructure/index.d.ts.map +0 -1
  321. package/dist/infrastructure/index.js.map +0 -1
  322. package/dist/infrastructure/rpc/handler.d.ts +0 -17
  323. package/dist/infrastructure/rpc/handler.d.ts.map +0 -1
  324. package/dist/infrastructure/rpc/handler.js +0 -78
  325. package/dist/infrastructure/rpc/handler.js.map +0 -1
  326. package/dist/infrastructure/rpc/index.d.ts +0 -1
  327. package/dist/infrastructure/rpc/index.d.ts.map +0 -1
  328. package/dist/infrastructure/rpc/index.js +0 -17
  329. package/dist/infrastructure/rpc/index.js.map +0 -1
  330. package/dist/infrastructure/rpc/server.d.ts +0 -3
  331. package/dist/infrastructure/rpc/server.d.ts.map +0 -1
  332. package/dist/infrastructure/rpc/server.js +0 -37
  333. package/dist/infrastructure/rpc/server.js.map +0 -1
  334. package/dist/infrastructure/storage/caching-workflow-storage.d.ts.map +0 -1
  335. package/dist/infrastructure/storage/caching-workflow-storage.js.map +0 -1
  336. package/dist/infrastructure/storage/context-storage.d.ts +0 -150
  337. package/dist/infrastructure/storage/context-storage.js +0 -40
  338. package/dist/infrastructure/storage/file-workflow-storage.d.ts.map +0 -1
  339. package/dist/infrastructure/storage/file-workflow-storage.js.map +0 -1
  340. package/dist/infrastructure/storage/filesystem-blob-storage.d.ts +0 -27
  341. package/dist/infrastructure/storage/filesystem-blob-storage.js +0 -363
  342. package/dist/infrastructure/storage/git-workflow-storage.d.ts.map +0 -1
  343. package/dist/infrastructure/storage/git-workflow-storage.js.map +0 -1
  344. package/dist/infrastructure/storage/hybrid-context-storage.d.ts +0 -29
  345. package/dist/infrastructure/storage/hybrid-context-storage.js +0 -400
  346. package/dist/infrastructure/storage/in-memory-storage.d.ts.map +0 -1
  347. package/dist/infrastructure/storage/in-memory-storage.js.map +0 -1
  348. package/dist/infrastructure/storage/index.d.ts.map +0 -1
  349. package/dist/infrastructure/storage/index.js.map +0 -1
  350. package/dist/infrastructure/storage/migrations/001_initial_schema.sql +0 -38
  351. package/dist/infrastructure/storage/migrations/002_context_concurrency_enhancements.sql +0 -234
  352. package/dist/infrastructure/storage/migrations/003_classification_overrides.sql +0 -20
  353. package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts +0 -32
  354. package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts.map +0 -1
  355. package/dist/infrastructure/storage/multi-directory-workflow-storage.js +0 -184
  356. package/dist/infrastructure/storage/multi-directory-workflow-storage.js.map +0 -1
  357. package/dist/infrastructure/storage/plugin-workflow-storage.d.ts.map +0 -1
  358. package/dist/infrastructure/storage/plugin-workflow-storage.js.map +0 -1
  359. package/dist/infrastructure/storage/remote-workflow-storage.d.ts.map +0 -1
  360. package/dist/infrastructure/storage/remote-workflow-storage.js.map +0 -1
  361. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts.map +0 -1
  362. package/dist/infrastructure/storage/schema-validating-workflow-storage.js.map +0 -1
  363. package/dist/infrastructure/storage/sqlite-metadata-storage.d.ts +0 -35
  364. package/dist/infrastructure/storage/sqlite-metadata-storage.js +0 -410
  365. package/dist/infrastructure/storage/sqlite-migrator.d.ts +0 -46
  366. package/dist/infrastructure/storage/sqlite-migrator.js +0 -293
  367. package/dist/infrastructure/storage/storage.d.ts.map +0 -1
  368. package/dist/infrastructure/storage/storage.js.map +0 -1
  369. package/dist/mcp-server.d.ts.map +0 -1
  370. package/dist/mcp-server.js.map +0 -1
  371. package/dist/tools/mcp_initialize.d.ts +0 -2
  372. package/dist/tools/mcp_initialize.d.ts.map +0 -1
  373. package/dist/tools/mcp_initialize.js +0 -45
  374. package/dist/tools/mcp_initialize.js.map +0 -1
  375. package/dist/tools/mcp_shutdown.d.ts +0 -2
  376. package/dist/tools/mcp_shutdown.d.ts.map +0 -1
  377. package/dist/tools/mcp_shutdown.js +0 -10
  378. package/dist/tools/mcp_shutdown.js.map +0 -1
  379. package/dist/tools/mcp_tools_list.d.ts +0 -2
  380. package/dist/tools/mcp_tools_list.d.ts.map +0 -1
  381. package/dist/tools/mcp_tools_list.js +0 -60
  382. package/dist/tools/mcp_tools_list.js.map +0 -1
  383. package/dist/tools/session-tools.d.ts +0 -5
  384. package/dist/tools/session-tools.js +0 -270
  385. package/dist/types/context-types.d.ts +0 -236
  386. package/dist/types/context-types.js +0 -10
  387. package/dist/types/documentation-types.d.ts +0 -37
  388. package/dist/types/loop-context-optimizer.d.ts +0 -7
  389. package/dist/types/mcp-types.d.ts +0 -273
  390. package/dist/types/mcp-types.d.ts.map +0 -1
  391. package/dist/types/mcp-types.js +0 -19
  392. package/dist/types/mcp-types.js.map +0 -1
  393. package/dist/types/server.d.ts.map +0 -1
  394. package/dist/types/server.js.map +0 -1
  395. package/dist/types/storage.d.ts.map +0 -1
  396. package/dist/types/storage.js.map +0 -1
  397. package/dist/types/workflow-types.d.ts +0 -336
  398. package/dist/types/workflow-types.d.ts.map +0 -1
  399. package/dist/types/workflow-types.js +0 -20
  400. package/dist/types/workflow-types.js.map +0 -1
  401. package/dist/utils/condition-evaluator.d.ts.map +0 -1
  402. package/dist/utils/condition-evaluator.js.map +0 -1
  403. package/dist/utils/config.d.ts +0 -149
  404. package/dist/utils/config.d.ts.map +0 -1
  405. package/dist/utils/config.js +0 -251
  406. package/dist/utils/config.js.map +0 -1
  407. package/dist/utils/storage-security.d.ts.map +0 -1
  408. package/dist/utils/storage-security.js.map +0 -1
  409. package/dist/validation/request-validator.d.ts +0 -8
  410. package/dist/validation/request-validator.d.ts.map +0 -1
  411. package/dist/validation/request-validator.js +0 -32
  412. package/dist/validation/request-validator.js.map +0 -1
  413. package/dist/validation/response-validator.d.ts +0 -8
  414. package/dist/validation/response-validator.d.ts.map +0 -1
  415. package/dist/validation/response-validator.js +0 -110
  416. package/dist/validation/response-validator.js.map +0 -1
  417. package/dist/validation/schemas.d.ts +0 -1
  418. package/dist/validation/schemas.d.ts.map +0 -1
  419. package/dist/validation/schemas.js +0 -53
  420. package/dist/validation/schemas.js.map +0 -1
  421. /package/dist/{types/documentation-types.js → errors/app-error.js} +0 -0
  422. /package/dist/{types/loop-context-optimizer.js → runtime/brand.js} +0 -0
@@ -1,30 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InMemoryWorkflowStorage = void 0;
4
+ exports.createTestStorage = createTestStorage;
5
+ const workflow_1 = require("../../types/workflow");
4
6
  class InMemoryWorkflowStorage {
5
- constructor(workflows = []) {
6
- this.workflows = [...workflows];
7
+ constructor(definitions = [], source = (0, workflow_1.createBundledSource)()) {
8
+ this.kind = 'single';
9
+ this.source = source;
10
+ this.workflows = definitions.map(def => (0, workflow_1.createWorkflow)(def, source));
11
+ }
12
+ setWorkflows(definitions) {
13
+ this.workflows = definitions.map(def => (0, workflow_1.createWorkflow)(def, this.source));
7
14
  }
8
- setWorkflows(workflows) {
15
+ setWorkflowsRaw(workflows) {
9
16
  this.workflows = [...workflows];
10
17
  }
11
18
  async loadAllWorkflows() {
12
19
  return [...this.workflows];
13
20
  }
14
21
  async getWorkflowById(id) {
15
- return this.workflows.find((wf) => wf.id === id) || null;
22
+ return this.workflows.find((wf) => wf.definition.id === id) || null;
16
23
  }
17
24
  async listWorkflowSummaries() {
18
- return this.workflows.map((workflow) => ({
19
- id: workflow.id,
20
- name: workflow.name,
21
- description: workflow.description,
22
- category: 'default',
23
- version: workflow.version
24
- }));
25
+ return this.workflows.map(workflow_1.toWorkflowSummary);
25
26
  }
26
- async save(workflow) {
27
- const index = this.workflows.findIndex((w) => w.id === workflow.id);
27
+ async save(definition) {
28
+ const index = this.workflows.findIndex((w) => w.definition.id === definition.id);
29
+ const workflow = (0, workflow_1.createWorkflow)(definition, this.source);
28
30
  if (index >= 0) {
29
31
  this.workflows[index] = workflow;
30
32
  }
@@ -34,3 +36,6 @@ class InMemoryWorkflowStorage {
34
36
  }
35
37
  }
36
38
  exports.InMemoryWorkflowStorage = InMemoryWorkflowStorage;
39
+ function createTestStorage(definitions = [], source) {
40
+ return new InMemoryWorkflowStorage(definitions, source);
41
+ }
@@ -1,5 +1,5 @@
1
1
  import { IWorkflowStorage } from '../../types/storage';
2
- import { Workflow, WorkflowSummary } from '../../types/mcp-types';
2
+ import { Workflow, WorkflowSummary, WorkflowSource } from '../../types/workflow';
3
3
  export interface WorkflowPlugin {
4
4
  name: string;
5
5
  version: string;
@@ -26,15 +26,17 @@ export interface ValidatedPluginWorkflowConfig extends Required<PluginWorkflowCo
26
26
  maxPlugins: number;
27
27
  }
28
28
  export declare class PluginWorkflowStorage implements IWorkflowStorage {
29
+ readonly kind: "single";
30
+ readonly source: WorkflowSource;
29
31
  private readonly config;
30
32
  private pluginCache;
31
33
  private lastScan;
32
- constructor(config?: PluginWorkflowConfig);
34
+ constructor(config?: PluginWorkflowConfig, source?: WorkflowSource);
33
35
  private validateAndNormalizeConfig;
34
36
  private getDefaultPluginPaths;
35
- loadAllWorkflows(): Promise<Workflow[]>;
37
+ loadAllWorkflows(): Promise<readonly Workflow[]>;
36
38
  getWorkflowById(id: string): Promise<Workflow | null>;
37
- listWorkflowSummaries(): Promise<WorkflowSummary[]>;
39
+ listWorkflowSummaries(): Promise<readonly WorkflowSummary[]>;
38
40
  save(): Promise<void>;
39
41
  private scanPlugins;
40
42
  private isWorkflowPlugin;
@@ -43,17 +45,3 @@ export declare class PluginWorkflowStorage implements IWorkflowStorage {
43
45
  getLoadedPlugins(): WorkflowPlugin[];
44
46
  getConfig(): ValidatedPluginWorkflowConfig;
45
47
  }
46
- export declare const PLUGIN_WORKFLOW_CONFIGS: {
47
- development: {
48
- scanInterval: number;
49
- maxFileSize: number;
50
- maxFiles: number;
51
- maxPlugins: number;
52
- };
53
- production: {
54
- scanInterval: number;
55
- maxFileSize: number;
56
- maxFiles: number;
57
- maxPlugins: number;
58
- };
59
- };
@@ -3,17 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PLUGIN_WORKFLOW_CONFIGS = exports.PluginWorkflowStorage = void 0;
6
+ exports.PluginWorkflowStorage = void 0;
7
+ const workflow_1 = require("../../types/workflow");
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const promises_1 = __importDefault(require("fs/promises"));
9
10
  const fs_1 = require("fs");
10
11
  const storage_security_1 = require("../../utils/storage-security");
11
12
  const error_handler_1 = require("../../core/error-handler");
12
13
  class PluginWorkflowStorage {
13
- constructor(config = {}) {
14
+ constructor(config = {}, source) {
15
+ this.kind = 'single';
14
16
  this.pluginCache = new Map();
15
17
  this.lastScan = 0;
16
18
  this.config = this.validateAndNormalizeConfig(config);
19
+ this.source = source ?? (0, workflow_1.createPluginSource)('plugins', '1.0.0');
17
20
  }
18
21
  validateAndNormalizeConfig(config) {
19
22
  const securityOptions = (0, storage_security_1.validateSecurityOptions)({
@@ -50,10 +53,7 @@ class PluginWorkflowStorage {
50
53
  }
51
54
  }
52
55
  catch {
53
- const commonPaths = [
54
- '/usr/local/lib/node_modules',
55
- '/usr/lib/node_modules'
56
- ];
56
+ const commonPaths = ['/usr/local/lib/node_modules', '/usr/lib/node_modules'];
57
57
  for (const commonPath of commonPaths) {
58
58
  if ((0, fs_1.existsSync)(commonPath)) {
59
59
  paths.push(commonPath);
@@ -85,17 +85,11 @@ class PluginWorkflowStorage {
85
85
  async getWorkflowById(id) {
86
86
  const sanitizedId = (0, storage_security_1.sanitizeId)(id);
87
87
  const workflows = await this.loadAllWorkflows();
88
- return workflows.find(w => w.id === sanitizedId) || null;
88
+ return workflows.find(w => w.definition.id === sanitizedId) || null;
89
89
  }
90
90
  async listWorkflowSummaries() {
91
91
  const workflows = await this.loadAllWorkflows();
92
- return workflows.map(workflow => ({
93
- id: workflow.id,
94
- name: workflow.name,
95
- description: workflow.description,
96
- category: 'plugin',
97
- version: workflow.version
98
- }));
92
+ return workflows.map(workflow_1.toWorkflowSummary);
99
93
  }
100
94
  async save() {
101
95
  throw new error_handler_1.StorageError('Plugin-based storage is read-only. Publish workflows as npm packages instead.');
@@ -108,9 +102,8 @@ class PluginWorkflowStorage {
108
102
  this.pluginCache.clear();
109
103
  let pluginCount = 0;
110
104
  for (const pluginPath of this.config.pluginPaths) {
111
- if (!(0, fs_1.existsSync)(pluginPath)) {
105
+ if (!(0, fs_1.existsSync)(pluginPath))
112
106
  continue;
113
- }
114
107
  try {
115
108
  (0, storage_security_1.assertWithinBase)(pluginPath, pluginPath);
116
109
  const entries = await promises_1.default.readdir(pluginPath);
@@ -145,9 +138,8 @@ class PluginWorkflowStorage {
145
138
  try {
146
139
  (0, storage_security_1.assertWithinBase)(pluginPath, path_1.default.dirname(pluginPath));
147
140
  const packageJsonPath = path_1.default.join(pluginPath, 'package.json');
148
- if (!(0, fs_1.existsSync)(packageJsonPath)) {
141
+ if (!(0, fs_1.existsSync)(packageJsonPath))
149
142
  return null;
150
- }
151
143
  (0, storage_security_1.assertWithinBase)(packageJsonPath, pluginPath);
152
144
  const packageStats = await promises_1.default.stat(packageJsonPath);
153
145
  (0, storage_security_1.validateFileSize)(packageStats.size, Math.min(this.config.maxFileSize, 64 * 1024), 'package.json');
@@ -159,27 +151,27 @@ class PluginWorkflowStorage {
159
151
  catch (parseError) {
160
152
  throw new error_handler_1.InvalidWorkflowError(pluginPath, `Invalid package.json: ${parseError.message}`);
161
153
  }
162
- if (!packageJson.workrail || !packageJson.workrail.workflows) {
154
+ if (!packageJson['workrail'] || !packageJson['workrail']['workflows']) {
163
155
  return null;
164
156
  }
165
- if (!packageJson.name || typeof packageJson.name !== 'string') {
166
- throw new error_handler_1.InvalidWorkflowError(pluginPath, `Invalid package name`);
157
+ if (!packageJson['name'] || typeof packageJson['name'] !== 'string') {
158
+ throw new error_handler_1.InvalidWorkflowError(pluginPath, 'Invalid package name');
167
159
  }
168
160
  const workflowsPath = path_1.default.join(pluginPath, 'workflows');
169
- if (!(0, fs_1.existsSync)(workflowsPath)) {
161
+ if (!(0, fs_1.existsSync)(workflowsPath))
170
162
  return null;
171
- }
172
163
  (0, storage_security_1.assertWithinBase)(workflowsPath, pluginPath);
173
- const workflows = await this.loadWorkflowsFromDirectory(workflowsPath);
164
+ const pluginSource = (0, workflow_1.createPluginSource)(packageJson['name'], packageJson['version'] || '0.0.0');
165
+ const workflows = await this.loadWorkflowsFromDirectory(workflowsPath, pluginSource);
174
166
  return {
175
- name: packageJson.name,
176
- version: packageJson.version || '0.0.0',
167
+ name: packageJson['name'],
168
+ version: packageJson['version'] || '0.0.0',
177
169
  workflows,
178
170
  metadata: {
179
- author: packageJson.author,
180
- description: packageJson.description,
181
- homepage: packageJson.homepage,
182
- repository: packageJson.repository?.url || packageJson.repository
171
+ author: packageJson['author'],
172
+ description: packageJson['description'],
173
+ homepage: packageJson['homepage'],
174
+ repository: packageJson['repository']?.['url'] || packageJson['repository']
183
175
  }
184
176
  };
185
177
  }
@@ -190,7 +182,7 @@ class PluginWorkflowStorage {
190
182
  throw new error_handler_1.StorageError(`Failed to load plugin from ${pluginPath}: ${error.message}`);
191
183
  }
192
184
  }
193
- async loadWorkflowsFromDirectory(workflowsPath) {
185
+ async loadWorkflowsFromDirectory(workflowsPath, pluginSource) {
194
186
  const workflows = [];
195
187
  try {
196
188
  const files = await promises_1.default.readdir(workflowsPath);
@@ -205,18 +197,18 @@ class PluginWorkflowStorage {
205
197
  const stats = await promises_1.default.stat(filePath);
206
198
  (0, storage_security_1.validateFileSize)(stats.size, this.config.maxFileSize, file);
207
199
  const content = await promises_1.default.readFile(filePath, 'utf-8');
208
- let workflow;
200
+ let definition;
209
201
  try {
210
- workflow = JSON.parse(content);
202
+ definition = JSON.parse(content);
211
203
  }
212
204
  catch (parseError) {
213
205
  throw new error_handler_1.InvalidWorkflowError(file, `Invalid JSON in workflow file: ${parseError.message}`);
214
206
  }
215
- const sanitizedId = (0, storage_security_1.sanitizeId)(workflow.id);
216
- if (workflow.id !== sanitizedId) {
217
- throw new error_handler_1.InvalidWorkflowError(workflow.id, `Invalid workflow ID in file ${file}`);
207
+ const sanitizedId = (0, storage_security_1.sanitizeId)(definition.id);
208
+ if (definition.id !== sanitizedId) {
209
+ throw new error_handler_1.InvalidWorkflowError(definition.id, `Invalid workflow ID in file ${file}`);
218
210
  }
219
- workflows.push(workflow);
211
+ workflows.push((0, workflow_1.createWorkflow)(definition, pluginSource));
220
212
  }
221
213
  catch (error) {
222
214
  if (error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.InvalidWorkflowError) {
@@ -242,17 +234,3 @@ class PluginWorkflowStorage {
242
234
  }
243
235
  }
244
236
  exports.PluginWorkflowStorage = PluginWorkflowStorage;
245
- exports.PLUGIN_WORKFLOW_CONFIGS = {
246
- development: {
247
- scanInterval: 60000,
248
- maxFileSize: 2 * 1024 * 1024,
249
- maxFiles: 100,
250
- maxPlugins: 50
251
- },
252
- production: {
253
- scanInterval: 300000,
254
- maxFileSize: 1024 * 1024,
255
- maxFiles: 50,
256
- maxPlugins: 20
257
- }
258
- };
@@ -1,5 +1,5 @@
1
1
  import { IWorkflowStorage } from '../../types/storage';
2
- import { Workflow, WorkflowSummary } from '../../types/mcp-types';
2
+ import { Workflow, WorkflowSummary, WorkflowDefinition, WorkflowSource } from '../../types/workflow';
3
3
  import { StorageSecurityOptions } from '../../utils/storage-security';
4
4
  export interface RemoteWorkflowRegistryConfig extends StorageSecurityOptions {
5
5
  baseUrl: string;
@@ -9,26 +9,17 @@ export interface RemoteWorkflowRegistryConfig extends StorageSecurityOptions {
9
9
  userAgent?: string;
10
10
  }
11
11
  export declare class RemoteWorkflowStorage implements IWorkflowStorage {
12
+ readonly kind: "single";
13
+ readonly source: WorkflowSource;
12
14
  private readonly config;
13
15
  private readonly securityOptions;
14
- constructor(config: RemoteWorkflowRegistryConfig);
16
+ constructor(config: RemoteWorkflowRegistryConfig, source?: WorkflowSource);
15
17
  private validateConfig;
16
- loadAllWorkflows(): Promise<Workflow[]>;
18
+ loadAllWorkflows(): Promise<readonly Workflow[]>;
17
19
  getWorkflowById(id: string): Promise<Workflow | null>;
18
- listWorkflowSummaries(): Promise<WorkflowSummary[]>;
19
- save(workflow: Workflow): Promise<void>;
20
+ listWorkflowSummaries(): Promise<readonly WorkflowSummary[]>;
21
+ save(definition: WorkflowDefinition): Promise<void>;
20
22
  private fetchWithRetry;
21
23
  private parseResponse;
22
- private validateWorkflows;
23
- private validateSummaries;
24
- private validateWorkflowForSave;
25
- }
26
- export declare class CommunityWorkflowStorage implements IWorkflowStorage {
27
- private readonly sources;
28
- private readonly remoteStorage;
29
- constructor(bundledStorage: IWorkflowStorage, localStorage: IWorkflowStorage, remoteConfig: RemoteWorkflowRegistryConfig);
30
- loadAllWorkflows(): Promise<Workflow[]>;
31
- getWorkflowById(id: string): Promise<Workflow | null>;
32
- listWorkflowSummaries(): Promise<WorkflowSummary[]>;
33
- save(workflow: Workflow): Promise<void>;
24
+ private validateDefinitions;
34
25
  }
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommunityWorkflowStorage = exports.RemoteWorkflowStorage = void 0;
3
+ exports.RemoteWorkflowStorage = void 0;
4
+ const workflow_1 = require("../../types/workflow");
4
5
  const storage_security_1 = require("../../utils/storage-security");
5
6
  const error_handler_1 = require("../../core/error-handler");
6
7
  class RemoteWorkflowStorage {
7
- constructor(config) {
8
+ constructor(config, source) {
9
+ this.kind = 'single';
8
10
  this.validateConfig(config);
9
11
  this.securityOptions = (0, storage_security_1.validateSecurityOptions)(config);
10
12
  this.config = {
@@ -15,6 +17,7 @@ class RemoteWorkflowStorage {
15
17
  retryAttempts: config.retryAttempts || 3,
16
18
  userAgent: config.userAgent || 'workrail-mcp-server/1.0'
17
19
  };
20
+ this.source = source ?? (0, workflow_1.createRemoteRegistrySource)(this.config.baseUrl);
18
21
  }
19
22
  validateConfig(config) {
20
23
  if (!config.baseUrl) {
@@ -32,8 +35,9 @@ class RemoteWorkflowStorage {
32
35
  try {
33
36
  const response = await this.fetchWithRetry('/workflows');
34
37
  const data = await this.parseResponse(response);
35
- const workflows = data.workflows || data.data || [];
36
- return this.validateWorkflows(workflows);
38
+ const definitions = data.workflows || data.data || [];
39
+ const validDefinitions = this.validateDefinitions(definitions);
40
+ return validDefinitions.map(def => (0, workflow_1.createWorkflow)(def, this.source));
37
41
  }
38
42
  catch (error) {
39
43
  if (error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.StorageError) {
@@ -47,50 +51,41 @@ class RemoteWorkflowStorage {
47
51
  const sanitizedId = (0, storage_security_1.sanitizeId)(id);
48
52
  const response = await this.fetchWithRetry(`/workflows/${encodeURIComponent(sanitizedId)}`);
49
53
  if (!response.ok) {
50
- if (response.status === 404) {
54
+ if (response.status === 404)
51
55
  return null;
52
- }
53
56
  throw new error_handler_1.StorageError(`Remote registry returned ${response.status}: ${response.statusText}`, 'remote-fetch');
54
57
  }
55
- const workflow = await this.parseResponse(response);
56
- if (workflow.id !== sanitizedId) {
57
- throw new error_handler_1.InvalidWorkflowError(sanitizedId, `Registry returned workflow with mismatched ID: ${workflow.id}`);
58
+ const definition = await this.parseResponse(response);
59
+ if (definition.id !== sanitizedId) {
60
+ throw new error_handler_1.InvalidWorkflowError(sanitizedId, `Registry returned workflow with mismatched ID: ${definition.id}`);
58
61
  }
59
- return workflow;
62
+ return (0, workflow_1.createWorkflow)(definition, this.source);
60
63
  }
61
64
  catch (error) {
62
- if (error instanceof error_handler_1.SecurityError ||
63
- error instanceof error_handler_1.StorageError ||
64
- error instanceof error_handler_1.InvalidWorkflowError) {
65
+ if (error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.StorageError || error instanceof error_handler_1.InvalidWorkflowError) {
65
66
  throw error;
66
67
  }
67
68
  throw new error_handler_1.StorageError(`Failed to load workflow ${id} from remote registry: ${error.message}`, 'remote-fetch');
68
69
  }
69
70
  }
70
71
  async listWorkflowSummaries() {
71
- try {
72
- const response = await this.fetchWithRetry('/workflows/summaries');
73
- const data = await this.parseResponse(response);
74
- const summaries = data.summaries || data.data || [];
75
- return this.validateSummaries(summaries);
76
- }
77
- catch (error) {
78
- if (error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.StorageError) {
79
- throw error;
80
- }
81
- throw new error_handler_1.StorageError(`Failed to load workflow summaries from remote registry: ${error.message}`, 'remote-fetch');
82
- }
72
+ const workflows = await this.loadAllWorkflows();
73
+ return workflows.map(workflow_1.toWorkflowSummary);
83
74
  }
84
- async save(workflow) {
75
+ async save(definition) {
85
76
  try {
86
- const sanitizedWorkflow = this.validateWorkflowForSave(workflow);
77
+ if (!definition.id || !definition.name || !definition.steps) {
78
+ throw new error_handler_1.InvalidWorkflowError(definition.id || 'unknown', 'Workflow must have id, name, and steps');
79
+ }
80
+ const sanitizedId = (0, storage_security_1.sanitizeId)(definition.id);
81
+ const sanitizedDefinition = { ...definition, id: sanitizedId };
87
82
  const response = await this.fetchWithRetry('/workflows', {
88
83
  method: 'POST',
89
84
  headers: {
90
85
  'Content-Type': 'application/json',
91
86
  ...(this.config.apiKey && { 'Authorization': `Bearer ${this.config.apiKey}` })
92
87
  },
93
- body: JSON.stringify(sanitizedWorkflow)
88
+ body: JSON.stringify(sanitizedDefinition)
94
89
  });
95
90
  if (!response.ok) {
96
91
  const errorData = await this.parseResponse(response);
@@ -98,9 +93,7 @@ class RemoteWorkflowStorage {
98
93
  }
99
94
  }
100
95
  catch (error) {
101
- if (error instanceof error_handler_1.SecurityError ||
102
- error instanceof error_handler_1.StorageError ||
103
- error instanceof error_handler_1.InvalidWorkflowError) {
96
+ if (error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.StorageError || error instanceof error_handler_1.InvalidWorkflowError) {
104
97
  throw error;
105
98
  }
106
99
  throw new error_handler_1.StorageError(`Failed to save workflow to remote registry: ${error.message}`, 'remote-save');
@@ -127,9 +120,8 @@ class RemoteWorkflowStorage {
127
120
  }
128
121
  catch (error) {
129
122
  lastError = error;
130
- if (attempt === this.config.retryAttempts) {
123
+ if (attempt === this.config.retryAttempts)
131
124
  break;
132
- }
133
125
  const delay = Math.pow(2, attempt) * 1000 + Math.random() * 1000;
134
126
  await new Promise(resolve => setTimeout(resolve, delay));
135
127
  }
@@ -145,26 +137,23 @@ class RemoteWorkflowStorage {
145
137
  return JSON.parse(text);
146
138
  }
147
139
  catch (error) {
148
- if (error instanceof error_handler_1.StorageError) {
140
+ if (error instanceof error_handler_1.StorageError)
149
141
  throw error;
150
- }
151
142
  throw new error_handler_1.StorageError(`Failed to parse response from remote registry: ${error.message}`, 'parse-error');
152
143
  }
153
144
  }
154
- validateWorkflows(workflows) {
155
- if (!Array.isArray(workflows)) {
145
+ validateDefinitions(definitions) {
146
+ if (!Array.isArray(definitions)) {
156
147
  throw new error_handler_1.StorageError('Remote registry returned invalid workflows data', 'validation-error');
157
148
  }
158
- return workflows.filter((workflow) => {
149
+ return definitions.filter((def) => {
159
150
  try {
160
- if (!workflow || typeof workflow !== 'object') {
151
+ if (!def || typeof def !== 'object')
161
152
  return false;
162
- }
163
- const wf = workflow;
164
- if (!wf.id || !wf.name || !wf.steps) {
153
+ const d = def;
154
+ if (!d['id'] || !d['name'] || !d['steps'])
165
155
  return false;
166
- }
167
- (0, storage_security_1.sanitizeId)(wf.id);
156
+ (0, storage_security_1.sanitizeId)(d['id']);
168
157
  return true;
169
158
  }
170
159
  catch {
@@ -172,117 +161,5 @@ class RemoteWorkflowStorage {
172
161
  }
173
162
  });
174
163
  }
175
- validateSummaries(summaries) {
176
- if (!Array.isArray(summaries)) {
177
- throw new error_handler_1.StorageError('Remote registry returned invalid summaries data', 'validation-error');
178
- }
179
- return summaries.filter((summary) => {
180
- try {
181
- if (!summary || typeof summary !== 'object') {
182
- return false;
183
- }
184
- const s = summary;
185
- if (!s.id || !s.name) {
186
- return false;
187
- }
188
- (0, storage_security_1.sanitizeId)(s.id);
189
- return true;
190
- }
191
- catch {
192
- return false;
193
- }
194
- });
195
- }
196
- validateWorkflowForSave(workflow) {
197
- if (!workflow || typeof workflow !== 'object') {
198
- throw new error_handler_1.InvalidWorkflowError('unknown', 'Workflow must be a valid object');
199
- }
200
- if (!workflow.id || !workflow.name || !workflow.steps) {
201
- throw new error_handler_1.InvalidWorkflowError(workflow.id || 'unknown', 'Workflow must have id, name, and steps');
202
- }
203
- const sanitizedId = (0, storage_security_1.sanitizeId)(workflow.id);
204
- return {
205
- ...workflow,
206
- id: sanitizedId
207
- };
208
- }
209
164
  }
210
165
  exports.RemoteWorkflowStorage = RemoteWorkflowStorage;
211
- class CommunityWorkflowStorage {
212
- constructor(bundledStorage, localStorage, remoteConfig) {
213
- this.remoteStorage = new RemoteWorkflowStorage(remoteConfig);
214
- this.sources = [bundledStorage, localStorage, this.remoteStorage];
215
- }
216
- async loadAllWorkflows() {
217
- const allWorkflows = [];
218
- const seenIds = new Set();
219
- for (const source of this.sources) {
220
- try {
221
- const workflows = await source.loadAllWorkflows();
222
- for (const workflow of workflows) {
223
- if (seenIds.has(workflow.id)) {
224
- const existingIndex = allWorkflows.findIndex(wf => wf.id === workflow.id);
225
- if (existingIndex >= 0) {
226
- allWorkflows[existingIndex] = workflow;
227
- }
228
- }
229
- else {
230
- allWorkflows.push(workflow);
231
- seenIds.add(workflow.id);
232
- }
233
- }
234
- }
235
- catch (error) {
236
- if (error instanceof error_handler_1.StorageError) {
237
- console.warn(`Storage source failed (graceful degradation):`, error.message);
238
- }
239
- else {
240
- console.warn(`Unexpected error from storage source:`, error);
241
- }
242
- }
243
- }
244
- return allWorkflows;
245
- }
246
- async getWorkflowById(id) {
247
- try {
248
- const sanitizedId = (0, storage_security_1.sanitizeId)(id);
249
- for (let i = this.sources.length - 1; i >= 0; i--) {
250
- try {
251
- const workflow = await this.sources[i].getWorkflowById(sanitizedId);
252
- if (workflow) {
253
- return workflow;
254
- }
255
- }
256
- catch (error) {
257
- if (error instanceof error_handler_1.StorageError) {
258
- console.warn(`Storage source failed for workflow ${sanitizedId}:`, error.message);
259
- }
260
- else {
261
- console.warn(`Unexpected error from storage source for workflow ${sanitizedId}:`, error);
262
- }
263
- }
264
- }
265
- return null;
266
- }
267
- catch (error) {
268
- if (error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.InvalidWorkflowError) {
269
- throw error;
270
- }
271
- throw new error_handler_1.StorageError(`Failed to retrieve workflow ${id}: ${error.message}`, 'multi-source-error');
272
- }
273
- }
274
- async listWorkflowSummaries() {
275
- const workflows = await this.loadAllWorkflows();
276
- return workflows.map(workflow => ({
277
- id: workflow.id,
278
- name: workflow.name,
279
- description: workflow.description,
280
- category: 'community',
281
- version: workflow.version
282
- }));
283
- }
284
- async save(workflow) {
285
- return this.remoteStorage.save(workflow);
286
- }
287
- }
288
- exports.CommunityWorkflowStorage = CommunityWorkflowStorage;
@@ -1,18 +1,26 @@
1
- import { IWorkflowStorage } from '../../types/storage';
2
- import { Workflow } from '../../types/mcp-types';
1
+ import { IWorkflowStorage, ICompositeWorkflowStorage } from '../../types/storage';
2
+ import { Workflow, WorkflowSummary, WorkflowDefinition, WorkflowSource } from '../../types/workflow';
3
3
  export declare class SchemaValidatingWorkflowStorage implements IWorkflowStorage {
4
4
  private readonly inner;
5
- private validator;
5
+ readonly kind: "single";
6
+ private readonly validator;
6
7
  constructor(inner: IWorkflowStorage);
7
- private ensureValid;
8
- loadAllWorkflows(): Promise<Workflow[]>;
8
+ get source(): WorkflowSource;
9
+ private validateDefinition;
10
+ loadAllWorkflows(): Promise<readonly Workflow[]>;
9
11
  getWorkflowById(id: string): Promise<Workflow | null>;
10
- listWorkflowSummaries(): Promise<{
11
- id: string;
12
- name: string;
13
- description: string;
14
- category: string;
15
- version: string;
16
- }[]>;
17
- save?(workflow: Workflow): Promise<void>;
12
+ listWorkflowSummaries(): Promise<readonly WorkflowSummary[]>;
13
+ save(definition: WorkflowDefinition): Promise<void>;
14
+ }
15
+ export declare class SchemaValidatingCompositeWorkflowStorage implements ICompositeWorkflowStorage {
16
+ private readonly inner;
17
+ readonly kind: "composite";
18
+ private readonly validator;
19
+ constructor(inner: ICompositeWorkflowStorage);
20
+ private validateDefinition;
21
+ getSources(): readonly WorkflowSource[];
22
+ loadAllWorkflows(): Promise<readonly Workflow[]>;
23
+ getWorkflowById(id: string): Promise<Workflow | null>;
24
+ listWorkflowSummaries(): Promise<readonly WorkflowSummary[]>;
25
+ save(definition: WorkflowDefinition): Promise<void>;
18
26
  }