@sjawhar/pi-envoy 9.7.0 → 10.0.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/README.md CHANGED
@@ -106,34 +106,68 @@ The extension registers no Dispatch tool. Agents reach Dispatch through the `dis
106
106
  their shell: `dispatch --help` lists its commands, `dispatch <command> --help` each one's flags and
107
107
  an example, and the `dispatch` skill teaches when to use each. The package ships `bin/dispatch`, a
108
108
  shim that runs the bundled `dist/dispatch.js` (built from `@legion/envoy-client`'s
109
- `bin/dispatch.ts`) with `bun`. At load the extension puts that `bin/` first on `PATH` and sets
110
- `DISPATCH_HOST=omp`; each session start, switch and branch sets `DISPATCH_SESSION_ID` to the
111
- session's id, so a command acts as the session whose shell ran it.
109
+ `bin/dispatch.ts`) with `bun`. At load the extension puts that `bin/` first on `PATH`, sets
110
+ `DISPATCH_HOST=omp` and hands the session's envoy.json on as `ENVOY_CONFIG_FILE`; each session
111
+ start, switch and branch sets `DISPATCH_SESSION_ID` to the session's id, so a command acts as the
112
+ session whose shell ran it and reads the file that session reads.
112
113
 
113
- Configure the shared `envoy.json` with:
114
+ A session reads one envoy.json, with a section for Dispatch and one for Envoy:
114
115
 
115
116
  ```json
116
117
  {
117
118
  "dispatch": {
118
119
  "enabled": true,
119
120
  "serverUrl": "https://dispatch.example",
120
- "token": "<agent-bearer-token>"
121
+ "token": "!secrets get DISPATCH_TOKEN"
122
+ },
123
+ "envoy": {
124
+ "enabled": true,
125
+ "url": "http://127.0.0.1:9020",
126
+ "natsUrls": ["nats://nats.internal.example:4222"],
127
+ "natsSeed": "!secrets get NATS_NKEY_SEED"
121
128
  }
122
129
  }
123
130
  ```
124
131
 
125
- The user file is `~/.config/opencode/envoy.json`; a
126
- `<cwd>/.opencode/envoy.json` file shallow-merges over it. A repository
127
- `dispatch.serverUrl` requires `dispatch.token` in that same repository file:
128
- it never combines with a user-file or process-environment credential. To
129
- override a repository endpoint for one process, set `DISPATCH_URL` together
130
- with `DISPATCH_TOKEN` or `DISPATCH_TOKEN_FILE`. `DISPATCH_TOKEN_FILE` (a path
131
- whose trimmed contents are the token — how the Legion daemon delivers it to a
132
- pane) wins over every other token source and never falls back when unreadable.
133
- Omitting `dispatch.serverUrl` while `dispatch.enabled` is true targets
134
- `http://localhost:8766`, the Go server's listen address. Invalid configuration,
135
- an invalid URL, or an empty token makes every `dispatch` command exit 2 naming the source of the
136
- error, and the extension reports it when the session starts.
132
+ An Oh My Pi profile (`OMP_PROFILE` other than `default`) reads `$PI_CODING_AGENT_DIR/envoy.json`;
133
+ any other session reads the file `ENVOY_CONFIG_FILE` names, else
134
+ `${XDG_CONFIG_HOME:-~/.config}/legion/envoy.json`. The session's `dispatch` command reads the file
135
+ the session chose, which the extension hands it in `ENVOY_CONFIG_FILE`. The `dispatch` section of a
136
+ `<cwd>/.envoy/envoy.json` merges over it: its server is used only with the token written beside it,
137
+ and its token only beside its own server. An `envoy` section there is not read, which the start
138
+ notice says, and a checkout's file that is not valid refuses Dispatch alone, and only while
139
+ `DISPATCH_URL` is unset. Each section is resolved on its own: `enabled: false` turns it off, and a
140
+ missing file contributes nothing, so each section is then on only when its variables name it. A
141
+ `token` or `natsSeed` starting with `!` is a command whose trimmed output is the value (10 s, its
142
+ exit status deciding; never run from a checkout's file). `DISPATCH_URL`, `DISPATCH_TOKEN_FILE`,
143
+ `DISPATCH_TOKEN`, `ENVOY_URL`, `ENVOY_NATS_URL`, `ENVOY_TOKEN_FILE`, `ENVOY_TOKEN`,
144
+ `NATS_NKEY_SEED_FILE` and `NATS_NKEY_SEED` each override their own field; a file's token goes with
145
+ `DISPATCH_URL` or `ENVOY_URL` only when it names the file's own server, and a file's seed with
146
+ `ENVOY_NATS_URL` only when it names the file's NATS servers, so another server needs its own token
147
+ or seed variable. `DISPATCH_TOKEN_FILE` (a path whose trimmed contents are the token — how the
148
+ Legion daemon delivers it to a pane) never falls back when unreadable. Omitting
149
+ `dispatch.serverUrl` while `dispatch.enabled` is true targets `http://localhost:8766`, the Go
150
+ server's listen address. With Envoy off the session has no Envoy tools and takes no inbound
151
+ messages; with Envoy on and no NATS server, or with its NATS seed refused (a seed that pairs with
152
+ other servers, a failing `natsSeed` command, a seed variable that cannot be read), it keeps the
153
+ tools and `/whoami`, takes no inbound messages, connects to no NATS server, and refuses
154
+ `envoy_subscribe` and the Legion role claim with `inbound messages are off for this session: <why>`,
155
+ the claim before any listener call, so a Legion process fails its boot rather than hold a role
156
+ whose tasks reach nobody. When a
157
+ section is off for a reason worth saying, the session says so once at its start:
158
+ `envoy: no envoy.json at <path>: Dispatch and Envoy are off`, the section's error, what a
159
+ checkout's file holds that is not read, or that inbound messages are off and why. Invalid configuration, an
160
+ invalid URL, or an empty token makes every `dispatch` command exit 2 naming the source of the error.
161
+
162
+ `~/.config/opencode/envoy.json` and a checkout's `.opencode/envoy.json` are not read. While the old
163
+ user file is there and the session's file is missing, Dispatch and Envoy stay off unless a variable
164
+ names one, and the start notice says the old file is not read and what to do: for
165
+ `~/.config/legion/envoy.json`,
166
+ `mkdir -p ~/.config/legion && mv ~/.config/opencode/envoy.json ~/.config/legion/`; for a profile's
167
+ own file, copy or link the old file to it, or write it; under a relocated `XDG_CONFIG_HOME`, only
168
+ that it is not read there. While a checkout has no `.envoy/envoy.json`, the start notice and the
169
+ `dispatch` command name the rename of its `.opencode/envoy.json`. A top-level `natsUrls` is
170
+ refused, naming `envoy.natsUrls`.
137
171
 
138
172
  A command that writes to an owner names either an issue (`--issue`, a native `KEY` or an external
139
173
  `owner/repo#n` reference) or an unlinked project document (`--project` plus `--artifact`). A Legion