summaryrefslogtreecommitdiffhomepage
path: root/packages/sdk/js
diff options
context:
space:
mode:
authorDax <[email protected]>2026-01-01 17:54:11 -0500
committerGitHub <[email protected]>2026-01-01 17:54:11 -0500
commit351ddeed914d237138fc6f3f8b3d65d2e559357a (patch)
treea3009b5b42e80b50095835152e334596f843f3cb /packages/sdk/js
parentdccb8875ad0e114242fce3dabc7f7e31c1bac29b (diff)
downloadopencode-351ddeed914d237138fc6f3f8b3d65d2e559357a.tar.gz
opencode-351ddeed914d237138fc6f3f8b3d65d2e559357a.zip
Permission rework (#6319)
Co-authored-by: Github Action <[email protected]> Co-authored-by: Adam <[email protected]>
Diffstat (limited to 'packages/sdk/js')
-rw-r--r--packages/sdk/js/src/v2/gen/sdk.gen.ts44
-rw-r--r--packages/sdk/js/src/v2/gen/types.gen.ts278
2 files changed, 194 insertions, 128 deletions
diff --git a/packages/sdk/js/src/v2/gen/sdk.gen.ts b/packages/sdk/js/src/v2/gen/sdk.gen.ts
index b0610b64b..f56e83677 100644
--- a/packages/sdk/js/src/v2/gen/sdk.gen.ts
+++ b/packages/sdk/js/src/v2/gen/sdk.gen.ts
@@ -55,8 +55,11 @@ import type {
PartUpdateResponses,
PathGetResponses,
PermissionListResponses,
+ PermissionReplyErrors,
+ PermissionReplyResponses,
PermissionRespondErrors,
PermissionRespondResponses,
+ PermissionRuleset,
ProjectCurrentResponses,
ProjectListResponses,
ProjectUpdateErrors,
@@ -728,6 +731,7 @@ export class Session extends HeyApiClient {
directory?: string
parentID?: string
title?: string
+ permission?: PermissionRuleset
},
options?: Options<never, ThrowOnError>,
) {
@@ -739,6 +743,7 @@ export class Session extends HeyApiClient {
{ in: "query", key: "directory" },
{ in: "body", key: "parentID" },
{ in: "body", key: "title" },
+ { in: "body", key: "permission" },
],
},
],
@@ -1591,6 +1596,8 @@ export class Permission extends HeyApiClient {
* Respond to permission
*
* Approve or deny a permission request from the AI assistant.
+ *
+ * @deprecated
*/
public respond<ThrowOnError extends boolean = false>(
parameters: {
@@ -1627,6 +1634,43 @@ export class Permission extends HeyApiClient {
}
/**
+ * Respond to permission request
+ *
+ * Approve or deny a permission request from the AI assistant.
+ */
+ public reply<ThrowOnError extends boolean = false>(
+ parameters: {
+ requestID: string
+ directory?: string
+ reply?: "once" | "always" | "reject"
+ },
+ options?: Options<never, ThrowOnError>,
+ ) {
+ const params = buildClientParams(
+ [parameters],
+ [
+ {
+ args: [
+ { in: "path", key: "requestID" },
+ { in: "query", key: "directory" },
+ { in: "body", key: "reply" },
+ ],
+ },
+ ],
+ )
+ return (options?.client ?? this.client).post<PermissionReplyResponses, PermissionReplyErrors, ThrowOnError>({
+ url: "/permission/{requestID}/reply",
+ ...options,
+ ...params,
+ headers: {
+ "Content-Type": "application/json",
+ ...options?.headers,
+ ...params.headers,
+ },
+ })
+ }
+
+ /**
* List pending permissions
*
* Get all pending permission requests across all sessions.
diff --git a/packages/sdk/js/src/v2/gen/types.gen.ts b/packages/sdk/js/src/v2/gen/types.gen.ts
index 85a3c4286..10764bebe 100644
--- a/packages/sdk/js/src/v2/gen/types.gen.ts
+++ b/packages/sdk/js/src/v2/gen/types.gen.ts
@@ -451,67 +451,32 @@ export type EventMessagePartRemoved = {
}
}
-export type Permission = {
+export type PermissionRequest = {
id: string
- type: string
- pattern?: string | Array<string>
sessionID: string
- messageID: string
- callID?: string
- title: string
+ permission: string
+ patterns: Array<string>
metadata: {
[key: string]: unknown
}
- time: {
- created: number
+ always: Array<string>
+ tool?: {
+ messageID: string
+ callID: string
}
}
-export type EventPermissionUpdated = {
- type: "permission.updated"
- properties: Permission
+export type EventPermissionAsked = {
+ type: "permission.asked"
+ properties: PermissionRequest
}
export type EventPermissionReplied = {
type: "permission.replied"
properties: {
sessionID: string
- permissionID: string
- response: string
- }
-}
-
-export type EventFileEdited = {
- type: "file.edited"
- properties: {
- file: string
- }
-}
-
-export type Todo = {
- /**
- * Brief description of the task
- */
- content: string
- /**
- * Current status of the task: pending, in_progress, completed, cancelled
- */
- status: string
- /**
- * Priority level of the task: high, medium, low
- */
- priority: string
- /**
- * Unique identifier for the todo item
- */
- id: string
-}
-
-export type EventTodoUpdated = {
- type: "todo.updated"
- properties: {
- sessionID: string
- todos: Array<Todo>
+ requestID: string
+ reply: "once" | "always" | "reject"
}
}
@@ -551,6 +516,40 @@ export type EventSessionCompacted = {
}
}
+export type EventFileEdited = {
+ type: "file.edited"
+ properties: {
+ file: string
+ }
+}
+
+export type Todo = {
+ /**
+ * Brief description of the task
+ */
+ content: string
+ /**
+ * Current status of the task: pending, in_progress, completed, cancelled
+ */
+ status: string
+ /**
+ * Priority level of the task: high, medium, low
+ */
+ priority: string
+ /**
+ * Unique identifier for the todo item
+ */
+ id: string
+}
+
+export type EventTodoUpdated = {
+ type: "todo.updated"
+ properties: {
+ sessionID: string
+ todos: Array<Todo>
+ }
+}
+
export type EventTuiPromptAppend = {
type: "tui.prompt.append"
properties: {
@@ -610,6 +609,16 @@ export type EventCommandExecuted = {
}
}
+export type PermissionAction = "allow" | "deny" | "ask"
+
+export type PermissionRule = {
+ permission: string
+ pattern: string
+ action: PermissionAction
+}
+
+export type PermissionRuleset = Array<PermissionRule>
+
export type Session = {
id: string
projectID: string
@@ -632,6 +641,7 @@ export type Session = {
compacting?: number
archived?: number
}
+ permission?: PermissionRuleset
revert?: {
messageID: string
partID?: string
@@ -756,13 +766,13 @@ export type Event =
| EventMessageRemoved
| EventMessagePartUpdated
| EventMessagePartRemoved
- | EventPermissionUpdated
+ | EventPermissionAsked
| EventPermissionReplied
- | EventFileEdited
- | EventTodoUpdated
| EventSessionStatus
| EventSessionIdle
| EventSessionCompacted
+ | EventFileEdited
+ | EventTodoUpdated
| EventTuiPromptAppend
| EventTuiCommandExecute
| EventTuiToastShow
@@ -1183,11 +1193,43 @@ export type ServerConfig = {
cors?: Array<string>
}
+export type PermissionActionConfig = "ask" | "allow" | "deny"
+
+export type PermissionObjectConfig = {
+ [key: string]: PermissionActionConfig
+}
+
+export type PermissionRuleConfig = PermissionActionConfig | PermissionObjectConfig
+
+export type PermissionConfig =
+ | {
+ read?: PermissionRuleConfig
+ edit?: PermissionRuleConfig
+ glob?: PermissionRuleConfig
+ grep?: PermissionRuleConfig
+ list?: PermissionRuleConfig
+ bash?: PermissionRuleConfig
+ task?: PermissionRuleConfig
+ external_directory?: PermissionRuleConfig
+ todowrite?: PermissionActionConfig
+ todoread?: PermissionActionConfig
+ webfetch?: PermissionActionConfig
+ websearch?: PermissionActionConfig
+ codesearch?: PermissionActionConfig
+ lsp?: PermissionRuleConfig
+ doom_loop?: PermissionActionConfig
+ [key: string]: PermissionRuleConfig | PermissionActionConfig | undefined
+ }
+ | PermissionActionConfig
+
export type AgentConfig = {
model?: string
temperature?: number
top_p?: number
prompt?: string
+ /**
+ * @deprecated Use 'permission' field instead
+ */
tools?: {
[key: string]: boolean
}
@@ -1197,6 +1239,9 @@ export type AgentConfig = {
*/
description?: string
mode?: "subagent" | "primary" | "all"
+ options?: {
+ [key: string]: unknown
+ }
/**
* Hex color code for the agent (e.g., #FF5733)
*/
@@ -1204,27 +1249,12 @@ export type AgentConfig = {
/**
* Maximum number of agentic iterations before forcing text-only response
*/
+ steps?: number
+ /**
+ * @deprecated Use 'steps' field instead.
+ */
maxSteps?: number
- permission?: {
- edit?: "ask" | "allow" | "deny"
- bash?:
- | "ask"
- | "allow"
- | "deny"
- | {
- [key: string]: "ask" | "allow" | "deny"
- }
- skill?:
- | "ask"
- | "allow"
- | "deny"
- | {
- [key: string]: "ask" | "allow" | "deny"
- }
- webfetch?: "ask" | "allow" | "deny"
- doom_loop?: "ask" | "allow" | "deny"
- external_directory?: "ask" | "allow" | "deny"
- }
+ permission?: PermissionConfig
[key: string]:
| unknown
| string
@@ -1236,28 +1266,12 @@ export type AgentConfig = {
| "subagent"
| "primary"
| "all"
- | string
- | number
| {
- edit?: "ask" | "allow" | "deny"
- bash?:
- | "ask"
- | "allow"
- | "deny"
- | {
- [key: string]: "ask" | "allow" | "deny"
- }
- skill?:
- | "ask"
- | "allow"
- | "deny"
- | {
- [key: string]: "ask" | "allow" | "deny"
- }
- webfetch?: "ask" | "allow" | "deny"
- doom_loop?: "ask" | "allow" | "deny"
- external_directory?: "ask" | "allow" | "deny"
+ [key: string]: unknown
}
+ | string
+ | number
+ | PermissionConfig
| undefined
}
@@ -1578,26 +1592,7 @@ export type Config = {
*/
instructions?: Array<string>
layout?: LayoutConfig
- permission?: {
- edit?: "ask" | "allow" | "deny"
- bash?:
- | "ask"
- | "allow"
- | "deny"
- | {
- [key: string]: "ask" | "allow" | "deny"
- }
- skill?:
- | "ask"
- | "allow"
- | "deny"
- | {
- [key: string]: "ask" | "allow" | "deny"
- }
- webfetch?: "ask" | "allow" | "deny"
- doom_loop?: "ask" | "allow" | "deny"
- external_directory?: "ask" | "allow" | "deny"
- }
+ permission?: PermissionConfig
tools?: {
[key: string]: boolean
}
@@ -1886,34 +1881,19 @@ export type Agent = {
mode: "subagent" | "primary" | "all"
native?: boolean
hidden?: boolean
- default?: boolean
topP?: number
temperature?: number
color?: string
- permission: {
- edit: "ask" | "allow" | "deny"
- bash: {
- [key: string]: "ask" | "allow" | "deny"
- }
- skill: {
- [key: string]: "ask" | "allow" | "deny"
- }
- webfetch?: "ask" | "allow" | "deny"
- doom_loop?: "ask" | "allow" | "deny"
- external_directory?: "ask" | "allow" | "deny"
- }
+ permission: PermissionRuleset
model?: {
modelID: string
providerID: string
}
prompt?: string
- tools: {
- [key: string]: boolean
- }
options: {
[key: string]: unknown
}
- maxSteps?: number
+ steps?: number
}
export type McpStatusConnected = {
@@ -2457,6 +2437,7 @@ export type SessionCreateData = {
body?: {
parentID?: string
title?: string
+ permission?: PermissionRuleset
}
path?: never
query?: {
@@ -2972,6 +2953,9 @@ export type SessionPromptData = {
}
agent?: string
noReply?: boolean
+ /**
+ * @deprecated tools and permissions have been merged, you can set permissions on the session itself now
+ */
tools?: {
[key: string]: boolean
}
@@ -3156,6 +3140,9 @@ export type SessionPromptAsyncData = {
}
agent?: string
noReply?: boolean
+ /**
+ * @deprecated tools and permissions have been merged, you can set permissions on the session itself now
+ */
tools?: {
[key: string]: boolean
}
@@ -3391,6 +3378,41 @@ export type PermissionRespondResponses = {
export type PermissionRespondResponse = PermissionRespondResponses[keyof PermissionRespondResponses]
+export type PermissionReplyData = {
+ body?: {
+ reply: "once" | "always" | "reject"
+ }
+ path: {
+ requestID: string
+ }
+ query?: {
+ directory?: string
+ }
+ url: "/permission/{requestID}/reply"
+}
+
+export type PermissionReplyErrors = {
+ /**
+ * Bad request
+ */
+ 400: BadRequestError
+ /**
+ * Not found
+ */
+ 404: NotFoundError
+}
+
+export type PermissionReplyError = PermissionReplyErrors[keyof PermissionReplyErrors]
+
+export type PermissionReplyResponses = {
+ /**
+ * Permission processed successfully
+ */
+ 200: boolean
+}
+
+export type PermissionReplyResponse = PermissionReplyResponses[keyof PermissionReplyResponses]
+
export type PermissionListData = {
body?: never
path?: never
@@ -3404,7 +3426,7 @@ export type PermissionListResponses = {
/**
* List of pending permissions
*/
- 200: Array<Permission>
+ 200: Array<PermissionRequest>
}
export type PermissionListResponse = PermissionListResponses[keyof PermissionListResponses]