feat(core): add connector authentication (#31837)

This commit is contained in:
Dax
2026-06-11 06:31:17 +00:00
committed by GitHub
parent bf05e8a122
commit dac0dd5309
47 changed files with 5433 additions and 862 deletions
+310
View File
@@ -265,6 +265,20 @@ import type {
V2AgentListResponses,
V2CommandListErrors,
V2CommandListResponses,
V2ConnectorConnectKeyErrors,
V2ConnectorConnectKeyResponses,
V2ConnectorConnectOauthBeginErrors,
V2ConnectorConnectOauthBeginResponses,
V2ConnectorConnectOauthCancelErrors,
V2ConnectorConnectOauthCancelResponses,
V2ConnectorConnectOauthCompleteErrors,
V2ConnectorConnectOauthCompleteResponses,
V2ConnectorConnectOauthStatusErrors,
V2ConnectorConnectOauthStatusResponses,
V2ConnectorGetErrors,
V2ConnectorGetResponses,
V2ConnectorListErrors,
V2ConnectorListResponses,
V2EventSubscribeErrors,
V2EventSubscribeResponses,
V2FsFindErrors,
@@ -5567,6 +5581,297 @@ export class Provider2 extends HeyApiClient {
}
}
export class Oauth2 extends HeyApiClient {
/**
* Begin OAuth connection
*
* Start an OAuth attempt and return the authorization details.
*/
public begin<ThrowOnError extends boolean = false>(
parameters: {
connectorID: string
location?: {
directory?: string
workspace?: string
}
methodID?: string
inputs?: {
[key: string]: string
}
label?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "connectorID" },
{ in: "query", key: "location" },
{ in: "body", key: "methodID" },
{ in: "body", key: "inputs" },
{ in: "body", key: "label" },
],
},
],
)
return (options?.client ?? this.client).post<
V2ConnectorConnectOauthBeginResponses,
V2ConnectorConnectOauthBeginErrors,
ThrowOnError
>({
url: "/api/connector/{connectorID}/connect/oauth",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
/**
* Cancel OAuth connection
*
* Cancel an OAuth attempt and release its resources.
*/
public cancel<ThrowOnError extends boolean = false>(
parameters: {
attemptID: string
location?: {
directory?: string
workspace?: string
}
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "attemptID" },
{ in: "query", key: "location" },
],
},
],
)
return (options?.client ?? this.client).delete<
V2ConnectorConnectOauthCancelResponses,
V2ConnectorConnectOauthCancelErrors,
ThrowOnError
>({
url: "/api/connector/oauth/{attemptID}",
...options,
...params,
})
}
/**
* Get OAuth attempt status
*
* Poll the current status of an OAuth attempt.
*/
public status<ThrowOnError extends boolean = false>(
parameters: {
attemptID: string
location?: {
directory?: string
workspace?: string
}
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "attemptID" },
{ in: "query", key: "location" },
],
},
],
)
return (options?.client ?? this.client).get<
V2ConnectorConnectOauthStatusResponses,
V2ConnectorConnectOauthStatusErrors,
ThrowOnError
>({
url: "/api/connector/oauth/{attemptID}",
...options,
...params,
})
}
/**
* Complete OAuth connection
*
* Complete a code-based OAuth attempt and store the resulting credential.
*/
public complete<ThrowOnError extends boolean = false>(
parameters: {
attemptID: string
location?: {
directory?: string
workspace?: string
}
code?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "attemptID" },
{ in: "query", key: "location" },
{ in: "body", key: "code" },
],
},
],
)
return (options?.client ?? this.client).post<
V2ConnectorConnectOauthCompleteResponses,
V2ConnectorConnectOauthCompleteErrors,
ThrowOnError
>({
url: "/api/connector/oauth/{attemptID}/complete",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
}
export class Connect extends HeyApiClient {
/**
* Connect with key
*
* Run a key authentication method and store the resulting credential.
*/
public key<ThrowOnError extends boolean = false>(
parameters: {
connectorID: string
location?: {
directory?: string
workspace?: string
}
methodID?: string
key?: string
inputs?: {
[key: string]: string
}
label?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "connectorID" },
{ in: "query", key: "location" },
{ in: "body", key: "methodID" },
{ in: "body", key: "key" },
{ in: "body", key: "inputs" },
{ in: "body", key: "label" },
],
},
],
)
return (options?.client ?? this.client).post<
V2ConnectorConnectKeyResponses,
V2ConnectorConnectKeyErrors,
ThrowOnError
>({
url: "/api/connector/{connectorID}/connect/key",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
private _oauth?: Oauth2
get oauth(): Oauth2 {
return (this._oauth ??= new Oauth2({ client: this.client }))
}
}
export class Connector extends HeyApiClient {
/**
* List connectors
*
* Retrieve available connectors and their authentication methods.
*/
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<V2ConnectorListResponses, V2ConnectorListErrors, ThrowOnError>({
url: "/api/connector",
...options,
...params,
})
}
/**
* Get connector
*
* Retrieve one connector and its authentication methods.
*/
public get<ThrowOnError extends boolean = false>(
parameters: {
connectorID: string
location?: {
directory?: string
workspace?: string
}
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "connectorID" },
{ in: "query", key: "location" },
],
},
],
)
return (options?.client ?? this.client).get<V2ConnectorGetResponses, V2ConnectorGetErrors, ThrowOnError>({
url: "/api/connector/{connectorID}",
...options,
...params,
})
}
private _connect?: Connect
get connect(): Connect {
return (this._connect ??= new Connect({ client: this.client }))
}
}
export class Request extends HeyApiClient {
/**
* List pending permission requests
@@ -5922,6 +6227,11 @@ export class V2 extends HeyApiClient {
return (this._provider ??= new Provider2({ client: this.client }))
}
private _connector?: Connector
get connector(): Connector {
return (this._connector ??= new Connector({ client: this.client }))
}
private _permission?: Permission3
get permission(): Permission3 {
return (this._permission ??= new Permission3({ client: this.client }))
+459 -68
View File
@@ -6,6 +6,9 @@ export type ClientOptions = {
export type Event =
| EventModelsDevRefreshed
| EventCredentialAdded
| EventCredentialRemoved
| EventCredentialSwitched
| EventPluginAdded
| EventCatalogModelUpdated
| EventSessionCreated
@@ -52,9 +55,7 @@ export type Event =
| EventInstallationUpdated
| EventInstallationUpdateAvailable
| EventFileEdited
| EventAccountAdded
| EventAccountRemoved
| EventAccountSwitched
| EventConnectorUpdated
| EventPermissionV2Asked
| EventPermissionV2Replied
| EventReferenceUpdated
@@ -730,6 +731,29 @@ export type GlobalEvent = {
[key: string]: unknown
}
}
| {
id: string
type: "credential.added"
properties: {
credential: CredentialInfo
}
}
| {
id: string
type: "credential.removed"
properties: {
credential: CredentialInfo
}
}
| {
id: string
type: "credential.switched"
properties: {
connectorID: string
from?: string
to?: string
}
}
| {
id: string
type: "plugin.added"
@@ -1251,25 +1275,9 @@ export type GlobalEvent = {
}
| {
id: string
type: "account.added"
type: "connector.updated"
properties: {
account: AuthInfo
}
}
| {
id: string
type: "account.removed"
properties: {
account: AuthInfo
}
}
| {
id: string
type: "account.switched"
properties: {
serviceID: string
from?: string
to?: string
[key: string]: unknown
}
}
| {
@@ -2838,6 +2846,34 @@ export type MoveSessionDestination = {
directory: string
}
export type CredentialOAuth = {
type: "oauth"
refresh: string
access: string
expires: number
metadata?: {
[key: string]: string
}
}
export type CredentialKey = {
type: "key"
key: string
metadata?: {
[key: string]: string
}
}
export type CredentialValue = CredentialOAuth | CredentialKey
export type CredentialInfo = {
id: string
connectorID: string
methodID: string
label: string
value: CredentialValue
}
export type ModelV2Info = {
id: string
providerID: string
@@ -2988,30 +3024,6 @@ export type SessionNextRetryError = {
}
}
export type AuthOAuthCredential = {
type: "oauth"
refresh: string
access: string
expires: number
}
export type AuthApiKeyCredential = {
type: "api"
key: string
metadata?: {
[key: string]: string
}
}
export type AuthCredential = AuthOAuthCredential | AuthApiKeyCredential
export type AuthInfo = {
id: string
serviceID: string
description: string
credential: AuthCredential
}
export type PermissionV2Source = {
type: "tool"
messageID: string
@@ -4062,8 +4074,8 @@ export type ProviderV2Info = {
name: string
}
| {
via: "account"
service: string
via: "credential"
credentialID: string
}
| {
via: "custom"
@@ -4098,6 +4110,63 @@ export type ProviderV2Info = {
}
}
export type ConnectorWhen = {
key: string
op: "eq" | "neq"
value: string
}
export type ConnectorTextPrompt = {
type: "text"
key: string
message: string
placeholder?: string
when?: ConnectorWhen
}
export type ConnectorSelectPrompt = {
type: "select"
key: string
message: string
options: Array<{
label: string
value: string
hint?: string
}>
when?: ConnectorWhen
}
export type ConnectorOAuthMethod = {
id: string
type: "oauth"
label: string
prompts?: Array<ConnectorTextPrompt | ConnectorSelectPrompt>
}
export type ConnectorKeyMethod = {
id: string
type: "key"
label: string
prompts?: Array<ConnectorTextPrompt | ConnectorSelectPrompt>
}
export type ConnectorInfo = {
id: string
name: string
methods: Array<ConnectorOAuthMethod | ConnectorKeyMethod>
}
export type ConnectorAttempt = {
attemptID: string
url: string
instructions: string
mode: "auto" | "code"
time: {
created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}
}
export type PermissionV2Request = {
id: string
sessionID: string
@@ -4200,6 +4269,32 @@ export type EventModelsDevRefreshed = {
}
}
export type EventCredentialAdded = {
id: string
type: "credential.added"
properties: {
credential: CredentialInfo
}
}
export type EventCredentialRemoved = {
id: string
type: "credential.removed"
properties: {
credential: CredentialInfo
}
}
export type EventCredentialSwitched = {
id: string
type: "credential.switched"
properties: {
connectorID: string
from?: string
to?: string
}
}
export type EventPluginAdded = {
id: string
type: "plugin.added"
@@ -4861,29 +4956,11 @@ export type EventFileEdited = {
}
}
export type EventAccountAdded = {
export type EventConnectorUpdated = {
id: string
type: "account.added"
type: "connector.updated"
properties: {
account: AuthInfo
}
}
export type EventAccountRemoved = {
id: string
type: "account.removed"
properties: {
account: AuthInfo
}
}
export type EventAccountSwitched = {
id: string
type: "account.switched"
properties: {
serviceID: string
from?: string
to?: string
[key: string]: unknown
}
}
@@ -9982,6 +10059,320 @@ export type V2ProviderGetResponses = {
export type V2ProviderGetResponse = V2ProviderGetResponses[keyof V2ProviderGetResponses]
export type V2ConnectorListData = {
body?: never
path?: never
query?: {
location?: {
directory?: string
workspace?: string
}
}
url: "/api/connector"
}
export type V2ConnectorListErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2ConnectorListError = V2ConnectorListErrors[keyof V2ConnectorListErrors]
export type V2ConnectorListResponses = {
/**
* Success
*/
200: {
location: LocationInfo
data: Array<ConnectorInfo>
}
}
export type V2ConnectorListResponse = V2ConnectorListResponses[keyof V2ConnectorListResponses]
export type V2ConnectorGetData = {
body?: never
path: {
connectorID: string
}
query?: {
location?: {
directory?: string
workspace?: string
}
}
url: "/api/connector/{connectorID}"
}
export type V2ConnectorGetErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2ConnectorGetError = V2ConnectorGetErrors[keyof V2ConnectorGetErrors]
export type V2ConnectorGetResponses = {
/**
* Success
*/
200: {
location: LocationInfo
data: ConnectorInfo
}
}
export type V2ConnectorGetResponse = V2ConnectorGetResponses[keyof V2ConnectorGetResponses]
export type V2ConnectorConnectKeyData = {
body: {
methodID: string
key: string
inputs: {
[key: string]: string
}
label?: string
}
path: {
connectorID: string
}
query?: {
location?: {
directory?: string
workspace?: string
}
}
url: "/api/connector/{connectorID}/connect/key"
}
export type V2ConnectorConnectKeyErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2ConnectorConnectKeyError = V2ConnectorConnectKeyErrors[keyof V2ConnectorConnectKeyErrors]
export type V2ConnectorConnectKeyResponses = {
/**
* <No Content>
*/
204: void
}
export type V2ConnectorConnectKeyResponse = V2ConnectorConnectKeyResponses[keyof V2ConnectorConnectKeyResponses]
export type V2ConnectorConnectOauthBeginData = {
body: {
methodID: string
inputs: {
[key: string]: string
}
label?: string
}
path: {
connectorID: string
}
query?: {
location?: {
directory?: string
workspace?: string
}
}
url: "/api/connector/{connectorID}/connect/oauth"
}
export type V2ConnectorConnectOauthBeginErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2ConnectorConnectOauthBeginError =
V2ConnectorConnectOauthBeginErrors[keyof V2ConnectorConnectOauthBeginErrors]
export type V2ConnectorConnectOauthBeginResponses = {
/**
* Success
*/
200: {
location: LocationInfo
data: ConnectorAttempt
}
}
export type V2ConnectorConnectOauthBeginResponse =
V2ConnectorConnectOauthBeginResponses[keyof V2ConnectorConnectOauthBeginResponses]
export type V2ConnectorConnectOauthCancelData = {
body?: never
path: {
attemptID: string
}
query?: {
location?: {
directory?: string
workspace?: string
}
}
url: "/api/connector/oauth/{attemptID}"
}
export type V2ConnectorConnectOauthCancelErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2ConnectorConnectOauthCancelError =
V2ConnectorConnectOauthCancelErrors[keyof V2ConnectorConnectOauthCancelErrors]
export type V2ConnectorConnectOauthCancelResponses = {
/**
* <No Content>
*/
204: void
}
export type V2ConnectorConnectOauthCancelResponse =
V2ConnectorConnectOauthCancelResponses[keyof V2ConnectorConnectOauthCancelResponses]
export type V2ConnectorConnectOauthStatusData = {
body?: never
path: {
attemptID: string
}
query?: {
location?: {
directory?: string
workspace?: string
}
}
url: "/api/connector/oauth/{attemptID}"
}
export type V2ConnectorConnectOauthStatusErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2ConnectorConnectOauthStatusError =
V2ConnectorConnectOauthStatusErrors[keyof V2ConnectorConnectOauthStatusErrors]
export type V2ConnectorConnectOauthStatusResponses = {
/**
* Success
*/
200: {
location: LocationInfo
data:
| {
status: "pending"
time: {
created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}
}
| {
status: "complete"
time: {
created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}
}
| {
status: "failed"
message: string
time: {
created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}
}
| {
status: "expired"
time: {
created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}
}
}
}
export type V2ConnectorConnectOauthStatusResponse =
V2ConnectorConnectOauthStatusResponses[keyof V2ConnectorConnectOauthStatusResponses]
export type V2ConnectorConnectOauthCompleteData = {
body: {
code?: string
}
path: {
attemptID: string
}
query?: {
location?: {
directory?: string
workspace?: string
}
}
url: "/api/connector/oauth/{attemptID}/complete"
}
export type V2ConnectorConnectOauthCompleteErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2ConnectorConnectOauthCompleteError =
V2ConnectorConnectOauthCompleteErrors[keyof V2ConnectorConnectOauthCompleteErrors]
export type V2ConnectorConnectOauthCompleteResponses = {
/**
* <No Content>
*/
204: void
}
export type V2ConnectorConnectOauthCompleteResponse =
V2ConnectorConnectOauthCompleteResponses[keyof V2ConnectorConnectOauthCompleteResponses]
export type V2PermissionRequestListData = {
body?: never
path?: never