Skip to content

feat: support sign-in into toolsets via client channel#100

Merged
adubovik merged 3 commits into
developmentfrom
feat/87-support-client-channels-api
Jun 1, 2026
Merged

feat: support sign-in into toolsets via client channel#100
adubovik merged 3 commits into
developmentfrom
feat/87-support-client-channels-api

Conversation

@ypldan
Copy link
Copy Markdown
Collaborator

@ypldan ypldan commented May 28, 2026

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:

results: dict[str, SigninResult] = client.client_channel.signin_toolsets(
    channel_id="<from X-DIAL-CLIENT-CHANNEL-ID>",
    toolset_ids=[...],
)

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_sse context manager on the HTTP client that mirrors request()'s auth and error semantics for streaming.

Scope is intentionally narrow (/interact via the toolset/signin method 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.

@ypldan ypldan requested a review from adubovik as a code owner May 28, 2026 09:59
@ypldan ypldan linked an issue May 28, 2026 that may be closed by this pull request
@ypldan ypldan self-assigned this May 28, 2026
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.
@ypldan ypldan force-pushed the feat/87-support-client-channels-api branch from 4105305 to 5f87c9b Compare May 28, 2026 14:28
Comment thread aidial_client/_http_client/_async.py
Comment thread aidial_client/resources/client_channel.py Outdated
Comment thread aidial_client/resources/client_channel.py Outdated
Comment thread aidial_client/types/client_channel.py Outdated
Comment thread aidial_client/types/client_channel.py Outdated
Comment thread aidial_client/resources/client_channel.py
Comment thread aidial_client/resources/client_channel.py Outdated
Comment thread aidial_client/_http_client/_sse.py
Comment thread README.md Outdated
ypldan and others added 2 commits May 28, 2026 20:26
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.
@ypldan ypldan requested a review from adubovik May 29, 2026 15:26
@adubovik adubovik changed the title feat: add client_channel.interact() for JSON-RPC over SSE #87 feat: support sign-in into toolsets via client channel Jun 1, 2026
@adubovik adubovik merged commit 5a01ddb into development Jun 1, 2026
11 checks passed
@adubovik adubovik deleted the feat/87-support-client-channels-api branch June 1, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support client channels API

2 participants