@@ -34,6 +34,7 @@ const client = new CopilotClient();
3434const session = await client .createSession ({
3535 sessionId: " user-123-task-456" ,
3636 model: " gpt-5.2-codex" ,
37+ onPermissionRequest : async () => ({ kind: " approved" }),
3738});
3839
3940// Do some work...
@@ -111,10 +112,10 @@ flowchart LR
111112 subgraph Day1["Day 1"]
112113 A1[Client A:<br/>createSession] --> A2[Work...]
113114 end
114-
115+
115116 A2 --> S[(💾 Storage:<br/>~/.copilot/session-state/)]
116117 S --> B1
117-
118+
118119 subgraph Day2["Day 2"]
119120 B1[Client B:<br/>resumeSession] --> B2[Continue]
120121 end
@@ -210,6 +211,7 @@ const session = await client.createSession({
210211 apiKey: process .env .AZURE_OPENAI_KEY ,
211212 deploymentId: " my-gpt-deployment" ,
212213 },
214+ onPermissionRequest : async () => ({ kind: " approved" }),
213215});
214216
215217// When resuming, you MUST re-provide the provider config
@@ -311,7 +313,7 @@ const repoSessions = await client.listSessions({ repository: "owner/repo" });
311313async function cleanupExpiredSessions(maxAgeMs : number ) {
312314 const sessions = await client .listSessions ();
313315 const now = Date .now ();
314-
316+
315317 for (const session of sessions ) {
316318 const age = now - new Date (session .createdAt ).getTime ();
317319 if (age > maxAgeMs ) {
@@ -333,7 +335,7 @@ When a task completes, destroy the session explicitly rather than waiting for ti
333335try {
334336 // Do work...
335337 await session .sendAndWait ({ prompt: " Complete the task" });
336-
338+
337339 // Task complete - clean up
338340 await session .destroy ();
339341} catch (error ) {
@@ -408,11 +410,11 @@ async function resumeSessionWithAuth(
408410): Promise <Session > {
409411 // Parse user from session ID
410412 const [sessionUserId] = sessionId .split (" -" );
411-
413+
412414 if (sessionUserId !== currentUserId ) {
413415 throw new Error (" Access denied: session belongs to another user" );
414416 }
415-
417+
416418 return client .resumeSession (sessionId );
417419}
418420```
@@ -446,10 +448,10 @@ flowchart LR
446448 subgraph Before["Container A"]
447449 CLI1[CLI + Session X]
448450 end
449-
451+
450452 CLI1 --> |persist| Azure[(☁️ Azure File Share)]
451453 Azure --> |restore| CLI2
452-
454+
453455 subgraph After["Container B (restart)"]
454456 CLI2[CLI + Session X]
455457 end
@@ -469,6 +471,7 @@ const session = await client.createSession({
469471 backgroundCompactionThreshold: 0.80 , // Start compaction at 80% context
470472 bufferExhaustionThreshold: 0.95 , // Block at 95% if needed
471473 },
474+ onPermissionRequest : async () => ({ kind: " approved" }),
472475});
473476```
474477
@@ -499,11 +502,11 @@ async function withSessionLock<T>(
499502): Promise <T > {
500503 const lockKey = ` session-lock:${sessionId } ` ;
501504 const acquired = await redis .set (lockKey , " locked" , " NX" , " EX" , 300 );
502-
505+
503506 if (! acquired ) {
504507 throw new Error (" Session is in use by another client" );
505508 }
506-
509+
507510 try {
508511 return await fn ();
509512 } finally {
0 commit comments