harnery 0.45.1 → 0.46.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/dist/commander.d.ts +13 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commands/admission.d.ts.map +1 -1
- package/dist/commands/admission.js +214 -27
- package/dist/commands/agents.d.ts +4 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +102 -25
- package/dist/commands/browse.d.ts +3 -0
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +172 -8
- package/dist/commands/fetch.js +1 -0
- package/dist/commands/ledger-v3.d.ts.map +1 -1
- package/dist/commands/ledger-v3.js +8 -2
- package/dist/commands/presence.d.ts.map +1 -1
- package/dist/commands/presence.js +40 -0
- package/dist/commands/qa-run.d.ts.map +1 -1
- package/dist/commands/qa-run.js +4 -3
- package/dist/commands/review-pack.d.ts.map +1 -1
- package/dist/commands/review-pack.js +33 -6
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +6 -45
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +0 -18
- package/dist/core/agents/index.d.ts +1 -0
- package/dist/core/agents/index.d.ts.map +1 -1
- package/dist/core/agents/index.js +1 -0
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +11 -4
- package/dist/core/agents/render/session-context.d.ts +0 -6
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +1 -6
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +12 -4
- package/dist/core/agents/state/heartbeat-reader.d.ts +3 -0
- package/dist/core/agents/state/heartbeat-reader.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.d.ts +3 -1
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +6 -2
- package/dist/core/agents/state/parent-reference-contract.d.ts +16 -0
- package/dist/core/agents/state/parent-reference-contract.d.ts.map +1 -0
- package/dist/core/agents/state/parent-reference-contract.js +1 -0
- package/dist/core/agents/state/parent-reference.d.ts +18 -0
- package/dist/core/agents/state/parent-reference.d.ts.map +1 -0
- package/dist/core/agents/state/parent-reference.js +119 -0
- package/dist/core/agents/state/pidmap.js +2 -2
- package/dist/core/agents/state/proc-start.d.ts +20 -31
- package/dist/core/agents/state/proc-start.d.ts.map +1 -1
- package/dist/core/agents/state/proc-start.js +37 -70
- package/dist/core/agents/state/service-process.d.ts +61 -0
- package/dist/core/agents/state/service-process.d.ts.map +1 -0
- package/dist/core/agents/state/service-process.js +143 -0
- package/dist/core/config.d.ts +39 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +63 -0
- package/dist/core/context/index.d.ts +6 -4
- package/dist/core/context/index.d.ts.map +1 -1
- package/dist/core/context/index.js +194 -256
- package/dist/core/context/observation.d.ts +9 -9
- package/dist/core/context/observation.d.ts.map +1 -1
- package/dist/core/context/observation.js +37 -6
- package/dist/core/diagnostics/path-identity.d.ts +1 -1
- package/dist/core/diagnostics/path-identity.d.ts.map +1 -1
- package/dist/core/diagnostics/path-identity.js +51 -6
- package/dist/core/events/v3/canonical.js +43 -14
- package/dist/core/events/v3/index.d.ts +1 -1
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +1 -1
- package/dist/core/events/v3/producers/recorder.d.ts +34 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +117 -13
- package/dist/core/events/v3/reader.d.ts.map +1 -1
- package/dist/core/events/v3/reader.js +53 -13
- package/dist/core/events/v3/runtime-build.d.ts +14 -0
- package/dist/core/events/v3/runtime-build.d.ts.map +1 -1
- package/dist/core/events/v3/runtime-build.js +44 -0
- package/dist/core/events/v3/validate.d.ts.map +1 -1
- package/dist/core/events/v3/validate.js +36 -1
- package/dist/core/governor/index.d.ts +2 -1
- package/dist/core/governor/index.d.ts.map +1 -1
- package/dist/core/governor/index.js +2 -1
- package/dist/core/governor/service-read.d.ts +3 -10
- package/dist/core/governor/service-read.d.ts.map +1 -1
- package/dist/core/governor/service-read.js +10 -94
- package/dist/core/governor/service.d.ts +3 -7
- package/dist/core/governor/service.d.ts.map +1 -1
- package/dist/core/governor/service.js +17 -182
- package/dist/core/hooks/adapter/native-parent.d.ts +23 -0
- package/dist/core/hooks/adapter/native-parent.d.ts.map +1 -0
- package/dist/core/hooks/adapter/native-parent.js +91 -0
- package/dist/core/hooks/cli.js +79 -4
- package/dist/core/hooks/resolve/owner.d.ts +0 -11
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +2 -25
- package/dist/core/hooks/shell-admission.d.ts +84 -0
- package/dist/core/hooks/shell-admission.d.ts.map +1 -0
- package/dist/core/hooks/shell-admission.js +622 -0
- package/dist/core/hooks/shell-commit-tree.d.ts +2 -0
- package/dist/core/hooks/shell-commit-tree.d.ts.map +1 -0
- package/dist/core/hooks/shell-commit-tree.js +104 -0
- package/dist/core/inbox/contract.d.ts +12 -0
- package/dist/core/inbox/contract.d.ts.map +1 -1
- package/dist/core/inbox/contract.js +16 -0
- package/dist/core/inbox/peer-messages.d.ts +41 -16
- package/dist/core/inbox/peer-messages.d.ts.map +1 -1
- package/dist/core/inbox/peer-messages.js +372 -15
- package/dist/core/inbox/service.d.ts +8 -1
- package/dist/core/inbox/service.d.ts.map +1 -1
- package/dist/core/inbox/service.js +83 -3
- package/dist/core/inbox/targets.d.ts +17 -3
- package/dist/core/inbox/targets.d.ts.map +1 -1
- package/dist/core/inbox/targets.js +77 -2
- package/dist/core/presence/git.d.ts +18 -12
- package/dist/core/presence/git.d.ts.map +1 -1
- package/dist/core/presence/git.js +32 -38
- package/dist/core/presence/index.d.ts +2 -2
- package/dist/core/presence/index.d.ts.map +1 -1
- package/dist/core/presence/index.js +8 -6
- package/dist/core/presence/mail.d.ts +133 -0
- package/dist/core/presence/mail.d.ts.map +1 -0
- package/dist/core/presence/mail.js +464 -0
- package/dist/core/resources/sampler.js +2 -2
- package/dist/core/resources/service-status.d.ts +2 -14
- package/dist/core/resources/service-status.d.ts.map +1 -1
- package/dist/core/resources/service-status.js +3 -23
- package/dist/core/resources/service.d.ts +3 -7
- package/dist/core/resources/service.d.ts.map +1 -1
- package/dist/core/resources/service.js +12 -101
- package/dist/core/resources/status.d.ts.map +1 -1
- package/dist/core/resources/status.js +3 -2
- package/dist/core/semantic/contract.d.ts +5 -5
- package/dist/core/semantic/service.d.ts.map +1 -1
- package/dist/core/semantic/service.js +9 -2
- package/dist/core/servers/index.d.ts +0 -2
- package/dist/core/servers/index.d.ts.map +1 -1
- package/dist/core/servers/index.js +3 -18
- package/dist/core/storage/modes.d.ts +4 -0
- package/dist/core/storage/modes.d.ts.map +1 -1
- package/dist/core/storage/modes.js +4 -0
- package/dist/core/storage/segments.d.ts.map +1 -1
- package/dist/core/storage/segments.js +5 -4
- package/dist/core/supervisor/service.d.ts +4 -7
- package/dist/core/supervisor/service.d.ts.map +1 -1
- package/dist/core/supervisor/service.js +23 -122
- package/dist/core/supervisor/services.js +2 -2
- package/dist/core/supervisor/status.d.ts +3 -17
- package/dist/core/supervisor/status.d.ts.map +1 -1
- package/dist/core/supervisor/status.js +7 -70
- package/dist/core/workflow/engine.js +2 -1
- package/dist/core/workflow/index.d.ts +3 -4
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +2 -2
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +30 -74
- package/dist/core/workflow/resume-lock.d.ts +17 -0
- package/dist/core/workflow/resume-lock.d.ts.map +1 -0
- package/dist/core/workflow/resume-lock.js +158 -0
- package/dist/core/workflow/run-state.d.ts +0 -21
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +3 -174
- package/dist/core/workflow/workspaces/leases.d.ts +4 -0
- package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/leases.js +1 -1
- package/dist/core/workflow/workspaces/local-git.js +91 -210
- package/dist/core/workflow/workspaces/ownership.d.ts +0 -7
- package/dist/core/workflow/workspaces/ownership.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/ownership.js +3 -130
- package/dist/core/workflow/workspaces/reclaim.d.ts +4 -7
- package/dist/core/workflow/workspaces/reclaim.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/reclaim.js +0 -4
- package/dist/core/workflow/workspaces/recovery.d.ts +1 -1
- package/dist/core/workflow/workspaces/recovery.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/recovery.js +1 -1
- package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/state.js +1 -4
- package/dist/lib/admission-history.d.ts +96 -0
- package/dist/lib/admission-history.d.ts.map +1 -0
- package/dist/lib/admission-history.js +196 -0
- package/dist/lib/admission.d.ts +56 -7
- package/dist/lib/admission.d.ts.map +1 -1
- package/dist/lib/admission.js +161 -19
- package/dist/lib/browser/client.d.ts +18 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +100 -12
- package/dist/lib/browser/content-checks.d.ts +3 -1
- package/dist/lib/browser/content-checks.d.ts.map +1 -1
- package/dist/lib/browser/content-checks.js +10 -2
- package/dist/lib/browser/critique.d.ts +32 -0
- package/dist/lib/browser/critique.d.ts.map +1 -1
- package/dist/lib/browser/critique.js +72 -3
- package/dist/lib/browser/geometry.d.ts +2 -0
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +61 -15
- package/dist/lib/browser/index.d.ts +1 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +1 -1
- package/dist/lib/browser/page-review-contracts.d.ts +6 -1
- package/dist/lib/browser/page-review-contracts.d.ts.map +1 -1
- package/dist/lib/browser/page-review-contracts.js +6 -1
- package/dist/lib/browser/page-review-judge.d.ts +3 -1
- package/dist/lib/browser/page-review-judge.d.ts.map +1 -1
- package/dist/lib/browser/page-review-judge.js +41 -11
- package/dist/lib/browser/page-review-pack.d.ts +3 -0
- package/dist/lib/browser/page-review-pack.d.ts.map +1 -1
- package/dist/lib/browser/page-review-pack.js +5 -2
- package/dist/lib/browser/qa-run-contracts.d.ts +11 -0
- package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -1
- package/dist/lib/browser/qa-run-contracts.js +11 -4
- package/dist/lib/browser/qa-run.d.ts.map +1 -1
- package/dist/lib/browser/qa-run.js +73 -16
- package/dist/lib/browser/runts.d.ts +4 -2
- package/dist/lib/browser/runts.d.ts.map +1 -1
- package/dist/lib/browser/runts.js +84 -33
- package/dist/lib/browser/windows-chrome.d.ts +14 -0
- package/dist/lib/browser/windows-chrome.d.ts.map +1 -1
- package/dist/lib/browser/windows-chrome.js +42 -0
- package/dist/lib/browser/windows-login-sync.d.ts +110 -0
- package/dist/lib/browser/windows-login-sync.d.ts.map +1 -0
- package/dist/lib/browser/windows-login-sync.js +171 -0
- package/dist/lib/cookies/client.d.ts +30 -5
- package/dist/lib/cookies/client.d.ts.map +1 -1
- package/dist/lib/cookies/client.js +55 -10
- package/dist/lib/cookies/index.d.ts +1 -1
- package/dist/lib/cookies/index.d.ts.map +1 -1
- package/dist/lib/cookies/index.js +1 -1
- package/dist/lib/docs-metadata-sync.d.ts.map +1 -1
- package/dist/lib/docs-metadata-sync.js +41 -2
- package/dist/lib/durable-job.d.ts +8 -0
- package/dist/lib/durable-job.d.ts.map +1 -1
- package/dist/lib/durable-job.js +10 -0
- package/dist/lib/http/client.d.ts +9 -8
- package/dist/lib/http/client.d.ts.map +1 -1
- package/dist/lib/http/client.js +44 -2
- package/dist/lib/instructions/templates.js +4 -4
- package/package.json +2 -2
- package/src/commander.ts +13 -0
- package/src/commands/admission.ts +272 -29
- package/src/commands/agents.ts +132 -27
- package/src/commands/browse.ts +208 -6
- package/src/commands/fetch.ts +1 -0
- package/src/commands/ledger-v3.ts +8 -2
- package/src/commands/presence.ts +49 -0
- package/src/commands/qa-run.ts +4 -3
- package/src/commands/review-pack.ts +41 -5
- package/src/commands/workflow.ts +8 -58
- package/src/core/agents/coord-client.ts +0 -20
- package/src/core/agents/index.ts +6 -0
- package/src/core/agents/live-authority-v3.ts +11 -4
- package/src/core/agents/render/session-context.ts +1 -7
- package/src/core/agents/session-events.ts +18 -3
- package/src/core/agents/state/heartbeat-reader.ts +3 -0
- package/src/core/agents/state/live-coordination-view.ts +13 -6
- package/src/core/agents/state/parent-reference-contract.ts +14 -0
- package/src/core/agents/state/parent-reference.ts +179 -0
- package/src/core/agents/state/pidmap.ts +2 -2
- package/src/core/agents/state/proc-start.ts +41 -69
- package/src/core/agents/state/service-process.ts +217 -0
- package/src/core/config.ts +85 -0
- package/src/core/context/index.ts +207 -272
- package/src/core/context/observation.ts +40 -9
- package/src/core/diagnostics/path-identity.ts +52 -6
- package/src/core/events/v3/canonical.ts +46 -13
- package/src/core/events/v3/index.ts +3 -0
- package/src/core/events/v3/producers/recorder.ts +151 -13
- package/src/core/events/v3/reader.ts +55 -11
- package/src/core/events/v3/runtime-build.ts +62 -0
- package/src/core/events/v3/validate.ts +42 -1
- package/src/core/governor/index.ts +1 -2
- package/src/core/governor/service-read.ts +15 -114
- package/src/core/governor/service.ts +36 -220
- package/src/core/hooks/adapter/native-parent.ts +109 -0
- package/src/core/hooks/cli.ts +83 -4
- package/src/core/hooks/resolve/owner.ts +2 -25
- package/src/core/hooks/shell-admission.ts +634 -0
- package/src/core/hooks/shell-commit-tree.ts +102 -0
- package/src/core/inbox/contract.ts +18 -0
- package/src/core/inbox/peer-messages.ts +501 -15
- package/src/core/inbox/service.ts +108 -3
- package/src/core/inbox/targets.ts +94 -3
- package/src/core/presence/git.ts +45 -37
- package/src/core/presence/index.ts +16 -8
- package/src/core/presence/mail.ts +620 -0
- package/src/core/resources/sampler.ts +3 -2
- package/src/core/resources/service-status.ts +6 -35
- package/src/core/resources/service.ts +23 -133
- package/src/core/resources/status.ts +3 -2
- package/src/core/semantic/service.ts +8 -2
- package/src/core/servers/index.ts +3 -23
- package/src/core/storage/modes.ts +6 -0
- package/src/core/storage/segments.ts +5 -4
- package/src/core/supervisor/service.ts +33 -155
- package/src/core/supervisor/services.ts +2 -2
- package/src/core/supervisor/status.ts +10 -85
- package/src/core/workflow/engine.ts +1 -1
- package/src/core/workflow/index.ts +2 -13
- package/src/core/workflow/proof.ts +35 -83
- package/src/core/workflow/resume-lock.ts +179 -0
- package/src/core/workflow/run-state.ts +3 -207
- package/src/core/workflow/workspaces/leases.ts +1 -1
- package/src/core/workflow/workspaces/local-git.ts +120 -239
- package/src/core/workflow/workspaces/ownership.ts +3 -158
- package/src/core/workflow/workspaces/reclaim.ts +3 -9
- package/src/core/workflow/workspaces/recovery.ts +1 -1
- package/src/core/workflow/workspaces/state.ts +1 -5
- package/src/lib/admission-history.ts +267 -0
- package/src/lib/admission.ts +217 -19
- package/src/lib/browser/client.ts +147 -35
- package/src/lib/browser/content-checks.ts +14 -3
- package/src/lib/browser/critique.ts +113 -3
- package/src/lib/browser/geometry.ts +63 -14
- package/src/lib/browser/index.ts +5 -0
- package/src/lib/browser/page-review-contracts.ts +6 -1
- package/src/lib/browser/page-review-judge.ts +58 -13
- package/src/lib/browser/page-review-pack.ts +13 -2
- package/src/lib/browser/qa-run-contracts.ts +30 -4
- package/src/lib/browser/qa-run.ts +78 -17
- package/src/lib/browser/runts.ts +85 -37
- package/src/lib/browser/windows-chrome.ts +50 -0
- package/src/lib/browser/windows-login-sync.ts +275 -0
- package/src/lib/cookies/client.ts +62 -10
- package/src/lib/cookies/index.ts +3 -0
- package/src/lib/docs-metadata-sync.ts +44 -2
- package/src/lib/durable-job.ts +15 -0
- package/src/lib/http/client.ts +63 -1
- package/src/lib/instructions/templates.ts +4 -4
- package/dist/core/agents/state/process-handle.d.ts +0 -26
- package/dist/core/agents/state/process-handle.d.ts.map +0 -1
- package/dist/core/agents/state/process-handle.js +0 -121
- package/dist/core/workflow/recovery-audit.d.ts +0 -30
- package/dist/core/workflow/recovery-audit.d.ts.map +0 -1
- package/dist/core/workflow/recovery-audit.js +0 -116
- package/src/core/agents/state/process-handle.ts +0 -165
- package/src/core/workflow/recovery-audit.ts +0 -181
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type NativeParentObservation = {
|
|
2
|
+
state: "observed";
|
|
3
|
+
parent_session_id: string;
|
|
4
|
+
source_witness: string;
|
|
5
|
+
} | {
|
|
6
|
+
state: "none";
|
|
7
|
+
reason: string;
|
|
8
|
+
source_witness: string;
|
|
9
|
+
} | {
|
|
10
|
+
state: "unknown";
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
export interface NativeParentRequest {
|
|
14
|
+
adapter: string;
|
|
15
|
+
native_session_id?: string;
|
|
16
|
+
transcript_path?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface NativeParentReaderOptions {
|
|
19
|
+
discoverTranscript?: (sessionId: string, transcriptPath?: string) => string | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** Native relationship evidence only; no prompt bodies, state writes or recipient authority. */
|
|
22
|
+
export declare function readNativeParentReference(request: NativeParentRequest, options?: NativeParentReaderOptions): NativeParentObservation;
|
|
23
|
+
//# sourceMappingURL=native-parent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-parent.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/adapter/native-parent.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,uBAAuB,GAC/B;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CACzF;AAYD,gGAAgG;AAChG,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,GAAE,yBAA8B,GACtC,uBAAuB,CAuDzB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readSync } from "node:fs";
|
|
3
|
+
import { discoverCodexSessionTranscript } from "./runtime-telemetry.js";
|
|
4
|
+
const HEADER_LIMIT = 1024 * 1024;
|
|
5
|
+
const NATIVE_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
6
|
+
const ORDINARY_SOURCES = new Set(["cli", "exec", "vscode", "app-server"]);
|
|
7
|
+
function object(value) {
|
|
8
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
9
|
+
? value
|
|
10
|
+
: undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Native relationship evidence only; no prompt bodies, state writes or recipient authority. */
|
|
13
|
+
export function readNativeParentReference(request, options = {}) {
|
|
14
|
+
if (request.adapter !== "codex")
|
|
15
|
+
return unknown("native_parent_adapter_unsupported");
|
|
16
|
+
const child = request.native_session_id;
|
|
17
|
+
if (!child || !NATIVE_ID.test(child))
|
|
18
|
+
return unknown("native_child_identity_unavailable");
|
|
19
|
+
let fd;
|
|
20
|
+
try {
|
|
21
|
+
const path = (options.discoverTranscript ?? discoverCodexSessionTranscript)(child, request.transcript_path);
|
|
22
|
+
if (!path)
|
|
23
|
+
return unknown("native_parent_transcript_unavailable");
|
|
24
|
+
const entry = lstatSync(path);
|
|
25
|
+
if (!entry.isFile() || entry.isSymbolicLink())
|
|
26
|
+
return unknown("native_parent_not_regular");
|
|
27
|
+
fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
28
|
+
const before = fstatSync(fd);
|
|
29
|
+
if (!before.isFile() || before.dev !== entry.dev || before.ino !== entry.ino) {
|
|
30
|
+
return unknown("native_parent_file_changed");
|
|
31
|
+
}
|
|
32
|
+
const header = readHeader(fd);
|
|
33
|
+
if (!header)
|
|
34
|
+
return unknown("native_parent_header_incomplete");
|
|
35
|
+
// Appending later rows is normal. The same header must remain unchanged.
|
|
36
|
+
const checked = readHeader(fd);
|
|
37
|
+
const after = lstatSync(path);
|
|
38
|
+
if (!checked?.equals(header) ||
|
|
39
|
+
!after.isFile() ||
|
|
40
|
+
after.isSymbolicLink() ||
|
|
41
|
+
before.dev !== after.dev ||
|
|
42
|
+
before.ino !== after.ino) {
|
|
43
|
+
return unknown("native_parent_file_changed");
|
|
44
|
+
}
|
|
45
|
+
const row = object(JSON.parse(header.toString("utf8")));
|
|
46
|
+
const payload = object(row?.payload);
|
|
47
|
+
if (row?.type !== "session_meta" || payload?.id !== child) {
|
|
48
|
+
return unknown("native_parent_child_mismatch");
|
|
49
|
+
}
|
|
50
|
+
const source_witness = createHash("sha256").update(header).digest("hex");
|
|
51
|
+
if (typeof payload.source === "string" && ORDINARY_SOURCES.has(payload.source)) {
|
|
52
|
+
return { state: "none", reason: "native_ordinary_session", source_witness };
|
|
53
|
+
}
|
|
54
|
+
const source = object(payload.source);
|
|
55
|
+
const spawn = object(object(source?.subagent)?.thread_spawn);
|
|
56
|
+
const parent = spawn?.parent_thread_id;
|
|
57
|
+
if (typeof parent !== "string" || !NATIVE_ID.test(parent)) {
|
|
58
|
+
return unknown("native_parent_not_reported");
|
|
59
|
+
}
|
|
60
|
+
if (parent.toLowerCase() === child.toLowerCase())
|
|
61
|
+
return unknown("native_parent_self_reference");
|
|
62
|
+
return { state: "observed", parent_session_id: parent, source_witness };
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return unknown("native_parent_metadata_unreadable");
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
if (fd !== undefined)
|
|
69
|
+
closeSync(fd);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function readHeader(fd) {
|
|
73
|
+
const chunks = [];
|
|
74
|
+
let offset = 0;
|
|
75
|
+
while (offset < HEADER_LIMIT) {
|
|
76
|
+
const buffer = Buffer.alloc(Math.min(16 * 1024, HEADER_LIMIT - offset));
|
|
77
|
+
const bytes = readSync(fd, buffer, 0, buffer.length, offset);
|
|
78
|
+
if (bytes === 0)
|
|
79
|
+
return undefined;
|
|
80
|
+
const data = buffer.subarray(0, bytes);
|
|
81
|
+
const newline = data.indexOf(10);
|
|
82
|
+
if (newline >= 0)
|
|
83
|
+
return Buffer.concat([...chunks, data.subarray(0, newline)]);
|
|
84
|
+
chunks.push(data);
|
|
85
|
+
offset += bytes;
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
function unknown(reason) {
|
|
90
|
+
return { state: "unknown", reason };
|
|
91
|
+
}
|
package/dist/core/hooks/cli.js
CHANGED
|
@@ -32,12 +32,13 @@ import { readLiveCoordinationRow } from "../agents/state/live-coordination-view.
|
|
|
32
32
|
import { ensureLiveCoordinationHeartbeat } from "../agents/state/live-coordination-writer.js";
|
|
33
33
|
import { assignName, readForkParent, readForkState, recordForkDetection, resolveName, } from "../agents/state/names.js";
|
|
34
34
|
import { writePidmapRow } from "../agents/state/pidmap.js";
|
|
35
|
-
import { agentsRequireGitFinalization, coordFreshnessSeconds, hostPromptContextConfig, resolveBinName, } from "../config.js";
|
|
35
|
+
import { agentsRequireGitFinalization, coordFreshnessSeconds, hostPromptContextConfig, readAdmissionConfig, resolveBinName, } from "../config.js";
|
|
36
36
|
import { checkpointContext, completeContextRecovery, extractContextSample, markContextCompactionCompleted, prepareContextRecovery, readContextState, recordContextSample, } from "../context/index.js";
|
|
37
37
|
import { tryWriteLiveDisplayV3 } from "../events/v3/live-feed.js";
|
|
38
38
|
import { liveHookSignalDefersDrainV3, reconcileLivePendingRuntimeContextV3, recordLiveDelegatedChildSessionV3, recordLiveHookSignalV3, resolveLiveEventLedgerRouteV3, } from "../events/v3/live-routing.js";
|
|
39
39
|
import { captureSpanClockV3 } from "../events/v3/span-state.js";
|
|
40
40
|
import { ensureRelayDaemon, fetchPresence, publishPresence } from "../presence/index.js";
|
|
41
|
+
import { importMail, publishMail } from "../presence/mail.js";
|
|
41
42
|
import { closeProcessLoggers, legacyLogFields, processLogger } from "../storage/logger.js";
|
|
42
43
|
import { stableScopeId } from "../workflow/scope-id.js";
|
|
43
44
|
import { adapterBehavior } from "./adapter/behaviors/index.js";
|
|
@@ -57,6 +58,7 @@ import { resolveOwner } from "./resolve/owner.js";
|
|
|
57
58
|
import { inspectSessionNameDisplayImmediately, scanAssistantStatusBoxPresent, scanStatusBoxPresent, scanTranscriptRuntime, } from "./resolve/transcript.js";
|
|
58
59
|
import { clearHookRunMarker, writeHookRunMarker } from "./run-markers.js";
|
|
59
60
|
import { sessionNamePresence } from "./session-name-presence.js";
|
|
61
|
+
import { shellCommitTreeReason } from "./shell-commit-tree.js";
|
|
60
62
|
import { shellRmReason } from "./shell-rm.js";
|
|
61
63
|
import { shellWaiterReason } from "./shell-waiter.js";
|
|
62
64
|
let hookHealthState;
|
|
@@ -227,7 +229,18 @@ function healForkLineage(coordRoot, instanceId, payload) {
|
|
|
227
229
|
function ensureSessionDisplayName(coordRoot, instanceId, sessionId, adapter, payload) {
|
|
228
230
|
if (coordEnv("WORKFLOW_CHILD") === "1")
|
|
229
231
|
return;
|
|
230
|
-
|
|
232
|
+
// This runs on every tool call. The heartbeat cache is the surface this
|
|
233
|
+
// function stamps, so a cache that already carries a name, or marks a
|
|
234
|
+
// session that never takes one, means there is nothing to do. Only a cache
|
|
235
|
+
// that cannot answer pays for the authoritative read, which re-validates the
|
|
236
|
+
// whole active ledger and cost about half a second per call at 22 MB.
|
|
237
|
+
const cached = readHeartbeat(coordRoot, instanceId);
|
|
238
|
+
if (cached?.kind === "subagent" || cached?.kind === "transient" || cached?.workflow_run_id) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (cached?.name?.trim())
|
|
242
|
+
return;
|
|
243
|
+
const row = readLiveCoordinationRow(coordRoot, instanceId) ?? cached;
|
|
231
244
|
if (row?.kind === "subagent" || row?.kind === "transient" || row?.workflow_run_id)
|
|
232
245
|
return;
|
|
233
246
|
if (row?.name?.trim())
|
|
@@ -1009,8 +1022,23 @@ function recordContextTelemetry(run) {
|
|
|
1009
1022
|
}
|
|
1010
1023
|
}
|
|
1011
1024
|
}
|
|
1025
|
+
/** Cross-machine peer messages (ADR 0222) ride the presence fetch: import
|
|
1026
|
+
* whatever mail refs are already local. Reads local refs only, at most once
|
|
1027
|
+
* per import interval; never blocks on the network. */
|
|
1028
|
+
async function receiveRemoteMail(coordRoot) {
|
|
1029
|
+
const { peerInbox } = await import("../inbox/peer-messages.js");
|
|
1030
|
+
importMail(coordRoot, peerInbox(coordRoot), { throttle: true });
|
|
1031
|
+
}
|
|
1012
1032
|
async function handleSessionStarted(run) {
|
|
1013
1033
|
const { coordRoot, adapter, payload, owner, sessionId, data } = run;
|
|
1034
|
+
// Import mail from refs fetched earlier, so a message sent from another
|
|
1035
|
+
// machine while this task was away is in the inbox this context renders.
|
|
1036
|
+
try {
|
|
1037
|
+
await receiveRemoteMail(coordRoot);
|
|
1038
|
+
}
|
|
1039
|
+
catch (err) {
|
|
1040
|
+
logError(coordRoot, err, { phase: "session-start-mail" });
|
|
1041
|
+
}
|
|
1014
1042
|
// A configured backup runs out of process and is freshness-gated per host.
|
|
1015
1043
|
// Startup never waits for restic or a remote provider; the child owns no
|
|
1016
1044
|
// hook stdio, so the harness is not held open until it finishes. A failed
|
|
@@ -1124,6 +1152,7 @@ async function handleTurnStarted(run) {
|
|
|
1124
1152
|
// interval; the systemMessage below reads whatever is locally known).
|
|
1125
1153
|
try {
|
|
1126
1154
|
fetchPresence(coordRoot);
|
|
1155
|
+
await receiveRemoteMail(coordRoot);
|
|
1127
1156
|
}
|
|
1128
1157
|
catch (err) {
|
|
1129
1158
|
logError(coordRoot, err, { phase: "user-prompt-submit-presence" });
|
|
@@ -1187,6 +1216,7 @@ async function handleStop(run) {
|
|
|
1187
1216
|
// its daemon intentionally exits when a machine has no live sessions.
|
|
1188
1217
|
try {
|
|
1189
1218
|
publishPresence(coordRoot);
|
|
1219
|
+
publishMail(coordRoot);
|
|
1190
1220
|
ensureRelayDaemon(coordRoot);
|
|
1191
1221
|
}
|
|
1192
1222
|
catch (err) {
|
|
@@ -1310,6 +1340,12 @@ async function handleToolRequested(run) {
|
|
|
1310
1340
|
emitDeny(adapter, rmReason);
|
|
1311
1341
|
return 0;
|
|
1312
1342
|
}
|
|
1343
|
+
const commitTreeReason = shellCommitTreeReason(payload?.tool_name, payload?.tool_input, resolveBinName(coordRoot));
|
|
1344
|
+
if (commitTreeReason) {
|
|
1345
|
+
const { emitDeny } = await import("./adapter/output.js");
|
|
1346
|
+
emitDeny(adapter, commitTreeReason);
|
|
1347
|
+
return 0;
|
|
1348
|
+
}
|
|
1313
1349
|
// G-guard for ALL adapters. Claude Code previously ran this via a
|
|
1314
1350
|
// pre-tool-use bash adapter (which called `agent-coord verdict --rule=claim`);
|
|
1315
1351
|
// that adapter is now deleted, so agent-hook owns the deny for every adapter.
|
|
@@ -1327,8 +1363,38 @@ async function handleToolRequested(run) {
|
|
|
1327
1363
|
}
|
|
1328
1364
|
if (!guardAllowed)
|
|
1329
1365
|
return 0;
|
|
1366
|
+
// Heavy shell checks queue for a machine-wide admission slot when the
|
|
1367
|
+
// project configures one. Fails open: any error runs the command as written.
|
|
1368
|
+
try {
|
|
1369
|
+
if (await emitAdmissionRewrite(coordRoot, adapter, payload))
|
|
1370
|
+
return 0;
|
|
1371
|
+
}
|
|
1372
|
+
catch (err) {
|
|
1373
|
+
logError(coordRoot, err, { phase: "pre-tool-use-admission" });
|
|
1374
|
+
}
|
|
1330
1375
|
return undefined;
|
|
1331
1376
|
}
|
|
1377
|
+
async function emitAdmissionRewrite(coordRoot, adapter, payload) {
|
|
1378
|
+
const resource = readAdmissionConfig(coordRoot)?.guard?.resource;
|
|
1379
|
+
if (!resource)
|
|
1380
|
+
return false;
|
|
1381
|
+
const { admissionHookOutput } = await import("./shell-admission.js");
|
|
1382
|
+
const output = admissionHookOutput({
|
|
1383
|
+
adapter,
|
|
1384
|
+
resource,
|
|
1385
|
+
bin: resolveBinName(coordRoot),
|
|
1386
|
+
projectRoot: coordRoot,
|
|
1387
|
+
toolName: payload?.tool_name,
|
|
1388
|
+
toolInput: payload?.tool_input,
|
|
1389
|
+
cwd: payload?.cwd,
|
|
1390
|
+
skip: coordEnv("ADMISSION_SKIP") === "1" || Boolean(coordEnv("ADMISSION_HELD")),
|
|
1391
|
+
platform: process.platform,
|
|
1392
|
+
});
|
|
1393
|
+
if (!output)
|
|
1394
|
+
return false;
|
|
1395
|
+
process.stdout.write(`${JSON.stringify(output)}\n`);
|
|
1396
|
+
return true;
|
|
1397
|
+
}
|
|
1332
1398
|
async function handlePostToolUse(run) {
|
|
1333
1399
|
const { coordRoot, adapter, eventName, payload, owner } = run;
|
|
1334
1400
|
// Inject the full instruction only at the successful tool boundary that
|
|
@@ -1348,9 +1414,18 @@ async function handlePostToolUse(run) {
|
|
|
1348
1414
|
// retry response already carries the full instruction and an end-turn
|
|
1349
1415
|
// status is the wrong place to ask.
|
|
1350
1416
|
try {
|
|
1351
|
-
const row = readLiveCoordinationRow(coordRoot, owner.instance_id);
|
|
1352
1417
|
// A workflow child has no user-visible title to set.
|
|
1353
|
-
|
|
1418
|
+
if (coordEnv("WORKFLOW_CHILD") === "1")
|
|
1419
|
+
return;
|
|
1420
|
+
// The live row copies every name-display field from a current heartbeat
|
|
1421
|
+
// cache and leaves them unset otherwise, so a raw cache with nothing
|
|
1422
|
+
// pending proves the row has nothing pending either. That skips a full
|
|
1423
|
+
// ledger read on almost every tool call; only a pending title pays for
|
|
1424
|
+
// the authoritative check below.
|
|
1425
|
+
if (!sessionNameDisplayPending(readHeartbeat(coordRoot, owner.instance_id)))
|
|
1426
|
+
return;
|
|
1427
|
+
const row = readLiveCoordinationRow(coordRoot, owner.instance_id);
|
|
1428
|
+
const name = sessionNameDisplayPending(row);
|
|
1354
1429
|
if (name && toolResponseMintedSessionName(payload?.tool_response, name)) {
|
|
1355
1430
|
// Record the title before asking for it. The suggestion can still
|
|
1356
1431
|
// change afterwards (an assigned-name rewrite, a lifecycle re-mint, a
|
|
@@ -30,17 +30,6 @@ export declare function resolveOwner(opts: {
|
|
|
30
30
|
instance_id: string;
|
|
31
31
|
source: "env" | "payload" | "session_env" | "pidmap-self" | "pidmap-ancestor";
|
|
32
32
|
} | null;
|
|
33
|
-
/**
|
|
34
|
-
* Find the parent owner for a subagent invocation. The per-shell marker at
|
|
35
|
-
* `.harnery/shells/<pid>` is set by `sub-agent-start` and removed by
|
|
36
|
-
* `sub-agent-stop`.
|
|
37
|
-
*
|
|
38
|
-
* Phase 2 stub: the marker file isn't written yet, so we return null in most
|
|
39
|
-
* cases. Phase 2 callers can pass through.
|
|
40
|
-
*/
|
|
41
|
-
export declare function readShellMarker(coordRoot: string, pid: number): string | null;
|
|
42
|
-
/** Read the V3-projected `agent_id` for an owner if it exists. */
|
|
43
|
-
export declare function readAgentIdForOwner(coordRoot: string, instanceId: string): string | null;
|
|
44
33
|
/** Diagnostic: list of pid-map entries (for debugging). */
|
|
45
34
|
export declare function listPidmap(coordRoot: string): Array<{
|
|
46
35
|
pid: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/owner.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,KAAK,GAAG,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,CAAC;CAC/E,GAAG,IAAI,CAgFP;AA2BD
|
|
1
|
+
{"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/owner.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,KAAK,GAAG,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,CAAC;CAC/E,GAAG,IAAI,CAgFP;AA2BD,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBnF"}
|
|
@@ -4,7 +4,7 @@ import { join } from "node:path";
|
|
|
4
4
|
import { coordEnv } from "../../../lib/env.js";
|
|
5
5
|
import { resolveOwnerBySessionEnv } from "../../agents/coord-client.js";
|
|
6
6
|
import { readLiveCoordinationRow } from "../../agents/state/live-coordination-view.js";
|
|
7
|
-
import {
|
|
7
|
+
import { verifyProcessGeneration } from "../../agents/state/proc-start.js";
|
|
8
8
|
/**
|
|
9
9
|
* Resolve the canonical `instance_id` for the current hook invocation.
|
|
10
10
|
*
|
|
@@ -91,7 +91,7 @@ export function resolveOwner(opts) {
|
|
|
91
91
|
// A row whose start token disagrees with the process now holding this
|
|
92
92
|
// pid is about a different, earlier process. Believing it hands this
|
|
93
93
|
// session another agent's identity, so walk past it.
|
|
94
|
-
const recycled =
|
|
94
|
+
const recycled = verifyProcessGeneration(pid, startToken) === "different";
|
|
95
95
|
if (owner && owner.length > 0 && !recycled) {
|
|
96
96
|
return {
|
|
97
97
|
instance_id: owner,
|
|
@@ -140,29 +140,6 @@ function readPpid(pid) {
|
|
|
140
140
|
}
|
|
141
141
|
return null;
|
|
142
142
|
}
|
|
143
|
-
/**
|
|
144
|
-
* Find the parent owner for a subagent invocation. The per-shell marker at
|
|
145
|
-
* `.harnery/shells/<pid>` is set by `sub-agent-start` and removed by
|
|
146
|
-
* `sub-agent-stop`.
|
|
147
|
-
*
|
|
148
|
-
* Phase 2 stub: the marker file isn't written yet, so we return null in most
|
|
149
|
-
* cases. Phase 2 callers can pass through.
|
|
150
|
-
*/
|
|
151
|
-
export function readShellMarker(coordRoot, pid) {
|
|
152
|
-
const path = join(coordRoot, ".harnery", "shells", String(pid));
|
|
153
|
-
if (!existsSync(path))
|
|
154
|
-
return null;
|
|
155
|
-
try {
|
|
156
|
-
return readFileSync(path, "utf8").trim() || null;
|
|
157
|
-
}
|
|
158
|
-
catch {
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/** Read the V3-projected `agent_id` for an owner if it exists. */
|
|
163
|
-
export function readAgentIdForOwner(coordRoot, instanceId) {
|
|
164
|
-
return readLiveCoordinationRow(coordRoot, instanceId)?.agent_id ?? null;
|
|
165
|
-
}
|
|
166
143
|
/** Diagnostic: list of pid-map entries (for debugging). */
|
|
167
144
|
export function listPidmap(coordRoot) {
|
|
168
145
|
const dir = join(coordRoot, ".harnery", "pid-map");
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admission guard for heavy shell checks. A whole-project typecheck, a full
|
|
3
|
+
* test suite, or a production build can each take gigabytes of memory, and
|
|
4
|
+
* several agents starting them at once on one machine can exhaust it. Asking
|
|
5
|
+
* agents in prose to wrap those commands in `admission run` does not work: the
|
|
6
|
+
* rule has to be read and remembered on every call. This guard rewrites the
|
|
7
|
+
* agent's shell command at PreToolUse instead, so each heavy check waits for a
|
|
8
|
+
* slot on a machine-wide admission resource.
|
|
9
|
+
*
|
|
10
|
+
* Enabled only when the project config names a resource
|
|
11
|
+
* (`admission.guard.resource`). It finds each simple command that is a heavy
|
|
12
|
+
* check and inserts `<bin> admission run --resource <name> --label 'agent:
|
|
13
|
+
* ...' --` in front of it, after any leading VAR=value assignments. The rest
|
|
14
|
+
* of the command (cd, pipes, redirects, && chains) is left byte for byte.
|
|
15
|
+
* Heavy means:
|
|
16
|
+
* - tsc, however launched (tsc, npx/bunx/bun x/pnpm exec/yarn tsc,
|
|
17
|
+
* node_modules/.bin/tsc, node .../typescript/bin/tsc)
|
|
18
|
+
* - next build
|
|
19
|
+
* - bun test with no file or directory named (a full suite)
|
|
20
|
+
* - the package scripts test / test:* (with no further positional
|
|
21
|
+
* argument), build, typecheck, type-check, typecheck:*, check-types, tsc,
|
|
22
|
+
* run through bun run, npm, pnpm, or yarn
|
|
23
|
+
* - bash/sh -c '<script>' whose script contains one of the above
|
|
24
|
+
* Watch modes, --help/--version, and named-file test runs are left alone.
|
|
25
|
+
*
|
|
26
|
+
* Passes through untouched: non-shell tools; a command that already runs
|
|
27
|
+
* `admission run` or `heavy-slot`; HARNERY_ADMISSION_SKIP=1 in the command or
|
|
28
|
+
* the hook's environment; HARNERY_ADMISSION_HELD in the hook's environment
|
|
29
|
+
* (the session already holds a slot); text inside quotes, heredocs, and
|
|
30
|
+
* comments. Any parse failure means no rewrite.
|
|
31
|
+
*/
|
|
32
|
+
export declare const ADMISSION_SKIP_PREFIX = "HARNERY_ADMISSION_SKIP=1";
|
|
33
|
+
/** Claude Code's maximum Bash timeout; a queued wait counts against it. */
|
|
34
|
+
export declare const BASH_TIMEOUT_MAX_MS = 600000;
|
|
35
|
+
/** POSIX single-quote a word when it needs quoting (shlex.quote semantics). */
|
|
36
|
+
export declare function shellQuote(value: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Return the command with each heavy simple command wrapped in `wrapper`
|
|
39
|
+
* (a shell-ready prefix such as `harn admission run --resource build`), or
|
|
40
|
+
* null when nothing changes.
|
|
41
|
+
*/
|
|
42
|
+
export declare function rewriteHeavyCommand(command: string, wrapper: string): string | null;
|
|
43
|
+
/** Normalized shell-tool name, or null for any other tool. */
|
|
44
|
+
export declare function shellToolName(toolName: unknown): string | null;
|
|
45
|
+
export interface AdmissionRewrite {
|
|
46
|
+
updatedInput: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Rewrite a shell tool's input so its heavy checks queue for admission.
|
|
50
|
+
* Handles `command` or `cmd` as a string, or as an argv such as
|
|
51
|
+
* ["bash", "-lc", "<script>"]. Returns null when nothing changes.
|
|
52
|
+
*/
|
|
53
|
+
export declare function admissionRewriteForTool(toolName: unknown, toolInput: unknown, wrapper: string): AdmissionRewrite | null;
|
|
54
|
+
export interface AdmissionHookInput {
|
|
55
|
+
adapter: string;
|
|
56
|
+
/** Admission resource the project's guard queues on. */
|
|
57
|
+
resource: string;
|
|
58
|
+
/** Host bin name used in the wrapper and the agent-facing note. */
|
|
59
|
+
bin: string;
|
|
60
|
+
/**
|
|
61
|
+
* Project whose admission config `admission run` should read. A nested
|
|
62
|
+
* checkout with its own `.harnery/` would otherwise shadow the host's
|
|
63
|
+
* resource settings for a shell started inside it.
|
|
64
|
+
*/
|
|
65
|
+
projectRoot?: string;
|
|
66
|
+
toolName: unknown;
|
|
67
|
+
toolInput: unknown;
|
|
68
|
+
cwd?: unknown;
|
|
69
|
+
/** True when HARNERY_ADMISSION_SKIP=1 or HARNERY_ADMISSION_HELD is set for the hook. */
|
|
70
|
+
skip?: boolean;
|
|
71
|
+
platform?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The PreToolUse output that queues a shell command's heavy checks, or null
|
|
75
|
+
* to let the command run as written. Claude Code applies `updatedInput`
|
|
76
|
+
* under the session's own permission rules, so no decision is sent, and its
|
|
77
|
+
* Bash timeout is raised to the maximum because a queued wait counts against
|
|
78
|
+
* it. Codex applies a rewrite only beside `permissionDecision: "allow"`.
|
|
79
|
+
* Cursor and OpenCode have no rewrite channel. Windows-native shells (a
|
|
80
|
+
* drive-letter or UNC workspace) are outside the machine whose queue this
|
|
81
|
+
* guards.
|
|
82
|
+
*/
|
|
83
|
+
export declare function admissionHookOutput(input: AdmissionHookInput): Record<string, unknown> | null;
|
|
84
|
+
//# sourceMappingURL=shell-admission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-admission.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/shell-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAuGH,eAAO,MAAM,qBAAqB,6BAA6B,CAAC;AAChE,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAgV3C,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhD;AAWD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsBnF;AAID,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAI9D;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,GACd,gBAAgB,GAAG,IAAI,CAmCzB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,wFAAwF;IACxF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA4B7F"}
|