microsoft / microsoft/agent-host-protocol
Proposal: add a transport-neutral TypeScript AHP server package
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 344
- Forks
- 122
- Avg merge
- 14h 12m
- Merged PRs (30d)
- 22
Description
Problem
The official TypeScript package currently owns the protocol types plus reusable client, multi-host, and WebSocket client surfaces, but it has no corresponding server runtime. A production host therefore has to reimplement the protocol lifecycle above the SDK.
VS Code already carries a substantial handwritten implementation in ProtocolServerHandler: JSON-RPC dispatch, initialize and reconnect, logical client restoration, version negotiation, subscription restoration and snapshots, replay buffering, reverse requests, action dispatch, and live broadcast behavior. Those are protocol/runtime concerns, but the current class is coupled to VS Code services, so other AHP hosts cannot consume them without reproducing the same state machine.
Evidence:
- Official TypeScript package exports: https://github.com/microsoft/agent-host-protocol/blob/a0bc67f840788f816c9b44bb1325181cb4c4661d/clients/typescript/package.json
- VS Code protocol server handler: https://github.com/microsoft/vscode/blob/2c808a76c969cb6d997ca152ea774a53e5a3f1bf/src/vs/platform/agentHost/node/protocolServerHandler.ts#L344
- VS Code reconnect and replay implementation: https://github.com/microsoft/vscode/blob/2c808a76c969cb6d997ca152ea774a53e5a3f1bf/src/vs/platform/agentHost/node/protocolServerHandler.ts#L731
- Server-side subscription bookkeeping: https://github.com/microsoft/vscode/blob/2c808a76c969cb6d997ca152ea774a53e5a3f1bf/src/vs/platform/agentHost/node/agentHostSubscriptionService.ts#L10
Proposed ownership
Add a transport-neutral TypeScript server surface under the official package, for example an exported server entry point. It should own only reusable AHP mechanics:
- JSON-RPC request, response, and notification routing
- initialize, reconnect, and protocol-version negotiation
- logical client identity independent of one transport connection
- subscription registration, restoration, and resource snapshots
- bounded replay and replay-versus-snapshot recovery
- fencing live broadcasts while replay is being delivered
- reverse-request correlation and settlement
- dispatch-action validation and accepted or rejected results
- transport-neutral connection interfaces and deterministic shutdown
Inject the actual resource store, action authority, authentication, persistence, and clock or scheduling effects. Keep VS Code database, filesystem, configuration, telemetry, tunnels, process lifecycle, terminals, provider activation, permissions UI, and workbench state in VS Code.
This should be a server runtime boundary, not a new wire protocol and not a package containing the current VS Code service-dependent class verbatim.
Acceptance cases
A conformance suite should prove at least:
- The server negotiates only a version offered by the client.
- A logical client can reconnect on a new transport without becoming a new protocol client.
- Retained actions replay in order, while an expired cursor returns replacement snapshots.
- Live actions cannot interleave ahead of replay completion.
- Restored subscriptions receive either their complete replay or a replacement snapshot.
- Reverse requests settle exactly once and are fenced across disconnect.
- Duplicate or stale action dispatch does not advance authority twice.
- Shutdown settles or rejects all pending work and leaves no owned transport resources.
- The package has no VS Code workbench, DI, storage, or UI dependency.
Coordinated adoption
The clean sequence would be:
- Agree on the server/runtime boundary and land conformance in this repository.
- Implement the transport-neutral server package here.
- Adapt VS Code services to the package.
- Delete the generic protocol lifecycle from ProtocolServerHandler, leaving only VS Code product adapters.
That gives the protocol repository one reusable server owner and lets VS Code remain the reference product integration rather than the only place the server state machine exists.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with clients/typescript/package.json, then compare the referenced VS Code protocolServerHandler.ts and agentHostSubscriptionService.ts implementations. Define the transport-neutral boundary and conformance tests for negotiation, reconnect, replay, snapshots, reverse requests, dispatch fencing, and shutdown. Done means the package passes those cases without VS Code workbench, DI, storage, or UI dependencies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100