feat(opencode): add filesystem read and list routes

This commit is contained in:
Dax Raad
2026-06-02 01:54:10 -04:00
parent 0136f03fa9
commit 5937e606df
10 changed files with 414 additions and 15 deletions

View File

@@ -247,6 +247,10 @@ import type {
TuiShowToastResponses,
TuiSubmitPromptErrors,
TuiSubmitPromptResponses,
V2FsListErrors,
V2FsListResponses,
V2FsReadErrors,
V2FsReadResponses,
V2ModelListErrors,
V2ModelListResponses,
V2PermissionRequestListErrors,
@@ -4727,6 +4731,74 @@ export class Permission3 extends HeyApiClient {
}
}
export class Fs extends HeyApiClient {
/**
* Read file
*
* Read one file relative to the requested location.
*/
public read<ThrowOnError extends boolean = false>(
parameters: {
location?: {
directory?: string
workspace?: string
}
path: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "location" },
{ in: "query", key: "path" },
],
},
],
)
return (options?.client ?? this.client).get<V2FsReadResponses, V2FsReadErrors, ThrowOnError>({
url: "/api/fs/read",
...options,
...params,
})
}
/**
* List directory
*
* List direct children of one directory relative to the requested location.
*/
public list<ThrowOnError extends boolean = false>(
parameters?: {
location?: {
directory?: string
workspace?: string
}
path?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "location" },
{ in: "query", key: "path" },
],
},
],
)
return (options?.client ?? this.client).get<V2FsListResponses, V2FsListErrors, ThrowOnError>({
url: "/api/fs/list",
...options,
...params,
})
}
}
export class V2 extends HeyApiClient {
private _session?: Session3
get session(): Session3 {
@@ -4747,6 +4819,11 @@ export class V2 extends HeyApiClient {
get permission(): Permission3 {
return (this._permission ??= new Permission3({ client: this.client }))
}
private _fs?: Fs
get fs(): Fs {
return (this._fs ??= new Fs({ client: this.client }))
}
}
export class Control extends HeyApiClient {

View File

@@ -3695,6 +3695,26 @@ export type PermissionSavedInfo = {
resource: string
}
export type LocationFileSystemTextContent = {
type: "text"
content: string
mime: string
}
export type LocationFileSystemBinaryContent = {
type: "binary"
content: string
encoding: "base64"
mime: string
}
export type LocationFileSystemEntry = {
path: string
uri: string
type: "file" | "directory"
mime: string
}
export type EventModelsDevRefreshed = {
id: string
type: "models-dev.refreshed"
@@ -8516,6 +8536,76 @@ export type V2PermissionSavedRemoveResponses = {
export type V2PermissionSavedRemoveResponse = V2PermissionSavedRemoveResponses[keyof V2PermissionSavedRemoveResponses]
export type V2FsReadData = {
body?: never
path?: never
query: {
location?: {
directory?: string
workspace?: string
}
path: string
}
url: "/api/fs/read"
}
export type V2FsReadErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2FsReadError = V2FsReadErrors[keyof V2FsReadErrors]
export type V2FsReadResponses = {
/**
* Success
*/
200: LocationFileSystemTextContent | LocationFileSystemBinaryContent
}
export type V2FsReadResponse = V2FsReadResponses[keyof V2FsReadResponses]
export type V2FsListData = {
body?: never
path?: never
query?: {
location?: {
directory?: string
workspace?: string
}
path?: string
}
url: "/api/fs/list"
}
export type V2FsListErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2FsListError = V2FsListErrors[keyof V2FsListErrors]
export type V2FsListResponses = {
/**
* Success
*/
200: Array<LocationFileSystemEntry>
}
export type V2FsListResponse = V2FsListResponses[keyof V2FsListResponses]
export type TuiAppendPromptData = {
body?: {
text: string