@@ -61,12 +61,13 @@ const session = await client.createSession({
6161
6262``` python
6363from copilot import CopilotClient
64+ from copilot.session import PermissionRequestResult
6465
6566client = CopilotClient()
6667await client.start()
6768
6869session = await client.create_session(
69- on_permission_request = lambda req , inv : { " kind" : " approve-once" } ,
70+ on_permission_request = lambda req , inv : PermissionRequestResult( kind = " approve-once" ) ,
7071 hooks = {
7172 " on_session_start" : on_session_start,
7273 " on_pre_tool_use" : on_pre_tool_use,
@@ -261,6 +262,8 @@ const session = await client.createSession({
261262<summary ><strong >Python</strong ></summary >
262263
263264``` python
265+ from copilot.session import PermissionRequestResult
266+
264267READ_ONLY_TOOLS = [" read_file" , " glob" , " grep" , " view" ]
265268
266269async def on_pre_tool_use (input_data , invocation ):
@@ -273,7 +276,7 @@ async def on_pre_tool_use(input_data, invocation):
273276 return {" permissionDecision" : " allow" }
274277
275278session = await client.create_session(
276- on_permission_request = lambda req , inv : { " kind" : " approve-once" } ,
279+ on_permission_request = lambda req , inv : PermissionRequestResult( kind = " approve-once" ) ,
277280 hooks = {" on_pre_tool_use" : on_pre_tool_use},
278281)
279282```
@@ -575,6 +578,7 @@ const session = await client.createSession({
575578<!-- docs-validate: skip -->
576579``` python
577580import json, aiofiles
581+ from copilot.session import PermissionRequestResult
578582
579583audit_log = []
580584
@@ -626,7 +630,7 @@ async def on_session_end(input_data, invocation):
626630 return None
627631
628632session = await client.create_session(
629- on_permission_request = lambda req , inv : { " kind" : " approve-once" } ,
633+ on_permission_request = lambda req , inv : PermissionRequestResult( kind = " approve-once" ) ,
630634 hooks = {
631635 " on_session_start" : on_session_start,
632636 " on_user_prompt_submitted" : on_user_prompt_submitted,
@@ -705,6 +709,7 @@ const session = await client.createSession({
705709
706710``` python
707711import subprocess
712+ from copilot.session import PermissionRequestResult
708713
709714async def on_session_end (input_data , invocation ):
710715 sid = invocation[" session_id" ][:8 ]
@@ -723,7 +728,7 @@ async def on_error_occurred(input_data, invocation):
723728 return None
724729
725730session = await client.create_session(
726- on_permission_request = lambda req , inv : { " kind" : " approve-once" } ,
731+ on_permission_request = lambda req , inv : PermissionRequestResult( kind = " approve-once" ) ,
727732 hooks = {
728733 " on_session_end" : on_session_end,
729734 " on_error_occurred" : on_error_occurred,
@@ -927,6 +932,8 @@ const session = await client.createSession({
927932<summary ><strong >Python</strong ></summary >
928933
929934``` python
935+ from copilot.session import PermissionRequestResult
936+
930937session_metrics = {}
931938
932939async def on_session_start (input_data , invocation ):
@@ -956,7 +963,7 @@ async def on_session_end(input_data, invocation):
956963 return None
957964
958965session = await client.create_session(
959- on_permission_request = lambda req , inv : { " kind" : " approve-once" } ,
966+ on_permission_request = lambda req , inv : PermissionRequestResult( kind = " approve-once" ) ,
960967 hooks = {
961968 " on_session_start" : on_session_start,
962969 " on_user_prompt_submitted" : on_user_prompt_submitted,
0 commit comments