@exaudeus/workrail 0.8.6 → 0.10.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 (428) 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 +1117 -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/ids/with-healthy-session-lock.d.ts +7 -0
  195. package/dist/v2/durable-core/ids/with-healthy-session-lock.js +2 -0
  196. package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +47 -0
  197. package/dist/v2/durable-core/schemas/compiled-workflow/index.js +17 -0
  198. package/dist/v2/durable-core/schemas/session/events.d.ts +1812 -0
  199. package/dist/v2/durable-core/schemas/session/events.js +332 -0
  200. package/dist/v2/durable-core/schemas/session/index.d.ts +3 -0
  201. package/dist/v2/durable-core/schemas/session/index.js +8 -0
  202. package/dist/v2/durable-core/schemas/session/manifest.d.ts +57 -0
  203. package/dist/v2/durable-core/schemas/session/manifest.js +30 -0
  204. package/dist/v2/durable-core/schemas/session/session-health.d.ts +25 -0
  205. package/dist/v2/durable-core/schemas/session/session-health.js +2 -0
  206. package/dist/v2/infra/local/crypto/index.d.ts +5 -0
  207. package/dist/v2/infra/local/crypto/index.js +12 -0
  208. package/dist/v2/infra/local/data-dir/index.d.ts +13 -0
  209. package/dist/v2/infra/local/data-dir/index.js +69 -0
  210. package/dist/v2/infra/local/fs/index.d.ts +26 -0
  211. package/dist/v2/infra/local/fs/index.js +156 -0
  212. package/dist/v2/infra/local/pinned-workflow-store/index.d.ts +11 -0
  213. package/dist/v2/infra/local/pinned-workflow-store/index.js +85 -0
  214. package/dist/v2/infra/local/session-lock/index.d.ts +12 -0
  215. package/dist/v2/infra/local/session-lock/index.js +44 -0
  216. package/dist/v2/infra/local/session-store/index.d.ts +23 -0
  217. package/dist/v2/infra/local/session-store/index.js +473 -0
  218. package/dist/v2/infra/local/sha256/index.d.ts +5 -0
  219. package/dist/v2/infra/local/sha256/index.js +12 -0
  220. package/dist/v2/ports/data-dir.port.d.ts +9 -0
  221. package/dist/v2/ports/data-dir.port.js +2 -0
  222. package/dist/v2/ports/fs.port.d.ts +41 -0
  223. package/dist/v2/ports/fs.port.js +2 -0
  224. package/dist/v2/ports/pinned-workflow-store.port.d.ts +11 -0
  225. package/dist/v2/ports/pinned-workflow-store.port.js +2 -0
  226. package/dist/v2/ports/session-event-log-store.port.d.ts +49 -0
  227. package/dist/v2/ports/session-event-log-store.port.js +2 -0
  228. package/dist/v2/ports/session-lock.port.d.ts +23 -0
  229. package/dist/v2/ports/session-lock.port.js +2 -0
  230. package/dist/v2/ports/sha256.port.d.ts +4 -0
  231. package/dist/v2/ports/sha256.port.js +2 -0
  232. package/dist/v2/projections/advance-outcomes.d.ts +23 -0
  233. package/dist/v2/projections/advance-outcomes.js +23 -0
  234. package/dist/v2/projections/capabilities.d.ts +27 -0
  235. package/dist/v2/projections/capabilities.js +33 -0
  236. package/dist/v2/projections/gaps.d.ts +29 -0
  237. package/dist/v2/projections/gaps.js +49 -0
  238. package/dist/v2/projections/node-outputs.d.ts +34 -0
  239. package/dist/v2/projections/node-outputs.js +73 -0
  240. package/dist/v2/projections/preferences.d.ts +28 -0
  241. package/dist/v2/projections/preferences.js +50 -0
  242. package/dist/v2/projections/run-dag.d.ts +42 -0
  243. package/dist/v2/projections/run-dag.js +186 -0
  244. package/dist/v2/projections/run-status-signals.d.ts +26 -0
  245. package/dist/v2/projections/run-status-signals.js +49 -0
  246. package/dist/v2/projections/session-health.d.ts +4 -0
  247. package/dist/v2/projections/session-health.js +12 -0
  248. package/dist/v2/read-only/v1-to-v2-shim.d.ts +3 -0
  249. package/dist/v2/read-only/v1-to-v2-shim.js +38 -0
  250. package/dist/v2/usecases/execution-session-gate.d.ts +53 -0
  251. package/dist/v2/usecases/execution-session-gate.js +167 -0
  252. package/package.json +35 -10
  253. package/spec/mcp-api-v1.0.md +5 -5
  254. package/web/assets/services/data-normalizer.js +17 -2
  255. package/web/assets/services/pattern-recognizer.js +3 -1
  256. package/web/assets/services/session-data.js +13 -8
  257. package/web/assets/utils/formatters.js +34 -23
  258. package/workflows/CHANGELOG-bug-investigation.md +4 -4
  259. package/workflows/coding-task-workflow-agentic.json +262 -0
  260. package/workflows/design-thinking-workflow-autonomous.agentic.json +215 -0
  261. package/workflows/design-thinking-workflow.json +198 -0
  262. package/workflows/mr-review-workflow.agentic.json +538 -0
  263. package/workflows/routines/context-gathering.json +0 -4
  264. package/dist/application/app.d.ts +0 -29
  265. package/dist/application/app.d.ts.map +0 -1
  266. package/dist/application/app.js +0 -114
  267. package/dist/application/app.js.map +0 -1
  268. package/dist/application/decorators/simple-output-decorator.d.ts +0 -8
  269. package/dist/application/decorators/simple-output-decorator.js +0 -89
  270. package/dist/application/services/classification-engine.d.ts +0 -33
  271. package/dist/application/services/classification-engine.js +0 -258
  272. package/dist/application/services/compression-service.d.ts +0 -20
  273. package/dist/application/services/compression-service.js +0 -312
  274. package/dist/application/services/context-management-service.d.ts +0 -38
  275. package/dist/application/services/context-management-service.js +0 -301
  276. package/dist/application/services/context-optimizer.d.ts +0 -11
  277. package/dist/application/services/context-optimizer.js +0 -62
  278. package/dist/application/services/context-persistence-service.d.ts +0 -45
  279. package/dist/application/services/context-persistence-service.js +0 -273
  280. package/dist/application/services/documentation-service.d.ts +0 -20
  281. package/dist/application/services/documentation-service.js +0 -155
  282. package/dist/application/services/enhanced-error-service.d.ts.map +0 -1
  283. package/dist/application/services/enhanced-error-service.js.map +0 -1
  284. package/dist/application/services/loop-context-optimizer.d.ts +0 -8
  285. package/dist/application/services/loop-context-optimizer.js +0 -114
  286. package/dist/application/services/loop-execution-context.d.ts +0 -23
  287. package/dist/application/services/loop-execution-context.js +0 -188
  288. package/dist/application/services/loop-step-resolver.d.ts +0 -11
  289. package/dist/application/services/loop-step-resolver.js +0 -70
  290. package/dist/application/services/validation-engine.d.ts.map +0 -1
  291. package/dist/application/services/validation-engine.js.map +0 -1
  292. package/dist/application/services/workflow-service.d.ts.map +0 -1
  293. package/dist/application/services/workflow-service.js.map +0 -1
  294. package/dist/application/use-cases/get-next-step.d.ts.map +0 -1
  295. package/dist/application/use-cases/get-next-step.js.map +0 -1
  296. package/dist/application/use-cases/get-workflow-docs.d.ts +0 -4
  297. package/dist/application/use-cases/get-workflow-docs.js +0 -12
  298. package/dist/application/use-cases/get-workflow.d.ts.map +0 -1
  299. package/dist/application/use-cases/get-workflow.js.map +0 -1
  300. package/dist/application/use-cases/get-workrail-help.d.ts +0 -4
  301. package/dist/application/use-cases/get-workrail-help.js +0 -12
  302. package/dist/application/use-cases/list-workflows.d.ts.map +0 -1
  303. package/dist/application/use-cases/list-workflows.js.map +0 -1
  304. package/dist/application/use-cases/validate-step-output.d.ts.map +0 -1
  305. package/dist/application/use-cases/validate-step-output.js.map +0 -1
  306. package/dist/application/use-cases/validate-workflow-json.d.ts.map +0 -1
  307. package/dist/application/use-cases/validate-workflow-json.js.map +0 -1
  308. package/dist/application/validation.d.ts.map +0 -1
  309. package/dist/application/validation.js.map +0 -1
  310. package/dist/cli/migrate-workflow.d.ts +0 -22
  311. package/dist/cli/migrate-workflow.js +0 -196
  312. package/dist/cli.d.ts.map +0 -1
  313. package/dist/cli.js.map +0 -1
  314. package/dist/container.d.ts +0 -15
  315. package/dist/container.d.ts.map +0 -1
  316. package/dist/container.js +0 -25
  317. package/dist/container.js.map +0 -1
  318. package/dist/core/error-handler.d.ts.map +0 -1
  319. package/dist/core/error-handler.js.map +0 -1
  320. package/dist/domain/index.d.ts +0 -2
  321. package/dist/domain/index.d.ts.map +0 -1
  322. package/dist/domain/index.js +0 -18
  323. package/dist/domain/index.js.map +0 -1
  324. package/dist/index.d.ts.map +0 -1
  325. package/dist/index.js.map +0 -1
  326. package/dist/infrastructure/index.d.ts.map +0 -1
  327. package/dist/infrastructure/index.js.map +0 -1
  328. package/dist/infrastructure/rpc/handler.d.ts +0 -17
  329. package/dist/infrastructure/rpc/handler.d.ts.map +0 -1
  330. package/dist/infrastructure/rpc/handler.js +0 -78
  331. package/dist/infrastructure/rpc/handler.js.map +0 -1
  332. package/dist/infrastructure/rpc/index.d.ts +0 -1
  333. package/dist/infrastructure/rpc/index.d.ts.map +0 -1
  334. package/dist/infrastructure/rpc/index.js +0 -17
  335. package/dist/infrastructure/rpc/index.js.map +0 -1
  336. package/dist/infrastructure/rpc/server.d.ts +0 -3
  337. package/dist/infrastructure/rpc/server.d.ts.map +0 -1
  338. package/dist/infrastructure/rpc/server.js +0 -37
  339. package/dist/infrastructure/rpc/server.js.map +0 -1
  340. package/dist/infrastructure/storage/caching-workflow-storage.d.ts.map +0 -1
  341. package/dist/infrastructure/storage/caching-workflow-storage.js.map +0 -1
  342. package/dist/infrastructure/storage/context-storage.d.ts +0 -150
  343. package/dist/infrastructure/storage/context-storage.js +0 -40
  344. package/dist/infrastructure/storage/file-workflow-storage.d.ts.map +0 -1
  345. package/dist/infrastructure/storage/file-workflow-storage.js.map +0 -1
  346. package/dist/infrastructure/storage/filesystem-blob-storage.d.ts +0 -27
  347. package/dist/infrastructure/storage/filesystem-blob-storage.js +0 -363
  348. package/dist/infrastructure/storage/git-workflow-storage.d.ts.map +0 -1
  349. package/dist/infrastructure/storage/git-workflow-storage.js.map +0 -1
  350. package/dist/infrastructure/storage/hybrid-context-storage.d.ts +0 -29
  351. package/dist/infrastructure/storage/hybrid-context-storage.js +0 -400
  352. package/dist/infrastructure/storage/in-memory-storage.d.ts.map +0 -1
  353. package/dist/infrastructure/storage/in-memory-storage.js.map +0 -1
  354. package/dist/infrastructure/storage/index.d.ts.map +0 -1
  355. package/dist/infrastructure/storage/index.js.map +0 -1
  356. package/dist/infrastructure/storage/migrations/001_initial_schema.sql +0 -38
  357. package/dist/infrastructure/storage/migrations/002_context_concurrency_enhancements.sql +0 -234
  358. package/dist/infrastructure/storage/migrations/003_classification_overrides.sql +0 -20
  359. package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts +0 -32
  360. package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts.map +0 -1
  361. package/dist/infrastructure/storage/multi-directory-workflow-storage.js +0 -184
  362. package/dist/infrastructure/storage/multi-directory-workflow-storage.js.map +0 -1
  363. package/dist/infrastructure/storage/plugin-workflow-storage.d.ts.map +0 -1
  364. package/dist/infrastructure/storage/plugin-workflow-storage.js.map +0 -1
  365. package/dist/infrastructure/storage/remote-workflow-storage.d.ts.map +0 -1
  366. package/dist/infrastructure/storage/remote-workflow-storage.js.map +0 -1
  367. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts.map +0 -1
  368. package/dist/infrastructure/storage/schema-validating-workflow-storage.js.map +0 -1
  369. package/dist/infrastructure/storage/sqlite-metadata-storage.d.ts +0 -35
  370. package/dist/infrastructure/storage/sqlite-metadata-storage.js +0 -410
  371. package/dist/infrastructure/storage/sqlite-migrator.d.ts +0 -46
  372. package/dist/infrastructure/storage/sqlite-migrator.js +0 -293
  373. package/dist/infrastructure/storage/storage.d.ts.map +0 -1
  374. package/dist/infrastructure/storage/storage.js.map +0 -1
  375. package/dist/mcp-server.d.ts.map +0 -1
  376. package/dist/mcp-server.js.map +0 -1
  377. package/dist/tools/mcp_initialize.d.ts +0 -2
  378. package/dist/tools/mcp_initialize.d.ts.map +0 -1
  379. package/dist/tools/mcp_initialize.js +0 -45
  380. package/dist/tools/mcp_initialize.js.map +0 -1
  381. package/dist/tools/mcp_shutdown.d.ts +0 -2
  382. package/dist/tools/mcp_shutdown.d.ts.map +0 -1
  383. package/dist/tools/mcp_shutdown.js +0 -10
  384. package/dist/tools/mcp_shutdown.js.map +0 -1
  385. package/dist/tools/mcp_tools_list.d.ts +0 -2
  386. package/dist/tools/mcp_tools_list.d.ts.map +0 -1
  387. package/dist/tools/mcp_tools_list.js +0 -60
  388. package/dist/tools/mcp_tools_list.js.map +0 -1
  389. package/dist/tools/session-tools.d.ts +0 -5
  390. package/dist/tools/session-tools.js +0 -270
  391. package/dist/types/context-types.d.ts +0 -236
  392. package/dist/types/context-types.js +0 -10
  393. package/dist/types/documentation-types.d.ts +0 -37
  394. package/dist/types/loop-context-optimizer.d.ts +0 -7
  395. package/dist/types/mcp-types.d.ts +0 -273
  396. package/dist/types/mcp-types.d.ts.map +0 -1
  397. package/dist/types/mcp-types.js +0 -19
  398. package/dist/types/mcp-types.js.map +0 -1
  399. package/dist/types/server.d.ts.map +0 -1
  400. package/dist/types/server.js.map +0 -1
  401. package/dist/types/storage.d.ts.map +0 -1
  402. package/dist/types/storage.js.map +0 -1
  403. package/dist/types/workflow-types.d.ts +0 -336
  404. package/dist/types/workflow-types.d.ts.map +0 -1
  405. package/dist/types/workflow-types.js +0 -20
  406. package/dist/types/workflow-types.js.map +0 -1
  407. package/dist/utils/condition-evaluator.d.ts.map +0 -1
  408. package/dist/utils/condition-evaluator.js.map +0 -1
  409. package/dist/utils/config.d.ts +0 -149
  410. package/dist/utils/config.d.ts.map +0 -1
  411. package/dist/utils/config.js +0 -251
  412. package/dist/utils/config.js.map +0 -1
  413. package/dist/utils/storage-security.d.ts.map +0 -1
  414. package/dist/utils/storage-security.js.map +0 -1
  415. package/dist/validation/request-validator.d.ts +0 -8
  416. package/dist/validation/request-validator.d.ts.map +0 -1
  417. package/dist/validation/request-validator.js +0 -32
  418. package/dist/validation/request-validator.js.map +0 -1
  419. package/dist/validation/response-validator.d.ts +0 -8
  420. package/dist/validation/response-validator.d.ts.map +0 -1
  421. package/dist/validation/response-validator.js +0 -110
  422. package/dist/validation/response-validator.js.map +0 -1
  423. package/dist/validation/schemas.d.ts +0 -1
  424. package/dist/validation/schemas.d.ts.map +0 -1
  425. package/dist/validation/schemas.js +0 -53
  426. package/dist/validation/schemas.js.map +0 -1
  427. /package/dist/{types/documentation-types.js → errors/app-error.js} +0 -0
  428. /package/dist/{types/loop-context-optimizer.js → runtime/brand.js} +0 -0
@@ -0,0 +1,317 @@
1
+ import { z } from 'zod';
2
+ export type JsonValue = string | number | boolean | null | readonly JsonValue[] | {
3
+ readonly [key: string]: JsonValue;
4
+ };
5
+ export declare const JsonValueSchema: z.ZodType<JsonValue>;
6
+ export declare const WorkflowSummarySchema: z.ZodObject<{
7
+ id: z.ZodString;
8
+ name: z.ZodString;
9
+ description: z.ZodString;
10
+ version: z.ZodString;
11
+ }, "strip", z.ZodTypeAny, {
12
+ id: string;
13
+ name: string;
14
+ description: string;
15
+ version: string;
16
+ }, {
17
+ id: string;
18
+ name: string;
19
+ description: string;
20
+ version: string;
21
+ }>;
22
+ export declare const WorkflowListOutputSchema: z.ZodObject<{
23
+ workflows: z.ZodArray<z.ZodObject<{
24
+ id: z.ZodString;
25
+ name: z.ZodString;
26
+ description: z.ZodString;
27
+ version: z.ZodString;
28
+ }, "strip", z.ZodTypeAny, {
29
+ id: string;
30
+ name: string;
31
+ description: string;
32
+ version: string;
33
+ }, {
34
+ id: string;
35
+ name: string;
36
+ description: string;
37
+ version: string;
38
+ }>, "many">;
39
+ }, "strip", z.ZodTypeAny, {
40
+ workflows: {
41
+ id: string;
42
+ name: string;
43
+ description: string;
44
+ version: string;
45
+ }[];
46
+ }, {
47
+ workflows: {
48
+ id: string;
49
+ name: string;
50
+ description: string;
51
+ version: string;
52
+ }[];
53
+ }>;
54
+ export declare const WorkflowGetOutputSchema: z.ZodObject<{
55
+ workflow: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>;
56
+ }, "strip", z.ZodTypeAny, {
57
+ workflow: JsonValue;
58
+ }, {
59
+ workflow: JsonValue;
60
+ }>;
61
+ export declare const WorkflowNextOutputSchema: z.ZodObject<{
62
+ state: z.ZodType<import("../domain/execution/state.js").ExecutionState, z.ZodTypeDef, import("../domain/execution/state.js").ExecutionState>;
63
+ next: z.ZodNullable<z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>>;
64
+ isComplete: z.ZodBoolean;
65
+ }, "strip", z.ZodTypeAny, {
66
+ state: import("../domain/execution/state.js").ExecutionState;
67
+ next: JsonValue;
68
+ isComplete: boolean;
69
+ }, {
70
+ state: import("../domain/execution/state.js").ExecutionState;
71
+ next: JsonValue;
72
+ isComplete: boolean;
73
+ }>;
74
+ export declare const WorkflowValidateJsonOutputSchema: z.ZodObject<{
75
+ valid: z.ZodBoolean;
76
+ errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
77
+ message: z.ZodString;
78
+ path: z.ZodOptional<z.ZodString>;
79
+ }, "strip", z.ZodTypeAny, {
80
+ message: string;
81
+ path?: string | undefined;
82
+ }, {
83
+ message: string;
84
+ path?: string | undefined;
85
+ }>, "many">>;
86
+ suggestions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
87
+ }, "strip", z.ZodTypeAny, {
88
+ valid: boolean;
89
+ suggestions?: string[] | undefined;
90
+ errors?: {
91
+ message: string;
92
+ path?: string | undefined;
93
+ }[] | undefined;
94
+ }, {
95
+ valid: boolean;
96
+ suggestions?: string[] | undefined;
97
+ errors?: {
98
+ message: string;
99
+ path?: string | undefined;
100
+ }[] | undefined;
101
+ }>;
102
+ export declare const WorkflowGetSchemaOutputSchema: z.ZodObject<{
103
+ schema: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>;
104
+ metadata: z.ZodObject<{
105
+ version: z.ZodString;
106
+ description: z.ZodString;
107
+ usage: z.ZodString;
108
+ schemaPath: z.ZodString;
109
+ }, "strip", z.ZodTypeAny, {
110
+ description: string;
111
+ version: string;
112
+ usage: string;
113
+ schemaPath: string;
114
+ }, {
115
+ description: string;
116
+ version: string;
117
+ usage: string;
118
+ schemaPath: string;
119
+ }>;
120
+ commonPatterns: z.ZodObject<{
121
+ basicWorkflow: z.ZodRecord<z.ZodString, z.ZodString>;
122
+ stepStructure: z.ZodRecord<z.ZodString, z.ZodString>;
123
+ }, "strip", z.ZodTypeAny, {
124
+ basicWorkflow: Record<string, string>;
125
+ stepStructure: Record<string, string>;
126
+ }, {
127
+ basicWorkflow: Record<string, string>;
128
+ stepStructure: Record<string, string>;
129
+ }>;
130
+ }, "strip", z.ZodTypeAny, {
131
+ schema: JsonValue;
132
+ metadata: {
133
+ description: string;
134
+ version: string;
135
+ usage: string;
136
+ schemaPath: string;
137
+ };
138
+ commonPatterns: {
139
+ basicWorkflow: Record<string, string>;
140
+ stepStructure: Record<string, string>;
141
+ };
142
+ }, {
143
+ schema: JsonValue;
144
+ metadata: {
145
+ description: string;
146
+ version: string;
147
+ usage: string;
148
+ schemaPath: string;
149
+ };
150
+ commonPatterns: {
151
+ basicWorkflow: Record<string, string>;
152
+ stepStructure: Record<string, string>;
153
+ };
154
+ }>;
155
+ export declare const V2WorkflowListItemSchema: z.ZodObject<{
156
+ workflowId: z.ZodString;
157
+ name: z.ZodString;
158
+ description: z.ZodString;
159
+ version: z.ZodString;
160
+ kind: z.ZodLiteral<"workflow">;
161
+ workflowHash: z.ZodNullable<z.ZodString>;
162
+ }, "strip", z.ZodTypeAny, {
163
+ name: string;
164
+ description: string;
165
+ version: string;
166
+ kind: "workflow";
167
+ workflowId: string;
168
+ workflowHash: string | null;
169
+ }, {
170
+ name: string;
171
+ description: string;
172
+ version: string;
173
+ kind: "workflow";
174
+ workflowId: string;
175
+ workflowHash: string | null;
176
+ }>;
177
+ export declare const V2WorkflowListOutputSchema: z.ZodObject<{
178
+ workflows: z.ZodArray<z.ZodObject<{
179
+ workflowId: z.ZodString;
180
+ name: z.ZodString;
181
+ description: z.ZodString;
182
+ version: z.ZodString;
183
+ kind: z.ZodLiteral<"workflow">;
184
+ workflowHash: z.ZodNullable<z.ZodString>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ name: string;
187
+ description: string;
188
+ version: string;
189
+ kind: "workflow";
190
+ workflowId: string;
191
+ workflowHash: string | null;
192
+ }, {
193
+ name: string;
194
+ description: string;
195
+ version: string;
196
+ kind: "workflow";
197
+ workflowId: string;
198
+ workflowHash: string | null;
199
+ }>, "many">;
200
+ }, "strip", z.ZodTypeAny, {
201
+ workflows: {
202
+ name: string;
203
+ description: string;
204
+ version: string;
205
+ kind: "workflow";
206
+ workflowId: string;
207
+ workflowHash: string | null;
208
+ }[];
209
+ }, {
210
+ workflows: {
211
+ name: string;
212
+ description: string;
213
+ version: string;
214
+ kind: "workflow";
215
+ workflowId: string;
216
+ workflowHash: string | null;
217
+ }[];
218
+ }>;
219
+ export declare const V2WorkflowInspectOutputSchema: z.ZodObject<{
220
+ workflowId: z.ZodString;
221
+ workflowHash: z.ZodString;
222
+ mode: z.ZodEnum<["metadata", "preview"]>;
223
+ compiled: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>;
224
+ }, "strip", z.ZodTypeAny, {
225
+ workflowId: string;
226
+ mode: "metadata" | "preview";
227
+ workflowHash: string;
228
+ compiled: JsonValue;
229
+ }, {
230
+ workflowId: string;
231
+ mode: "metadata" | "preview";
232
+ workflowHash: string;
233
+ compiled: JsonValue;
234
+ }>;
235
+ export declare const CreateSessionOutputSchema: z.ZodObject<{
236
+ sessionId: z.ZodString;
237
+ workflowId: z.ZodString;
238
+ path: z.ZodString;
239
+ dashboardUrl: z.ZodNullable<z.ZodString>;
240
+ createdAt: z.ZodString;
241
+ }, "strip", z.ZodTypeAny, {
242
+ path: string;
243
+ workflowId: string;
244
+ sessionId: string;
245
+ dashboardUrl: string | null;
246
+ createdAt: string;
247
+ }, {
248
+ path: string;
249
+ workflowId: string;
250
+ sessionId: string;
251
+ dashboardUrl: string | null;
252
+ createdAt: string;
253
+ }>;
254
+ export declare const UpdateSessionOutputSchema: z.ZodObject<{
255
+ updatedAt: z.ZodString;
256
+ }, "strip", z.ZodTypeAny, {
257
+ updatedAt: string;
258
+ }, {
259
+ updatedAt: string;
260
+ }>;
261
+ export declare const ReadSessionOutputSchema: z.ZodObject<{
262
+ query: z.ZodString;
263
+ data: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>;
264
+ }, "strip", z.ZodTypeAny, {
265
+ query: string;
266
+ data: JsonValue;
267
+ }, {
268
+ query: string;
269
+ data: JsonValue;
270
+ }>;
271
+ export declare const ReadSessionSchemaOutputSchema: z.ZodObject<{
272
+ query: z.ZodLiteral<"$schema">;
273
+ schema: z.ZodObject<{
274
+ description: z.ZodString;
275
+ mainSections: z.ZodRecord<z.ZodString, z.ZodString>;
276
+ commonQueries: z.ZodRecord<z.ZodString, z.ZodString>;
277
+ updatePatterns: z.ZodRecord<z.ZodString, z.ZodString>;
278
+ fullSchemaDoc: z.ZodString;
279
+ }, "strip", z.ZodTypeAny, {
280
+ description: string;
281
+ mainSections: Record<string, string>;
282
+ commonQueries: Record<string, string>;
283
+ updatePatterns: Record<string, string>;
284
+ fullSchemaDoc: string;
285
+ }, {
286
+ description: string;
287
+ mainSections: Record<string, string>;
288
+ commonQueries: Record<string, string>;
289
+ updatePatterns: Record<string, string>;
290
+ fullSchemaDoc: string;
291
+ }>;
292
+ }, "strip", z.ZodTypeAny, {
293
+ schema: {
294
+ description: string;
295
+ mainSections: Record<string, string>;
296
+ commonQueries: Record<string, string>;
297
+ updatePatterns: Record<string, string>;
298
+ fullSchemaDoc: string;
299
+ };
300
+ query: "$schema";
301
+ }, {
302
+ schema: {
303
+ description: string;
304
+ mainSections: Record<string, string>;
305
+ commonQueries: Record<string, string>;
306
+ updatePatterns: Record<string, string>;
307
+ fullSchemaDoc: string;
308
+ };
309
+ query: "$schema";
310
+ }>;
311
+ export declare const OpenDashboardOutputSchema: z.ZodObject<{
312
+ url: z.ZodString;
313
+ }, "strip", z.ZodTypeAny, {
314
+ url: string;
315
+ }, {
316
+ url: string;
317
+ }>;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenDashboardOutputSchema = exports.ReadSessionSchemaOutputSchema = exports.ReadSessionOutputSchema = exports.UpdateSessionOutputSchema = exports.CreateSessionOutputSchema = exports.V2WorkflowInspectOutputSchema = exports.V2WorkflowListOutputSchema = exports.V2WorkflowListItemSchema = exports.WorkflowGetSchemaOutputSchema = exports.WorkflowValidateJsonOutputSchema = exports.WorkflowNextOutputSchema = exports.WorkflowGetOutputSchema = exports.WorkflowListOutputSchema = exports.WorkflowSummarySchema = exports.JsonValueSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const state_js_1 = require("../domain/execution/state.js");
6
+ const JsonPrimitiveSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()]);
7
+ exports.JsonValueSchema = zod_1.z.lazy(() => zod_1.z.union([JsonPrimitiveSchema, zod_1.z.array(exports.JsonValueSchema), zod_1.z.record(exports.JsonValueSchema)]));
8
+ exports.WorkflowSummarySchema = zod_1.z.object({
9
+ id: zod_1.z.string().min(1),
10
+ name: zod_1.z.string(),
11
+ description: zod_1.z.string(),
12
+ version: zod_1.z.string(),
13
+ });
14
+ exports.WorkflowListOutputSchema = zod_1.z.object({
15
+ workflows: zod_1.z.array(exports.WorkflowSummarySchema),
16
+ });
17
+ exports.WorkflowGetOutputSchema = zod_1.z.object({
18
+ workflow: exports.JsonValueSchema,
19
+ });
20
+ exports.WorkflowNextOutputSchema = zod_1.z.object({
21
+ state: state_js_1.ExecutionStateSchema,
22
+ next: exports.JsonValueSchema.nullable(),
23
+ isComplete: zod_1.z.boolean(),
24
+ });
25
+ exports.WorkflowValidateJsonOutputSchema = zod_1.z.object({
26
+ valid: zod_1.z.boolean(),
27
+ errors: zod_1.z
28
+ .array(zod_1.z.object({
29
+ message: zod_1.z.string(),
30
+ path: zod_1.z.string().optional(),
31
+ }))
32
+ .optional(),
33
+ suggestions: zod_1.z.array(zod_1.z.string()).optional(),
34
+ });
35
+ exports.WorkflowGetSchemaOutputSchema = zod_1.z.object({
36
+ schema: exports.JsonValueSchema,
37
+ metadata: zod_1.z.object({
38
+ version: zod_1.z.string(),
39
+ description: zod_1.z.string(),
40
+ usage: zod_1.z.string(),
41
+ schemaPath: zod_1.z.string(),
42
+ }),
43
+ commonPatterns: zod_1.z.object({
44
+ basicWorkflow: zod_1.z.record(zod_1.z.string()),
45
+ stepStructure: zod_1.z.record(zod_1.z.string()),
46
+ }),
47
+ });
48
+ exports.V2WorkflowListItemSchema = zod_1.z.object({
49
+ workflowId: zod_1.z.string().min(1),
50
+ name: zod_1.z.string().min(1),
51
+ description: zod_1.z.string().min(1),
52
+ version: zod_1.z.string().min(1),
53
+ kind: zod_1.z.literal('workflow'),
54
+ workflowHash: zod_1.z.string().nullable(),
55
+ });
56
+ exports.V2WorkflowListOutputSchema = zod_1.z.object({
57
+ workflows: zod_1.z.array(exports.V2WorkflowListItemSchema),
58
+ });
59
+ exports.V2WorkflowInspectOutputSchema = zod_1.z.object({
60
+ workflowId: zod_1.z.string().min(1),
61
+ workflowHash: zod_1.z.string().min(1),
62
+ mode: zod_1.z.enum(['metadata', 'preview']),
63
+ compiled: exports.JsonValueSchema,
64
+ });
65
+ exports.CreateSessionOutputSchema = zod_1.z.object({
66
+ sessionId: zod_1.z.string().min(1),
67
+ workflowId: zod_1.z.string().min(1),
68
+ path: zod_1.z.string(),
69
+ dashboardUrl: zod_1.z.string().nullable(),
70
+ createdAt: zod_1.z.string(),
71
+ });
72
+ exports.UpdateSessionOutputSchema = zod_1.z.object({
73
+ updatedAt: zod_1.z.string(),
74
+ });
75
+ exports.ReadSessionOutputSchema = zod_1.z.object({
76
+ query: zod_1.z.string(),
77
+ data: exports.JsonValueSchema,
78
+ });
79
+ exports.ReadSessionSchemaOutputSchema = zod_1.z.object({
80
+ query: zod_1.z.literal('$schema'),
81
+ schema: zod_1.z.object({
82
+ description: zod_1.z.string(),
83
+ mainSections: zod_1.z.record(zod_1.z.string()),
84
+ commonQueries: zod_1.z.record(zod_1.z.string()),
85
+ updatePatterns: zod_1.z.record(zod_1.z.string()),
86
+ fullSchemaDoc: zod_1.z.string(),
87
+ }),
88
+ });
89
+ exports.OpenDashboardOutputSchema = zod_1.z.object({
90
+ url: zod_1.z.string(),
91
+ });
@@ -0,0 +1,3 @@
1
+ import type { ToolContext } from './types.js';
2
+ export declare function createToolContext(): ToolContext;
3
+ export declare function startServer(): Promise<void>;
@@ -0,0 +1,258 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createToolContext = createToolContext;
37
+ exports.startServer = startServer;
38
+ const zod_to_json_schema_js_1 = require("./zod-to-json-schema.js");
39
+ const container_js_1 = require("../di/container.js");
40
+ const tokens_js_1 = require("../di/tokens.js");
41
+ const tool_factory_js_1 = require("./tool-factory.js");
42
+ const workflow_next_prevalidate_js_1 = require("./validation/workflow-next-prevalidate.js");
43
+ const bounded_json_js_1 = require("./validation/bounded-json.js");
44
+ const tools_js_1 = require("./tools.js");
45
+ const tool_registry_js_1 = require("./v2/tool-registry.js");
46
+ const workflow_js_1 = require("./handlers/workflow.js");
47
+ const session_js_1 = require("./handlers/session.js");
48
+ function toMcpResult(result) {
49
+ switch (result.type) {
50
+ case 'success':
51
+ return {
52
+ content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }],
53
+ };
54
+ case 'error':
55
+ return {
56
+ content: [{
57
+ type: 'text',
58
+ text: JSON.stringify({
59
+ error: result.message,
60
+ code: result.code,
61
+ ...(result.suggestion && { suggestion: result.suggestion }),
62
+ }, null, 2),
63
+ }],
64
+ isError: true,
65
+ };
66
+ }
67
+ }
68
+ function createToolContext() {
69
+ const workflowService = container_js_1.container.resolve(tokens_js_1.DI.Services.Workflow);
70
+ const featureFlags = container_js_1.container.resolve(tokens_js_1.DI.Infra.FeatureFlags);
71
+ let sessionManager = null;
72
+ let httpServer = null;
73
+ if (featureFlags.isEnabled('sessionTools')) {
74
+ sessionManager = container_js_1.container.resolve(tokens_js_1.DI.Infra.SessionManager);
75
+ httpServer = container_js_1.container.resolve(tokens_js_1.DI.Infra.HttpServer);
76
+ console.error('[FeatureFlags] Session tools enabled');
77
+ }
78
+ else {
79
+ console.error('[FeatureFlags] Session tools disabled (enable with WORKRAIL_ENABLE_SESSION_TOOLS=true)');
80
+ }
81
+ return {
82
+ workflowService,
83
+ featureFlags,
84
+ sessionManager,
85
+ httpServer,
86
+ };
87
+ }
88
+ function toMcpTool(tool) {
89
+ return {
90
+ name: tool.name,
91
+ description: tool.description,
92
+ inputSchema: (0, zod_to_json_schema_js_1.zodToJsonSchema)(tool.inputSchema),
93
+ annotations: tool.annotations,
94
+ };
95
+ }
96
+ function createHandler(schema, handler) {
97
+ return async (args, ctx) => {
98
+ const parseResult = schema.safeParse(args);
99
+ if (!parseResult.success) {
100
+ return {
101
+ content: [{
102
+ type: 'text',
103
+ text: JSON.stringify({
104
+ error: 'Invalid input',
105
+ code: 'VALIDATION_ERROR',
106
+ details: parseResult.error.errors.map(e => ({
107
+ path: e.path.join('.'),
108
+ message: e.message,
109
+ })),
110
+ }, null, 2),
111
+ }],
112
+ isError: true,
113
+ };
114
+ }
115
+ return toMcpResult(await handler(parseResult.data, ctx));
116
+ };
117
+ }
118
+ function createValidatingHandler(schema, preValidate, handler) {
119
+ return async (args, ctx) => {
120
+ const pre = preValidate(args);
121
+ if (!pre.ok) {
122
+ const bounded = pre.correctTemplate ? (0, bounded_json_js_1.toBoundedJsonValue)(pre.correctTemplate, 512) : undefined;
123
+ return {
124
+ content: [{
125
+ type: 'text',
126
+ text: JSON.stringify({
127
+ error: pre.message,
128
+ code: pre.code,
129
+ ...(bounded ? { correctTemplate: bounded } : {}),
130
+ }, null, 2),
131
+ }],
132
+ isError: true,
133
+ };
134
+ }
135
+ return createHandler(schema, handler)(args, ctx);
136
+ };
137
+ }
138
+ async function startServer() {
139
+ await (0, container_js_1.bootstrap)({ runtimeMode: { kind: 'production' } });
140
+ const ctx = createToolContext();
141
+ const descriptionProvider = container_js_1.container.resolve(tokens_js_1.DI.Mcp.DescriptionProvider);
142
+ const buildTool = (0, tool_factory_js_1.createToolFactory)(descriptionProvider);
143
+ const workflowListTool = buildTool({
144
+ name: 'workflow_list',
145
+ title: tools_js_1.WORKFLOW_TOOL_TITLES.workflow_list,
146
+ inputSchema: tools_js_1.WorkflowListInput,
147
+ annotations: tools_js_1.WORKFLOW_TOOL_ANNOTATIONS.workflow_list,
148
+ });
149
+ const workflowGetTool = buildTool({
150
+ name: 'workflow_get',
151
+ title: tools_js_1.WORKFLOW_TOOL_TITLES.workflow_get,
152
+ inputSchema: tools_js_1.WorkflowGetInput,
153
+ annotations: tools_js_1.WORKFLOW_TOOL_ANNOTATIONS.workflow_get,
154
+ });
155
+ const workflowNextTool = buildTool({
156
+ name: 'workflow_next',
157
+ title: tools_js_1.WORKFLOW_TOOL_TITLES.workflow_next,
158
+ inputSchema: tools_js_1.WorkflowNextInput,
159
+ annotations: tools_js_1.WORKFLOW_TOOL_ANNOTATIONS.workflow_next,
160
+ });
161
+ const workflowValidateJsonTool = buildTool({
162
+ name: 'workflow_validate_json',
163
+ title: tools_js_1.WORKFLOW_TOOL_TITLES.workflow_validate_json,
164
+ inputSchema: tools_js_1.WorkflowValidateJsonInput,
165
+ annotations: tools_js_1.WORKFLOW_TOOL_ANNOTATIONS.workflow_validate_json,
166
+ });
167
+ const workflowGetSchemaTool = buildTool({
168
+ name: 'workflow_get_schema',
169
+ title: tools_js_1.WORKFLOW_TOOL_TITLES.workflow_get_schema,
170
+ inputSchema: tools_js_1.WorkflowGetSchemaInput,
171
+ annotations: tools_js_1.WORKFLOW_TOOL_ANNOTATIONS.workflow_get_schema,
172
+ });
173
+ const { Server } = await Promise.resolve().then(() => __importStar(require('@modelcontextprotocol/sdk/server/index.js')));
174
+ const { StdioServerTransport } = await Promise.resolve().then(() => __importStar(require('@modelcontextprotocol/sdk/server/stdio.js')));
175
+ const { CallToolRequestSchema, ListToolsRequestSchema, } = await Promise.resolve().then(() => __importStar(require('@modelcontextprotocol/sdk/types.js')));
176
+ const server = new Server({
177
+ name: 'workrail-server',
178
+ version: '0.1.0',
179
+ }, {
180
+ capabilities: {
181
+ tools: {},
182
+ },
183
+ });
184
+ const tools = [
185
+ toMcpTool(workflowListTool),
186
+ toMcpTool(workflowGetTool),
187
+ toMcpTool(workflowNextTool),
188
+ toMcpTool(workflowValidateJsonTool),
189
+ toMcpTool(workflowGetSchemaTool),
190
+ ];
191
+ if (ctx.featureFlags.isEnabled('sessionTools')) {
192
+ tools.push(toMcpTool(tools_js_1.createSessionTool), toMcpTool(tools_js_1.updateSessionTool), toMcpTool(tools_js_1.readSessionTool), toMcpTool(tools_js_1.openDashboardTool));
193
+ }
194
+ const v2Registry = ctx.featureFlags.isEnabled('v2Tools') ? (0, tool_registry_js_1.buildV2ToolRegistry)(buildTool) : null;
195
+ if (v2Registry) {
196
+ console.error('[FeatureFlags] v2 tools enabled (enable with WORKRAIL_ENABLE_V2_TOOLS=true)');
197
+ tools.push(...v2Registry.tools.map(toMcpTool));
198
+ }
199
+ else {
200
+ console.error('[FeatureFlags] v2 tools disabled (enable with WORKRAIL_ENABLE_V2_TOOLS=true)');
201
+ }
202
+ const handlers = {
203
+ workflow_list: createHandler(tools_js_1.WorkflowListInput, workflow_js_1.handleWorkflowList),
204
+ workflow_get: createHandler(tools_js_1.WorkflowGetInput, workflow_js_1.handleWorkflowGet),
205
+ workflow_next: createValidatingHandler(tools_js_1.WorkflowNextInput, workflow_next_prevalidate_js_1.preValidateWorkflowNextArgs, workflow_js_1.handleWorkflowNext),
206
+ workflow_validate_json: createHandler(tools_js_1.WorkflowValidateJsonInput, workflow_js_1.handleWorkflowValidateJson),
207
+ workflow_get_schema: createHandler(tools_js_1.WorkflowGetSchemaInput, workflow_js_1.handleWorkflowGetSchema),
208
+ workrail_create_session: createHandler(tools_js_1.createSessionTool.inputSchema, session_js_1.handleCreateSession),
209
+ workrail_update_session: createHandler(tools_js_1.updateSessionTool.inputSchema, session_js_1.handleUpdateSession),
210
+ workrail_read_session: createHandler(tools_js_1.readSessionTool.inputSchema, session_js_1.handleReadSession),
211
+ workrail_open_dashboard: createHandler(tools_js_1.openDashboardTool.inputSchema, session_js_1.handleOpenDashboard),
212
+ };
213
+ if (v2Registry) {
214
+ for (const [name, entry] of Object.entries(v2Registry.handlers)) {
215
+ handlers[name] = createHandler(entry.schema, entry.handler);
216
+ }
217
+ }
218
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
219
+ tools,
220
+ }));
221
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
222
+ const { name, arguments: args } = request.params;
223
+ const handler = handlers[name];
224
+ if (!handler) {
225
+ return {
226
+ content: [{ type: 'text', text: `Unknown tool: ${name}` }],
227
+ isError: true,
228
+ };
229
+ }
230
+ return handler(args ?? {}, ctx);
231
+ });
232
+ const transport = new StdioServerTransport();
233
+ await server.connect(transport);
234
+ console.error('WorkRail MCP Server running on stdio');
235
+ const shutdownEvents = container_js_1.container.resolve(tokens_js_1.DI.Runtime.ShutdownEvents);
236
+ const processSignals = container_js_1.container.resolve(tokens_js_1.DI.Runtime.ProcessSignals);
237
+ const terminator = container_js_1.container.resolve(tokens_js_1.DI.Runtime.ProcessTerminator);
238
+ processSignals.on('SIGINT', () => shutdownEvents.emit({ kind: 'shutdown_requested', signal: 'SIGINT' }));
239
+ processSignals.on('SIGTERM', () => shutdownEvents.emit({ kind: 'shutdown_requested', signal: 'SIGTERM' }));
240
+ processSignals.on('SIGHUP', () => shutdownEvents.emit({ kind: 'shutdown_requested', signal: 'SIGHUP' }));
241
+ let shutdownStarted = false;
242
+ shutdownEvents.onShutdown((event) => {
243
+ if (shutdownStarted)
244
+ return;
245
+ shutdownStarted = true;
246
+ void (async () => {
247
+ try {
248
+ console.error(`[Shutdown] Requested by ${event.signal}. Stopping services...`);
249
+ await ctx.httpServer?.stop();
250
+ terminator.terminate({ kind: 'success' });
251
+ }
252
+ catch (err) {
253
+ console.error('[Shutdown] Error while stopping services:', err);
254
+ terminator.terminate({ kind: 'failure' });
255
+ }
256
+ })();
257
+ });
258
+ }
@@ -0,0 +1,16 @@
1
+ import type { IFeatureFlagProvider } from '../config/feature-flags.js';
2
+ import type { DescriptionMode, WorkflowToolName } from './types/tool-description-types.js';
3
+ export interface IToolDescriptionProvider {
4
+ readonly mode: DescriptionMode;
5
+ getDescription(toolName: WorkflowToolName): string;
6
+ }
7
+ export declare class ToolDescriptionProvider implements IToolDescriptionProvider {
8
+ readonly mode: DescriptionMode;
9
+ constructor(featureFlags: IFeatureFlagProvider);
10
+ getDescription(toolName: WorkflowToolName): string;
11
+ }
12
+ export declare class StaticToolDescriptionProvider implements IToolDescriptionProvider {
13
+ readonly mode: DescriptionMode;
14
+ constructor(mode: DescriptionMode);
15
+ getDescription(toolName: WorkflowToolName): string;
16
+ }