@contractspec/lib.contracts-spec 2.0.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 (1058) hide show
  1. package/README.md +3 -0
  2. package/dist/app-config/app-config.capability.d.ts +1 -0
  3. package/dist/app-config/app-config.capability.js +730 -0
  4. package/dist/app-config/app-config.contracts.d.ts +239 -0
  5. package/dist/app-config/app-config.contracts.js +713 -0
  6. package/dist/app-config/app-config.contracts.test.d.ts +1 -0
  7. package/dist/app-config/app-config.feature.d.ts +5 -0
  8. package/dist/app-config/app-config.feature.js +255 -0
  9. package/dist/app-config/branding.d.ts +52 -0
  10. package/dist/app-config/branding.js +1 -0
  11. package/dist/app-config/branding.test.d.ts +1 -0
  12. package/dist/app-config/docs/app-config.docblock.d.ts +2 -0
  13. package/dist/app-config/docs/app-config.docblock.js +383 -0
  14. package/dist/app-config/events.d.ts +115 -0
  15. package/dist/app-config/events.js +386 -0
  16. package/dist/app-config/events.test.d.ts +1 -0
  17. package/dist/app-config/index.d.ts +9 -0
  18. package/dist/app-config/index.js +2899 -0
  19. package/dist/app-config/lifecycle-contracts.d.ts +265 -0
  20. package/dist/app-config/lifecycle-contracts.js +870 -0
  21. package/dist/app-config/lifecycle-contracts.test.d.ts +1 -0
  22. package/dist/app-config/lifecycle.d.ts +23 -0
  23. package/dist/app-config/lifecycle.js +1 -0
  24. package/dist/app-config/lifecycle.test.d.ts +1 -0
  25. package/dist/app-config/runtime.d.ts +111 -0
  26. package/dist/app-config/runtime.js +734 -0
  27. package/dist/app-config/runtime.test.d.ts +1 -0
  28. package/dist/app-config/spec.d.ts +169 -0
  29. package/dist/app-config/spec.js +229 -0
  30. package/dist/app-config/spec.test.d.ts +1 -0
  31. package/dist/app-config/validation.d.ts +43 -0
  32. package/dist/app-config/validation.js +650 -0
  33. package/dist/app-config/validation.test.d.ts +1 -0
  34. package/dist/capabilities/capabilities.d.ts +96 -0
  35. package/dist/capabilities/capabilities.js +217 -0
  36. package/dist/capabilities/capabilities.test.d.ts +1 -0
  37. package/dist/capabilities/context.d.ts +110 -0
  38. package/dist/capabilities/context.js +101 -0
  39. package/dist/capabilities/context.test.d.ts +1 -0
  40. package/dist/capabilities/docs/capabilities.docblock.d.ts +2 -0
  41. package/dist/capabilities/docs/capabilities.docblock.js +353 -0
  42. package/dist/capabilities/guards.d.ts +121 -0
  43. package/dist/capabilities/guards.js +177 -0
  44. package/dist/capabilities/index.d.ts +6 -0
  45. package/dist/capabilities/index.js +739 -0
  46. package/dist/capabilities/meeting-recorder.d.ts +5 -0
  47. package/dist/capabilities/meeting-recorder.js +154 -0
  48. package/dist/capabilities/openbanking.d.ts +5 -0
  49. package/dist/capabilities/openbanking.js +166 -0
  50. package/dist/capabilities/validation.d.ts +79 -0
  51. package/dist/capabilities/validation.js +185 -0
  52. package/dist/capabilities/validation.test.d.ts +1 -0
  53. package/dist/contract-registry/index.d.ts +3 -0
  54. package/dist/contract-registry/index.js +129 -0
  55. package/dist/contract-registry/schemas.d.ts +120 -0
  56. package/dist/contract-registry/schemas.js +129 -0
  57. package/dist/contract-registry/schemas.test.d.ts +1 -0
  58. package/dist/contract-registry/types.d.ts +42 -0
  59. package/dist/contract-registry/types.js +1 -0
  60. package/dist/data-views/data-views.d.ts +4 -0
  61. package/dist/data-views/data-views.js +232 -0
  62. package/dist/data-views/data-views.test.d.ts +1 -0
  63. package/dist/data-views/docs/data-views.docblock.d.ts +2 -0
  64. package/dist/data-views/docs/data-views.docblock.js +164 -0
  65. package/dist/data-views/index.d.ts +4 -0
  66. package/dist/data-views/index.js +232 -0
  67. package/dist/data-views/query-generator.d.ts +35 -0
  68. package/dist/data-views/query-generator.js +89 -0
  69. package/dist/data-views/registry.d.ts +12 -0
  70. package/dist/data-views/registry.js +226 -0
  71. package/dist/data-views/registry.test.d.ts +1 -0
  72. package/dist/data-views/report/contractVerificationTable.d.ts +4 -0
  73. package/dist/data-views/report/contractVerificationTable.js +240 -0
  74. package/dist/data-views/report/contractVerificationTable.test.d.ts +1 -0
  75. package/dist/data-views/runtime.d.ts +25 -0
  76. package/dist/data-views/runtime.js +108 -0
  77. package/dist/data-views/runtime.test.d.ts +1 -0
  78. package/dist/data-views/spec.d.ts +22 -0
  79. package/dist/data-views/spec.js +38 -0
  80. package/dist/data-views/spec.test.d.ts +1 -0
  81. package/dist/data-views/types.d.ts +152 -0
  82. package/dist/data-views/types.js +1 -0
  83. package/dist/data-views/types.test.d.ts +1 -0
  84. package/dist/docs/accessibility_wcag_compliance_specs.docblock.d.ts +2 -0
  85. package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +513 -0
  86. package/dist/docs/capabilities/documentationSystem.capability.d.ts +1 -0
  87. package/dist/docs/capabilities/documentationSystem.capability.js +784 -0
  88. package/dist/docs/capabilities/index.d.ts +1 -0
  89. package/dist/docs/capabilities/index.js +784 -0
  90. package/dist/docs/commands/docsGenerate.command.d.ts +88 -0
  91. package/dist/docs/commands/docsGenerate.command.js +802 -0
  92. package/dist/docs/commands/docsPublish.command.d.ts +57 -0
  93. package/dist/docs/commands/docsPublish.command.js +781 -0
  94. package/dist/docs/commands/index.d.ts +2 -0
  95. package/dist/docs/commands/index.js +906 -0
  96. package/dist/docs/constants.d.ts +4 -0
  97. package/dist/docs/constants.js +78 -0
  98. package/dist/docs/contracts.d.ts +430 -0
  99. package/dist/docs/contracts.js +1611 -0
  100. package/dist/docs/ensure-docblocks.d.ts +1 -0
  101. package/dist/docs/ensure-docblocks.js +264 -0
  102. package/dist/docs/events/docsGenerated.event.d.ts +56 -0
  103. package/dist/docs/events/docsGenerated.event.js +533 -0
  104. package/dist/docs/events/docsPublished.event.d.ts +64 -0
  105. package/dist/docs/events/docsPublished.event.js +534 -0
  106. package/dist/docs/events/index.d.ts +2 -0
  107. package/dist/docs/events/index.js +567 -0
  108. package/dist/docs/forms/docsSearch.form.d.ts +16 -0
  109. package/dist/docs/forms/docsSearch.form.js +676 -0
  110. package/dist/docs/forms/index.d.ts +1 -0
  111. package/dist/docs/forms/index.js +676 -0
  112. package/dist/docs/index.d.ts +40 -0
  113. package/dist/docs/index.js +4719 -0
  114. package/dist/docs/meta.docs.d.ts +2 -0
  115. package/dist/docs/meta.docs.js +176 -0
  116. package/dist/docs/presentations/docsLayout.presentation.d.ts +2 -0
  117. package/dist/docs/presentations/docsLayout.presentation.js +527 -0
  118. package/dist/docs/presentations/docsReferencePage.presentation.d.ts +2 -0
  119. package/dist/docs/presentations/docsReferencePage.presentation.js +527 -0
  120. package/dist/docs/presentations/index.d.ts +2 -0
  121. package/dist/docs/presentations/index.js +555 -0
  122. package/dist/docs/presentations.d.ts +27 -0
  123. package/dist/docs/presentations.js +97 -0
  124. package/dist/docs/presentations.test.d.ts +1 -0
  125. package/dist/docs/queries/contractReference.query.d.ts +211 -0
  126. package/dist/docs/queries/contractReference.query.js +752 -0
  127. package/dist/docs/queries/docsIndex.query.d.ts +266 -0
  128. package/dist/docs/queries/docsIndex.query.js +752 -0
  129. package/dist/docs/queries/index.d.ts +2 -0
  130. package/dist/docs/queries/index.js +827 -0
  131. package/dist/docs/registry.d.ts +19 -0
  132. package/dist/docs/registry.js +153 -0
  133. package/dist/docs/registry.test.d.ts +1 -0
  134. package/dist/docs/tech/auth/better-auth-nextjs.docblock.d.ts +2 -0
  135. package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +221 -0
  136. package/dist/docs/tech/cli.docblock.d.ts +2 -0
  137. package/dist/docs/tech/cli.docblock.js +291 -0
  138. package/dist/docs/tech/contracts/README.docblock.d.ts +2 -0
  139. package/dist/docs/tech/contracts/README.docblock.js +164 -0
  140. package/dist/docs/tech/contracts/migrations.docblock.d.ts +2 -0
  141. package/dist/docs/tech/contracts/migrations.docblock.js +164 -0
  142. package/dist/docs/tech/contracts/openapi-export.docblock.d.ts +2 -0
  143. package/dist/docs/tech/contracts/openapi-export.docblock.js +201 -0
  144. package/dist/docs/tech/contracts/openapi-import.docblock.d.ts +2 -0
  145. package/dist/docs/tech/contracts/openapi-import.docblock.js +207 -0
  146. package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.d.ts +2 -0
  147. package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +225 -0
  148. package/dist/docs/tech/contracts/overlays.docblock.d.ts +2 -0
  149. package/dist/docs/tech/contracts/overlays.docblock.js +231 -0
  150. package/dist/docs/tech/contracts/tests.docblock.d.ts +2 -0
  151. package/dist/docs/tech/contracts/tests.docblock.js +164 -0
  152. package/dist/docs/tech/contracts/themes.docblock.d.ts +2 -0
  153. package/dist/docs/tech/contracts/themes.docblock.js +257 -0
  154. package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.d.ts +2 -0
  155. package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +269 -0
  156. package/dist/docs/tech/docs-system.docblock.d.ts +1 -0
  157. package/dist/docs/tech/docs-system.docblock.js +264 -0
  158. package/dist/docs/tech/lifecycle-stage-system.docblock.d.ts +2 -0
  159. package/dist/docs/tech/lifecycle-stage-system.docblock.js +376 -0
  160. package/dist/docs/tech/llm/llm-integration.docblock.d.ts +7 -0
  161. package/dist/docs/tech/llm/llm-integration.docblock.js +482 -0
  162. package/dist/docs/tech/mcp-endpoints.docblock.d.ts +2 -0
  163. package/dist/docs/tech/mcp-endpoints.docblock.js +185 -0
  164. package/dist/docs/tech/presentation-runtime.docblock.d.ts +2 -0
  165. package/dist/docs/tech/presentation-runtime.docblock.js +221 -0
  166. package/dist/docs/tech/report-verification-table.docblock.d.ts +1 -0
  167. package/dist/docs/tech/report-verification-table.docblock.js +191 -0
  168. package/dist/docs/tech/report-verification-table.test.d.ts +1 -0
  169. package/dist/docs/tech/schema/README.docblock.d.ts +2 -0
  170. package/dist/docs/tech/schema/README.docblock.js +164 -0
  171. package/dist/docs/tech/studio/learning-events.docblock.d.ts +2 -0
  172. package/dist/docs/tech/studio/learning-events.docblock.js +190 -0
  173. package/dist/docs/tech/studio/learning-journeys.docblock.d.ts +2 -0
  174. package/dist/docs/tech/studio/learning-journeys.docblock.js +227 -0
  175. package/dist/docs/tech/studio/platform-admin-panel.docblock.d.ts +2 -0
  176. package/dist/docs/tech/studio/platform-admin-panel.docblock.js +226 -0
  177. package/dist/docs/tech/studio/project-access-teams.docblock.d.ts +2 -0
  178. package/dist/docs/tech/studio/project-access-teams.docblock.js +200 -0
  179. package/dist/docs/tech/studio/project-routing.docblock.d.ts +2 -0
  180. package/dist/docs/tech/studio/project-routing.docblock.js +209 -0
  181. package/dist/docs/tech/studio/sandbox-unlogged.docblock.d.ts +2 -0
  182. package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +183 -0
  183. package/dist/docs/tech/studio/team-invitations.docblock.d.ts +2 -0
  184. package/dist/docs/tech/studio/team-invitations.docblock.js +228 -0
  185. package/dist/docs/tech/studio/workspace-ops.docblock.d.ts +2 -0
  186. package/dist/docs/tech/studio/workspace-ops.docblock.js +189 -0
  187. package/dist/docs/tech/studio/workspaces.docblock.d.ts +2 -0
  188. package/dist/docs/tech/studio/workspaces.docblock.js +204 -0
  189. package/dist/docs/tech/telemetry-ingest.docblock.d.ts +2 -0
  190. package/dist/docs/tech/telemetry-ingest.docblock.js +305 -0
  191. package/dist/docs/tech/vscode-extension.docblock.d.ts +2 -0
  192. package/dist/docs/tech/vscode-extension.docblock.js +241 -0
  193. package/dist/docs/tech-contracts.docs.d.ts +2 -0
  194. package/dist/docs/tech-contracts.docs.js +239 -0
  195. package/dist/docs/types.d.ts +37 -0
  196. package/dist/docs/types.js +1 -0
  197. package/dist/docs/views/contractReference.dataView.d.ts +2 -0
  198. package/dist/docs/views/contractReference.dataView.js +838 -0
  199. package/dist/docs/views/docsIndex.dataView.d.ts +2 -0
  200. package/dist/docs/views/docsIndex.dataView.js +832 -0
  201. package/dist/docs/views/exampleCatalog.dataView.d.ts +2 -0
  202. package/dist/docs/views/exampleCatalog.dataView.js +816 -0
  203. package/dist/docs/views/index.d.ts +3 -0
  204. package/dist/docs/views/index.js +1031 -0
  205. package/dist/events.d.ts +142 -0
  206. package/dist/events.js +228 -0
  207. package/dist/events.test.d.ts +1 -0
  208. package/dist/examples/define.d.ts +5 -0
  209. package/dist/examples/define.js +36 -0
  210. package/dist/examples/docs/examples.docblock.d.ts +2 -0
  211. package/dist/examples/docs/examples.docblock.js +307 -0
  212. package/dist/examples/index.d.ts +7 -0
  213. package/dist/examples/index.js +604 -0
  214. package/dist/examples/registry.d.ts +38 -0
  215. package/dist/examples/registry.js +286 -0
  216. package/dist/examples/registry.test.d.ts +1 -0
  217. package/dist/examples/schema.d.ts +278 -0
  218. package/dist/examples/schema.js +166 -0
  219. package/dist/examples/schema.test.d.ts +1 -0
  220. package/dist/examples/types.d.ts +162 -0
  221. package/dist/examples/types.js +77 -0
  222. package/dist/examples/types.test.d.ts +1 -0
  223. package/dist/examples/validation.d.ts +61 -0
  224. package/dist/examples/validation.js +287 -0
  225. package/dist/examples/validation.test.d.ts +1 -0
  226. package/dist/experiments/docs/experiments.docblock.d.ts +2 -0
  227. package/dist/experiments/docs/experiments.docblock.js +291 -0
  228. package/dist/experiments/evaluator.d.ts +33 -0
  229. package/dist/experiments/evaluator.js +155 -0
  230. package/dist/experiments/evaluator.test.d.ts +1 -0
  231. package/dist/experiments/spec-resolver.d.ts +12 -0
  232. package/dist/experiments/spec-resolver.js +1 -0
  233. package/dist/experiments/spec.d.ts +79 -0
  234. package/dist/experiments/spec.js +227 -0
  235. package/dist/experiments/spec.test.d.ts +1 -0
  236. package/dist/features/index.d.ts +5 -0
  237. package/dist/features/index.js +275 -0
  238. package/dist/features/install.d.ts +14 -0
  239. package/dist/features/install.js +95 -0
  240. package/dist/features/install.test.d.ts +1 -0
  241. package/dist/features/registry.d.ts +21 -0
  242. package/dist/features/registry.js +192 -0
  243. package/dist/features/registry.test.d.ts +1 -0
  244. package/dist/features/types.d.ts +82 -0
  245. package/dist/features/types.js +36 -0
  246. package/dist/features/types.test.d.ts +1 -0
  247. package/dist/features/validation.d.ts +4 -0
  248. package/dist/features/validation.js +48 -0
  249. package/dist/features/validation.test.d.ts +1 -0
  250. package/dist/features.capabilities.test.d.ts +1 -0
  251. package/dist/forms/docs/forms.docblock.d.ts +2 -0
  252. package/dist/forms/docs/forms.docblock.js +164 -0
  253. package/dist/forms/forms.d.ts +264 -0
  254. package/dist/forms/forms.js +332 -0
  255. package/dist/forms/index.d.ts +1 -0
  256. package/dist/forms/index.js +332 -0
  257. package/dist/index.d.ts +36 -0
  258. package/dist/index.js +2195 -0
  259. package/dist/install.d.ts +75 -0
  260. package/dist/install.js +60 -0
  261. package/dist/integrations/binding.d.ts +14 -0
  262. package/dist/integrations/binding.js +1 -0
  263. package/dist/integrations/connection.d.ts +47 -0
  264. package/dist/integrations/connection.js +1 -0
  265. package/dist/integrations/docs/integrations.docblock.d.ts +2 -0
  266. package/dist/integrations/docs/integrations.docblock.js +140 -0
  267. package/dist/integrations/health.d.ts +17 -0
  268. package/dist/integrations/health.js +103 -0
  269. package/dist/integrations/health.test.d.ts +1 -0
  270. package/dist/integrations/index.d.ts +11 -0
  271. package/dist/integrations/index.js +3293 -0
  272. package/dist/integrations/integrations.capability.d.ts +1 -0
  273. package/dist/integrations/integrations.capability.js +48 -0
  274. package/dist/integrations/integrations.feature.d.ts +5 -0
  275. package/dist/integrations/integrations.feature.js +63 -0
  276. package/dist/integrations/meeting-recorder/contracts/index.d.ts +7 -0
  277. package/dist/integrations/meeting-recorder/contracts/index.js +504 -0
  278. package/dist/integrations/meeting-recorder/contracts/meetings.d.ts +451 -0
  279. package/dist/integrations/meeting-recorder/contracts/meetings.js +249 -0
  280. package/dist/integrations/meeting-recorder/contracts/transcripts.d.ts +166 -0
  281. package/dist/integrations/meeting-recorder/contracts/transcripts.js +317 -0
  282. package/dist/integrations/meeting-recorder/contracts/webhooks.d.ts +85 -0
  283. package/dist/integrations/meeting-recorder/contracts/webhooks.js +202 -0
  284. package/dist/integrations/meeting-recorder/meeting-recorder.capability.d.ts +1 -0
  285. package/dist/integrations/meeting-recorder/meeting-recorder.capability.js +48 -0
  286. package/dist/integrations/meeting-recorder/meeting-recorder.feature.d.ts +5 -0
  287. package/dist/integrations/meeting-recorder/meeting-recorder.feature.js +63 -0
  288. package/dist/integrations/meeting-recorder/models.d.ts +402 -0
  289. package/dist/integrations/meeting-recorder/models.js +152 -0
  290. package/dist/integrations/meeting-recorder/telemetry.d.ts +13 -0
  291. package/dist/integrations/meeting-recorder/telemetry.js +84 -0
  292. package/dist/integrations/openbanking/contracts/accounts.d.ts +282 -0
  293. package/dist/integrations/openbanking/contracts/accounts.js +358 -0
  294. package/dist/integrations/openbanking/contracts/balances.d.ts +158 -0
  295. package/dist/integrations/openbanking/contracts/balances.js +322 -0
  296. package/dist/integrations/openbanking/contracts/index.d.ts +7 -0
  297. package/dist/integrations/openbanking/contracts/index.js +674 -0
  298. package/dist/integrations/openbanking/contracts/transactions.d.ts +206 -0
  299. package/dist/integrations/openbanking/contracts/transactions.js +328 -0
  300. package/dist/integrations/openbanking/guards.d.ts +8 -0
  301. package/dist/integrations/openbanking/guards.js +72 -0
  302. package/dist/integrations/openbanking/guards.test.d.ts +1 -0
  303. package/dist/integrations/openbanking/models.d.ts +223 -0
  304. package/dist/integrations/openbanking/models.js +140 -0
  305. package/dist/integrations/openbanking/openbanking.capability.d.ts +1 -0
  306. package/dist/integrations/openbanking/openbanking.capability.js +48 -0
  307. package/dist/integrations/openbanking/openbanking.feature.d.ts +5 -0
  308. package/dist/integrations/openbanking/openbanking.feature.js +65 -0
  309. package/dist/integrations/openbanking/telemetry.d.ts +12 -0
  310. package/dist/integrations/openbanking/telemetry.js +81 -0
  311. package/dist/integrations/operations.d.ts +430 -0
  312. package/dist/integrations/operations.js +327 -0
  313. package/dist/integrations/operations.test.d.ts +1 -0
  314. package/dist/integrations/providers/analytics-reader.d.ts +103 -0
  315. package/dist/integrations/providers/analytics-reader.js +1 -0
  316. package/dist/integrations/providers/analytics-writer.d.ts +6 -0
  317. package/dist/integrations/providers/analytics-writer.js +1 -0
  318. package/dist/integrations/providers/analytics.d.ts +47 -0
  319. package/dist/integrations/providers/analytics.js +1 -0
  320. package/dist/integrations/providers/calendar.d.ts +75 -0
  321. package/dist/integrations/providers/calendar.js +1 -0
  322. package/dist/integrations/providers/database.d.ts +12 -0
  323. package/dist/integrations/providers/database.js +1 -0
  324. package/dist/integrations/providers/elevenlabs.d.ts +3 -0
  325. package/dist/integrations/providers/elevenlabs.js +116 -0
  326. package/dist/integrations/providers/email.d.ts +83 -0
  327. package/dist/integrations/providers/email.js +1 -0
  328. package/dist/integrations/providers/embedding.d.ts +21 -0
  329. package/dist/integrations/providers/embedding.js +1 -0
  330. package/dist/integrations/providers/fal.d.ts +3 -0
  331. package/dist/integrations/providers/fal.js +142 -0
  332. package/dist/integrations/providers/fathom.d.ts +3 -0
  333. package/dist/integrations/providers/fathom.js +156 -0
  334. package/dist/integrations/providers/fireflies.d.ts +3 -0
  335. package/dist/integrations/providers/fireflies.js +136 -0
  336. package/dist/integrations/providers/gcs-storage.d.ts +3 -0
  337. package/dist/integrations/providers/gcs-storage.js +127 -0
  338. package/dist/integrations/providers/gmail.d.ts +3 -0
  339. package/dist/integrations/providers/gmail.js +139 -0
  340. package/dist/integrations/providers/google-calendar.d.ts +3 -0
  341. package/dist/integrations/providers/google-calendar.js +122 -0
  342. package/dist/integrations/providers/gradium.d.ts +3 -0
  343. package/dist/integrations/providers/gradium.js +140 -0
  344. package/dist/integrations/providers/granola.d.ts +3 -0
  345. package/dist/integrations/providers/granola.js +137 -0
  346. package/dist/integrations/providers/index.d.ts +38 -0
  347. package/dist/integrations/providers/index.js +2124 -0
  348. package/dist/integrations/providers/jira.d.ts +3 -0
  349. package/dist/integrations/providers/jira.js +138 -0
  350. package/dist/integrations/providers/linear.d.ts +3 -0
  351. package/dist/integrations/providers/linear.js +137 -0
  352. package/dist/integrations/providers/llm.d.ts +79 -0
  353. package/dist/integrations/providers/llm.js +1 -0
  354. package/dist/integrations/providers/meeting-recorder.d.ts +129 -0
  355. package/dist/integrations/providers/meeting-recorder.js +1 -0
  356. package/dist/integrations/providers/mistral.d.ts +3 -0
  357. package/dist/integrations/providers/mistral.js +124 -0
  358. package/dist/integrations/providers/notion.d.ts +3 -0
  359. package/dist/integrations/providers/notion.js +143 -0
  360. package/dist/integrations/providers/openbanking.d.ts +125 -0
  361. package/dist/integrations/providers/openbanking.js +1 -0
  362. package/dist/integrations/providers/payments.d.ts +106 -0
  363. package/dist/integrations/providers/payments.js +1 -0
  364. package/dist/integrations/providers/posthog-llm-telemetry.d.ts +51 -0
  365. package/dist/integrations/providers/posthog-llm-telemetry.js +206 -0
  366. package/dist/integrations/providers/posthog.d.ts +3 -0
  367. package/dist/integrations/providers/posthog.js +136 -0
  368. package/dist/integrations/providers/postmark.d.ts +3 -0
  369. package/dist/integrations/providers/postmark.js +128 -0
  370. package/dist/integrations/providers/powens.d.ts +3 -0
  371. package/dist/integrations/providers/powens.js +154 -0
  372. package/dist/integrations/providers/project-management.d.ts +32 -0
  373. package/dist/integrations/providers/project-management.js +1 -0
  374. package/dist/integrations/providers/providers.test.d.ts +1 -0
  375. package/dist/integrations/providers/qdrant.d.ts +3 -0
  376. package/dist/integrations/providers/qdrant.js +131 -0
  377. package/dist/integrations/providers/registry.d.ts +6 -0
  378. package/dist/integrations/providers/registry.js +1908 -0
  379. package/dist/integrations/providers/sms.d.ts +31 -0
  380. package/dist/integrations/providers/sms.js +1 -0
  381. package/dist/integrations/providers/storage.d.ts +57 -0
  382. package/dist/integrations/providers/storage.js +1 -0
  383. package/dist/integrations/providers/stripe.d.ts +3 -0
  384. package/dist/integrations/providers/stripe.js +135 -0
  385. package/dist/integrations/providers/supabase-postgres.d.ts +3 -0
  386. package/dist/integrations/providers/supabase-postgres.js +117 -0
  387. package/dist/integrations/providers/supabase-vector.d.ts +3 -0
  388. package/dist/integrations/providers/supabase-vector.js +137 -0
  389. package/dist/integrations/providers/tldv.d.ts +3 -0
  390. package/dist/integrations/providers/tldv.js +136 -0
  391. package/dist/integrations/providers/twilio-sms.d.ts +3 -0
  392. package/dist/integrations/providers/twilio-sms.js +121 -0
  393. package/dist/integrations/providers/vector-store.d.ts +39 -0
  394. package/dist/integrations/providers/vector-store.js +1 -0
  395. package/dist/integrations/providers/voice.d.ts +31 -0
  396. package/dist/integrations/providers/voice.js +1 -0
  397. package/dist/integrations/runtime.d.ts +95 -0
  398. package/dist/integrations/runtime.js +239 -0
  399. package/dist/integrations/runtime.test.d.ts +1 -0
  400. package/dist/integrations/secrets/aws-secret-manager.d.ts +28 -0
  401. package/dist/integrations/secrets/aws-secret-manager.js +376 -0
  402. package/dist/integrations/secrets/env-secret-provider.d.ts +28 -0
  403. package/dist/integrations/secrets/env-secret-provider.js +189 -0
  404. package/dist/integrations/secrets/gcp-secret-manager.d.ts +29 -0
  405. package/dist/integrations/secrets/gcp-secret-manager.js +377 -0
  406. package/dist/integrations/secrets/index.d.ts +6 -0
  407. package/dist/integrations/secrets/index.js +1159 -0
  408. package/dist/integrations/secrets/manager.d.ts +44 -0
  409. package/dist/integrations/secrets/manager.js +213 -0
  410. package/dist/integrations/secrets/provider.d.ts +49 -0
  411. package/dist/integrations/secrets/provider.js +104 -0
  412. package/dist/integrations/secrets/provider.test.d.ts +1 -0
  413. package/dist/integrations/secrets/scaleway-secret-manager.d.ts +35 -0
  414. package/dist/integrations/secrets/scaleway-secret-manager.js +405 -0
  415. package/dist/integrations/secrets-types.d.ts +14 -0
  416. package/dist/integrations/secrets-types.js +1 -0
  417. package/dist/integrations/spec.d.ts +72 -0
  418. package/dist/integrations/spec.js +52 -0
  419. package/dist/integrations/spec.test.d.ts +1 -0
  420. package/dist/jobs/define-job.d.ts +15 -0
  421. package/dist/jobs/define-job.js +41 -0
  422. package/dist/jobs/gcp-cloud-tasks.d.ts +38 -0
  423. package/dist/jobs/gcp-cloud-tasks.js +103 -0
  424. package/dist/jobs/gcp-pubsub.d.ts +22 -0
  425. package/dist/jobs/gcp-pubsub.js +91 -0
  426. package/dist/jobs/handlers/gmail-sync-handler.d.ts +5 -0
  427. package/dist/jobs/handlers/gmail-sync-handler.js +40 -0
  428. package/dist/jobs/handlers/handlers.test.d.ts +1 -0
  429. package/dist/jobs/handlers/index.d.ts +5 -0
  430. package/dist/jobs/handlers/index.js +83 -0
  431. package/dist/jobs/handlers/ping-handler.d.ts +6 -0
  432. package/dist/jobs/handlers/ping-handler.js +47 -0
  433. package/dist/jobs/handlers/storage-document-handler.d.ts +8 -0
  434. package/dist/jobs/handlers/storage-document-handler.js +47 -0
  435. package/dist/jobs/index.d.ts +2 -0
  436. package/dist/jobs/index.js +64 -0
  437. package/dist/jobs/memory-queue.d.ts +14 -0
  438. package/dist/jobs/memory-queue.js +129 -0
  439. package/dist/jobs/queue.d.ts +126 -0
  440. package/dist/jobs/queue.js +55 -0
  441. package/dist/jobs/queue.test.d.ts +1 -0
  442. package/dist/jobs/scaleway-sqs-queue.d.ts +27 -0
  443. package/dist/jobs/scaleway-sqs-queue.js +222 -0
  444. package/dist/jsonschema.d.ts +39 -0
  445. package/dist/jsonschema.js +73 -0
  446. package/dist/jsonschema.test.d.ts +1 -0
  447. package/dist/knowledge/binding.d.ts +22 -0
  448. package/dist/knowledge/binding.js +1 -0
  449. package/dist/knowledge/docs/knowledge.docblock.d.ts +2 -0
  450. package/dist/knowledge/docs/knowledge.docblock.js +301 -0
  451. package/dist/knowledge/index.d.ts +4 -0
  452. package/dist/knowledge/index.js +467 -0
  453. package/dist/knowledge/ingestion/document-processor.d.ts +22 -0
  454. package/dist/knowledge/ingestion/document-processor.js +95 -0
  455. package/dist/knowledge/ingestion/embedding-service.d.ts +8 -0
  456. package/dist/knowledge/ingestion/embedding-service.js +57 -0
  457. package/dist/knowledge/ingestion/gmail-adapter.d.ts +14 -0
  458. package/dist/knowledge/ingestion/gmail-adapter.js +103 -0
  459. package/dist/knowledge/ingestion/index.d.ts +5 -0
  460. package/dist/knowledge/ingestion/index.js +252 -0
  461. package/dist/knowledge/ingestion/ingestion.test.d.ts +1 -0
  462. package/dist/knowledge/ingestion/storage-adapter.d.ts +11 -0
  463. package/dist/knowledge/ingestion/storage-adapter.js +62 -0
  464. package/dist/knowledge/ingestion/vector-indexer.d.ts +14 -0
  465. package/dist/knowledge/ingestion/vector-indexer.js +63 -0
  466. package/dist/knowledge/knowledge.capability.d.ts +1 -0
  467. package/dist/knowledge/knowledge.capability.js +726 -0
  468. package/dist/knowledge/knowledge.feature.d.ts +5 -0
  469. package/dist/knowledge/knowledge.feature.js +300 -0
  470. package/dist/knowledge/operations.d.ts +311 -0
  471. package/dist/knowledge/operations.js +619 -0
  472. package/dist/knowledge/operations.test.d.ts +1 -0
  473. package/dist/knowledge/query/index.d.ts +1 -0
  474. package/dist/knowledge/query/index.js +110 -0
  475. package/dist/knowledge/query/service.d.ts +25 -0
  476. package/dist/knowledge/query/service.js +110 -0
  477. package/dist/knowledge/query/service.test.d.ts +1 -0
  478. package/dist/knowledge/runtime.d.ts +28 -0
  479. package/dist/knowledge/runtime.js +91 -0
  480. package/dist/knowledge/runtime.test.d.ts +1 -0
  481. package/dist/knowledge/source.d.ts +29 -0
  482. package/dist/knowledge/source.js +1 -0
  483. package/dist/knowledge/spaces/email-threads.d.ts +3 -0
  484. package/dist/knowledge/spaces/email-threads.js +102 -0
  485. package/dist/knowledge/spaces/financial-docs.d.ts +3 -0
  486. package/dist/knowledge/spaces/financial-docs.js +102 -0
  487. package/dist/knowledge/spaces/financial-overview.d.ts +3 -0
  488. package/dist/knowledge/spaces/financial-overview.js +102 -0
  489. package/dist/knowledge/spaces/index.d.ts +6 -0
  490. package/dist/knowledge/spaces/index.js +273 -0
  491. package/dist/knowledge/spaces/product-canon.d.ts +3 -0
  492. package/dist/knowledge/spaces/product-canon.js +102 -0
  493. package/dist/knowledge/spaces/spaces.test.d.ts +1 -0
  494. package/dist/knowledge/spaces/support-faq.d.ts +3 -0
  495. package/dist/knowledge/spaces/support-faq.js +103 -0
  496. package/dist/knowledge/spaces/uploaded-docs.d.ts +3 -0
  497. package/dist/knowledge/spaces/uploaded-docs.js +102 -0
  498. package/dist/knowledge/spec.d.ts +42 -0
  499. package/dist/knowledge/spec.js +228 -0
  500. package/dist/knowledge/spec.test.d.ts +1 -0
  501. package/dist/llm/exporters.d.ts +68 -0
  502. package/dist/llm/exporters.js +1011 -0
  503. package/dist/llm/index.d.ts +12 -0
  504. package/dist/llm/index.js +1465 -0
  505. package/dist/llm/prompts.d.ts +53 -0
  506. package/dist/llm/prompts.js +1456 -0
  507. package/dist/llm/types.d.ts +212 -0
  508. package/dist/llm/types.js +1 -0
  509. package/dist/markdown.d.ts +16 -0
  510. package/dist/markdown.js +529 -0
  511. package/dist/migrations.d.ts +48 -0
  512. package/dist/migrations.js +67 -0
  513. package/dist/migrations.test.d.ts +1 -0
  514. package/dist/model-registry.d.ts +9 -0
  515. package/dist/model-registry.js +64 -0
  516. package/dist/model-registry.test.d.ts +1 -0
  517. package/dist/node/app-config/app-config.capability.js +730 -0
  518. package/dist/node/app-config/app-config.contracts.js +713 -0
  519. package/dist/node/app-config/app-config.feature.js +255 -0
  520. package/dist/node/app-config/branding.js +0 -0
  521. package/dist/node/app-config/docs/app-config.docblock.js +383 -0
  522. package/dist/node/app-config/events.js +386 -0
  523. package/dist/node/app-config/index.js +2899 -0
  524. package/dist/node/app-config/lifecycle-contracts.js +870 -0
  525. package/dist/node/app-config/lifecycle.js +0 -0
  526. package/dist/node/app-config/runtime.js +734 -0
  527. package/dist/node/app-config/spec.js +229 -0
  528. package/dist/node/app-config/validation.js +650 -0
  529. package/dist/node/capabilities/capabilities.js +217 -0
  530. package/dist/node/capabilities/context.js +101 -0
  531. package/dist/node/capabilities/docs/capabilities.docblock.js +353 -0
  532. package/dist/node/capabilities/guards.js +177 -0
  533. package/dist/node/capabilities/index.js +739 -0
  534. package/dist/node/capabilities/meeting-recorder.js +154 -0
  535. package/dist/node/capabilities/openbanking.js +166 -0
  536. package/dist/node/capabilities/validation.js +185 -0
  537. package/dist/node/contract-registry/index.js +129 -0
  538. package/dist/node/contract-registry/schemas.js +129 -0
  539. package/dist/node/contract-registry/types.js +0 -0
  540. package/dist/node/data-views/data-views.js +232 -0
  541. package/dist/node/data-views/docs/data-views.docblock.js +164 -0
  542. package/dist/node/data-views/index.js +232 -0
  543. package/dist/node/data-views/query-generator.js +89 -0
  544. package/dist/node/data-views/registry.js +226 -0
  545. package/dist/node/data-views/report/contractVerificationTable.js +240 -0
  546. package/dist/node/data-views/runtime.js +108 -0
  547. package/dist/node/data-views/spec.js +38 -0
  548. package/dist/node/data-views/types.js +0 -0
  549. package/dist/node/docs/accessibility_wcag_compliance_specs.docblock.js +513 -0
  550. package/dist/node/docs/capabilities/documentationSystem.capability.js +784 -0
  551. package/dist/node/docs/capabilities/index.js +784 -0
  552. package/dist/node/docs/commands/docsGenerate.command.js +802 -0
  553. package/dist/node/docs/commands/docsPublish.command.js +781 -0
  554. package/dist/node/docs/commands/index.js +906 -0
  555. package/dist/node/docs/constants.js +78 -0
  556. package/dist/node/docs/contracts.js +1611 -0
  557. package/dist/node/docs/ensure-docblocks.js +264 -0
  558. package/dist/node/docs/events/docsGenerated.event.js +533 -0
  559. package/dist/node/docs/events/docsPublished.event.js +534 -0
  560. package/dist/node/docs/events/index.js +567 -0
  561. package/dist/node/docs/forms/docsSearch.form.js +676 -0
  562. package/dist/node/docs/forms/index.js +676 -0
  563. package/dist/node/docs/index.js +4719 -0
  564. package/dist/node/docs/meta.docs.js +176 -0
  565. package/dist/node/docs/presentations/docsLayout.presentation.js +527 -0
  566. package/dist/node/docs/presentations/docsReferencePage.presentation.js +527 -0
  567. package/dist/node/docs/presentations/index.js +555 -0
  568. package/dist/node/docs/presentations.js +97 -0
  569. package/dist/node/docs/queries/contractReference.query.js +752 -0
  570. package/dist/node/docs/queries/docsIndex.query.js +752 -0
  571. package/dist/node/docs/queries/index.js +827 -0
  572. package/dist/node/docs/registry.js +153 -0
  573. package/dist/node/docs/tech/auth/better-auth-nextjs.docblock.js +221 -0
  574. package/dist/node/docs/tech/cli.docblock.js +291 -0
  575. package/dist/node/docs/tech/contracts/README.docblock.js +164 -0
  576. package/dist/node/docs/tech/contracts/migrations.docblock.js +164 -0
  577. package/dist/node/docs/tech/contracts/openapi-export.docblock.js +201 -0
  578. package/dist/node/docs/tech/contracts/openapi-import.docblock.js +207 -0
  579. package/dist/node/docs/tech/contracts/ops-to-presentation-linking.docblock.js +225 -0
  580. package/dist/node/docs/tech/contracts/overlays.docblock.js +231 -0
  581. package/dist/node/docs/tech/contracts/tests.docblock.js +164 -0
  582. package/dist/node/docs/tech/contracts/themes.docblock.js +257 -0
  583. package/dist/node/docs/tech/contracts/vertical-pocket-family-office.docblock.js +269 -0
  584. package/dist/node/docs/tech/docs-system.docblock.js +264 -0
  585. package/dist/node/docs/tech/lifecycle-stage-system.docblock.js +376 -0
  586. package/dist/node/docs/tech/llm/llm-integration.docblock.js +482 -0
  587. package/dist/node/docs/tech/mcp-endpoints.docblock.js +185 -0
  588. package/dist/node/docs/tech/presentation-runtime.docblock.js +221 -0
  589. package/dist/node/docs/tech/report-verification-table.docblock.js +191 -0
  590. package/dist/node/docs/tech/schema/README.docblock.js +164 -0
  591. package/dist/node/docs/tech/studio/learning-events.docblock.js +190 -0
  592. package/dist/node/docs/tech/studio/learning-journeys.docblock.js +227 -0
  593. package/dist/node/docs/tech/studio/platform-admin-panel.docblock.js +226 -0
  594. package/dist/node/docs/tech/studio/project-access-teams.docblock.js +200 -0
  595. package/dist/node/docs/tech/studio/project-routing.docblock.js +209 -0
  596. package/dist/node/docs/tech/studio/sandbox-unlogged.docblock.js +183 -0
  597. package/dist/node/docs/tech/studio/team-invitations.docblock.js +228 -0
  598. package/dist/node/docs/tech/studio/workspace-ops.docblock.js +189 -0
  599. package/dist/node/docs/tech/studio/workspaces.docblock.js +204 -0
  600. package/dist/node/docs/tech/telemetry-ingest.docblock.js +305 -0
  601. package/dist/node/docs/tech/vscode-extension.docblock.js +241 -0
  602. package/dist/node/docs/tech-contracts.docs.js +239 -0
  603. package/dist/node/docs/types.js +0 -0
  604. package/dist/node/docs/views/contractReference.dataView.js +838 -0
  605. package/dist/node/docs/views/docsIndex.dataView.js +832 -0
  606. package/dist/node/docs/views/exampleCatalog.dataView.js +816 -0
  607. package/dist/node/docs/views/index.js +1031 -0
  608. package/dist/node/events.js +228 -0
  609. package/dist/node/examples/define.js +36 -0
  610. package/dist/node/examples/docs/examples.docblock.js +307 -0
  611. package/dist/node/examples/index.js +604 -0
  612. package/dist/node/examples/registry.js +286 -0
  613. package/dist/node/examples/schema.js +166 -0
  614. package/dist/node/examples/types.js +77 -0
  615. package/dist/node/examples/validation.js +287 -0
  616. package/dist/node/experiments/docs/experiments.docblock.js +291 -0
  617. package/dist/node/experiments/evaluator.js +155 -0
  618. package/dist/node/experiments/spec-resolver.js +0 -0
  619. package/dist/node/experiments/spec.js +227 -0
  620. package/dist/node/features/index.js +275 -0
  621. package/dist/node/features/install.js +95 -0
  622. package/dist/node/features/registry.js +192 -0
  623. package/dist/node/features/types.js +36 -0
  624. package/dist/node/features/validation.js +48 -0
  625. package/dist/node/forms/docs/forms.docblock.js +164 -0
  626. package/dist/node/forms/forms.js +332 -0
  627. package/dist/node/forms/index.js +332 -0
  628. package/dist/node/index.js +2195 -0
  629. package/dist/node/install.js +60 -0
  630. package/dist/node/integrations/binding.js +0 -0
  631. package/dist/node/integrations/connection.js +0 -0
  632. package/dist/node/integrations/docs/integrations.docblock.js +140 -0
  633. package/dist/node/integrations/health.js +103 -0
  634. package/dist/node/integrations/index.js +3293 -0
  635. package/dist/node/integrations/integrations.capability.js +48 -0
  636. package/dist/node/integrations/integrations.feature.js +63 -0
  637. package/dist/node/integrations/meeting-recorder/contracts/index.js +504 -0
  638. package/dist/node/integrations/meeting-recorder/contracts/meetings.js +249 -0
  639. package/dist/node/integrations/meeting-recorder/contracts/transcripts.js +317 -0
  640. package/dist/node/integrations/meeting-recorder/contracts/webhooks.js +202 -0
  641. package/dist/node/integrations/meeting-recorder/meeting-recorder.capability.js +48 -0
  642. package/dist/node/integrations/meeting-recorder/meeting-recorder.feature.js +63 -0
  643. package/dist/node/integrations/meeting-recorder/models.js +152 -0
  644. package/dist/node/integrations/meeting-recorder/telemetry.js +84 -0
  645. package/dist/node/integrations/openbanking/contracts/accounts.js +358 -0
  646. package/dist/node/integrations/openbanking/contracts/balances.js +322 -0
  647. package/dist/node/integrations/openbanking/contracts/index.js +674 -0
  648. package/dist/node/integrations/openbanking/contracts/transactions.js +328 -0
  649. package/dist/node/integrations/openbanking/guards.js +72 -0
  650. package/dist/node/integrations/openbanking/models.js +140 -0
  651. package/dist/node/integrations/openbanking/openbanking.capability.js +48 -0
  652. package/dist/node/integrations/openbanking/openbanking.feature.js +65 -0
  653. package/dist/node/integrations/openbanking/telemetry.js +81 -0
  654. package/dist/node/integrations/operations.js +327 -0
  655. package/dist/node/integrations/providers/analytics-reader.js +0 -0
  656. package/dist/node/integrations/providers/analytics-writer.js +0 -0
  657. package/dist/node/integrations/providers/analytics.js +0 -0
  658. package/dist/node/integrations/providers/calendar.js +0 -0
  659. package/dist/node/integrations/providers/database.js +0 -0
  660. package/dist/node/integrations/providers/elevenlabs.js +116 -0
  661. package/dist/node/integrations/providers/email.js +0 -0
  662. package/dist/node/integrations/providers/embedding.js +0 -0
  663. package/dist/node/integrations/providers/fal.js +142 -0
  664. package/dist/node/integrations/providers/fathom.js +156 -0
  665. package/dist/node/integrations/providers/fireflies.js +136 -0
  666. package/dist/node/integrations/providers/gcs-storage.js +127 -0
  667. package/dist/node/integrations/providers/gmail.js +139 -0
  668. package/dist/node/integrations/providers/google-calendar.js +122 -0
  669. package/dist/node/integrations/providers/gradium.js +140 -0
  670. package/dist/node/integrations/providers/granola.js +137 -0
  671. package/dist/node/integrations/providers/index.js +2124 -0
  672. package/dist/node/integrations/providers/jira.js +138 -0
  673. package/dist/node/integrations/providers/linear.js +137 -0
  674. package/dist/node/integrations/providers/llm.js +0 -0
  675. package/dist/node/integrations/providers/meeting-recorder.js +0 -0
  676. package/dist/node/integrations/providers/mistral.js +124 -0
  677. package/dist/node/integrations/providers/notion.js +143 -0
  678. package/dist/node/integrations/providers/openbanking.js +0 -0
  679. package/dist/node/integrations/providers/payments.js +0 -0
  680. package/dist/node/integrations/providers/posthog-llm-telemetry.js +206 -0
  681. package/dist/node/integrations/providers/posthog.js +136 -0
  682. package/dist/node/integrations/providers/postmark.js +128 -0
  683. package/dist/node/integrations/providers/powens.js +154 -0
  684. package/dist/node/integrations/providers/project-management.js +0 -0
  685. package/dist/node/integrations/providers/qdrant.js +131 -0
  686. package/dist/node/integrations/providers/registry.js +1908 -0
  687. package/dist/node/integrations/providers/sms.js +0 -0
  688. package/dist/node/integrations/providers/storage.js +0 -0
  689. package/dist/node/integrations/providers/stripe.js +135 -0
  690. package/dist/node/integrations/providers/supabase-postgres.js +117 -0
  691. package/dist/node/integrations/providers/supabase-vector.js +137 -0
  692. package/dist/node/integrations/providers/tldv.js +136 -0
  693. package/dist/node/integrations/providers/twilio-sms.js +121 -0
  694. package/dist/node/integrations/providers/vector-store.js +0 -0
  695. package/dist/node/integrations/providers/voice.js +0 -0
  696. package/dist/node/integrations/runtime.js +239 -0
  697. package/dist/node/integrations/secrets/aws-secret-manager.js +376 -0
  698. package/dist/node/integrations/secrets/env-secret-provider.js +189 -0
  699. package/dist/node/integrations/secrets/gcp-secret-manager.js +377 -0
  700. package/dist/node/integrations/secrets/index.js +1159 -0
  701. package/dist/node/integrations/secrets/manager.js +213 -0
  702. package/dist/node/integrations/secrets/provider.js +104 -0
  703. package/dist/node/integrations/secrets/scaleway-secret-manager.js +405 -0
  704. package/dist/node/integrations/secrets-types.js +0 -0
  705. package/dist/node/integrations/spec.js +52 -0
  706. package/dist/node/jobs/define-job.js +41 -0
  707. package/dist/node/jobs/gcp-cloud-tasks.js +103 -0
  708. package/dist/node/jobs/gcp-pubsub.js +91 -0
  709. package/dist/node/jobs/handlers/gmail-sync-handler.js +40 -0
  710. package/dist/node/jobs/handlers/index.js +83 -0
  711. package/dist/node/jobs/handlers/ping-handler.js +47 -0
  712. package/dist/node/jobs/handlers/storage-document-handler.js +47 -0
  713. package/dist/node/jobs/index.js +64 -0
  714. package/dist/node/jobs/memory-queue.js +129 -0
  715. package/dist/node/jobs/queue.js +55 -0
  716. package/dist/node/jobs/scaleway-sqs-queue.js +222 -0
  717. package/dist/node/jsonschema.js +73 -0
  718. package/dist/node/knowledge/binding.js +0 -0
  719. package/dist/node/knowledge/docs/knowledge.docblock.js +301 -0
  720. package/dist/node/knowledge/index.js +467 -0
  721. package/dist/node/knowledge/ingestion/document-processor.js +95 -0
  722. package/dist/node/knowledge/ingestion/embedding-service.js +57 -0
  723. package/dist/node/knowledge/ingestion/gmail-adapter.js +103 -0
  724. package/dist/node/knowledge/ingestion/index.js +252 -0
  725. package/dist/node/knowledge/ingestion/storage-adapter.js +62 -0
  726. package/dist/node/knowledge/ingestion/vector-indexer.js +63 -0
  727. package/dist/node/knowledge/knowledge.capability.js +726 -0
  728. package/dist/node/knowledge/knowledge.feature.js +300 -0
  729. package/dist/node/knowledge/operations.js +619 -0
  730. package/dist/node/knowledge/query/index.js +110 -0
  731. package/dist/node/knowledge/query/service.js +110 -0
  732. package/dist/node/knowledge/runtime.js +91 -0
  733. package/dist/node/knowledge/source.js +0 -0
  734. package/dist/node/knowledge/spaces/email-threads.js +102 -0
  735. package/dist/node/knowledge/spaces/financial-docs.js +102 -0
  736. package/dist/node/knowledge/spaces/financial-overview.js +102 -0
  737. package/dist/node/knowledge/spaces/index.js +273 -0
  738. package/dist/node/knowledge/spaces/product-canon.js +102 -0
  739. package/dist/node/knowledge/spaces/support-faq.js +103 -0
  740. package/dist/node/knowledge/spaces/uploaded-docs.js +102 -0
  741. package/dist/node/knowledge/spec.js +228 -0
  742. package/dist/node/llm/exporters.js +1011 -0
  743. package/dist/node/llm/index.js +1465 -0
  744. package/dist/node/llm/prompts.js +1456 -0
  745. package/dist/node/llm/types.js +0 -0
  746. package/dist/node/markdown.js +529 -0
  747. package/dist/node/migrations.js +67 -0
  748. package/dist/node/model-registry.js +64 -0
  749. package/dist/node/onboarding-base.js +597 -0
  750. package/dist/node/openapi.js +151 -0
  751. package/dist/node/operations/index.js +408 -0
  752. package/dist/node/operations/operation.js +51 -0
  753. package/dist/node/operations/registry.js +405 -0
  754. package/dist/node/operations/report/getContractVerificationStatus.js +170 -0
  755. package/dist/node/operations/report/index.js +305 -0
  756. package/dist/node/ownership.js +73 -0
  757. package/dist/node/policy/context.js +206 -0
  758. package/dist/node/policy/docs/policy.docblock.js +313 -0
  759. package/dist/node/policy/engine.js +325 -0
  760. package/dist/node/policy/guards.js +387 -0
  761. package/dist/node/policy/index.js +1313 -0
  762. package/dist/node/policy/opa-adapter.js +110 -0
  763. package/dist/node/policy/registry.js +221 -0
  764. package/dist/node/policy/spec.js +0 -0
  765. package/dist/node/policy/validation.js +391 -0
  766. package/dist/node/presentations/docs/presentations-conventions.docblock.js +171 -0
  767. package/dist/node/presentations/index.js +227 -0
  768. package/dist/node/presentations/presentations.js +38 -0
  769. package/dist/node/presentations/registry.js +221 -0
  770. package/dist/node/presentations/transform-engine.js +600 -0
  771. package/dist/node/product-intent/contract-patch-intent.js +68 -0
  772. package/dist/node/product-intent/contract-spec-patch.js +75 -0
  773. package/dist/node/product-intent/evidence.js +45 -0
  774. package/dist/node/product-intent/findings.js +81 -0
  775. package/dist/node/product-intent/impact-report.js +62 -0
  776. package/dist/node/product-intent/index.js +742 -0
  777. package/dist/node/product-intent/insights.js +63 -0
  778. package/dist/node/product-intent/opportunity-brief.js +106 -0
  779. package/dist/node/product-intent/problems.js +55 -0
  780. package/dist/node/product-intent/registry.js +242 -0
  781. package/dist/node/product-intent/runtime.js +320 -0
  782. package/dist/node/product-intent/spec.js +425 -0
  783. package/dist/node/product-intent/task-pack.js +69 -0
  784. package/dist/node/product-intent/tickets.js +57 -0
  785. package/dist/node/product-intent/types.js +378 -0
  786. package/dist/node/product-intent/ui-wireframe.js +73 -0
  787. package/dist/node/prompt.js +38 -0
  788. package/dist/node/promptRegistry.js +63 -0
  789. package/dist/node/regenerator/adapters.js +0 -0
  790. package/dist/node/regenerator/docs/regenerator.docblock.js +164 -0
  791. package/dist/node/regenerator/executor.js +157 -0
  792. package/dist/node/regenerator/index.js +341 -0
  793. package/dist/node/regenerator/service.js +183 -0
  794. package/dist/node/regenerator/sinks.js +64 -0
  795. package/dist/node/regenerator/types.js +0 -0
  796. package/dist/node/regenerator/utils.js +87 -0
  797. package/dist/node/registry-utils.js +163 -0
  798. package/dist/node/registry.js +215 -0
  799. package/dist/node/resources.js +83 -0
  800. package/dist/node/schema-to-markdown.js +278 -0
  801. package/dist/node/serialization/index.js +179 -0
  802. package/dist/node/serialization/serializers.js +180 -0
  803. package/dist/node/serialization/types.js +0 -0
  804. package/dist/node/telemetry/anomaly.js +91 -0
  805. package/dist/node/telemetry/docs/telemetry.docblock.js +164 -0
  806. package/dist/node/telemetry/index.js +417 -0
  807. package/dist/node/telemetry/spec.js +261 -0
  808. package/dist/node/telemetry/tracker.js +129 -0
  809. package/dist/node/tests/index.js +231 -0
  810. package/dist/node/tests/runner.js +189 -0
  811. package/dist/node/tests/spec.js +74 -0
  812. package/dist/node/themes.js +225 -0
  813. package/dist/node/translations/catalog.js +0 -0
  814. package/dist/node/translations/index.js +533 -0
  815. package/dist/node/translations/registry.js +170 -0
  816. package/dist/node/translations/spec.js +36 -0
  817. package/dist/node/translations/tenant.js +0 -0
  818. package/dist/node/translations/validation.js +392 -0
  819. package/dist/node/types.js +0 -0
  820. package/dist/node/versioning/index.js +274 -0
  821. package/dist/node/versioning/refs.js +99 -0
  822. package/dist/node/versioning/types.js +55 -0
  823. package/dist/node/versioning/utils.js +184 -0
  824. package/dist/node/workflow/adapters/db-adapter.js +127 -0
  825. package/dist/node/workflow/adapters/file-adapter.js +38 -0
  826. package/dist/node/workflow/adapters/index.js +194 -0
  827. package/dist/node/workflow/adapters/memory-store.js +93 -0
  828. package/dist/node/workflow/context.js +247 -0
  829. package/dist/node/workflow/expression.js +157 -0
  830. package/dist/node/workflow/index.js +1546 -0
  831. package/dist/node/workflow/overview.docblock.js +164 -0
  832. package/dist/node/workflow/runner.js +532 -0
  833. package/dist/node/workflow/sla-monitor.js +84 -0
  834. package/dist/node/workflow/spec.js +221 -0
  835. package/dist/node/workflow/state.js +0 -0
  836. package/dist/node/workflow/validation.js +425 -0
  837. package/dist/node/workspace-config/contractsrc-schema.js +344 -0
  838. package/dist/node/workspace-config/contractsrc-types.js +0 -0
  839. package/dist/node/workspace-config/index.js +325 -0
  840. package/dist/node/workspace-config/workspace-config.docblock.js +188 -0
  841. package/dist/onboarding-base.d.ts +131 -0
  842. package/dist/onboarding-base.js +597 -0
  843. package/dist/openapi.d.ts +33 -0
  844. package/dist/openapi.js +151 -0
  845. package/dist/operations/index.d.ts +2 -0
  846. package/dist/operations/index.js +408 -0
  847. package/dist/operations/operation.d.ts +191 -0
  848. package/dist/operations/operation.js +51 -0
  849. package/dist/operations/registry.d.ts +58 -0
  850. package/dist/operations/registry.js +405 -0
  851. package/dist/operations/report/getContractVerificationStatus.d.ts +68 -0
  852. package/dist/operations/report/getContractVerificationStatus.js +170 -0
  853. package/dist/operations/report/getContractVerificationStatus.test.d.ts +1 -0
  854. package/dist/operations/report/index.d.ts +10 -0
  855. package/dist/operations/report/index.js +305 -0
  856. package/dist/operations/report/index.test.d.ts +1 -0
  857. package/dist/ownership.d.ts +211 -0
  858. package/dist/ownership.js +73 -0
  859. package/dist/ownership.test.d.ts +1 -0
  860. package/dist/policy/context.d.ts +234 -0
  861. package/dist/policy/context.js +206 -0
  862. package/dist/policy/context.test.d.ts +1 -0
  863. package/dist/policy/docs/policy.docblock.d.ts +2 -0
  864. package/dist/policy/docs/policy.docblock.js +313 -0
  865. package/dist/policy/engine.d.ts +36 -0
  866. package/dist/policy/engine.js +325 -0
  867. package/dist/policy/engine.test.d.ts +1 -0
  868. package/dist/policy/guards.d.ts +156 -0
  869. package/dist/policy/guards.js +387 -0
  870. package/dist/policy/guards.test.d.ts +1 -0
  871. package/dist/policy/index.d.ts +12 -0
  872. package/dist/policy/index.js +1313 -0
  873. package/dist/policy/opa-adapter.d.ts +41 -0
  874. package/dist/policy/opa-adapter.js +110 -0
  875. package/dist/policy/opa-adapter.test.d.ts +1 -0
  876. package/dist/policy/registry.d.ts +5 -0
  877. package/dist/policy/registry.js +221 -0
  878. package/dist/policy/spec.d.ts +102 -0
  879. package/dist/policy/spec.js +1 -0
  880. package/dist/policy/validation.d.ts +84 -0
  881. package/dist/policy/validation.js +391 -0
  882. package/dist/policy/validation.test.d.ts +1 -0
  883. package/dist/presentations/docs/presentations-conventions.docblock.d.ts +2 -0
  884. package/dist/presentations/docs/presentations-conventions.docblock.js +171 -0
  885. package/dist/presentations/index.d.ts +2 -0
  886. package/dist/presentations/index.js +227 -0
  887. package/dist/presentations/presentations.d.ts +52 -0
  888. package/dist/presentations/presentations.js +38 -0
  889. package/dist/presentations/registry.d.ts +6 -0
  890. package/dist/presentations/registry.js +221 -0
  891. package/dist/presentations/transform-engine.d.ts +62 -0
  892. package/dist/presentations/transform-engine.js +600 -0
  893. package/dist/presentations/transform-engine.test.d.ts +1 -0
  894. package/dist/product-intent/contract-patch-intent.d.ts +100 -0
  895. package/dist/product-intent/contract-patch-intent.js +68 -0
  896. package/dist/product-intent/contract-spec-patch.d.ts +86 -0
  897. package/dist/product-intent/contract-spec-patch.js +75 -0
  898. package/dist/product-intent/evidence.d.ts +14 -0
  899. package/dist/product-intent/evidence.js +45 -0
  900. package/dist/product-intent/findings.d.ts +57 -0
  901. package/dist/product-intent/findings.js +81 -0
  902. package/dist/product-intent/impact-report.d.ts +57 -0
  903. package/dist/product-intent/impact-report.js +62 -0
  904. package/dist/product-intent/index.d.ts +13 -0
  905. package/dist/product-intent/index.js +742 -0
  906. package/dist/product-intent/insights.d.ts +62 -0
  907. package/dist/product-intent/insights.js +63 -0
  908. package/dist/product-intent/opportunity-brief.d.ts +192 -0
  909. package/dist/product-intent/opportunity-brief.js +106 -0
  910. package/dist/product-intent/problems.d.ts +59 -0
  911. package/dist/product-intent/problems.js +55 -0
  912. package/dist/product-intent/registry.d.ts +28 -0
  913. package/dist/product-intent/registry.js +242 -0
  914. package/dist/product-intent/registry.test.d.ts +1 -0
  915. package/dist/product-intent/runtime.d.ts +92 -0
  916. package/dist/product-intent/runtime.js +320 -0
  917. package/dist/product-intent/runtime.test.d.ts +1 -0
  918. package/dist/product-intent/spec.d.ts +664 -0
  919. package/dist/product-intent/spec.js +425 -0
  920. package/dist/product-intent/task-pack.d.ts +98 -0
  921. package/dist/product-intent/task-pack.js +69 -0
  922. package/dist/product-intent/tickets.d.ts +67 -0
  923. package/dist/product-intent/tickets.js +57 -0
  924. package/dist/product-intent/types.d.ts +11 -0
  925. package/dist/product-intent/types.js +378 -0
  926. package/dist/product-intent/ui-wireframe.d.ts +100 -0
  927. package/dist/product-intent/ui-wireframe.js +73 -0
  928. package/dist/prompt.d.ts +49 -0
  929. package/dist/prompt.js +38 -0
  930. package/dist/prompt.test.d.ts +1 -0
  931. package/dist/promptRegistry.d.ts +11 -0
  932. package/dist/promptRegistry.js +63 -0
  933. package/dist/promptRegistry.test.d.ts +1 -0
  934. package/dist/regenerator/adapters.d.ts +15 -0
  935. package/dist/regenerator/adapters.js +1 -0
  936. package/dist/regenerator/docs/regenerator.docblock.d.ts +2 -0
  937. package/dist/regenerator/docs/regenerator.docblock.js +164 -0
  938. package/dist/regenerator/executor.d.ts +66 -0
  939. package/dist/regenerator/executor.js +157 -0
  940. package/dist/regenerator/executor.test.d.ts +1 -0
  941. package/dist/regenerator/index.d.ts +6 -0
  942. package/dist/regenerator/index.js +341 -0
  943. package/dist/regenerator/service.d.ts +29 -0
  944. package/dist/regenerator/service.js +183 -0
  945. package/dist/regenerator/service.test.d.ts +1 -0
  946. package/dist/regenerator/sinks.d.ts +23 -0
  947. package/dist/regenerator/sinks.js +64 -0
  948. package/dist/regenerator/sinks.test.d.ts +1 -0
  949. package/dist/regenerator/types.d.ts +103 -0
  950. package/dist/regenerator/types.js +1 -0
  951. package/dist/regenerator/utils.d.ts +6 -0
  952. package/dist/regenerator/utils.js +87 -0
  953. package/dist/registry-utils.d.ts +105 -0
  954. package/dist/registry-utils.js +163 -0
  955. package/dist/registry-utils.test.d.ts +1 -0
  956. package/dist/registry.d.ts +27 -0
  957. package/dist/registry.js +215 -0
  958. package/dist/resources.d.ts +60 -0
  959. package/dist/resources.js +83 -0
  960. package/dist/schema-to-markdown.d.ts +56 -0
  961. package/dist/schema-to-markdown.js +278 -0
  962. package/dist/serialization/index.d.ts +10 -0
  963. package/dist/serialization/index.js +179 -0
  964. package/dist/serialization/serializers.d.ts +35 -0
  965. package/dist/serialization/serializers.js +180 -0
  966. package/dist/serialization/types.d.ts +100 -0
  967. package/dist/serialization/types.js +1 -0
  968. package/dist/telemetry/anomaly.d.ts +23 -0
  969. package/dist/telemetry/anomaly.js +91 -0
  970. package/dist/telemetry/anomaly.test.d.ts +1 -0
  971. package/dist/telemetry/docs/telemetry.docblock.d.ts +2 -0
  972. package/dist/telemetry/docs/telemetry.docblock.js +164 -0
  973. package/dist/telemetry/index.d.ts +3 -0
  974. package/dist/telemetry/index.js +417 -0
  975. package/dist/telemetry/spec.d.ts +87 -0
  976. package/dist/telemetry/spec.js +261 -0
  977. package/dist/telemetry/spec.test.d.ts +1 -0
  978. package/dist/telemetry/tracker.d.ts +48 -0
  979. package/dist/telemetry/tracker.js +129 -0
  980. package/dist/telemetry/tracker.test.d.ts +1 -0
  981. package/dist/tests/index.d.ts +2 -0
  982. package/dist/tests/index.js +231 -0
  983. package/dist/tests/runner.d.ts +38 -0
  984. package/dist/tests/runner.js +189 -0
  985. package/dist/tests/runner.test.d.ts +1 -0
  986. package/dist/tests/spec.d.ts +82 -0
  987. package/dist/tests/spec.js +74 -0
  988. package/dist/tests/spec.test.d.ts +1 -0
  989. package/dist/themes.d.ts +50 -0
  990. package/dist/themes.js +225 -0
  991. package/dist/themes.test.d.ts +1 -0
  992. package/dist/translations/catalog.d.ts +25 -0
  993. package/dist/translations/catalog.js +1 -0
  994. package/dist/translations/index.d.ts +44 -0
  995. package/dist/translations/index.js +533 -0
  996. package/dist/translations/registry.d.ts +172 -0
  997. package/dist/translations/registry.js +170 -0
  998. package/dist/translations/registry.test.d.ts +1 -0
  999. package/dist/translations/spec.d.ts +153 -0
  1000. package/dist/translations/spec.js +36 -0
  1001. package/dist/translations/spec.test.d.ts +1 -0
  1002. package/dist/translations/tenant.d.ts +11 -0
  1003. package/dist/translations/tenant.js +1 -0
  1004. package/dist/translations/validation.d.ts +106 -0
  1005. package/dist/translations/validation.js +392 -0
  1006. package/dist/translations/validation.test.d.ts +1 -0
  1007. package/dist/types.d.ts +212 -0
  1008. package/dist/types.js +1 -0
  1009. package/dist/versioning/index.d.ts +9 -0
  1010. package/dist/versioning/index.js +274 -0
  1011. package/dist/versioning/refs.d.ts +176 -0
  1012. package/dist/versioning/refs.js +99 -0
  1013. package/dist/versioning/refs.test.d.ts +4 -0
  1014. package/dist/versioning/types.d.ts +130 -0
  1015. package/dist/versioning/types.js +55 -0
  1016. package/dist/versioning/utils.d.ts +93 -0
  1017. package/dist/versioning/utils.js +184 -0
  1018. package/dist/versioning/utils.test.d.ts +4 -0
  1019. package/dist/workflow/adapters/db-adapter.d.ts +43 -0
  1020. package/dist/workflow/adapters/db-adapter.js +127 -0
  1021. package/dist/workflow/adapters/file-adapter.d.ts +10 -0
  1022. package/dist/workflow/adapters/file-adapter.js +38 -0
  1023. package/dist/workflow/adapters/index.d.ts +3 -0
  1024. package/dist/workflow/adapters/index.js +194 -0
  1025. package/dist/workflow/adapters/memory-store.d.ts +13 -0
  1026. package/dist/workflow/adapters/memory-store.js +93 -0
  1027. package/dist/workflow/context.d.ts +217 -0
  1028. package/dist/workflow/context.js +247 -0
  1029. package/dist/workflow/context.test.d.ts +1 -0
  1030. package/dist/workflow/expression.d.ts +6 -0
  1031. package/dist/workflow/expression.js +157 -0
  1032. package/dist/workflow/expression.test.d.ts +1 -0
  1033. package/dist/workflow/index.d.ts +13 -0
  1034. package/dist/workflow/index.js +1546 -0
  1035. package/dist/workflow/overview.docblock.d.ts +2 -0
  1036. package/dist/workflow/overview.docblock.js +164 -0
  1037. package/dist/workflow/runner.d.ts +71 -0
  1038. package/dist/workflow/runner.js +532 -0
  1039. package/dist/workflow/runner.test.d.ts +1 -0
  1040. package/dist/workflow/sla-monitor.d.ts +16 -0
  1041. package/dist/workflow/sla-monitor.js +84 -0
  1042. package/dist/workflow/spec.d.ts +81 -0
  1043. package/dist/workflow/spec.js +221 -0
  1044. package/dist/workflow/state.d.ts +31 -0
  1045. package/dist/workflow/state.js +1 -0
  1046. package/dist/workflow/validation.d.ts +87 -0
  1047. package/dist/workflow/validation.js +425 -0
  1048. package/dist/workflow/validation.test.d.ts +1 -0
  1049. package/dist/workspace-config/contractsrc-schema.d.ts +144 -0
  1050. package/dist/workspace-config/contractsrc-schema.js +344 -0
  1051. package/dist/workspace-config/contractsrc-schema.test.d.ts +1 -0
  1052. package/dist/workspace-config/contractsrc-types.d.ts +342 -0
  1053. package/dist/workspace-config/contractsrc-types.js +1 -0
  1054. package/dist/workspace-config/index.d.ts +5 -0
  1055. package/dist/workspace-config/index.js +325 -0
  1056. package/dist/workspace-config/workspace-config.docblock.d.ts +2 -0
  1057. package/dist/workspace-config/workspace-config.docblock.js +188 -0
  1058. package/package.json +4426 -0
@@ -0,0 +1,1546 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
7
+ var __toCommonJS = (from) => {
8
+ var entry = __moduleCache.get(from), desc;
9
+ if (entry)
10
+ return entry;
11
+ entry = __defProp({}, "__esModule", { value: true });
12
+ if (from && typeof from === "object" || typeof from === "function")
13
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ }));
17
+ __moduleCache.set(from, entry);
18
+ return entry;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
29
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
+ var __require = import.meta.require;
31
+
32
+ // src/registry-utils.ts
33
+ var exports_registry_utils = {};
34
+ __export(exports_registry_utils, {
35
+ groupByToArray: () => groupByToArray,
36
+ groupByMultiple: () => groupByMultiple,
37
+ groupBy: () => groupBy,
38
+ getUniqueTags: () => getUniqueTags,
39
+ getUniqueOwners: () => getUniqueOwners,
40
+ getUniqueDomains: () => getUniqueDomains,
41
+ filterBy: () => filterBy,
42
+ GroupingStrategies: () => GroupingStrategies
43
+ });
44
+ function filterBy(items, filter) {
45
+ return items.filter((item) => {
46
+ if (filter.tags?.length) {
47
+ const hasMatchingTag = filter.tags.some((tag) => item.meta.tags?.includes(tag));
48
+ if (!hasMatchingTag)
49
+ return false;
50
+ }
51
+ if (filter.owners?.length) {
52
+ const hasMatchingOwner = filter.owners.some((owner) => item.meta.owners?.includes(owner));
53
+ if (!hasMatchingOwner)
54
+ return false;
55
+ }
56
+ if (filter.stability?.length) {
57
+ if (!filter.stability.includes(item.meta.stability ?? "stable")) {
58
+ return false;
59
+ }
60
+ }
61
+ if (filter.domain) {
62
+ const itemDomain = GroupingStrategies.byDomain(item);
63
+ if (itemDomain !== filter.domain)
64
+ return false;
65
+ }
66
+ if (filter.keyPattern) {
67
+ const name = item.meta.key ?? item.meta.key ?? "";
68
+ const pattern = filter.keyPattern.replace(/\*/g, ".*").replace(/\?/g, ".");
69
+ const regex = new RegExp(`^${pattern}$`, "i");
70
+ if (!regex.test(name))
71
+ return false;
72
+ }
73
+ return true;
74
+ });
75
+ }
76
+ function groupBy(items, keyFn) {
77
+ const groups = new Map;
78
+ for (const item of items) {
79
+ const key = keyFn(item);
80
+ const existing = groups.get(key);
81
+ if (existing) {
82
+ existing.push(item);
83
+ } else {
84
+ groups.set(key, [item]);
85
+ }
86
+ }
87
+ return groups;
88
+ }
89
+ function groupByToArray(items, keyFn) {
90
+ const map = groupBy(items, keyFn);
91
+ return Array.from(map.entries()).map(([key, items2]) => ({ key, items: items2 }));
92
+ }
93
+ function groupByMultiple(items, keysFn) {
94
+ const groups = new Map;
95
+ for (const item of items) {
96
+ const keys = keysFn(item);
97
+ for (const key of keys) {
98
+ const existing = groups.get(key);
99
+ if (existing) {
100
+ existing.push(item);
101
+ } else {
102
+ groups.set(key, [item]);
103
+ }
104
+ }
105
+ }
106
+ return groups;
107
+ }
108
+ function getUniqueTags(items) {
109
+ const tags = new Set;
110
+ for (const item of items) {
111
+ for (const tag of item.meta.tags ?? []) {
112
+ tags.add(tag);
113
+ }
114
+ }
115
+ return Array.from(tags).sort();
116
+ }
117
+ function getUniqueOwners(items) {
118
+ const owners = new Set;
119
+ for (const item of items) {
120
+ for (const owner of item.meta.owners ?? []) {
121
+ owners.add(owner);
122
+ }
123
+ }
124
+ return Array.from(owners).sort();
125
+ }
126
+ function getUniqueDomains(items) {
127
+ const domains = new Set;
128
+ for (const item of items) {
129
+ domains.add(GroupingStrategies.byDomain(item));
130
+ }
131
+ return Array.from(domains).sort();
132
+ }
133
+ var GroupingStrategies;
134
+ var init_registry_utils = __esm(() => {
135
+ GroupingStrategies = {
136
+ byTag: (item) => item.meta.tags?.[0] ?? "untagged",
137
+ byAllTags: (item) => item.meta.tags?.length ? item.meta.tags : ["untagged"],
138
+ byOwner: (item) => item.meta.owners?.[0] ?? "unowned",
139
+ byDomain: (item) => {
140
+ const name = item.meta.key ?? item.meta.key ?? "";
141
+ return name.split(".")[0] ?? "default";
142
+ },
143
+ byStability: (item) => item.meta.stability ?? "stable",
144
+ byUrlPath: (level) => (item) => {
145
+ if (!item.path)
146
+ return "root";
147
+ const segments = item.path.split("/").filter(Boolean);
148
+ return segments.slice(0, level).join("/") || "root";
149
+ }
150
+ };
151
+ });
152
+
153
+ // src/registry.ts
154
+ init_registry_utils();
155
+ import { compareVersions } from "compare-versions";
156
+ var keyOfSpecContract = (spec) => `${spec.meta.key}.v${spec.meta.version}`;
157
+
158
+ class SpecContractRegistry {
159
+ contractType;
160
+ items = new Map;
161
+ constructor(contractType, items) {
162
+ this.contractType = contractType;
163
+ if (items) {
164
+ items.forEach((p) => this.register(p));
165
+ }
166
+ }
167
+ register(p) {
168
+ const key = keyOfSpecContract(p);
169
+ if (this.items.has(key))
170
+ throw new Error(`Duplicate contract \`${this.contractType}\` ${key}`);
171
+ this.items.set(key, p);
172
+ return this;
173
+ }
174
+ count() {
175
+ return this.items.size;
176
+ }
177
+ list() {
178
+ return [...this.items.values()];
179
+ }
180
+ get(key, version) {
181
+ if (version != null)
182
+ return this.items.get(`${key}.v${version}`);
183
+ let candidate;
184
+ for (const [k, p] of this.items.entries()) {
185
+ if (!k.startsWith(`${key}.v`))
186
+ continue;
187
+ if (!candidate || compareVersions(p.meta.version, candidate.meta.version) > 0) {
188
+ candidate = p;
189
+ }
190
+ }
191
+ return candidate;
192
+ }
193
+ has(key, version) {
194
+ return !!this.get(key, version);
195
+ }
196
+ filter(criteria) {
197
+ return filterBy(this.list(), criteria);
198
+ }
199
+ listByTag(tag) {
200
+ return this.list().filter((p) => p.meta.tags?.includes(tag));
201
+ }
202
+ listByOwner(owner) {
203
+ return this.list().filter((p) => p.meta.owners?.includes(owner));
204
+ }
205
+ groupBy(keyFn) {
206
+ return groupBy(this.list(), keyFn);
207
+ }
208
+ getUniqueTags() {
209
+ return getUniqueTags(this.list());
210
+ }
211
+ }
212
+
213
+ // src/workflow/adapters/db-adapter.ts
214
+ class PrismaStateStore {
215
+ prisma;
216
+ constructor(prisma) {
217
+ this.prisma = prisma;
218
+ }
219
+ async create(state) {
220
+ await this.prisma.workflowState.create({
221
+ data: {
222
+ id: state.workflowId,
223
+ name: state.workflowName,
224
+ version: state.workflowVersion,
225
+ status: state.status,
226
+ currentStep: state.currentStep,
227
+ data: state.data,
228
+ history: state.history,
229
+ retryCounts: state.retryCounts ?? {},
230
+ createdAt: state.createdAt,
231
+ updatedAt: state.updatedAt
232
+ }
233
+ });
234
+ }
235
+ async get(workflowId) {
236
+ const record = await this.prisma.workflowState.findUnique({
237
+ where: { id: workflowId }
238
+ });
239
+ if (!record)
240
+ return;
241
+ return {
242
+ workflowId: record.id,
243
+ workflowName: record.name,
244
+ workflowVersion: record.version,
245
+ currentStep: record.currentStep,
246
+ data: record.data,
247
+ history: record.history,
248
+ retryCounts: record.retryCounts,
249
+ status: record.status,
250
+ createdAt: record.createdAt,
251
+ updatedAt: record.updatedAt
252
+ };
253
+ }
254
+ async update(workflowId, updater) {
255
+ const current = await this.get(workflowId);
256
+ if (!current) {
257
+ throw new Error(`Workflow ${workflowId} not found`);
258
+ }
259
+ const next = updater(current);
260
+ const updated = await this.prisma.workflowState.update({
261
+ where: { id: workflowId },
262
+ data: {
263
+ status: next.status,
264
+ currentStep: next.currentStep,
265
+ data: next.data,
266
+ history: next.history,
267
+ retryCounts: next.retryCounts,
268
+ updatedAt: next.updatedAt
269
+ }
270
+ });
271
+ return {
272
+ workflowId: updated.id,
273
+ workflowName: updated.name,
274
+ workflowVersion: updated.version,
275
+ currentStep: updated.currentStep,
276
+ data: updated.data,
277
+ history: updated.history,
278
+ retryCounts: updated.retryCounts,
279
+ status: updated.status,
280
+ createdAt: updated.createdAt,
281
+ updatedAt: updated.updatedAt
282
+ };
283
+ }
284
+ async list(filters) {
285
+ const where = {};
286
+ if (filters?.status) {
287
+ where.status = filters.status;
288
+ }
289
+ const records = await this.prisma.workflowState.findMany({
290
+ where
291
+ });
292
+ return records.map((record) => ({
293
+ workflowId: record.id,
294
+ workflowName: record.name,
295
+ workflowVersion: record.version,
296
+ currentStep: record.currentStep,
297
+ data: record.data,
298
+ history: record.history,
299
+ retryCounts: record.retryCounts,
300
+ status: record.status,
301
+ createdAt: record.createdAt,
302
+ updatedAt: record.updatedAt
303
+ }));
304
+ }
305
+ }
306
+
307
+ // src/workflow/adapters/file-adapter.ts
308
+ function createFileStateStore(_options) {
309
+ throw new Error("File-backed state store adapter not implemented. Provide a custom adapter that satisfies StateStore.");
310
+ }
311
+
312
+ // src/workflow/adapters/memory-store.ts
313
+ function cloneState(state) {
314
+ return {
315
+ ...state,
316
+ data: deepCopy(state.data),
317
+ history: state.history.map((execution) => ({
318
+ ...execution,
319
+ input: deepCopy(execution.input),
320
+ output: deepCopy(execution.output),
321
+ startedAt: new Date(execution.startedAt),
322
+ completedAt: execution.completedAt ? new Date(execution.completedAt) : undefined
323
+ })),
324
+ createdAt: new Date(state.createdAt),
325
+ updatedAt: new Date(state.updatedAt)
326
+ };
327
+ }
328
+
329
+ class InMemoryStateStore {
330
+ items = new Map;
331
+ async create(state) {
332
+ if (this.items.has(state.workflowId))
333
+ throw new Error(`Workflow state already exists: ${state.workflowId}`);
334
+ this.items.set(state.workflowId, cloneState(state));
335
+ }
336
+ async get(workflowId) {
337
+ const state = this.items.get(workflowId);
338
+ return state ? cloneState(state) : undefined;
339
+ }
340
+ async update(workflowId, updater) {
341
+ const current = this.items.get(workflowId);
342
+ if (!current)
343
+ throw new Error(`Workflow state not found for ${workflowId}`);
344
+ const next = cloneState(updater(cloneState(current)));
345
+ this.items.set(workflowId, next);
346
+ return cloneState(next);
347
+ }
348
+ async list(filters) {
349
+ const all = [...this.items.values()];
350
+ const filtered = filters?.status ? all.filter((state) => state.status === filters.status) : all;
351
+ return filtered.map(cloneState);
352
+ }
353
+ clear() {
354
+ this.items.clear();
355
+ }
356
+ }
357
+ function deepCopy(value) {
358
+ if (value instanceof Date)
359
+ return new Date(value.getTime());
360
+ if (Array.isArray(value))
361
+ return value.map((item) => deepCopy(item));
362
+ if (value && typeof value === "object") {
363
+ const result = {};
364
+ for (const [key, val] of Object.entries(value)) {
365
+ result[key] = deepCopy(val);
366
+ }
367
+ return result;
368
+ }
369
+ return value;
370
+ }
371
+ // src/workflow/context.ts
372
+ class WorkflowContextError extends Error {
373
+ errorType;
374
+ workflowId;
375
+ details;
376
+ constructor(type, workflowId, message, details) {
377
+ super(message);
378
+ this.name = "WorkflowContextError";
379
+ this.errorType = type;
380
+ this.workflowId = workflowId;
381
+ this.details = details;
382
+ }
383
+ }
384
+
385
+ class WorkflowContextImpl {
386
+ state;
387
+ spec;
388
+ constructor(state, spec) {
389
+ this.state = state;
390
+ this.spec = spec;
391
+ }
392
+ get workflowId() {
393
+ return this.state.workflowId;
394
+ }
395
+ get workflowKey() {
396
+ return this.state.workflowName;
397
+ }
398
+ get workflowVersion() {
399
+ return this.state.workflowVersion;
400
+ }
401
+ get currentStep() {
402
+ return this.state.currentStep;
403
+ }
404
+ get status() {
405
+ return this.state.status;
406
+ }
407
+ get data() {
408
+ return this.state.data;
409
+ }
410
+ get history() {
411
+ return this.state.history;
412
+ }
413
+ getState() {
414
+ return this.state;
415
+ }
416
+ getData(key) {
417
+ return this.state.data[key];
418
+ }
419
+ isTerminal() {
420
+ return this.state.status === "completed" || this.state.status === "failed" || this.state.status === "cancelled";
421
+ }
422
+ isRunning() {
423
+ return this.state.status === "running";
424
+ }
425
+ getCurrentStepDef() {
426
+ return this.spec.definition.steps.find((s) => s.id === this.state.currentStep);
427
+ }
428
+ getRetryCount(stepId) {
429
+ const id = stepId ?? this.state.currentStep;
430
+ return this.state.retryCounts?.[id] ?? 0;
431
+ }
432
+ canTransition(toStepId) {
433
+ const transitions = this.spec.definition.transitions.filter((t) => t.from === this.state.currentStep && t.to === toStepId);
434
+ return transitions.length > 0;
435
+ }
436
+ getAvailableTransitions() {
437
+ return this.spec.definition.transitions.filter((t) => t.from === this.state.currentStep).map((t) => ({
438
+ from: t.from,
439
+ to: t.to,
440
+ label: t.label,
441
+ condition: t.condition
442
+ }));
443
+ }
444
+ hasNextStep() {
445
+ return this.spec.definition.transitions.some((t) => t.from === this.state.currentStep);
446
+ }
447
+ getRemainingTime(slaKey) {
448
+ const sla = this.spec.definition.sla;
449
+ if (!sla)
450
+ return null;
451
+ const now = Date.now();
452
+ if (slaKey === "totalDuration") {
453
+ if (!sla.totalDurationMs)
454
+ return null;
455
+ const elapsed2 = now - this.state.createdAt.getTime();
456
+ return Math.max(0, sla.totalDurationMs - elapsed2);
457
+ }
458
+ const stepLimit = sla.stepDurationMs?.[slaKey];
459
+ if (!stepLimit)
460
+ return null;
461
+ const stepExecution = this.state.history.find((h) => h.stepId === slaKey && h.status === "running");
462
+ if (!stepExecution)
463
+ return stepLimit;
464
+ const elapsed = now - stepExecution.startedAt.getTime();
465
+ return Math.max(0, stepLimit - elapsed);
466
+ }
467
+ isSlaViolated(slaKey) {
468
+ const remaining = this.getRemainingTime(slaKey);
469
+ return remaining !== null && remaining <= 0;
470
+ }
471
+ getAllSlaStatuses() {
472
+ const sla = this.spec.definition.sla;
473
+ if (!sla)
474
+ return [];
475
+ const statuses = [];
476
+ const now = Date.now();
477
+ if (sla.totalDurationMs) {
478
+ const elapsed = now - this.state.createdAt.getTime();
479
+ const remaining = Math.max(0, sla.totalDurationMs - elapsed);
480
+ statuses.push({
481
+ key: "totalDuration",
482
+ type: "workflow",
483
+ limitMs: sla.totalDurationMs,
484
+ elapsedMs: elapsed,
485
+ remainingMs: remaining,
486
+ violated: remaining <= 0,
487
+ percentUsed: elapsed / sla.totalDurationMs * 100
488
+ });
489
+ }
490
+ if (sla.stepDurationMs) {
491
+ for (const [stepId, limitMs] of Object.entries(sla.stepDurationMs)) {
492
+ const stepExecution = this.state.history.find((h) => h.stepId === stepId && h.status === "running");
493
+ const elapsed = stepExecution ? now - stepExecution.startedAt.getTime() : 0;
494
+ const remaining = Math.max(0, limitMs - elapsed);
495
+ statuses.push({
496
+ key: stepId,
497
+ type: "step",
498
+ stepId,
499
+ limitMs,
500
+ elapsedMs: elapsed,
501
+ remainingMs: remaining,
502
+ violated: stepExecution !== undefined && remaining <= 0,
503
+ percentUsed: elapsed / limitMs * 100
504
+ });
505
+ }
506
+ }
507
+ return statuses;
508
+ }
509
+ hasCompensation() {
510
+ return this.spec.definition.compensation !== undefined;
511
+ }
512
+ getCompensableSteps() {
513
+ const compensation = this.spec.definition.compensation;
514
+ if (!compensation)
515
+ return [];
516
+ return compensation.steps.map((s) => s.stepId);
517
+ }
518
+ getEvents() {
519
+ const events = [];
520
+ for (const execution of this.state.history) {
521
+ events.push({
522
+ timestamp: execution.startedAt,
523
+ type: "step_started",
524
+ stepId: execution.stepId,
525
+ input: execution.input
526
+ });
527
+ if (execution.completedAt) {
528
+ if (execution.status === "completed") {
529
+ events.push({
530
+ timestamp: execution.completedAt,
531
+ type: "step_completed",
532
+ stepId: execution.stepId,
533
+ output: execution.output
534
+ });
535
+ } else if (execution.status === "failed") {
536
+ events.push({
537
+ timestamp: execution.completedAt,
538
+ type: "step_failed",
539
+ stepId: execution.stepId,
540
+ error: execution.error
541
+ });
542
+ }
543
+ }
544
+ }
545
+ events.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
546
+ return events;
547
+ }
548
+ }
549
+ function createWorkflowContext(state, spec) {
550
+ return new WorkflowContextImpl(state, spec);
551
+ }
552
+ function calculateWorkflowProgress(ctx) {
553
+ const state = ctx.getState();
554
+ const completedSteps = new Set(state.history.filter((h) => h.status === "completed").map((h) => h.stepId));
555
+ const _totalSteps = completedSteps.size + (ctx.isTerminal() ? 0 : 1);
556
+ if (ctx.status === "completed")
557
+ return 100;
558
+ if (ctx.status === "failed" || ctx.status === "cancelled") {
559
+ return completedSteps.size > 0 ? Math.min(99, completedSteps.size * 20) : 0;
560
+ }
561
+ return Math.min(99, completedSteps.size * 20);
562
+ }
563
+ function getWorkflowDuration(ctx) {
564
+ const state = ctx.getState();
565
+ const endTime = ctx.isTerminal() ? state.updatedAt.getTime() : Date.now();
566
+ return endTime - state.createdAt.getTime();
567
+ }
568
+ function getAverageStepDuration(ctx) {
569
+ const completedSteps = ctx.history.filter((h) => h.status === "completed" && h.completedAt);
570
+ if (completedSteps.length === 0)
571
+ return 0;
572
+ const totalDuration = completedSteps.reduce((sum, step) => {
573
+ if (!step.completedAt)
574
+ return sum;
575
+ const duration = step.completedAt.getTime() - step.startedAt.getTime();
576
+ return sum + duration;
577
+ }, 0);
578
+ return totalDuration / completedSteps.length;
579
+ }
580
+
581
+ // src/workflow/expression.ts
582
+ function evaluateExpression(expression, ctx) {
583
+ if (!expression)
584
+ return true;
585
+ const trimmed = expression.trim();
586
+ if (!trimmed)
587
+ return true;
588
+ const orParts = splitByOperator(trimmed, "||");
589
+ if (orParts.length > 1)
590
+ return orParts.some((part) => evaluateExpression(part, ctx));
591
+ const andParts = splitByOperator(trimmed, "&&");
592
+ if (andParts.length > 1)
593
+ return andParts.every((part) => evaluateExpression(part, ctx));
594
+ return evaluateSingle(trimmed, ctx);
595
+ }
596
+ function evaluateSingle(expr, ctx) {
597
+ const trimmed = expr.trim();
598
+ if (!trimmed)
599
+ return true;
600
+ if (trimmed.startsWith("!"))
601
+ return !evaluateSingle(trimmed.slice(1), ctx);
602
+ const comparisonMatch = trimmed.match(/^(data|input|output)\.([A-Za-z0-9_.[\]]+)\s*(===|==|!==|!=|>=|<=|>|<)\s*(.+)$/);
603
+ if (comparisonMatch) {
604
+ const [, root, path, operator, rawRight] = comparisonMatch;
605
+ const left = resolveRoot(root, ctx, path);
606
+ const right = parseLiteral(rawRight);
607
+ return compare(left, right, operator);
608
+ }
609
+ const truthyMatch = trimmed.match(/^(data|input|output)\.([A-Za-z0-9_.[\]]+)$/);
610
+ if (truthyMatch) {
611
+ const [, root, path] = truthyMatch;
612
+ const value = resolveRoot(root, ctx, path);
613
+ return Boolean(value);
614
+ }
615
+ const literal = parseLiteral(trimmed);
616
+ return Boolean(literal);
617
+ }
618
+ function compare(left, right, operator) {
619
+ switch (operator) {
620
+ case "===":
621
+ case "==":
622
+ return left === right;
623
+ case "!==":
624
+ case "!=":
625
+ return left !== right;
626
+ case ">":
627
+ return Number(left) > Number(right);
628
+ case ">=":
629
+ return Number(left) >= Number(right);
630
+ case "<":
631
+ return Number(left) < Number(right);
632
+ case "<=":
633
+ return Number(left) <= Number(right);
634
+ default:
635
+ return false;
636
+ }
637
+ }
638
+ function parseLiteral(value) {
639
+ const trimmed = (value ?? "").trim();
640
+ if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'"))
641
+ return trimmed.slice(1, -1);
642
+ if (/^-?\d+(\.\d+)?$/.test(trimmed))
643
+ return Number(trimmed);
644
+ if (/^true$/i.test(trimmed))
645
+ return true;
646
+ if (/^false$/i.test(trimmed))
647
+ return false;
648
+ if (/^null$/i.test(trimmed))
649
+ return null;
650
+ if (/^undefined$/i.test(trimmed))
651
+ return;
652
+ return trimmed;
653
+ }
654
+ function resolveRoot(root, ctx, path) {
655
+ const source = root === "data" ? ctx.data : root === "input" ? ctx.input : ctx.output;
656
+ return resolvePath(source, path);
657
+ }
658
+ function resolvePath(source, path) {
659
+ if (source == null)
660
+ return;
661
+ if (!path)
662
+ return source;
663
+ const segments = path.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
664
+ let current = source;
665
+ for (const segment of segments) {
666
+ if (current == null)
667
+ return;
668
+ current = current[segment];
669
+ }
670
+ return current;
671
+ }
672
+ function splitByOperator(expr, operator) {
673
+ const parts = [];
674
+ let buffer = "";
675
+ let inSingleQuote = false;
676
+ let inDoubleQuote = false;
677
+ for (let i = 0;i < expr.length; i++) {
678
+ const char = expr[i];
679
+ if (!char)
680
+ continue;
681
+ const next = expr.slice(i, i + operator.length);
682
+ if (char === "'" && !inDoubleQuote) {
683
+ inSingleQuote = !inSingleQuote;
684
+ buffer += char;
685
+ continue;
686
+ }
687
+ if (char === '"' && !inSingleQuote) {
688
+ inDoubleQuote = !inDoubleQuote;
689
+ buffer += char;
690
+ continue;
691
+ }
692
+ if (!inSingleQuote && !inDoubleQuote && next === operator) {
693
+ parts.push(buffer.trim());
694
+ buffer = "";
695
+ i += operator.length - 1;
696
+ continue;
697
+ }
698
+ buffer += char;
699
+ }
700
+ if (buffer.trim().length)
701
+ parts.push(buffer.trim());
702
+ return parts;
703
+ }
704
+
705
+ // src/workflow/spec.ts
706
+ class WorkflowRegistry extends SpecContractRegistry {
707
+ constructor(items) {
708
+ super("workflow", items);
709
+ }
710
+ }
711
+
712
+ // src/workflow/validation.ts
713
+ class WorkflowValidationError extends Error {
714
+ issues;
715
+ constructor(message, issues) {
716
+ super(message);
717
+ this.issues = issues;
718
+ this.name = "WorkflowValidationError";
719
+ }
720
+ }
721
+ function validateWorkflowSpec(spec, options = {}) {
722
+ const issues = [];
723
+ const { definition } = spec;
724
+ if (!definition.steps.length) {
725
+ issues.push({
726
+ level: "error",
727
+ message: "Workflow must declare at least one step."
728
+ });
729
+ return issues;
730
+ }
731
+ const stepsById = indexSteps(definition, issues);
732
+ const entryStepId = definition.entryStepId ?? definition.steps[0]?.id ?? null;
733
+ if (!entryStepId) {
734
+ issues.push({
735
+ level: "error",
736
+ message: "Workflow requires an entry step (definition.entryStepId)."
737
+ });
738
+ } else if (!stepsById.has(entryStepId)) {
739
+ issues.push({
740
+ level: "error",
741
+ message: `Entry step "${entryStepId}" is not defined in steps.`
742
+ });
743
+ }
744
+ const adjacency = buildAdjacency(definition, stepsById, issues);
745
+ validateStepActions(definition.steps, options, issues);
746
+ validateReachability(entryStepId, stepsById, adjacency, issues);
747
+ detectCycles(adjacency, issues);
748
+ return issues;
749
+ }
750
+ function assertWorkflowSpecValid(spec, options = {}) {
751
+ const issues = validateWorkflowSpec(spec, options);
752
+ const errors = issues.filter((issue) => issue.level === "error");
753
+ if (errors.length) {
754
+ throw new WorkflowValidationError(`Workflow ${spec.meta.key}.v${spec.meta.version} is invalid`, issues);
755
+ }
756
+ }
757
+ function indexSteps(definition, issues) {
758
+ const stepsById = new Map;
759
+ for (const step of definition.steps) {
760
+ if (stepsById.has(step.id)) {
761
+ issues.push({
762
+ level: "error",
763
+ message: `Duplicate step id "${step.id}" detected.`
764
+ });
765
+ continue;
766
+ }
767
+ stepsById.set(step.id, step);
768
+ if (step.type === "automation" && !step.action?.operation) {
769
+ issues.push({
770
+ level: "warning",
771
+ message: `Automation step "${step.id}" does not declare an operation.`
772
+ });
773
+ }
774
+ if (step.type === "human" && !step.action?.form) {
775
+ issues.push({
776
+ level: "warning",
777
+ message: `Human step "${step.id}" does not declare a form.`
778
+ });
779
+ }
780
+ if (step.guard && !step.guard.value.trim()) {
781
+ issues.push({
782
+ level: "error",
783
+ message: `Guard for step "${step.id}" must have a non-empty value.`
784
+ });
785
+ }
786
+ }
787
+ return stepsById;
788
+ }
789
+ function buildAdjacency(definition, stepsById, issues) {
790
+ const adjacency = new Map;
791
+ const incoming = new Map;
792
+ for (const stepId of stepsById.keys()) {
793
+ adjacency.set(stepId, new Set);
794
+ incoming.set(stepId, 0);
795
+ }
796
+ for (const transition of definition.transitions) {
797
+ const from = stepsById.get(transition.from);
798
+ const to = stepsById.get(transition.to);
799
+ if (!from) {
800
+ issues.push({
801
+ level: "error",
802
+ message: `Transition refers to unknown "from" step "${transition.from}".`
803
+ });
804
+ continue;
805
+ }
806
+ if (!to) {
807
+ issues.push({
808
+ level: "error",
809
+ message: `Transition refers to unknown "to" step "${transition.to}".`
810
+ });
811
+ continue;
812
+ }
813
+ adjacency.get(transition.from)?.add(transition.to);
814
+ incoming.set(transition.to, (incoming.get(transition.to) ?? 0) + 1);
815
+ validateTransition(transition, issues);
816
+ }
817
+ const roots = [...incoming.entries()].filter(([, count]) => count === 0).map(([id]) => id);
818
+ if (roots.length > 1) {
819
+ issues.push({
820
+ level: "warning",
821
+ message: `Workflow has multiple potential entry steps: ${roots.join(", ")}`
822
+ });
823
+ }
824
+ return adjacency;
825
+ }
826
+ function validateTransition(transition, issues) {
827
+ if (transition.condition && !transition.condition.trim()) {
828
+ issues.push({
829
+ level: "error",
830
+ message: `Transition ${transition.from} -> ${transition.to} declares an empty condition.`
831
+ });
832
+ }
833
+ }
834
+ function validateStepActions(steps, options, issues) {
835
+ for (const step of steps) {
836
+ const action = step.action;
837
+ if (!action)
838
+ continue;
839
+ if (action.operation && options.operations) {
840
+ const op = options.operations.get(action.operation.key, action.operation.version);
841
+ if (!op) {
842
+ issues.push({
843
+ level: "error",
844
+ message: `Step "${step.id}" references unknown operation ${action.operation.key}.v${action.operation.version}.`
845
+ });
846
+ }
847
+ }
848
+ if (action.form && options.forms) {
849
+ const form = options.forms.get(action.form.key, action.form.version);
850
+ if (!form) {
851
+ issues.push({
852
+ level: "error",
853
+ message: `Step "${step.id}" references unknown form ${action.form.key}.v${action.form.version}.`
854
+ });
855
+ }
856
+ }
857
+ }
858
+ }
859
+ function validateReachability(entryStepId, stepsById, adjacency, issues) {
860
+ if (!entryStepId || !stepsById.has(entryStepId))
861
+ return;
862
+ const visited = new Set;
863
+ const queue = [entryStepId];
864
+ visited.add(entryStepId);
865
+ while (queue.length) {
866
+ const current = queue.shift();
867
+ if (!current)
868
+ continue;
869
+ const neighbours = adjacency.get(current);
870
+ if (!neighbours)
871
+ continue;
872
+ for (const next of neighbours) {
873
+ if (visited.has(next))
874
+ continue;
875
+ visited.add(next);
876
+ queue.push(next);
877
+ }
878
+ }
879
+ for (const stepId of stepsById.keys()) {
880
+ if (!visited.has(stepId)) {
881
+ issues.push({
882
+ level: "error",
883
+ message: `Step "${stepId}" is unreachable from entry step "${entryStepId}".`
884
+ });
885
+ }
886
+ }
887
+ }
888
+ function detectCycles(adjacency, issues) {
889
+ const visited = new Set;
890
+ const stack = new Set;
891
+ let cycleReported = false;
892
+ const dfs = (node) => {
893
+ if (stack.has(node)) {
894
+ if (!cycleReported) {
895
+ issues.push({
896
+ level: "error",
897
+ message: `Workflow contains a cycle involving step "${node}".`
898
+ });
899
+ cycleReported = true;
900
+ }
901
+ return;
902
+ }
903
+ if (visited.has(node))
904
+ return;
905
+ stack.add(node);
906
+ const neighbours = adjacency.get(node);
907
+ if (neighbours) {
908
+ for (const next of neighbours)
909
+ dfs(next);
910
+ }
911
+ stack.delete(node);
912
+ visited.add(node);
913
+ };
914
+ for (const node of adjacency.keys())
915
+ dfs(node);
916
+ }
917
+ function validateWorkflowConsistency(deps) {
918
+ const issues = [];
919
+ for (const workflow of deps.workflows.list()) {
920
+ const specOptions = {
921
+ operations: deps.operations,
922
+ forms: deps.forms
923
+ };
924
+ const specIssues = validateWorkflowSpec(workflow, specOptions);
925
+ issues.push(...specIssues.map((i) => ({
926
+ ...i,
927
+ message: `[${workflow.meta.key}.v${workflow.meta.version}] ${i.message}`
928
+ })));
929
+ if (deps.capabilities) {
930
+ for (const step of workflow.definition.steps) {
931
+ for (const capRef of step.requiredCapabilities ?? []) {
932
+ const cap = deps.capabilities.get(capRef.key, capRef.version);
933
+ if (!cap) {
934
+ issues.push({
935
+ level: "error",
936
+ message: `[${workflow.meta.key}.v${workflow.meta.version}] Step "${step.id}" references unknown capability "${capRef.key}.v${capRef.version}"`,
937
+ context: { stepId: step.id, capability: capRef }
938
+ });
939
+ }
940
+ }
941
+ }
942
+ }
943
+ if (workflow.definition.compensation && deps.operations) {
944
+ for (const compStep of workflow.definition.compensation.steps) {
945
+ const op = deps.operations.get(compStep.operation.key, compStep.operation.version);
946
+ if (!op) {
947
+ issues.push({
948
+ level: "error",
949
+ message: `[${workflow.meta.key}.v${workflow.meta.version}] Compensation for step "${compStep.stepId}" references unknown operation "${compStep.operation.key}.v${compStep.operation.version}"`,
950
+ context: { stepId: compStep.stepId, operation: compStep.operation }
951
+ });
952
+ }
953
+ }
954
+ }
955
+ if (workflow.definition.sla?.stepDurationMs) {
956
+ const stepIds = new Set(workflow.definition.steps.map((s) => s.id));
957
+ for (const stepId of Object.keys(workflow.definition.sla.stepDurationMs)) {
958
+ if (!stepIds.has(stepId)) {
959
+ issues.push({
960
+ level: "warning",
961
+ message: `[${workflow.meta.key}.v${workflow.meta.version}] SLA references unknown step "${stepId}"`,
962
+ context: { stepId }
963
+ });
964
+ }
965
+ }
966
+ }
967
+ }
968
+ return {
969
+ valid: issues.filter((i) => i.level === "error").length === 0,
970
+ issues
971
+ };
972
+ }
973
+ function assertWorkflowConsistency(deps) {
974
+ const result = validateWorkflowConsistency(deps);
975
+ if (!result.valid) {
976
+ throw new WorkflowValidationError("Workflow consistency check failed", result.issues);
977
+ }
978
+ }
979
+ function validateSlaConfig(spec) {
980
+ const issues = [];
981
+ const sla = spec.definition.sla;
982
+ if (!sla)
983
+ return issues;
984
+ if (sla.totalDurationMs !== undefined && sla.totalDurationMs <= 0) {
985
+ issues.push({
986
+ level: "error",
987
+ message: "SLA totalDurationMs must be positive",
988
+ context: { totalDurationMs: sla.totalDurationMs }
989
+ });
990
+ }
991
+ if (sla.stepDurationMs) {
992
+ for (const [stepId, duration] of Object.entries(sla.stepDurationMs)) {
993
+ if (duration <= 0) {
994
+ issues.push({
995
+ level: "error",
996
+ message: `SLA stepDurationMs for "${stepId}" must be positive`,
997
+ context: { stepId, duration }
998
+ });
999
+ }
1000
+ }
1001
+ const stepDurationsSum = Object.values(sla.stepDurationMs).reduce((sum, d) => sum + d, 0);
1002
+ if (sla.totalDurationMs && stepDurationsSum > sla.totalDurationMs) {
1003
+ issues.push({
1004
+ level: "warning",
1005
+ message: `Sum of step durations (${stepDurationsSum}ms) exceeds total duration (${sla.totalDurationMs}ms)`,
1006
+ context: { stepDurationsSum, totalDurationMs: sla.totalDurationMs }
1007
+ });
1008
+ }
1009
+ }
1010
+ return issues;
1011
+ }
1012
+ function validateCompensation(spec) {
1013
+ const issues = [];
1014
+ const compensation = spec.definition.compensation;
1015
+ if (!compensation)
1016
+ return issues;
1017
+ const stepIds = new Set(spec.definition.steps.map((s) => s.id));
1018
+ const coveredSteps = new Set;
1019
+ for (const compStep of compensation.steps) {
1020
+ if (!stepIds.has(compStep.stepId)) {
1021
+ issues.push({
1022
+ level: "error",
1023
+ message: `Compensation references unknown step "${compStep.stepId}"`,
1024
+ context: { stepId: compStep.stepId }
1025
+ });
1026
+ }
1027
+ if (coveredSteps.has(compStep.stepId)) {
1028
+ issues.push({
1029
+ level: "warning",
1030
+ message: `Multiple compensation handlers for step "${compStep.stepId}"`,
1031
+ context: { stepId: compStep.stepId }
1032
+ });
1033
+ }
1034
+ coveredSteps.add(compStep.stepId);
1035
+ if (!compStep.operation?.key || !compStep.operation?.version) {
1036
+ issues.push({
1037
+ level: "error",
1038
+ message: `Compensation for step "${compStep.stepId}" must specify operation with key and version`,
1039
+ context: { stepId: compStep.stepId }
1040
+ });
1041
+ }
1042
+ }
1043
+ const automationSteps = spec.definition.steps.filter((s) => s.type === "automation");
1044
+ for (const step of automationSteps) {
1045
+ if (!coveredSteps.has(step.id)) {
1046
+ issues.push({
1047
+ level: "warning",
1048
+ message: `Automation step "${step.id}" has no compensation handler`,
1049
+ context: { stepId: step.id }
1050
+ });
1051
+ }
1052
+ }
1053
+ return issues;
1054
+ }
1055
+ function validateRetryConfig(spec) {
1056
+ const issues = [];
1057
+ for (const step of spec.definition.steps) {
1058
+ if (!step.retry)
1059
+ continue;
1060
+ if (step.retry.maxAttempts <= 0) {
1061
+ issues.push({
1062
+ level: "error",
1063
+ message: `Step "${step.id}" retry maxAttempts must be positive`,
1064
+ context: { stepId: step.id, maxAttempts: step.retry.maxAttempts }
1065
+ });
1066
+ }
1067
+ if (step.retry.delayMs <= 0) {
1068
+ issues.push({
1069
+ level: "error",
1070
+ message: `Step "${step.id}" retry delayMs must be positive`,
1071
+ context: { stepId: step.id, delayMs: step.retry.delayMs }
1072
+ });
1073
+ }
1074
+ if (step.retry.maxDelayMs !== undefined && step.retry.maxDelayMs < step.retry.delayMs) {
1075
+ issues.push({
1076
+ level: "warning",
1077
+ message: `Step "${step.id}" retry maxDelayMs (${step.retry.maxDelayMs}) is less than delayMs (${step.retry.delayMs})`,
1078
+ context: { stepId: step.id }
1079
+ });
1080
+ }
1081
+ }
1082
+ return issues;
1083
+ }
1084
+ function validateWorkflowComprehensive(spec, options = {}) {
1085
+ const issues = [];
1086
+ issues.push(...validateWorkflowSpec(spec, options));
1087
+ issues.push(...validateSlaConfig(spec));
1088
+ issues.push(...validateCompensation(spec));
1089
+ issues.push(...validateRetryConfig(spec));
1090
+ return {
1091
+ valid: issues.filter((i) => i.level === "error").length === 0,
1092
+ issues
1093
+ };
1094
+ }
1095
+ // src/workflow/runner.ts
1096
+ import { randomUUID } from "crypto";
1097
+ class WorkflowRunner {
1098
+ config;
1099
+ constructor(config) {
1100
+ this.config = config;
1101
+ }
1102
+ async preFlightCheck(workflowName, version, resolvedConfig) {
1103
+ const spec = this.getSpec(workflowName, version);
1104
+ return this.performPreFlight(spec, resolvedConfig);
1105
+ }
1106
+ async start(workflowName, version, initialData) {
1107
+ const spec = this.getSpec(workflowName, version);
1108
+ const entryStepId = resolveEntryStepId(spec);
1109
+ const now = new Date;
1110
+ const workflowId = randomUUID();
1111
+ const state = {
1112
+ workflowId,
1113
+ workflowName: spec.meta.key,
1114
+ workflowVersion: spec.meta.version,
1115
+ currentStep: entryStepId,
1116
+ data: { ...initialData ?? {} },
1117
+ retryCounts: {},
1118
+ history: [],
1119
+ status: "running",
1120
+ createdAt: now,
1121
+ updatedAt: now
1122
+ };
1123
+ const resolvedAppConfig = this.config.appConfigProvider ? await this.config.appConfigProvider(state) : undefined;
1124
+ const preFlightResult = await this.performPreFlight(spec, resolvedAppConfig);
1125
+ if (!preFlightResult.canStart) {
1126
+ throw new WorkflowPreFlightError(preFlightResult.issues);
1127
+ }
1128
+ await this.config.stateStore.create(state);
1129
+ this.emit("workflow.started", {
1130
+ workflowId,
1131
+ workflowName: spec.meta.key,
1132
+ workflowVersion: spec.meta.version,
1133
+ currentStep: entryStepId
1134
+ });
1135
+ return workflowId;
1136
+ }
1137
+ async executeStep(workflowId, input) {
1138
+ const state = await this.getStateOrThrow(workflowId);
1139
+ if (isTerminalStatus(state.status)) {
1140
+ throw new Error(`Workflow ${workflowId} is in terminal status "${state.status}".`);
1141
+ }
1142
+ const spec = this.getSpec(state.workflowName, state.workflowVersion);
1143
+ const step = getCurrentStep(spec, state.currentStep);
1144
+ const guardOk = await this.evaluateGuard(step, state, input);
1145
+ if (!guardOk)
1146
+ throw new Error(`GuardRejected: ${state.workflowName} -> ${step.id}`);
1147
+ const execution = {
1148
+ stepId: step.id,
1149
+ startedAt: new Date,
1150
+ status: "running",
1151
+ input
1152
+ };
1153
+ const workingState = {
1154
+ ...state,
1155
+ data: { ...state.data },
1156
+ history: [...state.history]
1157
+ };
1158
+ try {
1159
+ const output = await this.runStepAction(step, workingState, input);
1160
+ execution.output = output;
1161
+ execution.status = "completed";
1162
+ execution.completedAt = new Date;
1163
+ workingState.history.push(execution);
1164
+ workingState.updatedAt = new Date;
1165
+ if (isRecord(input)) {
1166
+ workingState.data = { ...workingState.data, ...input };
1167
+ }
1168
+ if (isRecord(output)) {
1169
+ workingState.data = { ...workingState.data, ...output };
1170
+ }
1171
+ const nextStepId = this.pickNextStepId(spec, workingState, step, input, output);
1172
+ if (nextStepId) {
1173
+ workingState.currentStep = nextStepId;
1174
+ workingState.status = "running";
1175
+ } else if (!hasOutgoing(spec, step.id)) {
1176
+ workingState.status = "completed";
1177
+ } else {
1178
+ throw new Error(`No transition matched after executing step "${step.id}".`);
1179
+ }
1180
+ await this.config.stateStore.update(workflowId, () => workingState);
1181
+ this.emit("workflow.step_completed", {
1182
+ workflowId,
1183
+ workflowName: state.workflowName,
1184
+ stepId: step.id,
1185
+ status: workingState.status
1186
+ });
1187
+ } catch (error) {
1188
+ execution.status = "failed";
1189
+ execution.completedAt = new Date;
1190
+ execution.error = error instanceof Error ? error.message : String(error);
1191
+ workingState.history.push(execution);
1192
+ workingState.updatedAt = new Date;
1193
+ if (step.retry) {
1194
+ const retries = state.retryCounts?.[step.id] ?? 0;
1195
+ if (retries < step.retry.maxAttempts) {
1196
+ const backoff = step.retry.backoff ?? "exponential";
1197
+ const baseDelay = step.retry.delayMs ?? 1000;
1198
+ const delay = backoff === "exponential" ? baseDelay * Math.pow(2, retries) : baseDelay;
1199
+ const cappedDelay = Math.min(delay, step.retry.maxDelayMs ?? Infinity);
1200
+ workingState.retryCounts = {
1201
+ ...state.retryCounts ?? {},
1202
+ [step.id]: retries + 1
1203
+ };
1204
+ workingState.status = "running";
1205
+ await this.config.stateStore.update(workflowId, () => workingState);
1206
+ this.emit("workflow.step_retrying", {
1207
+ workflowId,
1208
+ workflowName: state.workflowName,
1209
+ stepId: step.id,
1210
+ attempt: retries + 1,
1211
+ delay: cappedDelay,
1212
+ error: execution.error
1213
+ });
1214
+ await new Promise((resolve) => setTimeout(resolve, cappedDelay));
1215
+ return this.executeStep(workflowId, input);
1216
+ }
1217
+ }
1218
+ workingState.status = "failed";
1219
+ await this.config.stateStore.update(workflowId, () => workingState);
1220
+ this.emit("workflow.step_failed", {
1221
+ workflowId,
1222
+ workflowName: state.workflowName,
1223
+ stepId: step.id,
1224
+ error: execution.error ?? "unknown"
1225
+ });
1226
+ if (spec.definition.compensation?.trigger === "on_failure") {
1227
+ await this.rollback(workflowId);
1228
+ }
1229
+ throw error;
1230
+ }
1231
+ }
1232
+ async rollback(workflowId) {
1233
+ const state = await this.getStateOrThrow(workflowId);
1234
+ const spec = this.getSpec(state.workflowName, state.workflowVersion);
1235
+ if (!spec.definition.compensation) {
1236
+ return;
1237
+ }
1238
+ this.emit("workflow.rollback_started", { workflowId });
1239
+ const completedSteps = state.history.filter((h) => h.status === "completed").reverse();
1240
+ for (const execution of completedSteps) {
1241
+ const compStep = spec.definition.compensation.steps.find((s) => s.stepId === execution.stepId);
1242
+ if (compStep) {
1243
+ const input = {
1244
+ stepId: execution.stepId,
1245
+ originalInput: execution.input,
1246
+ originalOutput: execution.output,
1247
+ workflowData: state.data
1248
+ };
1249
+ try {
1250
+ const step = getCurrentStep(spec, execution.stepId);
1251
+ const resolvedAppConfig = this.config.appConfigProvider ? await this.config.appConfigProvider(state) : undefined;
1252
+ const executorContext = {
1253
+ workflow: state,
1254
+ step,
1255
+ resolvedAppConfig,
1256
+ integrations: resolvedAppConfig?.integrations ?? [],
1257
+ knowledge: resolvedAppConfig?.knowledge ?? [],
1258
+ branding: resolvedAppConfig?.branding,
1259
+ translation: resolvedAppConfig?.translation,
1260
+ translationResolver: this.config.translationResolver,
1261
+ secretProvider: this.config.secretProvider
1262
+ };
1263
+ await this.config.opExecutor(compStep.operation, input, executorContext);
1264
+ this.emit("workflow.compensation_step_completed", {
1265
+ workflowId,
1266
+ stepId: execution.stepId,
1267
+ compensationOp: compStep.operation.key
1268
+ });
1269
+ } catch (error) {
1270
+ const errorMessage = error instanceof Error ? error.message : String(error);
1271
+ this.emit("workflow.compensation_step_failed", {
1272
+ workflowId,
1273
+ stepId: execution.stepId,
1274
+ compensationOp: compStep.operation.key,
1275
+ error: errorMessage
1276
+ });
1277
+ }
1278
+ }
1279
+ }
1280
+ this.emit("workflow.rollback_completed", { workflowId });
1281
+ }
1282
+ async getState(workflowId) {
1283
+ return this.getStateOrThrow(workflowId);
1284
+ }
1285
+ async cancel(workflowId) {
1286
+ const state = await this.getStateOrThrow(workflowId);
1287
+ if (state.status === "cancelled")
1288
+ return;
1289
+ const nextState = {
1290
+ ...state,
1291
+ status: "cancelled",
1292
+ updatedAt: new Date
1293
+ };
1294
+ await this.config.stateStore.update(workflowId, () => nextState);
1295
+ this.emit("workflow.cancelled", {
1296
+ workflowId,
1297
+ workflowName: state.workflowName
1298
+ });
1299
+ }
1300
+ async performPreFlight(spec, resolvedConfig) {
1301
+ if (!resolvedConfig) {
1302
+ return { canStart: true, issues: [] };
1303
+ }
1304
+ const issues = [];
1305
+ const integrationBySlot = new Map;
1306
+ for (const integration of resolvedConfig.integrations) {
1307
+ integrationBySlot.set(integration.slot.slotId, integration);
1308
+ }
1309
+ for (const step of spec.definition.steps) {
1310
+ for (const slotId of step.requiredIntegrations ?? []) {
1311
+ const integration = integrationBySlot.get(slotId);
1312
+ if (!integration) {
1313
+ issues.push({
1314
+ stepId: step.id,
1315
+ type: "integration",
1316
+ identifier: slotId,
1317
+ severity: "error",
1318
+ reason: `Integration slot "${slotId}" is not bound in the resolved app config.`
1319
+ });
1320
+ continue;
1321
+ }
1322
+ const status = integration.connection.status;
1323
+ if (status === "disconnected" || status === "error") {
1324
+ issues.push({
1325
+ stepId: step.id,
1326
+ type: "integration",
1327
+ identifier: slotId,
1328
+ severity: "error",
1329
+ reason: `Integration slot "${slotId}" is in status "${status}".`
1330
+ });
1331
+ } else if (status === "unknown") {
1332
+ issues.push({
1333
+ stepId: step.id,
1334
+ type: "integration",
1335
+ identifier: slotId,
1336
+ severity: "warning",
1337
+ reason: `Integration slot "${slotId}" reports unknown health status.`
1338
+ });
1339
+ }
1340
+ }
1341
+ }
1342
+ const enabledCapabilities = new Set(resolvedConfig.capabilities.enabled.map(capabilityKey));
1343
+ for (const step of spec.definition.steps) {
1344
+ for (const required of step.requiredCapabilities ?? []) {
1345
+ if (!enabledCapabilities.has(capabilityKey(required))) {
1346
+ issues.push({
1347
+ stepId: step.id,
1348
+ type: "capability",
1349
+ identifier: capabilityKey(required),
1350
+ severity: "error",
1351
+ reason: `Capability "${required.key}@${required.version}" is not enabled.`
1352
+ });
1353
+ }
1354
+ }
1355
+ }
1356
+ const canStart = issues.every((issue) => issue.severity !== "error");
1357
+ return { canStart, issues };
1358
+ }
1359
+ async evaluateGuard(step, state, input) {
1360
+ if (!step.guard)
1361
+ return true;
1362
+ if (this.config.guardEvaluator)
1363
+ return this.config.guardEvaluator(step.guard, {
1364
+ workflow: state,
1365
+ step,
1366
+ input
1367
+ });
1368
+ if (step.guard.type === "expression") {
1369
+ return evaluateExpression(step.guard.value, {
1370
+ data: state.data,
1371
+ input
1372
+ });
1373
+ }
1374
+ return true;
1375
+ }
1376
+ async runStepAction(step, state, input) {
1377
+ if (step.type === "automation") {
1378
+ const op = step.action?.operation;
1379
+ if (!op)
1380
+ throw new Error(`Automation step "${step.id}" requires an operation.`);
1381
+ const resolvedAppConfig = this.config.appConfigProvider ? await this.config.appConfigProvider(state) : undefined;
1382
+ const executorContext = {
1383
+ workflow: state,
1384
+ step,
1385
+ resolvedAppConfig,
1386
+ integrations: resolvedAppConfig?.integrations ?? [],
1387
+ knowledge: resolvedAppConfig?.knowledge ?? [],
1388
+ branding: resolvedAppConfig?.branding,
1389
+ translation: resolvedAppConfig?.translation,
1390
+ translationResolver: this.config.translationResolver,
1391
+ secretProvider: this.config.secretProvider
1392
+ };
1393
+ if (this.config.enforceCapabilities) {
1394
+ await this.config.enforceCapabilities(op, executorContext);
1395
+ }
1396
+ return this.config.opExecutor(op, input, executorContext);
1397
+ }
1398
+ if (step.type === "human") {
1399
+ return input;
1400
+ }
1401
+ return input;
1402
+ }
1403
+ pickNextStepId(spec, state, step, input, output) {
1404
+ const transitions = spec.definition.transitions.filter((t) => t.from === step.id);
1405
+ for (const transition of transitions) {
1406
+ if (evaluateExpression(transition.condition, {
1407
+ data: state.data,
1408
+ input,
1409
+ output
1410
+ })) {
1411
+ const target = spec.definition.steps.find((s) => s.id === transition.to);
1412
+ if (!target)
1413
+ throw new Error(`Transition ${transition.from} -> ${transition.to} points to missing step.`);
1414
+ return target.id;
1415
+ }
1416
+ }
1417
+ return null;
1418
+ }
1419
+ getSpec(name, version) {
1420
+ const spec = this.config.registry.get(name, version);
1421
+ if (!spec)
1422
+ throw new Error(`Workflow spec not found for ${name}${version ? `.v${version}` : ""}`);
1423
+ return spec;
1424
+ }
1425
+ async getStateOrThrow(workflowId) {
1426
+ const state = await this.config.stateStore.get(workflowId);
1427
+ if (!state)
1428
+ throw new Error(`Workflow state not found for ${workflowId}`);
1429
+ return state;
1430
+ }
1431
+ emit(event, payload) {
1432
+ this.config.eventEmitter?.(event, payload);
1433
+ }
1434
+ }
1435
+ function resolveEntryStepId(spec) {
1436
+ const entry = spec.definition.entryStepId ?? spec.definition.steps[0]?.id ?? null;
1437
+ if (!entry)
1438
+ throw new Error(`Workflow ${spec.meta.key}.v${spec.meta.version} has no entry step.`);
1439
+ return entry;
1440
+ }
1441
+ function getCurrentStep(spec, stepId) {
1442
+ const step = spec.definition.steps.find((s) => s.id === stepId);
1443
+ if (!step)
1444
+ throw new Error(`Step "${stepId}" not found in workflow ${spec.meta.key}.v${spec.meta.version}.`);
1445
+ return step;
1446
+ }
1447
+ function hasOutgoing(spec, stepId) {
1448
+ return spec.definition.transitions.some((t) => t.from === stepId);
1449
+ }
1450
+ function isRecord(value) {
1451
+ return value != null && typeof value === "object" && !Array.isArray(value);
1452
+ }
1453
+ function isTerminalStatus(status) {
1454
+ return status === "completed" || status === "failed" || status === "cancelled";
1455
+ }
1456
+
1457
+ class WorkflowPreFlightError extends Error {
1458
+ issues;
1459
+ constructor(issues) {
1460
+ super(`Workflow pre-flight failed: ${issues.filter((issue) => issue.severity === "error").map((issue) => `${issue.type}:${issue.identifier}`).join(", ")}`);
1461
+ this.issues = issues;
1462
+ this.name = "WorkflowPreFlightError";
1463
+ }
1464
+ }
1465
+ function capabilityKey(ref) {
1466
+ return `${ref.key}@${ref.version}`;
1467
+ }
1468
+
1469
+ // src/workflow/sla-monitor.ts
1470
+ class SLAMonitor {
1471
+ eventEmitter;
1472
+ constructor(eventEmitter) {
1473
+ this.eventEmitter = eventEmitter;
1474
+ }
1475
+ check(state, spec) {
1476
+ const sla = spec.definition.sla;
1477
+ if (!sla)
1478
+ return;
1479
+ const now = new Date().getTime();
1480
+ if (sla.totalDurationMs) {
1481
+ const duration = now - state.createdAt.getTime();
1482
+ if (duration > sla.totalDurationMs) {
1483
+ if (state.status === "running" || state.status === "paused") {
1484
+ this.eventEmitter("workflow.sla_breach", {
1485
+ workflowId: state.workflowId,
1486
+ workflowName: state.workflowName,
1487
+ type: "workflow_duration",
1488
+ expectedMs: sla.totalDurationMs,
1489
+ actualMs: duration,
1490
+ breachedAt: new Date
1491
+ });
1492
+ }
1493
+ }
1494
+ }
1495
+ if (sla.stepDurationMs) {
1496
+ if (state.status === "running" && state.currentStep) {
1497
+ const currentExecution = state.history.find((h) => h.stepId === state.currentStep && h.status === "running");
1498
+ if (currentExecution) {
1499
+ const stepLimit = sla.stepDurationMs[state.currentStep];
1500
+ if (stepLimit) {
1501
+ const stepDuration = now - currentExecution.startedAt.getTime();
1502
+ if (stepDuration > stepLimit) {
1503
+ this.eventEmitter("workflow.sla_breach", {
1504
+ workflowId: state.workflowId,
1505
+ workflowName: state.workflowName,
1506
+ type: "step_duration",
1507
+ stepId: state.currentStep,
1508
+ expectedMs: stepLimit,
1509
+ actualMs: stepDuration,
1510
+ breachedAt: new Date
1511
+ });
1512
+ }
1513
+ }
1514
+ }
1515
+ }
1516
+ }
1517
+ }
1518
+ }
1519
+
1520
+ // src/workflow/index.ts
1521
+ var defineWorkflow = (spec2) => spec2;
1522
+ export {
1523
+ validateWorkflowSpec,
1524
+ validateWorkflowConsistency,
1525
+ validateWorkflowComprehensive,
1526
+ validateSlaConfig,
1527
+ validateRetryConfig,
1528
+ validateCompensation,
1529
+ getWorkflowDuration,
1530
+ getAverageStepDuration,
1531
+ evaluateExpression,
1532
+ defineWorkflow,
1533
+ createWorkflowContext,
1534
+ createFileStateStore,
1535
+ calculateWorkflowProgress,
1536
+ assertWorkflowSpecValid,
1537
+ assertWorkflowConsistency,
1538
+ WorkflowValidationError,
1539
+ WorkflowRunner,
1540
+ WorkflowRegistry,
1541
+ WorkflowPreFlightError,
1542
+ WorkflowContextError,
1543
+ SLAMonitor,
1544
+ PrismaStateStore,
1545
+ InMemoryStateStore
1546
+ };