Repository navigation
feat(server): add the provider adapter seam (step 18a) - #315
Merged
Merged
Conversation
The new core crate tern-server-provider is the adapter seam of step 18a in docs/bridge-to-rust.md. Its first piece is turns/ids.rs, moved unchanged; tern-server-threads re-exports it where it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the derived and allocated ids the adapters name their rows with: subagent and delegated task threads, provider items as nodes and messages, runtime requests with their node and card, raw events, plans and context handoffs, so every Rust adapter allocates ids as upstream's does. The fixtures' command and project ids are left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tern-server-provider takes the ProviderAdapter and SessionRuntime traits ported from ProviderAdapter.ts, the events and errors they report, the runtime request table Rust adapters share, the instance-to-adapter registry, and the bridge-backed adapter. tern-server composes a registry whose every row is the bridge, and tern-server-threads opens sessions, runs their operations and takes their events through the traits instead of calling the bridge's session methods. The protocol and what tern does are unchanged; the Replay example now runs its turn through the seam. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Step 18a of
docs/bridge-to-rust.md: the adapter seam. Every provider instance now reaches its adapter through traits, and every row of the registry still points at the bridge, so the protocol and behavior are unchanged. Later steps (18k ACP, 18l Codex, 18n Claude) switch one row at a time.What changes
tern-server-provider(uses wire, bridge):ProviderAdapter(capabilities, selection transition plan, account prompt commands,open_session) andSessionRuntime(everyOperationof upstream's session runtime, the context window, close), ported fromProviderAdapter.ts. Inputs and answers stay JSON encoded as upstream's schemas, which the server already reads and stores.ProviderEvent(typedProviderAdapterV2Eventfor Rust adapters to build) andSessionEvent(a session's event, its end, a continuation offer, an adapter's exit) on one channel toTurns.AdapterError, which keeps the bridge's error text, so stored failures do not depend on which adapter ran.ids:turns/ids.rsmoved here (own commit) and the rest ofIdAllocator.tsported, except the fixtures' ids.RuntimeRequests: the open questions and approvals a Rust adapter waits on, written once.Registry: one row per built-in driver plus a fallback;BridgeAdapterimplements the traits on the bridge protocol.tern-servercomposes the registry (every row the bridge) inattach_bridge, and the MCP sign-in runs on the session's runtime.tern-server-threadsopens sessions, runs their operations and takes their events through the traits. Sessions hold their runtime; an adapter that exits ends only its own sessions. Checkpoints, handoffs, workspaces, titles, terminals, devices and continuation requests are still asked of the bridge directly (their own steps; continuations move with the first adapter that offers them, 18k).bridgeexample runs its Replay turn throughBridgeAdapter.crates.md(row, tier, edges),crates.svgregenerated,bridge-to-rust.mdmarks 18a done,server-orchestration.md.Checks
cargo fmt --all,cargo clippy --workspace --all-targets --locked -- -D warnings,scripts/check-layers.py(53 crates, 0 allowed edges).cargo test --workspace --lockedwith a scratchHOMEandTERN_KEYCHAIN=off.cargo run -p tern-server --example bridge, Node 26.13.1): session opened with its operations,thread.ensure,turn.start, turncompletedin 5.2 s, startup 0.77 s, 360 MB resident.own_*harness unchanged, run by CI'sharnessesjob.🤖 Generated with Claude Code