@exaudeus/workrail 0.8.6 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/README.md +157 -403
  2. package/dist/application/services/enhanced-loop-validator.d.ts +2 -2
  3. package/dist/application/services/enhanced-loop-validator.js +12 -2
  4. package/dist/application/services/validation-engine.d.ts +8 -29
  5. package/dist/application/services/validation-engine.js +38 -21
  6. package/dist/application/services/workflow-compiler.d.ts +18 -0
  7. package/dist/application/services/workflow-compiler.js +79 -0
  8. package/dist/application/services/workflow-interpreter.d.ts +31 -0
  9. package/dist/application/services/workflow-interpreter.js +280 -0
  10. package/dist/application/services/workflow-service.d.ts +34 -32
  11. package/dist/application/services/workflow-service.js +93 -425
  12. package/dist/application/use-cases/get-next-step.d.ts +6 -10
  13. package/dist/application/use-cases/get-next-step.js +2 -6
  14. package/dist/application/use-cases/get-workflow.d.ts +8 -6
  15. package/dist/application/use-cases/get-workflow.js +42 -33
  16. package/dist/application/use-cases/list-workflows.d.ts +3 -3
  17. package/dist/application/use-cases/validate-step-output.d.ts +4 -4
  18. package/dist/application/use-cases/validate-workflow-file.d.ts +46 -0
  19. package/dist/application/use-cases/validate-workflow-file.js +57 -0
  20. package/dist/cli/commands/cleanup.d.ts +8 -0
  21. package/dist/cli/commands/cleanup.js +20 -0
  22. package/dist/cli/commands/index.d.ts +7 -0
  23. package/dist/cli/commands/index.js +21 -0
  24. package/dist/cli/commands/init.d.ts +11 -0
  25. package/dist/cli/commands/init.js +49 -0
  26. package/dist/cli/commands/list.d.ts +9 -0
  27. package/dist/cli/commands/list.js +34 -0
  28. package/dist/cli/commands/migrate.d.ts +78 -0
  29. package/dist/cli/commands/migrate.js +248 -0
  30. package/dist/cli/commands/sources.d.ts +21 -0
  31. package/dist/cli/commands/sources.js +87 -0
  32. package/dist/cli/commands/start.d.ts +8 -0
  33. package/dist/cli/commands/start.js +16 -0
  34. package/dist/cli/commands/validate.d.ts +6 -0
  35. package/dist/cli/commands/validate.js +55 -0
  36. package/dist/cli/interpret-result.d.ts +4 -0
  37. package/dist/cli/interpret-result.js +24 -0
  38. package/dist/cli/output-formatter.d.ts +10 -0
  39. package/dist/cli/output-formatter.js +97 -0
  40. package/dist/cli/types/cli-result.d.ts +23 -0
  41. package/dist/cli/types/cli-result.js +30 -0
  42. package/dist/cli/types/exit-code.d.ts +13 -0
  43. package/dist/cli/types/exit-code.js +23 -0
  44. package/dist/cli/types/index.d.ts +4 -0
  45. package/dist/cli/types/index.js +11 -0
  46. package/dist/cli.js +84 -278
  47. package/dist/config/app-config.d.ts +40 -0
  48. package/dist/config/app-config.js +58 -0
  49. package/dist/config/feature-flags.d.ts +10 -2
  50. package/dist/config/feature-flags.js +74 -12
  51. package/dist/core/error-handler.d.ts +18 -27
  52. package/dist/core/error-handler.js +24 -218
  53. package/dist/di/container.d.ts +12 -0
  54. package/dist/di/container.js +244 -0
  55. package/dist/di/tokens.d.ts +40 -0
  56. package/dist/di/tokens.js +42 -0
  57. package/dist/domain/execution/error.d.ts +32 -0
  58. package/dist/domain/execution/error.js +24 -0
  59. package/dist/domain/execution/event.d.ts +7 -0
  60. package/dist/domain/execution/event.js +11 -0
  61. package/dist/domain/execution/ids.d.ts +9 -0
  62. package/dist/domain/execution/ids.js +9 -0
  63. package/dist/domain/execution/result.d.ts +3 -0
  64. package/dist/domain/execution/result.js +10 -0
  65. package/dist/domain/execution/state.d.ts +57 -0
  66. package/dist/domain/execution/state.js +28 -0
  67. package/dist/errors/app-error.d.ts +23 -0
  68. package/dist/errors/factories.d.ts +6 -0
  69. package/dist/errors/factories.js +21 -0
  70. package/dist/errors/formatter.d.ts +2 -0
  71. package/dist/errors/formatter.js +32 -0
  72. package/dist/errors/index.d.ts +3 -0
  73. package/dist/errors/index.js +7 -0
  74. package/dist/index.d.ts +6 -1
  75. package/dist/index.js +10 -25
  76. package/dist/infrastructure/index.d.ts +0 -1
  77. package/dist/infrastructure/index.js +0 -1
  78. package/dist/infrastructure/session/DashboardHeartbeat.d.ts +8 -0
  79. package/dist/infrastructure/session/DashboardHeartbeat.js +39 -0
  80. package/dist/infrastructure/session/DashboardLockRelease.d.ts +2 -0
  81. package/dist/infrastructure/session/DashboardLockRelease.js +29 -0
  82. package/dist/infrastructure/session/HttpServer.d.ts +25 -6
  83. package/dist/infrastructure/session/HttpServer.js +245 -90
  84. package/dist/infrastructure/session/SessionDataNormalizer.js +12 -2
  85. package/dist/infrastructure/session/SessionDataValidator.js +12 -2
  86. package/dist/infrastructure/session/SessionManager.d.ts +5 -3
  87. package/dist/infrastructure/session/SessionManager.js +52 -6
  88. package/dist/infrastructure/storage/caching-workflow-storage.d.ts +30 -6
  89. package/dist/infrastructure/storage/caching-workflow-storage.js +105 -23
  90. package/dist/infrastructure/storage/enhanced-multi-source-workflow-storage.d.ts +13 -9
  91. package/dist/infrastructure/storage/enhanced-multi-source-workflow-storage.js +45 -39
  92. package/dist/infrastructure/storage/file-workflow-storage.d.ts +10 -8
  93. package/dist/infrastructure/storage/file-workflow-storage.js +48 -56
  94. package/dist/infrastructure/storage/git-workflow-storage.d.ts +7 -22
  95. package/dist/infrastructure/storage/git-workflow-storage.js +48 -103
  96. package/dist/infrastructure/storage/in-memory-storage.d.ts +10 -6
  97. package/dist/infrastructure/storage/in-memory-storage.js +18 -13
  98. package/dist/infrastructure/storage/plugin-workflow-storage.d.ts +6 -18
  99. package/dist/infrastructure/storage/plugin-workflow-storage.js +29 -51
  100. package/dist/infrastructure/storage/remote-workflow-storage.d.ts +8 -17
  101. package/dist/infrastructure/storage/remote-workflow-storage.js +33 -156
  102. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts +21 -13
  103. package/dist/infrastructure/storage/schema-validating-workflow-storage.js +86 -24
  104. package/dist/infrastructure/storage/storage.d.ts +7 -5
  105. package/dist/infrastructure/storage/storage.js +7 -6
  106. package/dist/manifest.json +1093 -0
  107. package/dist/mcp/error-mapper.d.ts +9 -0
  108. package/dist/mcp/error-mapper.js +66 -0
  109. package/dist/mcp/handlers/session.d.ts +34 -0
  110. package/dist/mcp/handlers/session.js +135 -0
  111. package/dist/mcp/handlers/v2-workflow.d.ts +4 -0
  112. package/dist/mcp/handlers/v2-workflow.js +112 -0
  113. package/dist/mcp/handlers/workflow.d.ts +45 -0
  114. package/dist/mcp/handlers/workflow.js +167 -0
  115. package/dist/mcp/index.d.ts +16 -0
  116. package/dist/mcp/index.js +51 -0
  117. package/dist/mcp/output-schemas.d.ts +317 -0
  118. package/dist/mcp/output-schemas.js +91 -0
  119. package/dist/mcp/server.d.ts +3 -0
  120. package/dist/mcp/server.js +258 -0
  121. package/dist/mcp/tool-description-provider.d.ts +16 -0
  122. package/dist/mcp/tool-description-provider.js +43 -0
  123. package/dist/mcp/tool-descriptions.d.ts +2 -0
  124. package/dist/mcp/tool-descriptions.js +109 -0
  125. package/dist/mcp/tool-factory.d.ts +23 -0
  126. package/dist/mcp/tool-factory.js +14 -0
  127. package/dist/mcp/tools.d.ts +156 -0
  128. package/dist/mcp/tools.js +196 -0
  129. package/dist/mcp/types/tool-description-types.d.ts +8 -0
  130. package/dist/mcp/types/tool-description-types.js +24 -0
  131. package/dist/mcp/types.d.ts +25 -0
  132. package/dist/mcp/types.js +15 -0
  133. package/dist/mcp/v2/tool-registry.d.ts +11 -0
  134. package/dist/mcp/v2/tool-registry.js +26 -0
  135. package/dist/mcp/v2/tools.d.ts +20 -0
  136. package/dist/mcp/v2/tools.js +17 -0
  137. package/dist/mcp/validation/bounded-json.d.ts +3 -0
  138. package/dist/mcp/validation/bounded-json.js +22 -0
  139. package/dist/mcp/validation/workflow-next-prevalidate.d.ts +9 -0
  140. package/dist/mcp/validation/workflow-next-prevalidate.js +83 -0
  141. package/dist/mcp/zod-to-json-schema.d.ts +17 -0
  142. package/dist/mcp/zod-to-json-schema.js +134 -0
  143. package/dist/mcp-server.d.ts +1 -1
  144. package/dist/mcp-server.js +6 -424
  145. package/dist/runtime/adapters/in-memory-shutdown-events.d.ts +6 -0
  146. package/dist/runtime/adapters/in-memory-shutdown-events.js +20 -0
  147. package/dist/runtime/adapters/node-process-signals.d.ts +4 -0
  148. package/dist/runtime/adapters/node-process-signals.js +11 -0
  149. package/dist/runtime/adapters/node-process-terminator.d.ts +4 -0
  150. package/dist/runtime/adapters/node-process-terminator.js +17 -0
  151. package/dist/runtime/adapters/noop-process-signals.d.ts +4 -0
  152. package/dist/runtime/adapters/noop-process-signals.js +8 -0
  153. package/dist/runtime/adapters/throwing-process-terminator.d.ts +4 -0
  154. package/dist/runtime/adapters/throwing-process-terminator.js +9 -0
  155. package/dist/runtime/assert-never.d.ts +1 -0
  156. package/dist/runtime/assert-never.js +6 -0
  157. package/dist/runtime/brand.d.ts +5 -0
  158. package/dist/runtime/ports/process-signals.d.ts +4 -0
  159. package/dist/runtime/ports/process-signals.js +2 -0
  160. package/dist/runtime/ports/process-terminator.d.ts +8 -0
  161. package/dist/runtime/ports/process-terminator.js +2 -0
  162. package/dist/runtime/ports/shutdown-events.d.ts +11 -0
  163. package/dist/runtime/ports/shutdown-events.js +2 -0
  164. package/dist/runtime/process-lifecycle-policy.d.ts +5 -0
  165. package/dist/runtime/process-lifecycle-policy.js +2 -0
  166. package/dist/runtime/result.d.ts +17 -0
  167. package/dist/runtime/result.js +31 -0
  168. package/dist/runtime/runtime-mode.d.ts +9 -0
  169. package/dist/runtime/runtime-mode.js +2 -0
  170. package/dist/types/storage.d.ts +16 -5
  171. package/dist/types/storage.js +8 -0
  172. package/dist/types/validation.d.ts +27 -0
  173. package/dist/types/validation.js +10 -0
  174. package/dist/types/workflow-definition.d.ts +63 -0
  175. package/dist/types/workflow-definition.js +33 -0
  176. package/dist/types/workflow-source.d.ts +51 -0
  177. package/dist/types/workflow-source.js +128 -0
  178. package/dist/types/workflow.d.ts +28 -0
  179. package/dist/types/workflow.js +96 -0
  180. package/dist/utils/workflow-init.d.ts +1 -0
  181. package/dist/utils/workflow-init.js +38 -0
  182. package/dist/v2/durable-core/canonical/hashing.d.ts +11 -0
  183. package/dist/v2/durable-core/canonical/hashing.js +13 -0
  184. package/dist/v2/durable-core/canonical/jcs.d.ts +11 -0
  185. package/dist/v2/durable-core/canonical/jcs.js +65 -0
  186. package/dist/v2/durable-core/canonical/json-types.d.ts +6 -0
  187. package/dist/v2/durable-core/canonical/json-types.js +2 -0
  188. package/dist/v2/durable-core/canonical/json-zod.d.ts +2 -0
  189. package/dist/v2/durable-core/canonical/json-zod.js +7 -0
  190. package/dist/v2/durable-core/canonical/jsonl.d.ts +4 -0
  191. package/dist/v2/durable-core/canonical/jsonl.js +13 -0
  192. package/dist/v2/durable-core/ids/index.d.ts +23 -0
  193. package/dist/v2/durable-core/ids/index.js +46 -0
  194. package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +47 -0
  195. package/dist/v2/durable-core/schemas/compiled-workflow/index.js +17 -0
  196. package/dist/v2/durable-core/schemas/session/events.d.ts +1812 -0
  197. package/dist/v2/durable-core/schemas/session/events.js +328 -0
  198. package/dist/v2/durable-core/schemas/session/index.d.ts +2 -0
  199. package/dist/v2/durable-core/schemas/session/index.js +8 -0
  200. package/dist/v2/durable-core/schemas/session/manifest.d.ts +57 -0
  201. package/dist/v2/durable-core/schemas/session/manifest.js +30 -0
  202. package/dist/v2/infra/local/crypto/index.d.ts +5 -0
  203. package/dist/v2/infra/local/crypto/index.js +12 -0
  204. package/dist/v2/infra/local/data-dir/index.d.ts +13 -0
  205. package/dist/v2/infra/local/data-dir/index.js +69 -0
  206. package/dist/v2/infra/local/fs/index.d.ts +26 -0
  207. package/dist/v2/infra/local/fs/index.js +156 -0
  208. package/dist/v2/infra/local/pinned-workflow-store/index.d.ts +11 -0
  209. package/dist/v2/infra/local/pinned-workflow-store/index.js +85 -0
  210. package/dist/v2/infra/local/session-lock/index.d.ts +12 -0
  211. package/dist/v2/infra/local/session-lock/index.js +44 -0
  212. package/dist/v2/infra/local/session-store/index.d.ts +22 -0
  213. package/dist/v2/infra/local/session-store/index.js +358 -0
  214. package/dist/v2/infra/local/sha256/index.d.ts +5 -0
  215. package/dist/v2/infra/local/sha256/index.js +12 -0
  216. package/dist/v2/ports/data-dir.port.d.ts +9 -0
  217. package/dist/v2/ports/data-dir.port.js +2 -0
  218. package/dist/v2/ports/fs.port.d.ts +41 -0
  219. package/dist/v2/ports/fs.port.js +2 -0
  220. package/dist/v2/ports/pinned-workflow-store.port.d.ts +11 -0
  221. package/dist/v2/ports/pinned-workflow-store.port.js +2 -0
  222. package/dist/v2/ports/session-event-log-store.port.d.ts +37 -0
  223. package/dist/v2/ports/session-event-log-store.port.js +2 -0
  224. package/dist/v2/ports/session-lock.port.d.ts +23 -0
  225. package/dist/v2/ports/session-lock.port.js +2 -0
  226. package/dist/v2/ports/sha256.port.d.ts +4 -0
  227. package/dist/v2/ports/sha256.port.js +2 -0
  228. package/dist/v2/projections/advance-outcomes.d.ts +23 -0
  229. package/dist/v2/projections/advance-outcomes.js +23 -0
  230. package/dist/v2/projections/capabilities.d.ts +27 -0
  231. package/dist/v2/projections/capabilities.js +33 -0
  232. package/dist/v2/projections/gaps.d.ts +29 -0
  233. package/dist/v2/projections/gaps.js +49 -0
  234. package/dist/v2/projections/node-outputs.d.ts +34 -0
  235. package/dist/v2/projections/node-outputs.js +73 -0
  236. package/dist/v2/projections/preferences.d.ts +28 -0
  237. package/dist/v2/projections/preferences.js +50 -0
  238. package/dist/v2/projections/run-dag.d.ts +42 -0
  239. package/dist/v2/projections/run-dag.js +186 -0
  240. package/dist/v2/projections/run-status-signals.d.ts +26 -0
  241. package/dist/v2/projections/run-status-signals.js +49 -0
  242. package/dist/v2/projections/session-health.d.ts +18 -0
  243. package/dist/v2/projections/session-health.js +15 -0
  244. package/dist/v2/read-only/v1-to-v2-shim.d.ts +3 -0
  245. package/dist/v2/read-only/v1-to-v2-shim.js +38 -0
  246. package/package.json +35 -10
  247. package/spec/mcp-api-v1.0.md +5 -5
  248. package/web/assets/services/data-normalizer.js +17 -2
  249. package/web/assets/services/pattern-recognizer.js +3 -1
  250. package/web/assets/services/session-data.js +13 -8
  251. package/web/assets/utils/formatters.js +34 -23
  252. package/workflows/CHANGELOG-bug-investigation.md +4 -4
  253. package/workflows/coding-task-workflow-agentic.json +262 -0
  254. package/workflows/design-thinking-workflow-autonomous.agentic.json +215 -0
  255. package/workflows/design-thinking-workflow.json +198 -0
  256. package/workflows/mr-review-workflow.agentic.json +538 -0
  257. package/workflows/routines/context-gathering.json +0 -4
  258. package/dist/application/app.d.ts +0 -29
  259. package/dist/application/app.d.ts.map +0 -1
  260. package/dist/application/app.js +0 -114
  261. package/dist/application/app.js.map +0 -1
  262. package/dist/application/decorators/simple-output-decorator.d.ts +0 -8
  263. package/dist/application/decorators/simple-output-decorator.js +0 -89
  264. package/dist/application/services/classification-engine.d.ts +0 -33
  265. package/dist/application/services/classification-engine.js +0 -258
  266. package/dist/application/services/compression-service.d.ts +0 -20
  267. package/dist/application/services/compression-service.js +0 -312
  268. package/dist/application/services/context-management-service.d.ts +0 -38
  269. package/dist/application/services/context-management-service.js +0 -301
  270. package/dist/application/services/context-optimizer.d.ts +0 -11
  271. package/dist/application/services/context-optimizer.js +0 -62
  272. package/dist/application/services/context-persistence-service.d.ts +0 -45
  273. package/dist/application/services/context-persistence-service.js +0 -273
  274. package/dist/application/services/documentation-service.d.ts +0 -20
  275. package/dist/application/services/documentation-service.js +0 -155
  276. package/dist/application/services/enhanced-error-service.d.ts.map +0 -1
  277. package/dist/application/services/enhanced-error-service.js.map +0 -1
  278. package/dist/application/services/loop-context-optimizer.d.ts +0 -8
  279. package/dist/application/services/loop-context-optimizer.js +0 -114
  280. package/dist/application/services/loop-execution-context.d.ts +0 -23
  281. package/dist/application/services/loop-execution-context.js +0 -188
  282. package/dist/application/services/loop-step-resolver.d.ts +0 -11
  283. package/dist/application/services/loop-step-resolver.js +0 -70
  284. package/dist/application/services/validation-engine.d.ts.map +0 -1
  285. package/dist/application/services/validation-engine.js.map +0 -1
  286. package/dist/application/services/workflow-service.d.ts.map +0 -1
  287. package/dist/application/services/workflow-service.js.map +0 -1
  288. package/dist/application/use-cases/get-next-step.d.ts.map +0 -1
  289. package/dist/application/use-cases/get-next-step.js.map +0 -1
  290. package/dist/application/use-cases/get-workflow-docs.d.ts +0 -4
  291. package/dist/application/use-cases/get-workflow-docs.js +0 -12
  292. package/dist/application/use-cases/get-workflow.d.ts.map +0 -1
  293. package/dist/application/use-cases/get-workflow.js.map +0 -1
  294. package/dist/application/use-cases/get-workrail-help.d.ts +0 -4
  295. package/dist/application/use-cases/get-workrail-help.js +0 -12
  296. package/dist/application/use-cases/list-workflows.d.ts.map +0 -1
  297. package/dist/application/use-cases/list-workflows.js.map +0 -1
  298. package/dist/application/use-cases/validate-step-output.d.ts.map +0 -1
  299. package/dist/application/use-cases/validate-step-output.js.map +0 -1
  300. package/dist/application/use-cases/validate-workflow-json.d.ts.map +0 -1
  301. package/dist/application/use-cases/validate-workflow-json.js.map +0 -1
  302. package/dist/application/validation.d.ts.map +0 -1
  303. package/dist/application/validation.js.map +0 -1
  304. package/dist/cli/migrate-workflow.d.ts +0 -22
  305. package/dist/cli/migrate-workflow.js +0 -196
  306. package/dist/cli.d.ts.map +0 -1
  307. package/dist/cli.js.map +0 -1
  308. package/dist/container.d.ts +0 -15
  309. package/dist/container.d.ts.map +0 -1
  310. package/dist/container.js +0 -25
  311. package/dist/container.js.map +0 -1
  312. package/dist/core/error-handler.d.ts.map +0 -1
  313. package/dist/core/error-handler.js.map +0 -1
  314. package/dist/domain/index.d.ts +0 -2
  315. package/dist/domain/index.d.ts.map +0 -1
  316. package/dist/domain/index.js +0 -18
  317. package/dist/domain/index.js.map +0 -1
  318. package/dist/index.d.ts.map +0 -1
  319. package/dist/index.js.map +0 -1
  320. package/dist/infrastructure/index.d.ts.map +0 -1
  321. package/dist/infrastructure/index.js.map +0 -1
  322. package/dist/infrastructure/rpc/handler.d.ts +0 -17
  323. package/dist/infrastructure/rpc/handler.d.ts.map +0 -1
  324. package/dist/infrastructure/rpc/handler.js +0 -78
  325. package/dist/infrastructure/rpc/handler.js.map +0 -1
  326. package/dist/infrastructure/rpc/index.d.ts +0 -1
  327. package/dist/infrastructure/rpc/index.d.ts.map +0 -1
  328. package/dist/infrastructure/rpc/index.js +0 -17
  329. package/dist/infrastructure/rpc/index.js.map +0 -1
  330. package/dist/infrastructure/rpc/server.d.ts +0 -3
  331. package/dist/infrastructure/rpc/server.d.ts.map +0 -1
  332. package/dist/infrastructure/rpc/server.js +0 -37
  333. package/dist/infrastructure/rpc/server.js.map +0 -1
  334. package/dist/infrastructure/storage/caching-workflow-storage.d.ts.map +0 -1
  335. package/dist/infrastructure/storage/caching-workflow-storage.js.map +0 -1
  336. package/dist/infrastructure/storage/context-storage.d.ts +0 -150
  337. package/dist/infrastructure/storage/context-storage.js +0 -40
  338. package/dist/infrastructure/storage/file-workflow-storage.d.ts.map +0 -1
  339. package/dist/infrastructure/storage/file-workflow-storage.js.map +0 -1
  340. package/dist/infrastructure/storage/filesystem-blob-storage.d.ts +0 -27
  341. package/dist/infrastructure/storage/filesystem-blob-storage.js +0 -363
  342. package/dist/infrastructure/storage/git-workflow-storage.d.ts.map +0 -1
  343. package/dist/infrastructure/storage/git-workflow-storage.js.map +0 -1
  344. package/dist/infrastructure/storage/hybrid-context-storage.d.ts +0 -29
  345. package/dist/infrastructure/storage/hybrid-context-storage.js +0 -400
  346. package/dist/infrastructure/storage/in-memory-storage.d.ts.map +0 -1
  347. package/dist/infrastructure/storage/in-memory-storage.js.map +0 -1
  348. package/dist/infrastructure/storage/index.d.ts.map +0 -1
  349. package/dist/infrastructure/storage/index.js.map +0 -1
  350. package/dist/infrastructure/storage/migrations/001_initial_schema.sql +0 -38
  351. package/dist/infrastructure/storage/migrations/002_context_concurrency_enhancements.sql +0 -234
  352. package/dist/infrastructure/storage/migrations/003_classification_overrides.sql +0 -20
  353. package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts +0 -32
  354. package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts.map +0 -1
  355. package/dist/infrastructure/storage/multi-directory-workflow-storage.js +0 -184
  356. package/dist/infrastructure/storage/multi-directory-workflow-storage.js.map +0 -1
  357. package/dist/infrastructure/storage/plugin-workflow-storage.d.ts.map +0 -1
  358. package/dist/infrastructure/storage/plugin-workflow-storage.js.map +0 -1
  359. package/dist/infrastructure/storage/remote-workflow-storage.d.ts.map +0 -1
  360. package/dist/infrastructure/storage/remote-workflow-storage.js.map +0 -1
  361. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts.map +0 -1
  362. package/dist/infrastructure/storage/schema-validating-workflow-storage.js.map +0 -1
  363. package/dist/infrastructure/storage/sqlite-metadata-storage.d.ts +0 -35
  364. package/dist/infrastructure/storage/sqlite-metadata-storage.js +0 -410
  365. package/dist/infrastructure/storage/sqlite-migrator.d.ts +0 -46
  366. package/dist/infrastructure/storage/sqlite-migrator.js +0 -293
  367. package/dist/infrastructure/storage/storage.d.ts.map +0 -1
  368. package/dist/infrastructure/storage/storage.js.map +0 -1
  369. package/dist/mcp-server.d.ts.map +0 -1
  370. package/dist/mcp-server.js.map +0 -1
  371. package/dist/tools/mcp_initialize.d.ts +0 -2
  372. package/dist/tools/mcp_initialize.d.ts.map +0 -1
  373. package/dist/tools/mcp_initialize.js +0 -45
  374. package/dist/tools/mcp_initialize.js.map +0 -1
  375. package/dist/tools/mcp_shutdown.d.ts +0 -2
  376. package/dist/tools/mcp_shutdown.d.ts.map +0 -1
  377. package/dist/tools/mcp_shutdown.js +0 -10
  378. package/dist/tools/mcp_shutdown.js.map +0 -1
  379. package/dist/tools/mcp_tools_list.d.ts +0 -2
  380. package/dist/tools/mcp_tools_list.d.ts.map +0 -1
  381. package/dist/tools/mcp_tools_list.js +0 -60
  382. package/dist/tools/mcp_tools_list.js.map +0 -1
  383. package/dist/tools/session-tools.d.ts +0 -5
  384. package/dist/tools/session-tools.js +0 -270
  385. package/dist/types/context-types.d.ts +0 -236
  386. package/dist/types/context-types.js +0 -10
  387. package/dist/types/documentation-types.d.ts +0 -37
  388. package/dist/types/loop-context-optimizer.d.ts +0 -7
  389. package/dist/types/mcp-types.d.ts +0 -273
  390. package/dist/types/mcp-types.d.ts.map +0 -1
  391. package/dist/types/mcp-types.js +0 -19
  392. package/dist/types/mcp-types.js.map +0 -1
  393. package/dist/types/server.d.ts.map +0 -1
  394. package/dist/types/server.js.map +0 -1
  395. package/dist/types/storage.d.ts.map +0 -1
  396. package/dist/types/storage.js.map +0 -1
  397. package/dist/types/workflow-types.d.ts +0 -336
  398. package/dist/types/workflow-types.d.ts.map +0 -1
  399. package/dist/types/workflow-types.js +0 -20
  400. package/dist/types/workflow-types.js.map +0 -1
  401. package/dist/utils/condition-evaluator.d.ts.map +0 -1
  402. package/dist/utils/condition-evaluator.js.map +0 -1
  403. package/dist/utils/config.d.ts +0 -149
  404. package/dist/utils/config.d.ts.map +0 -1
  405. package/dist/utils/config.js +0 -251
  406. package/dist/utils/config.js.map +0 -1
  407. package/dist/utils/storage-security.d.ts.map +0 -1
  408. package/dist/utils/storage-security.js.map +0 -1
  409. package/dist/validation/request-validator.d.ts +0 -8
  410. package/dist/validation/request-validator.d.ts.map +0 -1
  411. package/dist/validation/request-validator.js +0 -32
  412. package/dist/validation/request-validator.js.map +0 -1
  413. package/dist/validation/response-validator.d.ts +0 -8
  414. package/dist/validation/response-validator.d.ts.map +0 -1
  415. package/dist/validation/response-validator.js +0 -110
  416. package/dist/validation/response-validator.js.map +0 -1
  417. package/dist/validation/schemas.d.ts +0 -1
  418. package/dist/validation/schemas.d.ts.map +0 -1
  419. package/dist/validation/schemas.js +0 -53
  420. package/dist/validation/schemas.js.map +0 -1
  421. /package/dist/{types/documentation-types.js → errors/app-error.js} +0 -0
  422. /package/dist/{types/loop-context-optimizer.js → runtime/brand.js} +0 -0
@@ -1,114 +0,0 @@
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.METHOD_NAMES = exports.ApplicationMediator = void 0;
37
- exports.buildWorkflowApplication = buildWorkflowApplication;
38
- const error_handler_1 = require("../core/error-handler");
39
- const mcp_types_1 = require("../types/mcp-types");
40
- class ApplicationMediator {
41
- constructor(validator) {
42
- this.handlers = new Map();
43
- this.validateFn = validator.validate.bind(validator);
44
- }
45
- register(method, handler) {
46
- if (this.handlers.has(method)) {
47
- throw new Error(`Method already registered: ${method}`);
48
- }
49
- this.handlers.set(method, handler);
50
- }
51
- async execute(method, params) {
52
- const handler = this.handlers.get(method);
53
- if (!handler) {
54
- throw new error_handler_1.MCPError(mcp_types_1.MCPErrorCodes.METHOD_NOT_FOUND, 'Method not found', { method });
55
- }
56
- this.validateFn(method, params);
57
- const result = await handler(params);
58
- if (this.responseValidate) {
59
- this.responseValidate(method, result);
60
- }
61
- return result;
62
- }
63
- setResponseValidator(fn) {
64
- this.responseValidate = fn;
65
- }
66
- }
67
- exports.ApplicationMediator = ApplicationMediator;
68
- const request_validator_1 = require("../validation/request-validator");
69
- const response_validator_1 = require("../validation/response-validator");
70
- const list_workflows_1 = require("./use-cases/list-workflows");
71
- const get_workflow_1 = require("./use-cases/get-workflow");
72
- const get_next_step_1 = require("./use-cases/get-next-step");
73
- const simple_output_decorator_1 = require("./decorators/simple-output-decorator");
74
- exports.METHOD_NAMES = {
75
- WORKFLOW_LIST: 'workflow_list',
76
- WORKFLOW_GET: 'workflow_get',
77
- WORKFLOW_NEXT: 'workflow_next',
78
- INITIALIZE: 'initialize',
79
- TOOLS_LIST: 'tools/list',
80
- SHUTDOWN: 'shutdown'
81
- };
82
- function buildWorkflowApplication(workflowService, validator = request_validator_1.requestValidator, enableOutputOptimization = true) {
83
- const app = new ApplicationMediator(validator);
84
- app.setResponseValidator((method, result) => response_validator_1.responseValidator.validate(method, result));
85
- const listWorkflowsUseCase = (0, list_workflows_1.createListWorkflows)(workflowService);
86
- const getWorkflowUseCase = (0, get_workflow_1.createGetWorkflow)(workflowService);
87
- const getNextStepUseCase = (0, get_next_step_1.createGetNextStep)(workflowService);
88
- app.register(exports.METHOD_NAMES.WORKFLOW_LIST, async (_params) => {
89
- const workflows = await listWorkflowsUseCase();
90
- return { workflows };
91
- });
92
- app.register(exports.METHOD_NAMES.WORKFLOW_GET, async (params) => {
93
- return getWorkflowUseCase(params.id, params.mode);
94
- });
95
- app.register(exports.METHOD_NAMES.WORKFLOW_NEXT, async (params) => {
96
- return getNextStepUseCase(params.workflowId, params.completedSteps || [], params.context);
97
- });
98
- app.register(exports.METHOD_NAMES.INITIALIZE, async (params) => {
99
- const { initializeHandler } = await Promise.resolve().then(() => __importStar(require('../tools/mcp_initialize')));
100
- return (await initializeHandler({ id: 0, params, method: 'initialize', jsonrpc: '2.0' })).result;
101
- });
102
- app.register(exports.METHOD_NAMES.TOOLS_LIST, async (params) => {
103
- const { toolsListHandler } = await Promise.resolve().then(() => __importStar(require('../tools/mcp_tools_list')));
104
- return (await toolsListHandler({ id: 0, params, method: 'tools/list', jsonrpc: '2.0' })).result;
105
- });
106
- app.register(exports.METHOD_NAMES.SHUTDOWN, async (params) => {
107
- const { shutdownHandler } = await Promise.resolve().then(() => __importStar(require('../tools/mcp_shutdown')));
108
- return (await shutdownHandler({ id: 0, params, method: 'shutdown', jsonrpc: '2.0' })).result;
109
- });
110
- if (enableOutputOptimization) {
111
- return new simple_output_decorator_1.SimpleOutputDecorator(app);
112
- }
113
- return app;
114
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/application/app.ts"],"names":[],"mappings":"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"}
@@ -1,8 +0,0 @@
1
- import { IApplicationMediator } from '../app';
2
- export declare class SimpleOutputDecorator implements IApplicationMediator {
3
- private readonly wrapped;
4
- constructor(wrapped: IApplicationMediator);
5
- execute(method: string, params: any): Promise<any>;
6
- register(method: string, handler: any): void;
7
- setResponseValidator(fn: (method: string, result: any) => void): void;
8
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SimpleOutputDecorator = void 0;
4
- const CONTEXT_OPTIMIZATION_TEXT = `
5
-
6
- **CONTEXT OPTIMIZATION REQUIREMENTS**:
7
-
8
- The MCP server is STATELESS. You MUST send required data with each request:
9
-
10
- **ALWAYS INCLUDE:**
11
- 1. \`workflowId\` - Required for all calls
12
- 2. \`completedSteps\` - Full array of completed step IDs
13
- 3. **Condition Variables** - ANY variable used in step \`runCondition\` fields
14
- 4. **Template Variables** - ANY variable referenced in {{templates}} in prompts/titles
15
- 5. **Your New/Modified Variables** - Variables you created or changed in this step
16
-
17
- **CONDITIONALLY INCLUDE:**
18
- - **Loop Variables** (when in a loop): \`currentIteration\`, \`currentItem\`, \`currentIndex\`
19
- - **Active Loop State**: Only \`_loopState[currentLoopId]\` if currently in a loop
20
- - **Referenced Variables**: Any variable that future steps might need
21
-
22
- **NEVER INCLUDE:**
23
- - Large arrays that aren't being actively iterated (e.g., \`implementationSteps\` array)
24
- - Stale loop states from completed loops
25
- - Unreferenced historical data
26
- - Variables only used in completed steps
27
-
28
- **SIZE TARGETS:**
29
- - Normal steps: < 2KB
30
- - Loop iterations: < 5KB
31
- - Complex state: < 10KB
32
-
33
- **EXAMPLE - Loop Context:**
34
- \`\`\`json
35
- {
36
- "workflowId": "coding-task-workflow-with-loops",
37
- "completedSteps": ["phase-1", "phase-2", "loop-step-1"],
38
- "context": {
39
- // Required: condition/template variables
40
- "taskComplexity": "Medium",
41
- "totalImplementationSteps": 8,
42
- "currentStepNumber": 3,
43
-
44
- // Required: your changes
45
- "stepCompleted": true,
46
- "testResults": "passed",
47
-
48
- // Required: active loop state only
49
- "_loopState": {
50
- "phase-6-loop": { "iteration": 3 }
51
- },
52
-
53
- // DON'T include:
54
- // - implementationSteps: [...] // Large array
55
- // - analysisResults: {...} // From phase 1
56
- // - _loopState.oldLoop: {...} // Completed loop
57
- }
58
- }
59
- \`\`\`
60
-
61
- **VALIDATION CHECK**: Before sending, verify you have ALL variables referenced in:
62
- - The next step's \`runCondition\`
63
- - Any {{variable}} in the next step's prompts
64
- - Variables needed for loop control`;
65
- class SimpleOutputDecorator {
66
- constructor(wrapped) {
67
- this.wrapped = wrapped;
68
- }
69
- async execute(method, params) {
70
- const result = await this.wrapped.execute(method, params);
71
- if (method === 'workflow_next' && result?.guidance?.prompt) {
72
- return {
73
- ...result,
74
- guidance: {
75
- ...result.guidance,
76
- prompt: result.guidance.prompt + CONTEXT_OPTIMIZATION_TEXT
77
- }
78
- };
79
- }
80
- return result;
81
- }
82
- register(method, handler) {
83
- this.wrapped.register(method, handler);
84
- }
85
- setResponseValidator(fn) {
86
- this.wrapped.setResponseValidator(fn);
87
- }
88
- }
89
- exports.SimpleOutputDecorator = SimpleOutputDecorator;
@@ -1,33 +0,0 @@
1
- import { ContextLayer, ClassificationRules, ClassifiedContext, RawContext } from '../../types/context-types';
2
- export interface IClassificationEngine {
3
- classify(context: RawContext, rules?: ClassificationRules): Promise<ClassifiedContext>;
4
- loadRules(config?: Partial<ClassificationRules>): Promise<void>;
5
- addOverride(sessionId: string, contextKey: string, layer: ContextLayer): void;
6
- removeOverride(sessionId: string, contextKey: string): void;
7
- markCritical(sessionId: string, contextKey: string): Promise<void>;
8
- getStats(): ClassificationStats;
9
- }
10
- export interface ClassificationStats {
11
- totalClassifications: number;
12
- layerDistribution: Record<ContextLayer, number>;
13
- overrideCount: number;
14
- averageProcessingTime: number;
15
- }
16
- export declare class ClassificationEngine implements IClassificationEngine {
17
- private rules;
18
- private overrides;
19
- private stats;
20
- constructor(initialRules?: ClassificationRules);
21
- classify(context: RawContext, rules?: ClassificationRules): Promise<ClassifiedContext>;
22
- loadRules(config?: Partial<ClassificationRules>): Promise<void>;
23
- addOverride(sessionId: string, contextKey: string, layer: ContextLayer): void;
24
- removeOverride(sessionId: string, contextKey: string): void;
25
- markCritical(sessionId: string, contextKey: string): Promise<void>;
26
- getStats(): ClassificationStats;
27
- private classifyKeyValue;
28
- private applyPatternMatching;
29
- private matchesPattern;
30
- private applyHeuristics;
31
- private updateStats;
32
- private getDefaultRules;
33
- }
@@ -1,258 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClassificationEngine = void 0;
4
- const context_types_1 = require("../../types/context-types");
5
- class ClassificationEngine {
6
- constructor(initialRules) {
7
- this.overrides = new Map();
8
- this.rules = initialRules || this.getDefaultRules();
9
- this.stats = {
10
- totalClassifications: 0,
11
- layerDistribution: {
12
- [context_types_1.ContextLayer.CRITICAL]: 0,
13
- [context_types_1.ContextLayer.IMPORTANT]: 0,
14
- [context_types_1.ContextLayer.USEFUL]: 0,
15
- [context_types_1.ContextLayer.EPHEMERAL]: 0
16
- },
17
- overrideCount: 0,
18
- averageProcessingTime: 0
19
- };
20
- }
21
- async classify(context, rules) {
22
- const startTime = process.hrtime.bigint();
23
- const activeRules = rules || this.rules;
24
- const classified = {
25
- [context_types_1.ContextLayer.CRITICAL]: {},
26
- [context_types_1.ContextLayer.IMPORTANT]: {},
27
- [context_types_1.ContextLayer.USEFUL]: {},
28
- [context_types_1.ContextLayer.EPHEMERAL]: {}
29
- };
30
- for (const [key, value] of Object.entries(context)) {
31
- const layer = this.classifyKeyValue(key, value, activeRules);
32
- classified[layer][key] = value;
33
- }
34
- this.updateStats(startTime, classified);
35
- return Object.freeze(classified);
36
- }
37
- async loadRules(config) {
38
- if (config) {
39
- this.rules = {
40
- patterns: { ...this.rules.patterns, ...config.patterns },
41
- heuristics: { ...this.rules.heuristics, ...config.heuristics },
42
- overrides: { ...this.rules.overrides, ...config.overrides }
43
- };
44
- }
45
- }
46
- addOverride(sessionId, contextKey, layer) {
47
- if (!this.overrides.has(sessionId)) {
48
- this.overrides.set(sessionId, new Map());
49
- }
50
- const sessionOverrides = this.overrides.get(sessionId);
51
- sessionOverrides.set(contextKey, layer);
52
- this.stats.overrideCount++;
53
- }
54
- removeOverride(sessionId, contextKey) {
55
- const sessionOverrides = this.overrides.get(sessionId);
56
- if (sessionOverrides && sessionOverrides.has(contextKey)) {
57
- sessionOverrides.delete(contextKey);
58
- this.stats.overrideCount = Math.max(0, this.stats.overrideCount - 1);
59
- if (sessionOverrides.size === 0) {
60
- this.overrides.delete(sessionId);
61
- }
62
- }
63
- }
64
- async markCritical(sessionId, contextKey) {
65
- this.addOverride(sessionId, contextKey, context_types_1.ContextLayer.CRITICAL);
66
- console.log(`✓ Marked key '${contextKey}' as CRITICAL for session '${sessionId}'`);
67
- }
68
- getStats() {
69
- return { ...this.stats };
70
- }
71
- classifyKeyValue(key, value, rules, sessionId) {
72
- if (sessionId) {
73
- const sessionOverrides = this.overrides.get(sessionId);
74
- const override = sessionOverrides?.get(key);
75
- if (override) {
76
- return override;
77
- }
78
- }
79
- if (rules.overrides[key]) {
80
- return rules.overrides[key];
81
- }
82
- const patternLayer = this.applyPatternMatching(key, value, rules);
83
- if (patternLayer) {
84
- return patternLayer;
85
- }
86
- return this.applyHeuristics(key, value, rules);
87
- }
88
- applyPatternMatching(key, value, rules) {
89
- let bestMatch = null;
90
- for (const [layer, patterns] of Object.entries(rules.patterns)) {
91
- for (const pattern of patterns) {
92
- if (this.matchesPattern(key, value, pattern)) {
93
- if (!bestMatch || pattern.weight > bestMatch.weight) {
94
- bestMatch = { layer: layer, weight: pattern.weight };
95
- }
96
- }
97
- }
98
- }
99
- return bestMatch?.layer || null;
100
- }
101
- matchesPattern(key, value, pattern) {
102
- const keyRegex = new RegExp(pattern.keyPattern, 'i');
103
- if (!keyRegex.test(key)) {
104
- return false;
105
- }
106
- if (pattern.valuePattern) {
107
- const valueStr = typeof value === 'string' ? value : JSON.stringify(value);
108
- const valueRegex = new RegExp(pattern.valuePattern, 'i');
109
- if (!valueRegex.test(valueStr)) {
110
- return false;
111
- }
112
- }
113
- return true;
114
- }
115
- applyHeuristics(key, value, rules) {
116
- const heuristics = rules.heuristics;
117
- const valueStr = typeof value === 'string' ? value :
118
- value === undefined ? 'undefined' :
119
- value === null ? 'null' :
120
- JSON.stringify(value);
121
- const contentLength = valueStr.length;
122
- let keywordScore = 0;
123
- for (const [keyword, weight] of Object.entries(heuristics.keywordWeights)) {
124
- const regex = new RegExp(keyword, 'gi');
125
- const matches = (key + ' ' + valueStr).match(regex);
126
- if (matches) {
127
- keywordScore += matches.length * weight;
128
- }
129
- }
130
- if (keywordScore >= 10 || contentLength >= heuristics.lengthThresholds[context_types_1.ContextLayer.CRITICAL]) {
131
- return context_types_1.ContextLayer.CRITICAL;
132
- }
133
- else if (keywordScore >= 5 || contentLength >= heuristics.lengthThresholds[context_types_1.ContextLayer.IMPORTANT]) {
134
- return context_types_1.ContextLayer.IMPORTANT;
135
- }
136
- else if (contentLength >= heuristics.lengthThresholds[context_types_1.ContextLayer.USEFUL]) {
137
- return context_types_1.ContextLayer.USEFUL;
138
- }
139
- else {
140
- return heuristics.defaultLayer;
141
- }
142
- }
143
- updateStats(startTime, classified) {
144
- const endTime = process.hrtime.bigint();
145
- const processingTime = Number(endTime - startTime) / 1000000;
146
- this.stats.totalClassifications++;
147
- this.stats.averageProcessingTime =
148
- (this.stats.averageProcessingTime * (this.stats.totalClassifications - 1) + processingTime) /
149
- this.stats.totalClassifications;
150
- for (const [layer, content] of Object.entries(classified)) {
151
- const itemCount = Object.keys(content).length;
152
- this.stats.layerDistribution[layer] += itemCount;
153
- }
154
- }
155
- getDefaultRules() {
156
- return {
157
- patterns: {
158
- [context_types_1.ContextLayer.CRITICAL]: [
159
- {
160
- keyPattern: '^(goal|objective|target|requirement|result|answer|decision|conclusion)s?$',
161
- weight: 100,
162
- description: 'Core workflow objectives and final results'
163
- },
164
- {
165
- keyPattern: '^(user|customer|client).*',
166
- weight: 90,
167
- description: 'User-related information and requirements'
168
- },
169
- {
170
- keyPattern: '^(error|failure|critical|urgent|important).*',
171
- weight: 85,
172
- description: 'Critical errors and urgent items'
173
- }
174
- ],
175
- [context_types_1.ContextLayer.IMPORTANT]: [
176
- {
177
- keyPattern: '^(plan|strategy|approach|method|process|workflow)s?$',
178
- weight: 80,
179
- description: 'Planning and strategic information'
180
- },
181
- {
182
- keyPattern: '^(config|settings|parameters).*',
183
- weight: 70,
184
- description: 'Configuration and settings'
185
- },
186
- {
187
- keyPattern: '^(state|status|progress).*',
188
- weight: 65,
189
- description: 'Current state and progress tracking'
190
- }
191
- ],
192
- [context_types_1.ContextLayer.USEFUL]: [
193
- {
194
- keyPattern: '^(data|content|information|details).*',
195
- weight: 50,
196
- description: 'Supporting data and detailed information'
197
- },
198
- {
199
- keyPattern: '^(example|sample|demo)s?.*',
200
- weight: 45,
201
- description: 'Examples and demonstrations'
202
- },
203
- {
204
- keyPattern: '^(analysis|report|summary).*',
205
- weight: 40,
206
- description: 'Analysis results and reports'
207
- }
208
- ],
209
- [context_types_1.ContextLayer.EPHEMERAL]: [
210
- {
211
- keyPattern: '^(temp|temporary|cache|buffer).*',
212
- weight: 20,
213
- description: 'Temporary data and cache'
214
- },
215
- {
216
- keyPattern: '.*(debug|log|trace|timestamp).*',
217
- weight: 15,
218
- description: 'Debug information and logs'
219
- },
220
- {
221
- keyPattern: '^(_|internal).*',
222
- weight: 10,
223
- description: 'Internal system metadata'
224
- }
225
- ]
226
- },
227
- heuristics: {
228
- lengthThresholds: {
229
- [context_types_1.ContextLayer.CRITICAL]: 1000,
230
- [context_types_1.ContextLayer.IMPORTANT]: 500,
231
- [context_types_1.ContextLayer.USEFUL]: 100,
232
- [context_types_1.ContextLayer.EPHEMERAL]: 0
233
- },
234
- keywordWeights: {
235
- 'goal': 15,
236
- 'objective': 15,
237
- 'requirement': 12,
238
- 'critical': 10,
239
- 'important': 8,
240
- 'urgent': 8,
241
- 'user': 7,
242
- 'error': 7,
243
- 'failure': 7,
244
- 'plan': 6,
245
- 'strategy': 6,
246
- 'config': 5,
247
- 'data': 3,
248
- 'example': 2,
249
- 'debug': 1,
250
- 'temp': 1
251
- },
252
- defaultLayer: context_types_1.ContextLayer.USEFUL
253
- },
254
- overrides: {}
255
- };
256
- }
257
- }
258
- exports.ClassificationEngine = ClassificationEngine;
@@ -1,20 +0,0 @@
1
- import { ICompressionService, ClassifiedContext, CompressedBlob, RawContext, CompressionConfig, CompressionStats } from '../../types/context-types';
2
- export declare class CompressionService implements ICompressionService {
3
- private config;
4
- private stats;
5
- constructor(config?: Partial<CompressionConfig>);
6
- compress(classified: ClassifiedContext): Promise<CompressedBlob>;
7
- decompress(blob: CompressedBlob): Promise<RawContext>;
8
- getStats(): CompressionStats;
9
- resetStats(): void;
10
- updateConfig(newConfig: Partial<CompressionConfig>): void;
11
- private compressLayer;
12
- private decompressLayer;
13
- private applyLightCompression;
14
- private applyMediumCompression;
15
- private applyAggressiveCompression;
16
- private applyAlgorithmCompression;
17
- private applyAlgorithmDecompression;
18
- private createUncompressedBlob;
19
- private updateStats;
20
- }