oh-my-codex 0.21.48 → 0.22.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/Cargo.lock +6 -6
- package/Cargo.toml +1 -1
- package/README.md +15 -0
- package/crates/omx-mux/src/herdr.rs +481 -0
- package/crates/omx-mux/src/lib.rs +5 -0
- package/dist/cli/__tests__/session-compare.test.d.ts +2 -0
- package/dist/cli/__tests__/session-compare.test.d.ts.map +1 -0
- package/dist/cli/__tests__/session-compare.test.js +183 -0
- package/dist/cli/__tests__/session-compare.test.js.map +1 -0
- package/dist/cli/__tests__/team.test.js +8 -0
- package/dist/cli/__tests__/team.test.js.map +1 -1
- package/dist/cli/session-compare.d.ts +11 -0
- package/dist/cli/session-compare.d.ts.map +1 -0
- package/dist/cli/session-compare.js +172 -0
- package/dist/cli/session-compare.js.map +1 -0
- package/dist/cli/session-search.d.ts.map +1 -1
- package/dist/cli/session-search.js +7 -0
- package/dist/cli/session-search.js.map +1 -1
- package/dist/cli/team.d.ts.map +1 -1
- package/dist/cli/team.js +2 -0
- package/dist/cli/team.js.map +1 -1
- package/dist/config/__tests__/multiplexer.test.d.ts +2 -0
- package/dist/config/__tests__/multiplexer.test.d.ts.map +1 -0
- package/dist/config/__tests__/multiplexer.test.js +118 -0
- package/dist/config/__tests__/multiplexer.test.js.map +1 -0
- package/dist/config/multiplexer.d.ts +29 -0
- package/dist/config/multiplexer.d.ts.map +1 -0
- package/dist/config/multiplexer.js +91 -0
- package/dist/config/multiplexer.js.map +1 -0
- package/dist/scripts/__tests__/codex-native-hook.test.js +281 -1
- package/dist/scripts/__tests__/codex-native-hook.test.js.map +1 -1
- package/dist/scripts/codex-native-hook.d.ts.map +1 -1
- package/dist/scripts/codex-native-hook.js +8 -2
- package/dist/scripts/codex-native-hook.js.map +1 -1
- package/dist/scripts/notify-hook/team-worker-lease.d.ts +15 -0
- package/dist/scripts/notify-hook/team-worker-lease.d.ts.map +1 -0
- package/dist/scripts/notify-hook/team-worker-lease.js +63 -0
- package/dist/scripts/notify-hook/team-worker-lease.js.map +1 -0
- package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts +1 -0
- package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-worker-posttooluse.js +16 -5
- package/dist/scripts/notify-hook/team-worker-posttooluse.js.map +1 -1
- package/dist/scripts/notify-hook/team-worker.d.ts +12 -1
- package/dist/scripts/notify-hook/team-worker.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-worker.js +16 -4
- package/dist/scripts/notify-hook/team-worker.js.map +1 -1
- package/dist/session-history/__tests__/compare.test.d.ts +2 -0
- package/dist/session-history/__tests__/compare.test.d.ts.map +1 -0
- package/dist/session-history/__tests__/compare.test.js +257 -0
- package/dist/session-history/__tests__/compare.test.js.map +1 -0
- package/dist/session-history/compare.d.ts +74 -0
- package/dist/session-history/compare.d.ts.map +1 -0
- package/dist/session-history/compare.js +165 -0
- package/dist/session-history/compare.js.map +1 -0
- package/dist/team/__tests__/api-interop.test.js +3 -3
- package/dist/team/__tests__/cross-rebase-smoke.test.js +263 -31
- package/dist/team/__tests__/cross-rebase-smoke.test.js.map +1 -1
- package/dist/team/__tests__/herdr-session-realherdr.test.d.ts +2 -0
- package/dist/team/__tests__/herdr-session-realherdr.test.d.ts.map +1 -0
- package/dist/team/__tests__/herdr-session-realherdr.test.js +68 -0
- package/dist/team/__tests__/herdr-session-realherdr.test.js.map +1 -0
- package/dist/team/__tests__/herdr-session.test.d.ts +2 -0
- package/dist/team/__tests__/herdr-session.test.d.ts.map +1 -0
- package/dist/team/__tests__/herdr-session.test.js +228 -0
- package/dist/team/__tests__/herdr-session.test.js.map +1 -0
- package/dist/team/__tests__/idle-nudge.test.js +84 -0
- package/dist/team/__tests__/idle-nudge.test.js.map +1 -1
- package/dist/team/__tests__/rebalance-policy.test.js +27 -9
- package/dist/team/__tests__/rebalance-policy.test.js.map +1 -1
- package/dist/team/__tests__/runtime-delivery.test.d.ts +2 -0
- package/dist/team/__tests__/runtime-delivery.test.d.ts.map +1 -0
- package/dist/team/__tests__/runtime-delivery.test.js +570 -0
- package/dist/team/__tests__/runtime-delivery.test.js.map +1 -0
- package/dist/team/__tests__/runtime.test.js +332 -18
- package/dist/team/__tests__/runtime.test.js.map +1 -1
- package/dist/team/__tests__/scaling.test.js +293 -0
- package/dist/team/__tests__/scaling.test.js.map +1 -1
- package/dist/team/__tests__/state-renewal.test.d.ts +2 -0
- package/dist/team/__tests__/state-renewal.test.d.ts.map +1 -0
- package/dist/team/__tests__/state-renewal.test.js +555 -0
- package/dist/team/__tests__/state-renewal.test.js.map +1 -0
- package/dist/team/__tests__/task-lease.test.d.ts +2 -0
- package/dist/team/__tests__/task-lease.test.d.ts.map +1 -0
- package/dist/team/__tests__/task-lease.test.js +179 -0
- package/dist/team/__tests__/task-lease.test.js.map +1 -0
- package/dist/team/__tests__/team-ops-contract.test.js +1 -0
- package/dist/team/__tests__/team-ops-contract.test.js.map +1 -1
- package/dist/team/__tests__/worker-bootstrap.test.js +2 -0
- package/dist/team/__tests__/worker-bootstrap.test.js.map +1 -1
- package/dist/team/api-interop.d.ts +1 -1
- package/dist/team/api-interop.d.ts.map +1 -1
- package/dist/team/api-interop.js +13 -1
- package/dist/team/api-interop.js.map +1 -1
- package/dist/team/goal-workflow.js +1 -1
- package/dist/team/herdr-session.d.ts +234 -0
- package/dist/team/herdr-session.d.ts.map +1 -0
- package/dist/team/herdr-session.js +489 -0
- package/dist/team/herdr-session.js.map +1 -0
- package/dist/team/idle-nudge.d.ts +16 -4
- package/dist/team/idle-nudge.d.ts.map +1 -1
- package/dist/team/idle-nudge.js +51 -19
- package/dist/team/idle-nudge.js.map +1 -1
- package/dist/team/mcp-comm.d.ts +1 -1
- package/dist/team/mcp-comm.d.ts.map +1 -1
- package/dist/team/rebalance-policy.d.ts.map +1 -1
- package/dist/team/rebalance-policy.js +5 -2
- package/dist/team/rebalance-policy.js.map +1 -1
- package/dist/team/runtime.d.ts.map +1 -1
- package/dist/team/runtime.js +356 -81
- package/dist/team/runtime.js.map +1 -1
- package/dist/team/scaling.d.ts.map +1 -1
- package/dist/team/scaling.js +332 -143
- package/dist/team/scaling.js.map +1 -1
- package/dist/team/state/monitor.d.ts +3 -0
- package/dist/team/state/monitor.d.ts.map +1 -1
- package/dist/team/state/monitor.js +3 -0
- package/dist/team/state/monitor.js.map +1 -1
- package/dist/team/state/tasks.d.ts +2 -1
- package/dist/team/state/tasks.d.ts.map +1 -1
- package/dist/team/state/tasks.js +28 -0
- package/dist/team/state/tasks.js.map +1 -1
- package/dist/team/state/types.d.ts +8 -0
- package/dist/team/state/types.d.ts.map +1 -1
- package/dist/team/state/types.js.map +1 -1
- package/dist/team/state.d.ts +14 -2
- package/dist/team/state.d.ts.map +1 -1
- package/dist/team/state.js +29 -5
- package/dist/team/state.js.map +1 -1
- package/dist/team/task-lease.d.ts +4 -0
- package/dist/team/task-lease.d.ts.map +1 -0
- package/dist/team/task-lease.js +74 -0
- package/dist/team/task-lease.js.map +1 -0
- package/dist/team/team-ops.d.ts +2 -1
- package/dist/team/team-ops.d.ts.map +1 -1
- package/dist/team/team-ops.js +1 -0
- package/dist/team/team-ops.js.map +1 -1
- package/dist/team/tmux-session.d.ts +1 -1
- package/dist/team/tmux-session.d.ts.map +1 -1
- package/dist/team/tmux-session.js +10 -2
- package/dist/team/tmux-session.js.map +1 -1
- package/dist/team/worker-bootstrap.d.ts.map +1 -1
- package/dist/team/worker-bootstrap.js +14 -1
- package/dist/team/worker-bootstrap.js.map +1 -1
- package/package.json +1 -1
- package/plugins/oh-my-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/oh-my-codex/skills/worker/SKILL.md +7 -1
- package/skills/worker/SKILL.md +7 -1
- package/src/scripts/__tests__/codex-native-hook.test.ts +279 -0
- package/src/scripts/codex-native-hook.ts +8 -2
- package/src/scripts/notify-hook/team-worker-lease.ts +69 -0
- package/src/scripts/notify-hook/team-worker-posttooluse.ts +16 -4
- package/src/scripts/notify-hook/team-worker.ts +15 -4
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const execFileAsync = promisify(execFile);
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { isAbsolute } from "node:path";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
/**
|
|
8
|
+
* Herdr team runtime backend (issue #3241, Phase 2).
|
|
9
|
+
*
|
|
10
|
+
* When the multiplexer setting resolves to "herdr" (src/config/multiplexer.ts),
|
|
11
|
+
* team workers run as Herdr workspaces/tabs/agents instead of tmux
|
|
12
|
+
* sessions/windows/panes:
|
|
13
|
+
*
|
|
14
|
+
* - one Herdr workspace per team, labelled `omx-team-<name>` (visible in the
|
|
15
|
+
* Herdr sidebar, replacing the tmux HUD watch pane)
|
|
16
|
+
* - one tab per worker, carrying the worker env via `tab create --env`
|
|
17
|
+
* - one agent per tab, started with `agent start --kind <cli>` and driven
|
|
18
|
+
* through the semantic agent surface (`agent prompt` / `agent read` /
|
|
19
|
+
* `agent get`) instead of raw keystrokes
|
|
20
|
+
*
|
|
21
|
+
* Design constraints inherited from the Phase 1 bridge (src/adapt/herdr):
|
|
22
|
+
* - execFile argv arrays only, never a shell string
|
|
23
|
+
* - the binary is trust-pinned to HERDR_BIN_PATH when present
|
|
24
|
+
* - a Herdr failure surfaces as a typed error; callers decide severity
|
|
25
|
+
*
|
|
26
|
+
* The headless server is auto-started on demand (`herdr server` daemonizes the
|
|
27
|
+
* pane runtime), because Herdr CLI commands fail with `server_not_running`
|
|
28
|
+
* otherwise.
|
|
29
|
+
*/
|
|
30
|
+
export const HERDR_TEAM_WORKSPACE_LABEL_PREFIX = "omx-team-";
|
|
31
|
+
const HERDR_AGENT_NAME_PATTERN = /^[a-z][a-z0-9_-]{0,31}$/;
|
|
32
|
+
const HERDR_DEFAULT_EXEC_TIMEOUT_MS = 20_000;
|
|
33
|
+
const HERDR_AGENT_START_TIMEOUT_MS = 60_000;
|
|
34
|
+
const HERDR_SERVER_START_TIMEOUT_MS = 10_000;
|
|
35
|
+
const HERDR_SERVER_POLL_INTERVAL_MS = 250;
|
|
36
|
+
export class HerdrError extends Error {
|
|
37
|
+
code;
|
|
38
|
+
detail;
|
|
39
|
+
constructor(code, message, detail) {
|
|
40
|
+
super(`herdr_${code}: ${message}`);
|
|
41
|
+
this.code = code;
|
|
42
|
+
this.detail = detail;
|
|
43
|
+
this.name = "HerdrError";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function parseHerdrEnvelope(stdout) {
|
|
47
|
+
const trimmed = stdout.trim();
|
|
48
|
+
if (trimmed.length === 0) {
|
|
49
|
+
throw new HerdrError("empty_response", "herdr printed no JSON");
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(trimmed);
|
|
53
|
+
if (parsed && typeof parsed === "object")
|
|
54
|
+
return parsed;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// fall through
|
|
58
|
+
}
|
|
59
|
+
throw new HerdrError("invalid_response", "herdr printed non-JSON output", trimmed.slice(0, 200));
|
|
60
|
+
}
|
|
61
|
+
function extractErrorDetail(stderr) {
|
|
62
|
+
const trimmed = stderr.trim();
|
|
63
|
+
if (trimmed.length === 0)
|
|
64
|
+
return null;
|
|
65
|
+
try {
|
|
66
|
+
const parsed = JSON.parse(trimmed);
|
|
67
|
+
if (parsed?.error) {
|
|
68
|
+
return {
|
|
69
|
+
code: parsed.error.code ?? "error",
|
|
70
|
+
message: parsed.error.message ?? "herdr command failed",
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// non-JSON stderr
|
|
76
|
+
}
|
|
77
|
+
return { code: "error", message: trimmed.slice(0, 300) };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolve the Herdr binary. HERDR_BIN_PATH wins when it is an absolute path to
|
|
81
|
+
* an existing file (same trust-pinning as the Phase 1 bridge); otherwise the
|
|
82
|
+
* plain `herdr` name is used and resolved by PATH, mirroring how OMX invokes
|
|
83
|
+
* `tmux` today. Returns null when Herdr cannot be trusted to exist.
|
|
84
|
+
*/
|
|
85
|
+
export function resolveHerdrBinary(env = process.env) {
|
|
86
|
+
const pinned = env.HERDR_BIN_PATH?.trim();
|
|
87
|
+
if (pinned && isAbsolute(pinned) && existsSync(pinned)) {
|
|
88
|
+
return pinned;
|
|
89
|
+
}
|
|
90
|
+
return "herdr";
|
|
91
|
+
}
|
|
92
|
+
export async function isHerdrBinaryCallable(bin = resolveHerdrBinary(), env = process.env) {
|
|
93
|
+
if (bin === null)
|
|
94
|
+
return false;
|
|
95
|
+
return new Promise((resolvePromise) => {
|
|
96
|
+
execFile(bin, ["--version"], { timeout: 5_000, env }, (error) => {
|
|
97
|
+
resolvePromise(error === null);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export async function runHerdr(args, options = {}) {
|
|
102
|
+
const bin = resolveHerdrBinary(options.env);
|
|
103
|
+
if (bin === null) {
|
|
104
|
+
throw new HerdrError("binary_missing", "herdr binary not found");
|
|
105
|
+
}
|
|
106
|
+
const exec = options.execFn ?? execFileAsync;
|
|
107
|
+
const { stdout } = await exec(bin, args, {
|
|
108
|
+
timeout: options.timeoutMs ?? HERDR_DEFAULT_EXEC_TIMEOUT_MS,
|
|
109
|
+
env: options.env,
|
|
110
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
111
|
+
}).catch((error) => {
|
|
112
|
+
const detail = extractErrorDetail(String(error.stderr ?? error.stdout ?? ""));
|
|
113
|
+
const code = error.code === "ENOENT" ? "binary_missing" : (detail?.code ?? "spawn_failed");
|
|
114
|
+
throw new HerdrError(code, detail?.message ?? error.message, String(error.stderr ?? ""));
|
|
115
|
+
});
|
|
116
|
+
const envelope = parseHerdrEnvelope(String(stdout));
|
|
117
|
+
if (envelope.error) {
|
|
118
|
+
throw new HerdrError(envelope.error.code ?? "error", envelope.error.message ?? "herdr command failed");
|
|
119
|
+
}
|
|
120
|
+
return envelope;
|
|
121
|
+
}
|
|
122
|
+
export async function runHerdrResult(args, options = {}) {
|
|
123
|
+
const envelope = await runHerdr(args, options);
|
|
124
|
+
return envelope.result;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Run a Herdr command that prints plain text instead of the JSON envelope
|
|
128
|
+
* (pane/agent `read` on the CLI surface). Stderr is still decoded as a JSON
|
|
129
|
+
* error envelope when possible.
|
|
130
|
+
*/
|
|
131
|
+
export async function runHerdrRaw(args, options = {}) {
|
|
132
|
+
const bin = resolveHerdrBinary(options.env);
|
|
133
|
+
if (bin === null) {
|
|
134
|
+
throw new HerdrError("binary_missing", "herdr binary not found");
|
|
135
|
+
}
|
|
136
|
+
const exec = options.execFn ?? execFileAsync;
|
|
137
|
+
const { stdout } = await exec(bin, args, {
|
|
138
|
+
timeout: options.timeoutMs ?? HERDR_DEFAULT_EXEC_TIMEOUT_MS,
|
|
139
|
+
env: options.env,
|
|
140
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
141
|
+
}).catch((error) => {
|
|
142
|
+
const detail = extractErrorDetail(String(error.stderr ?? ""));
|
|
143
|
+
const code = error.code === "ENOENT" ? "binary_missing" : (detail?.code ?? "spawn_failed");
|
|
144
|
+
throw new HerdrError(code, detail?.message ?? error.message, String(error.stderr ?? ""));
|
|
145
|
+
});
|
|
146
|
+
return String(stdout);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Ensure a Herdr server owns the socket. When `agent list` answers
|
|
150
|
+
* `server_not_running`, spawn the headless `herdr server` detached and poll
|
|
151
|
+
* until commands answer (workers then outlive the OMX process, which is the
|
|
152
|
+
* Herdr model). Throws herdr_server_start_failed on timeout.
|
|
153
|
+
*/
|
|
154
|
+
export async function ensureHerdrServer(options = {}) {
|
|
155
|
+
const env = options.env ?? process.env;
|
|
156
|
+
const bin = options.bin ?? resolveHerdrBinary(env);
|
|
157
|
+
if (bin === null)
|
|
158
|
+
throw new HerdrError("binary_missing", "herdr binary not found");
|
|
159
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
160
|
+
try {
|
|
161
|
+
await runHerdr(["agent", "list"], { env, execFn: options.execFn });
|
|
162
|
+
return "running";
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
if (!(error instanceof HerdrError) || error.code !== "server_not_running")
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
if (attempt > 0)
|
|
169
|
+
break;
|
|
170
|
+
const child = spawn(bin, ["server"], {
|
|
171
|
+
stdio: "ignore",
|
|
172
|
+
detached: true,
|
|
173
|
+
env,
|
|
174
|
+
});
|
|
175
|
+
child.unref();
|
|
176
|
+
const deadline = Date.now() + HERDR_SERVER_START_TIMEOUT_MS;
|
|
177
|
+
while (Date.now() < deadline) {
|
|
178
|
+
await new Promise((resolveSleep) => setTimeout(resolveSleep, HERDR_SERVER_POLL_INTERVAL_MS));
|
|
179
|
+
try {
|
|
180
|
+
await runHerdr(["agent", "list"], { env, execFn: options.execFn });
|
|
181
|
+
return "started";
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// keep polling until the deadline
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
throw new HerdrError("server_start_failed", "herdr server did not become ready in time");
|
|
189
|
+
}
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
// Argv builders (pure; unit-tested)
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
export function buildWorkspaceCreateArgs(cwd, label) {
|
|
194
|
+
return ["workspace", "create", "--cwd", cwd, "--label", label, "--no-focus"];
|
|
195
|
+
}
|
|
196
|
+
export function buildTabCreateArgs(workspaceId, cwd, label, env) {
|
|
197
|
+
const args = ["tab", "create", "--workspace", workspaceId, "--cwd", cwd, "--label", label];
|
|
198
|
+
for (const [key, value] of Object.entries(env ?? {})) {
|
|
199
|
+
args.push("--env", `${key}=${value}`);
|
|
200
|
+
}
|
|
201
|
+
args.push("--no-focus");
|
|
202
|
+
return args;
|
|
203
|
+
}
|
|
204
|
+
export function buildAgentStartArgs(name, kind, paneId, agentArgs = [], timeoutMs = HERDR_AGENT_START_TIMEOUT_MS) {
|
|
205
|
+
const args = [
|
|
206
|
+
"agent",
|
|
207
|
+
"start",
|
|
208
|
+
name,
|
|
209
|
+
"--kind",
|
|
210
|
+
kind,
|
|
211
|
+
"--pane",
|
|
212
|
+
paneId,
|
|
213
|
+
"--timeout",
|
|
214
|
+
String(timeoutMs),
|
|
215
|
+
];
|
|
216
|
+
if (agentArgs.length > 0) {
|
|
217
|
+
args.push("--", ...agentArgs);
|
|
218
|
+
}
|
|
219
|
+
return args;
|
|
220
|
+
}
|
|
221
|
+
export function buildAgentPromptArgs(name, text) {
|
|
222
|
+
return ["agent", "prompt", name, text];
|
|
223
|
+
}
|
|
224
|
+
export function buildAgentGetArgs(name) {
|
|
225
|
+
return ["agent", "get", name];
|
|
226
|
+
}
|
|
227
|
+
export function buildPaneReadArgs(paneId, lines) {
|
|
228
|
+
return ["pane", "read", paneId, "--source", "recent-unwrapped", "--lines", String(lines)];
|
|
229
|
+
}
|
|
230
|
+
export function buildAgentSendKeysArgs(name, key) {
|
|
231
|
+
return ["agent", "send-keys", name, key];
|
|
232
|
+
}
|
|
233
|
+
export function buildTabCloseArgs(tabId) {
|
|
234
|
+
return ["tab", "close", tabId];
|
|
235
|
+
}
|
|
236
|
+
export function buildWorkspaceCloseArgs(workspaceId) {
|
|
237
|
+
return ["workspace", "close", workspaceId];
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Herdr agent names must match /^[a-z][a-z0-9_-]{0,31}$/ and be unique among
|
|
241
|
+
* live agents. Build a deterministic, collision-resistant name:
|
|
242
|
+
* `omx-<team[:10]>-<hash4>-w<index>`.
|
|
243
|
+
*/
|
|
244
|
+
export function buildHerdrAgentName(teamName, workerIndex) {
|
|
245
|
+
const sanitized = teamName.toLowerCase().replace(/[^a-z0-9_-]/g, "").slice(0, 10) || "team";
|
|
246
|
+
const hash = createHash("sha256").update(teamName).digest("hex").slice(0, 4);
|
|
247
|
+
const name = `omx-${sanitized}-${hash}-w${workerIndex}`;
|
|
248
|
+
if (!HERDR_AGENT_NAME_PATTERN.test(name)) {
|
|
249
|
+
throw new HerdrError("invalid_agent_name", `derived agent name is invalid: ${name}`);
|
|
250
|
+
}
|
|
251
|
+
return name;
|
|
252
|
+
}
|
|
253
|
+
export function herdrWorkspaceIdFromPaneId(paneId) {
|
|
254
|
+
const separator = paneId.indexOf(":");
|
|
255
|
+
if (separator <= 0 || separator === paneId.length - 1) {
|
|
256
|
+
throw new HerdrError("invalid_pane_id", `not a herdr pane id: ${paneId}`);
|
|
257
|
+
}
|
|
258
|
+
return paneId.slice(0, separator);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Herdr pane ids are `wN:pM` where both segments run alphanumeric past 9
|
|
262
|
+
* (`wA:pB`, ...). Unlike tmux `%N` ids they are never reused, so a recorded
|
|
263
|
+
* pane id remains a safe address for the pane's whole lifetime.
|
|
264
|
+
*/
|
|
265
|
+
export const HERDR_PANE_ID_PATTERN = /^w[0-9a-z]+:p[0-9a-z]+$/i;
|
|
266
|
+
export function isHerdrPaneId(paneId) {
|
|
267
|
+
return HERDR_PANE_ID_PATTERN.test(paneId);
|
|
268
|
+
}
|
|
269
|
+
function requirePaneId(result, command) {
|
|
270
|
+
const paneId = result?.root_pane?.pane_id;
|
|
271
|
+
if (typeof paneId !== "string" || paneId.length === 0) {
|
|
272
|
+
throw new HerdrError("missing_pane_id", `${command} did not return root_pane.pane_id`);
|
|
273
|
+
}
|
|
274
|
+
return paneId;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Bring a freshly started agent to a promptable state. Herdr returns
|
|
278
|
+
* `agent_not_ready` when the agent shows a first-run dialog (codex/claude
|
|
279
|
+
* folder trust) — the same situation the tmux backend dismisses with Enter
|
|
280
|
+
* rounds (dismissTrustPromptIfPresent). Dismiss and wait for a settled
|
|
281
|
+
* idle/done state before the first prompt.
|
|
282
|
+
*/
|
|
283
|
+
async function herdrAgentState(paneId, options) {
|
|
284
|
+
try {
|
|
285
|
+
const result = await runHerdrResult(["agent", "get", paneId], { env: options.env, execFn: options.execFn });
|
|
286
|
+
return result?.agent?.agent_status;
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
async function pollHerdrAgentSettled(paneId, options, timeoutMs) {
|
|
293
|
+
const deadline = Date.now() + timeoutMs;
|
|
294
|
+
for (;;) {
|
|
295
|
+
const state = await herdrAgentState(paneId, options);
|
|
296
|
+
if (state === "idle" || state === "done" || state === "blocked")
|
|
297
|
+
return state;
|
|
298
|
+
if (Date.now() >= deadline)
|
|
299
|
+
return state;
|
|
300
|
+
await new Promise((resolveSleep) => setTimeout(resolveSleep, 2_000));
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Bring a freshly started agent to a promptable state. Herdr returns
|
|
305
|
+
* `agent_not_ready` when the agent shows a first-run dialog (e.g. the codex
|
|
306
|
+
* "Folder access / Trust and continue" prompt, rule trust_directory). The
|
|
307
|
+
* highlighted option continues on Enter — the same dismissal the tmux backend
|
|
308
|
+
* applies — but the state needs settle time, so poll instead of assuming.
|
|
309
|
+
*/
|
|
310
|
+
export async function ensureHerdrAgentPromptable(paneId, options = {}) {
|
|
311
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
312
|
+
const settled = await pollHerdrAgentSettled(paneId, options, 15_000);
|
|
313
|
+
if (settled === "idle" || settled === "done")
|
|
314
|
+
return;
|
|
315
|
+
try {
|
|
316
|
+
await runHerdr(["agent", "send-keys", paneId, "enter"], {
|
|
317
|
+
env: options.env,
|
|
318
|
+
execFn: options.execFn,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
// best-effort dismissal; the next attempt re-checks state
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
throw new HerdrError("agent_not_promptable", `agent at ${paneId} never reached an idle state`);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Spawn one worker (tab + agent) inside an existing Herdr workspace. This is
|
|
329
|
+
* the per-worker core of createHerdrTeam, factored out so scaling can add a
|
|
330
|
+
* worker to a live team with identical semantics: worker env via
|
|
331
|
+
* `tab create --env`, agent-name collision fallback, first-run trust-dialog
|
|
332
|
+
* dismissal, and the optional initial prompt.
|
|
333
|
+
*
|
|
334
|
+
* On failure the created pane is closed (best effort) so the caller never
|
|
335
|
+
* inherits an orphan tab: createHerdrTeam's rollback closes the whole
|
|
336
|
+
* workspace anyway, while scaling must not disturb the live workspace.
|
|
337
|
+
*/
|
|
338
|
+
export async function spawnOneHerdrWorker(teamName, workspaceId, workerIndex, worker, options = {}) {
|
|
339
|
+
// The agent name is cosmetic (workers are addressed by pane id); on a
|
|
340
|
+
// collision with a leftover agent from an unclean prior team, degrade to a
|
|
341
|
+
// suffixed variant instead of failing the start.
|
|
342
|
+
let agentName = buildHerdrAgentName(teamName, workerIndex);
|
|
343
|
+
const tab = await runHerdrResult(buildTabCreateArgs(workspaceId, worker.cwd, `worker-${workerIndex}`, worker.env), { env: options.env, execFn: options.execFn });
|
|
344
|
+
const paneId = requirePaneId(tab, "tab create");
|
|
345
|
+
const tabId = typeof tab?.tab?.tab_id === "string" ? tab.tab.tab_id : "";
|
|
346
|
+
try {
|
|
347
|
+
try {
|
|
348
|
+
await runHerdr(buildAgentStartArgs(agentName, worker.kind, paneId, worker.agentArgs), { env: options.env, execFn: options.execFn, timeoutMs: HERDR_AGENT_START_TIMEOUT_MS + 10_000 }).catch(async (startError) => {
|
|
349
|
+
if (startError instanceof HerdrError && startError.code === "agent_name_taken") {
|
|
350
|
+
agentName = buildHerdrAgentName(`${teamName}r${workerIndex}`, workerIndex);
|
|
351
|
+
await runHerdr(buildAgentStartArgs(agentName, worker.kind, paneId, worker.agentArgs), { env: options.env, execFn: options.execFn, timeoutMs: HERDR_AGENT_START_TIMEOUT_MS + 10_000 });
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
throw startError;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
if (error instanceof HerdrError
|
|
359
|
+
&& (error.code === "agent_not_ready" || error.code === "timeout")) {
|
|
360
|
+
// First-run folder-trust dialogs block startup (agent_not_ready),
|
|
361
|
+
// and the start gate can also out-live its own timeout while the
|
|
362
|
+
// agent is actually fine. In both cases the pane may already host
|
|
363
|
+
// a live agent: dismiss any dialog, wait for idle, and continue
|
|
364
|
+
// addressing the worker by pane id.
|
|
365
|
+
await ensureHerdrAgentPromptable(paneId, options);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
throw error;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (worker.initialPrompt && worker.initialPrompt.trim().length > 0) {
|
|
372
|
+
await runHerdr(buildAgentPromptArgs(agentName, worker.initialPrompt), {
|
|
373
|
+
env: options.env,
|
|
374
|
+
execFn: options.execFn,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
try {
|
|
380
|
+
await runHerdr(["pane", "close", paneId], { env: options.env, execFn: options.execFn });
|
|
381
|
+
}
|
|
382
|
+
catch {
|
|
383
|
+
// best-effort cleanup; createHerdrTeam's rollback reaps the workspace
|
|
384
|
+
}
|
|
385
|
+
throw error;
|
|
386
|
+
}
|
|
387
|
+
return { index: workerIndex, agentName, paneId, tabId };
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Create the Herdr team topology: one workspace + one tab + one agent per
|
|
391
|
+
* worker. Returns identities for TeamConfig persistence.
|
|
392
|
+
*/
|
|
393
|
+
export async function createHerdrTeam(teamName, leaderCwd, workers, options = {}) {
|
|
394
|
+
await ensureHerdrServer(options);
|
|
395
|
+
const workspaceLabel = `${HERDR_TEAM_WORKSPACE_LABEL_PREFIX}${teamName}`;
|
|
396
|
+
const created = await runHerdrResult(buildWorkspaceCreateArgs(leaderCwd, workspaceLabel), { env: options.env, execFn: options.execFn });
|
|
397
|
+
const workspaceId = created?.workspace?.workspace_id;
|
|
398
|
+
if (typeof workspaceId !== "string" || workspaceId.length === 0) {
|
|
399
|
+
throw new HerdrError("missing_workspace_id", "workspace create did not return workspace_id");
|
|
400
|
+
}
|
|
401
|
+
// The workspace root tab is left empty on purpose: every worker gets its own
|
|
402
|
+
// tab so the Herdr sidebar lists one agent per worker.
|
|
403
|
+
const createdWorkers = [];
|
|
404
|
+
try {
|
|
405
|
+
for (const worker of workers) {
|
|
406
|
+
const workerIndex = createdWorkers.length + 1;
|
|
407
|
+
createdWorkers.push(await spawnOneHerdrWorker(teamName, workspaceId, workerIndex, worker, options));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
catch (error) {
|
|
411
|
+
// Roll back by closing the workspace: that reaps every pane/tab it
|
|
412
|
+
// created (closing individual tabs first races the agent shutdown and
|
|
413
|
+
// can leave the workspace — and its registered agent names — behind).
|
|
414
|
+
try {
|
|
415
|
+
await runHerdr(buildWorkspaceCloseArgs(workspaceId), { env: options.env, execFn: options.execFn });
|
|
416
|
+
}
|
|
417
|
+
catch {
|
|
418
|
+
// best-effort rollback
|
|
419
|
+
}
|
|
420
|
+
throw error;
|
|
421
|
+
}
|
|
422
|
+
return {
|
|
423
|
+
name: `herdr-${teamName}`,
|
|
424
|
+
workspaceId,
|
|
425
|
+
workspaceLabel,
|
|
426
|
+
workers: createdWorkers,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
/** Submit a task to a worker through the semantic agent surface. */
|
|
430
|
+
export async function submitToHerdrWorker(paneId, text, options = {}) {
|
|
431
|
+
await runHerdr(buildAgentPromptArgs(paneId, text), { env: options.env, execFn: options.execFn });
|
|
432
|
+
}
|
|
433
|
+
/** Interrupt the agent turn (Ctrl+C equivalent). */
|
|
434
|
+
export async function interruptHerdrWorker(paneId, options = {}) {
|
|
435
|
+
await runHerdr(buildAgentSendKeysArgs(paneId, "ctrl+c"), { env: options.env, execFn: options.execFn });
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Capture worker output for the shared pane-text classifiers
|
|
439
|
+
* (`paneLooksReady` / `paneHasActiveTask`, src/scripts/tmux-hook-engine).
|
|
440
|
+
* `recent-unwrapped` matches tmux `capture-pane -J` semantics: soft wraps
|
|
441
|
+
* joined, ANSI stripped.
|
|
442
|
+
*/
|
|
443
|
+
export async function captureHerdrWorkerPane(paneId, lines = 80, options = {}) {
|
|
444
|
+
return runHerdrRaw(buildPaneReadArgs(paneId, lines), {
|
|
445
|
+
env: options.env,
|
|
446
|
+
execFn: options.execFn,
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Worker liveness. `pane get` keeps answering for closed panes (IDs are never
|
|
451
|
+
* reused), so liveness is proven through the live-agent inventory instead:
|
|
452
|
+
* agent names are cleared when the agent exits.
|
|
453
|
+
*/
|
|
454
|
+
export async function isHerdrWorkerAlive(paneId, options = {}) {
|
|
455
|
+
try {
|
|
456
|
+
const result = await runHerdrResult(["agent", "list"], { env: options.env, execFn: options.execFn });
|
|
457
|
+
const agents = Array.isArray(result?.agents) ? result.agents : [];
|
|
458
|
+
return agents.some((agent) => agent.pane_id === paneId);
|
|
459
|
+
}
|
|
460
|
+
catch {
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Close the worker's pane (and with it the agent). Pane ids are the stable
|
|
466
|
+
* address Herdr hands out (`wN:pM`); tab ids cannot be derived from them, so
|
|
467
|
+
* teardown addresses the pane directly.
|
|
468
|
+
*/
|
|
469
|
+
export async function teardownHerdrWorker(paneId, options = {}) {
|
|
470
|
+
await runHerdr(["pane", "close", paneId], { env: options.env, execFn: options.execFn });
|
|
471
|
+
}
|
|
472
|
+
/** Close the whole team workspace (session teardown). */
|
|
473
|
+
export async function destroyHerdrTeam(workspaceId, options = {}) {
|
|
474
|
+
await runHerdr(buildWorkspaceCloseArgs(workspaceId), { env: options.env, execFn: options.execFn });
|
|
475
|
+
}
|
|
476
|
+
/** List teams by workspace label prefix, mirroring listTeamSessions. */
|
|
477
|
+
export async function listHerdrTeams(options = {}) {
|
|
478
|
+
const result = await runHerdrResult(["workspace", "list"], { env: options.env, execFn: options.execFn });
|
|
479
|
+
const workspaces = Array.isArray(result?.workspaces) ? result.workspaces : [];
|
|
480
|
+
return workspaces
|
|
481
|
+
.filter((workspace) => (workspace.label ?? "").startsWith(HERDR_TEAM_WORKSPACE_LABEL_PREFIX))
|
|
482
|
+
.map((workspace) => ({
|
|
483
|
+
workspaceId: workspace.workspace_id ?? "",
|
|
484
|
+
teamName: (workspace.label ?? "").slice(HERDR_TEAM_WORKSPACE_LABEL_PREFIX.length),
|
|
485
|
+
label: workspace.label ?? "",
|
|
486
|
+
}))
|
|
487
|
+
.filter((team) => team.workspaceId.length > 0);
|
|
488
|
+
}
|
|
489
|
+
//# sourceMappingURL=herdr-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"herdr-session.js","sourceRoot":"","sources":["../../src/team/herdr-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;G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,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Ported from OMC with adapted sendToWorker signature.
|
|
12
12
|
*/
|
|
13
|
+
import { type HerdrExecOptions } from './herdr-session.js';
|
|
13
14
|
export interface NudgeConfig {
|
|
14
15
|
/** Milliseconds a pane must be idle before the first nudge (default: 30000) */
|
|
15
16
|
delayMs: number;
|
|
@@ -19,13 +20,23 @@ export interface NudgeConfig {
|
|
|
19
20
|
message: string;
|
|
20
21
|
}
|
|
21
22
|
export declare const DEFAULT_NUDGE_CONFIG: NudgeConfig;
|
|
22
|
-
/**
|
|
23
|
-
export
|
|
23
|
+
/** Injectable herdr exec used by the herdr capture/send branches (tests). */
|
|
24
|
+
export type IdleNudgeHerdrExecFn = HerdrExecOptions['execFn'];
|
|
25
|
+
export interface IdleNudgeDeps {
|
|
26
|
+
herdrExecFn?: IdleNudgeHerdrExecFn;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Capture the last 80 lines of a worker pane — tmux (`%N`) or herdr
|
|
30
|
+
* (`wN:pM`). Herdr capture uses `pane read --source recent-unwrapped`, which
|
|
31
|
+
* matches `capture-pane -J` semantics (soft wraps joined, ANSI stripped), so
|
|
32
|
+
* the shared idle classifiers keep working. Returns '' on error.
|
|
33
|
+
*/
|
|
34
|
+
export declare function capturePane(paneId: string, deps?: IdleNudgeDeps): Promise<string>;
|
|
24
35
|
/**
|
|
25
36
|
* A pane is idle when it shows a prompt (ready for input) but has no
|
|
26
37
|
* active task running.
|
|
27
38
|
*/
|
|
28
|
-
export declare function isPaneIdle(paneId: string): Promise<boolean>;
|
|
39
|
+
export declare function isPaneIdle(paneId: string, deps?: IdleNudgeDeps): Promise<boolean>;
|
|
29
40
|
/**
|
|
30
41
|
* Thin wrapper to call OMX's sendToWorker by pane ID only (for NudgeTracker).
|
|
31
42
|
* workerIndex=0 is a dummy — paneTarget() prefers workerPaneId when provided.
|
|
@@ -39,11 +50,12 @@ export interface TeamNudgePaneTarget {
|
|
|
39
50
|
}
|
|
40
51
|
export declare class NudgeTracker {
|
|
41
52
|
private readonly config;
|
|
53
|
+
private readonly deps;
|
|
42
54
|
private readonly states;
|
|
43
55
|
/** Minimum interval between idle-detection scans (ms). */
|
|
44
56
|
private readonly scanIntervalMs;
|
|
45
57
|
private lastScanAt;
|
|
46
|
-
constructor(config?: Partial<NudgeConfig
|
|
58
|
+
constructor(config?: Partial<NudgeConfig>, deps?: IdleNudgeDeps);
|
|
47
59
|
/**
|
|
48
60
|
* Check worker panes for idle state and nudge when appropriate.
|
|
49
61
|
* Returns pane IDs that were nudged in this call.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idle-nudge.d.ts","sourceRoot":"","sources":["../../src/team/idle-nudge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"idle-nudge.d.ts","sourceRoot":"","sources":["../../src/team/idle-nudge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAO5B,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,EAAE,WAIlC,CAAC;AAMF,6EAA6E;AAC7E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,oBAAoB,CAAC;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,aAAk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