opencode-ahp 0.1.5 → 0.1.7

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
@@ -50,16 +50,23 @@ In the Agents window, an `opencode` host with:
50
50
  `discard-changes` operation restores a file. Requires the location
51
51
  directory to be a git repository (otherwise the changesets are empty);
52
52
  opt out with `capabilities.changesets: false`.
53
- - **Terminals** — read-only `ahp-terminal:` channels rendered from
54
- `shell`-tool executions (`isPty: false`, completed-command output with
55
- exit codes): while a turn runs a foreground shell command, the terminal
56
- appears in the root catalog, streams
57
- `data` → `commandFinished` → `exited` to subscribers, and leaves the
58
- catalog at turn end (the channel state stays subscribable until the
59
- chat/session is removed). The terminals are renderings, not pty —
60
- `createTerminal`/`disposeTerminal` and client `terminal/*` actions get
61
- clean read-only errors. Opt out with
62
- `capabilities.terminals: false`.
53
+ - **Terminals** — two kinds, both in the root catalog:
54
+ - **Interactive pty shells** (`createTerminal`) — a real shell in a pty
55
+ (your `$SHELL`, default 80×24, the location's working directory):
56
+ client-chosen channel, `isPty: true`, input/resize drive the process,
57
+ `disposeTerminal` kills it. This is what makes a VS Code Agents-window
58
+ session usable — clicking it opens a working terminal.
59
+ - **Read-only renderings** of `shell`-tool executions
60
+ (`ahp-terminal:`, `isPty: false`, completed-command output with exit
61
+ codes): while a turn runs a foreground shell command, the terminal
62
+ appears in the root catalog, streams
63
+ `data` → `commandFinished` → `exited` to subscribers, and leaves the
64
+ catalog at turn end (the channel state stays subscribable until the
65
+ chat/session is removed). These are host-managed — `createTerminal`
66
+ can't target them and client `terminal/*` actions get clean
67
+ read-only errors.
68
+
69
+ Opt out of both with `capabilities.terminals: false`.
63
70
 
64
71
  ## Requirements
65
72
 
@@ -83,6 +90,13 @@ opencode plugin add opencode-ahp
83
90
  opencode plugin add github:mattzink/opencode-ahp
84
91
  ```
85
92
 
93
+ Installed copies don't auto-update. To update:
94
+
95
+ ```sh
96
+ opencode plugin update opencode-ahp
97
+ opencode service restart
98
+ ```
99
+
86
100
  **Dev (local checkout):**
87
101
 
88
102
  ```jsonc
@@ -104,20 +118,16 @@ Per-key resolution: the config entry's `options` ▸ an `options.jsonc`
104
118
  sibling of `src/index.ts` (checkouts only — copy
105
119
  [`options.example.jsonc`](options.example.jsonc)) ▸ built-in defaults.
106
120
 
121
+ [`options.example.jsonc`](options.example.jsonc) documents the full
122
+ option set — every key, its default, and what it does. A few of the
123
+ important ones:
124
+
107
125
  | Key | Default | Description |
108
126
  | --- | --- | --- |
109
- | `enabled` | `true` | Master switch; `false` → no listener, the plugin is fully inert |
110
- | `port` | `8765` | WS listen port |
111
- | `host` | `"127.0.0.1"` | Bind address; a **non-loopback bind requires an explicit `token`** (the listener refuses to start otherwise) |
112
- | `path` | `"/ahp"` | WS path — VS Code's URL carries it verbatim |
113
127
  | `token` | auto | Omit → generated on first start, persisted in opencode's plugin storage, printed once to the service log. Accepted via the `?token=` query param and `Authorization: Bearer <token>`. **Always enforced**, loopback or not |
114
- | `allowedOrigins` | `"*"` | `"*"` or an exact list, e.g. `["vscode://vscode"]`. The token is still always required regardless |
115
- | `tls` | `null` | `{ keyPath, certPath }` — native TLS termination → `wss://` (off-LAN transports, D3). PEM **file paths**; the port becomes TLS-only (plain-HTTP requests to it fail) and the health endpoint is then HTTPS: `curl -k https://…:8765/healthz`. A missing/unreadable file disables the AHP listener — the opencode server keeps running |
116
- | `healthPath` | `"/healthz"` | Health endpoint (no auth): `curl …:8765/healthz` → `ok` (over the same TLS termination when `tls` is set) |
117
- | `keepAlive` | `true` | Keep the opencode location loaded against its idle timeout (`experimental.location_idle_timeout`, default 60 min) by periodically touching an internal anchor session — with this on, **no `location_idle_timeout` config entry is needed**. The anchor (`opencode-ahp (keep-alive)`) is a real opencode session: it shows in the TUI session list but is hidden from AHP clients (opencode's plugin surface cannot archive it) |
118
- | `keepAliveIntervalMinutes` | `10` | Minutes between keep-alive touches; keep well below the effective idle timeout |
119
- | `replayWindow` | `1000` | Per-channel actions kept for reconnect replay; older gaps → fresh snapshot |
120
- | `capabilities` | `{ changesets: true, terminals: true, automations: false }` | Host-side switches — never advertise what we don't implement (in AHP 1.0.0 none of these is a wire field; discovery is the state's optionality). Set `changesets` to `false` to disable the diff channels (the session/chat snapshots then carry no changeset catalogues and changeset URIs resolve to nothing); set `terminals` to `false` to disable the synthetic shell-command terminal channels (no `root/terminals` list, `shell` calls open no `ahp-terminal:` channels) |
128
+ | `host` | `"127.0.0.1"` | Bind address; a **non-loopback bind requires an explicit `token`** (the listener refuses to start otherwise) |
129
+ | `port` | `8765` | WS listen port |
130
+ | `keepAlive` | `true` | Keep the opencode location loaded against its idle timeout by periodically touching an internal anchor session — with this on, **no `location_idle_timeout` config entry is needed**. See the example file for the anchor's visibility details |
121
131
 
122
132
  ## Remote access (local LAN)
123
133
 
@@ -250,6 +260,18 @@ node scripts/ahp-multi-chat.mjs --token <token> --base http://127.0.0.1:8765 --r
250
260
  NODE_TLS_REJECT_UNAUTHORIZED=0 node scripts/ahp-changesets.mjs --token <token> --base https://127.0.0.1:8765
251
261
  ```
252
262
 
263
+ ### Local environment (git-ignored)
264
+
265
+ `docs/local.md` is the designated place for each developer to keep
266
+ local development environment specifics — facts about their own machine
267
+ that never belong in the committed tree, such as LAN IPs and hostnames,
268
+ per-machine versions, the port and config location of a daily opencode
269
+ service, the current LAN test server token/URL, reference checkouts
270
+ (the opencode and AHP repos, the extracted VS Code AHP client
271
+ sources), and scratch roots. The file is git-ignored and optional: it
272
+ does not exist on machines that have never created it, and nothing in
273
+ this repo requires it.
274
+
253
275
  ## Publishing
254
276
 
255
277
  House pattern: push to `main` → CI (`typecheck` + `test`) → the publish
@@ -258,9 +280,6 @@ workflow computes the version as `<major>.<minor>.<run-number>` and
258
280
  repo secret is stored (one-time setup: npmjs.com → package → *Package
259
281
  settings* → *Trusted publishers* → this workflow).
260
282
 
261
- Installed copies don't auto-update: `opencode plugin update opencode-ahp`
262
- - `opencode service restart`.
263
-
264
283
  ## Documentation
265
284
 
266
285
  - [`docs/design.md`](docs/design.md) — architecture and wire-contract findings.
@@ -52,6 +52,16 @@
52
52
  // Global actions kept for reconnect replay; older gaps → fresh snapshot.
53
53
  // "replayWindow": 1000,
54
54
 
55
+ // Timestamped capture of the raw opencode event stream to the server
56
+ // log — one line per raw V2 event: `event ok` (mapped to the host),
57
+ // `event dropped (missing: <fields>)` (known type, unusable instance —
58
+ // or a malformed envelope), `event unimplemented` (no handler for the
59
+ // type) — with the raw `data` JSON (truncated to 300 chars). Off by
60
+ // default: a busy turn emits dozens of lines. The LAN test server
61
+ // script (scripts/ahp-server.mjs) enables it. Use it to attribute turn
62
+ // latency to host vs client vs model (design.md §8.1).
63
+ // "logEvents": true,
64
+
55
65
  // Host-side capability switches — never advertise what we don't
56
66
  // implement (in AHP 1.0.0 none of these is a wire field; discovery is
57
67
  // the state's optionality).
@@ -60,8 +70,10 @@
60
70
  // catalogues in the session/chat snapshots; changeset URIs resolve to
61
71
  // nothing). Changesets require the location directory to be a git
62
72
  // repository.
63
- // "terminals": false disables the synthetic shell-command terminal
64
- // channels (shell-tool calls open no ahp-terminal: channels and the
65
- // root state carries no terminals list).
73
+ // "terminals": false disables both terminal kinds: the synthetic
74
+ // shell-command terminal channels (shell-tool calls open no
75
+ // ahp-terminal: channels and the root state carries no terminals list)
76
+ // and the interactive pty shells (createTerminal/disposeTerminal
77
+ // answer not-found).
66
78
  // "capabilities": { "changesets": false, "terminals": false, "automations": false }
67
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-ahp",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "OpenCode V2 plugin: hosts Agent Host Protocol (AHP) 1.0.0 in-process so opencode is a native agent in the VS Code Agents window",
5
5
  "type": "module",
6
6
  "exports": {