Skip to content

Commit 7463c54

Browse files
brettcannonSteveSandersonMSCopilot
authored
[Python] Remove copilot.types (#871)
* Remove `copilot.types` Along the way, simplify `copilot.__init__` to only export the high-level API. * fix: reorder import statements in test_telemetry.py * fix: ruff format client.py and session.py Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: update PermissionHandler import path in transform test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fixes after rebase * fix: use keyword params directly in create_session/resume_session bodies Remove cfg dict intermediary and use keyword parameters directly, fixing ty type checker errors where cfg.get() returned Any | None and shadowed the typed parameter variables. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: restore system message transform support lost during rebase Add back SectionTransformFn type, _extract_transform_callbacks helper, _handle_system_message_transform handler, and systemMessage.transform RPC registration that were part of PR #816 but lost during rebase. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: restore missing SystemMessageCustomizeConfig and related types The customize mode types (SystemPromptSection, SYSTEM_PROMPT_SECTIONS, SectionOverride, SystemMessageCustomizeConfig) were dropped when types.py was deleted but not re-added to session.py. This also moves SectionTransformFn and SectionOverrideAction before SectionOverride so the definitions flow in dependency order. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5ecfc94 commit 7463c54

File tree

68 files changed

+1744
-1822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1744
-1822
lines changed

docs/auth/byok.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ const client = new CopilotClient({
335335

336336
```python
337337
from copilot import CopilotClient
338-
from copilot.types import ModelInfo, ModelCapabilities, ModelSupports, ModelLimits
338+
from copilot.client import ModelInfo, ModelCapabilities, ModelSupports, ModelLimits
339339

340340
client = CopilotClient({
341341
"on_list_models": lambda: [

docs/features/custom-agents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const session = await client.createSession({
6565

6666
```python
6767
from copilot import CopilotClient
68-
from copilot.types import PermissionRequestResult
68+
from copilot.session import PermissionRequestResult
6969

7070
client = CopilotClient()
7171
await client.start()

docs/features/image-input.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ await session.send({
6969

7070
```python
7171
from copilot import CopilotClient
72-
from copilot.types import PermissionRequestResult
72+
from copilot.session import PermissionRequestResult
7373

7474
client = CopilotClient()
7575
await client.start()

docs/features/skills.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ await session.sendAndWait({ prompt: "Review this code for security issues" });
4343

4444
```python
4545
from copilot import CopilotClient
46-
from copilot.types import PermissionRequestResult
46+
from copilot.session import PermissionRequestResult
4747

4848
async def main():
4949
client = CopilotClient()

docs/features/steering-and-queueing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ await session.send({
7070

7171
```python
7272
from copilot import CopilotClient
73-
from copilot.types import PermissionRequestResult
73+
from copilot.session import PermissionRequestResult
7474

7575
async def main():
7676
client = CopilotClient()
@@ -229,7 +229,7 @@ await session.send({
229229

230230
```python
231231
from copilot import CopilotClient
232-
from copilot.types import PermissionRequestResult
232+
from copilot.session import PermissionRequestResult
233233

234234
async def main():
235235
client = CopilotClient()

docs/getting-started.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ Create `main.py`:
129129

130130
```python
131131
import asyncio
132-
from copilot import CopilotClient, PermissionHandler
132+
from copilot import CopilotClient
133+
from copilot.session import PermissionHandler
133134

134135
async def main():
135136
client = CopilotClient()
@@ -275,7 +276,8 @@ Update `main.py`:
275276
```python
276277
import asyncio
277278
import sys
278-
from copilot import CopilotClient, PermissionHandler
279+
from copilot import CopilotClient
280+
from copilot.session import PermissionHandler
279281
from copilot.generated.session_events import SessionEventType
280282

281283
async def main():
@@ -651,7 +653,8 @@ Update `main.py`:
651653
import asyncio
652654
import random
653655
import sys
654-
from copilot import CopilotClient, PermissionHandler
656+
from copilot import CopilotClient
657+
from copilot.session import PermissionHandler
655658
from copilot.tools import define_tool
656659
from copilot.generated.session_events import SessionEventType
657660
from pydantic import BaseModel, Field
@@ -919,7 +922,8 @@ Create `weather_assistant.py`:
919922
import asyncio
920923
import random
921924
import sys
922-
from copilot import CopilotClient, PermissionHandler
925+
from copilot import CopilotClient
926+
from copilot.session import PermissionHandler
923927
from copilot.tools import define_tool
924928
from copilot.generated.session_events import SessionEventType
925929
from pydantic import BaseModel, Field
@@ -1312,7 +1316,8 @@ const session = await client.createSession({ onPermissionRequest: approveAll });
13121316
<summary><strong>Python</strong></summary>
13131317

13141318
```python
1315-
from copilot import CopilotClient, PermissionHandler
1319+
from copilot import CopilotClient
1320+
from copilot.session import PermissionHandler
13161321

13171322
client = CopilotClient({
13181323
"cli_url": "localhost:4321"

docs/hooks/error-handling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ type ErrorOccurredHandler = (
3535

3636
<!-- docs-validate: hidden -->
3737
```python
38-
from copilot.types import ErrorOccurredHookInput, HookInvocation, ErrorOccurredHookOutput
38+
from copilot.session import ErrorOccurredHookInput, ErrorOccurredHookOutput
3939
from typing import Callable, Awaitable
4040

4141
ErrorOccurredHandler = Callable[
42-
[ErrorOccurredHookInput, HookInvocation],
42+
[ErrorOccurredHookInput, dict[str, str]],
4343
Awaitable[ErrorOccurredHookOutput | None]
4444
]
4545
```
4646
<!-- /docs-validate: hidden -->
4747
```python
4848
ErrorOccurredHandler = Callable[
49-
[ErrorOccurredHookInput, HookInvocation],
49+
[ErrorOccurredHookInput, dict[str, str]],
5050
Awaitable[ErrorOccurredHookOutput | None]
5151
]
5252
```

docs/hooks/post-tool-use.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ type PostToolUseHandler = (
3535

3636
<!-- docs-validate: hidden -->
3737
```python
38-
from copilot.types import PostToolUseHookInput, HookInvocation, PostToolUseHookOutput
38+
from copilot.session import PostToolUseHookInput, PostToolUseHookOutput
3939
from typing import Callable, Awaitable
4040

4141
PostToolUseHandler = Callable[
42-
[PostToolUseHookInput, HookInvocation],
42+
[PostToolUseHookInput, dict[str, str]],
4343
Awaitable[PostToolUseHookOutput | None]
4444
]
4545
```
4646
<!-- /docs-validate: hidden -->
4747
```python
4848
PostToolUseHandler = Callable[
49-
[PostToolUseHookInput, HookInvocation],
49+
[PostToolUseHookInput, dict[str, str]],
5050
Awaitable[PostToolUseHookOutput | None]
5151
]
5252
```

docs/hooks/pre-tool-use.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ type PreToolUseHandler = (
3535

3636
<!-- docs-validate: hidden -->
3737
```python
38-
from copilot.types import PreToolUseHookInput, HookInvocation, PreToolUseHookOutput
38+
from copilot.session import PreToolUseHookInput, PreToolUseHookOutput
3939
from typing import Callable, Awaitable
4040

4141
PreToolUseHandler = Callable[
42-
[PreToolUseHookInput, HookInvocation],
42+
[PreToolUseHookInput, dict[str, str]],
4343
Awaitable[PreToolUseHookOutput | None]
4444
]
4545
```
4646
<!-- /docs-validate: hidden -->
4747
```python
4848
PreToolUseHandler = Callable[
49-
[PreToolUseHookInput, HookInvocation],
49+
[PreToolUseHookInput, dict[str, str]],
5050
Awaitable[PreToolUseHookOutput | None]
5151
]
5252
```

docs/hooks/session-lifecycle.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ type SessionStartHandler = (
3939

4040
<!-- docs-validate: hidden -->
4141
```python
42-
from copilot.types import SessionStartHookInput, HookInvocation, SessionStartHookOutput
42+
from copilot.session import SessionStartHookInput, SessionStartHookOutput
4343
from typing import Callable, Awaitable
4444

4545
SessionStartHandler = Callable[
46-
[SessionStartHookInput, HookInvocation],
46+
[SessionStartHookInput, dict[str, str]],
4747
Awaitable[SessionStartHookOutput | None]
4848
]
4949
```
5050
<!-- /docs-validate: hidden -->
5151
```python
5252
SessionStartHandler = Callable[
53-
[SessionStartHookInput, HookInvocation],
53+
[SessionStartHookInput, dict[str, str]],
5454
Awaitable[SessionStartHookOutput | None]
5555
]
5656
```
@@ -249,18 +249,18 @@ type SessionEndHandler = (
249249

250250
<!-- docs-validate: hidden -->
251251
```python
252-
from copilot.types import SessionEndHookInput, HookInvocation
252+
from copilot.session import SessionEndHookInput
253253
from typing import Callable, Awaitable
254254

255255
SessionEndHandler = Callable[
256-
[SessionEndHookInput, HookInvocation],
256+
[SessionEndHookInput, dict[str, str]],
257257
Awaitable[None]
258258
]
259259
```
260260
<!-- /docs-validate: hidden -->
261261
```python
262262
SessionEndHandler = Callable[
263-
[SessionEndHookInput, HookInvocation],
263+
[SessionEndHookInput, dict[str, str]],
264264
Awaitable[SessionEndHookOutput | None]
265265
]
266266
```

0 commit comments

Comments
 (0)