@@ -65,15 +65,15 @@ from copilot import CopilotClient
6565client = CopilotClient()
6666await client.start()
6767
68- session = await client.create_session({
69- " hooks" : {
68+ session = await client.create_session(
69+ on_permission_request = lambda req , inv : {" kind" : " approved" },
70+ hooks = {
7071 " on_session_start" : on_session_start,
7172 " on_pre_tool_use" : on_pre_tool_use,
7273 " on_post_tool_use" : on_post_tool_use,
7374 # ... add only the hooks you need
7475 },
75- " on_permission_request" : lambda req , inv : {" kind" : " approved" },
76- })
76+ )
7777```
7878
7979</details >
@@ -245,10 +245,10 @@ async def on_pre_tool_use(input_data, invocation):
245245 }
246246 return {" permissionDecision" : " allow" }
247247
248- session = await client.create_session({
249- " hooks " : {" on_pre_tool_use " : on_pre_tool_use },
250- " on_permission_request " : lambda req , inv : { " kind " : " approved " },
251- } )
248+ session = await client.create_session(
249+ on_permission_request = lambda req , inv : {" kind " : " approved " },
250+ hooks = { " on_pre_tool_use " : on_pre_tool_use },
251+ )
252252```
253253
254254</details >
@@ -567,16 +567,16 @@ async def on_session_end(input_data, invocation):
567567 await f.write(json.dumps(audit_log, indent = 2 ))
568568 return None
569569
570- session = await client.create_session({
571- " hooks" : {
570+ session = await client.create_session(
571+ on_permission_request = lambda req , inv : {" kind" : " approved" },
572+ hooks = {
572573 " on_session_start" : on_session_start,
573574 " on_user_prompt_submitted" : on_user_prompt_submitted,
574575 " on_pre_tool_use" : on_pre_tool_use,
575576 " on_post_tool_use" : on_post_tool_use,
576577 " on_session_end" : on_session_end,
577578 },
578- " on_permission_request" : lambda req , inv : {" kind" : " approved" },
579- })
579+ )
580580```
581581
582582</details >
@@ -666,13 +666,13 @@ async def on_error_occurred(input_data, invocation):
666666 ])
667667 return None
668668
669- session = await client.create_session({
670- " hooks" : {
669+ session = await client.create_session(
670+ on_permission_request = lambda req , inv : {" kind" : " approved" },
671+ hooks = {
671672 " on_session_end" : on_session_end,
672673 " on_error_occurred" : on_error_occurred,
673674 },
674- " on_permission_request" : lambda req , inv : {" kind" : " approved" },
675- })
675+ )
676676```
677677
678678</details >
@@ -905,15 +905,15 @@ async def on_session_end(input_data, invocation):
905905 )
906906 return None
907907
908- session = await client.create_session({
909- " hooks" : {
908+ session = await client.create_session(
909+ on_permission_request = lambda req , inv : {" kind" : " approved" },
910+ hooks = {
910911 " on_session_start" : on_session_start,
911912 " on_user_prompt_submitted" : on_user_prompt_submitted,
912913 " on_pre_tool_use" : on_pre_tool_use,
913914 " on_session_end" : on_session_end,
914915 },
915- " on_permission_request" : lambda req , inv : {" kind" : " approved" },
916- })
916+ )
917917```
918918
919919</details >
0 commit comments