@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,186 @@
1
+ /**
2
+ * The `workflow.yaml` shape, as types.
3
+ *
4
+ * Every type here is inferred from `machine/spec-schema.ts` — the schema *is*
5
+ * the spec, and these aliases exist so call sites read as domain vocabulary
6
+ * (`MachineState`) rather than as `z.infer<typeof machineStateSchema>`.
7
+ */
8
+ import type { z } from "zod";
9
+ import type { allowEntrySchema, hookSchema, forbidEntrySchema, hookSpecSchema, machinePromptCacheSettingsSchema, machineSettingsSchema, machineSpecSchema, machineStateSchema, machineTransitionSchema, stateTypeSchema, runtimeMetadataSchema, skillsBlockSchema, mountsBlockSchema, mountAccessSchema, mountGrantEntrySchema, specExtensionsSchema, rubricDeclarationSchema, specMetadataSchema, stateBudgetSchema, toolsBlockSchema, transitionTypeSchema, triggerDeclarationSchema, workflowTestsConfigSchema, workflowSkillsConfigSchema, workflowMountsConfigSchema, workflowToolsConfigSchema } from "./spec-schema.js";
10
+ /**
11
+ * Semantic classification of an outgoing edge, primarily for **human states**: a
12
+ * UI can render `approve`/`reject`/`refine` as distinct decision buttons, and
13
+ * `none` (the default) is an ordinary route. A human state declares at most one
14
+ * transition of each labeled type. Metadata only on agent states.
15
+ */
16
+ export type TransitionType = z.infer<typeof transitionTypeSchema>;
17
+ /**
18
+ * One outgoing edge of a state. `description` is **required and non-empty**: the
19
+ * agent is disclosed the active state's edges and nothing else of the graph, so
20
+ * this is the whole of what it routes on — write it for a reader standing in the
21
+ * source state, which knows nothing of the target ("Refunds over $50", never "go
22
+ * to refund-review"). At a human state it is also the decision's button label.
23
+ */
24
+ export type MachineTransition = z.infer<typeof machineTransitionSchema>;
25
+ /**
26
+ * A single lifecycle hook: a tagged object whose single key names its **kind**
27
+ * (`script`, `rubric`, or a custom kind an executor is registered for) and
28
+ * whose value is the kind's target, optionally beside the reserved
29
+ * `max_iterations` sidecar (the bounded grade-and-retry budget of an `after`
30
+ * hook). A rubric's grading criteria are its `instructions` in the spec's
31
+ * `rubrics:` block, never a hook attribute.
32
+ */
33
+ export type Hook = z.infer<typeof hookSchema>;
34
+ /** A `before`/`after` field: one hook or an ordered list run in sequence. */
35
+ export type HookSpec = z.infer<typeof hookSpecSchema>;
36
+ /**
37
+ * Per-state execution budget. `maxTurns` bounds the model iterations of the
38
+ * turn's agent loop; `timeoutMs` aborts the turn when exceeded; `maxParks` bounds
39
+ * how many times the state may park itself with `archmax_wait`. Any exhaustion
40
+ * is a turn failure subject to `on_error`.
41
+ */
42
+ export type StateBudget = z.infer<typeof stateBudgetSchema>;
43
+ /** One entry of a `tools.allow` list: a bare tool name, or a constrained shape. */
44
+ export type AllowEntry = z.infer<typeof allowEntrySchema>;
45
+ /**
46
+ * Per-state tool governance. Allow-only: a state with `allow` permits exactly the
47
+ * listed tools/arg-shapes (plus workflow-level `allow_always` grants and the
48
+ * essential surface); a state without one gets the essential surface only.
49
+ */
50
+ export type ToolsBlock = z.infer<typeof toolsBlockSchema>;
51
+ /**
52
+ * A denial entry: the same grammar as {@link AllowEntry}, plus the tool `*`
53
+ * meaning every tool. Deny beats allow, and no narrower level widens a denial —
54
+ * so a wildcard is safe here and a document-level error in an `allow` list.
55
+ */
56
+ export type ForbidEntry = z.infer<typeof forbidEntrySchema>;
57
+ /**
58
+ * A **state's** skill governance by slug: what this state adds to the workflow's
59
+ * always-on grant. A skill is enabled only where a list names it — an absent
60
+ * block adds nothing, exactly as `allow: []` does, and exactly as an absent
61
+ * `tools.allow` grants no tool.
62
+ */
63
+ export type SkillsBlock = z.infer<typeof skillsBlockSchema>;
64
+ /**
65
+ * A **state's** mount governance by name: what this state adds to the
66
+ * workflow's always-on grant, and what it subtracts. A mount the host declared
67
+ * governed is enabled only where a list names it; an ungoverned mount is
68
+ * visible in every state and `forbid` is what takes it away.
69
+ */
70
+ /**
71
+ * How a state may use a mount it is given: `read` refuses writes there,
72
+ * `read_write` permits them where the host declared the mount writable. The
73
+ * host's posture is the ceiling — `read_write` cannot open a read-only mount —
74
+ * so this key's real work is narrowing a writable mount in the states that only
75
+ * read it.
76
+ */
77
+ export type MountAccess = z.infer<typeof mountAccessSchema>;
78
+ /**
79
+ * One entry of a mounts grant list: a bare mount name, taking the write posture
80
+ * the host declared, or `{ mount, access }` naming the access this level gives.
81
+ * Normalized to one shape by `normalizeMountGrants` (`machine/mount-grants.ts`).
82
+ */
83
+ export type MountGrantEntry = z.infer<typeof mountGrantEntrySchema>;
84
+ export type MountsBlock = z.infer<typeof mountsBlockSchema>;
85
+ /**
86
+ * The kind of a state: `agent` (default) runs a Deep Agent turn that picks a
87
+ * transition with `archmax_advance`; `human` parks the session and a person picks
88
+ * the outgoing edge.
89
+ */
90
+ export type StateType = z.infer<typeof stateTypeSchema>;
91
+ /**
92
+ * One state of the graph, keyed in {@link MachineSpec.states} by its **slug** —
93
+ * its sole identity. Every reference to a state (`to`, `on_error`, the `to` the
94
+ * agent passes to `archmax_advance`, events, artifacts, test assertions) is a
95
+ * slug.
96
+ *
97
+ * `model` names the model id this state's turns run on — an id only, resolved
98
+ * over the endpoint and credentials the assembly is already configured with. It
99
+ * is the most specific position of the chain state → {@link MachineSettings}
100
+ * `model` → the assembly's default, read once through `WorkflowMachine.modelFor`.
101
+ */
102
+ export type MachineState = z.infer<typeof machineStateSchema>;
103
+ /** Workflow-level tool grants. */
104
+ export type WorkflowToolsConfig = z.infer<typeof workflowToolsConfigSchema>;
105
+ /**
106
+ * Workflow-level skill governance: `allow_always` is enabled in every state and
107
+ * a state's `skills.allow` adds to it; `forbid_always` denies in every state and
108
+ * beats every grant. See {@link SkillsBlock} for the state's half.
109
+ */
110
+ export type WorkflowSkillsConfig = z.infer<typeof workflowSkillsConfigSchema>;
111
+ /**
112
+ * Workflow-level mount governance: `allow_always` enables its governed mounts
113
+ * in every state and a state's `mounts.allow` adds to it; `forbid_always`
114
+ * denies in every state, beats every grant, and binds every descendant session.
115
+ * See {@link MountsBlock} for the state's half.
116
+ */
117
+ export type WorkflowMountsConfig = z.infer<typeof workflowMountsConfigSchema>;
118
+ /** Workflow-declared provider prompt-cache settings. */
119
+ export type MachinePromptCacheSettings = z.infer<typeof machinePromptCacheSettingsSchema>;
120
+ /**
121
+ * Sandbox and prompt-cache knobs declared at the spec root, plus `model`: the
122
+ * model id every state of this workflow runs on unless the state names its own.
123
+ * An id only — the endpoint, credentials and sampling stay the assembly's
124
+ * configuration — and it overrides `ARCHMAX_MODEL`, not a host's explicit `model`.
125
+ */
126
+ export type MachineSettings = z.infer<typeof machineSettingsSchema>;
127
+ /** Offline-test suite configuration declared at the spec root. */
128
+ export type WorkflowTestsConfig = z.infer<typeof workflowTestsConfigSchema>;
129
+ /**
130
+ * Optional runtime contract declaration: the authoring/runtime semantics a
131
+ * workspace expects, independent of the installed npm version.
132
+ */
133
+ export type RuntimeMetadata = z.infer<typeof runtimeMetadataSchema>;
134
+ /**
135
+ * One trigger's declaration, under the `triggers:` of the state it enters: how
136
+ * its firings map to a session, and the run's signature. The state it sits on
137
+ * is its entry state and the key it sits under is its id, so neither is a key
138
+ * of the declaration.
139
+ */
140
+ export type TriggerDeclaration = z.infer<typeof triggerDeclarationSchema>;
141
+ /** Workspace-declared expectations the runtime cannot verify from the spec alone. */
142
+ export type SpecExtensions = z.infer<typeof specExtensionsSchema>;
143
+ /**
144
+ * Host data, accepted at three positions: the spec root (an authoring UI's canvas
145
+ * state), a state (a node's position), and a rubric (a display label). Preserved
146
+ * across a load, never read by the runtime, and dropped before the spec is
147
+ * hashed.
148
+ */
149
+ export type SpecMetadata = z.infer<typeof specMetadataSchema>;
150
+ /**
151
+ * One grading rubric: the standard a state's exit is measured against, declared
152
+ * in the same document as the state whose hook names it. `instructions` carries
153
+ * the criteria and the verdict to return; `max_iterations` bounds the
154
+ * grade-and-retry loop (a hook's own sidecar wins over it); `model` names the id
155
+ * the grader runs on. A rubric is authoring-plane content: the agent it grades
156
+ * can neither read it nor dispatch it.
157
+ */
158
+ export type RubricDeclaration = z.infer<typeof rubricDeclarationSchema>;
159
+ /** The whole of `workflow.yaml`. */
160
+ export type MachineSpec = z.infer<typeof machineSpecSchema>;
161
+ /** Runtime knobs derived from `settings`, consumed by the harness. */
162
+ export interface HarnessSettings {
163
+ timeoutMs: number;
164
+ memoryLimitBytes?: number;
165
+ maxPtcCalls?: number | null;
166
+ maxResultChars?: number;
167
+ /** Prompt-cache declaration, when present. */
168
+ promptCache?: {
169
+ enabled?: boolean;
170
+ ttl?: string;
171
+ };
172
+ }
173
+ export interface LifecycleHook {
174
+ /** Normalized ordered `before` hooks (single spec wrapped in a list). */
175
+ before?: Hook[];
176
+ /** Normalized ordered `after` hooks (single spec wrapped in a list). */
177
+ after?: Hook[];
178
+ }
179
+ /**
180
+ * Whether a spec declares itself out of service — the single interpretation
181
+ * point for {@link MachineSpec.disabled}; a function because some callers hold a
182
+ * spec that cannot build a machine. Read fail-closed: set unless the value is
183
+ * absent, `null`, or boolean `false`, so a mis-authored truthy value stops the
184
+ * workflow rather than running it.
185
+ */
186
+ export declare function specDisabled(spec: MachineSpec | null | undefined): boolean;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Whether a spec declares itself out of service — the single interpretation
3
+ * point for {@link MachineSpec.disabled}; a function because some callers hold a
4
+ * spec that cannot build a machine. Read fail-closed: set unless the value is
5
+ * absent, `null`, or boolean `false`, so a mis-authored truthy value stops the
6
+ * workflow rather than running it.
7
+ */
8
+ export function specDisabled(spec) {
9
+ const declared = spec?.disabled;
10
+ return declared !== undefined && declared !== null && declared !== false;
11
+ }
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/machine/types.ts"],"names":[],"mappings":"AAuOA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAoC;IAC/D,MAAM,QAAQ,GAAI,IAAkD,EAAE,QAAQ,CAAC;IAC/E,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,KAAK,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Everything that can be said about a `workflow.yaml` **from the document
3
+ * alone**: the shape (`machineSpecSchema`), the document-level cross-references
4
+ * (`refineSpec`) and the advisories (`lintSpec`), as one list of diagnostics.
5
+ *
6
+ * Pure — no workspace, no backend, no machine — so an editor can show the same
7
+ * findings inline that `archmax validate` prints, and the loader reports exactly
8
+ * these. What needs more than the document (hook scripts on disk, sibling
9
+ * workflows, the skill registry, kernel probes) is `validate/validate.ts`.
10
+ */
11
+ import type { Diagnostic } from "./diagnostic.js";
12
+ import { type SpecSchemaIssue } from "./spec-schema.js";
13
+ import type { MachineSpec } from "./types.js";
14
+ /** What {@link validateSpec} found. */
15
+ export interface SpecValidation {
16
+ /**
17
+ * Whether the shape and the document rules held — the spec can be compiled
18
+ * into a machine. An advisory (`lint`) never clears this, even at severity
19
+ * `error`: the runtime tolerates what the lint reports and `validate` fails on it.
20
+ */
21
+ ok: boolean;
22
+ /**
23
+ * The typed spec, when the shape held — also beside a document-level error
24
+ * (a dangling target), so the lint could read it and a caller can too.
25
+ */
26
+ spec?: MachineSpec;
27
+ /** The shape and document-rule findings, each an `error` addressed by its `field`. */
28
+ schema: Diagnostic[];
29
+ /** The advisory findings, warnings and the errors the runtime tolerates. */
30
+ lint: Diagnostic[];
31
+ /** `schema` then `lint`, for a caller that wants one list. */
32
+ diagnostics: Diagnostic[];
33
+ }
34
+ /** A structural issue as a diagnostic: an error at the key an author has to find. */
35
+ export declare function schemaIssueDiagnostic(issue: SpecSchemaIssue): Diagnostic;
36
+ /**
37
+ * Validate a parsed `workflow.yaml` mapping. Total: never throws, and a document
38
+ * the schema refuses still yields every issue the schema found, so an editor
39
+ * can show a blank transition `description` or a misspelled state key inline
40
+ * rather than as one refusal. `file` is left to the caller.
41
+ */
42
+ export declare function validateSpec(value: unknown): SpecValidation;
@@ -0,0 +1,29 @@
1
+ import { lintSpec } from "./lint-spec.js";
2
+ import { parseMachineSpec } from "./spec-schema.js";
3
+ /** A structural issue as a diagnostic: an error at the key an author has to find. */
4
+ export function schemaIssueDiagnostic(issue) {
5
+ return {
6
+ severity: "error",
7
+ message: issue.message,
8
+ ...(issue.path ? { field: issue.path } : {}),
9
+ };
10
+ }
11
+ /**
12
+ * Validate a parsed `workflow.yaml` mapping. Total: never throws, and a document
13
+ * the schema refuses still yields every issue the schema found, so an editor
14
+ * can show a blank transition `description` or a misspelled state key inline
15
+ * rather than as one refusal. `file` is left to the caller.
16
+ */
17
+ export function validateSpec(value) {
18
+ const parsed = parseMachineSpec(value);
19
+ const schema = parsed.ok ? [] : parsed.issues.map(schemaIssueDiagnostic);
20
+ const lint = parsed.spec ? lintSpec(parsed.spec) : [];
21
+ return {
22
+ ok: parsed.ok,
23
+ ...(parsed.spec ? { spec: parsed.spec } : {}),
24
+ schema,
25
+ lint,
26
+ diagnostics: [...schema, ...lint],
27
+ };
28
+ }
29
+ //# sourceMappingURL=validate-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-spec.js","sourceRoot":"","sources":["../../src/machine/validate-spec.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAwB,MAAM,kBAAkB,CAAC;AAwB1E,qFAAqF;AACrF,MAAM,UAAU,qBAAqB,CAAC,KAAsB;IAC1D,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACzE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,MAAM;QACN,IAAI;QACJ,WAAW,EAAE,CAAC,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;KAClC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Run-variable references — `${{name}}` and `${{name.dotted.path}}` — in guards,
3
+ * prompts and the arguments the agent writes. One resolver serves the kernel,
4
+ * disclosure, validation and substitution, so a reference means one thing.
5
+ *
6
+ * Three invariants carry the feature's safety: a substituted value is
7
+ * glob-escaped where the output is a *pattern* and verbatim where it is a
8
+ * *value*; resolution fails closed (never the literal `${{…}}` text, never `*`);
9
+ * and traversal reads own properties only (`resolvePath`), so `tags.length` and
10
+ * `constructor` never resolve.
11
+ */
12
+ import type { WorkflowMachine } from "./machine.js";
13
+ /** The shape a run-variable name must take: a snake_case identifier, never dotted. */
14
+ export declare const VARIABLE_NAME_PATTERN: RegExp;
15
+ /**
16
+ * The built-in variable holding the run's trigger id. Reserved: it is set by the
17
+ * harness at run start, locked, and needs no seed — so a guard may reference
18
+ * `${{trigger}}` without anything supplying it.
19
+ */
20
+ export declare const TRIGGER_VARIABLE = "trigger";
21
+ /**
22
+ * The built-in variable holding a short label for the task the run is doing.
23
+ * Agent-owned, unlike `trigger`: nothing sets it until the agent does. Two rules
24
+ * follow it everywhere it is written — it is **never locked** (a seed stores it
25
+ * unlocked; `set_variables` refuses `lock: true`), and it is **shape-checked on
26
+ * write** ({@link titleWriteError}). Unrelated to the spec's static `title`
27
+ * fields.
28
+ */
29
+ export declare const TITLE_VARIABLE = "title";
30
+ /**
31
+ * The longest a title may be. A bound, not a style guide — the system prompt asks
32
+ * for something short, and this only stops something unusable from being stored.
33
+ */
34
+ export declare const TITLE_MAX_LENGTH = 200;
35
+ /**
36
+ * Check a value destined for {@link TITLE_VARIABLE}, returning the refusal reason
37
+ * or `undefined` when it passes. Shared by both write routes (a seed throws, the
38
+ * agent's `set_variables` is refused). Refuses rather than coerces; trimming is
39
+ * the one coercion allowed.
40
+ */
41
+ export declare function titleWriteError(value: unknown): string | undefined;
42
+ /**
43
+ * The value to store for a title that has passed {@link titleWriteError} — the
44
+ * trimmed string. Separate from the check so a caller cannot store the untrimmed
45
+ * original by forgetting to.
46
+ */
47
+ export declare function normalizeTitle(value: string): string;
48
+ /** Thrown when a seeded (or written) variable name is not a valid identifier. */
49
+ export declare class InvalidVariableNameError extends Error {
50
+ readonly variable: string;
51
+ /** Where the name came from, for a message that points at the fix. */
52
+ readonly source: string;
53
+ constructor(variable: string,
54
+ /** Where the name came from, for a message that points at the fix. */
55
+ source?: string);
56
+ }
57
+ /**
58
+ * Thrown when a seeded `title` is not a usable label — a throw rather than the
59
+ * agent's string refusal, because a bad seed is a host defect that should
60
+ * surface at assembly.
61
+ */
62
+ export declare class InvalidTitleError extends Error {
63
+ /** The shape problem, in the same words the agent's refusal uses. */
64
+ readonly detail: string;
65
+ /** Where the value came from, for a message that points at the fix. */
66
+ readonly source: string;
67
+ constructor(
68
+ /** The shape problem, in the same words the agent's refusal uses. */
69
+ detail: string,
70
+ /** Where the value came from, for a message that points at the fix. */
71
+ source?: string);
72
+ }
73
+ /** A run variable as stored in checkpointed state. */
74
+ export interface VariableEntry {
75
+ value: unknown;
76
+ locked: boolean;
77
+ /**
78
+ * Set only by a **host seeding boundary** (a delivery into a wait-parked
79
+ * session, the start of a turn): the host is re-establishing the session's
80
+ * facts, so this replaces even a settled *locked* value. Everywhere else the
81
+ * merge is first-lock-wins. The variable tools never set it, so no
82
+ * agent-reachable path can bypass a lock.
83
+ */
84
+ reseed?: boolean;
85
+ }
86
+ /** The checkpointed variable store, keyed by name. */
87
+ export type VariableStore = Record<string, VariableEntry>;
88
+ /**
89
+ * Turn a caller's seeds into locked variable entries — the one way a run's
90
+ * opening facts are established, whether by a host's `variables` option, a
91
+ * delivery's seeds, or the arguments a delegation hands a sub-run. Locked because
92
+ * a `${{name}}` guard bound to a seed is worthless if the agent can rewrite it.
93
+ */
94
+ export declare function buildSeededVariables(seeds: Record<string, unknown> | undefined,
95
+ /** Where the names came from, for a message that points at the fix. */
96
+ source?: string): VariableStore;
97
+ /** One `${{…}}` reference found in a glob, with its span for substitution. */
98
+ export interface VariableReference {
99
+ /** The full matched text, e.g. `${{order.items.0.sku}}`. */
100
+ raw: string;
101
+ /** The variable name (first segment). */
102
+ name: string;
103
+ /** Path segments after the name; empty for a whole-variable reference. */
104
+ path: string[];
105
+ /** Index of `raw` within the glob it was found in. */
106
+ index: number;
107
+ }
108
+ /** Why a reference could not be resolved. Each is a fail-closed outcome. */
109
+ export type UnresolvedReason = "malformed" | "invalid-name" | "unset" | "path-missing" | "non-scalar";
110
+ export interface ResolvedGlob {
111
+ ok: true;
112
+ /** The glob with every reference substituted and glob-escaped. */
113
+ pattern: string;
114
+ }
115
+ export interface UnresolvedGlob {
116
+ ok: false;
117
+ reason: UnresolvedReason;
118
+ /** The reference that could not be resolved (its raw `${{…}}` text). */
119
+ reference: string;
120
+ /** Human-readable explanation, suitable for a governance block reason. */
121
+ detail: string;
122
+ }
123
+ export type GlobResolution = ResolvedGlob | UnresolvedGlob;
124
+ /**
125
+ * Whether a glob contains reference **syntax** — a `${{…}}` reference or an
126
+ * escaped `$${{…}}` literal. Callers use this to skip resolution entirely for the
127
+ * common reference-free glob, so an escape has to answer `true` here: it resolves
128
+ * nothing, but it still needs the pass that turns `$${{x}}` into `${{x}}`.
129
+ */
130
+ export declare function hasVariableReference(glob: string): boolean;
131
+ /**
132
+ * Every `${{…}}` reference in a glob, in order. A syntactically malformed
133
+ * reference still appears here (with an empty `name`), so callers can report it
134
+ * rather than skip it. An escaped `$${{…}}` is omitted — it is literal text, and
135
+ * reporting it as a reference would make `validate` warn about a variable the
136
+ * author deliberately spelled out.
137
+ */
138
+ export declare function parseReferences(glob: string): VariableReference[];
139
+ /** Whether a reference is structurally usable (name shape, no empty segments). */
140
+ export declare function referenceError(ref: VariableReference): UnresolvedReason | undefined;
141
+ /**
142
+ * Resolve a dotted path against a value, reading own properties only. Returns
143
+ * `undefined` when any segment misses — indistinguishable from a stored
144
+ * `undefined`, which is fine: both are unresolvable for a guard.
145
+ */
146
+ export declare function resolvePath(value: unknown, path: string[]): unknown;
147
+ /**
148
+ * Escape every picomatch metacharacter so a substituted value is matched as
149
+ * literal text; without it a variable holding `*` or `{a,b}` widens the guard.
150
+ */
151
+ export declare function escapeGlobLiteral(value: string): string;
152
+ /**
153
+ * Substitute every reference in a glob against the run's variables. Returns the
154
+ * resolved pattern, or the first unresolved reference and why — a glob with an
155
+ * unresolved reference matches nothing at all, so the caller must not fall back
156
+ * to the original text.
157
+ */
158
+ export declare function resolveGlob(glob: string, variables: VariableStore): GlobResolution;
159
+ /**
160
+ * Substitute every reference in a piece of **prose** (a sub-workflow prompt)
161
+ * verbatim: a prompt is text a model reads, where glob-escaping would teach it
162
+ * to emit backslashes. Failure is still closed — a literal `${{…}}` reaching a
163
+ * model is an instruction it cannot follow.
164
+ */
165
+ export declare function resolveText(text: string, variables: VariableStore): GlobResolution;
166
+ /**
167
+ * A resolved tool-call argument structure, or the first reference that stopped
168
+ * it. The failure side is the same `UnresolvedGlob` every other consumer reports.
169
+ */
170
+ export type ArgumentResolution = {
171
+ ok: true;
172
+ args: Record<string, unknown>;
173
+ } | UnresolvedGlob;
174
+ /**
175
+ * Substitute every reference in the **arguments the agent wrote**, verbatim.
176
+ * Walks deep (non-string leaves pass through), fails first-wins and totally (the
177
+ * tool never receives a half-resolved structure), and only reports. Objects are
178
+ * rebuilt with `Object.fromEntries`, which *defines* each key, so a model-emitted
179
+ * `__proto__` becomes a property rather than a prototype.
180
+ */
181
+ export declare function resolveArguments(args: Record<string, unknown>, variables: VariableStore): ArgumentResolution;
182
+ /**
183
+ * Render a guard glob for the model: the resolved pattern when it resolves, or a
184
+ * short unresolved marker naming the reference. The model is told a constraint
185
+ * exists and what it is waiting on, rather than being shown a placeholder it
186
+ * might try to pass literally into a call that would end the run.
187
+ */
188
+ export declare function describeGlob(glob: string, variables: VariableStore): string;
189
+ /**
190
+ * Warn about every `${{…}}` guard reference the assembly cannot *guarantee* is
191
+ * set — named by neither the host's seeds, any state's `requires`, nor the
192
+ * built-in `trigger`. A warning, not a throw: `archmax_set_variables` can create
193
+ * any name at runtime, so an upstream state may legitimately establish it; the
194
+ * enforcement is the runtime failure when the guard cannot resolve.
195
+ */
196
+ export declare function unguaranteedReferenceWarnings(machine: Pick<WorkflowMachine, "spec">, seededVariables: VariableStore): string[];