openAgent
gitlabThe open source UNIVERSAL agent.
clone
https://gitlab.com/bitzzdev/openAgent.gitAIagentautomationopen-sourceuniversal-agent
import type {AgentPart,OpencodeClient,Event,FilePart,LspStatus,McpStatus,Todo,Message,Part,Provider,PermissionRequest,QuestionRequest,Session,SessionStatus,TextPart,Config as SdkConfig,} from "@opencode-ai/sdk/v2"import type { CliRenderer, KeyEvent, RGBA, Renderable, SlotMode } from "@opentui/core"import type { Binding, Keymap } from "@opentui/keymap"import {createBindingLookup as createKeymapBindingLookup,type BindingConfig,type CreateBindingLookupOptions,type KeySequenceFormatPart,type SequenceBindingLike,} from "@opentui/keymap/extras"import type { JSX, SolidPlugin } from "@opentui/solid"import type { Config as PluginConfig, PluginOptions } from "./index.js"export type { CliRenderer, KeyEvent, Renderable, SlotMode } from "@opentui/core"export { stringifyKeySequence, stringifyKeyStroke } from "@opentui/keymap"export type { Binding, KeyLike, KeySequencePart, KeyStringifyInput, StringifyOptions } from "@opentui/keymap"export { formatCommandBindings, formatKeySequence } from "@opentui/keymap/extras"export type {BindingConfig,BindingLookup,BindingValue,CreateBindingLookupOptions,FormatCommandBindingsOptions,FormatKeySequenceOptions,KeySequenceFormatPart,SequenceBindingLike,} from "@opentui/keymap/extras"export function createBindingLookup(config: BindingConfig<Renderable, KeyEvent> | undefined,options?: CreateBindingLookupOptions<Renderable, KeyEvent>,) {return createKeymapBindingLookup<Renderable, KeyEvent>(config ?? {}, options)}export type TuiRouteCurrent =| {name: "home"}| {name: "session"params: {sessionID: stringprompt?: unknown}}| {name: stringparams?: Record<string, unknown>}export type TuiRouteDefinition = {name: stringrender: (input: { params?: Record<string, unknown> }) => JSX.Element}export type TuiKeys = {formatSequence: (parts: readonly KeySequenceFormatPart[] | undefined) => stringformatBindings: (bindings: readonly SequenceBindingLike[] | undefined) => string | undefined}export type TuiKeymap = Keymap<Renderable, KeyEvent>export type TuiModeApi = {current: () => stringpush: (mode: string) => () => void}/*** Legacy `api.command` shape kept so v1 plugins can initialize. Remove in v2.** @deprecated Use `api.keymap.registerLayer({ commands, bindings })` instead.*/export type TuiCommand = {title: stringvalue: stringdescription?: stringcategory?: stringkeybind?: stringsuggested?: booleanhidden?: booleanenabled?: booleanslash?: {name: stringaliases?: string[]}onSelect?: (dialog?: TuiDialogStack) => void | Promise<void>}/*** Legacy `api.command` API kept so v1 plugins can initialize. Remove in v2.** @deprecated Use `api.keymap.registerLayer`, `api.keymap.dispatchCommand`, and* `api.keymap.dispatchCommand("command.palette.show")` instead.*/export type TuiCommandApi = {/** @deprecated Use `api.keymap.registerLayer({ commands, bindings })` instead. */register: (cb: () => TuiCommand[]) => () => void/** @deprecated Use `api.keymap.dispatchCommand(name)` instead. */trigger: (value: string) => void/** @deprecated Use `api.keymap.dispatchCommand("command.palette.show")` instead. */show: () => void}export type TuiDialogProps = {size?: "medium" | "large" | "xlarge"onClose: () => voidchildren?: JSX.Element}export type TuiDialogStack = {replace: (render: () => JSX.Element, onClose?: () => void) => voidclear: () => voidsetSize: (size: "medium" | "large" | "xlarge") => voidreadonly size: "medium" | "large" | "xlarge"readonly depth: numberreadonly open: boolean}export type TuiDialogAlertProps = {title: stringmessage: stringonConfirm?: () => void}export type TuiDialogConfirmProps = {title: stringmessage: stringonConfirm?: () => voidonCancel?: () => void}export type TuiDialogPromptProps = {title: stringdescription?: () => JSX.Elementplaceholder?: stringvalue?: stringbusy?: booleanbusyText?: stringonConfirm?: (value: string) => voidonCancel?: () => void}export type TuiDialogSelectOption<Value = unknown> = {title: stringvalue: Valuedescription?: stringfooter?: JSX.Element | stringcategory?: stringdisabled?: booleanonSelect?: () => void}export type TuiDialogSelectProps<Value = unknown> = {title: stringplaceholder?: stringoptions: TuiDialogSelectOption<Value>[]flat?: booleanonMove?: (option: TuiDialogSelectOption<Value>) => voidonFilter?: (query: string) => voidonSelect?: (option: TuiDialogSelectOption<Value>) => voidskipFilter?: booleancurrent?: Value}export type TuiPromptInfo = {input: stringmode?: "normal" | "shell"parts: (| Omit<FilePart, "id" | "messageID" | "sessionID">| Omit<AgentPart, "id" | "messageID" | "sessionID">| (Omit<TextPart, "id" | "messageID" | "sessionID"> & {source?: {text: {start: numberend: numbervalue: string}}}))[]}export type TuiPromptRef = {focused: booleancurrent: TuiPromptInfoset(prompt: TuiPromptInfo): voidreset(): voidblur(): voidfocus(): voidsubmit(): void}export type TuiPromptProps = {sessionID?: stringvisible?: booleandisabled?: booleanonSubmit?: () => voidref?: (ref: TuiPromptRef | undefined) => voidhint?: JSX.Elementright?: JSX.ElementshowPlaceholder?: booleanplaceholders?: {normal?: string[]shell?: string[]}}export type TuiToast = {variant?: "info" | "success" | "warning" | "error"title?: stringmessage: stringduration?: number}export type TuiAttentionWhen = "always" | "focused" | "blurred"export const TuiAttentionSoundNames = ["default", "question", "permission", "error", "done", "subagent_done"] as constexport type TuiAttentionSoundName = (typeof TuiAttentionSoundNames)[number]export type TuiAttentionSound =| boolean| {name?: TuiAttentionSoundNamevolume?: numberwhen?: TuiAttentionWhen}export type TuiAttentionNotification =| boolean| {when?: TuiAttentionWhen}export type TuiAttentionSoundPack = {id: stringname?: stringsounds: Partial<Record<TuiAttentionSoundName, string>>}export type TuiAttentionSoundPackInfo = {id: stringname?: stringactive: booleanbuiltin: boolean}export type TuiAttentionSoundboardActivateOptions = {persist?: boolean}export type TuiAttentionSoundboard = {registerPack(pack: TuiAttentionSoundPack): () => voidactivate(id: string, options?: TuiAttentionSoundboardActivateOptions): booleancurrent(): stringlist(): ReadonlyArray<TuiAttentionSoundPackInfo>}export type TuiAttentionNotifyInput = {title?: stringmessage: stringnotification?: TuiAttentionNotificationsound?: TuiAttentionSound}export type TuiAttentionNotifySkipReason =| "attention_disabled"| "empty_message"| "blurred"| "focused"| "focus_unknown"| "renderer_destroyed"export type TuiAttentionNotifyResult = {ok: booleannotification: booleansound: booleanskipped?: TuiAttentionNotifySkipReason}export type TuiAttention = {notify(input: TuiAttentionNotifyInput): Promise<TuiAttentionNotifyResult>soundboard: TuiAttentionSoundboard}export type TuiThemeCurrent = {readonly primary: RGBAreadonly secondary: RGBAreadonly accent: RGBAreadonly error: RGBAreadonly warning: RGBAreadonly success: RGBAreadonly info: RGBAreadonly text: RGBAreadonly textMuted: RGBAreadonly selectedListItemText: RGBAreadonly background: RGBAreadonly backgroundPanel: RGBAreadonly backgroundElement: RGBAreadonly backgroundMenu: RGBAreadonly border: RGBAreadonly borderActive: RGBAreadonly borderSubtle: RGBAreadonly diffAdded: RGBAreadonly diffRemoved: RGBAreadonly diffContext: RGBAreadonly diffHunkHeader: RGBAreadonly diffHighlightAdded: RGBAreadonly diffHighlightRemoved: RGBAreadonly diffAddedBg: RGBAreadonly diffRemovedBg: RGBAreadonly diffContextBg: RGBAreadonly diffLineNumber: RGBAreadonly diffAddedLineNumberBg: RGBAreadonly diffRemovedLineNumberBg: RGBAreadonly markdownText: RGBAreadonly markdownHeading: RGBAreadonly markdownLink: RGBAreadonly markdownLinkText: RGBAreadonly markdownCode: RGBAreadonly markdownBlockQuote: RGBAreadonly markdownEmph: RGBAreadonly markdownStrong: RGBAreadonly markdownHorizontalRule: RGBAreadonly markdownListItem: RGBAreadonly markdownListEnumeration: RGBAreadonly markdownImage: RGBAreadonly markdownImageText: RGBAreadonly markdownCodeBlock: RGBAreadonly syntaxComment: RGBAreadonly syntaxKeyword: RGBAreadonly syntaxFunction: RGBAreadonly syntaxVariable: RGBAreadonly syntaxString: RGBAreadonly syntaxNumber: RGBAreadonly syntaxType: RGBAreadonly syntaxOperator: RGBAreadonly syntaxPunctuation: RGBAreadonly thinkingOpacity: number}export type TuiTheme = {readonly current: TuiThemeCurrentreadonly selected: stringhas: (name: string) => booleanset: (name: string) => booleaninstall: (jsonPath: string) => Promise<void>mode: () => "dark" | "light"readonly ready: boolean}export type TuiKV = {get: <Value = unknown>(key: string, fallback?: Value) => Valueset: (key: string, value: unknown) => voidreadonly ready: boolean}export type TuiState = {readonly ready: booleanreadonly config: SdkConfigreadonly provider: ReadonlyArray<Provider>readonly path: {state: stringconfig: stringworktree: stringdirectory: string}readonly vcs: { branch?: string; default_branch?: string } | undefinedsession: {count: () => numberget: (sessionID: string) => Session | undefineddiff: (sessionID: string) => ReadonlyArray<TuiSidebarFileItem>todo: (sessionID: string) => ReadonlyArray<TuiSidebarTodoItem>messages: (sessionID: string) => ReadonlyArray<Message>status: (sessionID: string) => SessionStatus | undefinedpermission: (sessionID: string) => ReadonlyArray<PermissionRequest>question: (sessionID: string) => ReadonlyArray<QuestionRequest>}part: (messageID: string) => ReadonlyArray<Part>lsp: () => ReadonlyArray<TuiSidebarLspItem>mcp: () => ReadonlyArray<TuiSidebarMcpItem>}type TuiBindingLookupView = {readonly bindings: ReadonlyArray<Binding<Renderable, KeyEvent>>get: (command: string) => ReadonlyArray<Binding<Renderable, KeyEvent>>has: (command: string) => booleangather: (name: string, commands: readonly string[]) => ReadonlyArray<Binding<Renderable, KeyEvent>>pick: (name: string, commands: readonly string[]) => Binding<Renderable, KeyEvent>[]omit: (name: string, commands: readonly string[]) => Binding<Renderable, KeyEvent>[]}type TuiAttentionConfigView = {enabled: booleannotifications: booleansound: booleanvolume: numbersound_pack: stringsounds: Partial<Record<TuiAttentionSoundName, string>>}type TuiConfigView = Pick<PluginConfig, "$schema" | "theme" | "plugin"> &NonNullable<PluginConfig["tui"]> & {leader_timeout: numberattention: TuiAttentionConfigViewplugin_enabled?: Record<string, boolean>keybinds: TuiBindingLookupView}export type TuiApp = {readonly version: string}type Frozen<Value> = Value extends (...args: never[]) => unknown? Value: Value extends ReadonlyArray<infer Item>? ReadonlyArray<Frozen<Item>>: Value extends object? { readonly [Key in keyof Value]: Frozen<Value[Key]> }: Valueexport type TuiSidebarMcpItem = {name: stringstatus: McpStatus["status"]error?: string}export type TuiSidebarLspItem = Pick<LspStatus, "id" | "root" | "status">export type TuiSidebarTodoItem = Pick<Todo, "content" | "status">export type TuiSidebarFileItem = {file: stringadditions: numberdeletions: number}export type TuiHostSlotMap = {app: {}app_bottom: {}home_logo: {}home_prompt: {ref?: (ref: TuiPromptRef | undefined) => void}home_prompt_right: {}session_prompt: {session_id: stringvisible?: booleandisabled?: booleanon_submit?: () => voidref?: (ref: TuiPromptRef | undefined) => void}session_prompt_right: {session_id: string}home_bottom: {}home_footer: {}sidebar_title: {session_id: stringtitle: stringshare_url?: string}sidebar_content: {session_id: string}sidebar_footer: {session_id: string}}export type TuiSlotMap<Slots extends Record<string, object> = {}> = TuiHostSlotMap & Slotstype TuiSlotShape<Name extends string, Slots extends Record<string, object>> = Name extends keyof TuiHostSlotMap? TuiHostSlotMap[Name]: Name extends keyof Slots? Slots[Name]: Record<string, unknown>export type TuiSlotProps<Name extends string = string, Slots extends Record<string, object> = {}> = {name: Namemode?: SlotModechildren?: JSX.Element} & TuiSlotShape<Name, Slots>export type TuiSlotContext = {theme: TuiTheme}type SlotCore<Slots extends Record<string, object> = {}> = SolidPlugin<TuiSlotMap<Slots>, TuiSlotContext>export type TuiSlotPlugin<Slots extends Record<string, object> = {}> = Omit<SlotCore<Slots>, "id"> & {id?: never}export type TuiSlots = {register: {(plugin: TuiSlotPlugin): string<Slots extends Record<string, object>>(plugin: TuiSlotPlugin<Slots>): string}}export type TuiEventBus = {on: <Type extends Event["type"]>(type: Type, handler: (event: Extract<Event, { type: Type }>) => void) => () => void}export type TuiDispose = () => void | Promise<void>export type TuiLifecycle = {readonly signal: AbortSignalonDispose: (fn: TuiDispose) => () => void}export type TuiPluginState = "first" | "updated" | "same"export type TuiPluginEntry = {id: stringsource: "file" | "npm" | "internal"spec: stringtarget: stringrequested?: stringversion?: stringmodified?: numberfirst_time: numberlast_time: numbertime_changed: numberload_count: numberfingerprint: string}export type TuiPluginMeta = TuiPluginEntry & {state: TuiPluginState}export type TuiPluginStatus = {id: stringsource: TuiPluginEntry["source"]spec: stringtarget: stringenabled: booleanactive: boolean}export type TuiPluginInstallOptions = {global?: boolean}export type TuiPluginInstallResult =| {ok: truedir: stringtui: boolean}| {ok: falsemessage: stringmissing?: boolean}export type TuiWorkspace = {current: () => string | undefinedset: (workspaceID?: string) => void}export type TuiPluginApi = {app: TuiAppattention: TuiAttention/*** Legacy `api.command` API kept so v1 plugins can initialize. Remove in v2.** @deprecated Use `api.keymap.registerLayer`, `api.keymap.dispatchCommand`, and* `api.keymap.dispatchCommand("command.palette.show")` instead.*/command?: TuiCommandApikeys: TuiKeyskeymap: TuiKeymapmode: TuiModeApiroute: {register: (routes: TuiRouteDefinition[]) => () => voidnavigate: (name: string, params?: Record<string, unknown>) => voidreadonly current: TuiRouteCurrent}ui: {Dialog: (props: TuiDialogProps) => JSX.ElementDialogAlert: (props: TuiDialogAlertProps) => JSX.ElementDialogConfirm: (props: TuiDialogConfirmProps) => JSX.ElementDialogPrompt: (props: TuiDialogPromptProps) => JSX.ElementDialogSelect: <Value = unknown>(props: TuiDialogSelectProps<Value>) => JSX.ElementSlot: <Name extends string>(props: TuiSlotProps<Name>) => JSX.Element | nullPrompt: (props: TuiPromptProps) => JSX.Elementtoast: (input: TuiToast) => voiddialog: TuiDialogStack}readonly tuiConfig: Frozen<TuiConfigView>kv: TuiKVstate: TuiStatetheme: TuiThemeclient: OpencodeClientevent: TuiEventBusrenderer: CliRendererslots: TuiSlotsplugins: {list: () => ReadonlyArray<TuiPluginStatus>activate: (id: string) => Promise<boolean>deactivate: (id: string) => Promise<boolean>add: (spec: string) => Promise<boolean>install: (spec: string, options?: TuiPluginInstallOptions) => Promise<TuiPluginInstallResult>}lifecycle: TuiLifecycle}export type TuiPlugin = (api: TuiPluginApi, options: PluginOptions | undefined, meta: TuiPluginMeta) => Promise<void>export type TuiPluginModule = {id?: stringtui: TuiPluginserver?: never}