harnery 0.31.6 → 0.33.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 +2 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +5 -1
- package/dist/commands/agents.d.ts +0 -9
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +280 -94
- package/dist/commands/browse-session.d.ts +21 -0
- package/dist/commands/browse-session.d.ts.map +1 -0
- package/dist/commands/browse-session.js +157 -0
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +205 -37
- package/dist/commands/checkpoint.js +1 -1
- package/dist/commands/claude-desktop.d.ts +2 -2
- package/dist/commands/claude-desktop.d.ts.map +1 -1
- package/dist/commands/claude-desktop.js +74 -3
- package/dist/commands/deinit.d.ts.map +1 -1
- package/dist/commands/deinit.js +4 -0
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +40 -0
- package/dist/commands/doctor.d.ts +4 -2
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +141 -19
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +26 -5
- package/dist/commands/instructions.d.ts +4 -0
- package/dist/commands/instructions.d.ts.map +1 -0
- package/dist/commands/instructions.js +100 -0
- package/dist/commands/presence.d.ts.map +1 -1
- package/dist/commands/presence.js +4 -1
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +2 -3
- package/dist/core/agents/canonical-emit.d.ts +2 -3
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +6 -5
- package/dist/core/agents/cli.js +128 -89
- package/dist/core/agents/coord-client.d.ts +18 -3
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +5 -4
- package/dist/core/agents/finalization.d.ts +68 -0
- package/dist/core/agents/finalization.d.ts.map +1 -0
- package/dist/core/agents/finalization.js +443 -0
- package/dist/core/agents/git-hook.d.ts +51 -0
- package/dist/core/agents/git-hook.d.ts.map +1 -0
- package/dist/core/agents/git-hook.js +118 -0
- 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/render/prompt-context.d.ts +12 -5
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +70 -16
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +23 -4
- package/dist/core/agents/rules/claim-conflict.js +3 -3
- package/dist/core/agents/rules/commit-conflict.d.ts +15 -6
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +21 -5
- package/dist/core/agents/rules/stop-hook.d.ts +3 -0
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +59 -23
- package/dist/core/agents/session-events.d.ts +8 -16
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +12 -26
- package/dist/core/agents/state/heartbeat-projector.d.ts +14 -0
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-projector.js +98 -1
- package/dist/core/agents/state/heartbeat-writer.d.ts +47 -5
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +86 -17
- package/dist/core/agents/state/names.d.ts +22 -1
- package/dist/core/agents/state/names.d.ts.map +1 -1
- package/dist/core/agents/state/names.js +40 -2
- package/dist/core/agents/state/session-state.d.ts +44 -0
- package/dist/core/agents/state/session-state.d.ts.map +1 -0
- package/dist/core/agents/state/session-state.js +81 -0
- package/dist/core/config.d.ts +30 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +74 -11
- package/dist/core/governor/planning.d.ts.map +1 -1
- package/dist/core/governor/planning.js +12 -13
- package/dist/core/hooks/adapter/detect.d.ts +2 -4
- package/dist/core/hooks/adapter/detect.d.ts.map +1 -1
- package/dist/core/hooks/adapter/detect.js +4 -14
- package/dist/core/hooks/adapter/events.d.ts.map +1 -1
- package/dist/core/hooks/adapter/events.js +1 -0
- package/dist/core/hooks/adapter/output.d.ts +1 -1
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +5 -4
- package/dist/core/hooks/adapter/parse.d.ts +1 -1
- package/dist/core/hooks/adapter/parse.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.js +2 -0
- package/dist/core/hooks/adapter/wiring.d.ts +23 -0
- package/dist/core/hooks/adapter/wiring.d.ts.map +1 -1
- package/dist/core/hooks/adapter/wiring.js +32 -0
- package/dist/core/hooks/cli.d.ts +1 -2
- package/dist/core/hooks/cli.d.ts.map +1 -1
- package/dist/core/hooks/cli.js +258 -32
- package/dist/core/hooks/codex-authorization.d.ts +30 -0
- package/dist/core/hooks/codex-authorization.d.ts.map +1 -0
- package/dist/core/hooks/codex-authorization.js +199 -0
- package/dist/core/hooks/codex-wsl-bridge.d.ts +46 -0
- package/dist/core/hooks/codex-wsl-bridge.d.ts.map +1 -0
- package/dist/core/hooks/codex-wsl-bridge.js +137 -0
- package/dist/core/hooks/effects/index.d.ts +1 -1
- package/dist/core/hooks/effects/index.js +3 -3
- package/dist/core/hooks/events/schema.d.ts +57 -1
- package/dist/core/hooks/events/schema.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.d.ts +7 -1
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +15 -0
- package/dist/core/hooks/resolve/transcript.d.ts +44 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +176 -1
- package/dist/core/hooks/session-name-presence.d.ts +30 -0
- package/dist/core/hooks/session-name-presence.d.ts.map +1 -0
- package/dist/core/hooks/session-name-presence.js +43 -0
- package/dist/core/hooks/unsafe-cross-shell.d.ts +13 -0
- package/dist/core/hooks/unsafe-cross-shell.d.ts.map +1 -0
- package/dist/core/hooks/unsafe-cross-shell.js +151 -0
- package/dist/core/presence/blob.d.ts +4 -0
- package/dist/core/presence/blob.d.ts.map +1 -1
- package/dist/core/presence/blob.js +12 -0
- package/dist/core/presence/index.js +15 -1
- package/dist/core/work/state.d.ts +4 -5
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +5 -8
- 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 +2 -2
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +2 -2
- package/dist/core/workflow/run-state.d.ts +2 -2
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +2 -2
- package/dist/core/workflow/types.d.ts +3 -3
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/execution.d.ts +2 -2
- package/dist/core/workflow/workspaces/execution.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/execution.js +5 -0
- package/dist/core/workflow/workspaces/index.d.ts +1 -1
- package/dist/core/workflow/workspaces/index.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.js +1 -2
- package/dist/core/workflow/workspaces/paths.d.ts +2 -2
- package/dist/core/workflow/workspaces/types.d.ts +0 -6
- package/dist/core/workflow/workspaces/types.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/validate.d.ts +0 -2
- package/dist/core/workflow/workspaces/validate.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/validate.js +0 -2
- package/dist/lib/browser/client.d.ts +118 -1
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +435 -6
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +180 -37
- package/dist/lib/browser/index.d.ts +5 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +5 -1
- package/dist/lib/browser/netscape-cookies.d.ts +6 -0
- package/dist/lib/browser/netscape-cookies.d.ts.map +1 -0
- package/dist/lib/browser/netscape-cookies.js +31 -0
- package/dist/lib/browser/proxy.d.ts +24 -0
- package/dist/lib/browser/proxy.d.ts.map +1 -0
- package/dist/lib/browser/proxy.js +84 -0
- package/dist/lib/browser/runts.d.ts +6 -0
- package/dist/lib/browser/runts.d.ts.map +1 -1
- package/dist/lib/browser/runts.js +21 -4
- package/dist/lib/browser/session-control.d.ts +112 -0
- package/dist/lib/browser/session-control.d.ts.map +1 -0
- package/dist/lib/browser/session-control.js +670 -0
- package/dist/lib/claude-desktop.d.ts +47 -0
- package/dist/lib/claude-desktop.d.ts.map +1 -1
- package/dist/lib/claude-desktop.js +169 -1
- package/dist/lib/docs-links.d.ts +108 -0
- package/dist/lib/docs-links.d.ts.map +1 -0
- package/dist/lib/docs-links.js +555 -0
- package/dist/lib/exec.d.ts +1 -1
- package/dist/lib/exec.js +1 -1
- package/dist/lib/identities/assume.d.ts +4 -2
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +15 -2
- package/dist/lib/instructions/bundle.d.ts +33 -0
- package/dist/lib/instructions/bundle.d.ts.map +1 -0
- package/dist/lib/instructions/bundle.js +149 -0
- package/dist/lib/instructions/git-hooks.d.ts +75 -0
- package/dist/lib/instructions/git-hooks.d.ts.map +1 -0
- package/dist/lib/instructions/git-hooks.js +238 -0
- package/dist/lib/instructions/splice.d.ts +10 -4
- package/dist/lib/instructions/splice.d.ts.map +1 -1
- package/dist/lib/instructions/splice.js +19 -11
- package/package.json +2 -2
- package/schemas/config.schema.json +32 -0
- package/src/commander.ts +5 -1
- package/src/commands/agents.ts +341 -113
- package/src/commands/browse-session.ts +245 -0
- package/src/commands/browse.ts +287 -44
- package/src/commands/checkpoint.ts +1 -1
- package/src/commands/claude-desktop.ts +106 -5
- package/src/commands/deinit.ts +7 -1
- package/src/commands/docs.ts +56 -0
- package/src/commands/doctor.ts +155 -21
- package/src/commands/init.ts +28 -9
- package/src/commands/instructions.ts +129 -0
- package/src/commands/presence.ts +7 -1
- package/src/commands/tunnel.ts +2 -5
- package/src/core/agents/canonical-emit.ts +7 -6
- package/src/core/agents/cli.ts +143 -89
- package/src/core/agents/coord-client.ts +21 -5
- package/src/core/agents/finalization.ts +595 -0
- package/src/core/agents/git-hook.ts +126 -0
- package/src/core/agents/index.ts +1 -0
- package/src/core/agents/render/prompt-context.ts +96 -16
- package/src/core/agents/render/session-context.ts +29 -4
- package/src/core/agents/rules/claim-conflict.ts +3 -3
- package/src/core/agents/rules/commit-conflict.ts +35 -8
- package/src/core/agents/rules/stop-hook.ts +71 -23
- package/src/core/agents/session-events.ts +14 -41
- package/src/core/agents/state/heartbeat-projector.ts +108 -1
- package/src/core/agents/state/heartbeat-writer.ts +129 -16
- package/src/core/agents/state/names.ts +54 -2
- package/src/core/agents/state/session-state.ts +131 -0
- package/src/core/config.ts +92 -12
- package/src/core/governor/planning.ts +17 -12
- package/src/core/hooks/adapter/detect.ts +4 -13
- package/src/core/hooks/adapter/events.ts +1 -0
- package/src/core/hooks/adapter/output.ts +9 -4
- package/src/core/hooks/adapter/parse.ts +3 -0
- package/src/core/hooks/adapter/wiring.ts +43 -0
- package/src/core/hooks/cli.ts +296 -27
- package/src/core/hooks/codex-authorization.ts +253 -0
- package/src/core/hooks/codex-wsl-bridge.ts +188 -0
- package/src/core/hooks/effects/index.ts +5 -5
- package/src/core/hooks/events/schema.ts +71 -0
- package/src/core/hooks/resolve/owner.ts +22 -1
- package/src/core/hooks/resolve/transcript.ts +164 -1
- package/src/core/hooks/session-name-presence.ts +52 -0
- package/src/core/hooks/unsafe-cross-shell.ts +160 -0
- package/src/core/presence/blob.ts +18 -0
- package/src/core/presence/index.ts +18 -1
- package/src/core/work/state.ts +8 -12
- package/src/core/workflow/engine.ts +2 -2
- package/src/core/workflow/index.ts +0 -1
- package/src/core/workflow/proof.ts +4 -4
- package/src/core/workflow/run-state.ts +5 -5
- package/src/core/workflow/types.ts +3 -3
- package/src/core/workflow/workspaces/execution.ts +11 -4
- package/src/core/workflow/workspaces/index.ts +0 -3
- package/src/core/workflow/workspaces/local-git.ts +1 -2
- package/src/core/workflow/workspaces/paths.ts +2 -2
- package/src/core/workflow/workspaces/types.ts +0 -9
- package/src/core/workflow/workspaces/validate.ts +1 -5
- package/src/lib/browser/client.ts +528 -6
- package/src/lib/browser/geometry.ts +197 -37
- package/src/lib/browser/index.ts +39 -0
- package/src/lib/browser/netscape-cookies.ts +39 -0
- package/src/lib/browser/proxy.ts +105 -0
- package/src/lib/browser/runts.ts +27 -3
- package/src/lib/browser/session-control.ts +892 -0
- package/src/lib/claude-desktop.ts +232 -1
- package/src/lib/docs-links.ts +674 -0
- package/src/lib/exec.ts +1 -1
- package/src/lib/identities/assume.ts +22 -1
- package/src/lib/instructions/bundle.ts +199 -0
- package/src/lib/instructions/git-hooks.ts +259 -0
- package/src/lib/instructions/splice.ts +41 -11
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createInterface } from "node:readline";
|
|
3
|
+
function isObject(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
function stringArray(value) {
|
|
7
|
+
return Array.isArray(value)
|
|
8
|
+
? value.filter((item) => typeof item === "string")
|
|
9
|
+
: [];
|
|
10
|
+
}
|
|
11
|
+
function trustStatus(value) {
|
|
12
|
+
return value === "managed" || value === "trusted" || value === "untrusted" || value === "modified"
|
|
13
|
+
? value
|
|
14
|
+
: null;
|
|
15
|
+
}
|
|
16
|
+
function normalizedPath(value) {
|
|
17
|
+
return value.replaceAll("\\", "/").replace(/\/$/, "").toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Convert Codex app-server's `hooks/list` response into the one authorization
|
|
21
|
+
* state doctor needs. This is intentionally read-only: hashes are observed but
|
|
22
|
+
* never persisted, and only commands containing Harnery's `agent-hook` binary
|
|
23
|
+
* are included in the result.
|
|
24
|
+
*/
|
|
25
|
+
export function assessCodexHookList(response, cwd) {
|
|
26
|
+
if (!isObject(response) || !isObject(response.result) || !Array.isArray(response.result.data)) {
|
|
27
|
+
return {
|
|
28
|
+
status: "error",
|
|
29
|
+
detail: "Codex hooks/list returned an invalid response",
|
|
30
|
+
hookCount: 0,
|
|
31
|
+
disabledCount: 0,
|
|
32
|
+
trustCounts: {},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const entries = response.result.data.filter(isObject);
|
|
36
|
+
const expected = normalizedPath(cwd);
|
|
37
|
+
const entry = entries.find((candidate) => {
|
|
38
|
+
const candidateCwd = candidate.cwd;
|
|
39
|
+
return typeof candidateCwd === "string" && normalizedPath(candidateCwd) === expected;
|
|
40
|
+
}) ?? (entries.length === 1 ? entries[0] : undefined);
|
|
41
|
+
if (!entry) {
|
|
42
|
+
return {
|
|
43
|
+
status: "error",
|
|
44
|
+
detail: "Codex hooks/list omitted the requested workspace",
|
|
45
|
+
hookCount: 0,
|
|
46
|
+
disabledCount: 0,
|
|
47
|
+
trustCounts: {},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const errors = stringArray(entry.errors);
|
|
51
|
+
if (errors.length > 0) {
|
|
52
|
+
return {
|
|
53
|
+
status: "error",
|
|
54
|
+
detail: `Codex could not load hooks: ${errors.join("; ")}`,
|
|
55
|
+
hookCount: 0,
|
|
56
|
+
disabledCount: 0,
|
|
57
|
+
trustCounts: {},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const hooks = Array.isArray(entry.hooks) ? entry.hooks.filter(isObject) : [];
|
|
61
|
+
const harneryHooks = hooks.filter((hook) => typeof hook.command === "string" && /(?:^|[\\/\s])agent-hook(?:\s|$)/.test(hook.command));
|
|
62
|
+
if (harneryHooks.length === 0) {
|
|
63
|
+
return {
|
|
64
|
+
status: "not_wired",
|
|
65
|
+
detail: "Codex discovered no Harnery hooks",
|
|
66
|
+
hookCount: 0,
|
|
67
|
+
disabledCount: 0,
|
|
68
|
+
trustCounts: {},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const counts = {};
|
|
72
|
+
let disabledCount = 0;
|
|
73
|
+
for (const hook of harneryHooks) {
|
|
74
|
+
const status = trustStatus(hook.trustStatus);
|
|
75
|
+
if (!status) {
|
|
76
|
+
return {
|
|
77
|
+
status: "error",
|
|
78
|
+
detail: "Codex returned an unknown hook trust state",
|
|
79
|
+
hookCount: harneryHooks.length,
|
|
80
|
+
disabledCount,
|
|
81
|
+
trustCounts: counts,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
counts[status] = (counts[status] ?? 0) + 1;
|
|
85
|
+
if (hook.enabled !== true)
|
|
86
|
+
disabledCount += 1;
|
|
87
|
+
}
|
|
88
|
+
const reviewCount = (counts.untrusted ?? 0) + (counts.modified ?? 0);
|
|
89
|
+
const warnings = stringArray(entry.warnings);
|
|
90
|
+
const warningSuffix = warnings.length > 0 ? `; ${warnings.length} Codex warning(s)` : "";
|
|
91
|
+
if (reviewCount > 0) {
|
|
92
|
+
return {
|
|
93
|
+
status: "review_required",
|
|
94
|
+
detail: `${reviewCount} of ${harneryHooks.length} Harnery hooks require review` +
|
|
95
|
+
` (${counts.untrusted ?? 0} new, ${counts.modified ?? 0} modified)${warningSuffix}`,
|
|
96
|
+
hookCount: harneryHooks.length,
|
|
97
|
+
disabledCount,
|
|
98
|
+
trustCounts: counts,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (disabledCount > 0) {
|
|
102
|
+
return {
|
|
103
|
+
status: "disabled",
|
|
104
|
+
detail: `${disabledCount} of ${harneryHooks.length} trusted Harnery hooks are disabled${warningSuffix}`,
|
|
105
|
+
hookCount: harneryHooks.length,
|
|
106
|
+
disabledCount,
|
|
107
|
+
trustCounts: counts,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
status: "runnable",
|
|
112
|
+
detail: `${harneryHooks.length} Harnery hooks trusted and enabled${warningSuffix}`,
|
|
113
|
+
hookCount: harneryHooks.length,
|
|
114
|
+
disabledCount: 0,
|
|
115
|
+
trustCounts: counts,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Ask the active Codex CLI for hook authorization through its app-server
|
|
120
|
+
* protocol. The child is closed as soon as `hooks/list` responds. Harnery never
|
|
121
|
+
* calls the trust-write method and never reads Codex's private config format.
|
|
122
|
+
*/
|
|
123
|
+
export function probeCodexHookAuthorization(options) {
|
|
124
|
+
const codexBin = options.codexBin ?? "codex";
|
|
125
|
+
const args = options.appServerArgs ?? ["app-server"];
|
|
126
|
+
const timeoutMs = options.timeoutMs ?? 5_000;
|
|
127
|
+
return new Promise((resolve) => {
|
|
128
|
+
const child = spawn(codexBin, args, {
|
|
129
|
+
cwd: options.cwd,
|
|
130
|
+
env: options.env ?? process.env,
|
|
131
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
132
|
+
windowsHide: true,
|
|
133
|
+
});
|
|
134
|
+
const lines = createInterface({ input: child.stdout });
|
|
135
|
+
let settled = false;
|
|
136
|
+
let stderr = "";
|
|
137
|
+
const finish = (result) => {
|
|
138
|
+
if (settled)
|
|
139
|
+
return;
|
|
140
|
+
settled = true;
|
|
141
|
+
clearTimeout(timer);
|
|
142
|
+
lines.close();
|
|
143
|
+
child.stdin.end();
|
|
144
|
+
child.kill();
|
|
145
|
+
resolve(result);
|
|
146
|
+
};
|
|
147
|
+
const fail = (detail) => finish({ status: "error", detail, hookCount: 0, disabledCount: 0, trustCounts: {} });
|
|
148
|
+
const timer = setTimeout(() => {
|
|
149
|
+
fail(`Codex hooks/list timed out after ${timeoutMs}ms`);
|
|
150
|
+
}, timeoutMs);
|
|
151
|
+
child.stderr.on("data", (chunk) => {
|
|
152
|
+
if (stderr.length < 4_096)
|
|
153
|
+
stderr += chunk.toString();
|
|
154
|
+
});
|
|
155
|
+
child.stdin.on("error", (error) => fail(`Codex app-server input failed: ${error.message}`));
|
|
156
|
+
child.on("error", (error) => fail(`could not start Codex app-server: ${error.message}`));
|
|
157
|
+
child.on("close", (code) => {
|
|
158
|
+
if (!settled) {
|
|
159
|
+
const suffix = stderr.trim() ? `: ${stderr.trim().slice(0, 500)}` : "";
|
|
160
|
+
fail(`Codex app-server exited before hooks/list completed (exit ${code ?? "unknown"})${suffix}`);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
lines.on("line", (line) => {
|
|
164
|
+
let message;
|
|
165
|
+
try {
|
|
166
|
+
const parsed = JSON.parse(line);
|
|
167
|
+
if (!isObject(parsed))
|
|
168
|
+
return;
|
|
169
|
+
message = parsed;
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (message.id === 0) {
|
|
175
|
+
if (message.error) {
|
|
176
|
+
fail("Codex app-server rejected initialization");
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
child.stdin.write(`${JSON.stringify({ method: "initialized" })}\n`);
|
|
180
|
+
child.stdin.write(`${JSON.stringify({ method: "hooks/list", id: 1, params: { cwds: [options.cwd] } })}\n`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (message.id === 1) {
|
|
184
|
+
if (message.error) {
|
|
185
|
+
fail("Codex app-server rejected hooks/list");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
finish(assessCodexHookList(message, options.cwd));
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
child.stdin.write(`${JSON.stringify({
|
|
192
|
+
method: "initialize",
|
|
193
|
+
id: 0,
|
|
194
|
+
params: {
|
|
195
|
+
clientInfo: { name: "harnery_doctor", title: "Harnery Doctor", version: "0.0.0" },
|
|
196
|
+
},
|
|
197
|
+
})}\n`);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface CodexWslBridgeStatus {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
detail: string;
|
|
4
|
+
threadIdPresent: boolean;
|
|
5
|
+
wslenvForwardsThreadId: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface CodexWslBridgeOptions {
|
|
8
|
+
/** The caller already knows this is a Codex adapter process. */
|
|
9
|
+
expected?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface CodexWslWorkspaceLinkMapping {
|
|
12
|
+
/** Absolute path seen by Linux-side tools. */
|
|
13
|
+
linuxRoot: string;
|
|
14
|
+
/** Forward-slash UNC path that Codex Desktop can use as a Markdown destination. */
|
|
15
|
+
hostRoot: string;
|
|
16
|
+
distro: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CodexWslFileLinkTelemetry {
|
|
19
|
+
/** Markdown destinations that still use the Linux root in a Windows-hosted WSL task. */
|
|
20
|
+
wsl_linux_file_link_count: number;
|
|
21
|
+
/** Bounded examples for local diagnosis; omitted when the count is zero. */
|
|
22
|
+
wsl_linux_file_link_examples?: string[];
|
|
23
|
+
}
|
|
24
|
+
/** Whether an adapter-reported workspace is a Linux path exposed through WSL UNC. */
|
|
25
|
+
export declare function isWslUncPath(value: unknown): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Derive the Linux-to-host path pair from the actual adapter workspace. The
|
|
28
|
+
* roots must overlap so an unrelated WSL UNC path cannot authorize a mapping
|
|
29
|
+
* for some other checkout.
|
|
30
|
+
*/
|
|
31
|
+
export declare function codexWslWorkspaceLinkMapping(coordRootRaw: string, workspaceCwd: unknown): CodexWslWorkspaceLinkMapping | null;
|
|
32
|
+
/** Fresh adapter context for the model. Shell paths stay Linux-native; only
|
|
33
|
+
* Markdown destinations use the host-visible root. */
|
|
34
|
+
export declare function renderCodexWslFileLinkContext(coordRoot: string, workspaceCwd: unknown): string;
|
|
35
|
+
/**
|
|
36
|
+
* Count Markdown links that point at the Linux workspace root even though the
|
|
37
|
+
* adapter workspace is Windows-visible UNC. This is telemetry only: the Stop
|
|
38
|
+
* hook must not replace or retry an otherwise complete Codex reply.
|
|
39
|
+
*/
|
|
40
|
+
export declare function codexWslFileLinkTelemetry(coordRoot: string, workspaceCwd: unknown, assistantMessage: string): CodexWslFileLinkTelemetry | null;
|
|
41
|
+
/**
|
|
42
|
+
* Inspect the environment contract used when Windows-native Codex launches a
|
|
43
|
+
* Harnery hook or shell inside WSL. Returns null outside that hybrid mode.
|
|
44
|
+
*/
|
|
45
|
+
export declare function inspectCodexWslBridge(env?: NodeJS.ProcessEnv, options?: CodexWslBridgeOptions): CodexWslBridgeStatus | null;
|
|
46
|
+
//# sourceMappingURL=codex-wsl-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-wsl-bridge.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/codex-wsl-bridge.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,OAAO,CAAC;IACzB,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,yBAAyB;IACxC,wFAAwF;IACxF,yBAAyB,EAAE,MAAM,CAAC;IAClC,4EAA4E;IAC5E,4BAA4B,CAAC,EAAE,MAAM,EAAE,CAAC;CACzC;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMpD;AA2BD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,OAAO,GACpB,4BAA4B,GAAG,IAAI,CAarC;AAED;sDACsD;AACtD,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,CAS9F;AAmCD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,OAAO,EACrB,gBAAgB,EAAE,MAAM,GACvB,yBAAyB,GAAG,IAAI,CAYlC;AAOD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,GAAG,IAAI,CAsB7B"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/** Whether an adapter-reported workspace is a Linux path exposed through WSL UNC. */
|
|
2
|
+
export function isWslUncPath(value) {
|
|
3
|
+
if (typeof value !== "string")
|
|
4
|
+
return false;
|
|
5
|
+
return (/^\\\\(?:wsl\.localhost|wsl\$)\\/i.test(value) ||
|
|
6
|
+
/^\\\\\?\\unc\\(?:wsl\.localhost|wsl\$)\\/i.test(value));
|
|
7
|
+
}
|
|
8
|
+
function parseWslUncPath(value) {
|
|
9
|
+
if (typeof value !== "string")
|
|
10
|
+
return null;
|
|
11
|
+
const ordinary = value.replace(/^\\\\\?\\UNC\\/i, "\\\\");
|
|
12
|
+
const match = ordinary.match(/^\\\\(wsl\.localhost|wsl\$)\\([^\\]+)(?:\\(.*))?$/i);
|
|
13
|
+
if (!match)
|
|
14
|
+
return null;
|
|
15
|
+
const host = match[1];
|
|
16
|
+
const distro = match[2];
|
|
17
|
+
const tail = (match[3] ?? "").split("\\").filter(Boolean).join("/");
|
|
18
|
+
return { host, distro, linuxPath: tail ? `/${tail}` : "/" };
|
|
19
|
+
}
|
|
20
|
+
function trimTrailingSlash(path) {
|
|
21
|
+
return path === "/" ? path : path.replace(/\/+$/, "");
|
|
22
|
+
}
|
|
23
|
+
function isWithinOrEqual(path, root) {
|
|
24
|
+
return path === root || path.startsWith(`${root}/`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Derive the Linux-to-host path pair from the actual adapter workspace. The
|
|
28
|
+
* roots must overlap so an unrelated WSL UNC path cannot authorize a mapping
|
|
29
|
+
* for some other checkout.
|
|
30
|
+
*/
|
|
31
|
+
export function codexWslWorkspaceLinkMapping(coordRootRaw, workspaceCwd) {
|
|
32
|
+
const parsed = parseWslUncPath(workspaceCwd);
|
|
33
|
+
const linuxRoot = trimTrailingSlash(coordRootRaw.replace(/\\/g, "/"));
|
|
34
|
+
if (!parsed || !linuxRoot.startsWith("/"))
|
|
35
|
+
return null;
|
|
36
|
+
const linuxCwd = trimTrailingSlash(parsed.linuxPath);
|
|
37
|
+
if (!isWithinOrEqual(linuxCwd, linuxRoot) && !isWithinOrEqual(linuxRoot, linuxCwd)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
linuxRoot,
|
|
42
|
+
hostRoot: `//${parsed.host}/${parsed.distro}${linuxRoot}`,
|
|
43
|
+
distro: parsed.distro,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** Fresh adapter context for the model. Shell paths stay Linux-native; only
|
|
47
|
+
* Markdown destinations use the host-visible root. */
|
|
48
|
+
export function renderCodexWslFileLinkContext(coordRoot, workspaceCwd) {
|
|
49
|
+
const mapping = codexWslWorkspaceLinkMapping(coordRoot, workspaceCwd);
|
|
50
|
+
if (!mapping)
|
|
51
|
+
return "";
|
|
52
|
+
return ("Codex WSL file links: this task is hosted by Windows while tools run inside WSL. " +
|
|
53
|
+
`For clickable local-file Markdown links, replace the Linux workspace root \`${mapping.linuxRoot}\` with the host-visible root \`${mapping.hostRoot}\`. ` +
|
|
54
|
+
`Example: \`[label](<${mapping.hostRoot}/path/to/file>)\`. ` +
|
|
55
|
+
"Keep Linux paths unchanged in shell commands and tool inputs.");
|
|
56
|
+
}
|
|
57
|
+
function withoutMarkdownCode(text) {
|
|
58
|
+
const output = [];
|
|
59
|
+
let fence = null;
|
|
60
|
+
for (const line of text.split(/\r?\n/)) {
|
|
61
|
+
const candidate = line.match(/^\s{0,3}(`{3,}|~{3,})/);
|
|
62
|
+
if (fence) {
|
|
63
|
+
if (candidate && candidate[1][0] === fence.marker && candidate[1].length >= fence.length) {
|
|
64
|
+
fence = null;
|
|
65
|
+
}
|
|
66
|
+
output.push("");
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (candidate) {
|
|
70
|
+
fence = { marker: candidate[1][0], length: candidate[1].length };
|
|
71
|
+
output.push("");
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
output.push(line.replace(/(`+)([^`\n]*?)\1/g, ""));
|
|
75
|
+
}
|
|
76
|
+
return output.join("\n");
|
|
77
|
+
}
|
|
78
|
+
function markdownDestinations(text) {
|
|
79
|
+
const out = [];
|
|
80
|
+
const visible = withoutMarkdownCode(text);
|
|
81
|
+
const re = /!?\[[^\]\n]*\]\(\s*(?:<([^>\n]+)>|([^\s)\n]+))/g;
|
|
82
|
+
for (const match of visible.matchAll(re)) {
|
|
83
|
+
const target = match[1] ?? match[2];
|
|
84
|
+
if (target)
|
|
85
|
+
out.push(target);
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Count Markdown links that point at the Linux workspace root even though the
|
|
91
|
+
* adapter workspace is Windows-visible UNC. This is telemetry only: the Stop
|
|
92
|
+
* hook must not replace or retry an otherwise complete Codex reply.
|
|
93
|
+
*/
|
|
94
|
+
export function codexWslFileLinkTelemetry(coordRoot, workspaceCwd, assistantMessage) {
|
|
95
|
+
const mapping = codexWslWorkspaceLinkMapping(coordRoot, workspaceCwd);
|
|
96
|
+
if (!mapping)
|
|
97
|
+
return null;
|
|
98
|
+
const mismatches = markdownDestinations(assistantMessage).filter((target) => isWithinOrEqual(target, mapping.linuxRoot));
|
|
99
|
+
return {
|
|
100
|
+
wsl_linux_file_link_count: mismatches.length,
|
|
101
|
+
...(mismatches.length > 0
|
|
102
|
+
? { wsl_linux_file_link_examples: mismatches.slice(0, 3).map((path) => path.slice(0, 240)) }
|
|
103
|
+
: {}),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function wslenvForwards(wslenv, variable) {
|
|
107
|
+
if (!wslenv)
|
|
108
|
+
return false;
|
|
109
|
+
return wslenv.split(":").some((entry) => entry.split("/", 1)[0] === variable);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Inspect the environment contract used when Windows-native Codex launches a
|
|
113
|
+
* Harnery hook or shell inside WSL. Returns null outside that hybrid mode.
|
|
114
|
+
*/
|
|
115
|
+
export function inspectCodexWslBridge(env = process.env, options = {}) {
|
|
116
|
+
const inWsl = Boolean(env.WSL_DISTRO_NAME?.trim() || env.WSL_INTEROP?.trim());
|
|
117
|
+
if (!inWsl)
|
|
118
|
+
return null;
|
|
119
|
+
const threadIdPresent = Boolean(env.CODEX_THREAD_ID?.trim());
|
|
120
|
+
const wslenvForwardsThreadId = wslenvForwards(env.WSLENV, "CODEX_THREAD_ID");
|
|
121
|
+
if (!options.expected && !threadIdPresent && !wslenvForwardsThreadId)
|
|
122
|
+
return null;
|
|
123
|
+
const problems = [];
|
|
124
|
+
if (!threadIdPresent)
|
|
125
|
+
problems.push("CODEX_THREAD_ID did not reach WSL");
|
|
126
|
+
if (!wslenvForwardsThreadId)
|
|
127
|
+
problems.push("WSLENV does not forward CODEX_THREAD_ID");
|
|
128
|
+
const distro = env.WSL_DISTRO_NAME?.trim();
|
|
129
|
+
return {
|
|
130
|
+
ok: problems.length === 0,
|
|
131
|
+
detail: problems.length === 0
|
|
132
|
+
? `thread identity forwarded through WSLENV${distro ? ` (${distro})` : ""}`
|
|
133
|
+
: problems.join("; "),
|
|
134
|
+
threadIdPresent,
|
|
135
|
+
wslenvForwardsThreadId,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -40,7 +40,7 @@ export declare function journalArchive(repoRoot: string, owner: string): void;
|
|
|
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/harness/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
|
|
@@ -113,7 +113,7 @@ export function journalArchive(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/harness/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
|
|
@@ -123,7 +123,7 @@ export function journalArchive(repoRoot, owner) {
|
|
|
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", "harness", "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", "harness", "claude-code", "extensions", "turn-summary.sh");
|
|
151
151
|
if (!existsSync(script))
|
|
152
152
|
return;
|
|
153
153
|
const child = spawn("bash", [script, owner, sessionId, transcriptPath], {
|
|
@@ -41,6 +41,14 @@ export type SessionStart = EventEnvelope<"session.start", {
|
|
|
41
41
|
cwd: string;
|
|
42
42
|
model?: string;
|
|
43
43
|
pid: number;
|
|
44
|
+
/** Content hash of every repo-authored instruction/config file this
|
|
45
|
+
* adapter can load for the session's working-path profile. */
|
|
46
|
+
instruction_bundle_id?: string;
|
|
47
|
+
/** Parallel hash of canonical AGENTS.md + .agents sources. This diagnoses
|
|
48
|
+
* sync drift without splitting behavior cohorts when rendered bytes match. */
|
|
49
|
+
instruction_source_id?: string;
|
|
50
|
+
instruction_profile_root?: string;
|
|
51
|
+
instruction_component_count?: number;
|
|
44
52
|
/** Present iff this session is a `workflow run` child: the run id whose
|
|
45
53
|
* transcript owns it (child env HARNERY_WORKFLOW_RUN_ID). Optional-field
|
|
46
54
|
* addition per the schema evolution rules (minor bump). */
|
|
@@ -65,10 +73,45 @@ export type UserPromptSubmit = EventEnvelope<"user_prompt.submit", {
|
|
|
65
73
|
prompt_text: string;
|
|
66
74
|
truncated?: boolean;
|
|
67
75
|
}>;
|
|
76
|
+
/** Direct adapter evidence that the session is waiting for operator input. */
|
|
77
|
+
export type InteractionInputRequested = EventEnvelope<"interaction.input_requested", {
|
|
78
|
+
request_kind: "permission";
|
|
79
|
+
tool_name?: string;
|
|
80
|
+
reason?: string;
|
|
81
|
+
}>;
|
|
68
82
|
export type TurnStop = EventEnvelope<"turn.stop", {
|
|
69
83
|
tool_call_count: number;
|
|
70
84
|
text_length: number;
|
|
71
85
|
status_box_present: boolean;
|
|
86
|
+
/** Strict variant of status_box_present: assistant text blocks only, so a
|
|
87
|
+
* tool_result carrying the box (the status command's own output) does not
|
|
88
|
+
* count. Shadow telemetry while the rule-2/3 detector decision is open;
|
|
89
|
+
* the Stop verdict does not read it yet. */
|
|
90
|
+
status_box_present_strict?: boolean;
|
|
91
|
+
/** Whether the session's suggested name is satisfied as of this turn:
|
|
92
|
+
* either this reply showed it, or an earlier reply did. Present whenever a
|
|
93
|
+
* suggested name exists, since the Stop verdict reads it per turn. */
|
|
94
|
+
session_name_present?: boolean;
|
|
95
|
+
/** Which suggested name `session_name_present` refers to. A projector
|
|
96
|
+
* rebuild attributes the sighting to this name instead of to whichever
|
|
97
|
+
* name is current during the replay. */
|
|
98
|
+
session_name_present_for?: string;
|
|
99
|
+
/** Shadow telemetry for Windows-hosted Codex workspaces: Markdown link
|
|
100
|
+
* destinations that still use the Linux coordination root. */
|
|
101
|
+
wsl_linux_file_link_count?: number;
|
|
102
|
+
/** Up to three bounded examples for diagnosing the mismatches locally. */
|
|
103
|
+
wsl_linux_file_link_examples?: string[];
|
|
104
|
+
}>;
|
|
105
|
+
/** The evaluated end-turn policy outcome. One row per Stop evaluation makes
|
|
106
|
+
* the future bounce denominator explicit and keeps repeated remediation nags
|
|
107
|
+
* from being mistaken for additional human turns. */
|
|
108
|
+
export type StopVerdict = EventEnvelope<"stop.verdict", {
|
|
109
|
+
allow: boolean;
|
|
110
|
+
rule: string;
|
|
111
|
+
reason?: string;
|
|
112
|
+
enforcement_mode: "enforced" | "observe_only" | "exempt" | "fail_open";
|
|
113
|
+
eligible: boolean;
|
|
114
|
+
nag_delivered: boolean;
|
|
72
115
|
}>;
|
|
73
116
|
export type CommandStart = EventEnvelope<"command.start", {
|
|
74
117
|
cmd_id: string;
|
|
@@ -164,6 +207,10 @@ export type ContextRecoveryInjected = EventEnvelope<"context.recovery.injected",
|
|
|
164
207
|
export type ClaimAcquire = EventEnvelope<"claim.acquire", {
|
|
165
208
|
path: string;
|
|
166
209
|
mode: "read" | "write";
|
|
210
|
+
finalization?: {
|
|
211
|
+
disposition: "git" | "output";
|
|
212
|
+
root: string;
|
|
213
|
+
};
|
|
167
214
|
}>;
|
|
168
215
|
export type ClaimRelease = EventEnvelope<"claim.release", {
|
|
169
216
|
path: string;
|
|
@@ -177,6 +224,15 @@ export type ClaimConflict = EventEnvelope<"claim.conflict", {
|
|
|
177
224
|
export type StateTaskSet = EventEnvelope<"state.task_set", {
|
|
178
225
|
task: string;
|
|
179
226
|
cleared: boolean;
|
|
227
|
+
/** True exactly when this call produced the session name (first non-empty
|
|
228
|
+
* declaration of a human-facing session); never true with a null name. */
|
|
229
|
+
first_of_session?: boolean;
|
|
230
|
+
/** The name produced by this call, for the Stop-hook naming rule. */
|
|
231
|
+
suggested_session_name?: string | null;
|
|
232
|
+
}>;
|
|
233
|
+
export type StateTaskState = EventEnvelope<"state.task_state", {
|
|
234
|
+
state: "active" | "blocked" | "done";
|
|
235
|
+
reason?: string;
|
|
180
236
|
}>;
|
|
181
237
|
export type StateStatusChecked = EventEnvelope<"state.status_checked", {
|
|
182
238
|
format: "box" | "json" | "table";
|
|
@@ -270,7 +326,7 @@ export type HealthVerdictFailure = EventEnvelope<"health.verdict_failure", {
|
|
|
270
326
|
timeout_ms?: number;
|
|
271
327
|
fallback: "allow";
|
|
272
328
|
}>;
|
|
273
|
-
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;
|
|
329
|
+
export type Event = SessionStart | SessionEnd | SubagentStart | SubagentStop | UserPromptSubmit | InteractionInputRequested | TurnStop | StopVerdict | CommandStart | CommandOutput | CommandEnd | Narration | ToolPreUse | ToolPostUse | ToolPostUseFailure | ToolOutputChunk | ImageCaptured | ContextSampled | ContextCheckpointCreated | ContextCompactionStarted | ContextCompactionCompleted | ContextRecoveryInjected | ClaimAcquire | ClaimRelease | ClaimConflict | StateTaskSet | StateTaskState | StateStatusChecked | StateJournalAppend | StatePresenceChange | StateHeartbeat | IdentityAssumed | CouncilOpen | CouncilRoundOpen | CouncilContribution | CouncilRoundClose | CouncilClose | CouncilArchive | DecisionBlock | DecisionWarn | DecisionAllow | HealthHeartbeatHeal | HealthPidmapHeal | HealthHeartbeatSwept | HealthVerdictFailure;
|
|
274
330
|
export type EventType = Event["event_type"];
|
|
275
331
|
/**
|
|
276
332
|
* 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;;;4CAG4C;AAC5C,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,MAAM,CAAC;IACzB;;iEAE6D;IAC7D,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CACF,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,aAAa,CACpC,aAAa,EACb;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB,CACF,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,aAAa,CACvC,gBAAgB,EAChB;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CACF,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,aAAa,CACtC,eAAe,EACf;IACE,WAAW,EAAE,IAAI,GAAG,OAAO,GAAG,aAAa,CAAC;CAC7C,CACF,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAC1C,oBAAoB,EACpB;IACE,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CACF,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,aAAa,CAClC,WAAW,EACX;IACE,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/events/schema.ts"],"names":[],"mappings":"AAAA;;;;;;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ClB,kBAAkB,GAClB,mBAAmB,GACnB,cAAc,GACd,eAAe,GACf,WAAW,GACX,gBAAgB,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"}
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
* events; session_id is the parent-shape default.
|
|
12
12
|
* 3. PID-map lookup at `.harnery/pid-map/<pid>` for our own pid, then ppid
|
|
13
13
|
* chain (up to 20 hops).
|
|
14
|
+
* 4. `CODEX_THREAD_ID` env var, accepted only when a live heartbeat by that
|
|
15
|
+
* id exists under `.harnery/active/`. Codex sessions use their thread id
|
|
16
|
+
* as the heartbeat instance_id, and a Windows→WSL bridge forwards the
|
|
17
|
+
* var into process trees that descend from no registered process — the
|
|
18
|
+
* one place the pid walk can never land. Validated so a garbage value
|
|
19
|
+
* cannot fabricate an identity.
|
|
14
20
|
*
|
|
15
21
|
* Returns null when nothing resolves. Callers must treat null as "no owner"
|
|
16
22
|
* and skip the event (Phase 2 fail-safe; Phase 3 will mint a temporary owner
|
|
@@ -21,7 +27,7 @@ export declare function resolveOwner(opts: {
|
|
|
21
27
|
coordRoot: string;
|
|
22
28
|
}): {
|
|
23
29
|
instance_id: string;
|
|
24
|
-
source: "env" | "payload" | "pidmap-self" | "pidmap-ancestor";
|
|
30
|
+
source: "env" | "payload" | "pidmap-self" | "pidmap-ancestor" | "codex-env";
|
|
25
31
|
} | null;
|
|
26
32
|
/**
|
|
27
33
|
* Find the parent owner for a subagent invocation. The per-shell marker at
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/owner.ts"],"names":[],"mappings":"AAMA
|
|
1
|
+
{"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/owner.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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,iBAAiB,GAAG,WAAW,CAAC;CAC7E,GAAG,IAAI,CAgEP;AA2BD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ7E;AAED,wEAAwE;AACxE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUxF;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBnF"}
|
|
@@ -16,6 +16,12 @@ import { checkPidToken } from "../../agents/state/proc-start.js";
|
|
|
16
16
|
* events; session_id is the parent-shape default.
|
|
17
17
|
* 3. PID-map lookup at `.harnery/pid-map/<pid>` for our own pid, then ppid
|
|
18
18
|
* chain (up to 20 hops).
|
|
19
|
+
* 4. `CODEX_THREAD_ID` env var, accepted only when a live heartbeat by that
|
|
20
|
+
* id exists under `.harnery/active/`. Codex sessions use their thread id
|
|
21
|
+
* as the heartbeat instance_id, and a Windows→WSL bridge forwards the
|
|
22
|
+
* var into process trees that descend from no registered process — the
|
|
23
|
+
* one place the pid walk can never land. Validated so a garbage value
|
|
24
|
+
* cannot fabricate an identity.
|
|
19
25
|
*
|
|
20
26
|
* Returns null when nothing resolves. Callers must treat null as "no owner"
|
|
21
27
|
* and skip the event (Phase 2 fail-safe; Phase 3 will mint a temporary owner
|
|
@@ -71,6 +77,15 @@ export function resolveOwner(opts) {
|
|
|
71
77
|
hops++;
|
|
72
78
|
}
|
|
73
79
|
}
|
|
80
|
+
// Tier 4: Codex thread id, heartbeat-validated. Last because the pid map is
|
|
81
|
+
// more specific when it answers — an inherited env var can outlive the
|
|
82
|
+
// process tree it described, a live pid-map row cannot.
|
|
83
|
+
const codexThreadId = process.env.CODEX_THREAD_ID?.trim();
|
|
84
|
+
if (codexThreadId &&
|
|
85
|
+
/^[A-Za-z0-9-]+$/.test(codexThreadId) &&
|
|
86
|
+
existsSync(join(opts.coordRoot, ".harnery", "active", `${codexThreadId}.json`))) {
|
|
87
|
+
return { instance_id: codexThreadId, source: "codex-env" };
|
|
88
|
+
}
|
|
74
89
|
return null;
|
|
75
90
|
}
|
|
76
91
|
function readPpid(pid) {
|