@archmax-ai/harness 0.9.0 → 1.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 (207) hide show
  1. package/README.md +58 -14
  2. package/dist/agent.d.ts +4 -6
  3. package/dist/agent.js +4 -6
  4. package/dist/agent.js.map +1 -1
  5. package/dist/assembly/compose.d.ts +5 -24
  6. package/dist/assembly/compose.js +28 -42
  7. package/dist/assembly/compose.js.map +1 -1
  8. package/dist/assembly/delegation-registry.js +3 -14
  9. package/dist/assembly/delegation-registry.js.map +1 -1
  10. package/dist/assembly/index.d.ts +8 -15
  11. package/dist/assembly/index.js +21 -28
  12. package/dist/assembly/index.js.map +1 -1
  13. package/dist/assembly/plain.js +1 -2
  14. package/dist/assembly/plain.js.map +1 -1
  15. package/dist/authoring-skill/archmax-harness/README.md +5 -5
  16. package/dist/authoring-skill/archmax-harness/SKILL.md +72 -30
  17. package/dist/authoring-skill/archmax-harness/references/backend-integration.md +33 -24
  18. package/dist/authoring-skill/archmax-harness/references/cases.md +41 -8
  19. package/dist/authoring-skill/archmax-harness/references/{hook-and-test-scripts.md → code-state-and-test-scripts.md} +599 -339
  20. package/dist/authoring-skill/archmax-harness/references/code-states-and-scripts.md +115 -0
  21. package/dist/authoring-skill/archmax-harness/references/diagnostics.md +40 -7
  22. package/dist/authoring-skill/archmax-harness/references/wiring.md +19 -10
  23. package/dist/authoring-skill/archmax-harness/references/workflow-schema.md +404 -293
  24. package/dist/authoring-skill/archmax-harness/references/workflow-yaml.md +151 -62
  25. package/dist/cli/state-flow.d.ts +1 -1
  26. package/dist/cli/state-flow.js +18 -28
  27. package/dist/cli/state-flow.js.map +1 -1
  28. package/dist/cli/turn.d.ts +1 -1
  29. package/dist/cli/turn.js +1 -1
  30. package/dist/core/code-description.d.ts +3 -3
  31. package/dist/core/code-description.js +3 -3
  32. package/dist/core/deepagents.d.ts +5 -12
  33. package/dist/core/deepagents.js +4 -17
  34. package/dist/core/deepagents.js.map +1 -1
  35. package/dist/core/events.d.ts +23 -42
  36. package/dist/core/events.js +21 -24
  37. package/dist/core/events.js.map +1 -1
  38. package/dist/core/message-readers.d.ts +4 -5
  39. package/dist/core/message-readers.js +3 -8
  40. package/dist/core/message-readers.js.map +1 -1
  41. package/dist/core/messages.d.ts +0 -22
  42. package/dist/core/messages.js +1 -32
  43. package/dist/core/messages.js.map +1 -1
  44. package/dist/core/mounts.js +3 -3
  45. package/dist/core/platform-prompt.generated.js +1 -1
  46. package/dist/core/platform-prompt.generated.js.map +1 -1
  47. package/dist/core/session-zone.d.ts +1 -1
  48. package/dist/core/session-zone.js +1 -1
  49. package/dist/core/workspace-context.d.ts +1 -1
  50. package/dist/core/workspace.d.ts +1 -1
  51. package/dist/core/workspace.js +1 -1
  52. package/dist/core/zones.d.ts +4 -4
  53. package/dist/core/zones.js +5 -5
  54. package/dist/core/zones.js.map +1 -1
  55. package/dist/env.d.ts +9 -9
  56. package/dist/index.d.ts +3 -7
  57. package/dist/index.js +2 -4
  58. package/dist/index.js.map +1 -1
  59. package/dist/kernel/kernel.d.ts +31 -61
  60. package/dist/kernel/kernel.js +54 -112
  61. package/dist/kernel/kernel.js.map +1 -1
  62. package/dist/machine/lint-spec.js +53 -12
  63. package/dist/machine/lint-spec.js.map +1 -1
  64. package/dist/machine/machine.d.ts +36 -18
  65. package/dist/machine/machine.js +62 -51
  66. package/dist/machine/machine.js.map +1 -1
  67. package/dist/machine/spec-schema.d.ts +32 -180
  68. package/dist/machine/spec-schema.js +52 -113
  69. package/dist/machine/spec-schema.js.map +1 -1
  70. package/dist/machine/tool-names.d.ts +34 -16
  71. package/dist/machine/tool-names.js +41 -16
  72. package/dist/machine/tool-names.js.map +1 -1
  73. package/dist/machine/types.d.ts +14 -46
  74. package/dist/machine/types.js +0 -2
  75. package/dist/machine/types.js.map +1 -1
  76. package/dist/machine/validate-spec.d.ts +1 -1
  77. package/dist/public/sandbox.d.ts +59 -95
  78. package/dist/public/sandbox.js +22 -23
  79. package/dist/public/sandbox.js.map +1 -1
  80. package/dist/public/spec.d.ts +13 -20
  81. package/dist/public/spec.js +12 -20
  82. package/dist/public/spec.js.map +1 -1
  83. package/dist/runtime/contract.d.ts +11 -12
  84. package/dist/runtime/contract.js +16 -16
  85. package/dist/runtime/contract.js.map +1 -1
  86. package/dist/sandbox/assets/parts/code-state.js +17 -0
  87. package/dist/sandbox/executor.d.ts +25 -7
  88. package/dist/sandbox/executor.js +56 -57
  89. package/dist/sandbox/executor.js.map +1 -1
  90. package/dist/sandbox/imports.d.ts +10 -10
  91. package/dist/sandbox/imports.js +11 -11
  92. package/dist/sandbox/imports.js.map +1 -1
  93. package/dist/sandbox/prelude.d.ts +5 -6
  94. package/dist/sandbox/prelude.js +38 -35
  95. package/dist/sandbox/prelude.js.map +1 -1
  96. package/dist/sandbox/ptc-gateway.d.ts +19 -18
  97. package/dist/sandbox/ptc-gateway.js +26 -22
  98. package/dist/sandbox/ptc-gateway.js.map +1 -1
  99. package/dist/sessions/resume.d.ts +2 -2
  100. package/dist/sessions/resume.js +1 -1
  101. package/dist/sessions/resume.js.map +1 -1
  102. package/dist/sessions/scope.d.ts +0 -10
  103. package/dist/sessions/scope.js +0 -17
  104. package/dist/sessions/scope.js.map +1 -1
  105. package/dist/sessions/summary.d.ts +1 -1
  106. package/dist/testing/assertions.js +9 -4
  107. package/dist/testing/assertions.js.map +1 -1
  108. package/dist/testing/driver.js +3 -0
  109. package/dist/testing/driver.js.map +1 -1
  110. package/dist/testing/interpreter.d.ts +2 -2
  111. package/dist/testing/runner.d.ts +2 -2
  112. package/dist/validate/validate.d.ts +1 -1
  113. package/dist/validate/validate.js +39 -70
  114. package/dist/validate/validate.js.map +1 -1
  115. package/dist/workflow/automated-controls.d.ts +63 -0
  116. package/dist/workflow/automated-controls.js +158 -0
  117. package/dist/workflow/automated-controls.js.map +1 -0
  118. package/dist/workflow/automated.d.ts +112 -0
  119. package/dist/workflow/automated.js +163 -0
  120. package/dist/workflow/automated.js.map +1 -0
  121. package/dist/workflow/code-state.d.ts +46 -0
  122. package/dist/workflow/code-state.js +26 -0
  123. package/dist/workflow/code-state.js.map +1 -0
  124. package/dist/workflow/control-tools.d.ts +54 -23
  125. package/dist/workflow/control-tools.js +99 -79
  126. package/dist/workflow/control-tools.js.map +1 -1
  127. package/dist/workflow/file-values.d.ts +4 -4
  128. package/dist/workflow/file-values.js +1 -1
  129. package/dist/workflow/file-values.js.map +1 -1
  130. package/dist/workflow/governance.d.ts +11 -22
  131. package/dist/workflow/governance.js +47 -104
  132. package/dist/workflow/governance.js.map +1 -1
  133. package/dist/workflow/grader-state.d.ts +55 -0
  134. package/dist/workflow/grader-state.js +182 -0
  135. package/dist/workflow/grader-state.js.map +1 -0
  136. package/dist/workflow/history.d.ts +11 -0
  137. package/dist/{lifecycle/transcript.js → workflow/history.js} +24 -8
  138. package/dist/workflow/history.js.map +1 -0
  139. package/dist/workflow/middleware.d.ts +14 -17
  140. package/dist/workflow/middleware.js +109 -95
  141. package/dist/workflow/middleware.js.map +1 -1
  142. package/dist/workflow/move-events.d.ts +21 -0
  143. package/dist/workflow/move-events.js +20 -0
  144. package/dist/workflow/move-events.js.map +1 -0
  145. package/dist/workflow/on-error.js +0 -2
  146. package/dist/workflow/on-error.js.map +1 -1
  147. package/dist/workflow/parks.d.ts +9 -2
  148. package/dist/workflow/parks.js +16 -10
  149. package/dist/workflow/parks.js.map +1 -1
  150. package/dist/workflow/paths.d.ts +9 -9
  151. package/dist/workflow/paths.js +19 -19
  152. package/dist/workflow/paths.js.map +1 -1
  153. package/dist/workflow/render-prompt.d.ts +7 -5
  154. package/dist/workflow/render-prompt.js +22 -37
  155. package/dist/workflow/render-prompt.js.map +1 -1
  156. package/dist/workflow/signature-checks.d.ts +2 -2
  157. package/dist/workflow/snapshot.js +5 -29
  158. package/dist/workflow/snapshot.js.map +1 -1
  159. package/dist/workflow/state.d.ts +14 -42
  160. package/dist/workflow/state.js +20 -33
  161. package/dist/workflow/state.js.map +1 -1
  162. package/dist/workflow/sub-workflow.d.ts +3 -3
  163. package/dist/workflow/sub-workflow.js +3 -7
  164. package/dist/workflow/sub-workflow.js.map +1 -1
  165. package/dist/workflow/tool-service.d.ts +1 -9
  166. package/dist/workflow/tool-service.js +21 -24
  167. package/dist/workflow/tool-service.js.map +1 -1
  168. package/dist/workflow/turn-boundary.d.ts +2 -2
  169. package/dist/workflow/turn-boundary.js +10 -15
  170. package/dist/workflow/turn-boundary.js.map +1 -1
  171. package/dist/workflow/turn-runner.js +5 -6
  172. package/dist/workflow/turn-runner.js.map +1 -1
  173. package/package.json +1 -1
  174. package/skills/archmax-harness/README.md +5 -5
  175. package/skills/archmax-harness/SKILL.md +72 -30
  176. package/skills/archmax-harness/references/backend-integration.md +33 -24
  177. package/skills/archmax-harness/references/cases.md +41 -8
  178. package/skills/archmax-harness/references/{hook-and-test-scripts.md → code-state-and-test-scripts.md} +599 -339
  179. package/skills/archmax-harness/references/code-states-and-scripts.md +115 -0
  180. package/skills/archmax-harness/references/diagnostics.md +40 -7
  181. package/skills/archmax-harness/references/wiring.md +19 -10
  182. package/skills/archmax-harness/references/workflow-schema.md +404 -293
  183. package/skills/archmax-harness/references/workflow-yaml.md +151 -62
  184. package/dist/authoring-skill/archmax-harness/references/hooks-and-scripts.md +0 -89
  185. package/dist/lifecycle/hook-shape.d.ts +0 -44
  186. package/dist/lifecycle/hook-shape.js +0 -66
  187. package/dist/lifecycle/hook-shape.js.map +0 -1
  188. package/dist/lifecycle/runner.d.ts +0 -197
  189. package/dist/lifecycle/runner.js +0 -419
  190. package/dist/lifecycle/runner.js.map +0 -1
  191. package/dist/lifecycle/tool-calls.d.ts +0 -9
  192. package/dist/lifecycle/tool-calls.js +0 -57
  193. package/dist/lifecycle/tool-calls.js.map +0 -1
  194. package/dist/lifecycle/transcript.d.ts +0 -31
  195. package/dist/lifecycle/transcript.js.map +0 -1
  196. package/dist/rubrics/rubrics.d.ts +0 -135
  197. package/dist/rubrics/rubrics.js +0 -145
  198. package/dist/rubrics/rubrics.js.map +0 -1
  199. package/dist/sandbox/assets/parts/core.js +0 -22
  200. package/dist/sandbox/assets/parts/lifecycle-hook.js +0 -47
  201. package/dist/sandbox/bridge.d.ts +0 -16
  202. package/dist/sandbox/bridge.js +0 -95
  203. package/dist/sandbox/bridge.js.map +0 -1
  204. package/dist/workflow/visits.d.ts +0 -21
  205. package/dist/workflow/visits.js +0 -45
  206. package/dist/workflow/visits.js.map +0 -1
  207. package/skills/archmax-harness/references/hooks-and-scripts.md +0 -89
@@ -6,7 +6,7 @@
6
6
  * (`MachineState`) rather than as `z.infer<typeof machineStateSchema>`.
7
7
  */
8
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, signatureEntryObjectSchema, specMetadataSchema, stateBudgetSchema, workflowBudgetSchema, toolsBlockSchema, transitionTypeSchema, triggerDeclarationSchema, workflowTestsConfigSchema, workflowSkillsConfigSchema, workflowMountsConfigSchema, workflowToolsConfigSchema } from "./spec-schema.js";
9
+ import type { allowEntrySchema, forbidEntrySchema, machinePromptCacheSettingsSchema, machineSettingsSchema, machineSpecSchema, machineStateSchema, machineTransitionSchema, stateTypeSchema, runtimeMetadataSchema, skillsBlockSchema, mountsBlockSchema, mountAccessSchema, mountGrantEntrySchema, signatureEntryObjectSchema, specMetadataSchema, stateBudgetSchema, toolsBlockSchema, transitionTypeSchema, triggerDeclarationSchema, workflowTestsConfigSchema, workflowSkillsConfigSchema, workflowMountsConfigSchema, workflowToolsConfigSchema } from "./spec-schema.js";
10
10
  /**
11
11
  * Semantic classification of an outgoing edge, primarily for **human states**: a
12
12
  * UI can render `approve`/`reject`/`refine` as distinct decision buttons, and
@@ -25,31 +25,14 @@ export type TransitionType = z.infer<typeof transitionTypeSchema>;
25
25
  */
26
26
  export type MachineTransition = z.infer<typeof machineTransitionSchema>;
27
27
  /**
28
- * A single lifecycle hook: a tagged object whose single key names its **kind**
29
- * (`script`, `rubric`, or a custom kind an executor is registered for) and
30
- * whose value is the kind's target, optionally beside the reserved
31
- * `max_iterations` sidecar (the bounded grade-and-retry budget of an `after`
32
- * hook). A rubric's grading criteria are its `instructions` in the spec's
33
- * `rubrics:` block, never a hook attribute.
34
- */
35
- export type Hook = z.infer<typeof hookSchema>;
36
- /** A `before`/`after` field: one hook or an ordered list run in sequence. */
37
- export type HookSpec = z.infer<typeof hookSpecSchema>;
38
- /**
39
- * Per-state execution budget. `maxTurns` bounds the model iterations of the
40
- * turn's agent loop; `timeoutMs` aborts the turn when exceeded; `maxParks` bounds
41
- * how many times the state may park itself with `archmax_wait`. Any exhaustion
42
- * is a turn failure subject to `on_error`.
28
+ * Per-state execution budget. `maxTurns` bounds the model calls of the state's
29
+ * visit — the session's agent in an agent state, the grader's own in a grader
30
+ * state; `timeoutMs` aborts a model call (an agent state) or the whole grader
31
+ * run (a grader state) when exceeded; `maxParks` bounds how many times an agent
32
+ * state may park itself with `archmax_wait`. Any exhaustion is a state failure
33
+ * subject to `on_error`. A code state takes no budget: it makes no model call.
43
34
  */
44
35
  export type StateBudget = z.infer<typeof stateBudgetSchema>;
45
- /**
46
- * Workflow-wide execution budget. `maxModelCalls` bounds the model calls of one
47
- * turn (an invocation: a message, a decision, a reply or a delivery) across every
48
- * state; exhausting it is a failure of the current state, subject to `on_error`.
49
- */
50
- export type WorkflowBudget = z.infer<typeof workflowBudgetSchema>;
51
- /** The turn budget a workflow runs under when it declares none. */
52
- export declare const DEFAULT_MAX_MODEL_CALLS = 50;
53
36
  /** One entry of a `tools.allow` list: a bare tool name, or a constrained shape. */
54
37
  export type AllowEntry = z.infer<typeof allowEntrySchema>;
55
38
  /**
@@ -96,7 +79,10 @@ export type MountsBlock = z.infer<typeof mountsBlockSchema>;
96
79
  /**
97
80
  * The kind of a state: `agent` (default) runs a Deep Agent turn that picks a
98
81
  * transition with `archmax_advance`; `human` parks the session and a person picks
99
- * the outgoing edge.
82
+ * the outgoing edge; `grader` runs an isolated grader subagent and `code` runs
83
+ * the state's `script` in the sandbox — the two **automated** types, which the
84
+ * runtime runs on entry with no model call of the session's agent and which
85
+ * leave by `archmax_advance` or end the session by `archmax_raise`.
100
86
  */
101
87
  export type StateType = z.infer<typeof stateTypeSchema>;
102
88
  /**
@@ -158,24 +144,12 @@ export type TriggerDeclaration = z.infer<typeof triggerDeclarationSchema>;
158
144
  * both spellings through `normalizeSignature`, never by hand.
159
145
  */
160
146
  export type SignatureEntryDeclaration = z.infer<typeof signatureEntryObjectSchema>;
161
- /** Workspace-declared expectations the runtime cannot verify from the spec alone. */
162
- export type SpecExtensions = z.infer<typeof specExtensionsSchema>;
163
147
  /**
164
- * Host data, accepted at three positions: the spec root (an authoring UI's canvas
165
- * state), a state (a node's position), and a rubric (a display label). Preserved
166
- * across a load, never read by the runtime, and dropped before the spec is
167
- * hashed.
148
+ * Host data, accepted at two positions: the spec root (an authoring UI's canvas
149
+ * state) and a state (a node's position). Preserved across a load, never read by
150
+ * the runtime, and dropped before the spec is hashed.
168
151
  */
169
152
  export type SpecMetadata = z.infer<typeof specMetadataSchema>;
170
- /**
171
- * One grading rubric: the standard a state's exit is measured against, declared
172
- * in the same document as the state whose hook names it. `instructions` carries
173
- * the criteria and the verdict to return; `max_iterations` bounds the
174
- * grade-and-retry loop (a hook's own sidecar wins over it); `model` names the id
175
- * the grader runs on. A rubric is authoring-plane content: the agent it grades
176
- * can neither read it nor dispatch it.
177
- */
178
- export type RubricDeclaration = z.infer<typeof rubricDeclarationSchema>;
179
153
  /** The whole of `workflow.yaml`. */
180
154
  export type MachineSpec = z.infer<typeof machineSpecSchema>;
181
155
  /** Runtime knobs derived from `settings`, consumed by the harness. */
@@ -190,12 +164,6 @@ export interface HarnessSettings {
190
164
  ttl?: string;
191
165
  };
192
166
  }
193
- export interface LifecycleHook {
194
- /** Normalized ordered `before` hooks (single spec wrapped in a list). */
195
- before?: Hook[];
196
- /** Normalized ordered `after` hooks (single spec wrapped in a list). */
197
- after?: Hook[];
198
- }
199
167
  /**
200
168
  * Whether a spec declares itself out of service — the single interpretation
201
169
  * point for {@link MachineSpec.disabled}; a function because some callers hold a
@@ -1,5 +1,3 @@
1
- /** The turn budget a workflow runs under when it declares none. */
2
- export const DEFAULT_MAX_MODEL_CALLS = 50;
3
1
  /**
4
2
  * Whether a spec declares itself out of service — the single interpretation
5
3
  * point for {@link MachineSpec.disabled}; a function because some callers hold a
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/machine/types.ts"],"names":[],"mappings":"AAsFA,mEAAmE;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAyK1C;;;;;;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"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/machine/types.ts"],"names":[],"mappings":"AAoNA;;;;;;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"}
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Pure — no workspace, no backend, no machine — so an editor can show the same
7
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
8
+ * these. What needs more than the document (code-state scripts on disk, sibling
9
9
  * workflows, the skill registry, kernel probes) is `validate/validate.ts`.
10
10
  */
11
11
  import type { Diagnostic } from "./diagnostic.js";
@@ -1,31 +1,35 @@
1
1
  /**
2
- * `@archmax-ai/harness/sandbox` — the typed authoring surface for lifecycle hook
3
- * scripts. Inside the QuickJS sandbox these names are provided by the prelude
4
- * and the import line is stripped before evaluation; importing from here buys
5
- * IDE completion for the hook input, nothing at runtime.
2
+ * `@archmax-ai/harness/sandbox` — the typed authoring surface for a code state's
3
+ * script (`workflows/<slug>/scripts/<file>.js`). Inside the QuickJS sandbox these
4
+ * names are provided by the prelude and the import line is stripped before
5
+ * evaluation; importing from here buys IDE completion for the state's input,
6
+ * nothing at runtime.
6
7
  *
7
8
  * ```js
8
- * import { veto, ok } from "@archmax-ai/harness/sandbox";
9
- * /** Vetoes a refund the policy forbids. *\/
10
- * export default async function hook({ state, phase, variables, messages, toolCalls, tools }) {
11
- * const refund = JSON.parse(await tools.readFile({ file_path: "scratchpad/refund.json" }));
12
- * if (refund.decision !== "denied") return veto(`order ${refund.orderId} is not eligible`);
13
- * return ok();
14
- * }
9
+ * import { defineCodeState } from "@archmax-ai/harness/sandbox";
10
+ * /** Sends a refund the policy forbids back to the agent. *\/
11
+ * export default defineCodeState(async ({ variables, tools }) => {
12
+ * const refund = JSON.parse(await tools.read_file({ file_path: "scratchpad/refund.json" }));
13
+ * if (refund.decision === "denied") {
14
+ * await tools.archmax_advance({ to: "refund-review", reason: "the denial matches the policy" });
15
+ * } else {
16
+ * await tools.archmax_advance({ to: "refund-request", reason: `order ${refund.orderId} is not eligible` });
17
+ * }
18
+ * });
15
19
  * ```
16
20
  *
17
- * Returning nothing is `ok`; throwing is a veto (hooks are fail-closed).
21
+ * A code state moves the session itself: `tools.archmax_advance({ to, reason })`
22
+ * along one of its transitions, or `tools.archmax_raise({ code, reason })` to end
23
+ * the session as failed. Nothing the script returns is read. A non-terminal code
24
+ * state that finishes without either call fails, as does one that throws. It
25
+ * reads the session it checks with `tools.archmax_get_history()`.
18
26
  */
19
- /** What a hook answers with. */
20
- export interface HookVerdict {
21
- verdict: "ok" | "correct" | "veto";
22
- reason: string;
23
- }
24
27
  /** One transcript message, as plain data. `role` is `user`, `assistant`, `tool`, `system`, or `runtime`. */
25
- export interface HookMessage {
28
+ export interface HistoryMessage {
26
29
  role: string;
27
- /** The message's text; empty on a tool result, whose result `toolCalls` returns. */
30
+ /** The message's text; on a tool result, the result. */
28
31
  text: string;
32
+ /** Assistant messages: the tool calls the message made. */
29
33
  toolCalls?: {
30
34
  id?: string;
31
35
  name: string;
@@ -33,99 +37,59 @@ export interface HookMessage {
33
37
  }[];
34
38
  /** Tool results: the tool that answered. */
35
39
  tool?: string;
36
- /** Tool results: the id of the call answered, as `toolCalls` records carry it. */
40
+ /** Tool results: the id of the call answered. */
37
41
  id?: string;
38
- /** Runtime notes: which kind of note (an arrival, a decision, an error route). */
42
+ /** Runtime notes: which kind of note (an arrival, a decision, an error route, an automated state's move). */
39
43
  note?: string;
40
44
  }
41
- /** One tool call of the session, as `toolCalls` returns it. */
42
- export interface ToolCallRecord {
43
- id?: string;
44
- name: string;
45
- args: unknown;
46
- /** The tool's result, parsed when it is JSON text; absent while `pending`. */
47
- result?: unknown;
48
- /** `rejected` is a call governance refused; `pending` has no result yet. */
49
- status: "completed" | "pending" | "failed" | "rejected";
50
- /** The state and visit (numbered from 1) of the message that made the call. */
51
- state: string;
52
- visit: number;
53
- }
54
- /** What `toolCalls` narrows by; every given key must match, and an unknown key is refused. */
55
- export interface ToolCallFilter {
56
- name?: string;
57
- state?: string;
58
- /** A visit's number, or `"current"`: the visit the hook sees. */
59
- visit?: number | "current";
60
- status?: ToolCallRecord["status"];
61
- /** Only the last `last` matches. */
62
- last?: number;
63
- }
64
- /** The machine context a lifecycle hook receives (also the global `args`). */
65
- export interface HookArgs {
66
- state: string;
67
- phase: "before" | "after";
68
- /** Which trigger started the run — its id. A run's input is in `variables`. */
69
- trigger?: string;
70
- /** The session's variables as a plain `name → value` map. Read-only: assigning changes nothing. */
71
- variables: Record<string, unknown>;
72
- /**
73
- * The transcript of the current visit, newest last: everything since the
74
- * session entered the state it is in (on an advance, the state being left).
75
- */
76
- messages: HookMessage[];
77
- /** The session's tool calls with their results, across every visit, oldest first. */
78
- toolCalls(filter?: ToolCallFilter): Promise<ToolCallRecord[]>;
79
- /** `after` hooks on an advance: the transition being attempted and the agent's reason. */
80
- from?: string;
81
- to?: string;
82
- reason?: string;
83
- }
84
- /**
85
- * The privileged tool-call bridge (`tools.*`): the agent's tools as async
86
- * functions keyed by camelCase name (`tools.readFile({ file_path })`). A hook
87
- * runs on runtime authority, so the state's allow list does not bind it; the
88
- * safety rules, the workflow `policy`, and consumer rules do. A refused call
89
- * rejects with the governance reason.
90
- */
91
- export type SandboxTools = Record<string, (input?: unknown) => Promise<unknown>>;
92
45
  /**
93
46
  * One committed traversal step of a session's audit trail: the state entered,
94
47
  * the kind of edge that committed it, the recorded rationale when one was given
95
48
  * (on `trigger` steps, the trigger id), and — on `sub-workflow` steps — the
96
49
  * child workflow and whether it completed. Each turn begins with a `trigger`
97
- * step; the order read back is the order committed.
50
+ * step; the order read back is the order committed. A move by the session's
51
+ * agent is `agent`, by a grader state `grader`, by a code state `code`.
98
52
  */
99
53
  export interface TrailStep {
100
54
  to: string;
101
- kind: "trigger" | "agent" | "human" | "sub-workflow" | "reset" | "on_error";
55
+ kind: "trigger" | "agent" | "human" | "grader" | "code" | "sub-workflow" | "reset" | "on_error";
102
56
  reason?: string;
103
57
  workflow?: string;
104
58
  status?: "ok" | "error";
105
59
  /** Epoch milliseconds at commit. */
106
60
  ts: number;
107
61
  }
108
- /** The single object a hook function is called with. */
109
- export interface HookInput extends HookArgs {
110
- tools: SandboxTools;
62
+ /** What a code state's script is run with (also the global `args`). */
63
+ export interface CodeStateArgs {
64
+ /** The code state's own slug. */
65
+ state: string;
66
+ /** Which trigger started the turn — its id. A session's input is in `variables`. */
67
+ trigger?: string;
68
+ /** The session's variables as a plain `name → value` map. Read-only: assigning changes nothing — write with `tools.archmax_set_variables`. */
69
+ variables: Record<string, unknown>;
111
70
  }
112
71
  /**
113
- * A hook's return: a verdict, `false` (veto), or nothing (`ok`).
114
- *
115
- * Nothing else is read as an opinion. A hook's return value *is* its verdict,
116
- * so any other object — a misspelled `verdict`, a retired shape like
117
- * `{ ok: false, reason }` — is a verdict the author got wrong and fails closed
118
- * with its keys named, rather than being read as `ok` and silently permitting
119
- * what the hook meant to block. Non-object values (`true`, a number, a bare
120
- * body's incidental completion value) stay `ok`.
121
- *
122
- * These rules are the whole verdict vocabulary, and every hook kind is read
123
- * through them — a custom kind registered via `hookExecutors` included.
72
+ * What `tools.archmax_get_history()` answers, as JSON: the session's whole
73
+ * transcript and its whole trail, oldest first — the same history a grader reads.
74
+ * `const { messages, trail } = JSON.parse(await tools.archmax_get_history())`.
124
75
  */
125
- export type HookResult = HookVerdict | false | void | undefined;
126
- export type HookFn = (input: HookInput) => HookResult | Promise<HookResult>;
127
- export declare function ok(reason?: string): HookVerdict;
128
- export declare function veto(reason: string): HookVerdict;
129
- export declare function correct(reason: string): HookVerdict;
130
- /** Alias for `export default`: `export default defineHook(async (input) => …)`. Identity at runtime. */
131
- export declare function defineHook(fn: HookFn): HookFn;
76
+ export interface SessionHistory {
77
+ messages: HistoryMessage[];
78
+ trail: TrailStep[];
79
+ }
80
+ /**
81
+ * The code state's tools (`tools.*`): exactly its state's surface — its grants,
82
+ * the workflow-wide grant, and its controls (`archmax_advance`, `archmax_raise`,
83
+ * `archmax_get_variables`, `archmax_set_variables`, `archmax_get_history`) — as async functions, by
84
+ * their own name (`tools.read_file`) or camelCase (`tools.readFile`). A tool the
85
+ * state does not offer is `undefined`. Every call is governed against the code
86
+ * state as a model's would be; a refused call rejects with the governance reason.
87
+ */
88
+ export type SandboxTools = Record<string, (input?: unknown) => Promise<unknown>>;
89
+ /** The single object a code state's default export is called with. */
90
+ export interface CodeStateInput extends CodeStateArgs {
91
+ tools: SandboxTools;
92
+ }
93
+ export type CodeStateFn = (input: CodeStateInput) => unknown | Promise<unknown>;
94
+ /** Alias for `export default`: `export default defineCodeState(async (input) => …)`. Identity at runtime. */
95
+ export declare function defineCodeState(fn: CodeStateFn): CodeStateFn;
@@ -1,32 +1,31 @@
1
1
  /**
2
- * `@archmax-ai/harness/sandbox` — the typed authoring surface for lifecycle hook
3
- * scripts. Inside the QuickJS sandbox these names are provided by the prelude
4
- * and the import line is stripped before evaluation; importing from here buys
5
- * IDE completion for the hook input, nothing at runtime.
2
+ * `@archmax-ai/harness/sandbox` — the typed authoring surface for a code state's
3
+ * script (`workflows/<slug>/scripts/<file>.js`). Inside the QuickJS sandbox these
4
+ * names are provided by the prelude and the import line is stripped before
5
+ * evaluation; importing from here buys IDE completion for the state's input,
6
+ * nothing at runtime.
6
7
  *
7
8
  * ```js
8
- * import { veto, ok } from "@archmax-ai/harness/sandbox";
9
- * /** Vetoes a refund the policy forbids. *\/
10
- * export default async function hook({ state, phase, variables, messages, toolCalls, tools }) {
11
- * const refund = JSON.parse(await tools.readFile({ file_path: "scratchpad/refund.json" }));
12
- * if (refund.decision !== "denied") return veto(`order ${refund.orderId} is not eligible`);
13
- * return ok();
14
- * }
9
+ * import { defineCodeState } from "@archmax-ai/harness/sandbox";
10
+ * /** Sends a refund the policy forbids back to the agent. *\/
11
+ * export default defineCodeState(async ({ variables, tools }) => {
12
+ * const refund = JSON.parse(await tools.read_file({ file_path: "scratchpad/refund.json" }));
13
+ * if (refund.decision === "denied") {
14
+ * await tools.archmax_advance({ to: "refund-review", reason: "the denial matches the policy" });
15
+ * } else {
16
+ * await tools.archmax_advance({ to: "refund-request", reason: `order ${refund.orderId} is not eligible` });
17
+ * }
18
+ * });
15
19
  * ```
16
20
  *
17
- * Returning nothing is `ok`; throwing is a veto (hooks are fail-closed).
21
+ * A code state moves the session itself: `tools.archmax_advance({ to, reason })`
22
+ * along one of its transitions, or `tools.archmax_raise({ code, reason })` to end
23
+ * the session as failed. Nothing the script returns is read. A non-terminal code
24
+ * state that finishes without either call fails, as does one that throws. It
25
+ * reads the session it checks with `tools.archmax_get_history()`.
18
26
  */
19
- export function ok(reason = "ok") {
20
- return { verdict: "ok", reason };
21
- }
22
- export function veto(reason) {
23
- return { verdict: "veto", reason };
24
- }
25
- export function correct(reason) {
26
- return { verdict: "correct", reason };
27
- }
28
- /** Alias for `export default`: `export default defineHook(async (input) => …)`. Identity at runtime. */
29
- export function defineHook(fn) {
27
+ /** Alias for `export default`: `export default defineCodeState(async (input) => …)`. Identity at runtime. */
28
+ export function defineCodeState(fn) {
30
29
  return fn;
31
30
  }
32
31
  //# sourceMappingURL=sandbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../src/public/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAoHH,MAAM,UAAU,EAAE,CAAC,MAAM,GAAG,IAAI;IAC9B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,MAAc;IACjC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,EAAE,CAAC;AACZ,CAAC"}
1
+ {"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../src/public/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAwEH,6GAA6G;AAC7G,MAAM,UAAU,eAAe,CAAC,EAAe;IAC7C,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -12,8 +12,8 @@
12
12
  *
13
13
  * What is **not** here, because it cannot be pure: loading a spec from a
14
14
  * backend (`loadMachineSpec`), compiling one (`WorkflowMachine`), the full
15
- * validator (`validateWorkflow`, which also probes the kernel and reads hook
16
- * scripts), resolving a trigger against a machine, and every store and mount.
15
+ * validator (`validateWorkflow`, which also probes the kernel and reads
16
+ * code-state scripts), resolving a trigger against a machine, and every store and mount.
17
17
  * Those stay on the package root.
18
18
  *
19
19
  * Several names here are also on the root. That is deliberate: this subpath
@@ -30,10 +30,12 @@ triggerDeclarationSchema,
30
30
  /** A state's `triggers:` mapping — trigger id to declaration (or `null`). */
31
31
  stateTriggersSchema,
32
32
  /** One transition. */
33
- machineTransitionSchema, transitionTypeSchema, stateTypeSchema, stateBudgetSchema, workflowBudgetSchema, allowEntrySchema, forbidEntrySchema,
33
+ machineTransitionSchema, transitionTypeSchema, stateTypeSchema, stateBudgetSchema, allowEntrySchema, forbidEntrySchema,
34
34
  /** The `*` entry a `forbid` list uses to refuse every tool. */
35
- FORBID_ANY_TOOL, toolsBlockSchema, skillsBlockSchema, mountAccessSchema, mountGrantEntrySchema, mountsBlockSchema, workflowMountsConfigSchema, hookSchema, hookSpecSchema, rubricDeclarationSchema, workflowToolsConfigSchema, workflowSkillsConfigSchema, machineSettingsSchema, machinePromptCacheSettingsSchema, workflowTestsConfigSchema, runtimeMetadataSchema, specExtensionsSchema,
36
- /** The loose slot for host metadata at the root, on a state and on a rubric. */
35
+ FORBID_ANY_TOOL, toolsBlockSchema, skillsBlockSchema, mountAccessSchema, mountGrantEntrySchema, mountsBlockSchema, workflowMountsConfigSchema,
36
+ /** A code state's `script:` — a workflow-relative path confined to `scripts/`. */
37
+ codeScriptPathSchema, workflowToolsConfigSchema, workflowSkillsConfigSchema, machineSettingsSchema, machinePromptCacheSettingsSchema, workflowTestsConfigSchema, runtimeMetadataSchema,
38
+ /** The loose slot for host metadata at the root and on a state. */
37
39
  specMetadataSchema,
38
40
  /** One `requires`/`returns` entry: a bare name, or `{ name, type?, description? }`. */
39
41
  signatureEntrySchema,
@@ -42,7 +44,7 @@ parseMachineSpec,
42
44
  /** The document-level rules alone, over a spec the shape has accepted. */
43
45
  refineSpec, } from "../machine/spec-schema.js";
44
46
  export type { SpecSchemaIssue } from "../machine/spec-schema.js";
45
- export type { MachineSpec, MachineState, MachineTransition, TransitionType, Hook, HookSpec, StateBudget, WorkflowBudget, AllowEntry, ForbidEntry, ToolsBlock, SkillsBlock, MountAccess, MountGrantEntry, MountsBlock, WorkflowMountsConfig, StateType, WorkflowToolsConfig, WorkflowSkillsConfig, MachineSettings, MachinePromptCacheSettings, WorkflowTestsConfig, RuntimeMetadata, TriggerDeclaration, SpecExtensions, SpecMetadata, RubricDeclaration, SignatureEntryDeclaration, } from "../machine/types.js";
47
+ export type { MachineSpec, MachineState, MachineTransition, TransitionType, StateBudget, AllowEntry, ForbidEntry, ToolsBlock, SkillsBlock, MountAccess, MountGrantEntry, MountsBlock, WorkflowMountsConfig, StateType, WorkflowToolsConfig, WorkflowSkillsConfig, MachineSettings, MachinePromptCacheSettings, WorkflowTestsConfig, RuntimeMetadata, TriggerDeclaration, SpecMetadata, SignatureEntryDeclaration, } from "../machine/types.js";
46
48
  /** Whether a spec declares itself out of service (`disabled: true`). */
47
49
  export { specDisabled } from "../machine/types.js";
48
50
  export {
@@ -61,15 +63,6 @@ export {
61
63
  mountNameOf,
62
64
  /** The mount a glob can only ever match inside, or `null` when it is broader. */
63
65
  mountNameOfPattern, } from "../core/zones.js";
64
- export {
65
- /** A `before:`/`after:` declaration as a flat list of hooks. */
66
- normalizeHooks,
67
- /** A hook's kind (`script`, `subagent`, a custom one). */
68
- hookKind,
69
- /** A hook's value: the script path, the rubric name. */
70
- hookValue,
71
- /** The keys that ride beside a hook's kind (`max_iterations`) rather than naming one. */
72
- HOOK_SIDECAR_KEYS, } from "../lifecycle/hook-shape.js";
73
66
  export { SLUG_PATTERN, isSlug } from "../machine/slug.js";
74
67
  export { MANUAL_TRIGGER, DEFAULT_TRIGGER_ID,
75
68
  /** Parse a dotted session path (`triggers.-1.conversationId`). */
@@ -162,15 +155,15 @@ dispatchIdOf,
162
155
  /** The top-level session an id belongs to: the part before the first `~`. */
163
156
  rootSessionIdOf, } from "../sessions/scope.js";
164
157
  export { DEFAULT_WORKFLOW,
165
- /** Where a hook script lives, relative to its workflow directory. */
166
- HOOKS_DIR,
158
+ /** Where a code state's script lives, relative to its workflow directory. */
159
+ SCRIPTS_DIR,
167
160
  /** Where a workspace may override the bundled platform prompt (`.platform/system/GRAPH_STATE.md`). */
168
161
  PLATFORM_PROMPT_PATH,
169
- /** The authored paths of one workflow (`workflow.yaml`, `WORKFLOW.md`, `tests/`, `hooks/`). */
162
+ /** The authored paths of one workflow (`workflow.yaml`, `WORKFLOW.md`, `tests/`, `scripts/`). */
170
163
  workflowPaths,
171
164
  /** The runtime-internal layout of one session's folder. */
172
165
  sessionPaths,
173
- /** Resolve a hook's declared `script:` to an authoring-backend path, or refuse it with a reason. */
174
- resolveHookScript, } from "../workflow/paths.js";
166
+ /** Resolve a code state's declared `script:` to an authoring-backend path, or refuse it with a reason. */
167
+ resolveCodeScript, } from "../workflow/paths.js";
175
168
  export { parseCodeDescription } from "../core/code-description.js";
176
169
  export type { CodeDescription } from "../core/code-description.js";
@@ -12,8 +12,8 @@
12
12
  *
13
13
  * What is **not** here, because it cannot be pure: loading a spec from a
14
14
  * backend (`loadMachineSpec`), compiling one (`WorkflowMachine`), the full
15
- * validator (`validateWorkflow`, which also probes the kernel and reads hook
16
- * scripts), resolving a trigger against a machine, and every store and mount.
15
+ * validator (`validateWorkflow`, which also probes the kernel and reads
16
+ * code-state scripts), resolving a trigger against a machine, and every store and mount.
17
17
  * Those stay on the package root.
18
18
  *
19
19
  * Several names here are also on the root. That is deliberate: this subpath
@@ -31,10 +31,12 @@ triggerDeclarationSchema,
31
31
  /** A state's `triggers:` mapping — trigger id to declaration (or `null`). */
32
32
  stateTriggersSchema,
33
33
  /** One transition. */
34
- machineTransitionSchema, transitionTypeSchema, stateTypeSchema, stateBudgetSchema, workflowBudgetSchema, allowEntrySchema, forbidEntrySchema,
34
+ machineTransitionSchema, transitionTypeSchema, stateTypeSchema, stateBudgetSchema, allowEntrySchema, forbidEntrySchema,
35
35
  /** The `*` entry a `forbid` list uses to refuse every tool. */
36
- FORBID_ANY_TOOL, toolsBlockSchema, skillsBlockSchema, mountAccessSchema, mountGrantEntrySchema, mountsBlockSchema, workflowMountsConfigSchema, hookSchema, hookSpecSchema, rubricDeclarationSchema, workflowToolsConfigSchema, workflowSkillsConfigSchema, machineSettingsSchema, machinePromptCacheSettingsSchema, workflowTestsConfigSchema, runtimeMetadataSchema, specExtensionsSchema,
37
- /** The loose slot for host metadata at the root, on a state and on a rubric. */
36
+ FORBID_ANY_TOOL, toolsBlockSchema, skillsBlockSchema, mountAccessSchema, mountGrantEntrySchema, mountsBlockSchema, workflowMountsConfigSchema,
37
+ /** A code state's `script:` — a workflow-relative path confined to `scripts/`. */
38
+ codeScriptPathSchema, workflowToolsConfigSchema, workflowSkillsConfigSchema, machineSettingsSchema, machinePromptCacheSettingsSchema, workflowTestsConfigSchema, runtimeMetadataSchema,
39
+ /** The loose slot for host metadata at the root and on a state. */
38
40
  specMetadataSchema,
39
41
  /** One `requires`/`returns` entry: a bare name, or `{ name, type?, description? }`. */
40
42
  signatureEntrySchema,
@@ -59,16 +61,6 @@ export {
59
61
  mountNameOf,
60
62
  /** The mount a glob can only ever match inside, or `null` when it is broader. */
61
63
  mountNameOfPattern, } from "../core/zones.js";
62
- // --- Hooks ------------------------------------------------------------------------
63
- export {
64
- /** A `before:`/`after:` declaration as a flat list of hooks. */
65
- normalizeHooks,
66
- /** A hook's kind (`script`, `subagent`, a custom one). */
67
- hookKind,
68
- /** A hook's value: the script path, the rubric name. */
69
- hookValue,
70
- /** The keys that ride beside a hook's kind (`max_iterations`) rather than naming one. */
71
- HOOK_SIDECAR_KEYS, } from "../lifecycle/hook-shape.js";
72
64
  // --- Slugs, triggers, variables --------------------------------------------------
73
65
  export { SLUG_PATTERN, isSlug } from "../machine/slug.js";
74
66
  export { MANUAL_TRIGGER, DEFAULT_TRIGGER_ID,
@@ -161,16 +153,16 @@ dispatchIdOf,
161
153
  rootSessionIdOf, } from "../sessions/scope.js";
162
154
  // --- Paths -------------------------------------------------------------------------------
163
155
  export { DEFAULT_WORKFLOW,
164
- /** Where a hook script lives, relative to its workflow directory. */
165
- HOOKS_DIR,
156
+ /** Where a code state's script lives, relative to its workflow directory. */
157
+ SCRIPTS_DIR,
166
158
  /** Where a workspace may override the bundled platform prompt (`.platform/system/GRAPH_STATE.md`). */
167
159
  PLATFORM_PROMPT_PATH,
168
- /** The authored paths of one workflow (`workflow.yaml`, `WORKFLOW.md`, `tests/`, `hooks/`). */
160
+ /** The authored paths of one workflow (`workflow.yaml`, `WORKFLOW.md`, `tests/`, `scripts/`). */
169
161
  workflowPaths,
170
162
  /** The runtime-internal layout of one session's folder. */
171
163
  sessionPaths,
172
- /** Resolve a hook's declared `script:` to an authoring-backend path, or refuse it with a reason. */
173
- resolveHookScript, } from "../workflow/paths.js";
164
+ /** Resolve a code state's declared `script:` to an authoring-backend path, or refuse it with a reason. */
165
+ resolveCodeScript, } from "../workflow/paths.js";
174
166
  // --- Scripts -------------------------------------------------------------------------------
175
167
  export { parseCodeDescription } from "../core/code-description.js";
176
168
  //# sourceMappingURL=spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/public/spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,gFAAgF;AAEhF,OAAO;AACL,0HAA0H;AAC1H,iBAAiB;AACjB,iBAAiB;AACjB,kBAAkB;AAClB,0FAA0F;AAC1F,wBAAwB;AACxB,6EAA6E;AAC7E,mBAAmB;AACnB,sBAAsB;AACtB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB;AACjB,+DAA+D;AAC/D,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,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AgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB;AACrB,qFAAqF;AACrF,kBAAkB,EAClB,iBAAiB;AACjB,kEAAkE;AAClE,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAG1B,0FAA0F;AAE1F,OAAO;AACL,2EAA2E;AAC3E,kBAAkB,EAClB,mBAAmB;AACnB,0EAA0E;AAC1E,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO;AACL,mEAAmE;AACnE,gBAAgB;AAChB,6EAA6E;AAC7E,iBAAiB;AACjB,4FAA4F;AAC5F,cAAc;AACd,wFAAwF;AACxF,YAAY;AACZ,6EAA6E;AAC7E,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAE9B,4FAA4F;AAE5F,OAAO,EACL,gBAAgB;AAChB,qEAAqE;AACrE,SAAS;AACT,sGAAsG;AACtG,oBAAoB;AACpB,+FAA+F;AAC/F,aAAa;AACb,2DAA2D;AAC3D,YAAY;AACZ,oGAAoG;AACpG,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,8FAA8F;AAE9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/public/spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,gFAAgF;AAEhF,OAAO;AACL,0HAA0H;AAC1H,iBAAiB;AACjB,iBAAiB;AACjB,kBAAkB;AAClB,0FAA0F;AAC1F,wBAAwB;AACxB,6EAA6E;AAC7E,mBAAmB;AACnB,sBAAsB;AACtB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB;AACjB,+DAA+D;AAC/D,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B;AAC1B,kFAAkF;AAClF,oBA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mB;AACnB,0EAA0E;AAC1E,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO;AACL,mEAAmE;AACnE,gBAAgB;AAChB,6EAA6E;AAC7E,iBAAiB;AACjB,4FAA4F;AAC5F,cAAc;AACd,wFAAwF;AACxF,YAAY;AACZ,6EAA6E;AAC7E,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAE9B,4FAA4F;AAE5F,OAAO,EACL,gBAAgB;AAChB,6EAA6E;AAC7E,WAAW;AACX,sGAAsG;AACtG,oBAAoB;AACpB,iGAAiG;AACjG,aAAa;AACb,2DAA2D;AAC3D,YAAY;AACZ,0GAA0G;AAC1G,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,8FAA8F;AAE9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -26,27 +26,26 @@ export interface ResolvedRuntimeContract extends RuntimeContract {
26
26
  /** Offline test-case format implied by this runtime version. */
27
27
  testFormat: string;
28
28
  }
29
+ /** Default contract version applied when metadata is omitted. */
30
+ export declare const DEFAULT_RUNTIME_VERSION = "3";
29
31
  /** The sandbox script contract applied when nothing resolves a runtime version. */
30
32
  export declare const DEFAULT_SANDBOX_VERSION: number;
31
33
  /**
32
- * The execution contexts the runtime assembles a prelude for. The vocabulary
33
- * survived the contract merge; the list of them did not, because nothing
34
- * enumerated it — a context is always named, never iterated.
34
+ * The execution contexts the runtime assembles a prelude for: `ptc` for the
35
+ * agent's own code (`archmax_eval`, `archmax_run`), `code` for a code state's
36
+ * script. A context is always named, never iterated.
35
37
  */
36
- export type SandboxContext = "lifecycle-hook" | "ptc";
38
+ export type SandboxContext = "ptc" | "code";
37
39
  /** The runtime engine this package implements. */
38
40
  export declare const RUNTIME_ENGINE = "archmax-harness";
39
- /** Default contract version applied when metadata is omitted. */
40
- export declare const DEFAULT_RUNTIME_VERSION = "1";
41
41
  /** The contract resolved for workspaces that omit `runtime` metadata. */
42
42
  export declare const DEFAULT_RUNTIME_CONTRACT: RuntimeContract;
43
43
  /**
44
- * The explicit set of runtime contracts the installed runtime supports.
45
- * Version 2 identifies the v2 authoring contract (two-file `workflow.yaml` /
46
- * `WORKFLOW.md` layout, declarative `tests:` block, typed sandbox imports,
47
- * verdict-returning hook functions). Load behavior is
48
- * layout-driven, not version-driven — the version is declarative metadata for
49
- * support checking, validation, and docs. Version 1 remains supported.
44
+ * The explicit set of runtime contracts the installed runtime supports. Version
45
+ * 3 identifies the current authoring contract (two-file `workflow.yaml` /
46
+ * `WORKFLOW.md` layout, declarative `tests:` block, typed sandbox imports, the
47
+ * four state types). Load behavior is layout-driven, not version-driven — the
48
+ * version is declarative metadata for support checking, validation, and docs.
50
49
  */
51
50
  export declare const SUPPORTED_RUNTIME_CONTRACTS: readonly RuntimeContract[];
52
51
  /** Render a contract as `engine@version` for messages and artifacts. */