owenloop 0.5.7 → 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.
Files changed (65) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +3 -6
  3. package/dist/packages/work/src/agent/capability-model.d.ts +64 -82
  4. package/dist/packages/work/src/agent/capability-model.js +94 -91
  5. package/dist/packages/work/src/agent/loop.d.ts +39 -25
  6. package/dist/packages/work/src/agent/loop.js +102 -50
  7. package/dist/packages/work/src/bundle/types.d.ts +3 -3
  8. package/dist/packages/work/src/exec/loop.js +37 -15
  9. package/dist/packages/work/src/harness/child-env.js +4 -5
  10. package/dist/packages/work/src/harness/codex.js +3 -4
  11. package/dist/packages/work/src/harness/session-store.d.ts +63 -3
  12. package/dist/packages/work/src/harness/session-store.js +104 -9
  13. package/dist/packages/work/src/hub/types.d.ts +3 -3
  14. package/dist/packages/work/src/roles/agent-run.js +48 -42
  15. package/dist/packages/work/src/roles/sessions.d.ts +3 -2
  16. package/dist/packages/work/src/roles/sessions.js +9 -2
  17. package/dist/packages/work/src/roles/settings.js +1 -1
  18. package/dist/packages/work/src/settings/roster.d.ts +21 -0
  19. package/dist/packages/work/src/settings/roster.js +80 -0
  20. package/dist/packages/work/src/settings/settings.d.ts +12 -24
  21. package/dist/packages/work/src/settings/settings.js +17 -35
  22. package/dist/packages/work/src/shift/runtime.js +2 -10
  23. package/dist/packages/work/src/shift/spawn.d.ts +6 -53
  24. package/dist/packages/work/src/shift/spawn.js +28 -66
  25. package/dist/packages/work/src/usage.d.ts +1 -1
  26. package/dist/packages/work/src/usage.js +3 -4
  27. package/dist/src/capabilities.d.ts +44 -0
  28. package/dist/src/capabilities.js +38 -0
  29. package/dist/src/cli.d.ts +1 -0
  30. package/dist/src/cli.js +460 -5
  31. package/dist/src/config-dir.d.ts +13 -18
  32. package/dist/src/config-dir.js +15 -23
  33. package/dist/src/credentials.d.ts +1 -1
  34. package/dist/src/credentials.js +1 -1
  35. package/dist/src/crypto/records.d.ts +1 -0
  36. package/dist/src/crypto/records.js +6 -0
  37. package/dist/src/crypto/trust-roots.d.ts +2 -2
  38. package/dist/src/crypto/trust-roots.js +2 -2
  39. package/dist/src/engine.d.ts +14 -0
  40. package/dist/src/engine.js +21 -13
  41. package/dist/src/global-config.d.ts +4 -7
  42. package/dist/src/global-config.js +4 -7
  43. package/dist/src/hub.d.ts +207 -5
  44. package/dist/src/hub.js +263 -3
  45. package/dist/src/index.d.ts +2 -2
  46. package/dist/src/index.js +1 -1
  47. package/dist/src/schemas/index.d.ts +8 -0
  48. package/dist/src/schemas/order.v1.schema.json +6 -1
  49. package/dist/src/store/pre-commit-verifier.js +1 -1
  50. package/dist/src/types.d.ts +24 -4
  51. package/dist/src/work-settings.d.ts +2 -4
  52. package/dist/src/work-settings.js +2 -4
  53. package/docs/agent-runner.md +2 -2
  54. package/docs/bundles.md +3 -1
  55. package/docs/cli.md +295 -101
  56. package/docs/crypto.md +14 -14
  57. package/docs/routing.md +607 -0
  58. package/docs/shift-logs.md +22 -6
  59. package/package.json +1 -1
  60. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
  61. package/plugins/claude-code/plugin/.mcp.json +1 -1
  62. package/plugins/claude-code/plugin/skills/author/SKILL.md +1 -2
  63. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
  64. package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
  65. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +1 -2
@@ -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 metadata,
132
- * not an operator override; the `agent-run` child resolves its authoritative
133
- * inputs in precedence order (`--harness`, `OWENLOOP_HARNESS`, verified runtime
134
- * step, registered default). The Shift command has no operator-facing harness
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,20 +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
- ...(spec.shiftName !== undefined && spec.shiftName !== ''
174
- ? { OWENLOOP_SHIFT_NAME: spec.shiftName }
175
- : {}),
176
- ...(spec.shiftOwner !== undefined && spec.shiftOwner !== ''
177
- ? { OWENLOOP_SHIFT_OWNER: spec.shiftOwner }
178
- : {}),
179
- ...(allowedWorkdirRoots !== undefined && allowedWorkdirRoots.length > 0
180
- ? { OWENLOOP_ALLOWED_WORKDIR_ROOTS: allowedWorkdirRoots.join(':') }
181
- : {}),
182
- },
146
+ env,
183
147
  },
184
148
  ...(logDir !== undefined && logDir !== '' ? { logFile: runLogFile(logDir, spec.run) } : {}),
185
149
  };
@@ -192,7 +156,7 @@ export function buildSpawnPlan(spec, origin, account, binPath, execPath = proces
192
156
  * relying on `buildSpawnPlan`'s default) so `shiftId` — trailing after it
193
157
  * — can be supplied positionally.
194
158
  */
195
- export function createDefaultSpawner(origin, account, binPath = resolveOwenloopBin(), shiftId, onFailure, logging, allowedWorkdirRoots) {
159
+ export function createDefaultSpawner(origin, account, binPath = resolveOwenloopBin(), shiftId, onFailure, logging, allowedWorkdirRoots, serveCrews) {
196
160
  // ONE report per shift, not one per dispatch. Every condition that stops a
197
161
  // worker log from opening — a full disk, a read-only log directory, an
198
162
  // operator deleting it underneath a running shift — PERSISTS across the
@@ -208,7 +172,7 @@ export function createDefaultSpawner(origin, account, binPath = resolveOwenloopB
208
172
  logging?.err?.(line);
209
173
  };
210
174
  return (spec) => {
211
- 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);
212
176
  // Open the log ONCE and hand the SAME descriptor to slots 1 and 2. Opening
213
177
  // it twice would create two independent file offsets, and the two streams
214
178
  // would overwrite each other's bytes — silent corruption no unit test on the
@@ -242,7 +206,6 @@ export function createDefaultSpawner(origin, account, binPath = resolveOwenloopB
242
206
  }
243
207
  }
244
208
  const kind = spec.kind === 'agent-run' ? 'agent-run' : 'exec';
245
- const harness = kind === 'agent-run' ? reportedHarnessId(spec, plan.options.env) : undefined;
246
209
  // This process is the executable Shift actually launched. The harness may
247
210
  // start its own vendor process later, but reporting or guessing that
248
211
  // executable here would couple the neutral dispatcher to one adapter.
@@ -272,7 +235,6 @@ export function createDefaultSpawner(origin, account, binPath = resolveOwenloopB
272
235
  run: spec.run,
273
236
  ...(spec.step !== undefined ? { step: spec.step } : {}),
274
237
  kind,
275
- ...(harness !== undefined ? { harness } : {}),
276
238
  executable,
277
239
  exitStatus,
278
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 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 (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";
@@ -86,8 +86,9 @@ Options:
86
86
  --workflow <wf> required when the order-id is a bare run id
87
87
  --origin <url> hub origin (else settings.hubOrigin)
88
88
  --harness <id> which registered harness hosts the step agent
89
- (else env OWENLOOP_HARNESS, else the step def's
90
- 'harness' field, else the first registered one)
89
+ (below a selected roster candidate; else the
90
+ step def's 'harness' field, then the first
91
+ registered one)
91
92
  --shift <id> dispatching Shift's self-declared id (else
92
93
  env OWENLOOP_SHIFT_ID); advisory only
93
94
  --heartbeat-interval <ms> lease renew cadence (default 60000)
@@ -152,8 +153,6 @@ Options:
152
153
  OWENLOOP_SHIFT_ID dispatching Shift's self-declared id for
153
154
  hold/exec/agent-run's --shift (advisory
154
155
  only, never for auth/routing/dispatch)
155
- OWENLOOP_HARNESS agent-run harness id; below --harness, above
156
- the step def's 'harness' field
157
156
  OWENLOOP_WORK_ROOT root for per-RUN agent work dirs
158
157
  (<workRoot>/<workflow>/<run>); above
159
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`?
@@ -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 {