owenloop 0.5.6 → 0.5.8
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/CHANGELOG.md +30 -0
- package/README.md +3 -6
- package/dist/packages/work/src/agent/approvals.d.ts +53 -0
- package/dist/packages/work/src/agent/approvals.js +132 -0
- package/dist/packages/work/src/agent/brief.d.ts +12 -0
- package/dist/packages/work/src/agent/brief.js +51 -0
- package/dist/packages/work/src/agent/capability-model.d.ts +64 -82
- package/dist/packages/work/src/agent/capability-model.js +94 -91
- package/dist/packages/work/src/agent/loop.d.ts +43 -25
- package/dist/packages/work/src/agent/loop.js +135 -50
- package/dist/packages/work/src/bundle/types.d.ts +3 -3
- package/dist/packages/work/src/exec/loop.js +37 -15
- package/dist/packages/work/src/harness/child-env.js +4 -5
- package/dist/packages/work/src/harness/claude.d.ts +4 -0
- package/dist/packages/work/src/harness/claude.js +72 -3
- package/dist/packages/work/src/harness/codex.d.ts +37 -1
- package/dist/packages/work/src/harness/codex.js +136 -18
- package/dist/packages/work/src/harness/contract.d.ts +54 -1
- package/dist/packages/work/src/harness/session-store.d.ts +127 -17
- package/dist/packages/work/src/harness/session-store.js +157 -60
- package/dist/packages/work/src/hub/client.d.ts +13 -1
- package/dist/packages/work/src/hub/client.js +3 -0
- package/dist/packages/work/src/hub/types.d.ts +104 -3
- package/dist/packages/work/src/main.js +1 -0
- package/dist/packages/work/src/roles/agent-run.js +52 -42
- package/dist/packages/work/src/roles/approvals.d.ts +76 -0
- package/dist/packages/work/src/roles/approvals.js +231 -0
- package/dist/packages/work/src/roles/sessions.d.ts +3 -2
- package/dist/packages/work/src/roles/sessions.js +9 -2
- package/dist/packages/work/src/roles/settings.js +1 -1
- package/dist/packages/work/src/settings/roster.d.ts +21 -0
- package/dist/packages/work/src/settings/roster.js +80 -0
- package/dist/packages/work/src/settings/settings.d.ts +12 -24
- package/dist/packages/work/src/settings/settings.js +17 -35
- package/dist/packages/work/src/shift/loop.d.ts +2 -0
- package/dist/packages/work/src/shift/loop.js +2 -0
- package/dist/packages/work/src/shift/runtime.js +17 -9
- package/dist/packages/work/src/shift/spawn.d.ts +10 -53
- package/dist/packages/work/src/shift/spawn.js +28 -60
- package/dist/packages/work/src/usage.d.ts +1 -1
- package/dist/packages/work/src/usage.js +8 -4
- package/dist/src/capabilities.d.ts +44 -0
- package/dist/src/capabilities.js +38 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.js +460 -5
- package/dist/src/config-dir.d.ts +13 -18
- package/dist/src/config-dir.js +15 -23
- package/dist/src/credentials.d.ts +1 -1
- package/dist/src/credentials.js +1 -1
- package/dist/src/crypto/records.d.ts +3 -0
- package/dist/src/crypto/records.js +19 -0
- package/dist/src/crypto/trust-roots.d.ts +2 -2
- package/dist/src/crypto/trust-roots.js +2 -2
- package/dist/src/engine.d.ts +14 -0
- package/dist/src/engine.js +26 -14
- package/dist/src/global-config.d.ts +4 -7
- package/dist/src/global-config.js +4 -7
- package/dist/src/hub.d.ts +207 -5
- package/dist/src/hub.js +263 -3
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/model.d.ts +37 -1
- package/dist/src/model.js +47 -1
- package/dist/src/schemas/index.d.ts +19 -0
- package/dist/src/schemas/order.v1.schema.json +15 -1
- package/dist/src/store/pre-commit-verifier.js +1 -1
- package/dist/src/types.d.ts +58 -4
- package/dist/src/work-settings.d.ts +2 -4
- package/dist/src/work-settings.js +2 -4
- package/docs/agent-runner.md +2 -2
- package/docs/bundles.md +3 -1
- package/docs/cli.md +295 -101
- package/docs/crypto.md +14 -14
- package/docs/routing.md +607 -0
- package/docs/shift-logs.md +22 -6
- package/package.json +1 -1
- package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/plugin/.mcp.json +1 -1
- package/plugins/claude-code/plugin/skills/author/SKILL.md +1 -2
- package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
- package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
- package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +1 -2
|
@@ -287,6 +287,14 @@ export async function runShiftRuntime(parsed, options = {}) {
|
|
|
287
287
|
process.stderr.write(`${roleLabel}: ${errMsg(err)}\n`);
|
|
288
288
|
return 1;
|
|
289
289
|
}
|
|
290
|
+
const now = () => Date.now();
|
|
291
|
+
const shiftId = `shf_${randomUUID()}`;
|
|
292
|
+
const startedAt = now();
|
|
293
|
+
const name = resolveShiftName(parsed.name, { shiftId });
|
|
294
|
+
// Explicit names are the human/stable identity. Unnamed shifts deliberately
|
|
295
|
+
// keep their per-boot public suffix for presence uniqueness, so their durable
|
|
296
|
+
// state directory is the stable owner key used by session reconciliation.
|
|
297
|
+
const shiftOwner = parsed.name ?? stateDir;
|
|
290
298
|
try {
|
|
291
299
|
ensureStateDir(stateDir);
|
|
292
300
|
}
|
|
@@ -295,12 +303,16 @@ export async function runShiftRuntime(parsed, options = {}) {
|
|
|
295
303
|
return 1;
|
|
296
304
|
}
|
|
297
305
|
{
|
|
298
|
-
|
|
306
|
+
// Reconcile the Shift's own dispatch records for capacity housekeeping. The
|
|
307
|
+
// session sweep below must use the session row's PID and ownership fields,
|
|
308
|
+
// not this run-id set, because every Shift on the machine shares the store.
|
|
309
|
+
reconcileInFlight(stateDir);
|
|
299
310
|
try {
|
|
300
|
-
const retired = reconcileActiveSessions(sessionsPath(cacheDir),
|
|
311
|
+
const retired = reconcileActiveSessions(sessionsPath(cacheDir), { shiftName: name, shiftOwner }, Date.now());
|
|
301
312
|
for (const rec of retired) {
|
|
302
313
|
process.stderr.write(`${roleLabel}: retired orphaned session ${rec.workflow}/${rec.run} step '${rec.step}' ` +
|
|
303
|
-
`(harness '${rec.harness}', attempt ${String(rec.attempt ?? 1)}
|
|
314
|
+
`(harness '${rec.harness}', attempt ${String(rec.attempt ?? 1)}, ` +
|
|
315
|
+
`shift '${String(rec.shiftName)}', pid ${String(rec.pid)} confirmed dead) — its worker is gone, ` +
|
|
304
316
|
'so the next attempt replays cold\n');
|
|
305
317
|
}
|
|
306
318
|
}
|
|
@@ -361,7 +373,6 @@ export async function runShiftRuntime(parsed, options = {}) {
|
|
|
361
373
|
? parsed.workRoots.map((entry) => resolve(process.cwd(), entry))
|
|
362
374
|
: resolveAllowedWorkdirRoots(env, settings.allowedWorkdirRoots, process.cwd());
|
|
363
375
|
const hub = createHubClient({ origin, getToken: async () => token });
|
|
364
|
-
const now = () => Date.now();
|
|
365
376
|
const monotonicNow = () => performance.now();
|
|
366
377
|
const home = [env.HOME, env.USERPROFILE].find((value) => value !== undefined && value.trim() !== '');
|
|
367
378
|
// Legacy orders and modern agent orders do not need Shift-side instruction
|
|
@@ -383,9 +394,6 @@ export async function runShiftRuntime(parsed, options = {}) {
|
|
|
383
394
|
return undefined;
|
|
384
395
|
return instructionSource.getVerifiedStep(order.defDigest, order.step);
|
|
385
396
|
};
|
|
386
|
-
const shiftId = `shf_${randomUUID()}`;
|
|
387
|
-
const startedAt = now();
|
|
388
|
-
const name = resolveShiftName(parsed.name, { shiftId });
|
|
389
397
|
let daemon;
|
|
390
398
|
/**
|
|
391
399
|
* `loop` is constructed BELOW this function, so it is captured by reference
|
|
@@ -451,7 +459,6 @@ export async function runShiftRuntime(parsed, options = {}) {
|
|
|
451
459
|
run: failure.run,
|
|
452
460
|
step: failure.step ?? '(unknown)',
|
|
453
461
|
kind: failure.kind,
|
|
454
|
-
...(failure.harness !== undefined ? { harness: failure.harness } : {}),
|
|
455
462
|
executable: failure.executable,
|
|
456
463
|
exitStatus: failure.exitStatus,
|
|
457
464
|
signal: failure.signal,
|
|
@@ -470,7 +477,7 @@ export async function runShiftRuntime(parsed, options = {}) {
|
|
|
470
477
|
// output discarded exactly as it did before this change.
|
|
471
478
|
logDirReady
|
|
472
479
|
? { dir: logDir, err: (line) => process.stderr.write(`${line}\n`) }
|
|
473
|
-
: undefined, allowedWorkdirRoots);
|
|
480
|
+
: undefined, allowedWorkdirRoots, parsed.serveCrews);
|
|
474
481
|
const pollIntervalMs = parsed.pollIntervalMs ?? DEFAULT_POLL_MS;
|
|
475
482
|
const loop = createShiftLoop({
|
|
476
483
|
hub,
|
|
@@ -489,6 +496,7 @@ export async function runShiftRuntime(parsed, options = {}) {
|
|
|
489
496
|
cap,
|
|
490
497
|
serveCrews: parsed.serveCrews ?? [],
|
|
491
498
|
name,
|
|
499
|
+
shiftOwner,
|
|
492
500
|
commandRouting: settings.commandRouting,
|
|
493
501
|
resolveOrderStep,
|
|
494
502
|
pollIntervalMs,
|
|
@@ -20,18 +20,12 @@ export interface SpawnSpec {
|
|
|
20
20
|
* hosts the step agent itself. This is the ONLY agent path.
|
|
21
21
|
*/
|
|
22
22
|
kind?: 'exec' | 'agent-run';
|
|
23
|
-
/**
|
|
24
|
-
* Optional safe lifecycle-reporting label for an `agent-run` child. This field
|
|
25
|
-
* never becomes `--harness`; the child resolves the authoritative harness from
|
|
26
|
-
* CLI/environment/verified runtime definition precedence.
|
|
27
|
-
*
|
|
28
|
-
* It is ONE INPUT to the reported label, not the label itself, and it is the
|
|
29
|
-
* LOWER-ranked one: `reportedHarnessId` puts the child's `OWENLOOP_HARNESS`
|
|
30
|
-
* above it, because the child does.
|
|
31
|
-
*/
|
|
32
|
-
harness?: string;
|
|
33
23
|
/** Closed start gate created by the durable Shift reservation. */
|
|
34
24
|
startGate?: string;
|
|
25
|
+
/** Stable shift name in force when this worker was dispatched. */
|
|
26
|
+
shiftName?: string;
|
|
27
|
+
/** Stable owner key for session reconciliation. */
|
|
28
|
+
shiftOwner?: string;
|
|
35
29
|
}
|
|
36
30
|
/** The result the loop records plus best-effort pre-start cancellation handles. */
|
|
37
31
|
export interface SpawnResult {
|
|
@@ -68,48 +62,12 @@ export interface WorkerFailure {
|
|
|
68
62
|
run: string;
|
|
69
63
|
step?: string;
|
|
70
64
|
kind: 'exec' | 'agent-run';
|
|
71
|
-
harness?: string;
|
|
72
65
|
executable: string;
|
|
73
66
|
exitStatus: number | null;
|
|
74
67
|
signal: NodeJS.Signals | null;
|
|
75
68
|
message: string;
|
|
76
69
|
}
|
|
77
70
|
export type WorkerFailureReporter = (failure: WorkerFailure) => void;
|
|
78
|
-
/**
|
|
79
|
-
* The harness id to REPORT on an agent-run worker failure — a best-effort
|
|
80
|
-
* mirror of the id the CHILD resolved, never an independent decision.
|
|
81
|
-
*
|
|
82
|
-
* It mirrors `resolveAdapter` in `roles/agent-run.ts`, minus the `--harness`
|
|
83
|
-
* rank the Shift never emits:
|
|
84
|
-
*
|
|
85
|
-
* 1. `OWENLOOP_HARNESS` when the variable is SET. Set-but-blank is not a
|
|
86
|
-
* fall-through: the child refuses that config outright and names it
|
|
87
|
-
* `<empty OWENLOOP_HARNESS>`, so the failure event says the same thing.
|
|
88
|
-
* 2. `spec.harness` — the prepared-cache step's `harness` field — when it is
|
|
89
|
-
* a non-empty string. An empty string counts as absent, matching the
|
|
90
|
-
* child.
|
|
91
|
-
* 3. Otherwise the child took the first REGISTERED adapter. This process
|
|
92
|
-
* cannot name it: the Shift is a neutral dispatcher and never imports the
|
|
93
|
-
* adapter composition root, so its own registry is empty and asking it
|
|
94
|
-
* would answer `undefined`. Report the placeholder instead.
|
|
95
|
-
*
|
|
96
|
-
* WHY THE ORDER MATTERS. It used to read `spec.harness ?? OWENLOOP_HARNESS`,
|
|
97
|
-
* which is the child's precedence INVERTED. An operator who pinned
|
|
98
|
-
* `OWENLOOP_HARNESS` on a shift whose cached step also named a harness got a
|
|
99
|
-
* failure event naming the harness that did NOT run — the single most
|
|
100
|
-
* misleading field in the record, since the harness is the first thing an
|
|
101
|
-
* operator reaches for when a worker dies.
|
|
102
|
-
*
|
|
103
|
-
* BEST-EFFORT IS DELIBERATE at rank 2. A modern agent order carries no
|
|
104
|
-
* `spec.harness` at all (the child reads the verified, order-pinned step), so
|
|
105
|
-
* rank 2 only ever fires on the legacy cache path. The alternative — the Shift
|
|
106
|
-
* verifying the order digest itself purely to label a failure — would duplicate
|
|
107
|
-
* the child's whole resolution for a diagnostic string.
|
|
108
|
-
*
|
|
109
|
-
* `env` is the environment the CHILD is spawned with (`plan.options.env`), not
|
|
110
|
-
* this process's — they differ, and the child's is the one that decided.
|
|
111
|
-
*/
|
|
112
|
-
export declare function reportedHarnessId(spec: Pick<SpawnSpec, 'harness'>, env: NodeJS.ProcessEnv): string;
|
|
113
71
|
/**
|
|
114
72
|
* The stdio topology of a detached worker.
|
|
115
73
|
*
|
|
@@ -158,11 +116,10 @@ export interface SpawnPlan {
|
|
|
158
116
|
* — is identical for both kinds, so an agent-run child is detached,
|
|
159
117
|
* stdio-ignored, and account-scoped exactly like an exec child.
|
|
160
118
|
*
|
|
161
|
-
* The Shift never emits `--harness`. A prepared-cache step is dispatch
|
|
162
|
-
* not an operator override; the `agent-run` child resolves
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* flag, so there is no legitimate CLI override for this seam to carry.
|
|
119
|
+
* The Shift never emits `--harness`. A prepared-cache step is dispatch
|
|
120
|
+
* metadata, not an operator override; the `agent-run` child resolves the
|
|
121
|
+
* selected crew-roster harness before its debug flag, verified runtime step,
|
|
122
|
+
* and registered default.
|
|
166
123
|
*
|
|
167
124
|
* `allowedWorkdirRoots` (trailing, for the same reason) rides the child's spawn
|
|
168
125
|
* env as `OWENLOOP_ALLOWED_WORKDIR_ROOTS`, a `:`-separated list — the same
|
|
@@ -180,7 +137,7 @@ export interface SpawnPlan {
|
|
|
180
137
|
* is pure, and `createDefaultSpawner` substitutes the descriptors. Omitted ⇒ no
|
|
181
138
|
* `logFile` key at all, and the plan is byte-identical to the pre-logging shape.
|
|
182
139
|
*/
|
|
183
|
-
export declare function buildSpawnPlan(spec: SpawnSpec, origin: string, account: string, binPath: string, execPath?: string, shiftId?: string, logDir?: string, allowedWorkdirRoots?: string[]): SpawnPlan;
|
|
140
|
+
export declare function buildSpawnPlan(spec: SpawnSpec, origin: string, account: string, binPath: string, execPath?: string, shiftId?: string, logDir?: string, allowedWorkdirRoots?: string[], serveCrews?: string[]): SpawnPlan;
|
|
184
141
|
/**
|
|
185
142
|
* The default detached spawner. Captures the resolved hub `origin`, the
|
|
186
143
|
* resolved `account`, the packaged bin path, and the dispatching Shift's
|
|
@@ -189,4 +146,4 @@ export declare function buildSpawnPlan(spec: SpawnSpec, origin: string, account:
|
|
|
189
146
|
* relying on `buildSpawnPlan`'s default) so `shiftId` — trailing after it
|
|
190
147
|
* — can be supplied positionally.
|
|
191
148
|
*/
|
|
192
|
-
export declare function createDefaultSpawner(origin: string, account: string, binPath?: string, shiftId?: string, onFailure?: WorkerFailureReporter, logging?: WorkerLogOptions, allowedWorkdirRoots?: string[]): Spawner;
|
|
149
|
+
export declare function createDefaultSpawner(origin: string, account: string, binPath?: string, shiftId?: string, onFailure?: WorkerFailureReporter, logging?: WorkerLogOptions, allowedWorkdirRoots?: string[], serveCrews?: string[]): Spawner;
|
|
@@ -63,48 +63,6 @@ function openWorkerLog(path, report) {
|
|
|
63
63
|
function err(e) {
|
|
64
64
|
return e instanceof Error ? e.message : String(e);
|
|
65
65
|
}
|
|
66
|
-
/**
|
|
67
|
-
* The harness id to REPORT on an agent-run worker failure — a best-effort
|
|
68
|
-
* mirror of the id the CHILD resolved, never an independent decision.
|
|
69
|
-
*
|
|
70
|
-
* It mirrors `resolveAdapter` in `roles/agent-run.ts`, minus the `--harness`
|
|
71
|
-
* rank the Shift never emits:
|
|
72
|
-
*
|
|
73
|
-
* 1. `OWENLOOP_HARNESS` when the variable is SET. Set-but-blank is not a
|
|
74
|
-
* fall-through: the child refuses that config outright and names it
|
|
75
|
-
* `<empty OWENLOOP_HARNESS>`, so the failure event says the same thing.
|
|
76
|
-
* 2. `spec.harness` — the prepared-cache step's `harness` field — when it is
|
|
77
|
-
* a non-empty string. An empty string counts as absent, matching the
|
|
78
|
-
* child.
|
|
79
|
-
* 3. Otherwise the child took the first REGISTERED adapter. This process
|
|
80
|
-
* cannot name it: the Shift is a neutral dispatcher and never imports the
|
|
81
|
-
* adapter composition root, so its own registry is empty and asking it
|
|
82
|
-
* would answer `undefined`. Report the placeholder instead.
|
|
83
|
-
*
|
|
84
|
-
* WHY THE ORDER MATTERS. It used to read `spec.harness ?? OWENLOOP_HARNESS`,
|
|
85
|
-
* which is the child's precedence INVERTED. An operator who pinned
|
|
86
|
-
* `OWENLOOP_HARNESS` on a shift whose cached step also named a harness got a
|
|
87
|
-
* failure event naming the harness that did NOT run — the single most
|
|
88
|
-
* misleading field in the record, since the harness is the first thing an
|
|
89
|
-
* operator reaches for when a worker dies.
|
|
90
|
-
*
|
|
91
|
-
* BEST-EFFORT IS DELIBERATE at rank 2. A modern agent order carries no
|
|
92
|
-
* `spec.harness` at all (the child reads the verified, order-pinned step), so
|
|
93
|
-
* rank 2 only ever fires on the legacy cache path. The alternative — the Shift
|
|
94
|
-
* verifying the order digest itself purely to label a failure — would duplicate
|
|
95
|
-
* the child's whole resolution for a diagnostic string.
|
|
96
|
-
*
|
|
97
|
-
* `env` is the environment the CHILD is spawned with (`plan.options.env`), not
|
|
98
|
-
* this process's — they differ, and the child's is the one that decided.
|
|
99
|
-
*/
|
|
100
|
-
export function reportedHarnessId(spec, env) {
|
|
101
|
-
const fromEnv = env['OWENLOOP_HARNESS'];
|
|
102
|
-
if (fromEnv !== undefined)
|
|
103
|
-
return fromEnv.trim() === '' ? '<empty OWENLOOP_HARNESS>' : fromEnv;
|
|
104
|
-
if (spec.harness !== undefined && spec.harness !== '')
|
|
105
|
-
return spec.harness;
|
|
106
|
-
return '<registered default>';
|
|
107
|
-
}
|
|
108
66
|
/**
|
|
109
67
|
* Build the argv + options for a detached
|
|
110
68
|
* `owenloop work exec <workflow>/<run> --origin <url>`. Pure — no spawn, no I/O — so
|
|
@@ -128,11 +86,10 @@ export function reportedHarnessId(spec, env) {
|
|
|
128
86
|
* — is identical for both kinds, so an agent-run child is detached,
|
|
129
87
|
* stdio-ignored, and account-scoped exactly like an exec child.
|
|
130
88
|
*
|
|
131
|
-
* The Shift never emits `--harness`. A prepared-cache step is dispatch
|
|
132
|
-
* not an operator override; the `agent-run` child resolves
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* flag, so there is no legitimate CLI override for this seam to carry.
|
|
89
|
+
* The Shift never emits `--harness`. A prepared-cache step is dispatch
|
|
90
|
+
* metadata, not an operator override; the `agent-run` child resolves the
|
|
91
|
+
* selected crew-roster harness before its debug flag, verified runtime step,
|
|
92
|
+
* and registered default.
|
|
136
93
|
*
|
|
137
94
|
* `allowedWorkdirRoots` (trailing, for the same reason) rides the child's spawn
|
|
138
95
|
* env as `OWENLOOP_ALLOWED_WORKDIR_ROOTS`, a `:`-separated list — the same
|
|
@@ -150,8 +107,28 @@ export function reportedHarnessId(spec, env) {
|
|
|
150
107
|
* is pure, and `createDefaultSpawner` substitutes the descriptors. Omitted ⇒ no
|
|
151
108
|
* `logFile` key at all, and the plan is byte-identical to the pre-logging shape.
|
|
152
109
|
*/
|
|
153
|
-
export function buildSpawnPlan(spec, origin, account, binPath, execPath = process.execPath, shiftId, logDir, allowedWorkdirRoots) {
|
|
110
|
+
export function buildSpawnPlan(spec, origin, account, binPath, execPath = process.execPath, shiftId, logDir, allowedWorkdirRoots, serveCrews) {
|
|
154
111
|
const role = spec.kind === 'agent-run' ? 'agent-run' : 'exec';
|
|
112
|
+
// `OWENLOOP_SERVE_CREWS` is Shift-owned routing plumbing, never ambient
|
|
113
|
+
// configuration. A child for --all must not inherit a stale named-crew list
|
|
114
|
+
// from the Shift process that launched it.
|
|
115
|
+
const env = { ...process.env };
|
|
116
|
+
delete env['OWENLOOP_SERVE_CREWS'];
|
|
117
|
+
env['OWENLOOP_ACCOUNT'] = account;
|
|
118
|
+
if (spec.startGate !== undefined)
|
|
119
|
+
env['OWENLOOP_START_GATE'] = spec.startGate;
|
|
120
|
+
if (spec.shiftName !== undefined && spec.shiftName !== '')
|
|
121
|
+
env['OWENLOOP_SHIFT_NAME'] = spec.shiftName;
|
|
122
|
+
if (spec.shiftOwner !== undefined && spec.shiftOwner !== '')
|
|
123
|
+
env['OWENLOOP_SHIFT_OWNER'] = spec.shiftOwner;
|
|
124
|
+
if (allowedWorkdirRoots !== undefined && allowedWorkdirRoots.length > 0) {
|
|
125
|
+
env['OWENLOOP_ALLOWED_WORKDIR_ROOTS'] = allowedWorkdirRoots.join(':');
|
|
126
|
+
}
|
|
127
|
+
// Shift-internal roster handoff only. It is deliberately not passed to the
|
|
128
|
+
// harness child and is absent for command workers.
|
|
129
|
+
if (role === 'agent-run' && serveCrews !== undefined && serveCrews.length > 0) {
|
|
130
|
+
env['OWENLOOP_SERVE_CREWS'] = serveCrews.join(',');
|
|
131
|
+
}
|
|
155
132
|
return {
|
|
156
133
|
command: execPath,
|
|
157
134
|
args: [
|
|
@@ -166,14 +143,7 @@ export function buildSpawnPlan(spec, origin, account, binPath, execPath = proces
|
|
|
166
143
|
options: {
|
|
167
144
|
detached: true,
|
|
168
145
|
stdio: ['ignore', 'ignore', 'ignore'],
|
|
169
|
-
env
|
|
170
|
-
...process.env,
|
|
171
|
-
OWENLOOP_ACCOUNT: account,
|
|
172
|
-
...(spec.startGate !== undefined ? { OWENLOOP_START_GATE: spec.startGate } : {}),
|
|
173
|
-
...(allowedWorkdirRoots !== undefined && allowedWorkdirRoots.length > 0
|
|
174
|
-
? { OWENLOOP_ALLOWED_WORKDIR_ROOTS: allowedWorkdirRoots.join(':') }
|
|
175
|
-
: {}),
|
|
176
|
-
},
|
|
146
|
+
env,
|
|
177
147
|
},
|
|
178
148
|
...(logDir !== undefined && logDir !== '' ? { logFile: runLogFile(logDir, spec.run) } : {}),
|
|
179
149
|
};
|
|
@@ -186,7 +156,7 @@ export function buildSpawnPlan(spec, origin, account, binPath, execPath = proces
|
|
|
186
156
|
* relying on `buildSpawnPlan`'s default) so `shiftId` — trailing after it
|
|
187
157
|
* — can be supplied positionally.
|
|
188
158
|
*/
|
|
189
|
-
export function createDefaultSpawner(origin, account, binPath = resolveOwenloopBin(), shiftId, onFailure, logging, allowedWorkdirRoots) {
|
|
159
|
+
export function createDefaultSpawner(origin, account, binPath = resolveOwenloopBin(), shiftId, onFailure, logging, allowedWorkdirRoots, serveCrews) {
|
|
190
160
|
// ONE report per shift, not one per dispatch. Every condition that stops a
|
|
191
161
|
// worker log from opening — a full disk, a read-only log directory, an
|
|
192
162
|
// operator deleting it underneath a running shift — PERSISTS across the
|
|
@@ -202,7 +172,7 @@ export function createDefaultSpawner(origin, account, binPath = resolveOwenloopB
|
|
|
202
172
|
logging?.err?.(line);
|
|
203
173
|
};
|
|
204
174
|
return (spec) => {
|
|
205
|
-
const plan = buildSpawnPlan(spec, origin, account, binPath, process.execPath, shiftId, logging?.dir, allowedWorkdirRoots);
|
|
175
|
+
const plan = buildSpawnPlan(spec, origin, account, binPath, process.execPath, shiftId, logging?.dir, allowedWorkdirRoots, serveCrews);
|
|
206
176
|
// Open the log ONCE and hand the SAME descriptor to slots 1 and 2. Opening
|
|
207
177
|
// it twice would create two independent file offsets, and the two streams
|
|
208
178
|
// would overwrite each other's bytes — silent corruption no unit test on the
|
|
@@ -236,7 +206,6 @@ export function createDefaultSpawner(origin, account, binPath = resolveOwenloopB
|
|
|
236
206
|
}
|
|
237
207
|
}
|
|
238
208
|
const kind = spec.kind === 'agent-run' ? 'agent-run' : 'exec';
|
|
239
|
-
const harness = kind === 'agent-run' ? reportedHarnessId(spec, plan.options.env) : undefined;
|
|
240
209
|
// This process is the executable Shift actually launched. The harness may
|
|
241
210
|
// start its own vendor process later, but reporting or guessing that
|
|
242
211
|
// executable here would couple the neutral dispatcher to one adapter.
|
|
@@ -266,7 +235,6 @@ export function createDefaultSpawner(origin, account, binPath = resolveOwenloopB
|
|
|
266
235
|
run: spec.run,
|
|
267
236
|
...(spec.step !== undefined ? { step: spec.step } : {}),
|
|
268
237
|
kind,
|
|
269
|
-
...(harness !== undefined ? { harness } : {}),
|
|
270
238
|
executable,
|
|
271
239
|
exitStatus,
|
|
272
240
|
signal,
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* exit 0) and on a dispatch error (to stderr, exit 2). Keeping it in one place
|
|
4
4
|
* means the help output and the error output never drift apart.
|
|
5
5
|
*/
|
|
6
|
-
export declare const USAGE = "owenloop work \u2014 execution-side CLI companion to owenloop\n\nUsage:\n owenloop work hold --order <id> [options] hold an order with a heartbeating lease\n owenloop work exec <order-id> [options] run a command order in a self-leasing loop\n owenloop work agent-run <order-id> [options] host an agent order's step agent in a\n harness, in a self-leasing loop\n owenloop work prepare <workflow> [--origin <url>]\n fetch, cache & normalize step specs\n owenloop work lint <workflow-name | path> lint x.harness option bags in a def\n owenloop work sessions [--all] [--json] list this machine's recorded harness\n sessions and how to re-open them\n owenloop work release --session <id> [options] drain a session's held claims\n owenloop work settings print the resolved settings file\n owenloop work join <code> [--hub <origin>] [--as <account>]\n redeem a join code and store the Scoped\n Identity credential (one-time provisioning)\n\nOptions:\n -h, --help show this help and exit 0\n --version print the owenloop work version and exit 0\n\n root shift options (run as owenloop shift start <crew...> | --all):\n <crew...> serve only these crews (positional, space\n separated); or --all for every crew on the key\n --all serve every crew on the key\n --origin <url> hub origin (else settings.hubOrigin)\n --as <account> Scoped Identity credential account to read + hand\n to dispatched holds/execs (default 'default')\n --name <n> Shift name (default <hostname>/<cwd>)\n --cap <n> max in-flight exec children (default 3)\n --poll-interval <ms> wake poll cadence (default 5000)\n --once bootstrap wake + one sweep, then exit (demo/e2e)\n --max-agents <n> max in-flight agent-run children, separate from\n --cap (default 4; else settings.maxConcurrentAgents)\n --cache-dir/--state-dir <p> override the resolved dirs\n\n hold options:\n --order <workflow>/<run> the order to hold (or --order <run> --workflow)\n --workflow <wf> required when --order is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --as <account> Scoped Identity credential account (default\n 'default'; the shift stamps this into born-bound\n holds)\n --session <id> session-holder tag (else env OWENLOOP_SESSION;\n else an anon:<hostname>:<pid> fallback \u2014 a\n holder is always sent)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n --ignore-stdin don't final-breath on stdin EOF (detached use)\n --never-release another process holds the claim; stop without\n releasing it (agent-run spawns its --mcp child\n this way \u2014 see hold.ts HOLDER OF RECORD)\n --mcp run as a stdio-MCP work-holder: tools get_order /\n submit, lease kept warm underneath (mutually\n exclusive with --ignore-stdin \u2014 stdin is the\n transport)\n\n exec options (usually spawned by shift, not run by hand):\n <workflow>/<run> the command order to run (positional order-id;\n or a bare <run> plus --workflow <wf>)\n --workflow <wf> required when the order-id is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n\n agent-run options (spawned by the shift, not run by hand):\n <workflow>/<run> the agent order to host (positional order-id;\n or a bare <run> plus --workflow <wf>)\n --workflow <wf> required when the order-id is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --harness <id> which registered harness hosts the step agent\n (else env OWENLOOP_HARNESS, else the step def's\n 'harness' field, else the first registered one)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n --submit-grace <ms> after the turn ends, how long to keep asking the\n hub whether the agent's submit landed (default\n 15000). Task completion comes from the HUB, never\n from the harness stream.\n --confirm-interval <ms> poll cadence inside that grace (default 1000)\n\n release options:\n --session <id> session whose claims to drain (else env\n OWENLOOP_SESSION). Agent-held claims re-offer;\n exec-held claims are drain-exempt (B3).\n --origin <url> hub origin (else settings.hubOrigin)\n\n settings (no options in v1):\n prints the resolved settings file path, whether it exists, each known\n knob (hubOrigin, cacheDir, stateDir, dispatchCap, commandRouting,\n maxConcurrentAgents, workRoot, workRepo) with its value + provenance,\n and any unrecognized keys.\n settings.dispatchCap/stateDir are the lowest-precedence\n fallbacks for shift's --cap/--state-dir. NO secrets ever\n live in settings \u2014 credentials stay in owenloop's own store.\n\n sessions options:\n --all include 'dead' sessions (hidden by default \u2014\n a dead session can no longer be resumed)\n --json print the raw newest-per-step records, tokens\n included, instead of the table\n --cache-dir <p> override the resolved cache dir\n\n join options:\n --hub <origin> hub to redeem against (else settings.hubOrigin;\n one of the two is REQUIRED \u2014 the code never\n chooses the hub)\n --as <account> credential account to store under (default:\n the Scoped Identity name the hub returns)\n\n shift/hold/exec/prepare/release env:\n credentials come from owenloop's store \u2014 each role reads the\n agent:<account> slot for its origin (never the human slot); a\n missing slot refuses with a runnable 'owenloop login' command.\n OWENLOOP_ACCOUNT Scoped Identity account for exec/prepare/release\n (default 'default'; shift uses --as, and\n stamps it onto dispatched holds/execs)\n OWENLOOP_TOKEN dev-only bearer override \u2014 when set, used\n verbatim and the store + account are\n bypassed (NOT the primary path)\n OWENLOOP_CACHE_DIR cache root\n OWENLOOP_STATE_DIR shift in-flight state dir\n OWENLOOP_SHIFT_LOG_DIR dir for the shift's shift.log and each\n worker's <run>.log; below --log-dir, above\n settings.shiftLogDir, default the state dir\n OWENLOOP_SHIFT_LOG_MAX_AGE_MS\n how long a worker's <run>.log is kept, in ms;\n below --log-max-age, above\n settings.shiftLogMaxAgeMs, default 14 days.\n Worker logs only \u2014 shift.log is never reaped\n OWENLOOP_SESSION hold session-holder tag / release drain target\n OWENLOOP_SHIFT_ID dispatching Shift's self-declared id for\n hold/exec/agent-run's --shift (advisory\n only, never for auth/routing/dispatch)\n OWENLOOP_HARNESS agent-run harness id; below --harness, above\n the step def's 'harness' field\n OWENLOOP_WORK_ROOT root for per-RUN agent work dirs\n (<workRoot>/<workflow>/<run>); above\n settings.workRoot, default <cacheDir>/work.\n A hub-supplied OrderPacket.workdir still\n wins, and is never reaped.\n OWENLOOP_WORK_REPO local git repo to cut per-run work dirs from\n as worktrees instead of plain dirs; above\n settings.workRepo, default off\n\n Credentials / accounts:\n owenloop work's RUNTIME roles (shift/hold/exec/prepare/release) are READ-ONLY\n over owenloop's credential store \u2014 they never write credentials. Each\n role reads the agent:<account> slot for its origin (never the human\n slot); the account defaults to 'default'. 'owenloop work join' is the one\n deliberate provisioning-time writer: it stores the Scoped Identity token a hub\n redeem returns via owenloop's public storeCredential, once, at join time\n \u2014 not a runtime write.\n store / connect an account (run owenloop; owenloop work never writes it):\n owenloop login --hub <origin> --as agent:<account>\n (use --as agent for the default account)\n or provision a fresh box from a hub-issued join code:\n owenloop work join <code> --hub <origin>\n select an account at run time:\n --as <account> on shift / hold\n OWENLOOP_ACCOUNT on exec / prepare / release\n (shift resolves once and threads both channels)\n owenloop work does NOT list stored accounts \u2014 enumerating an origin's accounts\n is an owenloop-side capability; check owenloop for which slots are stored.\n\nExit codes:\n 0 success / help / version / lint clean or warnings-only\n 1 runtime failure (fetch/hub error, cache write) / lint found an error\n 2 usage error (unknown or missing role, missing required arg)\n 3 role not implemented yet (skeleton stub \u2014 lands in a later delivery)\n";
|
|
6
|
+
export declare const USAGE = "owenloop work \u2014 execution-side CLI companion to owenloop\n\nUsage:\n owenloop work hold --order <id> [options] hold an order with a heartbeating lease\n owenloop work exec <order-id> [options] run a command order in a self-leasing loop\n owenloop work agent-run <order-id> [options] host an agent order's step agent in a\n harness, in a self-leasing loop\n owenloop work prepare <workflow> [--origin <url>]\n fetch, cache & normalize step specs\n owenloop work lint <workflow-name | path> lint x.harness option bags in a def\n owenloop work sessions [--all] [--json] list this machine's recorded harness\n sessions and how to re-open them\n owenloop work approvals [--json] every tool call a worker is blocked on\n RIGHT NOW, waiting for a person\n owenloop work approvals approve|deny <wf>/<run> <tool-use-id> [--note <text>]\n answer one; the answer goes back to the\n still-blocked call, not to a later attempt\n owenloop work release --session <id> [options] drain a session's held claims\n owenloop work settings print the resolved settings file\n owenloop work join <code> [--hub <origin>] [--as <account>]\n redeem a join code and store the Scoped\n Identity credential (one-time provisioning)\n\nOptions:\n -h, --help show this help and exit 0\n --version print the owenloop work version and exit 0\n\n root shift options (run as owenloop shift start <crew...> | --all):\n <crew...> serve only these crews (positional, space\n separated); or --all for every crew on the key\n --all serve every crew on the key\n --origin <url> hub origin (else settings.hubOrigin)\n --as <account> Scoped Identity credential account to read + hand\n to dispatched holds/execs (default 'default')\n --name <n> Shift name (default <hostname>/<cwd>)\n --cap <n> max in-flight exec children (default 3)\n --poll-interval <ms> wake poll cadence (default 5000)\n --once bootstrap wake + one sweep, then exit (demo/e2e)\n --max-agents <n> max in-flight agent-run children, separate from\n --cap (default 4; else settings.maxConcurrentAgents)\n --cache-dir/--state-dir <p> override the resolved dirs\n\n hold options:\n --order <workflow>/<run> the order to hold (or --order <run> --workflow)\n --workflow <wf> required when --order is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --as <account> Scoped Identity credential account (default\n 'default'; the shift stamps this into born-bound\n holds)\n --session <id> session-holder tag (else env OWENLOOP_SESSION;\n else an anon:<hostname>:<pid> fallback \u2014 a\n holder is always sent)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n --ignore-stdin don't final-breath on stdin EOF (detached use)\n --never-release another process holds the claim; stop without\n releasing it (agent-run spawns its --mcp child\n this way \u2014 see hold.ts HOLDER OF RECORD)\n --mcp run as a stdio-MCP work-holder: tools get_order /\n submit, lease kept warm underneath (mutually\n exclusive with --ignore-stdin \u2014 stdin is the\n transport)\n\n exec options (usually spawned by shift, not run by hand):\n <workflow>/<run> the command order to run (positional order-id;\n or a bare <run> plus --workflow <wf>)\n --workflow <wf> required when the order-id is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n\n agent-run options (spawned by the shift, not run by hand):\n <workflow>/<run> the agent order to host (positional order-id;\n or a bare <run> plus --workflow <wf>)\n --workflow <wf> required when the order-id is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --harness <id> which registered harness hosts the step agent\n (below a selected roster candidate; else the\n step def's 'harness' field, then the first\n registered one)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n --submit-grace <ms> after the turn ends, how long to keep asking the\n hub whether the agent's submit landed (default\n 15000). Task completion comes from the HUB, never\n from the harness stream.\n --confirm-interval <ms> poll cadence inside that grace (default 1000)\n\n release options:\n --session <id> session whose claims to drain (else env\n OWENLOOP_SESSION). Agent-held claims re-offer;\n exec-held claims are drain-exempt (B3).\n --origin <url> hub origin (else settings.hubOrigin)\n\n settings (no options in v1):\n prints the resolved settings file path, whether it exists, each known\n knob (hubOrigin, cacheDir, stateDir, dispatchCap, commandRouting,\n maxConcurrentAgents, workRoot, workRepo) with its value + provenance,\n and any unrecognized keys.\n settings.dispatchCap/stateDir are the lowest-precedence\n fallbacks for shift's --cap/--state-dir. NO secrets ever\n live in settings \u2014 credentials stay in owenloop's own store.\n\n sessions options:\n --all include 'dead' sessions (hidden by default \u2014\n a dead session can no longer be resumed)\n --json print the raw newest-per-step records, tokens\n included, instead of the table\n --cache-dir <p> override the resolved cache dir\n\n join options:\n --hub <origin> hub to redeem against (else settings.hubOrigin;\n one of the two is REQUIRED \u2014 the code never\n chooses the hub)\n --as <account> credential account to store under (default:\n the Scoped Identity name the hub returns)\n\n shift/hold/exec/prepare/release env:\n credentials come from owenloop's store \u2014 each role reads the\n agent:<account> slot for its origin (never the human slot); a\n missing slot refuses with a runnable 'owenloop login' command.\n OWENLOOP_ACCOUNT Scoped Identity account for exec/prepare/release\n (default 'default'; shift uses --as, and\n stamps it onto dispatched holds/execs)\n OWENLOOP_TOKEN dev-only bearer override \u2014 when set, used\n verbatim and the store + account are\n bypassed (NOT the primary path)\n OWENLOOP_CACHE_DIR cache root\n OWENLOOP_STATE_DIR shift in-flight state dir\n OWENLOOP_SHIFT_LOG_DIR dir for the shift's shift.log and each\n worker's <run>.log; below --log-dir, above\n settings.shiftLogDir, default the state dir\n OWENLOOP_SHIFT_LOG_MAX_AGE_MS\n how long a worker's <run>.log is kept, in ms;\n below --log-max-age, above\n settings.shiftLogMaxAgeMs, default 14 days.\n Worker logs only \u2014 shift.log is never reaped\n OWENLOOP_SESSION hold session-holder tag / release drain target\n OWENLOOP_SHIFT_ID dispatching Shift's self-declared id for\n hold/exec/agent-run's --shift (advisory\n only, never for auth/routing/dispatch)\n OWENLOOP_WORK_ROOT root for per-RUN agent work dirs\n (<workRoot>/<workflow>/<run>); above\n settings.workRoot, default <cacheDir>/work.\n A hub-supplied OrderPacket.workdir still\n wins, and is never reaped.\n OWENLOOP_WORK_REPO local git repo to cut per-run work dirs from\n as worktrees instead of plain dirs; above\n settings.workRepo, default off\n\n Credentials / accounts:\n owenloop work's RUNTIME roles (shift/hold/exec/prepare/release) are READ-ONLY\n over owenloop's credential store \u2014 they never write credentials. Each\n role reads the agent:<account> slot for its origin (never the human\n slot); the account defaults to 'default'. 'owenloop work join' is the one\n deliberate provisioning-time writer: it stores the Scoped Identity token a hub\n redeem returns via owenloop's public storeCredential, once, at join time\n \u2014 not a runtime write.\n store / connect an account (run owenloop; owenloop work never writes it):\n owenloop login --hub <origin> --as agent:<account>\n (use --as agent for the default account)\n or provision a fresh box from a hub-issued join code:\n owenloop work join <code> --hub <origin>\n select an account at run time:\n --as <account> on shift / hold\n OWENLOOP_ACCOUNT on exec / prepare / release\n (shift resolves once and threads both channels)\n owenloop work does NOT list stored accounts \u2014 enumerating an origin's accounts\n is an owenloop-side capability; check owenloop for which slots are stored.\n\nExit codes:\n 0 success / help / version / lint clean or warnings-only\n 1 runtime failure (fetch/hub error, cache write) / lint found an error\n 2 usage error (unknown or missing role, missing required arg)\n 3 role not implemented yet (skeleton stub \u2014 lands in a later delivery)\n";
|
|
@@ -15,6 +15,11 @@ Usage:
|
|
|
15
15
|
owenloop work lint <workflow-name | path> lint x.harness option bags in a def
|
|
16
16
|
owenloop work sessions [--all] [--json] list this machine's recorded harness
|
|
17
17
|
sessions and how to re-open them
|
|
18
|
+
owenloop work approvals [--json] every tool call a worker is blocked on
|
|
19
|
+
RIGHT NOW, waiting for a person
|
|
20
|
+
owenloop work approvals approve|deny <wf>/<run> <tool-use-id> [--note <text>]
|
|
21
|
+
answer one; the answer goes back to the
|
|
22
|
+
still-blocked call, not to a later attempt
|
|
18
23
|
owenloop work release --session <id> [options] drain a session's held claims
|
|
19
24
|
owenloop work settings print the resolved settings file
|
|
20
25
|
owenloop work join <code> [--hub <origin>] [--as <account>]
|
|
@@ -81,8 +86,9 @@ Options:
|
|
|
81
86
|
--workflow <wf> required when the order-id is a bare run id
|
|
82
87
|
--origin <url> hub origin (else settings.hubOrigin)
|
|
83
88
|
--harness <id> which registered harness hosts the step agent
|
|
84
|
-
(
|
|
85
|
-
'harness' field,
|
|
89
|
+
(below a selected roster candidate; else the
|
|
90
|
+
step def's 'harness' field, then the first
|
|
91
|
+
registered one)
|
|
86
92
|
--shift <id> dispatching Shift's self-declared id (else
|
|
87
93
|
env OWENLOOP_SHIFT_ID); advisory only
|
|
88
94
|
--heartbeat-interval <ms> lease renew cadence (default 60000)
|
|
@@ -147,8 +153,6 @@ Options:
|
|
|
147
153
|
OWENLOOP_SHIFT_ID dispatching Shift's self-declared id for
|
|
148
154
|
hold/exec/agent-run's --shift (advisory
|
|
149
155
|
only, never for auth/routing/dispatch)
|
|
150
|
-
OWENLOOP_HARNESS agent-run harness id; below --harness, above
|
|
151
|
-
the step def's 'harness' field
|
|
152
156
|
OWENLOOP_WORK_ROOT root for per-RUN agent work dirs
|
|
153
157
|
(<workRoot>/<workflow>/<run>); above
|
|
154
158
|
settings.workRoot, default <cacheDir>/work.
|
|
@@ -62,6 +62,50 @@ export declare function capabilityName(capability: string): string;
|
|
|
62
62
|
* compose onto, and inventing a lone `:deep` would be meaningless.
|
|
63
63
|
*/
|
|
64
64
|
export declare function composeCapabilities(authored: readonly string[] | undefined, modifier: string | undefined): string[];
|
|
65
|
+
/**
|
|
66
|
+
* A reroute decision the caller has already made, keyed by the composed
|
|
67
|
+
* capability the engine would otherwise offer.
|
|
68
|
+
*
|
|
69
|
+
* `{ 'build:express': 'build:standard' }` means: when this offer composes to
|
|
70
|
+
* `build:express`, offer `build:standard` instead. The engine attaches no
|
|
71
|
+
* meaning to either side and performs no lookup — it substitutes the string it
|
|
72
|
+
* is handed, exactly like `matchModes`, and for the same reason: deciding a
|
|
73
|
+
* reroute requires reading `capability_routes`, which the pure engine has never
|
|
74
|
+
* seen.
|
|
75
|
+
*
|
|
76
|
+
* SINGLE HOP, BY CONTRACT. A rewrite target is never itself looked up in the
|
|
77
|
+
* map. A caller with a multi-step rule chain resolves the whole chain and hands
|
|
78
|
+
* the engine the final answer, so a cycle is impossible here rather than merely
|
|
79
|
+
* bounded.
|
|
80
|
+
*/
|
|
81
|
+
export type CapabilityRewrites = Readonly<Record<string, string>>;
|
|
82
|
+
/**
|
|
83
|
+
* Substitute a caller's reroute decisions into a composed offer.
|
|
84
|
+
*
|
|
85
|
+
* Returns the offer to use plus — only when something actually changed — the
|
|
86
|
+
* list it replaced. The two are kept as SEPARATE fields rather than folded into
|
|
87
|
+
* one, because a rerouted order has two different true answers to "which
|
|
88
|
+
* capability is this?": the one being served (`offered`, which is what a shift
|
|
89
|
+
* resolves its model against) and the one that was asked for (`reroutedFrom`,
|
|
90
|
+
* which is what an operator wrote in the def). Collapsing them would make an
|
|
91
|
+
* order's routing history unrecoverable.
|
|
92
|
+
*
|
|
93
|
+
* Duplicates are removed FROM A REWRITTEN OFFER: two authored capabilities may
|
|
94
|
+
* reroute onto the same target, and an offer listing it twice would
|
|
95
|
+
* double-count in nothing but would read as a mistake.
|
|
96
|
+
*
|
|
97
|
+
* An offer no rule touched is returned VERBATIM, duplicates included. A step
|
|
98
|
+
* may author `capabilities: ['a', 'a']` — `defs.ts` validates each entry but
|
|
99
|
+
* never checks for duplicates — and `composeCapabilities` preserves that
|
|
100
|
+
* multiplicity, so deduplicating an untouched offer would change the stamped
|
|
101
|
+
* `order.capabilities` for a caller that supplied no rewrites at all. Dedup is
|
|
102
|
+
* a consequence of rerouting, not a tidy-up applied on the way past: with no
|
|
103
|
+
* applicable rule, this function returns byte-for-byte what it was handed.
|
|
104
|
+
*/
|
|
105
|
+
export declare function applyCapabilityRewrites(offered: readonly string[], rewrites: CapabilityRewrites): {
|
|
106
|
+
offered: string[];
|
|
107
|
+
reroutedFrom?: string[];
|
|
108
|
+
};
|
|
65
109
|
/**
|
|
66
110
|
* The claim-side match: may a caller presenting `caller` claim a step offered
|
|
67
111
|
* on `offered`?
|
package/dist/src/capabilities.js
CHANGED
|
@@ -55,6 +55,44 @@ export function composeCapabilities(authored, modifier) {
|
|
|
55
55
|
return [...authored];
|
|
56
56
|
return authored.map((c) => `${c}${MODIFIER_SEPARATOR}${modifier}`);
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Substitute a caller's reroute decisions into a composed offer.
|
|
60
|
+
*
|
|
61
|
+
* Returns the offer to use plus — only when something actually changed — the
|
|
62
|
+
* list it replaced. The two are kept as SEPARATE fields rather than folded into
|
|
63
|
+
* one, because a rerouted order has two different true answers to "which
|
|
64
|
+
* capability is this?": the one being served (`offered`, which is what a shift
|
|
65
|
+
* resolves its model against) and the one that was asked for (`reroutedFrom`,
|
|
66
|
+
* which is what an operator wrote in the def). Collapsing them would make an
|
|
67
|
+
* order's routing history unrecoverable.
|
|
68
|
+
*
|
|
69
|
+
* Duplicates are removed FROM A REWRITTEN OFFER: two authored capabilities may
|
|
70
|
+
* reroute onto the same target, and an offer listing it twice would
|
|
71
|
+
* double-count in nothing but would read as a mistake.
|
|
72
|
+
*
|
|
73
|
+
* An offer no rule touched is returned VERBATIM, duplicates included. A step
|
|
74
|
+
* may author `capabilities: ['a', 'a']` — `defs.ts` validates each entry but
|
|
75
|
+
* never checks for duplicates — and `composeCapabilities` preserves that
|
|
76
|
+
* multiplicity, so deduplicating an untouched offer would change the stamped
|
|
77
|
+
* `order.capabilities` for a caller that supplied no rewrites at all. Dedup is
|
|
78
|
+
* a consequence of rerouting, not a tidy-up applied on the way past: with no
|
|
79
|
+
* applicable rule, this function returns byte-for-byte what it was handed.
|
|
80
|
+
*/
|
|
81
|
+
export function applyCapabilityRewrites(offered, rewrites) {
|
|
82
|
+
if (offered.length === 0)
|
|
83
|
+
return { offered: [] };
|
|
84
|
+
let changed = false;
|
|
85
|
+
const out = [];
|
|
86
|
+
for (const c of offered) {
|
|
87
|
+
const target = rewrites[c];
|
|
88
|
+
const next = target ?? c;
|
|
89
|
+
if (target !== undefined && target !== c)
|
|
90
|
+
changed = true;
|
|
91
|
+
if (!out.includes(next))
|
|
92
|
+
out.push(next);
|
|
93
|
+
}
|
|
94
|
+
return changed ? { offered: out, reroutedFrom: [...offered] } : { offered: [...offered] };
|
|
95
|
+
}
|
|
58
96
|
/** True when one caller capability satisfies one offered capability under `mode`. */
|
|
59
97
|
function matchesOne(offered, caller, mode) {
|
|
60
98
|
return mode === 'exact' ? caller === offered : capabilityName(caller) === capabilityName(offered);
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { PrincipalKeyManager } from './crypto/keys.ts';
|
|
|
37
37
|
import type { LineStream } from './mcp/server.ts';
|
|
38
38
|
import type { BundleIngestor, PreCommitVerifier } from './store/index.ts';
|
|
39
39
|
import type { AgentIdentitySummary, Keychain } from './hub.ts';
|
|
40
|
+
import '../packages/work/src/harnesses.ts';
|
|
40
41
|
export type { Keychain } from './hub.ts';
|
|
41
42
|
export type HarnessId = 'claude-code' | 'codex';
|
|
42
43
|
export interface CliIO {
|