owenloop 0.4.0 → 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 +45 -0
- package/README.md +98 -25
- 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/{add.d.ts → src/add.d.ts} +12 -40
- package/dist/{add.js → src/add.js} +11 -176
- package/dist/src/cli.d.ts +147 -0
- package/dist/{cli.js → src/cli.js} +1643 -353
- package/dist/src/credentials.d.ts +280 -0
- package/dist/src/credentials.js +697 -0
- package/dist/{defs.js → src/defs.js} +59 -36
- package/dist/{engine.d.ts → src/engine.d.ts} +8 -8
- package/dist/{engine.js → src/engine.js} +29 -20
- package/dist/{hub.d.ts → src/hub.d.ts} +330 -2
- package/dist/{hub.js → src/hub.js} +531 -1
- package/dist/{index.d.ts → src/index.d.ts} +3 -1
- package/dist/{index.js → src/index.js} +2 -1
- package/dist/src/lock.d.ts +80 -0
- package/dist/src/lock.js +217 -0
- package/dist/src/mcp/serve.d.ts +85 -0
- package/dist/src/mcp/serve.js +702 -0
- package/dist/src/mcp/server.d.ts +132 -0
- package/dist/src/mcp/server.js +327 -0
- package/dist/{model.d.ts → src/model.d.ts} +59 -4
- package/dist/{model.js → src/model.js} +149 -22
- package/dist/{types.d.ts → src/types.d.ts} +66 -24
- package/dist/{util.d.ts → src/util.d.ts} +25 -0
- package/dist/{util.js → src/util.js} +26 -0
- package/dist/src/work-settings.d.ts +57 -0
- package/dist/src/work-settings.js +84 -0
- package/docs/authoring.md +102 -53
- package/docs/cli.md +883 -29
- package/docs/design.md +119 -45
- package/docs/embedding.md +39 -14
- 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/cli.d.ts +0 -83
- /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/{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
|
@@ -163,7 +163,7 @@ export type Credential = {
|
|
|
163
163
|
* distinct entries that never collide, and neither does `agent:ci` with
|
|
164
164
|
* `agent:release`.
|
|
165
165
|
*
|
|
166
|
-
* The discriminator is an **account**, never a "
|
|
166
|
+
* The discriminator is an **account**, never a "capability" — capabilities are a different
|
|
167
167
|
* axis of the system and the word is reserved.
|
|
168
168
|
*/
|
|
169
169
|
export type CredentialSlotSelector = {
|
|
@@ -348,7 +348,7 @@ export type ReadStoredCredentialOpts = CredentialSlotSelector & {
|
|
|
348
348
|
/**
|
|
349
349
|
* Read the stored hub credential for `origin` **in the named slot** from the
|
|
350
350
|
* chosen backend ONLY — the supported, read-only programmatic surface
|
|
351
|
-
* (
|
|
351
|
+
* (owenloop's CredentialReader seam wires to this once released). Secret hygiene
|
|
352
352
|
* is unchanged: this function never logs or echoes the returned credential, and
|
|
353
353
|
* there is deliberately no write/delete companion on the public surface —
|
|
354
354
|
* `login` / `logout` remain the only way to store or remove a credential.
|
|
@@ -389,6 +389,38 @@ export type ReadStoredCredentialOpts = CredentialSlotSelector & {
|
|
|
389
389
|
* it has always been.
|
|
390
390
|
*/
|
|
391
391
|
export declare function readStoredCredential(origin: string, opts: ReadStoredCredentialOpts): Credential | null;
|
|
392
|
+
/**
|
|
393
|
+
* Enumerate the hub origins that have a usable `human` credential stored, or
|
|
394
|
+
* `null` when the active backend cannot be enumerated.
|
|
395
|
+
*
|
|
396
|
+
* Consumer: `owenloop mcp`'s origin inference (`resolveMcpOrigin` in
|
|
397
|
+
* `src/mcp/serve.ts`). When the host spawns the server with neither `--hub` nor
|
|
398
|
+
* `OWENLOOP_HUB`, the server tries to infer the single hub the user is logged
|
|
399
|
+
* in to. That inference is only sound on the FILE backend, which can list its
|
|
400
|
+
* `hubs` map; the keychain and external-command backends cannot enumerate:
|
|
401
|
+
*
|
|
402
|
+
* - **file** → the origins in `readCredentialFile(credentialFilePath(env)).hubs`
|
|
403
|
+
* whose `human` slot parses as a well-formed `Credential` (`parseCredential`).
|
|
404
|
+
* An origin present only under an `agent:<name>` slot is NOT returned — the
|
|
405
|
+
* control plane authenticates as the human.
|
|
406
|
+
* - **keychain** → `null`. The `Keychain` interface (get/set/delete by
|
|
407
|
+
* `(service, account)`) has no list operation — macOS `security` cannot
|
|
408
|
+
* enumerate the accounts under a service without a keychain-wide dump this
|
|
409
|
+
* module deliberately does not perform. There is no way to know which origins
|
|
410
|
+
* have entries, so it returns `null` ("cannot enumerate") rather than a
|
|
411
|
+
* misleading empty list.
|
|
412
|
+
* - **external** → `null`, for the same reason: the command answers a single
|
|
413
|
+
* `(origin, slot)` query; it has no listing contract.
|
|
414
|
+
*
|
|
415
|
+
* `null` (cannot enumerate), `[]` (nothing stored), and a length>1 result are
|
|
416
|
+
* all distinct signals the caller turns into tailored exit-2 messages — this
|
|
417
|
+
* function reports the fact, it never decides the outcome. It never logs or
|
|
418
|
+
* echoes any credential; only the origin KEYS (never secrets) are returned.
|
|
419
|
+
*
|
|
420
|
+
* `env`/`keychain` are threaded exactly as `readStoredCredential` threads them,
|
|
421
|
+
* so a caller passing a fixture `env` stays hermetic.
|
|
422
|
+
*/
|
|
423
|
+
export declare function listStoredHubOrigins(env: Record<string, string | undefined>, keychain?: Keychain): string[] | null;
|
|
392
424
|
/**
|
|
393
425
|
* `.owenloop/hub.json` — written by `connect`. Safe to commit: contains no
|
|
394
426
|
* secrets, only the bound hub origin. Purely a binding — `push` diffs against
|
|
@@ -506,6 +538,302 @@ export interface WhoamiIdentity {
|
|
|
506
538
|
}
|
|
507
539
|
/** Narrow a `GET /api/whoami` 200 body to its typed shape. Throws on a malformed body. */
|
|
508
540
|
export declare function asWhoami(body: unknown): WhoamiIdentity;
|
|
541
|
+
/**
|
|
542
|
+
* Success shape of `POST /api/mint_agent_token` — the fields a caller is allowed
|
|
543
|
+
* to keep. Deliberately a WHITELIST: the real 200 body also carries a `text`
|
|
544
|
+
* field whose value CONTAINS the one-time `olp_` plaintext token ("Store this
|
|
545
|
+
* secret now …\n<olp_…>"), so a caller must never spread the raw body — it must
|
|
546
|
+
* build its result from these named fields only.
|
|
547
|
+
*
|
|
548
|
+
* `token` is the plaintext secret. It rides this typed shape exactly ONE hop:
|
|
549
|
+
* from `asMintAgentTokenOk`'s caller into `storeCredential`. It is never logged,
|
|
550
|
+
* printed, or embedded in an error — see `mintAgentCredential` (credentials.ts)
|
|
551
|
+
* and the identity model's §6 "rule of gates".
|
|
552
|
+
*/
|
|
553
|
+
export interface MintAgentTokenOk {
|
|
554
|
+
/** Token id — a non-secret revocation handle, safe to print. */
|
|
555
|
+
id: string;
|
|
556
|
+
/** The one-time `olp_` plaintext. SECRET — store-only, never echoed. */
|
|
557
|
+
token: string;
|
|
558
|
+
/** The minted agent's id — a non-secret handle, safe to print. */
|
|
559
|
+
agentId: string;
|
|
560
|
+
/** Resolved crew NAMES the token was granted on — non-secret. */
|
|
561
|
+
crews: string[];
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Narrow a `POST /api/mint_agent_token` 200 body to its typed success shape,
|
|
565
|
+
* validating STRICTLY (mirrors `asWhoami`/`asCreateWorkflowOk`'s throw-on-
|
|
566
|
+
* malformed style): a 2xx is not enough — the identity fields must be present
|
|
567
|
+
* and well-typed, or the "success" is a malformed response and must be treated
|
|
568
|
+
* as a failure rather than silently coerced.
|
|
569
|
+
*
|
|
570
|
+
* **Token hygiene (load-bearing):** every error message names the offending
|
|
571
|
+
* FIELD only — it never echoes a field VALUE. A malformed body could still carry
|
|
572
|
+
* the `olp_` plaintext (in `text`, or in a mistyped `token`), so echoing values
|
|
573
|
+
* here would be the exact leak §6 forbids. `id`/`agentId` must be non-empty
|
|
574
|
+
* strings; `token` a non-empty string starting `olp_`; `crews` an array of
|
|
575
|
+
* strings (empty allowed defensively — the server always resolves at least one,
|
|
576
|
+
* but the client does not depend on that to stay leak-safe).
|
|
577
|
+
*/
|
|
578
|
+
export declare function asMintAgentTokenOk(body: unknown): MintAgentTokenOk;
|
|
579
|
+
/**
|
|
580
|
+
* One Scoped Identity as `GET /api/agent_identities` reports it — the fields the
|
|
581
|
+
* setup converger and the doctor probe consult. The row is non-secret: it names
|
|
582
|
+
* agents and their crews, never a token.
|
|
583
|
+
*
|
|
584
|
+
* `lastContactAt` is identity-level (overwritten on EVERY authenticated contact,
|
|
585
|
+
* `olp_` or `mcpat_`). `lastUsedAt` is the edge-computed max over the identity's
|
|
586
|
+
* `agent`-kind tokens INCLUDING revoked ones — it deliberately survives a rekey.
|
|
587
|
+
* Both are epoch-ms or `null`; the succession UI shows `max(non-null of the two)`
|
|
588
|
+
* (see `lastActiveMs`). `disabled` gates whether the identity is a live
|
|
589
|
+
* succession candidate.
|
|
590
|
+
*/
|
|
591
|
+
export interface AgentIdentitySummary {
|
|
592
|
+
id: string;
|
|
593
|
+
name: string;
|
|
594
|
+
disabled: boolean;
|
|
595
|
+
crews: string[];
|
|
596
|
+
lastContactAt: number | null;
|
|
597
|
+
lastUsedAt: number | null;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Narrow `GET /api/agent_identities`'s 200 body (`{identities: [...]}`) to a
|
|
601
|
+
* typed array. Throws on a malformed body (missing `identities` array, or a row
|
|
602
|
+
* missing `id`/`name`). Non-secret shape — the rows carry no token — so errors
|
|
603
|
+
* may name indices/fields freely. `lastContactAt`/`lastUsedAt` tolerate `null`
|
|
604
|
+
* or absence (→ `null`) but reject a present non-number; `crews` defaults to an
|
|
605
|
+
* empty array when absent, rejects a present non-array-of-strings; `disabled`
|
|
606
|
+
* defaults to `false`.
|
|
607
|
+
*/
|
|
608
|
+
export declare function asAgentIdentities(body: unknown): AgentIdentitySummary[];
|
|
609
|
+
/**
|
|
610
|
+
* One **capability route** as the hub reports it — an org-scoped row mapping a
|
|
611
|
+
* workflow-def `capabilities:` entry to a crew. Unrelated to `HubBinding` above, which
|
|
612
|
+
* is this project directory's route to a hub (`owenloop connect`); every
|
|
613
|
+
* symbol in this family is `CapabilityRoute`-prefixed to keep the two apart.
|
|
614
|
+
*
|
|
615
|
+
* One row is ONE `(capability, crew)` PAIR, and a capability may bind MANY crews — so a
|
|
616
|
+
* single capability appears as MANY rows and nothing may key a collection on `capability`.
|
|
617
|
+
*
|
|
618
|
+
* `crewName` is `string | null`. A `null` name IS the **dangling route** case:
|
|
619
|
+
* the bound crew row was deleted, so the hub has no name left to resolve
|
|
620
|
+
* (`manage-capability-routes.ts`'s `toWire`). A dangling route routes nothing and
|
|
621
|
+
* never widens access, and it is deliberately SURFACED rather than filtered out —
|
|
622
|
+
* seeing the row is exactly what tells an operator there is something to clean up.
|
|
623
|
+
*
|
|
624
|
+
* Non-secret: the row names a capability, a crew, and who created it — never a token.
|
|
625
|
+
*/
|
|
626
|
+
export interface CapabilityRouteWire {
|
|
627
|
+
capability: string;
|
|
628
|
+
crewId: string;
|
|
629
|
+
crewName: string | null;
|
|
630
|
+
createdBy: string;
|
|
631
|
+
createdAt: number;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* `POST /api/add_capability_route`'s 200 body, narrowed.
|
|
635
|
+
*
|
|
636
|
+
* NESTED exactly as the wire nests it: the row lives under `route`, while
|
|
637
|
+
* `alreadyRouted` and `routedCrewCount` live at the BODY's top level. A flat
|
|
638
|
+
* interface would blur where each field actually sits.
|
|
639
|
+
*
|
|
640
|
+
* - `alreadyRouted` — was this exact `(capability, crew)` pair already present? The add
|
|
641
|
+
* is ADDITIVE and idempotent per pair, so a repeat is a 200 no-op, not an
|
|
642
|
+
* error, and `route.createdBy`/`createdAt` then echo the ORIGINAL row.
|
|
643
|
+
* - `routedCrewCount` — how many **LIVE** crews the capability binds AFTER the write. A
|
|
644
|
+
* route whose crew row was deleted routes nothing and is not counted.
|
|
645
|
+
*/
|
|
646
|
+
export interface CapabilityRouteAddedWire {
|
|
647
|
+
route: CapabilityRouteWire;
|
|
648
|
+
alreadyRouted: boolean;
|
|
649
|
+
routedCrewCount: number;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Narrow `POST /api/add_capability_route`'s 200 body
|
|
653
|
+
* (`{ text, route, alreadyRouted, routedCrewCount }`). Throws on anything
|
|
654
|
+
* malformed, naming the offending FIELD only — same discipline as
|
|
655
|
+
* `asAgentIdentities`, so no body value is echoed.
|
|
656
|
+
*
|
|
657
|
+
* `route.crewName` is required to be a NON-NULL non-empty string here, on top
|
|
658
|
+
* of `asCapabilityRouteRow`'s lenient check. That is not a contradiction: an add
|
|
659
|
+
* resolves its crew BY NAME, so the crew is live by construction and a `null`
|
|
660
|
+
* name in THIS response is genuinely malformed — whereas a `null` name in a
|
|
661
|
+
* `capability_routes` row is the legitimate dangling-route case. Layering a
|
|
662
|
+
* call-site-specific check on top of the shared row call is the established
|
|
663
|
+
* shape in this family, not a new pattern.
|
|
664
|
+
*/
|
|
665
|
+
export declare function asCapabilityRouteAdded(body: unknown): CapabilityRouteAddedWire;
|
|
666
|
+
/**
|
|
667
|
+
* Narrow `POST /api/remove_capability_route`'s 200 body
|
|
668
|
+
* (`{ text, capability, crewId, removed, remainingCrewIds }`).
|
|
669
|
+
*
|
|
670
|
+
* `removed` must be a BOOLEAN — this guard is how the CLI proves the 2xx really
|
|
671
|
+
* was the remove verb's answer. BOTH boolean values are valid, deliberate hub
|
|
672
|
+
* responses:
|
|
673
|
+
* - `true` — the `(capability, crew)` pair was bound and is now removed;
|
|
674
|
+
* - `false` — the pair was never bound, so there was nothing to do. The hub
|
|
675
|
+
* answers this with a 200, never a 404 (the `removeCrewMember` `{existed}`
|
|
676
|
+
* house pattern), and that tolerance is what makes `capability unbind` idempotent.
|
|
677
|
+
*
|
|
678
|
+
* `crewId` is LENIENT (absent or `null` both yield `null`) because `null` is a
|
|
679
|
+
* real hub output, not a defect: `manage-capability-routes.ts` resolves it as
|
|
680
|
+
* `namedCrew?.id ?? thisCapabilityRows.find(...)?.crewId ?? null`, so it is `null`
|
|
681
|
+
* on exactly the tolerant `removed: false` path where the argument matched
|
|
682
|
+
* neither a live crew name nor one of this capability's own route rows. Requiring a
|
|
683
|
+
* non-empty string here would throw on a normal success.
|
|
684
|
+
*
|
|
685
|
+
* `remainingCrewIds` is deliberately NOT lenient — it must be PRESENT and an
|
|
686
|
+
* array of non-empty strings. The asymmetry is the point: for a nullable name,
|
|
687
|
+
* the lenient default (`null`) is the SAFE reading, but defaulting an absent
|
|
688
|
+
* `remainingCrewIds` to `[]` would assert "this capability is now PARKED" — the
|
|
689
|
+
* alarming reading, and exactly the signal an operator acts on — off a malformed
|
|
690
|
+
* body. It lists LIVE crews only, so `[]` genuinely means zero live routes
|
|
691
|
+
* remain (which can happen while a dangling row survives, since such a row routes
|
|
692
|
+
* nothing).
|
|
693
|
+
*
|
|
694
|
+
* The stdout shape built from this is documented in `docs/cli.md`'s
|
|
695
|
+
* "Printed JSON" table under capability routes.
|
|
696
|
+
*/
|
|
697
|
+
export declare function asCapabilityRouteRemoved(body: unknown): {
|
|
698
|
+
capability: string;
|
|
699
|
+
crewId: string | null;
|
|
700
|
+
removed: boolean;
|
|
701
|
+
remainingCrewIds: string[];
|
|
702
|
+
};
|
|
703
|
+
/**
|
|
704
|
+
* Narrow `GET /api/capability_routes`'s 200 body (`{ text, routes: [...] }`) to a
|
|
705
|
+
* typed array. An EMPTY array is valid — that is the "this org has no routes
|
|
706
|
+
* yet" case, not an error.
|
|
707
|
+
*
|
|
708
|
+
* Rows are plain `CapabilityRouteWire`, ONE per `(capability, crew)` pair ordered by
|
|
709
|
+
* `capability, crew_id`, so a capability bound to many crews yields MANY rows — the array
|
|
710
|
+
* is forwarded as-is and must never be collapsed into a per-capability map. A row
|
|
711
|
+
* whose `crewName` is `null` is a dangling route and is kept, not dropped.
|
|
712
|
+
*/
|
|
713
|
+
export declare function asCapabilityRoutes(body: unknown): CapabilityRouteWire[];
|
|
714
|
+
/**
|
|
715
|
+
* A **crew** as the hub reports it — an org-scoped queue that agent work is
|
|
716
|
+
* stamped to. `kind` is `'personal' | 'shared' | 'orphan'` on the wire, but is
|
|
717
|
+
* deliberately NOT narrowed to that union here: `'orphan'` is a real value
|
|
718
|
+
* `GET /api/crews` returns, and the hub verbs (`packages/hub-core/src/verbs/
|
|
719
|
+
* manage-crews.ts`) are the enforcement of record for the other two — the same
|
|
720
|
+
* stance `agent new` takes for `--crews`.
|
|
721
|
+
*/
|
|
722
|
+
export interface CrewWire {
|
|
723
|
+
id: string;
|
|
724
|
+
name: string;
|
|
725
|
+
kind: string;
|
|
726
|
+
ownerMemberId: string | null;
|
|
727
|
+
createdBy: string;
|
|
728
|
+
createdAt: number;
|
|
729
|
+
}
|
|
730
|
+
/** One membership row on a `CrewListingWire` — `principalKind` is `'member' | 'agent'` on the wire, forwarded verbatim. */
|
|
731
|
+
export interface CrewMemberWire {
|
|
732
|
+
principalKind: string;
|
|
733
|
+
principalId: string;
|
|
734
|
+
addedBy: string;
|
|
735
|
+
addedAt: number;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* `GET /api/crews`' per-crew listing — a `CrewWire` plus its members inline
|
|
739
|
+
* (one hop, no per-crew fan-out) plus a CLIENT-DERIVED `orphan` boolean. `orphan`
|
|
740
|
+
* never appears on the wire; `asCrews` computes it with the same rule as the
|
|
741
|
+
* hub's own `isOrphanCrew` (`manage-crews.ts:170-172`) so the CLI can mark the
|
|
742
|
+
* org's reserved `orphan:unrouted` crew instead of filtering it out — an
|
|
743
|
+
* operator has to be able to see where a deleted crew's work went.
|
|
744
|
+
*/
|
|
745
|
+
export interface CrewListingWire extends CrewWire {
|
|
746
|
+
orphan: boolean;
|
|
747
|
+
members: CrewMemberWire[];
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* `POST /api/delete_crew`'s 200 body. `deleted` is always present; the six
|
|
751
|
+
* transfer fields are OPTIONAL and, deliberately, absent (not `null`, not `0`)
|
|
752
|
+
* when nothing moved — see `asCrewDeleted`.
|
|
753
|
+
*/
|
|
754
|
+
export interface CrewDeletedWire {
|
|
755
|
+
crewId: string;
|
|
756
|
+
deleted: boolean;
|
|
757
|
+
membersRemoved?: number;
|
|
758
|
+
orphanCrewId?: string;
|
|
759
|
+
orphanCrewName?: string;
|
|
760
|
+
stampsTransferred?: number;
|
|
761
|
+
runsTransferred?: string[];
|
|
762
|
+
runningRunsTransferred?: string[];
|
|
763
|
+
}
|
|
764
|
+
/** `POST /api/remove_crew_member`'s 200 body — tolerant of a non-member, exactly like `asCapabilityRouteRemoved`'s `removed`. */
|
|
765
|
+
export interface CrewMemberRemovedWire {
|
|
766
|
+
crewId: string;
|
|
767
|
+
principalId: string;
|
|
768
|
+
removed: boolean;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Narrow `GET /api/crews`'s 200 body (`{ text, crews: [...] }`) to a typed
|
|
772
|
+
* array. An EMPTY array is valid (a brand-new org). `GET /api/crews`
|
|
773
|
+
* deliberately returns the org's reserved orphan crew when it exists — this
|
|
774
|
+
* never filters it out; instead every row gets a derived `orphan` boolean,
|
|
775
|
+
* always present (`true` or `false`), so a scripted consumer never branches on
|
|
776
|
+
* the key's existence.
|
|
777
|
+
*/
|
|
778
|
+
export declare function asCrews(body: unknown): CrewListingWire[];
|
|
779
|
+
/**
|
|
780
|
+
* Narrow `POST /api/create_crew`'s 200 body (`{ text, crew }`) to the typed
|
|
781
|
+
* row.
|
|
782
|
+
*/
|
|
783
|
+
export declare function asCrewCreated(body: unknown): CrewWire;
|
|
784
|
+
/**
|
|
785
|
+
* Narrow `POST /api/delete_crew`'s 200 body. `crewId` and `deleted` are always
|
|
786
|
+
* present (`deleted` is a genuine boolean — both values are valid, deliberate
|
|
787
|
+
* hub answers, exactly like `asCapabilityRouteRemoved`). Each of the six transfer
|
|
788
|
+
* fields is validated ONLY IF PRESENT and OMITTED from the returned object when
|
|
789
|
+
* absent — never defaulted to `0`, `null`, or `[]`. Absence is the hub's way of
|
|
790
|
+
* saying "nothing moved"; default-filling would assert a transfer that never
|
|
791
|
+
* happened. `runsTransferred`/`runningRunsTransferred` are ARRAYS OF IDS, not
|
|
792
|
+
* counts — `stampsTransferred`/`membersRemoved` are the counts.
|
|
793
|
+
*/
|
|
794
|
+
export declare function asCrewDeleted(body: unknown): CrewDeletedWire;
|
|
795
|
+
/** Narrow `POST /api/add_crew_member`'s 200 body (`{ text, member }`) to the typed row. */
|
|
796
|
+
export declare function asCrewMemberAdded(body: unknown): CrewMemberWire;
|
|
797
|
+
/**
|
|
798
|
+
* Narrow `POST /api/remove_crew_member`'s 200 body (`{ text, crewId,
|
|
799
|
+
* principalId, removed }`). `removed` must be a genuine boolean — both values
|
|
800
|
+
* are valid, deliberate hub answers: `false` means the principal was never a
|
|
801
|
+
* member (tolerant, a normal success), exactly like `asCapabilityRouteRemoved`.
|
|
802
|
+
*/
|
|
803
|
+
export declare function asCrewMemberRemoved(body: unknown): CrewMemberRemovedWire;
|
|
804
|
+
/**
|
|
805
|
+
* Success shape of `POST /api/rekey_agent_token` — the whitelist a caller may
|
|
806
|
+
* keep. Sibling of `MintAgentTokenOk`, and MUST stay a whitelist for the same
|
|
807
|
+
* reason: the real 200 body carries a `text` field whose value CONTAINS the new
|
|
808
|
+
* one-time `olp_` plaintext, so a caller must never spread the raw body.
|
|
809
|
+
*
|
|
810
|
+
* Rekey has NO `crews` field (re-keying preserves the agent's existing crew
|
|
811
|
+
* membership — the verb changes none), so `MintAgentTokenOk`/`asMintAgentTokenOk`
|
|
812
|
+
* cannot be reused. `scopes` and `revokedTokenIds` are non-secret handles.
|
|
813
|
+
*/
|
|
814
|
+
export interface RekeyAgentTokenOk {
|
|
815
|
+
/** New token id — a non-secret revocation handle, safe to print. */
|
|
816
|
+
id: string;
|
|
817
|
+
/** The new one-time `olp_` plaintext. SECRET — store-only, never echoed. */
|
|
818
|
+
token: string;
|
|
819
|
+
/** The rekeyed agent's id — a non-secret handle, safe to print. */
|
|
820
|
+
agentId: string;
|
|
821
|
+
/** Ids of the tokens this rekey revoked — non-secret. */
|
|
822
|
+
revokedTokenIds: string[];
|
|
823
|
+
/** The new token's scopes — non-secret. */
|
|
824
|
+
scopes: string[];
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Narrow a `POST /api/rekey_agent_token` 200 body to its typed success shape.
|
|
828
|
+
* Mirrors `asMintAgentTokenOk`'s discipline exactly: STRICT validation of the
|
|
829
|
+
* identity fields, and every error names the offending FIELD only — never a
|
|
830
|
+
* field VALUE — because a malformed body could still carry the `olp_` plaintext
|
|
831
|
+
* (in `text`, or a mistyped `token`), and echoing values would be the exact leak
|
|
832
|
+
* §6 forbids. `id`/`agentId` non-empty strings; `token` a non-empty string
|
|
833
|
+
* starting `olp_`; `revokedTokenIds`/`scopes` arrays of strings, each tolerated
|
|
834
|
+
* absent (→ empty array) but rejected if present-and-malformed.
|
|
835
|
+
*/
|
|
836
|
+
export declare function asRekeyAgentTokenOk(body: unknown): RekeyAgentTokenOk;
|
|
509
837
|
/**
|
|
510
838
|
* Parse `GET /api/workflows`'s body into a `name -> WorkflowSummary` map for
|
|
511
839
|
* `computeServerDiff`. Throws a descriptive error (the caller wraps it in a
|