mirror of
https://github.com/anomalyco/opencode.git
synced 2026-06-02 06:16:48 +02:00
feat(core): add location-based permission service (#30287)
This commit is contained in:
@@ -117,6 +117,7 @@ import type {
|
||||
PermissionRespondErrors,
|
||||
PermissionRespondResponses,
|
||||
PermissionRuleset,
|
||||
PermissionV2Reply,
|
||||
ProjectCurrentErrors,
|
||||
ProjectCurrentResponses,
|
||||
ProjectInitGitErrors,
|
||||
@@ -248,6 +249,12 @@ import type {
|
||||
TuiSubmitPromptResponses,
|
||||
V2ModelListErrors,
|
||||
V2ModelListResponses,
|
||||
V2PermissionRequestListErrors,
|
||||
V2PermissionRequestListResponses,
|
||||
V2PermissionSavedListErrors,
|
||||
V2PermissionSavedListResponses,
|
||||
V2PermissionSavedRemoveErrors,
|
||||
V2PermissionSavedRemoveResponses,
|
||||
V2ProviderGetErrors,
|
||||
V2ProviderGetResponses,
|
||||
V2ProviderListErrors,
|
||||
@@ -260,6 +267,10 @@ import type {
|
||||
V2SessionListResponses,
|
||||
V2SessionMessagesErrors,
|
||||
V2SessionMessagesResponses,
|
||||
V2SessionPermissionListErrors,
|
||||
V2SessionPermissionListResponses,
|
||||
V2SessionPermissionReplyErrors,
|
||||
V2SessionPermissionReplyResponses,
|
||||
V2SessionPromptErrors,
|
||||
V2SessionPromptResponses,
|
||||
V2SessionWaitErrors,
|
||||
@@ -4255,6 +4266,74 @@ export class Sync extends HeyApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
export class Permission2 extends HeyApiClient {
|
||||
/**
|
||||
* List session permission requests
|
||||
*
|
||||
* Retrieve pending permission requests owned by a session.
|
||||
*/
|
||||
public list<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
sessionID: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
|
||||
return (options?.client ?? this.client).get<
|
||||
V2SessionPermissionListResponses,
|
||||
V2SessionPermissionListErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/session/{sessionID}/permission/request",
|
||||
...options,
|
||||
...params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Reply to pending permission request
|
||||
*
|
||||
* Respond to a pending permission request owned by a session.
|
||||
*/
|
||||
public reply<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
sessionID: string
|
||||
requestID: string
|
||||
reply?: PermissionV2Reply
|
||||
message?: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams(
|
||||
[parameters],
|
||||
[
|
||||
{
|
||||
args: [
|
||||
{ in: "path", key: "sessionID" },
|
||||
{ in: "path", key: "requestID" },
|
||||
{ in: "body", key: "reply" },
|
||||
{ in: "body", key: "message" },
|
||||
],
|
||||
},
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).post<
|
||||
V2SessionPermissionReplyResponses,
|
||||
V2SessionPermissionReplyErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/session/{sessionID}/permission/request/{requestID}/reply",
|
||||
...options,
|
||||
...params,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
...params.headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class Session3 extends HeyApiClient {
|
||||
/**
|
||||
* List v2 sessions
|
||||
@@ -4474,6 +4553,11 @@ export class Session3 extends HeyApiClient {
|
||||
...params,
|
||||
})
|
||||
}
|
||||
|
||||
private _permission?: Permission2
|
||||
get permission(): Permission2 {
|
||||
return (this._permission ??= new Permission2({ client: this.client }))
|
||||
}
|
||||
}
|
||||
|
||||
export class Model extends HeyApiClient {
|
||||
@@ -4557,6 +4641,94 @@ export class Provider2 extends HeyApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
export class Request extends HeyApiClient {
|
||||
/**
|
||||
* List pending permission requests
|
||||
*
|
||||
* Retrieve pending permission requests for a location.
|
||||
*/
|
||||
public list<ThrowOnError extends boolean = false>(
|
||||
parameters?: {
|
||||
location?: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
}
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "location" }] }])
|
||||
return (options?.client ?? this.client).get<
|
||||
V2PermissionRequestListResponses,
|
||||
V2PermissionRequestListErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/permission/request",
|
||||
...options,
|
||||
...params,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class Saved extends HeyApiClient {
|
||||
/**
|
||||
* List saved permissions
|
||||
*
|
||||
* Retrieve saved permissions, optionally filtered by project.
|
||||
*/
|
||||
public list<ThrowOnError extends boolean = false>(
|
||||
parameters?: {
|
||||
projectID?: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "projectID" }] }])
|
||||
return (options?.client ?? this.client).get<
|
||||
V2PermissionSavedListResponses,
|
||||
V2PermissionSavedListErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/permission/saved",
|
||||
...options,
|
||||
...params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove saved permission
|
||||
*
|
||||
* Remove a saved permission by ID.
|
||||
*/
|
||||
public remove<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
id: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "id" }] }])
|
||||
return (options?.client ?? this.client).delete<
|
||||
V2PermissionSavedRemoveResponses,
|
||||
V2PermissionSavedRemoveErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/permission/saved/{id}",
|
||||
...options,
|
||||
...params,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class Permission3 extends HeyApiClient {
|
||||
private _request?: Request
|
||||
get request(): Request {
|
||||
return (this._request ??= new Request({ client: this.client }))
|
||||
}
|
||||
|
||||
private _saved?: Saved
|
||||
get saved(): Saved {
|
||||
return (this._saved ??= new Saved({ client: this.client }))
|
||||
}
|
||||
}
|
||||
|
||||
export class V2 extends HeyApiClient {
|
||||
private _session?: Session3
|
||||
get session(): Session3 {
|
||||
@@ -4572,6 +4744,11 @@ export class V2 extends HeyApiClient {
|
||||
get provider(): Provider2 {
|
||||
return (this._provider ??= new Provider2({ client: this.client }))
|
||||
}
|
||||
|
||||
private _permission?: Permission3
|
||||
get permission(): Permission3 {
|
||||
return (this._permission ??= new Permission3({ client: this.client }))
|
||||
}
|
||||
}
|
||||
|
||||
export class Control extends HeyApiClient {
|
||||
|
||||
@@ -44,10 +44,10 @@ export type Event =
|
||||
| EventMessagePartUpdated
|
||||
| EventMessagePartRemoved
|
||||
| EventMessagePartDelta
|
||||
| EventPermissionAsked
|
||||
| EventPermissionReplied
|
||||
| EventSessionDiff
|
||||
| EventSessionError
|
||||
| EventPermissionAsked
|
||||
| EventPermissionReplied
|
||||
| EventQuestionAsked
|
||||
| EventQuestionReplied
|
||||
| EventQuestionRejected
|
||||
@@ -78,6 +78,8 @@ export type Event =
|
||||
| EventInstallationUpdateAvailable
|
||||
| EventServerConnected
|
||||
| EventGlobalDisposed
|
||||
| EventPermissionV2Asked
|
||||
| EventPermissionV2Replied
|
||||
| EventAccountAdded
|
||||
| EventAccountRemoved
|
||||
| EventAccountSwitched
|
||||
@@ -145,6 +147,16 @@ export type SnapshotFileDiff = {
|
||||
status?: "added" | "deleted" | "modified"
|
||||
}
|
||||
|
||||
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
|
||||
slug: string
|
||||
@@ -1094,6 +1106,29 @@ export type GlobalEvent = {
|
||||
delta: string
|
||||
}
|
||||
}
|
||||
| {
|
||||
id: string
|
||||
type: "session.diff"
|
||||
properties: {
|
||||
sessionID: string
|
||||
diff: Array<SnapshotFileDiff>
|
||||
}
|
||||
}
|
||||
| {
|
||||
id: string
|
||||
type: "session.error"
|
||||
properties: {
|
||||
sessionID?: string
|
||||
error?:
|
||||
| ProviderAuthError
|
||||
| UnknownError
|
||||
| MessageOutputLengthError
|
||||
| MessageAbortedError
|
||||
| StructuredOutputError
|
||||
| ContextOverflowError
|
||||
| ApiError
|
||||
}
|
||||
}
|
||||
| {
|
||||
id: string
|
||||
type: "permission.asked"
|
||||
@@ -1121,29 +1156,6 @@ export type GlobalEvent = {
|
||||
reply: "once" | "always" | "reject"
|
||||
}
|
||||
}
|
||||
| {
|
||||
id: string
|
||||
type: "session.diff"
|
||||
properties: {
|
||||
sessionID: string
|
||||
diff: Array<SnapshotFileDiff>
|
||||
}
|
||||
}
|
||||
| {
|
||||
id: string
|
||||
type: "session.error"
|
||||
properties: {
|
||||
sessionID?: string
|
||||
error?:
|
||||
| ProviderAuthError
|
||||
| UnknownError
|
||||
| MessageOutputLengthError
|
||||
| MessageAbortedError
|
||||
| StructuredOutputError
|
||||
| ContextOverflowError
|
||||
| ApiError
|
||||
}
|
||||
}
|
||||
| {
|
||||
id: string
|
||||
type: "question.asked"
|
||||
@@ -1415,6 +1427,30 @@ export type GlobalEvent = {
|
||||
[key: string]: unknown
|
||||
}
|
||||
}
|
||||
| {
|
||||
id: string
|
||||
type: "permission.v2.asked"
|
||||
properties: {
|
||||
id: string
|
||||
sessionID: string
|
||||
action: string
|
||||
resources: Array<string>
|
||||
save?: Array<string>
|
||||
metadata?: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
source?: PermissionV2Source
|
||||
}
|
||||
}
|
||||
| {
|
||||
id: string
|
||||
type: "permission.v2.replied"
|
||||
properties: {
|
||||
sessionID: string
|
||||
requestID: string
|
||||
reply: PermissionV2Reply
|
||||
}
|
||||
}
|
||||
| {
|
||||
id: string
|
||||
type: "account.added"
|
||||
@@ -2029,16 +2065,6 @@ export type WorktreeResetInput = {
|
||||
directory: string
|
||||
}
|
||||
|
||||
export type PermissionAction = "allow" | "deny" | "ask"
|
||||
|
||||
export type PermissionRule = {
|
||||
permission: string
|
||||
pattern: string
|
||||
action: PermissionAction
|
||||
}
|
||||
|
||||
export type PermissionRuleset = Array<PermissionRule>
|
||||
|
||||
export type ProjectSummary = {
|
||||
id: string
|
||||
name?: string
|
||||
@@ -2811,6 +2837,14 @@ export type SessionNextRetryError = {
|
||||
}
|
||||
}
|
||||
|
||||
export type PermissionV2Source = {
|
||||
type: "tool"
|
||||
messageID: string
|
||||
callID: string
|
||||
}
|
||||
|
||||
export type PermissionV2Reply = "once" | "always" | "reject"
|
||||
|
||||
export type AuthOAuthCredential = {
|
||||
type: "oauth"
|
||||
refresh: string
|
||||
@@ -3637,6 +3671,25 @@ export type ProviderV2Info = {
|
||||
}
|
||||
}
|
||||
|
||||
export type PermissionV2Request = {
|
||||
id: string
|
||||
sessionID: string
|
||||
action: string
|
||||
resources: Array<string>
|
||||
save?: Array<string>
|
||||
metadata?: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
source?: PermissionV2Source
|
||||
}
|
||||
|
||||
export type PermissionSavedInfo = {
|
||||
id: string
|
||||
projectID: string
|
||||
action: string
|
||||
resource: string
|
||||
}
|
||||
|
||||
export type EventModelsDevRefreshed = {
|
||||
id: string
|
||||
type: "models-dev.refreshed"
|
||||
@@ -4173,6 +4226,31 @@ export type EventMessagePartDelta = {
|
||||
}
|
||||
}
|
||||
|
||||
export type EventSessionDiff = {
|
||||
id: string
|
||||
type: "session.diff"
|
||||
properties: {
|
||||
sessionID: string
|
||||
diff: Array<SnapshotFileDiff>
|
||||
}
|
||||
}
|
||||
|
||||
export type EventSessionError = {
|
||||
id: string
|
||||
type: "session.error"
|
||||
properties: {
|
||||
sessionID?: string
|
||||
error?:
|
||||
| ProviderAuthError
|
||||
| UnknownError
|
||||
| MessageOutputLengthError
|
||||
| MessageAbortedError
|
||||
| StructuredOutputError
|
||||
| ContextOverflowError
|
||||
| ApiError
|
||||
}
|
||||
}
|
||||
|
||||
export type EventPermissionAsked = {
|
||||
id: string
|
||||
type: "permission.asked"
|
||||
@@ -4202,31 +4280,6 @@ export type EventPermissionReplied = {
|
||||
}
|
||||
}
|
||||
|
||||
export type EventSessionDiff = {
|
||||
id: string
|
||||
type: "session.diff"
|
||||
properties: {
|
||||
sessionID: string
|
||||
diff: Array<SnapshotFileDiff>
|
||||
}
|
||||
}
|
||||
|
||||
export type EventSessionError = {
|
||||
id: string
|
||||
type: "session.error"
|
||||
properties: {
|
||||
sessionID?: string
|
||||
error?:
|
||||
| ProviderAuthError
|
||||
| UnknownError
|
||||
| MessageOutputLengthError
|
||||
| MessageAbortedError
|
||||
| StructuredOutputError
|
||||
| ContextOverflowError
|
||||
| ApiError
|
||||
}
|
||||
}
|
||||
|
||||
export type EventQuestionAsked = {
|
||||
id: string
|
||||
type: "question.asked"
|
||||
@@ -4473,6 +4526,32 @@ export type EventGlobalDisposed = {
|
||||
}
|
||||
}
|
||||
|
||||
export type EventPermissionV2Asked = {
|
||||
id: string
|
||||
type: "permission.v2.asked"
|
||||
properties: {
|
||||
id: string
|
||||
sessionID: string
|
||||
action: string
|
||||
resources: Array<string>
|
||||
save?: Array<string>
|
||||
metadata?: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
source?: PermissionV2Source
|
||||
}
|
||||
}
|
||||
|
||||
export type EventPermissionV2Replied = {
|
||||
id: string
|
||||
type: "permission.v2.replied"
|
||||
properties: {
|
||||
sessionID: string
|
||||
requestID: string
|
||||
reply: PermissionV2Reply
|
||||
}
|
||||
}
|
||||
|
||||
export type EventAccountAdded = {
|
||||
id: string
|
||||
type: "account.added"
|
||||
@@ -8262,6 +8341,177 @@ export type V2ProviderGetResponses = {
|
||||
|
||||
export type V2ProviderGetResponse = V2ProviderGetResponses[keyof V2ProviderGetResponses]
|
||||
|
||||
export type V2PermissionRequestListData = {
|
||||
body?: never
|
||||
path?: never
|
||||
query?: {
|
||||
location?: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
}
|
||||
}
|
||||
url: "/api/permission/request"
|
||||
}
|
||||
|
||||
export type V2PermissionRequestListErrors = {
|
||||
/**
|
||||
* InvalidRequestError
|
||||
*/
|
||||
400: InvalidRequestError
|
||||
/**
|
||||
* UnauthorizedError
|
||||
*/
|
||||
401: UnauthorizedError
|
||||
}
|
||||
|
||||
export type V2PermissionRequestListError = V2PermissionRequestListErrors[keyof V2PermissionRequestListErrors]
|
||||
|
||||
export type V2PermissionRequestListResponses = {
|
||||
/**
|
||||
* Success
|
||||
*/
|
||||
200: Array<PermissionV2Request>
|
||||
}
|
||||
|
||||
export type V2PermissionRequestListResponse = V2PermissionRequestListResponses[keyof V2PermissionRequestListResponses]
|
||||
|
||||
export type V2SessionPermissionListData = {
|
||||
body?: never
|
||||
path: {
|
||||
sessionID: string
|
||||
}
|
||||
query?: never
|
||||
url: "/api/session/{sessionID}/permission/request"
|
||||
}
|
||||
|
||||
export type V2SessionPermissionListErrors = {
|
||||
/**
|
||||
* InvalidRequestError
|
||||
*/
|
||||
400: InvalidRequestError
|
||||
/**
|
||||
* UnauthorizedError
|
||||
*/
|
||||
401: UnauthorizedError
|
||||
/**
|
||||
* SessionNotFoundError
|
||||
*/
|
||||
404: SessionNotFoundError
|
||||
}
|
||||
|
||||
export type V2SessionPermissionListError = V2SessionPermissionListErrors[keyof V2SessionPermissionListErrors]
|
||||
|
||||
export type V2SessionPermissionListResponses = {
|
||||
/**
|
||||
* Success
|
||||
*/
|
||||
200: Array<PermissionV2Request>
|
||||
}
|
||||
|
||||
export type V2SessionPermissionListResponse = V2SessionPermissionListResponses[keyof V2SessionPermissionListResponses]
|
||||
|
||||
export type V2SessionPermissionReplyData = {
|
||||
body?: {
|
||||
reply: PermissionV2Reply
|
||||
message?: string
|
||||
}
|
||||
path: {
|
||||
sessionID: string
|
||||
requestID: string
|
||||
}
|
||||
query?: never
|
||||
url: "/api/session/{sessionID}/permission/request/{requestID}/reply"
|
||||
}
|
||||
|
||||
export type V2SessionPermissionReplyErrors = {
|
||||
/**
|
||||
* InvalidRequestError
|
||||
*/
|
||||
400: InvalidRequestError
|
||||
/**
|
||||
* UnauthorizedError
|
||||
*/
|
||||
401: UnauthorizedError
|
||||
/**
|
||||
* SessionNotFoundError | PermissionNotFoundError
|
||||
*/
|
||||
404: SessionNotFoundError | PermissionNotFoundError
|
||||
}
|
||||
|
||||
export type V2SessionPermissionReplyError = V2SessionPermissionReplyErrors[keyof V2SessionPermissionReplyErrors]
|
||||
|
||||
export type V2SessionPermissionReplyResponses = {
|
||||
/**
|
||||
* <No Content>
|
||||
*/
|
||||
204: void
|
||||
}
|
||||
|
||||
export type V2SessionPermissionReplyResponse =
|
||||
V2SessionPermissionReplyResponses[keyof V2SessionPermissionReplyResponses]
|
||||
|
||||
export type V2PermissionSavedListData = {
|
||||
body?: never
|
||||
path?: never
|
||||
query?: {
|
||||
projectID?: string
|
||||
}
|
||||
url: "/api/permission/saved"
|
||||
}
|
||||
|
||||
export type V2PermissionSavedListErrors = {
|
||||
/**
|
||||
* InvalidRequestError
|
||||
*/
|
||||
400: InvalidRequestError
|
||||
/**
|
||||
* UnauthorizedError
|
||||
*/
|
||||
401: UnauthorizedError
|
||||
}
|
||||
|
||||
export type V2PermissionSavedListError = V2PermissionSavedListErrors[keyof V2PermissionSavedListErrors]
|
||||
|
||||
export type V2PermissionSavedListResponses = {
|
||||
/**
|
||||
* Success
|
||||
*/
|
||||
200: Array<PermissionSavedInfo>
|
||||
}
|
||||
|
||||
export type V2PermissionSavedListResponse = V2PermissionSavedListResponses[keyof V2PermissionSavedListResponses]
|
||||
|
||||
export type V2PermissionSavedRemoveData = {
|
||||
body?: never
|
||||
path: {
|
||||
id: string
|
||||
}
|
||||
query?: never
|
||||
url: "/api/permission/saved/{id}"
|
||||
}
|
||||
|
||||
export type V2PermissionSavedRemoveErrors = {
|
||||
/**
|
||||
* InvalidRequestError
|
||||
*/
|
||||
400: InvalidRequestError
|
||||
/**
|
||||
* UnauthorizedError
|
||||
*/
|
||||
401: UnauthorizedError
|
||||
}
|
||||
|
||||
export type V2PermissionSavedRemoveError = V2PermissionSavedRemoveErrors[keyof V2PermissionSavedRemoveErrors]
|
||||
|
||||
export type V2PermissionSavedRemoveResponses = {
|
||||
/**
|
||||
* <No Content>
|
||||
*/
|
||||
204: void
|
||||
}
|
||||
|
||||
export type V2PermissionSavedRemoveResponse = V2PermissionSavedRemoveResponses[keyof V2PermissionSavedRemoveResponses]
|
||||
|
||||
export type TuiAppendPromptData = {
|
||||
body?: {
|
||||
text: string
|
||||
|
||||
Reference in New Issue
Block a user