Skip to content

Commit 145c827

Browse files
committed
Add onPermissionRequest handler to resumeSession across multiple guides
1 parent 2d021ac commit 145c827

6 files changed

Lines changed: 12 additions & 9 deletions

File tree

docs/guides/session-persistence.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ flowchart LR
125125

126126
```typescript
127127
// Resume from a different client instance (or after restart)
128-
const session = await client.resumeSession("user-123-task-456");
128+
const session = await client.resumeSession("user-123-task-456", { onPermissionRequest: async () => ({ kind: "approved" }) });
129129

130130
// Continue where you left off
131131
await session.sendAndWait({ prompt: "What did we discuss earlier?" });
@@ -193,6 +193,7 @@ When resuming a session, you can optionally reconfigure many settings. This is u
193193
const session = await client.resumeSession("user-123-task-456", {
194194
model: "claude-sonnet-4", // Switch to a different model
195195
reasoningEffort: "high", // Increase reasoning effort
196+
onPermissionRequest: async () => ({ kind: "approved" }),
196197
});
197198
```
198199

@@ -222,6 +223,7 @@ const resumed = await client.resumeSession("user-123-task-456", {
222223
apiKey: process.env.AZURE_OPENAI_KEY, // Required again
223224
deploymentId: "my-gpt-deployment",
224225
},
226+
onPermissionRequest: async () => ({ kind: "approved" }),
225227
});
226228
```
227229

@@ -415,7 +417,7 @@ async function resumeSessionWithAuth(
415417
throw new Error("Access denied: session belongs to another user");
416418
}
417419

418-
return client.resumeSession(sessionId);
420+
return client.resumeSession(sessionId, { onPermissionRequest: async () => ({ kind: "approved" }) });
419421
}
420422
```
421423

@@ -516,7 +518,7 @@ async function withSessionLock<T>(
516518

517519
// Usage
518520
await withSessionLock("user-123-task-456", async () => {
519-
const session = await client.resumeSession("user-123-task-456");
521+
const session = await client.resumeSession("user-123-task-456", { onPermissionRequest: async () => ({ kind: "approved" }) });
520522
await session.sendAndWait({ prompt: "Continue the task" });
521523
});
522524
```

docs/guides/setup/backend-services.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ app.post("/api/chat", async (req, res) => {
283283
// Create or resume session
284284
let session;
285285
try {
286-
session = await client.resumeSession(sessionId);
286+
session = await client.resumeSession(sessionId, { onPermissionRequest: async () => ({ kind: "approved" }) });
287287
} catch {
288288
session = await client.createSession({
289289
sessionId,

docs/guides/setup/bundled-cli.md

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

226226
// User closes app...
227227
// Later, resume where they left off
228-
const resumed = await client.resumeSession(sessionId);
228+
const resumed = await client.resumeSession(sessionId, { onPermissionRequest: async () => ({ kind: "approved" }) });
229229
```
230230

231231
Session state persists at `~/.copilot/session-state/{sessionId}/`.

docs/guides/setup/byok.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ const resumed = await client.resumeSession("task-123", {
334334
baseUrl: "https://api.openai.com/v1",
335335
apiKey: process.env.OPENAI_API_KEY, // Required again
336336
},
337+
onPermissionRequest: async () => ({ kind: "approved" }),
337338
});
338339
```
339340

docs/guides/setup/local-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ const session = await client.createSession({
177177
});
178178

179179
// Later, resume it
180-
const resumed = await client.resumeSession("my-project-analysis");
180+
const resumed = await client.resumeSession("my-project-analysis", { onPermissionRequest: async () => ({ kind: "approved" }) });
181181
```
182182

183183
Session state is stored locally at `~/.copilot/session-state/{sessionId}/`.

docs/guides/setup/scaling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async function resumeSessionWithAuth(
153153
if (sessionUserId !== currentUserId) {
154154
throw new Error("Access denied: session belongs to another user");
155155
}
156-
return sharedClient.resumeSession(sessionId);
156+
return sharedClient.resumeSession(sessionId, { onPermissionRequest: async () => ({ kind: "approved" }) });
157157
}
158158
```
159159

@@ -227,7 +227,7 @@ async function withSessionLock<T>(
227227
// Usage: serialize access to shared session
228228
app.post("/team-chat", authMiddleware, async (req, res) => {
229229
const result = await withSessionLock("team-project-review", async () => {
230-
const session = await client.resumeSession("team-project-review");
230+
const session = await client.resumeSession("team-project-review", { onPermissionRequest: async () => ({ kind: "approved" }) });
231231
return session.sendAndWait({ prompt: req.body.message });
232232
});
233233

@@ -489,7 +489,7 @@ app.post("/api/chat/start", async (req, res) => {
489489

490490
// Continue the conversation
491491
app.post("/api/chat/message", async (req, res) => {
492-
const session = await client.resumeSession(req.body.sessionId);
492+
const session = await client.resumeSession(req.body.sessionId, { onPermissionRequest: async () => ({ kind: "approved" }) });
493493
const response = await session.sendAndWait({ prompt: req.body.message });
494494

495495
res.json({ content: response?.data.content });

0 commit comments

Comments
 (0)