From a433766a31fbf5c0597aec757de59a3d882c02fa Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Thu, 14 Aug 2025 16:24:46 -0400 Subject: allow plugins to create custom auth providers --- packages/sdk/js/src/gen/sdk.gen.ts | 20 +++++++++++++ packages/sdk/js/src/gen/types.gen.ts | 56 ++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) (limited to 'packages/sdk/js/src/gen') diff --git a/packages/sdk/js/src/gen/sdk.gen.ts b/packages/sdk/js/src/gen/sdk.gen.ts index 8a26dfa70..5dd8552d5 100644 --- a/packages/sdk/js/src/gen/sdk.gen.ts +++ b/packages/sdk/js/src/gen/sdk.gen.ts @@ -77,6 +77,9 @@ import type { TuiClearPromptResponses, TuiExecuteCommandData, TuiExecuteCommandResponses, + AuthSetData, + AuthSetResponses, + AuthSetErrors, } from "./types.gen.js" import { client as _heyApiClient } from "./client.gen.js" @@ -517,6 +520,22 @@ class Tui extends _HeyApiClient { } } +class Auth extends _HeyApiClient { + /** + * Set authentication credentials + */ + public set(options: Options) { + return (options.client ?? this._client).put({ + url: "/auth/{id}", + ...options, + headers: { + "Content-Type": "application/json", + ...options.headers, + }, + }) + } +} + export class OpencodeClient extends _HeyApiClient { /** * Respond to a permission request @@ -544,4 +563,5 @@ export class OpencodeClient extends _HeyApiClient { find = new Find({ client: this._client }) file = new File({ client: this._client }) tui = new Tui({ client: this._client }) + auth = new Auth({ client: this._client }) } diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index 3652ea584..d2b990469 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/packages/sdk/js/src/gen/types.gen.ts @@ -1105,6 +1105,35 @@ export type Agent = { } } +export type Auth = + | ({ + type: "oauth" + } & OAuth) + | ({ + type: "api" + } & ApiAuth) + | ({ + type: "wellknown" + } & WellKnownAuth) + +export type OAuth = { + type: "oauth" + refresh: string + access: string + expires: number +} + +export type ApiAuth = { + type: "api" + key: string +} + +export type WellKnownAuth = { + type: "wellknown" + key: string + token: string +} + export type EventSubscribeData = { body?: never path?: never @@ -1858,6 +1887,33 @@ export type TuiExecuteCommandResponses = { export type TuiExecuteCommandResponse = TuiExecuteCommandResponses[keyof TuiExecuteCommandResponses] +export type AuthSetData = { + body?: Auth + path: { + id: string + } + query?: never + url: "/auth/{id}" +} + +export type AuthSetErrors = { + /** + * Bad request + */ + 400: _Error +} + +export type AuthSetError = AuthSetErrors[keyof AuthSetErrors] + +export type AuthSetResponses = { + /** + * Successfully set authentication credentials + */ + 200: boolean +} + +export type AuthSetResponse = AuthSetResponses[keyof AuthSetResponses] + export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}) } -- cgit v1.2.3