Skip to content

Commit 85f1780

Browse files
Address 4 post-merge review comments on PR #1376
1. docs/getting-started.md: Python snippet still used the removed `CopilotClientOptions` wrapper. Switch to the flat-kwargs form (`CopilotClient(connection=RuntimeConnection.for_uri(...))`). 2. python/README.md custom-permission-handler example imported per-kind variants (`PermissionRequestShell`, `PermissionDecisionApproveOnce`, `PermissionDecisionReject`) from `copilot` — but only `PermissionRequest` and `PermissionRequestResult` are re-exported at the top level. Fix the example to import the variant classes from `copilot.generated.session_events`. 3. python/copilot/client.py `RuntimeConnection` docstring referenced the old factory names `stdio`/`tcp`/`uri`. Update to `for_stdio`/`for_tcp`/`for_uri` to match the renamed methods. 4. python/copilot/session.py comment above `PermissionRequestResult` told users to construct variants with `kind=...` arguments — but Phase L baked the discriminator into a `ClassVar` default, so the generated variants reject `kind=` at the call site. Update the comment to reflect the new ergonomics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f6a669d commit 85f1780

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

docs/getting-started.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,12 +1967,10 @@ const session = await client.createSession({ onPermissionRequest: approveAll });
19671967
<summary><strong>Python</strong></summary>
19681968

19691969
```python
1970-
from copilot import CopilotClient, CopilotClientOptions, RuntimeConnection
1970+
from copilot import CopilotClient, RuntimeConnection
19711971
from copilot.session import PermissionHandler
19721972

1973-
client = CopilotClient(CopilotClientOptions(
1974-
connection=RuntimeConnection.for_uri("localhost:4321"),
1975-
))
1973+
client = CopilotClient(connection=RuntimeConnection.for_uri("localhost:4321"))
19761974
await client.start()
19771975

19781976
# Use the client normally

python/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,10 @@ session = await client.create_session(
574574
Provide your own function to inspect each request and apply custom logic (sync or async):
575575

576576
```python
577-
from copilot import (
577+
from copilot import PermissionRequest, PermissionRequestResult
578+
from copilot.generated.session_events import (
578579
PermissionDecisionApproveOnce,
579580
PermissionDecisionReject,
580-
PermissionRequest,
581-
PermissionRequestResult,
582581
PermissionRequestShell,
583582
)
584583

python/copilot/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ class TelemetryConfig(TypedDict, total=False):
159159
class RuntimeConnection:
160160
"""Discriminated config describing how to reach the Copilot runtime.
161161
162-
Construct via the static factories :meth:`stdio`, :meth:`tcp`, or
163-
:meth:`uri`. Each factory returns the matching subclass; pattern-match
164-
on the subclass (or :func:`isinstance`) to branch on the transport.
162+
Construct via the static factories :meth:`for_stdio`, :meth:`for_tcp`,
163+
or :meth:`for_uri`. Each factory returns the matching subclass;
164+
pattern-match on the subclass (or :func:`isinstance`) to branch on the
165+
transport.
165166
166167
Example:
167168
>>> CopilotClient() # default: stdio with the bundled runtime

python/copilot/session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@ class PermissionNoResult:
250250
# The decision returned by a permission handler. Identical shape to the wire
251251
# ``PermissionDecision`` discriminated union, plus a :class:`PermissionNoResult`
252252
# sentinel for v1 servers. Construct via the generated variant classes:
253-
# ``PermissionDecisionApproveOnce(kind=...)``, ``PermissionDecisionReject(kind=...,
254-
# feedback=...)``, etc.
253+
# ``PermissionDecisionApproveOnce()``, ``PermissionDecisionReject(feedback=...)``,
254+
# etc. The ``kind`` discriminator is baked in as a ``ClassVar`` default by
255+
# codegen, so callers must not pass it.
255256
PermissionRequestResult = PermissionDecision | PermissionNoResult
256257

257258

0 commit comments

Comments
 (0)