mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-20 01:04:22 +01:00
OpenTUI is here (#2685)
This commit is contained in:
@@ -26,4 +26,4 @@
|
||||
"publishConfig": {
|
||||
"directory": "dist"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import { createClient } from "@hey-api/openapi-ts"
|
||||
|
||||
await $`bun dev generate > ${dir}/openapi.json`.cwd(path.resolve(dir, "../../opencode"))
|
||||
|
||||
await $`rm -rf src/gen`
|
||||
|
||||
await createClient({
|
||||
input: "./openapi.json",
|
||||
output: {
|
||||
|
||||
@@ -105,6 +105,8 @@ import type {
|
||||
AppAgentsResponses,
|
||||
McpStatusData,
|
||||
McpStatusResponses,
|
||||
LspStatusData,
|
||||
LspStatusResponses,
|
||||
TuiAppendPromptData,
|
||||
TuiAppendPromptResponses,
|
||||
TuiAppendPromptErrors,
|
||||
@@ -125,6 +127,9 @@ import type {
|
||||
TuiExecuteCommandErrors,
|
||||
TuiShowToastData,
|
||||
TuiShowToastResponses,
|
||||
TuiPublishData,
|
||||
TuiPublishResponses,
|
||||
TuiPublishErrors,
|
||||
TuiControlNextData,
|
||||
TuiControlNextResponses,
|
||||
TuiControlResponseData,
|
||||
@@ -754,6 +759,20 @@ class Mcp extends _HeyApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
class Lsp extends _HeyApiClient {
|
||||
/**
|
||||
* Get LSP server status
|
||||
*/
|
||||
public status<ThrowOnError extends boolean = false>(
|
||||
options?: Options<LspStatusData, ThrowOnError>,
|
||||
) {
|
||||
return (options?.client ?? this._client).get<LspStatusResponses, unknown, ThrowOnError>({
|
||||
url: "/lsp",
|
||||
...options,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
class Control extends _HeyApiClient {
|
||||
/**
|
||||
* Get the next TUI request from the queue
|
||||
@@ -916,6 +935,26 @@ class Tui extends _HeyApiClient {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a TUI event
|
||||
*/
|
||||
public publish<ThrowOnError extends boolean = false>(
|
||||
options?: Options<TuiPublishData, ThrowOnError>,
|
||||
) {
|
||||
return (options?.client ?? this._client).post<
|
||||
TuiPublishResponses,
|
||||
TuiPublishErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/tui/publish",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
control = new Control({ client: this._client })
|
||||
}
|
||||
|
||||
@@ -983,6 +1022,7 @@ export class OpencodeClient extends _HeyApiClient {
|
||||
file = new File({ client: this._client })
|
||||
app = new App({ client: this._client })
|
||||
mcp = new Mcp({ client: this._client })
|
||||
lsp = new Lsp({ client: this._client })
|
||||
tui = new Tui({ client: this._client })
|
||||
auth = new Auth({ client: this._client })
|
||||
event = new Event({ client: this._client })
|
||||
|
||||
@@ -18,10 +18,6 @@ export type KeybindsConfig = {
|
||||
* Leader key for keybind combinations
|
||||
*/
|
||||
leader?: string
|
||||
/**
|
||||
* Show help dialog
|
||||
*/
|
||||
app_help?: string
|
||||
/**
|
||||
* Exit the application
|
||||
*/
|
||||
@@ -35,17 +31,13 @@ export type KeybindsConfig = {
|
||||
*/
|
||||
theme_list?: string
|
||||
/**
|
||||
* Create/update AGENTS.md
|
||||
* Toggle sidebar
|
||||
*/
|
||||
project_init?: string
|
||||
sidebar_toggle?: string
|
||||
/**
|
||||
* Toggle tool details
|
||||
* View status
|
||||
*/
|
||||
tool_details?: string
|
||||
/**
|
||||
* Toggle thinking blocks
|
||||
*/
|
||||
thinking_blocks?: string
|
||||
status_view?: string
|
||||
/**
|
||||
* Export session to editor
|
||||
*/
|
||||
@@ -78,14 +70,6 @@ export type KeybindsConfig = {
|
||||
* Compact the session
|
||||
*/
|
||||
session_compact?: string
|
||||
/**
|
||||
* Cycle to next child session
|
||||
*/
|
||||
session_child_cycle?: string
|
||||
/**
|
||||
* Cycle to previous child session
|
||||
*/
|
||||
session_child_cycle_reverse?: string
|
||||
/**
|
||||
* Scroll messages up by one page
|
||||
*/
|
||||
@@ -127,13 +111,9 @@ export type KeybindsConfig = {
|
||||
*/
|
||||
model_list?: string
|
||||
/**
|
||||
* Next recent model
|
||||
* List available commands
|
||||
*/
|
||||
model_cycle_recent?: string
|
||||
/**
|
||||
* Previous recent model
|
||||
*/
|
||||
model_cycle_recent_reverse?: string
|
||||
command_list?: string
|
||||
/**
|
||||
* List agents
|
||||
*/
|
||||
@@ -162,54 +142,6 @@ export type KeybindsConfig = {
|
||||
* Insert newline in input
|
||||
*/
|
||||
input_newline?: string
|
||||
/**
|
||||
* @deprecated use agent_cycle. Next mode
|
||||
*/
|
||||
switch_mode?: string
|
||||
/**
|
||||
* @deprecated use agent_cycle_reverse. Previous mode
|
||||
*/
|
||||
switch_mode_reverse?: string
|
||||
/**
|
||||
* @deprecated use agent_cycle. Next agent
|
||||
*/
|
||||
switch_agent?: string
|
||||
/**
|
||||
* @deprecated use agent_cycle_reverse. Previous agent
|
||||
*/
|
||||
switch_agent_reverse?: string
|
||||
/**
|
||||
* @deprecated Currently not available. List files
|
||||
*/
|
||||
file_list?: string
|
||||
/**
|
||||
* @deprecated Close file
|
||||
*/
|
||||
file_close?: string
|
||||
/**
|
||||
* @deprecated Search file
|
||||
*/
|
||||
file_search?: string
|
||||
/**
|
||||
* @deprecated Split/unified diff
|
||||
*/
|
||||
file_diff_toggle?: string
|
||||
/**
|
||||
* @deprecated Navigate to previous message
|
||||
*/
|
||||
messages_previous?: string
|
||||
/**
|
||||
* @deprecated Navigate to next message
|
||||
*/
|
||||
messages_next?: string
|
||||
/**
|
||||
* @deprecated Toggle layout
|
||||
*/
|
||||
messages_layout_toggle?: string
|
||||
/**
|
||||
* @deprecated use messages_undo. Revert message
|
||||
*/
|
||||
messages_revert?: string
|
||||
}
|
||||
|
||||
export type AgentConfig = {
|
||||
@@ -781,11 +713,17 @@ export type FilePart = {
|
||||
|
||||
export type ToolStatePending = {
|
||||
status: "pending"
|
||||
input: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
raw: string
|
||||
}
|
||||
|
||||
export type ToolStateRunning = {
|
||||
status: "running"
|
||||
input: unknown
|
||||
input: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
title?: string
|
||||
metadata?: {
|
||||
[key: string]: unknown
|
||||
@@ -1086,6 +1024,72 @@ export type Agent = {
|
||||
}
|
||||
}
|
||||
|
||||
export type McpStatusConnected = {
|
||||
status: "connected"
|
||||
}
|
||||
|
||||
export type McpStatusDisabled = {
|
||||
status: "disabled"
|
||||
}
|
||||
|
||||
export type McpStatusFailed = {
|
||||
status: "failed"
|
||||
error: string
|
||||
}
|
||||
|
||||
export type McpStatus = McpStatusConnected | McpStatusDisabled | McpStatusFailed
|
||||
|
||||
export type LspStatus = {
|
||||
id: string
|
||||
name: string
|
||||
root: string
|
||||
status: "connected" | "error"
|
||||
}
|
||||
|
||||
export type EventTuiPromptAppend = {
|
||||
type: "tui.prompt.append"
|
||||
properties: {
|
||||
text: string
|
||||
}
|
||||
}
|
||||
|
||||
export type EventTuiCommandExecute = {
|
||||
type: "tui.command.execute"
|
||||
properties: {
|
||||
command:
|
||||
| (
|
||||
| "session.list"
|
||||
| "session.new"
|
||||
| "session.share"
|
||||
| "session.interrupt"
|
||||
| "session.compact"
|
||||
| "session.page.up"
|
||||
| "session.page.down"
|
||||
| "session.half.page.up"
|
||||
| "session.half.page.down"
|
||||
| "session.first"
|
||||
| "session.last"
|
||||
| "prompt.clear"
|
||||
| "prompt.submit"
|
||||
| "agent.cycle"
|
||||
)
|
||||
| string
|
||||
}
|
||||
}
|
||||
|
||||
export type EventTuiToastShow = {
|
||||
type: "tui.toast.show"
|
||||
properties: {
|
||||
title?: string
|
||||
message: string
|
||||
variant: "info" | "success" | "warning" | "error"
|
||||
/**
|
||||
* Duration in milliseconds
|
||||
*/
|
||||
duration?: number
|
||||
}
|
||||
}
|
||||
|
||||
export type OAuth = {
|
||||
type: "oauth"
|
||||
refresh: string
|
||||
@@ -1121,6 +1125,13 @@ export type EventLspClientDiagnostics = {
|
||||
}
|
||||
}
|
||||
|
||||
export type EventLspUpdated = {
|
||||
type: "lsp.updated"
|
||||
properties: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
}
|
||||
|
||||
export type EventMessageUpdated = {
|
||||
type: "message.updated"
|
||||
properties: {
|
||||
@@ -1261,16 +1272,10 @@ export type EventServerConnected = {
|
||||
}
|
||||
}
|
||||
|
||||
export type EventIdeInstalled = {
|
||||
type: "ide.installed"
|
||||
properties: {
|
||||
ide: string
|
||||
}
|
||||
}
|
||||
|
||||
export type Event =
|
||||
| EventInstallationUpdated
|
||||
| EventLspClientDiagnostics
|
||||
| EventLspUpdated
|
||||
| EventMessageUpdated
|
||||
| EventMessageRemoved
|
||||
| EventMessagePartUpdated
|
||||
@@ -1286,8 +1291,10 @@ export type Event =
|
||||
| EventSessionUpdated
|
||||
| EventSessionDeleted
|
||||
| EventSessionError
|
||||
| EventTuiPromptAppend
|
||||
| EventTuiCommandExecute
|
||||
| EventTuiToastShow
|
||||
| EventServerConnected
|
||||
| EventIdeInstalled
|
||||
|
||||
export type ProjectListData = {
|
||||
body?: never
|
||||
@@ -2455,9 +2462,31 @@ export type McpStatusResponses = {
|
||||
/**
|
||||
* MCP server status
|
||||
*/
|
||||
200: unknown
|
||||
200: {
|
||||
[key: string]: McpStatus
|
||||
}
|
||||
}
|
||||
|
||||
export type McpStatusResponse = McpStatusResponses[keyof McpStatusResponses]
|
||||
|
||||
export type LspStatusData = {
|
||||
body?: never
|
||||
path?: never
|
||||
query?: {
|
||||
directory?: string
|
||||
}
|
||||
url: "/lsp"
|
||||
}
|
||||
|
||||
export type LspStatusResponses = {
|
||||
/**
|
||||
* LSP server status
|
||||
*/
|
||||
200: Array<LspStatus>
|
||||
}
|
||||
|
||||
export type LspStatusResponse = LspStatusResponses[keyof LspStatusResponses]
|
||||
|
||||
export type TuiAppendPromptData = {
|
||||
body?: {
|
||||
text: string
|
||||
@@ -2629,6 +2658,10 @@ export type TuiShowToastData = {
|
||||
title?: string
|
||||
message: string
|
||||
variant: "info" | "success" | "warning" | "error"
|
||||
/**
|
||||
* Duration in milliseconds
|
||||
*/
|
||||
duration?: number
|
||||
}
|
||||
path?: never
|
||||
query?: {
|
||||
@@ -2646,6 +2679,33 @@ export type TuiShowToastResponses = {
|
||||
|
||||
export type TuiShowToastResponse = TuiShowToastResponses[keyof TuiShowToastResponses]
|
||||
|
||||
export type TuiPublishData = {
|
||||
body?: EventTuiPromptAppend | EventTuiCommandExecute | EventTuiToastShow
|
||||
path?: never
|
||||
query?: {
|
||||
directory?: string
|
||||
}
|
||||
url: "/tui/publish"
|
||||
}
|
||||
|
||||
export type TuiPublishErrors = {
|
||||
/**
|
||||
* Bad request
|
||||
*/
|
||||
400: BadRequestError
|
||||
}
|
||||
|
||||
export type TuiPublishError = TuiPublishErrors[keyof TuiPublishErrors]
|
||||
|
||||
export type TuiPublishResponses = {
|
||||
/**
|
||||
* Event published successfully
|
||||
*/
|
||||
200: boolean
|
||||
}
|
||||
|
||||
export type TuiPublishResponse = TuiPublishResponses[keyof TuiPublishResponses]
|
||||
|
||||
export type TuiControlNextData = {
|
||||
body?: never
|
||||
path?: never
|
||||
|
||||
@@ -8,5 +8,6 @@
|
||||
"moduleResolution": "nodenext",
|
||||
"lib": ["es2022", "dom", "dom.iterable"]
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": ["src"],
|
||||
"exclude": ["src/gen"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user