feat(plugin): expose app metadata (#38179)
This commit is contained in:
parent
2ed8fe5960
commit
8de40be6ea
71 changed files with 477 additions and 286 deletions
|
|
@ -1,17 +1,16 @@
|
|||
import { InstallationVersion } from "@opencode-ai/util/installation/version"
|
||||
import { Effect } from "effect"
|
||||
import { SimulationControlServer } from "../control-server"
|
||||
import { SimulationProtocol } from "../protocol"
|
||||
import { SimulationActions, type Harness } from "./actions"
|
||||
import { SimulationRenderer } from "./renderer"
|
||||
|
||||
function handle(harness: Harness, request: SimulationProtocol.Frontend.Request) {
|
||||
function handle(harness: Harness, request: SimulationProtocol.Frontend.Request, version: string) {
|
||||
switch (request.method) {
|
||||
case "simulation.handshake":
|
||||
return SimulationProtocol.Handshake.dispatch(
|
||||
{
|
||||
role: "ui",
|
||||
server: { name: "opencode", version: InstallationVersion },
|
||||
server: { name: "opencode", version },
|
||||
capabilities: SimulationProtocol.Frontend.Capabilities,
|
||||
},
|
||||
request.params,
|
||||
|
|
@ -59,13 +58,17 @@ function handle(harness: Harness, request: SimulationProtocol.Frontend.Request)
|
|||
}
|
||||
}
|
||||
|
||||
export const start = Effect.fn("SimulationServer.start")(function* (harness: Harness, endpoint: string) {
|
||||
export const start = Effect.fn("SimulationServer.start")(function* (
|
||||
harness: Harness,
|
||||
endpoint: string,
|
||||
version = "unknown",
|
||||
) {
|
||||
return yield* SimulationControlServer.start({
|
||||
endpoint,
|
||||
label: "opencode drive ui websocket",
|
||||
data: () => ({ drive: true as const }),
|
||||
decode: SimulationProtocol.Frontend.decodeRequestEffect,
|
||||
handle: (_socket, request) => handle(harness, request),
|
||||
handle: (_socket, request) => handle(harness, request, version),
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { SimulationRenderer } from "./renderer"
|
|||
import { SimulationServer } from "./server"
|
||||
|
||||
/** Drive-mode renderer and control-server acquisition. */
|
||||
export const create = Effect.fn("Drive.create")(function* (options: CliRendererConfig) {
|
||||
export const create = Effect.fn("Drive.create")(function* (options: CliRendererConfig, version: string) {
|
||||
const headless = (yield* Config.string("OPENCODE_DRIVE_RENDERER").pipe(Config.withDefault("visible"))) === "headless"
|
||||
const manifest = yield* DriveManifest.resolve()
|
||||
const renderer = headless
|
||||
|
|
@ -19,7 +19,7 @@ export const create = Effect.fn("Drive.create")(function* (options: CliRendererC
|
|||
}),
|
||||
)
|
||||
if (!headless && manifest.viewport) renderer.resize(manifest.viewport.cols, manifest.viewport.rows)
|
||||
const server = yield* SimulationServer.start(SimulationActions.createHarness(renderer), manifest.endpoints.ui)
|
||||
const server = yield* SimulationServer.start(SimulationActions.createHarness(renderer), manifest.endpoints.ui, version)
|
||||
yield* Effect.sync(() => process.stderr.write(`opencode drive ui websocket: ${server.url}\n`))
|
||||
return renderer
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue