@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,9 @@
1
+ /**
2
+ * The delegation bounds a dispatcher enforces by default. Declared apart from the
3
+ * dispatcher so a host configuring `bounds` — or a browser-side editor showing
4
+ * what a workflow overrides — reads them without the LangGraph runtime.
5
+ */
6
+ /** Default nesting bound: a sub-workflow session is a whole extra agent session. */
7
+ export declare const DEFAULT_SUB_WORKFLOW_DEPTH = 3;
8
+ /** Default fan-out bound for one session's in-flight sub-workflow sessions. */
9
+ export declare const DEFAULT_SUB_WORKFLOW_CONCURRENCY = 4;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The delegation bounds a dispatcher enforces by default. Declared apart from the
3
+ * dispatcher so a host configuring `bounds` — or a browser-side editor showing
4
+ * what a workflow overrides — reads them without the LangGraph runtime.
5
+ */
6
+ /** Default nesting bound: a sub-workflow session is a whole extra agent session. */
7
+ export const DEFAULT_SUB_WORKFLOW_DEPTH = 3;
8
+ /** Default fan-out bound for one session's in-flight sub-workflow sessions. */
9
+ export const DEFAULT_SUB_WORKFLOW_CONCURRENCY = 4;
10
+ //# sourceMappingURL=delegation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../src/machine/delegation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oFAAoF;AACpF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** Severity of a finding about an authored workspace. */
2
+ export type DiagnosticSeverity = "error" | "warning";
3
+ /**
4
+ * One finding about a workflow, produced by the spec lint and by
5
+ * `validateWorkflow`, identifying the offending file and/or spec field.
6
+ */
7
+ export interface Diagnostic {
8
+ severity: DiagnosticSeverity;
9
+ message: string;
10
+ /** Workspace-relative file the finding relates to, when applicable. */
11
+ file?: string;
12
+ /** Dotted spec field the finding relates to (`states.review.transitions.0.to`). */
13
+ field?: string;
14
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=diagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../../src/machine/diagnostic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { Diagnostic } from "./diagnostic.js";
2
+ import type { MachineSpec } from "./types.js";
3
+ /** Findings for a spec the schema has accepted. `file` is left to the caller. */
4
+ export declare function lintSpec(spec: MachineSpec): Diagnostic[];
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Findings about one `workflow.yaml` that do not stop it loading: warnings about
3
+ * things that run but almost certainly do not do what the author meant, and
4
+ * **errors** the runtime tolerates but `archmax validate` fails on (a human state
5
+ * that cannot present the decision it declares). Pure over the parsed spec — no
6
+ * workspace, no registry — so the loader and the validator report the same
7
+ * findings. What the runtime cannot run without lives in `spec-schema.ts`.
8
+ */
9
+ import { classifyWorkspacePath, SESSION_OPEN_DIR } from "../core/zones.js";
10
+ import { guardReferences, normalizeAllowEntry } from "./allow.js";
11
+ import { normalizeMountGrants } from "./mount-grants.js";
12
+ import { triggerDeclarationSchema } from "./spec-schema.js";
13
+ import { ADVANCE_TOOL, ESSENTIAL_TOOLS } from "./tool-names.js";
14
+ import { declaredVariableNames } from "./triggers.js";
15
+ import { TRIGGER_VARIABLE } from "./variables.js";
16
+ /** The block keys the SDK defines; anything else on a declaration is the host's. */
17
+ const TRIGGER_KEYS = new Set(Object.keys(triggerDeclarationSchema.shape));
18
+ const LABELED_TRANSITION_TYPES = ["approve", "reject", "refine"];
19
+ /** Findings for a spec the schema has accepted. `file` is left to the caller. */
20
+ export function lintSpec(spec) {
21
+ const out = [];
22
+ const warn = (field, message) => out.push({ severity: "warning", message, field });
23
+ const error = (field, message) => out.push({ severity: "error", message, field });
24
+ if (spec.instructions === undefined) {
25
+ warn("instructions", `No top-level 'instructions', so the workflow ships no standing guidance in the system ` +
26
+ `prompt — conventions, house rules, and what "done" means have to be repeated in every ` +
27
+ `state's 'instructions' instead. Add an 'instructions' block for direction that holds ` +
28
+ `across the whole run.`);
29
+ }
30
+ // Validation is the one surface that stays fully functional for a disabled
31
+ // workflow, so it has to say plainly that runs will be refused.
32
+ if (spec.disabled === true) {
33
+ warn("disabled", `This workflow is disabled ('disabled: true'), so it starts no new turns: 'archmax run' ` +
34
+ `refuses, a trigger firing is rejected, and a caller's delegation call is refused. ` +
35
+ `Sessions already underway can still be decided, replied to and delivered to, and ` +
36
+ `'archmax test' skips its cases. Remove the key to re-enable it.`);
37
+ }
38
+ // Essential built-ins are always permitted, and only a state's own entry
39
+ // narrows them — so an `allow_always` entry naming one is inert. `task` is
40
+ // conditional, so an entry naming it can be what discloses it.
41
+ for (const entry of spec.tools?.allow_always ?? []) {
42
+ const { tool, argMatchers } = normalizeAllowEntry(entry);
43
+ if (!tool || !ESSENTIAL_TOOLS.has(tool))
44
+ continue;
45
+ warn("tools.allow_always", argMatchers
46
+ ? `'tools.allow_always' constrains essential tool '${tool}', but essential tools are always permitted and the constraint is never enforced; narrow it per state with a 'tools.allow' entry instead`
47
+ : `'tools.allow_always' lists essential tool '${tool}', which is always permitted; the entry is redundant`);
48
+ }
49
+ const alwaysSkills = spec.skills?.allow_always;
50
+ const forbiddenSkills = spec.skills?.forbid_always ?? [];
51
+ // A workflow-wide skill denial beats every grant, so a grant it covers reaches
52
+ // no state at all.
53
+ for (const named of forbiddenSkills) {
54
+ const grantedSomewhere = (alwaysSkills ?? []).includes(named) ||
55
+ Object.values(spec.states).some((state) => (state.skills?.allow ?? []).includes(named));
56
+ if (!grantedSomewhere)
57
+ continue;
58
+ warn("skills.forbid_always", `'skills.forbid_always' denies skill '${named}' in every state while a 'skills.allow' or ` +
59
+ `'skills.allow_always' list also grants it; a denial beats every grant, so the grant ` +
60
+ `reaches nothing. Drop one of the two.`);
61
+ }
62
+ const alwaysMounts = normalizeMountGrants(spec.mounts?.allow_always);
63
+ const alwaysMountNames = alwaysMounts.map((grant) => grant.mount);
64
+ const forbiddenMounts = spec.mounts?.forbid_always ?? [];
65
+ // A workflow-wide mount denial beats every grant, so a grant it covers reaches
66
+ // no state at all — the mounts twin of the skills lint above.
67
+ for (const named of forbiddenMounts) {
68
+ const grantedSomewhere = alwaysMountNames.includes(named) ||
69
+ Object.values(spec.states).some((state) => normalizeMountGrants(state.mounts?.allow).some((grant) => grant.mount === named));
70
+ if (!grantedSomewhere)
71
+ continue;
72
+ warn("mounts.forbid_always", `'mounts.forbid_always' denies mount '${named}' in every state while a 'mounts.allow' or ` +
73
+ `'mounts.allow_always' list also grants it; a denial beats every grant, so the grant ` +
74
+ `reaches nothing. Drop one of the two.`);
75
+ }
76
+ // The workflow-wide tool denial that strands every run: no state could leave
77
+ // itself, so nothing reaches a terminal state.
78
+ const hasNonTerminal = Object.values(spec.states).some((state) => (state.transitions ?? []).length > 0);
79
+ for (const entry of spec.tools?.forbid_always ?? []) {
80
+ const { tool } = normalizeAllowEntry(entry);
81
+ if (tool !== ADVANCE_TOOL || !hasNonTerminal)
82
+ continue;
83
+ error("tools.forbid_always", `'tools.forbid_always' denies '${ADVANCE_TOOL}', the only way a state moves, in a workflow ` +
84
+ `that has outgoing transitions — so no run could ever leave its start state. Deny a tool ` +
85
+ `the graph does not need, or remove the entry.`);
86
+ }
87
+ for (const [slug, state] of Object.entries(spec.states)) {
88
+ const at = `states.${slug}`;
89
+ const transitions = state.transitions ?? [];
90
+ // A state's model overrides the workflow's; naming the same id overrides it
91
+ // with itself, which reads as a deliberate choice while changing nothing.
92
+ if (state.model !== undefined && state.model === spec.settings?.model) {
93
+ warn(`${at}.model`, `State '${slug}' declares model '${state.model}', which is already ` +
94
+ `'settings.model' for the whole workflow; the entry changes nothing. Drop it, or name ` +
95
+ `a different id if this state should run on another model.`);
96
+ }
97
+ // A state's list adds; only its `forbid` takes away, so an entry the workflow
98
+ // already grants everywhere governs nothing, and an empty list that reads
99
+ // like a deny is not one.
100
+ if (alwaysSkills !== undefined && alwaysSkills.length > 0) {
101
+ const declaredSkills = state.skills?.allow;
102
+ if (declaredSkills !== undefined && declaredSkills.length === 0) {
103
+ warn(`${at}.skills.allow`, `State '${slug}' declares 'skills: { allow: [] }', which reads like a deny but subtracts ` +
104
+ `nothing: 'skills.allow_always' enables ${alwaysSkills.join(", ")} in every state. ` +
105
+ `'skills: { forbid: [...] }' is what subtracts — name the slugs this state must not ` +
106
+ `have there.`);
107
+ }
108
+ for (const named of declaredSkills ?? []) {
109
+ if (!alwaysSkills.includes(named))
110
+ continue;
111
+ warn(`${at}.skills.allow`, `State '${slug}' enables skill '${named}', which 'skills.allow_always' already enables ` +
112
+ `in every state; the entry grants nothing. Drop it here, or drop it from ` +
113
+ `'allow_always' if only some states should have it.`);
114
+ }
115
+ }
116
+ // The same three shapes for mounts. `access` is why the both-levels case is
117
+ // not simply redundant: a state entry that narrows the workflow's grant to
118
+ // reads is doing real work, so only one repeating it unchanged is warned.
119
+ const stateMounts = normalizeMountGrants(state.mounts?.allow);
120
+ if (alwaysMountNames.length > 0) {
121
+ if (Array.isArray(state.mounts?.allow) && stateMounts.length === 0) {
122
+ warn(`${at}.mounts.allow`, `State '${slug}' declares 'mounts: { allow: [] }', which reads like a deny but ` +
123
+ `subtracts nothing: 'mounts.allow_always' enables ${alwaysMountNames.join(", ")} in ` +
124
+ `every state. 'mounts: { forbid: [...] }' is what subtracts — name the mounts this ` +
125
+ `state must not reach.`);
126
+ }
127
+ for (const grant of stateMounts) {
128
+ if (!alwaysMountNames.includes(grant.mount))
129
+ continue;
130
+ const narrows = grant.access === "read" &&
131
+ alwaysMounts.some((a) => a.mount === grant.mount && a.access !== "read");
132
+ if (narrows)
133
+ continue;
134
+ warn(`${at}.mounts.allow`, `State '${slug}' enables mount '${grant.mount}', which 'mounts.allow_always' already ` +
135
+ `enables in every state; the entry grants nothing. Write ` +
136
+ `'{ mount: ${grant.mount}, access: read }' if the intent is to narrow it here, ` +
137
+ `'mounts.forbid' to take it away, or drop it from 'allow_always' if only some ` +
138
+ `states should have it.`);
139
+ }
140
+ }
141
+ for (const named of state.mounts?.forbid ?? []) {
142
+ if (stateMounts.some((grant) => grant.mount === named)) {
143
+ warn(`${at}.mounts.allow`, `State '${slug}' both enables and forbids mount '${named}'; the denial wins, so the ` +
144
+ `'allow' entry governs nothing. Drop one of the two.`);
145
+ }
146
+ }
147
+ // A state's own denial beats its own grant, so a slug or tool it both grants
148
+ // and denies is a grant that governs nothing.
149
+ const stateForbidSkills = state.skills?.forbid ?? [];
150
+ for (const named of stateForbidSkills) {
151
+ if ((state.skills?.allow ?? []).includes(named)) {
152
+ warn(`${at}.skills.allow`, `State '${slug}' both enables and forbids skill '${named}'; the denial wins, so the ` +
153
+ `'allow' entry governs nothing. Drop one of the two.`);
154
+ continue;
155
+ }
156
+ // Nothing granted it here, so the denial has nothing to subtract.
157
+ if (!(alwaysSkills ?? []).includes(named) && !forbiddenSkills.includes(named)) {
158
+ warn(`${at}.skills.forbid`, `State '${slug}' forbids skill '${named}', which nothing enables here — neither ` +
159
+ `'skills.allow_always' nor this state's own 'skills.allow' names it — so the entry ` +
160
+ `governs nothing.`);
161
+ }
162
+ }
163
+ const stateAllowTools = new Set((state.tools?.allow ?? []).map((entry) => normalizeAllowEntry(entry).tool));
164
+ for (const entry of state.tools?.forbid ?? []) {
165
+ const { tool } = normalizeAllowEntry(entry);
166
+ if (!tool || !stateAllowTools.has(tool))
167
+ continue;
168
+ warn(`${at}.tools.allow`, `State '${slug}' both allows and forbids '${tool}'; the denial wins, so the 'allow' entry ` +
169
+ `governs nothing. Drop one of the two.`);
170
+ }
171
+ // A state with several outgoing edges is making a routing decision, which
172
+ // belongs to its own `instructions`. Human states require them already.
173
+ if (state.type !== "human" && transitions.length > 1 && !state.instructions?.trim()) {
174
+ warn(`${at}.instructions`, `State '${slug}' has ${transitions.length} outgoing transitions but no 'instructions'; add guidance so the agent classifies the request and routes with archmax_advance instead of leaving that decision to whichever state it lands in`);
175
+ }
176
+ // No routing-context advisory here: every transition now carries a non-empty
177
+ // `description` by schema, and a state's `summary` reaches no model call.
178
+ if (state.type === "human") {
179
+ if (!state.instructions?.trim()) {
180
+ error(`${at}.instructions`, `Human state '${slug}' must declare 'instructions' describing the decision to present`);
181
+ }
182
+ if (transitions.length === 0) {
183
+ error(`${at}.transitions`, `Human state '${slug}' must declare at least one outgoing transition the human can route to`);
184
+ }
185
+ // A missing button label is not checked here: the schema requires a
186
+ // non-empty `description` on every transition, human or not.
187
+ transitions.forEach((transition, index) => {
188
+ // A decision routes the run *out* of the state: a self-edge is offered as
189
+ // a button and then ends the run instead of routing.
190
+ if (transition.to === slug) {
191
+ error(`${at}.transitions.${index}.to`, `Human state '${slug}' declares a transition to itself; a decision routes the run ` +
192
+ `*out* of the state, so this edge would be offered to the reviewer and then end ` +
193
+ `the run. Point it at the state that does the further work (e.g. the state that ` +
194
+ `produced what is being reviewed)`);
195
+ }
196
+ });
197
+ for (const labeled of LABELED_TRANSITION_TYPES) {
198
+ const count = transitions.filter((transition) => transition.type === labeled).length;
199
+ if (count > 1) {
200
+ error(`${at}.transitions`, `Human state '${slug}' declares ${count} '${labeled}' transitions; a labeled ` +
201
+ `decision type must map to a single target`);
202
+ }
203
+ }
204
+ // Every hook site lives inside an agent turn, and a human state runs
205
+ // none: a hook here validates cleanly and is never called.
206
+ for (const phase of ["before", "after"]) {
207
+ if (state[phase] === undefined)
208
+ continue;
209
+ error(`${at}.${phase}`, `Human state '${slug}' declares a '${phase}' hook, which can never run: hooks execute ` +
210
+ `inside an agent segment and a human state runs none — it presents the decision and ` +
211
+ `waits for a person. Move it to the agent state ` +
212
+ `${phase === "before" ? "that advances into" : "the decision routes to"} this state`);
213
+ }
214
+ }
215
+ const seen = new Set();
216
+ for (const name of state.requires ?? []) {
217
+ if (seen.has(name))
218
+ warn(`${at}.requires`, `State '${slug}' lists '${name}' twice in requires.`);
219
+ seen.add(name);
220
+ }
221
+ // An entry whose every path sits in the always-open working area reads as
222
+ // governance but cannot act as one there: `tool.scratchpad` allows the write
223
+ // before the state's list is consulted, in every state.
224
+ for (const entry of state.tools?.allow ?? []) {
225
+ const { tool, argMatchers } = normalizeAllowEntry(entry);
226
+ if ((tool !== "write_file" && tool !== "edit_file") || !argMatchers)
227
+ continue;
228
+ const paths = argMatchers.file_path ?? [];
229
+ if (paths.length === 0 || !paths.every((path) => classifyWorkspacePath(path) === "run-open")) {
230
+ continue;
231
+ }
232
+ warn(`${at}.tools.allow`, `State '${slug}' allows '${tool}' on ${paths.map((p) => `'${p}'`).join(", ")}, which is in the always-open '${SESSION_OPEN_DIR}/' area: those writes are permitted in every state regardless of this entry, so it does not constrain where inside '${SESSION_OPEN_DIR}/' the write may land. Name an ordinary run path (e.g. '${slug}.json') if the write itself should be governed.`);
233
+ }
234
+ }
235
+ // A declaration is loose, so a host may decorate it; the SDK reads the keys it
236
+ // knows and says so about the rest. There is nothing left to warn about an
237
+ // orphaned declaration: writing one is what makes its state a start state.
238
+ for (const [slug, state] of Object.entries(spec.states)) {
239
+ for (const [id, decl] of Object.entries(state.triggers ?? {})) {
240
+ for (const key of Object.keys(decl ?? {})) {
241
+ if (TRIGGER_KEYS.has(key))
242
+ continue;
243
+ warn(`states.${slug}.triggers.${id}`, `Trigger '${id}' declares unknown key '${key}', which the SDK ignores. The keys it reads are ${[...TRIGGER_KEYS].map((k) => `'${k}'`).join(", ")}.`);
244
+ }
245
+ }
246
+ }
247
+ // A guard on a variable nothing declares rests on the agent having called
248
+ // set_variables first. Not an error: the host may seed it at assembly, where
249
+ // the authoritative check runs with the seeds known.
250
+ const declared = declaredVariableNames(spec);
251
+ for (const ref of guardReferences(spec)) {
252
+ const name = ref.reference.name;
253
+ if (name === TRIGGER_VARIABLE || declared.has(name))
254
+ continue;
255
+ const where = ref.state ? `State '${ref.state}'` : "tools.allow_always";
256
+ warn(ref.state ? `states.${ref.state}.tools.allow` : "tools.allow_always", `${where} guards '${ref.tool ?? "?"}' on '${ref.reference.raw}', but no state requires ` +
257
+ `'${name}'. Supply it through the 'variables' option at assembly, or name it in the ` +
258
+ `'requires' of a state that runs first — otherwise the guard depends on the agent ` +
259
+ `having called set_variables, and the run fails at that call if it has not.` +
260
+ (ref.state
261
+ ? ""
262
+ : " An allow_always entry is evaluated in every state, including states reached before anything sets it."));
263
+ }
264
+ return out;
265
+ }
266
+ //# sourceMappingURL=lint-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint-spec.js","sourceRoot":"","sources":["../../src/machine/lint-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;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rD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7C,KAAK,MAAM,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC;QAChC,IAAI,IAAI,KAAK,gBAAgB,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QAC9D,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,oBAAoB,CAAC;QACxE,IAAI,CACF,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,oBAAoB,EACpE,GAAG,KAAK,YAAY,GAAG,CAAC,IAAI,IAAI,GAAG,SAAS,GAAG,CAAC,SAAS,CAAC,GAAG,2BAA2B;YACtF,IAAI,IAAI,6EAA6E;YACrF,mFAAmF;YACnF,4EAA4E;YAC5E,CAAC,GAAG,CAAC,KAAK;gBACR,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,uGAAuG,CAAC,CAC/G,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,90 @@
1
+ import type { Workspace } from "../core/workspace.js";
2
+ import type { MachineSpec } from "./types.js";
3
+ /**
4
+ * The distinct ways loading a machine spec can fall short of a usable machine.
5
+ * Each consumer maps these to its own reporting surface (runtime warning events
6
+ * vs. static validator diagnostics), so both agree on *why* a spec is unusable.
7
+ */
8
+ export type LoadIssueKind = "missing" | "not-a-mapping" | "schema" | "competing-machines" | "lint";
9
+ export interface LoadIssue {
10
+ kind: LoadIssueKind;
11
+ /**
12
+ * `error` issues make the spec unusable (fail-closed), except `lint` errors,
13
+ * which the runtime tolerates and `validate` fails on; `warning` issues are
14
+ * surfaced but the machine still loads.
15
+ */
16
+ severity: "error" | "warning";
17
+ /** Self-describing message, naming the file, for the runtime's warning events. */
18
+ message: string;
19
+ /** Dotted spec field the issue relates to, when the schema or lint named one. */
20
+ field?: string;
21
+ }
22
+ export interface LoadSpecResult {
23
+ /**
24
+ * The parsed machine spec when a spec file exists and parses to a mapping —
25
+ * even if it later fails the schema, so the static validator can keep
26
+ * inspecting it. `null` only when there is nothing parseable to inspect.
27
+ */
28
+ spec: MachineSpec | null;
29
+ /** Structured problems found while loading; empty when the spec is pristine. */
30
+ issues: LoadIssue[];
31
+ /**
32
+ * Advisory findings from `lintSpec` (kind `lint`): never load-blocking; the
33
+ * runtime emits them as warnings and `archmax validate` reports them (an
34
+ * error-severity lint finding fails validation, not the load).
35
+ */
36
+ lint: LoadIssue[];
37
+ /** Prose addendum: the sibling `WORKFLOW.md` content (empty when absent). */
38
+ body: string;
39
+ /** Workspace-relative path the machine spec was loaded from (for diagnostics). */
40
+ specFile: string;
41
+ /**
42
+ * Whether the loaded spec is a usable machine: it passed the schema and has
43
+ * no error-severity issues. The runtime builds a `WorkflowMachine` only when
44
+ * this is true.
45
+ */
46
+ usable: boolean;
47
+ }
48
+ /** The two files a workflow is authored in. */
49
+ export interface WorkflowSpecPaths {
50
+ /** The machine spec: `workflows/<slug>/workflow.yaml`. */
51
+ workflowYaml: string;
52
+ /** Optional prose addendum: `workflows/<slug>/WORKFLOW.md` (never a spec source). */
53
+ workflow: string;
54
+ }
55
+ /**
56
+ * Single implementation of machine-spec loading, shared by runtime assembly and
57
+ * the static validator. `workflow.yaml` is the sole spec source: a sibling
58
+ * `WORKFLOW.md` is prose only, and frontmatter there is a `competing-machines`
59
+ * error. Shape, document rules and advisories come from `validateSpec`.
60
+ */
61
+ export declare function loadMachineSpec(workspace: Workspace, paths: WorkflowSpecPaths): Promise<LoadSpecResult>;
62
+ /**
63
+ * Thrown by `createAgent` when a requested workflow cannot be loaded: its
64
+ * `workflow.yaml` is missing, or exists but has no valid machine spec. Assembly
65
+ * fails closed rather than silently degrading to an ungoverned plain agent.
66
+ */
67
+ export declare class WorkflowLoadError extends Error {
68
+ /** Workflow slug the load was attempted for. */
69
+ readonly workflow: string;
70
+ /** Workspace-relative path of the workflow definition. */
71
+ readonly workflowPath: string;
72
+ /** What went wrong (missing file vs invalid machine spec). */
73
+ readonly problem: string;
74
+ constructor(
75
+ /** Workflow slug the load was attempted for. */
76
+ workflow: string,
77
+ /** Workspace-relative path of the workflow definition. */
78
+ workflowPath: string,
79
+ /** What went wrong (missing file vs invalid machine spec). */
80
+ problem: string);
81
+ }
82
+ /**
83
+ * Thrown when a turn would start a session on a workflow that declares
84
+ * `disabled: true`. Parked sessions can still be decided, replied to and
85
+ * delivered to; only a new turn is refused.
86
+ */
87
+ export declare class WorkflowDisabledError extends Error {
88
+ readonly workflow: string;
89
+ constructor(workflow: string);
90
+ }
@@ -0,0 +1,120 @@
1
+ import { parse as parseYaml } from "yaml";
2
+ import { parseFrontmatter } from "../core/frontmatter.js";
3
+ import { validateSpec } from "./validate-spec.js";
4
+ /**
5
+ * Single implementation of machine-spec loading, shared by runtime assembly and
6
+ * the static validator. `workflow.yaml` is the sole spec source: a sibling
7
+ * `WORKFLOW.md` is prose only, and frontmatter there is a `competing-machines`
8
+ * error. Shape, document rules and advisories come from `validateSpec`.
9
+ */
10
+ export async function loadMachineSpec(workspace, paths) {
11
+ const specFile = paths.workflowYaml;
12
+ const yamlRaw = await workspace.readText(specFile);
13
+ if (yamlRaw == null) {
14
+ return {
15
+ spec: null,
16
+ issues: [{ kind: "missing", severity: "error", message: `${specFile} not found` }],
17
+ body: "",
18
+ specFile,
19
+ usable: false,
20
+ lint: [],
21
+ };
22
+ }
23
+ const issues = [];
24
+ let data;
25
+ try {
26
+ data = parseYaml(yamlRaw.replace(/\r(?=\n|$)/g, "")) ?? null;
27
+ }
28
+ catch {
29
+ data = null;
30
+ }
31
+ if (!data || typeof data !== "object" || Array.isArray(data)) {
32
+ issues.push({
33
+ kind: "not-a-mapping",
34
+ severity: "error",
35
+ message: `invalid machine spec at ${specFile} (expected a YAML mapping)`,
36
+ });
37
+ return { spec: null, issues, lint: [], body: "", specFile, usable: false };
38
+ }
39
+ // One validator for the loader and the editor-facing `validateSpec`: the
40
+ // shape and document rules here are exactly what it reports.
41
+ const checked = validateSpec(data);
42
+ for (const finding of checked.schema) {
43
+ issues.push({
44
+ kind: "schema",
45
+ severity: "error",
46
+ message: `${specFile}: ${finding.field ? `'${finding.field}': ` : ""}${finding.message}`,
47
+ ...(finding.field ? { field: finding.field } : {}),
48
+ });
49
+ }
50
+ // The lint reads typed fields, so it runs whenever the shape held — including
51
+ // beside a document-level error, so one dangling target does not hide every
52
+ // advisory behind it.
53
+ const lint = checked.lint.map((finding) => ({
54
+ kind: "lint",
55
+ severity: finding.severity,
56
+ message: `${specFile}: ${finding.message}`,
57
+ ...(finding.field ? { field: finding.field } : {}),
58
+ }));
59
+ // The unvalidated mapping is carried forward when the schema rejects it, so the
60
+ // validator's cross-file passes still run; `usable` is false, so nothing runs it.
61
+ const spec = checked.ok && checked.spec ? checked.spec : data;
62
+ let body = "";
63
+ const proseRaw = await workspace.readText(paths.workflow);
64
+ if (proseRaw != null) {
65
+ if (parseFrontmatter(proseRaw)) {
66
+ issues.push({
67
+ kind: "competing-machines",
68
+ severity: "error",
69
+ message: `${paths.workflow} declares YAML frontmatter but ${specFile} is the ` +
70
+ `machine spec; remove the frontmatter from ${paths.workflow} (it is prose only).`,
71
+ });
72
+ }
73
+ body = proseRaw;
74
+ }
75
+ // A lint error fails `validate`, not the load: the runtime tolerates what it
76
+ // reports, so a run is not refused over a missing button label. Lint lives in
77
+ // its own list so `issues` keeps meaning "what stands between this file and a
78
+ // usable machine" — a host asserting `issues` is empty for a valid spec is right.
79
+ const usable = !issues.some((i) => i.severity === "error");
80
+ return { spec, issues, lint, body, specFile, usable };
81
+ }
82
+ /**
83
+ * Thrown by `createAgent` when a requested workflow cannot be loaded: its
84
+ * `workflow.yaml` is missing, or exists but has no valid machine spec. Assembly
85
+ * fails closed rather than silently degrading to an ungoverned plain agent.
86
+ */
87
+ export class WorkflowLoadError extends Error {
88
+ workflow;
89
+ workflowPath;
90
+ problem;
91
+ constructor(
92
+ /** Workflow slug the load was attempted for. */
93
+ workflow,
94
+ /** Workspace-relative path of the workflow definition. */
95
+ workflowPath,
96
+ /** What went wrong (missing file vs invalid machine spec). */
97
+ problem) {
98
+ super(`Cannot load workflow '${workflow}' (${workflowPath}): ${problem}. ` +
99
+ `Run 'archmax validate ${workflow}' for details.`);
100
+ this.workflow = workflow;
101
+ this.workflowPath = workflowPath;
102
+ this.problem = problem;
103
+ this.name = "WorkflowLoadError";
104
+ }
105
+ }
106
+ /**
107
+ * Thrown when a turn would start a session on a workflow that declares
108
+ * `disabled: true`. Parked sessions can still be decided, replied to and
109
+ * delivered to; only a new turn is refused.
110
+ */
111
+ export class WorkflowDisabledError extends Error {
112
+ workflow;
113
+ constructor(workflow) {
114
+ super(`workflow '${workflow}' is disabled ('disabled: true' in its workflow.yaml); no session started. ` +
115
+ `Remove that flag to re-enable it. Parked sessions can still be decided, replied to and delivered to.`);
116
+ this.workflow = workflow;
117
+ this.name = "WorkflowDisabledError";
118
+ }
119
+ }
120
+ //# sourceMappingURL=load-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-spec.js","sourceRoot":"","sources":["../../src/machine/load-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0DlD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAAoB,EACpB,KAAwB;IAExB,MAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC;IACpC,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnD,IAAI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