🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@opencode-ai/cli-linux-x64

Package Overview
Dependencies
Maintainers
2
Versions
2263
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencode-ai/cli-linux-x64 - npm Package Compare versions

Comparing version
0.0.0-next-16027
to
0.0.0-next-16033
+10
bin/chunk-0e9szfx2.js.map
{
"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": ";66BAAA,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,CAC1C,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": "408C18CAC640DF8A64756E2164756E21",
"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/util/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 global = yield* Global.Service\n const configPath = yield* Effect.promise(() => resolveConfigPath(input.global ? global.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": ";qrBAAA,mBAAS,gBACT,yBACA,w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,CACjB,EAAK,KAAK,EAAW,eAAe,EACpC,EAAK,KAAK,EAAW,gBAAgB,EACrC,EAAK,KAAK,EAAW,YAAa,eAAe,EACjD,EAAK,KAAK,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": "5935E728C5B31F9964756E2164756E21",
"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 config: {\n update: (update) => runServicePromise(config.update(update)),\n },\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,EACX,OAAQ,CACN,OAAQ,CAAC,IAAW,EAAkB,EAAO,OAAO,CAAM,CAAC,CAC7D,CACF,CAAC,CACH,EACD,CACH",
"debugId": "B915ABB75B938B5764756E2164756E21",
"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": ";+0BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,WACnC,OAAO,QAAG,wBAAmB,OAAE,cAAU,OAAG,MAC1C,SAAM,OAAY,WAAO,OAAQ,YAAO,MAAO,EAAc,QAAQ,CAAC,EACtE,QAAQ,OAAO,MAAM,EAAU,IAAM,CAAG,EACzC,CACH",
"debugId": "882EDB8FFBBB07A964756E2164756E21",
"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": ";83BAAA,mBAAS,gBAQT,SAAM,OAAW,MAAE,eAAW,aAAQ,SAAI,MAAE,OAE7B,SAAQ,aACrB,OAAS,cAAS,UAAK,cAAS,aAChC,OAAO,QAAG,uBAAkB,OAAE,cAAU,MAAC,EAAO,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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46ACAAA8664756E2164756E21",
"names": []
}

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": ";83BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,WAAM,cAAS,YACjC,OAAO,QAAG,uBAAkB,OAAE,cAAU,OAAG,MACzC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,GADQ,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": "97096986A07B4DC964756E2164756E21",
"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": ";83BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,UAC/B,OAAO,QAAG,mBAAc,OAAE,cAAU,OAAG,MACrC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,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,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": "31632EC4E9C311F864756E2164756E21",
"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": ";+0BAMA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,UACnC,OAAO,QAAG,uBAAkB,OAAE,cAAU,OAAG,MACzC,WAAO,OAAQ,UAAK,WAAO,OAAc,aAAQ,MAAC,EACnD,CACH",
"debugId": "C8258D95CE88312564756E2164756E21",
"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": ";2oBAIA,SAAe,SAAQ,aAAQ,OAAS,cAAS,aAAS,MAAC,SAAW,OAAO,SAAI,4BAAuB,MAAC",
"debugId": "BC8C3A98F28D6D2264756E2164756E21",
"names": []
}

Sorry, the diff of this file is too big to display

{
"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": ";+0BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,aACnC,OAAO,QAAG,0BAAqB,OAAE,cAAU,OAAG,MAC5C,SAAM,OAAU,WAAO,OAAc,aAAQ,EAC7C,MAAO,EAAQ,KAAK,CAAO,EAC3B,IAAM,EAAY,MAAO,EAAQ,OAAO,CAAO,EAC/C,QAAQ,OAAO,MAAM,EAAU,IAAM,CAAG,EACzC,CACH",
"debugId": "980F38570B29248F64756E2164756E21",
"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": ";+0BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,YACnC,OAAO,QAAG,yBAAoB,OAAE,cAAU,OAAG,MAC3C,SAAM,OAAU,WAAO,OAAc,aAAQ,EACvC,EAAQ,MAAO,EAAQ,SAAS,IAAK,EAAS,QAAS,MAAU,CAAC,EACxE,QAAQ,OAAO,OAAO,GAAO,KAAO,WAAa,CAAG,EACrD,CACH",
"debugId": "63FF9ECAF29B058864756E2164756E21",
"names": []
}
{
"version": 3,
"sources": ["src/services/server-connection.ts"],
"sourcesContent": [
"import { Service, type Endpoint, type EnsureOptions } from \"@opencode-ai/client/effect/service\"\nimport { ClientError, isUnauthorizedError, OpenCode } from \"@opencode-ai/client/promise\"\nimport { OPENCODE_VERSION } from \"../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 !== OPENCODE_VERSION)\n process.stderr.write(\n `Warning: Server at ${endpoint.url} has version ${health.version}; this client is ${OPENCODE_VERSION}. 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": ";0cAoBO,SAAM,OAAU,OAAO,QAAG,oCAA+B,OAAE,cAAU,CAAC,EAAY,CACvF,GAAI,EAAK,SAAW,QAAa,EAAK,WACpC,OAAO,MAAO,EAAO,KAAS,MAAM,8CAA8C,CAAC,EACrF,GAAI,EAAK,SAAW,OAAW,CAC7B,IAAM,EAAW,MAAO,EAAI,SACtB,EAAW,CACf,IAAK,EAAK,OACV,KAAM,EAAW,CAAE,KAAM,QAAkB,SAAU,WAAY,SAAU,EAAS,MAAM,CAAQ,CAAE,EAAI,MAC1G,EACM,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EACpF,EAAS,MAAO,EAAO,WAAW,CACtC,IAAK,IAAM,EAAO,OAAO,IAAI,CAAE,OAAQ,YAAY,QAAQ,IAAK,CAAE,CAAC,EACnE,MAAO,CAAC,IAAU,EAAa,EAAU,CAAK,CAChD,CAAC,EACD,GAAI,EAAO,UAAY,EACrB,QAAQ,OAAO,MACb,sBAAsB,EAAS,mBAAmB,EAAO,2BAA2B;AAAA,CACtF,EACF,MAAO,CAAE,UAAS,EAEpB,GAAI,EAAK,WACP,MAAO,CAAE,SAAU,MAAO,EAAW,MAAM,CAAE,EAG/C,IAAM,EAAU,MAAO,EAAc,QAAQ,EAC7C,MAAO,CACL,SAAU,MAAO,EAAe,IAAK,EAAS,QAAS,EAAK,OAAQ,EAAG,EAAK,UAAY,SAAS,EACjG,QAAS,EAAe,CAAO,CACjC,EACD,EAED,SAAS,CAAc,CAAC,EAAwB,CAC9C,IAAM,EAAmB,IAAK,EAAS,QAAS,MAAU,EAC1D,MAAO,CACL,UAAW,IAAM,EAAQ,OAAO,CAAgB,EAChD,QAAS,IACP,EAAO,IAAI,SAAU,EAAG,CACtB,MAAO,EAAQ,KAAK,CAAO,EAC3B,MAAO,EAAQ,OAAO,CAAgB,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": "9CED01F2E9A5836864756E2164756E21",
"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": ";00BAAA,mBAAS,gBAMT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,SACnC,OAAO,QAAG,sBAAiB,OAAE,cAAU,MAAC,OAAO,MAC7C,aAAQ,YAAO,YAAO,WAAO,EAAc,IAAI,EAAO,eAAe,EAAM,GAAG,CAAC,GAAK,CAAG,EACxF,CACH",
"debugId": "0238A6B004869E8164756E2164756E21",
"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/util/effect/layer-node\"\nimport { Global } from \"@opencode-ai/util/global\"\nimport { OPENCODE_CHANNEL, OPENCODE_VERSION } from \"./version\"\nimport { AppProcess } from \"@opencode-ai/util/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(\n LayerNode.compile(LayerNode.group([Global.node, AppProcess.node]), [\n [\n Global.node,\n Global.layerWith(process.env.OPENCODE_CONFIG_DIR ? { config: process.env.OPENCODE_CONFIG_DIR } : {}),\n ],\n ]),\n ),\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 app: {\n name: process.env.OPENCODE_CLIENT ?? \"cli\",\n version: OPENCODE_VERSION,\n channel: OPENCODE_CHANNEL,\n },\n hostname,\n port,\n password,\n simulation: truthy(process.env.OPENCODE_SIMULATE),\n database: {\n path:\n process.env.OPENCODE_DB ??\n ([\"latest\", \"beta\", \"prod\"].includes(OPENCODE_CHANNEL) ||\n process.env.OPENCODE_DISABLE_CHANNEL_DB === \"1\" ||\n process.env.OPENCODE_DISABLE_CHANNEL_DB === \"true\"\n ? \"opencode.db\"\n : `opencode-${OPENCODE_CHANNEL.replace(/[^a-zA-Z0-9._-]/g, \"-\")}.db`),\n },\n models: {\n url: process.env.OPENCODE_MODELS_URL,\n file: process.env.OPENCODE_MODELS_PATH,\n fetch: !truthy(process.env.OPENCODE_DISABLE_MODELS_FETCH),\n },\n observability: {\n endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,\n headers: process.env.OTEL_EXPORTER_OTLP_HEADERS,\n },\n config: {\n directory: process.env.OPENCODE_CONFIG_DIR,\n project: !truthy(\n process.env.OPENCODE_CONFIG_PROJECT_DISABLE ?? process.env.OPENCODE_DISABLE_PROJECT_CONFIG,\n ),\n file: process.env.OPENCODE_CONFIG,\n content: process.env.OPENCODE_CONFIG_CONTENT,\n },\n windows: {\n gitbash: process.env.OPENCODE_GIT_BASH_PATH,\n },\n fs: {\n filewatcher: !truthy(\n process.env.OPENCODE_FILEWATCHER_DISABLE ?? process.env.OPENCODE_DISABLE_FILEWATCHER,\n ),\n fff:\n process.env.OPENCODE_DISABLE_FFF === undefined\n ? process.platform !== \"win32\"\n : !truthy(process.env.OPENCODE_DISABLE_FFF),\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: OPENCODE_VERSION,\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 truthy(value?: string) {\n return value === \"1\" || value?.toLowerCase() === \"true\"\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": ";0kCAQA,2BAAS,qBAAa,oBACtB,yBAgBO,SAAM,OAAM,OAAO,gBAAW,cAAU,MAAC,OAAkB,MAChE,YAAO,WAAO,OAAc,MAAO,OAAE,UACnC,OAAO,aAAQ,OAAQ,UAAK,OAC5B,EAAO,QACL,EAAU,QAAQ,EAAU,MAAM,CAAC,EAAO,KAAM,EAAW,IAAI,CAAC,EAAG,CACjE,CACE,EAAO,KACP,EAAO,UAAU,QAAQ,IAAI,oBAAsB,CAAE,OAAQ,QAAQ,IAAI,mBAAoB,EAAI,CAAC,CAAC,CACrG,CACF,CAAC,CACH,EACA,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,EAA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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": "0F18A970B4CBC59064756E2164756E21",
"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": ";k0BAKA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,SACnC,OAAO,QAAG,sBAAiB,OAAE,cAAU,MAAC,OAAO,MAC7C,WAAO,OAAc,SAAI,OAAM,SAAK,OAAM,KAAK,EAChD,CACH",
"debugId": "217B0F21A34BBE0E64756E2164756E21",
"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": ";66BAAA,mBAAS,gBAST,SAAe,SAAQ,aACrB,OAAS,cAAS,UAClB,OAAO,QAAG,eAAU,OAAE,cAAU,OAAG,MACjC,SAAM,OAAW,WAAO,OAAQ,YAAO,WAAO,OAAc,aAAQ,MAAC,EAC/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": "4CE250B634AF740E64756E2164756E21",
"names": []
}
{
"version": 3,
"sources": ["src/services/service-config.ts"],
"sourcesContent": [
"import { Global } from \"@opencode-ai/util/global\"\nimport { OPENCODE_CHANNEL, OPENCODE_VERSION } from \"../version\"\nimport { Hash } from \"@opencode-ai/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 = OPENCODE_CHANNEL) {\n if (channel === \"latest\" || channel === \"next\") return \"service.json\"\n return `service-${channel.replace(/[^a-zA-Z0-9._-]/g, \"-\")}.json`\n}\n\nexport function defaultPort(channel = OPENCODE_CHANNEL) {\n if (channel === \"latest\" || channel === \"next\") 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 legacyFilename(channel = OPENCODE_CHANNEL) {\n if (channel === \"latest\" || channel === \"local\") return\n return `service-${Hash.fast(channel)}.json`\n}\n\nexport function versionBelongsToChannel(\n version: string | undefined,\n channel = OPENCODE_CHANNEL,\n installedVersion = OPENCODE_VERSION,\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 = OPENCODE_CHANNEL,\n installedVersion = OPENCODE_VERSION,\n) {\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\nexport const migrateConfig = Effect.fnUntraced(function* (legacy: string, file: string) {\n const fs = yield* FileSystem.FileSystem\n const text = yield* fs.readFileString(legacy).pipe(Effect.option)\n if (Option.isNone(text)) return\n if (Option.isNone(yield* decodeInfo(text.value).pipe(Effect.option))) 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 legacy = legacyFilename()\n const file = path.join(global.state, name)\n return {\n fs,\n file,\n legacyConfigFile: legacy ? path.join(global.config, legacy) : undefined,\n legacyRegistrationFiles: [\n ...(legacy ? [path.join(global.state, legacy)] : []),\n ...(name !== \"service.json\" && OPENCODE_CHANNEL !== \"local\" ? [path.join(global.state, \"service.json\")] : []),\n ],\n configFile: path.join(global.config, name),\n }\n})\n\nexport const options = Effect.fnUntraced(function* () {\n const { file, legacyRegistrationFiles } = yield* paths\n yield* Effect.forEach(legacyRegistrationFiles, (legacy) => migrateRegistration(legacy, file))\n return {\n file,\n version: OPENCODE_VERSION,\n command: [...selfCommand(), \"serve\", \"--service\"],\n }\n})\n\nexport const read = Effect.fn(\"cli.service-config.read\")(function* () {\n const { fs, configFile, legacyConfigFile } = yield* paths\n if (legacyConfigFile) yield* migrateConfig(legacyConfigFile, configFile)\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"
],
"mappings": ";gkBAKA,2BAAS,oBACT,yBAOO,SAAM,OAAO,EAAO,OAAO,CAChC,SAAU,EAAO,SAAS,EAAO,MAAM,EACvC,KAAM,EAAO,SAAS,EAAO,IAAI,MAAM,EAAO,uBAAuB,CAAC,EAAG,EAAO,oBAAoB,KAAM,CAAC,CAAC,EAC5G,SAAU,EAAO,SAAS,EAAO,MAAM,CACzC,CAAC,EAMD,IAAM,EAAa,EAAO,oBAAoB,EAAO,eAAe,CAAI,CAAC,EACnE,EAAqB,EAAO,oBAAoB,EAAO,eAAe,EAAQ,IAAI,CAAC,EAElF,SAAS,CAAQ,CAAC,EAAU,EAAkB,CACnD,GAAI,IAAY,UAAY,IAAY,OAAQ,MAAO,eACvD,MAAO,WAAW,EAAQ,QAAQ,mBAAoB,GAAG,SAGpD,SAAS,CAAW,CAAC,EAAU,EAAkB,CACtD,GAAI,IAAY,UAAY,IAAY,OAAQ,MAAO,OACvD,GAAI,IAAY,QAAS,MAAO,OAChC,MAAO,KAAU,OAAO,SAAS,EAAK,KAAK,CAAO,EAAE,MAAM,EAAG,CAAC,EAAG,EAAE,EAAI,MAGlE,SAAS,CAAc,CAAC,EAAU,EAAkB,CACzD,GAAI,IAAY,UAAY,IAAY,QAAS,OACjD,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ACK,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": "F078B3565094F56F64756E2164756E21",
"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 ? `${p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,CAAM,EAAE,OAAO,EAAE,KAAU,CAAC,EAAK,IAAI,CAAI,CAAC,CAAC,EAAE,SAAS,EACvG,OAAO,EAAQ,GAAG,KAAY,IAAU",
"debugId": "E0CE0AF1CF9C51D464756E2164756E21",
"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/util/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": ";0lCAYA,OAAwB,OACxB,SAAM,O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O,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": "E44573A494AAEBD264756E2164756E21",
"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": ";k0BAKA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,WACnC,OAAO,QAAG,wBAAmB,OAAE,cAAU,MAAC,OAAO,MAC/C,WAAO,OAAc,WAAM,OAAM,QAAG,OACrC,CACH",
"debugId": "3195B6BC099E09E464756E2164756E21",
"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": ";66BAAA,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,CAC5C,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": "D55DC034FDF4FCEA64756E2164756E21",
"names": []
}
{
"version": 3,
"sources": ["src/version.ts"],
"sourcesContent": [
"declare const OPENCODE_VERSION: string\ndeclare const OPENCODE_CHANNEL: string\n\nconst version = typeof OPENCODE_VERSION === \"string\" ? OPENCODE_VERSION : \"local\"\nconst channel = typeof OPENCODE_CHANNEL === \"string\" ? OPENCODE_CHANNEL : \"local\"\n\nexport { version as OPENCODE_VERSION, channel as OPENCODE_CHANNEL }\nexport const OPENCODE_LOCAL = channel === \"local\"\n"
],
"mappings": ";AAGA,IAAM,EAAiD,mBACjD,EAAiD,OAGhD,IAAM,EAAiB",
"debugId": "37D79C53D73A1B8664756E2164756E21",
"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": ";83BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,YAAO,cAAS,UAClC,OAAO,QAAG,sBAAiB,OAAE,cAAU,OAAG,MACxC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,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,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": "A98FFAF5C52FCEBD64756E2164756E21",
"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": "B07C05B3FE06C7B764756E2164756E21",
"names": []
}

Sorry, the diff of this file is too big to display

{
"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/util/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 { 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 (options.variant\n ? await client.model\n .default({ location: { directory: next.location.directory, workspace: next.location.workspaceID } })\n .then((result) => result.data)\n : undefined)\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 return { model, agent: next.agent }\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 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 SessionMessageInfo,\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 const renderedText = new Map<string, string>()\n const renderedReasoning = new Map<string, string>()\n const renderedTools = new Set<string>()\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 prePromotionError: { message: string; [key: string]: unknown } | undefined\n let finalizing = 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 writeReasoning = (part: { text: string; [key: string]: unknown }, timestamp: number) => {\n if (emit(\"reasoning\", timestamp, { part })) return\n const text = part.text.trim()\n if (!text) return\n const line = `Thinking: ${text}`\n if (!process.stdout.isTTY) return void process.stdout.write(line + EOL)\n UI.empty()\n UI.println(`${UI.Style.TEXT_DIM}\\u001b[3m${line}\\u001b[0m${UI.Style.TEXT_NORMAL}`)\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 prePromotionError = undefined\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 && event.type === \"session.execution.failed\") {\n prePromotionError = event.data.error\n if (finalizing) return\n continue\n }\n if (\n !promoted &&\n finalizing &&\n (event.type === \"session.execution.succeeded\" || event.type === \"session.execution.interrupted\")\n )\n return\n if (!promoted) continue\n if (finalizing && !event.type.startsWith(\"session.execution.\")) 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\\u0000${contentKey(event.data.assistantMessageID, event.data.ordinal)}`, {\n id: partID(event.id),\n timestamp: time,\n })\n continue\n }\n if (event.type === \"session.text.ended\") {\n const key = contentKey(event.data.assistantMessageID, event.data.ordinal)\n const started = starts.get(`text\\u0000${key}`)\n starts.delete(`text\\u0000${key}`)\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 renderedText.set(key, event.data.text)\n writeText(part, time)\n continue\n }\n\n if (event.type === \"session.reasoning.started\") {\n flushStep()\n starts.set(`reasoning\\u0000${contentKey(event.data.assistantMessageID, event.data.ordinal)}`, {\n id: partID(event.id),\n timestamp: time,\n })\n continue\n }\n if (event.type === \"session.reasoning.ended\" && input.thinking) {\n const key = contentKey(event.data.assistantMessageID, event.data.ordinal)\n const started = starts.get(`reasoning\\u0000${key}`)\n starts.delete(`reasoning\\u0000${key}`)\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 renderedReasoning.set(key, event.data.text)\n writeReasoning(part, time)\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 renderedTools.add(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 structured = event.data.metadata ?? current.structured\n const content = event.data.content ?? current.content\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,\n 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 renderedTools.add(key)\n if (input.compatibility === \"v1\" && (permissionRejected || formCancelled)) continue\n if (!emit(\"tool_use\", time, { part })) {\n if (toolOutputText(current.tool, content).trim())\n await input.renderTool({\n ...tool,\n state: {\n status: \"completed\",\n input: current.input,\n structured,\n 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 projectedMessages = async () => {\n const messages: SessionMessageInfo[] = []\n let cursor: string | undefined\n while (true) {\n const page = await input.client.message.list(\n cursor\n ? { sessionID: input.sessionID, limit: 200, cursor }\n : { sessionID: input.sessionID, limit: 200, order: \"desc\" },\n )\n for (const message of page.data) {\n if (message.id === messageID) return { found: true, messages: messages.toReversed() }\n messages.push(message)\n }\n cursor = page.cursor.next ?? undefined\n if (!cursor) return { found: false, messages: [] }\n }\n }\n\n const reconcile = async () => {\n const projected = await projectedMessages()\n for (const message of projected.messages) {\n if (message.type !== \"assistant\") continue\n const timestamp = message.time.completed ?? message.time.created\n let textOrdinal = 0\n let reasoningOrdinal = 0\n for (const item of message.content) {\n if (item.type === \"text\") {\n const ordinal = textOrdinal++\n const key = contentKey(message.id, ordinal)\n const rendered = renderedText.get(key) ?? \"\"\n if (rendered === item.text || !item.text.startsWith(rendered)) continue\n const text = item.text.slice(rendered.length)\n writeText(\n {\n id: projectedPartID(message.id, `text-${ordinal}`),\n sessionID: input.sessionID,\n messageID: message.id,\n type: \"text\",\n text,\n time: { start: message.time.created, end: timestamp },\n },\n timestamp,\n )\n renderedText.set(key, item.text)\n continue\n }\n if (item.type === \"reasoning\") {\n const ordinal = reasoningOrdinal++\n if (!input.thinking) continue\n const key = contentKey(message.id, ordinal)\n const rendered = renderedReasoning.get(key) ?? \"\"\n if (rendered === item.text || !item.text.startsWith(rendered)) continue\n const text = item.text.slice(rendered.length)\n const part = {\n id: projectedPartID(message.id, `reasoning-${ordinal}`),\n sessionID: input.sessionID,\n messageID: message.id,\n type: \"reasoning\",\n text,\n metadata: item.state,\n time: { start: message.time.created, end: timestamp },\n }\n renderedReasoning.set(key, item.text)\n writeReasoning(part, timestamp)\n continue\n }\n\n const key = toolKey(message.id, item.id)\n if (renderedTools.has(key) || item.state.status === \"streaming\" || item.state.status === \"running\") continue\n const part: MiniToolPart = {\n id: projectedPartID(message.id, `tool-${item.id}`),\n sessionID: input.sessionID,\n messageID: message.id,\n type: \"tool\",\n callID: item.id,\n tool: item.name,\n state:\n item.state.status === \"completed\"\n ? {\n status: \"completed\",\n input: item.state.input,\n output: toolOutputText(item.name, item.state.content),\n title: item.name,\n metadata: { structured: item.state.structured, content: item.state.content, result: item.state.result },\n time: { start: item.time.ran ?? item.time.created, end: item.time.completed ?? timestamp },\n }\n : {\n status: \"error\",\n input: item.state.input,\n error: item.state.error.message,\n metadata: { structured: item.state.structured, content: item.state.content, result: item.state.result },\n time: { start: item.time.ran ?? item.time.created, end: item.time.completed ?? timestamp },\n },\n }\n renderedTools.add(key)\n if (emit(\"tool_use\", timestamp, { part })) continue\n if (item.state.status === \"completed\") {\n await input.renderTool(item)\n continue\n }\n if (toolOutputText(item.name, item.state.content).trim()) {\n await input.renderTool({ ...item, state: { ...item.state, status: \"completed\" } })\n }\n await input.renderToolError(item)\n UI.error(item.state.error.message)\n }\n\n if (message.error && !emittedError) {\n emittedError = true\n process.exitCode = 1\n if (!emit(\"error\", timestamp, { error: message.error })) UI.error(message.error.message)\n }\n }\n return {\n found: projected.found,\n responded: projected.messages.some((message) => message.type === \"assistant\"),\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 if (input.compatibility === \"v1\") {\n await completed\n return\n }\n\n const waiting = input.client.session.wait({ sessionID: input.sessionID })\n await Promise.race([waiting, completed.then(() => waiting)])\n finalizing = true\n const projected = await reconcile()\n if (\n !projected.responded &&\n !interrupted &&\n !permissionRejected &&\n !formCancelled &&\n !emittedError &&\n !prePromotionError\n ) {\n await completed\n }\n if (!projected.found && !interrupted && !permissionRejected && !formCancelled && !emittedError) {\n const error = prePromotionError ?? { type: \"unknown\", message: \"Prompt was not promoted\" }\n emittedError = true\n process.exitCode = 1\n if (!emit(\"error\", Date.now(), { error })) UI.error(error.message)\n }\n } finally {\n process.off(\"SIGINT\", interrupt)\n controller.abort()\n if (input.compatibility === \"v1\") await stream.return?.(undefined).catch(() => {})\n else void 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 contentKey(messageID: string, ordinal: number) {\n return `${messageID}\\u0000${ordinal}`\n}\n\nfunction projectedPartID(messageID: string, part: string) {\n return `prt_${messageID.replace(/^msg_/, \"\")}_${part}`\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": ";o/BAGA,oBAAS,0BACT,0BCMA,mBAAS,gBACT,wBAAS,wGCXT,mBAAS,iBAEF,SAAM,OAAQ,MACnB,cAAU,gBACV,iBAAa,eACb,uBAAmB,uBACnB,sBAAkB,sBACpB,OAEO,cAAS,MAAO,SAAI,OAAmB,CAC5C,QAAQ,OAAO,MAAM,EAAQ,KAAK,GAAG,EAAI,EAAG,EAG9C,IAAI,GAAQ,GAEL,SAAS,EAAK,EAAG,CACtB,GAAI,GAAO,OACX,EAAQ,EAAM,WAAW,EACzB,GAAQ,GAGH,SAAS,EAAK,CAAC,EAAiB,CACrC,GAAI,EAAQ,WAAW,SAAS,EAAG,EAAU,EAAQ,MAAM,CAAgB,EAC3E,EAAQ,EAAM,iBAAmB,UAAY,EAAM,YAAc,CAAO,ED4C1E,IAAM,EAAyB,SAE/B,eAAsB,EAAuB,CAAC,EAAc,CAC1D,IAAM,EAAa,IAAI,gBACjB,EAAS,EAAM,OAAO,MAAM,UAAU,CAAE,OAAQ,EAAW,MAAO,CAAC,EAAE,OAAO,eAAe,EAEjG,IADkB,MAAM,EAAO,KAAK,GACtB,KAAM,MAAU,MAAM,mDAAmD,EAEvF,IAAM,EAAY,GAAe,GAAG,OAAO,EACrC,EAAS,IAAI,IACb,EAAQ,IAAI,IACZ,EAAe,IAAI,IACnB,EAAoB,IAAI,IACxB,EAAgB,IAAI,IACtB,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AGlB,SAAS,CAAI,CAAC,EAAwB,CACpC,MAAU,MAAM,CAAO",
"debugId": "C3F7ED78D4DC38D564756E2164756E21",
"names": []
}
+1
-1
{
"name": "@opencode-ai/cli-linux-x64",
"version": "0.0.0-next-16027",
"version": "0.0.0-next-16033",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

{
"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": ";00BAAA,mBAAS,gBAMT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,SACnC,OAAO,QAAG,sBAAiB,OAAE,cAAU,MAAC,OAAO,MAC7C,aAAQ,YAAO,YAAO,WAAO,EAAc,IAAI,EAAO,eAAe,EAAM,GAAG,CAAC,GAAK,CAAG,EACxF,CACH",
"debugId": "0238A6B004869E8164756E2164756E21",
"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": ";66BAAA,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,CAC5C,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": "D55DC034FDF4FCEA64756E2164756E21",
"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": ";+0BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,WACnC,OAAO,QAAG,wBAAmB,OAAE,cAAU,OAAG,MAC1C,SAAM,OAAY,WAAO,OAAQ,YAAO,MAAO,EAAc,QAAQ,CAAC,EACtE,QAAQ,OAAO,MAAM,EAAU,IAAM,CAAG,EACzC,CACH",
"debugId": "882EDB8FFBBB07A964756E2164756E21",
"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": ";83BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,YAAO,cAAS,UAClC,OAAO,QAAG,sBAAiB,OAAE,cAAU,OAAG,MACxC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,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,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": "A98FFAF5C52FCEBD64756E2164756E21",
"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": ";83BAAA,mBAAS,gBAQT,SAAM,OAAW,MAAE,eAAW,aAAQ,SAAI,MAAE,OAE7B,SAAQ,aACrB,OAAS,cAAS,UAAK,cAAS,aAChC,OAAO,QAAG,uBAAkB,OAAE,cAAU,MAAC,EAAO,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,UAA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/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": "B07C05B3FE06C7B764756E2164756E21",
"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,QAA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,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": "E0CE0AF1CF9C51D464756E2164756E21",
"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/util/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": ";0lCAYA,OAAwB,OACxB,SAAM,OAAiB,MAAC,cAAI,cAAK,cAAK,cAAK,cAAK,cAAK,cAAK,cAAK,cAAK,aAAG,OACjE,QAAe,UACf,OAAS,MACb,YAAQ,OAAK,eAAU,MAAC,EACxB,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,MA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SAAW,SAAU,MAAO,EAAO,KAAS,MAAM,EAAO,OAAO,CAAC,EAC5E,GAAI,EAAO,SAAW,UAAW,MAAO,EAAO,KAAS,MAAM,qBAAqB,CAAC,EAEpF,MAAO,EAAQ,IAAM,EAAS,QAAQ,+BAA+B,CAAC,EACtE,MAAO,EAAQ,IAAM,EAAS,MAAM,MAAM,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": "E44573A494AAEBD264756E2164756E21",
"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": ";83BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,UAC/B,OAAO,QAAG,mBAAc,OAAE,cAAU,OAAG,MACrC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,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,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": "31632EC4E9C311F864756E2164756E21",
"names": []
}
{
"version": 3,
"sources": ["src/version.ts"],
"sourcesContent": [
"declare const OPENCODE_VERSION: string\ndeclare const OPENCODE_CHANNEL: string\n\nconst version = typeof OPENCODE_VERSION === \"string\" ? OPENCODE_VERSION : \"local\"\nconst channel = typeof OPENCODE_CHANNEL === \"string\" ? OPENCODE_CHANNEL : \"local\"\n\nexport { version as OPENCODE_VERSION, channel as OPENCODE_CHANNEL }\nexport const OPENCODE_LOCAL = channel === \"local\"\n"
],
"mappings": ";AAGA,IAAM,EAAiD,mBACjD,EAAiD,OAGhD,IAAM,EAAiB",
"debugId": "BA1623A5D09EA80B64756E2164756E21",
"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": ";83BAAA,mBAAS,gBAQT,SAAe,SAAQ,aACrB,OAAS,cAAS,WAAM,cAAS,YACjC,OAAO,QAAG,uBAAkB,OAAE,cAAU,OAAG,MACzC,SAAM,OAAU,WAAO,OAAc,aAAQ,OAEvC,GADQ,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": "97096986A07B4DC964756E2164756E21",
"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": ";+0BAMA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,UACnC,OAAO,QAAG,uBAAkB,OAAE,cAAU,OAAG,MACzC,WAAO,OAAQ,UAAK,WAAO,OAAc,aAAQ,MAAC,EACnD,CACH",
"debugId": "C8258D95CE88312564756E2164756E21",
"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": ";k0BAKA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,SACnC,OAAO,QAAG,sBAAiB,OAAE,cAAU,MAAC,OAAO,MAC7C,WAAO,OAAc,SAAI,OAAM,SAAK,OAAM,KAAK,EAChD,CACH",
"debugId": "217B0F21A34BBE0E64756E2164756E21",
"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/util/effect/layer-node\"\nimport { Global } from \"@opencode-ai/util/global\"\nimport { OPENCODE_CHANNEL, OPENCODE_VERSION } from \"./version\"\nimport { AppProcess } from \"@opencode-ai/util/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(\n LayerNode.compile(LayerNode.group([Global.node, AppProcess.node]), [\n [\n Global.node,\n Global.layerWith(process.env.OPENCODE_CONFIG_DIR ? { config: process.env.OPENCODE_CONFIG_DIR } : {}),\n ],\n ]),\n ),\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 app: {\n name: process.env.OPENCODE_CLIENT ?? \"cli\",\n version: OPENCODE_VERSION,\n channel: OPENCODE_CHANNEL,\n },\n hostname,\n port,\n password,\n simulation: truthy(process.env.OPENCODE_SIMULATE),\n database: {\n path:\n process.env.OPENCODE_DB ??\n ([\"latest\", \"beta\", \"prod\"].includes(OPENCODE_CHANNEL) ||\n process.env.OPENCODE_DISABLE_CHANNEL_DB === \"1\" ||\n process.env.OPENCODE_DISABLE_CHANNEL_DB === \"true\"\n ? \"opencode.db\"\n : `opencode-${OPENCODE_CHANNEL.replace(/[^a-zA-Z0-9._-]/g, \"-\")}.db`),\n },\n models: {\n url: process.env.OPENCODE_MODELS_URL,\n file: process.env.OPENCODE_MODELS_PATH,\n fetch: !truthy(process.env.OPENCODE_DISABLE_MODELS_FETCH),\n },\n observability: {\n endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,\n headers: process.env.OTEL_EXPORTER_OTLP_HEADERS,\n },\n config: {\n directory: process.env.OPENCODE_CONFIG_DIR,\n project: !truthy(\n process.env.OPENCODE_CONFIG_PROJECT_DISABLE ?? process.env.OPENCODE_DISABLE_PROJECT_CONFIG,\n ),\n file: process.env.OPENCODE_CONFIG,\n content: process.env.OPENCODE_CONFIG_CONTENT,\n },\n windows: {\n gitbash: process.env.OPENCODE_GIT_BASH_PATH,\n },\n fs: {\n filewatcher: !truthy(\n process.env.OPENCODE_FILEWATCHER_DISABLE ?? process.env.OPENCODE_DISABLE_FILEWATCHER,\n ),\n fff:\n process.env.OPENCODE_DISABLE_FFF === undefined\n ? process.platform !== \"win32\"\n : !truthy(process.env.OPENCODE_DISABLE_FFF),\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: OPENCODE_VERSION,\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 truthy(value?: string) {\n return value === \"1\" || value?.toLowerCase() === \"true\"\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\",\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,SAAS,CAAY,CAAC,EAAyB,CAC7C,GAAI,OAAO,IAAU,UAAY,IAAU,KAAM,MAAO,GACxD,GAAI,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,EC/OH,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": "0F18A970B4CBC59064756E2164756E21",
"names": []
}
{
"version": 3,
"sources": ["src/services/server-connection.ts"],
"sourcesContent": [
"import { Service, type Endpoint, type EnsureOptions } from \"@opencode-ai/client/effect/service\"\nimport { ClientError, isUnauthorizedError, OpenCode } from \"@opencode-ai/client/promise\"\nimport { OPENCODE_VERSION } from \"../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 !== OPENCODE_VERSION)\n process.stderr.write(\n `Warning: Server at ${endpoint.url} has version ${health.version}; this client is ${OPENCODE_VERSION}. 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": ";0cAoBO,SAAM,OAAU,OAAO,QAAG,oCAA+B,OAAE,cAAU,CAAC,EAAY,CACvF,GAAI,EAAK,SAAW,QAAa,EAAK,WACpC,OAAO,MAAO,EAAO,KAAS,MAAM,8CAA8C,CAAC,EACrF,GAAI,EAAK,SAAW,OAAW,CAC7B,IAAM,EAAW,MAAO,EAAI,SACtB,EAAW,CACf,IAAK,EAAK,OACV,KAAM,EAAW,CAAE,KAAM,QAAkB,SAAU,WAAY,SAAU,EAAS,MAAM,CAAQ,CAAE,EAAI,MAC1G,EACM,EAAS,EAAS,KAAK,CAAE,QAAS,EAAS,IAAK,QAAS,EAAQ,QAAQ,CAAQ,CAAE,CAAC,EACpF,EAAS,MAAO,EAAO,WAAW,CACtC,IAAK,IAAM,EAAO,OAAO,IAAI,CAAE,OAAQ,YAAY,QAAQ,IAAK,CAAE,CAAC,EACnE,MAAO,CAAC,IAAU,EAAa,EAAU,CAAK,CAChD,CAAC,EACD,GAAI,EAAO,UAAY,EACrB,QAAQ,OAAO,MACb,sBAAsB,EAAS,mBAAmB,EAAO,2BAA2B;AAAA,CACtF,EACF,MAAO,CAAE,UAAS,EAEpB,GAAI,EAAK,WACP,MAAO,CAAE,SAAU,MAAO,EAAW,MAAM,CAAE,EAG/C,IAAM,EAAU,MAAO,EAAc,QAAQ,EAC7C,MAAO,CACL,SAAU,MAAO,EAAe,IAAK,EAAS,QAAS,EAAK,OAAQ,EAAG,EAAK,UAAY,SAAS,EACjG,QAAS,EAAe,CAAO,CACjC,EACD,EAED,SAAS,CAAc,CAAC,EAAwB,CAC9C,IAAM,EAAmB,IAAK,EAAS,QAAS,MAAU,EAC1D,MAAO,CACL,UAAW,IAAM,EAAQ,OAAO,CAAgB,EAChD,QAAS,IACP,EAAO,IAAI,SAAU,EAAG,CACtB,MAAO,EAAQ,KAAK,CAAO,EAC3B,MAAO,EAAQ,OAAO,CAAgB,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": "9CED01F2E9A5836864756E2164756E21",
"names": []
}
{
"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": ";66BAAA,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,CAC1C,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": "408C18CAC640DF8A64756E2164756E21",
"names": []
}

Sorry, the diff of this file is too big to display

{
"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": ";66BAAA,mBAAS,gBAST,SAAe,SAAQ,aACrB,OAAS,cAAS,UAClB,OAAO,QAAG,eAAU,OAAE,cAAU,OAAG,MACjC,SAAM,OAAW,WAAO,OAAQ,YAAO,WAAO,OAAc,aAAQ,MAAC,EAC/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": "4CE250B634AF740E64756E2164756E21",
"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/util/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 global = yield* Global.Service\n const configPath = yield* Effect.promise(() => resolveConfigPath(input.global ? global.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": ";qrBAAA,mBAAS,gBACT,yBACA,wBAAS,eAAU,oBAAM,yBAOzB,SAAe,SAAQ,aACrB,OAAS,cAAS,SAAI,cAAS,SAC/B,OAAO,QAAG,aAAa,EAAE,SAAU,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,MAAM,+CAA+C,CAAC,EAE/G,IAAM,EAAS,EACX,CAAE,KAAM,SAAmB,SAAS,EAAU,CAAE,SAAQ,EAAI,CAAC,CAAG,EAChE,CAAE,KAAM,QAAkB,aAAa,EAAc,CAAE,aAAY,EAAI,CAAC,CAAG,EAEzE,EAAS,MAAO,EAAO,QACvB,EAAa,MAAO,EAAO,QAAQ,IAAM,EAAkB,EAAM,OAAS,EAAO,OAAS,QAAQ,IAAI,CAAC,CAAC,EAC9G,MAAO,EAAO,QAAQ,IAAM,EAAM,EAAY,EAAM,KAAM,CAAM,CAAC,EACjE,QAAQ,OAAO,MAAM,eAAe,EAAM,kBAAkB,IAAe,CAAG,EAC/E,CACH,EAEA,eAAsB,CAAiB,CAAC,EAAmB,CACzD,IAAM,EAAa,CACjB,EAAK,KAAK,EAAW,eAAe,EACpC,EAAK,KAAK,EAAW,gBAAgB,EACrC,EAAK,KAAK,EAAW,YAAa,eAAe,EACjD,EAAK,KAAK,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": "5935E728C5B31F9964756E2164756E21",
"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/util/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 { 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 (options.variant\n ? await client.model\n .default({ location: { directory: next.location.directory, workspace: next.location.workspaceID } })\n .then((result) => result.data)\n : undefined)\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 return { model, agent: next.agent }\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 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 SessionMessageInfo,\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 const renderedText = new Map<string, string>()\n const renderedReasoning = new Map<string, string>()\n const renderedTools = new Set<string>()\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 prePromotionError: { message: string; [key: string]: unknown } | undefined\n let finalizing = 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 writeReasoning = (part: { text: string; [key: string]: unknown }, timestamp: number) => {\n if (emit(\"reasoning\", timestamp, { part })) return\n const text = part.text.trim()\n if (!text) return\n const line = `Thinking: ${text}`\n if (!process.stdout.isTTY) return void process.stdout.write(line + EOL)\n UI.empty()\n UI.println(`${UI.Style.TEXT_DIM}\\u001b[3m${line}\\u001b[0m${UI.Style.TEXT_NORMAL}`)\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 prePromotionError = undefined\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 && event.type === \"session.execution.failed\") {\n prePromotionError = event.data.error\n if (finalizing) return\n continue\n }\n if (\n !promoted &&\n finalizing &&\n (event.type === \"session.execution.succeeded\" || event.type === \"session.execution.interrupted\")\n )\n return\n if (!promoted) continue\n if (finalizing && !event.type.startsWith(\"session.execution.\")) 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\\u0000${contentKey(event.data.assistantMessageID, event.data.ordinal)}`, {\n id: partID(event.id),\n timestamp: time,\n })\n continue\n }\n if (event.type === \"session.text.ended\") {\n const key = contentKey(event.data.assistantMessageID, event.data.ordinal)\n const started = starts.get(`text\\u0000${key}`)\n starts.delete(`text\\u0000${key}`)\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 renderedText.set(key, event.data.text)\n writeText(part, time)\n continue\n }\n\n if (event.type === \"session.reasoning.started\") {\n flushStep()\n starts.set(`reasoning\\u0000${contentKey(event.data.assistantMessageID, event.data.ordinal)}`, {\n id: partID(event.id),\n timestamp: time,\n })\n continue\n }\n if (event.type === \"session.reasoning.ended\" && input.thinking) {\n const key = contentKey(event.data.assistantMessageID, event.data.ordinal)\n const started = starts.get(`reasoning\\u0000${key}`)\n starts.delete(`reasoning\\u0000${key}`)\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 renderedReasoning.set(key, event.data.text)\n writeReasoning(part, time)\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 renderedTools.add(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 structured = event.data.metadata ?? current.structured\n const content = event.data.content ?? current.content\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,\n 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 renderedTools.add(key)\n if (input.compatibility === \"v1\" && (permissionRejected || formCancelled)) continue\n if (!emit(\"tool_use\", time, { part })) {\n if (toolOutputText(current.tool, content).trim())\n await input.renderTool({\n ...tool,\n state: {\n status: \"completed\",\n input: current.input,\n structured,\n 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 projectedMessages = async () => {\n const messages: SessionMessageInfo[] = []\n let cursor: string | undefined\n while (true) {\n const page = await input.client.message.list(\n cursor\n ? { sessionID: input.sessionID, limit: 200, cursor }\n : { sessionID: input.sessionID, limit: 200, order: \"desc\" },\n )\n for (const message of page.data) {\n if (message.id === messageID) return { found: true, messages: messages.toReversed() }\n messages.push(message)\n }\n cursor = page.cursor.next ?? undefined\n if (!cursor) return { found: false, messages: [] }\n }\n }\n\n const reconcile = async () => {\n const projected = await projectedMessages()\n for (const message of projected.messages) {\n if (message.type !== \"assistant\") continue\n const timestamp = message.time.completed ?? message.time.created\n let textOrdinal = 0\n let reasoningOrdinal = 0\n for (const item of message.content) {\n if (item.type === \"text\") {\n const ordinal = textOrdinal++\n const key = contentKey(message.id, ordinal)\n const rendered = renderedText.get(key) ?? \"\"\n if (rendered === item.text || !item.text.startsWith(rendered)) continue\n const text = item.text.slice(rendered.length)\n writeText(\n {\n id: projectedPartID(message.id, `text-${ordinal}`),\n sessionID: input.sessionID,\n messageID: message.id,\n type: \"text\",\n text,\n time: { start: message.time.created, end: timestamp },\n },\n timestamp,\n )\n renderedText.set(key, item.text)\n continue\n }\n if (item.type === \"reasoning\") {\n const ordinal = reasoningOrdinal++\n if (!input.thinking) continue\n const key = contentKey(message.id, ordinal)\n const rendered = renderedReasoning.get(key) ?? \"\"\n if (rendered === item.text || !item.text.startsWith(rendered)) continue\n const text = item.text.slice(rendered.length)\n const part = {\n id: projectedPartID(message.id, `reasoning-${ordinal}`),\n sessionID: input.sessionID,\n messageID: message.id,\n type: \"reasoning\",\n text,\n metadata: item.state,\n time: { start: message.time.created, end: timestamp },\n }\n renderedReasoning.set(key, item.text)\n writeReasoning(part, timestamp)\n continue\n }\n\n const key = toolKey(message.id, item.id)\n if (renderedTools.has(key) || item.state.status === \"streaming\" || item.state.status === \"running\") continue\n const part: MiniToolPart = {\n id: projectedPartID(message.id, `tool-${item.id}`),\n sessionID: input.sessionID,\n messageID: message.id,\n type: \"tool\",\n callID: item.id,\n tool: item.name,\n state:\n item.state.status === \"completed\"\n ? {\n status: \"completed\",\n input: item.state.input,\n output: toolOutputText(item.name, item.state.content),\n title: item.name,\n metadata: { structured: item.state.structured, content: item.state.content, result: item.state.result },\n time: { start: item.time.ran ?? item.time.created, end: item.time.completed ?? timestamp },\n }\n : {\n status: \"error\",\n input: item.state.input,\n error: item.state.error.message,\n metadata: { structured: item.state.structured, content: item.state.content, result: item.state.result },\n time: { start: item.time.ran ?? item.time.created, end: item.time.completed ?? timestamp },\n },\n }\n renderedTools.add(key)\n if (emit(\"tool_use\", timestamp, { part })) continue\n if (item.state.status === \"completed\") {\n await input.renderTool(item)\n continue\n }\n if (toolOutputText(item.name, item.state.content).trim()) {\n await input.renderTool({ ...item, state: { ...item.state, status: \"completed\" } })\n }\n await input.renderToolError(item)\n UI.error(item.state.error.message)\n }\n\n if (message.error && !emittedError) {\n emittedError = true\n process.exitCode = 1\n if (!emit(\"error\", timestamp, { error: message.error })) UI.error(message.error.message)\n }\n }\n return {\n found: projected.found,\n responded: projected.messages.some((message) => message.type === \"assistant\"),\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 if (input.compatibility === \"v1\") {\n await completed\n return\n }\n\n const waiting = input.client.session.wait({ sessionID: input.sessionID })\n await Promise.race([waiting, completed.then(() => waiting)])\n finalizing = true\n const projected = await reconcile()\n if (\n !projected.responded &&\n !interrupted &&\n !permissionRejected &&\n !formCancelled &&\n !emittedError &&\n !prePromotionError\n ) {\n await completed\n }\n if (!projected.found && !interrupted && !permissionRejected && !formCancelled && !emittedError) {\n const error = prePromotionError ?? { type: \"unknown\", message: \"Prompt was not promoted\" }\n emittedError = true\n process.exitCode = 1\n if (!emit(\"error\", Date.now(), { error })) UI.error(error.message)\n }\n } finally {\n process.off(\"SIGINT\", interrupt)\n controller.abort()\n if (input.compatibility === \"v1\") await stream.return?.(undefined).catch(() => {})\n else void 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 contentKey(messageID: string, ordinal: number) {\n return `${messageID}\\u0000${ordinal}`\n}\n\nfunction projectedPartID(messageID: string, part: string) {\n return `prt_${messageID.replace(/^msg_/, \"\")}_${part}`\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": ";o/BAGA,oBAAS,0BACT,0BCMA,mBAAS,gBACT,wBAAS,wGCXT,mBAAS,iBAEF,SAAM,OAAQ,MACnB,cAAU,gBACV,iBAAa,eACb,uBAAmB,uBACnB,sBAAkB,sBACpB,OAEO,cAAS,MAAO,SAAI,OAAmB,CAC5C,QAAQ,OAAO,MAAM,EAAQ,KAAK,GAAG,EAAI,EAAG,EAG9C,IAAI,GAAQ,GAEL,SAAS,EAAK,EAAG,CACtB,GAAI,GAAO,OACX,EAAQ,EAAM,WAAW,EACzB,GAAQ,GAGH,SAAS,EAAK,CAAC,EAAiB,CACrC,GAAI,EAAQ,WAAW,SAAS,EAAG,EAAU,EAAQ,MAAM,CAAgB,EAC3E,EAAQ,EAAM,iBAAmB,UAAY,EAAM,YAAc,CAAO,ED4C1E,IAAM,EAAyB,SAE/B,eAAsB,EAAuB,CAAC,EAAc,CAC1D,IAAM,EAAa,IAAI,gBACjB,EAAS,EAAM,OAAO,MAAM,UAA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C,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": "C3F7ED78D4DC38D564756E2164756E21",
"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": ";k0BAKA,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,WACnC,OAAO,QAAG,wBAAmB,OAAE,cAAU,MAAC,OAAO,MAC/C,WAAO,OAAc,WAAM,OAAM,QAAG,OACrC,CACH",
"debugId": "3195B6BC099E09E464756E2164756E21",
"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": ";+0BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,YACnC,OAAO,QAAG,yBAAoB,OAAE,cAAU,OAAG,MAC3C,SAAM,OAAU,WAAO,OAAc,aAAQ,EACvC,EAAQ,MAAO,EAAQ,SAAS,IAAK,EAAS,QAAS,MAAU,CAAC,EACxE,QAAQ,OAAO,OAAO,GAAO,KAAO,WAAa,CAAG,EACrD,CACH",
"debugId": "63FF9ECAF29B058864756E2164756E21",
"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 config: {\n update: (update) => runServicePromise(config.update(update)),\n },\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,EACX,OAAQ,CACN,OAAQ,CAAC,IAAW,EAAkB,EAAO,OAAO,CAAM,CAAC,CAC7D,CACF,CAAC,CACH,EACD,CACH",
"debugId": "B915ABB75B938B5764756E2164756E21",
"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": ";2oBAIA,SAAe,SAAQ,aAAQ,OAAS,cAAS,aAAS,MAAC,SAAW,OAAO,SAAI,4BAAuB,MAAC",
"debugId": "BC8C3A98F28D6D2264756E2164756E21",
"names": []
}
{
"version": 3,
"sources": ["src/services/service-config.ts"],
"sourcesContent": [
"import { Global } from \"@opencode-ai/util/global\"\nimport { OPENCODE_CHANNEL, OPENCODE_VERSION } from \"../version\"\nimport { Hash } from \"@opencode-ai/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 = OPENCODE_CHANNEL) {\n if (channel === \"latest\" || channel === \"next\") return \"service.json\"\n return `service-${channel.replace(/[^a-zA-Z0-9._-]/g, \"-\")}.json`\n}\n\nexport function defaultPort(channel = OPENCODE_CHANNEL) {\n if (channel === \"latest\" || channel === \"next\") 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 legacyFilename(channel = OPENCODE_CHANNEL) {\n if (channel === \"latest\" || channel === \"local\") return\n return `service-${Hash.fast(channel)}.json`\n}\n\nexport function versionBelongsToChannel(\n version: string | undefined,\n channel = OPENCODE_CHANNEL,\n installedVersion = OPENCODE_VERSION,\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 = OPENCODE_CHANNEL,\n installedVersion = OPENCODE_VERSION,\n) {\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\nexport const migrateConfig = Effect.fnUntraced(function* (legacy: string, file: string) {\n const fs = yield* FileSystem.FileSystem\n const text = yield* fs.readFileString(legacy).pipe(Effect.option)\n if (Option.isNone(text)) return\n if (Option.isNone(yield* decodeInfo(text.value).pipe(Effect.option))) 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 legacy = legacyFilename()\n const file = path.join(global.state, name)\n return {\n fs,\n file,\n legacyConfigFile: legacy ? path.join(global.config, legacy) : undefined,\n legacyRegistrationFiles: [\n ...(legacy ? [path.join(global.state, legacy)] : []),\n ...(name !== \"service.json\" && OPENCODE_CHANNEL !== \"local\" ? [path.join(global.state, \"service.json\")] : []),\n ],\n configFile: path.join(global.config, name),\n }\n})\n\nexport const options = Effect.fnUntraced(function* () {\n const { file, legacyRegistrationFiles } = yield* paths\n yield* Effect.forEach(legacyRegistrationFiles, (legacy) => migrateRegistration(legacy, file))\n return {\n file,\n version: OPENCODE_VERSION,\n command: [...selfCommand(), \"serve\", \"--service\"],\n }\n})\n\nexport const read = Effect.fn(\"cli.service-config.read\")(function* () {\n const { fs, configFile, legacyConfigFile } = yield* paths\n if (legacyConfigFile) yield* migrateConfig(legacyConfigFile, configFile)\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"
],
"mappings": ";gkBAKA,2BAAS,oBACT,yBAOO,SAAM,OAAO,EAAO,OAAO,CAChC,SAAU,EAAO,SAAS,EAAO,MAAM,EACvC,KAAM,EAAO,SAAS,EAAO,IAAI,MAAM,EAAO,uBAAuB,CAAC,EAAG,EAAO,oBAAoB,KAAM,CAAC,CAAC,EAC5G,SAAU,EAAO,SAAS,EAAO,MAAM,CACzC,CAAC,EAMD,IAAM,EAAa,EAAO,oBAAoB,EAAO,eAAe,CAAI,CAAC,EACnE,EAAqB,EAAO,oBAAoB,EAAO,eAAe,EAAQ,IAAI,CAAC,EAElF,SAAS,CAAQ,CAAC,EAAU,EAAkB,CACnD,GAAI,IAAY,UAAY,IAAY,OAAQ,MAAO,eACvD,MAAO,WAAW,EAAQ,QAAQ,mBAAoB,GAAG,SAGpD,SAAS,CAAW,CAAC,EAAU,EAAkB,CACtD,GAAI,IAAY,UAAY,IAAY,OAAQ,MAAO,OACvD,GAAI,IAAY,QAAS,MAAO,OAChC,MAAO,KAAU,OAAO,SAAS,EAAK,KAAK,CAAO,EAAE,MAAM,EAAG,CAAC,EAAG,EAAE,EAAI,MAGlE,SAAS,CAAc,CAAC,EAAU,EAAkB,CACzD,GAAI,IAAY,UAAY,IAAY,QAAS,OACjD,MAAO,WAAW,EAAK,KAAK,CAAO,SAG9B,SAAS,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Q,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": "F078B3565094F56F64756E2164756E21",
"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": ";+0BAAA,mBAAS,gBAOT,SAAe,SAAQ,aACrB,OAAS,cAAS,aAAQ,cAAS,aACnC,OAAO,QAAG,0BAAqB,OAAE,cAAU,OAAG,MAC5C,SAAM,OAAU,WAAO,OAAc,aAAQ,EAC7C,MAAO,EAAQ,KAAK,CAAO,EAC3B,IAAM,EAAY,MAAO,EAAQ,OAAO,CAAO,EAC/C,QAAQ,OAAO,MAAM,EAAU,IAAM,CAAG,EACzC,CACH",
"debugId": "980F38570B29248F64756E2164756E21",
"names": []
}

Sorry, the diff of this file is not supported yet