@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
@@ -0,0 +1,9 @@
1
+ import type { DomainError } from '../domain/execution/error.js';
2
+ import type { ErrorCode } from './types.js';
3
+ export interface ToolErrorMapping {
4
+ readonly code: ErrorCode;
5
+ readonly message: string;
6
+ readonly suggestion?: string;
7
+ }
8
+ export declare function mapDomainErrorToToolError(err: DomainError): ToolErrorMapping;
9
+ export declare function mapUnknownErrorToToolError(err: unknown): ToolErrorMapping;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapDomainErrorToToolError = mapDomainErrorToToolError;
4
+ exports.mapUnknownErrorToToolError = mapUnknownErrorToToolError;
5
+ const bounded_json_js_1 = require("./validation/bounded-json.js");
6
+ function assertNever(x) {
7
+ throw new Error(`Unhandled DomainError variant: ${JSON.stringify(x)}`);
8
+ }
9
+ function mapDomainErrorToToolError(err) {
10
+ switch (err._tag) {
11
+ case 'WorkflowNotFound':
12
+ return {
13
+ code: 'NOT_FOUND',
14
+ message: err.message,
15
+ suggestion: `Check available workflows with workflow_list`,
16
+ };
17
+ case 'InvalidState':
18
+ return {
19
+ code: 'VALIDATION_ERROR',
20
+ message: err.message,
21
+ suggestion: `Use the "state" returned by the last workflow_next call.\n` +
22
+ `If you are completing a step, send an event like:\n` +
23
+ (0, bounded_json_js_1.toBoundedJsonString)({
24
+ kind: 'step_completed',
25
+ stepInstanceId: {
26
+ stepId: '<previous next.stepInstanceId.stepId>',
27
+ loopPath: [],
28
+ },
29
+ }, 512),
30
+ };
31
+ case 'InvalidLoop':
32
+ return {
33
+ code: 'VALIDATION_ERROR',
34
+ message: err.message,
35
+ suggestion: 'Validate the workflow definition and ensure loop/body step IDs are consistent',
36
+ };
37
+ case 'MissingContext':
38
+ return {
39
+ code: 'PRECONDITION_FAILED',
40
+ message: err.message,
41
+ suggestion: 'Provide the required keys in the `context` object for condition evaluation and loop inputs.\n' +
42
+ 'Example:\n' +
43
+ (0, bounded_json_js_1.toBoundedJsonString)({ context: { '<requiredKey>': '<value>' } }, 256),
44
+ };
45
+ case 'ConditionEvalFailed':
46
+ return {
47
+ code: 'INTERNAL_ERROR',
48
+ message: err.message,
49
+ suggestion: 'Validate workflow JSON and condition expressions with workflow_validate_json',
50
+ };
51
+ case 'MaxIterationsExceeded':
52
+ return {
53
+ code: 'PRECONDITION_FAILED',
54
+ message: err.message,
55
+ suggestion: `Increase maxIterations for loop '${err.loopId}' or adjust its condition/body`,
56
+ };
57
+ default:
58
+ return assertNever(err);
59
+ }
60
+ }
61
+ function mapUnknownErrorToToolError(err) {
62
+ if (err instanceof Error) {
63
+ return { code: 'INTERNAL_ERROR', message: err.message };
64
+ }
65
+ return { code: 'INTERNAL_ERROR', message: String(err) };
66
+ }
@@ -0,0 +1,34 @@
1
+ import type { ToolContext, ToolResult } from '../types.js';
2
+ import type { CreateSessionInput, UpdateSessionInput, ReadSessionInput, OpenDashboardInput } from '../tools.js';
3
+ export interface CreateSessionOutput {
4
+ sessionId: string;
5
+ workflowId: string;
6
+ path: string;
7
+ dashboardUrl: string | null;
8
+ createdAt: string;
9
+ }
10
+ export interface UpdateSessionOutput {
11
+ updatedAt: string;
12
+ }
13
+ export interface ReadSessionOutput {
14
+ query: string;
15
+ data: unknown;
16
+ }
17
+ export interface SchemaOverview {
18
+ description: string;
19
+ mainSections: Record<string, string>;
20
+ commonQueries: Record<string, string>;
21
+ updatePatterns: Record<string, string>;
22
+ fullSchemaDoc: string;
23
+ }
24
+ export interface ReadSessionSchemaOutput {
25
+ query: '$schema';
26
+ schema: SchemaOverview;
27
+ }
28
+ export interface OpenDashboardOutput {
29
+ url: string;
30
+ }
31
+ export declare function handleCreateSession(input: CreateSessionInput, ctx: ToolContext): Promise<ToolResult<CreateSessionOutput>>;
32
+ export declare function handleUpdateSession(input: UpdateSessionInput, ctx: ToolContext): Promise<ToolResult<UpdateSessionOutput>>;
33
+ export declare function handleReadSession(input: ReadSessionInput, ctx: ToolContext): Promise<ToolResult<ReadSessionOutput | ReadSessionSchemaOutput>>;
34
+ export declare function handleOpenDashboard(input: OpenDashboardInput, ctx: ToolContext): Promise<ToolResult<OpenDashboardOutput>>;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleCreateSession = handleCreateSession;
4
+ exports.handleUpdateSession = handleUpdateSession;
5
+ exports.handleReadSession = handleReadSession;
6
+ exports.handleOpenDashboard = handleOpenDashboard;
7
+ const types_js_1 = require("../types.js");
8
+ const output_schemas_js_1 = require("../output-schemas.js");
9
+ const error_mapper_js_1 = require("../error-mapper.js");
10
+ const SESSION_SCHEMA_OVERVIEW = {
11
+ description: 'Bug Investigation Session Data Structure',
12
+ mainSections: {
13
+ dashboard: 'Real-time UI display (progress, confidence, currentPhase, status)',
14
+ bugSummary: 'Initial bug context (title, description, impact, reproduction)',
15
+ phases: 'Detailed phase progress (phase-0, phase-1, etc.)',
16
+ hypotheses: 'Array of investigation theories with status tracking',
17
+ ruledOut: 'Array of rejected hypotheses',
18
+ timeline: 'Array of timestamped events',
19
+ confidenceJourney: 'Array of confidence changes over time',
20
+ codebaseMap: 'Spatial understanding of components (optional)',
21
+ rootCause: 'Final diagnosis (set in Phase 6)',
22
+ fix: 'Proposed solution (set in Phase 6)',
23
+ recommendations: 'Future prevention steps (set in Phase 6)',
24
+ metadata: 'Technical details (workflowVersion, projectType, etc.)',
25
+ },
26
+ commonQueries: {
27
+ 'dashboard': 'Get all dashboard fields',
28
+ 'dashboard.progress': 'Get just progress percentage',
29
+ 'timeline': 'Get all timeline events',
30
+ 'hypotheses': 'Get all hypotheses',
31
+ 'hypotheses[0]': 'Get first hypothesis',
32
+ 'phases.phase-1': 'Get Phase 1 data',
33
+ 'confidenceJourney': 'Get confidence history',
34
+ },
35
+ updatePatterns: {
36
+ incrementalProgress: 'workrail_update_session(wf, id, {"dashboard.progress": 35, "dashboard.currentPhase": "Phase 2"})',
37
+ addTimelineEvent: 'Read timeline array, append event, write back',
38
+ updateConfidence: 'Update both dashboard.confidence AND confidenceJourney array',
39
+ completePhase: 'Set phases.phase-X.complete = true and add summary',
40
+ },
41
+ fullSchemaDoc: 'See docs/dashboard-architecture/bug-investigation-session-schema.md for complete details',
42
+ };
43
+ function requireSessionTools(ctx) {
44
+ if (!ctx.sessionManager || !ctx.httpServer) {
45
+ return (0, types_js_1.error)('PRECONDITION_FAILED', 'Session tools are not enabled', 'Set WORKRAIL_ENABLE_SESSION_TOOLS=true to enable session tools');
46
+ }
47
+ return null;
48
+ }
49
+ async function handleCreateSession(input, ctx) {
50
+ const guardError = requireSessionTools(ctx);
51
+ if (guardError)
52
+ return guardError;
53
+ const sessionManager = ctx.sessionManager;
54
+ const httpServer = ctx.httpServer;
55
+ try {
56
+ const session = await sessionManager.createSession(input.workflowId, input.sessionId, input.initialData);
57
+ const baseUrl = httpServer.getBaseUrl();
58
+ const dashboardUrl = baseUrl ? `${baseUrl}?session=${input.sessionId}` : null;
59
+ const payload = output_schemas_js_1.CreateSessionOutputSchema.parse({
60
+ sessionId: session.id,
61
+ workflowId: session.workflowId,
62
+ path: sessionManager.getSessionPath(input.workflowId, input.sessionId),
63
+ dashboardUrl,
64
+ createdAt: session.createdAt,
65
+ });
66
+ return (0, types_js_1.success)(payload);
67
+ }
68
+ catch (err) {
69
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
70
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
71
+ }
72
+ }
73
+ async function handleUpdateSession(input, ctx) {
74
+ const guardError = requireSessionTools(ctx);
75
+ if (guardError)
76
+ return guardError;
77
+ const sessionManager = ctx.sessionManager;
78
+ try {
79
+ await sessionManager.updateSession(input.workflowId, input.sessionId, input.updates);
80
+ const payload = output_schemas_js_1.UpdateSessionOutputSchema.parse({ updatedAt: new Date().toISOString() });
81
+ return (0, types_js_1.success)(payload);
82
+ }
83
+ catch (err) {
84
+ const message = err instanceof Error ? err.message : String(err);
85
+ if (message.toLowerCase().includes('not found')) {
86
+ return (0, types_js_1.error)('NOT_FOUND', message, 'Make sure the session exists. Use workrail_create_session() first.');
87
+ }
88
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
89
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
90
+ }
91
+ }
92
+ async function handleReadSession(input, ctx) {
93
+ const guardError = requireSessionTools(ctx);
94
+ if (guardError)
95
+ return guardError;
96
+ const sessionManager = ctx.sessionManager;
97
+ if (input.path === '$schema') {
98
+ const payload = output_schemas_js_1.ReadSessionSchemaOutputSchema.parse({
99
+ query: '$schema',
100
+ schema: SESSION_SCHEMA_OVERVIEW,
101
+ });
102
+ return (0, types_js_1.success)(payload);
103
+ }
104
+ try {
105
+ const data = await sessionManager.readSession(input.workflowId, input.sessionId, input.path);
106
+ const payload = output_schemas_js_1.ReadSessionOutputSchema.parse({
107
+ query: input.path ?? '(full session)',
108
+ data,
109
+ });
110
+ return (0, types_js_1.success)(payload);
111
+ }
112
+ catch (err) {
113
+ const message = err instanceof Error ? err.message : String(err);
114
+ if (message.toLowerCase().includes('not found')) {
115
+ return (0, types_js_1.error)('NOT_FOUND', message, 'Make sure the session exists. Use workrail_create_session() first.');
116
+ }
117
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
118
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
119
+ }
120
+ }
121
+ async function handleOpenDashboard(input, ctx) {
122
+ const guardError = requireSessionTools(ctx);
123
+ if (guardError)
124
+ return guardError;
125
+ const httpServer = ctx.httpServer;
126
+ try {
127
+ const url = await httpServer.openDashboard(input.sessionId);
128
+ const payload = output_schemas_js_1.OpenDashboardOutputSchema.parse({ url });
129
+ return (0, types_js_1.success)(payload);
130
+ }
131
+ catch (err) {
132
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
133
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
134
+ }
135
+ }
@@ -0,0 +1,4 @@
1
+ import type { ToolContext, ToolResult } from '../types.js';
2
+ import type { V2InspectWorkflowInput, V2ListWorkflowsInput } from '../v2/tools.js';
3
+ export declare function handleV2ListWorkflows(_input: V2ListWorkflowsInput, ctx: ToolContext): Promise<ToolResult<unknown>>;
4
+ export declare function handleV2InspectWorkflow(input: V2InspectWorkflowInput, ctx: ToolContext): Promise<ToolResult<unknown>>;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleV2ListWorkflows = handleV2ListWorkflows;
4
+ exports.handleV2InspectWorkflow = handleV2InspectWorkflow;
5
+ const types_js_1 = require("../types.js");
6
+ const error_mapper_js_1 = require("../error-mapper.js");
7
+ const output_schemas_js_1 = require("../output-schemas.js");
8
+ const v1_to_v2_shim_js_1 = require("../../v2/read-only/v1-to-v2-shim.js");
9
+ const index_js_1 = require("../../v2/infra/local/crypto/index.js");
10
+ const index_js_2 = require("../../v2/infra/local/data-dir/index.js");
11
+ const index_js_3 = require("../../v2/infra/local/pinned-workflow-store/index.js");
12
+ const hashing_js_1 = require("../../v2/durable-core/canonical/hashing.js");
13
+ const TIMEOUT_MS = 30000;
14
+ async function withTimeout(operation, timeoutMs, name) {
15
+ const timeoutPromise = new Promise((_, reject) => {
16
+ setTimeout(() => reject(new Error(`${name} timed out after ${timeoutMs}ms`)), timeoutMs);
17
+ });
18
+ return Promise.race([operation, timeoutPromise]);
19
+ }
20
+ async function handleV2ListWorkflows(_input, ctx) {
21
+ try {
22
+ const summaries = await withTimeout(ctx.workflowService.listWorkflowSummaries(), TIMEOUT_MS, 'list_workflows');
23
+ const crypto = new index_js_1.NodeCryptoV2();
24
+ const dataDir = new index_js_2.LocalDataDirV2(process.env);
25
+ const pinnedStore = new index_js_3.LocalPinnedWorkflowStoreV2(dataDir);
26
+ const compiled = await Promise.all(summaries.map(async (s) => {
27
+ const wf = await ctx.workflowService.getWorkflowById(s.id);
28
+ if (!wf) {
29
+ return {
30
+ workflowId: s.id,
31
+ name: s.name,
32
+ description: s.description,
33
+ version: s.version,
34
+ workflowHash: null,
35
+ kind: 'workflow',
36
+ };
37
+ }
38
+ const snapshot = (0, v1_to_v2_shim_js_1.compileV1WorkflowToV2CompiledSnapshotV1)(wf);
39
+ const hashRes = (0, hashing_js_1.workflowHashForCompiledSnapshot)(snapshot, crypto);
40
+ if (hashRes.isErr()) {
41
+ return {
42
+ workflowId: s.id,
43
+ name: s.name,
44
+ description: s.description,
45
+ version: s.version,
46
+ workflowHash: null,
47
+ kind: 'workflow',
48
+ };
49
+ }
50
+ const hash = hashRes.value;
51
+ const existing = await pinnedStore.get(hash).match((v) => v, () => null);
52
+ if (!existing) {
53
+ await pinnedStore.put(hash, snapshot).match(() => undefined, () => undefined);
54
+ }
55
+ return {
56
+ workflowId: s.id,
57
+ name: s.name,
58
+ description: s.description,
59
+ version: s.version,
60
+ workflowHash: hash,
61
+ kind: 'workflow',
62
+ };
63
+ }));
64
+ const payload = output_schemas_js_1.V2WorkflowListOutputSchema.parse({
65
+ workflows: compiled.sort((a, b) => a.workflowId.localeCompare(b.workflowId)),
66
+ });
67
+ return (0, types_js_1.success)(payload);
68
+ }
69
+ catch (err) {
70
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
71
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
72
+ }
73
+ }
74
+ async function handleV2InspectWorkflow(input, ctx) {
75
+ try {
76
+ const workflow = await withTimeout(ctx.workflowService.getWorkflowById(input.workflowId), TIMEOUT_MS, 'inspect_workflow');
77
+ if (!workflow) {
78
+ return (0, types_js_1.error)('NOT_FOUND', `Workflow not found: ${input.workflowId}`);
79
+ }
80
+ const crypto = new index_js_1.NodeCryptoV2();
81
+ const dataDir = new index_js_2.LocalDataDirV2(process.env);
82
+ const pinnedStore = new index_js_3.LocalPinnedWorkflowStoreV2(dataDir);
83
+ const snapshot = (0, v1_to_v2_shim_js_1.compileV1WorkflowToV2CompiledSnapshotV1)(workflow);
84
+ const hashRes = (0, hashing_js_1.workflowHashForCompiledSnapshot)(snapshot, crypto);
85
+ if (hashRes.isErr()) {
86
+ return (0, types_js_1.error)('INTERNAL_ERROR', hashRes.error.message);
87
+ }
88
+ const workflowHash = hashRes.value;
89
+ const existing = await pinnedStore.get(workflowHash).match((v) => v, () => null);
90
+ if (!existing) {
91
+ const wrote = await pinnedStore.put(workflowHash, snapshot).match(() => ({ ok: true }), (e) => ({ ok: false, error: e }));
92
+ if (!wrote.ok) {
93
+ return (0, types_js_1.error)('INTERNAL_ERROR', wrote.error.message);
94
+ }
95
+ }
96
+ const compiled = (await pinnedStore.get(workflowHash).match((v) => v, () => null)) ?? snapshot;
97
+ const body = input.mode === 'metadata'
98
+ ? { schemaVersion: compiled.schemaVersion, sourceKind: compiled.sourceKind, workflowId: compiled.workflowId }
99
+ : compiled;
100
+ const payload = output_schemas_js_1.V2WorkflowInspectOutputSchema.parse({
101
+ workflowId: input.workflowId,
102
+ workflowHash,
103
+ mode: input.mode,
104
+ compiled: body,
105
+ });
106
+ return (0, types_js_1.success)(payload);
107
+ }
108
+ catch (err) {
109
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
110
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
111
+ }
112
+ }
@@ -0,0 +1,45 @@
1
+ import type { ToolContext, ToolResult } from '../types.js';
2
+ import type { WorkflowListInput, WorkflowGetInput, WorkflowNextInput, WorkflowValidateJsonInput, WorkflowGetSchemaInput } from '../tools.js';
3
+ export interface WorkflowSummary {
4
+ id: string;
5
+ name: string;
6
+ description: string;
7
+ version: string;
8
+ }
9
+ export interface WorkflowListOutput {
10
+ workflows: readonly WorkflowSummary[];
11
+ }
12
+ export interface WorkflowGetOutput {
13
+ workflow: unknown;
14
+ }
15
+ export interface WorkflowNextOutput {
16
+ state: unknown;
17
+ next: unknown | null;
18
+ isComplete: boolean;
19
+ }
20
+ export interface WorkflowValidateJsonOutput {
21
+ valid: boolean;
22
+ errors?: Array<{
23
+ message: string;
24
+ path?: string;
25
+ }>;
26
+ suggestions?: string[];
27
+ }
28
+ export interface WorkflowGetSchemaOutput {
29
+ schema: unknown;
30
+ metadata: {
31
+ version: string;
32
+ description: string;
33
+ usage: string;
34
+ schemaPath: string;
35
+ };
36
+ commonPatterns: {
37
+ basicWorkflow: Record<string, string>;
38
+ stepStructure: Record<string, string>;
39
+ };
40
+ }
41
+ export declare function handleWorkflowList(_input: WorkflowListInput, ctx: ToolContext): Promise<ToolResult<WorkflowListOutput>>;
42
+ export declare function handleWorkflowGet(input: WorkflowGetInput, ctx: ToolContext): Promise<ToolResult<WorkflowGetOutput>>;
43
+ export declare function handleWorkflowNext(input: WorkflowNextInput, ctx: ToolContext): Promise<ToolResult<WorkflowNextOutput>>;
44
+ export declare function handleWorkflowValidateJson(input: WorkflowValidateJsonInput, ctx: ToolContext): Promise<ToolResult<WorkflowValidateJsonOutput>>;
45
+ export declare function handleWorkflowGetSchema(_input: WorkflowGetSchemaInput, ctx: ToolContext): Promise<ToolResult<WorkflowGetSchemaOutput>>;
@@ -0,0 +1,167 @@
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.handleWorkflowList = handleWorkflowList;
37
+ exports.handleWorkflowGet = handleWorkflowGet;
38
+ exports.handleWorkflowNext = handleWorkflowNext;
39
+ exports.handleWorkflowValidateJson = handleWorkflowValidateJson;
40
+ exports.handleWorkflowGetSchema = handleWorkflowGetSchema;
41
+ const types_js_1 = require("../types.js");
42
+ const output_schemas_js_1 = require("../output-schemas.js");
43
+ const error_mapper_js_1 = require("../error-mapper.js");
44
+ const TIMEOUT_MS = 30000;
45
+ async function withTimeout(operation, timeoutMs, operationName) {
46
+ const timeoutPromise = new Promise((_, reject) => {
47
+ setTimeout(() => {
48
+ reject(new Error(`${operationName} timed out after ${timeoutMs}ms`));
49
+ }, timeoutMs);
50
+ });
51
+ return Promise.race([operation, timeoutPromise]);
52
+ }
53
+ async function handleWorkflowList(_input, ctx) {
54
+ try {
55
+ const workflows = await withTimeout(ctx.workflowService.listWorkflowSummaries(), TIMEOUT_MS, 'workflow_list');
56
+ const payload = output_schemas_js_1.WorkflowListOutputSchema.parse({ workflows });
57
+ return (0, types_js_1.success)(payload);
58
+ }
59
+ catch (err) {
60
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
61
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
62
+ }
63
+ }
64
+ async function handleWorkflowGet(input, ctx) {
65
+ try {
66
+ const { createGetWorkflow } = await Promise.resolve().then(() => __importStar(require('../../application/use-cases/get-workflow.js')));
67
+ const getWorkflowUseCase = createGetWorkflow(ctx.workflowService);
68
+ const result = await withTimeout(getWorkflowUseCase(input.id, input.mode), TIMEOUT_MS, 'workflow_get');
69
+ if (result.isErr()) {
70
+ const mapped = (0, error_mapper_js_1.mapDomainErrorToToolError)(result.error);
71
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
72
+ }
73
+ const payload = output_schemas_js_1.WorkflowGetOutputSchema.parse({ workflow: result.value });
74
+ return (0, types_js_1.success)(payload);
75
+ }
76
+ catch (err) {
77
+ const message = err instanceof Error ? err.message : String(err);
78
+ if (message.includes('timed out')) {
79
+ return (0, types_js_1.error)('TIMEOUT', message);
80
+ }
81
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
82
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
83
+ }
84
+ }
85
+ async function handleWorkflowNext(input, ctx) {
86
+ const startTime = Date.now();
87
+ try {
88
+ console.error(`[workflow_next] Starting with workflowId=${input.workflowId}, ` +
89
+ `stateKind=${input.state.kind}, ` +
90
+ `eventKind=${input.event?.kind ?? 'none'}, ` +
91
+ `contextKeys=${Object.keys(input.context ?? {})}`);
92
+ const result = await withTimeout(ctx.workflowService.getNextStep(input.workflowId, input.state, input.event, input.context), TIMEOUT_MS, 'workflow_next');
93
+ console.error(`[workflow_next] Completed in ${Date.now() - startTime}ms, ` +
94
+ `returned=${result.isOk() ? 'ok' : 'err'}`);
95
+ if (result.isErr()) {
96
+ const mapped = (0, error_mapper_js_1.mapDomainErrorToToolError)(result.error);
97
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
98
+ }
99
+ const payload = output_schemas_js_1.WorkflowNextOutputSchema.parse(result.value);
100
+ return (0, types_js_1.success)(payload);
101
+ }
102
+ catch (err) {
103
+ const elapsed = Date.now() - startTime;
104
+ const message = err instanceof Error ? err.message : String(err);
105
+ console.error(`[workflow_next] Failed after ${elapsed}ms: ${message}`);
106
+ if (message.includes('timed out')) {
107
+ return (0, types_js_1.error)('TIMEOUT', message);
108
+ }
109
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
110
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
111
+ }
112
+ }
113
+ async function handleWorkflowValidateJson(input, ctx) {
114
+ void ctx;
115
+ try {
116
+ const { createValidateWorkflowJson } = await Promise.resolve().then(() => __importStar(require('../../application/use-cases/validate-workflow-json.js')));
117
+ const validateWorkflowJsonUseCase = createValidateWorkflowJson();
118
+ const result = await validateWorkflowJsonUseCase(input.workflowJson);
119
+ const payload = output_schemas_js_1.WorkflowValidateJsonOutputSchema.parse(result);
120
+ return (0, types_js_1.success)(payload);
121
+ }
122
+ catch (err) {
123
+ const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
124
+ return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
125
+ }
126
+ }
127
+ async function handleWorkflowGetSchema(_input, ctx) {
128
+ void ctx;
129
+ try {
130
+ const fs = await Promise.resolve().then(() => __importStar(require('fs')));
131
+ const path = await Promise.resolve().then(() => __importStar(require('path')));
132
+ const schemaPath = path.resolve(__dirname, '../../../spec/workflow.schema.json');
133
+ const schemaContent = fs.readFileSync(schemaPath, 'utf-8');
134
+ const schema = JSON.parse(schemaContent);
135
+ const result = {
136
+ schema,
137
+ metadata: {
138
+ version: '1.0.0',
139
+ description: 'Complete JSON schema for workflow files',
140
+ usage: 'This schema defines the structure, required fields, and validation rules for workflow JSON files',
141
+ schemaPath: 'spec/workflow.schema.json',
142
+ },
143
+ commonPatterns: {
144
+ basicWorkflow: {
145
+ id: 'string (required): Unique identifier using lowercase letters, numbers, and hyphens',
146
+ name: 'string (required): Human-readable workflow name',
147
+ description: 'string (required): Detailed description of the workflow purpose',
148
+ version: 'string (required): Semantic version (e.g., "1.0.0")',
149
+ steps: 'array (required): List of workflow steps, minimum 1 item',
150
+ },
151
+ stepStructure: {
152
+ id: 'string (required): Unique step identifier',
153
+ title: 'string (required): Human-readable step title',
154
+ prompt: 'string (required): Instructions for the step',
155
+ agentRole: 'string (required): Role description for the agent',
156
+ validationCriteria: 'array (optional): Validation rules for step output',
157
+ },
158
+ },
159
+ };
160
+ const payload = output_schemas_js_1.WorkflowGetSchemaOutputSchema.parse(result);
161
+ return (0, types_js_1.success)(payload);
162
+ }
163
+ catch (err) {
164
+ const message = err instanceof Error ? err.message : String(err);
165
+ return (0, types_js_1.error)('INTERNAL_ERROR', message, 'Ensure the workflow schema file exists at spec/workflow.schema.json');
166
+ }
167
+ }
@@ -0,0 +1,16 @@
1
+ export type { ErrorCode, ToolSuccess, ToolError, ToolResult, ToolContext, ToolHandler, } from './types.js';
2
+ export { success, error, } from './types.js';
3
+ export type { ToolAnnotations, ToolDefinition, ToolConfig, ToolBuilder, } from './tool-factory.js';
4
+ export { createToolFactory } from './tool-factory.js';
5
+ export type { DescriptionMode, WorkflowToolName, ToolDescriptionMap, DescriptionsByMode, } from './types/tool-description-types.js';
6
+ export { DESCRIPTION_MODES, WORKFLOW_TOOL_NAMES, isDescriptionMode, isWorkflowToolName, } from './types/tool-description-types.js';
7
+ export type { IToolDescriptionProvider } from './tool-description-provider.js';
8
+ export { ToolDescriptionProvider, StaticToolDescriptionProvider, } from './tool-description-provider.js';
9
+ export { DESCRIPTIONS } from './tool-descriptions.js';
10
+ export { WorkflowListInput, WorkflowGetInput, WorkflowNextInput, WorkflowValidateJsonInput, WorkflowGetSchemaInput, WORKFLOW_TOOL_ANNOTATIONS, WORKFLOW_TOOL_TITLES, CreateSessionInput, UpdateSessionInput, ReadSessionInput, OpenDashboardInput, createSessionTool, updateSessionTool, readSessionTool, openDashboardTool, sessionTools, } from './tools.js';
11
+ export { handleWorkflowList, handleWorkflowGet, handleWorkflowNext, handleWorkflowValidateJson, handleWorkflowGetSchema, } from './handlers/workflow.js';
12
+ export type { WorkflowSummary, WorkflowListOutput, WorkflowGetOutput, WorkflowNextOutput, WorkflowValidateJsonOutput, WorkflowGetSchemaOutput, } from './handlers/workflow.js';
13
+ export { handleCreateSession, handleUpdateSession, handleReadSession, handleOpenDashboard, } from './handlers/session.js';
14
+ export type { CreateSessionOutput, UpdateSessionOutput, ReadSessionOutput, ReadSessionSchemaOutput, SchemaOverview, OpenDashboardOutput, } from './handlers/session.js';
15
+ export { createToolContext, startServer, } from './server.js';
16
+ export { zodToJsonSchema } from './zod-to-json-schema.js';
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zodToJsonSchema = exports.startServer = exports.createToolContext = exports.handleOpenDashboard = exports.handleReadSession = exports.handleUpdateSession = exports.handleCreateSession = exports.handleWorkflowGetSchema = exports.handleWorkflowValidateJson = exports.handleWorkflowNext = exports.handleWorkflowGet = exports.handleWorkflowList = exports.sessionTools = exports.openDashboardTool = exports.readSessionTool = exports.updateSessionTool = exports.createSessionTool = exports.OpenDashboardInput = exports.ReadSessionInput = exports.UpdateSessionInput = exports.CreateSessionInput = exports.WORKFLOW_TOOL_TITLES = exports.WORKFLOW_TOOL_ANNOTATIONS = exports.WorkflowGetSchemaInput = exports.WorkflowValidateJsonInput = exports.WorkflowNextInput = exports.WorkflowGetInput = exports.WorkflowListInput = exports.DESCRIPTIONS = exports.StaticToolDescriptionProvider = exports.ToolDescriptionProvider = exports.isWorkflowToolName = exports.isDescriptionMode = exports.WORKFLOW_TOOL_NAMES = exports.DESCRIPTION_MODES = exports.createToolFactory = exports.error = exports.success = void 0;
4
+ var types_js_1 = require("./types.js");
5
+ Object.defineProperty(exports, "success", { enumerable: true, get: function () { return types_js_1.success; } });
6
+ Object.defineProperty(exports, "error", { enumerable: true, get: function () { return types_js_1.error; } });
7
+ var tool_factory_js_1 = require("./tool-factory.js");
8
+ Object.defineProperty(exports, "createToolFactory", { enumerable: true, get: function () { return tool_factory_js_1.createToolFactory; } });
9
+ var tool_description_types_js_1 = require("./types/tool-description-types.js");
10
+ Object.defineProperty(exports, "DESCRIPTION_MODES", { enumerable: true, get: function () { return tool_description_types_js_1.DESCRIPTION_MODES; } });
11
+ Object.defineProperty(exports, "WORKFLOW_TOOL_NAMES", { enumerable: true, get: function () { return tool_description_types_js_1.WORKFLOW_TOOL_NAMES; } });
12
+ Object.defineProperty(exports, "isDescriptionMode", { enumerable: true, get: function () { return tool_description_types_js_1.isDescriptionMode; } });
13
+ Object.defineProperty(exports, "isWorkflowToolName", { enumerable: true, get: function () { return tool_description_types_js_1.isWorkflowToolName; } });
14
+ var tool_description_provider_js_1 = require("./tool-description-provider.js");
15
+ Object.defineProperty(exports, "ToolDescriptionProvider", { enumerable: true, get: function () { return tool_description_provider_js_1.ToolDescriptionProvider; } });
16
+ Object.defineProperty(exports, "StaticToolDescriptionProvider", { enumerable: true, get: function () { return tool_description_provider_js_1.StaticToolDescriptionProvider; } });
17
+ var tool_descriptions_js_1 = require("./tool-descriptions.js");
18
+ Object.defineProperty(exports, "DESCRIPTIONS", { enumerable: true, get: function () { return tool_descriptions_js_1.DESCRIPTIONS; } });
19
+ var tools_js_1 = require("./tools.js");
20
+ Object.defineProperty(exports, "WorkflowListInput", { enumerable: true, get: function () { return tools_js_1.WorkflowListInput; } });
21
+ Object.defineProperty(exports, "WorkflowGetInput", { enumerable: true, get: function () { return tools_js_1.WorkflowGetInput; } });
22
+ Object.defineProperty(exports, "WorkflowNextInput", { enumerable: true, get: function () { return tools_js_1.WorkflowNextInput; } });
23
+ Object.defineProperty(exports, "WorkflowValidateJsonInput", { enumerable: true, get: function () { return tools_js_1.WorkflowValidateJsonInput; } });
24
+ Object.defineProperty(exports, "WorkflowGetSchemaInput", { enumerable: true, get: function () { return tools_js_1.WorkflowGetSchemaInput; } });
25
+ Object.defineProperty(exports, "WORKFLOW_TOOL_ANNOTATIONS", { enumerable: true, get: function () { return tools_js_1.WORKFLOW_TOOL_ANNOTATIONS; } });
26
+ Object.defineProperty(exports, "WORKFLOW_TOOL_TITLES", { enumerable: true, get: function () { return tools_js_1.WORKFLOW_TOOL_TITLES; } });
27
+ Object.defineProperty(exports, "CreateSessionInput", { enumerable: true, get: function () { return tools_js_1.CreateSessionInput; } });
28
+ Object.defineProperty(exports, "UpdateSessionInput", { enumerable: true, get: function () { return tools_js_1.UpdateSessionInput; } });
29
+ Object.defineProperty(exports, "ReadSessionInput", { enumerable: true, get: function () { return tools_js_1.ReadSessionInput; } });
30
+ Object.defineProperty(exports, "OpenDashboardInput", { enumerable: true, get: function () { return tools_js_1.OpenDashboardInput; } });
31
+ Object.defineProperty(exports, "createSessionTool", { enumerable: true, get: function () { return tools_js_1.createSessionTool; } });
32
+ Object.defineProperty(exports, "updateSessionTool", { enumerable: true, get: function () { return tools_js_1.updateSessionTool; } });
33
+ Object.defineProperty(exports, "readSessionTool", { enumerable: true, get: function () { return tools_js_1.readSessionTool; } });
34
+ Object.defineProperty(exports, "openDashboardTool", { enumerable: true, get: function () { return tools_js_1.openDashboardTool; } });
35
+ Object.defineProperty(exports, "sessionTools", { enumerable: true, get: function () { return tools_js_1.sessionTools; } });
36
+ var workflow_js_1 = require("./handlers/workflow.js");
37
+ Object.defineProperty(exports, "handleWorkflowList", { enumerable: true, get: function () { return workflow_js_1.handleWorkflowList; } });
38
+ Object.defineProperty(exports, "handleWorkflowGet", { enumerable: true, get: function () { return workflow_js_1.handleWorkflowGet; } });
39
+ Object.defineProperty(exports, "handleWorkflowNext", { enumerable: true, get: function () { return workflow_js_1.handleWorkflowNext; } });
40
+ Object.defineProperty(exports, "handleWorkflowValidateJson", { enumerable: true, get: function () { return workflow_js_1.handleWorkflowValidateJson; } });
41
+ Object.defineProperty(exports, "handleWorkflowGetSchema", { enumerable: true, get: function () { return workflow_js_1.handleWorkflowGetSchema; } });
42
+ var session_js_1 = require("./handlers/session.js");
43
+ Object.defineProperty(exports, "handleCreateSession", { enumerable: true, get: function () { return session_js_1.handleCreateSession; } });
44
+ Object.defineProperty(exports, "handleUpdateSession", { enumerable: true, get: function () { return session_js_1.handleUpdateSession; } });
45
+ Object.defineProperty(exports, "handleReadSession", { enumerable: true, get: function () { return session_js_1.handleReadSession; } });
46
+ Object.defineProperty(exports, "handleOpenDashboard", { enumerable: true, get: function () { return session_js_1.handleOpenDashboard; } });
47
+ var server_js_1 = require("./server.js");
48
+ Object.defineProperty(exports, "createToolContext", { enumerable: true, get: function () { return server_js_1.createToolContext; } });
49
+ Object.defineProperty(exports, "startServer", { enumerable: true, get: function () { return server_js_1.startServer; } });
50
+ var zod_to_json_schema_js_1 = require("./zod-to-json-schema.js");
51
+ Object.defineProperty(exports, "zodToJsonSchema", { enumerable: true, get: function () { return zod_to_json_schema_js_1.zodToJsonSchema; } });