Merge lane-chat: keep the lane's reviewed work
This commit is contained in:
@@ -224,16 +224,29 @@ traversal, absolute paths, symlink escapes and unknown runs/steps.
|
||||
- Do not invent artifact files or claim a stage produced one without the recorded
|
||||
evidence; the server observes the directory after the stage.
|
||||
|
||||
## Brokered OpenCode chat (unshipped)
|
||||
## Brokered OpenCode chat
|
||||
|
||||
The protocol declares the brokered `chat_*` surface (`chat_sessions`,
|
||||
`chat_create`, `chat_prompt`, `chat_messages`, `chat_interrupt`, `chat_permission`,
|
||||
`chat_reply`). The server dispatches `chat_sessions`, `chat_prompt`,
|
||||
`chat_messages`, `chat_interrupt` and `chat_reply`, answers the declared
|
||||
`chat_create` with an explicit protocol error because it is not yet brokered, and
|
||||
pushes `chat_event` frames derived from OpenCode's global `/api/event` firehose,
|
||||
with retained per-session/per-message state so a reconnecting client re-syncs
|
||||
instead of replaying deltas.
|
||||
pushes `chat_event` frames derived from OpenCode's global SSE firehose
|
||||
(`/event` on the native serve, `/api/event` on the V2 API), with retained
|
||||
per-session/per-message state so a reconnecting client re-syncs instead of
|
||||
replaying deltas.
|
||||
|
||||
At startup `cmd/pipelines-server` calls `opencode.OpenChat`, which detects the
|
||||
installed backend and opens exactly one owned `opencode serve` endpoint for it:
|
||||
the native wire for v1, the V2 API for the installed V2 CLI. Chat is enabled only
|
||||
when that connection carries a URL-bearing, SSE-capable event endpoint; otherwise
|
||||
chat stays disabled and every `chat_*` request is answered with a protocol error
|
||||
naming the missing configuration rather than hanging. Stage generation still
|
||||
reaches V2 through the `opencode api` CLI, so the owned serve process is chat's
|
||||
single transport and starts no process for stages. The adapter skips firehose
|
||||
events it does not surface before decoding their data, so an unrelated event
|
||||
whose `delta` has a different shape (`session.instructions.updated` carries an
|
||||
object) never fails the stream.
|
||||
|
||||
`chat_sessions` is brokered but restricted: OpenCode's `GET /api/session` lists
|
||||
every session on the machine, so the server filters it to the sessions recorded
|
||||
@@ -258,19 +271,34 @@ ends or the client disconnects.
|
||||
|
||||
The permission list and reply are implemented against the V2 HTTP API only: their
|
||||
field names match the service's `Permission.Request`/`Permission.Reply` schemas
|
||||
(verified against the installed service's `/openapi.json`), and the native v1 serve
|
||||
translation rejects them explicitly instead of guessing an endpoint. Because this
|
||||
build enables brokered chat only when the OpenCode connection exposes a URL-bearing
|
||||
SSE endpoint (the owned v1 serve process), the approval flow is not reachable on the
|
||||
backend that currently enables chat; on that backend the permission poller stops
|
||||
quietly rather than reporting the documented limitation as a per-prompt error. This is
|
||||
an internal, unshipped capability: no client consumes it, and on a V2 CLI
|
||||
(`opencode api`, no owned serve) that endpoint is absent, so every dispatched `chat_*`
|
||||
request returns a protocol error naming the missing configuration. The live
|
||||
end-to-end approval flow has NOT been tested against a real OpenCode service; the wire
|
||||
shapes and the exact reply path/body are covered by unit tests over an httptest
|
||||
fixture, not against a live pending request. Do not describe brokered chat as a
|
||||
finished or user-facing feature.
|
||||
(verified against the installed service's `/openapi.json`). The native v1 serve
|
||||
translation rejects them explicitly instead of guessing an endpoint, so on v1 the
|
||||
permission poller stops quietly rather than reporting the documented limitation as
|
||||
a per-prompt error.
|
||||
|
||||
### Verification evidence (2026-10-17)
|
||||
|
||||
Verified against the installed OpenCode 2.0.20 on 2026-10-17:
|
||||
|
||||
- `opencode --version` reports `2.0.20`; `opencode --help` advertises `api` and
|
||||
`serve`. `GET /openapi.json` on an owned `opencode serve` lists `GET /api/event`
|
||||
(SSE) and the session/prompt/interrupt/permission endpoints.
|
||||
- A live turn streamed token-level `session.text.delta` and
|
||||
`session.reasoning.delta` events (each with `assistantMessageID` and `ordinal`),
|
||||
plus `session.step.*` and `session.usage.updated`; the V2 API server
|
||||
authenticates the fixed `opencode` basic-auth user.
|
||||
- The opt-in live end-to-end test (`PIPELINES_TEST_OPENCODE_CHAT_LIVE=1 go test
|
||||
./internal/server/... -run TestChatLiveEndToEnd`) opened an owned V2 endpoint,
|
||||
listed the owned scratch session, streamed a completed turn as
|
||||
`[step:started,text,step:streamed,step:ended]` (first delta `"pong"`), and
|
||||
interrupted a running turn so the session left the V2 active set.
|
||||
- Not verified live: a genuine pending-approval round trip and any backend other
|
||||
than the installed 2.0.20. The permission wire shapes are unit-tested over an
|
||||
httptest fixture, not against a live pending request.
|
||||
|
||||
Deployment state: not deployed. This is reviewed and committed locally only;
|
||||
deploying it (and restarting the server) is the operator's step. Do not describe
|
||||
brokered chat as already deployed.
|
||||
|
||||
## Debug and retry
|
||||
|
||||
|
||||
Reference in New Issue
Block a user