harnery 0.30.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.map +1 -1
- package/dist/commands/work.js +38 -22
- 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 +23 -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 +66 -52
- package/dist/core/{supervisor → governor}/plan-types.d.ts +57 -56
- 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 +125 -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 +228 -108
- 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/state.d.ts +12 -4
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +50 -17
- 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 +138 -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 +1 -1
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/proof.d.ts +11 -5
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +45 -36
- 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 +9 -6
- 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 +9 -6
- 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 +9 -6
- package/dist/core/workflow/spawn-failure.d.ts +1 -1
- package/dist/core/workflow/spawn-failure.js +1 -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 +98 -51
- 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/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 +50 -35
- 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 +23 -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 +112 -97
- package/src/core/{supervisor → governor}/plan-types.ts +59 -56
- package/src/core/{supervisor → governor}/planning.ts +223 -192
- 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 +325 -167
- 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/state.ts +65 -23
- 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 +155 -90
- package/src/core/workflow/evidence-preflight.ts +165 -0
- package/src/core/workflow/index.ts +3 -3
- package/src/core/workflow/proof.ts +60 -50
- 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 +13 -10
- package/src/core/workflow/spawn-codex.ts +13 -10
- package/src/core/workflow/spawn-cursor.ts +13 -10
- package/src/core/workflow/spawn-failure.ts +1 -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 +108 -51
- 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/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.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
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
* the canonical stream. The web image feed (`/images`) groups those events by
|
|
10
10
|
* hash and streams them live over the existing SSE infra.
|
|
11
11
|
*
|
|
12
|
-
* Why this lives at the hook layer: it's the single
|
|
12
|
+
* Why this lives at the hook layer: it's the single adapter-agnostic chokepoint
|
|
13
13
|
* that sees every tool call across Claude Code / Cursor / Codex with the full
|
|
14
14
|
* `tool_input` (file paths) and `tool_response`. No per-command code needed.
|
|
15
15
|
*
|
|
16
16
|
* Everything here is best-effort and MUST NOT throw; callers wrap it in
|
|
17
17
|
* try/catch + logError, matching every other effect.
|
|
18
18
|
*/
|
|
19
|
-
import type {
|
|
20
|
-
import type {
|
|
19
|
+
import type { ParsedPayload } from "../adapter/parse.js";
|
|
20
|
+
import type { Adapter } from "../events/schema.js";
|
|
21
21
|
export interface CaptureContext {
|
|
22
22
|
eventType: "tool.pre_use" | "tool.post_use";
|
|
23
23
|
/** The built event data (tool_name, tool_input string, intent, tool_use_id). */
|
|
@@ -26,7 +26,7 @@ export interface CaptureContext {
|
|
|
26
26
|
payload: ParsedPayload | null;
|
|
27
27
|
instanceId: string;
|
|
28
28
|
sessionId: string;
|
|
29
|
-
|
|
29
|
+
adapter: Adapter;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Inspect one tool event for image references and capture any that resolve to
|
|
@@ -36,7 +36,7 @@ export declare function captureImages(coordRoot: string, ctx: CaptureContext): v
|
|
|
36
36
|
/**
|
|
37
37
|
* Prune `.harnery/images/` past a size cap (default 2 GB) and an age cap
|
|
38
38
|
* (default 30 days), oldest-mtime-first. Fired on session.start next to
|
|
39
|
-
*
|
|
39
|
+
* journalJanitor. Pure-fs, fail-soft. Orphaned `image.captured` events whose
|
|
40
40
|
* blob was pruned render as an "expired" placeholder in the gallery.
|
|
41
41
|
*/
|
|
42
42
|
export declare function imageJanitor(coordRoot: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-capture.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/effects/image-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"image-capture.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/effects/image-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAcH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAoBnD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,cAAc,GAAG,eAAe,CAAC;IAC5C,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,gFAAgF;IAChF,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB;AAUD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAoC1E;AA2FD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAmDpD"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* the canonical stream. The web image feed (`/images`) groups those events by
|
|
10
10
|
* hash and streams them live over the existing SSE infra.
|
|
11
11
|
*
|
|
12
|
-
* Why this lives at the hook layer: it's the single
|
|
12
|
+
* Why this lives at the hook layer: it's the single adapter-agnostic chokepoint
|
|
13
13
|
* that sees every tool call across Claude Code / Cursor / Codex with the full
|
|
14
14
|
* `tool_input` (file paths) and `tool_response`. No per-command code needed.
|
|
15
15
|
*
|
|
@@ -58,7 +58,7 @@ export function captureImages(coordRoot, ctx) {
|
|
|
58
58
|
event_type: "image.captured",
|
|
59
59
|
instance_id: ctx.instanceId,
|
|
60
60
|
session_id: ctx.sessionId,
|
|
61
|
-
|
|
61
|
+
adapter: ctx.adapter,
|
|
62
62
|
data: {
|
|
63
63
|
hash: captured.hash,
|
|
64
64
|
ext: captured.ext,
|
|
@@ -162,7 +162,7 @@ function captureOne(imagesDir, cand) {
|
|
|
162
162
|
/**
|
|
163
163
|
* Prune `.harnery/images/` past a size cap (default 2 GB) and an age cap
|
|
164
164
|
* (default 30 days), oldest-mtime-first. Fired on session.start next to
|
|
165
|
-
*
|
|
165
|
+
* journalJanitor. Pure-fs, fail-soft. Orphaned `image.captured` events whose
|
|
166
166
|
* blob was pruned render as an "expired" placeholder in the gallery.
|
|
167
167
|
*/
|
|
168
168
|
export function imageJanitor(coordRoot) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Non-coordination side effects fired from the normalized `agent-hook` handlers.
|
|
3
3
|
*
|
|
4
|
-
* These are DELIBERATELY outside the agent-coord path: sounds,
|
|
4
|
+
* These are DELIBERATELY outside the agent-coord path: sounds, journal
|
|
5
5
|
* lifecycle, session telemetry, presence detection. They used to live in
|
|
6
|
-
* per-
|
|
6
|
+
* per-adapter bash adapters. Per the directive ("use the normalized hooks; if
|
|
7
7
|
* they aren't coordination, implement them outside of coordination") they move
|
|
8
|
-
* here so the
|
|
8
|
+
* here so the adapter configs reference only `agent-hook`, while staying a
|
|
9
9
|
* distinct concern from the coordination logic in cli.ts / agent-coord.
|
|
10
10
|
*
|
|
11
11
|
* Everything here is best-effort: it never throws and never blocks the hook on a
|
|
@@ -26,27 +26,27 @@ export declare function soundForEvent(eventName: string): {
|
|
|
26
26
|
sound: string;
|
|
27
27
|
maxPlays: number;
|
|
28
28
|
} | null;
|
|
29
|
-
/** Prune stale
|
|
30
|
-
export declare function
|
|
29
|
+
/** Prune stale journal archives + sweep orphans (global, fast). Fire-and-forget. */
|
|
30
|
+
export declare function journalJanitor(repoRoot: string): void;
|
|
31
31
|
/**
|
|
32
|
-
* Return the one-line
|
|
32
|
+
* Return the one-line journal recovery cue for SessionStart, or "" if none.
|
|
33
33
|
* The caller merges it into the session-start additionalContext (it used to be
|
|
34
|
-
* a standalone additionalContext emission from the previous
|
|
34
|
+
* a standalone additionalContext emission from the previous journal-on-start adapter).
|
|
35
35
|
*/
|
|
36
|
-
export declare function
|
|
37
|
-
/** Archive the ending agent's
|
|
38
|
-
export declare function
|
|
36
|
+
export declare function journalRecoveryCue(repoRoot: string): string;
|
|
37
|
+
/** Archive the ending agent's journal. Fire-and-forget. */
|
|
38
|
+
export declare function journalArchive(repoRoot: string, owner: string): void;
|
|
39
39
|
/**
|
|
40
40
|
* Fire the optional host session-sync extension on turn stop / session end.
|
|
41
41
|
* harnery core has no session-telemetry sink of its own; a host that wants one
|
|
42
42
|
* drops an executable at
|
|
43
|
-
* `scripts/hooks/
|
|
43
|
+
* `scripts/hooks/adapter/claude_code/extensions/session-sync.sh` under the coord
|
|
44
44
|
* root, and core runs it detached + unref'd so a slow sink never blocks the
|
|
45
45
|
* hook. `force` arrives as argv $1 ("1" on session end, "0" on turn stop) so the
|
|
46
46
|
* host can rate-limit the stop path and force-flush on end. No-op when the
|
|
47
47
|
* script is absent, so a plain public install spawns nothing. Mirrors
|
|
48
48
|
* `runTurnSummary`'s extension-script pattern. Caller gates to the claude-code
|
|
49
|
-
*
|
|
49
|
+
* adapter.
|
|
50
50
|
*/
|
|
51
51
|
export declare function runSessionSyncExtension(repoRoot: string, force: boolean): void;
|
|
52
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/effects/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjE;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,SAAI,GACX,IAAI,CAYN;AAED,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAW3F;AAOD,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAYrD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAa3D;AAED,
|
|
1
|
+
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11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Non-coordination side effects fired from the normalized `agent-hook` handlers.
|
|
3
3
|
*
|
|
4
|
-
* These are DELIBERATELY outside the agent-coord path: sounds,
|
|
4
|
+
* These are DELIBERATELY outside the agent-coord path: sounds, journal
|
|
5
5
|
* lifecycle, session telemetry, presence detection. They used to live in
|
|
6
|
-
* per-
|
|
6
|
+
* per-adapter bash adapters. Per the directive ("use the normalized hooks; if
|
|
7
7
|
* they aren't coordination, implement them outside of coordination") they move
|
|
8
|
-
* here so the
|
|
8
|
+
* here so the adapter configs reference only `agent-hook`, while staying a
|
|
9
9
|
* distinct concern from the coordination logic in cli.ts / agent-coord.
|
|
10
10
|
*
|
|
11
11
|
* Everything here is best-effort: it never throws and never blocks the hook on a
|
|
@@ -56,13 +56,13 @@ function harnBin(repoRoot) {
|
|
|
56
56
|
const bin = join(repoRoot, "harnery", "bin", "harn");
|
|
57
57
|
return existsSync(bin) ? bin : null;
|
|
58
58
|
}
|
|
59
|
-
/** Prune stale
|
|
60
|
-
export function
|
|
59
|
+
/** Prune stale journal archives + sweep orphans (global, fast). Fire-and-forget. */
|
|
60
|
+
export function journalJanitor(repoRoot) {
|
|
61
61
|
try {
|
|
62
62
|
const bin = harnBin(repoRoot);
|
|
63
63
|
if (!bin)
|
|
64
64
|
return;
|
|
65
|
-
spawnSync("bash", [bin, "
|
|
65
|
+
spawnSync("bash", [bin, "journal", "janitor", "--quiet"], {
|
|
66
66
|
env: { ...process.env, HARNERY_OUTPUT_SESSION_TEE: "0" },
|
|
67
67
|
timeout: 5000,
|
|
68
68
|
stdio: "ignore",
|
|
@@ -73,16 +73,16 @@ export function scratchJanitor(repoRoot) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
* Return the one-line
|
|
76
|
+
* Return the one-line journal recovery cue for SessionStart, or "" if none.
|
|
77
77
|
* The caller merges it into the session-start additionalContext (it used to be
|
|
78
|
-
* a standalone additionalContext emission from the previous
|
|
78
|
+
* a standalone additionalContext emission from the previous journal-on-start adapter).
|
|
79
79
|
*/
|
|
80
|
-
export function
|
|
80
|
+
export function journalRecoveryCue(repoRoot) {
|
|
81
81
|
try {
|
|
82
82
|
const bin = harnBin(repoRoot);
|
|
83
83
|
if (!bin)
|
|
84
84
|
return "";
|
|
85
|
-
const r = spawnSync("bash", [bin, "
|
|
85
|
+
const r = spawnSync("bash", [bin, "journal", "recovery-cue"], {
|
|
86
86
|
env: { ...process.env, HARNERY_OUTPUT_SESSION_TEE: "0" },
|
|
87
87
|
timeout: 5000,
|
|
88
88
|
encoding: "utf8",
|
|
@@ -93,13 +93,13 @@ export function scratchRecoveryCue(repoRoot) {
|
|
|
93
93
|
return "";
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
/** Archive the ending agent's
|
|
97
|
-
export function
|
|
96
|
+
/** Archive the ending agent's journal. Fire-and-forget. */
|
|
97
|
+
export function journalArchive(repoRoot, owner) {
|
|
98
98
|
try {
|
|
99
99
|
const bin = harnBin(repoRoot);
|
|
100
100
|
if (!bin || !owner)
|
|
101
101
|
return;
|
|
102
|
-
spawnSync("bash", [bin, "
|
|
102
|
+
spawnSync("bash", [bin, "journal", "archive", "--owner", owner], {
|
|
103
103
|
env: { ...process.env, HARNERY_OUTPUT_SESSION_TEE: "0" },
|
|
104
104
|
timeout: 5000,
|
|
105
105
|
stdio: "ignore",
|
|
@@ -113,17 +113,17 @@ export function scratchArchive(repoRoot, owner) {
|
|
|
113
113
|
* Fire the optional host session-sync extension on turn stop / session end.
|
|
114
114
|
* harnery core has no session-telemetry sink of its own; a host that wants one
|
|
115
115
|
* drops an executable at
|
|
116
|
-
* `scripts/hooks/
|
|
116
|
+
* `scripts/hooks/adapter/claude_code/extensions/session-sync.sh` under the coord
|
|
117
117
|
* root, and core runs it detached + unref'd so a slow sink never blocks the
|
|
118
118
|
* hook. `force` arrives as argv $1 ("1" on session end, "0" on turn stop) so the
|
|
119
119
|
* host can rate-limit the stop path and force-flush on end. No-op when the
|
|
120
120
|
* script is absent, so a plain public install spawns nothing. Mirrors
|
|
121
121
|
* `runTurnSummary`'s extension-script pattern. Caller gates to the claude-code
|
|
122
|
-
*
|
|
122
|
+
* adapter.
|
|
123
123
|
*/
|
|
124
124
|
export function runSessionSyncExtension(repoRoot, force) {
|
|
125
125
|
try {
|
|
126
|
-
const script = join(repoRoot, "scripts", "hooks", "
|
|
126
|
+
const script = join(repoRoot, "scripts", "hooks", "adapter", "claude_code", "extensions", "session-sync.sh");
|
|
127
127
|
if (!existsSync(script))
|
|
128
128
|
return;
|
|
129
129
|
const child = spawn("bash", [script, force ? "1" : "0"], {
|
|
@@ -147,7 +147,7 @@ export function runTurnSummary(repoRoot, owner, sessionId, transcriptPath) {
|
|
|
147
147
|
try {
|
|
148
148
|
if (!transcriptPath || !existsSync(transcriptPath))
|
|
149
149
|
return;
|
|
150
|
-
const script = join(repoRoot, "scripts", "hooks", "
|
|
150
|
+
const script = join(repoRoot, "scripts", "hooks", "adapter", "claude_code", "extensions", "turn-summary.sh");
|
|
151
151
|
if (!existsSync(script))
|
|
152
152
|
return;
|
|
153
153
|
const child = spawn("bash", [script, owner, sessionId, transcriptPath], {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Adapter, type EventEnvelope, type EventType, type Source } from "./schema.js";
|
|
2
2
|
export interface EmitInput<TType extends EventType, TData> {
|
|
3
3
|
event_type: TType;
|
|
4
4
|
instance_id: string;
|
|
5
5
|
session_id: string;
|
|
6
|
-
|
|
6
|
+
adapter: Adapter;
|
|
7
7
|
source?: Source;
|
|
8
8
|
parent_session_id?: string;
|
|
9
9
|
turn_id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/events/emit.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/events/emit.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,SAAS,EAEd,KAAK,MAAM,EACZ,MAAM,aAAa,CAAC;AAQrB,MAAM,WAAW,SAAS,CAAC,KAAK,SAAS,SAAS,EAAE,KAAK;IACvD,UAAU,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC;CACb;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAS,SAAS,EAAE,KAAK,EAC1D,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,GAC7B,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAe7B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,KAAK,SAAS,SAAS,EAAE,KAAK,EACjD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,GAC7B,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAyC7B"}
|
|
@@ -21,7 +21,7 @@ export function buildEnvelope(input) {
|
|
|
21
21
|
parent_session_id: input.parent_session_id,
|
|
22
22
|
turn_id: input.turn_id,
|
|
23
23
|
parent_turn_id: input.parent_turn_id,
|
|
24
|
-
|
|
24
|
+
adapter: input.adapter,
|
|
25
25
|
source: input.source ?? "agent-hooks",
|
|
26
26
|
data: input.data,
|
|
27
27
|
};
|
|
@@ -48,7 +48,7 @@ function resolveRollBytes() {
|
|
|
48
48
|
return Number.isFinite(n) && n > 0 ? n : DEFAULT_ROLL_BYTES;
|
|
49
49
|
}
|
|
50
50
|
/** `YYYY-MM-DD` (UTC) from a millisecond timestamp. Uses the file's own mtime
|
|
51
|
-
* rather than `Date.now()` so it's deterministic and independent of the
|
|
51
|
+
* rather than `Date.now()` so it's deterministic and independent of the adapter
|
|
52
52
|
* runtime's clock surface. */
|
|
53
53
|
function utcDateStamp(mtimeMs) {
|
|
54
54
|
const d = new Date(mtimeMs);
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
* `schema_version`.
|
|
11
11
|
*/
|
|
12
12
|
export declare const SCHEMA_VERSION: 1;
|
|
13
|
-
|
|
13
|
+
/** The adapters harnery ships first-party hook wiring for. The registry's open
|
|
14
|
+
* `AdapterId` covers any adapter a host registers; this is the closed set, and
|
|
15
|
+
* it is declared exactly once. Re-exported by the two event modules that used
|
|
16
|
+
* to keep their own byte-identical copy. */
|
|
17
|
+
export type Adapter = "claude-code" | "cursor" | "codex";
|
|
14
18
|
export type Source = "agent-hooks" | "agent-coord" | "user" | "system";
|
|
15
19
|
/**
|
|
16
20
|
* Common envelope every event carries. Tool events, `user_prompt.submit`, and
|
|
@@ -28,7 +32,7 @@ export interface EventEnvelope<TType extends string, TData> {
|
|
|
28
32
|
parent_session_id?: string;
|
|
29
33
|
turn_id?: string;
|
|
30
34
|
parent_turn_id?: string;
|
|
31
|
-
|
|
35
|
+
adapter: Adapter;
|
|
32
36
|
source: Source;
|
|
33
37
|
data: TData;
|
|
34
38
|
}
|
|
@@ -38,9 +42,13 @@ export type SessionStart = EventEnvelope<"session.start", {
|
|
|
38
42
|
model?: string;
|
|
39
43
|
pid: number;
|
|
40
44
|
/** Present iff this session is a `workflow run` child: the run id whose
|
|
41
|
-
*
|
|
45
|
+
* transcript owns it (child env HARNERY_WORKFLOW_RUN_ID). Optional-field
|
|
42
46
|
* addition per the schema evolution rules (minor bump). */
|
|
43
47
|
workflow_run_id?: string;
|
|
48
|
+
/** Which agent row of that run this session is running (`a1`, `a2`, …), from
|
|
49
|
+
* child env HARNERY_WORKFLOW_AGENT_ID. Lets a dashboard attribute in-flight
|
|
50
|
+
* child activity to one agent instead of only to the run. */
|
|
51
|
+
workflow_agent_id?: string;
|
|
44
52
|
}>;
|
|
45
53
|
export type SessionEnd = EventEnvelope<"session.end", {
|
|
46
54
|
ended_at: string;
|
|
@@ -175,7 +183,7 @@ export type StateStatusChecked = EventEnvelope<"state.status_checked", {
|
|
|
175
183
|
agent_count: number;
|
|
176
184
|
included_self: boolean;
|
|
177
185
|
}>;
|
|
178
|
-
export type
|
|
186
|
+
export type StateJournalAppend = EventEnvelope<"state.journal_append", {
|
|
179
187
|
category: "note" | "plan" | "decision" | "blocker" | "question" | "done" | "handoff";
|
|
180
188
|
body_summary: string;
|
|
181
189
|
}>;
|
|
@@ -261,7 +269,7 @@ export type HealthVerdictFailure = EventEnvelope<"health.verdict_failure", {
|
|
|
261
269
|
timeout_ms?: number;
|
|
262
270
|
fallback: "allow";
|
|
263
271
|
}>;
|
|
264
|
-
export type Event = SessionStart | SessionEnd | SubagentStart | SubagentStop | UserPromptSubmit | TurnStop | CommandStart | CommandOutput | CommandEnd | Narration | ToolPreUse | ToolPostUse | ToolPostUseFailure | ToolOutputChunk | ImageCaptured | ContextSampled | ContextCheckpointCreated | ContextCompactionStarted | ContextCompactionCompleted | ContextRecoveryInjected | ClaimAcquire | ClaimRelease | ClaimConflict | StateTaskSet | StateStatusChecked |
|
|
272
|
+
export type Event = SessionStart | SessionEnd | SubagentStart | SubagentStop | UserPromptSubmit | TurnStop | CommandStart | CommandOutput | CommandEnd | Narration | ToolPreUse | ToolPostUse | ToolPostUseFailure | ToolOutputChunk | ImageCaptured | ContextSampled | ContextCheckpointCreated | ContextCompactionStarted | ContextCompactionCompleted | ContextRecoveryInjected | ClaimAcquire | ClaimRelease | ClaimConflict | StateTaskSet | StateStatusChecked | StateJournalAppend | StatePresenceChange | StateHeartbeat | IdentityAssumed | CouncilOpen | CouncilRoundOpen | CouncilContribution | CouncilRoundClose | CouncilClose | CouncilArchive | DecisionBlock | DecisionWarn | DecisionAllow | HealthHeartbeatHeal | HealthPidmapHeal | HealthHeartbeatSwept | HealthVerdictFailure;
|
|
265
273
|
export type EventType = Event["event_type"];
|
|
266
274
|
/**
|
|
267
275
|
* Redaction marker that may be attached to any `data` payload during emission.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/events/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,cAAc,EAAG,CAAU,CAAC;AAEzC,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzD,MAAM,MAAM,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK;IACxD,cAAc,EAAE,OAAO,cAAc,CAAC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,KAAK,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,KAAK,CAAC;CACb;AAKD,MAAM,MAAM,YAAY,GAAG,aAAa,CACtC,eAAe,EACf;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ;;+DAE2D;IAC3D,eAAe,CAAC,EAAE,MA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gB,GAChB,mBAAmB,GACnB,iBAAiB,GACjB,YAAY,GACZ,cAAc,GACd,aAAa,GACb,YAAY,GACZ,aAAa,GACb,mBAAmB,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,oBAAoB,CAAC;AAEzB,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,cAAc,CAAC;IAC/D,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Canonicalize a write-tool target path for the claim guard.
|
|
3
3
|
*
|
|
4
4
|
* Returns the monorepo-relative path, or `null` when the target lies OUTSIDE the
|
|
5
|
-
* repo (an absolute path not under coordRoot, e.g. a `/tmp`
|
|
5
|
+
* repo (an absolute path not under coordRoot, e.g. a `/tmp` journal or other
|
|
6
6
|
* session-temp file).
|
|
7
7
|
*
|
|
8
8
|
* The claim system is intentionally repo-scoped: it coordinates monorepo files,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* them is right on two counts. First, it keeps non-repo paths out of a
|
|
11
11
|
* heartbeat's `files_touched`. Second, the ordering rule compares raw path
|
|
12
12
|
* strings, and an absolute `/tmp/…` sorts before every repo-relative path
|
|
13
|
-
* (`/` = 0x2F < any letter), so without this a
|
|
13
|
+
* (`/` = 0x2F < any letter), so without this a journal write would spuriously
|
|
14
14
|
* "block" a legitimately-held repo file. Returning null keeps such paths out of
|
|
15
15
|
* the claim system entirely.
|
|
16
16
|
*
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Canonicalize a write-tool target path for the claim guard.
|
|
3
3
|
*
|
|
4
4
|
* Returns the monorepo-relative path, or `null` when the target lies OUTSIDE the
|
|
5
|
-
* repo (an absolute path not under coordRoot, e.g. a `/tmp`
|
|
5
|
+
* repo (an absolute path not under coordRoot, e.g. a `/tmp` journal or other
|
|
6
6
|
* session-temp file).
|
|
7
7
|
*
|
|
8
8
|
* The claim system is intentionally repo-scoped: it coordinates monorepo files,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* them is right on two counts. First, it keeps non-repo paths out of a
|
|
11
11
|
* heartbeat's `files_touched`. Second, the ordering rule compares raw path
|
|
12
12
|
* strings, and an absolute `/tmp/…` sorts before every repo-relative path
|
|
13
|
-
* (`/` = 0x2F < any letter), so without this a
|
|
13
|
+
* (`/` = 0x2F < any letter), so without this a journal write would spuriously
|
|
14
14
|
* "block" a legitimately-held repo file. Returning null keeps such paths out of
|
|
15
15
|
* the claim system entirely.
|
|
16
16
|
*
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* Phase 1 (skeleton): exposes only the canonical event schema types. Parsers,
|
|
5
5
|
* resolvers, and emit helpers ship in Phase 2.
|
|
6
6
|
*/
|
|
7
|
-
export { type
|
|
7
|
+
export { type Adapter, type Event, type EventEnvelope, type EventType, type RedactionMarker, SCHEMA_VERSION, type Source, } from "./events/schema.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,cAAc,EACd,KAAK,MAAM,GACZ,MAAM,oBAAoB,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the heartbeat pid-map row should be keyed to, so the agent's later shell
|
|
4
4
|
* tool calls (which ppid-walk up to find it) resolve their own identity.
|
|
5
5
|
*
|
|
6
|
-
* Split out of cli.ts's `
|
|
6
|
+
* Split out of cli.ts's `findAdapterAnchorPid` so the comm-matching logic is
|
|
7
7
|
* unit-testable against the real Phase 0 Cursor probe chains without needing a
|
|
8
8
|
* live /proc tree.
|
|
9
9
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* calls a reachable, stable pid-map row. This faithfully restores the previous
|
|
15
15
|
* cursor anchor behavior (match `cursor` first, then fall back to `node`) that
|
|
16
16
|
* was dropped in the Phase 4-6 TS refactor, the same regression class as the
|
|
17
|
-
* heartbeat-platform + pidmap-self-heal losses. Scoped to `
|
|
17
|
+
* heartbeat-platform + pidmap-self-heal losses. Scoped to `adapter === "cursor"`
|
|
18
18
|
* so Claude Code / Codex never
|
|
19
19
|
* mis-anchor on an unrelated `node` ancestor (they match their own comm token
|
|
20
20
|
* directly).
|
|
@@ -24,22 +24,31 @@
|
|
|
24
24
|
* wins between them. Single-chat-per-window (the common case) is correct;
|
|
25
25
|
* concurrent same-window chats disambiguate via `--session-id`.
|
|
26
26
|
*/
|
|
27
|
+
/**
|
|
28
|
+
* The adapter pid as stated by the adapter itself, or undefined.
|
|
29
|
+
*
|
|
30
|
+
* Sanity-checked against our own pid: a variable naming this process would
|
|
31
|
+
* anchor the row to whatever short-lived thing is running the hook, which is
|
|
32
|
+
* the failure it exists to avoid.
|
|
33
|
+
*/
|
|
34
|
+
export declare function adapterPidFromEnv(): number | undefined;
|
|
27
35
|
/**
|
|
28
36
|
* Pick the anchor PID from a ppid chain ordered nearest-first (the resolving
|
|
29
37
|
* process at index 0, walking up toward init). Returns the first ancestor
|
|
30
|
-
* matching a
|
|
38
|
+
* matching a adapter comm token; for cursor, falls back to the first `node`
|
|
31
39
|
* ancestor; otherwise undefined (caller falls back to process.ppid).
|
|
32
40
|
*/
|
|
33
41
|
export declare function selectAnchorPid(chain: ReadonlyArray<{
|
|
34
42
|
pid: number;
|
|
35
43
|
comm: string;
|
|
36
|
-
|
|
44
|
+
exe?: string;
|
|
45
|
+
}>, adapter?: string): number | undefined;
|
|
37
46
|
/**
|
|
38
47
|
* Parse one `ps -o ppid=,comm= -p <pid>` line into the same `{ ppid, comm }`
|
|
39
48
|
* shape the `/proc` fast path produces, for the macOS/BSD branch of the anchor
|
|
40
49
|
* walk. `ps` prints `comm` as a full executable path (and some Apple helper
|
|
41
50
|
* names contain spaces, e.g. `Code Helper (Plugin)`), so the comm is reduced to
|
|
42
|
-
* its basename to match the
|
|
51
|
+
* its basename to match the adapter comm tokens the way Linux's `/proc/<pid>/comm`
|
|
43
52
|
* basename does. Returns null when the line has no leading numeric ppid.
|
|
44
53
|
*
|
|
45
54
|
* Pure (no I/O) so the parsing — the error-prone part — is unit-testable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/anchor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/anchor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAoBH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAStD;AAmBD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EACjE,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAgBpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQpF"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the heartbeat pid-map row should be keyed to, so the agent's later shell
|
|
4
4
|
* tool calls (which ppid-walk up to find it) resolve their own identity.
|
|
5
5
|
*
|
|
6
|
-
* Split out of cli.ts's `
|
|
6
|
+
* Split out of cli.ts's `findAdapterAnchorPid` so the comm-matching logic is
|
|
7
7
|
* unit-testable against the real Phase 0 Cursor probe chains without needing a
|
|
8
8
|
* live /proc tree.
|
|
9
9
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* calls a reachable, stable pid-map row. This faithfully restores the previous
|
|
15
15
|
* cursor anchor behavior (match `cursor` first, then fall back to `node`) that
|
|
16
16
|
* was dropped in the Phase 4-6 TS refactor, the same regression class as the
|
|
17
|
-
* heartbeat-platform + pidmap-self-heal losses. Scoped to `
|
|
17
|
+
* heartbeat-platform + pidmap-self-heal losses. Scoped to `adapter === "cursor"`
|
|
18
18
|
* so Claude Code / Codex never
|
|
19
19
|
* mis-anchor on an unrelated `node` ancestor (they match their own comm token
|
|
20
20
|
* directly).
|
|
@@ -24,21 +24,78 @@
|
|
|
24
24
|
* wins between them. Single-chat-per-window (the common case) is correct;
|
|
25
25
|
* concurrent same-window chats disambiguate via `--session-id`.
|
|
26
26
|
*/
|
|
27
|
-
/**
|
|
27
|
+
/** Adapter-binary comm names. CC's tool calls descend from `claude`, Codex's
|
|
28
28
|
* from `codex`; matched directly so neither needs the `node` fallback. */
|
|
29
29
|
const PRIMARY_COMM_TOKENS = new Set(["claude", "claude-code", "cursor", "codex"]);
|
|
30
|
+
/**
|
|
31
|
+
* Adapter-exported pid environment variables, in precedence order.
|
|
32
|
+
*
|
|
33
|
+
* A adapter that names its own process spares us the guessing entirely, and the
|
|
34
|
+
* guess is the part that breaks: comm matching only recognises a binary called
|
|
35
|
+
* by its adapter name, and at least one Claude Code build installs its CLI
|
|
36
|
+
* under a version-numbered filename, whose comm is a bare version string. The
|
|
37
|
+
* walk then finds nothing, falls back to the ephemeral hook shell, and writes a
|
|
38
|
+
* row that is dead within seconds.
|
|
39
|
+
*
|
|
40
|
+
* Only Claude Code is known to export one today. Absent variables cost a lookup.
|
|
41
|
+
*/
|
|
42
|
+
const ADAPTER_PID_ENV_VARS = ["CLAUDE_PID"];
|
|
43
|
+
/**
|
|
44
|
+
* The adapter pid as stated by the adapter itself, or undefined.
|
|
45
|
+
*
|
|
46
|
+
* Sanity-checked against our own pid: a variable naming this process would
|
|
47
|
+
* anchor the row to whatever short-lived thing is running the hook, which is
|
|
48
|
+
* the failure it exists to avoid.
|
|
49
|
+
*/
|
|
50
|
+
export function adapterPidFromEnv() {
|
|
51
|
+
for (const key of ADAPTER_PID_ENV_VARS) {
|
|
52
|
+
const raw = process.env[key]?.trim();
|
|
53
|
+
if (!raw)
|
|
54
|
+
continue;
|
|
55
|
+
const pid = Number(raw);
|
|
56
|
+
if (!Number.isInteger(pid) || pid <= 1 || pid === process.pid)
|
|
57
|
+
continue;
|
|
58
|
+
return pid;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Does an executable path belong to a adapter?
|
|
64
|
+
*
|
|
65
|
+
* Read as path segments rather than substrings, so a token has to be a whole
|
|
66
|
+
* directory or file name. The leading dot is optional because adapters install
|
|
67
|
+
* under a dotted home directory, and that directory is what identifies the
|
|
68
|
+
* binary when the binary's own name is a version number.
|
|
69
|
+
*/
|
|
70
|
+
function pathNamesAAdapter(exePath) {
|
|
71
|
+
if (!exePath)
|
|
72
|
+
return false;
|
|
73
|
+
for (const raw of exePath.split("/")) {
|
|
74
|
+
const segment = raw.startsWith(".") ? raw.slice(1) : raw;
|
|
75
|
+
if (PRIMARY_COMM_TOKENS.has(segment))
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
30
80
|
/**
|
|
31
81
|
* Pick the anchor PID from a ppid chain ordered nearest-first (the resolving
|
|
32
82
|
* process at index 0, walking up toward init). Returns the first ancestor
|
|
33
|
-
* matching a
|
|
83
|
+
* matching a adapter comm token; for cursor, falls back to the first `node`
|
|
34
84
|
* ancestor; otherwise undefined (caller falls back to process.ppid).
|
|
35
85
|
*/
|
|
36
|
-
export function selectAnchorPid(chain,
|
|
86
|
+
export function selectAnchorPid(chain, adapter) {
|
|
37
87
|
for (const hop of chain) {
|
|
38
88
|
if (PRIMARY_COMM_TOKENS.has(hop.comm))
|
|
39
89
|
return hop.pid;
|
|
40
90
|
}
|
|
41
|
-
|
|
91
|
+
// Second pass on the executable path, for a adapter whose binary is not named
|
|
92
|
+
// after itself. Kept behind the comm pass so an exactly-named ancestor still
|
|
93
|
+
// wins, and so this only ever adds matches.
|
|
94
|
+
for (const hop of chain) {
|
|
95
|
+
if (pathNamesAAdapter(hop.exe))
|
|
96
|
+
return hop.pid;
|
|
97
|
+
}
|
|
98
|
+
if (adapter === "cursor") {
|
|
42
99
|
for (const hop of chain) {
|
|
43
100
|
if (hop.comm === "node")
|
|
44
101
|
return hop.pid;
|
|
@@ -51,7 +108,7 @@ export function selectAnchorPid(chain, harness) {
|
|
|
51
108
|
* shape the `/proc` fast path produces, for the macOS/BSD branch of the anchor
|
|
52
109
|
* walk. `ps` prints `comm` as a full executable path (and some Apple helper
|
|
53
110
|
* names contain spaces, e.g. `Code Helper (Plugin)`), so the comm is reduced to
|
|
54
|
-
* its basename to match the
|
|
111
|
+
* its basename to match the adapter comm tokens the way Linux's `/proc/<pid>/comm`
|
|
55
112
|
* basename does. Returns null when the line has no leading numeric ppid.
|
|
56
113
|
*
|
|
57
114
|
* Pure (no I/O) so the parsing — the error-prone part — is unit-testable
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Resolution precedence:
|
|
6
6
|
* 1. HARNERY_COORD_ROOT_OVERRIDE — explicit pin (tests, git hooks).
|
|
7
|
-
* 2. The
|
|
7
|
+
* 2. The adapter's project dir (CLAUDE_PROJECT_DIR) — hook processes
|
|
8
8
|
* inherit the session's *shell* cwd, which follows `cd` into
|
|
9
9
|
* subdirectories/submodules that may carry a `.harnery/` of their own
|
|
10
|
-
* (or none at all, e.g. a
|
|
11
|
-
* coordination home is the project the
|
|
10
|
+
* (or none at all, e.g. a journal dir under /tmp). The session's
|
|
11
|
+
* coordination home is the project the adapter opened, not wherever the
|
|
12
12
|
* shell happens to sit, so a project dir that resolves to a coord root
|
|
13
13
|
* wins over the cwd walk.
|
|
14
14
|
* 3. Walk up from `start` (default cwd).
|
|
@@ -7,11 +7,11 @@ import { coordEnv } from "../../../lib/env.js";
|
|
|
7
7
|
*
|
|
8
8
|
* Resolution precedence:
|
|
9
9
|
* 1. HARNERY_COORD_ROOT_OVERRIDE — explicit pin (tests, git hooks).
|
|
10
|
-
* 2. The
|
|
10
|
+
* 2. The adapter's project dir (CLAUDE_PROJECT_DIR) — hook processes
|
|
11
11
|
* inherit the session's *shell* cwd, which follows `cd` into
|
|
12
12
|
* subdirectories/submodules that may carry a `.harnery/` of their own
|
|
13
|
-
* (or none at all, e.g. a
|
|
14
|
-
* coordination home is the project the
|
|
13
|
+
* (or none at all, e.g. a journal dir under /tmp). The session's
|
|
14
|
+
* coordination home is the project the adapter opened, not wherever the
|
|
15
15
|
* shell happens to sit, so a project dir that resolves to a coord root
|
|
16
16
|
* wins over the cwd walk.
|
|
17
17
|
* 3. Walk up from `start` (default cwd).
|
|
@@ -27,7 +27,7 @@ export function findCoordRoot(start = process.cwd()) {
|
|
|
27
27
|
if (override)
|
|
28
28
|
return override;
|
|
29
29
|
// Claude Code exports CLAUDE_PROJECT_DIR to every hook process; other
|
|
30
|
-
//
|
|
30
|
+
// adapters don't set it, so this is inert outside claude-code hooks.
|
|
31
31
|
const projectDir = process.env.CLAUDE_PROJECT_DIR;
|
|
32
32
|
if (projectDir) {
|
|
33
33
|
const fromProject = walkUp(projectDir);
|