copilot-sdk-supercharged 2.3.0__tar.gz → 2.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/.gitignore +0 -3
  2. {copilot_sdk_supercharged-2.3.0/copilot_sdk_supercharged.egg-info → copilot_sdk_supercharged-2.4.0}/PKG-INFO +69 -87
  3. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/README.md +65 -86
  4. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/__init__.py +94 -15
  5. copilot_sdk_supercharged-2.4.0/copilot/__main__.py +6 -0
  6. copilot_sdk_supercharged-2.4.0/copilot/_cli_download.py +386 -0
  7. copilot_sdk_supercharged-2.4.0/copilot/_cli_version.py +95 -0
  8. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/_jsonrpc.py +75 -4
  9. copilot_sdk_supercharged-2.4.0/copilot/_mode.py +347 -0
  10. copilot_sdk_supercharged-2.4.0/copilot/canvas.py +164 -0
  11. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/client.py +962 -313
  12. copilot_sdk_supercharged-2.4.0/copilot/copilot_request_handler.py +733 -0
  13. copilot_sdk_supercharged-2.4.0/copilot/generated/__init__.py +6 -0
  14. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/generated/rpc.py +20625 -9170
  15. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/generated/session_events.py +3440 -934
  16. copilot_sdk_supercharged-2.4.0/copilot/rpc.py +13 -0
  17. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/session.py +636 -103
  18. copilot_sdk_supercharged-2.4.0/copilot/session_events.py +10 -0
  19. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/tools.py +11 -0
  20. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0/copilot_sdk_supercharged.egg-info}/PKG-INFO +69 -87
  21. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot_sdk_supercharged.egg-info/SOURCES.txt +35 -1
  22. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot_sdk_supercharged.egg-info/requires.txt +3 -0
  23. copilot_sdk_supercharged-2.4.0/e2e/_copilot_request_helpers.py +360 -0
  24. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/conftest.py +4 -1
  25. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_abort_e2e.py +19 -4
  26. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_agent_and_compact_rpc_e2e.py +1 -1
  27. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_builtin_tools_e2e.py +23 -9
  28. copilot_sdk_supercharged-2.4.0/e2e/test_byok_bearer_token_provider_e2e.py +255 -0
  29. copilot_sdk_supercharged-2.4.0/e2e/test_canvas_e2e.py +169 -0
  30. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_client_lifecycle_e2e.py +2 -1
  31. copilot_sdk_supercharged-2.4.0/e2e/test_client_options_e2e.py +588 -0
  32. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_compaction_e2e.py +2 -2
  33. copilot_sdk_supercharged-2.4.0/e2e/test_copilot_request_cancel_error_e2e.py +130 -0
  34. copilot_sdk_supercharged-2.4.0/e2e/test_copilot_request_handler_e2e.py +284 -0
  35. copilot_sdk_supercharged-2.4.0/e2e/test_copilot_request_session_id_e2e.py +120 -0
  36. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_event_fidelity_e2e.py +2 -2
  37. copilot_sdk_supercharged-2.4.0/e2e/test_github_telemetry_e2e.py +57 -0
  38. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_hooks_e2e.py +6 -2
  39. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_hooks_extended_e2e.py +68 -13
  40. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_mcp_and_agents_e2e.py +1 -1
  41. copilot_sdk_supercharged-2.4.0/e2e/test_mcp_oauth_e2e.py +333 -0
  42. copilot_sdk_supercharged-2.4.0/e2e/test_mode_empty_e2e.py +221 -0
  43. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_mode_handlers_e2e.py +3 -3
  44. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_multi_client_e2e.py +133 -87
  45. copilot_sdk_supercharged-2.4.0/e2e/test_multi_provider_registry_e2e.py +206 -0
  46. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_multi_turn_e2e.py +2 -2
  47. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_pending_work_resume_e2e.py +61 -33
  48. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_per_session_auth_e2e.py +4 -4
  49. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_permissions_e2e.py +29 -13
  50. copilot_sdk_supercharged-2.4.0/e2e/test_provider_endpoint_e2e.py +117 -0
  51. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_commands_e2e.py +117 -0
  52. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_rpc_e2e.py +9 -5
  53. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_event_log_e2e.py +157 -0
  54. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_rpc_event_side_effects_e2e.py +6 -6
  55. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_rpc_mcp_and_skills_e2e.py +192 -2
  56. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_rpc_mcp_config_e2e.py +6 -6
  57. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_mcp_lifecycle_e2e.py +151 -0
  58. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_queue_e2e.py +168 -0
  59. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_remote_e2e.py +86 -0
  60. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_schedule_e2e.py +37 -0
  61. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_server_e2e.py +574 -0
  62. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_server_misc_e2e.py +235 -0
  63. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_server_plugins_e2e.py +293 -0
  64. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_server_remote_control_e2e.py +130 -0
  65. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_rpc_session_state_e2e.py +375 -20
  66. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_session_state_extras_e2e.py +303 -0
  67. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_rpc_shell_and_fleet_e2e.py +7 -3
  68. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_shell_user_requested_e2e.py +122 -0
  69. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_rpc_tasks_and_handlers_e2e.py +189 -2
  70. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_ui_ephemeral_query_e2e.py +33 -0
  71. copilot_sdk_supercharged-2.4.0/e2e/test_rpc_workspace_checkpoints_e2e.py +133 -0
  72. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_session_config_e2e.py +257 -3
  73. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_session_e2e.py +73 -22
  74. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_session_fs_e2e.py +12 -13
  75. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_session_fs_sqlite_e2e.py +1 -1
  76. copilot_sdk_supercharged-2.4.0/e2e/test_session_todos_changed_e2e.py +47 -0
  77. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_skills_e2e.py +1 -1
  78. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_streaming_fidelity_e2e.py +1 -1
  79. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_suspend_e2e.py +1 -1
  80. copilot_sdk_supercharged-2.4.0/e2e/test_system_message_sections_e2e.py +73 -0
  81. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_telemetry_e2e.py +12 -25
  82. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_tools_e2e.py +48 -2
  83. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_ui_elicitation_multi_client_e2e.py +2 -2
  84. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/testharness/__init__.py +2 -1
  85. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/testharness/context.py +19 -5
  86. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/testharness/helper.py +29 -1
  87. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/pyproject.toml +4 -4
  88. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/samples/chat.py +2 -2
  89. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/samples/manual_tool_resume.py +5 -2
  90. copilot_sdk_supercharged-2.4.0/scripts/inject-cli-version.mjs +56 -0
  91. copilot_sdk_supercharged-2.4.0/test_canvas.py +360 -0
  92. copilot_sdk_supercharged-2.4.0/test_client.py +2532 -0
  93. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/test_commands_and_elicitation.py +19 -19
  94. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/test_event_forward_compatibility.py +19 -3
  95. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/test_rpc_generated.py +1 -1
  96. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/test_rpc_timeout.py +2 -2
  97. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/test_telemetry.py +4 -0
  98. copilot_sdk_supercharged-2.4.0/test_tool_set.py +292 -0
  99. copilot_sdk_supercharged-2.3.0/copilot/canvas.py +0 -312
  100. copilot_sdk_supercharged-2.3.0/copilot/generated/__init__.py +0 -0
  101. copilot_sdk_supercharged-2.3.0/e2e/test_client_options_e2e.py +0 -274
  102. copilot_sdk_supercharged-2.3.0/e2e/test_rpc_server_e2e.py +0 -192
  103. copilot_sdk_supercharged-2.3.0/scripts/build-wheels.mjs +0 -373
  104. copilot_sdk_supercharged-2.3.0/test_canvas.py +0 -249
  105. copilot_sdk_supercharged-2.3.0/test_client.py +0 -1022
  106. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/_diagnostics.py +0 -0
  107. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/_sdk_protocol_version.py +0 -0
  108. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/_telemetry.py +0 -0
  109. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/py.typed +0 -0
  110. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot/session_fs_provider.py +0 -0
  111. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot_sdk_supercharged.egg-info/dependency_links.txt +0 -0
  112. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/copilot_sdk_supercharged.egg-info/top_level.txt +0 -0
  113. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/__init__.py +0 -0
  114. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_ask_user_e2e.py +0 -0
  115. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_client_api_e2e.py +0 -0
  116. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_client_e2e.py +0 -0
  117. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_commands_e2e.py +0 -0
  118. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_connection_token.py +0 -0
  119. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_error_resilience_e2e.py +0 -0
  120. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_pre_mcp_tool_call_hook_e2e.py +0 -0
  121. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_subagent_hooks_e2e.py +0 -0
  122. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_system_message_transform_e2e.py +0 -0
  123. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_tool_results_e2e.py +0 -0
  124. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/test_ui_elicitation_e2e.py +0 -0
  125. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/e2e/testharness/proxy.py +0 -0
  126. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/setup.cfg +0 -0
  127. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/test_jsonrpc.py +0 -0
  128. {copilot_sdk_supercharged-2.3.0 → copilot_sdk_supercharged-2.4.0}/test_tools.py +0 -0
@@ -169,6 +169,3 @@ uv.lock
169
169
  # Build script caches
170
170
  .cli-cache/
171
171
  .build-temp/
172
-
173
- # Bundled CLI binary (only in platform wheels, not in repo)
174
- copilot/bin/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: copilot-sdk-supercharged
3
- Version: 2.3.0
3
+ Version: 2.4.0
4
4
  Summary: GitHub Copilot SDK Supercharged - Python SDK for programmatic control of GitHub Copilot CLI. Supports 40 languages.
5
5
  Author: jeremiahjordanisaacson
6
6
  License-Expression: MIT
@@ -17,6 +17,7 @@ Requires-Python: >=3.11
17
17
  Description-Content-Type: text/markdown
18
18
  Requires-Dist: python-dateutil>=2.9.0.post0
19
19
  Requires-Dist: pydantic>=2.13.3
20
+ Requires-Dist: httpx>=0.24.0
20
21
  Provides-Extra: dev
21
22
  Requires-Dist: ruff>=0.15.12; extra == "dev"
22
23
  Requires-Dist: ty<0.0.34,>=0.0.33; extra == "dev"
@@ -24,6 +25,8 @@ Requires-Dist: pytest>=9.0.3; extra == "dev"
24
25
  Requires-Dist: pytest-asyncio>=1.3.0; extra == "dev"
25
26
  Requires-Dist: pytest-timeout>=2.4.0; extra == "dev"
26
27
  Requires-Dist: httpx>=0.28.1; extra == "dev"
28
+ Requires-Dist: websockets>=12.0; extra == "dev"
29
+ Requires-Dist: opentelemetry-sdk>=1.0.0; extra == "dev"
27
30
  Provides-Extra: telemetry
28
31
  Requires-Dist: opentelemetry-api>=1.41.1; extra == "telemetry"
29
32
 
@@ -61,16 +64,12 @@ import asyncio
61
64
 
62
65
  from copilot import CopilotClient
63
66
  from copilot.generated.session_events import AssistantMessageData, SessionIdleData
64
- from copilot.session import PermissionHandler
65
67
 
66
68
  async def main():
67
69
  # Client automatically starts on enter and cleans up on exit
68
70
  async with CopilotClient() as client:
69
71
  # Create a session with automatic cleanup
70
- async with await client.create_session(
71
- on_permission_request=PermissionHandler.approve_all,
72
- model="gpt-5",
73
- ) as session:
72
+ async with await client.create_session(model="gpt-5") as session:
74
73
  # Wait for response using session.idle event
75
74
  done = asyncio.Event()
76
75
 
@@ -105,7 +104,7 @@ async def main():
105
104
  client = CopilotClient()
106
105
  await client.start()
107
106
 
108
- # Create a session (on_permission_request is optional; approve_all allows every tool)
107
+ # Create a session (on_permission_request is required)
109
108
  session = await client.create_session(
110
109
  on_permission_request=PermissionHandler.approve_all,
111
110
  model="gpt-5",
@@ -136,7 +135,7 @@ asyncio.run(main())
136
135
  - ✅ Full JSON-RPC protocol support
137
136
  - ✅ stdio and TCP transports
138
137
  - ✅ Real-time streaming events
139
- - ✅ Session history with `get_events()`
138
+ - ✅ Session history with `get_messages()`
140
139
  - ✅ Type hints throughout
141
140
  - ✅ Async/await native
142
141
  - ✅ Async context manager support for automatic resource cleanup
@@ -146,14 +145,11 @@ asyncio.run(main())
146
145
  ### CopilotClient
147
146
 
148
147
  ```python
149
- from copilot import CopilotClient
148
+ from copilot import CopilotClient, SubprocessConfig
150
149
  from copilot.session import PermissionHandler
151
150
 
152
151
  async with CopilotClient() as client:
153
- async with await client.create_session(
154
- on_permission_request=PermissionHandler.approve_all,
155
- model="gpt-5",
156
- ) as session:
152
+ async with await client.create_session(model="gpt-5") as session:
157
153
  def on_event(event):
158
154
  print(f"Event: {event.type}")
159
155
 
@@ -166,39 +162,40 @@ async with CopilotClient() as client:
166
162
  > **Note:** For manual lifecycle management, see [Manual Resource Management](#manual-resource-management) above.
167
163
 
168
164
  ```python
169
- from copilot import CopilotClient, RuntimeConnection
165
+ from copilot import CopilotClient, ExternalServerConfig
170
166
 
171
167
  # Connect to an existing CLI server
172
- client = CopilotClient(connection=RuntimeConnection.for_uri("localhost:3000"))
168
+ client = CopilotClient(ExternalServerConfig(url="localhost:3000"))
173
169
  ```
174
170
 
175
171
  **CopilotClient Constructor:**
176
172
 
177
173
  ```python
178
- CopilotClient() # spawn the bundled runtime with defaults
179
- CopilotClient(connection=..., log_level="debug", github_token=..., ...)
174
+ CopilotClient(
175
+ config=None, # SubprocessConfig | ExternalServerConfig | None
176
+ *,
177
+ auto_start=True, # auto-start server on first use
178
+ on_list_models=None, # custom handler for list_models()
179
+ )
180
180
  ```
181
181
 
182
- All options are kw-only parameters:
182
+ **SubprocessConfig** — spawn a local CLI process:
183
183
 
184
- - `connection` (RuntimeConnection | None): How to reach the runtime. Use
185
- `RuntimeConnection.for_stdio(...)`, `RuntimeConnection.for_tcp(...)`, or
186
- `RuntimeConnection.for_uri(...)`. Defaults to a stdio connection with the bundled binary.
187
- - `working_directory` (str | None): Working directory for the CLI process (default: current dir).
188
- - `log_level` (str): Log level (default: "info").
189
- - `env` (dict | None): Environment variables for the CLI process.
184
+ - `cli_path` (str | None): Path to CLI executable (default: `COPILOT_CLI_PATH` env var, or bundled binary)
185
+ - `cli_args` (list[str]): Extra arguments for the CLI executable
186
+ - `cwd` (str | None): Working directory for CLI process (default: current dir)
187
+ - `use_stdio` (bool): Use stdio transport instead of TCP (default: True)
188
+ - `port` (int): Server port for TCP mode (default: 0 for random)
189
+ - `log_level` (str): Log level (default: "info")
190
+ - `env` (dict | None): Environment variables for the CLI process
190
191
  - `github_token` (str | None): GitHub token for authentication. When provided, takes priority over other auth methods.
191
- - `base_directory` (str | None): Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned CLI process. When `None`, the CLI defaults to `~/.copilot`. Useful in restricted environments where only specific directories are writable. Ignored when using a `UriRuntimeConnection`.
192
+ - `copilot_home` (str | None): Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned CLI process. When `None`, the CLI defaults to `~/.copilot`. Useful in restricted environments where only specific directories are writable. Ignored when using `ExternalServerConfig`.
192
193
  - `use_logged_in_user` (bool | None): Whether to use logged-in user for authentication (default: True, but False when `github_token` is provided).
193
194
  - `telemetry` (dict | None): OpenTelemetry configuration for the CLI process. Providing this enables telemetry — no separate flag needed. See [Telemetry](#telemetry) below.
194
- - `enable_remote_sessions` (bool): Enable remote/cloud session support (default: False).
195
- - `on_list_models` (callable | None): Custom handler for `list_models()`. When provided, the handler is called instead of querying the runtime.
196
195
 
197
- **RuntimeConnection variants:**
196
+ **ExternalServerConfig** — connect to an existing CLI server:
198
197
 
199
- - `RuntimeConnection.for_stdio(path=None, args=None)` — spawn a local CLI process and talk over stdio.
200
- - `RuntimeConnection.for_tcp(port=0, connection_token=None, path=None, args=None)` — spawn a local CLI in TCP mode.
201
- - `RuntimeConnection.for_uri(url, connection_token=None)` — connect to an existing CLI server (e.g. `"localhost:8080"`).
198
+ - `url` (str): Server URL (e.g., `"localhost:8080"`, `"http://127.0.0.1:9000"`, or just `"8080"`).
202
199
 
203
200
  **`CopilotClient.create_session()`:**
204
201
 
@@ -207,12 +204,12 @@ These are passed as keyword arguments to `create_session()`:
207
204
  - `model` (str): Model to use ("gpt-5", "claude-sonnet-4.5", etc.). **Required when using custom provider.**
208
205
  - `reasoning_effort` (str): Reasoning effort level for models that support it ("low", "medium", "high", "xhigh"). Use `list_models()` to check which models support this option.
209
206
  - `session_id` (str): Custom session ID
210
- - `tools` (list): Custom tools exposed to the CLI. Tools with `handler=None` are declaration-only and must be resolved via pending tool-call RPCs.
207
+ - `tools` (list): Custom tools exposed to the CLI
211
208
  - `system_message` (SystemMessageConfig): System message configuration
212
209
  - `streaming` (bool): Enable streaming delta events
213
210
  - `provider` (ProviderConfig): Custom API provider configuration (BYOK). See [Custom Providers](#custom-providers) section.
214
211
  - `infinite_sessions` (InfiniteSessionConfig): Automatic context compaction configuration
215
- - `on_permission_request` (callable): Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. Use `PermissionHandler.approve_all` to allow everything, or provide a custom function for fine-grained control. See [Permission Handling](#permission-handling) section.
212
+ - `on_permission_request` (callable): **Required.** Handler called before each tool execution to approve or deny it. Use `PermissionHandler.approve_all` to allow everything, or provide a custom function for fine-grained control. See [Permission Handling](#permission-handling) section.
216
213
  - `on_user_input_request` (callable): Handler for user input requests from the agent (enables ask_user tool). See [User Input Requests](#user-input-requests) section.
217
214
  - `hooks` (SessionHooks): Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section.
218
215
 
@@ -227,12 +224,12 @@ await client.set_foreground_session_id("session-123")
227
224
 
228
225
  # Subscribe to all lifecycle events
229
226
  def on_lifecycle(event):
230
- print(f"{event.type}: {event.session_id}")
227
+ print(f"{event.type}: {event.sessionId}")
231
228
 
232
- unsubscribe = client.on_lifecycle(on_lifecycle)
229
+ unsubscribe = client.on(on_lifecycle)
233
230
 
234
231
  # Subscribe to specific event type
235
- unsubscribe = client.on_lifecycle("session.foreground", lambda e: print(f"Foreground: {e.session_id}"))
232
+ unsubscribe = client.on("session.foreground", lambda e: print(f"Foreground: {e.sessionId}"))
236
233
 
237
234
  # Later, to stop receiving events:
238
235
  unsubscribe()
@@ -311,17 +308,7 @@ async with await client.create_session(
311
308
  ...
312
309
  ```
313
310
 
314
- The SDK automatically handles `tool.call`, executes your handler (sync or async), and responds with the final result when the tool completes. If a tool has no handler, it is exposed as a declaration only; observe `external_tool.requested` events and resolve the call with the pending tool RPC.
315
-
316
- You can also create a declaration-only tool with generated Pydantic parameters:
317
-
318
- ```python
319
- tool = define_tool(
320
- "lookup_issue",
321
- description="Fetch issue details from our tracker",
322
- params_type=LookupIssueParams,
323
- )
324
- ```
311
+ The SDK automatically handles `tool.call`, executes your handler (sync or async), and responds with the final result when the tool completes.
325
312
 
326
313
  #### Overriding Built-in Tools
327
314
 
@@ -633,13 +620,13 @@ async with await client.create_session(
633
620
  The SDK supports OpenTelemetry for distributed tracing. Provide a `telemetry` config to enable trace export and automatic W3C Trace Context propagation.
634
621
 
635
622
  ```python
636
- from copilot import CopilotClient
623
+ from copilot import CopilotClient, SubprocessConfig
637
624
 
638
- client = CopilotClient(
625
+ client = CopilotClient(SubprocessConfig(
639
626
  telemetry={
640
627
  "otlp_endpoint": "http://localhost:4318",
641
628
  },
642
- )
629
+ ))
643
630
  ```
644
631
 
645
632
  **TelemetryConfig options:**
@@ -656,7 +643,7 @@ Install with telemetry extras: `pip install copilot-sdk[telemetry]` (provides `o
656
643
 
657
644
  ## Permission Handling
658
645
 
659
- An `on_permission_request` handler is optional when you create or resume a session. When provided, it is called before the agent executes each tool (file writes, shell commands, custom tools, etc.) and returns a decision. When omitted, permission requests are emitted as events and left pending for the consumer to resolve with the pending permission RPC.
646
+ An `on_permission_request` handler is **required** whenever you create or resume a session. The handler is called before the agent executes each tool (file writes, shell commands, custom tools, etc.) and must return a decision.
660
647
 
661
648
  ### Approve All (simplest)
662
649
 
@@ -677,26 +664,31 @@ session = await client.create_session(
677
664
  Provide your own function to inspect each request and apply custom logic (sync or async):
678
665
 
679
666
  ```python
680
- from copilot import PermissionRequest, PermissionRequestResult
681
- from copilot.generated.rpc import (
682
- PermissionDecisionApproveOnce,
683
- PermissionDecisionReject,
684
- )
685
- from copilot.generated.session_events import PermissionRequestShell
686
-
667
+ from copilot.session import PermissionRequestResult
668
+ from copilot.generated.session_events import PermissionRequest
687
669
 
688
670
  def on_permission_request(
689
671
  request: PermissionRequest, invocation: dict
690
672
  ) -> PermissionRequestResult:
691
- # ``PermissionRequest`` is a discriminated union — pattern-match on
692
- # the variant class to access the per-kind fields.
693
- match request:
694
- case PermissionRequestShell(full_command_text=cmd):
695
- # Deny shell commands
696
- return PermissionDecisionReject(feedback=f"Shell denied: {cmd}")
697
- case _:
698
- return PermissionDecisionApproveOnce()
699
-
673
+ # request.kind — what type of operation is being requested:
674
+ # "shell" — executing a shell command
675
+ # "write" — writing or editing a file
676
+ # "read" — reading a file
677
+ # "mcp" — calling an MCP tool
678
+ # "custom-tool" — calling one of your registered tools
679
+ # "url" — fetching a URL
680
+ # "memory" — accessing or updating session/workspace memory
681
+ # "hook" — invoking a registered hook
682
+ # request.tool_call_id — the tool call that triggered this request
683
+ # request.tool_name — name of the tool (for custom-tool / mcp)
684
+ # request.file_name — file being written (for write)
685
+ # request.full_command_text — full shell command (for shell)
686
+
687
+ if request.kind.value == "shell":
688
+ # Deny shell commands
689
+ return PermissionRequestResult(kind="denied-interactively-by-user")
690
+
691
+ return PermissionRequestResult(kind="approved")
700
692
 
701
693
  session = await client.create_session(
702
694
  on_permission_request=on_permission_request,
@@ -712,33 +704,23 @@ async def on_permission_request(
712
704
  ) -> PermissionRequestResult:
713
705
  # Simulate an async approval check (e.g., prompting a user over a network)
714
706
  await asyncio.sleep(0)
715
- return PermissionDecisionApproveOnce()
707
+ return PermissionRequestResult(kind="approved")
716
708
  ```
717
709
 
718
710
  ### Permission Result Kinds
719
711
 
720
- The handler returns a ``PermissionRequestResult``, which is an alias for
721
- ``PermissionDecision | PermissionNoResult`` (the generated wire-level
722
- union of every decision variant, plus a small sentinel for v1 servers).
723
- Approval decisions are present-tense — they describe the decision to
724
- apply, not the past-tense outcome reported back on `permission.completed`
725
- session events.
726
-
727
- | Variant | Meaning |
728
- | --------------------------------------------- | ------------------------------------------------------------------------------------------- |
729
- | `PermissionDecisionApproveOnce()` | Allow this single request |
730
- | `PermissionDecisionReject(feedback="…")` | Deny the request (optional feedback string forwarded to the LLM) |
731
- | `PermissionDecisionUserNotAvailable()` | Deny the request because no user is available to confirm it (the default) |
732
- | `PermissionNoResult()` | Leave the request unanswered (only valid with protocol v1; rejected by protocol v2 servers) |
733
-
734
- Several richer variants (``PermissionDecisionApproveForSession``,
735
- ``PermissionDecisionApproveForLocation``, ``PermissionDecisionApprovePermanently``,
736
- …) are available for granting longer-lived approvals; see the generated
737
- ``copilot.generated.rpc`` module for the full list.
712
+ | `kind` value | Meaning |
713
+ | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
714
+ | `"approved"` | Allow the tool to run |
715
+ | `"denied-interactively-by-user"` | User explicitly denied the request |
716
+ | `"denied-no-approval-rule-and-could-not-request-from-user"` | No approval rule matched and user could not be asked (default when no kind is specified) |
717
+ | `"denied-by-rules"` | Denied by a policy rule |
718
+ | `"denied-by-content-exclusion-policy"` | Denied due to a content exclusion policy |
719
+ | `"no-result"` | Leave the request unanswered (not allowed for protocol v2 permission requests) |
738
720
 
739
721
  ### Resuming Sessions
740
722
 
741
- You may pass `on_permission_request` when resuming a session too:
723
+ Pass `on_permission_request` when resuming a session too — it is required:
742
724
 
743
725
  ```python
744
726
  session = await client.resume_session(
@@ -32,16 +32,12 @@ import asyncio
32
32
 
33
33
  from copilot import CopilotClient
34
34
  from copilot.generated.session_events import AssistantMessageData, SessionIdleData
35
- from copilot.session import PermissionHandler
36
35
 
37
36
  async def main():
38
37
  # Client automatically starts on enter and cleans up on exit
39
38
  async with CopilotClient() as client:
40
39
  # Create a session with automatic cleanup
41
- async with await client.create_session(
42
- on_permission_request=PermissionHandler.approve_all,
43
- model="gpt-5",
44
- ) as session:
40
+ async with await client.create_session(model="gpt-5") as session:
45
41
  # Wait for response using session.idle event
46
42
  done = asyncio.Event()
47
43
 
@@ -76,7 +72,7 @@ async def main():
76
72
  client = CopilotClient()
77
73
  await client.start()
78
74
 
79
- # Create a session (on_permission_request is optional; approve_all allows every tool)
75
+ # Create a session (on_permission_request is required)
80
76
  session = await client.create_session(
81
77
  on_permission_request=PermissionHandler.approve_all,
82
78
  model="gpt-5",
@@ -107,7 +103,7 @@ asyncio.run(main())
107
103
  - ✅ Full JSON-RPC protocol support
108
104
  - ✅ stdio and TCP transports
109
105
  - ✅ Real-time streaming events
110
- - ✅ Session history with `get_events()`
106
+ - ✅ Session history with `get_messages()`
111
107
  - ✅ Type hints throughout
112
108
  - ✅ Async/await native
113
109
  - ✅ Async context manager support for automatic resource cleanup
@@ -117,14 +113,11 @@ asyncio.run(main())
117
113
  ### CopilotClient
118
114
 
119
115
  ```python
120
- from copilot import CopilotClient
116
+ from copilot import CopilotClient, SubprocessConfig
121
117
  from copilot.session import PermissionHandler
122
118
 
123
119
  async with CopilotClient() as client:
124
- async with await client.create_session(
125
- on_permission_request=PermissionHandler.approve_all,
126
- model="gpt-5",
127
- ) as session:
120
+ async with await client.create_session(model="gpt-5") as session:
128
121
  def on_event(event):
129
122
  print(f"Event: {event.type}")
130
123
 
@@ -137,39 +130,40 @@ async with CopilotClient() as client:
137
130
  > **Note:** For manual lifecycle management, see [Manual Resource Management](#manual-resource-management) above.
138
131
 
139
132
  ```python
140
- from copilot import CopilotClient, RuntimeConnection
133
+ from copilot import CopilotClient, ExternalServerConfig
141
134
 
142
135
  # Connect to an existing CLI server
143
- client = CopilotClient(connection=RuntimeConnection.for_uri("localhost:3000"))
136
+ client = CopilotClient(ExternalServerConfig(url="localhost:3000"))
144
137
  ```
145
138
 
146
139
  **CopilotClient Constructor:**
147
140
 
148
141
  ```python
149
- CopilotClient() # spawn the bundled runtime with defaults
150
- CopilotClient(connection=..., log_level="debug", github_token=..., ...)
142
+ CopilotClient(
143
+ config=None, # SubprocessConfig | ExternalServerConfig | None
144
+ *,
145
+ auto_start=True, # auto-start server on first use
146
+ on_list_models=None, # custom handler for list_models()
147
+ )
151
148
  ```
152
149
 
153
- All options are kw-only parameters:
150
+ **SubprocessConfig** — spawn a local CLI process:
154
151
 
155
- - `connection` (RuntimeConnection | None): How to reach the runtime. Use
156
- `RuntimeConnection.for_stdio(...)`, `RuntimeConnection.for_tcp(...)`, or
157
- `RuntimeConnection.for_uri(...)`. Defaults to a stdio connection with the bundled binary.
158
- - `working_directory` (str | None): Working directory for the CLI process (default: current dir).
159
- - `log_level` (str): Log level (default: "info").
160
- - `env` (dict | None): Environment variables for the CLI process.
152
+ - `cli_path` (str | None): Path to CLI executable (default: `COPILOT_CLI_PATH` env var, or bundled binary)
153
+ - `cli_args` (list[str]): Extra arguments for the CLI executable
154
+ - `cwd` (str | None): Working directory for CLI process (default: current dir)
155
+ - `use_stdio` (bool): Use stdio transport instead of TCP (default: True)
156
+ - `port` (int): Server port for TCP mode (default: 0 for random)
157
+ - `log_level` (str): Log level (default: "info")
158
+ - `env` (dict | None): Environment variables for the CLI process
161
159
  - `github_token` (str | None): GitHub token for authentication. When provided, takes priority over other auth methods.
162
- - `base_directory` (str | None): Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned CLI process. When `None`, the CLI defaults to `~/.copilot`. Useful in restricted environments where only specific directories are writable. Ignored when using a `UriRuntimeConnection`.
160
+ - `copilot_home` (str | None): Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned CLI process. When `None`, the CLI defaults to `~/.copilot`. Useful in restricted environments where only specific directories are writable. Ignored when using `ExternalServerConfig`.
163
161
  - `use_logged_in_user` (bool | None): Whether to use logged-in user for authentication (default: True, but False when `github_token` is provided).
164
162
  - `telemetry` (dict | None): OpenTelemetry configuration for the CLI process. Providing this enables telemetry — no separate flag needed. See [Telemetry](#telemetry) below.
165
- - `enable_remote_sessions` (bool): Enable remote/cloud session support (default: False).
166
- - `on_list_models` (callable | None): Custom handler for `list_models()`. When provided, the handler is called instead of querying the runtime.
167
163
 
168
- **RuntimeConnection variants:**
164
+ **ExternalServerConfig** — connect to an existing CLI server:
169
165
 
170
- - `RuntimeConnection.for_stdio(path=None, args=None)` — spawn a local CLI process and talk over stdio.
171
- - `RuntimeConnection.for_tcp(port=0, connection_token=None, path=None, args=None)` — spawn a local CLI in TCP mode.
172
- - `RuntimeConnection.for_uri(url, connection_token=None)` — connect to an existing CLI server (e.g. `"localhost:8080"`).
166
+ - `url` (str): Server URL (e.g., `"localhost:8080"`, `"http://127.0.0.1:9000"`, or just `"8080"`).
173
167
 
174
168
  **`CopilotClient.create_session()`:**
175
169
 
@@ -178,12 +172,12 @@ These are passed as keyword arguments to `create_session()`:
178
172
  - `model` (str): Model to use ("gpt-5", "claude-sonnet-4.5", etc.). **Required when using custom provider.**
179
173
  - `reasoning_effort` (str): Reasoning effort level for models that support it ("low", "medium", "high", "xhigh"). Use `list_models()` to check which models support this option.
180
174
  - `session_id` (str): Custom session ID
181
- - `tools` (list): Custom tools exposed to the CLI. Tools with `handler=None` are declaration-only and must be resolved via pending tool-call RPCs.
175
+ - `tools` (list): Custom tools exposed to the CLI
182
176
  - `system_message` (SystemMessageConfig): System message configuration
183
177
  - `streaming` (bool): Enable streaming delta events
184
178
  - `provider` (ProviderConfig): Custom API provider configuration (BYOK). See [Custom Providers](#custom-providers) section.
185
179
  - `infinite_sessions` (InfiniteSessionConfig): Automatic context compaction configuration
186
- - `on_permission_request` (callable): Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. Use `PermissionHandler.approve_all` to allow everything, or provide a custom function for fine-grained control. See [Permission Handling](#permission-handling) section.
180
+ - `on_permission_request` (callable): **Required.** Handler called before each tool execution to approve or deny it. Use `PermissionHandler.approve_all` to allow everything, or provide a custom function for fine-grained control. See [Permission Handling](#permission-handling) section.
187
181
  - `on_user_input_request` (callable): Handler for user input requests from the agent (enables ask_user tool). See [User Input Requests](#user-input-requests) section.
188
182
  - `hooks` (SessionHooks): Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section.
189
183
 
@@ -198,12 +192,12 @@ await client.set_foreground_session_id("session-123")
198
192
 
199
193
  # Subscribe to all lifecycle events
200
194
  def on_lifecycle(event):
201
- print(f"{event.type}: {event.session_id}")
195
+ print(f"{event.type}: {event.sessionId}")
202
196
 
203
- unsubscribe = client.on_lifecycle(on_lifecycle)
197
+ unsubscribe = client.on(on_lifecycle)
204
198
 
205
199
  # Subscribe to specific event type
206
- unsubscribe = client.on_lifecycle("session.foreground", lambda e: print(f"Foreground: {e.session_id}"))
200
+ unsubscribe = client.on("session.foreground", lambda e: print(f"Foreground: {e.sessionId}"))
207
201
 
208
202
  # Later, to stop receiving events:
209
203
  unsubscribe()
@@ -282,17 +276,7 @@ async with await client.create_session(
282
276
  ...
283
277
  ```
284
278
 
285
- The SDK automatically handles `tool.call`, executes your handler (sync or async), and responds with the final result when the tool completes. If a tool has no handler, it is exposed as a declaration only; observe `external_tool.requested` events and resolve the call with the pending tool RPC.
286
-
287
- You can also create a declaration-only tool with generated Pydantic parameters:
288
-
289
- ```python
290
- tool = define_tool(
291
- "lookup_issue",
292
- description="Fetch issue details from our tracker",
293
- params_type=LookupIssueParams,
294
- )
295
- ```
279
+ The SDK automatically handles `tool.call`, executes your handler (sync or async), and responds with the final result when the tool completes.
296
280
 
297
281
  #### Overriding Built-in Tools
298
282
 
@@ -604,13 +588,13 @@ async with await client.create_session(
604
588
  The SDK supports OpenTelemetry for distributed tracing. Provide a `telemetry` config to enable trace export and automatic W3C Trace Context propagation.
605
589
 
606
590
  ```python
607
- from copilot import CopilotClient
591
+ from copilot import CopilotClient, SubprocessConfig
608
592
 
609
- client = CopilotClient(
593
+ client = CopilotClient(SubprocessConfig(
610
594
  telemetry={
611
595
  "otlp_endpoint": "http://localhost:4318",
612
596
  },
613
- )
597
+ ))
614
598
  ```
615
599
 
616
600
  **TelemetryConfig options:**
@@ -627,7 +611,7 @@ Install with telemetry extras: `pip install copilot-sdk[telemetry]` (provides `o
627
611
 
628
612
  ## Permission Handling
629
613
 
630
- An `on_permission_request` handler is optional when you create or resume a session. When provided, it is called before the agent executes each tool (file writes, shell commands, custom tools, etc.) and returns a decision. When omitted, permission requests are emitted as events and left pending for the consumer to resolve with the pending permission RPC.
614
+ An `on_permission_request` handler is **required** whenever you create or resume a session. The handler is called before the agent executes each tool (file writes, shell commands, custom tools, etc.) and must return a decision.
631
615
 
632
616
  ### Approve All (simplest)
633
617
 
@@ -648,26 +632,31 @@ session = await client.create_session(
648
632
  Provide your own function to inspect each request and apply custom logic (sync or async):
649
633
 
650
634
  ```python
651
- from copilot import PermissionRequest, PermissionRequestResult
652
- from copilot.generated.rpc import (
653
- PermissionDecisionApproveOnce,
654
- PermissionDecisionReject,
655
- )
656
- from copilot.generated.session_events import PermissionRequestShell
657
-
635
+ from copilot.session import PermissionRequestResult
636
+ from copilot.generated.session_events import PermissionRequest
658
637
 
659
638
  def on_permission_request(
660
639
  request: PermissionRequest, invocation: dict
661
640
  ) -> PermissionRequestResult:
662
- # ``PermissionRequest`` is a discriminated union — pattern-match on
663
- # the variant class to access the per-kind fields.
664
- match request:
665
- case PermissionRequestShell(full_command_text=cmd):
666
- # Deny shell commands
667
- return PermissionDecisionReject(feedback=f"Shell denied: {cmd}")
668
- case _:
669
- return PermissionDecisionApproveOnce()
670
-
641
+ # request.kind — what type of operation is being requested:
642
+ # "shell" — executing a shell command
643
+ # "write" — writing or editing a file
644
+ # "read" — reading a file
645
+ # "mcp" — calling an MCP tool
646
+ # "custom-tool" — calling one of your registered tools
647
+ # "url" — fetching a URL
648
+ # "memory" — accessing or updating session/workspace memory
649
+ # "hook" — invoking a registered hook
650
+ # request.tool_call_id — the tool call that triggered this request
651
+ # request.tool_name — name of the tool (for custom-tool / mcp)
652
+ # request.file_name — file being written (for write)
653
+ # request.full_command_text — full shell command (for shell)
654
+
655
+ if request.kind.value == "shell":
656
+ # Deny shell commands
657
+ return PermissionRequestResult(kind="denied-interactively-by-user")
658
+
659
+ return PermissionRequestResult(kind="approved")
671
660
 
672
661
  session = await client.create_session(
673
662
  on_permission_request=on_permission_request,
@@ -683,33 +672,23 @@ async def on_permission_request(
683
672
  ) -> PermissionRequestResult:
684
673
  # Simulate an async approval check (e.g., prompting a user over a network)
685
674
  await asyncio.sleep(0)
686
- return PermissionDecisionApproveOnce()
675
+ return PermissionRequestResult(kind="approved")
687
676
  ```
688
677
 
689
678
  ### Permission Result Kinds
690
679
 
691
- The handler returns a ``PermissionRequestResult``, which is an alias for
692
- ``PermissionDecision | PermissionNoResult`` (the generated wire-level
693
- union of every decision variant, plus a small sentinel for v1 servers).
694
- Approval decisions are present-tense — they describe the decision to
695
- apply, not the past-tense outcome reported back on `permission.completed`
696
- session events.
697
-
698
- | Variant | Meaning |
699
- | --------------------------------------------- | ------------------------------------------------------------------------------------------- |
700
- | `PermissionDecisionApproveOnce()` | Allow this single request |
701
- | `PermissionDecisionReject(feedback="…")` | Deny the request (optional feedback string forwarded to the LLM) |
702
- | `PermissionDecisionUserNotAvailable()` | Deny the request because no user is available to confirm it (the default) |
703
- | `PermissionNoResult()` | Leave the request unanswered (only valid with protocol v1; rejected by protocol v2 servers) |
704
-
705
- Several richer variants (``PermissionDecisionApproveForSession``,
706
- ``PermissionDecisionApproveForLocation``, ``PermissionDecisionApprovePermanently``,
707
- …) are available for granting longer-lived approvals; see the generated
708
- ``copilot.generated.rpc`` module for the full list.
680
+ | `kind` value | Meaning |
681
+ | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
682
+ | `"approved"` | Allow the tool to run |
683
+ | `"denied-interactively-by-user"` | User explicitly denied the request |
684
+ | `"denied-no-approval-rule-and-could-not-request-from-user"` | No approval rule matched and user could not be asked (default when no kind is specified) |
685
+ | `"denied-by-rules"` | Denied by a policy rule |
686
+ | `"denied-by-content-exclusion-policy"` | Denied due to a content exclusion policy |
687
+ | `"no-result"` | Leave the request unanswered (not allowed for protocol v2 permission requests) |
709
688
 
710
689
  ### Resuming Sessions
711
690
 
712
- You may pass `on_permission_request` when resuming a session too:
691
+ Pass `on_permission_request` when resuming a session too — it is required:
713
692
 
714
693
  ```python
715
694
  session = await client.resume_session(