refactor(core): split out instance and route through workspaces (#19335)

This commit is contained in:
James Long
2026-03-27 11:51:21 -04:00
committed by GitHub
parent e528ed5d86
commit a76be695c7
8 changed files with 622 additions and 598 deletions

View File

@@ -411,6 +411,113 @@ export class Auth extends HeyApiClient {
}
}
export class App extends HeyApiClient {
/**
* Write log
*
* Write a log entry to the server logs with specified level and metadata.
*/
public log<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
service?: string
level?: "debug" | "info" | "error" | "warn"
message?: string
extra?: {
[key: string]: unknown
}
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
{ in: "body", key: "service" },
{ in: "body", key: "level" },
{ in: "body", key: "message" },
{ in: "body", key: "extra" },
],
},
],
)
return (options?.client ?? this.client).post<AppLogResponses, AppLogErrors, ThrowOnError>({
url: "/log",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
/**
* List agents
*
* Get a list of all available AI agents in the OpenCode system.
*/
public agents<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<AppAgentsResponses, unknown, ThrowOnError>({
url: "/agent",
...options,
...params,
})
}
/**
* List skills
*
* Get a list of all available skills in the OpenCode system.
*/
public skills<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<AppSkillsResponses, unknown, ThrowOnError>({
url: "/skill",
...options,
...params,
})
}
}
export class Project extends HeyApiClient {
/**
* List all projects
@@ -3773,113 +3880,6 @@ export class Command extends HeyApiClient {
}
}
export class App extends HeyApiClient {
/**
* Write log
*
* Write a log entry to the server logs with specified level and metadata.
*/
public log<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
service?: string
level?: "debug" | "info" | "error" | "warn"
message?: string
extra?: {
[key: string]: unknown
}
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
{ in: "body", key: "service" },
{ in: "body", key: "level" },
{ in: "body", key: "message" },
{ in: "body", key: "extra" },
],
},
],
)
return (options?.client ?? this.client).post<AppLogResponses, AppLogErrors, ThrowOnError>({
url: "/log",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
/**
* List agents
*
* Get a list of all available AI agents in the OpenCode system.
*/
public agents<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<AppAgentsResponses, unknown, ThrowOnError>({
url: "/agent",
...options,
...params,
})
}
/**
* List skills
*
* Get a list of all available skills in the OpenCode system.
*/
public skills<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<AppSkillsResponses, unknown, ThrowOnError>({
url: "/skill",
...options,
...params,
})
}
}
export class Lsp extends HeyApiClient {
/**
* Get LSP status
@@ -3962,6 +3962,11 @@ export class OpencodeClient extends HeyApiClient {
return (this._auth ??= new Auth({ client: this.client }))
}
private _app?: App
get app(): App {
return (this._app ??= new App({ client: this.client }))
}
private _project?: Project
get project(): Project {
return (this._project ??= new Project({ client: this.client }))
@@ -4062,11 +4067,6 @@ export class OpencodeClient extends HeyApiClient {
return (this._command ??= new Command({ client: this.client }))
}
private _app?: App
get app(): App {
return (this._app ??= new App({ client: this.client }))
}
private _lsp?: Lsp
get lsp(): Lsp {
return (this._lsp ??= new Lsp({ client: this.client }))

View File

@@ -2249,6 +2249,53 @@ export type AuthSetResponses = {
export type AuthSetResponse = AuthSetResponses[keyof AuthSetResponses]
export type AppLogData = {
body?: {
/**
* Service name for the log entry
*/
service: string
/**
* Log level
*/
level: "debug" | "info" | "error" | "warn"
/**
* Log message
*/
message: string
/**
* Additional metadata for the log entry
*/
extra?: {
[key: string]: unknown
}
}
path?: never
query?: {
directory?: string
workspace?: string
}
url: "/log"
}
export type AppLogErrors = {
/**
* Bad request
*/
400: BadRequestError
}
export type AppLogError = AppLogErrors[keyof AppLogErrors]
export type AppLogResponses = {
/**
* Log entry written successfully
*/
200: boolean
}
export type AppLogResponse = AppLogResponses[keyof AppLogResponses]
export type ProjectListData = {
body?: never
path?: never
@@ -5036,53 +5083,6 @@ export type CommandListResponses = {
export type CommandListResponse = CommandListResponses[keyof CommandListResponses]
export type AppLogData = {
body?: {
/**
* Service name for the log entry
*/
service: string
/**
* Log level
*/
level: "debug" | "info" | "error" | "warn"
/**
* Log message
*/
message: string
/**
* Additional metadata for the log entry
*/
extra?: {
[key: string]: unknown
}
}
path?: never
query?: {
directory?: string
workspace?: string
}
url: "/log"
}
export type AppLogErrors = {
/**
* Bad request
*/
400: BadRequestError
}
export type AppLogError = AppLogErrors[keyof AppLogErrors]
export type AppLogResponses = {
/**
* Log entry written successfully
*/
200: boolean
}
export type AppLogResponse = AppLogResponses[keyof AppLogResponses]
export type AppAgentsData = {
body?: never
path?: never

View File

@@ -356,6 +356,90 @@
]
}
},
"/log": {
"post": {
"operationId": "app.log",
"parameters": [
{
"in": "query",
"name": "directory",
"schema": {
"type": "string"
}
},
{
"in": "query",
"name": "workspace",
"schema": {
"type": "string"
}
}
],
"summary": "Write log",
"description": "Write a log entry to the server logs with specified level and metadata.",
"responses": {
"200": {
"description": "Log entry written successfully",
"content": {
"application/json": {
"schema": {
"type": "boolean"
}
}
}
},
"400": {
"description": "Bad request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BadRequestError"
}
}
}
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"service": {
"description": "Service name for the log entry",
"type": "string"
},
"level": {
"description": "Log level",
"type": "string",
"enum": ["debug", "info", "error", "warn"]
},
"message": {
"description": "Log message",
"type": "string"
},
"extra": {
"description": "Additional metadata for the log entry",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {}
}
},
"required": ["service", "level", "message"]
}
}
}
},
"x-codeSamples": [
{
"lang": "js",
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.app.log({\n ...\n})"
}
]
}
},
"/project": {
"get": {
"operationId": "project.list",
@@ -6762,90 +6846,6 @@
]
}
},
"/log": {
"post": {
"operationId": "app.log",
"parameters": [
{
"in": "query",
"name": "directory",
"schema": {
"type": "string"
}
},
{
"in": "query",
"name": "workspace",
"schema": {
"type": "string"
}
}
],
"summary": "Write log",
"description": "Write a log entry to the server logs with specified level and metadata.",
"responses": {
"200": {
"description": "Log entry written successfully",
"content": {
"application/json": {
"schema": {
"type": "boolean"
}
}
}
},
"400": {
"description": "Bad request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BadRequestError"
}
}
}
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"service": {
"description": "Service name for the log entry",
"type": "string"
},
"level": {
"description": "Log level",
"type": "string",
"enum": ["debug", "info", "error", "warn"]
},
"message": {
"description": "Log message",
"type": "string"
},
"extra": {
"description": "Additional metadata for the log entry",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {}
}
},
"required": ["service", "level", "message"]
}
}
}
},
"x-codeSamples": [
{
"lang": "js",
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.app.log({\n ...\n})"
}
]
}
},
"/agent": {
"get": {
"operationId": "app.agents",