@archmax-ai/harness 0.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 (351) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -0
  3. package/dist/agent.d.ts +174 -0
  4. package/dist/agent.js +140 -0
  5. package/dist/agent.js.map +1 -0
  6. package/dist/assembly/compose.d.ts +170 -0
  7. package/dist/assembly/compose.js +391 -0
  8. package/dist/assembly/compose.js.map +1 -0
  9. package/dist/assembly/delegation-registry.d.ts +5 -0
  10. package/dist/assembly/delegation-registry.js +118 -0
  11. package/dist/assembly/delegation-registry.js.map +1 -0
  12. package/dist/assembly/index.d.ts +192 -0
  13. package/dist/assembly/index.js +265 -0
  14. package/dist/assembly/index.js.map +1 -0
  15. package/dist/assembly/plain.d.ts +7 -0
  16. package/dist/assembly/plain.js +41 -0
  17. package/dist/assembly/plain.js.map +1 -0
  18. package/dist/authoring-skill/archmax-harness/README.md +76 -0
  19. package/dist/authoring-skill/archmax-harness/SKILL.md +241 -0
  20. package/dist/authoring-skill/archmax-harness/references/backend-integration.md +626 -0
  21. package/dist/authoring-skill/archmax-harness/references/cases.md +41 -0
  22. package/dist/authoring-skill/archmax-harness/references/diagnostics.md +51 -0
  23. package/dist/authoring-skill/archmax-harness/references/hook-and-test-scripts.md +1070 -0
  24. package/dist/authoring-skill/archmax-harness/references/hooks-and-scripts.md +82 -0
  25. package/dist/authoring-skill/archmax-harness/references/wiring.md +101 -0
  26. package/dist/authoring-skill/archmax-harness/references/workflow-schema.md +1631 -0
  27. package/dist/authoring-skill/archmax-harness/references/workflow-yaml.md +241 -0
  28. package/dist/behaviour/support.d.ts +232 -0
  29. package/dist/behaviour/support.js +339 -0
  30. package/dist/behaviour/support.js.map +1 -0
  31. package/dist/cli/banner.d.ts +11 -0
  32. package/dist/cli/banner.js +29 -0
  33. package/dist/cli/banner.js.map +1 -0
  34. package/dist/cli/bootstrap.d.ts +33 -0
  35. package/dist/cli/bootstrap.js +153 -0
  36. package/dist/cli/bootstrap.js.map +1 -0
  37. package/dist/cli/command.d.ts +39 -0
  38. package/dist/cli/command.js +97 -0
  39. package/dist/cli/command.js.map +1 -0
  40. package/dist/cli/state-flow.d.ts +46 -0
  41. package/dist/cli/state-flow.js +268 -0
  42. package/dist/cli/state-flow.js.map +1 -0
  43. package/dist/cli/style.d.ts +41 -0
  44. package/dist/cli/style.js +64 -0
  45. package/dist/cli/style.js.map +1 -0
  46. package/dist/cli/turn.d.ts +41 -0
  47. package/dist/cli/turn.js +161 -0
  48. package/dist/cli/turn.js.map +1 -0
  49. package/dist/cli.d.ts +10 -0
  50. package/dist/cli.js +426 -0
  51. package/dist/cli.js.map +1 -0
  52. package/dist/core/code-description.d.ts +22 -0
  53. package/dist/core/code-description.js +38 -0
  54. package/dist/core/code-description.js.map +1 -0
  55. package/dist/core/deepagents.d.ts +183 -0
  56. package/dist/core/deepagents.js +128 -0
  57. package/dist/core/deepagents.js.map +1 -0
  58. package/dist/core/events.d.ts +350 -0
  59. package/dist/core/events.js +205 -0
  60. package/dist/core/events.js.map +1 -0
  61. package/dist/core/frontmatter.d.ts +15 -0
  62. package/dist/core/frontmatter.js +32 -0
  63. package/dist/core/frontmatter.js.map +1 -0
  64. package/dist/core/listing-redact.d.ts +37 -0
  65. package/dist/core/listing-redact.js +88 -0
  66. package/dist/core/listing-redact.js.map +1 -0
  67. package/dist/core/match.d.ts +26 -0
  68. package/dist/core/match.js +75 -0
  69. package/dist/core/match.js.map +1 -0
  70. package/dist/core/message-readers.d.ts +84 -0
  71. package/dist/core/message-readers.js +159 -0
  72. package/dist/core/message-readers.js.map +1 -0
  73. package/dist/core/messages.d.ts +49 -0
  74. package/dist/core/messages.js +85 -0
  75. package/dist/core/messages.js.map +1 -0
  76. package/dist/core/mount-prompt.d.ts +28 -0
  77. package/dist/core/mount-prompt.js +55 -0
  78. package/dist/core/mount-prompt.js.map +1 -0
  79. package/dist/core/mount-redact.d.ts +28 -0
  80. package/dist/core/mount-redact.js +32 -0
  81. package/dist/core/mount-redact.js.map +1 -0
  82. package/dist/core/mounts.d.ts +88 -0
  83. package/dist/core/mounts.js +147 -0
  84. package/dist/core/mounts.js.map +1 -0
  85. package/dist/core/path-mapping.d.ts +52 -0
  86. package/dist/core/path-mapping.js +113 -0
  87. package/dist/core/path-mapping.js.map +1 -0
  88. package/dist/core/platform-prompt.generated.d.ts +2 -0
  89. package/dist/core/platform-prompt.generated.js +4 -0
  90. package/dist/core/platform-prompt.generated.js.map +1 -0
  91. package/dist/core/prompt.d.ts +42 -0
  92. package/dist/core/prompt.js +75 -0
  93. package/dist/core/prompt.js.map +1 -0
  94. package/dist/core/session-id.d.ts +38 -0
  95. package/dist/core/session-id.js +61 -0
  96. package/dist/core/session-id.js.map +1 -0
  97. package/dist/core/session-store.d.ts +85 -0
  98. package/dist/core/session-store.js +149 -0
  99. package/dist/core/session-store.js.map +1 -0
  100. package/dist/core/session-zone.d.ts +54 -0
  101. package/dist/core/session-zone.js +82 -0
  102. package/dist/core/session-zone.js.map +1 -0
  103. package/dist/core/skill-prompt.d.ts +31 -0
  104. package/dist/core/skill-prompt.js +54 -0
  105. package/dist/core/skill-prompt.js.map +1 -0
  106. package/dist/core/skill-redact.d.ts +15 -0
  107. package/dist/core/skill-redact.js +27 -0
  108. package/dist/core/skill-redact.js.map +1 -0
  109. package/dist/core/skills.d.ts +172 -0
  110. package/dist/core/skills.js +214 -0
  111. package/dist/core/skills.js.map +1 -0
  112. package/dist/core/tool-mocks.d.ts +23 -0
  113. package/dist/core/tool-mocks.js +39 -0
  114. package/dist/core/tool-mocks.js.map +1 -0
  115. package/dist/core/tool-telemetry.d.ts +16 -0
  116. package/dist/core/tool-telemetry.js +40 -0
  117. package/dist/core/tool-telemetry.js.map +1 -0
  118. package/dist/core/usage.d.ts +114 -0
  119. package/dist/core/usage.js +226 -0
  120. package/dist/core/usage.js.map +1 -0
  121. package/dist/core/workspace-context.d.ts +136 -0
  122. package/dist/core/workspace-context.js +178 -0
  123. package/dist/core/workspace-context.js.map +1 -0
  124. package/dist/core/workspace-prompt.d.ts +7 -0
  125. package/dist/core/workspace-prompt.js +102 -0
  126. package/dist/core/workspace-prompt.js.map +1 -0
  127. package/dist/core/workspace-router.d.ts +61 -0
  128. package/dist/core/workspace-router.js +145 -0
  129. package/dist/core/workspace-router.js.map +1 -0
  130. package/dist/core/workspace.d.ts +85 -0
  131. package/dist/core/workspace.js +193 -0
  132. package/dist/core/workspace.js.map +1 -0
  133. package/dist/core/zones.d.ts +181 -0
  134. package/dist/core/zones.js +202 -0
  135. package/dist/core/zones.js.map +1 -0
  136. package/dist/env.d.ts +99 -0
  137. package/dist/env.js +271 -0
  138. package/dist/env.js.map +1 -0
  139. package/dist/index.d.ts +265 -0
  140. package/dist/index.js +197 -0
  141. package/dist/index.js.map +1 -0
  142. package/dist/kernel/kernel.d.ts +192 -0
  143. package/dist/kernel/kernel.js +751 -0
  144. package/dist/kernel/kernel.js.map +1 -0
  145. package/dist/lifecycle/hook-shape.d.ts +44 -0
  146. package/dist/lifecycle/hook-shape.js +66 -0
  147. package/dist/lifecycle/hook-shape.js.map +1 -0
  148. package/dist/lifecycle/runner.d.ts +177 -0
  149. package/dist/lifecycle/runner.js +372 -0
  150. package/dist/lifecycle/runner.js.map +1 -0
  151. package/dist/lifecycle/transcript.d.ts +27 -0
  152. package/dist/lifecycle/transcript.js +43 -0
  153. package/dist/lifecycle/transcript.js.map +1 -0
  154. package/dist/machine/allow.d.ts +65 -0
  155. package/dist/machine/allow.js +107 -0
  156. package/dist/machine/allow.js.map +1 -0
  157. package/dist/machine/delegation.d.ts +9 -0
  158. package/dist/machine/delegation.js +10 -0
  159. package/dist/machine/delegation.js.map +1 -0
  160. package/dist/machine/diagnostic.d.ts +14 -0
  161. package/dist/machine/diagnostic.js +2 -0
  162. package/dist/machine/diagnostic.js.map +1 -0
  163. package/dist/machine/lint-spec.d.ts +4 -0
  164. package/dist/machine/lint-spec.js +266 -0
  165. package/dist/machine/lint-spec.js.map +1 -0
  166. package/dist/machine/load-spec.d.ts +90 -0
  167. package/dist/machine/load-spec.js +120 -0
  168. package/dist/machine/load-spec.js.map +1 -0
  169. package/dist/machine/machine.d.ts +273 -0
  170. package/dist/machine/machine.js +551 -0
  171. package/dist/machine/machine.js.map +1 -0
  172. package/dist/machine/mount-grants.d.ts +25 -0
  173. package/dist/machine/mount-grants.js +24 -0
  174. package/dist/machine/mount-grants.js.map +1 -0
  175. package/dist/machine/slug.d.ts +14 -0
  176. package/dist/machine/slug.js +17 -0
  177. package/dist/machine/slug.js.map +1 -0
  178. package/dist/machine/spec-schema.d.ts +662 -0
  179. package/dist/machine/spec-schema.js +717 -0
  180. package/dist/machine/spec-schema.js.map +1 -0
  181. package/dist/machine/tool-names.d.ts +98 -0
  182. package/dist/machine/tool-names.js +144 -0
  183. package/dist/machine/tool-names.js.map +1 -0
  184. package/dist/machine/triggers.d.ts +114 -0
  185. package/dist/machine/triggers.js +165 -0
  186. package/dist/machine/triggers.js.map +1 -0
  187. package/dist/machine/types.d.ts +186 -0
  188. package/dist/machine/types.js +12 -0
  189. package/dist/machine/types.js.map +1 -0
  190. package/dist/machine/validate-spec.d.ts +42 -0
  191. package/dist/machine/validate-spec.js +29 -0
  192. package/dist/machine/validate-spec.js.map +1 -0
  193. package/dist/machine/variables.d.ts +196 -0
  194. package/dist/machine/variables.js +415 -0
  195. package/dist/machine/variables.js.map +1 -0
  196. package/dist/public/cli.d.ts +15 -0
  197. package/dist/public/cli.js +14 -0
  198. package/dist/public/cli.js.map +1 -0
  199. package/dist/public/messages.d.ts +33 -0
  200. package/dist/public/messages.js +33 -0
  201. package/dist/public/messages.js.map +1 -0
  202. package/dist/public/sandbox.d.ts +99 -0
  203. package/dist/public/sandbox.js +32 -0
  204. package/dist/public/sandbox.js.map +1 -0
  205. package/dist/public/spec.d.ts +147 -0
  206. package/dist/public/spec.js +149 -0
  207. package/dist/public/spec.js.map +1 -0
  208. package/dist/public/testing.d.ts +71 -0
  209. package/dist/public/testing.js +39 -0
  210. package/dist/public/testing.js.map +1 -0
  211. package/dist/rubrics/rubrics.d.ts +135 -0
  212. package/dist/rubrics/rubrics.js +145 -0
  213. package/dist/rubrics/rubrics.js.map +1 -0
  214. package/dist/runtime/contract.d.ts +73 -0
  215. package/dist/runtime/contract.js +96 -0
  216. package/dist/runtime/contract.js.map +1 -0
  217. package/dist/sandbox/assets/parts/core.js +22 -0
  218. package/dist/sandbox/assets/parts/lifecycle-hook.js +47 -0
  219. package/dist/sandbox/bridge.d.ts +16 -0
  220. package/dist/sandbox/bridge.js +95 -0
  221. package/dist/sandbox/bridge.js.map +1 -0
  222. package/dist/sandbox/executor.d.ts +46 -0
  223. package/dist/sandbox/executor.js +119 -0
  224. package/dist/sandbox/executor.js.map +1 -0
  225. package/dist/sandbox/imports.d.ts +33 -0
  226. package/dist/sandbox/imports.js +67 -0
  227. package/dist/sandbox/imports.js.map +1 -0
  228. package/dist/sandbox/prelude.d.ts +12 -0
  229. package/dist/sandbox/prelude.js +51 -0
  230. package/dist/sandbox/prelude.js.map +1 -0
  231. package/dist/sandbox/ptc-gateway.d.ts +104 -0
  232. package/dist/sandbox/ptc-gateway.js +167 -0
  233. package/dist/sandbox/ptc-gateway.js.map +1 -0
  234. package/dist/sandbox/runtime.d.ts +59 -0
  235. package/dist/sandbox/runtime.js +51 -0
  236. package/dist/sandbox/runtime.js.map +1 -0
  237. package/dist/sandbox/tools.d.ts +34 -0
  238. package/dist/sandbox/tools.js +147 -0
  239. package/dist/sandbox/tools.js.map +1 -0
  240. package/dist/sessions/operations.d.ts +79 -0
  241. package/dist/sessions/operations.js +121 -0
  242. package/dist/sessions/operations.js.map +1 -0
  243. package/dist/sessions/resolve.d.ts +97 -0
  244. package/dist/sessions/resolve.js +145 -0
  245. package/dist/sessions/resolve.js.map +1 -0
  246. package/dist/sessions/resume.d.ts +242 -0
  247. package/dist/sessions/resume.js +288 -0
  248. package/dist/sessions/resume.js.map +1 -0
  249. package/dist/sessions/scope.d.ts +99 -0
  250. package/dist/sessions/scope.js +145 -0
  251. package/dist/sessions/scope.js.map +1 -0
  252. package/dist/sessions/summary.d.ts +65 -0
  253. package/dist/sessions/summary.js +56 -0
  254. package/dist/sessions/summary.js.map +1 -0
  255. package/dist/testing/assertions.d.ts +30 -0
  256. package/dist/testing/assertions.js +231 -0
  257. package/dist/testing/assertions.js.map +1 -0
  258. package/dist/testing/case-document.d.ts +141 -0
  259. package/dist/testing/case-document.js +51 -0
  260. package/dist/testing/case-document.js.map +1 -0
  261. package/dist/testing/case-schema.d.ts +29 -0
  262. package/dist/testing/case-schema.js +519 -0
  263. package/dist/testing/case-schema.js.map +1 -0
  264. package/dist/testing/discovery.d.ts +10 -0
  265. package/dist/testing/discovery.js +24 -0
  266. package/dist/testing/discovery.js.map +1 -0
  267. package/dist/testing/driver.d.ts +78 -0
  268. package/dist/testing/driver.js +117 -0
  269. package/dist/testing/driver.js.map +1 -0
  270. package/dist/testing/grade.d.ts +116 -0
  271. package/dist/testing/grade.js +261 -0
  272. package/dist/testing/grade.js.map +1 -0
  273. package/dist/testing/interpreter.d.ts +55 -0
  274. package/dist/testing/interpreter.js +103 -0
  275. package/dist/testing/interpreter.js.map +1 -0
  276. package/dist/testing/mock-middleware.d.ts +5 -0
  277. package/dist/testing/mock-middleware.js +33 -0
  278. package/dist/testing/mock-middleware.js.map +1 -0
  279. package/dist/testing/runner.d.ts +205 -0
  280. package/dist/testing/runner.js +266 -0
  281. package/dist/testing/runner.js.map +1 -0
  282. package/dist/testing/target.d.ts +27 -0
  283. package/dist/testing/target.js +21 -0
  284. package/dist/testing/target.js.map +1 -0
  285. package/dist/validate/validate.d.ts +41 -0
  286. package/dist/validate/validate.js +669 -0
  287. package/dist/validate/validate.js.map +1 -0
  288. package/dist/workflow/agent-tools.d.ts +10 -0
  289. package/dist/workflow/agent-tools.js +10 -0
  290. package/dist/workflow/agent-tools.js.map +1 -0
  291. package/dist/workflow/checkpointer.d.ts +52 -0
  292. package/dist/workflow/checkpointer.js +200 -0
  293. package/dist/workflow/checkpointer.js.map +1 -0
  294. package/dist/workflow/control-tools.d.ts +174 -0
  295. package/dist/workflow/control-tools.js +468 -0
  296. package/dist/workflow/control-tools.js.map +1 -0
  297. package/dist/workflow/governance.d.ts +104 -0
  298. package/dist/workflow/governance.js +546 -0
  299. package/dist/workflow/governance.js.map +1 -0
  300. package/dist/workflow/middleware.d.ts +85 -0
  301. package/dist/workflow/middleware.js +283 -0
  302. package/dist/workflow/middleware.js.map +1 -0
  303. package/dist/workflow/on-error.d.ts +25 -0
  304. package/dist/workflow/on-error.js +58 -0
  305. package/dist/workflow/on-error.js.map +1 -0
  306. package/dist/workflow/parks.d.ts +46 -0
  307. package/dist/workflow/parks.js +513 -0
  308. package/dist/workflow/parks.js.map +1 -0
  309. package/dist/workflow/paths.d.ts +67 -0
  310. package/dist/workflow/paths.js +108 -0
  311. package/dist/workflow/paths.js.map +1 -0
  312. package/dist/workflow/prompt-cache.d.ts +70 -0
  313. package/dist/workflow/prompt-cache.js +103 -0
  314. package/dist/workflow/prompt-cache.js.map +1 -0
  315. package/dist/workflow/prompt-pruning.d.ts +20 -0
  316. package/dist/workflow/prompt-pruning.js +83 -0
  317. package/dist/workflow/prompt-pruning.js.map +1 -0
  318. package/dist/workflow/render-prompt.d.ts +45 -0
  319. package/dist/workflow/render-prompt.js +140 -0
  320. package/dist/workflow/render-prompt.js.map +1 -0
  321. package/dist/workflow/runtime-config.d.ts +7 -0
  322. package/dist/workflow/runtime-config.js +9 -0
  323. package/dist/workflow/runtime-config.js.map +1 -0
  324. package/dist/workflow/session-artifacts.d.ts +90 -0
  325. package/dist/workflow/session-artifacts.js +134 -0
  326. package/dist/workflow/session-artifacts.js.map +1 -0
  327. package/dist/workflow/session-view.d.ts +31 -0
  328. package/dist/workflow/session-view.js +94 -0
  329. package/dist/workflow/session-view.js.map +1 -0
  330. package/dist/workflow/snapshot.d.ts +14 -0
  331. package/dist/workflow/snapshot.js +97 -0
  332. package/dist/workflow/snapshot.js.map +1 -0
  333. package/dist/workflow/state.d.ts +347 -0
  334. package/dist/workflow/state.js +322 -0
  335. package/dist/workflow/state.js.map +1 -0
  336. package/dist/workflow/sub-workflow.d.ts +174 -0
  337. package/dist/workflow/sub-workflow.js +392 -0
  338. package/dist/workflow/sub-workflow.js.map +1 -0
  339. package/dist/workflow/tool-service.d.ts +48 -0
  340. package/dist/workflow/tool-service.js +291 -0
  341. package/dist/workflow/tool-service.js.map +1 -0
  342. package/dist/workflow/turn-boundary.d.ts +39 -0
  343. package/dist/workflow/turn-boundary.js +128 -0
  344. package/dist/workflow/turn-boundary.js.map +1 -0
  345. package/dist/workflow/turn-runner.d.ts +40 -0
  346. package/dist/workflow/turn-runner.js +122 -0
  347. package/dist/workflow/turn-runner.js.map +1 -0
  348. package/dist/workflow/workflow-tools.d.ts +46 -0
  349. package/dist/workflow/workflow-tools.js +90 -0
  350. package/dist/workflow/workflow-tools.js.map +1 -0
  351. package/package.json +119 -0
@@ -0,0 +1,546 @@
1
+ import { AIMessage, SystemMessage, ToolMessage } from "@langchain/core/messages";
2
+ import { v4 as uuidv4 } from "@langchain/core/utils/uuid";
3
+ import { Command } from "@langchain/langgraph";
4
+ import { ADVANCE_TOOL, entryStateOf, RESET_TOOL, unresolvedArgumentMessage } from "./control-tools.js";
5
+ import { resolveArguments } from "../machine/variables.js";
6
+ import { currentWorkflowState, isReplyOnly, readAuditTrail, readVariables, readWorkflowState, } from "./state.js";
7
+ import { CALLING_STATE_KEY, releaseScopes } from "../sessions/scope.js";
8
+ import { isWorkflowToolName, workflowSlugFromToolName } from "../machine/tool-names.js";
9
+ import { toolOutputPreview } from "../core/tool-telemetry.js";
10
+ import { decide } from "../kernel/kernel.js";
11
+ import { skillPrefixes } from "../core/skills.js";
12
+ import { renderSkillsSection } from "../core/skill-prompt.js";
13
+ import { renderMountsSection } from "../core/mount-prompt.js";
14
+ import { REDACTED_TOOLS, redactDisabledSkills } from "../core/skill-redact.js";
15
+ import { redactHiddenMounts } from "../core/mount-redact.js";
16
+ import { asModelCallResult, asStructuredTools, } from "../core/deepagents.js";
17
+ import { cacheControl, DEFAULT_CACHE_TTL, } from "./prompt-cache.js";
18
+ import { replyOnlyDirective } from "./parks.js";
19
+ import { renderStateGraph } from "./render-prompt.js";
20
+ import { pruneUndisclosedToolSections } from "./prompt-pruning.js";
21
+ import { blockedMessage, createToolService } from "./tool-service.js";
22
+ import { buildRunnableConfig } from "./runtime-config.js";
23
+ export { buildRunnableConfig } from "./runtime-config.js";
24
+ /**
25
+ * Resolve the name the model called to a registered tool: an exact match, or the
26
+ * bare action name of a namespaced `<collection>__<action>` id (models routinely
27
+ * drop the prefix) when that suffix is unambiguous.
28
+ */
29
+ export function resolveToolName(called, registered) {
30
+ if (registered.includes(called))
31
+ return called;
32
+ const matches = registered.filter((name) => name.endsWith(`__${called}`));
33
+ return matches.length === 1 ? matches[0] : undefined;
34
+ }
35
+ function unknownToolMessage(called, registered) {
36
+ const ambiguous = registered.filter((name) => name.endsWith(`__${called}`));
37
+ const hint = ambiguous.length > 1
38
+ ? ` Did you mean one of: ${ambiguous.join(", ")}? Call it by its full name.`
39
+ : "";
40
+ return (`[workflow] '${called}' is not a tool. Call one of the tools you were given, ` +
41
+ `by its exact name.${hint}`);
42
+ }
43
+ /**
44
+ * Whether the run was already sitting in its current state when this turn
45
+ * opened (the trail's last step is an arrival), as opposed to having
46
+ * transitioned into it this turn. The terminal directive applies only to the
47
+ * former; a run routed into a terminal state to do work must not be told to
48
+ * restart, or it restarts forever.
49
+ */
50
+ function arrivedInPlace(state) {
51
+ const trail = readAuditTrail(state);
52
+ return trail[trail.length - 1]?.kind === "trigger";
53
+ }
54
+ /**
55
+ * How coarsely the clock is rendered. The line is *quantised*, not merely put in
56
+ * the volatile block, because "volatile" is not free: the provider's cache key
57
+ * is a prefix, and LangChain's Anthropic/Bedrock middlewares put their
58
+ * breakpoint on the last message — so a system block that differs between two
59
+ * calls costs the cache of the whole transcript behind it, not just its own
60
+ * bytes. A per-second stamp would therefore re-price every turn at full input
61
+ * cost on every call.
62
+ *
63
+ * Ten minutes is chosen against the cache TTLs (5m default, 1h option): a turn
64
+ * shorter than the bucket renders one byte-identical line for all its model
65
+ * calls, and two turns close enough for the previous turn's cache to still be
66
+ * warm are usually inside one bucket too. What it costs is precision the model
67
+ * has no use for — a date, a weekday and the time to the ten minutes are what
68
+ * date arithmetic needs, and a state can always read the exact instant from the
69
+ * sandbox.
70
+ */
71
+ const CLOCK_BUCKET_MINUTES = 10;
72
+ /** The host's IANA zone, or `null` when it is UTC or the platform will not say. */
73
+ function hostTimeZone() {
74
+ try {
75
+ const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
76
+ return zone && zone !== "UTC" && zone !== "Etc/UTC" ? zone : null;
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ }
82
+ function inZone(at, timeZone, options,
83
+ // `en-CA` renders a date as `YYYY-MM-DD`, matching the UTC stamp beside it.
84
+ locale = "en-CA") {
85
+ return new Intl.DateTimeFormat(locale, { timeZone, ...options }).format(at);
86
+ }
87
+ /**
88
+ * The wall clock, one line, rendered per model call and never in the cacheable
89
+ * prefix. UTC leads because that is the zone the park and trail records stamp,
90
+ * so what the model reads and what the session stores agree; the weekday is
91
+ * spelled out because it is the part a model cannot derive; the host's zone is
92
+ * named when it differs, because a workflow that reasons about business hours
93
+ * runs there. Rounding is stated rather than hidden — a clock that may be ten
94
+ * minutes behind and says so is usable, one that quietly is not.
95
+ */
96
+ function renderNow(now) {
97
+ const bucketMs = CLOCK_BUCKET_MINUTES * 60_000;
98
+ const at = new Date(Math.floor(now.getTime() / bucketMs) * bucketMs);
99
+ const utc = at.toISOString().slice(0, 16).replace("T", " ");
100
+ const weekday = inZone(at, "UTC", { weekday: "long" }, "en-GB");
101
+ const zone = hostTimeZone();
102
+ let local = "";
103
+ if (zone) {
104
+ const day = inZone(at, zone, { year: "numeric", month: "2-digit", day: "2-digit" });
105
+ const time = inZone(at, zone, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" });
106
+ // The local date is repeated only when the zone puts it on the other side of midnight.
107
+ local = ` Locally that is ${day === utc.slice(0, 10) ? time : `${day} ${time}`} in ${zone}.`;
108
+ }
109
+ return (`Current date and time: ${utc} UTC (${weekday}), rounded down to the nearest ` +
110
+ `${CLOCK_BUCKET_MINUTES} minutes — it can be that much behind.${local}`);
111
+ }
112
+ /** The composed static prompt on a request: `systemMessage`, or the deprecated `systemPrompt`. */
113
+ function staticPromptOf(request) {
114
+ const message = request.systemMessage;
115
+ if (message) {
116
+ if (typeof message.text === "string")
117
+ return message.text;
118
+ if (typeof message.content === "string")
119
+ return message.content;
120
+ }
121
+ return typeof request.systemPrompt === "string" ? request.systemPrompt : "";
122
+ }
123
+ /**
124
+ * Rewrite the system message as `[static, volatile]` blocks, marking the static
125
+ * block cacheable when a marker is supplied. Only `systemMessage` is written:
126
+ * changing it and `systemPrompt` in one request is rejected by the agent node.
127
+ */
128
+ function applySystemMessage(request, staticText, volatileText, marker) {
129
+ if (!volatileText && !marker && staticText === staticPromptOf(request))
130
+ return;
131
+ const blocks = [];
132
+ if (staticText) {
133
+ blocks.push({ type: "text", text: staticText, ...(marker ? { cache_control: marker } : {}) });
134
+ }
135
+ if (volatileText)
136
+ blocks.push({ type: "text", text: volatileText });
137
+ if (blocks.length === 0)
138
+ return;
139
+ // `cache_control` is a provider extension the core `ContentBlock` union does not model.
140
+ request.systemMessage = new SystemMessage({
141
+ content: blocks,
142
+ });
143
+ }
144
+ /** Where a model call that ran out of its state's time budget says so. */
145
+ const BUDGET_EXHAUSTED_KEY = "archmax_budget_exhausted";
146
+ /** Where a reply standing in for a model call a `before` hook refused says so. */
147
+ const BEFORE_VETO_KEY = "archmax_before_veto";
148
+ /** The reason kwarg `key` carries on `message`, when it carries one. */
149
+ function markerReason(message, key) {
150
+ const kwargs = message
151
+ ?.additional_kwargs;
152
+ const reason = kwargs?.[key];
153
+ return typeof reason === "string" ? reason : undefined;
154
+ }
155
+ /** The reason a message stands in for a model call that exceeded its `budget.timeoutMs`, if it does. */
156
+ export function budgetExhaustedReason(message) {
157
+ return markerReason(message, BUDGET_EXHAUSTED_KEY);
158
+ }
159
+ /**
160
+ * The reason a `before` hook refused the state this message stands in for, if it
161
+ * did. The refusal is a fail-closed rejection like any other, so `afterModel`
162
+ * routes it through `on_error` instead of letting the turn settle as completed
163
+ * (issue #29) — the marker is how it tells the refusal apart from an ordinary
164
+ * reply, since the model never ran.
165
+ */
166
+ export function beforeVetoReason(message) {
167
+ return markerReason(message, BEFORE_VETO_KEY);
168
+ }
169
+ export function createGovernance(ctx) {
170
+ const { machine, emit, lifecycle, policyRules, mountPrefixes, skills, ptcGateway, subWorkflows } = ctx;
171
+ const skillTable = skillPrefixes(skills);
172
+ const skillSlugs = [...skills.keys()];
173
+ const enabledSkillsIn = (state) => machine.enabledSkills(state, skillSlugs);
174
+ const enabledMountsIn = (state) => machine.enabledMounts(state, mountPrefixes.governed);
175
+ /** Whether any mount of the table can be hidden at all — cheap early exit. */
176
+ const tableGoverns = mountPrefixes.governed.length > 0 || machine.workflowForbiddenMounts().length > 0;
177
+ const cacheStrategy = ctx.shaping.cacheStrategy ?? "off";
178
+ const cacheTtl = ctx.shaping.cacheTtl ?? DEFAULT_CACHE_TTL;
179
+ // Keyed by session id; a sub-run is its own session.
180
+ const modelContexts = new Map();
181
+ const pendingBeforeDone = new Map();
182
+ // Fallback ids for tool calls the model supplied no id for.
183
+ let generatedCallSeq = 0;
184
+ const service = createToolService({
185
+ machine,
186
+ emit,
187
+ lifecycle,
188
+ mountPrefixes,
189
+ ...(subWorkflows ? { subWorkflows } : {}),
190
+ lifecycleCtx,
191
+ });
192
+ // The static prompt is identical on every call of a run; memoized by incoming
193
+ // text because a byte difference is a cache miss.
194
+ const staticPromptCache = new Map();
195
+ function shapeStaticPrompt(text) {
196
+ const cached = staticPromptCache.get(text);
197
+ if (cached !== undefined)
198
+ return cached;
199
+ let shaped = text;
200
+ const withheld = ctx.shaping.withheldBuiltins ?? [];
201
+ if (withheld.length > 0 && text) {
202
+ const result = pruneUndisclosedToolSections(text, withheld);
203
+ shaped = result.text;
204
+ if (result.missingTools?.length) {
205
+ emit({
206
+ type: "warning",
207
+ scope: "workflow",
208
+ message: `could not prune the upstream prompt guidance for withheld tool(s) ` +
209
+ `(${result.missingTools.join(", ")}); its text is unchanged and still billed ` +
210
+ `— the expected section headings may have been reworded upstream`,
211
+ });
212
+ }
213
+ }
214
+ staticPromptCache.set(text, shaped);
215
+ return shaped;
216
+ }
217
+ /**
218
+ * Filter a scoped listing (`ls`, `glob`, `grep`) to what the state can reach:
219
+ * the kernel refuses a path inside a disabled skill bundle or a mount the
220
+ * state does not have, but a listing names a *scope* the state may reach and
221
+ * would otherwise hand back everything in it — including a directory the
222
+ * agent would then be refused, which reads as a broken workspace rather than
223
+ * as a capability it was not given.
224
+ *
225
+ * Skills first, then mounts, then one rebuilt message: the two filters are
226
+ * independent (a bundle lives inside the `skills/` mount) and both are
227
+ * identity when they hide nothing.
228
+ */
229
+ function redactListings(result, state, toolName) {
230
+ if (!REDACTED_TOOLS.has(toolName))
231
+ return result;
232
+ if (!(result instanceof ToolMessage) || typeof result.content !== "string")
233
+ return result;
234
+ let text = result.content;
235
+ if (skillTable.length > 0) {
236
+ text = redactDisabledSkills(text, enabledSkillsIn(state), skillTable);
237
+ }
238
+ if (tableGoverns) {
239
+ text = redactHiddenMounts(text, { enabled: enabledMountsIn(state), forbidden: machine.forbiddenMounts(state) }, mountPrefixes);
240
+ }
241
+ if (text === result.content)
242
+ return result;
243
+ return new ToolMessage({
244
+ ...(result.status ? { status: result.status } : {}),
245
+ content: text,
246
+ tool_call_id: result.tool_call_id,
247
+ ...(result.id !== undefined ? { id: result.id } : {}),
248
+ ...(result.name !== undefined ? { name: result.name } : {}),
249
+ ...(result.artifact !== undefined ? { artifact: result.artifact } : {}),
250
+ additional_kwargs: result.additional_kwargs,
251
+ response_metadata: result.response_metadata,
252
+ });
253
+ }
254
+ function lifecycleCtx(sessionId, state, messages) {
255
+ const context = modelContexts.get(sessionId);
256
+ const fields = readWorkflowState(state);
257
+ return {
258
+ sessionId,
259
+ tools: context?.tools ?? [],
260
+ messages,
261
+ taskTool: context?.taskTool,
262
+ config: context?.config ?? {},
263
+ iterations: { ...(fields.iterations ?? {}) },
264
+ ...(fields.trigger ? { trigger: fields.trigger } : {}),
265
+ variables: Object.fromEntries(Object.entries(readVariables(state)).map(([name, entry]) => [name, entry.value])),
266
+ variableStore: readVariables(state),
267
+ };
268
+ }
269
+ /** The volatile prompt section: what the model is told about where the run stands right now. */
270
+ function volatileSection(request, workflowState, replyOnly) {
271
+ // First, and outside either heading: the clock is true of the turn, not of
272
+ // the state the turn is in, so a parked run reads it as well.
273
+ const clock = renderNow(new Date());
274
+ if (replyOnly) {
275
+ return `${clock}\n\n## This run is parked\n\n${replyOnlyDirective(machine, request.state)}`;
276
+ }
277
+ const sections = [];
278
+ if (machine.isTerminal(workflowState) &&
279
+ workflowState !== entryStateOf(readWorkflowState(request.state), machine) &&
280
+ arrivedInPlace(request.state)) {
281
+ // A durable session sits in the terminal state it finished in, so a follow-up
282
+ // arrives where no transition leads out. Said only where it applies (see
283
+ // arrivedInPlace); that the state *is* terminal is stated by renderStateGraph
284
+ // below, so this covers only what is particular to a follow-up landing here.
285
+ sections.push(`This state is where this run finished. If what is in front of you now is a new message ` +
286
+ `rather than the work you entered this state to do, that run is over — call ` +
287
+ `${RESET_TOOL} before answering and before doing any of the work, then go forward ` +
288
+ `through the graph from the state the conversation began in. Do not answer a follow-up ` +
289
+ `from here.`);
290
+ }
291
+ // A human state's `instructions` address the reviewer, which is why a reply-only turn gets none.
292
+ const instructions = machine.spec.states[workflowState]?.instructions?.trim();
293
+ if (instructions)
294
+ sections.push(instructions);
295
+ const skillsSection = renderSkillsSection(enabledSkillsIn(workflowState), skills);
296
+ if (skillsSection)
297
+ sections.push(skillsSection);
298
+ // Beside the skills section, and volatile for the same reason: which mounts
299
+ // a state reaches varies, and the cacheable prefix does not.
300
+ const mountsSection = renderMountsSection(enabledMountsIn(workflowState), mountPrefixes, (name) => machine.mountWritable(workflowState, name, mountPrefixes));
301
+ if (mountsSection)
302
+ sections.push(mountsSection);
303
+ // Names, never values: one can hold a whole event payload.
304
+ const variables = readVariables(request.state);
305
+ const variableNames = Object.keys(variables).sort();
306
+ sections.push(variableNames.length > 0
307
+ ? `Run variables set: ${variableNames.join(", ")}. Read one with archmax_get_variables.`
308
+ : "Run variables: none set.");
309
+ const argConstraints = machine.describeArgConstraints(workflowState, variables);
310
+ if (argConstraints.length > 0) {
311
+ sections.push([
312
+ "Enforced tool argument constraints in this state (a call with any other value is blocked):",
313
+ ...argConstraints,
314
+ ].join("\n"));
315
+ }
316
+ // Last, immediately before the model acts: choosing the edge is the decision
317
+ // the turn ends on. This is the only place the graph is disclosed at all.
318
+ const graph = renderStateGraph(machine, workflowState, {
319
+ trigger: readWorkflowState(request.state).trigger?.id,
320
+ });
321
+ if (graph)
322
+ sections.push(graph);
323
+ // The heading asserts itself over the transcript: a durable session carries
324
+ // earlier turns' advance results, which a model would otherwise read as current.
325
+ return `${clock}\n\n## Current state: ${workflowState}\n\nThis is the state you are in now; it overrides any state movement recorded earlier in this conversation.${sections.length > 0 ? `\n\n${sections.join("\n\n")}` : ""}`;
326
+ }
327
+ async function wrapModelCall(request, handler) {
328
+ const sessionId = ctx.sessionIdOf(request.runtime);
329
+ const tools = asStructuredTools(request.tools);
330
+ const workflowState = currentWorkflowState(request.state, machine.entry);
331
+ const config = buildRunnableConfig(request.runtime ?? {});
332
+ const replyOnly = isReplyOnly(request.state);
333
+ // Point every wrapped PTC tool at the state, config and variables in force
334
+ // now; the state rides on the config so a script's delegation names it, and
335
+ // the variables are what a script call's `${{name}}` guards resolve against.
336
+ ptcGateway?.refresh(sessionId, {
337
+ state: workflowState,
338
+ config: {
339
+ ...config,
340
+ configurable: { ...(config.configurable ?? {}), [CALLING_STATE_KEY]: workflowState },
341
+ },
342
+ replyOnly,
343
+ variables: readVariables(request.state),
344
+ });
345
+ // Captured from the UNFILTERED surface: lifecycle hooks keep full access
346
+ // regardless of what the model is shown.
347
+ const lifecycleTools = lifecycle.resolvePtcTools(tools);
348
+ modelContexts.set(sessionId, {
349
+ tools: ptcGateway
350
+ ? ptcGateway.wrap(lifecycleTools, { origin: "lifecycle", sessionId })
351
+ : lifecycleTools,
352
+ taskTool: tools.find((t) => t.name === "task"),
353
+ config,
354
+ messages: request.messages ?? [],
355
+ toolNames: tools.map((t) => t.name),
356
+ });
357
+ // Progressive disclosure: the active state's surface in registration order (a
358
+ // byte-identical cacheable prefix); a reply-only turn is handed nothing.
359
+ if (replyOnly)
360
+ request.tools = [];
361
+ else {
362
+ const disclosed = machine.disclosedTools(workflowState);
363
+ request.tools = tools.filter((t) => disclosed.has(t.name));
364
+ }
365
+ // The model this state declared, if it declared one. Set here because this
366
+ // is where the machine's position is known: a session moves inside a turn,
367
+ // so a state's model cannot be chosen when the graph is built. A reply-only
368
+ // turn is made in the state the session is parked at, so the handoff message
369
+ // runs on that state's model too.
370
+ const stateModel = ctx.stateModels?.modelFor(workflowState);
371
+ if (stateModel)
372
+ request.model = stateModel;
373
+ // The breakpoint belongs to the model that is about to be called, not to the
374
+ // assembly: a state on Claude behind an OpenAI-compatible endpoint needs it
375
+ // whatever the workflow's own model is.
376
+ const strategy = ctx.stateModels?.cacheStrategyFor(workflowState) ?? cacheStrategy;
377
+ applySystemMessage(request, shapeStaticPrompt(staticPromptOf(request)), volatileSection(request, workflowState, replyOnly), strategy === "anthropic-compat" ? cacheControl(cacheTtl) : undefined);
378
+ // A reply-only turn enters nothing, so no `before` hook gates it.
379
+ const beforeDone = {
380
+ ...(readWorkflowState(request.state).beforeDone ?? {}),
381
+ ...(pendingBeforeDone.get(sessionId) ?? {}),
382
+ };
383
+ if (!replyOnly && !beforeDone[workflowState]) {
384
+ const veto = await lifecycle.runPhase(workflowState, "before", lifecycleCtx(sessionId, request.state, request.messages ?? []));
385
+ if (veto) {
386
+ // The refusal is the person's answer *and* a rejection: the text is the
387
+ // reply, the marker is what `afterModel` routes on.
388
+ return new AIMessage({
389
+ content: `Request rejected before the '${workflowState}' state could run: ${veto.reason}`,
390
+ additional_kwargs: { [BEFORE_VETO_KEY]: veto.reason },
391
+ });
392
+ }
393
+ pendingBeforeDone.set(sessionId, { ...beforeDone, [workflowState]: true });
394
+ }
395
+ // Narrowed rather than forwarded blind: this middleware is innermost, so the
396
+ // agent node blames it for whatever the handler returned.
397
+ const call = async () => asModelCallResult(await handler(request), `state '${workflowState}'`);
398
+ // `budget.timeoutMs`: the call races a timer. On expiry an empty marker message
399
+ // stands in for the answer so `afterModel` can route through `on_error`; the
400
+ // in-flight request itself is not cancelled (the framework exposes no per-call signal).
401
+ const timeoutMs = machine.spec.states[workflowState]?.budget?.timeoutMs;
402
+ if (timeoutMs == null)
403
+ return call();
404
+ let timer;
405
+ const expiry = new Promise((resolve) => {
406
+ timer = setTimeout(() => resolve(new AIMessage({
407
+ content: "",
408
+ id: `budget_${uuidv4()}`,
409
+ additional_kwargs: {
410
+ [BUDGET_EXHAUSTED_KEY]: `state '${workflowState}' exceeded its time budget (timeoutMs: ${timeoutMs})`,
411
+ },
412
+ })), timeoutMs);
413
+ });
414
+ try {
415
+ return await Promise.race([call(), expiry]);
416
+ }
417
+ finally {
418
+ if (timer)
419
+ clearTimeout(timer);
420
+ }
421
+ }
422
+ async function wrapToolCall(request, handler) {
423
+ const called = request.toolCall?.name ?? "";
424
+ const sessionId = ctx.sessionIdOf(request.runtime);
425
+ const workflowState = currentWorkflowState(request.state, machine.entry);
426
+ const callId = request.toolCall?.id || `tool-${++generatedCallSeq}`;
427
+ const toolCallId = request.toolCall?.id ?? "";
428
+ // A bare action name of a namespaced id resolves to its target; the rest is
429
+ // refused as unknown, a different mistake from a governance denial. The control
430
+ // tools never reach the tool node, so they are registered by definition.
431
+ const registeredNames = modelContexts.get(sessionId)?.toolNames;
432
+ const resolved = request.tool !== undefined || registeredNames === undefined || called === ADVANCE_TOOL
433
+ ? called
434
+ : resolveToolName(called, registeredNames);
435
+ if (resolved === undefined) {
436
+ return new ToolMessage({
437
+ content: unknownToolMessage(called, registeredNames ?? []),
438
+ tool_call_id: toolCallId,
439
+ name: called,
440
+ status: "error",
441
+ });
442
+ }
443
+ const toolName = resolved;
444
+ if (toolName !== called) {
445
+ request = { ...request, toolCall: { ...request.toolCall, name: toolName } };
446
+ }
447
+ const call = { sessionId, workflowState, toolName, callId, toolCallId };
448
+ const block = (reason, args) => {
449
+ emit({ type: "tool-blocked", state: workflowState, tool: toolName, reason, callId, args });
450
+ return blockedMessage(toolName, toolCallId, reason);
451
+ };
452
+ // Variable substitution is the FIRST stage, ahead of the kernel, so a guard and
453
+ // an argument referencing the same variable agree by construction. Delegation
454
+ // tools are exempt: their params go through `resolveParams`.
455
+ const variables = readVariables(request.state);
456
+ let args = (request.toolCall?.args ?? {});
457
+ if (!isWorkflowToolName(toolName)) {
458
+ const substituted = resolveArguments(args, variables);
459
+ if (!substituted.ok)
460
+ return block(unresolvedArgumentMessage(substituted), args);
461
+ args = substituted.args;
462
+ request = { ...request, toolCall: { ...request.toolCall, args } };
463
+ }
464
+ const verdict = decide(machine, {
465
+ kind: "tool-call",
466
+ state: workflowState,
467
+ tool: toolName,
468
+ args,
469
+ // A reply-only turn is handed no tools, so a call here was invented from transcript context.
470
+ ...(isReplyOnly(request.state) ? { replyOnly: true } : {}),
471
+ }, policyRules, mountPrefixes, variables, skillTable);
472
+ if (verdict.decision === "block") {
473
+ const message = verdict.reason ?? "";
474
+ if (verdict.warn) {
475
+ emit({ type: "tool-blocked", state: workflowState, tool: toolName, reason: message, callId, args });
476
+ }
477
+ const blocked = blockedMessage(toolName, toolCallId, message);
478
+ // A terminal verdict (an unevaluable guard) cannot be corrected by the agent:
479
+ // committed as `rejected`, so the run routes through `on_error` rather than looping.
480
+ if (verdict.terminal)
481
+ return new Command({ update: { rejected: message, messages: [blocked] } });
482
+ return blocked;
483
+ }
484
+ if (subWorkflows && isWorkflowToolName(toolName)) {
485
+ return service.serviceDelegation(request, subWorkflows, call, args);
486
+ }
487
+ const serviced = await service.serviceControlTool(request, call, args);
488
+ if (serviced)
489
+ return serviced;
490
+ // Governed call telemetry. A rubric dispatch is *not* bracketed here: only
491
+ // the runtime reaches `task`, through the bridge, which emits its own
492
+ // `rubric-start`/`rubric-result` pair — an agent-initiated call never gets
493
+ // this far, because the kernel refuses it.
494
+ service.emitToolCalled(workflowState, toolName, callId, args);
495
+ const startedAt = Date.now();
496
+ const settle = (status, preview) => {
497
+ const durationMs = Date.now() - startedAt;
498
+ emit({ type: "tool-result", state: workflowState, tool: toolName, callId, status, durationMs, ...preview });
499
+ };
500
+ try {
501
+ const result = redactListings(await handler(request), workflowState, toolName);
502
+ const failed = result instanceof ToolMessage && result.status === "error";
503
+ settle(failed ? "error" : "ok", toolOutputPreview(result));
504
+ const steps = service.dispatchSteps(sessionId, workflowState);
505
+ // A delegation the tool body ran itself (no dispatcher wired): recorded from its result.
506
+ if (steps.length === 0 && isWorkflowToolName(toolName) && result instanceof ToolMessage) {
507
+ steps.push({
508
+ to: workflowState,
509
+ kind: "sub-workflow",
510
+ workflow: workflowSlugFromToolName(toolName),
511
+ status: failed ? "error" : "ok",
512
+ ...(failed ? { reason: String(result.content).slice(0, 500) } : {}),
513
+ ts: Date.now(),
514
+ });
515
+ }
516
+ return result instanceof ToolMessage ? service.withDispatchSteps(result, steps) : result;
517
+ }
518
+ catch (err) {
519
+ settle("error", toolOutputPreview(err?.message ?? String(err)));
520
+ throw err;
521
+ }
522
+ }
523
+ return {
524
+ wrapModelCall,
525
+ wrapToolCall,
526
+ lifecycleCtx,
527
+ reportMove: service.reportMove,
528
+ endTurn(sessionId) {
529
+ const staged = pendingBeforeDone.get(sessionId);
530
+ modelContexts.delete(sessionId);
531
+ pendingBeforeDone.delete(sessionId);
532
+ service.releaseSession(sessionId);
533
+ return staged;
534
+ },
535
+ release(sessionId) {
536
+ const scopes = [
537
+ ...releaseScopes(modelContexts, sessionId),
538
+ ...releaseScopes(pendingBeforeDone, sessionId),
539
+ ];
540
+ for (const scope of new Set([...scopes, sessionId]))
541
+ service.releaseSession(scope);
542
+ return scopes;
543
+ },
544
+ };
545
+ }
546
+ //# sourceMappingURL=governance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/workflow/governance.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAK/C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,aAAa,EACb,iBAAiB,GAElB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAuB,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,aAAa,EAAsB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC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