@opencode-ai/cli-linux-arm64
Advanced tools
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/unset.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect } from \"effect\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.unset,\n Effect.fn(\"cli.service.unset\")(function* (input) {\n yield* ServiceConfig.unset(input.key)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";o2BAKA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,WACnC,OAAO,QAAG,wBAAmB,OAAE,cAAU,MAAC,OAAO,MAC/C,WAAO,OAAc,WAAM,OAAM,QAAG,OACrC,MACH", | ||
| "debugId": "55A9FFA548651C1C64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../simulation/src/frontend/actions.ts", "../simulation/src/recording.ts", "../simulation/src/frontend/renderer.ts", "../simulation/src/frontend/semantics.ts", "../simulation/src/frontend/server.ts", "../simulation/src/frontend/simulation.ts"], | ||
| "sourcesContent": [ | ||
| "import { tmpdir } from \"node:os\"\nimport { extname, join, resolve } from \"node:path\"\nimport type { CliRenderer, Renderable } from \"@opentui/core\"\nimport {\n createMockKeys,\n createMockMouse,\n KeyCodes,\n type KeyInput,\n type MockInput,\n type MockMouse,\n} from \"@opentui/core/testing\"\nimport { Config, Effect, FileSystem, Schema } from \"effect\"\nimport { SimulationProtocol } from \"../protocol\"\nimport { SimulationRenderer } from \"./renderer\"\nimport { SimulationSemantics } from \"./semantics\"\n\nexport type Action = SimulationProtocol.Frontend.Action\nexport type Element = SimulationProtocol.Frontend.Element\n\nexport interface Harness {\n readonly renderer: CliRenderer\n readonly mockInput: MockInput\n readonly mockMouse: MockMouse\n readonly resize: (cols: number, rows: number) => void\n readonly renderOnce: () => Promise<void>\n readonly screen: () => string\n}\n\ntype RenderBuffer = {\n readonly width: number\n readonly height: number\n getRealCharBytes(includeAnsi?: boolean): Uint8Array\n}\n\nconst decoder = new TextDecoder()\n\nfunction isKeyCode(key: string): key is keyof typeof KeyCodes {\n return Object.hasOwn(KeyCodes, key)\n}\n\nfunction keyInput(key: string): KeyInput {\n const named = key.toUpperCase()\n return isKeyCode(named) ? named : key\n}\n\nfunction children(renderable: Renderable) {\n return renderable.getChildren().filter((child): child is Renderable => \"num\" in child)\n}\n\nfunction all(renderable: Renderable): Renderable[] {\n return [renderable, ...children(renderable).flatMap(all)]\n}\n\nfunction mouseListeners(renderable: Renderable) {\n const general = Reflect.get(renderable, \"_mouseListener\")\n const specific = Reflect.get(renderable, \"_mouseListeners\")\n return Boolean(general) || (specific && typeof specific === \"object\" && Object.keys(specific).length > 0)\n}\n\nfunction hit(renderer: CliRenderer, renderable: Renderable) {\n if (renderable.width <= 0 || renderable.height <= 0) return false\n const x = Math.floor(renderable.screenX + renderable.width / 2)\n const y = Math.floor(renderable.screenY + renderable.height / 2)\n const target = renderer.hitTest(x, y)\n return all(renderable).some((item) => item.num === target)\n}\n\n/**\n * Builds the harness the simulation server drives.\n *\n * When the renderer is the headless simulation renderer, its TestRendererSetup\n * provides the supported testing APIs. For the visible terminal renderer the\n * harness falls back to `requestRender` + `idle` and reading the private\n * `currentRenderBuffer`.\n */\nexport function createHarness(renderer: CliRenderer): Harness {\n const setup = SimulationRenderer.setupFor(renderer)\n return {\n renderer,\n mockInput: setup?.mockInput ?? createMockKeys(renderer),\n mockMouse: setup?.mockMouse ?? createMockMouse(renderer),\n resize: setup?.resize ?? ((cols, rows) => renderer.resize(cols, rows)),\n renderOnce:\n setup?.renderOnce ??\n (async () => {\n renderer.requestRender()\n await renderer.idle()\n }),\n // captureCharFrame follows the test renderer's output sink. Recording\n // redirects that sink to the timeline, so read the live render buffer\n // instead; it is also the source used by screenshots.\n screen: () => decoder.decode((Reflect.get(renderer, \"currentRenderBuffer\") as RenderBuffer).getRealCharBytes()),\n }\n}\n\nexport function elements(renderer: CliRenderer): Element[] {\n return all(renderer.root)\n .filter((renderable) => renderable.visible && !renderable.isDestroyed)\n .map((renderable) => {\n const clickable = mouseListeners(renderable) && hit(renderer, renderable)\n return {\n id: renderable.id,\n num: renderable.num,\n x: renderable.screenX,\n y: renderable.screenY,\n width: renderable.width,\n height: renderable.height,\n focusable: renderable.focusable,\n focused: renderable.focused,\n clickable,\n editor: renderer.currentFocusedEditor === renderable,\n } satisfies Element\n })\n .filter((element) => element.focusable || element.clickable || element.editor)\n}\n\nexport function state(harness: Harness) {\n return {\n focused: {\n renderable: harness.renderer.currentFocusedRenderable?.num,\n editor: Boolean(harness.renderer.currentFocusedEditor),\n },\n elements: elements(harness.renderer),\n }\n}\n\nexport function snapshot(harness: Harness): SimulationProtocol.Frontend.SemanticSnapshot {\n const ids = new Set<string>()\n const visit = (renderable: Renderable, parent?: string): SimulationProtocol.Frontend.SemanticNode[] => {\n if (!renderable.visible || renderable.isDestroyed) return []\n const definition = SimulationSemantics.read(renderable)?.()\n if (definition && ids.has(renderable.id)) throw new Error(`duplicate semantic UI id: ${renderable.id}`)\n if (definition) ids.add(renderable.id)\n const node = definition\n ? [{ id: renderable.id, ...definition, ...(parent === undefined ? {} : { parent }), element: renderable.num }]\n : []\n const ancestor = definition ? renderable.id : parent\n return [...node, ...children(renderable).flatMap((child) => visit(child, ancestor))]\n }\n return Schema.decodeUnknownSync(SimulationProtocol.Frontend.SemanticSnapshot)({\n format: \"opencode-ui-snapshot-v1\",\n nodes: visit(harness.renderer.root),\n })\n}\n\nexport function matches(harness: Pick<Harness, \"screen\">, text: string) {\n return harness.screen().includes(text)\n}\n\nexport const capture = Effect.fn(\"SimulationActions.capture\")(function* (harness: Harness) {\n yield* Effect.tryPromise(() => harness.renderOnce())\n const buffer = harness.renderer.currentRenderBuffer\n return {\n cols: buffer.width,\n rows: buffer.height,\n cursor: [0, 0] as const,\n lines: buffer.getSpanLines().map((line) => ({\n spans: line.spans.map((span) => ({\n text: span.text,\n fg: span.fg.toInts(),\n bg: span.bg.toInts(),\n attributes: span.attributes,\n width: span.width,\n })),\n })),\n } satisfies SimulationProtocol.Frontend.CapturedFrame\n})\n\nexport const screenshot = Effect.fn(\"SimulationActions.screenshot\")(function* (harness: Harness, name?: string) {\n const filename = name ?? `screenshot-${crypto.randomUUID()}`\n if (!filename || filename.includes(\"/\") || filename.includes(\"\\\\\") || extname(filename))\n return yield* Effect.fail(new Error(\"screenshot name must not contain a path or extension\"))\n yield* Effect.tryPromise(() => harness.renderOnce())\n const { SimulationPng } = yield* Effect.promise(() => import(\"./png\"))\n const image = SimulationPng.screenshot(harness.renderer)\n const directory = resolve(\n yield* Config.string(\"OPENCODE_DRIVE_MEDIA_DIR\").pipe(\n Config.withDefault(join(tmpdir(), \"opencode-drive\", \"output\")),\n ),\n )\n const fs = yield* FileSystem.FileSystem\n yield* fs.makeDirectory(directory, { recursive: true })\n const path = join(directory, `${filename}.png`)\n yield* fs.writeFile(path, image.data)\n return path\n})\n\nexport const execute = Effect.fn(\"SimulationActions.execute\")(function* (harness: Harness, action: Action) {\n switch (action.type) {\n case \"ui.type\":\n yield* Effect.tryPromise(() => harness.mockInput.typeText(action.text))\n break\n case \"ui.press\":\n harness.mockInput.pressKey(keyInput(action.key), action.modifiers)\n break\n case \"ui.enter\":\n harness.mockInput.pressEnter()\n break\n case \"ui.arrow\":\n harness.mockInput.pressArrow(action.direction)\n break\n case \"ui.focus\":\n all(harness.renderer.root)\n .find((item) => item.num === action.target)\n ?.focus()\n break\n case \"ui.click\": {\n const target = all(harness.renderer.root).find((item) => item.num === action.target)\n if (!target || !target.visible || target.isDestroyed)\n return yield* Effect.fail(new Error(`click target is stale or unavailable: ${action.target}`))\n if (action.semantic) {\n const current = snapshot(harness).nodes.find((node) => node.element === action.target)\n if (\n current?.id !== action.semantic.id ||\n current.instance !== action.semantic.instance ||\n current.element !== action.semantic.element\n )\n return yield* Effect.fail(new Error(`semantic click target is stale or unavailable: ${action.semantic.id}`))\n }\n if (\n !Number.isFinite(action.x) ||\n action.x < 0 ||\n action.x >= target.width ||\n !Number.isFinite(action.y) ||\n action.y < 0 ||\n action.y >= target.height\n )\n return yield* Effect.fail(new Error(\"click position must be within the target element\"))\n yield* Effect.tryPromise(() => harness.mockMouse.click(target.screenX + action.x, target.screenY + action.y))\n break\n }\n case \"ui.resize\":\n if (\n !Number.isSafeInteger(action.cols) ||\n action.cols <= 0 ||\n !Number.isSafeInteger(action.rows) ||\n action.rows <= 0\n ) {\n return yield* Effect.fail(new Error(\"resize cols and rows must be positive integers\"))\n }\n harness.resize(action.cols, action.rows)\n SimulationRenderer.recordResize(harness.renderer, action.cols, action.rows)\n break\n }\n yield* Effect.tryPromise(() => harness.renderOnce())\n return state(harness)\n})\n\nexport * as SimulationActions from \"./actions\"\n", | ||
| "import { createWriteStream, type WriteStream } from \"node:fs\"\nimport { mkdir } from \"node:fs/promises\"\nimport { dirname } from \"node:path\"\nimport { Writable } from \"node:stream\"\nimport { finished } from \"node:stream/promises\"\nimport { Schema } from \"effect\"\n\nexport const Header = Schema.Struct({\n type: Schema.Literal(\"header\"),\n version: Schema.Literal(1),\n cols: Schema.Number,\n rows: Schema.Number,\n encoding: Schema.Literal(\"base64\"),\n})\nexport interface Header extends Schema.Schema.Type<typeof Header> {}\n\nexport const Output = Schema.Struct({\n type: Schema.Literal(\"output\"),\n at_ms: Schema.Number,\n data: Schema.String,\n})\nexport interface Output extends Schema.Schema.Type<typeof Output> {}\n\nexport const Resize = Schema.Struct({\n type: Schema.Literal(\"resize\"),\n at_ms: Schema.Number,\n cols: Schema.Number,\n rows: Schema.Number,\n})\nexport interface Resize extends Schema.Schema.Type<typeof Resize> {}\n\nexport const Event = Schema.Union([Header, Output, Resize])\nexport type Event = Schema.Schema.Type<typeof Event>\n\nexport class Timeline extends Writable {\n readonly isTTY = true\n readonly path: string\n readonly columns: number\n readonly rows: number\n private readonly output: WriteStream\n private readonly started = performance.now()\n private readonly timestamps: number[] = []\n private done?: Promise<string>\n\n private constructor(path: string, cols: number, rows: number, output: WriteStream) {\n super()\n this.path = path\n this.columns = cols\n this.rows = rows\n this.output = output\n // finish() reports stream failures; keep Writable from also throwing them process-wide.\n this.on(\"error\", () => {})\n output.on(\"error\", (error) => this.destroy(error))\n }\n\n static async create(path: string, cols: number, rows: number) {\n await mkdir(dirname(path), { recursive: true })\n const output = createWriteStream(path)\n const timeline = new Timeline(path, cols, rows, output)\n await new Promise<void>((resolve, reject) => {\n output.write(\n `${JSON.stringify({ type: \"header\", version: 1, cols, rows, encoding: \"base64\" } satisfies Header)}\\n`,\n (error) => (error ? reject(error) : resolve()),\n )\n })\n return timeline\n }\n\n getColorDepth() {\n return 24\n }\n\n override write(chunk: unknown, callback?: (error?: Error | null) => void): boolean\n override write(chunk: unknown, encoding: BufferEncoding, callback?: (error?: Error | null) => void): boolean\n override write(\n chunk: unknown,\n encoding?: BufferEncoding | ((error?: Error | null) => void),\n callback?: (error?: Error | null) => void,\n ) {\n if (!this.writableEnded) {\n this.timestamps.push(this.elapsed())\n if (typeof encoding === \"function\") return super.write(chunk, encoding)\n if (encoding === undefined) return super.write(chunk, callback)\n return super.write(chunk, encoding, callback)\n }\n const done = typeof encoding === \"function\" ? encoding : callback\n queueMicrotask(() => done?.(null))\n return true\n }\n\n override _write(chunk: Buffer, _encoding: BufferEncoding, callback: (error?: Error | null) => void) {\n this.writeOutput(chunk, this.timestamps.shift() ?? this.elapsed(), callback)\n }\n\n override _final(callback: (error?: Error | null) => void) {\n this.writeOutput(Buffer.alloc(0), this.elapsed(), (error) => {\n if (error) return callback(error)\n this.output.end(callback)\n })\n }\n\n finish() {\n if (this.done) return this.done\n this.end()\n this.done = finished(this).then(() => this.path)\n return this.done\n }\n\n resize(cols: number, rows: number) {\n if (this.writableEnded) return\n const event = { type: \"resize\", at_ms: this.elapsed(), cols, rows } satisfies Resize\n this.output.write(`${JSON.stringify(event)}\\n`)\n }\n\n private elapsed() {\n return Math.max(0, Math.round(performance.now() - this.started))\n }\n\n private writeOutput(data: Buffer, at_ms: number, callback: (error?: Error | null) => void) {\n const event = {\n type: \"output\",\n at_ms,\n data: data.toString(\"base64\"),\n } satisfies Output\n this.output.write(`${JSON.stringify(event)}\\n`, callback)\n }\n}\n\nexport * as SimulationRecording from \"./recording\"\n", | ||
| "import type { CliRenderer, CliRendererConfig } from \"@opentui/core\"\nimport { createTestRenderer, type TestRendererSetup } from \"@opentui/core/testing\"\nimport { Effect } from \"effect\"\nimport { Timeline } from \"../recording\"\n\nconst setups = new WeakMap<CliRenderer, TestRendererSetup>()\nconst recordings = new WeakMap<CliRenderer, Timeline>()\n\n/**\n * Creates a headless renderer with optional recording: a real CliRenderer\n * backed by an in-memory screen buffer. The TestRendererSetup is kept\n * module-side so the harness can use supported testing APIs without app\n * code carrying it around.\n */\nexport interface Viewport {\n readonly cols: number\n readonly rows: number\n}\n\nexport const create = Effect.fn(\"SimulationRenderer.create\")(function* (\n options: CliRendererConfig,\n path?: string,\n viewport?: Viewport,\n) {\n const cols = viewport?.cols ?? 100\n const rows = viewport?.rows ?? 40\n const recording = path\n ? yield* Effect.acquireRelease(\n Effect.tryPromise(() => Timeline.create(path, cols, rows)),\n (recording) =>\n Effect.tryPromise(() => recording.finish()).pipe(\n Effect.catch((error) =>\n Effect.sync(() => process.stderr.write(`Failed to finish UI recording: ${error}\\n`)),\n ),\n ),\n )\n : undefined\n const setup = yield* Effect.acquireRelease(\n Effect.tryPromise(() =>\n createTestRenderer({\n ...options,\n width: cols,\n height: rows,\n ...(recording\n ? {\n stdout: recording as unknown as NodeJS.WriteStream,\n bufferedOutput: \"stdout\" as const,\n }\n : {}),\n }),\n ),\n (setup) =>\n Effect.sync(() => {\n if (!setup.renderer.isDestroyed) setup.renderer.destroy()\n }),\n )\n setups.set(setup.renderer, setup)\n if (recording) recordings.set(setup.renderer, recording)\n return setup.renderer\n})\n\nexport function recordResize(renderer: CliRenderer, cols: number, rows: number) {\n recordings.get(renderer)?.resize(cols, rows)\n}\n\nexport function setupFor(renderer: CliRenderer): TestRendererSetup | undefined {\n return setups.get(renderer)\n}\n\nexport function finish(renderer: CliRenderer) {\n const recording = recordings.get(renderer)\n if (!recording) return Effect.fail(new Error(\"UI recording is not available\"))\n return Effect.tryPromise(() => recording.finish())\n}\n\nexport * as SimulationRenderer from \"./renderer\"\n", | ||
| "import type { Renderable } from \"@opentui/core\"\nimport type { SimulationProtocol } from \"../protocol\"\n\n// Semantic renderables set an explicit stable OpenTUI id so ui.state and\n// ui.snapshot expose the same identity. Hierarchy and element handles come\n// from the live render tree.\nexport type Definition = Omit<SimulationProtocol.Frontend.SemanticNode, \"id\" | \"element\" | \"parent\">\n\nconst key = Symbol.for(\"opencode.simulation.semantics\")\n\nconst bind = (definition: () => Definition) => (renderable: Renderable) => {\n Object.defineProperty(renderable, key, { value: definition, configurable: true })\n}\n\nexport const read = (renderable: Renderable) => {\n const definition: unknown = Reflect.get(renderable, key)\n return typeof definition === \"function\" ? (definition as () => Definition) : undefined\n}\n\nexport const SimulationSemantics = { bind, read }\n", | ||
| "import { InstallationVersion } from \"@opencode-ai/core/installation/version\"\nimport { Effect } from \"effect\"\nimport { SimulationControlServer } from \"../control-server\"\nimport { SimulationProtocol } from \"../protocol\"\nimport { SimulationActions, type Harness } from \"./actions\"\nimport { SimulationRenderer } from \"./renderer\"\n\nfunction handle(harness: Harness, request: SimulationProtocol.Frontend.Request) {\n switch (request.method) {\n case \"simulation.handshake\":\n return SimulationProtocol.Handshake.dispatch(\n {\n role: \"ui\",\n server: { name: \"opencode\", version: InstallationVersion },\n capabilities: SimulationProtocol.Frontend.Capabilities,\n },\n request.params,\n )\n case \"ui.capture\":\n return SimulationActions.capture(harness)\n case \"ui.screenshot\":\n return SimulationActions.screenshot(harness, request.params?.name)\n case \"ui.state\":\n return Effect.sync(() => SimulationActions.state(harness))\n case \"ui.snapshot\":\n return Effect.sync(() => SimulationActions.snapshot(harness))\n case \"ui.matches\":\n return Effect.sync(() => SimulationActions.matches(harness, request.params.text))\n case \"ui.recording.finish\":\n return SimulationRenderer.finish(harness.renderer)\n case \"ui.type\":\n return SimulationActions.execute(harness, { type: \"ui.type\", text: request.params.text })\n case \"ui.enter\":\n return SimulationActions.execute(harness, { type: \"ui.enter\" })\n case \"ui.press\":\n return SimulationActions.execute(harness, {\n type: \"ui.press\",\n key: request.params.key,\n modifiers: request.params.modifiers,\n })\n case \"ui.arrow\":\n return SimulationActions.execute(harness, { type: \"ui.arrow\", direction: request.params.direction })\n case \"ui.focus\":\n return SimulationActions.execute(harness, { type: \"ui.focus\", target: request.params.target })\n case \"ui.click\":\n return SimulationActions.execute(harness, {\n type: \"ui.click\",\n target: request.params.target,\n x: request.params.x,\n y: request.params.y,\n semantic: request.params.semantic,\n })\n case \"ui.resize\":\n return SimulationActions.execute(harness, {\n type: \"ui.resize\",\n cols: request.params.cols,\n rows: request.params.rows,\n })\n }\n}\n\nexport const start = Effect.fn(\"SimulationServer.start\")(function* (harness: Harness, endpoint: string) {\n return yield* SimulationControlServer.start({\n endpoint,\n label: \"opencode drive ui websocket\",\n data: () => ({ drive: true as const }),\n decode: SimulationProtocol.Frontend.decodeRequestEffect,\n handle: (_socket, request) => handle(harness, request),\n })\n})\n\nexport * as SimulationServer from \"./server\"\n", | ||
| "import { createCliRenderer, type CliRendererConfig } from \"@opentui/core\"\nimport { Config, Effect } from \"effect\"\nimport { DriveManifest } from \"../manifest\"\nimport { SimulationActions } from \"./actions\"\nimport { SimulationRenderer } from \"./renderer\"\nimport { SimulationServer } from \"./server\"\n\n/** Drive-mode renderer and control-server acquisition. */\nexport const create = Effect.fn(\"Drive.create\")(function* (options: CliRendererConfig) {\n const headless = (yield* Config.string(\"OPENCODE_DRIVE_RENDERER\").pipe(Config.withDefault(\"visible\"))) === \"headless\"\n const manifest = yield* DriveManifest.resolve()\n const renderer = headless\n ? yield* SimulationRenderer.create(options, manifest.recording?.timeline, manifest.viewport)\n : yield* Effect.acquireRelease(\n Effect.tryPromise(() => createCliRenderer(options)),\n (renderer) =>\n Effect.sync(() => {\n if (!renderer.isDestroyed) renderer.destroy()\n }),\n )\n if (!headless && manifest.viewport) renderer.resize(manifest.viewport.cols, manifest.viewport.rows)\n const server = yield* SimulationServer.start(SimulationActions.createHarness(renderer), manifest.endpoints.ui)\n yield* Effect.sync(() => process.stderr.write(`opencode drive ui websocket: ${server.url}\\n`))\n return renderer\n})\n\nexport * as Drive from \"./simulation\"\n" | ||
| ], | ||
| "mappings": ";6pBAAA,sBAAS,iBACT,uBAAS,gBAAS,kBAAM,wHCDxB,iCAAS,gBACT,gBAAS,oBACT,kBAAS,aACT,mBAAS,eACT,mBAAS,wBAGF,IAAM,EAAS,EAAO,OAAO,CAClC,KAAM,EAAO,QAAQ,QAAQ,EAC7B,QAAS,EAAO,QAAQ,CAAC,EACzB,KAAM,EAAO,OACb,KAAM,EAAO,OACb,SAAU,EAAO,QAAQ,QAAQ,CACnC,CAAC,EAGY,EAAS,EAAO,OAAO,CAClC,KAAM,EAAO,QAAQ,QAAQ,EAC7B,MAAO,EAAO,OACd,KAAM,EAAO,MACf,CAAC,EAGY,EAAS,EAAO,OAAO,CAClC,KAAM,EAAO,QAAQ,QAAQ,EAC7B,MAAO,EAAO,OACd,KAAM,EAAO,OACb,KAAM,EAAO,MACf,CAAC,EAGY,GAAQ,EAAO,MAAM,CAAC,EAAQ,EAAQ,CAAM,CAAC,EAGnD,MAAM,UAAiB,CAAS,CAC5B,MAAQ,GACR,KACA,QACA,KACQ,OACA,QAAU,YAAY,IAAI,EAC1B,WAAuB,CAAC,EACjC,KAEA,WAAW,CAAC,EAAc,EAAc,EAAc,EAAqB,CACjF,MAAM,EACN,KAAK,KAAO,EACZ,KAAK,QAAU,EACf,KAAK,KAAO,EACZ,KAAK,OAAS,EAEd,KAAK,GAAG,QAAS,IAAM,EAAE,EACzB,EAAO,GAAG,QAAS,CAAC,IAAU,KAAK,QAAQ,CAAK,CAAC,cAGtC,OAAM,CAAC,EAAc,EAAc,EAAc,CAC5D,MAAM,EAAM,E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OAAO,MAAO,EAAwB,MAAM,CAC1C,WACA,MAAO,8BACP,KAAM,KAAO,CAAE,MAAO,EAAc,GACpC,OAAQ,EAAmB,SAAS,oBACpC,OAAQ,CAAC,EAAS,IAAY,GAAO,EAAS,CAAO,CACvD,CAAC,EACF,EC7DM,IAAM,GAAS,EAAO,GAAG,cAAc,EAAE,SAAU,CAAC,EAA4B,CACrF,IAAM,GAAY,MAAO,EAAO,OAAO,yBAAyB,EAAE,KAAK,EAAO,YAAY,SAAS,CAAC,KAAO,WACrG,EAAW,MAAO,EAAc,QAAQ,EACxC,EAAW,EACb,MAAO,EAAmB,OAAO,EAAS,EAAS,WAAW,SAAU,EAAS,QAAQ,EACzF,MAAO,EAAO,eACZ,EAAO,WAAW,IAAM,EAAkB,CAAO,CAAC,EAClD,CAAC,IACC,EAAO,KAAK,IAAM,CAChB,GAAI,CAAC,EAAS,YAAa,EAAS,QAAQ,EAC7C,CACL,EACJ,GAAI,CAAC,GAAY,EAAS,SAAU,EAAS,OAAO,EAAS,SAAS,KAAM,EAAS,SAAS,IAAI,EAClG,IAAM,EAAS,MAAO,EAAiB,MAAM,EAAkB,cAAc,CAAQ,EAAG,EAAS,UAAU,EAAE,EAE7G,OADA,MAAO,EAAO,KAAK,IAAM,QAAQ,OAAO,MAAM,gCAAgC,EAAO;AAAA,CAAO,CAAC,EACtF,EACR", | ||
| "debugId": "082C19EA0CB93F2964756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/status.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.status,\n Effect.fn(\"cli.service.status\")(function* () {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover({ ...options, version: undefined })\n process.stdout.write((found?.url ?? \"stopped\") + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";i3BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,YACnC,OAAO,QAAG,yBAAoB,OAAE,cAAU,OAAG,MAC3C,SAAM,OAAU,WAAO,OAAc,aAAQ,OACvC,EAAQ,MAAO,EAAQ,SAAS,IAAK,EAAS,QAAS,MAAU,CAAC,EACxE,QAAQ,OAAO,OAAO,GAAO,KAAO,WAAa,CAAG,EACrD,CACH", | ||
| "debugId": "9A2BF00F84A4EDBE64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/migrate.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\n\nexport default Runtime.handler(Commands.commands.migrate, (_input) => Effect.log(\"No migrations to run.\"))\n" | ||
| ], | ||
| "mappings": ";ivBAIA,SAAe,SAAQ,aAAQ,OAAS,cAAS,aAAS,MAAC,SAAW,OAAO,SAAI,4BAAuB,MAAC", | ||
| "debugId": "16CFE6704F84F1D764756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/mcp/logout.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport { OpenCode } from \"@opencode-ai/client\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { ServiceConfig } from \"../../../services/service-config\"\nimport { resolveIntegration } from \"./resolve\"\n\nconst location = { directory: process.cwd() }\n\nexport default Runtime.handler(\n Commands.commands.mcp.commands.logout,\n Effect.fn(\"cli.mcp.logout\")(function* (input) {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n\n const integration = yield* resolveIntegration(client, input.name, location)\n if (!integration) {\n process.stdout.write(`No stored credentials for ${input.name}` + EOL)\n return\n }\n\n const credentials = integration.connections.filter((connection) => connection.type === \"credential\")\n if (credentials.length === 0) {\n process.stdout.write(`No stored credentials for ${input.name}` + EOL)\n return\n }\n\n yield* Effect.forEach(\n credentials,\n (connection) => Effect.promise(() => client.credential.remove({ credentialID: connection.id, location })),\n { discard: true },\n )\n process.stdout.write(`Removed OAuth credentials for ${input.name}` + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";+8BAAA,mBAAS,gBAST,SAAM,OAAW,MAAE,eAAW,aAAQ,SAAI,MAAE,OAE7B,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,YAC/B,OAAO,QAAG,qBAAgB,OAAE,cAAU,MAAC,OAAO,MAC5C,IAAM,EAAU,MAAO,EAAc,QAAQ,EAEvC,GADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAEpF,EAAc,MAAO,EAAmB,EAAQ,EAAM,KAAM,CAAQ,EAC1E,GAAI,CAAC,EAAa,CAChB,QAAQ,OAAO,MAAM,6BAA6B,EAAM,OAAS,CAAG,EACpE,OAGF,IAAM,EAAc,EAAY,YAAY,OAAO,CAAC,IAAe,EAAW,OAAS,YAAY,EACnG,GAAI,EAAY,SAAW,EAAG,CAC5B,QAAQ,OAAO,MAAM,6BAA6B,EAAM,OAAS,CAAG,EACpE,OAGF,MAAO,EAAO,QACZ,EACA,CAAC,IAAe,EAAO,QAAQ,IAAM,EAAO,WAAW,OAAO,CAAE,aAAc,EAAW,GAAI,UAAS,CAAC,CAAC,EACxG,CAAE,QAAS,EAAK,CAClB,EACA,QAAQ,OAAO,MAAM,iCAAiC,EAAM,OAAS,CAAG,EACzE,CACH", | ||
| "debugId": "C57B3A2934A8D52E64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../core/src/plugin/sdk.ts", "../plugin/src/v2/effect/tool.ts", "../plugin/src/v2/effect/plugin.ts", "../schema/src/session.ts", "../schema/src/command.ts", "../schema/src/reference.ts"], | ||
| "sourcesContent": [ | ||
| "export * as SdkPlugins from \"./sdk\"\n\nimport type { Plugin } from \"@opencode-ai/plugin/v2/effect/plugin\"\nimport { Context, Effect, Layer } from \"effect\"\nimport { makeGlobalNode } from \"../effect/app-node\"\nimport { EventV2 } from \"../event\"\nimport type { PluginV2 } from \"../plugin\"\n\nexport const Updated = EventV2.ephemeral({ type: \"sdk.plugin.updated\", schema: {} })\n\n/**\n * Holds the plugins an embedder (the `@opencode-ai/sdk-next` host) contributes,\n * so `PluginSupervisor` can add them on every Location boot through the ordinary\n * generation path that `PluginSupervisor` uses for plugins discovered from\n * config. Registration publishes an unlocated update so every booted Location\n * reloads its plugin generation from the shared store.\n *\n * Each host-global layer owns one private store. Location graphs reuse that\n * layer through Effect's memoization, so separate hosts remain isolated while\n * every Location in one host sees the same registrations.\n */\nexport interface Interface {\n readonly register: (plugin: Plugin) => Effect.Effect<void>\n readonly all: () => readonly PluginV2.Versioned[]\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@opencode/SdkPlugins\") {}\n\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const events = yield* EventV2.Service\n const plugins = new Map<string, PluginV2.Versioned>()\n let revision = 0\n return Service.of({\n register: (plugin) =>\n Effect.sync(() => {\n plugins.set(plugin.id, { ...plugin, version: String(++revision) })\n }).pipe(Effect.andThen(events.publish(Updated, {})), Effect.asVoid),\n all: () => [...plugins.values()],\n })\n }),\n)\n\nexport const node = makeGlobalNode({ service: Service, layer, deps: [EventV2.node] })\n", | ||
| "export * as Tool from \"./tool.js\"\n\nimport { Agent } from \"@opencode-ai/schema/agent\"\nimport type { LLM } from \"@opencode-ai/schema/llm\"\nimport { Session } from \"@opencode-ai/schema/session\"\nimport { SessionMessage } from \"@opencode-ai/schema/session-message\"\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from \"@standard-schema/spec\"\nimport { Effect, JsonSchema, Schema } from \"effect\"\nimport type { Hooks, Transform } from \"./registration.js\"\n\nexport interface Context {\n readonly sessionID: Session.ID\n readonly agent: Agent.ID\n readonly messageID: SessionMessage.ID\n readonly callID: string\n readonly progress: (update: Progress) => Effect.Effect<void>\n}\n\nexport interface Progress {\n readonly structured: Readonly<Record<string, unknown>>\n readonly content?: ReadonlyArray<Content>\n}\n\nexport type StandardSchemaType<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output> &\n StandardJSONSchemaV1<Input, Output>\nexport type SchemaType<A> = Schema.Codec<A, any> | StandardSchemaType<any, A>\ntype IsAny<A> = 0 extends 1 & A ? true : false\nexport type InputValue<S> =\n IsAny<S> extends true\n ? any\n : S extends Schema.Codec<infer A, any>\n ? A\n : S extends StandardSchemaV1<any, infer A>\n ? A\n : never\nexport type OutputValue<S> =\n IsAny<S> extends true\n ? any\n : S extends Schema.Codec<infer A, any>\n ? A\n : S extends StandardSchemaV1<infer A, any>\n ? A\n : never\nexport type EncodedValue<S> =\n IsAny<S> extends true\n ? any\n : S extends Schema.Codec<any, infer A>\n ? A\n : S extends StandardSchemaV1<any, infer A>\n ? A\n : never\n\ntype ToolDefinition = {\n readonly name: string\n readonly description: string\n readonly inputSchema: JsonSchema.JsonSchema\n readonly outputSchema?: JsonSchema.JsonSchema\n}\n\ntype ToolCall = {\n readonly input: unknown\n readonly [key: string]: unknown\n}\n\ntype ToolResultValue =\n | { readonly type: \"json\"; readonly value: unknown }\n | { readonly type: \"text\"; readonly value: unknown }\n | { readonly type: \"error\"; readonly value: unknown }\n | { readonly type: \"content\"; readonly value: ReadonlyArray<LLM.ToolContent> }\n\ntype ToolOutput = {\n readonly structured: unknown\n readonly content: ReadonlyArray<LLM.ToolContent>\n}\n\nexport class Failure extends Schema.TaggedErrorClass<Failure>()(\"LLM.ToolFailure\", {\n message: Schema.String,\n error: Schema.optional(Schema.Defect()),\n metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n}) {}\n\nexport class RegistrationError extends Schema.TaggedErrorClass<RegistrationError>()(\"Tool.RegistrationError\", {\n name: Schema.String,\n message: Schema.String,\n}) {}\n\nexport type Content =\n | { readonly type: \"text\"; readonly text: string }\n | { readonly type: \"file\"; readonly data: string; readonly mime: string; readonly name?: string }\n\nexport type Definition<\n Input extends SchemaType<any>,\n Structured extends SchemaType<any>,\n Output extends SchemaType<any> = any,\n> = {\n readonly description: string\n readonly input: Input\n readonly output: Output\n readonly structured?: Structured\n readonly permission?: string\n readonly toStructuredOutput?: (input: {\n readonly input: InputValue<Input>\n readonly output: EncodedValue<Output>\n }) => OutputValue<Structured>\n readonly execute: (input: InputValue<Input>, context: Context) => Effect.Effect<OutputValue<Output>, Failure>\n readonly toModelOutput?: (input: {\n readonly input: InputValue<Input>\n readonly output: EncodedValue<Output>\n }) => ReadonlyArray<Content>\n}\n\nexport type DynamicOutput = {\n readonly structured: unknown\n readonly content: ReadonlyArray<Content>\n}\n\n/**\n * Config for a tool whose input shape is a raw JSON Schema not known at compile\n * time (MCP servers, plugin manifests). Input is passed through as `unknown`;\n * `execute` returns the already-projected structured value and model content.\n */\nexport type DynamicDefinition = {\n readonly description: string\n readonly jsonSchema: JsonSchema.JsonSchema\n readonly outputSchema?: JsonSchema.JsonSchema\n readonly permission?: string\n readonly execute: (input: unknown, context: Context) => Effect.Effect<DynamicOutput, Failure>\n}\n\nexport type AnyTool = Definition<any, any> | DynamicDefinition\n\nexport function make<\n Input extends SchemaType<any>,\n Output extends SchemaType<any>,\n Structured extends SchemaType<any> = Output,\n>(config: Definition<Input, Structured, Output>): Definition<Input, Structured, Output>\nexport function make(config: DynamicDefinition): DynamicDefinition\nexport function make(config: AnyTool): AnyTool\nexport function make(config: AnyTool): AnyTool {\n return config\n}\n\nfunction toModelContent(part: Content) {\n if (part.type === \"text\") return { type: \"text\" as const, text: part.text }\n return { type: \"file\" as const, uri: `data:${part.mime};base64,${part.data}`, mime: part.mime, name: part.name }\n}\n\nexport const validateName = (name: string) =>\n /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(name)\n ? Effect.void\n : Effect.fail(new RegistrationError({ name, message: `Invalid tool name: ${name}` }))\n\nexport const registrationEntries = (tools: Readonly<Record<string, AnyTool>>, namespace?: string) =>\n Object.entries(tools).map(([name, tool]) => {\n const normalized = name.replace(/[^a-zA-Z0-9_-]/g, \"_\")\n return {\n key: namespace === undefined ? normalized : `${namespace.replaceAll(\".\", \"_\")}_${normalized}`,\n name: normalized,\n namespace,\n tool,\n }\n })\n\nexport const validateNamespace = (namespace: string) =>\n namespace.split(\".\").every((segment) => /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(segment))\n ? Effect.void\n : Effect.fail(\n new RegistrationError({ name: namespace, message: `Invalid tool namespace: ${JSON.stringify(namespace)}` }),\n )\n\nexport const withPermission = <T extends AnyTool>(\n tool: T,\n permission: string,\n): Omit<T, \"permission\"> & {\n readonly permission: string\n} => ({ ...tool, permission })\n\nexport const permission = (tool: AnyTool, name: string) => tool.permission ?? name\n\nexport const definition = (name: string, tool: AnyTool): ToolDefinition =>\n \"jsonSchema\" in tool\n ? {\n name,\n description: tool.description,\n inputSchema: tool.jsonSchema,\n outputSchema: tool.outputSchema,\n }\n : {\n name,\n description: tool.description,\n inputSchema: inputJsonSchema(tool.input),\n outputSchema: outputJsonSchema(tool.structured ?? tool.output),\n }\n\nexport const settle = (tool: AnyTool, call: ToolCall, context: Context): Effect.Effect<ToolOutput, Failure> =>\n Effect.gen(function* () {\n if (\"jsonSchema\" in tool) {\n const output = yield* tool.execute(call.input, context)\n return { structured: output.structured, content: output.content.map(toModelContent) }\n }\n\n const input = yield* decodeInput(tool.input, call.input)\n const value = yield* tool.execute(input, context)\n const output = yield* encodeOutput(tool.output, value)\n const structured =\n tool.structured && tool.toStructuredOutput\n ? yield* encodeOutput(tool.structured, tool.toStructuredOutput({ input, output }))\n : output\n return {\n structured,\n content:\n tool.toModelOutput?.({ input, output }).map(toModelContent) ??\n (typeof output === \"string\" ? [{ type: \"text\" as const, text: output }] : []),\n }\n })\n\nfunction decodeInput(schema: SchemaType<any>, value: unknown): Effect.Effect<any, Failure> {\n if (Schema.isSchema(schema))\n return Schema.decodeUnknownEffect(schema)(value).pipe(\n Effect.mapError((error) => new Failure({ message: `Invalid tool input: ${error.message}` })),\n )\n return validateStandard(schema, value, \"Invalid tool input\")\n}\n\nfunction encodeOutput(schema: SchemaType<any>, value: unknown): Effect.Effect<any, Failure> {\n if (Schema.isSchema(schema))\n return Schema.encodeEffect(schema)(value).pipe(\n Effect.mapError(\n (error) => new Failure({ message: `Tool returned an invalid value for its output schema: ${error.message}` }),\n ),\n )\n return validateStandard(schema, value, \"Tool returned an invalid value for its output schema\")\n}\n\nfunction validateStandard(schema: StandardSchemaType, value: unknown, prefix: string): Effect.Effect<unknown, Failure> {\n return Effect.gen(function* () {\n const pending = yield* Effect.try({\n try: () => schema[\"~standard\"].validate(value),\n catch: (error) => standardFailure(prefix, error),\n })\n const result =\n pending instanceof Promise\n ? yield* Effect.tryPromise({ try: () => pending, catch: (error) => standardFailure(prefix, error) })\n : pending\n if (result.issues)\n return yield* Effect.fail(\n new Failure({ message: `${prefix}: ${result.issues.map((issue) => issue.message).join(\", \")}` }),\n )\n return result.value\n })\n}\n\nfunction standardFailure(prefix: string, error: unknown) {\n return new Failure({ message: `${prefix}: ${error instanceof Error ? error.message : String(error)}` })\n}\n\nfunction inputJsonSchema(schema: SchemaType<any>): JsonSchema.JsonSchema {\n if (!Schema.isSchema(schema))\n return schema[\"~standard\"].jsonSchema.input({ target: \"draft-2020-12\" }) as JsonSchema.JsonSchema\n return toJsonSchema(schema)\n}\n\nfunction outputJsonSchema(schema: SchemaType<any>): JsonSchema.JsonSchema {\n if (!Schema.isSchema(schema))\n return schema[\"~standard\"].jsonSchema.output({ target: \"draft-2020-12\" }) as JsonSchema.JsonSchema\n return toJsonSchema(schema)\n}\n\nfunction toJsonSchema(schema: Schema.Top): JsonSchema.JsonSchema {\n const document = Schema.toJsonSchemaDocument(schema)\n if (Object.keys(document.definitions).length === 0) return document.schema\n return { ...document.schema, $defs: document.definitions }\n}\n\nexport interface ToolExecuteBeforeEvent {\n readonly tool: string\n readonly sessionID: Session.ID\n readonly agent: Agent.ID\n readonly messageID: SessionMessage.ID\n readonly callID: string\n input: unknown\n}\n\nexport interface ToolExecuteAfterEvent {\n readonly tool: string\n readonly sessionID: Session.ID\n readonly agent: Agent.ID\n readonly messageID: SessionMessage.ID\n readonly callID: string\n readonly input: unknown\n result: ToolResultValue\n output?: ToolOutput\n outputPaths?: ReadonlyArray<string>\n}\n\nexport interface RegisterOptions {\n readonly namespace?: string\n /** Defaults to true. False exposes the tool directly to the provider. */\n readonly codemode?: boolean\n}\n\nexport interface ToolDraft {\n add(name: string, tool: AnyTool, options?: RegisterOptions): void\n}\n\nexport interface ToolHooks {\n readonly \"execute.before\": ToolExecuteBeforeEvent\n readonly \"execute.after\": ToolExecuteAfterEvent\n}\n\nexport interface ToolDomain {\n readonly transform: Transform<ToolDraft>\n readonly hook: Hooks<ToolHooks>\n}\n", | ||
| "import type { PluginApi } from \"@opencode-ai/client/effect/api\"\nimport type { Effect, Scope } from \"effect\"\nimport type { PluginOptions } from \"../options.js\"\nimport type { AgentDomain } from \"./agent.js\"\nimport type { AISDKDomain } from \"./aisdk.js\"\nimport type { CatalogDomain } from \"./catalog.js\"\nimport type { CommandDomain } from \"./command.js\"\nimport type { EventDomain } from \"./event.js\"\nimport type { IntegrationDomain } from \"./integration.js\"\nimport type { ReferenceDomain } from \"./reference.js\"\nimport type { SessionDomain } from \"./session.js\"\nimport type { SkillDomain } from \"./skill.js\"\nimport type { ToolDomain } from \"./tool.js\"\n\nexport interface Context {\n readonly options: PluginOptions\n readonly agent: AgentDomain\n readonly aisdk: AISDKDomain\n readonly catalog: CatalogDomain\n readonly command: CommandDomain\n readonly event: EventDomain\n readonly integration: IntegrationDomain\n readonly plugin: PluginApi<unknown>\n readonly reference: ReferenceDomain\n readonly session: SessionDomain\n readonly skill: SkillDomain\n readonly tool: ToolDomain\n}\n\nexport interface Plugin<R = Scope.Scope> {\n readonly id: string\n readonly effect: (context: Context) => Effect.Effect<void, never, R>\n}\n\nexport function define<R = Scope.Scope>(plugin: Plugin<R>) {\n return plugin\n}\n", | ||
| "export * as Session from \"./session.js\"\n\nimport { Schema } from \"effect\"\nimport { Agent } from \"./agent.js\"\nimport { Location } from \"./location.js\"\nimport { Model } from \"./model.js\"\nimport { Project } from \"./project.js\"\nimport { DateTimeUtcFromMillis, optional, RelativePath } from \"./schema.js\"\nimport { SessionEvent } from \"./session-event.js\"\nimport { SessionID } from \"./session-id.js\"\nimport { SessionMessage } from \"./session-message.js\"\nimport { Money } from \"./money.js\"\nimport { TokenUsage } from \"./token-usage.js\"\nimport { Revert } from \"./session-revert.js\"\n\nexport const ID = SessionID\nexport type ID = SessionID\n\nexport const Event = SessionEvent\n\nexport { Revert }\n\nexport interface Info extends Schema.Schema.Type<typeof Info> {}\nexport const Info = Schema.Struct({\n id: ID,\n parentID: ID.pipe(optional),\n fork: Schema.Struct({\n sessionID: ID,\n /** Messages before this exclusive boundary are copied into the fork. */\n messageID: SessionMessage.ID.pipe(optional),\n }).pipe(optional),\n projectID: Project.ID,\n agent: Agent.ID.pipe(optional),\n model: Model.Ref.pipe(optional),\n cost: Money.USD,\n tokens: TokenUsage.Info,\n time: Schema.Struct({\n created: DateTimeUtcFromMillis,\n updated: DateTimeUtcFromMillis,\n archived: DateTimeUtcFromMillis.pipe(optional),\n }),\n title: Schema.String,\n location: Location.Ref,\n subpath: RelativePath.pipe(optional),\n revert: Revert.pipe(optional),\n}).annotate({ identifier: \"Session.Info\" })\n\nexport const ListAnchor = Schema.Struct({\n id: ID,\n time: Schema.Finite,\n direction: Schema.Literals([\"previous\", \"next\"]),\n}).annotate({ identifier: \"Session.ListAnchor\" })\nexport interface ListAnchor extends Schema.Schema.Type<typeof ListAnchor> {}\n", | ||
| "export * as Command from \"./command.js\"\n\nimport { Schema } from \"effect\"\nimport { ephemeral, inventory } from \"./event.js\"\nimport { optional } from \"./schema.js\"\nimport { Model } from \"./model.js\"\nimport { Agent } from \"./agent.js\"\n\nconst Updated = ephemeral({ type: \"command.updated\", schema: {} })\n\nexport interface Info extends Schema.Schema.Type<typeof Info> {}\nexport const Info = Schema.Struct({\n name: Schema.String,\n template: Schema.String,\n description: Schema.String.pipe(optional),\n agent: Agent.ID.pipe(optional),\n model: Model.Ref.pipe(optional),\n subtask: Schema.Boolean.pipe(optional),\n}).annotate({ identifier: \"Command.Info\" })\n\nexport const Event = {\n Updated,\n Definitions: inventory(Updated),\n}\n", | ||
| "export * as Reference from \"./reference.js\"\n\nimport { Schema } from \"effect\"\nimport { optional } from \"./schema.js\"\nimport { ephemeral, inventory } from \"./event.js\"\nimport { AbsolutePath } from \"./schema.js\"\n\nconst Updated = ephemeral({ type: \"reference.updated\", schema: {} })\nexport const Event = { Updated, Definitions: inventory(Updated) }\n\nexport interface LocalSource extends Schema.Schema.Type<typeof LocalSource> {}\nexport const LocalSource = Schema.Struct({\n type: Schema.Literal(\"local\"),\n path: AbsolutePath,\n description: Schema.String.pipe(optional),\n hidden: Schema.Boolean.pipe(optional),\n}).annotate({ identifier: \"Reference.LocalSource\" })\n\nexport interface GitSource extends Schema.Schema.Type<typeof GitSource> {}\nexport const GitSource = Schema.Struct({\n type: Schema.Literal(\"git\"),\n repository: Schema.String,\n branch: Schema.String.pipe(optional),\n description: Schema.String.pipe(optional),\n hidden: Schema.Boolean.pipe(optional),\n}).annotate({ identifier: \"Reference.GitSource\" })\n\nexport const Source = Schema.Union([LocalSource, GitSource])\n .pipe(Schema.toTaggedUnion(\"type\"))\n .annotate({ identifier: \"Reference.Source\" })\nexport type Source = typeof Source.Type\n\nexport const Info = Schema.Struct({\n name: Schema.String,\n path: AbsolutePath,\n description: Schema.String.pipe(optional),\n hidden: Schema.Boolean.pipe(optional),\n source: Source,\n}).annotate({ identifier: \"Reference.Info\" })\nexport interface Info extends Schema.Schema.Type<typeof Info> {}\n" | ||
| ], | ||
| "mappings": ";kiBAQO,SAAM,OAAU,OAAQ,eAAU,MAAE,UAAM,qBAAsB,OAAQ,CAAC,CAAE,CAAC,EAkB5E,MAAM,UAAgB,EAAQ,QAA4B,EAAE,sBAAsB,CAAE,CAAC,CAErF,IAAM,EAAQ,EAAM,OACzB,EACA,EAAO,IAAI,SAAU,EAAG,CACtB,IAAM,EAAS,MAAO,EAAQ,QACxB,EAAU,IAAI,IAChB,EAAW,EACf,OAAO,EAAQ,GAAG,CAChB,SAAU,CAAC,IACT,EAAO,KAAK,IAAM,CAChB,EAAQ,IAAI,EAAO,GAAI,IAAK,EAAQ,QAAS,OAAO,EAAE,CAAQ,CAAE,CAAC,EAClE,EAAE,KAAK,EAAO,QAAQ,EAAO,QAAQ,EAAS,CAAC,CAAC,CAAC,EAAG,EAAO,MAAM,EACpE,IAAK,IAAM,CAAC,GAAG,EAAQ,OAAO,CAAC,CACjC,CAAC,EACF,CACH,EAEa,EAAO,EAAe,CAAE,QAAS,EAAS,QAAO,KAAM,CAAC,EAAQ,IAAI,CAAE,CAAC,6NC+B7E,MAAM,UAAgB,EAAO,iBAA0B,EAAE,kBAAmB,CACjF,QAAS,EAAO,OAChB,MAAO,EAAO,SAAS,EAAO,OAAO,CAAC,EACtC,SAAU,EAAO,SAAS,EAAO,OAAO,EAAO,OAAQ,EAAO,OAAO,CAAC,CACxE,CAAC,CAAE,CAAC,CAEG,MAAM,UAA0B,EAAO,iBAAoC,EAAE,yBAA0B,CAC5G,KAAM,EAAO,OACb,QAAS,EAAO,MAClB,CAAC,CAAE,CAAC,CAsDG,SAAS,CAAI,CAAC,EAA0B,CAC7C,OAAO,EAGT,SAAS,CAAc,CAAC,EAAe,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,KAAK,EAC1B,WAAY,EAAO,OACnB,OAAQ,EAAO,OAAO,KAAK,CAAQ,EACnC,YAAa,EAAO,OAAO,KAAK,CAAQ,EACxC,OAAQ,EAAO,QAAQ,KAAK,CAAQ,CACtC,CAAC,EAAE,SAAS,CAAE,WAAY,qBAAsB,CAAC,EAEpC,EAAS,EAAO,MAAM,CAAC,EAAa,CAAS,CAAC,EACxD,KAAK,EAAO,cAAc,MAAM,CAAC,EACjC,SAAS,CAAE,WAAY,kBAAmB,CAAC,EAGjC,GAAO,EAAO,OAAO,CAChC,KAAM,EAAO,OACb,KAAM,EACN,YAAa,EAAO,OAAO,KAAK,CAAQ,EACxC,OAAQ,EAAO,QAAQ,KAAK,CAAQ,EACpC,OAAQ,CACV,CAAC,EAAE,SAAS,CAAE,WAAY,gBAAiB,CAAC", | ||
| "debugId": "5B3446E1347CC99164756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/pair.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { OpenCode } from \"@opencode-ai/client/promise\"\nimport { renderUnicodeCompact } from \"uqr\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { ServiceConfig } from \"../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.pair,\n Effect.fn(\"cli.pair\")(function* () {\n const endpoint = yield* Service.ensure(yield* ServiceConfig.options())\n const password = yield* ServiceConfig.password()\n const server = yield* Effect.tryPromise(() =>\n OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) }).server.get(),\n )\n const info = { urls: server.urls, username: \"opencode\", password }\n process.stdout.write(\n [\n \"\",\n ` URLs ${info.urls[0] ?? \"(none)\"}`,\n ...info.urls.slice(1).map((url) => ` ${url}`),\n ` Username ${info.username}`,\n ` Password ${info.password}`,\n \"\",\n \" Scan to pair\",\n \"\",\n renderUnicodeCompact(JSON.stringify(info), { border: 2 })\n .split(EOL)\n .map((line) => \" \" + line)\n .join(EOL),\n \"\",\n ].join(EOL) + EOL,\n )\n\n const hostname = new URL(endpoint.url).hostname\n if (![\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(hostname)) return\n process.stderr.write(\n ` Run \\`opencode service set hostname 0.0.0.0\\` to access the service remotely.${EOL}${EOL}`,\n )\n }),\n)\n" | ||
| ], | ||
| "mappings": ";+8BAAA,mBAAS,gBAST,SAAe,SAAQ,aACrB,OAAS,cAAS,UAClB,OAAO,QAAG,eAAU,OAAE,cAAU,OAAG,MACjC,SAAM,OAAW,WAAO,OAAQ,YAAO,WAAO,OAAc,aAAQ,MAAC,OAC/D,EAAW,MAAO,EAAc,SAAS,EAIzC,EAAO,CAAE,MAHA,MAAO,EAAO,WAAW,IACtC,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAAE,OAAO,IAAI,CAC1F,GAC4B,KAAM,SAAU,WAAY,UAAS,EACjE,QAAQ,OAAO,MACb,CACE,GACA,eAAe,EAAK,KAAK,IAAM,WAC/B,GAAG,EAAK,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAQ,eAAe,GAAK,EACvD,eAAe,EAAK,WACpB,eAAe,EAAK,WACpB,GACA,iBACA,GACA,EAAqB,KAAK,UAAU,CAAI,EAAG,CAAE,OAAQ,CAAE,CAAC,EACrD,MAAM,CAAG,EACT,IAAI,CAAC,IAAS,KAAO,CAAI,EACzB,KAAK,CAAG,EACX,EACF,EAAE,KAAK,CAAG,EAAI,CAChB,EAEA,IAAM,EAAW,IAAI,IAAI,EAAS,GAAG,EAAE,SACvC,GAAI,CAAC,CAAC,YAAa,YAAa,OAAO,EAAE,SAAS,CAAQ,EAAG,OAC7D,QAAQ,OAAO,MACb,kFAAkF,IAAM,GAC1F,EACD,CACH", | ||
| "debugId": "B71FF73628071C4764756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/stop.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.stop,\n Effect.fn(\"cli.service.stop\")(function* () {\n yield* Service.stop(yield* ServiceConfig.options())\n }),\n)\n" | ||
| ], | ||
| "mappings": ";i3BAMA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,UACnC,OAAO,QAAG,uBAAkB,OAAE,cAAU,OAAG,MACzC,WAAO,OAAQ,UAAK,WAAO,OAAc,aAAQ,MAAC,OACnD,CACH", | ||
| "debugId": "8FD5F50B48CD7B9D64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/mcp/list.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport { OpenCode, type McpServer } from \"@opencode-ai/client\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.mcp.commands.list,\n Effect.fn(\"cli.mcp.list\")(function* () {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const response = yield* Effect.promise(() => client.mcp.list({ location: { directory: process.cwd() } }))\n const servers = response.data.toSorted((a, b) => a.name.localeCompare(b.name))\n if (servers.length === 0) {\n process.stdout.write(\"No MCP servers configured\" + EOL)\n return\n }\n const width = Math.max(...servers.map((server) => server.name.length))\n const lines = servers.map(\n (server) => `${icon(server.status)} ${server.name.padEnd(width)} ${describe(server.status)}`,\n )\n process.stdout.write(lines.join(EOL) + EOL)\n }),\n)\n\nfunction icon(status: McpServer[\"status\"]) {\n switch (status.status) {\n case \"connected\":\n return \"✓\"\n case \"needs_auth\":\n return \"⚠\"\n case \"failed\":\n case \"needs_client_registration\":\n return \"✗\"\n default:\n return \"○\"\n }\n}\n\nfunction describe(status: McpServer[\"status\"]) {\n switch (status.status) {\n case \"needs_auth\":\n return \"needs authentication\"\n case \"needs_client_registration\":\n return `needs client registration: ${status.error}`\n case \"failed\":\n return `failed: ${status.error}`\n default:\n return status.status\n }\n}\n" | ||
| ], | ||
| "mappings": ";g6BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,UAC/B,OAAO,QAAG,mBAAc,OAAE,cAAU,OAAG,MACrC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,QADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAEpF,GADW,MAAO,EAAO,QAAQ,IAAM,EAAO,IAAI,KAAK,CAAE,SAAU,CAAE,UAAW,QAAQ,IAAI,CAAE,CAAE,CAAC,CAAC,GAC/E,KAAK,SAAS,CAAC,EAAG,IAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC,EAC7E,GAAI,EAAQ,SAAW,EAAG,CACxB,QAAQ,OAAO,MAAM,4BAA8B,CAAG,EACtD,OAEF,IAAM,EAAQ,KAAK,IAAI,GAAG,EAAQ,IAAI,CAAC,IAAW,EAAO,KAAK,MAAM,CAAC,EAC/D,EAAQ,EAAQ,IACpB,CAAC,IAAW,GAAG,EAAK,EAAO,MAAM,KAAK,EAAO,KAAK,OAAO,CAAK,MAAM,EAAS,EAAO,MAAM,GAC5F,EACA,QAAQ,OAAO,MAAM,EAAM,KAAK,CAAG,EAAI,CAAG,EAC3C,CACH,EAEA,SAAS,CAAI,CAAC,EAA6B,CACzC,OAAQ,EAAO,YACR,YACH,MAAO,aACJ,aACH,MAAO,aACJ,aACA,4BACH,MAAO,iBAEP,MAAO,UAIb,SAAS,CAAQ,CAAC,EAA6B,CAC7C,OAAQ,EAAO,YACR,aACH,MAAO,2BACJ,4BACH,MAAO,8BAA8B,EAAO,YACzC,SACH,MAAO,WAAW,EAAO,gBAEzB,OAAO,EAAO", | ||
| "debugId": "E62EFFBCF0E94EB964756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/start.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.start,\n Effect.fn(\"cli.service.start\")(function* () {\n const transport = yield* Service.ensure(yield* ServiceConfig.options())\n process.stdout.write(transport.url + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";i3BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,WACnC,OAAO,QAAG,wBAAmB,OAAE,cAAU,OAAG,MAC1C,SAAM,OAAY,WAAO,OAAQ,YAAO,WAAO,EAAc,QAAQ,CAAC,EACtE,QAAQ,OAAO,MAAM,EAAU,IAAM,CAAG,EACzC,CACH", | ||
| "debugId": "D62E26ED08896BA064756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../core/src/image/photon-wasm.bun.ts", "../core/src/image/photon.ts"], | ||
| "sourcesContent": [ | ||
| "// @ts-ignore Bun embeds static file imports when compiling the CLI.\nimport photonWasm from \"@silvia-odwyer/photon-node/photon_rs_bg.wasm\" with { type: \"file\" }\n\nexport default photonWasm\n", | ||
| "import photonWasm from \"#photon-wasm\"\nimport { Effect } from \"effect\"\nimport path from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\nimport { FileSystem } from \"../filesystem\"\nimport { DecodeError, ResizerUnavailableError, SizeError } from \"../image\"\n\nconst JPEG_QUALITIES = [80, 85, 70, 55, 40]\n\nexport const make = Effect.gen(function* () {\n ;(globalThis as typeof globalThis & { __OPENCODE_PHOTON_WASM_PATH?: string }).__OPENCODE_PHOTON_WASM_PATH =\n path.isAbsolute(photonWasm) ? photonWasm : fileURLToPath(new URL(photonWasm, import.meta.url))\n const loadPhoton = yield* Effect.cached(\n Effect.tryPromise({\n try: () => import(\"@silvia-odwyer/photon-node\"),\n catch: () => new ResizerUnavailableError(),\n }),\n )\n return Effect.fn(\"Image.Photon.normalize\")(function* (\n resource: string,\n content: FileSystem.Content & { readonly encoding: \"base64\" },\n limits: {\n readonly autoResize: boolean\n readonly maxWidth: number\n readonly maxHeight: number\n readonly maxBase64Bytes: number\n },\n ) {\n const photon = yield* loadPhoton\n const decoded = yield* Effect.try({\n try: () => photon.PhotonImage.new_from_byteslice(Buffer.from(content.content, \"base64\")),\n catch: () => new DecodeError({ resource }),\n })\n try {\n const width = decoded.get_width()\n const height = decoded.get_height()\n const bytes = Buffer.byteLength(content.content, \"utf-8\")\n if (width <= limits.maxWidth && height <= limits.maxHeight && bytes <= limits.maxBase64Bytes) return content\n if (!limits.autoResize)\n return yield* new SizeError({\n resource,\n width,\n height,\n bytes,\n maxWidth: limits.maxWidth,\n maxHeight: limits.maxHeight,\n maxBytes: limits.maxBase64Bytes,\n })\n const scale = Math.min(1, limits.maxWidth / width, limits.maxHeight / height)\n const sizes = Array.from({ length: 32 }).reduce<Array<{ width: number; height: number }>>((acc) => {\n const previous = acc.at(-1) ?? {\n width: Math.max(1, Math.round(width * scale)),\n height: Math.max(1, Math.round(height * scale)),\n }\n const next =\n acc.length === 0\n ? previous\n : {\n width: previous.width === 1 ? 1 : Math.max(1, Math.floor(previous.width * 0.75)),\n height: previous.height === 1 ? 1 : Math.max(1, Math.floor(previous.height * 0.75)),\n }\n return acc.some((item) => item.width === next.width && item.height === next.height) ? acc : [...acc, next]\n }, [])\n for (const size of sizes) {\n const resized = photon.resize(decoded, size.width, size.height, photon.SamplingFilter.Lanczos3)\n try {\n const encoders: Array<readonly [mime: string, encode: () => Uint8Array]> = [\n [\"image/png\", () => resized.get_bytes()],\n ...JPEG_QUALITIES.map((quality) => [\"image/jpeg\", () => resized.get_bytes_jpeg(quality)] as const),\n ]\n for (const [mime, encode] of encoders) {\n const candidate = Buffer.from(encode()).toString(\"base64\")\n if (Buffer.byteLength(candidate, \"utf-8\") <= limits.maxBase64Bytes)\n return { ...content, content: candidate, encoding: \"base64\" as const, mime }\n }\n } finally {\n resized.free()\n }\n }\n return yield* new SizeError({\n resource,\n width,\n height,\n bytes,\n maxWidth: limits.maxWidth,\n maxHeight: limits.maxHeight,\n maxBytes: limits.maxBase64Bytes,\n })\n } finally {\n decoded.free()\n }\n })\n})\n" | ||
| ], | ||
| "mappings": ";i4BAGA,SAAe,SCDf,yBACA,6BAAS,iBAIT,SAAM,OAAiB,MAAC,QAAI,QAAI,QAAI,QAAI,OAAE,OAE7B,OAAO,OAAO,SAAI,cAAU,OAAG,MACxC,gBAA4E,iCAC5E,OAAK,yBAAW,CAAU,EAAI,EAAa,EAAc,IAAI,IAAI,EAAY,YAAY,GAAG,CAAC,EAC/F,IAAM,EAAa,MAAO,EAAO,OAC/B,EAAO,WAAW,CAChB,IAAK,IAAa,yCAClB,MAAO,IAAM,IAAI,CACnB,CAAC,CACH,EACA,OAAO,EAAO,GAAG,wBAAwB,EAAE,SAAU,CACnD,EACA,EACA,EAMA,CACA,IAAM,EAAS,MAAO,EAChB,EAAU,MAAO,EAAO,IAAI,CAChC,IAAK,IAAM,EAAO,YAAY,mBAAmB,OAAO,KAAK,EAAQ,QAAS,QAAQ,CAAC,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AQ,UAAU,CAAC,EACvC,GAAG,EAAe,IAAI,CAAC,IAAY,CAAC,aAAc,IAAM,EAAQ,eAAe,CAAO,CAAC,CAAU,CACnG,EACA,QAAY,EAAM,KAAW,EAAU,CACrC,IAAM,EAAY,OAAO,KAAK,EAAO,CAAC,EAAE,SAAS,QAAQ,EACzD,GAAI,OAAO,WAAW,EAAW,OAAO,GAAK,EAAO,eAClD,MAAO,IAAK,EAAS,QAAS,EAAW,SAAU,SAAmB,MAAK,UAE/E,CACA,EAAQ,KAAK,GAGjB,OAAO,MAAO,IAAI,EAAU,CAC1B,WACA,QACA,SACA,QACA,SAAU,EAAO,SACjB,UAAW,EAAO,UAClB,SAAU,EAAO,cACnB,CAAC,SACD,CACA,EAAQ,KAAK,GAEhB,EACF", | ||
| "debugId": "DF2CE38034FD532064756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/set.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect } from \"effect\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.set,\n Effect.fn(\"cli.service.set\")(function* (input) {\n yield* ServiceConfig.set(input.key, input.value)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";o2BAKA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,SACnC,OAAO,QAAG,sBAAiB,OAAE,cAAU,MAAC,OAAO,MAC7C,WAAO,OAAc,SAAI,OAAM,SAAK,OAAM,UAAK,EAChD,CACH", | ||
| "debugId": "56067E2425DCF85764756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/api.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect, Option } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { Service, type Endpoint } from \"@opencode-ai/client/effect/service\"\nimport { ServerConnection } from \"../../services/server-connection\"\n\nconst methods = new Set([\"delete\", \"get\", \"head\", \"options\", \"patch\", \"post\", \"put\"])\n\ntype Operation = {\n operationId?: string\n}\n\ntype OpenApi = {\n paths?: Record<string, Record<string, Operation>>\n}\n\nexport default Runtime.handler(\n Commands.commands.api,\n Effect.fn(\"cli.api\")(function* (input) {\n const server = yield* ServerConnection.resolve({\n server: Option.getOrUndefined(input.server),\n standalone: input.standalone,\n mismatch: \"ignore\",\n })\n const endpoint = server.endpoint\n const params = Option.getOrElse(input.param, () => ({}))\n const request = yield* resolveRequest(endpoint, input.request, params)\n const headers = new Headers(Service.headers(endpoint))\n for (const header of input.header) {\n const index = header.indexOf(\":\")\n if (index < 1) return yield* Effect.fail(new Error(`Invalid header, expected name:value: ${header}`))\n headers.set(header.slice(0, index).trim(), header.slice(index + 1).trim())\n }\n const body = Option.getOrUndefined(input.data)\n if (body !== undefined && !headers.has(\"content-type\")) headers.set(\"content-type\", \"application/json\")\n\n const response = yield* Effect.tryPromise(() =>\n fetch(new URL(request.path, endpoint.url), {\n method: request.method,\n headers,\n body,\n }),\n )\n const output = yield* Effect.promise(() => response.text())\n if (output) process.stdout.write(output + (output.endsWith(EOL) ? \"\" : EOL))\n }),\n)\n\nexport function resolveOperation(spec: OpenApi, operationID: string, params: Record<string, string>) {\n for (const [path, operations] of Object.entries(spec.paths ?? {})) {\n for (const [method, operation] of Object.entries(operations)) {\n if (!methods.has(method) || operation.operationId !== operationID) continue\n return { method: method.toUpperCase(), path: interpolate(path, params) }\n }\n }\n throw new Error(`Operation not found: ${operationID}`)\n}\n\nexport function rawRequest(input: readonly string[]) {\n if (input.length !== 2 || !methods.has(input[0].toLowerCase()) || !input[1].startsWith(\"/\")) return\n return { method: input[0].toUpperCase(), path: input[1] }\n}\n\nfunction resolveRequest(endpoint: Endpoint, input: readonly string[], params: Record<string, string>) {\n const raw = rawRequest(input)\n if (raw) return Effect.succeed(raw)\n if (input.length !== 1) return Effect.fail(new Error(\"Expected an operation name or an HTTP method and path\"))\n return Effect.tryPromise(async () => {\n const response = await fetch(new URL(\"/openapi.json\", endpoint.url), { headers: Service.headers(endpoint) })\n if (!response.ok) throw new Error(`Failed to load OpenAPI document: HTTP ${response.status}`)\n return resolveOperation((await response.json()) as OpenApi, input[0], params)\n })\n}\n\nfunction interpolate(path: string, params: Record<string, string>) {\n const used = new Set<string>()\n const pathname = path.replaceAll(/\\{([^}]+)\\}/g, (_, name: string) => {\n const value = params[name]\n if (value === undefined) throw new Error(`Missing path parameter: ${name}`)\n used.add(name)\n return encodeURIComponent(value)\n })\n const query = new URLSearchParams(Object.entries(params).filter(([name]) => !used.has(name))).toString()\n return query ? `${pathname}?${query}` : pathname\n}\n" | ||
| ], | ||
| "mappings": ";+9BAAA,mBAAS,gBAOT,SAAM,OAAU,SAAI,SAAI,MAAC,cAAU,WAAO,YAAQ,eAAW,aAAS,YAAQ,UAAK,MAAC,OAUrE,SAAQ,aACrB,OAAS,cAAS,SAClB,OAAO,QAAG,cAAS,OAAE,cAAU,CAAC,EAAO,CAMrC,IAAM,GALS,MAAO,EAAiB,QAAQ,CAC7C,OAAQ,EAAO,eAAe,EAAM,MAAM,EAC1C,WAAY,EAAM,WAClB,SAAU,QACZ,CAAC,GACuB,SAClB,EAAS,EAAO,UAAU,EAAM,MAAO,KAAO,CAAC,EAAE,EACjD,EAAU,MAAO,EAAe,EAAU,EAAM,QAAS,CAAM,EAC/D,EAAU,IAAI,QAAQ,EAAQ,QAAQ,CAAQ,CAAC,EACrD,QAAW,KAAU,EAAM,OAAQ,CACjC,IAAM,EAAQ,EAAO,QAAQ,GAAG,EAChC,GAAI,EAAQ,EAAG,OAAO,MAAO,EAAO,KAAS,MAAM,wCAAwC,GAAQ,CAAC,EACpG,EAAQ,IAAI,EAAO,MAAM,EAAG,CAAK,EAAE,KAAK,EAAG,EAAO,MAAM,EAAQ,CAAC,EAAE,KAAK,CAAC,EAE3E,I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GAAG,EAAG,CAAE,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAC3G,GAAI,CAAC,EAAS,GAAI,MAAU,MAAM,yCAAyC,EAAS,QAAQ,EAC5F,OAAO,EAAkB,MAAM,EAAS,KAAK,EAAe,EAAM,GAAI,CAAM,EAC7E,EAGH,SAAS,CAAW,CAAC,EAAc,EAAgC,CACjE,IAAM,EAAO,IAAI,IACX,EAAW,EAAK,WAAW,eAAgB,CAAC,EAAG,IAAiB,CACpE,IAAM,EAAQ,EAAO,GACrB,GAAI,IAAU,OAAW,MAAU,MAAM,2BAA2B,GAAM,EAE1E,OADA,EAAK,IAAI,CAAI,EACN,mBAAmB,CAAK,EAChC,EACK,EAAQ,IAAI,gBAAgB,OAAO,QAAQ,CAAM,EAAE,OAAO,EAAE,KAAU,CAAC,EAAK,IAAI,CAAI,CAAC,CAAC,EAAE,SAAS,EACvG,OAAO,EAAQ,GAAG,KAAY,IAAU", | ||
| "debugId": "DE615A60EE9BB2D064756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
| { | ||
| "version": 3, | ||
| "sources": ["src/ui/timeline.tsx", "src/commands/handlers/console/login.ts"], | ||
| "sourcesContent": [ | ||
| "import { createComponent as _$createComponent } from \"@opentui/solid\";\nimport { effect as _$effect } from \"@opentui/solid\";\nimport { createTextNode as _$createTextNode } from \"@opentui/solid\";\nimport { insertNode as _$insertNode } from \"@opentui/solid\";\nimport { insert as _$insert } from \"@opentui/solid\";\nimport { setProp as _$setProp } from \"@opentui/solid\";\nimport { createElement as _$createElement } from \"@opentui/solid\";\n/** @jsxImportSource @opentui/solid */\nimport { createCliRenderer, RGBA } from \"@opentui/core\";\nimport { createScrollbackWriter, render, useKeyboard } from \"@opentui/solid\";\nimport { registerOpencodeSpinner } from \"@opencode-ai/tui/component/register-spinner\";\nimport { Show, createSignal } from \"solid-js\";\nregisterOpencodeSpinner();\nconst SPINNER_FRAMES = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\nconst IDLE_TIMEOUT = 1_000;\nconst COLORS = {\n accent: RGBA.fromIndex(6),\n error: RGBA.fromIndex(1),\n foreground: RGBA.defaultForeground(),\n muted: RGBA.fromIndex(8),\n success: RGBA.fromIndex(2)\n};\nconst ROWS = {\n intro: {\n marker: \"┌\",\n color: COLORS.muted,\n connector: true\n },\n item: {\n marker: \"●\",\n color: COLORS.accent,\n connector: true\n },\n success: {\n marker: \"◇\",\n color: COLORS.success,\n connector: true\n },\n failure: {\n marker: \"■\",\n color: COLORS.error,\n connector: false\n },\n outro: {\n marker: \"└\",\n color: COLORS.muted,\n connector: false\n }\n};\nfunction row(kind, value) {\n const style = ROWS[kind];\n return createScrollbackWriter(() => (() => {\n var _el$ = _$createElement(\"box\"),\n _el$2 = _$createElement(\"box\"),\n _el$3 = _$createElement(\"text\"),\n _el$4 = _$createElement(\"text\");\n _$insertNode(_el$, _el$2);\n _$setProp(_el$, \"width\", \"100%\");\n _$setProp(_el$, \"minHeight\", 1);\n _$setProp(_el$, \"flexDirection\", \"column\");\n _$insertNode(_el$2, _el$3);\n _$insertNode(_el$2, _el$4);\n _$setProp(_el$2, \"width\", \"100%\");\n _$setProp(_el$2, \"minHeight\", 1);\n _$setProp(_el$2, \"flexDirection\", \"row\");\n _$setProp(_el$2, \"gap\", 1);\n _$setProp(_el$3, \"flexShrink\", 0);\n _$insert(_el$3, () => style.marker);\n _$setProp(_el$4, \"wrapMode\", \"word\");\n _$insert(_el$4, value);\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return style.connector;\n },\n get children() {\n var _el$5 = _$createElement(\"text\");\n _$insertNode(_el$5, _$createTextNode(`│`));\n _$effect(_$p => _$setProp(_el$5, \"fg\", COLORS.muted, _$p));\n return _el$5;\n }\n }), null);\n _$effect(_p$ => {\n var _v$ = style.color,\n _v$2 = COLORS.foreground;\n _v$ !== _p$.e && (_p$.e = _$setProp(_el$3, \"fg\", _v$, _p$.e));\n _v$2 !== _p$.t && (_p$.t = _$setProp(_el$4, \"fg\", _v$2, _p$.t));\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$;\n })(), {\n startOnNewLine: true,\n trailingNewline: !style.connector\n });\n}\nfunction TimelineFooter(props) {\n useKeyboard(event => {\n if (event.name !== \"escape\" && !(event.ctrl && event.name === \"c\")) return;\n event.preventDefault();\n props.cancel();\n });\n return (() => {\n var _el$7 = _$createElement(\"box\");\n _$setProp(_el$7, \"width\", \"100%\");\n _$setProp(_el$7, \"height\", 1);\n _$setProp(_el$7, \"flexDirection\", \"row\");\n _$setProp(_el$7, \"gap\", 1);\n _$insert(_el$7, _$createComponent(Show, {\n get when() {\n return props.pending();\n },\n children: text => [(() => {\n var _el$8 = _$createElement(\"spinner\");\n _$setProp(_el$8, \"frames\", SPINNER_FRAMES);\n _$setProp(_el$8, \"interval\", 80);\n _$effect(_$p => _$setProp(_el$8, \"color\", COLORS.accent, _$p));\n return _el$8;\n })(), (() => {\n var _el$9 = _$createElement(\"text\");\n _$setProp(_el$9, \"wrapMode\", \"none\");\n _$setProp(_el$9, \"truncate\", true);\n _$insert(_el$9, text);\n _$effect(_$p => _$setProp(_el$9, \"fg\", COLORS.foreground, _$p));\n return _el$9;\n })()]\n }));\n return _el$7;\n })();\n}\nfunction bounded(task) {\n return new Promise(resolve => {\n const timer = setTimeout(resolve, IDLE_TIMEOUT);\n timer.unref();\n const finish = () => {\n clearTimeout(timer);\n resolve();\n };\n void task.then(finish, finish);\n });\n}\nasync function shutdown(renderer) {\n await bounded(renderer.idle());\n try {\n renderer.externalOutputMode = \"passthrough\";\n } finally {\n try {\n renderer.screenMode = \"main-screen\";\n } finally {\n if (!renderer.isDestroyed) renderer.destroy();\n }\n }\n}\nexport async function createTimelineHost() {\n const stdout = process.stdout;\n const controller = new AbortController();\n const signals = [\"SIGINT\", \"SIGHUP\", \"SIGQUIT\"];\n const cancel = () => {\n if (!controller.signal.aborted) controller.abort();\n };\n signals.forEach(signal => process.on(signal, cancel));\n if (!stdout.isTTY || !process.stdin.isTTY) {\n let closed = false;\n let writing = false;\n let active;\n let closeTask;\n const write = async (kind, text) => {\n if (closed) throw new Error(\"timeline closed\");\n if (writing) throw new Error(\"timeline write already in progress\");\n writing = true;\n try {\n const style = kind === \"pending\" ? undefined : ROWS[kind];\n const marker = kind === \"pending\" ? \".\" : ROWS[kind].marker;\n const connector = style?.connector ? \"│\\n\" : \"\";\n active = new Promise((resolve, reject) => {\n stdout.write(`${marker} ${text}\\n${connector}`, error => error ? reject(error) : resolve());\n });\n await active;\n } finally {\n writing = false;\n active = undefined;\n }\n };\n const close = () => {\n if (closeTask) return closeTask;\n closed = true;\n closeTask = (async () => {\n await active?.catch(() => {});\n signals.forEach(signal => process.off(signal, cancel));\n })();\n return closeTask;\n };\n return {\n signal: controller.signal,\n intro: text => write(\"intro\", text),\n item: text => write(\"item\", text),\n pending: text => write(\"pending\", text),\n success: text => write(\"success\", text),\n failure: text => write(\"failure\", text),\n outro: text => write(\"outro\", text),\n close\n };\n }\n let renderer;\n try {\n // Start on a fresh row so delayed SSH cursor reports cannot make\n // split-footer overwrite the shell command.\n process.stdout.write(\"\\n\");\n renderer = await createCliRenderer({\n stdin: process.stdin,\n useMouse: false,\n autoFocus: false,\n openConsoleOnError: false,\n exitOnCtrlC: false,\n exitSignals: [],\n screenMode: \"split-footer\",\n footerHeight: 1,\n externalOutputMode: \"capture-stdout\",\n consoleMode: \"disabled\",\n clearOnShutdown: false\n });\n const activeRenderer = renderer;\n const [pending, setPending] = createSignal();\n const renderTask = render(() => _$createComponent(TimelineFooter, {\n pending: pending,\n cancel: cancel\n }), activeRenderer);\n void renderTask.catch(cancel);\n await bounded(activeRenderer.idle());\n let closed = false;\n let writing = false;\n let active;\n let closeTask;\n const write = (kind, text) => {\n if (closed) return Promise.reject(new Error(\"timeline closed\"));\n if (writing) return Promise.reject(new Error(\"timeline write already in progress\"));\n writing = true;\n active = (async () => {\n if (kind === \"pending\") {\n setPending(text);\n activeRenderer.requestRender();\n } else {\n if (kind === \"success\" || kind === \"failure\" || kind === \"outro\") setPending(undefined);\n activeRenderer.writeToScrollback(row(kind, text));\n activeRenderer.requestRender();\n }\n await bounded(activeRenderer.idle());\n })().finally(() => {\n writing = false;\n active = undefined;\n });\n return active;\n };\n const close = () => {\n if (closeTask) return closeTask;\n closed = true;\n closeTask = (async () => {\n await active?.catch(() => {});\n try {\n await shutdown(activeRenderer);\n await bounded(renderTask);\n } finally {\n signals.forEach(signal => process.off(signal, cancel));\n }\n })();\n return closeTask;\n };\n return {\n signal: controller.signal,\n intro: text => write(\"intro\", text),\n item: text => write(\"item\", text),\n pending: text => write(\"pending\", text),\n success: text => write(\"success\", text),\n failure: text => write(\"failure\", text),\n outro: text => write(\"outro\", text),\n close\n };\n } catch (error) {\n try {\n if (renderer) await shutdown(renderer);\n } finally {\n signals.forEach(signal => process.off(signal, cancel));\n }\n throw error;\n }\n}", | ||
| "import { Cause, Effect, Exit, Option } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { OpenCode, type OpenCodeClient } from \"@opencode-ai/client/promise\"\nimport { AppProcess } from \"@opencode-ai/core/process\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\nimport { createTimelineHost, type TimelineHost } from \"../../../ui/timeline\"\n\nconst integrationID = \"opencode\"\nconst location = { directory: process.cwd() }\n\nexport default Runtime.handler(\n Commands.commands.console.commands.login,\n Effect.fn(\"cli.console.login\")(function* (input) {\n const timeline = yield* Effect.acquireRelease(\n Effect.promise(() => createTimelineHost()),\n (value) => request(() => value.close()).pipe(Effect.ignore),\n )\n const exit = yield* login(timeline, Option.getOrUndefined(input.url)).pipe(\n Effect.raceFirst(AppProcess.waitForAbort(timeline.signal)),\n Effect.exit,\n )\n if (Exit.isSuccess(exit)) return\n\n const cancelled = timeline.signal.aborted\n yield* request(() => timeline.failure(cancelled ? \"Authorization cancelled\" : errorMessage(exit.cause))).pipe(\n Effect.ignore,\n )\n process.exitCode = cancelled ? 130 : 1\n }),\n)\n\nconst login = Effect.fn(\"cli.console.login.run\")(function* (timeline: TimelineHost, server?: string) {\n yield* request(() => timeline.intro(\"Log in\"))\n yield* request(() => timeline.pending(\"Connecting to OpenCode...\"))\n\n const endpoint = yield* Service.ensure(yield* ServiceConfig.options())\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const found = yield* request((signal) => client.integration.get({ integrationID, location }, { signal }))\n const integration = yield* required(found.data, \"OpenCode Console integration is unavailable\")\n const method = yield* required(\n integration.methods.find((candidate) => candidate.type === \"oauth\"),\n \"OpenCode Console login is unavailable\",\n )\n\n yield* request(() => timeline.pending(\"Starting authorization...\"))\n const started = yield* request((signal) =>\n client.integration.oauth.connect(\n {\n integrationID,\n methodID: method.id,\n inputs: server ? { server } : {},\n location,\n },\n { signal },\n ),\n )\n const attempt = started.data\n yield* Effect.addFinalizer(() =>\n request(() =>\n client.integration.oauth.cancel(\n { integrationID, attemptID: attempt.attemptID, location },\n { signal: AbortSignal.timeout(5_000) },\n ),\n ).pipe(Effect.ignore),\n )\n if (attempt.mode !== \"auto\") yield* Effect.fail(new Error(\"OpenCode Console requires a device login\"))\n\n yield* request(() => timeline.item(`Go to: ${attempt.url}`))\n yield* request(() => timeline.item(attempt.instructions))\n yield* request(async () => {\n const { default: open } = await import(\"open\")\n await open(attempt.url)\n }).pipe(Effect.ignore)\n yield* request(() => timeline.pending(\"Waiting for authorization...\"))\n\n const status = yield* waitForConsoleLogin(client, integrationID, attempt.attemptID)\n if (status.status === \"failed\") yield* Effect.fail(new Error(status.message))\n if (status.status === \"expired\") yield* Effect.fail(new Error(\"Device code expired\"))\n\n yield* request(() => timeline.success(\"Connected to OpenCode Console\"))\n yield* request(() => timeline.outro(\"Done\"))\n})\n\nconst waitForConsoleLogin = Effect.fn(\"cli.console.login.wait\")(function* (\n client: OpenCodeClient,\n integrationID: string,\n attemptID: string,\n) {\n while (true) {\n const response = yield* request((signal) =>\n client.integration.oauth.status({ integrationID, attemptID, location }, { signal }),\n )\n if (response.data.status !== \"pending\") return response.data\n yield* Effect.sleep(500)\n }\n})\n\nfunction request<A>(task: (signal: AbortSignal) => Promise<A>) {\n return Effect.tryPromise({\n try: task,\n catch: (cause) => cause,\n })\n}\n\nfunction required<A>(value: A | null | undefined, message: string) {\n return value === null || value === undefined ? Effect.fail(new Error(message)) : Effect.succeed(value)\n}\n\nfunction errorMessage(cause: Cause.Cause<unknown>) {\n const error = Cause.squash(cause)\n if (error instanceof Error) return error.message\n if (typeof error === \"object\" && error !== null && \"message\" in error && typeof error.message === \"string\") {\n return error.message\n }\n return String(error)\n}\n" | ||
| ], | ||
| "mappings": ";4nCAYA,OAAwB,OACxB,SAAM,OAAiB,MAAC,cAAI,cAAK,cAAK,cAAK,cAAK,cAAK,cAAK,cAAK,cAAK,aAAG,OACjE,QAAe,UACf,OAAS,MACb,YAAQ,OAAK,eAAU,MAAC,OACxB,MAAO,EAAK,UAAU,CAAC,EACvB,WAAY,EAAK,kBAAkB,EACnC,MAAO,EAAK,UAAU,CAAC,EACvB,QAAS,EAAK,UAAU,CAAC,CAC3B,EACM,EAAO,CACX,MAAO,CACL,OAAQ,SACR,MAAO,EAAO,MACd,UAAW,EACb,EACA,KAAM,CACJ,OAAQ,SACR,MAAO,EAAO,OACd,UAAW,EACb,EACA,QAAS,CACP,OAAQ,SACR,MAAO,EAAO,QACd,UAAW,EACb,EACA,QAAS,CACP,OAAQ,SACR,MAAO,EAAO,MACd,UAAW,EACb,EACA,MAAO,CACL,OAAQ,SACR,MAAO,EAAO,MACd,UAAW,EACb,CACF,EACA,SAAS,EAAG,CAAC,EAAM,EAAO,CACxB,IAAM,EAAQ,EAAK,GACnB,OAAO,EAAuB,KAAO,IAAM,CACzC,IAAI,EAAO,EAAgB,KAAK,EAC9B,EAAQ,EAAgB,KAAK,EAC7B,EAAQ,E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M,CAAC,EAC5C,EAEK,GAAsB,EAAO,GAAG,wBAAwB,EAAE,SAAU,CACxE,EACA,EACA,EACA,CACA,MAAO,GAAM,CACX,IAAM,EAAW,MAAO,EAAQ,CAAC,IAC/B,EAAO,YAAY,MAAM,OAAO,CAAE,gBAAe,YAAW,UAAS,EAAG,CAAE,QAAO,CAAC,CACpF,EACA,GAAI,EAAS,KAAK,SAAW,UAAW,OAAO,EAAS,KACxD,MAAO,EAAO,MAAM,GAAG,GAE1B,EAED,SAAS,CAAU,CAAC,EAA2C,CAC7D,OAAO,EAAO,WAAW,CACvB,IAAK,EACL,MAAO,CAAC,IAAU,CACpB,CAAC,EAGH,SAAS,CAAW,CAAC,EAA6B,EAAiB,CACjE,OAAO,IAAU,MAAQ,IAAU,OAAY,EAAO,KAAS,MAAM,CAAO,CAAC,EAAI,EAAO,QAAQ,CAAK,EAGvG,SAAS,EAAY,CAAC,EAA6B,CACjD,IAAM,EAAQ,EAAM,OAAO,CAAK,EAChC,GAAI,aAAiB,MAAO,OAAO,EAAM,QACzC,GAAI,OAAO,IAAU,UAAY,IAAU,MAAQ,YAAa,GAAS,OAAO,EAAM,UAAY,SAChG,OAAO,EAAM,QAEf,OAAO,OAAO,CAAK", | ||
| "debugId": "C812B28B6854912F64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/run.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect, Option } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { ServerConnection } from \"../../services/server-connection\"\n\nexport default Runtime.handler(Commands.commands.run, (input) =>\n Effect.gen(function* () {\n const { runNonInteractive } = yield* Effect.promise(() => import(\"../../run/run\"))\n const separator = process.argv.indexOf(\"--\", 2)\n const server = yield* ServerConnection.resolve({\n server: Option.getOrUndefined(input.server),\n standalone: input.standalone,\n })\n yield* Effect.promise(() =>\n runNonInteractive({\n server,\n message: [...input.message, ...(separator === -1 ? [] : process.argv.slice(separator + 1))],\n continue: input.continue,\n session: Option.getOrUndefined(input.session),\n fork: input.fork,\n model: Option.getOrUndefined(input.model),\n agent: Option.getOrUndefined(input.agent),\n format: input.format,\n file: [...input.file],\n title: Option.getOrUndefined(input.title),\n thinking: input.thinking,\n auto: input.auto || input.yolo,\n }),\n )\n }),\n)\n" | ||
| ], | ||
| "mappings": ";+9BAKA,SAAe,SAAQ,aAAQ,OAAS,cAAS,SAAK,MAAC,SACrD,OAAO,SAAI,cAAU,OAAG,MACtB,SAAQ,0BAAsB,WAAO,OAAO,aAAQ,SAAa,wCAAgB,OAC3E,OAAY,aAAQ,UAAK,aAAQ,UAAM,MAAC,EACxC,EAAS,MAAO,EAAiB,QAAQ,CAC7C,OAAQ,EAAO,eAAe,EAAM,MAAM,EAC1C,WAAY,EAAM,UACpB,CAAC,EACD,MAAO,EAAO,QAAQ,IACpB,EAAkB,CAChB,SACA,QAAS,CAAC,GAAG,EAAM,QAAS,GAAI,IAAc,GAAK,CAAC,EAAI,QAAQ,KAAK,MAAM,EAAY,CAAC,CAAE,EAC1F,SAAU,EAAM,SAChB,QAAS,EAAO,eAAe,EAAM,OAAO,EAC5C,KAAM,EAAM,KACZ,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,OAAQ,EAAM,OACd,KAAM,CAAC,GAAG,EAAM,IAAI,EACpB,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,SAAU,EAAM,SAChB,KAAM,EAAM,MAAQ,EAAM,IAC5B,CAAC,CACH,EACD,CACH", | ||
| "debugId": "730F8EB39B96A32F64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/mini.ts"], | ||
| "sourcesContent": [ | ||
| "import { Context, Effect, FileSystem, Option } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { ServerConnection } from \"../../services/server-connection\"\nimport { Config } from \"../../config\"\nimport { resolve } from \"@opencode-ai/tui/config\"\n\nexport default Runtime.handler(Commands.commands.mini, (input) =>\n Effect.gen(function* () {\n const { runMini, validateMiniTerminal } = yield* Effect.promise(() => import(\"../../mini\"))\n yield* Effect.promise(async () => validateMiniTerminal())\n const serverURL = Option.getOrUndefined(input.server)\n const server = yield* ServerConnection.resolve({ server: serverURL, standalone: input.standalone })\n const config = yield* Config.Service\n const resolved = resolve(yield* config.get(), { terminalSuspend: process.platform !== \"win32\" })\n const fileSystem = yield* FileSystem.FileSystem\n const runServicePromise = Effect.runPromiseWith(Context.make(FileSystem.FileSystem, fileSystem))\n const service = server.service\n yield* Effect.promise(() =>\n runMini({\n server: {\n endpoint: server.endpoint,\n reconnect: service ? (signal) => runServicePromise(service.reconnect(), { signal }) : undefined,\n },\n continue: input.continue,\n session: Option.getOrUndefined(input.session),\n fork: input.fork,\n model: Option.getOrUndefined(input.model),\n agent: Option.getOrUndefined(input.agent),\n prompt: Option.getOrUndefined(input.prompt),\n replay: input.replay,\n replayLimit: Option.getOrUndefined(input.replayLimit),\n demo: input.demo,\n tuiConfig: resolved,\n }),\n )\n }),\n)\n" | ||
| ], | ||
| "mappings": ";ogCAOA,SAAe,SAAQ,aAAQ,OAAS,cAAS,UAAM,MAAC,SACtD,OAAO,SAAI,cAAU,OAAG,MACtB,SAAQ,eAAS,6BAAyB,WAAO,OAAO,aAAQ,SAAa,wCAAa,OAC1F,WAAO,OAAO,aAAQ,cAAY,OAAqB,CAAC,EACxD,IAAM,EAAY,EAAO,eAAe,EAAM,MAAM,EAC9C,EAAS,MAAO,EAAiB,QAAQ,CAAE,OAAQ,EAAW,WAAY,EAAM,UAAW,CAAC,EAC5F,EAAS,MAAO,EAAO,QACvB,EAAW,EAAQ,MAAO,EAAO,IAAI,EAAG,CAAE,gBAAiB,EAA6B,CAAC,EACzF,EAAa,MAAO,EAAW,WAC/B,EAAoB,EAAO,eAAe,EAAQ,KAAK,EAAW,WAAY,CAAU,CAAC,EACzF,EAAU,EAAO,QACvB,MAAO,EAAO,QAAQ,IACpB,EAAQ,CACN,OAAQ,CACN,SAAU,EAAO,SACjB,UAAW,EAAU,CAAC,IAAW,EAAkB,EAAQ,UAAU,EAAG,CAAE,QAAO,CAAC,EAAI,MACxF,EACA,SAAU,EAAM,SAChB,QAAS,EAAO,eAAe,EAAM,OAAO,EAC5C,KAAM,EAAM,KACZ,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,OAAQ,EAAO,eAAe,EAAM,MAAM,EAC1C,OAAQ,EAAM,OACd,YAAa,EAAO,eAAe,EAAM,WAAW,EACpD,KAAM,EAAM,KACZ,UAAW,CACb,CAAC,CACH,EACD,CACH", | ||
| "debugId": "43EB2D782450D9CA64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/auth/connect.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { OpenCode, type IntegrationCommandStatusOutput, type OpenCodeClient } from \"@opencode-ai/client/promise\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nconst location = { directory: process.cwd() }\n\nexport default Runtime.handler(\n Commands.commands.auth.commands.connect,\n Effect.fn(\"cli.auth.connect\")(function* (input) {\n process.stdout.write(\"Connecting...\" + EOL + EOL)\n const endpoint = yield* Service.ensure(yield* ServiceConfig.options())\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n yield* request(() => client.integration.wellknown.add({ url: input.url, location }))\n const integrationID = input.url.replace(/\\/+$/, \"\")\n const started = yield* request(() =>\n client.integration.command.connect({ integrationID, methodID: \"login\", location }),\n )\n yield* Effect.addFinalizer(() =>\n request(() =>\n client.integration.command.cancel({ integrationID, attemptID: started.data.attemptID, location }),\n ).pipe(Effect.ignore),\n )\n\n const status = yield* wait(client, integrationID, started.data.attemptID)\n if (status.status === \"failed\") return yield* Effect.fail(new Error(status.message))\n if (status.status === \"expired\") return yield* Effect.fail(new Error(\"Authentication expired\"))\n process.stdout.write(\"Connected\" + EOL)\n }),\n)\n\nconst wait = (\n client: OpenCodeClient,\n integrationID: string,\n attemptID: string,\n shown = false,\n): Effect.Effect<Exclude<IntegrationCommandStatusOutput[\"data\"], { status: \"pending\" }>, unknown> =>\n Effect.gen(function* () {\n const response = yield* request(() => client.integration.command.status({ integrationID, attemptID, location }))\n if (response.data.status !== \"pending\") return response.data\n const output = response.data.message?.trim()\n if (!shown && output) process.stdout.write(output + EOL + EOL)\n yield* Effect.sleep(500)\n return yield* wait(client, integrationID, attemptID, shown || !!output)\n })\n\nfunction request<A>(task: () => Promise<A>) {\n return Effect.tryPromise({ try: task, catch: (cause) => cause })\n}\n" | ||
| ], | ||
| "mappings": ";g6BAAA,mBAAS,gBAQT,SAAM,OAAW,MAAE,eAAW,aAAQ,SAAI,MAAE,OAE7B,SAAQ,aACrB,OAAS,cAAS,UAAK,cAAS,aAChC,OAAO,QAAG,uBAAkB,OAAE,cAAU,MAAC,OAAO,CAC9C,QAAQ,OAAO,MAAM,gBAAkB,EAAM,CAAG,EAChD,IAAM,EAAW,MAAO,EAAQ,OAAO,MAAO,EAAc,QAAQ,CAAC,EAC/D,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAC1F,MAAO,EAAQ,IAAM,EAAO,YAAY,UAAU,IAAI,CAAE,IAAK,EAAM,IAAK,UAAS,CAAC,CAAC,EACnF,IAAM,EAAgB,EAAM,IAAI,QAAQ,OAAQ,EAAE,EAC5C,EAAU,MAAO,EAAQ,IAC7B,EAAO,YAAY,QAAQ,QAAQ,CAAE,gBAAe,SAAU,QAAS,UAAS,CAAC,CACnF,EACA,MAAO,EAAO,aAAa,IACzB,EAAQ,IACN,EAAO,YAAY,QAAQ,OAAO,CAAE,gBAAe,UAAW,EAAQ,KAAK,UAAW,UAAS,CAAC,CAClG,EAAE,KAAK,EAAO,MAAM,CACtB,EAEA,IAAM,EAAS,MAAO,EAAK,EAAQ,EAAe,EAAQ,KAAK,SAAS,EACxE,GAAI,EAAO,SAAW,SAAU,OAAO,MAAO,EAAO,KAAS,MAAM,EAAO,OAAO,CAAC,EACnF,GAAI,EAAO,SAAW,UAAW,OAAO,MAAO,EAAO,KAAS,MAAM,wBAAwB,CAAC,EAC9F,QAAQ,OAAO,MAAM,YAAc,CAAG,EACvC,CACH,EAEM,EAAO,CACX,EACA,EACA,EACA,EAAQ,KAER,EAAO,IAAI,SAAU,EAAG,CACtB,IAAM,EAAW,MAAO,EAAQ,IAAM,EAAO,YAAY,QAAQ,OAAO,CAAE,gBAAe,YAAW,UAAS,CAAC,CAAC,EAC/G,GAAI,EAAS,KAAK,SAAW,UAAW,OAAO,EAAS,KACxD,IAAM,EAAS,EAAS,KAAK,SAAS,KAAK,EAC3C,GAAI,CAAC,GAAS,EAAQ,QAAQ,OAAO,MAAM,EAAS,EAAM,CAAG,EAE7D,OADA,MAAO,EAAO,MAAM,GAAG,EAChB,MAAO,EAAK,EAAQ,EAAe,EAAW,GAAS,CAAC,CAAC,CAAM,EACvE,EAEH,SAAS,CAAU,CAAC,EAAwB,CAC1C,OAAO,EAAO,WAAW,CAAE,IAAK,EAAM,MAAO,CAAC,IAAU,CAAM,CAAC", | ||
| "debugId": "1CB821DBAE99EE7F64756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/debug/agents.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { OpenCode } from \"@opencode-ai/client\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.debug.commands.agents,\n Effect.fn(\"cli.debug.agents\")(function* () {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const response = yield* Effect.promise(() => client.agent.list({ location: { directory: process.cwd() } }))\n process.stdout.write(\n JSON.stringify(\n response.data.toSorted((a, b) => a.id.localeCompare(b.id)),\n null,\n 2,\n ) + EOL,\n )\n }),\n)\n" | ||
| ], | ||
| "mappings": ";g6BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,WAAM,cAAS,YACjC,OAAO,QAAG,uBAAkB,OAAE,cAAU,OAAG,MACzC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,QADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EACpF,EAAW,MAAO,EAAO,QAAQ,IAAM,EAAO,MAAM,KAAK,CAAE,SAAU,CAAE,UAAW,QAAQ,IAAI,CAAE,CAAE,CAAC,CAAC,EAC1G,QAAQ,OAAO,MACb,KAAK,UACH,EAAS,KAAK,SAAS,CAAC,EAAG,IAAM,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,EACzD,KACA,CACF,EAAI,CACN,EACD,CACH", | ||
| "debugId": "FBD5446154631FCB64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/services/standalone.ts", "src/services/server-connection.ts"], | ||
| "sourcesContent": [ | ||
| "import { Service, type Endpoint } from \"@opencode-ai/client/effect/service\"\nimport { CrossSpawnSpawner } from \"@opencode-ai/core/cross-spawn-spawner\"\nimport { LayerNode } from \"@opencode-ai/core/effect/layer-node\"\nimport { Deferred, Effect, Schema, Stream } from \"effect\"\nimport { ChildProcess, ChildProcessSpawner } from \"effect/unstable/process\"\nimport { randomBytes } from \"node:crypto\"\nimport { selfCommand } from \"../util/process\"\n\nconst Ready = Schema.Struct({ url: Schema.String })\nconst decodeReady = Schema.decodeUnknownPromise(Schema.fromJsonString(Ready))\n\ntype Options = {\n readonly command?: ReadonlyArray<string>\n}\n\nfunction command(password: string, options: Options) {\n const [executable, ...args] = options.command ?? [...selfCommand(), \"serve\"]\n if (!executable) throw new Error(\"Failed to resolve standalone server command\")\n return ChildProcess.make(executable, [...args, \"--stdio\", \"--port\", \"0\"], {\n cwd: process.cwd(),\n // Explicit entry wins over anything inherited, so a user-exported\n // OPENCODE_PASSWORD cannot shadow the child's lease credential.\n env: { OPENCODE_PASSWORD: password },\n extendEnv: true,\n // The server treats EOF on this pipe as the end of its ownership lease.\n // The OS closes it even when the TUI is killed before Effect finalizers run.\n stdin: \"pipe\",\n stderr: \"ignore\",\n killSignal: \"SIGTERM\",\n forceKillAfter: \"3 seconds\",\n })\n}\n\nconst makeEndpoint = Effect.fn(\"cli.standalone.endpoint\")(\n function* (options: Options) {\n const password = randomBytes(32).toString(\"base64url\")\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner\n const proc = yield* spawner.spawn(command(password, options))\n const readyLine = yield* Deferred.make<string, Error>()\n // Keep draining stdout after readiness so later server writes cannot hit EPIPE.\n yield* proc.stdout.pipe(\n Stream.decodeText(),\n Stream.splitLines,\n Stream.runForEach((line) => Deferred.succeed(readyLine, line)),\n Effect.ensuring(Deferred.fail(readyLine, new Error(\"Standalone server exited before reporting readiness\"))),\n Effect.forkScoped,\n )\n const output = yield* Deferred.await(readyLine)\n const ready = yield* Effect.tryPromise(() => decodeReady(output))\n return {\n url: ready.url,\n auth: { type: \"basic\" as const, username: \"opencode\", password },\n pid: proc.pid,\n } satisfies Endpoint & { readonly pid: number }\n },\n Effect.provide(LayerNode.compile(CrossSpawnSpawner.node)),\n)\n\nexport function start(options: Options = {}) {\n return makeEndpoint(options)\n}\n\nexport * as Standalone from \"./standalone\"\n", | ||
| "import { Service, type Endpoint, type EnsureOptions } from \"@opencode-ai/client/effect/service\"\nimport { ClientError, isUnauthorizedError, OpenCode } from \"@opencode-ai/client/promise\"\nimport { InstallationVersion } from \"@opencode-ai/core/installation/version\"\nimport { Effect, Redacted } from \"effect\"\nimport { Env } from \"../env\"\nimport { ServiceConfig } from \"./service-config\"\nimport { Standalone } from \"./standalone\"\n\nexport type Args = {\n readonly server?: string\n readonly standalone?: boolean\n readonly mismatch?: \"replace\" | \"ignore\" | \"error\"\n readonly onStart?: EnsureOptions[\"onStart\"]\n}\n\nexport type Resolved = {\n readonly endpoint: Endpoint\n readonly service?: ReturnType<typeof managedService>\n}\n\nexport const resolve = Effect.fn(\"cli.server-connection.resolve\")(function* (args: Args) {\n if (args.server !== undefined && args.standalone)\n return yield* Effect.fail(new Error(\"--server and --standalone cannot be combined\"))\n if (args.server !== undefined) {\n const password = yield* Env.password\n const endpoint = {\n url: args.server,\n auth: password ? { type: \"basic\" as const, username: \"opencode\", password: Redacted.value(password) } : undefined,\n } satisfies Endpoint\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const health = yield* Effect.tryPromise({\n try: () => client.health.get({ signal: AbortSignal.timeout(5_000) }),\n catch: (cause) => connectError(endpoint, cause),\n })\n if (health.version !== InstallationVersion)\n process.stderr.write(\n `Warning: Server at ${endpoint.url} has version ${health.version}; this client is ${InstallationVersion}. Continuing anyway.\\n`,\n )\n return { endpoint } satisfies Resolved\n }\n if (args.standalone) {\n return { endpoint: yield* Standalone.start() } satisfies Resolved\n }\n\n const options = yield* ServiceConfig.options()\n return {\n endpoint: yield* resolveManaged({ ...options, onStart: args.onStart }, args.mismatch ?? \"replace\"),\n service: managedService(options),\n } satisfies Resolved\n})\n\nfunction managedService(options: EnsureOptions) {\n const reconnectOptions = { ...options, version: undefined }\n return {\n reconnect: () => Service.ensure(reconnectOptions),\n restart: () =>\n Effect.gen(function* () {\n yield* Service.stop(options)\n yield* Service.ensure(reconnectOptions)\n }),\n }\n}\n\nconst resolveManaged = Effect.fnUntraced(function* (\n options: EnsureOptions,\n mismatch: NonNullable<Args[\"mismatch\"]>,\n) {\n if (mismatch === \"replace\") return yield* Service.ensure(options)\n if (mismatch === \"ignore\") return yield* Service.ensure({ ...options, version: undefined })\n\n const compatible = yield* Service.discover(options)\n if (compatible !== undefined) return compatible\n const existing = yield* Service.discover({ ...options, version: undefined })\n if (existing !== undefined)\n return yield* Effect.fail(new Error(\"Background server version does not match this client\"))\n return yield* Service.ensure(options)\n})\n\nfunction connectError(endpoint: Endpoint, cause: unknown) {\n if (isUnauthorizedError(cause)) {\n return new Error(\n endpoint.auth === undefined\n ? `Server at ${endpoint.url} requires a password; set OPENCODE_PASSWORD`\n : `Server at ${endpoint.url} rejected the password`,\n { cause },\n )\n }\n if (cause instanceof ClientError && cause.reason === \"Transport\")\n return new Error(`Could not reach server at ${endpoint.url}`, { cause })\n return new Error(`Server at ${endpoint.url} did not provide a compatible V2 health response`, { cause })\n}\n\nexport * as ServerConnection from \"./server-connection\"\n" | ||
| ], | ||
| "mappings": ";slBAKA,2BAAS,oBAGT,SAAM,OAAQ,OAAO,YAAO,MAAE,SAAK,EAAO,MAAO,CAAC,EAC5C,EAAc,EAAO,qBAAqB,EAAO,eAAe,CAAK,CAAC,EAM5E,SAAS,CAAO,CAAC,EAAkB,EAAkB,CACnD,IAAO,KAAe,GAAQ,EAAQ,SAAW,CAAC,GAAG,EAAY,EAAG,OAAO,EAC3E,GAAI,CAAC,EAAY,MAAU,MAAM,6CAA6C,EAC9E,OAAO,EAAa,KAAK,EAAY,CAAC,GAAG,EAAM,UAAW,SAAU,GAAG,EAAG,CACxE,IAAK,QAAQ,IAAI,EAGjB,IAAK,CAAE,kBAAmB,CAAS,EACnC,UAAW,GAGX,MAAO,OACP,OAAQ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Aa,EAAS,iDACtB,aAAa,EAAS,4BAC1B,CAAE,OAAM,CACV,EAEF,GAAI,aAAiB,GAAe,EAAM,SAAW,YACnD,OAAW,MAAM,6BAA6B,EAAS,MAAO,CAAE,OAAM,CAAC,EACzE,OAAW,MAAM,aAAa,EAAS,sDAAuD,CAAE,OAAM,CAAC", | ||
| "debugId": "0D9B2C1D7B66B84464756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/run/run.ts", "src/run/noninteractive.ts", "src/run/ui.ts"], | ||
| "sourcesContent": [ | ||
| "import { Service, type Endpoint } from \"@opencode-ai/client/effect/service\"\nimport { OpenCode, type OpenCodeClient, type SessionMessageAssistantTool } from \"@opencode-ai/client/promise\"\nimport { FSUtil } from \"@opencode-ai/core/fs-util\"\nimport { open } from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { readStdin } from \"../util/io\"\nimport { ServerConnection } from \"../services/server-connection\"\nimport { waitForCatalogReady } from \"../services/catalog\"\nimport { parseSessionTargetModel, resolveSessionTarget } from \"../session-target\"\nimport { toolInlineInfo } from \"@opencode-ai/tui/mini/tool\"\nimport { runNonInteractivePrompt } from \"./noninteractive\"\nimport { UI } from \"./ui\"\n\nexport type RunCommandInput = {\n server: ServerConnection.Resolved\n message: string[]\n continue?: boolean\n session?: string\n fork?: boolean\n model?: string\n agent?: string\n format: \"default\" | \"json\"\n file: string[]\n title?: string\n thinking?: boolean\n auto?: boolean\n}\n\ntype FilePart = {\n url: string\n filename: string\n mime: string\n}\n\ntype Prepared = {\n directory?: string\n message: string\n files: FilePart[]\n}\n\ntype ExecutionOptions = {\n root?: string\n directory?: string\n useServerDirectory?: boolean\n variant?: string\n attached?: boolean\n compatibility?: \"v1\"\n}\n\nclass RunTargetError extends Error {\n constructor(\n message: string,\n readonly sessionID?: string,\n ) {\n super(message)\n }\n}\n\nconst ATTACH_FILE_MAX_BYTES = 10 * 1024 * 1024\n\nexport function runNonInteractive(input: RunCommandInput) {\n return runNonInteractiveWithOptions(input, {})\n}\n\n/** @internal Used only by the V1 command boundary. */\nexport function runNonInteractiveWithOptions(input: RunCommandInput, options: ExecutionOptions) {\n return run(input, options).catch((error) => reportRunError(input, errorMessage(error)))\n}\n\nasync function run(input: RunCommandInput, options: ExecutionOptions) {\n if (input.fork && !input.continue && !input.session) fail(\"--fork requires --continue or --session\")\n const root = options.root ?? process.env.PWD ?? process.cwd()\n const local = localDirectory(root)\n const directory = options.useServerDirectory ? undefined : (options.directory ?? local)\n const message = mergeInput(formatMessage(input.message), process.stdin.isTTY ? undefined : await readStdin())\n if (!message?.trim()) fail(\"You must provide a message\")\n const files = await Promise.all(input.file.map((file) => prepareFile(file, root, options)))\n const prepared = { directory, message, files }\n return execute(input, prepared, input.server.endpoint, options)\n}\n\nasync function execute(input: RunCommandInput, prepared: Prepared, endpoint: Endpoint, options: ExecutionOptions) {\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const explicit = parseRunModel(input.model)\n const target = await resolveSessionTarget({\n client,\n location: prepared.directory ? { directory: prepared.directory } : undefined,\n continue: input.continue,\n session: input.session,\n fork: input.fork,\n model: explicit\n ? { providerID: explicit.model.providerID, id: explicit.model.modelID, variant: explicit.variant }\n : undefined,\n agent: input.agent,\n prepare: async (next) => {\n const selected =\n next.model ??\n (await client.model\n .default({ location: { directory: next.location.directory, workspace: next.location.workspaceID } })\n .then((result) => result.data))\n const model = selected\n ? {\n providerID: selected.providerID,\n id: selected.id,\n variant: options.variant ?? (\"variant\" in selected ? selected.variant : undefined),\n }\n : undefined\n if ((options.variant ?? explicit?.variant) && !model)\n throw new RunTargetError(\"Cannot select a variant before selecting a model\", next.session?.id)\n if (model) {\n await waitForCatalogReady({\n sdk: client,\n directory: next.location.directory,\n workspace: next.location.workspaceID,\n model: { providerID: model.providerID, modelID: model.id },\n })\n const available = await client.model.list({\n location: { directory: next.location.directory, workspace: next.location.workspaceID },\n })\n if (!available.data.some((item) => item.providerID === model.providerID && item.id === model.id))\n throw new RunTargetError(`Model unavailable: ${model.providerID}/${model.id}`, next.session?.id)\n }\n return {\n model,\n agent: input.agent\n ? await validateAgent(client, next.location.directory, next.location.workspaceID, input.agent)\n : next.agent,\n }\n },\n }).catch((error) => {\n if (!(error instanceof RunTargetError)) throw error\n reportRunError(input, error.message, error.sessionID)\n return undefined\n })\n if (!target) return\n const model = target.model ? { providerID: target.model.providerID, modelID: target.model.id } : undefined\n const variant = target.model?.variant\n if (!target.resume && input.title !== undefined) {\n await client.session.rename({\n sessionID: target.session.id,\n title: input.title || prepared.message.slice(0, 50) + (prepared.message.length > 50 ? \"...\" : \"\"),\n })\n }\n\n await runNonInteractivePrompt({\n client,\n sessionID: target.session.id,\n location: target.location,\n message: prepared.message,\n files: prepared.files,\n agent: target.agent,\n model,\n variant,\n thinking: input.thinking ?? false,\n format: input.format,\n auto: input.auto ?? false,\n attached: options.attached ?? true,\n compatibility: options.compatibility,\n renderTool: (part) => renderTool(part, target.location.directory),\n renderToolError: (part) => renderToolError(part, target.location.directory),\n }).catch((error) => reportRunError(input, errorMessage(error), target.session.id))\n}\n\nexport function mergeInput(message: string | undefined, piped: string | undefined) {\n if (!message) return piped || undefined\n if (!piped) return message\n return message + \"\\n\" + piped\n}\n\nfunction formatMessage(message: string[]) {\n const value = message.map((part) => (part.includes(\" \") ? `\"${part.replace(/\"/g, '\\\\\"')}\"` : part)).join(\" \")\n return value || undefined\n}\n\nfunction localDirectory(root: string) {\n try {\n process.chdir(root)\n return process.cwd()\n } catch {\n fail(`Failed to change directory to ${root}`)\n }\n}\n\nexport function parseRunModel(value?: string) {\n const ref = parseSessionTargetModel(value)\n if (!ref) return\n return {\n model: { providerID: ref.providerID, modelID: ref.id },\n variant: ref.variant,\n }\n}\n\nasync function validateAgent(client: OpenCodeClient, directory: string, workspace: string | undefined, name?: string) {\n if (!name) return\n const agents = await client.agent\n .list({ location: { directory, workspace } })\n .then((result) => result.data)\n .catch(() => undefined)\n if (!agents) {\n warning(\"failed to list agents. Falling back to default agent\")\n return\n }\n const agent = agents.find((item) => item.id === name)\n if (!agent) {\n warning(`agent \"${name}\" not found. Falling back to default agent`)\n return\n }\n if (agent.mode === \"subagent\") {\n warning(`agent \"${name}\" is a subagent, not a primary agent. Falling back to default agent`)\n return\n }\n return name\n}\n\nasync function prepareFile(input: string, directory: string, options: ExecutionOptions): Promise<FilePart> {\n const file = path.resolve(directory, input)\n const handle = await open(file, \"r\").catch(() => fail(`File not found: ${input}`))\n try {\n const stat = await handle.stat()\n if (options.compatibility === \"v1\" && options.attached && stat.isDirectory())\n fail(`Cannot attach local directory without a shared filesystem: ${input}`)\n if (!stat.isFile() || stat.size > ATTACH_FILE_MAX_BYTES)\n fail(`Cannot attach a directory, special file, or file larger than 10 MiB: ${input}`)\n const content = Buffer.alloc(Number(stat.size))\n let offset = 0\n while (offset < content.length) {\n const read = await handle.read(content, offset, content.length - offset, offset)\n if (read.bytesRead === 0) break\n offset += read.bytesRead\n }\n const bytes = content.subarray(0, offset)\n const detected = FSUtil.mimeType(file)\n const text = bytes.toString(\"utf8\")\n const mime =\n detected.startsWith(\"image/\") || detected === \"application/pdf\"\n ? detected\n : !isBinaryContent(bytes) && Buffer.from(text, \"utf8\").equals(bytes)\n ? \"text/plain\"\n : detected\n return {\n url: `data:${mime};base64,${bytes.toString(\"base64\")}`,\n filename: path.basename(file),\n mime,\n }\n } finally {\n await handle.close()\n }\n}\n\nfunction isBinaryContent(bytes: Uint8Array) {\n if (bytes.length === 0) return false\n if (bytes.includes(0)) return true\n return bytes.reduce((count, byte) => count + Number(byte < 9 || (byte > 13 && byte < 32)), 0) / bytes.length > 0.3\n}\n\nasync function renderTool(part: SessionMessageAssistantTool, directory: string) {\n const info = toolInlineInfo(part, directory)\n if (info.mode === \"block\") {\n UI.empty()\n UI.println(UI.Style.TEXT_NORMAL + info.icon, UI.Style.TEXT_NORMAL + info.title)\n if (info.body?.trim()) UI.println(info.body)\n UI.empty()\n return\n }\n UI.println(\n UI.Style.TEXT_NORMAL + info.icon,\n UI.Style.TEXT_NORMAL + info.title,\n info.description ? UI.Style.TEXT_DIM + info.description + UI.Style.TEXT_NORMAL : \"\",\n )\n}\n\nasync function renderToolError(part: SessionMessageAssistantTool, directory: string) {\n const info = toolInlineInfo(part, directory)\n UI.println(UI.Style.TEXT_NORMAL + \"✗\", UI.Style.TEXT_NORMAL + `${info.title} failed`)\n}\n\nfunction warning(message: string) {\n UI.println(UI.Style.TEXT_WARNING_BOLD + \"!\", UI.Style.TEXT_NORMAL, message)\n}\n\nfunction errorMessage(error: unknown) {\n if (error instanceof Error) return error.message\n if (typeof error === \"object\" && error !== null && \"message\" in error && typeof error.message === \"string\")\n return error.message\n return String(error)\n}\n\n/** @internal Used by the V1 command boundary before a Session exists. */\nexport function reportRunError(input: Pick<RunCommandInput, \"format\">, message: string, sessionID?: string) {\n process.exitCode = 1\n if (input.format === \"json\") {\n process.stdout.write(\n JSON.stringify({\n type: \"error\",\n timestamp: Date.now(),\n sessionID: sessionID ?? \"\",\n error: { type: \"unknown\", message },\n }) + \"\\n\",\n )\n return\n }\n UI.error(message)\n}\n\nfunction fail(message: string): never {\n throw new Error(message)\n}\n", | ||
| "import type {\n EventSubscribeOutput,\n JsonValue,\n LLMToolContent,\n LocationRef,\n OpenCodeClient,\n SessionMessageAssistantTool,\n} from \"@opencode-ai/client/promise\"\nimport { SessionMessage } from \"@opencode-ai/schema/session-message\"\nimport { EOL } from \"node:os\"\nimport { readFile } from \"node:fs/promises\"\nimport { toolOutputText, type MiniToolPart } from \"@opencode-ai/tui/mini/tool\"\nimport { UI } from \"./ui\"\n\ntype Model = {\n providerID: string\n modelID: string\n}\n\ntype File = {\n url: string\n filename: string\n mime: string\n}\n\ntype Input = {\n client: OpenCodeClient\n sessionID: string\n location: LocationRef\n message: string\n files: File[]\n agent?: string\n model?: Model\n variant?: string\n thinking: boolean\n format: \"default\" | \"json\"\n auto: boolean\n /** True when the client is attached to a shared server rather than an exclusive in-process one. */\n attached: boolean\n compatibility?: \"v1\"\n renderTool: (part: SessionMessageAssistantTool) => Promise<void>\n renderToolError: (part: SessionMessageAssistantTool) => Promise<void>\n}\n\ntype StartedPart = {\n id: string\n timestamp: number\n}\n\ntype ToolState = StartedPart & {\n assistantMessageID: string\n tool: string\n input: Record<string, JsonValue>\n raw?: string\n provider?: unknown\n providerState?: SessionMessageAssistantTool[\"providerState\"]\n structured: Record<string, JsonValue>\n content: LLMToolContent[]\n}\n\ntype V2Event = EventSubscribeOutput\ntype FormRequest = Extract<V2Event, { type: \"form.created\" }>[\"data\"][\"form\"]\n\n// MCP elicitations are temporarily owned by the \"global\" sentinel instead of a real\n// session. An exclusive local process may treat them as this run's blockers; an\n// attached client must not cancel input that may belong to another session.\nconst GLOBAL_FORM_SESSION_ID = \"global\"\n\nexport async function runNonInteractivePrompt(input: Input) {\n const controller = new AbortController()\n const stream = input.client.event.subscribe({ signal: controller.signal })[Symbol.asyncIterator]()\n const connected = await stream.next()\n if (connected.done) throw new Error(\"Event stream disconnected before prompt admission\")\n\n const messageID = SessionMessage.ID.create()\n const starts = new Map<string, StartedPart>()\n const tools = new Map<string, ToolState>()\n let submitted = false\n let promoted = false\n let emittedError = false\n let permissionRejected = false\n let formCancelled = false\n let interrupted = false\n let v1InvalidOutput = false\n let admission: AbortController | undefined\n let pendingStep: { timestamp: number; part: Record<string, unknown>; label: string } | undefined\n\n const emit = (type: string, timestamp: number, data: Record<string, unknown>) => {\n if (input.format !== \"json\") return false\n process.stdout.write(JSON.stringify({ type, timestamp, sessionID: input.sessionID, ...data }) + EOL)\n return true\n }\n\n const writeText = (part: { text: string; [key: string]: unknown }, timestamp: number) => {\n if (emit(\"text\", timestamp, { part })) return\n const text = part.text.trim()\n if (!text) return\n if (!process.stdout.isTTY) {\n process.stdout.write(text + EOL)\n return\n }\n UI.empty()\n UI.println(text)\n UI.empty()\n }\n\n const flushStep = () => {\n if (!pendingStep) return\n const value = pendingStep\n pendingStep = undefined\n if (!emit(\"step_start\", value.timestamp, { part: value.part }) && input.format !== \"json\") {\n UI.empty()\n UI.println(value.label)\n UI.empty()\n }\n }\n\n const replyPermission = async (request: { id: string; action: string; resources: ReadonlyArray<string> }) => {\n if (!input.auto) {\n permissionRejected = true\n UI.println(\n UI.Style.TEXT_WARNING_BOLD + \"!\",\n UI.Style.TEXT_NORMAL +\n `permission requested: ${request.action} (${request.resources.join(\", \")}); auto-rejecting`,\n )\n }\n await input.client.permission\n .reply({\n sessionID: input.sessionID,\n requestID: request.id,\n reply: input.auto ? \"once\" : \"reject\",\n })\n .catch(() => {})\n if (!input.auto) {\n await input.client.session.interrupt({ sessionID: input.sessionID }).catch(() => {})\n }\n }\n\n const cancelForm = async (request: Pick<FormRequest, \"id\" | \"sessionID\">) => {\n try {\n await input.client.form.cancel(\n { sessionID: request.sessionID, formID: request.id },\n ...formRequestOptions(request.sessionID === GLOBAL_FORM_SESSION_ID ? input.location : undefined),\n )\n } catch (error) {\n if (!formAlreadySettled(error)) throw error\n }\n formCancelled = true\n }\n\n const consume = async () => {\n while (!controller.signal.aborted) {\n const next = await stream.next().catch((error) => {\n if (!emittedError) throw error\n return { done: true as const, value: undefined }\n })\n if (next.done) {\n if (emittedError) return\n throw new Error(\"Event stream disconnected during prompt execution\")\n }\n const event = next.value\n\n if (event.type === \"permission.v2.asked\" && submitted && event.data.sessionID === input.sessionID) {\n await replyPermission(event.data)\n continue\n }\n if (\n event.type === \"form.created\" &&\n submitted &&\n (event.data.form.sessionID === input.sessionID ||\n (!input.attached &&\n event.data.form.sessionID === GLOBAL_FORM_SESSION_ID &&\n sameLocation(event.location, input.location)))\n ) {\n await cancelForm(event.data.form)\n continue\n }\n if (!(\"sessionID\" in event.data) || event.data.sessionID !== input.sessionID) continue\n const time = toMillis(\"created\" in event ? event.created : undefined)\n\n if (event.type === \"session.input.promoted\") {\n if (event.data.inputID === messageID) {\n promoted = true\n continue\n }\n }\n if (\n event.type === \"session.execution.interrupted\" &&\n event.data.reason === \"user\" &&\n (interrupted || permissionRejected || formCancelled)\n ) {\n return\n }\n if (!promoted) continue\n\n if (event.type === \"session.step.started\") {\n const part = {\n id: partID(event.id),\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"step-start\",\n snapshot: event.data.snapshot,\n }\n if (input.compatibility === \"v1\") {\n pendingStep = {\n timestamp: time,\n part,\n label: `> ${event.data.agent} · ${event.data.model.id}`,\n }\n continue\n }\n if (!emit(\"step_start\", time, { part }) && input.format !== \"json\") {\n UI.empty()\n UI.println(`> ${event.data.agent} · ${event.data.model.id}`)\n UI.empty()\n }\n continue\n }\n\n if (event.type === \"session.text.started\") {\n flushStep()\n starts.set(\"text\", { id: partID(event.id), timestamp: time })\n continue\n }\n if (event.type === \"session.text.ended\") {\n const started = starts.get(\"text\")\n starts.delete(\"text\")\n const part = {\n id: started?.id ?? partID(event.id),\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"text\",\n text: event.data.text,\n time: { start: started?.timestamp ?? time, end: time },\n }\n writeText(part, time)\n continue\n }\n\n if (event.type === \"session.reasoning.started\") {\n flushStep()\n starts.set(\"reasoning\", { id: partID(event.id), timestamp: time })\n continue\n }\n if (event.type === \"session.reasoning.ended\" && input.thinking) {\n const started = starts.get(\"reasoning\")\n starts.delete(\"reasoning\")\n const part = {\n id: started?.id ?? partID(event.id),\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"reasoning\",\n text: event.data.text,\n metadata: event.data.state,\n time: { start: started?.timestamp ?? time, end: time },\n }\n if (emit(\"reasoning\", time, { part })) continue\n const text = part.text.trim()\n if (!text) continue\n const line = `Thinking: ${text}`\n if (!process.stdout.isTTY) {\n process.stdout.write(line + EOL)\n continue\n }\n UI.empty()\n UI.println(`${UI.Style.TEXT_DIM}\\u001b[3m${line}\\u001b[0m${UI.Style.TEXT_NORMAL}`)\n UI.empty()\n continue\n }\n\n if (event.type === \"session.tool.input.started\") {\n flushStep()\n tools.set(toolKey(event.data.assistantMessageID, event.data.callID), {\n id: partID(event.id),\n timestamp: time,\n assistantMessageID: event.data.assistantMessageID,\n tool: event.data.name,\n input: {},\n structured: {},\n content: [],\n })\n continue\n }\n if (event.type === \"session.tool.input.ended\") {\n const current = tools.get(toolKey(event.data.assistantMessageID, event.data.callID))\n if (current) current.raw = event.data.text\n continue\n }\n if (event.type === \"session.tool.input.delta\") {\n const current = tools.get(toolKey(event.data.assistantMessageID, event.data.callID))\n if (current) current.raw = (current.raw ?? \"\") + event.data.delta\n continue\n }\n if (event.type === \"session.tool.called\") {\n flushStep()\n const key = toolKey(event.data.assistantMessageID, event.data.callID)\n const current = tools.get(key)\n tools.set(key, {\n id: current?.id ?? partID(event.id),\n timestamp: current?.timestamp ?? time,\n assistantMessageID: event.data.assistantMessageID,\n tool: current?.tool ?? \"tool\",\n input: event.data.input,\n raw: current?.raw,\n provider: { executed: event.data.executed, state: event.data.state },\n providerState: event.data.state,\n structured: {},\n content: [],\n })\n continue\n }\n if (event.type === \"session.tool.progress\") {\n const current = tools.get(toolKey(event.data.assistantMessageID, event.data.callID))\n if (current) {\n current.structured = event.data.structured\n current.content = event.data.content\n }\n continue\n }\n if (event.type === \"session.tool.success\") {\n const key = toolKey(event.data.assistantMessageID, event.data.callID)\n const current = tools.get(key) ?? fallbackTool(event)\n const tool: SessionMessageAssistantTool = {\n type: \"tool\",\n id: event.data.callID,\n name: current.tool,\n executed: event.data.executed,\n providerState: current.providerState,\n providerResultState: event.data.resultState,\n state: {\n status: \"completed\",\n input: current.input,\n structured: event.data.structured,\n content: event.data.content,\n result: event.data.result,\n },\n time: { created: current.timestamp, ran: current.timestamp, completed: time },\n }\n const part: MiniToolPart = {\n id: current.id,\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"tool\",\n callID: event.data.callID,\n tool: current.tool,\n state: {\n status: \"completed\",\n input: current.input,\n output: toolOutputText(current.tool, event.data.content),\n title: current.tool,\n metadata: {\n structured: event.data.structured,\n content: event.data.content,\n result: event.data.result,\n providerCall: current.provider,\n providerResult: { executed: event.data.executed, state: event.data.resultState },\n rawInput: current.raw,\n },\n time: { start: current.timestamp, end: time },\n },\n }\n tools.delete(key)\n if (!emit(\"tool_use\", time, { part })) await input.renderTool(tool)\n continue\n }\n if (event.type === \"session.tool.failed\") {\n const key = toolKey(event.data.assistantMessageID, event.data.callID)\n const current = tools.get(key) ?? fallbackTool(event)\n const error = event.data.error.message\n const tool: SessionMessageAssistantTool = {\n type: \"tool\",\n id: event.data.callID,\n name: current.tool,\n executed: event.data.executed,\n providerState: current.providerState,\n providerResultState: event.data.resultState,\n state: {\n status: \"error\",\n input: current.input,\n structured: current.structured,\n content: current.content,\n error: event.data.error,\n result: event.data.result,\n },\n time: { created: current.timestamp, ran: current.timestamp, completed: time },\n }\n const part: MiniToolPart = {\n id: current.id,\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"tool\",\n callID: event.data.callID,\n tool: current.tool,\n state: {\n status: \"error\",\n input: current.input,\n error,\n metadata: {\n result: event.data.result,\n providerCall: current.provider,\n providerResult: { executed: event.data.executed, state: event.data.resultState },\n rawInput: current.raw,\n },\n time: { start: current.timestamp, end: time },\n },\n }\n tools.delete(key)\n if (input.compatibility === \"v1\" && (permissionRejected || formCancelled)) continue\n if (!emit(\"tool_use\", time, { part })) {\n if (toolOutputText(current.tool, current.content).trim())\n await input.renderTool({\n ...tool,\n state: {\n status: \"completed\",\n input: current.input,\n structured: current.structured,\n content: current.content,\n result: event.data.result,\n },\n })\n await input.renderToolError(tool)\n UI.error(error)\n }\n continue\n }\n\n if (event.type === \"session.step.ended\") {\n flushStep()\n const part = {\n id: partID(event.id),\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"step-finish\",\n reason: event.data.finish,\n snapshot: event.data.snapshot,\n cost: event.data.cost,\n tokens: event.data.tokens,\n }\n emit(\"step_finish\", time, { part })\n continue\n }\n if (event.type === \"session.step.failed\") {\n if (\n input.compatibility === \"v1\" &&\n event.data.error.message === \"Provider stream ended without a terminal finish event\"\n ) {\n pendingStep = undefined\n v1InvalidOutput = true\n continue\n }\n if (interrupted || permissionRejected || formCancelled) continue\n flushStep()\n emittedError = true\n process.exitCode = 1\n if (!emit(\"error\", time, { error: event.data.error })) UI.error(event.data.error.message)\n continue\n }\n if (event.type === \"session.execution.failed\") {\n if (input.compatibility === \"v1\" && (v1InvalidOutput || permissionRejected || formCancelled)) return\n flushStep()\n if (!emittedError && !formCancelled) {\n emittedError = true\n process.exitCode = 1\n if (!emit(\"error\", time, { error: event.data.error })) UI.error(event.data.error.message)\n }\n return\n }\n if (event.type === \"session.execution.interrupted\") {\n if (input.compatibility === \"v1\" && (permissionRejected || formCancelled)) return\n if (event.data.reason === \"user\" && interrupted) process.exitCode = 130\n if (event.data.reason !== \"user\" && !emittedError) {\n emittedError = true\n process.exitCode = 1\n const error = { type: \"aborted\" as const, message: `Session interrupted: ${event.data.reason}` }\n if (!emit(\"error\", time, { error })) UI.error(error.message)\n }\n return\n }\n if (event.type === \"session.execution.succeeded\") return\n }\n }\n\n const interrupt = () => {\n if (interrupted) process.exit(130)\n interrupted = true\n process.exitCode = 130\n admission?.abort()\n void input.client.session.interrupt({ sessionID: input.sessionID }).catch(() => {})\n }\n process.on(\"SIGINT\", interrupt)\n\n let completed: Promise<void> | undefined\n try {\n if (input.agent) {\n await input.client.session.switchAgent({ sessionID: input.sessionID, agent: input.agent })\n }\n const selected = input.model\n ? { providerID: input.model.providerID, id: input.model.modelID, variant: input.variant }\n : input.variant\n ? await input.client.session\n .get({ sessionID: input.sessionID })\n .then((result) => result.model)\n .then(async (model) => {\n if (model) return { ...model, variant: input.variant }\n const result = await input.client.model.default()\n const fallback = result.data\n return fallback ? { providerID: fallback.providerID, id: fallback.id, variant: input.variant } : undefined\n })\n : undefined\n if (input.variant && !selected) throw new Error(\"Cannot select a variant before selecting a model\")\n if (selected) {\n await input.client.session.switchModel({ sessionID: input.sessionID, model: selected })\n }\n\n const prepared = await Promise.all(input.files.map(prepareFile))\n if (interrupted) return\n submitted = true\n completed = consume()\n admission = new AbortController()\n const response = await input.client.session\n .prompt(\n {\n sessionID: input.sessionID,\n id: messageID,\n text: [input.message, ...prepared.flatMap((file) => (file.text ? [file.text] : []))].join(\"\\n\\n\"),\n files: prepared.flatMap((file) => (file.attachment ? [file.attachment] : [])),\n delivery: \"steer\",\n },\n { signal: admission.signal },\n )\n .catch(async (error) => {\n if (interrupted) {\n await input.client.session.interrupt({ sessionID: input.sessionID }).catch(() => {})\n }\n controller.abort()\n await completed?.catch(() => {})\n if (interrupted || emittedError) return undefined\n throw error\n })\n admission = undefined\n if (!response) return\n if (interrupted) await input.client.session.interrupt({ sessionID: input.sessionID }).catch(() => {})\n\n const [permissions, forms, globals] = await Promise.all([\n input.client.permission.list({ sessionID: input.sessionID }).catch(() => undefined),\n input.client.form.list({ sessionID: input.sessionID }).catch(() => undefined),\n input.attached\n ? Promise.resolve(undefined)\n : input.client.form.request\n .list({\n location: { directory: input.location.directory, workspace: input.location.workspaceID },\n })\n .catch(() => undefined),\n ])\n await Promise.all([\n ...(permissions ?? []).map(replyPermission),\n ...(forms ?? []).map(cancelForm),\n ...(globals && sameLocation(globals.location, input.location)\n ? globals.data.filter((form) => form.sessionID === GLOBAL_FORM_SESSION_ID).map(cancelForm)\n : []),\n ])\n await completed\n } finally {\n process.off(\"SIGINT\", interrupt)\n controller.abort()\n await stream.return?.(undefined).catch(() => {})\n }\n}\n\nfunction sameLocation(left: LocationRef | undefined, right: LocationRef) {\n return !!left && left.directory === right.directory && left.workspaceID === right.workspaceID\n}\n\nfunction formRequestOptions(location: LocationRef | undefined): [] | [{ headers: Record<string, string> }] {\n if (!location) return []\n return [\n {\n headers: {\n \"x-opencode-directory\": encodeURIComponent(location.directory),\n ...(location.workspaceID ? { \"x-opencode-workspace\": location.workspaceID } : {}),\n },\n },\n ]\n}\n\nfunction formAlreadySettled(error: unknown) {\n return !!error && typeof error === \"object\" && Reflect.get(error, \"_tag\") === \"FormAlreadySettledError\"\n}\n\nfunction partID(eventID: string) {\n return `prt_${eventID.replace(/^evt_/, \"\")}`\n}\n\nfunction toolKey(messageID: string, callID: string) {\n return `${messageID}\\u0000${callID}`\n}\n\nfunction fallbackTool(event: {\n id: string\n created: number\n data: { assistantMessageID: string; callID: string }\n}): ToolState {\n return {\n id: partID(event.id),\n timestamp: toMillis(event.created),\n assistantMessageID: event.data.assistantMessageID,\n tool: \"tool\",\n input: {},\n structured: {},\n content: [],\n }\n}\n\nfunction toMillis(value: unknown) {\n if (typeof value === \"number\") return value\n if (typeof value === \"string\") return new Date(value).getTime()\n return Date.now()\n}\n\nasync function prepareFile(file: File) {\n if (file.mime !== \"text/plain\") {\n const uri = file.url.startsWith(\"data:\")\n ? file.url\n : `data:${file.mime};base64,${(await readFile(new URL(file.url))).toString(\"base64\")}`\n return { attachment: { uri, name: file.filename } }\n }\n const content = file.url.startsWith(\"data:\")\n ? Buffer.from(file.url.slice(file.url.indexOf(\",\") + 1), \"base64\").toString(\"utf8\")\n : await readFile(new URL(file.url), \"utf8\")\n return { text: `<file name=\"${file.filename}\">\\n${content}\\n</file>` }\n}\n", | ||
| "import { EOL } from \"node:os\"\n\nexport const Style = {\n TEXT_DIM: \"\\x1b[90m\",\n TEXT_NORMAL: \"\\x1b[0m\",\n TEXT_WARNING_BOLD: \"\\x1b[93m\\x1b[1m\",\n TEXT_DANGER_BOLD: \"\\x1b[91m\\x1b[1m\",\n}\n\nexport function println(...message: string[]) {\n process.stderr.write(message.join(\" \") + EOL)\n}\n\nlet blank = false\n\nexport function empty() {\n if (blank) return\n println(Style.TEXT_NORMAL)\n blank = true\n}\n\nexport function error(message: string) {\n if (message.startsWith(\"Error: \")) message = message.slice(\"Error: \".length)\n println(Style.TEXT_DANGER_BOLD + \"Error: \" + Style.TEXT_NORMAL + message)\n}\n\nexport * as UI from \"./ui\"\n" | ||
| ], | ||
| "mappings": ";s7BAGA,oBAAS,0BACT,yBCKA,mBAAS,gBACT,wBAAS,uGCVT,mBAA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AC5B,EAAK,YAAc,EAAG,MAAM,SAAW,EAAK,YAAc,EAAG,MAAM,YAAc,EACnF,EAGF,eAAe,EAAe,CAAC,EAAmC,EAAmB,CACnF,IAAM,EAAO,EAAe,EAAM,CAAS,EAC3C,EAAG,QAAQ,EAAG,MAAM,YAAc,SAAI,EAAG,MAAM,YAAc,GAAG,EAAK,cAAc,EAGrF,SAAS,CAAO,CAAC,EAAiB,CAChC,EAAG,QAAQ,EAAG,MAAM,kBAAoB,IAAK,EAAG,MAAM,YAAa,CAAO,EAG5E,SAAS,EAAY,CAAC,EAAgB,CACpC,GAAI,aAAiB,MAAO,OAAO,EAAM,QACzC,GAAI,OAAO,IAAU,UAAY,IAAU,MAAQ,YAAa,GAAS,OAAO,EAAM,UAAY,SAChG,OAAO,EAAM,QACf,OAAO,OAAO,CAAK,EAId,SAAS,CAAc,CAAC,EAAwC,EAAiB,EAAoB,CAE1G,GADA,QAAQ,SAAW,EACf,EAAM,SAAW,OAAQ,CAC3B,QAAQ,OAAO,MACb,KAAK,UAAU,CACb,KAAM,QACN,UAAW,KAAK,IAAI,EACpB,UAAW,GAAa,GACxB,MAAO,CAAE,KAAM,UAAW,SAAQ,CACpC,CAAC,EAAI;AAAA,CACP,EACA,OAEF,EAAG,MAAM,CAAO,EAGlB,SAAS,CAAI,CAAC,EAAwB,CACpC,MAAU,MAAM,CAAO", | ||
| "debugId": "DE7CD11D9276CF0E64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../ai/src/protocols/xai-images.ts", "../ai/src/providers/xai.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect, Encoding, Schema } from \"effect\"\nimport { Headers, HttpClientRequest } from \"effect/unstable/http\"\nimport { GeneratedImage, ImageModel, ImageResponse, type ImageRequestFor, type ImageRoute } from \"../image\"\nimport { Auth, type Definition as AuthDefinition } from \"../route/auth\"\nimport {\n InvalidProviderOutputReason,\n LLMError,\n Usage,\n mergeHttpOptions,\n mergeJsonRecords,\n type HttpOptions,\n} from \"../schema\"\nimport { ProviderShared, optionalNull } from \"./shared\"\nimport { ImageInputs } from \"./utils/image-input\"\n\nconst ADAPTER = \"xai-images\"\nexport const DEFAULT_BASE_URL = \"https://api.x.ai/v1\"\nexport const PATH = \"/images/generations\"\nexport const EDIT_PATH = \"/images/edits\"\n\nexport type XAIImageString<Known extends string> = Known | (string & {})\n\nexport type XAIImageOptions = {\n readonly n?: number\n readonly aspectRatio?: XAIImageString<\n | \"1:1\"\n | \"3:4\"\n | \"4:3\"\n | \"9:16\"\n | \"16:9\"\n | \"2:3\"\n | \"3:2\"\n | \"9:19.5\"\n | \"19.5:9\"\n | \"9:20\"\n | \"20:9\"\n | \"1:2\"\n | \"2:1\"\n | \"auto\"\n >\n readonly aspect_ratio?: XAIImageString<\n | \"1:1\"\n | \"3:4\"\n | \"4:3\"\n | \"9:16\"\n | \"16:9\"\n | \"2:3\"\n | \"3:2\"\n | \"9:19.5\"\n | \"19.5:9\"\n | \"9:20\"\n | \"20:9\"\n | \"1:2\"\n | \"2:1\"\n | \"auto\"\n >\n readonly resolution?: XAIImageString<\"1k\" | \"2k\">\n readonly responseFormat?: XAIImageString<\"url\" | \"b64_json\">\n readonly response_format?: XAIImageString<\"url\" | \"b64_json\">\n} & Record<string, unknown>\n\ntype XAIImageBody = Record<string, unknown> & {\n readonly model: string\n readonly prompt: string\n}\n\nconst XAIImageResponse = Schema.Struct({\n data: Schema.Array(\n Schema.Struct({\n b64_json: optionalNull(Schema.String),\n url: optionalNull(Schema.String),\n revised_prompt: optionalNull(Schema.String),\n mime_type: optionalNull(Schema.String),\n }),\n ),\n usage: Schema.optional(Schema.Unknown),\n})\n\nexport interface ModelInput {\n readonly id: string\n readonly auth: AuthDefinition\n readonly baseURL?: string\n readonly headers?: Record<string, string>\n readonly http?: HttpOptions\n}\n\nconst nativeOptions = (options: XAIImageOptions | undefined) => {\n if (!options) return undefined\n const { aspectRatio, responseFormat, ...native } = options\n return {\n aspect_ratio: aspectRatio,\n response_format: responseFormat,\n ...native,\n }\n}\n\nconst invalidOutput = (message: string) =>\n new LLMError({\n module: ADAPTER,\n method: \"generate\",\n reason: new InvalidProviderOutputReason({ message, route: ADAPTER }),\n })\n\nconst applyQuery = (url: string, query: Record<string, string> | undefined) => {\n if (!query) return url\n const next = new URL(url)\n Object.entries(query).forEach(([key, value]) => next.searchParams.set(key, value))\n return next.toString()\n}\n\nexport const model = (input: ModelInput) => {\n const route: ImageRoute<XAIImageOptions> = {\n id: ADAPTER,\n generate: Effect.fn(\"XAIImages.generate\")(function* (request: ImageRequestFor<XAIImageOptions>, execute) {\n const http = mergeHttpOptions(request.model.http, request.http)\n const imageReferences = (request.images ?? []).map((image) => {\n if (image.type === \"bytes\") return { url: ImageInputs.dataUrl(image), type: \"image_url\" as const }\n if (image.type === \"url\") return { url: image.url, type: \"image_url\" as const }\n if (image.type === \"file-id\") return { file_id: image.id }\n return undefined\n })\n if (imageReferences.some((image) => image === undefined))\n return yield* ImageInputs.invalid(ADAPTER, \"xAI Images accepts image URLs, data URLs, bytes, and file IDs\")\n const requestBody = mergeJsonRecords(\n {\n model: request.model.id,\n prompt: request.prompt,\n image: imageReferences.length === 1 ? imageReferences[0] : undefined,\n images: imageReferences.length > 1 ? imageReferences : undefined,\n },\n nativeOptions(request.options),\n http?.body,\n ) as XAIImageBody\n const text = ProviderShared.encodeJson(requestBody)\n const url = applyQuery(\n `${(input.baseURL ?? DEFAULT_BASE_URL).replace(/\\/$/, \"\")}${imageReferences.length === 0 ? PATH : EDIT_PATH}`,\n http?.query,\n )\n const headers = yield* Auth.toEffect(input.auth)({\n request,\n method: \"POST\",\n url,\n body: text,\n headers: Headers.fromInput({ ...input.headers, ...http?.headers }),\n })\n const response = yield* execute(\n HttpClientRequest.post(url).pipe(\n HttpClientRequest.setHeaders(headers),\n HttpClientRequest.bodyText(text, \"application/json\"),\n ),\n )\n const payload = yield* response.json.pipe(\n Effect.mapError(() => invalidOutput(\"Failed to read the xAI Images response\")),\n )\n const decoded = yield* Schema.decodeUnknownEffect(XAIImageResponse)(payload).pipe(\n Effect.mapError(() => invalidOutput(\"xAI Images returned an invalid response\")),\n )\n const images = yield* Effect.forEach(decoded.data, (item, index) => {\n const mediaType = item.mime_type ?? \"application/octet-stream\"\n if (item.b64_json)\n return Effect.fromResult(Encoding.decodeBase64(item.b64_json)).pipe(\n Effect.mapError(() => invalidOutput(`xAI Images result ${index} contains invalid base64 data`)),\n Effect.map(\n (data) =>\n new GeneratedImage({\n mediaType,\n data,\n providerMetadata:\n item.revised_prompt === undefined || item.revised_prompt === null\n ? undefined\n : { xai: { revisedPrompt: item.revised_prompt } },\n }),\n ),\n )\n if (item.url)\n return Effect.succeed(\n new GeneratedImage({\n mediaType,\n data: item.url,\n providerMetadata:\n item.revised_prompt === undefined || item.revised_prompt === null\n ? undefined\n : { xai: { revisedPrompt: item.revised_prompt } },\n }),\n )\n return Effect.fail(invalidOutput(`xAI Images result ${index} has neither image data nor a URL`))\n })\n if (images.length === 0) return yield* invalidOutput(\"xAI Images returned no images\")\n const usage = ProviderShared.isRecord(decoded.usage) ? decoded.usage : undefined\n return new ImageResponse({\n images,\n usage: usage === undefined ? undefined : new Usage({ providerMetadata: { xai: usage } }),\n providerMetadata: usage === undefined ? undefined : { xai: { usage } },\n })\n }),\n }\n return ImageModel.make<XAIImageOptions>({ id: input.id, provider: \"xai\", route, http: input.http })\n}\n\nexport const XAIImages = {\n model,\n} as const\n", | ||
| "import { AuthOptions, type ProviderAuthOption } from \"../route/auth-options\"\nimport type { RouteDefaultsInput } from \"../route/client\"\nimport { HttpOptions, ProviderID, type ModelID } from \"../schema\"\nimport * as OpenAICompatibleProfiles from \"./openai-compatible-profile\"\nimport * as OpenAICompatibleChat from \"../protocols/openai-compatible-chat\"\nimport * as OpenAIResponses from \"../protocols/openai-responses\"\nimport { XAIImages } from \"../protocols/xai-images\"\n\nexport const id = ProviderID.make(\"xai\")\n\nexport type ModelOptions = RouteDefaultsInput &\n ProviderAuthOption<\"optional\"> & {\n readonly baseURL?: string\n }\n\nexport type { XAIImageOptions } from \"../protocols/xai-images\"\n\nexport const routes = [OpenAIResponses.route, OpenAICompatibleChat.route]\n\nconst auth = (options: ProviderAuthOption<\"optional\">) => AuthOptions.bearer(options, \"XAI_API_KEY\")\n\nconst configuredResponsesRoute = (input: ModelOptions) => {\n const { apiKey: _, auth: _auth, baseURL, ...rest } = input\n return OpenAIResponses.route.with({\n ...rest,\n provider: id,\n endpoint: { baseURL: baseURL ?? OpenAICompatibleProfiles.profiles.xai.baseURL },\n auth: auth(input),\n })\n}\n\nconst configuredChatRoute = (input: ModelOptions) => {\n const { apiKey: _, auth: _auth, baseURL, ...rest } = input\n return OpenAICompatibleChat.route.with({\n ...rest,\n provider: id,\n endpoint: { baseURL: baseURL ?? OpenAICompatibleProfiles.profiles.xai.baseURL },\n auth: auth(input),\n })\n}\n\nexport const configure = (input: ModelOptions = {}) => {\n const responsesRoute = configuredResponsesRoute(input)\n const chatRoute = configuredChatRoute(input)\n const responses = (modelID: string | ModelID) => responsesRoute.model({ id: modelID })\n const chat = (modelID: string | ModelID) => chatRoute.model({ id: modelID })\n const image = (modelID: string | ModelID) =>\n XAIImages.model({\n id: modelID,\n auth: auth(input),\n baseURL: input.baseURL ?? OpenAICompatibleProfiles.profiles.xai.baseURL,\n headers: input.headers,\n http: input.http === undefined ? undefined : HttpOptions.make(input.http),\n })\n return {\n id,\n model: responses,\n responses,\n chat,\n image,\n configure,\n }\n}\n\nexport const provider = configure()\nexport const model = provider.model\nexport const responses = provider.responses\nexport const chat = provider.chat\nexport const image = provider.image\n" | ||
| ], | ||
| "mappings": ";0wBAeA,SAAM,OAAU,kBACH,OAAmB,2BACnB,OAAO,2BACP,OAAY,qBAgDnB,OAAmB,OAAO,YAAO,MACrC,UAAM,OAAO,MACX,EAAO,OAAO,CACZ,SAAU,EAAa,EAAO,MAAM,EACpC,IAAK,EAAa,EAAO,MAAM,EAC/B,eAAgB,EAAa,EAAO,M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AQ,CAAC,EAUrF,MAAO,CACL,KACA,MAAO,EACP,YACA,KAbW,CAAC,IAA8B,EAAU,MAAM,CAAE,GAAI,CAAQ,CAAC,EAczE,MAbY,CAAC,IACb,EAAU,MAAM,CACd,GAAI,EACJ,KAAM,EAAK,CAAK,EAChB,QAAS,EAAM,SAAoC,EAAS,IAAI,QAChE,QAAS,EAAM,QACf,KAAM,EAAM,OAAS,OAAY,OAAY,EAAY,KAAK,EAAM,IAAI,CAC1E,CAAC,EAOD,WACF,GAGW,EAAW,EAAU,EACrB,GAAQ,EAAS,MACjB,GAAY,EAAS,UACrB,GAAO,EAAS,KAChB,GAAQ,EAAS", | ||
| "debugId": "7D014CB044DA3C3864756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/plugin/list.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport { OpenCode } from \"@opencode-ai/client\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.plugin.commands.list,\n Effect.fn(\"cli.plugin.list\")(function* () {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const response = yield* Effect.promise(() => client.plugin.list({ location: { directory: process.cwd() } }))\n const plugins = response.data.toSorted((a, b) => a.id.localeCompare(b.id))\n if (plugins.length === 0) {\n process.stdout.write(\"No plugins loaded\" + EOL)\n return\n }\n process.stdout.write(plugins.map((plugin) => plugin.id).join(EOL) + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";g6BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,YAAO,cAAS,UAClC,OAAO,QAAG,sBAAiB,OAAE,cAAU,OAAG,MACxC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,QADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAEpF,GADW,MAAO,EAAO,QAAQ,IAAM,EAAO,OAAO,KAAK,CAAE,SAAU,CAAE,UAAW,QAAQ,IAAI,CAAE,CAAE,CAAC,CAAC,GAClF,KAAK,SAAS,CAAC,EAAG,IAAM,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,EACzE,GAAI,EAAQ,SAAW,EAAG,CACxB,QAAQ,OAAO,MAAM,oBAAsB,CAAG,EAC9C,OAEF,QAAQ,OAAO,MAAM,EAAQ,IAAI,CAAC,IAAW,EAAO,EAAE,EAAE,KAAK,CAAG,EAAI,CAAG,EACxE,CACH", | ||
| "debugId": "D170785B34A3495264756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/get.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect, Option } from \"effect\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.get,\n Effect.fn(\"cli.service.get\")(function* (input) {\n process.stdout.write((yield* ServiceConfig.get(Option.getOrUndefined(input.key))) + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";42BAAA,mBAAS,gBAMT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,SACnC,OAAO,QAAG,sBAAiB,OAAE,cAAU,MAAC,OAAO,MAC7C,aAAQ,YAAO,YAAO,WAAO,OAAc,IAAI,EAAO,eAAe,EAAM,GAAG,CAAC,GAAK,CAAG,EACxF,CACH", | ||
| "debugId": "63ADFFCDE40D177964756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/restart.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.restart,\n Effect.fn(\"cli.service.restart\")(function* () {\n const options = yield* ServiceConfig.options()\n yield* Service.stop(options)\n const transport = yield* Service.ensure(options)\n process.stdout.write(transport.url + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";i3BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,aACnC,OAAO,QAAG,0BAAqB,OAAE,cAAU,OAAG,MAC5C,SAAM,OAAU,WAAO,OAAc,aAAQ,OAC7C,MAAO,EAAQ,KAAK,CAAO,EAC3B,IAAM,EAAY,MAAO,EAAQ,OAAO,CAAO,EAC/C,QAAQ,OAAO,MAAM,EAAU,IAAM,CAAG,EACzC,CACH", | ||
| "debugId": "9E17EC650CC6B0B664756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/services/service-config.ts", "src/util/process.ts"], | ||
| "sourcesContent": [ | ||
| "import { Global } from \"@opencode-ai/core/global\"\nimport { InstallationChannel, InstallationVersion } from \"@opencode-ai/core/installation/version\"\nimport { Hash } from \"@opencode-ai/core/util/hash\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Effect, FileSystem, Option, Schema } from \"effect\"\nimport { randomBytes } from \"crypto\"\nimport path from \"path\"\nimport { selfCommand } from \"../util/process\"\n\n// The CLI's service configuration file, plus the Service.EnsureOptions binding that\n// points the client package's service operations at this CLI: which\n// registration file (by channel), which version, and how to spawn opencode.\n\nexport const Info = Schema.Struct({\n hostname: Schema.optional(Schema.String),\n port: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(65_535))),\n password: Schema.optional(Schema.String),\n})\nexport type Info = typeof Info.Type\n\nconst keys = [\"hostname\", \"port\", \"password\"] as const\ntype Key = (typeof keys)[number]\n\nconst decodeInfo = Schema.decodeUnknownEffect(Schema.fromJsonString(Info))\nconst decodeRegistration = Schema.decodeUnknownEffect(Schema.fromJsonString(Service.Info))\n\nexport function filename(channel = InstallationChannel) {\n if (channel === \"latest\") return \"service.json\"\n if (channel === \"local\") return \"service-local.json\"\n return `service-${Hash.fast(channel)}.json`\n}\n\nexport function defaultPort(channel = InstallationChannel) {\n if (channel === \"latest\") return 0xc0de\n if (channel === \"local\") return 0xc0df\n return 10_000 + (Number.parseInt(Hash.fast(channel).slice(0, 8), 16) % 50_000)\n}\n\nexport function versionBelongsToChannel(\n version: string | undefined,\n channel = InstallationChannel,\n installedVersion = InstallationVersion,\n) {\n if (version === undefined) return false\n if (version === installedVersion) return true\n const prefix = `0.0.0-${channel}-`\n if (!version.startsWith(prefix)) return false\n return /^\\d+(?:\\.\\d+)?$/.test(version.slice(prefix.length))\n}\n\nexport const migrateRegistration = Effect.fnUntraced(function* (\n legacy: string,\n file: string,\n channel = InstallationChannel,\n installedVersion = InstallationVersion,\n) {\n if (channel === \"latest\" || channel === \"local\") return\n const fs = yield* FileSystem.FileSystem\n const text = yield* fs.readFileString(legacy).pipe(Effect.option)\n if (Option.isNone(text)) return\n const registration = yield* decodeRegistration(text.value).pipe(Effect.option)\n if (Option.isNone(registration)) return\n if (!versionBelongsToChannel(registration.value.version, channel, installedVersion)) return\n yield* fs.writeFileString(file, text.value, { flag: \"wx\", mode: 0o600 }).pipe(Effect.ignore)\n})\n\nfunction configKey(key: string): Key {\n if (key === \"hostname\" || key === \"port\" || key === \"password\") return key\n throw new Error(`Unknown service config key: ${key}`)\n}\n\nconst paths = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem\n const global = yield* Global.Service\n const name = filename()\n const file = path.join(global.state, name)\n return {\n fs,\n file,\n legacyFile: path.join(global.state, \"service.json\"),\n configFile: path.join(global.config, name),\n }\n})\n\nexport const options = Effect.fnUntraced(function* () {\n const { file, legacyFile } = yield* paths\n yield* migrateRegistration(legacyFile, file)\n return {\n file,\n version: InstallationVersion,\n command: [...selfCommand(), \"serve\", \"--service\"],\n }\n})\n\nexport const read = Effect.fn(\"cli.service-config.read\")(function* () {\n const { fs, configFile } = yield* paths\n return yield* fs.readFileString(configFile).pipe(\n Effect.flatMap(decodeInfo),\n Effect.catch(() => Effect.succeed({} as Info)),\n )\n})\n\nconst write = Effect.fn(\"cli.service-config.write\")(function* (value: Info) {\n const { fs, configFile } = yield* paths\n const temp = configFile + \".tmp\"\n yield* fs.makeDirectory(path.dirname(configFile), { recursive: true })\n yield* fs.writeFileString(temp, JSON.stringify(value, null, 2) + \"\\n\", { mode: 0o600 })\n yield* fs.rename(temp, configFile)\n})\n\nexport const password = Effect.fn(\"cli.service-config.password\")(function* (value?: string) {\n const existing = yield* read()\n if (value === undefined && existing.password) return existing.password\n const next = value ?? randomBytes(32).toString(\"base64url\")\n\n // Keep one private credential across server restarts so discovered clients\n // can reconnect without exposing a password flag or environment variable.\n yield* write({ ...existing, password: next })\n return next\n})\n\nexport const get = Effect.fn(\"cli.service-config.get\")(function* (key?: string) {\n if (key === undefined) {\n const { password: _password, ...safe } = yield* read()\n return JSON.stringify(safe, null, 2)\n }\n switch (configKey(key)) {\n case \"hostname\": {\n return (yield* read()).hostname ?? \"\"\n }\n case \"port\": {\n const port = (yield* read()).port\n return port === undefined ? \"\" : String(port)\n }\n case \"password\": {\n return yield* password()\n }\n }\n throw new Error(`Unknown service config key: ${key}`)\n})\n\nexport const set = Effect.fn(\"cli.service-config.set\")(function* (key: string, value: string) {\n switch (configKey(key)) {\n case \"hostname\": {\n yield* Service.stop(yield* options())\n yield* write({ ...(yield* read()), hostname: value })\n return\n }\n case \"port\": {\n const port = Number(value)\n if (!Number.isInteger(port) || port < 1 || port > 65_535) throw new Error(\"Port must be between 1 and 65535\")\n yield* Service.stop(yield* options())\n yield* write({ ...(yield* read()), port })\n return\n }\n case \"password\": {\n yield* Service.stop(yield* options())\n yield* password(value)\n return\n }\n }\n})\n\nexport const unset = Effect.fn(\"cli.service-config.unset\")(function* (key: string) {\n switch (configKey(key)) {\n case \"hostname\": {\n yield* Service.stop(yield* options())\n const { hostname: _hostname, ...next } = yield* read()\n yield* write(next)\n return\n }\n case \"port\": {\n yield* Service.stop(yield* options())\n const { port: _port, ...next } = yield* read()\n yield* write(next)\n return\n }\n case \"password\": {\n yield* Service.stop(yield* options())\n const { password: _password, ...next } = yield* read()\n yield* write(next)\n return\n }\n }\n})\n\nexport * as ServiceConfig from \"./service-config\"\n", | ||
| "import path from \"node:path\"\n\nexport function selfCommand() {\n const runtime = path.basename(process.execPath, path.extname(process.execPath)).toLowerCase()\n if (runtime !== \"bun\" && runtime !== \"node\" && runtime !== \"nodejs\") return [process.execPath]\n if (!process.argv[1]) throw new Error(\"Failed to resolve CLI entrypoint\")\n if (runtime === \"node\" || runtime === \"nodejs\") return [process.execPath, ...nodeFlags(), process.argv[1]]\n return [process.execPath, process.argv[1]]\n}\n\nfunction nodeFlags() {\n return process.execArgv.flatMap((arg, index, args) => {\n if (index > 0 && args[index - 1] === \"--conditions\") return []\n if (arg === \"--conditions\") return args[index + 1] ? [arg, args[index + 1]] : []\n if (arg.startsWith(\"--conditions=\")) return [arg]\n if (\n arg === \"--experimental-ffi\" ||\n arg === \"--use-system-ca\" ||\n arg === \"--enable-source-maps\" ||\n arg === \"--no-addons\"\n )\n return [arg]\n if (arg === \"--no-warnings\" || arg.startsWith(\"--disable-warning=\")) return [arg]\n return []\n })\n}\n" | ||
| ], | ||
| "mappings": ";weAKA,2BAAS,oBACT,yBCNA,yBAEO,SAAS,CAAW,EAAG,CAC5B,IAAM,EAAU,EAAK,SAAS,QAAQ,SAAU,EAAK,QAAQ,QAAQ,QAAQ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,EAAQ,CAAC,EACpC,IAAQ,SAAU,KAAc,GAAS,MAAO,EAAK,EACrD,MAAO,EAAM,CAAI,EACjB,MACF,GAEH", | ||
| "debugId": "E4FDDD79810F148864756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
| { | ||
| "version": 3, | ||
| "sources": ["src/server-process.ts", "src/commands/handlers/serve.ts"], | ||
| "sourcesContent": [ | ||
| "export * as ServerProcess from \"./server-process\"\n\nimport { NodeServices } from \"@effect/platform-node\"\nimport { Service, type DiscoverOptions, type Info } from \"@opencode-ai/client/effect/service\"\nimport { LayerNode } from \"@opencode-ai/core/effect/layer-node\"\nimport { Global } from \"@opencode-ai/core/global\"\nimport { InstallationVersion } from \"@opencode-ai/core/installation/version\"\nimport { AppProcess } from \"@opencode-ai/core/process\"\nimport { randomBytes, randomUUID } from \"node:crypto\"\nimport path from \"node:path\"\nimport { Effect, FileSystem, Logger, Option, Redacted, Schedule, Schema } from \"effect\"\nimport { HttpServer } from \"effect/unstable/http\"\nimport { Env } from \"./env\"\nimport { ServiceConfig } from \"./services/service-config\"\nimport { Updater } from \"./services/updater\"\n\nexport type Mode = \"default\" | \"service\" | \"stdio\"\n\nexport type Options = {\n readonly mode: Mode\n readonly hostname?: string\n readonly port?: number\n}\n\n// The process effect lives until server shutdown; tracing it would parent every request to one process-lifetime trace.\nexport const run = Effect.fnUntraced(function* (options: Options) {\n return yield* processEffect(options).pipe(\n Effect.provide(Updater.layer),\n Effect.provide(LayerNode.compile(LayerNode.group([Global.node, AppProcess.node]))),\n Effect.provide(NodeServices.layer),\n )\n})\n\nconst processEffect = Effect.fnUntraced(function* (options: Options) {\n if (options.mode === \"service\") yield* Effect.sync(() => process.chdir(Global.Path.home))\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const serviceOptions = options.mode === \"service\" ? yield* ServiceConfig.options() : undefined\n const config = options.mode === \"service\" ? yield* ServiceConfig.read() : {}\n const hostname = options.hostname ?? config.hostname ?? \"127.0.0.1\"\n const port = options.port ?? config.port ?? (options.mode === \"service\" ? ServiceConfig.defaultPort() : undefined)\n if (\n serviceOptions !== undefined &&\n port !== undefined &&\n (yield* Service.incumbent({ ...serviceOptions, url: serviceURL(hostname, port) })) !== undefined\n )\n return\n const { start } = yield* Effect.promise(() => import(\"@opencode-ai/server/process\"))\n const environmentPassword = yield* Env.password\n // Keep the lease credential out of the environment inherited by tools.\n if (options.mode === \"stdio\") {\n delete process.env.OPENCODE_PASSWORD\n delete process.env.OPENCODE_SERVER_PASSWORD\n }\n const password =\n options.mode === \"service\"\n ? config.password || randomBytes(32).toString(\"base64url\")\n : environmentPassword\n ? Redacted.value(environmentPassword)\n : randomBytes(32).toString(\"base64url\")\n if (!password) return yield* Effect.fail(new Error(\"Missing server password\"))\n const instanceID = randomUUID()\n const server = yield* start(\n {\n hostname,\n port,\n password,\n database: {\n path: process.env.OPENCODE_DB,\n },\n models: {\n url: process.env.OPENCODE_MODELS_URL,\n file: process.env.OPENCODE_MODELS_PATH,\n fetch: ![\"1\", \"true\"].includes(process.env.OPENCODE_DISABLE_MODELS_FETCH?.toLowerCase() ?? \"\"),\n },\n },\n serviceOptions === undefined\n ? undefined\n : {\n instanceID,\n onListen: (address, shutdown) =>\n Effect.gen(function* () {\n if (!config.password) yield* ServiceConfig.password(password)\n return yield* register(address, password, instanceID, serviceOptions.file, shutdown)\n }),\n },\n ).pipe(\n Effect.provide(Logger.layer([], { mergeWithExisting: false })),\n Effect.catch((error) => {\n if (serviceOptions === undefined || port === undefined || !addressInUse(error)) return Effect.fail(error)\n return recognizeIncumbent(serviceOptions, hostname, port).pipe(\n Effect.flatMap((found) =>\n found\n ? Effect.void\n : Effect.fail(\n new Error(\n `Managed service port ${port} on ${hostname} is already in use by another process. ` +\n \"Configure another port with `opencode service set port <port>` and start the service again.\",\n { cause: error },\n ),\n ),\n ),\n )\n }),\n )\n if (server === undefined) return\n const url = HttpServer.formatAddress(server.address)\n console.log(options.mode === \"stdio\" ? JSON.stringify({ url }) : `server listening on ${url}`)\n if (options.mode === \"default\" && !environmentPassword) console.log(`server password ${password}`)\n const updater = yield* Updater.Service\n yield* updater.check().pipe(Effect.schedule(Schedule.spaced(\"10 minutes\")), Effect.forkScoped)\n return yield* options.mode === \"service\"\n ? server.shutdown\n : options.mode === \"stdio\"\n ? waitForStdinClose()\n : Effect.never\n }).pipe(Effect.annotateLogs({ role: \"server\" })),\n )\n})\n\nconst infoJson = Schema.fromJsonString(Service.Info)\nconst encodeInfo = Schema.encodeEffect(infoJson)\nconst decodeInfo = Schema.decodeUnknownEffect(infoJson)\n\nconst register = Effect.fnUntraced(function* (\n address: HttpServer.Address,\n password: string,\n id: string,\n file: string,\n shutdown: Effect.Effect<void>,\n) {\n const fs = yield* FileSystem.FileSystem\n const temp = file + \".\" + id + \".tmp\"\n yield* fs.makeDirectory(path.dirname(file), { recursive: true })\n const info = {\n id,\n version: InstallationVersion,\n url: HttpServer.formatAddress(address),\n pid: process.pid,\n password,\n }\n const encoded = yield* encodeInfo(info)\n const current = fs.readFileString(file).pipe(\n Effect.flatMap(decodeInfo),\n Effect.orElseSucceed(() => undefined),\n )\n const owns = (found: Info | undefined) =>\n found?.id === info.id &&\n found.version === info.version &&\n found.url === info.url &&\n found.pid === info.pid &&\n found.password === info.password\n yield* fs.writeFileString(temp, encoded, { mode: 0o600 }).pipe(Effect.andThen(fs.rename(temp, file)))\n yield* current.pipe(\n Effect.filterOrFail(owns),\n Effect.repeat(Schedule.spaced(\"5 seconds\")),\n Effect.ignore,\n Effect.andThen(shutdown),\n Effect.forkScoped,\n )\n return current.pipe(\n Effect.flatMap((found) => (owns(found) ? fs.remove(file) : Effect.void)),\n Effect.ignore,\n )\n})\n\nconst recognizeIncumbent = Effect.fnUntraced(function* (options: DiscoverOptions, hostname: string, port: number) {\n const found = yield* Service.incumbent({ ...options, url: serviceURL(hostname, port) }).pipe(\n Effect.filterOrFail((value) => value !== undefined),\n Effect.retry(Schedule.spaced(\"100 millis\")),\n Effect.timeoutOption(\"15 seconds\"),\n )\n return Option.isSome(found)\n})\n\nfunction serviceURL(hostname: string, port: number) {\n return `http://${hostname.includes(\":\") ? `[${hostname}]` : hostname}:${port}`\n}\n\nfunction addressInUse(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null) return false\n if (\"code\" in error && error.code === \"EADDRINUSE\") return true\n return \"cause\" in error && addressInUse(error.cause)\n}\n\nfunction waitForStdinClose() {\n return Effect.callback<void>((resume) => {\n const close = () => resume(Effect.void)\n process.stdin.once(\"end\", close)\n process.stdin.once(\"close\", close)\n process.stdin.resume()\n if (process.stdin.readableEnded || process.stdin.destroyed) close()\n return Effect.sync(() => {\n process.stdin.off(\"end\", close)\n process.stdin.off(\"close\", close)\n process.stdin.pause()\n })\n })\n}\n", | ||
| "import { Effect, Option } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { ServerProcess } from \"../../server-process\"\n\nexport default Runtime.handler(\n Commands.commands.serve,\n Effect.fnUntraced(function* (input) {\n if (input.service && input.stdio) return yield* Effect.fail(new Error(\"--service and --stdio cannot be combined\"))\n return yield* ServerProcess.run({\n mode: input.service ? \"service\" : input.stdio ? \"stdio\" : \"default\",\n hostname: Option.getOrUndefined(input.hostname),\n port: Option.getOrUndefined(input.port),\n })\n }),\n)\n" | ||
| ], | ||
| "mappings": ";omCAQA,2BAAS,qBAAa,oBACtB,yBAgBO,SAAM,OAAM,OAAO,gBAAW,cAAU,MAAC,OAAkB,MAChE,YAAO,WAAO,OAAc,MAAO,OAAE,UACnC,OAAO,aAAQ,OAAQ,UAAK,OAC5B,OAAO,QAAQ,EAAU,QAAQ,EAAU,MAAM,CAAC,EAAO,KAAM,EAAW,IAAI,CAAC,CAAC,CAAC,EACjF,EAAO,QAAQ,EAAa,KAAK,CACnC,EACD,EAEK,EAAgB,EAAO,WAAW,SAAU,CAAC,EAAkB,CACnE,GAAI,EAAQ,OAAS,UAAW,MAAO,EAAO,KAAK,IAAM,QAAQ,M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,SAAU,GAAS,EAAM,OAAS,aAAc,MAAO,GAC3D,MAAO,UAAW,GAAS,EAAa,EAAM,KAAK,EAGrD,SAAS,CAAiB,EAAG,CAC3B,OAAO,EAAO,SAAe,CAAC,IAAW,CACvC,IAAM,EAAQ,IAAM,EAAO,EAAO,IAAI,EAItC,GAHA,QAAQ,MAAM,KAAK,MAAO,CAAK,EAC/B,QAAQ,MAAM,KAAK,QAAS,CAAK,EACjC,QAAQ,MAAM,OAAO,EACjB,QAAQ,MAAM,eAAiB,QAAQ,MAAM,UAAW,EAAM,EAClE,OAAO,EAAO,KAAK,IAAM,CACvB,QAAQ,MAAM,IAAI,MAAO,CAAK,EAC9B,QAAQ,MAAM,IAAI,QAAS,CAAK,EAChC,QAAQ,MAAM,MAAM,EACrB,EACF,EChMH,IAAe,KAAQ,QACrB,EAAS,SAAS,MAClB,EAAO,WAAW,SAAU,CAAC,EAAO,CAClC,GAAI,EAAM,SAAW,EAAM,MAAO,OAAO,MAAO,EAAO,KAAS,MAAM,0CAA0C,CAAC,EACjH,OAAO,MAAO,EAAc,IAAI,CAC9B,KAAM,EAAM,QAAU,UAAY,EAAM,MAAQ,QAAU,UAC1D,SAAU,EAAO,eAAe,EAAM,QAAQ,EAC9C,KAAM,EAAO,eAAe,EAAM,IAAI,CACxC,CAAC,EACF,CACH", | ||
| "debugId": "594FA0FC78D569C664756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../core/src/installation/version.ts"], | ||
| "sourcesContent": [ | ||
| "declare global {\n const OPENCODE_VERSION: string\n const OPENCODE_CHANNEL: string\n}\n\nexport const InstallationVersion = typeof OPENCODE_VERSION === \"string\" ? OPENCODE_VERSION : \"local\"\nexport const InstallationChannel = typeof OPENCODE_CHANNEL === \"string\" ? OPENCODE_CHANNEL : \"local\"\nexport const InstallationLocal = InstallationChannel === \"local\"\n" | ||
| ], | ||
| "mappings": ";AAKO,IAAM,EAA6D,mBAC7D,EAA6D,OAC7D,EAAoB", | ||
| "debugId": "752A4BF87EE5D56964756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/mcp/add.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport path from \"node:path\"\nimport { readFile, stat, writeFile } from \"node:fs/promises\"\nimport { Effect, Option } from \"effect\"\nimport { applyEdits, modify } from \"jsonc-parser\"\nimport { Global } from \"@opencode-ai/core/global\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\n\nexport default Runtime.handler(\n Commands.commands.mcp.commands.add,\n Effect.fn(\"cli.mcp.add\")(function* (input) {\n const url = Option.getOrUndefined(input.url)\n const headers = Option.getOrUndefined(input.header)\n const environment = Option.getOrUndefined(input.env)\n // The CLI framework strands `--` operands on the root command, so read the local server command\n // straight from argv after `--`. This also lets the command carry its own flags (e.g. `npx -y`).\n const dash = process.argv.indexOf(\"--\")\n const command = dash === -1 ? [...input.command] : process.argv.slice(dash + 1)\n\n const hasCommand = command.length > 0\n if (url && hasCommand)\n return yield* Effect.fail(new Error(\"Provide either --url <url> or a command after --, not both\"))\n if (!url && !hasCommand) return yield* Effect.fail(new Error(\"Provide either --url <url> or a command after --\"))\n if (url && !URL.canParse(url)) return yield* Effect.fail(new Error(`Invalid URL: ${url}`))\n if (url && environment) return yield* Effect.fail(new Error(\"--env is only valid for local MCP servers\"))\n if (hasCommand && headers) return yield* Effect.fail(new Error(\"--header is only valid for remote MCP servers\"))\n\n const server = url\n ? { type: \"remote\" as const, url, ...(headers ? { headers } : {}) }\n : { type: \"local\" as const, command, ...(environment ? { environment } : {}) }\n\n const configPath = yield* Effect.promise(() => resolveConfigPath(input.global ? Global.Path.config : process.cwd()))\n yield* Effect.promise(() => write(configPath, input.name, server))\n process.stdout.write(`MCP server \"${input.name}\" added to ${configPath}` + EOL)\n }),\n)\n\nexport async function resolveConfigPath(directory: string) {\n const candidates = [\n path.join(directory, \"opencode.json\"),\n path.join(directory, \"opencode.jsonc\"),\n path.join(directory, \".opencode\", \"opencode.json\"),\n path.join(directory, \".opencode\", \"opencode.jsonc\"),\n ]\n for (const candidate of candidates) {\n if (\n await stat(candidate).then(\n (info) => info.isFile(),\n () => false,\n )\n )\n return candidate\n }\n return candidates[0]\n}\n\nasync function write(configPath: string, name: string, server: unknown) {\n const text = await readFile(configPath, \"utf8\").catch((error) => {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") return \"{}\"\n throw error\n })\n const edits = modify(text, [\"mcp\", \"servers\", name], server, {\n formattingOptions: { tabSize: 2, insertSpaces: true },\n })\n await writeFile(configPath, applyEdits(text, edits))\n}\n" | ||
| ], | ||
| "mappings": ";2xBAAA,mBAAS,gBACT,yBACA,wBAAS,eAAU,oBAAM,yBAOzB,SAAe,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,SAC/B,OAAO,QAAG,kBAAa,OAAE,cAAU,CAAC,EAAO,CACzC,IAAM,EAAM,EAAO,eAAe,EAAM,GAAG,EACrC,EAAU,EAAO,eAAe,EAAM,MAAM,EAC5C,EAAc,EAAO,eAAe,EAAM,GAAG,EAG7C,EAAO,QAAQ,KAAK,QAAQ,IAAI,EAChC,EAAU,IAAS,GAAK,CAAC,GAAG,EAAM,OAAO,EAAI,QAAQ,KAAK,MAAM,EAAO,CAAC,EAExE,EAAa,EAAQ,OAAS,EACpC,GAAI,GAAO,EACT,OAAO,MAAO,EAAO,KAAS,MAAM,4DAA4D,CAAC,EACnG,GAAI,CAAC,GAAO,CAAC,EAAY,OAAO,MAAO,EAAO,KAAS,MAAM,kDAAkD,CAAC,EAChH,GAAI,GAAO,CAAC,IAAI,SAAS,CAAG,EAAG,OAAO,MAAO,EAAO,KAAS,MAAM,gBAAgB,GAAK,CAAC,EACzF,GAAI,GAAO,EAAa,OAAO,MAAO,EAAO,KAAS,MAAM,2CAA2C,CAAC,EACxG,GAAI,GAAc,EAAS,OAAO,MAAO,EAAO,KAAS,MA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cesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport {\n OpenCode,\n type IntegrationAttemptStatus,\n type IntegrationOAuthMethod,\n type OpenCodeClient,\n} from \"@opencode-ai/client\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { ServiceConfig } from \"../../../services/service-config\"\nimport { resolveIntegration } from \"./resolve\"\n\nconst location = { directory: process.cwd() }\n\nexport default Runtime.handler(\n Commands.commands.mcp.commands.auth,\n Effect.fn(\"cli.mcp.auth\")(function* (input) {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n\n const integration = yield* resolveIntegration(client, input.name, location)\n if (!integration)\n return yield* Effect.fail(new Error(`MCP server \"${input.name}\" is not an OAuth-capable remote server`))\n const method = integration.methods.find(\n (candidate): candidate is IntegrationOAuthMethod => candidate.type === \"oauth\",\n )\n if (!method)\n return yield* Effect.fail(new Error(`MCP server \"${input.name}\" is not an OAuth-capable remote server`))\n\n const started = yield* Effect.promise(() =>\n client.integration.oauth.connect({ integrationID: integration.id, methodID: method.id, inputs: {}, location }),\n )\n const attempt = started.data\n if (attempt.mode === \"code\")\n return yield* Effect.fail(new Error(\"This server requires manual code entry, which the CLI does not support\"))\n\n process.stdout.write(attempt.instructions + EOL + attempt.url + EOL)\n\n const result = yield* poll(client, integration.id, attempt.attemptID)\n if (result.status === \"complete\") {\n process.stdout.write(`Authenticated with ${input.name}` + EOL)\n return\n }\n const reason = result.status === \"failed\" ? `: ${result.message}` : \"\"\n return yield* Effect.fail(new Error(`Authentication ${result.status}${reason}`))\n }),\n)\n\nconst poll = (\n client: OpenCodeClient,\n integrationID: string,\n attemptID: string,\n): Effect.Effect<Exclude<IntegrationAttemptStatus, { status: \"pending\" }>> =>\n Effect.gen(function* () {\n const status = yield* Effect.promise(() =>\n client.integration.oauth.status({ integrationID, attemptID, location }),\n ).pipe(Effect.map((result) => result.data))\n if (status.status === \"pending\") {\n yield* Effect.sleep(\"1 second\")\n return yield* poll(client, integrationID, attemptID)\n }\n return status\n })\n" | ||
| ], | ||
| "mappings": ";+8BAAA,mBAAS,gBAcT,SAAM,OAAW,MAAE,eAAW,aAAQ,SAAI,MAAE,OAE7B,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,UAC/B,OAAO,QAAG,mBAAc,OAAE,cAAU,MAAC,OAAO,MAC1C,IAAM,EAAU,MAAO,EAAc,QAAQ,EAEvC,GADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAEpF,EAAc,MAAO,EAAmB,EAAQ,EAAM,KAAM,CAAQ,EAC1E,GAAI,CAAC,EACH,OAAO,MAAO,EAAO,KAAS,MAAM,eAAe,EAAM,6CAA6C,CAAC,EACzG,IAAM,EAAS,EAAY,QAAQ,KACjC,CAAC,IAAmD,EAAU,OAAS,OACzE,EACA,GAAI,CAAC,EACH,OAAO,MAAO,EAAO,KAAS,MAAM,eAAe,EAAM,6CAA6C,CAAC,EAKzG,IAAM,GAHU,MAAO,EAAO,QAAQ,IACpC,EAAO,YAAY,MAAM,QAAQ,CAAE,cAAe,EAAY,GAAI,SAAU,EAAO,GAAI,OAAQ,CAAC,EAAG,UAAS,CAAC,CAC/G,GACwB,KACxB,GAAI,EAAQ,OAAS,OACnB,OAAO,MAAO,EAAO,KAAS,MAAM,wEAAwE,CAAC,EAE/G,QAAQ,OAAO,MAAM,EAAQ,aAAe,EAAM,EAAQ,IAAM,CAAG,EAEnE,IAAM,EAAS,MAAO,EAAK,EAAQ,EAAY,GAAI,EAAQ,SAAS,EACpE,GAAI,EAAO,SAAW,WAAY,CAChC,QAAQ,OAAO,MAAM,sBAAsB,EAAM,OAAS,CAAG,EAC7D,OAEF,IAAM,EAAS,EAAO,SAAW,SAAW,KAAK,EAAO,UAAY,GACpE,OAAO,MAAO,EAAO,KAAS,MAAM,kBAAkB,EAAO,SAAS,GAAQ,CAAC,EAChF,CACH,EAEM,EAAO,CACX,EACA,EACA,IAEA,EAAO,IAAI,SAAU,EAAG,CACtB,IAAM,EAAS,MAAO,EAAO,QAAQ,IACnC,EAAO,YAAY,MAAM,OAAO,CAAE,gBAAe,YAAW,UAAS,CAAC,CACxE,EAAE,KAAK,EAAO,IAAI,CAAC,IAAW,EAAO,IAAI,CAAC,EAC1C,GAAI,EAAO,SAAW,UAEpB,OADA,MAAO,EAAO,MAAM,UAAU,EACvB,MAAO,EAAK,EAAQ,EAAe,CAAS,EAErD,OAAO,EACR", | ||
| "debugId": "A4AA5A23DC021CF164756E2164756E21", | ||
| "names": [] | ||
| } |
+1
-1
| { | ||
| "name": "@opencode-ai/cli-linux-arm64", | ||
| "version": "0.0.0-next-15914", | ||
| "version": "0.0.0-next-15915", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/mcp/auth.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport {\n OpenCode,\n type IntegrationAttemptStatus,\n type IntegrationOAuthMethod,\n type OpenCodeClient,\n} from \"@opencode-ai/client\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { ServiceConfig } from \"../../../services/service-config\"\nimport { resolveIntegration } from \"./resolve\"\n\nconst location = { directory: process.cwd() }\n\nexport default Runtime.handler(\n Commands.commands.mcp.commands.auth,\n Effect.fn(\"cli.mcp.auth\")(function* (input) {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n\n const integration = yield* resolveIntegration(client, input.name, location)\n if (!integration)\n return yield* Effect.fail(new Error(`MCP server \"${input.name}\" is not an OAuth-capable remote server`))\n const method = integration.methods.find(\n (candidate): candidate is IntegrationOAuthMethod => candidate.type === \"oauth\",\n )\n if (!method)\n return yield* Effect.fail(new Error(`MCP server \"${input.name}\" is not an OAuth-capable remote server`))\n\n const started = yield* Effect.promise(() =>\n client.integration.oauth.connect({ integrationID: integration.id, methodID: method.id, inputs: {}, location }),\n )\n const attempt = started.data\n if (attempt.mode === \"code\")\n return yield* Effect.fail(new Error(\"This server requires manual code entry, which the CLI does not support\"))\n\n process.stdout.write(attempt.instructions + EOL + attempt.url + EOL)\n\n const result = yield* poll(client, integration.id, attempt.attemptID)\n if (result.status === \"complete\") {\n process.stdout.write(`Authenticated with ${input.name}` + EOL)\n return\n }\n const reason = result.status === \"failed\" ? `: ${result.message}` : \"\"\n return yield* Effect.fail(new Error(`Authentication ${result.status}${reason}`))\n }),\n)\n\nconst poll = (\n client: OpenCodeClient,\n integrationID: string,\n attemptID: string,\n): Effect.Effect<Exclude<IntegrationAttemptStatus, { status: \"pending\" }>> =>\n Effect.gen(function* () {\n const status = yield* Effect.promise(() =>\n client.integration.oauth.status({ integrationID, attemptID, location }),\n ).pipe(Effect.map((result) => result.data))\n if (status.status === \"pending\") {\n yield* Effect.sleep(\"1 second\")\n return yield* poll(client, integrationID, attemptID)\n }\n return status\n })\n" | ||
| ], | ||
| "mappings": ";+8BAAA,mBAAS,gBAcT,SAAM,OAAW,MAAE,eAAW,aAAQ,SAAI,MAAE,OAE7B,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,UAC/B,OAAO,QAAG,mBAAc,OAAE,cAAU,MAAC,OAAO,MAC1C,IAAM,EAAU,MAAO,EAAc,QAAQ,EAEvC,GADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAA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,EAAe,CAAS,EAErD,OAAO,EACR", | ||
| "debugId": "A4AA5A23DC021CF164756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/server-process.ts", "src/commands/handlers/serve.ts"], | ||
| "sourcesContent": [ | ||
| "export * as ServerProcess from \"./server-process\"\n\nimport { NodeServices } from \"@effect/platform-node\"\nimport { Service, type DiscoverOptions, type Info } from \"@opencode-ai/client/effect/service\"\nimport { LayerNode } from \"@opencode-ai/core/effect/layer-node\"\nimport { Global } from \"@opencode-ai/core/global\"\nimport { InstallationVersion } from \"@opencode-ai/core/installation/version\"\nimport { AppProcess } from \"@opencode-ai/core/process\"\nimport { randomBytes, randomUUID } from \"node:crypto\"\nimport path from \"node:path\"\nimport { Effect, FileSystem, Logger, Option, Redacted, Schedule, Schema } from \"effect\"\nimport { HttpServer } from \"effect/unstable/http\"\nimport { Env } from \"./env\"\nimport { ServiceConfig } from \"./services/service-config\"\nimport { Updater } from \"./services/updater\"\n\nexport type Mode = \"default\" | \"service\" | \"stdio\"\n\nexport type Options = {\n readonly mode: Mode\n readonly hostname?: string\n readonly port?: number\n}\n\n// The process effect lives until server shutdown; tracing it would parent every request to one process-lifetime trace.\nexport const run = Effect.fnUntraced(function* (options: Options) {\n return yield* processEffect(options).pipe(\n Effect.provide(Updater.layer),\n Effect.provide(LayerNode.compile(LayerNode.group([Global.node, AppProcess.node]))),\n Effect.provide(NodeServices.layer),\n )\n})\n\nconst processEffect = Effect.fnUntraced(function* (options: Options) {\n if (options.mode === \"service\") yield* Effect.sync(() => process.chdir(Global.Path.home))\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const serviceOptions = options.mode === \"service\" ? yield* ServiceConfig.options() : undefined\n const config = options.mode === \"service\" ? yield* ServiceConfig.read() : {}\n const hostname = options.hostname ?? config.hostname ?? \"127.0.0.1\"\n const port = options.port ?? config.port ?? (options.mode === \"service\" ? ServiceConfig.defaultPort() : undefined)\n if (\n serviceOptions !== undefined &&\n port !== undefined &&\n (yield* Service.incumbent({ ...serviceOptions, url: serviceURL(hostname, port) })) !== undefined\n )\n return\n const { start } = yield* Effect.promise(() => import(\"@opencode-ai/server/process\"))\n const environmentPassword = yield* Env.password\n // Keep the lease credential out of the environment inherited by tools.\n if (options.mode === \"stdio\") {\n delete process.env.OPENCODE_PASSWORD\n delete process.env.OPENCODE_SERVER_PASSWORD\n }\n const password =\n options.mode === \"service\"\n ? config.password || randomBytes(32).toString(\"base64url\")\n : environmentPassword\n ? Redacted.value(environmentPassword)\n : randomBytes(32).toString(\"base64url\")\n if (!password) return yield* Effect.fail(new Error(\"Missing server password\"))\n const instanceID = randomUUID()\n const server = yield* start({\n hostname,\n port: Option.fromNullishOr(port),\n password,\n instanceID,\n database: {\n path: process.env.OPENCODE_DB,\n },\n models: {\n url: process.env.OPENCODE_MODELS_URL,\n file: process.env.OPENCODE_MODELS_PATH,\n fetch: ![\"1\", \"true\"].includes(process.env.OPENCODE_DISABLE_MODELS_FETCH?.toLowerCase() ?? \"\"),\n },\n service:\n serviceOptions === undefined\n ? undefined\n : {\n onListen: (address, shutdown) =>\n Effect.gen(function* () {\n if (!config.password) yield* ServiceConfig.password(password)\n return yield* register(address, password, instanceID, serviceOptions.file, shutdown)\n }),\n },\n }).pipe(\n Effect.provide(Logger.layer([], { mergeWithExisting: false })),\n Effect.catch((error) => {\n if (serviceOptions === undefined || port === undefined || !addressInUse(error)) return Effect.fail(error)\n return recognizeIncumbent(serviceOptions, hostname, port).pipe(\n Effect.flatMap((found) =>\n found\n ? Effect.void\n : Effect.fail(\n new Error(\n `Managed service port ${port} on ${hostname} is already in use by another process. ` +\n \"Configure another port with `opencode service set port <port>` and start the service again.\",\n { cause: error },\n ),\n ),\n ),\n )\n }),\n )\n if (server === undefined) return\n const url = HttpServer.formatAddress(server.address)\n console.log(options.mode === \"stdio\" ? JSON.stringify({ url }) : `server listening on ${url}`)\n if (options.mode === \"default\" && !environmentPassword) console.log(`server password ${password}`)\n const updater = yield* Updater.Service\n yield* updater.check().pipe(Effect.schedule(Schedule.spaced(\"10 minutes\")), Effect.forkScoped)\n return yield* options.mode === \"service\"\n ? server.shutdown\n : options.mode === \"stdio\"\n ? waitForStdinClose()\n : Effect.never\n }).pipe(Effect.annotateLogs({ role: \"server\" })),\n )\n})\n\nconst infoJson = Schema.fromJsonString(Service.Info)\nconst encodeInfo = Schema.encodeEffect(infoJson)\nconst decodeInfo = Schema.decodeUnknownEffect(infoJson)\n\nconst register = Effect.fnUntraced(function* (\n address: HttpServer.Address,\n password: string,\n id: string,\n file: string,\n shutdown: Effect.Effect<void>,\n) {\n const fs = yield* FileSystem.FileSystem\n const temp = file + \".\" + id + \".tmp\"\n yield* fs.makeDirectory(path.dirname(file), { recursive: true })\n const info = {\n id,\n version: InstallationVersion,\n url: HttpServer.formatAddress(address),\n pid: process.pid,\n password,\n }\n const encoded = yield* encodeInfo(info)\n const current = fs.readFileString(file).pipe(\n Effect.flatMap(decodeInfo),\n Effect.orElseSucceed(() => undefined),\n )\n const owns = (found: Info | undefined) =>\n found?.id === info.id &&\n found.version === info.version &&\n found.url === info.url &&\n found.pid === info.pid &&\n found.password === info.password\n yield* fs.writeFileString(temp, encoded, { mode: 0o600 }).pipe(Effect.andThen(fs.rename(temp, file)))\n yield* current.pipe(\n Effect.filterOrFail(owns),\n Effect.repeat(Schedule.spaced(\"5 seconds\")),\n Effect.ignore,\n Effect.andThen(shutdown),\n Effect.forkScoped,\n )\n return current.pipe(\n Effect.flatMap((found) => (owns(found) ? fs.remove(file) : Effect.void)),\n Effect.ignore,\n )\n})\n\nconst recognizeIncumbent = Effect.fnUntraced(function* (options: DiscoverOptions, hostname: string, port: number) {\n const found = yield* Service.incumbent({ ...options, url: serviceURL(hostname, port) }).pipe(\n Effect.filterOrFail((value) => value !== undefined),\n Effect.retry(Schedule.spaced(\"100 millis\")),\n Effect.timeoutOption(\"15 seconds\"),\n )\n return Option.isSome(found)\n})\n\nfunction serviceURL(hostname: string, port: number) {\n return `http://${hostname.includes(\":\") ? `[${hostname}]` : hostname}:${port}`\n}\n\nfunction addressInUse(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null) return false\n if (\"code\" in error && error.code === \"EADDRINUSE\") return true\n return \"cause\" in error && addressInUse(error.cause)\n}\n\nfunction waitForStdinClose() {\n return Effect.callback<void>((resume) => {\n const close = () => resume(Effect.void)\n process.stdin.once(\"end\", close)\n process.stdin.once(\"close\", close)\n process.stdin.resume()\n if (process.stdin.readableEnded || process.stdin.destroyed) close()\n return Effect.sync(() => {\n process.stdin.off(\"end\", close)\n process.stdin.off(\"close\", close)\n process.stdin.pause()\n })\n })\n}\n", | ||
| "import { Effect, Option } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { ServerProcess } from \"../../server-process\"\n\nexport default Runtime.handler(\n Commands.commands.serve,\n Effect.fnUntraced(function* (input) {\n if (input.service && input.stdio) return yield* Effect.fail(new Error(\"--service and --stdio cannot be combined\"))\n return yield* ServerProcess.run({\n mode: input.service ? \"service\" : input.stdio ? \"stdio\" : \"default\",\n hostname: Option.getOrUndefined(input.hostname),\n port: Option.getOrUndefined(input.port),\n })\n }),\n)\n" | ||
| ], | ||
| "mappings": ";omCAQA,2BAAS,qBAAa,oBACtB,yBAgBO,SAAM,OAAM,OAAO,gBAAW,cAAU,MAAC,OAAkB,MAChE,YAAO,WAAO,OAAc,MAAO,OAAE,UACnC,OAAO,aAAQ,OAAQ,UAAK,OAC5B,OAAO,QAAQ,EAAU,QAAQ,EAAU,MAAM,CAAC,EAAO,KAAM,EAAW,IAAI,CAAC,CAAC,CAAC,EACjF,EAAO,QAAQ,EAAa,KAAK,CACnC,EACD,EAEK,EAAgB,EAAO,WAAW,SAAU,CAAC,EAAkB,CACnE,GAAI,EAAQ,OAAS,UAAW,MAAO,EAAO,KAAK,IAAM,QAAQ,MAAM,EAAO,KAAK,IAAI,CAAC,EACxF,OAAO,MAAO,EAAO,OACnB,EAAO,IAAI,SA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AC3D,MAAO,UAAW,GAAS,EAAa,EAAM,KAAK,EAGrD,SAAS,CAAiB,EAAG,CAC3B,OAAO,EAAO,SAAe,CAAC,IAAW,CACvC,IAAM,EAAQ,IAAM,EAAO,EAAO,IAAI,EAItC,GAHA,QAAQ,MAAM,KAAK,MAAO,CAAK,EAC/B,QAAQ,MAAM,KAAK,QAAS,CAAK,EACjC,QAAQ,MAAM,OAAO,EACjB,QAAQ,MAAM,eAAiB,QAAQ,MAAM,UAAW,EAAM,EAClE,OAAO,EAAO,KAAK,IAAM,CACvB,QAAQ,MAAM,IAAI,MAAO,CAAK,EAC9B,QAAQ,MAAM,IAAI,QAAS,CAAK,EAChC,QAAQ,MAAM,MAAM,EACrB,EACF,EC/LH,IAAe,KAAQ,QACrB,EAAS,SAAS,MAClB,EAAO,WAAW,SAAU,CAAC,EAAO,CAClC,GAAI,EAAM,SAAW,EAAM,MAAO,OAAO,MAAO,EAAO,KAAS,MAAM,0CAA0C,CAAC,EACjH,OAAO,MAAO,EAAc,IAAI,CAC9B,KAAM,EAAM,QAAU,UAAY,EAAM,MAAQ,QAAU,UAC1D,SAAU,EAAO,eAAe,EAAM,QAAQ,EAC9C,KAAM,EAAO,eAAe,EAAM,IAAI,CACxC,CAAC,EACF,CACH", | ||
| "debugId": "8571DFCCA6767DCF64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/stop.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.stop,\n Effect.fn(\"cli.service.stop\")(function* () {\n yield* Service.stop(yield* ServiceConfig.options())\n }),\n)\n" | ||
| ], | ||
| "mappings": ";i3BAMA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,UACnC,OAAO,QAAG,uBAAkB,OAAE,cAAU,OAAG,MACzC,WAAO,OAAQ,UAAK,WAAO,OAAc,aAAQ,MAAC,OACnD,CACH", | ||
| "debugId": "8FD5F50B48CD7B9D64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/unset.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect } from \"effect\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.unset,\n Effect.fn(\"cli.service.unset\")(function* (input) {\n yield* ServiceConfig.unset(input.key)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";o2BAKA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,WACnC,OAAO,QAAG,wBAAmB,OAAE,cAAU,MAAC,OAAO,MAC/C,WAAO,OAAc,WAAM,OAAM,QAAG,OACrC,MACH", | ||
| "debugId": "55A9FFA548651C1C64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../ai/src/protocols/xai-images.ts", "../ai/src/providers/xai.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect, Encoding, Schema } from \"effect\"\nimport { Headers, HttpClientRequest } from \"effect/unstable/http\"\nimport { GeneratedImage, ImageModel, ImageResponse, type ImageRequestFor, type ImageRoute } from \"../image\"\nimport { Auth, type Definition as AuthDefinition } from \"../route/auth\"\nimport {\n InvalidProviderOutputReason,\n LLMError,\n Usage,\n mergeHttpOptions,\n mergeJsonRecords,\n type HttpOptions,\n} from \"../schema\"\nimport { ProviderShared, optionalNull } from \"./shared\"\nimport { ImageInputs } from \"./utils/image-input\"\n\nconst ADAPTER = \"xai-images\"\nexport const DEFAULT_BASE_URL = \"https://api.x.ai/v1\"\nexport const PATH = \"/images/generations\"\nexport const EDIT_PATH = \"/images/edits\"\n\nexport type XAIImageString<Known extends string> = Known | (string & {})\n\nexport type XAIImageOptions = {\n readonly n?: number\n readonly aspectRatio?: XAIImageString<\n | \"1:1\"\n | \"3:4\"\n | \"4:3\"\n | \"9:16\"\n | \"16:9\"\n | \"2:3\"\n | \"3:2\"\n | \"9:19.5\"\n | \"19.5:9\"\n | \"9:20\"\n | \"20:9\"\n | \"1:2\"\n | \"2:1\"\n | \"auto\"\n >\n readonly aspect_ratio?: XAIImageString<\n | \"1:1\"\n | \"3:4\"\n | \"4:3\"\n | \"9:16\"\n | \"16:9\"\n | \"2:3\"\n | \"3:2\"\n | \"9:19.5\"\n | \"19.5:9\"\n | \"9:20\"\n | \"20:9\"\n | \"1:2\"\n | \"2:1\"\n | \"auto\"\n >\n readonly resolution?: XAIImageString<\"1k\" | \"2k\">\n readonly responseFormat?: XAIImageString<\"url\" | \"b64_json\">\n readonly response_format?: XAIImageString<\"url\" | \"b64_json\">\n} & Record<string, unknown>\n\ntype XAIImageBody = Record<string, unknown> & {\n readonly model: string\n readonly prompt: string\n}\n\nconst XAIImageResponse = Schema.Struct({\n data: Schema.Array(\n Schema.Struct({\n b64_json: optionalNull(Schema.String),\n url: optionalNull(Schema.String),\n revised_prompt: optionalNull(Schema.String),\n mime_type: optionalNull(Schema.String),\n }),\n ),\n usage: Schema.optional(Schema.Unknown),\n})\n\nexport interface ModelInput {\n readonly id: string\n readonly auth: AuthDefinition\n readonly baseURL?: string\n readonly headers?: Record<string, string>\n readonly http?: HttpOptions\n}\n\nconst nativeOptions = (options: XAIImageOptions | undefined) => {\n if (!options) return undefined\n const { aspectRatio, responseFormat, ...native } = options\n return {\n aspect_ratio: aspectRatio,\n response_format: responseFormat,\n ...native,\n }\n}\n\nconst invalidOutput = (message: string) =>\n new LLMError({\n module: ADAPTER,\n method: \"generate\",\n reason: new InvalidProviderOutputReason({ message, route: ADAPTER }),\n })\n\nconst applyQuery = (url: string, query: Record<string, string> | undefined) => {\n if (!query) return url\n const next = new URL(url)\n Object.entries(query).forEach(([key, value]) => next.searchParams.set(key, value))\n return next.toString()\n}\n\nexport const model = (input: ModelInput) => {\n const route: ImageRoute<XAIImageOptions> = {\n id: ADAPTER,\n generate: Effect.fn(\"XAIImages.generate\")(function* (request: ImageRequestFor<XAIImageOptions>, execute) {\n const http = mergeHttpOptions(request.model.http, request.http)\n const imageReferences = (request.images ?? []).map((image) => {\n if (image.type === \"bytes\") return { url: ImageInputs.dataUrl(image), type: \"image_url\" as const }\n if (image.type === \"url\") return { url: image.url, type: \"image_url\" as const }\n if (image.type === \"file-id\") return { file_id: image.id }\n return undefined\n })\n if (imageReferences.some((image) => image === undefined))\n return yield* ImageInputs.invalid(ADAPTER, \"xAI Images accepts image URLs, data URLs, bytes, and file IDs\")\n const requestBody = mergeJsonRecords(\n {\n model: request.model.id,\n prompt: request.prompt,\n image: imageReferences.length === 1 ? imageReferences[0] : undefined,\n images: imageReferences.length > 1 ? imageReferences : undefined,\n },\n nativeOptions(request.options),\n http?.body,\n ) as XAIImageBody\n const text = ProviderShared.encodeJson(requestBody)\n const url = applyQuery(\n `${(input.baseURL ?? DEFAULT_BASE_URL).replace(/\\/$/, \"\")}${imageReferences.length === 0 ? PATH : EDIT_PATH}`,\n http?.query,\n )\n const headers = yield* Auth.toEffect(input.auth)({\n request,\n method: \"POST\",\n url,\n body: text,\n headers: Headers.fromInput({ ...input.headers, ...http?.headers }),\n })\n const response = yield* execute(\n HttpClientRequest.post(url).pipe(\n HttpClientRequest.setHeaders(headers),\n HttpClientRequest.bodyText(text, \"application/json\"),\n ),\n )\n const payload = yield* response.json.pipe(\n Effect.mapError(() => invalidOutput(\"Failed to read the xAI Images response\")),\n )\n const decoded = yield* Schema.decodeUnknownEffect(XAIImageResponse)(payload).pipe(\n Effect.mapError(() => invalidOutput(\"xAI Images returned an invalid response\")),\n )\n const images = yield* Effect.forEach(decoded.data, (item, index) => {\n const mediaType = item.mime_type ?? \"application/octet-stream\"\n if (item.b64_json)\n return Effect.fromResult(Encoding.decodeBase64(item.b64_json)).pipe(\n Effect.mapError(() => invalidOutput(`xAI Images result ${index} contains invalid base64 data`)),\n Effect.map(\n (data) =>\n new GeneratedImage({\n mediaType,\n data,\n providerMetadata:\n item.revised_prompt === undefined || item.revised_prompt === null\n ? undefined\n : { xai: { revisedPrompt: item.revised_prompt } },\n }),\n ),\n )\n if (item.url)\n return Effect.succeed(\n new GeneratedImage({\n mediaType,\n data: item.url,\n providerMetadata:\n item.revised_prompt === undefined || item.revised_prompt === null\n ? undefined\n : { xai: { revisedPrompt: item.revised_prompt } },\n }),\n )\n return Effect.fail(invalidOutput(`xAI Images result ${index} has neither image data nor a URL`))\n })\n if (images.length === 0) return yield* invalidOutput(\"xAI Images returned no images\")\n const usage = ProviderShared.isRecord(decoded.usage) ? decoded.usage : undefined\n return new ImageResponse({\n images,\n usage: usage === undefined ? undefined : new Usage({ providerMetadata: { xai: usage } }),\n providerMetadata: usage === undefined ? undefined : { xai: { usage } },\n })\n }),\n }\n return ImageModel.make<XAIImageOptions>({ id: input.id, provider: \"xai\", route, http: input.http })\n}\n\nexport const XAIImages = {\n model,\n} as const\n", | ||
| "import { AuthOptions, type ProviderAuthOption } from \"../route/auth-options\"\nimport type { RouteDefaultsInput } from \"../route/client\"\nimport { HttpOptions, ProviderID, type ModelID } from \"../schema\"\nimport * as OpenAICompatibleProfiles from \"./openai-compatible-profile\"\nimport * as OpenAICompatibleChat from \"../protocols/openai-compatible-chat\"\nimport * as OpenAIResponses from \"../protocols/openai-responses\"\nimport { XAIImages } from \"../protocols/xai-images\"\n\nexport const id = ProviderID.make(\"xai\")\n\nexport type ModelOptions = RouteDefaultsInput &\n ProviderAuthOption<\"optional\"> & {\n readonly baseURL?: string\n }\n\nexport type { XAIImageOptions } from \"../protocols/xai-images\"\n\nexport const routes = [OpenAIResponses.route, OpenAICompatibleChat.route]\n\nconst auth = (options: ProviderAuthOption<\"optional\">) => AuthOptions.bearer(options, \"XAI_API_KEY\")\n\nconst configuredResponsesRoute = (input: ModelOptions) => {\n const { apiKey: _, auth: _auth, baseURL, ...rest } = input\n return OpenAIResponses.route.with({\n ...rest,\n provider: id,\n endpoint: { baseURL: baseURL ?? OpenAICompatibleProfiles.profiles.xai.baseURL },\n auth: auth(input),\n })\n}\n\nconst configuredChatRoute = (input: ModelOptions) => {\n const { apiKey: _, auth: _auth, baseURL, ...rest } = input\n return OpenAICompatibleChat.route.with({\n ...rest,\n provider: id,\n endpoint: { baseURL: baseURL ?? OpenAICompatibleProfiles.profiles.xai.baseURL },\n auth: auth(input),\n })\n}\n\nexport const configure = (input: ModelOptions = {}) => {\n const responsesRoute = configuredResponsesRoute(input)\n const chatRoute = configuredChatRoute(input)\n const responses = (modelID: string | ModelID) => responsesRoute.model({ id: modelID })\n const chat = (modelID: string | ModelID) => chatRoute.model({ id: modelID })\n const image = (modelID: string | ModelID) =>\n XAIImages.model({\n id: modelID,\n auth: auth(input),\n baseURL: input.baseURL ?? OpenAICompatibleProfiles.profiles.xai.baseURL,\n headers: input.headers,\n http: input.http === undefined ? undefined : HttpOptions.make(input.http),\n })\n return {\n id,\n model: responses,\n responses,\n chat,\n image,\n configure,\n }\n}\n\nexport const provider = configure()\nexport const model = provider.model\nexport const responses = provider.responses\nexport const chat = provider.chat\nexport const image = provider.image\n" | ||
| ], | ||
| "mappings": ";0wBAeA,SAAM,OAAU,kBACH,OAAmB,2BACnB,OAAO,2BACP,OAAY,qBAgDnB,OAAmB,OAAO,YAAO,MACrC,UAAM,OAAO,MACX,EAAO,OAAO,CACZ,SAAU,EAAa,EAAO,MAAM,EACpC,IAAK,EAAa,EAAO,MAAM,EAC/B,eAAgB,EAAa,EAAO,MAAM,EAC1C,UAAW,EAAa,EAAO,MAAM,CACvC,CAAC,CACH,EACA,MAAO,EAAO,SAAS,EAAO,OAAO,CACvC,CAAC,EAUK,EAAgB,CAAC,IAAyC,CAC9D,GAAI,CAAC,EAAS,OACd,IAAQ,cAAa,oBAAmB,GAAW,EACnD,MAAO,CACL,aAAc,EACd,gBAAiB,KACd,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EAAM,QACf,KAAM,EAAM,OAAS,OAAY,OAAY,EAAY,KAAK,EAAM,IAAI,CAC1E,CAAC,EAOD,WACF,GAGW,EAAW,EAAU,EACrB,GAAQ,EAAS,MACjB,GAAY,EAAS,UACrB,GAAO,EAAS,KAChB,GAAQ,EAAS", | ||
| "debugId": "C1FD4DA387E1E93B64756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/auth/connect.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { OpenCode, type IntegrationCommandStatusOutput, type OpenCodeClient } from \"@opencode-ai/client/promise\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nconst location = { directory: process.cwd() }\n\nexport default Runtime.handler(\n Commands.commands.auth.commands.connect,\n Effect.fn(\"cli.auth.connect\")(function* (input) {\n process.stdout.write(\"Connecting...\" + EOL + EOL)\n const endpoint = yield* Service.ensure(yield* ServiceConfig.options())\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n yield* request(() => client.integration.wellknown.add({ url: input.url, location }))\n const integrationID = input.url.replace(/\\/+$/, \"\")\n const started = yield* request(() =>\n client.integration.command.connect({ integrationID, methodID: \"login\", location }),\n )\n yield* Effect.addFinalizer(() =>\n request(() =>\n client.integration.command.cancel({ integrationID, attemptID: started.data.attemptID, location }),\n ).pipe(Effect.ignore),\n )\n\n const status = yield* wait(client, integrationID, started.data.attemptID)\n if (status.status === \"failed\") return yield* Effect.fail(new Error(status.message))\n if (status.status === \"expired\") return yield* Effect.fail(new Error(\"Authentication expired\"))\n process.stdout.write(\"Connected\" + EOL)\n }),\n)\n\nconst wait = (\n client: OpenCodeClient,\n integrationID: string,\n attemptID: string,\n shown = false,\n): Effect.Effect<Exclude<IntegrationCommandStatusOutput[\"data\"], { status: \"pending\" }>, unknown> =>\n Effect.gen(function* () {\n const response = yield* request(() => client.integration.command.status({ integrationID, attemptID, location }))\n if (response.data.status !== \"pending\") return response.data\n const output = response.data.message?.trim()\n if (!shown && output) process.stdout.write(output + EOL + EOL)\n yield* Effect.sleep(500)\n return yield* wait(client, integrationID, attemptID, shown || !!output)\n })\n\nfunction request<A>(task: () => Promise<A>) {\n return Effect.tryPromise({ try: task, catch: (cause) => cause })\n}\n" | ||
| ], | ||
| "mappings": ";g6BAAA,mBAAS,gBAQT,SAAM,OAAW,MAAE,eAAW,aAAQ,SAAI,MAAE,OAE7B,SAAQ,aACrB,OAAS,cAAS,UAAK,cAAS,aAChC,OAAO,QAAG,uBAAkB,OAAE,cAAU,MAAC,OAAO,CAC9C,QAAQ,OAAO,MAAM,gBAAkB,EAAM,CAAG,EAChD,IAAM,EAAW,MAAO,EAAQ,OAAO,MAAO,EAAc,QAAQ,CAAC,EAC/D,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAC1F,MAAO,EAAQ,IAAM,EAAO,YAAY,UAAU,IAAI,CAAE,IAAK,EAAM,IAAK,UAAS,CAAC,CAAC,EACnF,IAAM,EAAgB,EAAM,IAAI,QAAQ,OAAQ,EAAE,EAC5C,EAAU,MAAO,EAAQ,IAC7B,EAAO,YAAY,QAAQ,QAAQ,CAAE,gBAAe,SAAU,QAAS,UAAS,CAAC,CACnF,EACA,MAAO,EAAO,aAAa,IACzB,EAAQ,IACN,EAAO,YAAY,QAAQ,OAAO,CAAE,gBAAe,UAAW,EAAQ,KAAK,UAAW,UAAS,CAAC,CAClG,EAAE,KAAK,EAAO,MAAM,CACtB,EAEA,IAAM,EAAS,MAAO,EAAK,EAAQ,EAAe,EAAQ,KAAK,SAAS,EACxE,GAAI,EAAO,SAAW,SAAU,OAAO,MAAO,EAAO,KAAS,MAAM,EAAO,OAAO,CAAC,EACnF,GAAI,EAAO,SAAW,UAAW,OAAO,MAAO,EAAO,KAAS,MAAM,wBAAwB,CAAC,EAC9F,QAAQ,OAAO,MAAM,YAAc,CAAG,EACvC,CACH,EAEM,EAAO,CACX,EACA,EACA,EACA,EAAQ,KAER,EAAO,IAAI,SAAU,EAAG,CACtB,IAAM,EAAW,MAAO,EAAQ,IAAM,EAAO,YAAY,QAAQ,OAAO,CAAE,gBAAe,YAAW,UAAS,CAAC,CAAC,EAC/G,GAAI,EAAS,KAAK,SAAW,UAAW,OAAO,EAAS,KACxD,IAAM,EAAS,EAAS,KAAK,SAAS,KAAK,EAC3C,GAAI,CAAC,GAAS,EAAQ,QAAQ,OAAO,MAAM,EAAS,EAAM,CAAG,EAE7D,OADA,MAAO,EAAO,MAAM,GAAG,EAChB,MAAO,EAAK,EAAQ,EAAe,EAAW,GAAS,CAAC,CAAC,CAAM,EACvE,EAEH,SAAS,CAAU,CAAC,EAAwB,CAC1C,OAAO,EAAO,WAAW,CAAE,IAAK,EAAM,MAAO,CAAC,IAAU,CAAM,CAAC", | ||
| "debugId": "1CB821DBAE99EE7F64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/mcp/add.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport path from \"node:path\"\nimport { readFile, stat, writeFile } from \"node:fs/promises\"\nimport { Effect, Option } from \"effect\"\nimport { applyEdits, modify } from \"jsonc-parser\"\nimport { Global } from \"@opencode-ai/core/global\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\n\nexport default Runtime.handler(\n Commands.commands.mcp.commands.add,\n Effect.fn(\"cli.mcp.add\")(function* (input) {\n const url = Option.getOrUndefined(input.url)\n const headers = Option.getOrUndefined(input.header)\n const environment = Option.getOrUndefined(input.env)\n // The CLI framework strands `--` operands on the root command, so read the local server command\n // straight from argv after `--`. This also lets the command carry its own flags (e.g. `npx -y`).\n const dash = process.argv.indexOf(\"--\")\n const command = dash === -1 ? [...input.command] : process.argv.slice(dash + 1)\n\n const hasCommand = command.length > 0\n if (url && hasCommand)\n return yield* Effect.fail(new Error(\"Provide either --url <url> or a command after --, not both\"))\n if (!url && !hasCommand) return yield* Effect.fail(new Error(\"Provide either --url <url> or a command after --\"))\n if (url && !URL.canParse(url)) return yield* Effect.fail(new Error(`Invalid URL: ${url}`))\n if (url && environment) return yield* Effect.fail(new Error(\"--env is only valid for local MCP servers\"))\n if (hasCommand && headers) return yield* Effect.fail(new Error(\"--header is only valid for remote MCP servers\"))\n\n const server = url\n ? { type: \"remote\" as const, url, ...(headers ? { headers } : {}) }\n : { type: \"local\" as const, command, ...(environment ? { environment } : {}) }\n\n const configPath = yield* Effect.promise(() => resolveConfigPath(input.global ? Global.Path.config : process.cwd()))\n yield* Effect.promise(() => write(configPath, input.name, server))\n process.stdout.write(`MCP server \"${input.name}\" added to ${configPath}` + EOL)\n }),\n)\n\nexport async function resolveConfigPath(directory: string) {\n const candidates = [\n path.join(directory, \"opencode.json\"),\n path.join(directory, \"opencode.jsonc\"),\n path.join(directory, \".opencode\", \"opencode.json\"),\n path.join(directory, \".opencode\", \"opencode.jsonc\"),\n ]\n for (const candidate of candidates) {\n if (\n await stat(candidate).then(\n (info) => info.isFile(),\n () => false,\n )\n )\n return candidate\n }\n return candidates[0]\n}\n\nasync function write(configPath: string, name: string, server: unknown) {\n const text = await readFile(configPath, \"utf8\").catch((error) => {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") return \"{}\"\n throw error\n })\n const edits = modify(text, [\"mcp\", \"servers\", name], server, {\n formattingOptions: { tabSize: 2, insertSpaces: true },\n })\n await writeFile(configPath, applyEdits(text, edits))\n}\n" | ||
| ], | ||
| "mappings": ";2xBAAA,mBAAS,gBACT,yBACA,wBAAS,eAAU,oBAAM,yBAOzB,SAAe,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,SAC/B,OAAO,QAAG,kBAAa,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K,EAAW,YAAa,gBAAgB,CACpD,EACA,QAAW,KAAa,EACtB,GACE,MAAM,EAAK,CAAS,EAAE,KACpB,CAAC,IAAS,EAAK,OAAO,EACtB,IAAM,EACR,EAEA,OAAO,EAEX,OAAO,EAAW,GAGpB,eAAe,CAAK,CAAC,EAAoB,EAAc,EAAiB,CACtE,IAAM,EAAO,MAAM,EAAS,EAAY,MAAM,EAAE,MAAM,CAAC,IAAU,CAC/D,GAAI,OAAO,IAAU,UAAY,IAAU,MAAQ,SAAU,GAAS,EAAM,OAAS,SAAU,MAAO,KACtG,MAAM,EACP,EACK,EAAQ,EAAO,EAAM,CAAC,MAAO,UAAW,CAAI,EAAG,EAAQ,CAC3D,kBAAmB,CAAE,QAAS,EAAG,aAAc,EAAK,CACtD,CAAC,EACD,MAAM,EAAU,EAAY,EAAW,EAAM,CAAK,CAAC", | ||
| "debugId": "C5D492BCABCFF6C764756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/plugin/list.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport { OpenCode } from \"@opencode-ai/client\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.plugin.commands.list,\n Effect.fn(\"cli.plugin.list\")(function* () {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const response = yield* Effect.promise(() => client.plugin.list({ location: { directory: process.cwd() } }))\n const plugins = response.data.toSorted((a, b) => a.id.localeCompare(b.id))\n if (plugins.length === 0) {\n process.stdout.write(\"No plugins loaded\" + EOL)\n return\n }\n process.stdout.write(plugins.map((plugin) => plugin.id).join(EOL) + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";g6BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,YAAO,cAAS,UAClC,OAAO,QAAG,sBAAiB,OAAE,cAAU,OAAG,MACxC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,QADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAEpF,GADW,MAAO,EAAO,QAAQ,IAAM,EAAO,OAAO,KAAK,CAAE,SAAU,CAAE,UAAW,QAAQ,IAAI,CAAE,CAAE,CAAC,CAAC,GAClF,KAAK,SAAS,CAAC,EAAG,IAAM,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,EACzE,GAAI,EAAQ,SAAW,EAAG,CACxB,QAAQ,OAAO,MAAM,oBAAsB,CAAG,EAC9C,OAEF,QAAQ,OAAO,MAAM,EAAQ,IAAI,CAAC,IAAW,EAAO,EAAE,EAAE,KAAK,CAAG,EAAI,CAAG,EACxE,CACH", | ||
| "debugId": "D170785B34A3495264756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/mcp/logout.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport { OpenCode } from \"@opencode-ai/client\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { ServiceConfig } from \"../../../services/service-config\"\nimport { resolveIntegration } from \"./resolve\"\n\nconst location = { directory: process.cwd() }\n\nexport default Runtime.handler(\n Commands.commands.mcp.commands.logout,\n Effect.fn(\"cli.mcp.logout\")(function* (input) {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n\n const integration = yield* resolveIntegration(client, input.name, location)\n if (!integration) {\n process.stdout.write(`No stored credentials for ${input.name}` + EOL)\n return\n }\n\n const credentials = integration.connections.filter((connection) => connection.type === \"credential\")\n if (credentials.length === 0) {\n process.stdout.write(`No stored credentials for ${input.name}` + EOL)\n return\n }\n\n yield* Effect.forEach(\n credentials,\n (connection) => Effect.promise(() => client.credential.remove({ credentialID: connection.id, location })),\n { discard: true },\n )\n process.stdout.write(`Removed OAuth credentials for ${input.name}` + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";+8BAAA,mBAAS,gBAST,SAAM,OAAW,MAAE,eAAW,aAAQ,SAAI,MAAE,OAE7B,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,YAC/B,OAAO,QAAG,qBAAgB,OAAE,cAAU,MAAC,OAAO,MAC5C,IAAM,EAAU,MAAO,EAAc,QAAQ,EAEvC,GADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAEpF,EAAc,MAAO,EAAmB,EAAQ,EAAM,KAAM,CAAQ,EAC1E,GAAI,CAAC,EAAa,CAChB,QAAQ,OAAO,MAAM,6BAA6B,EAAM,OAAS,CAAG,EACpE,OAGF,IAAM,EAAc,EAAY,YAAY,OAAO,CAAC,IAAe,EAAW,OAAS,YAAY,EACnG,GAAI,EAAY,SAAW,EAAG,CAC5B,QAAQ,OAAO,MAAM,6BAA6B,EAAM,OAAS,CAAG,EACpE,OAGF,MAAO,EAAO,QACZ,EACA,CAAC,IAAe,EAAO,QAAQ,IAAM,EAAO,WAAW,OAAO,CAAE,aAAc,EAAW,GAAI,UAAS,CAAC,CAAC,EACxG,CAAE,QAAS,EAAK,CAClB,EACA,QAAQ,OAAO,MAAM,iCAAiC,EAAM,OAAS,CAAG,EACzE,CACH", | ||
| "debugId": "C57B3A2934A8D52E64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/status.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.status,\n Effect.fn(\"cli.service.status\")(function* () {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover({ ...options, version: undefined })\n process.stdout.write((found?.url ?? \"stopped\") + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";i3BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,YACnC,OAAO,QAAG,yBAAoB,OAAE,cAAU,OAAG,MAC3C,SAAM,OAAU,WAAO,OAAc,aAAQ,OACvC,EAAQ,MAAO,EAAQ,SAAS,IAAK,EAAS,QAAS,MAAU,CAAC,EACxE,QAAQ,OAAO,OAAO,GAAO,KAAO,WAAa,CAAG,EACrD,CACH", | ||
| "debugId": "9A2BF00F84A4EDBE64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/run.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect, Option } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { ServerConnection } from \"../../services/server-connection\"\n\nexport default Runtime.handler(Commands.commands.run, (input) =>\n Effect.gen(function* () {\n const { runNonInteractive } = yield* Effect.promise(() => import(\"../../run/run\"))\n const separator = process.argv.indexOf(\"--\", 2)\n const server = yield* ServerConnection.resolve({\n server: Option.getOrUndefined(input.server),\n standalone: input.standalone,\n })\n yield* Effect.promise(() =>\n runNonInteractive({\n server,\n message: [...input.message, ...(separator === -1 ? [] : process.argv.slice(separator + 1))],\n continue: input.continue,\n session: Option.getOrUndefined(input.session),\n fork: input.fork,\n model: Option.getOrUndefined(input.model),\n agent: Option.getOrUndefined(input.agent),\n format: input.format,\n file: [...input.file],\n title: Option.getOrUndefined(input.title),\n thinking: input.thinking,\n auto: input.auto || input.yolo,\n }),\n )\n }),\n)\n" | ||
| ], | ||
| "mappings": ";+9BAKA,SAAe,SAAQ,aAAQ,OAAS,cAAS,SAAK,MAAC,SACrD,OAAO,SAAI,cAAU,OAAG,MACtB,SAAQ,0BAAsB,WAAO,OAAO,aAAQ,SAAa,wCAAgB,OAC3E,OAAY,aAAQ,UAAK,aAAQ,UAAM,MAAC,EACxC,EAAS,MAAO,EAAiB,QAAQ,CAC7C,OAAQ,EAAO,eAAe,EAAM,MAAM,EAC1C,WAAY,EAAM,UACpB,CAAC,EACD,MAAO,EAAO,QAAQ,IACpB,EAAkB,CAChB,SACA,QAAS,CAAC,GAAG,EAAM,QAAS,GAAI,IAAc,GAAK,CAAC,EAAI,QAAQ,KAAK,MAAM,EAAY,CAAC,CAAE,EAC1F,SAAU,EAAM,SAChB,QAAS,EAAO,eAAe,EAAM,OAAO,EAC5C,KAAM,EAAM,KACZ,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,OAAQ,EAAM,OACd,KAAM,CAAC,GAAG,EAAM,IAAI,EACpB,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,SAAU,EAAM,SAChB,KAAM,EAAM,MAAQ,EAAM,IAC5B,CAAC,CACH,EACD,CACH", | ||
| "debugId": "730F8EB39B96A32F64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../simulation/src/frontend/actions.ts", "../simulation/src/recording.ts", "../simulation/src/frontend/renderer.ts", "../simulation/src/frontend/semantics.ts", "../simulation/src/frontend/server.ts", "../simulation/src/frontend/simulation.ts"], | ||
| "sourcesContent": [ | ||
| "import { tmpdir } from \"node:os\"\nimport { extname, join, resolve } from \"node:path\"\nimport type { CliRenderer, Renderable } from \"@opentui/core\"\nimport {\n createMockKeys,\n createMockMouse,\n KeyCodes,\n type KeyInput,\n type MockInput,\n type MockMouse,\n} from \"@opentui/core/testing\"\nimport { Config, Effect, FileSystem, Schema } from \"effect\"\nimport { SimulationProtocol } from \"../protocol\"\nimport { SimulationRenderer } from \"./renderer\"\nimport { SimulationSemantics } from \"./semantics\"\n\nexport type Action = SimulationProtocol.Frontend.Action\nexport type Element = SimulationProtocol.Frontend.Element\n\nexport interface Harness {\n readonly renderer: CliRenderer\n readonly mockInput: MockInput\n readonly mockMouse: MockMouse\n readonly resize: (cols: number, rows: number) => void\n readonly renderOnce: () => Promise<void>\n readonly screen: () => string\n}\n\ntype RenderBuffer = {\n readonly width: number\n readonly height: number\n getRealCharBytes(includeAnsi?: boolean): Uint8Array\n}\n\nconst decoder = new TextDecoder()\n\nfunction isKeyCode(key: string): key is keyof typeof KeyCodes {\n return Object.hasOwn(KeyCodes, key)\n}\n\nfunction keyInput(key: string): KeyInput {\n const named = key.toUpperCase()\n return isKeyCode(named) ? named : key\n}\n\nfunction children(renderable: Renderable) {\n return renderable.getChildren().filter((child): child is Renderable => \"num\" in child)\n}\n\nfunction all(renderable: Renderable): Renderable[] {\n return [renderable, ...children(renderable).flatMap(all)]\n}\n\nfunction mouseListeners(renderable: Renderable) {\n const general = Reflect.get(renderable, \"_mouseListener\")\n const specific = Reflect.get(renderable, \"_mouseListeners\")\n return Boolean(general) || (specific && typeof specific === \"object\" && Object.keys(specific).length > 0)\n}\n\nfunction hit(renderer: CliRenderer, renderable: Renderable) {\n if (renderable.width <= 0 || renderable.height <= 0) return false\n const x = Math.floor(renderable.screenX + renderable.width / 2)\n const y = Math.floor(renderable.screenY + renderable.height / 2)\n const target = renderer.hitTest(x, y)\n return all(renderable).some((item) => item.num === target)\n}\n\n/**\n * Builds the harness the simulation server drives.\n *\n * When the renderer is the headless simulation renderer, its TestRendererSetup\n * provides the supported testing APIs. For the visible terminal renderer the\n * harness falls back to `requestRender` + `idle` and reading the private\n * `currentRenderBuffer`.\n */\nexport function createHarness(renderer: CliRenderer): Harness {\n const setup = SimulationRenderer.setupFor(renderer)\n return {\n renderer,\n mockInput: setup?.mockInput ?? createMockKeys(renderer),\n mockMouse: setup?.mockMouse ?? createMockMouse(renderer),\n resize: setup?.resize ?? ((cols, rows) => renderer.resize(cols, rows)),\n renderOnce:\n setup?.renderOnce ??\n (async () => {\n renderer.requestRender()\n await renderer.idle()\n }),\n // captureCharFrame follows the test renderer's output sink. Recording\n // redirects that sink to the timeline, so read the live render buffer\n // instead; it is also the source used by screenshots.\n screen: () => decoder.decode((Reflect.get(renderer, \"currentRenderBuffer\") as RenderBuffer).getRealCharBytes()),\n }\n}\n\nexport function elements(renderer: CliRenderer): Element[] {\n return all(renderer.root)\n .filter((renderable) => renderable.visible && !renderable.isDestroyed)\n .map((renderable) => {\n const clickable = mouseListeners(renderable) && hit(renderer, renderable)\n return {\n id: renderable.id,\n num: renderable.num,\n x: renderable.screenX,\n y: renderable.screenY,\n width: renderable.width,\n height: renderable.height,\n focusable: renderable.focusable,\n focused: renderable.focused,\n clickable,\n editor: renderer.currentFocusedEditor === renderable,\n } satisfies Element\n })\n .filter((element) => element.focusable || element.clickable || element.editor)\n}\n\nexport function state(harness: Harness) {\n return {\n focused: {\n renderable: harness.renderer.currentFocusedRenderable?.num,\n editor: Boolean(harness.renderer.currentFocusedEditor),\n },\n elements: elements(harness.renderer),\n }\n}\n\nexport function snapshot(harness: Harness): SimulationProtocol.Frontend.SemanticSnapshot {\n const ids = new Set<string>()\n const visit = (renderable: Renderable, parent?: string): SimulationProtocol.Frontend.SemanticNode[] => {\n if (!renderable.visible || renderable.isDestroyed) return []\n const definition = SimulationSemantics.read(renderable)?.()\n if (definition && ids.has(renderable.id)) throw new Error(`duplicate semantic UI id: ${renderable.id}`)\n if (definition) ids.add(renderable.id)\n const node = definition\n ? [{ id: renderable.id, ...definition, ...(parent === undefined ? {} : { parent }), element: renderable.num }]\n : []\n const ancestor = definition ? renderable.id : parent\n return [...node, ...children(renderable).flatMap((child) => visit(child, ancestor))]\n }\n return Schema.decodeUnknownSync(SimulationProtocol.Frontend.SemanticSnapshot)({\n format: \"opencode-ui-snapshot-v1\",\n nodes: visit(harness.renderer.root),\n })\n}\n\nexport function matches(harness: Pick<Harness, \"screen\">, text: string) {\n return harness.screen().includes(text)\n}\n\nexport const capture = Effect.fn(\"SimulationActions.capture\")(function* (harness: Harness) {\n yield* Effect.tryPromise(() => harness.renderOnce())\n const buffer = harness.renderer.currentRenderBuffer\n return {\n cols: buffer.width,\n rows: buffer.height,\n cursor: [0, 0] as const,\n lines: buffer.getSpanLines().map((line) => ({\n spans: line.spans.map((span) => ({\n text: span.text,\n fg: span.fg.toInts(),\n bg: span.bg.toInts(),\n attributes: span.attributes,\n width: span.width,\n })),\n })),\n } satisfies SimulationProtocol.Frontend.CapturedFrame\n})\n\nexport const screenshot = Effect.fn(\"SimulationActions.screenshot\")(function* (harness: Harness, name?: string) {\n const filename = name ?? `screenshot-${crypto.randomUUID()}`\n if (!filename || filename.includes(\"/\") || filename.includes(\"\\\\\") || extname(filename))\n return yield* Effect.fail(new Error(\"screenshot name must not contain a path or extension\"))\n yield* Effect.tryPromise(() => harness.renderOnce())\n const { SimulationPng } = yield* Effect.promise(() => import(\"./png\"))\n const image = SimulationPng.screenshot(harness.renderer)\n const directory = resolve(\n yield* Config.string(\"OPENCODE_DRIVE_MEDIA_DIR\").pipe(\n Config.withDefault(join(tmpdir(), \"opencode-drive\", \"output\")),\n ),\n )\n const fs = yield* FileSystem.FileSystem\n yield* fs.makeDirectory(directory, { recursive: true })\n const path = join(directory, `${filename}.png`)\n yield* fs.writeFile(path, image.data)\n return path\n})\n\nexport const execute = Effect.fn(\"SimulationActions.execute\")(function* (harness: Harness, action: Action) {\n switch (action.type) {\n case \"ui.type\":\n yield* Effect.tryPromise(() => harness.mockInput.typeText(action.text))\n break\n case \"ui.press\":\n harness.mockInput.pressKey(keyInput(action.key), action.modifiers)\n break\n case \"ui.enter\":\n harness.mockInput.pressEnter()\n break\n case \"ui.arrow\":\n harness.mockInput.pressArrow(action.direction)\n break\n case \"ui.focus\":\n all(harness.renderer.root)\n .find((item) => item.num === action.target)\n ?.focus()\n break\n case \"ui.click\": {\n const target = all(harness.renderer.root).find((item) => item.num === action.target)\n if (!target || !target.visible || target.isDestroyed)\n return yield* Effect.fail(new Error(`click target is stale or unavailable: ${action.target}`))\n if (action.semantic) {\n const current = snapshot(harness).nodes.find((node) => node.element === action.target)\n if (\n current?.id !== action.semantic.id ||\n current.instance !== action.semantic.instance ||\n current.element !== action.semantic.element\n )\n return yield* Effect.fail(new Error(`semantic click target is stale or unavailable: ${action.semantic.id}`))\n }\n if (\n !Number.isFinite(action.x) ||\n action.x < 0 ||\n action.x >= target.width ||\n !Number.isFinite(action.y) ||\n action.y < 0 ||\n action.y >= target.height\n )\n return yield* Effect.fail(new Error(\"click position must be within the target element\"))\n yield* Effect.tryPromise(() => harness.mockMouse.click(target.screenX + action.x, target.screenY + action.y))\n break\n }\n case \"ui.resize\":\n if (\n !Number.isSafeInteger(action.cols) ||\n action.cols <= 0 ||\n !Number.isSafeInteger(action.rows) ||\n action.rows <= 0\n ) {\n return yield* Effect.fail(new Error(\"resize cols and rows must be positive integers\"))\n }\n harness.resize(action.cols, action.rows)\n SimulationRenderer.recordResize(harness.renderer, action.cols, action.rows)\n break\n }\n yield* Effect.tryPromise(() => harness.renderOnce())\n return state(harness)\n})\n\nexport * as SimulationActions from \"./actions\"\n", | ||
| "import { createWriteStream, type WriteStream } from \"node:fs\"\nimport { mkdir } from \"node:fs/promises\"\nimport { dirname } from \"node:path\"\nimport { Writable } from \"node:stream\"\nimport { finished } from \"node:stream/promises\"\nimport { Schema } from \"effect\"\n\nexport const Header = Schema.Struct({\n type: Schema.Literal(\"header\"),\n version: Schema.Literal(1),\n cols: Schema.Number,\n rows: Schema.Number,\n encoding: Schema.Literal(\"base64\"),\n})\nexport interface Header extends Schema.Schema.Type<typeof Header> {}\n\nexport const Output = Schema.Struct({\n type: Schema.Literal(\"output\"),\n at_ms: Schema.Number,\n data: Schema.String,\n})\nexport interface Output extends Schema.Schema.Type<typeof Output> {}\n\nexport const Resize = Schema.Struct({\n type: Schema.Literal(\"resize\"),\n at_ms: Schema.Number,\n cols: Schema.Number,\n rows: Schema.Number,\n})\nexport interface Resize extends Schema.Schema.Type<typeof Resize> {}\n\nexport const Event = Schema.Union([Header, Output, Resize])\nexport type Event = Schema.Schema.Type<typeof Event>\n\nexport class Timeline extends Writable {\n readonly isTTY = true\n readonly path: string\n readonly columns: number\n readonly rows: number\n private readonly output: WriteStream\n private readonly started = performance.now()\n private readonly timestamps: number[] = []\n private done?: Promise<string>\n\n private constructor(path: string, cols: number, rows: number, output: WriteStream) {\n super()\n this.path = path\n this.columns = cols\n this.rows = rows\n this.output = output\n // finish() reports stream failures; keep Writable from also throwing them process-wide.\n this.on(\"error\", () => {})\n output.on(\"error\", (error) => this.destroy(error))\n }\n\n static async create(path: string, cols: number, rows: number) {\n await mkdir(dirname(path), { recursive: true })\n const output = createWriteStream(path)\n const timeline = new Timeline(path, cols, rows, output)\n await new Promise<void>((resolve, reject) => {\n output.write(\n `${JSON.stringify({ type: \"header\", version: 1, cols, rows, encoding: \"base64\" } satisfies Header)}\\n`,\n (error) => (error ? reject(error) : resolve()),\n )\n })\n return timeline\n }\n\n getColorDepth() {\n return 24\n }\n\n override write(chunk: unknown, callback?: (error?: Error | null) => void): boolean\n override write(chunk: unknown, encoding: BufferEncoding, callback?: (error?: Error | null) => void): boolean\n override write(\n chunk: unknown,\n encoding?: BufferEncoding | ((error?: Error | null) => void),\n callback?: (error?: Error | null) => void,\n ) {\n if (!this.writableEnded) {\n this.timestamps.push(this.elapsed())\n if (typeof encoding === \"function\") return super.write(chunk, encoding)\n if (encoding === undefined) return super.write(chunk, callback)\n return super.write(chunk, encoding, callback)\n }\n const done = typeof encoding === \"function\" ? encoding : callback\n queueMicrotask(() => done?.(null))\n return true\n }\n\n override _write(chunk: Buffer, _encoding: BufferEncoding, callback: (error?: Error | null) => void) {\n this.writeOutput(chunk, this.timestamps.shift() ?? this.elapsed(), callback)\n }\n\n override _final(callback: (error?: Error | null) => void) {\n this.writeOutput(Buffer.alloc(0), this.elapsed(), (error) => {\n if (error) return callback(error)\n this.output.end(callback)\n })\n }\n\n finish() {\n if (this.done) return this.done\n this.end()\n this.done = finished(this).then(() => this.path)\n return this.done\n }\n\n resize(cols: number, rows: number) {\n if (this.writableEnded) return\n const event = { type: \"resize\", at_ms: this.elapsed(), cols, rows } satisfies Resize\n this.output.write(`${JSON.stringify(event)}\\n`)\n }\n\n private elapsed() {\n return Math.max(0, Math.round(performance.now() - this.started))\n }\n\n private writeOutput(data: Buffer, at_ms: number, callback: (error?: Error | null) => void) {\n const event = {\n type: \"output\",\n at_ms,\n data: data.toString(\"base64\"),\n } satisfies Output\n this.output.write(`${JSON.stringify(event)}\\n`, callback)\n }\n}\n\nexport * as SimulationRecording from \"./recording\"\n", | ||
| "import type { CliRenderer, CliRendererConfig } from \"@opentui/core\"\nimport { createTestRenderer, type TestRendererSetup } from \"@opentui/core/testing\"\nimport { Effect } from \"effect\"\nimport { Timeline } from \"../recording\"\n\nconst setups = new WeakMap<CliRenderer, TestRendererSetup>()\nconst recordings = new WeakMap<CliRenderer, Timeline>()\n\n/**\n * Creates a headless renderer with optional recording: a real CliRenderer\n * backed by an in-memory screen buffer. The TestRendererSetup is kept\n * module-side so the harness can use supported testing APIs without app\n * code carrying it around.\n */\nexport interface Viewport {\n readonly cols: number\n readonly rows: number\n}\n\nexport const create = Effect.fn(\"SimulationRenderer.create\")(function* (\n options: CliRendererConfig,\n path?: string,\n viewport?: Viewport,\n) {\n const cols = viewport?.cols ?? 100\n const rows = viewport?.rows ?? 40\n const recording = path\n ? yield* Effect.acquireRelease(\n Effect.tryPromise(() => Timeline.create(path, cols, rows)),\n (recording) =>\n Effect.tryPromise(() => recording.finish()).pipe(\n Effect.catch((error) =>\n Effect.sync(() => process.stderr.write(`Failed to finish UI recording: ${error}\\n`)),\n ),\n ),\n )\n : undefined\n const setup = yield* Effect.acquireRelease(\n Effect.tryPromise(() =>\n createTestRenderer({\n ...options,\n width: cols,\n height: rows,\n ...(recording\n ? {\n stdout: recording as unknown as NodeJS.WriteStream,\n bufferedOutput: \"stdout\" as const,\n }\n : {}),\n }),\n ),\n (setup) =>\n Effect.sync(() => {\n if (!setup.renderer.isDestroyed) setup.renderer.destroy()\n }),\n )\n setups.set(setup.renderer, setup)\n if (recording) recordings.set(setup.renderer, recording)\n return setup.renderer\n})\n\nexport function recordResize(renderer: CliRenderer, cols: number, rows: number) {\n recordings.get(renderer)?.resize(cols, rows)\n}\n\nexport function setupFor(renderer: CliRenderer): TestRendererSetup | undefined {\n return setups.get(renderer)\n}\n\nexport function finish(renderer: CliRenderer) {\n const recording = recordings.get(renderer)\n if (!recording) return Effect.fail(new Error(\"UI recording is not available\"))\n return Effect.tryPromise(() => recording.finish())\n}\n\nexport * as SimulationRenderer from \"./renderer\"\n", | ||
| "import type { Renderable } from \"@opentui/core\"\nimport type { SimulationProtocol } from \"../protocol\"\n\n// Semantic renderables set an explicit stable OpenTUI id so ui.state and\n// ui.snapshot expose the same identity. Hierarchy and element handles come\n// from the live render tree.\nexport type Definition = Omit<SimulationProtocol.Frontend.SemanticNode, \"id\" | \"element\" | \"parent\">\n\nconst key = Symbol.for(\"opencode.simulation.semantics\")\n\nconst bind = (definition: () => Definition) => (renderable: Renderable) => {\n Object.defineProperty(renderable, key, { value: definition, configurable: true })\n}\n\nexport const read = (renderable: Renderable) => {\n const definition: unknown = Reflect.get(renderable, key)\n return typeof definition === \"function\" ? (definition as () => Definition) : undefined\n}\n\nexport const SimulationSemantics = { bind, read }\n", | ||
| "import { InstallationVersion } from \"@opencode-ai/core/installation/version\"\nimport { Effect } from \"effect\"\nimport { SimulationControlServer } from \"../control-server\"\nimport { SimulationProtocol } from \"../protocol\"\nimport { SimulationActions, type Harness } from \"./actions\"\nimport { SimulationRenderer } from \"./renderer\"\n\nfunction handle(harness: Harness, request: SimulationProtocol.Frontend.Request) {\n switch (request.method) {\n case \"simulation.handshake\":\n return SimulationProtocol.Handshake.dispatch(\n {\n role: \"ui\",\n server: { name: \"opencode\", version: InstallationVersion },\n capabilities: SimulationProtocol.Frontend.Capabilities,\n },\n request.params,\n )\n case \"ui.capture\":\n return SimulationActions.capture(harness)\n case \"ui.screenshot\":\n return SimulationActions.screenshot(harness, request.params?.name)\n case \"ui.state\":\n return Effect.sync(() => SimulationActions.state(harness))\n case \"ui.snapshot\":\n return Effect.sync(() => SimulationActions.snapshot(harness))\n case \"ui.matches\":\n return Effect.sync(() => SimulationActions.matches(harness, request.params.text))\n case \"ui.recording.finish\":\n return SimulationRenderer.finish(harness.renderer)\n case \"ui.type\":\n return SimulationActions.execute(harness, { type: \"ui.type\", text: request.params.text })\n case \"ui.enter\":\n return SimulationActions.execute(harness, { type: \"ui.enter\" })\n case \"ui.press\":\n return SimulationActions.execute(harness, {\n type: \"ui.press\",\n key: request.params.key,\n modifiers: request.params.modifiers,\n })\n case \"ui.arrow\":\n return SimulationActions.execute(harness, { type: \"ui.arrow\", direction: request.params.direction })\n case \"ui.focus\":\n return SimulationActions.execute(harness, { type: \"ui.focus\", target: request.params.target })\n case \"ui.click\":\n return SimulationActions.execute(harness, {\n type: \"ui.click\",\n target: request.params.target,\n x: request.params.x,\n y: request.params.y,\n semantic: request.params.semantic,\n })\n case \"ui.resize\":\n return SimulationActions.execute(harness, {\n type: \"ui.resize\",\n cols: request.params.cols,\n rows: request.params.rows,\n })\n }\n}\n\nexport const start = Effect.fn(\"SimulationServer.start\")(function* (harness: Harness, endpoint: string) {\n return yield* SimulationControlServer.start({\n endpoint,\n label: \"opencode drive ui websocket\",\n data: () => ({ drive: true as const }),\n decode: SimulationProtocol.Frontend.decodeRequestEffect,\n handle: (_socket, request) => handle(harness, request),\n })\n})\n\nexport * as SimulationServer from \"./server\"\n", | ||
| "import { createCliRenderer, type CliRendererConfig } from \"@opentui/core\"\nimport { Config, Effect } from \"effect\"\nimport { DriveManifest } from \"../manifest\"\nimport { SimulationActions } from \"./actions\"\nimport { SimulationRenderer } from \"./renderer\"\nimport { SimulationServer } from \"./server\"\n\n/** Drive-mode renderer and control-server acquisition. */\nexport const create = Effect.fn(\"Drive.create\")(function* (options: CliRendererConfig) {\n const headless = (yield* Config.string(\"OPENCODE_DRIVE_RENDERER\").pipe(Config.withDefault(\"visible\"))) === \"headless\"\n const manifest = yield* DriveManifest.resolve()\n const renderer = headless\n ? yield* SimulationRenderer.create(options, manifest.recording?.timeline, manifest.viewport)\n : yield* Effect.acquireRelease(\n Effect.tryPromise(() => createCliRenderer(options)),\n (renderer) =>\n Effect.sync(() => {\n if (!renderer.isDestroyed) renderer.destroy()\n }),\n )\n if (!headless && manifest.viewport) renderer.resize(manifest.viewport.cols, manifest.viewport.rows)\n const server = yield* SimulationServer.start(SimulationActions.createHarness(renderer), manifest.endpoints.ui)\n yield* Effect.sync(() => process.stderr.write(`opencode drive ui websocket: ${server.url}\\n`))\n return renderer\n})\n\nexport * as Drive from \"./simulation\"\n" | ||
| ], | ||
| "mappings": ";6pBAAA,sBAAS,iBACT,uBAAS,gBAAS,kBAAM,wHCDxB,iCAAS,gBACT,gBAAS,oBACT,kBAAS,aACT,mBAAS,eACT,mBAAS,wBAGF,IAAM,EAAS,EAAO,OAAO,CAClC,KAAM,EAAO,QAAQ,QAAQ,EAC7B,QAAS,EAAO,QAAQ,CAAC,EACzB,KAAM,EAAO,OACb,KAAM,EAAO,OACb,SAAU,EAAO,QAAQ,QAAQ,CACnC,CAAC,EAGY,EAAS,EAAO,OAAO,CAClC,KAAM,EAAO,QAAQ,QAAQ,EAC7B,MAAO,EAAO,OACd,KAAM,EAAO,MACf,CAAC,EAGY,EAAS,EAAO,OAAO,CAClC,KAAM,EAAO,QAAQ,QAAQ,EAC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AG,EAAS,UAAU,EAAE,EAE7G,OADA,MAAO,EAAO,KAAK,IAAM,QAAQ,OAAO,MAAM,gCAAgC,EAAO;AAAA,CAAO,CAAC,EACtF,EACR", | ||
| "debugId": "082C19EA0CB93F2964756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/debug/agents.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { OpenCode } from \"@opencode-ai/client\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.debug.commands.agents,\n Effect.fn(\"cli.debug.agents\")(function* () {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const response = yield* Effect.promise(() => client.agent.list({ location: { directory: process.cwd() } }))\n process.stdout.write(\n JSON.stringify(\n response.data.toSorted((a, b) => a.id.localeCompare(b.id)),\n null,\n 2,\n ) + EOL,\n )\n }),\n)\n" | ||
| ], | ||
| "mappings": ";g6BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,WAAM,cAAS,YACjC,OAAO,QAAG,uBAAkB,OAAE,cAAU,OAAG,MACzC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,QADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EACpF,EAAW,MAAO,EAAO,QAAQ,IAAM,EAAO,MAAM,KAAK,CAAE,SAAU,CAAE,UAAW,QAAQ,IAAI,CAAE,CAAE,CAAC,CAAC,EAC1G,QAAQ,OAAO,MACb,KAAK,UACH,EAAS,KAAK,SAAS,CAAC,EAAG,IAAM,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,EACzD,KACA,CACF,EAAI,CACN,EACD,CACH", | ||
| "debugId": "FBD5446154631FCB64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/api.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect, Option } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { Service, type Endpoint } from \"@opencode-ai/client/effect/service\"\nimport { ServerConnection } from \"../../services/server-connection\"\n\nconst methods = new Set([\"delete\", \"get\", \"head\", \"options\", \"patch\", \"post\", \"put\"])\n\ntype Operation = {\n operationId?: string\n}\n\ntype OpenApi = {\n paths?: Record<string, Record<string, Operation>>\n}\n\nexport default Runtime.handler(\n Commands.commands.api,\n Effect.fn(\"cli.api\")(function* (input) {\n const server = yield* ServerConnection.resolve({\n server: Option.getOrUndefined(input.server),\n standalone: input.standalone,\n mismatch: \"ignore\",\n })\n const endpoint = server.endpoint\n const params = Option.getOrElse(input.param, () => ({}))\n const request = yield* resolveRequest(endpoint, input.request, params)\n const headers = new Headers(Service.headers(endpoint))\n for (const header of input.header) {\n const index = header.indexOf(\":\")\n if (index < 1) return yield* Effect.fail(new Error(`Invalid header, expected name:value: ${header}`))\n headers.set(header.slice(0, index).trim(), header.slice(index + 1).trim())\n }\n const body = Option.getOrUndefined(input.data)\n if (body !== undefined && !headers.has(\"content-type\")) headers.set(\"content-type\", \"application/json\")\n\n const response = yield* Effect.tryPromise(() =>\n fetch(new URL(request.path, endpoint.url), {\n method: request.method,\n headers,\n body,\n }),\n )\n const output = yield* Effect.promise(() => response.text())\n if (output) process.stdout.write(output + (output.endsWith(EOL) ? \"\" : EOL))\n }),\n)\n\nexport function resolveOperation(spec: OpenApi, operationID: string, params: Record<string, string>) {\n for (const [path, operations] of Object.entries(spec.paths ?? {})) {\n for (const [method, operation] of Object.entries(operations)) {\n if (!methods.has(method) || operation.operationId !== operationID) continue\n return { method: method.toUpperCase(), path: interpolate(path, params) }\n }\n }\n throw new Error(`Operation not found: ${operationID}`)\n}\n\nexport function rawRequest(input: readonly string[]) {\n if (input.length !== 2 || !methods.has(input[0].toLowerCase()) || !input[1].startsWith(\"/\")) return\n return { method: input[0].toUpperCase(), path: input[1] }\n}\n\nfunction resolveRequest(endpoint: Endpoint, input: readonly string[], params: Record<string, string>) {\n const raw = rawRequest(input)\n if (raw) return Effect.succeed(raw)\n if (input.length !== 1) return Effect.fail(new Error(\"Expected an operation name or an HTTP method and path\"))\n return Effect.tryPromise(async () => {\n const response = await fetch(new URL(\"/openapi.json\", endpoint.url), { headers: Service.headers(endpoint) })\n if (!response.ok) throw new Error(`Failed to load OpenAPI document: HTTP ${response.status}`)\n return resolveOperation((await response.json()) as OpenApi, input[0], params)\n })\n}\n\nfunction interpolate(path: string, params: Record<string, string>) {\n const used = new Set<string>()\n const pathname = path.replaceAll(/\\{([^}]+)\\}/g, (_, name: string) => {\n const value = params[name]\n if (value === undefined) throw new Error(`Missing path parameter: ${name}`)\n used.add(name)\n return encodeURIComponent(value)\n })\n const query = new URLSearchParams(Object.entries(params).filter(([name]) => !used.has(name))).toString()\n return query ? `${pathname}?${query}` : pathname\n}\n" | ||
| ], | ||
| "mappings": ";+9BAAA,mBAAS,gBAOT,SAAM,OAAU,SAAI,SAAI,MAAC,cAAU,WAAO,YAAQ,eAAW,aAAS,YAAQ,UAAK,MAAC,OAUrE,SAAQ,aACrB,OAAS,cAAS,SAClB,OAAO,QAAG,cAAS,OAAE,cAAU,CAAC,EAAO,CAMrC,IAAM,GALS,MAAO,EAAiB,QAAQ,CAC7C,OAAQ,EAAO,eAAe,EAAM,MAAM,EAC1C,WAAY,EAAM,WAClB,SAAU,QACZ,CAAC,GACuB,SAClB,EAAS,EAA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YAAY,CAAC,GAAK,CAAC,EAAM,GAAG,WAAW,GAAG,EAAG,OAC7F,MAAO,CAAE,OAAQ,EAAM,GAAG,YAAY,EAAG,KAAM,EAAM,EAAG,EAG1D,SAAS,CAAc,CAAC,EAAoB,EAA0B,EAAgC,CACpG,IAAM,EAAM,EAAW,CAAK,EAC5B,GAAI,EAAK,OAAO,EAAO,QAAQ,CAAG,EAClC,GAAI,EAAM,SAAW,EAAG,OAAO,EAAO,KAAS,MAAM,uDAAuD,CAAC,EAC7G,OAAO,EAAO,WAAW,SAAY,CACnC,IAAM,EAAW,MAAM,MAAM,IAAI,IAAI,gBAAiB,EAAS,GAAG,EAAG,CAAE,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAC3G,GAAI,CAAC,EAAS,GAAI,MAAU,MAAM,yCAAyC,EAAS,QAAQ,EAC5F,OAAO,EAAkB,MAAM,EAAS,KAAK,EAAe,EAAM,GAAI,CAAM,EAC7E,EAGH,SAAS,CAAW,CAAC,EAAc,EAAgC,CACjE,IAAM,EAAO,IAAI,IACX,EAAW,EAAK,WAAW,eAAgB,CAAC,EAAG,IAAiB,CACpE,IAAM,EAAQ,EAAO,GACrB,GAAI,IAAU,OAAW,MAAU,MAAM,2BAA2B,GAAM,EAE1E,OADA,EAAK,IAAI,CAAI,EACN,mBAAmB,CAAK,EAChC,EACK,EAAQ,IAAI,gBAAgB,OAAO,QAAQ,CAAM,EAAE,OAAO,EAAE,KAAU,CAAC,EAAK,IAAI,CAAI,CAAC,CAAC,EAAE,SAAS,EACvG,OAAO,EAAQ,GAAG,KAAY,IAAU", | ||
| "debugId": "DE615A60EE9BB2D064756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/restart.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.restart,\n Effect.fn(\"cli.service.restart\")(function* () {\n const options = yield* ServiceConfig.options()\n yield* Service.stop(options)\n const transport = yield* Service.ensure(options)\n process.stdout.write(transport.url + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";i3BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,aACnC,OAAO,QAAG,0BAAqB,OAAE,cAAU,OAAG,MAC5C,SAAM,OAAU,WAAO,OAAc,aAAQ,OAC7C,MAAO,EAAQ,KAAK,CAAO,EAC3B,IAAM,EAAY,MAAO,EAAQ,OAAO,CAAO,EAC/C,QAAQ,OAAO,MAAM,EAAU,IAAM,CAAG,EACzC,CACH", | ||
| "debugId": "9E17EC650CC6B0B664756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/mcp/list.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"node:os\"\nimport { Effect } from \"effect\"\nimport { OpenCode, type McpServer } from \"@opencode-ai/client\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.mcp.commands.list,\n Effect.fn(\"cli.mcp.list\")(function* () {\n const options = yield* ServiceConfig.options()\n const found = yield* Service.discover(options)\n const endpoint = found ?? (yield* Service.ensure(options))\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const response = yield* Effect.promise(() => client.mcp.list({ location: { directory: process.cwd() } }))\n const servers = response.data.toSorted((a, b) => a.name.localeCompare(b.name))\n if (servers.length === 0) {\n process.stdout.write(\"No MCP servers configured\" + EOL)\n return\n }\n const width = Math.max(...servers.map((server) => server.name.length))\n const lines = servers.map(\n (server) => `${icon(server.status)} ${server.name.padEnd(width)} ${describe(server.status)}`,\n )\n process.stdout.write(lines.join(EOL) + EOL)\n }),\n)\n\nfunction icon(status: McpServer[\"status\"]) {\n switch (status.status) {\n case \"connected\":\n return \"✓\"\n case \"needs_auth\":\n return \"⚠\"\n case \"failed\":\n case \"needs_client_registration\":\n return \"✗\"\n default:\n return \"○\"\n }\n}\n\nfunction describe(status: McpServer[\"status\"]) {\n switch (status.status) {\n case \"needs_auth\":\n return \"needs authentication\"\n case \"needs_client_registration\":\n return `needs client registration: ${status.error}`\n case \"failed\":\n return `failed: ${status.error}`\n default:\n return status.status\n }\n}\n" | ||
| ], | ||
| "mappings": ";g6BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,UAC/B,OAAO,QAAG,mBAAc,OAAE,cAAU,OAAG,MACrC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,QADQ,MAAO,EAAQ,SAAS,CAAO,KAClB,MAAO,EAAQ,OAAO,CAAO,GAClD,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAEpF,GADW,MAAO,EAAO,QAAQ,IAAM,EAAO,IAAI,KAAK,CAAE,SAAU,CAAE,UAAW,QAAQ,IAAI,CAAE,CAAE,CAAC,CAAC,GAC/E,KAAK,SAAS,CAAC,EAAG,IAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC,EAC7E,GAAI,EAAQ,SAAW,EAAG,CACxB,QAAQ,OAAO,MAAM,4BAA8B,CAAG,EACtD,OAEF,IAAM,EAAQ,KAAK,IAAI,GAAG,EAAQ,IAAI,CAAC,IAAW,EAAO,KAAK,MAAM,CAAC,EAC/D,EAAQ,EAAQ,IACpB,CAAC,IAAW,GAAG,EAAK,EAAO,MAAM,KAAK,EAAO,KAAK,OAAO,CAAK,MAAM,EAAS,EAAO,MAAM,GAC5F,EACA,QAAQ,OAAO,MAAM,EAAM,KAAK,CAAG,EAAI,CAAG,EAC3C,CACH,EAEA,SAAS,CAAI,CAAC,EAA6B,CACzC,OAAQ,EAAO,YACR,YACH,MAAO,aACJ,aACH,MAAO,aACJ,aACA,4BACH,MAAO,iBAEP,MAAO,UAIb,SAAS,CAAQ,CAAC,EAA6B,CAC7C,OAAQ,EAAO,YACR,aACH,MAAO,2BACJ,4BACH,MAAO,8BAA8B,EAAO,YACzC,SACH,MAAO,WAAW,EAAO,gBAEzB,OAAO,EAAO", | ||
| "debugId": "E62EFFBCF0E94EB964756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/services/standalone.ts", "src/services/server-connection.ts"], | ||
| "sourcesContent": [ | ||
| "import { Service, type Endpoint } from \"@opencode-ai/client/effect/service\"\nimport { CrossSpawnSpawner } from \"@opencode-ai/core/cross-spawn-spawner\"\nimport { LayerNode } from \"@opencode-ai/core/effect/layer-node\"\nimport { Deferred, Effect, Schema, Stream } from \"effect\"\nimport { ChildProcess, ChildProcessSpawner } from \"effect/unstable/process\"\nimport { randomBytes } from \"node:crypto\"\nimport { selfCommand } from \"../util/process\"\n\nconst Ready = Schema.Struct({ url: Schema.String })\nconst decodeReady = Schema.decodeUnknownPromise(Schema.fromJsonString(Ready))\n\ntype Options = {\n readonly command?: ReadonlyArray<string>\n}\n\nfunction command(password: string, options: Options) {\n const [executable, ...args] = options.command ?? [...selfCommand(), \"serve\"]\n if (!executable) throw new Error(\"Failed to resolve standalone server command\")\n return ChildProcess.make(executable, [...args, \"--stdio\", \"--port\", \"0\"], {\n cwd: process.cwd(),\n // Explicit entry wins over anything inherited, so a user-exported\n // OPENCODE_PASSWORD cannot shadow the child's lease credential.\n env: { OPENCODE_PASSWORD: password },\n extendEnv: true,\n // The server treats EOF on this pipe as the end of its ownership lease.\n // The OS closes it even when the TUI is killed before Effect finalizers run.\n stdin: \"pipe\",\n stderr: \"ignore\",\n killSignal: \"SIGTERM\",\n forceKillAfter: \"3 seconds\",\n })\n}\n\nconst makeEndpoint = Effect.fn(\"cli.standalone.endpoint\")(\n function* (options: Options) {\n const password = randomBytes(32).toString(\"base64url\")\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner\n const proc = yield* spawner.spawn(command(password, options))\n const readyLine = yield* Deferred.make<string, Error>()\n // Keep draining stdout after readiness so later server writes cannot hit EPIPE.\n yield* proc.stdout.pipe(\n Stream.decodeText(),\n Stream.splitLines,\n Stream.runForEach((line) => Deferred.succeed(readyLine, line)),\n Effect.ensuring(Deferred.fail(readyLine, new Error(\"Standalone server exited before reporting readiness\"))),\n Effect.forkScoped,\n )\n const output = yield* Deferred.await(readyLine)\n const ready = yield* Effect.tryPromise(() => decodeReady(output))\n return {\n url: ready.url,\n auth: { type: \"basic\" as const, username: \"opencode\", password },\n pid: proc.pid,\n } satisfies Endpoint & { readonly pid: number }\n },\n Effect.provide(LayerNode.compile(CrossSpawnSpawner.node)),\n)\n\nexport function start(options: Options = {}) {\n return makeEndpoint(options)\n}\n\nexport * as Standalone from \"./standalone\"\n", | ||
| "import { Service, type Endpoint, type EnsureOptions } from \"@opencode-ai/client/effect/service\"\nimport { ClientError, isUnauthorizedError, OpenCode } from \"@opencode-ai/client/promise\"\nimport { InstallationVersion } from \"@opencode-ai/core/installation/version\"\nimport { Effect, Redacted } from \"effect\"\nimport { Env } from \"../env\"\nimport { ServiceConfig } from \"./service-config\"\nimport { Standalone } from \"./standalone\"\n\nexport type Args = {\n readonly server?: string\n readonly standalone?: boolean\n readonly mismatch?: \"replace\" | \"ignore\" | \"error\"\n readonly onStart?: EnsureOptions[\"onStart\"]\n}\n\nexport type Resolved = {\n readonly endpoint: Endpoint\n readonly service?: ReturnType<typeof managedService>\n}\n\nexport const resolve = Effect.fn(\"cli.server-connection.resolve\")(function* (args: Args) {\n if (args.server !== undefined && args.standalone)\n return yield* Effect.fail(new Error(\"--server and --standalone cannot be combined\"))\n if (args.server !== undefined) {\n const password = yield* Env.password\n const endpoint = {\n url: args.server,\n auth: password ? { type: \"basic\" as const, username: \"opencode\", password: Redacted.value(password) } : undefined,\n } satisfies Endpoint\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const health = yield* Effect.tryPromise({\n try: () => client.health.get({ signal: AbortSignal.timeout(5_000) }),\n catch: (cause) => connectError(endpoint, cause),\n })\n if (health.version !== InstallationVersion)\n process.stderr.write(\n `Warning: Server at ${endpoint.url} has version ${health.version}; this client is ${InstallationVersion}. Continuing anyway.\\n`,\n )\n return { endpoint } satisfies Resolved\n }\n if (args.standalone) {\n return { endpoint: yield* Standalone.start() } satisfies Resolved\n }\n\n const options = yield* ServiceConfig.options()\n return {\n endpoint: yield* resolveManaged({ ...options, onStart: args.onStart }, args.mismatch ?? \"replace\"),\n service: managedService(options),\n } satisfies Resolved\n})\n\nfunction managedService(options: EnsureOptions) {\n const reconnectOptions = { ...options, version: undefined }\n return {\n reconnect: () => Service.ensure(reconnectOptions),\n restart: () =>\n Effect.gen(function* () {\n yield* Service.stop(options)\n yield* Service.ensure(reconnectOptions)\n }),\n }\n}\n\nconst resolveManaged = Effect.fnUntraced(function* (\n options: EnsureOptions,\n mismatch: NonNullable<Args[\"mismatch\"]>,\n) {\n if (mismatch === \"replace\") return yield* Service.ensure(options)\n if (mismatch === \"ignore\") return yield* Service.ensure({ ...options, version: undefined })\n\n const compatible = yield* Service.discover(options)\n if (compatible !== undefined) return compatible\n const existing = yield* Service.discover({ ...options, version: undefined })\n if (existing !== undefined)\n return yield* Effect.fail(new Error(\"Background server version does not match this client\"))\n return yield* Service.ensure(options)\n})\n\nfunction connectError(endpoint: Endpoint, cause: unknown) {\n if (isUnauthorizedError(cause)) {\n return new Error(\n endpoint.auth === undefined\n ? `Server at ${endpoint.url} requires a password; set OPENCODE_PASSWORD`\n : `Server at ${endpoint.url} rejected the password`,\n { cause },\n )\n }\n if (cause instanceof ClientError && cause.reason === \"Transport\")\n return new Error(`Could not reach server at ${endpoint.url}`, { cause })\n return new Error(`Server at ${endpoint.url} did not provide a compatible V2 health response`, { cause })\n}\n\nexport * as ServerConnection from \"./server-connection\"\n" | ||
| ], | ||
| "mappings": ";slBAKA,2BAAS,oBAGT,SAAM,OAAQ,OAAO,YAAO,MAAE,SAAK,EAAO,MAAO,CAAC,EAC5C,EAAc,EAAO,qBAAqB,EAAO,eAAe,CAAK,CAAC,EAM5E,SAAS,CAAO,CAAC,EAAkB,EAAkB,CACnD,IAAO,KAAe,GAAQ,EAAQ,SAAW,CAAC,GAAG,EAAY,EAAG,OAAO,EAC3E,GAAI,CAAC,EAAY,MAAU,MAAM,6CAA6C,EAC9E,OAAO,EAAa,KAAK,EAAY,CAAC,GAAG,EAAM,UAAW,SAAU,GAAG,EAAG,CACxE,IAAK,QAAQ,IAAI,EAGjB,IAAK,CAAE,kBAAmB,CAAS,EACnC,UAAW,GAGX,MAAO,OACP,OAAQ,SACR,WAAY,UACZ,eAAgB,WAClB,CAAC,EAGH,IAAM,EAAe,EAAO,GAAG,yBAAyB,EACtD,SAAU,CAAC,EAAkB,CAC3B,IAAM,EAAW,EAAY,EAAE,EAAE,SAAS,WAAW,EAE/C,EAAO,OADG,MAAO,EAAoB,qBACf,MAAM,EAAQ,EAAU,CAAO,CAAC,EACtD,EAAY,MAAO,EAAS,KAAoB,EAEtD,MAAO,EAAK,OAAO,KACjB,EAAO,WAAW,EAClB,EAAO,WACP,EAAO,WAAW,CAAC,IAAS,EAAS,QAAQ,EAAW,CAAI,CAAC,EAC7D,EAAO,SAAS,EAAS,KAAK,EAAe,MAAM,qDAAqD,CAAC,CAAC,EAC1G,EAAO,UACT,EACA,IAAM,EAAS,MAAO,EAAS,MAAM,CAAS,EAE9C,MAAO,CACL,KAFY,MAAO,EAAO,WAAW,IAAM,EAAY,CAAM,CAAC,GAEnD,IACX,KAAM,CAAE,KAAM,QAAkB,SAAU,WAAY,UAAS,EAC/D,IAAK,EAAK,GACZ,GAEF,EAAO,QAAQ,EAAU,QAAQ,EAAkB,IAAI,CAAC,CAC1D,EAE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EACvC,CACL,EAGF,IAAM,EAAiB,EAAO,WAAW,SAAU,CACjD,EACA,EACA,CACA,GAAI,IAAa,UAAW,OAAO,MAAO,EAAQ,OAAO,CAAO,EAChE,GAAI,IAAa,SAAU,OAAO,MAAO,EAAQ,OAAO,IAAK,EAAS,QAAS,MAAU,CAAC,EAE1F,IAAM,EAAa,MAAO,EAAQ,SAAS,CAAO,EAClD,GAAI,IAAe,OAAW,OAAO,EAErC,IADiB,MAAO,EAAQ,SAAS,IAAK,EAAS,QAAS,MAAU,CAAC,KAC1D,OACf,OAAO,MAAO,EAAO,KAAS,MAAM,sDAAsD,CAAC,EAC7F,OAAO,MAAO,EAAQ,OAAO,CAAO,EACrC,EAED,SAAS,CAAY,CAAC,EAAoB,EAAgB,CACxD,GAAI,EAAoB,CAAK,EAC3B,OAAW,MACT,EAAS,OAAS,OACd,aAAa,EAAS,iDACtB,aAAa,EAAS,4BAC1B,CAAE,OAAM,CACV,EAEF,GAAI,aAAiB,GAAe,EAAM,SAAW,YACnD,OAAW,MAAM,6BAA6B,EAAS,MAAO,CAAE,OAAM,CAAC,EACzE,OAAW,MAAM,aAAa,EAAS,sDAAuD,CAAE,OAAM,CAAC", | ||
| "debugId": "0D9B2C1D7B66B84464756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/pair.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { OpenCode } from \"@opencode-ai/client/promise\"\nimport { renderUnicodeCompact } from \"uqr\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { ServiceConfig } from \"../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.pair,\n Effect.fn(\"cli.pair\")(function* () {\n const endpoint = yield* Service.ensure(yield* ServiceConfig.options())\n const password = yield* ServiceConfig.password()\n const server = yield* Effect.tryPromise(() =>\n OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) }).server.get(),\n )\n const info = { urls: server.urls, username: \"opencode\", password }\n process.stdout.write(\n [\n \"\",\n ` URLs ${info.urls[0] ?? \"(none)\"}`,\n ...info.urls.slice(1).map((url) => ` ${url}`),\n ` Username ${info.username}`,\n ` Password ${info.password}`,\n \"\",\n \" Scan to pair\",\n \"\",\n renderUnicodeCompact(JSON.stringify(info), { border: 2 })\n .split(EOL)\n .map((line) => \" \" + line)\n .join(EOL),\n \"\",\n ].join(EOL) + EOL,\n )\n\n const hostname = new URL(endpoint.url).hostname\n if (![\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(hostname)) return\n process.stderr.write(\n ` Run \\`opencode service set hostname 0.0.0.0\\` to access the service remotely.${EOL}${EOL}`,\n )\n }),\n)\n" | ||
| ], | ||
| "mappings": ";+8BAAA,mBAAS,gBAST,SAAe,SAAQ,aACrB,OAAS,cAAS,UAClB,OAAO,QAAG,eAAU,OAAE,cAAU,OAAG,MACjC,SAAM,OAAW,WAAO,OAAQ,YAAO,WAAO,OAAc,aAAQ,MAAC,OAC/D,EAAW,MAAO,EAAc,SAAS,EAIzC,EAAO,CAAE,MAHA,MAAO,EAAO,WAAW,IACtC,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EAAE,OAAO,IAAI,CAC1F,GAC4B,KAAM,SAAU,WAAY,UAAS,EACjE,QAAQ,OAAO,MACb,CACE,GACA,eAAe,EAAK,KAAK,IAAM,WAC/B,GAAG,EAAK,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAQ,eAAe,GAAK,EACvD,eAAe,EAAK,WACpB,eAAe,EAAK,WACpB,GACA,iBACA,GACA,EAAqB,KAAK,UAAU,CAAI,EAAG,CAAE,OAAQ,CAAE,CAAC,EACrD,MAAM,CAAG,EACT,IAAI,CAAC,IAAS,KAAO,CAAI,EACzB,KAAK,CAAG,EACX,EACF,EAAE,KAAK,CAAG,EAAI,CAChB,EAEA,IAAM,EAAW,IAAI,IAAI,EAAS,GAAG,EAAE,SACvC,GAAI,CAAC,CAAC,YAAa,YAAa,OAAO,EAAE,SAAS,CAAQ,EAAG,OAC7D,QAAQ,OAAO,MACb,kFAAkF,IAAM,GAC1F,EACD,CACH", | ||
| "debugId": "B71FF73628071C4764756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
| { | ||
| "version": 3, | ||
| "sources": ["src/services/service-config.ts", "src/util/process.ts"], | ||
| "sourcesContent": [ | ||
| "import { Global } from \"@opencode-ai/core/global\"\nimport { InstallationChannel, InstallationVersion } from \"@opencode-ai/core/installation/version\"\nimport { Hash } from \"@opencode-ai/core/util/hash\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Effect, FileSystem, Option, Schema } from \"effect\"\nimport { randomBytes } from \"crypto\"\nimport path from \"path\"\nimport { selfCommand } from \"../util/process\"\n\n// The CLI's service configuration file, plus the Service.EnsureOptions binding that\n// points the client package's service operations at this CLI: which\n// registration file (by channel), which version, and how to spawn opencode.\n\nexport const Info = Schema.Struct({\n hostname: Schema.optional(Schema.String),\n port: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(65_535))),\n password: Schema.optional(Schema.String),\n})\nexport type Info = typeof Info.Type\n\nconst keys = [\"hostname\", \"port\", \"password\"] as const\ntype Key = (typeof keys)[number]\n\nconst decodeInfo = Schema.decodeUnknownEffect(Schema.fromJsonString(Info))\nconst decodeRegistration = Schema.decodeUnknownEffect(Schema.fromJsonString(Service.Info))\n\nexport function filename(channel = InstallationChannel) {\n if (channel === \"latest\") return \"service.json\"\n if (channel === \"local\") return \"service-local.json\"\n return `service-${Hash.fast(channel)}.json`\n}\n\nexport function defaultPort(channel = InstallationChannel) {\n if (channel === \"latest\") return 0xc0de\n if (channel === \"local\") return 0xc0df\n return 10_000 + (Number.parseInt(Hash.fast(channel).slice(0, 8), 16) % 50_000)\n}\n\nexport function versionBelongsToChannel(\n version: string | undefined,\n channel = InstallationChannel,\n installedVersion = InstallationVersion,\n) {\n if (version === undefined) return false\n if (version === installedVersion) return true\n const prefix = `0.0.0-${channel}-`\n if (!version.startsWith(prefix)) return false\n return /^\\d+(?:\\.\\d+)?$/.test(version.slice(prefix.length))\n}\n\nexport const migrateRegistration = Effect.fnUntraced(function* (\n legacy: string,\n file: string,\n channel = InstallationChannel,\n installedVersion = InstallationVersion,\n) {\n if (channel === \"latest\" || channel === \"local\") return\n const fs = yield* FileSystem.FileSystem\n const text = yield* fs.readFileString(legacy).pipe(Effect.option)\n if (Option.isNone(text)) return\n const registration = yield* decodeRegistration(text.value).pipe(Effect.option)\n if (Option.isNone(registration)) return\n if (!versionBelongsToChannel(registration.value.version, channel, installedVersion)) return\n yield* fs.writeFileString(file, text.value, { flag: \"wx\", mode: 0o600 }).pipe(Effect.ignore)\n})\n\nfunction configKey(key: string): Key {\n if (key === \"hostname\" || key === \"port\" || key === \"password\") return key\n throw new Error(`Unknown service config key: ${key}`)\n}\n\nconst paths = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem\n const global = yield* Global.Service\n const name = filename()\n const file = path.join(global.state, name)\n return {\n fs,\n file,\n legacyFile: path.join(global.state, \"service.json\"),\n configFile: path.join(global.config, name),\n }\n})\n\nexport const options = Effect.fnUntraced(function* () {\n const { file, legacyFile } = yield* paths\n yield* migrateRegistration(legacyFile, file)\n return {\n file,\n version: InstallationVersion,\n command: [...selfCommand(), \"serve\", \"--service\"],\n }\n})\n\nexport const read = Effect.fn(\"cli.service-config.read\")(function* () {\n const { fs, configFile } = yield* paths\n return yield* fs.readFileString(configFile).pipe(\n Effect.flatMap(decodeInfo),\n Effect.catch(() => Effect.succeed({} as Info)),\n )\n})\n\nconst write = Effect.fn(\"cli.service-config.write\")(function* (value: Info) {\n const { fs, configFile } = yield* paths\n const temp = configFile + \".tmp\"\n yield* fs.makeDirectory(path.dirname(configFile), { recursive: true })\n yield* fs.writeFileString(temp, JSON.stringify(value, null, 2) + \"\\n\", { mode: 0o600 })\n yield* fs.rename(temp, configFile)\n})\n\nexport const password = Effect.fn(\"cli.service-config.password\")(function* (value?: string) {\n const existing = yield* read()\n if (value === undefined && existing.password) return existing.password\n const next = value ?? randomBytes(32).toString(\"base64url\")\n\n // Keep one private credential across server restarts so discovered clients\n // can reconnect without exposing a password flag or environment variable.\n yield* write({ ...existing, password: next })\n return next\n})\n\nexport const get = Effect.fn(\"cli.service-config.get\")(function* (key?: string) {\n if (key === undefined) {\n const { password: _password, ...safe } = yield* read()\n return JSON.stringify(safe, null, 2)\n }\n switch (configKey(key)) {\n case \"hostname\": {\n return (yield* read()).hostname ?? \"\"\n }\n case \"port\": {\n const port = (yield* read()).port\n return port === undefined ? \"\" : String(port)\n }\n case \"password\": {\n return yield* password()\n }\n }\n throw new Error(`Unknown service config key: ${key}`)\n})\n\nexport const set = Effect.fn(\"cli.service-config.set\")(function* (key: string, value: string) {\n switch (configKey(key)) {\n case \"hostname\": {\n yield* Service.stop(yield* options())\n yield* write({ ...(yield* read()), hostname: value })\n return\n }\n case \"port\": {\n const port = Number(value)\n if (!Number.isInteger(port) || port < 1 || port > 65_535) throw new Error(\"Port must be between 1 and 65535\")\n yield* Service.stop(yield* options())\n yield* write({ ...(yield* read()), port })\n return\n }\n case \"password\": {\n yield* Service.stop(yield* options())\n yield* password(value)\n return\n }\n }\n})\n\nexport const unset = Effect.fn(\"cli.service-config.unset\")(function* (key: string) {\n switch (configKey(key)) {\n case \"hostname\": {\n yield* Service.stop(yield* options())\n const { hostname: _hostname, ...next } = yield* read()\n yield* write(next)\n return\n }\n case \"port\": {\n yield* Service.stop(yield* options())\n const { port: _port, ...next } = yield* read()\n yield* write(next)\n return\n }\n case \"password\": {\n yield* Service.stop(yield* options())\n const { password: _password, ...next } = yield* read()\n yield* write(next)\n return\n }\n }\n})\n\nexport * as ServiceConfig from \"./service-config\"\n", | ||
| "import path from \"node:path\"\n\nexport function selfCommand() {\n const runtime = path.basename(process.execPath, path.extname(process.execPath)).toLowerCase()\n if (runtime !== \"bun\" && runtime !== \"node\" && runtime !== \"nodejs\") return [process.execPath]\n if (!process.argv[1]) throw new Error(\"Failed to resolve CLI entrypoint\")\n if (runtime === \"node\" || runtime === \"nodejs\") return [process.execPath, ...nodeFlags(), process.argv[1]]\n return [process.execPath, process.argv[1]]\n}\n\nfunction nodeFlags() {\n return process.execArgv.flatMap((arg, index, args) => {\n if (index > 0 && args[index - 1] === \"--conditions\") return []\n if (arg === \"--conditions\") return args[index + 1] ? [arg, args[index + 1]] : []\n if (arg.startsWith(\"--conditions=\")) return [arg]\n if (\n arg === \"--experimental-ffi\" ||\n arg === \"--use-system-ca\" ||\n arg === \"--enable-source-maps\" ||\n arg === \"--no-addons\"\n )\n return [arg]\n if (arg === \"--no-warnings\" || arg.startsWith(\"--disable-warning=\")) return [arg]\n return []\n })\n}\n" | ||
| ], | ||
| "mappings": ";weAKA,2BAAS,oBACT,yBCNA,yBAEO,SAAS,CAAW,EAAG,CAC5B,IAAM,EAAU,EAAK,SAAS,QAAQ,SAAU,EAAK,QAAQ,QAAQ,QAAQ,CAAC,EAAE,YAAY,EAC5F,GAAI,IAAY,OAAS,IAAY,QAAU,IAAY,SAAU,MAAO,CAAC,QAAQ,QAAQ,EAC7F,GAAI,CAAC,QAAQ,KAAK,GAAI,MAAU,MAAM,kCAAkC,EACxE,GAAI,IAAY,QAAU,IAAY,SAAU,MAAO,CAAC,QAAQ,SAAU,GAAG,EAAU,EAAG,QAAQ,KAAK,EAAE,EACzG,MAAO,CAAC,QAAQ,SAAU,QAAQ,KAAK,EAAE,EAG3C,SAAS,CAAS,EAAG,CACnB,OAAO,QAAQ,SAAS,QAAQ,CAAC,EAAK,EAAO,IAAS,CACpD,GAAI,EAAQ,GAAK,EAAK,EAAQ,KAAO,eAAgB,MAAO,CAAC,EAC7D,GAAI,IAAQ,eAAgB,OAAO,EAAK,EAAQ,GAAK,CAAC,EAAK,EAA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,CACX,IAAM,EAAO,OAAO,CAAK,EACzB,GAAI,CAAC,OAAO,UAAU,CAAI,GAAK,EAAO,GAAK,EAAO,MAAQ,MAAU,MAAM,kCAAkC,EAC5G,MAAO,EAAQ,KAAK,MAAO,EAAQ,CAAC,EACpC,MAAO,EAAM,IAAM,MAAO,EAAK,EAAI,MAAK,CAAC,EACzC,MACF,KACK,WAAY,CACf,MAAO,EAAQ,KAAK,MAAO,EAAQ,CAAC,EACpC,MAAO,EAAS,CAAK,EACrB,MACF,GAEH,EAEY,EAAQ,EAAO,GAAG,0BAA0B,EAAE,SAAU,CAAC,EAAa,CACjF,OAAQ,EAAU,CAAG,OACd,WAAY,CACf,MAAO,EAAQ,KAAK,MAAO,EAAQ,CAAC,EACpC,IAAQ,SAAU,KAAc,GAAS,MAAO,EAAK,EACrD,MAAO,EAAM,CAAI,EACjB,MACF,KACK,OAAQ,CACX,MAAO,EAAQ,KAAK,MAAO,EAAQ,CAAC,EACpC,IAAQ,KAAM,KAAU,GAAS,MAAO,EAAK,EAC7C,MAAO,EAAM,CAAI,EACjB,MACF,KACK,WAAY,CACf,MAAO,EAAQ,KAAK,MAAO,EAAQ,CAAC,EACpC,IAAQ,SAAU,KAAc,GAAS,MAAO,EAAK,EACrD,MAAO,EAAM,CAAI,EACjB,MACF,GAEH", | ||
| "debugId": "E4FDDD79810F148864756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/set.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect } from \"effect\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.set,\n Effect.fn(\"cli.service.set\")(function* (input) {\n yield* ServiceConfig.set(input.key, input.value)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";o2BAKA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,SACnC,OAAO,QAAG,sBAAiB,OAAE,cAAU,MAAC,OAAO,MAC7C,WAAO,OAAc,SAAI,OAAM,SAAK,OAAM,UAAK,EAChD,CACH", | ||
| "debugId": "56067E2425DCF85764756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/run/run.ts", "src/run/noninteractive.ts", "src/run/ui.ts"], | ||
| "sourcesContent": [ | ||
| "import { Service, type Endpoint } from \"@opencode-ai/client/effect/service\"\nimport { OpenCode, type OpenCodeClient, type SessionMessageAssistantTool } from \"@opencode-ai/client/promise\"\nimport { FSUtil } from \"@opencode-ai/core/fs-util\"\nimport { open } from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { readStdin } from \"../util/io\"\nimport { ServerConnection } from \"../services/server-connection\"\nimport { waitForCatalogReady } from \"../services/catalog\"\nimport { parseSessionTargetModel, resolveSessionTarget } from \"../session-target\"\nimport { toolInlineInfo } from \"@opencode-ai/tui/mini/tool\"\nimport { runNonInteractivePrompt } from \"./noninteractive\"\nimport { UI } from \"./ui\"\n\nexport type RunCommandInput = {\n server: ServerConnection.Resolved\n message: string[]\n continue?: boolean\n session?: string\n fork?: boolean\n model?: string\n agent?: string\n format: \"default\" | \"json\"\n file: string[]\n title?: string\n thinking?: boolean\n auto?: boolean\n}\n\ntype FilePart = {\n url: string\n filename: string\n mime: string\n}\n\ntype Prepared = {\n directory?: string\n message: string\n files: FilePart[]\n}\n\ntype ExecutionOptions = {\n root?: string\n directory?: string\n useServerDirectory?: boolean\n variant?: string\n attached?: boolean\n compatibility?: \"v1\"\n}\n\nclass RunTargetError extends Error {\n constructor(\n message: string,\n readonly sessionID?: string,\n ) {\n super(message)\n }\n}\n\nconst ATTACH_FILE_MAX_BYTES = 10 * 1024 * 1024\n\nexport function runNonInteractive(input: RunCommandInput) {\n return runNonInteractiveWithOptions(input, {})\n}\n\n/** @internal Used only by the V1 command boundary. */\nexport function runNonInteractiveWithOptions(input: RunCommandInput, options: ExecutionOptions) {\n return run(input, options).catch((error) => reportRunError(input, errorMessage(error)))\n}\n\nasync function run(input: RunCommandInput, options: ExecutionOptions) {\n if (input.fork && !input.continue && !input.session) fail(\"--fork requires --continue or --session\")\n const root = options.root ?? process.env.PWD ?? process.cwd()\n const local = localDirectory(root)\n const directory = options.useServerDirectory ? undefined : (options.directory ?? local)\n const message = mergeInput(formatMessage(input.message), process.stdin.isTTY ? undefined : await readStdin())\n if (!message?.trim()) fail(\"You must provide a message\")\n const files = await Promise.all(input.file.map((file) => prepareFile(file, root, options)))\n const prepared = { directory, message, files }\n return execute(input, prepared, input.server.endpoint, options)\n}\n\nasync function execute(input: RunCommandInput, prepared: Prepared, endpoint: Endpoint, options: ExecutionOptions) {\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const explicit = parseRunModel(input.model)\n const target = await resolveSessionTarget({\n client,\n location: prepared.directory ? { directory: prepared.directory } : undefined,\n continue: input.continue,\n session: input.session,\n fork: input.fork,\n model: explicit\n ? { providerID: explicit.model.providerID, id: explicit.model.modelID, variant: explicit.variant }\n : undefined,\n agent: input.agent,\n prepare: async (next) => {\n const selected =\n next.model ??\n (await client.model\n .default({ location: { directory: next.location.directory, workspace: next.location.workspaceID } })\n .then((result) => result.data))\n const model = selected\n ? {\n providerID: selected.providerID,\n id: selected.id,\n variant: options.variant ?? (\"variant\" in selected ? selected.variant : undefined),\n }\n : undefined\n if ((options.variant ?? explicit?.variant) && !model)\n throw new RunTargetError(\"Cannot select a variant before selecting a model\", next.session?.id)\n if (model) {\n await waitForCatalogReady({\n sdk: client,\n directory: next.location.directory,\n workspace: next.location.workspaceID,\n model: { providerID: model.providerID, modelID: model.id },\n })\n const available = await client.model.list({\n location: { directory: next.location.directory, workspace: next.location.workspaceID },\n })\n if (!available.data.some((item) => item.providerID === model.providerID && item.id === model.id))\n throw new RunTargetError(`Model unavailable: ${model.providerID}/${model.id}`, next.session?.id)\n }\n return {\n model,\n agent: input.agent\n ? await validateAgent(client, next.location.directory, next.location.workspaceID, input.agent)\n : next.agent,\n }\n },\n }).catch((error) => {\n if (!(error instanceof RunTargetError)) throw error\n reportRunError(input, error.message, error.sessionID)\n return undefined\n })\n if (!target) return\n const model = target.model ? { providerID: target.model.providerID, modelID: target.model.id } : undefined\n const variant = target.model?.variant\n if (!target.resume && input.title !== undefined) {\n await client.session.rename({\n sessionID: target.session.id,\n title: input.title || prepared.message.slice(0, 50) + (prepared.message.length > 50 ? \"...\" : \"\"),\n })\n }\n\n await runNonInteractivePrompt({\n client,\n sessionID: target.session.id,\n location: target.location,\n message: prepared.message,\n files: prepared.files,\n agent: target.agent,\n model,\n variant,\n thinking: input.thinking ?? false,\n format: input.format,\n auto: input.auto ?? false,\n attached: options.attached ?? true,\n compatibility: options.compatibility,\n renderTool: (part) => renderTool(part, target.location.directory),\n renderToolError: (part) => renderToolError(part, target.location.directory),\n }).catch((error) => reportRunError(input, errorMessage(error), target.session.id))\n}\n\nexport function mergeInput(message: string | undefined, piped: string | undefined) {\n if (!message) return piped || undefined\n if (!piped) return message\n return message + \"\\n\" + piped\n}\n\nfunction formatMessage(message: string[]) {\n const value = message.map((part) => (part.includes(\" \") ? `\"${part.replace(/\"/g, '\\\\\"')}\"` : part)).join(\" \")\n return value || undefined\n}\n\nfunction localDirectory(root: string) {\n try {\n process.chdir(root)\n return process.cwd()\n } catch {\n fail(`Failed to change directory to ${root}`)\n }\n}\n\nexport function parseRunModel(value?: string) {\n const ref = parseSessionTargetModel(value)\n if (!ref) return\n return {\n model: { providerID: ref.providerID, modelID: ref.id },\n variant: ref.variant,\n }\n}\n\nasync function validateAgent(client: OpenCodeClient, directory: string, workspace: string | undefined, name?: string) {\n if (!name) return\n const agents = await client.agent\n .list({ location: { directory, workspace } })\n .then((result) => result.data)\n .catch(() => undefined)\n if (!agents) {\n warning(\"failed to list agents. Falling back to default agent\")\n return\n }\n const agent = agents.find((item) => item.id === name)\n if (!agent) {\n warning(`agent \"${name}\" not found. Falling back to default agent`)\n return\n }\n if (agent.mode === \"subagent\") {\n warning(`agent \"${name}\" is a subagent, not a primary agent. Falling back to default agent`)\n return\n }\n return name\n}\n\nasync function prepareFile(input: string, directory: string, options: ExecutionOptions): Promise<FilePart> {\n const file = path.resolve(directory, input)\n const handle = await open(file, \"r\").catch(() => fail(`File not found: ${input}`))\n try {\n const stat = await handle.stat()\n if (options.compatibility === \"v1\" && options.attached && stat.isDirectory())\n fail(`Cannot attach local directory without a shared filesystem: ${input}`)\n if (!stat.isFile() || stat.size > ATTACH_FILE_MAX_BYTES)\n fail(`Cannot attach a directory, special file, or file larger than 10 MiB: ${input}`)\n const content = Buffer.alloc(Number(stat.size))\n let offset = 0\n while (offset < content.length) {\n const read = await handle.read(content, offset, content.length - offset, offset)\n if (read.bytesRead === 0) break\n offset += read.bytesRead\n }\n const bytes = content.subarray(0, offset)\n const detected = FSUtil.mimeType(file)\n const text = bytes.toString(\"utf8\")\n const mime =\n detected.startsWith(\"image/\") || detected === \"application/pdf\"\n ? detected\n : !isBinaryContent(bytes) && Buffer.from(text, \"utf8\").equals(bytes)\n ? \"text/plain\"\n : detected\n return {\n url: `data:${mime};base64,${bytes.toString(\"base64\")}`,\n filename: path.basename(file),\n mime,\n }\n } finally {\n await handle.close()\n }\n}\n\nfunction isBinaryContent(bytes: Uint8Array) {\n if (bytes.length === 0) return false\n if (bytes.includes(0)) return true\n return bytes.reduce((count, byte) => count + Number(byte < 9 || (byte > 13 && byte < 32)), 0) / bytes.length > 0.3\n}\n\nasync function renderTool(part: SessionMessageAssistantTool, directory: string) {\n const info = toolInlineInfo(part, directory)\n if (info.mode === \"block\") {\n UI.empty()\n UI.println(UI.Style.TEXT_NORMAL + info.icon, UI.Style.TEXT_NORMAL + info.title)\n if (info.body?.trim()) UI.println(info.body)\n UI.empty()\n return\n }\n UI.println(\n UI.Style.TEXT_NORMAL + info.icon,\n UI.Style.TEXT_NORMAL + info.title,\n info.description ? UI.Style.TEXT_DIM + info.description + UI.Style.TEXT_NORMAL : \"\",\n )\n}\n\nasync function renderToolError(part: SessionMessageAssistantTool, directory: string) {\n const info = toolInlineInfo(part, directory)\n UI.println(UI.Style.TEXT_NORMAL + \"✗\", UI.Style.TEXT_NORMAL + `${info.title} failed`)\n}\n\nfunction warning(message: string) {\n UI.println(UI.Style.TEXT_WARNING_BOLD + \"!\", UI.Style.TEXT_NORMAL, message)\n}\n\nfunction errorMessage(error: unknown) {\n if (error instanceof Error) return error.message\n if (typeof error === \"object\" && error !== null && \"message\" in error && typeof error.message === \"string\")\n return error.message\n return String(error)\n}\n\n/** @internal Used by the V1 command boundary before a Session exists. */\nexport function reportRunError(input: Pick<RunCommandInput, \"format\">, message: string, sessionID?: string) {\n process.exitCode = 1\n if (input.format === \"json\") {\n process.stdout.write(\n JSON.stringify({\n type: \"error\",\n timestamp: Date.now(),\n sessionID: sessionID ?? \"\",\n error: { type: \"unknown\", message },\n }) + \"\\n\",\n )\n return\n }\n UI.error(message)\n}\n\nfunction fail(message: string): never {\n throw new Error(message)\n}\n", | ||
| "import type {\n EventSubscribeOutput,\n JsonValue,\n LLMToolContent,\n LocationRef,\n OpenCodeClient,\n SessionMessageAssistantTool,\n} from \"@opencode-ai/client/promise\"\nimport { SessionMessage } from \"@opencode-ai/schema/session-message\"\nimport { EOL } from \"node:os\"\nimport { readFile } from \"node:fs/promises\"\nimport { toolOutputText, type MiniToolPart } from \"@opencode-ai/tui/mini/tool\"\nimport { UI } from \"./ui\"\n\ntype Model = {\n providerID: string\n modelID: string\n}\n\ntype File = {\n url: string\n filename: string\n mime: string\n}\n\ntype Input = {\n client: OpenCodeClient\n sessionID: string\n location: LocationRef\n message: string\n files: File[]\n agent?: string\n model?: Model\n variant?: string\n thinking: boolean\n format: \"default\" | \"json\"\n auto: boolean\n /** True when the client is attached to a shared server rather than an exclusive in-process one. */\n attached: boolean\n compatibility?: \"v1\"\n renderTool: (part: SessionMessageAssistantTool) => Promise<void>\n renderToolError: (part: SessionMessageAssistantTool) => Promise<void>\n}\n\ntype StartedPart = {\n id: string\n timestamp: number\n}\n\ntype ToolState = StartedPart & {\n assistantMessageID: string\n tool: string\n input: Record<string, JsonValue>\n raw?: string\n provider?: unknown\n providerState?: SessionMessageAssistantTool[\"providerState\"]\n structured: Record<string, JsonValue>\n content: LLMToolContent[]\n}\n\ntype V2Event = EventSubscribeOutput\ntype FormRequest = Extract<V2Event, { type: \"form.created\" }>[\"data\"][\"form\"]\n\n// MCP elicitations are temporarily owned by the \"global\" sentinel instead of a real\n// session. An exclusive local process may treat them as this run's blockers; an\n// attached client must not cancel input that may belong to another session.\nconst GLOBAL_FORM_SESSION_ID = \"global\"\n\nexport async function runNonInteractivePrompt(input: Input) {\n const controller = new AbortController()\n const stream = input.client.event.subscribe({ signal: controller.signal })[Symbol.asyncIterator]()\n const connected = await stream.next()\n if (connected.done) throw new Error(\"Event stream disconnected before prompt admission\")\n\n const messageID = SessionMessage.ID.create()\n const starts = new Map<string, StartedPart>()\n const tools = new Map<string, ToolState>()\n let submitted = false\n let promoted = false\n let emittedError = false\n let permissionRejected = false\n let formCancelled = false\n let interrupted = false\n let v1InvalidOutput = false\n let admission: AbortController | undefined\n let pendingStep: { timestamp: number; part: Record<string, unknown>; label: string } | undefined\n\n const emit = (type: string, timestamp: number, data: Record<string, unknown>) => {\n if (input.format !== \"json\") return false\n process.stdout.write(JSON.stringify({ type, timestamp, sessionID: input.sessionID, ...data }) + EOL)\n return true\n }\n\n const writeText = (part: { text: string; [key: string]: unknown }, timestamp: number) => {\n if (emit(\"text\", timestamp, { part })) return\n const text = part.text.trim()\n if (!text) return\n if (!process.stdout.isTTY) {\n process.stdout.write(text + EOL)\n return\n }\n UI.empty()\n UI.println(text)\n UI.empty()\n }\n\n const flushStep = () => {\n if (!pendingStep) return\n const value = pendingStep\n pendingStep = undefined\n if (!emit(\"step_start\", value.timestamp, { part: value.part }) && input.format !== \"json\") {\n UI.empty()\n UI.println(value.label)\n UI.empty()\n }\n }\n\n const replyPermission = async (request: { id: string; action: string; resources: ReadonlyArray<string> }) => {\n if (!input.auto) {\n permissionRejected = true\n UI.println(\n UI.Style.TEXT_WARNING_BOLD + \"!\",\n UI.Style.TEXT_NORMAL +\n `permission requested: ${request.action} (${request.resources.join(\", \")}); auto-rejecting`,\n )\n }\n await input.client.permission\n .reply({\n sessionID: input.sessionID,\n requestID: request.id,\n reply: input.auto ? \"once\" : \"reject\",\n })\n .catch(() => {})\n if (!input.auto) {\n await input.client.session.interrupt({ sessionID: input.sessionID }).catch(() => {})\n }\n }\n\n const cancelForm = async (request: Pick<FormRequest, \"id\" | \"sessionID\">) => {\n try {\n await input.client.form.cancel(\n { sessionID: request.sessionID, formID: request.id },\n ...formRequestOptions(request.sessionID === GLOBAL_FORM_SESSION_ID ? input.location : undefined),\n )\n } catch (error) {\n if (!formAlreadySettled(error)) throw error\n }\n formCancelled = true\n }\n\n const consume = async () => {\n while (!controller.signal.aborted) {\n const next = await stream.next().catch((error) => {\n if (!emittedError) throw error\n return { done: true as const, value: undefined }\n })\n if (next.done) {\n if (emittedError) return\n throw new Error(\"Event stream disconnected during prompt execution\")\n }\n const event = next.value\n\n if (event.type === \"permission.v2.asked\" && submitted && event.data.sessionID === input.sessionID) {\n await replyPermission(event.data)\n continue\n }\n if (\n event.type === \"form.created\" &&\n submitted &&\n (event.data.form.sessionID === input.sessionID ||\n (!input.attached &&\n event.data.form.sessionID === GLOBAL_FORM_SESSION_ID &&\n sameLocation(event.location, input.location)))\n ) {\n await cancelForm(event.data.form)\n continue\n }\n if (!(\"sessionID\" in event.data) || event.data.sessionID !== input.sessionID) continue\n const time = toMillis(\"created\" in event ? event.created : undefined)\n\n if (event.type === \"session.input.promoted\") {\n if (event.data.inputID === messageID) {\n promoted = true\n continue\n }\n }\n if (\n event.type === \"session.execution.interrupted\" &&\n event.data.reason === \"user\" &&\n (interrupted || permissionRejected || formCancelled)\n ) {\n return\n }\n if (!promoted) continue\n\n if (event.type === \"session.step.started\") {\n const part = {\n id: partID(event.id),\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"step-start\",\n snapshot: event.data.snapshot,\n }\n if (input.compatibility === \"v1\") {\n pendingStep = {\n timestamp: time,\n part,\n label: `> ${event.data.agent} · ${event.data.model.id}`,\n }\n continue\n }\n if (!emit(\"step_start\", time, { part }) && input.format !== \"json\") {\n UI.empty()\n UI.println(`> ${event.data.agent} · ${event.data.model.id}`)\n UI.empty()\n }\n continue\n }\n\n if (event.type === \"session.text.started\") {\n flushStep()\n starts.set(\"text\", { id: partID(event.id), timestamp: time })\n continue\n }\n if (event.type === \"session.text.ended\") {\n const started = starts.get(\"text\")\n starts.delete(\"text\")\n const part = {\n id: started?.id ?? partID(event.id),\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"text\",\n text: event.data.text,\n time: { start: started?.timestamp ?? time, end: time },\n }\n writeText(part, time)\n continue\n }\n\n if (event.type === \"session.reasoning.started\") {\n flushStep()\n starts.set(\"reasoning\", { id: partID(event.id), timestamp: time })\n continue\n }\n if (event.type === \"session.reasoning.ended\" && input.thinking) {\n const started = starts.get(\"reasoning\")\n starts.delete(\"reasoning\")\n const part = {\n id: started?.id ?? partID(event.id),\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"reasoning\",\n text: event.data.text,\n metadata: event.data.state,\n time: { start: started?.timestamp ?? time, end: time },\n }\n if (emit(\"reasoning\", time, { part })) continue\n const text = part.text.trim()\n if (!text) continue\n const line = `Thinking: ${text}`\n if (!process.stdout.isTTY) {\n process.stdout.write(line + EOL)\n continue\n }\n UI.empty()\n UI.println(`${UI.Style.TEXT_DIM}\\u001b[3m${line}\\u001b[0m${UI.Style.TEXT_NORMAL}`)\n UI.empty()\n continue\n }\n\n if (event.type === \"session.tool.input.started\") {\n flushStep()\n tools.set(toolKey(event.data.assistantMessageID, event.data.callID), {\n id: partID(event.id),\n timestamp: time,\n assistantMessageID: event.data.assistantMessageID,\n tool: event.data.name,\n input: {},\n structured: {},\n content: [],\n })\n continue\n }\n if (event.type === \"session.tool.input.ended\") {\n const current = tools.get(toolKey(event.data.assistantMessageID, event.data.callID))\n if (current) current.raw = event.data.text\n continue\n }\n if (event.type === \"session.tool.input.delta\") {\n const current = tools.get(toolKey(event.data.assistantMessageID, event.data.callID))\n if (current) current.raw = (current.raw ?? \"\") + event.data.delta\n continue\n }\n if (event.type === \"session.tool.called\") {\n flushStep()\n const key = toolKey(event.data.assistantMessageID, event.data.callID)\n const current = tools.get(key)\n tools.set(key, {\n id: current?.id ?? partID(event.id),\n timestamp: current?.timestamp ?? time,\n assistantMessageID: event.data.assistantMessageID,\n tool: current?.tool ?? \"tool\",\n input: event.data.input,\n raw: current?.raw,\n provider: { executed: event.data.executed, state: event.data.state },\n providerState: event.data.state,\n structured: {},\n content: [],\n })\n continue\n }\n if (event.type === \"session.tool.progress\") {\n const current = tools.get(toolKey(event.data.assistantMessageID, event.data.callID))\n if (current) {\n current.structured = event.data.structured\n current.content = event.data.content\n }\n continue\n }\n if (event.type === \"session.tool.success\") {\n const key = toolKey(event.data.assistantMessageID, event.data.callID)\n const current = tools.get(key) ?? fallbackTool(event)\n const tool: SessionMessageAssistantTool = {\n type: \"tool\",\n id: event.data.callID,\n name: current.tool,\n executed: event.data.executed,\n providerState: current.providerState,\n providerResultState: event.data.resultState,\n state: {\n status: \"completed\",\n input: current.input,\n structured: event.data.structured,\n content: event.data.content,\n result: event.data.result,\n },\n time: { created: current.timestamp, ran: current.timestamp, completed: time },\n }\n const part: MiniToolPart = {\n id: current.id,\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"tool\",\n callID: event.data.callID,\n tool: current.tool,\n state: {\n status: \"completed\",\n input: current.input,\n output: toolOutputText(current.tool, event.data.content),\n title: current.tool,\n metadata: {\n structured: event.data.structured,\n content: event.data.content,\n result: event.data.result,\n providerCall: current.provider,\n providerResult: { executed: event.data.executed, state: event.data.resultState },\n rawInput: current.raw,\n },\n time: { start: current.timestamp, end: time },\n },\n }\n tools.delete(key)\n if (!emit(\"tool_use\", time, { part })) await input.renderTool(tool)\n continue\n }\n if (event.type === \"session.tool.failed\") {\n const key = toolKey(event.data.assistantMessageID, event.data.callID)\n const current = tools.get(key) ?? fallbackTool(event)\n const error = event.data.error.message\n const tool: SessionMessageAssistantTool = {\n type: \"tool\",\n id: event.data.callID,\n name: current.tool,\n executed: event.data.executed,\n providerState: current.providerState,\n providerResultState: event.data.resultState,\n state: {\n status: \"error\",\n input: current.input,\n structured: current.structured,\n content: current.content,\n error: event.data.error,\n result: event.data.result,\n },\n time: { created: current.timestamp, ran: current.timestamp, completed: time },\n }\n const part: MiniToolPart = {\n id: current.id,\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"tool\",\n callID: event.data.callID,\n tool: current.tool,\n state: {\n status: \"error\",\n input: current.input,\n error,\n metadata: {\n result: event.data.result,\n providerCall: current.provider,\n providerResult: { executed: event.data.executed, state: event.data.resultState },\n rawInput: current.raw,\n },\n time: { start: current.timestamp, end: time },\n },\n }\n tools.delete(key)\n if (input.compatibility === \"v1\" && (permissionRejected || formCancelled)) continue\n if (!emit(\"tool_use\", time, { part })) {\n if (toolOutputText(current.tool, current.content).trim())\n await input.renderTool({\n ...tool,\n state: {\n status: \"completed\",\n input: current.input,\n structured: current.structured,\n content: current.content,\n result: event.data.result,\n },\n })\n await input.renderToolError(tool)\n UI.error(error)\n }\n continue\n }\n\n if (event.type === \"session.step.ended\") {\n flushStep()\n const part = {\n id: partID(event.id),\n sessionID: input.sessionID,\n messageID: event.data.assistantMessageID,\n type: \"step-finish\",\n reason: event.data.finish,\n snapshot: event.data.snapshot,\n cost: event.data.cost,\n tokens: event.data.tokens,\n }\n emit(\"step_finish\", time, { part })\n continue\n }\n if (event.type === \"session.step.failed\") {\n if (\n input.compatibility === \"v1\" &&\n event.data.error.message === \"Provider stream ended without a terminal finish event\"\n ) {\n pendingStep = undefined\n v1InvalidOutput = true\n continue\n }\n if (interrupted || permissionRejected || formCancelled) continue\n flushStep()\n emittedError = true\n process.exitCode = 1\n if (!emit(\"error\", time, { error: event.data.error })) UI.error(event.data.error.message)\n continue\n }\n if (event.type === \"session.execution.failed\") {\n if (input.compatibility === \"v1\" && (v1InvalidOutput || permissionRejected || formCancelled)) return\n flushStep()\n if (!emittedError && !formCancelled) {\n emittedError = true\n process.exitCode = 1\n if (!emit(\"error\", time, { error: event.data.error })) UI.error(event.data.error.message)\n }\n return\n }\n if (event.type === \"session.execution.interrupted\") {\n if (input.compatibility === \"v1\" && (permissionRejected || formCancelled)) return\n if (event.data.reason === \"user\" && interrupted) process.exitCode = 130\n if (event.data.reason !== \"user\" && !emittedError) {\n emittedError = true\n process.exitCode = 1\n const error = { type: \"aborted\" as const, message: `Session interrupted: ${event.data.reason}` }\n if (!emit(\"error\", time, { error })) UI.error(error.message)\n }\n return\n }\n if (event.type === \"session.execution.succeeded\") return\n }\n }\n\n const interrupt = () => {\n if (interrupted) process.exit(130)\n interrupted = true\n process.exitCode = 130\n admission?.abort()\n void input.client.session.interrupt({ sessionID: input.sessionID }).catch(() => {})\n }\n process.on(\"SIGINT\", interrupt)\n\n let completed: Promise<void> | undefined\n try {\n if (input.agent) {\n await input.client.session.switchAgent({ sessionID: input.sessionID, agent: input.agent })\n }\n const selected = input.model\n ? { providerID: input.model.providerID, id: input.model.modelID, variant: input.variant }\n : input.variant\n ? await input.client.session\n .get({ sessionID: input.sessionID })\n .then((result) => result.model)\n .then(async (model) => {\n if (model) return { ...model, variant: input.variant }\n const result = await input.client.model.default()\n const fallback = result.data\n return fallback ? { providerID: fallback.providerID, id: fallback.id, variant: input.variant } : undefined\n })\n : undefined\n if (input.variant && !selected) throw new Error(\"Cannot select a variant before selecting a model\")\n if (selected) {\n await input.client.session.switchModel({ sessionID: input.sessionID, model: selected })\n }\n\n const prepared = await Promise.all(input.files.map(prepareFile))\n if (interrupted) return\n submitted = true\n completed = consume()\n admission = new AbortController()\n const response = await input.client.session\n .prompt(\n {\n sessionID: input.sessionID,\n id: messageID,\n text: [input.message, ...prepared.flatMap((file) => (file.text ? [file.text] : []))].join(\"\\n\\n\"),\n files: prepared.flatMap((file) => (file.attachment ? [file.attachment] : [])),\n delivery: \"steer\",\n },\n { signal: admission.signal },\n )\n .catch(async (error) => {\n if (interrupted) {\n await input.client.session.interrupt({ sessionID: input.sessionID }).catch(() => {})\n }\n controller.abort()\n await completed?.catch(() => {})\n if (interrupted || emittedError) return undefined\n throw error\n })\n admission = undefined\n if (!response) return\n if (interrupted) await input.client.session.interrupt({ sessionID: input.sessionID }).catch(() => {})\n\n const [permissions, forms, globals] = await Promise.all([\n input.client.permission.list({ sessionID: input.sessionID }).catch(() => undefined),\n input.client.form.list({ sessionID: input.sessionID }).catch(() => undefined),\n input.attached\n ? Promise.resolve(undefined)\n : input.client.form.request\n .list({\n location: { directory: input.location.directory, workspace: input.location.workspaceID },\n })\n .catch(() => undefined),\n ])\n await Promise.all([\n ...(permissions ?? []).map(replyPermission),\n ...(forms ?? []).map(cancelForm),\n ...(globals && sameLocation(globals.location, input.location)\n ? globals.data.filter((form) => form.sessionID === GLOBAL_FORM_SESSION_ID).map(cancelForm)\n : []),\n ])\n await completed\n } finally {\n process.off(\"SIGINT\", interrupt)\n controller.abort()\n await stream.return?.(undefined).catch(() => {})\n }\n}\n\nfunction sameLocation(left: LocationRef | undefined, right: LocationRef) {\n return !!left && left.directory === right.directory && left.workspaceID === right.workspaceID\n}\n\nfunction formRequestOptions(location: LocationRef | undefined): [] | [{ headers: Record<string, string> }] {\n if (!location) return []\n return [\n {\n headers: {\n \"x-opencode-directory\": encodeURIComponent(location.directory),\n ...(location.workspaceID ? { \"x-opencode-workspace\": location.workspaceID } : {}),\n },\n },\n ]\n}\n\nfunction formAlreadySettled(error: unknown) {\n return !!error && typeof error === \"object\" && Reflect.get(error, \"_tag\") === \"FormAlreadySettledError\"\n}\n\nfunction partID(eventID: string) {\n return `prt_${eventID.replace(/^evt_/, \"\")}`\n}\n\nfunction toolKey(messageID: string, callID: string) {\n return `${messageID}\\u0000${callID}`\n}\n\nfunction fallbackTool(event: {\n id: string\n created: number\n data: { assistantMessageID: string; callID: string }\n}): ToolState {\n return {\n id: partID(event.id),\n timestamp: toMillis(event.created),\n assistantMessageID: event.data.assistantMessageID,\n tool: \"tool\",\n input: {},\n structured: {},\n content: [],\n }\n}\n\nfunction toMillis(value: unknown) {\n if (typeof value === \"number\") return value\n if (typeof value === \"string\") return new Date(value).getTime()\n return Date.now()\n}\n\nasync function prepareFile(file: File) {\n if (file.mime !== \"text/plain\") {\n const uri = file.url.startsWith(\"data:\")\n ? file.url\n : `data:${file.mime};base64,${(await readFile(new URL(file.url))).toString(\"base64\")}`\n return { attachment: { uri, name: file.filename } }\n }\n const content = file.url.startsWith(\"data:\")\n ? Buffer.from(file.url.slice(file.url.indexOf(\",\") + 1), \"base64\").toString(\"utf8\")\n : await readFile(new URL(file.url), \"utf8\")\n return { text: `<file name=\"${file.filename}\">\\n${content}\\n</file>` }\n}\n", | ||
| "import { EOL } from \"node:os\"\n\nexport const Style = {\n TEXT_DIM: \"\\x1b[90m\",\n TEXT_NORMAL: \"\\x1b[0m\",\n TEXT_WARNING_BOLD: \"\\x1b[93m\\x1b[1m\",\n TEXT_DANGER_BOLD: \"\\x1b[91m\\x1b[1m\",\n}\n\nexport function println(...message: string[]) {\n process.stderr.write(message.join(\" \") + EOL)\n}\n\nlet blank = false\n\nexport function empty() {\n if (blank) return\n println(Style.TEXT_NORMAL)\n blank = true\n}\n\nexport function error(message: string) {\n if (message.startsWith(\"Error: \")) message = message.slice(\"Error: \".length)\n println(Style.TEXT_DANGER_BOLD + \"Error: \" + Style.TEXT_NORMAL + message)\n}\n\nexport * as UI from \"./ui\"\n" | ||
| ], | ||
| "mappings": ";s7BAGA,oBAAS,0BACT,yBCKA,mBAAS,gBACT,wBAAS,uGCVT,mBAAS,iBAEF,SAAM,OAAQ,MACnB,cAAU,gBACV,iBAAa,eACb,uBAAmB,uBACnB,sBAAkB,sBACpB,OAEO,cAAS,MAAO,I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EAAmB,CACnF,IAAM,EAAO,EAAe,EAAM,CAAS,EAC3C,EAAG,QAAQ,EAAG,MAAM,YAAc,SAAI,EAAG,MAAM,YAAc,GAAG,EAAK,cAAc,EAGrF,SAAS,CAAO,CAAC,EAAiB,CAChC,EAAG,QAAQ,EAAG,MAAM,kBAAoB,IAAK,EAAG,MAAM,YAAa,CAAO,EAG5E,SAAS,EAAY,CAAC,EAAgB,CACpC,GAAI,aAAiB,MAAO,OAAO,EAAM,QACzC,GAAI,OAAO,IAAU,UAAY,IAAU,MAAQ,YAAa,GAAS,OAAO,EAAM,UAAY,SAChG,OAAO,EAAM,QACf,OAAO,OAAO,CAAK,EAId,SAAS,CAAc,CAAC,EAAwC,EAAiB,EAAoB,CAE1G,GADA,QAAQ,SAAW,EACf,EAAM,SAAW,OAAQ,CAC3B,QAAQ,OAAO,MACb,KAAK,UAAU,CACb,KAAM,QACN,UAAW,KAAK,IAAI,EACpB,UAAW,GAAa,GACxB,MAAO,CAAE,KAAM,UAAW,SAAQ,CACpC,CAAC,EAAI;AAAA,CACP,EACA,OAEF,EAAG,MAAM,CAAO,EAGlB,SAAS,CAAI,CAAC,EAAwB,CACpC,MAAU,MAAM,CAAO", | ||
| "debugId": "DE7CD11D9276CF0E64756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/get.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect, Option } from \"effect\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.get,\n Effect.fn(\"cli.service.get\")(function* (input) {\n process.stdout.write((yield* ServiceConfig.get(Option.getOrUndefined(input.key))) + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";42BAAA,mBAAS,gBAMT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,SACnC,OAAO,QAAG,sBAAiB,OAAE,cAAU,MAAC,OAAO,MAC7C,aAAQ,YAAO,YAAO,WAAO,OAAc,IAAI,EAAO,eAAe,EAAM,GAAG,CAAC,GAAK,CAAG,EACxF,CACH", | ||
| "debugId": "63ADFFCDE40D177964756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/service/start.ts"], | ||
| "sourcesContent": [ | ||
| "import { EOL } from \"os\"\nimport { Effect } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\n\nexport default Runtime.handler(\n Commands.commands.service.commands.start,\n Effect.fn(\"cli.service.start\")(function* () {\n const transport = yield* Service.ensure(yield* ServiceConfig.options())\n process.stdout.write(transport.url + EOL)\n }),\n)\n" | ||
| ], | ||
| "mappings": ";i3BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,WACnC,OAAO,QAAG,wBAAmB,OAAE,cAAU,OAAG,MAC1C,SAAM,OAAY,WAAO,OAAQ,YAAO,WAAO,EAAc,QAAQ,CAAC,EACtE,QAAQ,OAAO,MAAM,EAAU,IAAM,CAAG,EACzC,CACH", | ||
| "debugId": "D62E26ED08896BA064756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/mini.ts"], | ||
| "sourcesContent": [ | ||
| "import { Context, Effect, FileSystem, Option } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\nimport { ServerConnection } from \"../../services/server-connection\"\nimport { Config } from \"../../config\"\nimport { resolve } from \"@opencode-ai/tui/config\"\n\nexport default Runtime.handler(Commands.commands.mini, (input) =>\n Effect.gen(function* () {\n const { runMini, validateMiniTerminal } = yield* Effect.promise(() => import(\"../../mini\"))\n yield* Effect.promise(async () => validateMiniTerminal())\n const serverURL = Option.getOrUndefined(input.server)\n const server = yield* ServerConnection.resolve({ server: serverURL, standalone: input.standalone })\n const config = yield* Config.Service\n const resolved = resolve(yield* config.get(), { terminalSuspend: process.platform !== \"win32\" })\n const fileSystem = yield* FileSystem.FileSystem\n const runServicePromise = Effect.runPromiseWith(Context.make(FileSystem.FileSystem, fileSystem))\n const service = server.service\n yield* Effect.promise(() =>\n runMini({\n server: {\n endpoint: server.endpoint,\n reconnect: service ? (signal) => runServicePromise(service.reconnect(), { signal }) : undefined,\n },\n continue: input.continue,\n session: Option.getOrUndefined(input.session),\n fork: input.fork,\n model: Option.getOrUndefined(input.model),\n agent: Option.getOrUndefined(input.agent),\n prompt: Option.getOrUndefined(input.prompt),\n replay: input.replay,\n replayLimit: Option.getOrUndefined(input.replayLimit),\n demo: input.demo,\n tuiConfig: resolved,\n }),\n )\n }),\n)\n" | ||
| ], | ||
| "mappings": ";ogCAOA,SAAe,SAAQ,aAAQ,OAAS,cAAS,UAAM,MAAC,SACtD,OAAO,SAAI,cAAU,OAAG,MACtB,SAAQ,eAAS,6BAAyB,WAAO,OAAO,aAAQ,SAAa,wCAAa,OAC1F,WAAO,OAAO,aAAQ,cAAY,OAAqB,CAAC,EACxD,IAAM,EAAY,EAAO,eAAe,EAAM,MAAM,EAC9C,EAAS,MAAO,EAAiB,QAAQ,CAAE,OAAQ,EAAW,WAAY,EAAM,UAAW,CAAC,EAC5F,EAAS,MAAO,EAAO,QACvB,EAAW,EAAQ,MAAO,EAAO,IAAI,EAAG,CAAE,gBAAiB,EAA6B,CAAC,EACzF,EAAa,MAAO,EAAW,WAC/B,EAAoB,EAAO,eAAe,EAAQ,KAAK,EAAW,WAAY,CAAU,CAAC,EACzF,EAAU,EAAO,QACvB,MAAO,EAAO,QAAQ,IACpB,EAAQ,CACN,OAAQ,CACN,SAAU,EAAO,SACjB,UAAW,EAAU,CAAC,IAAW,EAAkB,EAAQ,UAAU,EAAG,CAAE,QAAO,CAAC,EAAI,MACxF,EACA,SAAU,EAAM,SAChB,QAAS,EAAO,eAAe,EAAM,OAAO,EAC5C,KAAM,EAAM,KACZ,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,MAAO,EAAO,eAAe,EAAM,KAAK,EACxC,OAAQ,EAAO,eAAe,EAAM,MAAM,EAC1C,OAAQ,EAAM,OACd,YAAa,EAAO,eAAe,EAAM,WAAW,EACpD,KAAM,EAAM,KACZ,UAAW,CACb,CAAC,CACH,EACD,CACH", | ||
| "debugId": "43EB2D782450D9CA64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../core/src/image/photon-wasm.bun.ts", "../core/src/image/photon.ts"], | ||
| "sourcesContent": [ | ||
| "// @ts-ignore Bun embeds static file imports when compiling the CLI.\nimport photonWasm from \"@silvia-odwyer/photon-node/photon_rs_bg.wasm\" with { type: \"file\" }\n\nexport default photonWasm\n", | ||
| "import photonWasm from \"#photon-wasm\"\nimport { Effect } from \"effect\"\nimport path from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\nimport { FileSystem } from \"../filesystem\"\nimport { DecodeError, ResizerUnavailableError, SizeError } from \"../image\"\n\nconst JPEG_QUALITIES = [80, 85, 70, 55, 40]\n\nexport const make = Effect.gen(function* () {\n ;(globalThis as typeof globalThis & { __OPENCODE_PHOTON_WASM_PATH?: string }).__OPENCODE_PHOTON_WASM_PATH =\n path.isAbsolute(photonWasm) ? photonWasm : fileURLToPath(new URL(photonWasm, import.meta.url))\n const loadPhoton = yield* Effect.cached(\n Effect.tryPromise({\n try: () => import(\"@silvia-odwyer/photon-node\"),\n catch: () => new ResizerUnavailableError(),\n }),\n )\n return Effect.fn(\"Image.Photon.normalize\")(function* (\n resource: string,\n content: FileSystem.Content & { readonly encoding: \"base64\" },\n limits: {\n readonly autoResize: boolean\n readonly maxWidth: number\n readonly maxHeight: number\n readonly maxBase64Bytes: number\n },\n ) {\n const photon = yield* loadPhoton\n const decoded = yield* Effect.try({\n try: () => photon.PhotonImage.new_from_byteslice(Buffer.from(content.content, \"base64\")),\n catch: () => new DecodeError({ resource }),\n })\n try {\n const width = decoded.get_width()\n const height = decoded.get_height()\n const bytes = Buffer.byteLength(content.content, \"utf-8\")\n if (width <= limits.maxWidth && height <= limits.maxHeight && bytes <= limits.maxBase64Bytes) return content\n if (!limits.autoResize)\n return yield* new SizeError({\n resource,\n width,\n height,\n bytes,\n maxWidth: limits.maxWidth,\n maxHeight: limits.maxHeight,\n maxBytes: limits.maxBase64Bytes,\n })\n const scale = Math.min(1, limits.maxWidth / width, limits.maxHeight / height)\n const sizes = Array.from({ length: 32 }).reduce<Array<{ width: number; height: number }>>((acc) => {\n const previous = acc.at(-1) ?? {\n width: Math.max(1, Math.round(width * scale)),\n height: Math.max(1, Math.round(height * scale)),\n }\n const next =\n acc.length === 0\n ? previous\n : {\n width: previous.width === 1 ? 1 : Math.max(1, Math.floor(previous.width * 0.75)),\n height: previous.height === 1 ? 1 : Math.max(1, Math.floor(previous.height * 0.75)),\n }\n return acc.some((item) => item.width === next.width && item.height === next.height) ? acc : [...acc, next]\n }, [])\n for (const size of sizes) {\n const resized = photon.resize(decoded, size.width, size.height, photon.SamplingFilter.Lanczos3)\n try {\n const encoders: Array<readonly [mime: string, encode: () => Uint8Array]> = [\n [\"image/png\", () => resized.get_bytes()],\n ...JPEG_QUALITIES.map((quality) => [\"image/jpeg\", () => resized.get_bytes_jpeg(quality)] as const),\n ]\n for (const [mime, encode] of encoders) {\n const candidate = Buffer.from(encode()).toString(\"base64\")\n if (Buffer.byteLength(candidate, \"utf-8\") <= limits.maxBase64Bytes)\n return { ...content, content: candidate, encoding: \"base64\" as const, mime }\n }\n } finally {\n resized.free()\n }\n }\n return yield* new SizeError({\n resource,\n width,\n height,\n bytes,\n maxWidth: limits.maxWidth,\n maxHeight: limits.maxHeight,\n maxBytes: limits.maxBase64Bytes,\n })\n } finally {\n decoded.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IAAI,EAAG,KAAK,MAAM,EAAS,CAAK,CAAC,CAChD,EACM,EACJ,EAAI,SAAW,EACX,EACA,CACE,MAAO,EAAS,QAAU,EAAI,EAAI,KAAK,IAAI,EAAG,KAAK,MAAM,EAAS,MAAQ,IAAI,CAAC,EAC/E,OAAQ,EAAS,SAAW,EAAI,EAAI,KAAK,IAAI,EAAG,KAAK,MAAM,EAAS,OAAS,IAAI,CAAC,CACpF,EACN,OAAO,EAAI,KAAK,CAAC,IAAS,EAAK,QAAU,EAAK,OAAS,EAAK,SAAW,EAAK,MAAM,EAAI,EAAM,CAAC,GAAG,EAAK,CAAI,GACxG,CAAC,CAAC,EACL,QAAW,KAAQ,EAAO,CACxB,IAAM,EAAU,EAAO,OAAO,EAAS,EAAK,MAAO,EAAK,OAAQ,EAAO,eAAe,QAAQ,EAC9F,GAAI,CACF,IAAM,EAAqE,CACzE,CAAC,YAAa,IAAM,EAAQ,UAAU,CAAC,EACvC,GAAG,EAAe,IAAI,CAAC,IAAY,CAAC,aAAc,IAAM,EAAQ,eAAe,CAAO,CAAC,CAAU,CACnG,EACA,QAAY,EAAM,KAAW,EAAU,CACrC,IAAM,EAAY,OAAO,KAAK,EAAO,CAAC,EAAE,SAAS,QAAQ,EACzD,GAAI,OAAO,WAAW,EAAW,OAAO,GAAK,EAAO,eAClD,MAAO,IAAK,EAAS,QAAS,EAAW,SAAU,SAAmB,MAAK,UAE/E,CACA,EAAQ,KAAK,GAGjB,OAAO,MAAO,IAAI,EAAU,CAC1B,WACA,QACA,SACA,QACA,SAAU,EAAO,SACjB,UAAW,EAAO,UAClB,SAAU,EAAO,cACnB,CAAC,SACD,CACA,EAAQ,KAAK,GAEhB,EACF", | ||
| "debugId": "DF2CE38034FD532064756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../core/src/plugin/sdk.ts", "../plugin/src/v2/effect/tool.ts", "../plugin/src/v2/effect/plugin.ts", "../schema/src/session.ts", "../schema/src/command.ts", "../schema/src/reference.ts"], | ||
| "sourcesContent": [ | ||
| "export * as SdkPlugins from \"./sdk\"\n\nimport type { Plugin } from \"@opencode-ai/plugin/v2/effect/plugin\"\nimport { Context, Effect, Layer } from \"effect\"\nimport { makeGlobalNode } from \"../effect/app-node\"\nimport { EventV2 } from \"../event\"\nimport type { PluginV2 } from \"../plugin\"\n\nexport const Updated = EventV2.ephemeral({ type: \"sdk.plugin.updated\", schema: {} })\n\n/**\n * Holds the plugins an embedder (the `@opencode-ai/sdk-next` host) contributes,\n * so `PluginSupervisor` can add them on every Location boot through the ordinary\n * generation path that `PluginSupervisor` uses for plugins discovered from\n * config. Registration publishes an unlocated update so every booted Location\n * reloads its plugin generation from the shared store.\n *\n * Each host-global layer owns one private store. Location graphs reuse that\n * layer through Effect's memoization, so separate hosts remain isolated while\n * every Location in one host sees the same registrations.\n */\nexport interface Interface {\n readonly register: (plugin: Plugin) => Effect.Effect<void>\n readonly all: () => readonly PluginV2.Versioned[]\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@opencode/SdkPlugins\") {}\n\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const events = yield* EventV2.Service\n const plugins = new Map<string, PluginV2.Versioned>()\n let revision = 0\n return Service.of({\n register: (plugin) =>\n Effect.sync(() => {\n plugins.set(plugin.id, { ...plugin, version: String(++revision) })\n }).pipe(Effect.andThen(events.publish(Updated, {})), Effect.asVoid),\n all: () => [...plugins.values()],\n })\n }),\n)\n\nexport const node = makeGlobalNode({ service: Service, layer, deps: [EventV2.node] })\n", | ||
| "export * as Tool from \"./tool.js\"\n\nimport { Agent } from \"@opencode-ai/schema/agent\"\nimport type { LLM } from \"@opencode-ai/schema/llm\"\nimport { Session } from \"@opencode-ai/schema/session\"\nimport { SessionMessage } from \"@opencode-ai/schema/session-message\"\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from \"@standard-schema/spec\"\nimport { Effect, JsonSchema, Schema } from \"effect\"\nimport type { Hooks, Transform } from \"./registration.js\"\n\nexport interface Context {\n readonly sessionID: Session.ID\n readonly agent: Agent.ID\n readonly messageID: SessionMessage.ID\n readonly callID: string\n readonly progress: (update: Progress) => Effect.Effect<void>\n}\n\nexport interface Progress {\n readonly structured: Readonly<Record<string, unknown>>\n readonly content?: ReadonlyArray<Content>\n}\n\nexport type StandardSchemaType<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output> &\n StandardJSONSchemaV1<Input, Output>\nexport type SchemaType<A> = Schema.Codec<A, any> | StandardSchemaType<any, A>\ntype IsAny<A> = 0 extends 1 & A ? true : false\nexport type InputValue<S> =\n IsAny<S> extends true\n ? any\n : S extends Schema.Codec<infer A, any>\n ? A\n : S extends StandardSchemaV1<any, infer A>\n ? A\n : never\nexport type OutputValue<S> =\n IsAny<S> extends true\n ? any\n : S extends Schema.Codec<infer A, any>\n ? A\n : S extends StandardSchemaV1<infer A, any>\n ? A\n : never\nexport type EncodedValue<S> =\n IsAny<S> extends true\n ? any\n : S extends Schema.Codec<any, infer A>\n ? A\n : S extends StandardSchemaV1<any, infer A>\n ? A\n : never\n\ntype ToolDefinition = {\n readonly name: string\n readonly description: string\n readonly inputSchema: JsonSchema.JsonSchema\n readonly outputSchema?: JsonSchema.JsonSchema\n}\n\ntype ToolCall = {\n readonly input: unknown\n readonly [key: string]: unknown\n}\n\ntype ToolResultValue =\n | { readonly type: \"json\"; readonly value: unknown }\n | { readonly type: \"text\"; readonly value: unknown }\n | { readonly type: \"error\"; readonly value: unknown }\n | { readonly type: \"content\"; readonly value: ReadonlyArray<LLM.ToolContent> }\n\ntype ToolOutput = {\n readonly structured: unknown\n readonly content: ReadonlyArray<LLM.ToolContent>\n}\n\nexport class Failure extends Schema.TaggedErrorClass<Failure>()(\"LLM.ToolFailure\", {\n message: Schema.String,\n error: Schema.optional(Schema.Defect()),\n metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n}) {}\n\nexport class RegistrationError extends Schema.TaggedErrorClass<RegistrationError>()(\"Tool.RegistrationError\", {\n name: Schema.String,\n message: Schema.String,\n}) {}\n\nexport type Content =\n | { readonly type: \"text\"; readonly text: string }\n | { readonly type: \"file\"; readonly data: string; readonly mime: string; readonly name?: string }\n\nexport type Definition<\n Input extends SchemaType<any>,\n Structured extends SchemaType<any>,\n Output extends SchemaType<any> = any,\n> = {\n readonly description: string\n readonly input: Input\n readonly output: Output\n readonly structured?: Structured\n readonly permission?: string\n readonly toStructuredOutput?: (input: {\n readonly input: InputValue<Input>\n readonly output: EncodedValue<Output>\n }) => OutputValue<Structured>\n readonly execute: (input: InputValue<Input>, context: Context) => Effect.Effect<OutputValue<Output>, Failure>\n readonly toModelOutput?: (input: {\n readonly input: InputValue<Input>\n readonly output: EncodedValue<Output>\n }) => ReadonlyArray<Content>\n}\n\nexport type DynamicOutput = {\n readonly structured: unknown\n readonly content: ReadonlyArray<Content>\n}\n\n/**\n * Config for a tool whose input shape is a raw JSON Schema not known at compile\n * time (MCP servers, plugin manifests). Input is passed through as `unknown`;\n * `execute` returns the already-projected structured value and model content.\n */\nexport type DynamicDefinition = {\n readonly description: string\n readonly jsonSchema: JsonSchema.JsonSchema\n readonly outputSchema?: JsonSchema.JsonSchema\n readonly permission?: string\n readonly execute: (input: unknown, context: Context) => Effect.Effect<DynamicOutput, Failure>\n}\n\nexport type AnyTool = Definition<any, any> | DynamicDefinition\n\nexport function make<\n Input extends SchemaType<any>,\n Output extends SchemaType<any>,\n Structured extends SchemaType<any> = Output,\n>(config: Definition<Input, Structured, Output>): Definition<Input, Structured, Output>\nexport function make(config: DynamicDefinition): DynamicDefinition\nexport function make(config: AnyTool): AnyTool\nexport function make(config: AnyTool): AnyTool {\n return config\n}\n\nfunction toModelContent(part: Content) {\n if (part.type === \"text\") return { type: \"text\" as const, text: part.text }\n return { type: \"file\" as const, uri: `data:${part.mime};base64,${part.data}`, mime: part.mime, name: part.name }\n}\n\nexport const validateName = (name: string) =>\n /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(name)\n ? Effect.void\n : Effect.fail(new RegistrationError({ name, message: `Invalid tool name: ${name}` }))\n\nexport const registrationEntries = (tools: Readonly<Record<string, AnyTool>>, namespace?: string) =>\n Object.entries(tools).map(([name, tool]) => {\n const normalized = name.replace(/[^a-zA-Z0-9_-]/g, \"_\")\n return {\n key: namespace === undefined ? normalized : `${namespace.replaceAll(\".\", \"_\")}_${normalized}`,\n name: normalized,\n namespace,\n tool,\n }\n })\n\nexport const validateNamespace = (namespace: string) =>\n namespace.split(\".\").every((segment) => /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(segment))\n ? Effect.void\n : Effect.fail(\n new RegistrationError({ name: namespace, message: `Invalid tool namespace: ${JSON.stringify(namespace)}` }),\n )\n\nexport const withPermission = <T extends AnyTool>(\n tool: T,\n permission: string,\n): Omit<T, \"permission\"> & {\n readonly permission: string\n} => ({ ...tool, permission })\n\nexport const permission = (tool: AnyTool, name: string) => tool.permission ?? name\n\nexport const definition = (name: string, tool: AnyTool): ToolDefinition =>\n \"jsonSchema\" in tool\n ? {\n name,\n description: tool.description,\n inputSchema: tool.jsonSchema,\n outputSchema: tool.outputSchema,\n }\n : {\n name,\n description: tool.description,\n inputSchema: inputJsonSchema(tool.input),\n outputSchema: outputJsonSchema(tool.structured ?? tool.output),\n }\n\nexport const settle = (tool: AnyTool, call: ToolCall, context: Context): Effect.Effect<ToolOutput, Failure> =>\n Effect.gen(function* () {\n if (\"jsonSchema\" in tool) {\n const output = yield* tool.execute(call.input, context)\n return { structured: output.structured, content: output.content.map(toModelContent) }\n }\n\n const input = yield* decodeInput(tool.input, call.input)\n const value = yield* tool.execute(input, context)\n const output = yield* encodeOutput(tool.output, value)\n const structured =\n tool.structured && tool.toStructuredOutput\n ? yield* encodeOutput(tool.structured, tool.toStructuredOutput({ input, output }))\n : output\n return {\n structured,\n content:\n tool.toModelOutput?.({ input, output }).map(toModelContent) ??\n (typeof output === \"string\" ? [{ type: \"text\" as const, text: output }] : []),\n }\n })\n\nfunction decodeInput(schema: SchemaType<any>, value: unknown): Effect.Effect<any, Failure> {\n if (Schema.isSchema(schema))\n return Schema.decodeUnknownEffect(schema)(value).pipe(\n Effect.mapError((error) => new Failure({ message: `Invalid tool input: ${error.message}` })),\n )\n return validateStandard(schema, value, \"Invalid tool input\")\n}\n\nfunction encodeOutput(schema: SchemaType<any>, value: unknown): Effect.Effect<any, Failure> {\n if (Schema.isSchema(schema))\n return Schema.encodeEffect(schema)(value).pipe(\n Effect.mapError(\n (error) => new Failure({ message: `Tool returned an invalid value for its output schema: ${error.message}` }),\n ),\n )\n return validateStandard(schema, value, \"Tool returned an invalid value for its output schema\")\n}\n\nfunction validateStandard(schema: StandardSchemaType, value: unknown, prefix: string): Effect.Effect<unknown, Failure> {\n return Effect.gen(function* () {\n const pending = yield* Effect.try({\n try: () => schema[\"~standard\"].validate(value),\n catch: (error) => standardFailure(prefix, error),\n })\n const result =\n pending instanceof Promise\n ? yield* Effect.tryPromise({ try: () => pending, catch: (error) => standardFailure(prefix, error) })\n : pending\n if (result.issues)\n return yield* Effect.fail(\n new Failure({ message: `${prefix}: ${result.issues.map((issue) => issue.message).join(\", \")}` }),\n )\n return result.value\n })\n}\n\nfunction standardFailure(prefix: string, error: unknown) {\n return new Failure({ message: `${prefix}: ${error instanceof Error ? error.message : String(error)}` })\n}\n\nfunction inputJsonSchema(schema: SchemaType<any>): JsonSchema.JsonSchema {\n if (!Schema.isSchema(schema))\n return schema[\"~standard\"].jsonSchema.input({ target: \"draft-2020-12\" }) as JsonSchema.JsonSchema\n return toJsonSchema(schema)\n}\n\nfunction outputJsonSchema(schema: SchemaType<any>): JsonSchema.JsonSchema {\n if (!Schema.isSchema(schema))\n return schema[\"~standard\"].jsonSchema.output({ target: \"draft-2020-12\" }) as JsonSchema.JsonSchema\n return toJsonSchema(schema)\n}\n\nfunction toJsonSchema(schema: Schema.Top): JsonSchema.JsonSchema {\n const document = Schema.toJsonSchemaDocument(schema)\n if (Object.keys(document.definitions).length === 0) return document.schema\n return { ...document.schema, $defs: document.definitions }\n}\n\nexport interface ToolExecuteBeforeEvent {\n readonly tool: string\n readonly sessionID: Session.ID\n readonly agent: Agent.ID\n readonly messageID: SessionMessage.ID\n readonly callID: string\n input: unknown\n}\n\nexport interface ToolExecuteAfterEvent {\n readonly tool: string\n readonly sessionID: Session.ID\n readonly agent: Agent.ID\n readonly messageID: SessionMessage.ID\n readonly callID: string\n readonly input: unknown\n result: ToolResultValue\n output?: ToolOutput\n outputPaths?: ReadonlyArray<string>\n}\n\nexport interface RegisterOptions {\n readonly namespace?: string\n /** Defaults to true. False exposes the tool directly to the provider. */\n readonly codemode?: boolean\n}\n\nexport interface ToolDraft {\n add(name: string, tool: AnyTool, options?: RegisterOptions): void\n}\n\nexport interface ToolHooks {\n readonly \"execute.before\": ToolExecuteBeforeEvent\n readonly \"execute.after\": ToolExecuteAfterEvent\n}\n\nexport interface ToolDomain {\n readonly transform: Transform<ToolDraft>\n readonly hook: Hooks<ToolHooks>\n}\n", | ||
| "import type { PluginApi } from \"@opencode-ai/client/effect/api\"\nimport type { Effect, Scope } from \"effect\"\nimport type { PluginOptions } from \"../options.js\"\nimport type { AgentDomain } from \"./agent.js\"\nimport type { AISDKDomain } from \"./aisdk.js\"\nimport type { CatalogDomain } from \"./catalog.js\"\nimport type { CommandDomain } from \"./command.js\"\nimport type { EventDomain } from \"./event.js\"\nimport type { IntegrationDomain } from \"./integration.js\"\nimport type { ReferenceDomain } from \"./reference.js\"\nimport type { SessionDomain } from \"./session.js\"\nimport type { SkillDomain } from \"./skill.js\"\nimport type { ToolDomain } from \"./tool.js\"\n\nexport interface Context {\n readonly options: PluginOptions\n readonly agent: AgentDomain\n readonly aisdk: AISDKDomain\n readonly catalog: CatalogDomain\n readonly command: CommandDomain\n readonly event: EventDomain\n readonly integration: IntegrationDomain\n readonly plugin: PluginApi<unknown>\n readonly reference: ReferenceDomain\n readonly session: SessionDomain\n readonly skill: SkillDomain\n readonly tool: ToolDomain\n}\n\nexport interface Plugin<R = Scope.Scope> {\n readonly id: string\n readonly effect: (context: Context) => Effect.Effect<void, never, R>\n}\n\nexport function define<R = Scope.Scope>(plugin: Plugin<R>) {\n return plugin\n}\n", | ||
| "export * as Session from \"./session.js\"\n\nimport { Schema } from \"effect\"\nimport { Agent } from \"./agent.js\"\nimport { Location } from \"./location.js\"\nimport { Model } from \"./model.js\"\nimport { Project } from \"./project.js\"\nimport { DateTimeUtcFromMillis, optional, RelativePath } from \"./schema.js\"\nimport { SessionEvent } from \"./session-event.js\"\nimport { SessionID } from \"./session-id.js\"\nimport { SessionMessage } from \"./session-message.js\"\nimport { Money } from \"./money.js\"\nimport { TokenUsage } from \"./token-usage.js\"\nimport { Revert } from \"./session-revert.js\"\n\nexport const ID = SessionID\nexport type ID = SessionID\n\nexport const Event = SessionEvent\n\nexport { Revert }\n\nexport interface Info extends Schema.Schema.Type<typeof Info> {}\nexport const Info = Schema.Struct({\n id: ID,\n parentID: ID.pipe(optional),\n fork: Schema.Struct({\n sessionID: ID,\n /** Messages before this exclusive boundary are copied into the fork. */\n messageID: SessionMessage.ID.pipe(optional),\n }).pipe(optional),\n projectID: Project.ID,\n agent: Agent.ID.pipe(optional),\n model: Model.Ref.pipe(optional),\n cost: Money.USD,\n tokens: TokenUsage.Info,\n time: Schema.Struct({\n created: DateTimeUtcFromMillis,\n updated: DateTimeUtcFromMillis,\n archived: DateTimeUtcFromMillis.pipe(optional),\n }),\n title: Schema.String,\n location: Location.Ref,\n subpath: RelativePath.pipe(optional),\n revert: Revert.pipe(optional),\n}).annotate({ identifier: \"Session.Info\" })\n\nexport const ListAnchor = Schema.Struct({\n id: ID,\n time: Schema.Finite,\n direction: Schema.Literals([\"previous\", \"next\"]),\n}).annotate({ identifier: \"Session.ListAnchor\" })\nexport interface ListAnchor extends Schema.Schema.Type<typeof ListAnchor> {}\n", | ||
| "export * as Command from \"./command.js\"\n\nimport { Schema } from \"effect\"\nimport { ephemeral, inventory } from \"./event.js\"\nimport { optional } from \"./schema.js\"\nimport { Model } from \"./model.js\"\nimport { Agent } from \"./agent.js\"\n\nconst Updated = ephemeral({ type: \"command.updated\", schema: {} })\n\nexport interface Info extends Schema.Schema.Type<typeof Info> {}\nexport const Info = Schema.Struct({\n name: Schema.String,\n template: Schema.String,\n description: Schema.String.pipe(optional),\n agent: Agent.ID.pipe(optional),\n model: Model.Ref.pipe(optional),\n subtask: Schema.Boolean.pipe(optional),\n}).annotate({ identifier: \"Command.Info\" })\n\nexport const Event = {\n Updated,\n Definitions: inventory(Updated),\n}\n", | ||
| "export * as Reference from \"./reference.js\"\n\nimport { Schema } from \"effect\"\nimport { optional } from \"./schema.js\"\nimport { ephemeral, inventory } from \"./event.js\"\nimport { AbsolutePath } from \"./schema.js\"\n\nconst Updated = ephemeral({ type: \"reference.updated\", schema: {} })\nexport const Event = { Updated, Definitions: inventory(Updated) }\n\nexport interface LocalSource extends Schema.Schema.Type<typeof LocalSource> {}\nexport const LocalSource = Schema.Struct({\n type: Schema.Literal(\"local\"),\n path: AbsolutePath,\n description: Schema.String.pipe(optional),\n hidden: Schema.Boolean.pipe(optional),\n}).annotate({ identifier: \"Reference.LocalSource\" })\n\nexport interface GitSource extends Schema.Schema.Type<typeof GitSource> {}\nexport const GitSource = Schema.Struct({\n type: Schema.Literal(\"git\"),\n repository: Schema.String,\n branch: Schema.String.pipe(optional),\n description: Schema.String.pipe(optional),\n hidden: Schema.Boolean.pipe(optional),\n}).annotate({ identifier: \"Reference.GitSource\" })\n\nexport const Source = Schema.Union([LocalSource, GitSource])\n .pipe(Schema.toTaggedUnion(\"type\"))\n .annotate({ identifier: \"Reference.Source\" })\nexport type Source = typeof Source.Type\n\nexport const Info = Schema.Struct({\n name: Schema.String,\n path: AbsolutePath,\n description: Schema.String.pipe(optional),\n hidden: Schema.Boolean.pipe(optional),\n source: Source,\n}).annotate({ identifier: \"Reference.Info\" })\nexport interface Info extends Schema.Schema.Type<typeof Info> {}\n" | ||
| ], | ||
| "mappings": ";kiBAQO,SAAM,OAAU,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CAAC,EAAa,CAAS,CAAC,EACxD,KAAK,EAAO,cAAc,MAAM,CAAC,EACjC,SAAS,CAAE,WAAY,kBAAmB,CAAC,EAGjC,GAAO,EAAO,OAAO,CAChC,KAAM,EAAO,OACb,KAAM,EACN,YAAa,EAAO,OAAO,KAAK,CAAQ,EACxC,OAAQ,EAAO,QAAQ,KAAK,CAAQ,EACpC,OAAQ,CACV,CAAC,EAAE,SAAS,CAAE,WAAY,gBAAiB,CAAC", | ||
| "debugId": "5B3446E1347CC99164756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/ui/timeline.tsx", "src/commands/handlers/console/login.ts"], | ||
| "sourcesContent": [ | ||
| "import { createComponent as _$createComponent } from \"@opentui/solid\";\nimport { effect as _$effect } from \"@opentui/solid\";\nimport { createTextNode as _$createTextNode } from \"@opentui/solid\";\nimport { insertNode as _$insertNode } from \"@opentui/solid\";\nimport { insert as _$insert } from \"@opentui/solid\";\nimport { setProp as _$setProp } from \"@opentui/solid\";\nimport { createElement as _$createElement } from \"@opentui/solid\";\n/** @jsxImportSource @opentui/solid */\nimport { createCliRenderer, RGBA } from \"@opentui/core\";\nimport { createScrollbackWriter, render, useKeyboard } from \"@opentui/solid\";\nimport { registerOpencodeSpinner } from \"@opencode-ai/tui/component/register-spinner\";\nimport { Show, createSignal } from \"solid-js\";\nregisterOpencodeSpinner();\nconst SPINNER_FRAMES = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\nconst IDLE_TIMEOUT = 1_000;\nconst COLORS = {\n accent: RGBA.fromIndex(6),\n error: RGBA.fromIndex(1),\n foreground: RGBA.defaultForeground(),\n muted: RGBA.fromIndex(8),\n success: RGBA.fromIndex(2)\n};\nconst ROWS = {\n intro: {\n marker: \"┌\",\n color: COLORS.muted,\n connector: true\n },\n item: {\n marker: \"●\",\n color: COLORS.accent,\n connector: true\n },\n success: {\n marker: \"◇\",\n color: COLORS.success,\n connector: true\n },\n failure: {\n marker: \"■\",\n color: COLORS.error,\n connector: false\n },\n outro: {\n marker: \"└\",\n color: COLORS.muted,\n connector: false\n }\n};\nfunction row(kind, value) {\n const style = ROWS[kind];\n return createScrollbackWriter(() => (() => {\n var _el$ = _$createElement(\"box\"),\n _el$2 = _$createElement(\"box\"),\n _el$3 = _$createElement(\"text\"),\n _el$4 = _$createElement(\"text\");\n _$insertNode(_el$, _el$2);\n _$setProp(_el$, \"width\", \"100%\");\n _$setProp(_el$, \"minHeight\", 1);\n _$setProp(_el$, \"flexDirection\", \"column\");\n _$insertNode(_el$2, _el$3);\n _$insertNode(_el$2, _el$4);\n _$setProp(_el$2, \"width\", \"100%\");\n _$setProp(_el$2, \"minHeight\", 1);\n _$setProp(_el$2, \"flexDirection\", \"row\");\n _$setProp(_el$2, \"gap\", 1);\n _$setProp(_el$3, \"flexShrink\", 0);\n _$insert(_el$3, () => style.marker);\n _$setProp(_el$4, \"wrapMode\", \"word\");\n _$insert(_el$4, value);\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return style.connector;\n },\n get children() {\n var _el$5 = _$createElement(\"text\");\n _$insertNode(_el$5, _$createTextNode(`│`));\n _$effect(_$p => _$setProp(_el$5, \"fg\", COLORS.muted, _$p));\n return _el$5;\n }\n }), null);\n _$effect(_p$ => {\n var _v$ = style.color,\n _v$2 = COLORS.foreground;\n _v$ !== _p$.e && (_p$.e = _$setProp(_el$3, \"fg\", _v$, _p$.e));\n _v$2 !== _p$.t && (_p$.t = _$setProp(_el$4, \"fg\", _v$2, _p$.t));\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$;\n })(), {\n startOnNewLine: true,\n trailingNewline: !style.connector\n });\n}\nfunction TimelineFooter(props) {\n useKeyboard(event => {\n if (event.name !== \"escape\" && !(event.ctrl && event.name === \"c\")) return;\n event.preventDefault();\n props.cancel();\n });\n return (() => {\n var _el$7 = _$createElement(\"box\");\n _$setProp(_el$7, \"width\", \"100%\");\n _$setProp(_el$7, \"height\", 1);\n _$setProp(_el$7, \"flexDirection\", \"row\");\n _$setProp(_el$7, \"gap\", 1);\n _$insert(_el$7, _$createComponent(Show, {\n get when() {\n return props.pending();\n },\n children: text => [(() => {\n var _el$8 = _$createElement(\"spinner\");\n _$setProp(_el$8, \"frames\", SPINNER_FRAMES);\n _$setProp(_el$8, \"interval\", 80);\n _$effect(_$p => _$setProp(_el$8, \"color\", COLORS.accent, _$p));\n return _el$8;\n })(), (() => {\n var _el$9 = _$createElement(\"text\");\n _$setProp(_el$9, \"wrapMode\", \"none\");\n _$setProp(_el$9, \"truncate\", true);\n _$insert(_el$9, text);\n _$effect(_$p => _$setProp(_el$9, \"fg\", COLORS.foreground, _$p));\n return _el$9;\n })()]\n }));\n return _el$7;\n })();\n}\nfunction bounded(task) {\n return new Promise(resolve => {\n const timer = setTimeout(resolve, IDLE_TIMEOUT);\n timer.unref();\n const finish = () => {\n clearTimeout(timer);\n resolve();\n };\n void task.then(finish, finish);\n });\n}\nasync function shutdown(renderer) {\n await bounded(renderer.idle());\n try {\n renderer.externalOutputMode = \"passthrough\";\n } finally {\n try {\n renderer.screenMode = \"main-screen\";\n } finally {\n if (!renderer.isDestroyed) renderer.destroy();\n }\n }\n}\nexport async function createTimelineHost() {\n const stdout = process.stdout;\n const controller = new AbortController();\n const signals = [\"SIGINT\", \"SIGHUP\", \"SIGQUIT\"];\n const cancel = () => {\n if (!controller.signal.aborted) controller.abort();\n };\n signals.forEach(signal => process.on(signal, cancel));\n if (!stdout.isTTY || !process.stdin.isTTY) {\n let closed = false;\n let writing = false;\n let active;\n let closeTask;\n const write = async (kind, text) => {\n if (closed) throw new Error(\"timeline closed\");\n if (writing) throw new Error(\"timeline write already in progress\");\n writing = true;\n try {\n const style = kind === \"pending\" ? undefined : ROWS[kind];\n const marker = kind === \"pending\" ? \".\" : ROWS[kind].marker;\n const connector = style?.connector ? \"│\\n\" : \"\";\n active = new Promise((resolve, reject) => {\n stdout.write(`${marker} ${text}\\n${connector}`, error => error ? reject(error) : resolve());\n });\n await active;\n } finally {\n writing = false;\n active = undefined;\n }\n };\n const close = () => {\n if (closeTask) return closeTask;\n closed = true;\n closeTask = (async () => {\n await active?.catch(() => {});\n signals.forEach(signal => process.off(signal, cancel));\n })();\n return closeTask;\n };\n return {\n signal: controller.signal,\n intro: text => write(\"intro\", text),\n item: text => write(\"item\", text),\n pending: text => write(\"pending\", text),\n success: text => write(\"success\", text),\n failure: text => write(\"failure\", text),\n outro: text => write(\"outro\", text),\n close\n };\n }\n let renderer;\n try {\n // Start on a fresh row so delayed SSH cursor reports cannot make\n // split-footer overwrite the shell command.\n process.stdout.write(\"\\n\");\n renderer = await createCliRenderer({\n stdin: process.stdin,\n useMouse: false,\n autoFocus: false,\n openConsoleOnError: false,\n exitOnCtrlC: false,\n exitSignals: [],\n screenMode: \"split-footer\",\n footerHeight: 1,\n externalOutputMode: \"capture-stdout\",\n consoleMode: \"disabled\",\n clearOnShutdown: false\n });\n const activeRenderer = renderer;\n const [pending, setPending] = createSignal();\n const renderTask = render(() => _$createComponent(TimelineFooter, {\n pending: pending,\n cancel: cancel\n }), activeRenderer);\n void renderTask.catch(cancel);\n await bounded(activeRenderer.idle());\n let closed = false;\n let writing = false;\n let active;\n let closeTask;\n const write = (kind, text) => {\n if (closed) return Promise.reject(new Error(\"timeline closed\"));\n if (writing) return Promise.reject(new Error(\"timeline write already in progress\"));\n writing = true;\n active = (async () => {\n if (kind === \"pending\") {\n setPending(text);\n activeRenderer.requestRender();\n } else {\n if (kind === \"success\" || kind === \"failure\" || kind === \"outro\") setPending(undefined);\n activeRenderer.writeToScrollback(row(kind, text));\n activeRenderer.requestRender();\n }\n await bounded(activeRenderer.idle());\n })().finally(() => {\n writing = false;\n active = undefined;\n });\n return active;\n };\n const close = () => {\n if (closeTask) return closeTask;\n closed = true;\n closeTask = (async () => {\n await active?.catch(() => {});\n try {\n await shutdown(activeRenderer);\n await bounded(renderTask);\n } finally {\n signals.forEach(signal => process.off(signal, cancel));\n }\n })();\n return closeTask;\n };\n return {\n signal: controller.signal,\n intro: text => write(\"intro\", text),\n item: text => write(\"item\", text),\n pending: text => write(\"pending\", text),\n success: text => write(\"success\", text),\n failure: text => write(\"failure\", text),\n outro: text => write(\"outro\", text),\n close\n };\n } catch (error) {\n try {\n if (renderer) await shutdown(renderer);\n } finally {\n signals.forEach(signal => process.off(signal, cancel));\n }\n throw error;\n }\n}", | ||
| "import { Cause, Effect, Exit, Option } from \"effect\"\nimport { Service } from \"@opencode-ai/client/effect/service\"\nimport { OpenCode, type OpenCodeClient } from \"@opencode-ai/client/promise\"\nimport { AppProcess } from \"@opencode-ai/core/process\"\nimport { Commands } from \"../../commands\"\nimport { Runtime } from \"../../../framework/runtime\"\nimport { ServiceConfig } from \"../../../services/service-config\"\nimport { createTimelineHost, type TimelineHost } from \"../../../ui/timeline\"\n\nconst integrationID = \"opencode\"\nconst location = { directory: process.cwd() }\n\nexport default Runtime.handler(\n Commands.commands.console.commands.login,\n Effect.fn(\"cli.console.login\")(function* (input) {\n const timeline = yield* Effect.acquireRelease(\n Effect.promise(() => createTimelineHost()),\n (value) => request(() => value.close()).pipe(Effect.ignore),\n )\n const exit = yield* login(timeline, Option.getOrUndefined(input.url)).pipe(\n Effect.raceFirst(AppProcess.waitForAbort(timeline.signal)),\n Effect.exit,\n )\n if (Exit.isSuccess(exit)) return\n\n const cancelled = timeline.signal.aborted\n yield* request(() => timeline.failure(cancelled ? \"Authorization cancelled\" : errorMessage(exit.cause))).pipe(\n Effect.ignore,\n )\n process.exitCode = cancelled ? 130 : 1\n }),\n)\n\nconst login = Effect.fn(\"cli.console.login.run\")(function* (timeline: TimelineHost, server?: string) {\n yield* request(() => timeline.intro(\"Log in\"))\n yield* request(() => timeline.pending(\"Connecting to OpenCode...\"))\n\n const endpoint = yield* Service.ensure(yield* ServiceConfig.options())\n const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })\n const found = yield* request((signal) => client.integration.get({ integrationID, location }, { signal }))\n const integration = yield* required(found.data, \"OpenCode Console integration is unavailable\")\n const method = yield* required(\n integration.methods.find((candidate) => candidate.type === \"oauth\"),\n \"OpenCode Console login is unavailable\",\n )\n\n yield* request(() => timeline.pending(\"Starting authorization...\"))\n const started = yield* request((signal) =>\n client.integration.oauth.connect(\n {\n integrationID,\n methodID: method.id,\n inputs: server ? { server } : {},\n location,\n },\n { signal },\n ),\n )\n const attempt = started.data\n yield* Effect.addFinalizer(() =>\n request(() =>\n client.integration.oauth.cancel(\n { integrationID, attemptID: attempt.attemptID, location },\n { signal: AbortSignal.timeout(5_000) },\n ),\n ).pipe(Effect.ignore),\n )\n if (attempt.mode !== \"auto\") yield* Effect.fail(new Error(\"OpenCode Console requires a device login\"))\n\n yield* request(() => timeline.item(`Go to: ${attempt.url}`))\n yield* request(() => timeline.item(attempt.instructions))\n yield* request(async () => {\n const { default: open } = await import(\"open\")\n await open(attempt.url)\n }).pipe(Effect.ignore)\n yield* request(() => timeline.pending(\"Waiting for authorization...\"))\n\n const status = yield* waitForConsoleLogin(client, integrationID, attempt.attemptID)\n if (status.status === \"failed\") yield* Effect.fail(new Error(status.message))\n if (status.status === \"expired\") yield* Effect.fail(new Error(\"Device code expired\"))\n\n yield* request(() => timeline.success(\"Connected to OpenCode Console\"))\n yield* request(() => timeline.outro(\"Done\"))\n})\n\nconst waitForConsoleLogin = Effect.fn(\"cli.console.login.wait\")(function* (\n client: OpenCodeClient,\n integrationID: string,\n attemptID: string,\n) {\n while (true) {\n const response = yield* request((signal) =>\n client.integration.oauth.status({ integrationID, attemptID, location }, { signal }),\n )\n if (response.data.status !== \"pending\") return response.data\n yield* Effect.sleep(500)\n }\n})\n\nfunction request<A>(task: (signal: AbortSignal) => Promise<A>) {\n return Effect.tryPromise({\n try: task,\n catch: (cause) => cause,\n })\n}\n\nfunction required<A>(value: A | null | undefined, message: string) {\n return value === null || value === undefined ? Effect.fail(new Error(message)) : Effect.succeed(value)\n}\n\nfunction errorMessage(cause: Cause.Cause<unknown>) {\n const error = Cause.squash(cause)\n if (error instanceof Error) return error.message\n if (typeof error === \"object\" && error !== null && \"message\" in error && typeof error.message === \"string\") {\n return error.message\n }\n return String(error)\n}\n" | ||
| ], | ||
| "mappings": ";4nCAYA,OAAwB,OACxB,SAAM,OAAiB,MAAC,cAAI,cAAK,cAAK,cAAK,cAAK,cAAK,cAAK,cAAK,cAAK,aAAG,OACjE,QAAe,UACf,OAAS,MACb,YAAQ,OAAK,eAAU,MAAC,OACxB,MAAO,EAAK,UAAU,CAAC,EACvB,WAAY,EAAK,kBAAkB,EACnC,MAAO,EAAK,UAAU,CAAC,EACvB,QAAS,EAAK,UAAU,CAAC,CAC3B,EACM,EAAO,CACX,MAAO,CACL,OAAQ,SACR,MAAO,EAAO,MACd,UAAW,EACb,EACA,KAAM,CACJ,OAAQ,SACR,MAAO,EAAO,OACd,UAAW,EACb,EACA,QAAS,CACP,OAAQ,SACR,MAAO,EAAO,QACd,UAAW,EACb,EACA,QAAS,CACP,OAAQ,SACR,MAAO,EAAO,MACd,UAAW,EACb,EACA,MAAO,CACL,OAAQ,SACR,MAAO,EAAO,MACd,UAAW,EACb,CACF,EACA,SAAS,EAAG,CAAC,EAAM,EAAO,CACxB,IAAM,EAAQ,EAAK,GACnB,OAAO,EAAuB,KAAO,IAAM,CACzC,IAAI,EAAO,EAAgB,KAAK,EAC9B,EAAQ,EAAgB,KAAK,EAC7B,EAAQ,EAAgB,MAAM,EAC9B,EAAQ,EAAgB,MAAM,EAoChC,OAnCA,EAAa,EAAM,CAAK,EACxB,EAAU,EAAM,QAAS,MAAM,EAC/B,EAAU,EAAM,YAAa,CAAC,EAC9B,EAAU,EAAM,gBAAiB,QAAQ,EACzC,EAAa,EAAO,CAAK,EACzB,EAAa,EAAO,CAAK,EACzB,EAAU,EAAO,QAAS,MAAM,EAChC,EAAU,EAAO,YAAa,CAAC,EAC/B,EAAU,EAAO,gBAAiB,KAAK,EACvC,EAAU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,CAAC,EAA2C,CAC7D,OAAO,EAAO,WAAW,CACvB,IAAK,EACL,MAAO,CAAC,IAAU,CACpB,CAAC,EAGH,SAAS,CAAW,CAAC,EAA6B,EAAiB,CACjE,OAAO,IAAU,MAAQ,IAAU,OAAY,EAAO,KAAS,MAAM,CAAO,CAAC,EAAI,EAAO,QAAQ,CAAK,EAGvG,SAAS,EAAY,CAAC,EAA6B,CACjD,IAAM,EAAQ,EAAM,OAAO,CAAK,EAChC,GAAI,aAAiB,MAAO,OAAO,EAAM,QACzC,GAAI,OAAO,IAAU,UAAY,IAAU,MAAQ,YAAa,GAAS,OAAO,EAAM,UAAY,SAChG,OAAO,EAAM,QAEf,OAAO,OAAO,CAAK", | ||
| "debugId": "C812B28B6854912F64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../core/src/installation/version.ts"], | ||
| "sourcesContent": [ | ||
| "declare global {\n const OPENCODE_VERSION: string\n const OPENCODE_CHANNEL: string\n}\n\nexport const InstallationVersion = typeof OPENCODE_VERSION === \"string\" ? OPENCODE_VERSION : \"local\"\nexport const InstallationChannel = typeof OPENCODE_CHANNEL === \"string\" ? OPENCODE_CHANNEL : \"local\"\nexport const InstallationLocal = InstallationChannel === \"local\"\n" | ||
| ], | ||
| "mappings": ";AAKO,IAAM,EAA6D,mBAC7D,EAA6D,OAC7D,EAAoB", | ||
| "debugId": "5DAB758EDCD87EDD64756E2164756E21", | ||
| "names": [] | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["src/commands/handlers/migrate.ts"], | ||
| "sourcesContent": [ | ||
| "import { Effect } from \"effect\"\nimport { Commands } from \"../commands\"\nimport { Runtime } from \"../../framework/runtime\"\n\nexport default Runtime.handler(Commands.commands.migrate, (_input) => Effect.log(\"No migrations to run.\"))\n" | ||
| ], | ||
| "mappings": ";ivBAIA,SAAe,SAAQ,aAAQ,OAAS,cAAS,aAAS,MAAC,SAAW,OAAO,SAAI,4BAAuB,MAAC", | ||
| "debugId": "16CFE6704F84F1D764756E2164756E21", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is not supported yet
258404464
0