feat(simulation): add endpoint handshake protocol - #37157
Merged
Conversation
This was referenced Jul 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a canonical
simulation.handshakerequest to both simulation WebSocket endpoints so controllers can detect protocol skew before issuing UI or LLM operations.The handshake reports:
uiorbackendClients declare offered protocol versions plus required and optional capabilities. OpenCode rejects role mismatches, unsupported versions, and missing required capabilities with typed failures.
How
packages/simulation/src/protocol/index.tsdefines the shared handshake schemas, typed errors, dispatch validation, and canonical endpoint capability lists.packages/simulation/src/frontend/server.tshandles the handshake before UI operations and advertises the installed frontend handlers.packages/simulation/src/backend/simulated-provider.tshandles the same request on the LLM controller endpoint.Scope
This retains the existing JSON-RPC transport and all current method payloads. It does not migrate simulation control to Effect RPC, add tool lifecycle simulation, or extract a shared protocol package.
Older controllers remain compatible because the new method is additive. Controllers that require negotiation can fail early against older OpenCode builds; controllers that support a legacy profile can explicitly fall back.
Testing
bun run typecheckinpackages/simulationbun testinpackages/simulation: 25 testsFlow
sequenceDiagram participant Drive as Simulation controller participant Endpoint as OpenCode UI or backend Drive->>Endpoint: simulation.handshake<br/>role, versions, required + optional capabilities Endpoint->>Endpoint: Validate role and select protocol v1 Endpoint->>Endpoint: Verify required capabilities are installed alt compatible Endpoint-->>Drive: role, OpenCode version, protocol v1, capabilities Drive->>Endpoint: ui.* or llm.* operations else incompatible Endpoint-->>Drive: typed JSON-RPC failure end