Add typed completions / sessionConfigCompletions client entry points#347
Conversation
The generated `Completions*` / `SessionConfigCompletions*` types shipped in every client but had no typed way to invoke them — callers had to fall back to `request(method: "completions", …)` with a raw string (issue #340). - Swift: add `AHPCommands.completions` / `sessionConfigCompletions` request factories (via generate-swift.ts) and `AHPClient` convenience methods. - Go / Rust / TypeScript: add `completions` / `sessionConfigCompletions` convenience methods matching the existing `resource*` wrappers. - Kotlin already exposed both `AhpCommands` factories, so it needed no change. `completions` preserves the caller-supplied chat channel; the `sessionConfigCompletions` wrappers force the root channel like `resource*`. Adds round-trip tests per client and per-client changelog fragments. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b7e9085c-8ab2-43c9-ba95-3e8c77683537
There was a problem hiding this comment.
Pull request overview
Adds first-class, typed client entry points for the completions (session channel) and sessionConfigCompletions (root channel) commands across Swift, Go, Rust, and TypeScript, closing the gap where consumers previously had to use untyped request(method: ...) calls.
Changes:
- Adds typed convenience methods in Swift (
AHPClient), Go (Client), Rust (Client), and TypeScript (AhpClient) forcompletionsandsessionConfigCompletions. - Updates Swift code generation (
AHPCommands) and regeneratesMessages.generated.swiftto include typed request factories for both commands. - Adds per-client round-trip tests validating channel behavior (preserve caller channel for
completions, force root forsessionConfigCompletions) and ships per-client changelog fragments.
Show a summary per file
| File | Description |
|---|---|
| scripts/generate-swift.ts | Extends Swift command-factory generation to include completions + sessionConfigCompletions. |
| clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/Generated/Messages.generated.swift | Regenerated output adding AHPCommands.completions and AHPCommands.sessionConfigCompletions. |
| clients/swift/AgentHostProtocol/Sources/AgentHostProtocolClient/AHPClient.swift | Adds typed AHPClient convenience methods for both completions commands (with root-channel forcing for session config). |
| clients/swift/AgentHostProtocol/Tests/AgentHostProtocolClientTests/AHPClientTests.swift | Adds round-trip tests verifying method names and channel behavior for both wrappers. |
| clients/typescript/src/client/client.ts | Adds typed AhpClient.completions() and AhpClient.sessionConfigCompletions() wrappers (with root-channel fill-in). |
| clients/typescript/test/client.test.ts | Adds tests verifying request method names and channel behavior for both wrappers. |
| clients/rust/crates/ahp/src/client.rs | Adds typed Client::completions() and Client::session_config_completions() wrappers (forcing root channel for session config). |
| clients/rust/crates/ahp/tests/client_roundtrip.rs | Adds round-trip tests for both Rust wrappers, including channel assertions. |
| clients/go/ahp/client.go | Adds typed Client.Completions() and Client.SessionConfigCompletions() wrappers (forcing root channel for session config). |
| clients/go/ahp/client_test.go | Adds round-trip tests for both Go wrappers, including channel assertions. |
| docs/.changes/20260717-typescript-client-completions.json | Changelog fragment for TypeScript client wrapper additions. |
| docs/.changes/20260717-swift-client-completions.json | Changelog fragment for Swift client wrapper/builder additions. |
| docs/.changes/20260717-rust-client-completions.json | Changelog fragment for Rust client wrapper additions. |
| docs/.changes/20260717-go-client-completions.json | Changelog fragment for Go client wrapper additions. |
Review details
- Files reviewed: 13/14 changed files
- Comments generated: 0
- Review effort level: Low
|
@copilot resolve the merge conflicts in this pull request |
Resolved. The two conflicting files ( |
|
@copilot you left merge markers in the code v.v |
Removed the remaining conflict markers and restored the missing closing brace for |
Fixes #340.
Problem
Every client ships the generated
Completions*/SessionConfigCompletions*types, but most had no typed way to invoke thecompletions(session channel) andsessionConfigCompletions(root channel) commands. Callers had to fall back to the untypedrequest(method: "completions", params: …)with a hand-written method string, losing the compile-time coupling the rest of the client provides.Cross-client gap analysis
AHPCommandsbuilder +AHPClientmethodsClientconvenience methodsCompletions/SessionConfigCompletionsClientconvenience methodscompletions/session_config_completionsAhpClientconvenience methodscompletions/sessionConfigCompletionsAhpCommandsbuilder (no client layer)Channel handling
completions:channelis the caller-set chat URI it is scoped to → preserved (unlike theresource*wrappers).sessionConfigCompletions: always targetsahp-root://→ the wrappers force the root channel, matching theresource*family.Changes
scripts/generate-swift.ts, regeneratedMessages.generated.swift.AHPClient/Client/AhpClientconvenience methods for Swift, Go, Rust, TypeScript.completions, force-root forsessionConfigCompletions).docs/.changes/.Validation
swift test— 112 passedgo test ./...— all packages pass (gofmt/go vetclean)cargo test -p ahp— all tests + doctests pass (cargo fmt --checkclean)node --test— 65 passednpm run lintandnpm run verify:change-fragmentspassnpm run generateproduces no drift beyond the intended changes