harnery 0.29.0 → 0.31.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/README.md +4 -4
- package/dist/commander.d.ts +8 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +14 -13
- package/dist/commands/adapter.d.ts +12 -0
- package/dist/commands/adapter.d.ts.map +1 -0
- package/dist/commands/{harness.js → adapter.js} +35 -35
- package/dist/commands/agents.d.ts +3 -2
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +61 -60
- package/dist/commands/artifacts.d.ts +4 -0
- package/dist/commands/artifacts.d.ts.map +1 -0
- package/dist/commands/artifacts.js +143 -0
- package/dist/commands/backup.d.ts +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +5 -2
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +310 -7
- package/dist/commands/checkpoint.d.ts +12 -0
- package/dist/commands/checkpoint.d.ts.map +1 -0
- package/dist/commands/checkpoint.js +162 -0
- package/dist/commands/context.d.ts +2 -2
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +3 -151
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +31 -7
- package/dist/commands/deinit.d.ts +2 -2
- package/dist/commands/deinit.js +15 -15
- package/dist/commands/doctor.js +23 -23
- package/dist/commands/governor.d.ts +4 -0
- package/dist/commands/governor.d.ts.map +1 -0
- package/dist/commands/{supervisor.js → governor.js} +133 -108
- package/dist/commands/init.d.ts +12 -12
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +44 -30
- package/dist/commands/{session.d.ts → journal.d.ts} +2 -2
- package/dist/commands/journal.d.ts.map +1 -0
- package/dist/commands/{scratch.js → journal.js} +47 -47
- package/dist/commands/policy.js +1 -1
- package/dist/commands/presence.js +2 -2
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.js +3 -3
- package/dist/commands/tunnel.d.ts +16 -0
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +193 -23
- package/dist/commands/web-fetch.js +1 -1
- package/dist/commands/web.d.ts +19 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +51 -0
- package/dist/commands/work.d.ts +2 -1
- package/dist/commands/work.d.ts.map +1 -1
- package/dist/commands/work.js +55 -25
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +35 -28
- package/dist/core/{harnesses → adapters}/attest-projection.d.ts +2 -2
- package/dist/core/adapters/attest-projection.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/attest.d.ts +16 -16
- package/dist/core/adapters/attest.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/attest.js +9 -9
- package/dist/core/{harnesses → adapters}/attestation.d.ts +16 -16
- package/dist/core/adapters/attestation.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/attestation.js +20 -20
- package/dist/core/{harnesses → adapters}/bench.d.ts +12 -12
- package/dist/core/adapters/bench.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/bench.js +12 -12
- package/dist/core/adapters/index.d.ts +13 -0
- package/dist/core/adapters/index.d.ts.map +1 -0
- package/dist/core/adapters/index.js +6 -0
- package/dist/core/{harnesses → adapters}/profiles.d.ts +11 -11
- package/dist/core/adapters/profiles.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/profiles.js +11 -11
- package/dist/core/adapters/registry.d.ts +15 -0
- package/dist/core/adapters/registry.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/registry.js +11 -11
- package/dist/core/{harnesses → adapters}/types.d.ts +28 -23
- package/dist/core/adapters/types.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/types.js +1 -1
- package/dist/core/agents/canonical-emit.d.ts +4 -4
- package/dist/core/agents/canonical-emit.js +5 -5
- package/dist/core/agents/cli-emit.js +1 -1
- package/dist/core/agents/cli.js +30 -26
- package/dist/core/agents/codex-replay.d.ts +1 -1
- package/dist/core/agents/codex-replay.js +6 -6
- package/dist/core/agents/coord-client.d.ts +21 -2
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +122 -27
- package/dist/core/agents/events/consume.d.ts +1 -1
- package/dist/core/agents/events/emit.d.ts +5 -6
- package/dist/core/agents/events/emit.d.ts.map +1 -1
- package/dist/core/agents/events/emit.js +2 -2
- package/dist/core/agents/render/prompt-context.d.ts +21 -9
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +82 -30
- package/dist/core/agents/render/session-context.d.ts +1 -1
- package/dist/core/agents/render/session-context.js +5 -5
- package/dist/core/agents/rules/claim-conflict.d.ts +2 -6
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/claim-conflict.js +1 -1
- package/dist/core/agents/rules/commit-conflict.js +98 -22
- package/dist/core/agents/rules/stop-hook.d.ts +9 -9
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +23 -5
- package/dist/core/agents/rules/verdict.d.ts +14 -0
- package/dist/core/agents/rules/verdict.d.ts.map +1 -0
- package/dist/core/agents/rules/verdict.js +1 -0
- package/dist/core/agents/session-events.js +3 -3
- package/dist/core/agents/state/council.d.ts +1 -1
- package/dist/core/agents/state/council.js +1 -1
- package/dist/core/agents/state/heartbeat-projector.d.ts +3 -2
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-projector.js +14 -10
- package/dist/core/agents/state/heartbeat-writer.d.ts +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +12 -12
- package/dist/core/agents/state/{scratch.d.ts → journal.d.ts} +7 -7
- package/dist/core/agents/state/{scratch.d.ts.map → journal.d.ts.map} +1 -1
- package/dist/core/agents/state/{scratch.js → journal.js} +12 -12
- package/dist/core/agents/state/pidmap.d.ts +28 -4
- package/dist/core/agents/state/pidmap.d.ts.map +1 -1
- package/dist/core/agents/state/pidmap.js +130 -15
- package/dist/core/agents/state/proc-start.d.ts +95 -0
- package/dist/core/agents/state/proc-start.d.ts.map +1 -0
- package/dist/core/agents/state/proc-start.js +199 -0
- package/dist/core/agents/state/shell-mutation.d.ts +1 -1
- package/dist/core/agents/state/shell-mutation.js +1 -1
- package/dist/core/agents/state/stale-sweep.js +7 -7
- package/dist/core/artifacts/index.d.ts +86 -0
- package/dist/core/artifacts/index.d.ts.map +1 -0
- package/dist/core/artifacts/index.js +421 -0
- package/dist/core/config.d.ts +9 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +26 -2
- package/dist/core/context/index.d.ts +12 -12
- package/dist/core/context/index.js +10 -10
- package/dist/core/governor/adapter-spread.d.ts +52 -0
- package/dist/core/governor/adapter-spread.d.ts.map +1 -0
- package/dist/core/governor/adapter-spread.js +52 -0
- package/dist/core/governor/index.d.ts +7 -0
- package/dist/core/governor/index.d.ts.map +1 -0
- package/dist/core/governor/index.js +6 -0
- package/dist/core/governor/plan-api.d.ts +38 -0
- package/dist/core/governor/plan-api.d.ts.map +1 -0
- package/dist/core/governor/plan-api.js +83 -0
- package/dist/core/governor/plan-read.d.ts +5 -0
- package/dist/core/governor/plan-read.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/plan-read.js +71 -51
- package/dist/core/governor/plan-types.d.ts +181 -0
- package/dist/core/governor/plan-types.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/plan-types.js +4 -4
- package/dist/core/governor/planning.d.ts +48 -0
- package/dist/core/governor/planning.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/planning.js +143 -94
- package/dist/core/governor/read.d.ts +6 -0
- package/dist/core/governor/read.d.ts.map +1 -0
- package/dist/core/governor/read.js +4 -0
- package/dist/core/governor/runner.d.ts +37 -0
- package/dist/core/governor/runner.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/runner.js +15 -15
- package/dist/core/governor/service-read.d.ts +6 -0
- package/dist/core/governor/service-read.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/service-read.js +12 -12
- package/dist/core/governor/service.d.ts +114 -0
- package/dist/core/governor/service.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/service.js +57 -57
- package/dist/core/governor/state.d.ts +116 -0
- package/dist/core/governor/state.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/state.js +290 -116
- package/dist/core/hooks/adapter/detect.d.ts +9 -0
- package/dist/core/hooks/{harness → adapter}/detect.d.ts.map +1 -1
- package/dist/core/hooks/{harness → adapter}/detect.js +8 -8
- package/dist/core/hooks/{harness → adapter}/events.d.ts +15 -14
- package/dist/core/hooks/adapter/events.d.ts.map +1 -0
- package/dist/core/hooks/{harness → adapter}/events.js +5 -5
- package/dist/core/hooks/{harness → adapter}/output.d.ts +20 -14
- package/dist/core/hooks/adapter/output.d.ts.map +1 -0
- package/dist/core/hooks/{harness → adapter}/output.js +30 -22
- package/dist/core/hooks/{harness → adapter}/parse.d.ts +5 -5
- package/dist/core/hooks/{harness → adapter}/parse.d.ts.map +1 -1
- package/dist/core/hooks/{harness → adapter}/parse.js +4 -4
- package/dist/core/hooks/{harness → adapter}/wiring.d.ts +15 -15
- package/dist/core/hooks/{harness → adapter}/wiring.d.ts.map +1 -1
- package/dist/core/hooks/{harness → adapter}/wiring.js +13 -13
- package/dist/core/hooks/cli.d.ts +3 -3
- package/dist/core/hooks/cli.js +175 -151
- package/dist/core/hooks/effects/image-capture.d.ts +5 -5
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +3 -3
- package/dist/core/hooks/effects/index.d.ts +12 -12
- package/dist/core/hooks/effects/index.d.ts.map +1 -1
- package/dist/core/hooks/effects/index.js +17 -17
- package/dist/core/hooks/events/emit.d.ts +2 -2
- package/dist/core/hooks/events/emit.d.ts.map +1 -1
- package/dist/core/hooks/events/emit.js +1 -1
- package/dist/core/hooks/events/rotate.js +1 -1
- package/dist/core/hooks/events/schema.d.ts +13 -5
- package/dist/core/hooks/events/schema.d.ts.map +1 -1
- package/dist/core/hooks/guard-path.d.ts +2 -2
- package/dist/core/hooks/guard-path.js +2 -2
- package/dist/core/hooks/index.d.ts +1 -1
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/resolve/anchor.d.ts +14 -5
- package/dist/core/hooks/resolve/anchor.d.ts.map +1 -1
- package/dist/core/hooks/resolve/anchor.js +64 -7
- package/dist/core/hooks/resolve/coord-root.d.ts +3 -3
- package/dist/core/hooks/resolve/coord-root.js +4 -4
- package/dist/core/hooks/resolve/intent.js +1 -1
- package/dist/core/hooks/resolve/owner.d.ts +1 -1
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +11 -5
- package/dist/core/{scratch → journal}/index.d.ts +25 -25
- package/dist/core/{scratch → journal}/index.d.ts.map +1 -1
- package/dist/core/{scratch → journal}/index.js +38 -38
- package/dist/core/policy/evaluate.d.ts +1 -1
- package/dist/core/policy/evaluate.d.ts.map +1 -1
- package/dist/core/policy/evaluate.js +7 -7
- package/dist/core/policy/types.d.ts +3 -3
- package/dist/core/policy/types.d.ts.map +1 -1
- package/dist/core/work/runner.d.ts.map +1 -1
- package/dist/core/work/runner.js +11 -2
- package/dist/core/work/state.d.ts +28 -3
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +148 -16
- package/dist/core/workflow/adapters.d.ts +17 -0
- package/dist/core/workflow/adapters.d.ts.map +1 -0
- package/dist/core/workflow/adapters.js +21 -0
- package/dist/core/workflow/approvals.js +6 -6
- package/dist/core/workflow/billing.d.ts +9 -9
- package/dist/core/workflow/billing.js +9 -9
- package/dist/core/workflow/child-env.d.ts +10 -2
- package/dist/core/workflow/child-env.d.ts.map +1 -1
- package/dist/core/workflow/child-env.js +12 -4
- package/dist/core/workflow/engine.d.ts +15 -5
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +151 -83
- package/dist/core/workflow/evidence-preflight.d.ts +24 -0
- package/dist/core/workflow/evidence-preflight.d.ts.map +1 -0
- package/dist/core/workflow/evidence-preflight.js +134 -0
- package/dist/core/workflow/index.d.ts +3 -2
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +2 -1
- package/dist/core/workflow/proof.d.ts +28 -5
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +77 -34
- package/dist/core/workflow/run-state.d.ts +1 -1
- package/dist/core/workflow/run-state.js +7 -7
- package/dist/core/workflow/sandbox-projection.d.ts +6 -6
- package/dist/core/workflow/sandbox-projection.d.ts.map +1 -1
- package/dist/core/workflow/sandbox-projection.js +11 -11
- package/dist/core/workflow/spawn-claude.d.ts +3 -3
- package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
- package/dist/core/workflow/spawn-claude.js +28 -8
- package/dist/core/workflow/spawn-codex.d.ts +4 -4
- package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
- package/dist/core/workflow/spawn-codex.js +26 -8
- package/dist/core/workflow/spawn-cursor.d.ts +4 -4
- package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
- package/dist/core/workflow/spawn-cursor.js +27 -8
- package/dist/core/workflow/spawn-failure.d.ts +15 -1
- package/dist/core/workflow/spawn-failure.d.ts.map +1 -1
- package/dist/core/workflow/spawn-failure.js +35 -1
- package/dist/core/workflow/specialists.js +2 -2
- package/dist/core/workflow/{journal.d.ts → transcript.d.ts} +8 -8
- package/dist/core/workflow/transcript.d.ts.map +1 -0
- package/dist/core/workflow/{journal.js → transcript.js} +14 -14
- package/dist/core/workflow/types.d.ts +119 -46
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/types.js +11 -1
- package/dist/core/workflow/validate.d.ts +1 -1
- package/dist/core/workflow/validate.js +1 -1
- package/dist/core/workflow/workspaces/cancellation.js +2 -2
- package/dist/core/workflow/workspaces/cleanup.js +2 -2
- package/dist/core/workflow/workspaces/execution.js +6 -6
- package/dist/core/workflow/workspaces/inspect.js +9 -9
- package/dist/core/workflow/workspaces/integration.js +14 -14
- package/dist/core/workflow/workspaces/lifecycle.d.ts +1 -1
- package/dist/core/workflow/workspaces/lifecycle.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/lifecycle.js +9 -9
- package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.js +39 -5
- package/dist/core/workflow/workspaces/recovery.js +3 -3
- package/dist/core/workflow/workspaces/state.d.ts +1 -1
- package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/state.js +3 -3
- package/dist/core/workflow/workspaces/types.d.ts +1 -1
- package/dist/core/workflow/workspaces/types.d.ts.map +1 -1
- package/dist/lib/browser/asserts.d.ts +28 -0
- package/dist/lib/browser/asserts.d.ts.map +1 -0
- package/dist/lib/browser/asserts.js +152 -0
- package/dist/lib/browser/client.d.ts +49 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +155 -14
- package/dist/lib/browser/content-checks.d.ts +108 -0
- package/dist/lib/browser/content-checks.d.ts.map +1 -0
- package/dist/lib/browser/content-checks.js +474 -0
- package/dist/lib/browser/critique.d.ts +91 -0
- package/dist/lib/browser/critique.d.ts.map +1 -0
- package/dist/lib/browser/critique.js +167 -0
- package/dist/lib/browser/geometry.d.ts +32 -0
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +244 -1
- package/dist/lib/browser/index.d.ts +4 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +2 -0
- package/dist/lib/claude-desktop.d.ts.map +1 -1
- package/dist/lib/claude-desktop.js +4 -1
- package/dist/lib/council/index.d.ts +6 -6
- package/dist/lib/council/index.d.ts.map +1 -1
- package/dist/lib/council/index.js +8 -8
- package/dist/lib/exec.d.ts +7 -0
- package/dist/lib/exec.d.ts.map +1 -1
- package/dist/lib/exec.js +6 -3
- package/dist/lib/identities/assume.d.ts +2 -2
- package/dist/lib/identities/assume.js +7 -7
- package/dist/lib/instructions/apply.d.ts +3 -3
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +75 -27
- package/dist/lib/instructions/host-addendum.d.ts +54 -0
- package/dist/lib/instructions/host-addendum.d.ts.map +1 -0
- package/dist/lib/instructions/host-addendum.js +107 -0
- package/dist/lib/instructions/templates.d.ts +10 -3
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +41 -12
- package/dist/lib/machine.d.ts +2 -2
- package/dist/lib/machine.js +2 -2
- package/package.json +26 -21
- package/schemas/config.schema.json +26 -1
- package/src/commander.ts +22 -13
- package/src/commands/{harness.ts → adapter.ts} +46 -46
- package/src/commands/agents.ts +71 -64
- package/src/commands/artifacts.ts +168 -0
- package/src/commands/backup.ts +47 -33
- package/src/commands/browse.ts +438 -2
- package/src/commands/checkpoint.ts +196 -0
- package/src/commands/context.ts +3 -176
- package/src/commands/decision.ts +41 -7
- package/src/commands/deinit.ts +16 -16
- package/src/commands/doctor.ts +28 -28
- package/src/commands/{supervisor.ts → governor.ts} +184 -154
- package/src/commands/init.ts +50 -34
- package/src/commands/{scratch.ts → journal.ts} +60 -60
- package/src/commands/policy.ts +1 -1
- package/src/commands/presence.ts +2 -2
- package/src/commands/sync.ts +3 -3
- package/src/commands/tunnel.ts +237 -34
- package/src/commands/web-fetch.ts +1 -1
- package/src/commands/web.ts +56 -1
- package/src/commands/work.ts +72 -38
- package/src/commands/workflow.ts +43 -34
- package/src/core/{harnesses → adapters}/attest-projection.ts +2 -2
- package/src/core/{harnesses → adapters}/attest.ts +27 -27
- package/src/core/{harnesses → adapters}/attestation.ts +41 -41
- package/src/core/{harnesses → adapters}/bench.ts +34 -43
- package/src/core/adapters/index.ts +56 -0
- package/src/core/{harnesses → adapters}/profiles.ts +16 -16
- package/src/core/{harnesses → adapters}/registry.ts +23 -23
- package/src/core/{harnesses → adapters}/types.ts +28 -23
- package/src/core/agents/canonical-emit.ts +6 -6
- package/src/core/agents/cli-emit.ts +1 -1
- package/src/core/agents/cli.ts +30 -28
- package/src/core/agents/codex-replay.ts +6 -6
- package/src/core/agents/coord-client.ts +119 -28
- package/src/core/agents/events/consume.ts +1 -1
- package/src/core/agents/events/emit.ts +7 -6
- package/src/core/agents/render/prompt-context.ts +107 -31
- package/src/core/agents/render/session-context.ts +6 -6
- package/src/core/agents/rules/claim-conflict.ts +4 -7
- package/src/core/agents/rules/commit-conflict.ts +103 -22
- package/src/core/agents/rules/stop-hook.ts +33 -17
- package/src/core/agents/rules/verdict.ts +13 -0
- package/src/core/agents/session-events.ts +4 -4
- package/src/core/agents/state/council.ts +1 -1
- package/src/core/agents/state/heartbeat-projector.ts +16 -12
- package/src/core/agents/state/heartbeat-writer.ts +12 -12
- package/src/core/agents/state/{scratch.ts → journal.ts} +12 -12
- package/src/core/agents/state/pidmap.ts +130 -15
- package/src/core/agents/state/proc-start.ts +208 -0
- package/src/core/agents/state/shell-mutation.ts +1 -1
- package/src/core/agents/state/stale-sweep.ts +7 -7
- package/src/core/artifacts/index.ts +557 -0
- package/src/core/config.ts +30 -2
- package/src/core/context/index.ts +15 -15
- package/src/core/governor/adapter-spread.ts +82 -0
- package/src/core/governor/index.ts +91 -0
- package/src/core/governor/plan-api.ts +115 -0
- package/src/core/{supervisor → governor}/plan-read.ts +120 -96
- package/src/core/{supervisor → governor}/plan-types.ts +64 -50
- package/src/core/{supervisor → governor}/planning.ts +240 -188
- package/src/core/governor/read.ts +59 -0
- package/src/core/{supervisor → governor}/runner.ts +39 -39
- package/src/core/{supervisor → governor}/service-read.ts +22 -22
- package/src/core/{supervisor → governor}/service.ts +117 -119
- package/src/core/{supervisor → governor}/state.ts +389 -174
- package/src/core/hooks/adapter/detect.ts +30 -0
- package/src/core/hooks/{harness → adapter}/events.ts +16 -14
- package/src/core/hooks/{harness → adapter}/output.ts +31 -23
- package/src/core/hooks/{harness → adapter}/parse.ts +5 -5
- package/src/core/hooks/{harness → adapter}/wiring.ts +21 -21
- package/src/core/hooks/cli.ts +185 -162
- package/src/core/hooks/effects/image-capture.ts +6 -6
- package/src/core/hooks/effects/index.ts +17 -17
- package/src/core/hooks/events/emit.ts +3 -3
- package/src/core/hooks/events/rotate.ts +1 -1
- package/src/core/hooks/events/schema.ts +15 -7
- package/src/core/hooks/guard-path.ts +2 -2
- package/src/core/hooks/index.ts +1 -1
- package/src/core/hooks/resolve/anchor.ts +63 -8
- package/src/core/hooks/resolve/coord-root.ts +4 -4
- package/src/core/hooks/resolve/intent.ts +1 -1
- package/src/core/hooks/resolve/owner.ts +11 -5
- package/src/core/{scratch → journal}/index.ts +53 -53
- package/src/core/policy/evaluate.ts +8 -8
- package/src/core/policy/types.ts +3 -3
- package/src/core/work/runner.ts +11 -2
- package/src/core/work/state.ts +185 -21
- package/src/core/workflow/adapters.ts +33 -0
- package/src/core/workflow/approvals.ts +7 -7
- package/src/core/workflow/billing.ts +12 -12
- package/src/core/workflow/child-env.ts +13 -4
- package/src/core/workflow/engine.ts +166 -90
- package/src/core/workflow/evidence-preflight.ts +165 -0
- package/src/core/workflow/index.ts +6 -3
- package/src/core/workflow/proof.ts +94 -48
- package/src/core/workflow/run-state.ts +7 -7
- package/src/core/workflow/sandbox-projection.ts +16 -16
- package/src/core/workflow/spawn-claude.ts +34 -12
- package/src/core/workflow/spawn-codex.ts +30 -12
- package/src/core/workflow/spawn-cursor.ts +31 -12
- package/src/core/workflow/spawn-failure.ts +41 -1
- package/src/core/workflow/specialists.ts +2 -2
- package/src/core/workflow/{journal.ts → transcript.ts} +16 -16
- package/src/core/workflow/types.ts +130 -46
- package/src/core/workflow/validate.ts +1 -1
- package/src/core/workflow/workspaces/cancellation.ts +2 -2
- package/src/core/workflow/workspaces/cleanup.ts +2 -2
- package/src/core/workflow/workspaces/execution.ts +6 -6
- package/src/core/workflow/workspaces/inspect.ts +14 -11
- package/src/core/workflow/workspaces/integration.ts +18 -14
- package/src/core/workflow/workspaces/lifecycle.ts +10 -10
- package/src/core/workflow/workspaces/local-git.ts +47 -5
- package/src/core/workflow/workspaces/recovery.ts +3 -3
- package/src/core/workflow/workspaces/state.ts +4 -3
- package/src/core/workflow/workspaces/types.ts +1 -1
- package/src/lib/browser/asserts.ts +177 -0
- package/src/lib/browser/client.ts +189 -14
- package/src/lib/browser/content-checks.ts +571 -0
- package/src/lib/browser/critique.ts +231 -0
- package/src/lib/browser/geometry.ts +297 -1
- package/src/lib/browser/index.ts +34 -0
- package/src/lib/claude-desktop.ts +4 -1
- package/src/lib/council/index.ts +9 -9
- package/src/lib/exec.ts +13 -3
- package/src/lib/identities/assume.ts +7 -7
- package/src/lib/instructions/apply.ts +87 -25
- package/src/lib/instructions/host-addendum.ts +126 -0
- package/src/lib/instructions/templates.ts +44 -15
- package/src/lib/machine.ts +2 -2
- package/dist/commands/harness.d.ts +0 -12
- package/dist/commands/harness.d.ts.map +0 -1
- package/dist/commands/scratch.d.ts +0 -4
- package/dist/commands/scratch.d.ts.map +0 -1
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js +0 -162
- package/dist/commands/supervisor.d.ts +0 -4
- package/dist/commands/supervisor.d.ts.map +0 -1
- package/dist/core/harnesses/attest-projection.d.ts.map +0 -1
- package/dist/core/harnesses/attest.d.ts.map +0 -1
- package/dist/core/harnesses/attestation.d.ts.map +0 -1
- package/dist/core/harnesses/bench.d.ts.map +0 -1
- package/dist/core/harnesses/index.d.ts +0 -13
- package/dist/core/harnesses/index.d.ts.map +0 -1
- package/dist/core/harnesses/index.js +0 -6
- package/dist/core/harnesses/profiles.d.ts.map +0 -1
- package/dist/core/harnesses/registry.d.ts +0 -15
- package/dist/core/harnesses/registry.d.ts.map +0 -1
- package/dist/core/harnesses/types.d.ts.map +0 -1
- package/dist/core/hooks/harness/detect.d.ts +0 -9
- package/dist/core/hooks/harness/events.d.ts.map +0 -1
- package/dist/core/hooks/harness/output.d.ts.map +0 -1
- package/dist/core/supervisor/index.d.ts +0 -7
- package/dist/core/supervisor/index.d.ts.map +0 -1
- package/dist/core/supervisor/index.js +0 -6
- package/dist/core/supervisor/plan-api.d.ts +0 -23
- package/dist/core/supervisor/plan-api.d.ts.map +0 -1
- package/dist/core/supervisor/plan-api.js +0 -50
- package/dist/core/supervisor/plan-read.d.ts +0 -5
- package/dist/core/supervisor/plan-read.d.ts.map +0 -1
- package/dist/core/supervisor/plan-types.d.ts +0 -170
- package/dist/core/supervisor/plan-types.d.ts.map +0 -1
- package/dist/core/supervisor/planning.d.ts +0 -33
- package/dist/core/supervisor/planning.d.ts.map +0 -1
- package/dist/core/supervisor/read.d.ts +0 -6
- package/dist/core/supervisor/read.d.ts.map +0 -1
- package/dist/core/supervisor/read.js +0 -4
- package/dist/core/supervisor/runner.d.ts +0 -37
- package/dist/core/supervisor/runner.d.ts.map +0 -1
- package/dist/core/supervisor/service-read.d.ts +0 -6
- package/dist/core/supervisor/service-read.d.ts.map +0 -1
- package/dist/core/supervisor/service.d.ts +0 -114
- package/dist/core/supervisor/service.d.ts.map +0 -1
- package/dist/core/supervisor/state.d.ts +0 -95
- package/dist/core/supervisor/state.d.ts.map +0 -1
- package/dist/core/workflow/harnesses.d.ts +0 -17
- package/dist/core/workflow/harnesses.d.ts.map +0 -1
- package/dist/core/workflow/harnesses.js +0 -21
- package/dist/core/workflow/journal.d.ts.map +0 -1
- package/src/commands/session.ts +0 -187
- package/src/core/harnesses/index.ts +0 -56
- package/src/core/hooks/harness/detect.ts +0 -30
- package/src/core/supervisor/index.ts +0 -89
- package/src/core/supervisor/plan-api.ts +0 -73
- package/src/core/supervisor/read.ts +0 -59
- package/src/core/workflow/harnesses.ts +0 -33
- /package/dist/core/{harnesses → adapters}/attest-projection.js +0 -0
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { exec } from "../../lib/exec.ts";
|
|
22
|
-
import {
|
|
23
|
-
import type {
|
|
22
|
+
import { builtinAdapterProfile, validateAdapterEffort } from "../adapters/profiles.ts";
|
|
23
|
+
import type { AdapterInvocation, AdapterRawResult } from "../adapters/types.ts";
|
|
24
|
+
import { notFoundError } from "./adapters.ts";
|
|
24
25
|
import { buildChildEnv } from "./child-env.ts";
|
|
25
|
-
import { notFoundError } from "./harnesses.ts";
|
|
26
26
|
import { resolveSandboxProjection } from "./sandbox-projection.ts";
|
|
27
|
-
import { vendorFailureText } from "./spawn-failure.ts";
|
|
27
|
+
import { isUpstreamFailureText, vendorFailureText } from "./spawn-failure.ts";
|
|
28
28
|
import type { Spawner, SpawnRequest, SpawnResult } from "./types.ts";
|
|
29
29
|
|
|
30
30
|
interface ClaudeEnvelope {
|
|
@@ -37,13 +37,13 @@ interface ClaudeEnvelope {
|
|
|
37
37
|
errors?: string[];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export function buildClaudeInvocation(req: SpawnRequest):
|
|
41
|
-
|
|
40
|
+
export function buildClaudeInvocation(req: SpawnRequest): AdapterInvocation {
|
|
41
|
+
validateAdapterEffort("claude-code", req.effort);
|
|
42
42
|
if (req.filesystemPolicy) {
|
|
43
43
|
// Declared unrepresentable: refuse rather than drop it silently (ADR 0039).
|
|
44
44
|
resolveSandboxProjection(
|
|
45
45
|
"claude-code",
|
|
46
|
-
|
|
46
|
+
builtinAdapterProfile("claude-code")?.sandboxProjection,
|
|
47
47
|
req.filesystemPolicy,
|
|
48
48
|
);
|
|
49
49
|
}
|
|
@@ -61,7 +61,7 @@ export function buildClaudeInvocation(req: SpawnRequest): HarnessInvocation {
|
|
|
61
61
|
return { argv };
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function normalizeClaudeResult(raw:
|
|
64
|
+
export function normalizeClaudeResult(raw: AdapterRawResult): SpawnResult {
|
|
65
65
|
if (raw.timedOut) {
|
|
66
66
|
return {
|
|
67
67
|
ok: false,
|
|
@@ -70,7 +70,20 @@ export function normalizeClaudeResult(raw: HarnessRawResult): SpawnResult {
|
|
|
70
70
|
error: `claude timed out after ${raw.durationMs}ms and was killed`,
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
// Structural environment signal: the binary was never there (spawned directly,
|
|
74
|
+
// so a missing binary surfaces as ENOENT). Uncharged and not retried.
|
|
75
|
+
if (raw.spawnErrno === "ENOENT") {
|
|
76
|
+
return {
|
|
77
|
+
ok: false,
|
|
78
|
+
text: "",
|
|
79
|
+
durationMs: raw.durationMs,
|
|
80
|
+
error: notFoundError("claude-code"),
|
|
81
|
+
class: "environment",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
73
84
|
if (raw.exitCode === 127) {
|
|
85
|
+
// A bare 127 with no errno is a shell/vendor 127, indistinguishable from a
|
|
86
|
+
// legitimate one — charged as work rather than classed environment.
|
|
74
87
|
return {
|
|
75
88
|
ok: false,
|
|
76
89
|
text: "",
|
|
@@ -79,11 +92,13 @@ export function normalizeClaudeResult(raw: HarnessRawResult): SpawnResult {
|
|
|
79
92
|
};
|
|
80
93
|
}
|
|
81
94
|
if (raw.exitCode !== 0) {
|
|
95
|
+
const failureText = vendorFailureText(raw);
|
|
82
96
|
return {
|
|
83
97
|
ok: false,
|
|
84
98
|
text: "",
|
|
85
99
|
durationMs: raw.durationMs,
|
|
86
|
-
error: `claude exited ${raw.exitCode}: ${
|
|
100
|
+
error: `claude exited ${raw.exitCode}: ${failureText}`,
|
|
101
|
+
...(isUpstreamFailureText(failureText) ? { class: "upstream" as const } : {}),
|
|
87
102
|
};
|
|
88
103
|
}
|
|
89
104
|
|
|
@@ -100,13 +115,17 @@ export function normalizeClaudeResult(raw: HarnessRawResult): SpawnResult {
|
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
if (envelope.is_error) {
|
|
118
|
+
const envelopeError = `${envelope.subtype ?? ""} ${(envelope.errors ?? []).join("; ")} ${String(
|
|
119
|
+
envelope.result ?? "",
|
|
120
|
+
)}`;
|
|
103
121
|
return {
|
|
104
122
|
ok: false,
|
|
105
123
|
text: String(envelope.result ?? ""),
|
|
106
124
|
sessionId: envelope.session_id,
|
|
107
125
|
costUsd: envelope.total_cost_usd,
|
|
108
126
|
durationMs: raw.durationMs,
|
|
109
|
-
error: `
|
|
127
|
+
error: `adapter error (${envelope.subtype ?? "unknown"}): ${(envelope.errors ?? []).join("; ") || "see envelope"}`,
|
|
128
|
+
...(isUpstreamFailureText(envelopeError) ? { class: "upstream" as const } : {}),
|
|
110
129
|
};
|
|
111
130
|
}
|
|
112
131
|
|
|
@@ -121,7 +140,7 @@ export function normalizeClaudeResult(raw: HarnessRawResult): SpawnResult {
|
|
|
121
140
|
|
|
122
141
|
export const claudeCodeSpawner: Spawner = async (req: SpawnRequest): Promise<SpawnResult> => {
|
|
123
142
|
const t0 = Date.now();
|
|
124
|
-
let invocation:
|
|
143
|
+
let invocation: AdapterInvocation;
|
|
125
144
|
try {
|
|
126
145
|
invocation = buildClaudeInvocation(req);
|
|
127
146
|
} catch (error) {
|
|
@@ -129,7 +148,10 @@ export const claudeCodeSpawner: Spawner = async (req: SpawnRequest): Promise<Spa
|
|
|
129
148
|
}
|
|
130
149
|
const r = await exec(invocation.argv, {
|
|
131
150
|
cwd: req.cwd,
|
|
132
|
-
env: buildChildEnv(req.runId, {
|
|
151
|
+
env: buildChildEnv(req.runId, {
|
|
152
|
+
subscriptionOnly: req.subscriptionOnly,
|
|
153
|
+
agentId: req.agentId,
|
|
154
|
+
}),
|
|
133
155
|
timeout: req.timeoutMs,
|
|
134
156
|
});
|
|
135
157
|
return normalizeClaudeResult({ ...r, durationMs: Date.now() - t0 });
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* subprocess.
|
|
4
4
|
*
|
|
5
5
|
* Contract notes (LIVE-VERIFIED 2026-07-16 against codex-cli 0.144.5: flags
|
|
6
|
-
* present, schema-gated triage + text stages round-trip via `--
|
|
6
|
+
* present, schema-gated triage + text stages round-trip via `--adapter codex`):
|
|
7
7
|
* - `codex exec "<prompt>"` is the non-interactive mode.
|
|
8
8
|
* - The final assistant message is captured via `--output-last-message <file>`
|
|
9
9
|
* (a temp file), which is far more drift-tolerant than parsing the
|
|
@@ -20,22 +20,22 @@ import { existsSync, readFileSync, rmSync } from "node:fs";
|
|
|
20
20
|
import { tmpdir } from "node:os";
|
|
21
21
|
import { join } from "node:path";
|
|
22
22
|
import { exec } from "../../lib/exec.ts";
|
|
23
|
-
import {
|
|
24
|
-
import type {
|
|
23
|
+
import { builtinAdapterProfile, validateAdapterEffort } from "../adapters/profiles.ts";
|
|
24
|
+
import type { AdapterInvocation, AdapterRawResult } from "../adapters/types.ts";
|
|
25
|
+
import { notFoundError } from "./adapters.ts";
|
|
25
26
|
import { buildChildEnv } from "./child-env.ts";
|
|
26
|
-
import { notFoundError } from "./harnesses.ts";
|
|
27
27
|
import { resolveSandboxProjection } from "./sandbox-projection.ts";
|
|
28
|
-
import { vendorFailureText } from "./spawn-failure.ts";
|
|
28
|
+
import { isUpstreamFailureText, vendorFailureText } from "./spawn-failure.ts";
|
|
29
29
|
import type { Spawner, SpawnRequest, SpawnResult } from "./types.ts";
|
|
30
30
|
|
|
31
|
-
export function buildCodexInvocation(req: SpawnRequest, resultFile?: string):
|
|
32
|
-
|
|
31
|
+
export function buildCodexInvocation(req: SpawnRequest, resultFile?: string): AdapterInvocation {
|
|
32
|
+
validateAdapterEffort("codex", req.effort);
|
|
33
33
|
if (!resultFile) throw new Error("codex adapter requires a final-message result file");
|
|
34
34
|
// Default stays workspace-write so an unprojected request is unchanged.
|
|
35
35
|
const projection = req.filesystemPolicy
|
|
36
36
|
? resolveSandboxProjection(
|
|
37
37
|
"codex",
|
|
38
|
-
|
|
38
|
+
builtinAdapterProfile("codex")?.sandboxProjection,
|
|
39
39
|
req.filesystemPolicy,
|
|
40
40
|
)
|
|
41
41
|
: undefined;
|
|
@@ -60,7 +60,7 @@ export function buildCodexInvocation(req: SpawnRequest, resultFile?: string): Ha
|
|
|
60
60
|
return { argv, resultFile };
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export function normalizeCodexResult(raw:
|
|
63
|
+
export function normalizeCodexResult(raw: AdapterRawResult): SpawnResult {
|
|
64
64
|
if (raw.timedOut) {
|
|
65
65
|
return {
|
|
66
66
|
ok: false,
|
|
@@ -69,15 +69,30 @@ export function normalizeCodexResult(raw: HarnessRawResult): SpawnResult {
|
|
|
69
69
|
error: `codex timed out after ${raw.durationMs}ms and was killed`,
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
+
// Structural environment signal: the binary was never there (spawned directly,
|
|
73
|
+
// so a missing binary surfaces as ENOENT). Uncharged and not retried.
|
|
74
|
+
if (raw.spawnErrno === "ENOENT") {
|
|
75
|
+
return {
|
|
76
|
+
ok: false,
|
|
77
|
+
text: "",
|
|
78
|
+
durationMs: raw.durationMs,
|
|
79
|
+
error: notFoundError("codex"),
|
|
80
|
+
class: "environment",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
72
83
|
if (raw.exitCode === 127) {
|
|
84
|
+
// A bare 127 with no errno is a shell/vendor 127, indistinguishable from a
|
|
85
|
+
// legitimate one — charged as work rather than classed environment.
|
|
73
86
|
return { ok: false, text: "", durationMs: raw.durationMs, error: notFoundError("codex") };
|
|
74
87
|
}
|
|
75
88
|
if (raw.exitCode !== 0) {
|
|
89
|
+
const failureText = vendorFailureText(raw);
|
|
76
90
|
return {
|
|
77
91
|
ok: false,
|
|
78
92
|
text: "",
|
|
79
93
|
durationMs: raw.durationMs,
|
|
80
|
-
error: `codex exited ${raw.exitCode}: ${
|
|
94
|
+
error: `codex exited ${raw.exitCode}: ${failureText}`,
|
|
95
|
+
...(isUpstreamFailureText(failureText) ? { class: "upstream" as const } : {}),
|
|
81
96
|
};
|
|
82
97
|
}
|
|
83
98
|
return {
|
|
@@ -95,7 +110,7 @@ export const codexSpawner: Spawner = async (req: SpawnRequest): Promise<SpawnRes
|
|
|
95
110
|
);
|
|
96
111
|
|
|
97
112
|
try {
|
|
98
|
-
let invocation:
|
|
113
|
+
let invocation: AdapterInvocation;
|
|
99
114
|
try {
|
|
100
115
|
invocation = buildCodexInvocation(req, outFile);
|
|
101
116
|
} catch (error) {
|
|
@@ -103,7 +118,10 @@ export const codexSpawner: Spawner = async (req: SpawnRequest): Promise<SpawnRes
|
|
|
103
118
|
}
|
|
104
119
|
const r = await exec(invocation.argv, {
|
|
105
120
|
cwd: req.cwd,
|
|
106
|
-
env: buildChildEnv(req.runId, {
|
|
121
|
+
env: buildChildEnv(req.runId, {
|
|
122
|
+
subscriptionOnly: req.subscriptionOnly,
|
|
123
|
+
agentId: req.agentId,
|
|
124
|
+
}),
|
|
107
125
|
timeout: req.timeoutMs,
|
|
108
126
|
});
|
|
109
127
|
return normalizeCodexResult({
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Contract notes (LIVE-VERIFIED 2026-07-17 against cursor-agent
|
|
6
6
|
* 2026.07.16-899851b: schema-gated triage + text stages round-trip via
|
|
7
|
-
* `--
|
|
7
|
+
* `--adapter cursor`, session_id parses from the envelope):
|
|
8
8
|
* - `cursor-agent -p "<prompt>" --output-format json` prints a single result
|
|
9
9
|
* envelope modeled on Claude Code's (`{type: "result", is_error, result,
|
|
10
10
|
* session_id, …}`).
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import { exec } from "../../lib/exec.ts";
|
|
23
|
-
import {
|
|
24
|
-
import type {
|
|
23
|
+
import { builtinAdapterProfile, validateAdapterEffort } from "../adapters/profiles.ts";
|
|
24
|
+
import type { AdapterInvocation, AdapterRawResult } from "../adapters/types.ts";
|
|
25
|
+
import { notFoundError } from "./adapters.ts";
|
|
25
26
|
import { buildChildEnv } from "./child-env.ts";
|
|
26
|
-
import { notFoundError } from "./harnesses.ts";
|
|
27
27
|
import { resolveSandboxProjection } from "./sandbox-projection.ts";
|
|
28
|
-
import { vendorFailureText } from "./spawn-failure.ts";
|
|
28
|
+
import { isUpstreamFailureText, vendorFailureText } from "./spawn-failure.ts";
|
|
29
29
|
import type { Spawner, SpawnRequest, SpawnResult } from "./types.ts";
|
|
30
30
|
|
|
31
31
|
interface CursorEnvelope {
|
|
@@ -53,13 +53,13 @@ export function parseCursorOutput(stdout: string): {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function buildCursorInvocation(req: SpawnRequest):
|
|
57
|
-
|
|
56
|
+
export function buildCursorInvocation(req: SpawnRequest): AdapterInvocation {
|
|
57
|
+
validateAdapterEffort("cursor", req.effort);
|
|
58
58
|
if (req.filesystemPolicy) {
|
|
59
59
|
// Declared unrepresentable: refuse rather than drop it silently (ADR 0039).
|
|
60
60
|
resolveSandboxProjection(
|
|
61
61
|
"cursor",
|
|
62
|
-
|
|
62
|
+
builtinAdapterProfile("cursor")?.sandboxProjection,
|
|
63
63
|
req.filesystemPolicy,
|
|
64
64
|
);
|
|
65
65
|
}
|
|
@@ -73,7 +73,7 @@ export function buildCursorInvocation(req: SpawnRequest): HarnessInvocation {
|
|
|
73
73
|
return { argv };
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export function normalizeCursorResult(raw:
|
|
76
|
+
export function normalizeCursorResult(raw: AdapterRawResult): SpawnResult {
|
|
77
77
|
if (raw.timedOut) {
|
|
78
78
|
return {
|
|
79
79
|
ok: false,
|
|
@@ -82,15 +82,30 @@ export function normalizeCursorResult(raw: HarnessRawResult): SpawnResult {
|
|
|
82
82
|
error: `cursor timed out after ${raw.durationMs}ms and was killed`,
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
+
// Structural environment signal: the binary was never there (spawned directly,
|
|
86
|
+
// so a missing binary surfaces as ENOENT). Uncharged and not retried.
|
|
87
|
+
if (raw.spawnErrno === "ENOENT") {
|
|
88
|
+
return {
|
|
89
|
+
ok: false,
|
|
90
|
+
text: "",
|
|
91
|
+
durationMs: raw.durationMs,
|
|
92
|
+
error: notFoundError("cursor"),
|
|
93
|
+
class: "environment",
|
|
94
|
+
};
|
|
95
|
+
}
|
|
85
96
|
if (raw.exitCode === 127) {
|
|
97
|
+
// A bare 127 with no errno is a shell/vendor 127, indistinguishable from a
|
|
98
|
+
// legitimate one — charged as work rather than classed environment.
|
|
86
99
|
return { ok: false, text: "", durationMs: raw.durationMs, error: notFoundError("cursor") };
|
|
87
100
|
}
|
|
88
101
|
if (raw.exitCode !== 0) {
|
|
102
|
+
const failureText = vendorFailureText(raw);
|
|
89
103
|
return {
|
|
90
104
|
ok: false,
|
|
91
105
|
text: "",
|
|
92
106
|
durationMs: raw.durationMs,
|
|
93
|
-
error: `cursor-agent exited ${raw.exitCode}: ${
|
|
107
|
+
error: `cursor-agent exited ${raw.exitCode}: ${failureText}`,
|
|
108
|
+
...(isUpstreamFailureText(failureText) ? { class: "upstream" as const } : {}),
|
|
94
109
|
};
|
|
95
110
|
}
|
|
96
111
|
|
|
@@ -102,6 +117,7 @@ export function normalizeCursorResult(raw: HarnessRawResult): SpawnResult {
|
|
|
102
117
|
sessionId: parsed.sessionId,
|
|
103
118
|
durationMs: raw.durationMs,
|
|
104
119
|
error: `cursor-agent reported is_error: ${parsed.text.slice(0, 300)}`,
|
|
120
|
+
...(isUpstreamFailureText(parsed.text) ? { class: "upstream" as const } : {}),
|
|
105
121
|
};
|
|
106
122
|
}
|
|
107
123
|
return {
|
|
@@ -114,7 +130,7 @@ export function normalizeCursorResult(raw: HarnessRawResult): SpawnResult {
|
|
|
114
130
|
|
|
115
131
|
export const cursorSpawner: Spawner = async (req: SpawnRequest): Promise<SpawnResult> => {
|
|
116
132
|
const t0 = Date.now();
|
|
117
|
-
let invocation:
|
|
133
|
+
let invocation: AdapterInvocation;
|
|
118
134
|
try {
|
|
119
135
|
invocation = buildCursorInvocation(req);
|
|
120
136
|
} catch (error) {
|
|
@@ -123,7 +139,10 @@ export const cursorSpawner: Spawner = async (req: SpawnRequest): Promise<SpawnRe
|
|
|
123
139
|
|
|
124
140
|
const r = await exec(invocation.argv, {
|
|
125
141
|
cwd: req.cwd,
|
|
126
|
-
env: buildChildEnv(req.runId, {
|
|
142
|
+
env: buildChildEnv(req.runId, {
|
|
143
|
+
subscriptionOnly: req.subscriptionOnly,
|
|
144
|
+
agentId: req.agentId,
|
|
145
|
+
}),
|
|
127
146
|
timeout: req.timeoutMs,
|
|
128
147
|
});
|
|
129
148
|
return normalizeCursorResult({ ...r, durationMs: Date.now() - t0 });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared failure-text extraction for the
|
|
2
|
+
* Shared failure-text extraction for the adapter spawn adapters.
|
|
3
3
|
*
|
|
4
4
|
* A vendor CLI prints its banner, resolved config, and startup warnings first,
|
|
5
5
|
* and the reason it actually failed last. Every adapter used to keep the FIRST
|
|
@@ -26,3 +26,43 @@ export function vendorFailureText(
|
|
|
26
26
|
const combined = parts.join("\n");
|
|
27
27
|
return combined.length > maxChars ? `…${combined.slice(-maxChars)}` : combined;
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
// A 429 or 5xx status, but only where it sits in HTTP-status CONTEXT — not any
|
|
31
|
+
// digits that merely happen to fall in that range. A bare-number match treats a
|
|
32
|
+
// line number ("at line 500"), an item count ("got 429 items"), or a duration
|
|
33
|
+
// ("after 502 seconds") as an upstream refusal, which wrongly withholds a charge
|
|
34
|
+
// for a failure that was entirely our code. Three recognized shapes:
|
|
35
|
+
// 1. after an "HTTP" label: "HTTP 429", "HTTP/1.1 503 Service Unavailable"
|
|
36
|
+
// 2. after a "status" label: "status 500", "status: 429", "status code 502"
|
|
37
|
+
// 3. a bare status line: "503 Service Unavailable" (code at line start,
|
|
38
|
+
// then a reason phrase) — the classic "<code> <Reason-Phrase>" shape.
|
|
39
|
+
// The trailing `(?![0-9])` and the label/line-start anchors also keep a status
|
|
40
|
+
// embedded in a longer number ("4295"/"5031") out. All 5xx are server-side; 429
|
|
41
|
+
// is the only 4xx that means "reached and refused, retry later".
|
|
42
|
+
const STATUS = "(?:429|5[0-9]{2})";
|
|
43
|
+
const UPSTREAM_STATUS = new RegExp(
|
|
44
|
+
`(?:\\bHTTP\\b[/0-9. ]*|\\bstatus(?:\\s*code)?\\b[\\s:=]*)${STATUS}(?![0-9])` +
|
|
45
|
+
`|(?:^|\\n)\\s*${STATUS}\\s+[A-Za-z]`,
|
|
46
|
+
"i",
|
|
47
|
+
);
|
|
48
|
+
// Explicit vendor wording for the same conditions when a numeric status is
|
|
49
|
+
// absent. Deliberately short — see isUpstreamFailureText.
|
|
50
|
+
const UPSTREAM_PHRASES =
|
|
51
|
+
/circuit[ _-]?open|service unavailable|too many requests|rate[ _-]?limit|overloaded|bad gateway|gateway time-?out|internal server error/i;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Whether failure text names an UPSTREAM refusal — the vendor was reached and
|
|
55
|
+
* refused (a 5xx/429 status or circuit-open wording), as opposed to a work
|
|
56
|
+
* failure (the model ran and produced a wrong or incomplete result).
|
|
57
|
+
*
|
|
58
|
+
* There is no structural upstream signal the way ENOENT structurally marks a
|
|
59
|
+
* missing binary, so this is the one text match in the classifier. It is kept
|
|
60
|
+
* SHORT and documented on purpose: a per-vendor regex zoo would rot, and a
|
|
61
|
+
* false positive here wrongly withholds a charge, so both the phrase list and
|
|
62
|
+
* the numeric match stay tight — the number must sit in HTTP-status context, not
|
|
63
|
+
* merely fall in the 429/5xx range. Anything it does not match falls through to
|
|
64
|
+
* a charged work failure.
|
|
65
|
+
*/
|
|
66
|
+
export function isUpstreamFailureText(text: string): boolean {
|
|
67
|
+
return UPSTREAM_STATUS.test(text) || UPSTREAM_PHRASES.test(text);
|
|
68
|
+
}
|
|
@@ -29,7 +29,7 @@ export function normalizeWorkflowSpecialists(
|
|
|
29
29
|
`workflow specialist ${id} instructions`,
|
|
30
30
|
MAX_INSTRUCTIONS,
|
|
31
31
|
),
|
|
32
|
-
|
|
32
|
+
adapter: optional(profile.adapter, `workflow specialist ${id} adapter`),
|
|
33
33
|
model: optional(profile.model, `workflow specialist ${id} model`),
|
|
34
34
|
effort: optional(profile.effort, `workflow specialist ${id} effort`),
|
|
35
35
|
maxAttempts: positiveOptional(
|
|
@@ -64,7 +64,7 @@ export function resolveSpecialistAssignment(
|
|
|
64
64
|
prompt: `${profile.instructions}\n\nAssignment:\n${prompt}`,
|
|
65
65
|
opts: {
|
|
66
66
|
specialist: opts.specialist,
|
|
67
|
-
|
|
67
|
+
adapter: opts.adapter ?? profile.adapter,
|
|
68
68
|
model: opts.model ?? profile.model,
|
|
69
69
|
effort: opts.effort ?? profile.effort,
|
|
70
70
|
maxAttempts: opts.maxAttempts ?? profile.maxAttempts,
|
|
@@ -3,27 +3,27 @@ import { dirname, join, resolve } from "node:path";
|
|
|
3
3
|
import { fsyncParentDirectory, stableDigest } from "./durable-record.ts";
|
|
4
4
|
|
|
5
5
|
// Limit for the JSON record body. The trailing newline delimiter is outside the
|
|
6
|
-
// record and is not counted by readers after splitting
|
|
7
|
-
export const
|
|
6
|
+
// record and is not counted by readers after splitting transcript lines.
|
|
7
|
+
export const WORKFLOW_TRANSCRIPT_EVENT_BYTES = 16 * 1024;
|
|
8
8
|
|
|
9
9
|
/** Key under which a shrunk record names the fields it had to drop. */
|
|
10
|
-
export const
|
|
10
|
+
export const WORKFLOW_TRANSCRIPT_OMITTED = "omitted_fields";
|
|
11
11
|
|
|
12
12
|
const RUN_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/;
|
|
13
13
|
|
|
14
|
-
export interface
|
|
14
|
+
export interface WorkflowTranscriptOmission {
|
|
15
15
|
field: string;
|
|
16
16
|
bytes: number;
|
|
17
17
|
sha256: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export function
|
|
20
|
+
export function workflowTranscriptPath(coordRoot: string, runId: string): string {
|
|
21
21
|
if (!RUN_ID.test(runId)) throw new Error(`invalid workflow run id ${JSON.stringify(runId)}`);
|
|
22
|
-
return join(resolve(coordRoot), ".harnery", "workflows", runId, "
|
|
22
|
+
return join(resolve(coordRoot), ".harnery", "workflows", runId, "transcript.jsonl");
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Append one
|
|
26
|
+
* Append one transcript record, always.
|
|
27
27
|
*
|
|
28
28
|
* A record that would exceed what a reader accepts has its largest fields
|
|
29
29
|
* replaced by a digest and a byte count until it fits, and it names what it
|
|
@@ -35,14 +35,14 @@ export function workflowJournalPath(coordRoot: string, runId: string): string {
|
|
|
35
35
|
* this limit by construction. Losing detail from a record is recoverable.
|
|
36
36
|
* Losing the run that was writing it is not.
|
|
37
37
|
*/
|
|
38
|
-
export function
|
|
38
|
+
export function appendWorkflowTranscriptEvent(
|
|
39
39
|
coordRoot: string,
|
|
40
40
|
runId: string,
|
|
41
41
|
event: string,
|
|
42
42
|
data: Record<string, unknown>,
|
|
43
43
|
): void {
|
|
44
|
-
const path =
|
|
45
|
-
const record =
|
|
44
|
+
const path = workflowTranscriptPath(coordRoot, runId);
|
|
45
|
+
const record = fitWorkflowTranscriptRecord(
|
|
46
46
|
{ schema_version: 1, run_id: runId, ts: new Date().toISOString(), event },
|
|
47
47
|
data,
|
|
48
48
|
);
|
|
@@ -64,16 +64,16 @@ export function appendWorkflowJournalEvent(
|
|
|
64
64
|
* The envelope is never dropped, so a record keeps its run id, timestamp, and
|
|
65
65
|
* event name however much detail it loses. Exported for tests.
|
|
66
66
|
*/
|
|
67
|
-
export function
|
|
67
|
+
export function fitWorkflowTranscriptRecord(
|
|
68
68
|
envelope: Record<string, unknown>,
|
|
69
69
|
data: Record<string, unknown>,
|
|
70
70
|
): Record<string, unknown> {
|
|
71
71
|
const candidate = { ...envelope, ...data };
|
|
72
|
-
if (Buffer.byteLength(JSON.stringify(candidate)) <=
|
|
72
|
+
if (Buffer.byteLength(JSON.stringify(candidate)) <= WORKFLOW_TRANSCRIPT_EVENT_BYTES) {
|
|
73
73
|
return candidate;
|
|
74
74
|
}
|
|
75
75
|
const kept: Record<string, unknown> = { ...data };
|
|
76
|
-
const omitted:
|
|
76
|
+
const omitted: WorkflowTranscriptOmission[] = [];
|
|
77
77
|
const bySize = Object.keys(data)
|
|
78
78
|
.map((field) => ({ field, bytes: Buffer.byteLength(JSON.stringify(data[field]) ?? "") }))
|
|
79
79
|
.sort((a, b) => b.bytes - a.bytes);
|
|
@@ -81,10 +81,10 @@ export function fitWorkflowJournalRecord(
|
|
|
81
81
|
for (const { field, bytes } of bySize) {
|
|
82
82
|
omitted.push({ field, bytes, sha256: stableDigest(data[field]) });
|
|
83
83
|
delete kept[field];
|
|
84
|
-
const next = { ...envelope, ...kept, [
|
|
85
|
-
if (Buffer.byteLength(JSON.stringify(next)) <=
|
|
84
|
+
const next = { ...envelope, ...kept, [WORKFLOW_TRANSCRIPT_OMITTED]: omitted };
|
|
85
|
+
if (Buffer.byteLength(JSON.stringify(next)) <= WORKFLOW_TRANSCRIPT_EVENT_BYTES) return next;
|
|
86
86
|
}
|
|
87
87
|
// Every field dropped and still over: the omission list is itself the excess.
|
|
88
88
|
// Keep the envelope and a count so the record stays parseable and honest.
|
|
89
|
-
return { ...envelope, [
|
|
89
|
+
return { ...envelope, [WORKFLOW_TRANSCRIPT_OMITTED]: omitted.length };
|
|
90
90
|
}
|