owenloop 0.4.1 → 0.5.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/CHANGELOG.md +26 -0
- package/README.md +58 -31
- package/bin/owenloop.mjs +2 -2
- package/dist/packages/work/src/agent/brief.d.ts +172 -0
- package/dist/packages/work/src/agent/brief.js +193 -0
- package/dist/packages/work/src/agent/loop.d.ts +135 -0
- package/dist/packages/work/src/agent/loop.js +542 -0
- package/dist/packages/work/src/agent/workdir.d.ts +210 -0
- package/dist/packages/work/src/agent/workdir.js +319 -0
- package/dist/packages/work/src/bundle/cache.d.ts +90 -0
- package/dist/packages/work/src/bundle/cache.js +324 -0
- package/dist/packages/work/src/bundle/fetch.d.ts +85 -0
- package/dist/packages/work/src/bundle/fetch.js +325 -0
- package/dist/packages/work/src/bundle/types.d.ts +160 -0
- package/dist/packages/work/src/bundle/types.js +1 -0
- package/dist/packages/work/src/credentials/owenloop.d.ts +11 -0
- package/dist/packages/work/src/credentials/owenloop.js +28 -0
- package/dist/packages/work/src/credentials/reader.d.ts +36 -0
- package/dist/packages/work/src/credentials/reader.js +32 -0
- package/dist/packages/work/src/credentials/resolve.d.ts +19 -0
- package/dist/packages/work/src/credentials/resolve.js +56 -0
- package/dist/packages/work/src/exec/loop.d.ts +29 -0
- package/dist/packages/work/src/exec/loop.js +215 -0
- package/dist/packages/work/src/exec/receipt.d.ts +38 -0
- package/dist/packages/work/src/exec/receipt.js +21 -0
- package/dist/packages/work/src/exec/runner.d.ts +65 -0
- package/dist/packages/work/src/exec/runner.js +185 -0
- package/dist/packages/work/src/harness/child-env.d.ts +100 -0
- package/dist/packages/work/src/harness/child-env.js +127 -0
- package/dist/packages/work/src/harness/claude.d.ts +128 -0
- package/dist/packages/work/src/harness/claude.js +635 -0
- package/dist/packages/work/src/harness/codex.d.ts +110 -0
- package/dist/packages/work/src/harness/codex.js +896 -0
- package/dist/packages/work/src/harness/contract.d.ts +283 -0
- package/dist/packages/work/src/harness/contract.js +32 -0
- package/dist/packages/work/src/harness/fake.d.ts +59 -0
- package/dist/packages/work/src/harness/fake.js +90 -0
- package/dist/packages/work/src/harness/jsonrpc-stdio.d.ts +108 -0
- package/dist/packages/work/src/harness/jsonrpc-stdio.js +344 -0
- package/dist/packages/work/src/harness/permissions.d.ts +62 -0
- package/dist/packages/work/src/harness/permissions.js +93 -0
- package/dist/packages/work/src/harness/registry.d.ts +47 -0
- package/dist/packages/work/src/harness/registry.js +45 -0
- package/dist/packages/work/src/harness/session-store.d.ts +163 -0
- package/dist/packages/work/src/harness/session-store.js +319 -0
- package/dist/packages/work/src/harness/types.d.ts +29 -0
- package/dist/packages/work/src/harness/types.js +14 -0
- package/dist/packages/work/src/harnesses.d.ts +38 -0
- package/dist/packages/work/src/harnesses.js +38 -0
- package/dist/packages/work/src/hold/loop.d.ts +36 -0
- package/dist/packages/work/src/hold/loop.js +23 -0
- package/dist/packages/work/src/hold/mcp.d.ts +55 -0
- package/dist/packages/work/src/hold/mcp.js +149 -0
- package/dist/packages/work/src/hub/client.d.ts +22 -0
- package/dist/packages/work/src/hub/client.js +78 -0
- package/dist/packages/work/src/hub/types.d.ts +290 -0
- package/dist/packages/work/src/hub/types.js +28 -0
- package/dist/packages/work/src/lease/loop.d.ts +94 -0
- package/dist/packages/work/src/lease/loop.js +277 -0
- package/dist/packages/work/src/main.d.ts +1 -0
- package/dist/packages/work/src/main.js +48 -0
- package/dist/packages/work/src/mcp/server.d.ts +125 -0
- package/dist/packages/work/src/mcp/server.js +320 -0
- package/dist/packages/work/src/roles/agent-run.d.ts +118 -0
- package/dist/packages/work/src/roles/agent-run.js +447 -0
- package/dist/packages/work/src/roles/exec.d.ts +40 -0
- package/dist/packages/work/src/roles/exec.js +203 -0
- package/dist/packages/work/src/roles/hold.d.ts +68 -0
- package/dist/packages/work/src/roles/hold.js +324 -0
- package/dist/packages/work/src/roles/join.d.ts +18 -0
- package/dist/packages/work/src/roles/join.js +204 -0
- package/dist/packages/work/src/roles/lint.d.ts +59 -0
- package/dist/packages/work/src/roles/lint.js +200 -0
- package/dist/packages/work/src/roles/prepare.d.ts +1 -0
- package/dist/packages/work/src/roles/prepare.js +249 -0
- package/dist/packages/work/src/roles/release.d.ts +48 -0
- package/dist/packages/work/src/roles/release.js +137 -0
- package/dist/packages/work/src/roles/sessions.d.ts +61 -0
- package/dist/packages/work/src/roles/sessions.js +180 -0
- package/dist/packages/work/src/roles/settings.d.ts +6 -0
- package/dist/packages/work/src/roles/settings.js +66 -0
- package/dist/packages/work/src/roles/shift.d.ts +12 -0
- package/dist/packages/work/src/roles/shift.js +228 -0
- package/dist/packages/work/src/roles/signals.d.ts +55 -0
- package/dist/packages/work/src/roles/signals.js +62 -0
- package/dist/packages/work/src/settings/provision.d.ts +21 -0
- package/dist/packages/work/src/settings/provision.js +47 -0
- package/dist/packages/work/src/settings/settings.d.ts +120 -0
- package/dist/packages/work/src/settings/settings.js +116 -0
- package/dist/packages/work/src/shift/client.d.ts +24 -0
- package/dist/packages/work/src/shift/client.js +124 -0
- package/dist/packages/work/src/shift/loop.d.ts +120 -0
- package/dist/packages/work/src/shift/loop.js +468 -0
- package/dist/packages/work/src/shift/protocol.d.ts +91 -0
- package/dist/packages/work/src/shift/protocol.js +24 -0
- package/dist/packages/work/src/shift/routing.d.ts +35 -0
- package/dist/packages/work/src/shift/routing.js +50 -0
- package/dist/packages/work/src/shift/runtime.d.ts +43 -0
- package/dist/packages/work/src/shift/runtime.js +274 -0
- package/dist/packages/work/src/shift/server.d.ts +23 -0
- package/dist/packages/work/src/shift/server.js +716 -0
- package/dist/packages/work/src/shift/spawn.d.ts +86 -0
- package/dist/packages/work/src/shift/spawn.js +100 -0
- package/dist/packages/work/src/shift/state.d.ts +77 -0
- package/dist/packages/work/src/shift/state.js +162 -0
- package/dist/packages/work/src/usage.d.ts +6 -0
- package/dist/packages/work/src/usage.js +175 -0
- package/dist/{cli.d.ts → src/cli.d.ts} +18 -3
- package/dist/{cli.js → src/cli.js} +770 -114
- package/dist/{credentials.d.ts → src/credentials.d.ts} +18 -12
- package/dist/{credentials.js → src/credentials.js} +14 -12
- package/dist/{defs.js → src/defs.js} +36 -36
- package/dist/{engine.d.ts → src/engine.d.ts} +8 -8
- package/dist/{engine.js → src/engine.js} +14 -14
- package/dist/{hub.d.ts → src/hub.d.ts} +205 -10
- package/dist/{hub.js → src/hub.js} +370 -12
- package/dist/{index.d.ts → src/index.d.ts} +1 -1
- package/dist/{index.js → src/index.js} +1 -1
- package/dist/{mcp → src/mcp}/serve.d.ts +5 -4
- package/dist/{mcp → src/mcp}/serve.js +168 -31
- package/dist/{mcp → src/mcp}/server.d.ts +6 -9
- package/dist/{mcp → src/mcp}/server.js +6 -9
- package/dist/{model.js → src/model.js} +1 -1
- package/dist/{types.d.ts → src/types.d.ts} +18 -18
- package/dist/{util.d.ts → src/util.d.ts} +3 -2
- package/dist/{util.js → src/util.js} +3 -2
- package/dist/{owenwork.d.ts → src/work-settings.d.ts} +22 -22
- package/dist/{owenwork.js → src/work-settings.js} +27 -27
- package/docs/authoring.md +93 -53
- package/docs/cli.md +597 -76
- package/docs/design.md +33 -33
- package/docs/embedding.md +10 -9
- package/examples/workflows/{command-worker.yaml → command-executor.yaml} +15 -15
- package/examples/workflows/compile-dev-playbook.yaml +338 -0
- package/examples/workflows/judges/gate-sharpness.md +39 -0
- package/examples/workflows/judges/security.md +34 -0
- package/package.json +17 -8
- /package/dist/{add.d.ts → src/add.d.ts} +0 -0
- /package/dist/{add.js → src/add.js} +0 -0
- /package/dist/{defs.d.ts → src/defs.d.ts} +0 -0
- /package/dist/{factory.d.ts → src/factory.d.ts} +0 -0
- /package/dist/{factory.js → src/factory.js} +0 -0
- /package/dist/{lock.d.ts → src/lock.d.ts} +0 -0
- /package/dist/{lock.js → src/lock.js} +0 -0
- /package/dist/{model.d.ts → src/model.d.ts} +0 -0
- /package/dist/{paths.d.ts → src/paths.d.ts} +0 -0
- /package/dist/{paths.js → src/paths.js} +0 -0
- /package/dist/{schema.d.ts → src/schema.d.ts} +0 -0
- /package/dist/{schema.js → src/schema.js} +0 -0
- /package/dist/{store.d.ts → src/store.d.ts} +0 -0
- /package/dist/{store.js → src/store.js} +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
- /package/dist/{untar.d.ts → src/untar.d.ts} +0 -0
- /package/dist/{untar.js → src/untar.js} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Credential WRITE + OAuth refresh library surface.
|
|
3
3
|
*
|
|
4
4
|
* Extracted from `src/cli.ts` (where these were module-private) so external
|
|
5
|
-
* consumers — a future `owenloop mcp` stdio server, an `
|
|
5
|
+
* consumers — a future `owenloop mcp` stdio server, an `owenloop work join` command —
|
|
6
6
|
* can store credentials and keep an OAuth access token fresh without depending
|
|
7
7
|
* on the CLI module. The exported `storeCredential` / `deleteCredential` /
|
|
8
8
|
* `ensureFreshOAuth` are re-imported by `cli.ts`, so every existing subcommand
|
|
@@ -182,13 +182,19 @@ export interface MintAgentResult {
|
|
|
182
182
|
id: string;
|
|
183
183
|
/** The minted agent's id — a non-secret handle. */
|
|
184
184
|
agentId: string;
|
|
185
|
-
/** Resolved
|
|
186
|
-
|
|
185
|
+
/** Resolved crew NAMES from the server. */
|
|
186
|
+
crews: string[];
|
|
187
|
+
/**
|
|
188
|
+
* The minted token's scopes — the client-resolved request value (the H3 route
|
|
189
|
+
* requires non-empty scopes and honors them verbatim, so request == minted).
|
|
190
|
+
* Non-secret; lets callers print the truth instead of a hard-coded literal.
|
|
191
|
+
*/
|
|
192
|
+
scopes: string[];
|
|
187
193
|
/** Which local backend the token landed in. */
|
|
188
194
|
storage: 'keychain' | 'file';
|
|
189
195
|
}
|
|
190
196
|
/**
|
|
191
|
-
* Mint a new
|
|
197
|
+
* Mint a new Scoped Identity on `origin` as the human `cred` and persist the
|
|
192
198
|
* returned `olp_` token to slot `agent:<name>`. CLI-free (no `Args`, no exit
|
|
193
199
|
* codes — the caller maps failures to exit codes) so both `owenloop agent new`
|
|
194
200
|
* (O3) and `owenloop mcp`'s `create_agent` (O2) can reuse it.
|
|
@@ -209,12 +215,12 @@ export interface MintAgentResult {
|
|
|
209
215
|
* today; explicit for symmetry with the store/refresh signatures).
|
|
210
216
|
* @param params.scopes defaults to `['work']` — the H3 route REQUIRES a
|
|
211
217
|
* non-empty `scopes`; an empty list is server-refused.
|
|
212
|
-
* @param params.
|
|
213
|
-
* personal
|
|
218
|
+
* @param params.crews omitted when absent so the server defaults to the minter's
|
|
219
|
+
* personal crew (`crews: []` is server-refused with `crew_invalid`).
|
|
214
220
|
*/
|
|
215
221
|
export declare function mintAgentCredential(io: CredentialIO, origin: string, humanSlot: CredentialSlotSelector, cred: Credential, params: {
|
|
216
222
|
name: string;
|
|
217
|
-
|
|
223
|
+
crews?: string[];
|
|
218
224
|
scopes?: string[];
|
|
219
225
|
}): Promise<MintAgentResult>;
|
|
220
226
|
/**
|
|
@@ -224,8 +230,8 @@ export declare function mintAgentCredential(io: CredentialIO, origin: string, hu
|
|
|
224
230
|
*
|
|
225
231
|
* `revokedTokenIds` are the ids the rekey invalidated server-side — the OLD
|
|
226
232
|
* installation's credential(s). Their presence is the honest signal that any
|
|
227
|
-
* still-running copy of this agent elsewhere is now disconnected. No `
|
|
228
|
-
* field: rekey changes no
|
|
233
|
+
* still-running copy of this agent elsewhere is now disconnected. No `crews`
|
|
234
|
+
* field: rekey changes no crew membership.
|
|
229
235
|
*/
|
|
230
236
|
export interface RekeyAgentResult {
|
|
231
237
|
/** New token id — a non-secret revocation handle. */
|
|
@@ -240,14 +246,14 @@ export interface RekeyAgentResult {
|
|
|
240
246
|
storage: 'keychain' | 'file';
|
|
241
247
|
}
|
|
242
248
|
/**
|
|
243
|
-
* Re-key an EXISTING
|
|
249
|
+
* Re-key an EXISTING Scoped Identity on `origin` as the human `cred`: the hub
|
|
244
250
|
* mints a fresh `olp_` token for `agentId`, REVOKES the identity's current
|
|
245
251
|
* token(s), and this function persists the new token into the SAME
|
|
246
252
|
* `agent:<name>` slot — overwriting the old one. Sibling of
|
|
247
253
|
* `mintAgentCredential` with the identical §6 discipline; the only shape
|
|
248
254
|
* differences are the endpoint (`/api/rekey_agent_token`), the request body
|
|
249
|
-
* (`{agentId}` — no name/scopes/
|
|
250
|
-
* guard (`asRekeyAgentTokenOk` — no `
|
|
255
|
+
* (`{agentId}` — no name/scopes/crews; rekey preserves crews), and the response
|
|
256
|
+
* guard (`asRekeyAgentTokenOk` — no `crews` field).
|
|
251
257
|
*
|
|
252
258
|
* **The token NEVER leaves this function.** It flows exactly one hop —
|
|
253
259
|
* `asRekeyAgentTokenOk(body).token` → `storeCredential` — and is never returned,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Credential WRITE + OAuth refresh library surface.
|
|
3
3
|
*
|
|
4
4
|
* Extracted from `src/cli.ts` (where these were module-private) so external
|
|
5
|
-
* consumers — a future `owenloop mcp` stdio server, an `
|
|
5
|
+
* consumers — a future `owenloop mcp` stdio server, an `owenloop work join` command —
|
|
6
6
|
* can store credentials and keep an OAuth access token fresh without depending
|
|
7
7
|
* on the CLI module. The exported `storeCredential` / `deleteCredential` /
|
|
8
8
|
* `ensureFreshOAuth` are re-imported by `cli.ts`, so every existing subcommand
|
|
@@ -460,7 +460,7 @@ export async function refreshOAuth(io, origin, slot, cred, persist = true) {
|
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
/**
|
|
463
|
-
* Mint a new
|
|
463
|
+
* Mint a new Scoped Identity on `origin` as the human `cred` and persist the
|
|
464
464
|
* returned `olp_` token to slot `agent:<name>`. CLI-free (no `Args`, no exit
|
|
465
465
|
* codes — the caller maps failures to exit codes) so both `owenloop agent new`
|
|
466
466
|
* (O3) and `owenloop mcp`'s `create_agent` (O2) can reuse it.
|
|
@@ -481,8 +481,8 @@ export async function refreshOAuth(io, origin, slot, cred, persist = true) {
|
|
|
481
481
|
* today; explicit for symmetry with the store/refresh signatures).
|
|
482
482
|
* @param params.scopes defaults to `['work']` — the H3 route REQUIRES a
|
|
483
483
|
* non-empty `scopes`; an empty list is server-refused.
|
|
484
|
-
* @param params.
|
|
485
|
-
* personal
|
|
484
|
+
* @param params.crews omitted when absent so the server defaults to the minter's
|
|
485
|
+
* personal crew (`crews: []` is server-refused with `crew_invalid`).
|
|
486
486
|
*/
|
|
487
487
|
export async function mintAgentCredential(io, origin, humanSlot, cred, params) {
|
|
488
488
|
// 1. Validate the agent name before any I/O. The client regex is byte-identical
|
|
@@ -508,12 +508,12 @@ export async function mintAgentCredential(io, origin, humanSlot, cred, params) {
|
|
|
508
508
|
'Content-Type': 'application/json',
|
|
509
509
|
Accept: 'application/json',
|
|
510
510
|
},
|
|
511
|
-
// `
|
|
511
|
+
// `crews` omitted entirely when absent (server default = personal crew);
|
|
512
512
|
// never sent as `[]` (server-refused).
|
|
513
513
|
body: JSON.stringify({
|
|
514
514
|
name: params.name,
|
|
515
515
|
scopes,
|
|
516
|
-
...(params.
|
|
516
|
+
...(params.crews !== undefined ? { crews: params.crews } : {}),
|
|
517
517
|
}),
|
|
518
518
|
});
|
|
519
519
|
// 4 + 5. POST; on a 401 with an oauth credential, refresh once and retry once —
|
|
@@ -530,7 +530,7 @@ export async function mintAgentCredential(io, origin, humanSlot, cred, params) {
|
|
|
530
530
|
throw new CliError('credential rejected by the hub — run `owenloop login`');
|
|
531
531
|
}
|
|
532
532
|
// 6. Any other non-2xx: surface the hub's typed `message` VERBATIM (this is how
|
|
533
|
-
// H1's `agent name already taken: "…"`, `
|
|
533
|
+
// H1's `agent name already taken: "…"`, `crew_invalid`, `bad_request`, and
|
|
534
534
|
// `forbidden` all surface uniformly). Never include raw body text.
|
|
535
535
|
if (!res.ok) {
|
|
536
536
|
let message;
|
|
@@ -580,18 +580,20 @@ export async function mintAgentCredential(io, origin, humanSlot, cred, params) {
|
|
|
580
580
|
`The agent '${params.name}' now exists on the hub — recover via the console (Reconnect/re-key) ` +
|
|
581
581
|
`once storage works; re-running \`agent new ${params.name}\` will refuse the taken name`);
|
|
582
582
|
}
|
|
583
|
-
// 9. Return non-secret handles only — no token field exists to leak.
|
|
584
|
-
|
|
583
|
+
// 9. Return non-secret handles only — no token field exists to leak. `scopes`
|
|
584
|
+
// is the client-resolved request value (server honors it verbatim), not a
|
|
585
|
+
// server-body field — the mint response guard does not parse scopes.
|
|
586
|
+
return { id: ok.id, agentId: ok.agentId, crews: ok.crews, scopes, storage };
|
|
585
587
|
}
|
|
586
588
|
/**
|
|
587
|
-
* Re-key an EXISTING
|
|
589
|
+
* Re-key an EXISTING Scoped Identity on `origin` as the human `cred`: the hub
|
|
588
590
|
* mints a fresh `olp_` token for `agentId`, REVOKES the identity's current
|
|
589
591
|
* token(s), and this function persists the new token into the SAME
|
|
590
592
|
* `agent:<name>` slot — overwriting the old one. Sibling of
|
|
591
593
|
* `mintAgentCredential` with the identical §6 discipline; the only shape
|
|
592
594
|
* differences are the endpoint (`/api/rekey_agent_token`), the request body
|
|
593
|
-
* (`{agentId}` — no name/scopes/
|
|
594
|
-
* guard (`asRekeyAgentTokenOk` — no `
|
|
595
|
+
* (`{agentId}` — no name/scopes/crews; rekey preserves crews), and the response
|
|
596
|
+
* guard (`asRekeyAgentTokenOk` — no `crews` field).
|
|
595
597
|
*
|
|
596
598
|
* **The token NEVER leaves this function.** It flows exactly one hop —
|
|
597
599
|
* `asRekeyAgentTokenOk(body).token` → `storeCredential` — and is never returned,
|
|
@@ -35,13 +35,13 @@ const RAW_PRODUCE_KEYS = ['name', 'schema', 'judges', 'maxAttempts', 'maxSchemaF
|
|
|
35
35
|
* fields, so it gets its own allowlist rather than folding into
|
|
36
36
|
* RAW_PRODUCE_KEYS (§27 unknown-key rejection). */
|
|
37
37
|
const RAW_GROUP_KEYS = ['group', 'mode', 'of'];
|
|
38
|
-
const RAW_JUDGE_KEYS = ['name', 'body', 'bodyFile', 'model', 'inputs', 'cadence', 'maxRunsPerDay', '
|
|
38
|
+
const RAW_JUDGE_KEYS = ['name', 'body', 'bodyFile', 'model', 'inputs', 'cadence', 'maxRunsPerDay', 'executor', 'command', 'spec'];
|
|
39
39
|
/** Keys valid on a normal (non-calls:, non-include:) step entry. */
|
|
40
40
|
const RAW_STEP_KEYS = [
|
|
41
41
|
'name', 'consumes', 'produces', 'generates', 'invalidates', 'cadence',
|
|
42
42
|
'maxRunsPerDay', 'parallel', 'maxAttempts', 'maxSchemaFailures', 'model',
|
|
43
43
|
'workdir', 'terminal', 'effect', 'on', 'idleAfter', 'body', 'bodyFile',
|
|
44
|
-
'calls', 'reapTtl', '
|
|
44
|
+
'calls', 'reapTtl', 'capabilities', 'maxLease', 'x', 'executor', 'command', 'spec',
|
|
45
45
|
];
|
|
46
46
|
/** Keys valid on a calls: step entry — a DIFFERENT (smaller) shape than RawStep;
|
|
47
47
|
* the `calls:` key is what routes an entry here instead of RAW_STEP_KEYS. */
|
|
@@ -49,7 +49,7 @@ const RAW_CALLS_KEYS = ['name', 'calls', 'inputs', 'produces'];
|
|
|
49
49
|
/** Keys valid on an include: directive entry — the `include:` key is the
|
|
50
50
|
* discriminator that routes an entry here instead of RAW_STEP_KEYS/RAW_CALLS_KEYS. */
|
|
51
51
|
const RAW_INCLUDE_KEYS = ['include', 'as', 'inputs'];
|
|
52
|
-
const RAW_DEF_KEYS = ['name', 'title', 'description', 'inputs', 'steps', 'outputs', 'invariants', 'engine', 'x', '
|
|
52
|
+
const RAW_DEF_KEYS = ['name', 'title', 'description', 'inputs', 'steps', 'outputs', 'invariants', 'engine', 'x', 'executors'];
|
|
53
53
|
// ---- defaults ----------------------------------------------------------------
|
|
54
54
|
const DEFAULTS = {
|
|
55
55
|
cadence: '0s',
|
|
@@ -263,8 +263,8 @@ function parseJudges(v, ctx, baseDir) {
|
|
|
263
263
|
if (raw.maxRunsPerDay !== undefined) {
|
|
264
264
|
judge.maxRunsPerDay = asNumber(raw.maxRunsPerDay, DEFAULTS.maxRunsPerDay, `judge '${name}'.maxRunsPerDay`);
|
|
265
265
|
}
|
|
266
|
-
if (raw.
|
|
267
|
-
judge.
|
|
266
|
+
if (raw.executor !== undefined)
|
|
267
|
+
judge.executor = asString(raw.executor, `judge '${name}'.executor`);
|
|
268
268
|
if (raw.command !== undefined)
|
|
269
269
|
judge.command = asString(raw.command, `judge '${name}'.command`);
|
|
270
270
|
if (raw.spec !== undefined)
|
|
@@ -574,8 +574,8 @@ export function buildDef(raw, source, baseDir) {
|
|
|
574
574
|
}
|
|
575
575
|
if (r.x !== undefined)
|
|
576
576
|
def.x = asExtension(r.x, `workflow '${name}'.x`);
|
|
577
|
-
if (r.
|
|
578
|
-
def.
|
|
577
|
+
if (r.executors !== undefined)
|
|
578
|
+
def.executors = asStringArray(r.executors, `workflow '${name}'.executors`);
|
|
579
579
|
return def;
|
|
580
580
|
}
|
|
581
581
|
// ---- Mode 1 expand helpers (M1-EXPAND) ----------------------------------------
|
|
@@ -780,8 +780,8 @@ function synthesizeJudgeSteps(producerStepName, pat, producerConsumeStems) {
|
|
|
780
780
|
};
|
|
781
781
|
if (j.model !== undefined)
|
|
782
782
|
step.model = j.model;
|
|
783
|
-
if (j.
|
|
784
|
-
step.
|
|
783
|
+
if (j.executor !== undefined)
|
|
784
|
+
step.executor = j.executor;
|
|
785
785
|
if (j.command !== undefined)
|
|
786
786
|
step.command = j.command;
|
|
787
787
|
if (j.spec !== undefined)
|
|
@@ -879,8 +879,8 @@ function buildStep(rl, i, baseDir) {
|
|
|
879
879
|
step.workdir = asString(rl.workdir, `step '${name}'.workdir`);
|
|
880
880
|
if (rl.model !== undefined)
|
|
881
881
|
step.model = asString(rl.model, `step '${name}'.model`);
|
|
882
|
-
if (rl.
|
|
883
|
-
step.
|
|
882
|
+
if (rl.executor !== undefined)
|
|
883
|
+
step.executor = asString(rl.executor, `step '${name}'.executor`);
|
|
884
884
|
if (rl.command !== undefined)
|
|
885
885
|
step.command = asString(rl.command, `step '${name}'.command`);
|
|
886
886
|
if (rl.spec !== undefined)
|
|
@@ -929,12 +929,12 @@ function buildStep(rl, i, baseDir) {
|
|
|
929
929
|
const reapTtlStr = asString(rl.reapTtl, `step '${name}'.reapTtl`);
|
|
930
930
|
step.reapTtlMs = parseDurationMs(reapTtlStr);
|
|
931
931
|
}
|
|
932
|
-
// A2: opaque routing
|
|
932
|
+
// A2: opaque routing capabilities. Empty list normalizes to absent (claimable by
|
|
933
933
|
// any caller), mirroring the groups.length > 0 pattern below.
|
|
934
|
-
if (rl.
|
|
935
|
-
const ls = asStringArray(rl.
|
|
934
|
+
if (rl.capabilities !== undefined) {
|
|
935
|
+
const ls = asStringArray(rl.capabilities, `step '${name}'.capabilities`);
|
|
936
936
|
if (ls.length > 0)
|
|
937
|
-
step.
|
|
937
|
+
step.capabilities = ls;
|
|
938
938
|
}
|
|
939
939
|
// A3: per-step max total lease lifetime (duration string, same as reapTtl).
|
|
940
940
|
if (rl.maxLease !== undefined) {
|
|
@@ -1098,40 +1098,40 @@ export function validateDef(def) {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
|
-
// W1-VALIDATE:
|
|
1102
|
-
// Only two hard requirements; any other
|
|
1101
|
+
// W1-VALIDATE: executor:/command: shape rules (declarative executor dispatch).
|
|
1102
|
+
// Only two hard requirements; any other executor value is fully opaque.
|
|
1103
1103
|
for (const l of def.steps) {
|
|
1104
|
-
const
|
|
1105
|
-
// Deliberately `l.
|
|
1106
|
-
// `(l.
|
|
1104
|
+
const executor = l.executor ?? 'agent';
|
|
1105
|
+
// Deliberately `l.executor === 'agent'` (explicit opt-in), NOT
|
|
1106
|
+
// `(l.executor ?? 'agent') === 'agent'` — that stricter form would also
|
|
1107
1107
|
// catch every default-agent step that already gets away with an empty
|
|
1108
1108
|
// body today (e.g. calls:-adjacent or generator-only fixtures), breaking
|
|
1109
|
-
// existing defs that never write `
|
|
1110
|
-
// an EXPLICIT `
|
|
1111
|
-
// unaffected while still catching "someone opted into the agent
|
|
1109
|
+
// existing defs that never write `executor:` at all. Scoping the check to
|
|
1110
|
+
// an EXPLICIT `executor: agent` keeps every pre-existing def byte-for-byte
|
|
1111
|
+
// unaffected while still catching "someone opted into the agent executor
|
|
1112
1112
|
// type and forgot a body".
|
|
1113
|
-
if (l.
|
|
1114
|
-
errors.push(`step '${l.name}' has
|
|
1113
|
+
if (l.executor === 'agent' && l.body.trim() === '') {
|
|
1114
|
+
errors.push(`step '${l.name}' has executor 'agent' but no body: (an agent step needs a prompt)`);
|
|
1115
1115
|
}
|
|
1116
|
-
else if (
|
|
1116
|
+
else if (executor === 'command') {
|
|
1117
1117
|
if (l.command === undefined) {
|
|
1118
|
-
errors.push(`step '${l.name}' has
|
|
1118
|
+
errors.push(`step '${l.name}' has executor 'command' but no command:`);
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
|
-
// any other
|
|
1121
|
+
// any other executor value: opaque, no body/command requirement
|
|
1122
1122
|
}
|
|
1123
|
-
// W1-VALIDATE:
|
|
1124
|
-
// per-step `
|
|
1123
|
+
// W1-VALIDATE: executors: def-level allow-list typo guard. Applied AFTER the
|
|
1124
|
+
// per-step `executor` default (?? 'agent') — a def declaring `executors:
|
|
1125
1125
|
// [command]` (deliberately excluding 'agent') still fails a step that omits
|
|
1126
|
-
// `
|
|
1126
|
+
// `executor:` entirely, since its effective executor is 'agent'. This is
|
|
1127
1127
|
// intended (the list is exhaustive once declared), documented in
|
|
1128
1128
|
// docs/authoring.md.
|
|
1129
|
-
if (def.
|
|
1130
|
-
const allowed = new Set(def.
|
|
1129
|
+
if (def.executors && def.executors.length > 0) {
|
|
1130
|
+
const allowed = new Set(def.executors);
|
|
1131
1131
|
for (const l of def.steps) {
|
|
1132
|
-
const
|
|
1133
|
-
if (!allowed.has(
|
|
1134
|
-
errors.push(`step '${l.name}' has
|
|
1132
|
+
const executor = l.executor ?? 'agent';
|
|
1133
|
+
if (!allowed.has(executor)) {
|
|
1134
|
+
errors.push(`step '${l.name}' has executor '${executor}' but workflow '${def.name}'.executors does not list it`);
|
|
1135
1135
|
}
|
|
1136
1136
|
}
|
|
1137
1137
|
}
|
|
@@ -45,11 +45,11 @@ export declare class SchemaRefusalError extends Error {
|
|
|
45
45
|
* step's daily run allowance is exhausted (binding over parallel); `'parallel-cap'`
|
|
46
46
|
* — the step's concurrency cap is the binding constraint. Always emitted by
|
|
47
47
|
* `applySchedule` or `tick`; never alters which firings are selected or claimed.
|
|
48
|
-
* `'
|
|
49
|
-
* intersect the step's declared
|
|
50
|
-
*
|
|
48
|
+
* `'capability-mismatch'` (A2) — the tick caller passed a capability filter that does not
|
|
49
|
+
* intersect the step's declared capabilities, so a peer orchestrator serving other
|
|
50
|
+
* capabilities leaves it for the matching caller.
|
|
51
51
|
*/
|
|
52
|
-
export type DeferredReason = 'in-flight' | 'cadence' | 'daily-budget' | 'parallel-cap' | '
|
|
52
|
+
export type DeferredReason = 'in-flight' | 'cadence' | 'daily-budget' | 'parallel-cap' | 'capability-mismatch';
|
|
53
53
|
export interface DeferredFiring {
|
|
54
54
|
step: string;
|
|
55
55
|
key: string;
|
|
@@ -428,7 +428,7 @@ export declare class Engine {
|
|
|
428
428
|
tick(workflow: string, opts?: {
|
|
429
429
|
now?: number;
|
|
430
430
|
deep?: boolean;
|
|
431
|
-
|
|
431
|
+
capabilities?: string[];
|
|
432
432
|
}): TickResult;
|
|
433
433
|
/**
|
|
434
434
|
* The recursive tick worker. Runs this instance's own maintain → reap →
|
|
@@ -501,9 +501,9 @@ export declare class Engine {
|
|
|
501
501
|
private callsDescendTargets;
|
|
502
502
|
/**
|
|
503
503
|
* Per-step cadence + daily budget + parallel cap over the eligible firings.
|
|
504
|
-
* A2: `
|
|
505
|
-
* step whose own `
|
|
506
|
-
* intersect; a disjoint step's firings are deferred as `'
|
|
504
|
+
* A2: `capabilities` is the tick caller's optional claim filter — when non-empty, a
|
|
505
|
+
* step whose own `capabilities` are also non-empty is only schedulable when the two
|
|
506
|
+
* intersect; a disjoint step's firings are deferred as `'capability-mismatch'`.
|
|
507
507
|
* Filtering here (before cadence/budget) means a mismatched firing never
|
|
508
508
|
* consumes the caller's slots and never perturbs cadence math.
|
|
509
509
|
*/
|
|
@@ -806,7 +806,7 @@ export class Engine {
|
|
|
806
806
|
* only this instance's own orders. See `TickResult` for the fold semantics.
|
|
807
807
|
*/
|
|
808
808
|
tick(workflow, opts = {}) {
|
|
809
|
-
return this.tickInternal(workflow, opts.now ?? nowMs(), opts.deep ?? true, opts.
|
|
809
|
+
return this.tickInternal(workflow, opts.now ?? nowMs(), opts.deep ?? true, opts.capabilities ?? [], new Set(), 0);
|
|
810
810
|
}
|
|
811
811
|
/**
|
|
812
812
|
* The recursive tick worker. Runs this instance's own maintain → reap →
|
|
@@ -847,7 +847,7 @@ export class Engine {
|
|
|
847
847
|
* edge it hangs from. The guard is silent (no debt/reasons/events), mirroring
|
|
848
848
|
* the abort discipline of `publishCallsGreen`/`provisionCallsChild`.
|
|
849
849
|
*/
|
|
850
|
-
tickInternal(workflow, now, deep,
|
|
850
|
+
tickInternal(workflow, now, deep, capabilities, visited, depth, parentEdge) {
|
|
851
851
|
if (depth > this.maxCallDepth) {
|
|
852
852
|
throw new Error(`calls depth limit exceeded (maxCallDepth=${this.maxCallDepth}) ticking '${workflow}': `
|
|
853
853
|
+ `a calls: composition is deeper than the bound, which usually means a calls: cycle `
|
|
@@ -893,7 +893,7 @@ export class Engine {
|
|
|
893
893
|
// Compute time facts for idle eligibility (clock-read boundary).
|
|
894
894
|
const timeFacts = this.computeTimeFacts(def, workflow, arts, now);
|
|
895
895
|
const firings = eligibleFirings(def, arts, timeFacts);
|
|
896
|
-
const { selected, deferred } = this.applySchedule(workflow, def, firings, now,
|
|
896
|
+
const { selected, deferred } = this.applySchedule(workflow, def, firings, now, capabilities);
|
|
897
897
|
// Clear alarm_at for any idle firing that was selected (consume the alarm).
|
|
898
898
|
for (const f of selected) {
|
|
899
899
|
if (f.cause === 'idle') {
|
|
@@ -927,7 +927,7 @@ export class Engine {
|
|
|
927
927
|
// subtree — do not tick grandchildren off a frame that issued nothing.
|
|
928
928
|
if (deep && !staleEdge) {
|
|
929
929
|
for (const { step, child } of this.callsDescendTargets(workflow, def)) {
|
|
930
|
-
const cr = this.tickInternal(child.id, now, deep,
|
|
930
|
+
const cr = this.tickInternal(child.id, now, deep, capabilities, visited, depth + 1, {
|
|
931
931
|
parentWf: workflow,
|
|
932
932
|
step,
|
|
933
933
|
callsStem: step.produces[0].stem,
|
|
@@ -1001,13 +1001,13 @@ export class Engine {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
/**
|
|
1003
1003
|
* Per-step cadence + daily budget + parallel cap over the eligible firings.
|
|
1004
|
-
* A2: `
|
|
1005
|
-
* step whose own `
|
|
1006
|
-
* intersect; a disjoint step's firings are deferred as `'
|
|
1004
|
+
* A2: `capabilities` is the tick caller's optional claim filter — when non-empty, a
|
|
1005
|
+
* step whose own `capabilities` are also non-empty is only schedulable when the two
|
|
1006
|
+
* intersect; a disjoint step's firings are deferred as `'capability-mismatch'`.
|
|
1007
1007
|
* Filtering here (before cadence/budget) means a mismatched firing never
|
|
1008
1008
|
* consumes the caller's slots and never perturbs cadence math.
|
|
1009
1009
|
*/
|
|
1010
|
-
applySchedule(workflow, def, firings, now,
|
|
1010
|
+
applySchedule(workflow, def, firings, now, capabilities) {
|
|
1011
1011
|
const midnight = localMidnightMs(now);
|
|
1012
1012
|
const selected = [];
|
|
1013
1013
|
const deferred = [];
|
|
@@ -1021,13 +1021,13 @@ export class Engine {
|
|
|
1021
1021
|
const stepFirings = firings.filter((f) => f.step === step.name);
|
|
1022
1022
|
if (stepFirings.length === 0)
|
|
1023
1023
|
continue;
|
|
1024
|
-
// A2: caller
|
|
1024
|
+
// A2: caller capability filter vs. step capabilities. Both non-empty and disjoint →
|
|
1025
1025
|
// this caller must not claim the step; defer every firing and skip it
|
|
1026
1026
|
// before it touches cadence/budget/slot math.
|
|
1027
|
-
if (
|
|
1028
|
-
!step.
|
|
1027
|
+
if (capabilities.length > 0 && step.capabilities && step.capabilities.length > 0 &&
|
|
1028
|
+
!step.capabilities.some((l) => capabilities.includes(l))) {
|
|
1029
1029
|
for (const f of stepFirings)
|
|
1030
|
-
defer(f, '
|
|
1030
|
+
defer(f, 'capability-mismatch');
|
|
1031
1031
|
continue;
|
|
1032
1032
|
}
|
|
1033
1033
|
const latest = this.store.latestRun(workflow, step.name);
|
|
@@ -1187,8 +1187,8 @@ export class Engine {
|
|
|
1187
1187
|
order.workdir = step.workdir;
|
|
1188
1188
|
if (step.model !== undefined)
|
|
1189
1189
|
order.model = step.model;
|
|
1190
|
-
if (step.
|
|
1191
|
-
order.
|
|
1190
|
+
if (step.executor !== undefined)
|
|
1191
|
+
order.executor = step.executor;
|
|
1192
1192
|
if (step.command !== undefined)
|
|
1193
1193
|
order.command = step.command;
|
|
1194
1194
|
if (step.spec !== undefined)
|