Download packages/cli/src/tui.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/cli/src/tui.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/cli/src/tui.ts
-
curl -L -o tui.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/cli/src/tui.ts
1.24 kB
| import { run } from "@opencode-ai/tui" | |
| import { TuiConfig } from "@opencode-ai/tui/config" | |
| import { Effect } from "effect" | |
| import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder" | |
| import { Global } from "@opencode-ai/core/global" | |
| export function runTui(transport: { url: string; headers: RequestInit["headers"] }) { | |
| const config = TuiConfig.resolve({}, { terminalSuspend: false }) | |
| return run({ | |
| ...transport, | |
| args: {}, | |
| config, | |
| fetch: gracefulFetch, | |
| pluginHost: { | |
| async start() {}, | |
| async dispose() {}, | |
| }, | |
| }).pipe(Effect.provide(AppNodeBuilder.build(Global.node))) | |
| } | |
| const legacyDefaults: Record<string, unknown> = { | |
| "/config/providers": { providers: [], default: {} }, | |
| "/provider": { all: [], default: {}, connected: [] }, | |
| "/agent": [], | |
| "/config": {}, | |
| } | |
| const gracefulFetch = Object.assign( | |
| async (input: RequestInfo | URL, init?: RequestInit) => { | |
| const response = await fetch(input, init) | |
| if (response.status !== 404) return response | |
| const fallback = legacyDefaults[new URL(input instanceof Request ? input.url : input).pathname] | |
| if (fallback === undefined) return response | |
| return Response.json(fallback) | |
| }, | |
| { preconnect: fetch.preconnect }, | |
| ) | |