@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.
- package/LICENSE +21 -0
- package/README.md +219 -0
- package/dist/agent.d.ts +174 -0
- package/dist/agent.js +140 -0
- package/dist/agent.js.map +1 -0
- package/dist/assembly/compose.d.ts +170 -0
- package/dist/assembly/compose.js +391 -0
- package/dist/assembly/compose.js.map +1 -0
- package/dist/assembly/delegation-registry.d.ts +5 -0
- package/dist/assembly/delegation-registry.js +118 -0
- package/dist/assembly/delegation-registry.js.map +1 -0
- package/dist/assembly/index.d.ts +192 -0
- package/dist/assembly/index.js +265 -0
- package/dist/assembly/index.js.map +1 -0
- package/dist/assembly/plain.d.ts +7 -0
- package/dist/assembly/plain.js +41 -0
- package/dist/assembly/plain.js.map +1 -0
- package/dist/authoring-skill/archmax-harness/README.md +76 -0
- package/dist/authoring-skill/archmax-harness/SKILL.md +241 -0
- package/dist/authoring-skill/archmax-harness/references/backend-integration.md +626 -0
- package/dist/authoring-skill/archmax-harness/references/cases.md +41 -0
- package/dist/authoring-skill/archmax-harness/references/diagnostics.md +51 -0
- package/dist/authoring-skill/archmax-harness/references/hook-and-test-scripts.md +1070 -0
- package/dist/authoring-skill/archmax-harness/references/hooks-and-scripts.md +82 -0
- package/dist/authoring-skill/archmax-harness/references/wiring.md +101 -0
- package/dist/authoring-skill/archmax-harness/references/workflow-schema.md +1631 -0
- package/dist/authoring-skill/archmax-harness/references/workflow-yaml.md +241 -0
- package/dist/behaviour/support.d.ts +232 -0
- package/dist/behaviour/support.js +339 -0
- package/dist/behaviour/support.js.map +1 -0
- package/dist/cli/banner.d.ts +11 -0
- package/dist/cli/banner.js +29 -0
- package/dist/cli/banner.js.map +1 -0
- package/dist/cli/bootstrap.d.ts +33 -0
- package/dist/cli/bootstrap.js +153 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/command.d.ts +39 -0
- package/dist/cli/command.js +97 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/state-flow.d.ts +46 -0
- package/dist/cli/state-flow.js +268 -0
- package/dist/cli/state-flow.js.map +1 -0
- package/dist/cli/style.d.ts +41 -0
- package/dist/cli/style.js +64 -0
- package/dist/cli/style.js.map +1 -0
- package/dist/cli/turn.d.ts +41 -0
- package/dist/cli/turn.js +161 -0
- package/dist/cli/turn.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +426 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/code-description.d.ts +22 -0
- package/dist/core/code-description.js +38 -0
- package/dist/core/code-description.js.map +1 -0
- package/dist/core/deepagents.d.ts +183 -0
- package/dist/core/deepagents.js +128 -0
- package/dist/core/deepagents.js.map +1 -0
- package/dist/core/events.d.ts +350 -0
- package/dist/core/events.js +205 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/frontmatter.d.ts +15 -0
- package/dist/core/frontmatter.js +32 -0
- package/dist/core/frontmatter.js.map +1 -0
- package/dist/core/listing-redact.d.ts +37 -0
- package/dist/core/listing-redact.js +88 -0
- package/dist/core/listing-redact.js.map +1 -0
- package/dist/core/match.d.ts +26 -0
- package/dist/core/match.js +75 -0
- package/dist/core/match.js.map +1 -0
- package/dist/core/message-readers.d.ts +84 -0
- package/dist/core/message-readers.js +159 -0
- package/dist/core/message-readers.js.map +1 -0
- package/dist/core/messages.d.ts +49 -0
- package/dist/core/messages.js +85 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/mount-prompt.d.ts +28 -0
- package/dist/core/mount-prompt.js +55 -0
- package/dist/core/mount-prompt.js.map +1 -0
- package/dist/core/mount-redact.d.ts +28 -0
- package/dist/core/mount-redact.js +32 -0
- package/dist/core/mount-redact.js.map +1 -0
- package/dist/core/mounts.d.ts +88 -0
- package/dist/core/mounts.js +147 -0
- package/dist/core/mounts.js.map +1 -0
- package/dist/core/path-mapping.d.ts +52 -0
- package/dist/core/path-mapping.js +113 -0
- package/dist/core/path-mapping.js.map +1 -0
- package/dist/core/platform-prompt.generated.d.ts +2 -0
- package/dist/core/platform-prompt.generated.js +4 -0
- package/dist/core/platform-prompt.generated.js.map +1 -0
- package/dist/core/prompt.d.ts +42 -0
- package/dist/core/prompt.js +75 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/session-id.d.ts +38 -0
- package/dist/core/session-id.js +61 -0
- package/dist/core/session-id.js.map +1 -0
- package/dist/core/session-store.d.ts +85 -0
- package/dist/core/session-store.js +149 -0
- package/dist/core/session-store.js.map +1 -0
- package/dist/core/session-zone.d.ts +54 -0
- package/dist/core/session-zone.js +82 -0
- package/dist/core/session-zone.js.map +1 -0
- package/dist/core/skill-prompt.d.ts +31 -0
- package/dist/core/skill-prompt.js +54 -0
- package/dist/core/skill-prompt.js.map +1 -0
- package/dist/core/skill-redact.d.ts +15 -0
- package/dist/core/skill-redact.js +27 -0
- package/dist/core/skill-redact.js.map +1 -0
- package/dist/core/skills.d.ts +172 -0
- package/dist/core/skills.js +214 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/tool-mocks.d.ts +23 -0
- package/dist/core/tool-mocks.js +39 -0
- package/dist/core/tool-mocks.js.map +1 -0
- package/dist/core/tool-telemetry.d.ts +16 -0
- package/dist/core/tool-telemetry.js +40 -0
- package/dist/core/tool-telemetry.js.map +1 -0
- package/dist/core/usage.d.ts +114 -0
- package/dist/core/usage.js +226 -0
- package/dist/core/usage.js.map +1 -0
- package/dist/core/workspace-context.d.ts +136 -0
- package/dist/core/workspace-context.js +178 -0
- package/dist/core/workspace-context.js.map +1 -0
- package/dist/core/workspace-prompt.d.ts +7 -0
- package/dist/core/workspace-prompt.js +102 -0
- package/dist/core/workspace-prompt.js.map +1 -0
- package/dist/core/workspace-router.d.ts +61 -0
- package/dist/core/workspace-router.js +145 -0
- package/dist/core/workspace-router.js.map +1 -0
- package/dist/core/workspace.d.ts +85 -0
- package/dist/core/workspace.js +193 -0
- package/dist/core/workspace.js.map +1 -0
- package/dist/core/zones.d.ts +181 -0
- package/dist/core/zones.js +202 -0
- package/dist/core/zones.js.map +1 -0
- package/dist/env.d.ts +99 -0
- package/dist/env.js +271 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +265 -0
- package/dist/index.js +197 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel/kernel.d.ts +192 -0
- package/dist/kernel/kernel.js +751 -0
- package/dist/kernel/kernel.js.map +1 -0
- package/dist/lifecycle/hook-shape.d.ts +44 -0
- package/dist/lifecycle/hook-shape.js +66 -0
- package/dist/lifecycle/hook-shape.js.map +1 -0
- package/dist/lifecycle/runner.d.ts +177 -0
- package/dist/lifecycle/runner.js +372 -0
- package/dist/lifecycle/runner.js.map +1 -0
- package/dist/lifecycle/transcript.d.ts +27 -0
- package/dist/lifecycle/transcript.js +43 -0
- package/dist/lifecycle/transcript.js.map +1 -0
- package/dist/machine/allow.d.ts +65 -0
- package/dist/machine/allow.js +107 -0
- package/dist/machine/allow.js.map +1 -0
- package/dist/machine/delegation.d.ts +9 -0
- package/dist/machine/delegation.js +10 -0
- package/dist/machine/delegation.js.map +1 -0
- package/dist/machine/diagnostic.d.ts +14 -0
- package/dist/machine/diagnostic.js +2 -0
- package/dist/machine/diagnostic.js.map +1 -0
- package/dist/machine/lint-spec.d.ts +4 -0
- package/dist/machine/lint-spec.js +266 -0
- package/dist/machine/lint-spec.js.map +1 -0
- package/dist/machine/load-spec.d.ts +90 -0
- package/dist/machine/load-spec.js +120 -0
- package/dist/machine/load-spec.js.map +1 -0
- package/dist/machine/machine.d.ts +273 -0
- package/dist/machine/machine.js +551 -0
- package/dist/machine/machine.js.map +1 -0
- package/dist/machine/mount-grants.d.ts +25 -0
- package/dist/machine/mount-grants.js +24 -0
- package/dist/machine/mount-grants.js.map +1 -0
- package/dist/machine/slug.d.ts +14 -0
- package/dist/machine/slug.js +17 -0
- package/dist/machine/slug.js.map +1 -0
- package/dist/machine/spec-schema.d.ts +662 -0
- package/dist/machine/spec-schema.js +717 -0
- package/dist/machine/spec-schema.js.map +1 -0
- package/dist/machine/tool-names.d.ts +98 -0
- package/dist/machine/tool-names.js +144 -0
- package/dist/machine/tool-names.js.map +1 -0
- package/dist/machine/triggers.d.ts +114 -0
- package/dist/machine/triggers.js +165 -0
- package/dist/machine/triggers.js.map +1 -0
- package/dist/machine/types.d.ts +186 -0
- package/dist/machine/types.js +12 -0
- package/dist/machine/types.js.map +1 -0
- package/dist/machine/validate-spec.d.ts +42 -0
- package/dist/machine/validate-spec.js +29 -0
- package/dist/machine/validate-spec.js.map +1 -0
- package/dist/machine/variables.d.ts +196 -0
- package/dist/machine/variables.js +415 -0
- package/dist/machine/variables.js.map +1 -0
- package/dist/public/cli.d.ts +15 -0
- package/dist/public/cli.js +14 -0
- package/dist/public/cli.js.map +1 -0
- package/dist/public/messages.d.ts +33 -0
- package/dist/public/messages.js +33 -0
- package/dist/public/messages.js.map +1 -0
- package/dist/public/sandbox.d.ts +99 -0
- package/dist/public/sandbox.js +32 -0
- package/dist/public/sandbox.js.map +1 -0
- package/dist/public/spec.d.ts +147 -0
- package/dist/public/spec.js +149 -0
- package/dist/public/spec.js.map +1 -0
- package/dist/public/testing.d.ts +71 -0
- package/dist/public/testing.js +39 -0
- package/dist/public/testing.js.map +1 -0
- package/dist/rubrics/rubrics.d.ts +135 -0
- package/dist/rubrics/rubrics.js +145 -0
- package/dist/rubrics/rubrics.js.map +1 -0
- package/dist/runtime/contract.d.ts +73 -0
- package/dist/runtime/contract.js +96 -0
- package/dist/runtime/contract.js.map +1 -0
- package/dist/sandbox/assets/parts/core.js +22 -0
- package/dist/sandbox/assets/parts/lifecycle-hook.js +47 -0
- package/dist/sandbox/bridge.d.ts +16 -0
- package/dist/sandbox/bridge.js +95 -0
- package/dist/sandbox/bridge.js.map +1 -0
- package/dist/sandbox/executor.d.ts +46 -0
- package/dist/sandbox/executor.js +119 -0
- package/dist/sandbox/executor.js.map +1 -0
- package/dist/sandbox/imports.d.ts +33 -0
- package/dist/sandbox/imports.js +67 -0
- package/dist/sandbox/imports.js.map +1 -0
- package/dist/sandbox/prelude.d.ts +12 -0
- package/dist/sandbox/prelude.js +51 -0
- package/dist/sandbox/prelude.js.map +1 -0
- package/dist/sandbox/ptc-gateway.d.ts +104 -0
- package/dist/sandbox/ptc-gateway.js +167 -0
- package/dist/sandbox/ptc-gateway.js.map +1 -0
- package/dist/sandbox/runtime.d.ts +59 -0
- package/dist/sandbox/runtime.js +51 -0
- package/dist/sandbox/runtime.js.map +1 -0
- package/dist/sandbox/tools.d.ts +34 -0
- package/dist/sandbox/tools.js +147 -0
- package/dist/sandbox/tools.js.map +1 -0
- package/dist/sessions/operations.d.ts +79 -0
- package/dist/sessions/operations.js +121 -0
- package/dist/sessions/operations.js.map +1 -0
- package/dist/sessions/resolve.d.ts +97 -0
- package/dist/sessions/resolve.js +145 -0
- package/dist/sessions/resolve.js.map +1 -0
- package/dist/sessions/resume.d.ts +242 -0
- package/dist/sessions/resume.js +288 -0
- package/dist/sessions/resume.js.map +1 -0
- package/dist/sessions/scope.d.ts +99 -0
- package/dist/sessions/scope.js +145 -0
- package/dist/sessions/scope.js.map +1 -0
- package/dist/sessions/summary.d.ts +65 -0
- package/dist/sessions/summary.js +56 -0
- package/dist/sessions/summary.js.map +1 -0
- package/dist/testing/assertions.d.ts +30 -0
- package/dist/testing/assertions.js +231 -0
- package/dist/testing/assertions.js.map +1 -0
- package/dist/testing/case-document.d.ts +141 -0
- package/dist/testing/case-document.js +51 -0
- package/dist/testing/case-document.js.map +1 -0
- package/dist/testing/case-schema.d.ts +29 -0
- package/dist/testing/case-schema.js +519 -0
- package/dist/testing/case-schema.js.map +1 -0
- package/dist/testing/discovery.d.ts +10 -0
- package/dist/testing/discovery.js +24 -0
- package/dist/testing/discovery.js.map +1 -0
- package/dist/testing/driver.d.ts +78 -0
- package/dist/testing/driver.js +117 -0
- package/dist/testing/driver.js.map +1 -0
- package/dist/testing/grade.d.ts +116 -0
- package/dist/testing/grade.js +261 -0
- package/dist/testing/grade.js.map +1 -0
- package/dist/testing/interpreter.d.ts +55 -0
- package/dist/testing/interpreter.js +103 -0
- package/dist/testing/interpreter.js.map +1 -0
- package/dist/testing/mock-middleware.d.ts +5 -0
- package/dist/testing/mock-middleware.js +33 -0
- package/dist/testing/mock-middleware.js.map +1 -0
- package/dist/testing/runner.d.ts +205 -0
- package/dist/testing/runner.js +266 -0
- package/dist/testing/runner.js.map +1 -0
- package/dist/testing/target.d.ts +27 -0
- package/dist/testing/target.js +21 -0
- package/dist/testing/target.js.map +1 -0
- package/dist/validate/validate.d.ts +41 -0
- package/dist/validate/validate.js +669 -0
- package/dist/validate/validate.js.map +1 -0
- package/dist/workflow/agent-tools.d.ts +10 -0
- package/dist/workflow/agent-tools.js +10 -0
- package/dist/workflow/agent-tools.js.map +1 -0
- package/dist/workflow/checkpointer.d.ts +52 -0
- package/dist/workflow/checkpointer.js +200 -0
- package/dist/workflow/checkpointer.js.map +1 -0
- package/dist/workflow/control-tools.d.ts +174 -0
- package/dist/workflow/control-tools.js +468 -0
- package/dist/workflow/control-tools.js.map +1 -0
- package/dist/workflow/governance.d.ts +104 -0
- package/dist/workflow/governance.js +546 -0
- package/dist/workflow/governance.js.map +1 -0
- package/dist/workflow/middleware.d.ts +85 -0
- package/dist/workflow/middleware.js +283 -0
- package/dist/workflow/middleware.js.map +1 -0
- package/dist/workflow/on-error.d.ts +25 -0
- package/dist/workflow/on-error.js +58 -0
- package/dist/workflow/on-error.js.map +1 -0
- package/dist/workflow/parks.d.ts +46 -0
- package/dist/workflow/parks.js +513 -0
- package/dist/workflow/parks.js.map +1 -0
- package/dist/workflow/paths.d.ts +67 -0
- package/dist/workflow/paths.js +108 -0
- package/dist/workflow/paths.js.map +1 -0
- package/dist/workflow/prompt-cache.d.ts +70 -0
- package/dist/workflow/prompt-cache.js +103 -0
- package/dist/workflow/prompt-cache.js.map +1 -0
- package/dist/workflow/prompt-pruning.d.ts +20 -0
- package/dist/workflow/prompt-pruning.js +83 -0
- package/dist/workflow/prompt-pruning.js.map +1 -0
- package/dist/workflow/render-prompt.d.ts +45 -0
- package/dist/workflow/render-prompt.js +140 -0
- package/dist/workflow/render-prompt.js.map +1 -0
- package/dist/workflow/runtime-config.d.ts +7 -0
- package/dist/workflow/runtime-config.js +9 -0
- package/dist/workflow/runtime-config.js.map +1 -0
- package/dist/workflow/session-artifacts.d.ts +90 -0
- package/dist/workflow/session-artifacts.js +134 -0
- package/dist/workflow/session-artifacts.js.map +1 -0
- package/dist/workflow/session-view.d.ts +31 -0
- package/dist/workflow/session-view.js +94 -0
- package/dist/workflow/session-view.js.map +1 -0
- package/dist/workflow/snapshot.d.ts +14 -0
- package/dist/workflow/snapshot.js +97 -0
- package/dist/workflow/snapshot.js.map +1 -0
- package/dist/workflow/state.d.ts +347 -0
- package/dist/workflow/state.js +322 -0
- package/dist/workflow/state.js.map +1 -0
- package/dist/workflow/sub-workflow.d.ts +174 -0
- package/dist/workflow/sub-workflow.js +392 -0
- package/dist/workflow/sub-workflow.js.map +1 -0
- package/dist/workflow/tool-service.d.ts +48 -0
- package/dist/workflow/tool-service.js +291 -0
- package/dist/workflow/tool-service.js.map +1 -0
- package/dist/workflow/turn-boundary.d.ts +39 -0
- package/dist/workflow/turn-boundary.js +128 -0
- package/dist/workflow/turn-boundary.js.map +1 -0
- package/dist/workflow/turn-runner.d.ts +40 -0
- package/dist/workflow/turn-runner.js +122 -0
- package/dist/workflow/turn-runner.js.map +1 -0
- package/dist/workflow/workflow-tools.d.ts +46 -0
- package/dist/workflow/workflow-tools.js +90 -0
- package/dist/workflow/workflow-tools.js.map +1 -0
- package/package.json +119 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { runContextFromMessages } from "../core/messages.js";
|
|
2
|
+
import { createSubagentBridgeDispatch } from "../sandbox/bridge.js";
|
|
3
|
+
import { PROCESS_SESSION, } from "../sandbox/executor.js";
|
|
4
|
+
import { resolvePtcTools } from "../sandbox/tools.js";
|
|
5
|
+
import { afterHookLabel, hookKind, hookMaxIterations, iterationKey } from "./hook-shape.js";
|
|
6
|
+
import { hookTranscript } from "./transcript.js";
|
|
7
|
+
import { buildRubricTaskDescription, isRubricVerdict, resolveRubricResponseFormat, rubricId, } from "../rubrics/rubrics.js";
|
|
8
|
+
import { createWorkflowEventEmitter, } from "../core/events.js";
|
|
9
|
+
import { decide, reduceHookFact } from "../kernel/kernel.js";
|
|
10
|
+
/**
|
|
11
|
+
* Interpret a lifecycle hook's return value into a decision, an error, or
|
|
12
|
+
* `null` (no opinion — proceed).
|
|
13
|
+
*
|
|
14
|
+
* **One contract for every hook kind**, the one `HookResult` declares: a verdict
|
|
15
|
+
* object decides, a bare `false` vetoes, returning nothing is `ok`, and any
|
|
16
|
+
* *other* object fails closed with its keys named. A hook's return value is its
|
|
17
|
+
* verdict and nothing else, so an object that is not one is a verdict its author
|
|
18
|
+
* got wrong; reading it as `ok` would silently permit what the hook meant to
|
|
19
|
+
* block, with nothing said.
|
|
20
|
+
*
|
|
21
|
+
* A **script** hook's value arrives already reduced — the sandbox wrapper
|
|
22
|
+
* applies the same rules and throws on the last one — so what reaches here from
|
|
23
|
+
* a script is a verdict or an error outcome. The rules are restated because a
|
|
24
|
+
* custom `hookExecutors` kind hands its value through raw, and a consumer's
|
|
25
|
+
* executor is held to the same contract as a script: one governance vocabulary,
|
|
26
|
+
* whoever implements the kind.
|
|
27
|
+
*/
|
|
28
|
+
export function parseLifecycleDecision(outcome) {
|
|
29
|
+
if (!outcome.ok)
|
|
30
|
+
return { error: outcome.error?.message ?? "script error" };
|
|
31
|
+
const value = outcome.value;
|
|
32
|
+
if (isRubricVerdict(value)) {
|
|
33
|
+
return {
|
|
34
|
+
verdict: value.verdict,
|
|
35
|
+
reason: value.reason,
|
|
36
|
+
...(value.rubric !== undefined ? { rubric: value.rubric } : {}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (value === false)
|
|
40
|
+
return { verdict: "veto", reason: "precondition not met" };
|
|
41
|
+
if (value !== null && typeof value === "object") {
|
|
42
|
+
return {
|
|
43
|
+
error: `hook returned ${describeNonVerdict(value)}, which is not a verdict — return ` +
|
|
44
|
+
`{ verdict: "ok" | "correct" | "veto", reason }, false, or nothing at all`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Name a non-verdict object by its keys, never its values, so a diagnostic
|
|
51
|
+
* cannot leak what the hook was inspecting. Mirrors `__hookShape` in the
|
|
52
|
+
* sandbox prelude, which does the same for a script hook.
|
|
53
|
+
*/
|
|
54
|
+
function describeNonVerdict(value) {
|
|
55
|
+
if (Array.isArray(value))
|
|
56
|
+
return "an array";
|
|
57
|
+
const keys = Object.keys(value);
|
|
58
|
+
if (keys.length === 0)
|
|
59
|
+
return "an object with no keys";
|
|
60
|
+
const shown = keys
|
|
61
|
+
.slice(0, 6)
|
|
62
|
+
.map((key) => `'${key}'`)
|
|
63
|
+
.join(", ");
|
|
64
|
+
return `an object with ${keys.length > 6 ? "keys including " : "keys "}${shown}`;
|
|
65
|
+
}
|
|
66
|
+
/** The built-in hook kinds, which consumer executors may not shadow. */
|
|
67
|
+
export const BUILTIN_HOOK_KINDS = ["script", "rubric"];
|
|
68
|
+
/** Short raw-output excerpt surfaced when a judge response cannot be parsed. */
|
|
69
|
+
function snippet(value) {
|
|
70
|
+
let text;
|
|
71
|
+
try {
|
|
72
|
+
text = typeof value === "string" ? value : JSON.stringify(value);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
text = String(value);
|
|
76
|
+
}
|
|
77
|
+
if (text === undefined || text === "undefined")
|
|
78
|
+
text = "(no output)";
|
|
79
|
+
return text.length > 200 ? `${text.slice(0, 200)}…` : text;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Runs deterministic `before`/`after` hooks (scripts or grading rubrics) at the
|
|
83
|
+
* machine's fixed points, in the same backend-backed interpreter as the model's
|
|
84
|
+
* own sandbox tool calls.
|
|
85
|
+
*/
|
|
86
|
+
export class LifecycleRunner {
|
|
87
|
+
machine;
|
|
88
|
+
executor;
|
|
89
|
+
rubrics;
|
|
90
|
+
ptcNames;
|
|
91
|
+
emit;
|
|
92
|
+
/** Hook kind → executor. Built-ins (`script`, `rubric`) plus registered custom kinds. */
|
|
93
|
+
hookExecutors;
|
|
94
|
+
/**
|
|
95
|
+
* Maps a hook's declared `script:` value to the path its source is read from.
|
|
96
|
+
* Injected so the runner stays ignorant of workspace layout: the harness binds
|
|
97
|
+
* it to the running workflow (workflow-relative, confined to `hooks/`). The
|
|
98
|
+
* identity default keeps a bare runner working.
|
|
99
|
+
*/
|
|
100
|
+
resolveScript;
|
|
101
|
+
/** Deprecations already reported — each is said once per assembly. */
|
|
102
|
+
constructor(machine, executor, rubrics, ptcNames, hookExecutors, onEvent, opts = {}) {
|
|
103
|
+
this.machine = machine;
|
|
104
|
+
this.executor = executor;
|
|
105
|
+
this.rubrics = rubrics;
|
|
106
|
+
this.ptcNames = ptcNames;
|
|
107
|
+
this.emit = createWorkflowEventEmitter(onEvent);
|
|
108
|
+
this.resolveScript = opts.resolveScript ?? ((declared) => ({ ok: true, path: declared }));
|
|
109
|
+
// Built-ins first; consumer executors add kinds alongside them (built-ins
|
|
110
|
+
// are non-shadowable, enforced at assembly).
|
|
111
|
+
this.hookExecutors = new Map([
|
|
112
|
+
["script", (hook, ctx, args) => this.runScript(String(hook.script), ctx, args)],
|
|
113
|
+
]);
|
|
114
|
+
for (const [kind, exec] of Object.entries(hookExecutors ?? {})) {
|
|
115
|
+
this.hookExecutors.set(kind, exec);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
resolvePtcTools(allTools) {
|
|
119
|
+
return resolvePtcTools(allTools, this.ptcNames);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The runtime's own dispatch for an inline grader, through the framework
|
|
123
|
+
* `task` tool. Reached only by {@link runRubric} — never wired into a script's
|
|
124
|
+
* sandbox, which has no name to dispatch by.
|
|
125
|
+
*/
|
|
126
|
+
rubricDispatch(ctx, lifecycleArgs) {
|
|
127
|
+
if (!ctx.taskTool)
|
|
128
|
+
return undefined;
|
|
129
|
+
const base = createSubagentBridgeDispatch(ctx.taskTool, ctx.config, {
|
|
130
|
+
emit: this.emit,
|
|
131
|
+
...(typeof lifecycleArgs.state === "string" ? { state: lifecycleArgs.state } : {}),
|
|
132
|
+
});
|
|
133
|
+
return async (input) => {
|
|
134
|
+
const rubric = this.rubrics.get(input.subagentType);
|
|
135
|
+
const description = input.description?.trim() ||
|
|
136
|
+
buildRubricTaskDescription({ ...lifecycleArgs, ...runContextFromMessages(ctx.messages) });
|
|
137
|
+
const responseSchema = input.responseSchema ?? (rubric ? resolveRubricResponseFormat(rubric) : undefined);
|
|
138
|
+
return base({
|
|
139
|
+
description,
|
|
140
|
+
subagentType: input.subagentType,
|
|
141
|
+
...(responseSchema !== undefined
|
|
142
|
+
? { responseSchema: responseSchema }
|
|
143
|
+
: {}),
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
async runScript(script, ctx, args) {
|
|
148
|
+
// A hook that cannot be placed is a hook that cannot be trusted: refusing
|
|
149
|
+
// here produces an error outcome, and an errored hook vetoes fail-closed —
|
|
150
|
+
// the same posture as a hook that throws.
|
|
151
|
+
const resolved = this.resolveScript(script);
|
|
152
|
+
if (!resolved.ok) {
|
|
153
|
+
return {
|
|
154
|
+
ok: false,
|
|
155
|
+
value: undefined,
|
|
156
|
+
logs: [],
|
|
157
|
+
error: { message: resolved.reason },
|
|
158
|
+
formatted: `error: ${resolved.reason}`,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return this.executor.runFile(resolved.path, {
|
|
162
|
+
sessionId: ctx.sessionId,
|
|
163
|
+
sessionNamespace: PROCESS_SESSION,
|
|
164
|
+
args,
|
|
165
|
+
tools: ctx.tools,
|
|
166
|
+
// No `task()` for a script hook: an inline rubric has no name a script
|
|
167
|
+
// could pass, so there is nothing to dispatch by. A script that wants a
|
|
168
|
+
// model verdict gets a `rubric` hook declared beside it in the same list.
|
|
169
|
+
lifecycle: true,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
async runRubric(name, ctx, args) {
|
|
173
|
+
const dispatch = this.rubricDispatch(ctx, args);
|
|
174
|
+
if (!dispatch) {
|
|
175
|
+
const message = `rubric '${name}' could not be dispatched (no task tool)`;
|
|
176
|
+
return { ok: false, value: undefined, logs: [], error: { message }, formatted: `error: ${message}` };
|
|
177
|
+
}
|
|
178
|
+
const rubric = this.rubrics.get(name);
|
|
179
|
+
const responseSchema = rubric ? resolveRubricResponseFormat(rubric) : undefined;
|
|
180
|
+
try {
|
|
181
|
+
const value = await dispatch({
|
|
182
|
+
subagentType: name,
|
|
183
|
+
// The grader's payload keeps the compact `userRequest`/`history` view a
|
|
184
|
+
// rubric's `instructions` are written against.
|
|
185
|
+
description: buildRubricTaskDescription({ ...args, ...runContextFromMessages(ctx.messages) }),
|
|
186
|
+
...(responseSchema !== undefined ? { responseSchema } : {}),
|
|
187
|
+
});
|
|
188
|
+
// Fail closed on unreadable grader output, exactly like a thrown error: a
|
|
189
|
+
// grader whose verdict cannot be read has approved nothing.
|
|
190
|
+
const verdict = value && typeof value === "object" && isRubricVerdict(value)
|
|
191
|
+
? { ...value, rubric: name }
|
|
192
|
+
: {
|
|
193
|
+
verdict: "veto",
|
|
194
|
+
reason: `rubric '${name}' returned no parseable verdict: ${snippet(value)}`,
|
|
195
|
+
rubric: name,
|
|
196
|
+
};
|
|
197
|
+
return { ok: true, value: verdict, logs: [], formatted: JSON.stringify(verdict) };
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
const message = err.message ?? String(err);
|
|
201
|
+
return { ok: false, value: undefined, logs: [], error: { message }, formatted: `error: ${message}` };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Dispatch a single tagged hook through its kind's registered executor.
|
|
206
|
+
* An unknown kind (no registered executor) produces an error outcome that
|
|
207
|
+
* reduces to a fail-closed veto — the same path as any hook execution error.
|
|
208
|
+
*/
|
|
209
|
+
async runHook(hook, ctx, args, at) {
|
|
210
|
+
const kind = hookKind(hook);
|
|
211
|
+
// `rubric` is serviced here rather than through the executor map, because
|
|
212
|
+
// dispatching an inline grader needs the hook's *position* — that is the id
|
|
213
|
+
// the runtime registered it under, and a `HookExecutor` sees only the hook.
|
|
214
|
+
// The kind is still non-shadowable: assembly checks `BUILTIN_HOOK_KINDS`.
|
|
215
|
+
if (kind === "rubric") {
|
|
216
|
+
return this.runRubric(rubricId(at.state, at.phase, at.index), ctx, args);
|
|
217
|
+
}
|
|
218
|
+
const executor = kind ? this.hookExecutors.get(kind) : undefined;
|
|
219
|
+
if (!executor) {
|
|
220
|
+
const message = kind
|
|
221
|
+
? `no executor registered for hook kind '${kind}'`
|
|
222
|
+
: `malformed hook (expected a single-key tagged object)`;
|
|
223
|
+
return { ok: false, value: undefined, logs: [], error: { message }, formatted: `error: ${message}` };
|
|
224
|
+
}
|
|
225
|
+
return executor(hook, ctx, args);
|
|
226
|
+
}
|
|
227
|
+
applyDecision(state, label, decision, ctx, opts) {
|
|
228
|
+
this.emit({
|
|
229
|
+
type: "hook-verdict",
|
|
230
|
+
state,
|
|
231
|
+
phase: opts.phase,
|
|
232
|
+
label,
|
|
233
|
+
verdict: decision.verdict,
|
|
234
|
+
reason: decision.reason,
|
|
235
|
+
});
|
|
236
|
+
const budget = iterationKey(state, opts.phase, opts.index);
|
|
237
|
+
const used = ctx.iterations[budget] ?? 0;
|
|
238
|
+
// Iteration budget, uniform across hook kinds: the hook-level
|
|
239
|
+
// `max_iterations` sidecar wins (it describes *this* state's retry loop); a
|
|
240
|
+
// rubric hook falls back to the rubric's own `max_iterations`; otherwise 0
|
|
241
|
+
// (a `correct` hard-vetoes).
|
|
242
|
+
const rubric = decision.rubric ? this.rubrics.get(decision.rubric) : undefined;
|
|
243
|
+
const maxIterations = opts.maxIterations ?? rubric?.max_iterations ?? 0;
|
|
244
|
+
// The reduction rule lives in the decision kernel; the runner only executes
|
|
245
|
+
// hooks and applies the verdict (correction bookkeeping + events).
|
|
246
|
+
const verdict = reduceHookFact({ ...decision, maxIterations, iterationsUsed: used }, { phase: opts.phase, veto: opts.veto, to: opts.to });
|
|
247
|
+
if (verdict.decision === "block") {
|
|
248
|
+
if (verdict.correctionConsumed)
|
|
249
|
+
ctx.iterations[budget] = used + 1;
|
|
250
|
+
const reason = verdict.reason ?? decision.reason;
|
|
251
|
+
this.emit({ type: "hook-rejected", state, phase: opts.phase, reason });
|
|
252
|
+
// Exhausted iteration budget (after-phase correction flow only) cannot be
|
|
253
|
+
// fixed by retrying in place; a deliberate veto, an in-budget correction,
|
|
254
|
+
// or a before-phase rejection can. The kernel decides which this is, from
|
|
255
|
+
// the same reduction that wrote the reason.
|
|
256
|
+
return { reason, terminal: verdict.budgetExhausted === true };
|
|
257
|
+
}
|
|
258
|
+
// Only this hook's own budget is released: a passing hook ahead of a
|
|
259
|
+
// correcting one must not hand the latter a fresh budget every attempt.
|
|
260
|
+
delete ctx.iterations[budget];
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
async runPhase(state, phase, ctx, extraArgs, veto = false) {
|
|
264
|
+
const hooks = this.machine.lifecycleHooks()[state];
|
|
265
|
+
const list = phase === "before" ? hooks?.before : hooks?.after;
|
|
266
|
+
if (!list || list.length === 0)
|
|
267
|
+
return null;
|
|
268
|
+
// The hook input (`HookArgs` in the sandbox): the trigger reaches a hook as
|
|
269
|
+
// its bare id — a run's *input* lives in `variables` — and the transcript as
|
|
270
|
+
// plain messages.
|
|
271
|
+
const scriptArgs = {
|
|
272
|
+
state,
|
|
273
|
+
phase,
|
|
274
|
+
...(ctx.trigger ? { trigger: ctx.trigger.id } : {}),
|
|
275
|
+
variables: ctx.variables ?? {},
|
|
276
|
+
messages: hookTranscript(ctx.messages),
|
|
277
|
+
...extraArgs,
|
|
278
|
+
};
|
|
279
|
+
const to = typeof extraArgs?.to === "string" ? extraArgs.to : undefined;
|
|
280
|
+
// Run hooks in declaration order, short-circuiting on the first that fails.
|
|
281
|
+
// The index travels: an inline rubric has no name, so its position in this
|
|
282
|
+
// list is its identity — for dispatch and for its own retry budget.
|
|
283
|
+
for (const [index, hook] of list.entries()) {
|
|
284
|
+
const reject = await this.runSingleHook(state, phase, hook, ctx, scriptArgs, { veto, to, index });
|
|
285
|
+
if (reject)
|
|
286
|
+
return reject;
|
|
287
|
+
}
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
async runSingleHook(state, phase, hook, ctx, scriptArgs, opts) {
|
|
291
|
+
const label = afterHookLabel(hook, opts.index);
|
|
292
|
+
this.emit({ type: "hook-start", state, phase, label });
|
|
293
|
+
const outcome = await this.runHook(hook, ctx, scriptArgs, {
|
|
294
|
+
state,
|
|
295
|
+
phase,
|
|
296
|
+
index: opts.index,
|
|
297
|
+
});
|
|
298
|
+
for (const line of outcome.logs) {
|
|
299
|
+
if (line.trim()) {
|
|
300
|
+
this.emit({ type: "hook-output", state, line: line.trimEnd() });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const parsed = parseLifecycleDecision(outcome);
|
|
304
|
+
if (parsed && "error" in parsed) {
|
|
305
|
+
this.emit({ type: "hook-rejected", state, phase, reason: parsed.error });
|
|
306
|
+
// A hook that could not execute is a terminal failure: retrying the
|
|
307
|
+
// same turn re-runs the same broken hook.
|
|
308
|
+
return { reason: parsed.error, terminal: true };
|
|
309
|
+
}
|
|
310
|
+
if (!parsed) {
|
|
311
|
+
if (phase === "before") {
|
|
312
|
+
this.emit({ type: "hook-passed", state, phase });
|
|
313
|
+
}
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
const maxIterations = hookMaxIterations(hook);
|
|
317
|
+
return this.applyDecision(state, label, parsed, ctx, {
|
|
318
|
+
phase,
|
|
319
|
+
veto: opts.veto,
|
|
320
|
+
to: opts.to,
|
|
321
|
+
index: opts.index,
|
|
322
|
+
...(maxIterations !== undefined ? { maxIterations } : {}),
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
async attemptTransition(from, to, ctx, reason,
|
|
326
|
+
/**
|
|
327
|
+
* The tool call driving this attempt, when one is. Carried onto the `advance`
|
|
328
|
+
* event so a consumer can attribute the transition to the call that made it;
|
|
329
|
+
* a transition the runtime itself performs passes nothing.
|
|
330
|
+
*/
|
|
331
|
+
options) {
|
|
332
|
+
// Work on a copy of the correction counts so the attempt never mutates the
|
|
333
|
+
// caller's context; the resulting counts are returned for the caller to
|
|
334
|
+
// commit to the checkpoint.
|
|
335
|
+
const corrections = { ...ctx.iterations };
|
|
336
|
+
const localCtx = { ...ctx, iterations: corrections };
|
|
337
|
+
// Edge validity is a pure, statically-decidable rule — route it through the
|
|
338
|
+
// decision kernel so runtime and `agent validate` agree. Hook reduction runs
|
|
339
|
+
// per-hook inside `runPhase` (also kernel-backed via `applyDecision`).
|
|
340
|
+
const edgeVerdict = decide(this.machine, { kind: "transition", from, to, hookFacts: [] }, [], undefined, ctx.variableStore ?? {});
|
|
341
|
+
if (edgeVerdict.decision === "block") {
|
|
342
|
+
return {
|
|
343
|
+
ok: false,
|
|
344
|
+
reason: edgeVerdict.reason ?? `cannot advance from '${from}' to '${to}'.`,
|
|
345
|
+
// An invalid edge is always recoverable: the agent picks a valid target.
|
|
346
|
+
terminal: false,
|
|
347
|
+
corrections,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
const trimmedReason = reason?.trim();
|
|
351
|
+
const afterReject = await this.runPhase(from, "after", localCtx, { from, to, ...(trimmedReason ? { reason: trimmedReason } : {}) }, true);
|
|
352
|
+
if (afterReject) {
|
|
353
|
+
return { ok: false, reason: afterReject.reason, terminal: afterReject.terminal, corrections };
|
|
354
|
+
}
|
|
355
|
+
const beforeReject = await this.runPhase(to, "before", localCtx);
|
|
356
|
+
if (beforeReject) {
|
|
357
|
+
return { ok: false, reason: beforeReject.reason, terminal: beforeReject.terminal, corrections };
|
|
358
|
+
}
|
|
359
|
+
this.emit({
|
|
360
|
+
type: "advance",
|
|
361
|
+
from,
|
|
362
|
+
to,
|
|
363
|
+
...(trimmedReason ? { reason: trimmedReason } : {}),
|
|
364
|
+
...(options?.callId ? { callId: options.callId } : {}),
|
|
365
|
+
});
|
|
366
|
+
return { ok: true, from, to, corrections };
|
|
367
|
+
}
|
|
368
|
+
dispose(sessionId) {
|
|
369
|
+
this.executor.dispose(sessionId, PROCESS_SESSION);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/lifecycle/runner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,eAAe,GAGhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,QAAQ,GAET,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,0BAA0B,GAG3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAW7D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAsB;IAEtB,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,cAAc,EAAE,CAAC;IAE5E,MAA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IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjE,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;QAClG,CAAC;QAED,IAAI,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,SAAS;YACf,IAAI;YACJ,EAAE;YACF,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnD,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvD,CAAC,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC;IAC7C,CAAC;IAED,OAAO,CAAC,SAAiB;QACvB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One transcript message as a hook reads it: plain data, no LangChain classes.
|
|
3
|
+
* `role` is `user`, `assistant`, `tool`, `system`, or `runtime` — the last for
|
|
4
|
+
* a note the runtime wrote (an arrival, a decision, an error route), which a
|
|
5
|
+
* model cannot read as a person speaking and a hook should not either.
|
|
6
|
+
*/
|
|
7
|
+
export interface HookMessage {
|
|
8
|
+
role: string;
|
|
9
|
+
text: string;
|
|
10
|
+
/** Assistant messages only: the tool calls the message made. */
|
|
11
|
+
toolCalls?: {
|
|
12
|
+
name: string;
|
|
13
|
+
args: unknown;
|
|
14
|
+
}[];
|
|
15
|
+
/** Tool results only: the tool that produced the text. */
|
|
16
|
+
tool?: string;
|
|
17
|
+
/** Runtime notes only: which kind of note this is. */
|
|
18
|
+
note?: string;
|
|
19
|
+
}
|
|
20
|
+
/** How much of the transcript a hook is handed: the most recent messages. */
|
|
21
|
+
export declare const HOOK_TRANSCRIPT_LIMIT = 24;
|
|
22
|
+
/**
|
|
23
|
+
* The recent transcript as a hook receives it in `messages`, newest last. A
|
|
24
|
+
* runtime note is carried in the transcript as a tool-call pair; only the half
|
|
25
|
+
* holding the text is kept, as one `runtime` entry.
|
|
26
|
+
*/
|
|
27
|
+
export declare function hookTranscript(messages: unknown[], limit?: number): HookMessage[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { contentToString, messageTypeOf, runtimeNoteKind } from "../core/messages.js";
|
|
2
|
+
const ROLE_BY_TYPE = {
|
|
3
|
+
human: "user",
|
|
4
|
+
ai: "assistant",
|
|
5
|
+
system: "system",
|
|
6
|
+
tool: "tool",
|
|
7
|
+
function: "tool",
|
|
8
|
+
};
|
|
9
|
+
/** How much of the transcript a hook is handed: the most recent messages. */
|
|
10
|
+
export const HOOK_TRANSCRIPT_LIMIT = 24;
|
|
11
|
+
/**
|
|
12
|
+
* The recent transcript as a hook receives it in `messages`, newest last. A
|
|
13
|
+
* runtime note is carried in the transcript as a tool-call pair; only the half
|
|
14
|
+
* holding the text is kept, as one `runtime` entry.
|
|
15
|
+
*/
|
|
16
|
+
export function hookTranscript(messages, limit = HOOK_TRANSCRIPT_LIMIT) {
|
|
17
|
+
const out = [];
|
|
18
|
+
for (const raw of Array.isArray(messages) ? messages : []) {
|
|
19
|
+
const msg = raw;
|
|
20
|
+
const type = messageTypeOf(raw);
|
|
21
|
+
const text = contentToString(msg.content);
|
|
22
|
+
const note = runtimeNoteKind(raw);
|
|
23
|
+
if (note !== null) {
|
|
24
|
+
if (text.trim() === "")
|
|
25
|
+
continue;
|
|
26
|
+
out.push({ role: "runtime", text, note });
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const entry = { role: ROLE_BY_TYPE[type] ?? (type || "unknown"), text };
|
|
30
|
+
const calls = msg.tool_calls;
|
|
31
|
+
if ((type === "ai" || type === "assistant") && Array.isArray(calls) && calls.length > 0) {
|
|
32
|
+
entry.toolCalls = calls.map((c) => {
|
|
33
|
+
const call = c;
|
|
34
|
+
return { name: String(call.name ?? ""), args: call.args ?? {} };
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (entry.role === "tool" && typeof msg.name === "string")
|
|
38
|
+
entry.tool = msg.name;
|
|
39
|
+
out.push(entry);
|
|
40
|
+
}
|
|
41
|
+
return out.slice(-limit);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=transcript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../src/lifecycle/transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAmBtF,MAAM,YAAY,GAA2B;IAC3C,KAAK,EAAE,MAAM;IACb,EAAE,EAAE,WAAW;IACf,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,MAAM;CACjB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,QAAmB,EAAE,KAAK,GAAG,qBAAqB;IAC/E,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC1D,MAAM,GAAG,GAAG,GAA8B,CAAC;QAC3C,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,OAA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{ AllowEntry, MachineSpec } from "./types.js";
|
|
2
|
+
import { type VariableReference, type VariableStore } from "./variables.js";
|
|
3
|
+
/** Conventional path argument for file tools and `archmax_run`. */
|
|
4
|
+
export declare const DEFAULT_PATH_ARG = "file_path";
|
|
5
|
+
export interface NormalizedAllowEntry {
|
|
6
|
+
tool: string | undefined;
|
|
7
|
+
/** Per-argument glob matchers, or null to allow the tool with any arguments. */
|
|
8
|
+
argMatchers: Record<string, string[]> | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Whether a value matches any of the given globs. The value is canonicalized
|
|
12
|
+
* (`.`/`..`/`//` resolved) so a `./` or `.//` prefix cannot dodge a
|
|
13
|
+
* `forbid_paths` glob — the matcher sees the same path the backend resolves.
|
|
14
|
+
* Globs are leading-slash-normalized only, preserving their wildcards.
|
|
15
|
+
*
|
|
16
|
+
* `dot: true`: a workspace path is not a shell glob, and a governance glob that
|
|
17
|
+
* skipped dot-prefixed segments would read the same either way — `secrets/**`
|
|
18
|
+
* would miss `secrets/.env` on the deny side while `scratchpad/**` would refuse
|
|
19
|
+
* `scratchpad/.cache` on the allow side.
|
|
20
|
+
*/
|
|
21
|
+
export declare function valueMatches(value: unknown, globs: string[]): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Normalize an `allow` entry into a tool name plus optional argument matchers.
|
|
24
|
+
* One shared derivation for the kernel, disclosure, and `validate`, so they
|
|
25
|
+
* cannot disagree about what an entry covers.
|
|
26
|
+
*/
|
|
27
|
+
export declare function normalizeAllowEntry(entry: AllowEntry): NormalizedAllowEntry;
|
|
28
|
+
/**
|
|
29
|
+
* An unresolvable `${{…}}` reference in a guard. Not a mismatch: the harness
|
|
30
|
+
* could not evaluate the governance the author declared, so the caller turns
|
|
31
|
+
* this into a terminal run failure rather than a retryable block.
|
|
32
|
+
*/
|
|
33
|
+
export interface GuardResolutionFailure {
|
|
34
|
+
reference: string;
|
|
35
|
+
detail: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a tool call's arguments satisfy a normalized allow entry's matchers.
|
|
39
|
+
*
|
|
40
|
+
* `${{…}}` references are resolved against the run's variables per call, never
|
|
41
|
+
* cached: a `set_variables` later in the same turn must take effect on the very
|
|
42
|
+
* next call. An unresolvable reference makes the entry match nothing and reports
|
|
43
|
+
* why through `onUnresolved` — never the literal `${{…}}` text or a permissive
|
|
44
|
+
* pattern. A dotted argument key (`args.file_path`) is read with the same
|
|
45
|
+
* own-property traversal `${{…}}` paths use, never the prototype chain.
|
|
46
|
+
*/
|
|
47
|
+
export declare function argsSatisfy(argMatchers: Record<string, string[]> | null, args: Record<string, unknown>, variables?: VariableStore, onUnresolved?: (failure: GuardResolutionFailure) => void): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* One `${{…}}` reference found in a tool-argument guard, with enough context to
|
|
50
|
+
* name it in a diagnostic: which state (null for an `allow_always` entry, which
|
|
51
|
+
* binds in every state), which tool, and which argument.
|
|
52
|
+
*/
|
|
53
|
+
export interface GuardVariableReference {
|
|
54
|
+
state: string | null;
|
|
55
|
+
tool: string | undefined;
|
|
56
|
+
arg: string;
|
|
57
|
+
glob: string;
|
|
58
|
+
reference: VariableReference;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Every `${{…}}` reference in the spec's tool-argument guards, with where it was
|
|
62
|
+
* found. Used at assembly to warn about a reference nothing guarantees, and by
|
|
63
|
+
* the spec lint for the same check minus the host's seeds.
|
|
64
|
+
*/
|
|
65
|
+
export declare function guardReferences(spec: MachineSpec): GuardVariableReference[];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import picomatch from "picomatch";
|
|
2
|
+
import { canonicalizeRelPath, normalizeRelPath } from "../core/workspace.js";
|
|
3
|
+
import { hasVariableReference, parseReferences, resolveGlob, resolvePath, } from "./variables.js";
|
|
4
|
+
/** Conventional path argument for file tools and `archmax_run`. */
|
|
5
|
+
export const DEFAULT_PATH_ARG = "file_path";
|
|
6
|
+
/**
|
|
7
|
+
* Whether a value matches any of the given globs. The value is canonicalized
|
|
8
|
+
* (`.`/`..`/`//` resolved) so a `./` or `.//` prefix cannot dodge a
|
|
9
|
+
* `forbid_paths` glob — the matcher sees the same path the backend resolves.
|
|
10
|
+
* Globs are leading-slash-normalized only, preserving their wildcards.
|
|
11
|
+
*
|
|
12
|
+
* `dot: true`: a workspace path is not a shell glob, and a governance glob that
|
|
13
|
+
* skipped dot-prefixed segments would read the same either way — `secrets/**`
|
|
14
|
+
* would miss `secrets/.env` on the deny side while `scratchpad/**` would refuse
|
|
15
|
+
* `scratchpad/.cache` on the allow side.
|
|
16
|
+
*/
|
|
17
|
+
export function valueMatches(value, globs) {
|
|
18
|
+
if (value == null || globs.length === 0)
|
|
19
|
+
return false;
|
|
20
|
+
return picomatch.isMatch(canonicalizeRelPath(String(value)).path, globs.map(normalizeRelPath), {
|
|
21
|
+
dot: true,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Normalize an `allow` entry into a tool name plus optional argument matchers.
|
|
26
|
+
* One shared derivation for the kernel, disclosure, and `validate`, so they
|
|
27
|
+
* cannot disagree about what an entry covers.
|
|
28
|
+
*/
|
|
29
|
+
export function normalizeAllowEntry(entry) {
|
|
30
|
+
if (typeof entry === "string")
|
|
31
|
+
return { tool: entry, argMatchers: null };
|
|
32
|
+
if (!entry || typeof entry !== "object")
|
|
33
|
+
return { tool: undefined, argMatchers: null };
|
|
34
|
+
const tool = entry.tool;
|
|
35
|
+
if (entry.args && typeof entry.args === "object") {
|
|
36
|
+
const argMatchers = {};
|
|
37
|
+
for (const [name, globs] of Object.entries(entry.args)) {
|
|
38
|
+
argMatchers[name] = Array.isArray(globs) ? globs : [globs];
|
|
39
|
+
}
|
|
40
|
+
return { tool, argMatchers };
|
|
41
|
+
}
|
|
42
|
+
if (entry.paths !== undefined) {
|
|
43
|
+
const globs = Array.isArray(entry.paths) ? entry.paths : [entry.paths];
|
|
44
|
+
return { tool, argMatchers: { [DEFAULT_PATH_ARG]: globs } };
|
|
45
|
+
}
|
|
46
|
+
return { tool, argMatchers: null };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether a tool call's arguments satisfy a normalized allow entry's matchers.
|
|
50
|
+
*
|
|
51
|
+
* `${{…}}` references are resolved against the run's variables per call, never
|
|
52
|
+
* cached: a `set_variables` later in the same turn must take effect on the very
|
|
53
|
+
* next call. An unresolvable reference makes the entry match nothing and reports
|
|
54
|
+
* why through `onUnresolved` — never the literal `${{…}}` text or a permissive
|
|
55
|
+
* pattern. A dotted argument key (`args.file_path`) is read with the same
|
|
56
|
+
* own-property traversal `${{…}}` paths use, never the prototype chain.
|
|
57
|
+
*/
|
|
58
|
+
export function argsSatisfy(argMatchers, args, variables, onUnresolved) {
|
|
59
|
+
if (!argMatchers)
|
|
60
|
+
return true;
|
|
61
|
+
return Object.entries(argMatchers).every(([name, globs]) => {
|
|
62
|
+
const resolved = [];
|
|
63
|
+
for (const glob of globs) {
|
|
64
|
+
if (!hasVariableReference(glob)) {
|
|
65
|
+
resolved.push(glob);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const result = resolveGlob(glob, variables ?? {});
|
|
69
|
+
if (!result.ok) {
|
|
70
|
+
onUnresolved?.({ reference: result.reference, detail: result.detail });
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
resolved.push(result.pattern);
|
|
74
|
+
}
|
|
75
|
+
return valueMatches(resolvePath(args, name.split(".")), resolved);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Every `${{…}}` reference in the spec's tool-argument guards, with where it was
|
|
80
|
+
* found. Used at assembly to warn about a reference nothing guarantees, and by
|
|
81
|
+
* the spec lint for the same check minus the host's seeds.
|
|
82
|
+
*/
|
|
83
|
+
export function guardReferences(spec) {
|
|
84
|
+
const found = [];
|
|
85
|
+
const collect = (entries, state) => {
|
|
86
|
+
for (const entry of entries ?? []) {
|
|
87
|
+
const { tool, argMatchers } = normalizeAllowEntry(entry);
|
|
88
|
+
if (!argMatchers)
|
|
89
|
+
continue;
|
|
90
|
+
for (const [arg, globs] of Object.entries(argMatchers)) {
|
|
91
|
+
for (const glob of globs) {
|
|
92
|
+
for (const ref of parseReferences(glob)) {
|
|
93
|
+
found.push({ state, tool, arg, glob, reference: ref });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
collect(spec.tools?.allow_always, null);
|
|
100
|
+
collect(spec.tools?.forbid_always, null);
|
|
101
|
+
for (const [slug, state] of Object.entries(spec.states)) {
|
|
102
|
+
collect(state.tools?.allow, slug);
|
|
103
|
+
collect(state.tools?.forbid, slug);
|
|
104
|
+
}
|
|
105
|
+
return found;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=allow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allow.js","sourceRoot":"","sources":["../../src/machine/allow.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,WAAW,GAGZ,MAAM,gBAAgB,CAAC;AAExB,mEAAmE;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAQ5C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,KAAe;IAC1D,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtD,OAAO,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE;QAC7F,GAAG,EAAE,IAAI;K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