feat: support sign-in into toolsets via client channel#100
Merged
Conversation
Implements the /v1/ops/client-channel/interact endpoint as a thin transport
in the DIAL Python client, so other apps no longer need to re-implement the
SSE + JSON-RPC plumbing currently duplicated in ai-dial-quickapps-backend.
- types/client_channel.py: JsonRpcRequest/Response/Error (pydantic v1/v2
compatible, smart_union to preserve int ids).
- resources/client_channel.py: ClientChannel/AsyncClientChannel.interact()
taking a single request or a batch, returning List[JsonRpcResponse].
Rejects id=None (would be a JSON-RPC notification with no response).
- _http_client/_sse.py: minimal SSE data-event parser (sync + async).
- _http_client/{_sync,_async}.py: stream_sse() context manager wrapping
httpx streaming responses with auth, timeout sentinel, and DialException
translation for transport errors.
4105305 to
5f87c9b
Compare
adubovik
requested changes
May 28, 2026
Per @adubovik's review on PR #100, replaces the public `interact(JsonRpcRequest)` surface with a typed `signin_toolsets(channel_id, toolset_ids) -> dict[str, SigninResult]`. JSON-RPC plumbing moves to `_internal_types/_json_rpc.py`; only `SigninResult` is exported publicly. Review-comment fixes also applied (C1-C8): except Exception fallback in stream_sse, presence-based result/error XOR via pydantic root_validator (so `{"result": null}` parses), private `_CLIENT_CHANNEL_HEADER`, types moved out of client_channel.py, required `jsonrpc`/`id` on response, parsing via a pydantic root model, `_serialize` -> `_serialize_requests`, SSE warning on uncommitted trailing buffer. Additional correctness fixes from the post-redesign review pass: reject str/duplicate toolset_ids and materialize iterators; surface server-level JSON-RPC errors (id=null) as DialException; always emit array wire body; narrow stream_sse catch from Exception to httpx.HTTPError so user-code exceptions inside the with-body propagate.
adubovik
approved these changes
Jun 1, 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.
Applicable issues
Description of changes
Adds typed client-channel support so deployments can drive interactive actions on the connected client (e.g. the chat UI) without re-implementing the SSE + JSON-RPC plumbing currently duplicated in
ai-dial-quickapps-backend.Public surface is a single typed method:
The client owns id assignment and response correlation; JSON-RPC is an internal transport detail, not part of the public API. Sync and async variants both supported.
Under the hood: a minimal SSE data-event parser and a
stream_ssecontext manager on the HTTP client that mirrorsrequest()'s auth and error semantics for streaming.Scope is intentionally narrow (
/interactvia thetoolset/signinmethod only). Other channel actions can be added as typed methods as they're needed.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.