feat(server): add permission request endpoints (#33774)

This commit is contained in:
Dax
2026-06-25 13:55:17 +00:00
committed by GitHub
parent bcff162c60
commit 7f40aeab21
5 changed files with 287 additions and 2 deletions
+92
View File
@@ -128,6 +128,7 @@ import type {
PermissionRespondResponses,
PermissionRuleset,
PermissionV2Reply,
PermissionV2Source,
ProjectCurrentErrors,
ProjectCurrentResponses,
ProjectDirectoriesErrors,
@@ -341,6 +342,10 @@ import type {
V2SessionListResponses,
V2SessionMessagesErrors,
V2SessionMessagesResponses,
V2SessionPermissionCreateErrors,
V2SessionPermissionCreateResponses,
V2SessionPermissionGetErrors,
V2SessionPermissionGetResponses,
V2SessionPermissionListErrors,
V2SessionPermissionListResponses,
V2SessionPermissionReplyErrors,
@@ -5183,6 +5188,93 @@ export class Permission2 extends HeyApiClient {
})
}
/**
* Create permission request
*
* Evaluate and, when approval is required, create a permission request for a session.
*/
public create<ThrowOnError extends boolean = false>(
parameters: {
sessionID: string
id?: string
action?: string
resources?: Array<string>
save?: Array<string>
metadata?: {
[key: string]: unknown
}
source?: PermissionV2Source
agent?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "sessionID" },
{ in: "body", key: "id" },
{ in: "body", key: "action" },
{ in: "body", key: "resources" },
{ in: "body", key: "save" },
{ in: "body", key: "metadata" },
{ in: "body", key: "source" },
{ in: "body", key: "agent" },
],
},
],
)
return (options?.client ?? this.client).post<
V2SessionPermissionCreateResponses,
V2SessionPermissionCreateErrors,
ThrowOnError
>({
url: "/api/session/{sessionID}/permission",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
/**
* Get permission request
*
* Retrieve a pending permission request owned by a session.
*/
public get<ThrowOnError extends boolean = false>(
parameters: {
sessionID: string
requestID: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "sessionID" },
{ in: "path", key: "requestID" },
],
},
],
)
return (options?.client ?? this.client).get<
V2SessionPermissionGetResponses,
V2SessionPermissionGetErrors,
ThrowOnError
>({
url: "/api/session/{sessionID}/permission/{requestID}",
...options,
...params,
})
}
/**
* Reply to pending permission request
*
+89
View File
@@ -12581,6 +12581,95 @@ export type V2SessionPermissionListResponses = {
export type V2SessionPermissionListResponse = V2SessionPermissionListResponses[keyof V2SessionPermissionListResponses]
export type V2SessionPermissionCreateData = {
body: {
id?: string
action: string
resources: Array<string>
save?: Array<string>
metadata?: {
[key: string]: unknown
}
source?: PermissionV2Source
agent?: string
}
path: {
sessionID: string
}
query?: never
url: "/api/session/{sessionID}/permission"
}
export type V2SessionPermissionCreateErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
/**
* SessionNotFoundError
*/
404: SessionNotFoundError
}
export type V2SessionPermissionCreateError = V2SessionPermissionCreateErrors[keyof V2SessionPermissionCreateErrors]
export type V2SessionPermissionCreateResponses = {
/**
* Success
*/
200: {
data: {
id: string
effect: PermissionV2Effect
}
}
}
export type V2SessionPermissionCreateResponse =
V2SessionPermissionCreateResponses[keyof V2SessionPermissionCreateResponses]
export type V2SessionPermissionGetData = {
body?: never
path: {
sessionID: string
requestID: string
}
query?: never
url: "/api/session/{sessionID}/permission/{requestID}"
}
export type V2SessionPermissionGetErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
/**
* SessionNotFoundError | PermissionNotFoundError
*/
404: PermissionNotFoundError | SessionNotFoundError
}
export type V2SessionPermissionGetError = V2SessionPermissionGetErrors[keyof V2SessionPermissionGetErrors]
export type V2SessionPermissionGetResponses = {
/**
* Success
*/
200: {
data: PermissionV2Request
}
}
export type V2SessionPermissionGetResponse = V2SessionPermissionGetResponses[keyof V2SessionPermissionGetResponses]
export type V2SessionPermissionReplyData = {
body: {
reply: PermissionV2Reply