@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,108 @@
1
+ import { SESSION_INTERNAL_DIRS, SESSION_OFFLOAD_DIRS, SESSION_OPEN_DIR, SESSION_AGNOSTIC_PREFIX, } from "../core/zones.js";
2
+ /** Default workflow slug when none is supplied. */
3
+ export const DEFAULT_WORKFLOW = "order-lookup";
4
+ /**
5
+ * Where a workspace may override the platform system prompt. Nothing needs to be
6
+ * served there: the runtime ships the default prompt in its code.
7
+ */
8
+ export const PLATFORM_PROMPT_PATH = ".platform/system/GRAPH_STATE.md";
9
+ export { PLATFORM_PROMPT_PATH as PLATFORM_BACKEND_PROMPT_PATH };
10
+ /** Workspace-relative paths for a named workflow (the read-only authored zone). */
11
+ export function workflowPaths(workflow) {
12
+ const base = `workflows/${workflow}`;
13
+ return {
14
+ platformPrompt: PLATFORM_PROMPT_PATH,
15
+ agentsPrompt: "AGENTS.md",
16
+ /** The machine spec: a pure YAML mapping. */
17
+ workflowYaml: `${base}/workflow.yaml`,
18
+ /** Optional prose addendum, appended after the spec-rendered prompt section. Never a machine source. */
19
+ workflow: `${base}/WORKFLOW.md`,
20
+ testsDir: `${base}/tests`,
21
+ /** Lifecycle hook scripts: the runtime's code, which the agent can neither read nor execute. */
22
+ hooksDir: `${base}/hooks`,
23
+ };
24
+ }
25
+ /** Where a hook script must live, relative to its workflow directory. */
26
+ export const HOOKS_DIR = "hooks";
27
+ /**
28
+ * Resolve a hook's declared `script:` to an authoring-backend path. A hook path
29
+ * is workflow-relative and confined to the workflow's own `hooks/`; anything
30
+ * leaving it is refused with a reason. This keeps the two script classes
31
+ * disjoint: a hook can never be an `archmax_run` target.
32
+ */
33
+ export function resolveHookScript(workflow, declared) {
34
+ const raw = declared.trim();
35
+ if (raw === "")
36
+ return { ok: false, reason: "hook script path is empty" };
37
+ if (raw.startsWith("/")) {
38
+ return {
39
+ ok: false,
40
+ reason: `hook script '${declared}' is an absolute path; a hook script path is relative to its ` +
41
+ `workflow directory (e.g. '${HOOKS_DIR}/check.js')`,
42
+ };
43
+ }
44
+ const segments = [];
45
+ for (const segment of raw.split("/")) {
46
+ if (segment === "" || segment === ".")
47
+ continue;
48
+ // A `..` climb that leaves `hooks/` is caught by the prefix check below.
49
+ if (segment === "..")
50
+ segments.pop();
51
+ else
52
+ segments.push(segment);
53
+ }
54
+ const rel = segments.join("/");
55
+ if (rel !== HOOKS_DIR && !rel.startsWith(`${HOOKS_DIR}/`)) {
56
+ return {
57
+ ok: false,
58
+ reason: `hook script '${declared}' resolves outside '${HOOKS_DIR}/'; hook scripts live in ` +
59
+ `'workflows/${workflow}/${HOOKS_DIR}/' and are wired workflow-relative ` +
60
+ `(e.g. '${HOOKS_DIR}/check.js').`,
61
+ };
62
+ }
63
+ if (rel === HOOKS_DIR) {
64
+ return { ok: false, reason: `hook script '${declared}' names the '${HOOKS_DIR}/' directory, not a file` };
65
+ }
66
+ return { ok: true, path: `workflows/${workflow}/${rel}` };
67
+ }
68
+ /**
69
+ * The runtime-internal layout of one session's folder. These paths carry the
70
+ * session id explicitly (`<sessionId>/…`) because internal writers run both
71
+ * inside and outside a bound turn; the agent addresses the same folders id-free.
72
+ */
73
+ export function sessionPaths(sessionId) {
74
+ const base = sessionId;
75
+ return {
76
+ base,
77
+ /** Durable checkpoint and pending-write records, one immutable file each. */
78
+ checkpointsDir: `${base}/${SESSION_INTERNAL_DIRS[0]}`,
79
+ artifactsDir: `${base}/${SESSION_INTERNAL_DIRS[1]}`,
80
+ /** The run's working area (`scratchpad/…` to the agent). Durable; nothing cleans it up. */
81
+ scratchpadDir: `${base}/${SESSION_OPEN_DIR}`,
82
+ /** Deep Agents' context-offload areas: agent-readable, never agent-writable. */
83
+ largeToolResultsDir: `${base}/${SESSION_OFFLOAD_DIRS[0]}`,
84
+ conversationHistoryDir: `${base}/${SESSION_OFFLOAD_DIRS[1]}`,
85
+ };
86
+ }
87
+ /** Paths of a session's observability artifacts under `<sessionId>/artifacts/`. */
88
+ export function runArtifactPaths(sessionId) {
89
+ const runDir = sessionPaths(sessionId).artifactsDir;
90
+ return {
91
+ runDir,
92
+ graphJson: `${runDir}/graph.json`,
93
+ graphMermaid: `${runDir}/graph.mmd`,
94
+ trajectoryJson: `${runDir}/trajectory.json`,
95
+ metadataJson: `${runDir}/metadata.json`,
96
+ trailJson: `${runDir}/trail.json`,
97
+ variablesJson: `${runDir}/variables.json`,
98
+ };
99
+ }
100
+ /**
101
+ * Path of a content-addressed spec snapshot, keyed by `specHash`. Lives under
102
+ * the session-agnostic `_specs/` prefix so every session sharing a spec version
103
+ * shares one file; the run-zone router passes this prefix through unprefixed.
104
+ */
105
+ export function specSnapshotPath(hash) {
106
+ return `${SESSION_AGNOSTIC_PREFIX}/${hash}.json`;
107
+ }
108
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/workflow/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,G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AE,GAAG,IAAI,IAAI,oBAAoB,CAAC,CAAC,CAAC,EAAE;KAC7D,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC;IACpD,OAAO;QACL,MAAM;QACN,SAAS,EAAE,GAAG,MAAM,aAAa;QACjC,YAAY,EAAE,GAAG,MAAM,YAAY;QACnC,cAAc,EAAE,GAAG,MAAM,kBAAkB;QAC3C,YAAY,EAAE,GAAG,MAAM,gBAAgB;QACvC,SAAS,EAAE,GAAG,MAAM,aAAa;QACjC,aAAa,EAAE,GAAG,MAAM,iBAAiB;KAC1C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,GAAG,uBAAuB,IAAI,IAAI,OAAO,CAAC;AACnD,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Provider prompt caching for the stable prompt prefix (tool schemas and the
3
+ * static system prompt, re-sent on every model call of a turn).
4
+ *
5
+ * LangChain owns the provider mechanics where it has them: a native
6
+ * `ChatAnthropic` or `ChatBedrockConverse` gets LangChain's own caching
7
+ * middleware. The one case with no built-in is the default — Claude reached
8
+ * through an OpenAI-compatible endpoint — where the workflow middleware places
9
+ * an explicit `cache_control` breakpoint on the static system block. Anything
10
+ * else is a no-op (OpenAI and Gemini cache prefixes automatically).
11
+ */
12
+ import { type AgentMiddleware } from "langchain";
13
+ export declare const CACHE_TTLS: readonly ["5m", "1h"];
14
+ export type CacheTtl = (typeof CACHE_TTLS)[number];
15
+ export declare const DEFAULT_CACHE_TTL: CacheTtl;
16
+ export declare function isCacheTtl(value: unknown): value is CacheTtl;
17
+ /**
18
+ * How caching is applied: `anthropic-native` / `bedrock-native` via LangChain's
19
+ * middlewares; `anthropic-compat` via an explicit marker on the static system
20
+ * block; `unsupported` when requested for a model with no known mechanism; `off`.
21
+ */
22
+ export type PromptCacheStrategy = "anthropic-native" | "bedrock-native" | "anthropic-compat" | "off" | "unsupported";
23
+ /**
24
+ * The strategies LangChain implements as graph-level provider middleware. They
25
+ * cannot vary per model call, which is why a state whose model wants a different
26
+ * one is reported at assembly rather than silently mis-cached.
27
+ */
28
+ export declare const NATIVE_CACHE_STRATEGIES: ReadonlySet<PromptCacheStrategy>;
29
+ export interface PromptCacheConfig {
30
+ enabled: boolean;
31
+ ttl: CacheTtl;
32
+ }
33
+ export interface PromptCacheOptions {
34
+ enabled?: boolean;
35
+ ttl?: string;
36
+ }
37
+ /** A `cache_control` marker as Anthropic and its gateways accept it. */
38
+ export interface CacheControlMarker {
39
+ type: "ephemeral";
40
+ ttl: CacheTtl;
41
+ }
42
+ export declare function cacheControl(ttl: CacheTtl): CacheControlMarker;
43
+ /** The provider's model id, however the client exposes it. */
44
+ export declare function modelIdOf(model: unknown): string;
45
+ /**
46
+ * Pick the mechanism for `model`, with the same client/provider tests LangChain's
47
+ * middlewares apply, so a `*-native` strategy is exactly one that middleware acts on.
48
+ */
49
+ export declare function resolveCacheStrategy(model: unknown, enabled: boolean): PromptCacheStrategy;
50
+ /**
51
+ * The LangChain provider middleware for `strategy`, or `null` when none is
52
+ * needed. `minMessagesToCache: 1` because the prefix is large from the first
53
+ * call; `unsupportedModelBehavior: "ignore"` because the strategy was already
54
+ * reported through `onEvent`.
55
+ */
56
+ export declare function createProviderCacheMiddleware(strategy: PromptCacheStrategy, ttl: CacheTtl): AgentMiddleware | null;
57
+ /** The assembly-time diagnostic for an unsupported model. */
58
+ export declare function unsupportedCacheMessage(model: unknown): string;
59
+ /** Precedence host option → workflow spec → env → default (on, 5m). A bad `ttl` falls back rather than failing a run. */
60
+ export declare function resolvePromptCacheConfig(sources: {
61
+ option?: PromptCacheOptions | undefined;
62
+ spec?: {
63
+ enabled?: boolean;
64
+ ttl?: string;
65
+ } | undefined;
66
+ env?: {
67
+ enabled?: boolean;
68
+ ttl?: string;
69
+ } | undefined;
70
+ }): PromptCacheConfig;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Provider prompt caching for the stable prompt prefix (tool schemas and the
3
+ * static system prompt, re-sent on every model call of a turn).
4
+ *
5
+ * LangChain owns the provider mechanics where it has them: a native
6
+ * `ChatAnthropic` or `ChatBedrockConverse` gets LangChain's own caching
7
+ * middleware. The one case with no built-in is the default — Claude reached
8
+ * through an OpenAI-compatible endpoint — where the workflow middleware places
9
+ * an explicit `cache_control` breakpoint on the static system block. Anything
10
+ * else is a no-op (OpenAI and Gemini cache prefixes automatically).
11
+ */
12
+ import { anthropicPromptCachingMiddleware, bedrockPromptCachingMiddleware, } from "langchain";
13
+ export const CACHE_TTLS = ["5m", "1h"];
14
+ export const DEFAULT_CACHE_TTL = "5m";
15
+ export function isCacheTtl(value) {
16
+ return typeof value === "string" && CACHE_TTLS.includes(value);
17
+ }
18
+ /**
19
+ * The strategies LangChain implements as graph-level provider middleware. They
20
+ * cannot vary per model call, which is why a state whose model wants a different
21
+ * one is reported at assembly rather than silently mis-cached.
22
+ */
23
+ export const NATIVE_CACHE_STRATEGIES = new Set([
24
+ "anthropic-native",
25
+ "bedrock-native",
26
+ ]);
27
+ export function cacheControl(ttl) {
28
+ return { type: "ephemeral", ttl };
29
+ }
30
+ function modelName(model) {
31
+ const named = model;
32
+ try {
33
+ return typeof named?.getName === "function" ? named.getName() : "";
34
+ }
35
+ catch {
36
+ return "";
37
+ }
38
+ }
39
+ /** The provider's model id, however the client exposes it. */
40
+ export function modelIdOf(model) {
41
+ const candidate = model;
42
+ for (const value of [candidate?.model, candidate?.modelName, candidate?._defaultConfig?.model]) {
43
+ if (typeof value === "string" && value.trim())
44
+ return value;
45
+ }
46
+ return "";
47
+ }
48
+ const ANTHROPIC_MODEL_ID = /claude|anthropic/i;
49
+ /** Bedrock caches only these model families (mirrors LangChain's own check). */
50
+ const BEDROCK_CACHEABLE_ID = /anthropic\.claude|amazon\.nova/i;
51
+ /**
52
+ * Pick the mechanism for `model`, with the same client/provider tests LangChain's
53
+ * middlewares apply, so a `*-native` strategy is exactly one that middleware acts on.
54
+ */
55
+ export function resolveCacheStrategy(model, enabled) {
56
+ if (!enabled || !model)
57
+ return "off";
58
+ const name = modelName(model);
59
+ const provider = model?._defaultConfig
60
+ ?.modelProvider;
61
+ const id = modelIdOf(model);
62
+ if (name === "ChatAnthropic" || (name === "ConfigurableModel" && provider === "anthropic")) {
63
+ return "anthropic-native";
64
+ }
65
+ const isBedrock = name === "ChatBedrockConverse" ||
66
+ (name === "ConfigurableModel" && (provider === "bedrock" || provider === "aws"));
67
+ if (isBedrock)
68
+ return BEDROCK_CACHEABLE_ID.test(id) ? "bedrock-native" : "unsupported";
69
+ if (ANTHROPIC_MODEL_ID.test(id) || ANTHROPIC_MODEL_ID.test(name))
70
+ return "anthropic-compat";
71
+ return "unsupported";
72
+ }
73
+ /**
74
+ * The LangChain provider middleware for `strategy`, or `null` when none is
75
+ * needed. `minMessagesToCache: 1` because the prefix is large from the first
76
+ * call; `unsupportedModelBehavior: "ignore"` because the strategy was already
77
+ * reported through `onEvent`.
78
+ */
79
+ export function createProviderCacheMiddleware(strategy, ttl) {
80
+ const options = { ttl, minMessagesToCache: 1, unsupportedModelBehavior: "ignore" };
81
+ if (strategy === "anthropic-native") {
82
+ return anthropicPromptCachingMiddleware(options);
83
+ }
84
+ if (strategy === "bedrock-native") {
85
+ return bedrockPromptCachingMiddleware(options);
86
+ }
87
+ return null;
88
+ }
89
+ /** The assembly-time diagnostic for an unsupported model. */
90
+ export function unsupportedCacheMessage(model) {
91
+ const id = modelIdOf(model) || modelName(model) || "the configured model";
92
+ return (`prompt caching is inactive for '${id}': no cache-breakpoint mechanism is known for it ` +
93
+ `(supported: Anthropic natively or over an OpenAI-compatible endpoint, and Bedrock Converse ` +
94
+ `Claude/Nova). Providers with automatic prefix caching still benefit from the stable prefix.`);
95
+ }
96
+ /** Precedence host option → workflow spec → env → default (on, 5m). A bad `ttl` falls back rather than failing a run. */
97
+ export function resolvePromptCacheConfig(sources) {
98
+ const { option, spec, env } = sources;
99
+ const enabled = option?.enabled ?? spec?.enabled ?? env?.enabled ?? true;
100
+ const ttlCandidate = option?.ttl ?? spec?.ttl ?? env?.ttl;
101
+ return { enabled, ttl: isCacheTtl(ttlCandidate) ? ttlCandidate : DEFAULT_CACHE_TTL };
102
+ }
103
+ //# sourceMappingURL=prompt-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-cache.js","sourceRoot":"","sources":["../../src/workflow/prompt-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,gCAAgC,EAChC,8BAA8B,GAE/B,MAAM,WAAW,CAAC;AAEnB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAGhD,MAAM,CAAC,MAAM,iBAAiB,GAAa,IAAI,CAAC;AAEhD,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,UAAgC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxF,CAAC;AAcD;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAqC,IAAI,GAAG,CAAC;IAC/E,kBAAkB;IAClB,gBAAgB;CACjB,CAAC,CAAC;AAkBH,MAAM,UAAU,YAAY,CAAC,GAAa;IACxC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;AACpC,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,MAAM,KAAK,GAAG,KAAmC,CAAC;IAClD,IAAI,CAAC;QACH,OAAO,OAAO,KAAK,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,8DAA8D;AAC9D,MAAM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0,0 +1,20 @@
1
+ /**
2
+ * Pruning of upstream Deep Agents prompt guidance for built-in tools an
3
+ * assembly withholds: guidance for a tool the model cannot call only teaches it
4
+ * to try.
5
+ */
6
+ /** The upstream headings that document `tool`'s guidance (empty when unknown). */
7
+ export declare function upstreamSectionsFor(tool: string): readonly string[];
8
+ export interface PruneResult {
9
+ /** The prompt text with matched sections removed. */
10
+ text: string;
11
+ /** Headings that were found and removed. */
12
+ removed: string[];
13
+ /**
14
+ * Tools whose guidance was found nowhere. A partial match is a successful
15
+ * prune (upstream may carry only some of a tool's sections).
16
+ */
17
+ missingTools?: string[];
18
+ }
19
+ /** Prune the upstream guidance for every tool in `undisclosed`; tools with no known sections are ignored. */
20
+ export declare function pruneUndisclosedToolSections(text: string, undisclosed: readonly string[]): PruneResult;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Pruning of upstream Deep Agents prompt guidance for built-in tools an
3
+ * assembly withholds: guidance for a tool the model cannot call only teaches it
4
+ * to try.
5
+ */
6
+ /**
7
+ * Upstream section headings owned by a built-in tool's guidance.
8
+ *
9
+ * `task`'s guidance is two sections, and both must be named: the spawner
10
+ * overview carries the bulk of it, and the notes section follows. A partial
11
+ * match counts as a successful prune, so listing only one of them silently ships
12
+ * the other.
13
+ */
14
+ const SECTIONS_BY_TOOL = {
15
+ task: ["## `task` (subagent spawner)", "## Important Task Tool Usage Notes to Remember"],
16
+ };
17
+ /** The upstream headings that document `tool`'s guidance (empty when unknown). */
18
+ export function upstreamSectionsFor(tool) {
19
+ return SECTIONS_BY_TOOL[tool] ?? [];
20
+ }
21
+ /** A section spans its heading line to the next heading of the same or higher level. */
22
+ function sectionEnd(lines, start, level) {
23
+ for (let i = start + 1; i < lines.length; i++) {
24
+ const match = /^(#{1,6})\s/.exec(lines[i]);
25
+ if (match && match[1].length <= level)
26
+ return i;
27
+ }
28
+ return lines.length;
29
+ }
30
+ function headingLevel(heading) {
31
+ return /^(#{1,6})\s/.exec(heading)?.[1].length ?? 2;
32
+ }
33
+ /**
34
+ * Put a target heading on its own line when composition glued it to the end of
35
+ * the previous one.
36
+ *
37
+ * Upstream concatenates its prompt fragments without a separating newline, so a
38
+ * section can arrive as `…within files## \`task\` (subagent spawner)`. Matching is
39
+ * line-anchored (a `##` mid-sentence is prose, not a heading), so without this
40
+ * the section is silently kept and billed on every call. Narrow by construction:
41
+ * only a heading we were asked to remove is ever split out.
42
+ */
43
+ function unglueHeadings(text, headings) {
44
+ let out = text;
45
+ for (const heading of headings) {
46
+ let at = out.indexOf(heading);
47
+ while (at > 0) {
48
+ if (out[at - 1] !== "\n") {
49
+ out = `${out.slice(0, at)}\n${out.slice(at)}`;
50
+ at += 1;
51
+ }
52
+ at = out.indexOf(heading, at + heading.length);
53
+ }
54
+ }
55
+ return out;
56
+ }
57
+ /** Remove each heading's section. Matching is exact on the trimmed heading line. */
58
+ function pruneSections(text, headings) {
59
+ if (!text || headings.length === 0)
60
+ return { text, removed: [] };
61
+ const removed = [];
62
+ let lines = unglueHeadings(text, headings).split("\n");
63
+ for (const heading of headings) {
64
+ const index = lines.findIndex((line) => line.trim() === heading);
65
+ if (index === -1)
66
+ continue;
67
+ const end = sectionEnd(lines, index, headingLevel(heading));
68
+ lines = [...lines.slice(0, index), ...lines.slice(end)];
69
+ removed.push(heading);
70
+ }
71
+ // Collapse the blank runs left behind so the result is byte-stable however many sections were cut.
72
+ return { text: lines.join("\n").replace(/\n{3,}/g, "\n\n").trim(), removed };
73
+ }
74
+ /** Prune the upstream guidance for every tool in `undisclosed`; tools with no known sections are ignored. */
75
+ export function pruneUndisclosedToolSections(text, undisclosed) {
76
+ const result = pruneSections(text, undisclosed.flatMap((tool) => [...upstreamSectionsFor(tool)]));
77
+ const missingTools = undisclosed.filter((tool) => {
78
+ const owned = upstreamSectionsFor(tool);
79
+ return owned.length > 0 && !owned.some((heading) => result.removed.includes(heading));
80
+ });
81
+ return { ...result, ...(missingTools.length > 0 ? { missingTools } : {}) };
82
+ }
83
+ //# sourceMappingURL=pr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AK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC;AAC/E,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,4BAA4B,CAC1C,IAAY,EACZ,WAA8B;IAE9B,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAClG,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/C,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACxC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Deterministic rendering of the two spec-derived prompt sections, both pure
3
+ * functions of the machine, so what the agent reads cannot drift from what the
4
+ * runtime enforces.
5
+ *
6
+ * The graph is disclosed the way the tool surface is — only from where the agent
7
+ * stands — which puts the two halves on opposite sides of the cache boundary:
8
+ *
9
+ * - {@link renderWorkflowPrompt} is the **cacheable** half: the workflow's
10
+ * `title` and root `instructions`, and no state of the graph. It is a
11
+ * function of the header alone, so the prefix does not grow with the state
12
+ * count. Authored `WORKFLOW.md` prose is appended after it by the caller.
13
+ * - {@link renderStateGraph} is the **volatile** half, re-rendered per model
14
+ * call for the state in force: its outgoing edges, its own markers and hooks,
15
+ * and the run's trigger signature.
16
+ *
17
+ * No other state's slug, `title`, `summary`, hooks, budget or transitions is
18
+ * rendered anywhere, and neither is a count of the states: a state the agent
19
+ * cannot advance to is a state it cannot name. A state's `instructions` body is
20
+ * surfaced only for the active state, by the caller.
21
+ */
22
+ import type { WorkflowMachine } from "../machine/machine.js";
23
+ /** What {@link renderStateGraph} needs about the run, beyond the state it is in. */
24
+ export interface StateGraphContext {
25
+ /** The id of the trigger this session was started by, when one is recorded. */
26
+ trigger?: string;
27
+ }
28
+ /**
29
+ * The active state's half of the graph: its hooks, the run's trigger signature,
30
+ * and either its outgoing edges or the statement that it has none.
31
+ *
32
+ * Terminality is stated rather than left to be inferred from an absent list —
33
+ * the old whole-graph section taught "a state listed with no transitions is
34
+ * terminal", and with the listing gone there is nothing to read that from.
35
+ * Returns `null` when the state discloses nothing at all.
36
+ */
37
+ export declare function renderStateGraph(machine: WorkflowMachine, state: string, ctx?: StateGraphContext): string | null;
38
+ /**
39
+ * The cacheable half: the workflow's `title` and its root `instructions`. No
40
+ * state is named — see the module docstring for why, and
41
+ * {@link renderStateGraph} for what the agent is told instead.
42
+ */
43
+ export declare function renderWorkflowPrompt(machine: WorkflowMachine): string;
44
+ /** Strip HTML comments from authored prose; the model would be charged for them on every call. */
45
+ export declare function stripHtmlComments(text: string): string;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Deterministic rendering of the two spec-derived prompt sections, both pure
3
+ * functions of the machine, so what the agent reads cannot drift from what the
4
+ * runtime enforces.
5
+ *
6
+ * The graph is disclosed the way the tool surface is — only from where the agent
7
+ * stands — which puts the two halves on opposite sides of the cache boundary:
8
+ *
9
+ * - {@link renderWorkflowPrompt} is the **cacheable** half: the workflow's
10
+ * `title` and root `instructions`, and no state of the graph. It is a
11
+ * function of the header alone, so the prefix does not grow with the state
12
+ * count. Authored `WORKFLOW.md` prose is appended after it by the caller.
13
+ * - {@link renderStateGraph} is the **volatile** half, re-rendered per model
14
+ * call for the state in force: its outgoing edges, its own markers and hooks,
15
+ * and the run's trigger signature.
16
+ *
17
+ * No other state's slug, `title`, `summary`, hooks, budget or transitions is
18
+ * rendered anywhere, and neither is a count of the states: a state the agent
19
+ * cannot advance to is a state it cannot name. A state's `instructions` body is
20
+ * surfaced only for the active state, by the caller.
21
+ */
22
+ import { afterHookLabel, hookKind, normalizeHooks } from "../lifecycle/hook-shape.js";
23
+ import { ADVANCE_TOOL, SET_VARIABLES_TOOL } from "../machine/tool-names.js";
24
+ /**
25
+ * One outgoing edge: the target's slug (the exact token `archmax_advance` takes),
26
+ * its declared `type`, and the required `description` the agent routes on.
27
+ *
28
+ * The two markers a target may carry are disclosed because each changes what the
29
+ * call must carry or what follows it — `evidence` is accepted only when the
30
+ * target is a human state, and both markers mean *stop* rather than *continue*.
31
+ * They disclose the **consequence of taking the edge**, not the state on the
32
+ * other side of it: nothing of the target's own title, summary, instructions,
33
+ * hooks or transitions is rendered.
34
+ */
35
+ function renderTransition(machine, edge) {
36
+ const notes = [];
37
+ if (edge.type && edge.type !== "none")
38
+ notes.push(edge.type);
39
+ if (machine.isHumanState(edge.to))
40
+ notes.push("human decision node");
41
+ if (machine.isTerminal(edge.to))
42
+ notes.push("terminal");
43
+ const suffix = notes.length ? ` (${notes.join(", ")})` : "";
44
+ return `- to \`${edge.to}\`${suffix} — ${edge.description.trim()}`;
45
+ }
46
+ /**
47
+ * The active state's hooks, by phase. A **rubric** hook renders as its bare kind
48
+ * — never the rubric's name, and never any of its declaration.
49
+ *
50
+ * Presence is disclosed because it is actionable: a graded exit can come back
51
+ * with a correction the agent must act on. Identity is withheld because it is
52
+ * not: no disclosed tool takes a rubric name, and the name is a handle into
53
+ * content the agent may not read. Nothing here can reach the criteria, the
54
+ * budget or the model — they live in a block this renderer never reads.
55
+ */
56
+ function renderHooks(state) {
57
+ const parts = [];
58
+ for (const phase of ["before", "after"]) {
59
+ const hooks = normalizeHooks(state[phase]);
60
+ if (hooks.length === 0)
61
+ continue;
62
+ const labels = hooks.map((hook, index) => hookKind(hook) === "rubric" ? "rubric" : afterHookLabel(hook, index));
63
+ parts.push(`${phase}: ${labels.join(", ")}`);
64
+ }
65
+ return parts.length ? parts.join("; ") : null;
66
+ }
67
+ /**
68
+ * The signature of the trigger this run was started by — and only that one. The
69
+ * triggers of states this run did not enter are not disclosed, and the id needs
70
+ * no label: there is one trigger and it is this run's.
71
+ */
72
+ function renderSignature(machine, trigger) {
73
+ if (!trigger)
74
+ return [];
75
+ const lines = [];
76
+ const requires = machine.requiresForTrigger(trigger) ?? [];
77
+ const returns = machine.returnsForTrigger(trigger) ?? [];
78
+ if (requires.length > 0) {
79
+ lines.push(`This run was started with: ${requires.join(", ")}.`);
80
+ }
81
+ if (returns.length > 0) {
82
+ lines.push(`This run must set ${returns.join(", ")} with \`${SET_VARIABLES_TOOL}\` — it does not ` +
83
+ `complete until every one is set.`);
84
+ }
85
+ return lines;
86
+ }
87
+ /**
88
+ * The active state's half of the graph: its hooks, the run's trigger signature,
89
+ * and either its outgoing edges or the statement that it has none.
90
+ *
91
+ * Terminality is stated rather than left to be inferred from an absent list —
92
+ * the old whole-graph section taught "a state listed with no transitions is
93
+ * terminal", and with the listing gone there is nothing to read that from.
94
+ * Returns `null` when the state discloses nothing at all.
95
+ */
96
+ export function renderStateGraph(machine, state, ctx = {}) {
97
+ const declared = machine.spec.states[state];
98
+ if (!declared)
99
+ return null;
100
+ const sections = [];
101
+ const hooks = renderHooks(declared);
102
+ if (hooks)
103
+ sections.push(`Hooks: ${hooks}`);
104
+ sections.push(...renderSignature(machine, ctx.trigger));
105
+ const transitions = declared.transitions ?? [];
106
+ sections.push(transitions.length > 0
107
+ ? [
108
+ `Transitions — choose one with \`${ADVANCE_TOOL}\` when this state's work is done:`,
109
+ ...transitions.map((edge) => renderTransition(machine, edge)),
110
+ ].join("\n")
111
+ : `This state is terminal: no transition leads out of it. Finish its work and stop.`);
112
+ return sections.length > 0 ? sections.join("\n\n") : null;
113
+ }
114
+ /**
115
+ * The cacheable half: the workflow's `title` and its root `instructions`. No
116
+ * state is named — see the module docstring for why, and
117
+ * {@link renderStateGraph} for what the agent is told instead.
118
+ */
119
+ export function renderWorkflowPrompt(machine) {
120
+ const { spec } = machine;
121
+ const lines = [];
122
+ const title = spec.title?.trim();
123
+ lines.push(`# Workflow${title ? `: ${title}` : ""}`);
124
+ // Standing instructions apply to every turn, so they belong in the static, cacheable prefix.
125
+ if (spec.instructions?.trim()) {
126
+ lines.push("", "## Instructions", "", spec.instructions.trim());
127
+ }
128
+ return lines.join("\n");
129
+ }
130
+ /** Strip HTML comments from authored prose; the model would be charged for them on every call. */
131
+ export function stripHtmlComments(text) {
132
+ if (!text.includes("<!--"))
133
+ return text;
134
+ return text
135
+ .replace(/<!--[\s\S]*?-->/g, "")
136
+ .replace(/[ \t]+$/gm, "")
137
+ .replace(/\n{3,}/g, "\n\n")
138
+ .trim();
139
+ }
140
+ //# sourceMappingURL=render-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-prompt.js","sourceRoot":"","sources":["../../src/workflow/render-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG5E;;;;;;;;;;GAUG;AACH,SAAS,gBAAgB,CAAC,OAAwB,EAAE,IAAuB;IACzE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,qBA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,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { RunnableConfig } from "@langchain/core/runnables";
2
+ /** The runnable config a hook's or request's runtime stands for. */
3
+ export declare function buildRunnableConfig(runtime: {
4
+ configurable?: Record<string, unknown>;
5
+ signal?: AbortSignal;
6
+ store?: unknown;
7
+ }): RunnableConfig;
@@ -0,0 +1,9 @@
1
+ /** The runnable config a hook's or request's runtime stands for. */
2
+ export function buildRunnableConfig(runtime) {
3
+ return {
4
+ configurable: runtime?.configurable ?? {},
5
+ signal: runtime?.signal,
6
+ ...(runtime?.store !== undefined ? { store: runtime.store } : {}),
7
+ };
8
+ }
9
+ //# sourceMappingURL=runtime-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-config.js","sourceRoot":"","sources":["../../src/workflow/runtime-config.ts"],"names":[],"mappings":"AAEA,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CAAC,OAInC;IACC,OAAO;QACL,YAAY,EAAE,OAAO,EAAE,YAAY,IAAI,EAAE;QACzC,MAAM,EAAE,OAAO,EAAE,MAAM;QACvB,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAC;AACJ,CAAC"}