@amsterdamdatalabs/enact-operator 0.1.2

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 (377) hide show
  1. package/README.md +33 -0
  2. package/dist/index.d.ts +24 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +24 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lanes/autopilot/index.d.ts +95 -0
  7. package/dist/lanes/autopilot/index.d.ts.map +1 -0
  8. package/dist/lanes/autopilot/index.js +499 -0
  9. package/dist/lanes/autopilot/index.js.map +1 -0
  10. package/dist/lanes/ralph/index.d.ts +118 -0
  11. package/dist/lanes/ralph/index.d.ts.map +1 -0
  12. package/dist/lanes/ralph/index.js +680 -0
  13. package/dist/lanes/ralph/index.js.map +1 -0
  14. package/dist/lanes/team/index.d.ts +110 -0
  15. package/dist/lanes/team/index.d.ts.map +1 -0
  16. package/dist/lanes/team/index.js +748 -0
  17. package/dist/lanes/team/index.js.map +1 -0
  18. package/dist/lanes/team/roles.d.ts +15 -0
  19. package/dist/lanes/team/roles.d.ts.map +1 -0
  20. package/dist/lanes/team/roles.js +89 -0
  21. package/dist/lanes/team/roles.js.map +1 -0
  22. package/dist/lanes/ultrawork/burst.d.ts +69 -0
  23. package/dist/lanes/ultrawork/burst.d.ts.map +1 -0
  24. package/dist/lanes/ultrawork/burst.js +254 -0
  25. package/dist/lanes/ultrawork/burst.js.map +1 -0
  26. package/dist/lanes/ultrawork/index.d.ts +159 -0
  27. package/dist/lanes/ultrawork/index.d.ts.map +1 -0
  28. package/dist/lanes/ultrawork/index.js +919 -0
  29. package/dist/lanes/ultrawork/index.js.map +1 -0
  30. package/dist/lanes/ultrawork/phases.d.ts +57 -0
  31. package/dist/lanes/ultrawork/phases.d.ts.map +1 -0
  32. package/dist/lanes/ultrawork/phases.js +116 -0
  33. package/dist/lanes/ultrawork/phases.js.map +1 -0
  34. package/dist/mcp/activation.d.ts +5 -0
  35. package/dist/mcp/activation.d.ts.map +1 -0
  36. package/dist/mcp/activation.js +234 -0
  37. package/dist/mcp/activation.js.map +1 -0
  38. package/dist/mcp/cli.d.ts +11 -0
  39. package/dist/mcp/cli.d.ts.map +1 -0
  40. package/dist/mcp/cli.js +140 -0
  41. package/dist/mcp/cli.js.map +1 -0
  42. package/dist/mcp/continuation.d.ts +5 -0
  43. package/dist/mcp/continuation.d.ts.map +1 -0
  44. package/dist/mcp/continuation.js +360 -0
  45. package/dist/mcp/continuation.js.map +1 -0
  46. package/dist/mcp/jobs.d.ts +5 -0
  47. package/dist/mcp/jobs.d.ts.map +1 -0
  48. package/dist/mcp/jobs.js +212 -0
  49. package/dist/mcp/jobs.js.map +1 -0
  50. package/dist/mcp/laneSupport.d.ts +19 -0
  51. package/dist/mcp/laneSupport.d.ts.map +1 -0
  52. package/dist/mcp/laneSupport.js +21 -0
  53. package/dist/mcp/laneSupport.js.map +1 -0
  54. package/dist/mcp/lanes/autopilot.d.ts +5 -0
  55. package/dist/mcp/lanes/autopilot.d.ts.map +1 -0
  56. package/dist/mcp/lanes/autopilot.js +227 -0
  57. package/dist/mcp/lanes/autopilot.js.map +1 -0
  58. package/dist/mcp/lanes/ralph.d.ts +5 -0
  59. package/dist/mcp/lanes/ralph.d.ts.map +1 -0
  60. package/dist/mcp/lanes/ralph.js +392 -0
  61. package/dist/mcp/lanes/ralph.js.map +1 -0
  62. package/dist/mcp/lanes/team.d.ts +5 -0
  63. package/dist/mcp/lanes/team.d.ts.map +1 -0
  64. package/dist/mcp/lanes/team.js +413 -0
  65. package/dist/mcp/lanes/team.js.map +1 -0
  66. package/dist/mcp/lanes/ultrawork.d.ts +5 -0
  67. package/dist/mcp/lanes/ultrawork.d.ts.map +1 -0
  68. package/dist/mcp/lanes/ultrawork.js +497 -0
  69. package/dist/mcp/lanes/ultrawork.js.map +1 -0
  70. package/dist/mcp/linkage.d.ts +5 -0
  71. package/dist/mcp/linkage.d.ts.map +1 -0
  72. package/dist/mcp/linkage.js +126 -0
  73. package/dist/mcp/linkage.js.map +1 -0
  74. package/dist/mcp/planning.d.ts +5 -0
  75. package/dist/mcp/planning.d.ts.map +1 -0
  76. package/dist/mcp/planning.js +584 -0
  77. package/dist/mcp/planning.js.map +1 -0
  78. package/dist/mcp/rpcTransport.d.ts +17 -0
  79. package/dist/mcp/rpcTransport.d.ts.map +1 -0
  80. package/dist/mcp/rpcTransport.js +90 -0
  81. package/dist/mcp/rpcTransport.js.map +1 -0
  82. package/dist/mcp/schemas/ralphVerify.d.ts +32 -0
  83. package/dist/mcp/schemas/ralphVerify.d.ts.map +1 -0
  84. package/dist/mcp/schemas/ralphVerify.js +20 -0
  85. package/dist/mcp/schemas/ralphVerify.js.map +1 -0
  86. package/dist/mcp/server.d.ts +5 -0
  87. package/dist/mcp/server.d.ts.map +1 -0
  88. package/dist/mcp/server.js +176 -0
  89. package/dist/mcp/server.js.map +1 -0
  90. package/dist/mcp/system.d.ts +5 -0
  91. package/dist/mcp/system.d.ts.map +1 -0
  92. package/dist/mcp/system.js +445 -0
  93. package/dist/mcp/system.js.map +1 -0
  94. package/dist/mcp/toolFilter.d.ts +2 -0
  95. package/dist/mcp/toolFilter.d.ts.map +1 -0
  96. package/dist/mcp/toolFilter.js +2 -0
  97. package/dist/mcp/toolFilter.js.map +1 -0
  98. package/dist/mcp/toolPartitions.d.ts +20 -0
  99. package/dist/mcp/toolPartitions.d.ts.map +1 -0
  100. package/dist/mcp/toolPartitions.js +280 -0
  101. package/dist/mcp/toolPartitions.js.map +1 -0
  102. package/dist/mcp/toolRuntime.d.ts +9 -0
  103. package/dist/mcp/toolRuntime.d.ts.map +1 -0
  104. package/dist/mcp/toolRuntime.js +179 -0
  105. package/dist/mcp/toolRuntime.js.map +1 -0
  106. package/dist/mcp/workflow.d.ts +12 -0
  107. package/dist/mcp/workflow.d.ts.map +1 -0
  108. package/dist/mcp/workflow.js +723 -0
  109. package/dist/mcp/workflow.js.map +1 -0
  110. package/dist/operator/hooks/hookDispatcher.d.ts +39 -0
  111. package/dist/operator/hooks/hookDispatcher.d.ts.map +1 -0
  112. package/dist/operator/hooks/hookDispatcher.js +58 -0
  113. package/dist/operator/hooks/hookDispatcher.js.map +1 -0
  114. package/dist/operator/hooks/hookGating.d.ts +28 -0
  115. package/dist/operator/hooks/hookGating.d.ts.map +1 -0
  116. package/dist/operator/hooks/hookGating.js +61 -0
  117. package/dist/operator/hooks/hookGating.js.map +1 -0
  118. package/dist/operator/hooks/hooks.d.ts +20 -0
  119. package/dist/operator/hooks/hooks.d.ts.map +1 -0
  120. package/dist/operator/hooks/hooks.js +124 -0
  121. package/dist/operator/hooks/hooks.js.map +1 -0
  122. package/dist/operator/hooks/toolGuardHooks.d.ts +86 -0
  123. package/dist/operator/hooks/toolGuardHooks.d.ts.map +1 -0
  124. package/dist/operator/hooks/toolGuardHooks.js +163 -0
  125. package/dist/operator/hooks/toolGuardHooks.js.map +1 -0
  126. package/dist/operator/hud.d.ts +115 -0
  127. package/dist/operator/hud.d.ts.map +1 -0
  128. package/dist/operator/hud.js +229 -0
  129. package/dist/operator/hud.js.map +1 -0
  130. package/dist/operator/missions.d.ts +125 -0
  131. package/dist/operator/missions.d.ts.map +1 -0
  132. package/dist/operator/missions.js +304 -0
  133. package/dist/operator/missions.js.map +1 -0
  134. package/dist/operator/operatorCore.d.ts +11 -0
  135. package/dist/operator/operatorCore.d.ts.map +1 -0
  136. package/dist/operator/operatorCore.js +9 -0
  137. package/dist/operator/operatorCore.js.map +1 -0
  138. package/dist/operator/operatorRuntimeCore.d.ts +17 -0
  139. package/dist/operator/operatorRuntimeCore.d.ts.map +1 -0
  140. package/dist/operator/operatorRuntimeCore.js +17 -0
  141. package/dist/operator/operatorRuntimeCore.js.map +1 -0
  142. package/dist/operator/runtime.d.ts +74 -0
  143. package/dist/operator/runtime.d.ts.map +1 -0
  144. package/dist/operator/runtime.js +357 -0
  145. package/dist/operator/runtime.js.map +1 -0
  146. package/dist/shared/core/bootstrap.d.ts +16 -0
  147. package/dist/shared/core/bootstrap.d.ts.map +1 -0
  148. package/dist/shared/core/bootstrap.js +77 -0
  149. package/dist/shared/core/bootstrap.js.map +1 -0
  150. package/dist/shared/core/contract.d.ts +71 -0
  151. package/dist/shared/core/contract.d.ts.map +1 -0
  152. package/dist/shared/core/contract.js +452 -0
  153. package/dist/shared/core/contract.js.map +1 -0
  154. package/dist/shared/core/events.d.ts +57 -0
  155. package/dist/shared/core/events.d.ts.map +1 -0
  156. package/dist/shared/core/events.js +36 -0
  157. package/dist/shared/core/events.js.map +1 -0
  158. package/dist/shared/core/jobs.d.ts +46 -0
  159. package/dist/shared/core/jobs.d.ts.map +1 -0
  160. package/dist/shared/core/jobs.js +137 -0
  161. package/dist/shared/core/jobs.js.map +1 -0
  162. package/dist/shared/core/json.d.ts +12 -0
  163. package/dist/shared/core/json.d.ts.map +1 -0
  164. package/dist/shared/core/json.js +52 -0
  165. package/dist/shared/core/json.js.map +1 -0
  166. package/dist/shared/core/layoutMigration.d.ts +11 -0
  167. package/dist/shared/core/layoutMigration.d.ts.map +1 -0
  168. package/dist/shared/core/layoutMigration.js +56 -0
  169. package/dist/shared/core/layoutMigration.js.map +1 -0
  170. package/dist/shared/core/lifecycle.d.ts +61 -0
  171. package/dist/shared/core/lifecycle.d.ts.map +1 -0
  172. package/dist/shared/core/lifecycle.js +123 -0
  173. package/dist/shared/core/lifecycle.js.map +1 -0
  174. package/dist/shared/core/packagePaths.d.ts +2 -0
  175. package/dist/shared/core/packagePaths.d.ts.map +1 -0
  176. package/dist/shared/core/packagePaths.js +9 -0
  177. package/dist/shared/core/packagePaths.js.map +1 -0
  178. package/dist/shared/core/terminology.d.ts +38 -0
  179. package/dist/shared/core/terminology.d.ts.map +1 -0
  180. package/dist/shared/core/terminology.js +54 -0
  181. package/dist/shared/core/terminology.js.map +1 -0
  182. package/dist/shared/core/types.d.ts +30 -0
  183. package/dist/shared/core/types.d.ts.map +1 -0
  184. package/dist/shared/core/types.js +2 -0
  185. package/dist/shared/core/types.js.map +1 -0
  186. package/dist/shared/diagnostics/doctor.d.ts +19 -0
  187. package/dist/shared/diagnostics/doctor.d.ts.map +1 -0
  188. package/dist/shared/diagnostics/doctor.js +82 -0
  189. package/dist/shared/diagnostics/doctor.js.map +1 -0
  190. package/dist/shared/diagnostics/hostRollout.d.ts +16 -0
  191. package/dist/shared/diagnostics/hostRollout.d.ts.map +1 -0
  192. package/dist/shared/diagnostics/hostRollout.js +78 -0
  193. package/dist/shared/diagnostics/hostRollout.js.map +1 -0
  194. package/dist/shared/observability/emit.d.ts +3 -0
  195. package/dist/shared/observability/emit.d.ts.map +1 -0
  196. package/dist/shared/observability/emit.js +17 -0
  197. package/dist/shared/observability/emit.js.map +1 -0
  198. package/dist/shared/observability/testWorkspace.d.ts +4 -0
  199. package/dist/shared/observability/testWorkspace.d.ts.map +1 -0
  200. package/dist/shared/observability/testWorkspace.js +35 -0
  201. package/dist/shared/observability/testWorkspace.js.map +1 -0
  202. package/dist/shared/state/installRegistry.d.ts +22 -0
  203. package/dist/shared/state/installRegistry.d.ts.map +1 -0
  204. package/dist/shared/state/installRegistry.js +51 -0
  205. package/dist/shared/state/installRegistry.js.map +1 -0
  206. package/dist/shared/state/session.d.ts +18 -0
  207. package/dist/shared/state/session.d.ts.map +1 -0
  208. package/dist/shared/state/session.js +127 -0
  209. package/dist/shared/state/session.js.map +1 -0
  210. package/dist/shared/state/state.d.ts +16 -0
  211. package/dist/shared/state/state.d.ts.map +1 -0
  212. package/dist/shared/state/state.js +91 -0
  213. package/dist/shared/state/state.js.map +1 -0
  214. package/dist/shared/state/tasks.d.ts +113 -0
  215. package/dist/shared/state/tasks.d.ts.map +1 -0
  216. package/dist/shared/state/tasks.js +274 -0
  217. package/dist/shared/state/tasks.js.map +1 -0
  218. package/dist/shared/workflow/activation/activeSkill.d.ts +46 -0
  219. package/dist/shared/workflow/activation/activeSkill.d.ts.map +1 -0
  220. package/dist/shared/workflow/activation/activeSkill.js +158 -0
  221. package/dist/shared/workflow/activation/activeSkill.js.map +1 -0
  222. package/dist/shared/workflow/activation/gateProfiles.d.ts +26 -0
  223. package/dist/shared/workflow/activation/gateProfiles.d.ts.map +1 -0
  224. package/dist/shared/workflow/activation/gateProfiles.js +102 -0
  225. package/dist/shared/workflow/activation/gateProfiles.js.map +1 -0
  226. package/dist/shared/workflow/activation/modeMatrix.d.ts +28 -0
  227. package/dist/shared/workflow/activation/modeMatrix.d.ts.map +1 -0
  228. package/dist/shared/workflow/activation/modeMatrix.js +91 -0
  229. package/dist/shared/workflow/activation/modeMatrix.js.map +1 -0
  230. package/dist/shared/workflow/activation/skillActivation.d.ts +74 -0
  231. package/dist/shared/workflow/activation/skillActivation.d.ts.map +1 -0
  232. package/dist/shared/workflow/activation/skillActivation.js +485 -0
  233. package/dist/shared/workflow/activation/skillActivation.js.map +1 -0
  234. package/dist/shared/workflow/activation/skillVariant.d.ts +18 -0
  235. package/dist/shared/workflow/activation/skillVariant.d.ts.map +1 -0
  236. package/dist/shared/workflow/activation/skillVariant.js +44 -0
  237. package/dist/shared/workflow/activation/skillVariant.js.map +1 -0
  238. package/dist/shared/workflow/authority/authority.d.ts +34 -0
  239. package/dist/shared/workflow/authority/authority.d.ts.map +1 -0
  240. package/dist/shared/workflow/authority/authority.js +64 -0
  241. package/dist/shared/workflow/authority/authority.js.map +1 -0
  242. package/dist/shared/workflow/closure/closureManifest.d.ts +39 -0
  243. package/dist/shared/workflow/closure/closureManifest.d.ts.map +1 -0
  244. package/dist/shared/workflow/closure/closureManifest.js +62 -0
  245. package/dist/shared/workflow/closure/closureManifest.js.map +1 -0
  246. package/dist/shared/workflow/closure/closureRequirements.d.ts +12 -0
  247. package/dist/shared/workflow/closure/closureRequirements.d.ts.map +1 -0
  248. package/dist/shared/workflow/closure/closureRequirements.js +30 -0
  249. package/dist/shared/workflow/closure/closureRequirements.js.map +1 -0
  250. package/dist/shared/workflow/closure/contractParity.d.ts +24 -0
  251. package/dist/shared/workflow/closure/contractParity.d.ts.map +1 -0
  252. package/dist/shared/workflow/closure/contractParity.js +238 -0
  253. package/dist/shared/workflow/closure/contractParity.js.map +1 -0
  254. package/dist/shared/workflow/closure/contractParityContext.d.ts +8 -0
  255. package/dist/shared/workflow/closure/contractParityContext.d.ts.map +1 -0
  256. package/dist/shared/workflow/closure/contractParityContext.js +50 -0
  257. package/dist/shared/workflow/closure/contractParityContext.js.map +1 -0
  258. package/dist/shared/workflow/closure/scopeGuard.d.ts +11 -0
  259. package/dist/shared/workflow/closure/scopeGuard.d.ts.map +1 -0
  260. package/dist/shared/workflow/closure/scopeGuard.js +69 -0
  261. package/dist/shared/workflow/closure/scopeGuard.js.map +1 -0
  262. package/dist/shared/workflow/closure/ultragoalArtifact.d.ts +13 -0
  263. package/dist/shared/workflow/closure/ultragoalArtifact.d.ts.map +1 -0
  264. package/dist/shared/workflow/closure/ultragoalArtifact.js +31 -0
  265. package/dist/shared/workflow/closure/ultragoalArtifact.js.map +1 -0
  266. package/dist/shared/workflow/closure/workflowReconcile.d.ts +70 -0
  267. package/dist/shared/workflow/closure/workflowReconcile.d.ts.map +1 -0
  268. package/dist/shared/workflow/closure/workflowReconcile.js +267 -0
  269. package/dist/shared/workflow/closure/workflowReconcile.js.map +1 -0
  270. package/dist/shared/workflow/continuation/continuation.d.ts +109 -0
  271. package/dist/shared/workflow/continuation/continuation.d.ts.map +1 -0
  272. package/dist/shared/workflow/continuation/continuation.js +550 -0
  273. package/dist/shared/workflow/continuation/continuation.js.map +1 -0
  274. package/dist/shared/workflow/continuation/continuationEventReservations.d.ts +17 -0
  275. package/dist/shared/workflow/continuation/continuationEventReservations.d.ts.map +1 -0
  276. package/dist/shared/workflow/continuation/continuationEventReservations.js +88 -0
  277. package/dist/shared/workflow/continuation/continuationEventReservations.js.map +1 -0
  278. package/dist/shared/workflow/continuation/continuationFollowUp.d.ts +114 -0
  279. package/dist/shared/workflow/continuation/continuationFollowUp.d.ts.map +1 -0
  280. package/dist/shared/workflow/continuation/continuationFollowUp.js +330 -0
  281. package/dist/shared/workflow/continuation/continuationFollowUp.js.map +1 -0
  282. package/dist/shared/workflow/continuation/continuationOrchestrator.d.ts +66 -0
  283. package/dist/shared/workflow/continuation/continuationOrchestrator.d.ts.map +1 -0
  284. package/dist/shared/workflow/continuation/continuationOrchestrator.js +144 -0
  285. package/dist/shared/workflow/continuation/continuationOrchestrator.js.map +1 -0
  286. package/dist/shared/workflow/continuation/hookContinuation.d.ts +44 -0
  287. package/dist/shared/workflow/continuation/hookContinuation.d.ts.map +1 -0
  288. package/dist/shared/workflow/continuation/hookContinuation.js +85 -0
  289. package/dist/shared/workflow/continuation/hookContinuation.js.map +1 -0
  290. package/dist/shared/workflow/continuation/stopPolicy.d.ts +38 -0
  291. package/dist/shared/workflow/continuation/stopPolicy.d.ts.map +1 -0
  292. package/dist/shared/workflow/continuation/stopPolicy.js +435 -0
  293. package/dist/shared/workflow/continuation/stopPolicy.js.map +1 -0
  294. package/dist/shared/workflow/continuation/stopVerdict.d.ts +31 -0
  295. package/dist/shared/workflow/continuation/stopVerdict.d.ts.map +1 -0
  296. package/dist/shared/workflow/continuation/stopVerdict.js +98 -0
  297. package/dist/shared/workflow/continuation/stopVerdict.js.map +1 -0
  298. package/dist/shared/workflow/delegation/delegatedSession.d.ts +118 -0
  299. package/dist/shared/workflow/delegation/delegatedSession.d.ts.map +1 -0
  300. package/dist/shared/workflow/delegation/delegatedSession.js +496 -0
  301. package/dist/shared/workflow/delegation/delegatedSession.js.map +1 -0
  302. package/dist/shared/workflow/delegation/delegationPrompt.d.ts +3 -0
  303. package/dist/shared/workflow/delegation/delegationPrompt.d.ts.map +1 -0
  304. package/dist/shared/workflow/delegation/delegationPrompt.js +15 -0
  305. package/dist/shared/workflow/delegation/delegationPrompt.js.map +1 -0
  306. package/dist/shared/workflow/delegation/sessionTasks.d.ts +40 -0
  307. package/dist/shared/workflow/delegation/sessionTasks.d.ts.map +1 -0
  308. package/dist/shared/workflow/delegation/sessionTasks.js +73 -0
  309. package/dist/shared/workflow/delegation/sessionTasks.js.map +1 -0
  310. package/dist/shared/workflow/delegation/subagentRuntime.d.ts +26 -0
  311. package/dist/shared/workflow/delegation/subagentRuntime.d.ts.map +1 -0
  312. package/dist/shared/workflow/delegation/subagentRuntime.js +231 -0
  313. package/dist/shared/workflow/delegation/subagentRuntime.js.map +1 -0
  314. package/dist/shared/workflow/delivery/adoAuxiliaryRuntime.d.ts +79 -0
  315. package/dist/shared/workflow/delivery/adoAuxiliaryRuntime.d.ts.map +1 -0
  316. package/dist/shared/workflow/delivery/adoAuxiliaryRuntime.js +166 -0
  317. package/dist/shared/workflow/delivery/adoAuxiliaryRuntime.js.map +1 -0
  318. package/dist/shared/workflow/delivery/finalWave.d.ts +57 -0
  319. package/dist/shared/workflow/delivery/finalWave.d.ts.map +1 -0
  320. package/dist/shared/workflow/delivery/finalWave.js +123 -0
  321. package/dist/shared/workflow/delivery/finalWave.js.map +1 -0
  322. package/dist/shared/workflow/delivery/lifecyclePushMap.d.ts +68 -0
  323. package/dist/shared/workflow/delivery/lifecyclePushMap.d.ts.map +1 -0
  324. package/dist/shared/workflow/delivery/lifecyclePushMap.js +82 -0
  325. package/dist/shared/workflow/delivery/lifecyclePushMap.js.map +1 -0
  326. package/dist/shared/workflow/delivery/prSidecar.d.ts +7 -0
  327. package/dist/shared/workflow/delivery/prSidecar.d.ts.map +1 -0
  328. package/dist/shared/workflow/delivery/prSidecar.js +4 -0
  329. package/dist/shared/workflow/delivery/prSidecar.js.map +1 -0
  330. package/dist/shared/workflow/delivery/reviewStaleness.d.ts +37 -0
  331. package/dist/shared/workflow/delivery/reviewStaleness.d.ts.map +1 -0
  332. package/dist/shared/workflow/delivery/reviewStaleness.js +94 -0
  333. package/dist/shared/workflow/delivery/reviewStaleness.js.map +1 -0
  334. package/dist/shared/workflow/planning/hyperplan.d.ts +40 -0
  335. package/dist/shared/workflow/planning/hyperplan.d.ts.map +1 -0
  336. package/dist/shared/workflow/planning/hyperplan.js +133 -0
  337. package/dist/shared/workflow/planning/hyperplan.js.map +1 -0
  338. package/dist/shared/workflow/planning/notepad.d.ts +17 -0
  339. package/dist/shared/workflow/planning/notepad.d.ts.map +1 -0
  340. package/dist/shared/workflow/planning/notepad.js +84 -0
  341. package/dist/shared/workflow/planning/notepad.js.map +1 -0
  342. package/dist/shared/workflow/planning/planFormat.d.ts +3 -0
  343. package/dist/shared/workflow/planning/planFormat.d.ts.map +1 -0
  344. package/dist/shared/workflow/planning/planFormat.js +14 -0
  345. package/dist/shared/workflow/planning/planFormat.js.map +1 -0
  346. package/package.json +155 -0
  347. package/runtime/hooks/_continuation.mjs +2 -0
  348. package/runtime/hooks/_lib.mjs +2 -0
  349. package/runtime/hooks/_toolGuards.mjs +2 -0
  350. package/runtime/hooks/lanes/resolveSkillActivation.mjs +241 -0
  351. package/runtime/hooks/lanes/user-prompt-submit.mjs +326 -0
  352. package/runtime/hooks/layout-dir.mjs +2 -0
  353. package/runtime/hooks/lifecycle/pre-compact.mjs +121 -0
  354. package/runtime/hooks/lifecycle/session-start.mjs +356 -0
  355. package/runtime/hooks/lifecycle/stop.mjs +223 -0
  356. package/runtime/hooks/observability.mjs +2 -0
  357. package/runtime/hooks/post-tool-use-failure.mjs +5 -0
  358. package/runtime/hooks/post-tool-use.mjs +4 -0
  359. package/runtime/hooks/pre-compact.mjs +4 -0
  360. package/runtime/hooks/pre-tool-use.mjs +4 -0
  361. package/runtime/hooks/resolveSkillActivation.mjs +4 -0
  362. package/runtime/hooks/root-dir.mjs +2 -0
  363. package/runtime/hooks/session-start.mjs +4 -0
  364. package/runtime/hooks/shared/_continuation.mjs +341 -0
  365. package/runtime/hooks/shared/_lib.mjs +60 -0
  366. package/runtime/hooks/shared/_toolGuards.mjs +237 -0
  367. package/runtime/hooks/shared/config.mjs +143 -0
  368. package/runtime/hooks/shared/layout-dir.mjs +12 -0
  369. package/runtime/hooks/shared/observability.mjs +257 -0
  370. package/runtime/hooks/shared/root-dir.mjs +9 -0
  371. package/runtime/hooks/stop.mjs +4 -0
  372. package/runtime/hooks/subagent-tracker.mjs +4 -0
  373. package/runtime/hooks/subagents/subagent-tracker.mjs +106 -0
  374. package/runtime/hooks/tools/post-tool-use-failure.mjs +251 -0
  375. package/runtime/hooks/tools/post-tool-use.mjs +205 -0
  376. package/runtime/hooks/tools/pre-tool-use.mjs +268 -0
  377. package/runtime/hooks/user-prompt-submit.mjs +4 -0
@@ -0,0 +1,137 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { existsSync, mkdirSync, renameSync, writeFileSync } from 'node:fs';
3
+ import { appendLedger } from '../../operator/runtime.js';
4
+ import { layoutPath } from '../../shared/core/contract.js';
5
+ import { readJson } from '../../shared/core/json.js';
6
+ /** Maximum number of history entries kept in memory per job. Oldest entries are dropped first. */
7
+ const HISTORY_CAP = 50;
8
+ function jobsFile(root) {
9
+ return layoutPath(root, 'jobs', 'index.json');
10
+ }
11
+ function ensureJobsDir(root) {
12
+ const dir = layoutPath(root, 'jobs');
13
+ if (!existsSync(dir)) {
14
+ mkdirSync(dir, { recursive: true });
15
+ }
16
+ }
17
+ function loadJobs(root) {
18
+ ensureJobsDir(root);
19
+ return readJson(jobsFile(root), []);
20
+ }
21
+ function saveJobs(root, jobs) {
22
+ ensureJobsDir(root);
23
+ const filePath = jobsFile(root);
24
+ const tmp = filePath + '.tmp';
25
+ writeFileSync(tmp, JSON.stringify(jobs, null, 2), 'utf8');
26
+ renameSync(tmp, filePath);
27
+ }
28
+ function nowIso() {
29
+ return new Date().toISOString();
30
+ }
31
+ export function createJob(root, partial) {
32
+ const at = nowIso();
33
+ const job = {
34
+ id: `job_${randomUUID().slice(0, 12)}`,
35
+ createdAt: at,
36
+ updatedAt: at,
37
+ history: [{ at, event: 'created' }],
38
+ ...partial,
39
+ };
40
+ const jobs = loadJobs(root);
41
+ jobs.push(job);
42
+ saveJobs(root, jobs);
43
+ appendLedger(root, {
44
+ kind: 'job',
45
+ action: 'job_created',
46
+ detail: `Job "${job.id}" created (kind=${job.kind}, status=${job.status})`,
47
+ metadata: { jobId: job.id, status: job.status, kind: job.kind },
48
+ });
49
+ return job;
50
+ }
51
+ export function getJob(root, id) {
52
+ const jobs = loadJobs(root);
53
+ return jobs.find((j) => j.id === id) ?? null;
54
+ }
55
+ export function listJobs(root, filter) {
56
+ let jobs = loadJobs(root);
57
+ if (!filter)
58
+ return jobs;
59
+ if (filter.kind !== undefined) {
60
+ jobs = jobs.filter((j) => j.kind === filter.kind);
61
+ }
62
+ if (filter.status !== undefined) {
63
+ jobs = jobs.filter((j) => j.status === filter.status);
64
+ }
65
+ if (filter.linkage !== undefined) {
66
+ const lf = filter.linkage;
67
+ jobs = jobs.filter((j) => {
68
+ if (!j.linkage)
69
+ return false;
70
+ for (const [key, val] of Object.entries(lf)) {
71
+ if (val !== undefined && j.linkage[key] !== val)
72
+ return false;
73
+ }
74
+ return true;
75
+ });
76
+ }
77
+ return jobs;
78
+ }
79
+ export function updateJob(root, id, patch) {
80
+ const jobs = loadJobs(root);
81
+ const idx = jobs.findIndex((j) => j.id === id);
82
+ if (idx === -1)
83
+ throw new Error(`Job "${id}" not found.`);
84
+ const prev = jobs[idx];
85
+ const at = nowIso();
86
+ const updated = { ...prev, ...patch, updatedAt: at };
87
+ // Append history entry when status changes, capped at HISTORY_CAP
88
+ if (patch.status !== undefined && patch.status !== prev.status) {
89
+ const event = patch.status;
90
+ const detail = patch.detail;
91
+ const newEntry = { at, event, ...(detail !== undefined ? { detail } : {}) };
92
+ const uncapped = [...prev.history, newEntry];
93
+ if (uncapped.length > HISTORY_CAP) {
94
+ const dropped = uncapped.length - HISTORY_CAP;
95
+ updated.history = uncapped.slice(dropped);
96
+ updated.historyTruncatedCount = (prev.historyTruncatedCount ?? 0) + dropped;
97
+ }
98
+ else {
99
+ updated.history = uncapped;
100
+ updated.historyTruncatedCount = prev.historyTruncatedCount;
101
+ }
102
+ }
103
+ else {
104
+ updated.history = prev.history;
105
+ updated.historyTruncatedCount = prev.historyTruncatedCount;
106
+ }
107
+ jobs[idx] = updated;
108
+ saveJobs(root, jobs);
109
+ const action = patch.status !== undefined ? `job_${patch.status}` : 'job_updated';
110
+ appendLedger(root, {
111
+ kind: 'job',
112
+ action,
113
+ detail: `Job "${id}" updated (status=${updated.status})`,
114
+ metadata: { jobId: id, status: updated.status, kind: updated.kind },
115
+ });
116
+ return updated;
117
+ }
118
+ export function deleteJob(root, id) {
119
+ const jobs = loadJobs(root);
120
+ const idx = jobs.findIndex((j) => j.id === id);
121
+ if (idx === -1)
122
+ return false;
123
+ // Append cancelled history entry before removal
124
+ const at = nowIso();
125
+ const job = jobs[idx];
126
+ job.history = [...job.history, { at, event: 'cancelled' }];
127
+ jobs.splice(idx, 1);
128
+ saveJobs(root, jobs);
129
+ appendLedger(root, {
130
+ kind: 'job',
131
+ action: 'job_cancelled',
132
+ detail: `Job "${id}" deleted/cancelled`,
133
+ metadata: { jobId: id, status: 'cancelled', kind: job.kind },
134
+ });
135
+ return true;
136
+ }
137
+ //# sourceMappingURL=jobs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../../src/shared/core/jobs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AA6BjD,kGAAkG;AAClG,MAAM,WAAW,GAAG,EAAE,CAAC;AAiBvB,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI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E,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;KACpE,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,EAAU;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/C,IAAI,GAAG,KAAK,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAE7B,gDAAgD;IAChD,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,GAAG,CAAC,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;IAE3D,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrB,YAAY,CAAC,IAAI,EAAE;QACjB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE,QAAQ,EAAE,qBAAqB;QACvC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE;KAC7D,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ZodType } from 'zod';
2
+ export declare function ensureDir(path: string): void;
3
+ export declare class OperatorStateError extends Error {
4
+ readonly path: string;
5
+ readonly detail?: string | undefined;
6
+ constructor(message: string, path: string, detail?: string | undefined);
7
+ }
8
+ export declare function readJson<T>(path: string, fallback: T): T;
9
+ export declare function writeJson(path: string, value: unknown): void;
10
+ export declare function readJsonFile(path: string): unknown | undefined;
11
+ export declare function validateJsonFile<T>(path: string, raw: unknown, schema: ZodType<T>): T;
12
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/shared/core/json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAGzC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;gBAFxB,OAAO,EAAE,MAAM,EACN,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,YAAA;CAK3B;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAUxD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAG5D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAc9D;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAUrF"}
@@ -0,0 +1,52 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { dirname } from 'node:path';
3
+ export function ensureDir(path) {
4
+ mkdirSync(path, { recursive: true });
5
+ }
6
+ export class OperatorStateError extends Error {
7
+ path;
8
+ detail;
9
+ constructor(message, path, detail) {
10
+ super(detail ? `${message}: ${detail}` : message);
11
+ this.path = path;
12
+ this.detail = detail;
13
+ this.name = 'OperatorStateError';
14
+ }
15
+ }
16
+ export function readJson(path, fallback) {
17
+ if (!existsSync(path)) {
18
+ return fallback;
19
+ }
20
+ try {
21
+ return JSON.parse(readFileSync(path, 'utf8'));
22
+ }
23
+ catch {
24
+ return fallback;
25
+ }
26
+ }
27
+ export function writeJson(path, value) {
28
+ ensureDir(dirname(path));
29
+ writeFileSync(path, JSON.stringify(value, null, 2), 'utf8');
30
+ }
31
+ export function readJsonFile(path) {
32
+ if (!existsSync(path)) {
33
+ return undefined;
34
+ }
35
+ try {
36
+ return JSON.parse(readFileSync(path, 'utf8'));
37
+ }
38
+ catch (error) {
39
+ throw new OperatorStateError(`Malformed JSON in ${path}`, path, error instanceof Error ? error.message : String(error));
40
+ }
41
+ }
42
+ export function validateJsonFile(path, raw, schema) {
43
+ const parsed = schema.safeParse(raw);
44
+ if (parsed.success) {
45
+ return parsed.data;
46
+ }
47
+ const detail = parsed.error.issues
48
+ .map((issue) => `${issue.path.join('.') || '(root)'} ${issue.message}`)
49
+ .join('; ');
50
+ throw new OperatorStateError(`Schema validation failed for ${path}`, path, detail);
51
+ }
52
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/shared/core/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAGhC;IACA;IAHX,YACE,OAAe,EACN,IAAY,EACZ,MAAe;QAExB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK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AE,GAAY,EAAE,MAAkB;IAChF,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM;SAC/B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;SACtE,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,IAAI,kBAAkB,CAAC,gCAAgC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const LEGACY_OPERATOR_LAYOUT_SEGMENTS: readonly [".enact", "operator"];
2
+ export declare function legacyOperatorLayoutPath(root: string): string;
3
+ /**
4
+ * One-time merge from `.enact/operator/` into the canonical layout root.
5
+ * Copies each file only when the target is missing or the legacy file is newer.
6
+ */
7
+ export declare function migrateLegacyOperatorLayout(root: string, targetLayout: string): {
8
+ copied: number;
9
+ legacyPath: string;
10
+ };
11
+ //# sourceMappingURL=layoutMigration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layoutMigration.d.ts","sourceRoot":"","sources":["../../../src/shared/core/layoutMigration.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,+BAA+B,iCAAkC,CAAC;AAE/E,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7D;AAkCD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAUtH"}
@@ -0,0 +1,56 @@
1
+ import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';
2
+ import { dirname, join, resolve } from 'node:path';
3
+ export const LEGACY_OPERATOR_LAYOUT_SEGMENTS = ['.enact', 'operator'];
4
+ export function legacyOperatorLayoutPath(root) {
5
+ return join(root, ...LEGACY_OPERATOR_LAYOUT_SEGMENTS);
6
+ }
7
+ function shouldCopySource(sourcePath, targetPath) {
8
+ if (!existsSync(targetPath))
9
+ return true;
10
+ try {
11
+ const sourceStat = statSync(sourcePath);
12
+ const targetStat = statSync(targetPath);
13
+ return sourceStat.mtimeMs > targetStat.mtimeMs;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ function mergeLegacyTree(sourceDir, targetDir) {
20
+ if (!existsSync(sourceDir))
21
+ return 0;
22
+ mkdirSync(targetDir, { recursive: true });
23
+ let copied = 0;
24
+ for (const entry of readdirSync(sourceDir, { withFileTypes: true })) {
25
+ const sourcePath = join(sourceDir, entry.name);
26
+ const targetPath = join(targetDir, entry.name);
27
+ if (entry.isDirectory()) {
28
+ copied += mergeLegacyTree(sourcePath, targetPath);
29
+ continue;
30
+ }
31
+ if (!entry.isFile())
32
+ continue;
33
+ if (!shouldCopySource(sourcePath, targetPath))
34
+ continue;
35
+ mkdirSync(dirname(targetPath), { recursive: true });
36
+ cpSync(sourcePath, targetPath);
37
+ copied += 1;
38
+ }
39
+ return copied;
40
+ }
41
+ /**
42
+ * One-time merge from `.enact/operator/` into the canonical layout root.
43
+ * Copies each file only when the target is missing or the legacy file is newer.
44
+ */
45
+ export function migrateLegacyOperatorLayout(root, targetLayout) {
46
+ const legacyPath = legacyOperatorLayoutPath(root);
47
+ if (!existsSync(legacyPath)) {
48
+ return { copied: 0, legacyPath };
49
+ }
50
+ if (resolve(legacyPath) === resolve(targetLayout)) {
51
+ return { copied: 0, legacyPath };
52
+ }
53
+ const copied = mergeLegacyTree(legacyPath, targetLayout);
54
+ return { copied, legacyPath };
55
+ }
56
+ //# sourceMappingURL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IAAI,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAClD,SAAS;QACX,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAAE,SAAS;QAC9B,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC;YAAE,SAAS;QACxD,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC/B,MAAM,IAAI,CAAC,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAY,EAAE,YAAoB;IAC5E,MAAM,UAAU,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QAClD,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;IACnC,CAAC;IACD,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACzD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { type PhaseTransitionEvent } from '../../shared/core/events.js';
2
+ import { type GateProfile, type GoalScope } from '../../shared/workflow/activation/gateProfiles.js';
3
+ export interface LifecycleHistoryEntryBase<Phase extends string> {
4
+ phase: Phase;
5
+ at: string;
6
+ by?: string;
7
+ note?: string;
8
+ }
9
+ export declare function lifecycleNow(): string;
10
+ export declare function buildLifecycleCore<Phase extends string, HistoryEntry extends LifecycleHistoryEntryBase<string>>(args: {
11
+ id: string;
12
+ phase: Phase;
13
+ history: HistoryEntry[];
14
+ goalScope?: GoalScope;
15
+ gateProfile?: GateProfile;
16
+ }): {
17
+ id: string;
18
+ active: boolean;
19
+ phase: Phase;
20
+ history: HistoryEntry[];
21
+ goalScope: GoalScope | undefined;
22
+ gateProfile: GateProfile | undefined;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ };
26
+ export declare function resolveLifecycleStartScopeAndProfile(root: string, args: {
27
+ text: string;
28
+ explicitGoalScope?: GoalScope;
29
+ explicitGateProfile?: GateProfile;
30
+ contextLabel: string;
31
+ hint: string;
32
+ }): {
33
+ resolvedProfile: GateProfile | undefined;
34
+ resolvedScope: GoalScope;
35
+ };
36
+ export declare function resolveLifecycleRetargetScopeAndProfile(root: string, args: {
37
+ text: string;
38
+ explicitGoalScope?: GoalScope;
39
+ explicitGateProfile?: GateProfile;
40
+ currentGoalScope?: GoalScope;
41
+ currentGateProfile?: GateProfile;
42
+ contextLabel: string;
43
+ }): {
44
+ resolvedProfile: GateProfile | undefined;
45
+ resolvedScope: GoalScope;
46
+ };
47
+ export declare function assertLifecycleTransitionAllowed<Phase extends string>(label: string, id: string, currentPhase: Phase, nextPhase: Phase, transitions: Record<Phase, Phase[]>): void;
48
+ export declare function recordLifecyclePhaseTransition(root: string, args: {
49
+ modeType: PhaseTransitionEvent['modeType'];
50
+ laneId: string;
51
+ fromPhase: string;
52
+ toPhase: string;
53
+ trigger?: PhaseTransitionEvent['trigger'];
54
+ sessionAction: string;
55
+ sessionDetail: string;
56
+ sessionMetadata?: Record<string, unknown>;
57
+ actor?: string;
58
+ sessionId?: string;
59
+ runId?: string;
60
+ }): void;
61
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0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WAAW,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;CACtB;;;EAiBA;AAED,wBAAgB,gCAAgC,CAAC,KAAK,SAAS,MAAM,EACnE,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,KAAK,EAChB,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,QAQpC;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IACjE,QAAQ,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,QA8CA"}
@@ -0,0 +1,123 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { createEvidenceHorizon } from '../../shared/core/events.js';
3
+ import { appendLedger } from '../../operator/runtime.js';
4
+ import { emitEvent } from '../../shared/observability/emit.js';
5
+ import { defaultGoalScopeForRoot, inferGateProfile, isOperatorRepo, } from '../../shared/workflow/activation/gateProfiles.js';
6
+ export function lifecycleNow() {
7
+ return new Date().toISOString();
8
+ }
9
+ export function buildLifecycleCore(args) {
10
+ const timestamp = lifecycleNow();
11
+ return {
12
+ id: args.id,
13
+ active: true,
14
+ phase: args.phase,
15
+ history: args.history,
16
+ goalScope: args.goalScope,
17
+ gateProfile: args.gateProfile,
18
+ createdAt: timestamp,
19
+ updatedAt: timestamp,
20
+ };
21
+ }
22
+ function refineScope(root, scope, profile) {
23
+ if (scope !== undefined) {
24
+ return scope;
25
+ }
26
+ let resolvedScope = defaultGoalScopeForRoot(root);
27
+ if (profile === 'operator-runtime') {
28
+ resolvedScope = 'operator-runtime';
29
+ }
30
+ else if (profile === 'operator-replacement') {
31
+ resolvedScope = 'operator-replacement';
32
+ }
33
+ return resolvedScope;
34
+ }
35
+ export function resolveLifecycleStartScopeAndProfile(root, args) {
36
+ let resolvedProfile = args.explicitGateProfile;
37
+ if (resolvedProfile === undefined) {
38
+ const inferred = inferGateProfile(args.text, root);
39
+ if (inferred !== null) {
40
+ resolvedProfile = inferred;
41
+ }
42
+ else if (isOperatorRepo(root)) {
43
+ throw Object.assign(new Error(`${args.contextLabel}: cannot infer gate profile for "${args.text}" in the enact-operator repo. ` +
44
+ `Please provide an explicit gateProfile ('repo-delivery', 'operator-runtime', or 'operator-replacement').`), {
45
+ code: 'GATE_PROFILE_REQUIRED',
46
+ root,
47
+ text: args.text,
48
+ hint: args.hint,
49
+ });
50
+ }
51
+ }
52
+ return {
53
+ resolvedProfile,
54
+ resolvedScope: refineScope(root, args.explicitGoalScope, resolvedProfile),
55
+ };
56
+ }
57
+ export function resolveLifecycleRetargetScopeAndProfile(root, args) {
58
+ let resolvedProfile = args.explicitGateProfile ?? args.currentGateProfile;
59
+ if (args.explicitGateProfile === undefined) {
60
+ const inferred = inferGateProfile(args.text, root);
61
+ if (inferred !== null) {
62
+ resolvedProfile = inferred;
63
+ }
64
+ else if (resolvedProfile === undefined && isOperatorRepo(root)) {
65
+ throw new Error(`${args.contextLabel}: cannot infer gate profile for "${args.text}" in the enact-operator repo. Provide an explicit gateProfile.`);
66
+ }
67
+ }
68
+ return {
69
+ resolvedProfile,
70
+ resolvedScope: refineScope(root, args.explicitGoalScope ?? args.currentGoalScope, resolvedProfile),
71
+ };
72
+ }
73
+ export function assertLifecycleTransitionAllowed(label, id, currentPhase, nextPhase, transitions) {
74
+ const allowed = transitions[currentPhase];
75
+ if (!allowed.includes(nextPhase)) {
76
+ throw new Error(`Invalid transition for ${label} "${id}": "${currentPhase}" → "${nextPhase}" is not allowed. Allowed targets: [${allowed.join(', ') || 'none'}].`);
77
+ }
78
+ }
79
+ export function recordLifecyclePhaseTransition(root, args) {
80
+ appendLedger(root, {
81
+ kind: 'session',
82
+ action: args.sessionAction,
83
+ detail: args.sessionDetail,
84
+ actor: args.actor,
85
+ metadata: args.sessionMetadata,
86
+ });
87
+ const phaseEvent = {
88
+ kind: 'phase_transition',
89
+ action: 'phase_transition',
90
+ schemaVersion: 1,
91
+ correlationId: `phase_${randomUUID().slice(0, 12)}`,
92
+ modeType: args.modeType,
93
+ modeId: args.laneId,
94
+ fromPhase: args.fromPhase,
95
+ toPhase: args.toPhase,
96
+ trigger: args.trigger ?? 'operator',
97
+ evidenceHorizon: createEvidenceHorizon(root),
98
+ };
99
+ appendLedger(root, {
100
+ kind: 'phase_transition',
101
+ action: phaseEvent.action,
102
+ detail: `Phase transition ${args.modeType} "${args.laneId}": "${args.fromPhase}" → "${args.toPhase}"`,
103
+ metadata: phaseEvent,
104
+ });
105
+ void emitEvent({
106
+ schema_version: 'enact.raw.v1',
107
+ source: 'enact-operator',
108
+ event_type: 'state.transition',
109
+ session_id: args.sessionId ?? 'unknown',
110
+ run_id: args.runId ?? args.sessionId ?? args.laneId,
111
+ ts: lifecycleNow(),
112
+ payload: {
113
+ 'openinference.span.kind': 'CHAIN',
114
+ 'enact.entity': args.modeType,
115
+ 'enact.entity_id': args.laneId,
116
+ 'enact.from_state': args.fromPhase,
117
+ 'enact.to_state': args.toPhase,
118
+ 'enact.actor': args.actor ?? 'system',
119
+ 'enact.hook_event': args.trigger ?? 'operator',
120
+ },
121
+ });
122
+ }
123
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/shared/core/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UA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KAC7C,CAAC;IAEF,YAAY,CAAC,IAAI,EAAE;QACjB,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,MAAM,EAAE,oBAAoB,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,SAAS,QAAQ,IAAI,CAAC,OAAO,GAAG;QACrG,QAAQ,EAAE,UAAgD;KAC3D,CAAC,CAAC;IAEH,KAAK,SAAS,CAAC;QACb,cAAc,EAAE,cAAc;QAC9B,MAAM,EAAE,gBAAgB;QACxB,UAAU,EAAE,kBAAkB;QAC9B,UAAU,EAAE,IAAI,CAAC,SAAS,IAAI,SAAS;QACvC,MAAM,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM;QACnD,EAAE,EAAE,YAAY,EAAE;QAClB,OAAO,EAAE;YACP,yBAAyB,EAAE,OAAO;YAClC,cAAc,EAAE,IAAI,CAAC,QAAQ;YAC7B,iBAAiB,EAAE,IAAI,CAAC,MAAM;YAC9B,kBAAkB,EAAE,IAAI,CAAC,SAAS;YAClC,gBAAgB,EAAE,IAAI,CAAC,OAAO;YAC9B,aAAa,EAAE,IAAI,CAAC,KAAK,IAAI,QAAQ;YACrC,kBAAkB,EAAE,IAAI,CAAC,OAAO,IAAI,UAAU;SAC/C;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function packagedHooksHandlersPath(): string;
2
+ //# sourceMappingURL=packagePaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packagePaths.d.ts","sourceRoot":"","sources":["../../../src/shared/core/packagePaths.ts"],"names":[],"mappings":"AAOA,wBAAgB,yBAAyB,IAAI,MAAM,CAElD"}
@@ -0,0 +1,9 @@
1
+ import { dirname, join, resolve } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ function packageRoot() {
4
+ return resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
5
+ }
6
+ export function packagedHooksHandlersPath() {
7
+ return join(packageRoot(), 'runtime', 'hooks');
8
+ }
9
+ //# sourceMappingURL=packagePaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packagePaths.js","sourceRoot":"","sources":["../../../src/shared/core/packagePaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,SAAS,WAAW;IAClB,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * ENACT operator vocabulary (operator runtime only).
3
+ *
4
+ * - **OperatorTask** (`state/tasks.json`): local operator task; id prefix `task_*`.
5
+ * - **Session task** (`state/session-tasks.json`): MCP/session-scoped work units.
6
+ * - **assignmentRef**: opaque factory/board reference on mode state (never AzDO sync here).
7
+ * - **taskId** on reviews/inbox/ledger/team: always a OperatorTask id or externalId link.
8
+ *
9
+ * Factory-owned tasks live in enact-factory only.
10
+ */
11
+ export type OperatorAssignmentRef = string;
12
+ export type TaskIdCarrier = {
13
+ taskId?: string;
14
+ };
15
+ export declare function coalesceTaskId(carrier: TaskIdCarrier | undefined | null): string | undefined;
16
+ export declare function withCanonicalTaskId<T extends TaskIdCarrier>(record: T): T & {
17
+ taskId: string;
18
+ };
19
+ export type AssignmentRefCarrier = {
20
+ assignmentRef?: string;
21
+ };
22
+ export declare function coalesceAssignmentRef(carrier: AssignmentRefCarrier | undefined | null): string | undefined;
23
+ export declare function withCanonicalAssignmentRef<T extends AssignmentRefCarrier>(record: T): T & {
24
+ assignmentRef: string;
25
+ };
26
+ export declare const CANONICAL_LEDGER_KINDS: {
27
+ readonly task: "task";
28
+ readonly taskManualClose: "task_manual_close";
29
+ /** Factory alias: factory_workitem_acknowledge_close emits this kind; treated as task_manual_close by stop-policy. */
30
+ readonly workitemManualClose: "workitem_manual_close";
31
+ readonly taskCloseDeferred: "task_close_deferred";
32
+ };
33
+ export declare function isManualTaskCloseLedgerKind(kind: string): boolean;
34
+ export declare function isTaskCloseDeferredLedgerKind(kind: string): boolean;
35
+ export declare function ledgerEntryTaskId(entry: TaskIdCarrier & {
36
+ metadata?: Record<string, unknown>;
37
+ }): string | undefined;
38
+ //# sourceMappingURL=terminology.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminology.d.ts","sourceRoot":"","sources":["../../../src/shared/core/terminology.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAG5F;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAM9F;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAG1G;AAED,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,oBAAoB,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAMnH;AAED,eAAO,MAAM,sBAAsB;;;IAGjC,sHAAsH;;;CAG9G,CAAC;AAEX,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGjE;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,MAAM,GAAG,SAAS,CAInH"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * ENACT operator vocabulary (operator runtime only).
3
+ *
4
+ * - **OperatorTask** (`state/tasks.json`): local operator task; id prefix `task_*`.
5
+ * - **Session task** (`state/session-tasks.json`): MCP/session-scoped work units.
6
+ * - **assignmentRef**: opaque factory/board reference on mode state (never AzDO sync here).
7
+ * - **taskId** on reviews/inbox/ledger/team: always a OperatorTask id or externalId link.
8
+ *
9
+ * Factory-owned tasks live in enact-factory only.
10
+ */
11
+ export function coalesceTaskId(carrier) {
12
+ if (!carrier)
13
+ return undefined;
14
+ return typeof carrier.taskId === 'string' && carrier.taskId.length > 0 ? carrier.taskId : undefined;
15
+ }
16
+ export function withCanonicalTaskId(record) {
17
+ const taskId = coalesceTaskId(record);
18
+ if (!taskId) {
19
+ throw new Error('taskId is required');
20
+ }
21
+ return { ...record, taskId };
22
+ }
23
+ export function coalesceAssignmentRef(carrier) {
24
+ if (!carrier)
25
+ return undefined;
26
+ return typeof carrier.assignmentRef === 'string' && carrier.assignmentRef.length > 0 ? carrier.assignmentRef : undefined;
27
+ }
28
+ export function withCanonicalAssignmentRef(record) {
29
+ const assignmentRef = coalesceAssignmentRef(record);
30
+ if (!assignmentRef) {
31
+ throw new Error('assignmentRef is required');
32
+ }
33
+ return { ...record, assignmentRef };
34
+ }
35
+ export const CANONICAL_LEDGER_KINDS = {
36
+ task: 'task',
37
+ taskManualClose: 'task_manual_close',
38
+ /** Factory alias: factory_workitem_acknowledge_close emits this kind; treated as task_manual_close by stop-policy. */
39
+ workitemManualClose: 'workitem_manual_close',
40
+ taskCloseDeferred: 'task_close_deferred',
41
+ };
42
+ export function isManualTaskCloseLedgerKind(kind) {
43
+ return kind === CANONICAL_LEDGER_KINDS.taskManualClose
44
+ || kind === CANONICAL_LEDGER_KINDS.workitemManualClose;
45
+ }
46
+ export function isTaskCloseDeferredLedgerKind(kind) {
47
+ return kind === CANONICAL_LEDGER_KINDS.taskCloseDeferred;
48
+ }
49
+ export function ledgerEntryTaskId(entry) {
50
+ return coalesceTaskId(entry) ?? (typeof entry.metadata?.taskId === 'string'
51
+ ? entry.metadata.taskId
52
+ : undefined);
53
+ }
54
+ //# sourceMappingURL=terminology.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminology.js","sourceRoot":"","sources":["../../../src/shared/core/terminology.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,MAAM,UAAU,cAAc,CAAC,OAAyC;IACtE,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,OAAO,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACtG,CAAC;AAED,MAAM,UAAU,mBAAmB,CAA0B,MAAS;IACpE,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC;AAID,MAAM,UAAU,qBAAqB,CAAC,OAAgD;IACpF,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,OAAO,OAAO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