Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pkgs/fleet/book/reference/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,24 @@ Prints all 16 kinds with their groups, seats, and enrolment notes as one JSON ob

```
fleet agent enroll --kind K --name N [--groups a,b] [--dry-run] [--profile PATH]
fleet agent enroll --kind K --name N --bootstrap TOKEN
```

| Flag | Argument | Default | Meaning |
| ----------- | -------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--kind` | `K` | required | One of the 16 kinds (see `kinds`). An unknown kind is a usage error listing all kinds, with "use generic for anything with a shell". |
| `--name` | `N` | required | The agent's name (its bridge mailbox name). The shared USAGE spells this `--name`; the domain help line abbreviates it as the enroll line's second value. |
| `--groups` | `a,b` | kind's built-in groups | Additional bridge groups; adds to the kind's groups, never replaces them. |
| `--dry-run` | — | off | Probe nothing and register nothing. |
| `--profile` | `PATH` | default profile path | Where to save the profile. |
| Flag | Argument | Default | Meaning |
| ------------- | -------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--kind` | `K` | required | One of the 16 kinds (see `kinds`). An unknown kind is a usage error listing all kinds, with "use generic for anything with a shell". |
| `--name` | `N` | required | The agent's name (its bridge mailbox name). The shared USAGE spells this `--name`; the domain help line abbreviates it as the enroll line's second value. |
| `--groups` | `a,b` | kind's built-in groups | Additional bridge groups; adds to the kind's groups, never replaces them. |
| `--dry-run` | — | off | Probe nothing and register nothing. |
| `--profile` | `PATH` | default profile path | Where to save the profile. |
| `--bootstrap` | `TOKEN` | — | Provision from the owner's single-use bootstrap token instead of the shared fleet token (binary seats only; never with `--dry-run` — the exchange burns the token). |

### Behaviour

Registers an agent and saves its profile. Flow: the kind is validated; `--groups` adds to the kind's built-in groups; for a binary/http seat the bridge leg is probed in **Register** mode — `bridge hello` with the name and groups, which is what actually registers the mailbox; connector kinds instead get the "attach the connector" instruction and a fixed channel address. The four legs are probed (see `doctor`) and the saved profile records agent, kind, groups, and leg state.

With `--bootstrap`, provisioning comes first: [`fleet bridge exchange`](bridge.md#fleet-bridge-exchange) trades the token — minted by the owner bound to this name, kind and groups — for the agent's own credentials, which land in the vault by name (`bridge.<agent>-fleet-token`, `bridge.<agent>-token`). The mint-bound groups replace the kind/`--groups` set (they are the truth a credentialed hello cannot change), the profile is saved early so the probe's hello resolves the new credential by its recorded name, and the profile records the credential **names** and the notes identity — never a value. For a `muse` seat whose mint carried a notes identity, enrolment also writes the wake hookup (the signal-poll detector under `~/hooks/scripts/` and the hook definition under `~/hooks/definitions/`, the hatch-personal `scripts/messages-hook/` pattern), so the agent is woken when a note lands. A refused exchange enrols nothing: no vault write, no profile, no hook.

The JSON answer carries: the profile, `registered` (true only when not a dry run _and_ the bridge leg answered), the legs, the **rungs** map, and seat-specific next-step lines — for a binary seat the run loop (`fleet agent next --agent <name>`, do the task, run its `then` lines, repeat while the run has budget) and the `fleet shell` line ("runs where builds belong; never build in a limited sandbox"); for an http seat the token-by-name note and the reference-client commands; for central, the `fleet bridge send --to <address> [--command]` lines.

### Exit codes
Expand Down
63 changes: 63 additions & 0 deletions pkgs/fleet/book/reference/bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Two token families, both resolved **by name** through fleet-secrets; values are
| --------------------------- | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------- |
| Owner token (central verbs) | `message-bridge.access-token` (renamable via `[bridge] owner_token_name`) | `send`, `agents`, `log` | `/api/<owner-token>/fleet/…` |
| Fleet token (agent verbs) | `message-bridge.fleet-token` | `hello`, `inbox`, `post`, `ack` — agent routes only; it cannot send commands | `/fleet/<fleet-token>/…` |
| Per-agent credential | `bridge.<agent>-fleet-token` (the name the agent profile records) | The same agent routes, as that one agent only; its groups are the ones bound when the owner minted its bootstrap token | `/fleet/<credential>/…` |
| Notes token (notes family) | `bridge.<agent>-token` (renamable via `[bridge] notes_token_name`) | `notes send`, `notes inbox`, `notes ack` for the token's class/name identity | `Authorization: Bearer` header on `/notes/…` |

Tokens travel **in the URL path**, so every error string is scrubbed of token values (`<token>`) before it is printed, and a 404 is reported as "a wrong token, an old bridge without fleet mailboxes, or a wrong URL". Plain `http` URLs are accepted only to this machine; anything else must be `https`, because tokens ride the path.

Expand Down Expand Up @@ -236,6 +238,8 @@ fleet bridge hello [--agent A] [--groups g1,g2]

Agent verb (fleet token). Registers / refreshes this agent and its groups — this is the registry write: the bridge's agent registry is exactly the set of agents that have said hello. Route: `POST /fleet/<fleet-token>/hello` with `{agent, groups}`.

Under a **per-agent credential** the hello only refreshes: the credential's groups were bound when the owner minted its bootstrap token and set by the exchange, and a credentialed hello (or inbox call) cannot change them — group membership drives `group:<name>` addressing, so it is not the caller's to reassign. The shared fleet token keeps caller-supplied groups.

### Exit codes

`0` ok · `2` usage · `3` transport or credentials · `4` the bridge refused the request.
Expand Down Expand Up @@ -342,6 +346,65 @@ $ fleet bridge ack --agent archer --up-to 412

Marks all of `archer`'s messages up to id 412 as read.

## fleet bridge exchange

```
fleet bridge exchange --agent A --bootstrap TOKEN
```

| Flag | Argument | Default | Meaning |
| ------------- | -------- | --------------------------------------------- | ----------------------------------------------------------------------- |
| `--agent` | `A` | `$FLEET_AGENT`, then `[bridge] agent` | The agent name the bootstrap token was minted for. |
| `--bootstrap` | `TOKEN` | required | The single-use bootstrap token the owner minted (console hand-off). |

### Behaviour

Provisioning verb (no stored token; the bootstrap token rides the request body and is scrubbed from every error). Trades the token at `POST /enroll/exchange` for the agent's own credentials — a per-agent fleet credential and, when the mint carried a notes identity, a notes token. The values come back exactly once and go straight into the vault through fleet-secrets' write path (Bitwarden, into the project named by `$FLEET_BWS_PROJECT_ID` or `[secrets] bws_project_id`) under `bridge.<agent>-fleet-token` and `bridge.<agent>-token`. The verb prints names and metadata only — never a value. A refused exchange (wrong, used, expired or revoked token, or a name that is not the minted name) stores nothing; if storing fails after a successful exchange, the error says so loudly, because the burned token cannot be replayed. `fleet agent enroll --bootstrap` runs this verb first, then enrols as usual.

### Exit codes

`0` ok · `2` usage · `3` transport, credentials or vault write · `4` the bridge refused the exchange.

### Example

```console
$ fleet bridge exchange --agent muse-9 --bootstrap <token from the console>
```

Stores `muse-9`'s credentials under `bridge.muse-9-fleet-token` and `bridge.muse-9-token` and prints the exchange's names and metadata.

## fleet bridge notes

```
fleet bridge notes send --to CLASS/NAME [--kind note|instruction] [--reply-to ID] <text | ->
fleet bridge notes inbox
fleet bridge notes ack (--up-to ID | ID...)
```

| Flag | Argument | Default | Meaning |
| -------------------------- | ----------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `--to` | `CLASS/NAME` | — | Recipient identity; a `*` segment wildcards (`muse/*`, `*/archer`, `*/*`). Required unless `--reply-to` is given. |
| `--kind` | `note\|instruction` | `note` | `instruction` makes the note a work item: it lands in the recipient's inbox **without a sender** (the bridge keeps the sender store-side). |
| `--reply-to` | `ID` | — | Answer a note in your own inbox. The reply is routed store-side to that note's real sender — including an instruction whose sender you cannot see — and may replace `--to`. |
| `--up-to` (ack) | `ID` | — | Acknowledge every note up to this id. Alternative to listing ids. |
| `ID...` (ack, positional) | ids | — | Acknowledge exactly these notes. |

### Behaviour

The class/name notes family, authenticated by the calling identity's own notes token as a `Bearer` header (routes `POST /notes/send`, `GET /notes/inbox`, `POST /notes/ack`). Inbox rows carry `kind` and `reply_to`; a plain note names its sender in `from`, an instruction's `from` is null. Replying to an instruction therefore needs nothing but its id: the replier never learns who sent it, and the reply still reaches them.

### Exit codes

`0` ok · `2` usage · `3` transport or credentials · `4` the bridge refused the request.

### Example

```console
$ fleet bridge notes send --reply-to 41 "check done, filed as task 23101"
```

Answers note 41 — even if it arrived as a sender-free instruction.

## fleet bridge health

```
Expand Down
2 changes: 2 additions & 0 deletions pkgs/fleet/book/reference/secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

The platform rule is that secrets are resolved by name through the fleet-secrets chain only; no domain shells out to `bws` or reads a token file on its own.

Writes exist at the same library level, for one flow: fleet-secrets' `BwsStore` stores a value under a name through `bws secret create` (replacing any existing secret of that name, then verifying by reading it back), into the Bitwarden project named by `$FLEET_BWS_PROJECT_ID` or `[secrets] bws_project_id`. Its only caller is [`fleet bridge exchange`](bridge.md#fleet-bridge-exchange), putting a freshly minted per-agent credential under its name during bootstrap enrolment. There is still no `fleet secrets` write verb, and the broker remains a read-through cache.

## The resolution chain (shared context)

`get` walks this chain in order:
Expand Down
Loading