Skip to content

Commit d62ec77

Browse files
authored
feat: allow session permission updates (#22070)
1 parent cb1e5d9 commit d62ec77

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

packages/opencode/src/server/instance/session.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export const SessionRoutes = lazy(() =>
273273
"json",
274274
z.object({
275275
title: z.string().optional(),
276+
permission: Permission.Ruleset.optional(),
276277
time: z
277278
.object({
278279
archived: z.number().optional(),
@@ -283,10 +284,17 @@ export const SessionRoutes = lazy(() =>
283284
async (c) => {
284285
const sessionID = c.req.valid("param").sessionID
285286
const updates = c.req.valid("json")
287+
const current = await Session.get(sessionID)
286288

287289
if (updates.title !== undefined) {
288290
await Session.setTitle({ sessionID, title: updates.title })
289291
}
292+
if (updates.permission !== undefined) {
293+
await Session.setPermission({
294+
sessionID,
295+
permission: Permission.merge(current.permission ?? [], updates.permission),
296+
})
297+
}
290298
if (updates.time?.archived !== undefined) {
291299
await Session.setArchived({ sessionID, time: updates.time.archived })
292300
}

packages/opencode/src/session/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,11 @@ export namespace Session {
708708
runPromise((svc) => svc.setArchived(input)),
709709
)
710710

711+
export const setPermission = fn(
712+
z.object({ sessionID: SessionID.zod, permission: Permission.Ruleset }),
713+
(input) => runPromise((svc) => svc.setPermission(input)),
714+
)
715+
711716
export const setRevert = fn(
712717
z.object({ sessionID: SessionID.zod, revert: Info.shape.revert, summary: Info.shape.summary }),
713718
(input) =>

packages/sdk/js/src/v2/gen/sdk.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,7 @@ export class Session2 extends HeyApiClient {
17251725
directory?: string
17261726
workspace?: string
17271727
title?: string
1728+
permission?: PermissionRuleset
17281729
time?: {
17291730
archived?: number
17301731
}
@@ -1740,6 +1741,7 @@ export class Session2 extends HeyApiClient {
17401741
{ in: "query", key: "directory" },
17411742
{ in: "query", key: "workspace" },
17421743
{ in: "body", key: "title" },
1744+
{ in: "body", key: "permission" },
17431745
{ in: "body", key: "time" },
17441746
],
17451747
},

packages/sdk/js/src/v2/gen/types.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3266,6 +3266,7 @@ export type SessionGetResponse = SessionGetResponses[keyof SessionGetResponses]
32663266
export type SessionUpdateData = {
32673267
body?: {
32683268
title?: string
3269+
permission?: PermissionRuleset
32693270
time?: {
32703271
archived?: number
32713272
}

0 commit comments

Comments
 (0)