@munitoai/cli 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +10 -1
- package/dist/api/types.d.ts +52 -0
- package/dist/{chunk-EZEXBJTZ.js → chunk-7XUGUENM.js} +64 -7
- package/dist/chunk-7XUGUENM.js.map +1 -0
- package/dist/cli.js +202 -33
- package/dist/cli.js.map +1 -1
- package/dist/core/providers.d.ts +4 -0
- package/dist/core/proxies.d.ts +9 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-EZEXBJTZ.js.map +0 -1
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/core/workspace.ts","../src/cli/main.ts","../src/cli/commands/agent.ts","../src/cli/theme.ts","../src/cli/output.ts","../src/cli/context.ts","../src/cli/desktop.ts","../src/cli/commands/ci.ts","../src/cli/commands/auth.ts","../src/cli/commands/herdr.ts","../src/cli/commands/init.ts","../src/cli/commands/mcp.ts","../src/cli/commands/sandboxes.ts","../src/core/ssh.ts","../src/cli/commands/templates.ts"],"sourcesContent":["#!/usr/bin/env node\n/** The `munito` binary. One place turns a failure into a line a person can act on. */\n\nimport { runCommand, runMain } from \"citty\";\n\nimport { ApiError } from \"./api/client.ts\";\nimport { MissingKeyError } from \"./core/keys.ts\";\nimport { WiringError } from \"./core/providers.ts\";\nimport { TemplateError } from \"./core/templates.ts\";\nimport { WorkspaceError } from \"./core/workspace.ts\";\nimport { main } from \"./cli/main.ts\";\nimport { out } from \"./cli/output.ts\";\n\nconst CONSOLE_BILLING = \"https://console.munito.ai/billing\";\n\nfunction report(error: unknown): number {\n const channel = out(false);\n if (error instanceof MissingKeyError) {\n channel.error(error.message);\n return 2;\n }\n if (error instanceof WiringError || error instanceof WorkspaceError || error instanceof TemplateError) {\n channel.error(error.message);\n return 2;\n }\n if (error instanceof ApiError) {\n channel.error(error.message);\n if (error.status === 401) channel.line(channel.p.dim(\" The key is not valid here. Run `munito login`.\"));\n if (error.status === 402) channel.line(channel.p.dim(` Check your plan and credits at ${CONSOLE_BILLING}`));\n if (error.status === 429) channel.line(channel.p.dim(\" Too many at once. Wait, or ask for a larger plan.\"));\n if (error.requestId) channel.line(channel.p.dim(` request ${error.requestId}`));\n return error.status === 401 || error.status === 402 ? 2 : 1;\n }\n channel.error(error instanceof Error ? error.message : String(error));\n return 1;\n}\n\nprocess.on(\"unhandledRejection\", (reason) => {\n process.exit(report(reason));\n});\n\n// citty's runMain prints every failure with its stack and exits 1, so it runs only what it owns: help, the version,\n// and a usage error, which citty raises before any command runs. A second pass then prints the usage.\nconst rawArgs = process.argv.slice(2);\nconst own =\n rawArgs.some((arg) => arg === \"--help\" || arg === \"-h\") ||\n (rawArgs.length === 1 && (rawArgs[0] === \"--version\" || rawArgs[0] === \"-v\"));\nif (own) await runMain(main);\nelse\n await runCommand(main, { rawArgs }).catch(async (error: unknown) => {\n if (error instanceof Error && error.name === \"CLIError\") await runMain(main);\n process.exit(report(error));\n });\n","/** The local worktree that an agent should see, and the patch it sends back.\n\nOnly files that git already tracks or would track, so an ignored secret, a build directory and a venv never leave the\nmachine. Core code: no terminal output.\n*/\n\nimport { execFile } from \"node:child_process\";\nimport { mkdtemp, readFile, rm, stat, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { promisify } from \"node:util\";\n\nimport type { UploadFile } from \"./agents.ts\";\n\nconst run = promisify(execFile);\n\n/** Caps, so a stray directory cannot turn one command into a long upload. */\nexport const MAX_FILES = 2_000;\nexport const MAX_FILE_BYTES = 1 << 20;\nexport const MAX_TOTAL_BYTES = 16 << 20;\n\nexport class WorkspaceError extends Error {}\n\n/** The files of the git worktree at `dir`, or none when it is not a repository. */\nexport async function collect(dir?: string): Promise<UploadFile[]> {\n const root = resolve(dir ?? process.cwd());\n const listed = await listTracked(root);\n if (!listed) return [];\n\n const files: UploadFile[] = [];\n let total = 0;\n for (const relative of listed) {\n if (files.length >= MAX_FILES) break;\n const absolute = join(root, relative);\n let info;\n try {\n info = await stat(absolute);\n } catch {\n continue;\n }\n if (!info.isFile() || info.size > MAX_FILE_BYTES) continue;\n if (total + info.size > MAX_TOTAL_BYTES) break;\n const buffer = await readFile(absolute);\n if (isBinary(buffer)) continue;\n total += info.size;\n files.push({ path: relative, content: buffer.toString(\"utf8\") });\n }\n return files;\n}\n\nasync function listTracked(root: string): Promise<string[] | null> {\n try {\n // Tracked plus untracked, with .gitignore applied, so nothing ignored is ever uploaded.\n const { stdout } = await run(\"git\", [\"-C\", root, \"ls-files\", \"-co\", \"--exclude-standard\", \"-z\"], {\n maxBuffer: 32 << 20,\n });\n return stdout.split(\"\\0\").filter(Boolean);\n } catch {\n return null;\n }\n}\n\n/** A NUL byte in the first block is the same test git uses. */\nfunction isBinary(buffer: Buffer): boolean {\n return buffer.subarray(0, 8000).includes(0);\n}\n\nexport function describeUpload(files: UploadFile[]): string {\n const bytes = files.reduce((sum, file) => sum + Buffer.byteLength(file.content), 0);\n const size = bytes > 1 << 20 ? `${(bytes / (1 << 20)).toFixed(1)} MiB` : `${Math.ceil(bytes / 1024)} KiB`;\n return `${files.length} files, ${size}`;\n}\n\n/** Apply a unified diff to the worktree. Returns the files that changed, and changes nothing when it cannot. */\nexport async function applyPatch(patch: string, dir?: string): Promise<string[]> {\n const root = resolve(dir ?? process.cwd());\n if (!patch.trim()) return [];\n const file = join(await mkdtemp(join(tmpdir(), \"munito-\")), \"patch.diff\");\n await writeFile(file, patch);\n try {\n // --check first, so a patch that cannot apply leaves the worktree untouched.\n await run(\"git\", [\"-C\", root, \"apply\", \"--check\", file]);\n const { stdout } = await run(\"git\", [\"-C\", root, \"apply\", \"--numstat\", file]);\n await run(\"git\", [\"-C\", root, \"apply\", file]);\n return stdout\n .split(\"\\n\")\n .map((line) => line.split(\"\\t\").at(2))\n .filter((name): name is string => Boolean(name));\n } catch (error) {\n throw new WorkspaceError(`The patch did not apply: ${(error as Error).message}`);\n } finally {\n await rm(file, { force: true });\n }\n}\n","/** The command tree. Every command is a thin layer over core/, which does the work. */\n\nimport { defineCommand } from \"citty\";\n\nimport { agent } from \"./commands/agent.ts\";\nimport { ci } from \"./commands/ci.ts\";\nimport { login, logout, whoami } from \"./commands/auth.ts\";\nimport { herdr } from \"./commands/herdr.ts\";\nimport { init } from \"./commands/init.ts\";\nimport { mcp } from \"./commands/mcp.ts\";\nimport { create, exec, fork, ls, open, pause, resume, rm, run, ssh } from \"./commands/sandboxes.ts\";\nimport { templates } from \"./commands/templates.ts\";\n\n// The build replaces this with the version in package.json.\ndeclare const __MUNITO_VERSION__: string;\nconst VERSION = typeof __MUNITO_VERSION__ === \"string\" ? __MUNITO_VERSION__ : \"0.0.0-dev\";\n\nexport const main = defineCommand({\n meta: {\n name: \"munito\",\n // Without this, `munito --version` exits with \"No version specified\".\n version: VERSION,\n description: \"Run coding agents on European infrastructure, one command at a time.\",\n },\n subCommands: {\n agent,\n ci,\n herdr,\n init,\n mcp,\n login,\n logout,\n whoami,\n ls,\n create,\n run,\n exec,\n ssh,\n open,\n rm,\n pause,\n resume,\n fork,\n templates,\n },\n});\n","/** `munito agent` — the one command. */\n\nimport { defineCommand } from \"citty\";\n\nimport { runAgent, type AgentEvent } from \"../../core/agents.ts\";\nimport { AGENTS, PROVIDERS, type AgentName, type AuthMode, type ProviderName } from \"../../core/providers.ts\";\nimport { applyPatch, collect, describeUpload } from \"../../core/workspace.ts\";\nimport { commonArgs, context } from \"../context.ts\";\nimport { duration } from \"../output.ts\";\nimport { openDesktop } from \"../desktop.ts\";\n\nexport const agent = defineCommand({\n meta: {\n name: \"agent\",\n description: \"Run a coding agent in a sandbox and bring its work back.\",\n },\n args: {\n ...commonArgs,\n agent: {\n type: \"positional\",\n required: false,\n description: `Which harness: ${AGENTS.join(\", \")}. The default is claude.`,\n },\n prompt: { type: \"positional\", required: false, description: \"What the agent should do.\" },\n provider: {\n type: \"string\",\n description: `Where the model comes from: ${PROVIDERS.join(\", \")}.`,\n default: \"munito\",\n },\n auth: { type: \"string\", description: \"token or subscription.\", default: \"token\" },\n model: { type: \"string\", description: \"A model id, in place of the recommended one.\" },\n repo: { type: \"string\", description: \"A directory to upload. The default is the current git worktree.\" },\n \"no-upload\": { type: \"boolean\", description: \"Send no files at all.\" },\n size: { type: \"string\", description: \"tiny, small, default or large.\", default: \"default\" },\n template: { type: \"string\", description: \"A sandbox template, in place of the agent one.\" },\n timeout: { type: \"string\", description: \"Seconds the sandbox may live. The default is 3600.\" },\n \"max-turns\": { type: \"string\", description: \"Stop the agent after this many turns.\" },\n keep: { type: \"boolean\", description: \"Leave the sandbox running when the task ends.\" },\n desktop: { type: \"boolean\", description: \"Give the agent a screen, and open the viewer. Implies --keep.\" },\n \"no-apply\": { type: \"boolean\", description: \"Do not apply the agent's patch to your worktree.\" },\n },\n async run({ args }) {\n // One positional means the prompt, and claude runs it.\n let name = (args.agent ?? \"claude\") as AgentName;\n let prompt = args.prompt as string | undefined;\n if (!AGENTS.includes(name)) {\n prompt = [args.agent, prompt].filter(Boolean).join(\" \");\n name = \"claude\";\n }\n if (!prompt) throw new Error('Give the agent something to do: munito agent \"fix the failing test\"');\n\n const ctx = await context(args);\n const { out, client } = ctx;\n\n // The parser reads `--no-x` as `x: false`, so a flag named `no-x` never arrives under its own name.\n const off = (name: string) => args[`no-${name}`] === true || args[name] === false;\n const upload = off(\"upload\") ? [] : await collect(args.repo);\n const started = Date.now();\n // A screen is only useful while the machine lives, so a desktop run keeps it.\n const desktop = Boolean(args.desktop);\n const keep = Boolean(args.keep) || desktop;\n\n out.line();\n out.line(`${out.p.badge(\"munito\")} ${out.p.bold(name)} ${out.p.dim(`on ${args.provider}`)}`);\n out.line(out.p.dim(` ${prompt}`));\n out.line();\n if (upload.length) out.step(\"workspace\", describeUpload(upload));\n\n let streamed = false;\n const onEvent = (event: AgentEvent) => {\n out.event({ ...event });\n switch (event.type) {\n case \"sandbox.creating\":\n out.step(\"sandbox\", \"starting\");\n break;\n case \"sandbox.created\":\n out.step(\"sandbox\", `${event.sandboxId} in ${duration(event.ms)}`);\n if (desktop) void openDesktop(client, event.sandboxId, out);\n break;\n case \"files.uploaded\":\n out.step(\"uploaded\", `${event.count} files`);\n break;\n case \"harness.installing\":\n out.step(\"installing\", `${event.package}, once`);\n break;\n case \"harness.installed\":\n out.step(\"installed\", duration(event.ms));\n break;\n case \"agent.started\":\n out.step(\"running\", name);\n out.line();\n break;\n case \"output\":\n // Claude Code answers with one JSON envelope, so holding it back keeps the screen clean.\n if (name !== \"claude\") {\n streamed = true;\n out.raw(event.data, event.stream);\n }\n break;\n case \"agent.finished\":\n if (streamed) out.line();\n out.step(\"finished\", `exit ${event.exitCode} in ${duration(event.ms)}`);\n break;\n case \"sandbox.kept\":\n out.step(\"kept\", `${event.sandboxId} — munito ssh ${event.sandboxId}`);\n break;\n default:\n break;\n }\n };\n\n const run = await runAgent(client, {\n agent: name,\n prompt,\n provider: args.provider as ProviderName,\n auth: args.auth as AuthMode,\n model: args.model,\n size: args.size,\n template: args.template ?? (desktop ? \"desktop\" : undefined),\n timeout: args.timeout ? Number(args.timeout) : undefined,\n maxTurns: args[\"max-turns\"] ? Number(args[\"max-turns\"]) : undefined,\n keep,\n files: upload,\n onEvent,\n });\n\n if (!streamed && run.result && out.mode !== \"json\") {\n out.line();\n out.line(run.result);\n }\n\n let changed: string[] = [];\n if (run.patch && !off(\"apply\")) {\n try {\n changed = await applyPatch(run.patch, args.repo);\n out.line();\n out.step(\"applied\", `${changed.length} files`);\n for (const file of changed) out.line(out.p.dim(` ${file}`));\n } catch (error) {\n out.warn((error as Error).message);\n out.line(out.p.dim(\" The diff is in the JSON output: rerun with --json.\"));\n }\n } else if (run.patch) {\n out.step(\"patch\", `${Buffer.byteLength(run.patch)} bytes, not applied`);\n }\n\n out.line();\n out.step(\"done\", duration(Date.now() - started));\n out.result(run.result, {\n sandbox_id: run.sandboxId,\n exit_code: run.exitCode,\n session_id: run.sessionId,\n duration_ms: run.durationMs,\n files_changed: changed,\n patch: run.patch || undefined,\n });\n if (run.exitCode !== 0) process.exitCode = run.exitCode;\n },\n});\n","/** The Munito palette in a terminal, and the rule that decides whether to use it.\n\nThe brand violet `#702cf6` is unreadable as text on a dark terminal. The design system already answers this: in dark\nmode it swaps the text violet to the cube top. A terminal is dark mode, so the primary here is `#9a68fa`.\nSource: `typescript/packages/design-system/src/styles/tokens.css`, which copies the brand kit.\n*/\n\nexport const BRAND = {\n violet: [0x70, 0x2c, 0xf6],\n cubeTop: [0x9a, 0x68, 0xfa],\n cubeSide: [0x4a, 0x1f, 0xa8],\n lime: [0xd7, 0xfa, 0x4a],\n lilac: [0xa0, 0x81, 0xde],\n paper: [0xf0, 0xee, 0xf3],\n ink: [0x21, 0x16, 0x29],\n night: [0x14, 0x10, 0x19],\n} as const satisfies Record<string, readonly [number, number, number]>;\n\nexport type Depth = 0 | 4 | 8 | 24;\n\n/** What the stream can draw, from the environment that the user and their tools set. */\nexport function colorDepth(stream: NodeJS.WriteStream = process.stdout): Depth {\n if (process.env.NO_COLOR !== undefined && process.env.NO_COLOR !== \"\") return 0;\n const forced = process.env.FORCE_COLOR;\n if (forced !== undefined) {\n if (forced === \"0\" || forced === \"false\") return 0;\n if (forced === \"1\" || forced === \"true\") return 4;\n if (forced === \"2\") return 8;\n if (forced === \"3\") return 24;\n }\n if (!stream.isTTY) return 0;\n if (process.env.TERM === \"dumb\") return 0;\n const colorterm = process.env.COLORTERM ?? \"\";\n if (colorterm === \"truecolor\" || colorterm === \"24bit\") return 24;\n if (/-256(color)?$/i.test(process.env.TERM ?? \"\")) return 8;\n return 4;\n}\n\nconst RESET = \"\\u001b[39m\";\nconst BOLD = \"\\u001b[1m\";\nconst UNBOLD = \"\\u001b[22m\";\nconst DIM = \"\\u001b[2m\";\nconst UNDIM = \"\\u001b[22m\";\n\n/** The nearest xterm-256 index of a colour, through the 6x6x6 cube. */\nfunction to256([r, g, b]: readonly [number, number, number]): number {\n const step = (value: number) => (value < 48 ? 0 : value < 115 ? 1 : Math.min(5, Math.round((value - 35) / 40)));\n return 16 + 36 * step(r) + 6 * step(g) + step(b);\n}\n\n/** The nearest of the 8 basic colours. Violet and lilac land on magenta, lime on bright yellow. */\nfunction to16([r, g, b]: readonly [number, number, number]): number {\n const bright = Math.max(r, g, b) > 0xa0;\n const bit = (value: number) => (value > 0x7f ? 1 : 0);\n const code = bit(r) + bit(g) * 2 + bit(b) * 4;\n return (bright ? 90 : 30) + code;\n}\n\nexport interface Palette {\n readonly depth: Depth;\n primary(text: string): string;\n accent(text: string): string;\n dim(text: string): string;\n text(text: string): string;\n bold(text: string): string;\n /** Paper on brand violet, the one place the true brand violet reads well. */\n badge(text: string): string;\n}\n\nexport function palette(stream: NodeJS.WriteStream = process.stdout): Palette {\n const depth = colorDepth(stream);\n const fg = (color: readonly [number, number, number]) => {\n if (depth === 0) return (text: string) => text;\n if (depth === 24) return (text: string) => `\\u001b[38;2;${color[0]};${color[1]};${color[2]}m${text}${RESET}`;\n if (depth === 8) return (text: string) => `\\u001b[38;5;${to256(color)}m${text}${RESET}`;\n return (text: string) => `\\u001b[${to16(color)}m${text}${RESET}`;\n };\n const plain = depth === 0;\n return {\n depth,\n primary: fg(BRAND.cubeTop),\n accent: fg(BRAND.lime),\n dim: plain ? (text) => text : (text) => `${DIM}${fg(BRAND.lilac)(text)}${UNDIM}`,\n text: fg(BRAND.paper),\n bold: plain ? (text) => text : (text) => `${BOLD}${text}${UNBOLD}`,\n badge: plain\n ? (text) => text\n : (text) =>\n depth === 24\n ? `\\u001b[48;2;${BRAND.violet.join(\";\")}m\\u001b[38;2;${BRAND.paper.join(\";\")}m ${text} \\u001b[49m${RESET}`\n : `\\u001b[45m\\u001b[97m ${text} \\u001b[49m${RESET}`,\n };\n}\n\n/** The cube of the brand mark, in half blocks. The wordmark is the logo and does not belong in ASCII. */\nexport function cube(p: Palette): string {\n const top = p.primary(\"▄▄▄▄▄▄\");\n const body = p.primary(\"██████\");\n return [` ${top}`, ` ${body}`, ` ${p.dim(\"▀▀▀▀▀▀\")}`].join(\"\\n\");\n}\n","/** What reaches the terminal. Rich when it is a terminal, plain lines when it is not, NDJSON with --json.\n\nOur own agents call this CLI through a pipe, so every command has to be readable without a TTY.\n*/\n\nimport { palette, type Palette } from \"./theme.ts\";\n\nexport type Mode = \"rich\" | \"plain\" | \"json\";\n\nexport interface Out {\n readonly mode: Mode;\n readonly p: Palette;\n /** One line for a person. Silent in json mode. */\n line(text?: string): void;\n /** A labelled step, such as a created sandbox. */\n step(label: string, detail?: string): void;\n /** One machine-readable event. Printed only in json mode. */\n event(body: Record<string, unknown>): void;\n /** The machine-readable end of a command. Prints in json mode only: a person's copy is the caller's job. */\n result(text: string, body?: Record<string, unknown>): void;\n warn(text: string): void;\n error(text: string): void;\n /** Raw bytes of a child process, passed through with no decoration. */\n raw(text: string, stream?: \"stdout\" | \"stderr\"): void;\n}\n\nexport function out(json: boolean, stream: NodeJS.WriteStream = process.stdout): Out {\n const p = palette(stream);\n const mode: Mode = json ? \"json\" : p.depth === 0 ? \"plain\" : \"rich\";\n const write = (text: string) => stream.write(`${text}\\n`);\n return {\n mode,\n p,\n line(text = \"\") {\n if (mode !== \"json\") write(text);\n },\n step(label, detail) {\n if (mode === \"json\") return;\n const mark = mode === \"rich\" ? p.primary(\"›\") : \">\";\n write(detail ? `${mark} ${label} ${p.dim(detail)}` : `${mark} ${label}`);\n },\n event(body) {\n if (mode === \"json\") write(JSON.stringify(body));\n },\n result(text, body) {\n if (mode === \"json\") write(JSON.stringify({ type: \"result\", ...body, result: text }));\n },\n warn(text) {\n if (mode === \"json\") {\n process.stderr.write(`${JSON.stringify({ type: \"warning\", message: text })}\\n`);\n return;\n }\n process.stderr.write(`${mode === \"rich\" ? p.accent(\"!\") : \"!\"} ${text}\\n`);\n },\n error(text) {\n if (mode === \"json\") {\n process.stderr.write(`${JSON.stringify({ type: \"error\", message: text })}\\n`);\n return;\n }\n process.stderr.write(`${mode === \"rich\" ? \"\\u001b[31m✗\\u001b[39m\" : \"x\"} ${text}\\n`);\n },\n raw(text, target = \"stdout\") {\n if (mode === \"json\") return;\n (target === \"stderr\" ? process.stderr : stream).write(text);\n },\n };\n}\n\n/** Seconds with one decimal, or milliseconds below a second. */\nexport function duration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)} ms`;\n if (ms < 60_000) return `${(ms / 1000).toFixed(1)} s`;\n const minutes = Math.floor(ms / 60_000);\n return `${minutes} min ${Math.round((ms % 60_000) / 1000)} s`;\n}\n\n/** The size of the files of an image, as \"1.2 GiB\" or \"340 MiB\". */\nexport function bytes(value?: number | null): string {\n if (value === null || value === undefined) return \"-\";\n if (value >= 1024 ** 3) return `${(value / 1024 ** 3).toFixed(1)} GiB`;\n return `${Math.max(1, Math.round(value / 1024 ** 2))} MiB`;\n}\n\n/** A left-aligned table that stays readable with no colour. */\nexport function table(rows: string[][], p: Palette, heading = true): string {\n if (!rows.length) return \"\";\n const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => (row[column] ?? \"\").length)));\n return rows\n .map((row, index) => {\n const line = row\n .map((cell, column) => (cell ?? \"\").padEnd(widths[column]))\n .join(\" \")\n .trimEnd();\n return heading && index === 0 ? p.dim(line) : line;\n })\n .join(\"\\n\");\n}\n","/** What every command needs: the key, a client and an output channel. */\n\nimport { Client } from \"../api/client.ts\";\nimport * as keys from \"../core/keys.ts\";\nimport { out, type Out } from \"./output.ts\";\n\nexport interface CommonArgs {\n json?: boolean;\n region?: string;\n host?: string;\n}\n\nexport interface Context {\n client: Client;\n out: Out;\n host: string;\n source: string;\n}\n\n/** The shared flags, so every command declares them the same way. */\nexport const commonArgs = {\n json: { type: \"boolean\" as const, description: \"Print NDJSON events instead of text.\" },\n region: { type: \"string\" as const, description: \"global, eu or us. The default is global.\" },\n host: { type: \"string\" as const, description: \"A full API URL, in place of a region.\" },\n};\n\nexport async function context(args: CommonArgs): Promise<Context> {\n const channel = out(Boolean(args.json));\n const credentials = await keys.require(args.host ?? args.region);\n return {\n client: new Client({ apiKey: credentials.apiKey, baseUrl: credentials.host }),\n out: channel,\n host: credentials.host,\n source: credentials.source,\n };\n}\n\n/** An output channel before the key is known, for `login` and for failures. */\nexport function channel(args: CommonArgs): Out {\n return out(Boolean(args.json));\n}\n","/** Signing a port and handing it to a browser, shared by `munito open` and `munito agent --desktop`. */\n\nimport { spawn } from \"node:child_process\";\n\nimport type { Client } from \"../api/client.ts\";\nimport type { Out } from \"./output.ts\";\n\nexport const DESKTOP_PORT = 6080;\n\nexport function openInBrowser(url: string): void {\n const opener = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n spawn(opener, [url], { stdio: \"ignore\", detached: true }).unref();\n}\n\n/** A viewer for a running desktop sandbox. The sandbox has to be up, so a caller waits for its create first. */\nexport async function openDesktop(client: Client, sandboxId: string, out: Out, expiresIn = 3600): Promise<void> {\n try {\n const signed = await client.signPortUrl(sandboxId, DESKTOP_PORT, expiresIn);\n out.event({ type: \"url\", url: signed.url, port: DESKTOP_PORT });\n out.step(\"desktop\", signed.url);\n if (out.mode !== \"json\" && process.stdout.isTTY) openInBrowser(signed.url);\n } catch (error) {\n out.warn(`The desktop did not open: ${(error as Error).message}`);\n }\n}\n","/** `munito ci` — the warm-base CI recipe as three commands. */\n\nimport { defineCommand } from \"citty\";\n\nimport { DEFAULT_BASE_SIZE, DEFAULT_DISK_GIB, drop, findBase, job, warm, type CiEvent } from \"../../core/ci.ts\";\nimport { commonArgs, context, type CommonArgs } from \"../context.ts\";\nimport { duration } from \"../output.ts\";\n\nconst nameArg = {\n name: { type: \"string\" as const, description: \"Which warm base. The default is the repository name.\", default: \"\" },\n};\n\n/** citty loses its argument types inside subCommands, so a nested command reads them through these. */\nconst str = (value: unknown): string | undefined => (typeof value === \"string\" && value ? value : undefined);\nconst num = (value: unknown): number | undefined => (typeof value === \"string\" && value ? Number(value) : undefined);\n\n/** One base per repository unless the caller names another. */\nfunction baseName(given: string): string {\n if (given) return given;\n const repo = process.env.GITHUB_REPOSITORY ?? process.env.CI_PROJECT_PATH;\n if (repo) return repo.replaceAll(\"/\", \"-\");\n return process.cwd().split(\"/\").filter(Boolean).at(-1) ?? \"default\";\n}\n\nexport const ci = defineCommand({\n meta: { name: \"ci\", description: \"Run CI jobs on a warm sandbox that already holds your dependencies.\" },\n subCommands: {\n warm: defineCommand({\n meta: { name: \"warm\", description: \"Build the warm base and pause it.\" },\n args: {\n ...commonArgs,\n ...nameArg,\n setup: { type: \"positional\", required: true, description: \"The command that installs everything.\" },\n size: { type: \"string\", description: `The size of the base. The default is ${DEFAULT_BASE_SIZE}.` },\n disk: { type: \"string\", description: `Root disk in GiB. The default is ${DEFAULT_DISK_GIB}.` },\n template: { type: \"string\", description: \"A template. The default is ubuntu.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const name = baseName(str(args.name) ?? \"\");\n const result = await warm(client, {\n name,\n setup: String(args.setup),\n size: str(args.size),\n diskGib: num(args.disk),\n template: str(args.template),\n onEvent: report(out),\n });\n out.step(\"ready\", `base ${result.sandboxId} for ${name}`);\n out.line(out.p.dim(` munito ci run --name ${name} \"<your test command>\"`));\n out.result(\"\", { base: result.sandboxId, name });\n },\n }),\n\n run: defineCommand({\n meta: { name: \"run\", description: \"Fork the warm base, run one job, delete the fork.\" },\n args: {\n ...commonArgs,\n ...nameArg,\n command: { type: \"positional\", required: true, description: \"The job command.\" },\n cwd: { type: \"string\", description: \"The working directory in the sandbox.\" },\n timeout: { type: \"string\", description: \"Seconds the job may take.\" },\n keep: { type: \"boolean\", description: \"Keep the fork, to look at a failure.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const name = baseName(str(args.name) ?? \"\");\n const exit = await job(client, {\n name,\n command: String(args.command),\n cwd: str(args.cwd),\n timeout: num(args.timeout),\n keep: Boolean(args.keep),\n onOutput: (text, stream) => out.raw(text, stream),\n onEvent: report(out),\n });\n out.result(\"\", { exit_code: exit, name });\n if (exit !== 0) process.exitCode = exit;\n },\n }),\n\n status: defineCommand({\n meta: { name: \"status\", description: \"Show the warm base of this repository.\" },\n args: { ...commonArgs, ...nameArg },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const name = baseName(str(args.name) ?? \"\");\n const base = await findBase(client, name);\n if (!base) {\n out.line(out.p.dim(`No warm base named ${name}.`));\n out.result(\"\", { name, base: null });\n return;\n }\n out.step(name, `${base.id} ${base.status}`);\n out.result(\"\", { name, base: base.id, status: base.status });\n },\n }),\n\n drop: defineCommand({\n meta: { name: \"drop\", description: \"Delete the warm base.\" },\n args: { ...commonArgs, ...nameArg },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const name = baseName(str(args.name) ?? \"\");\n const gone = await drop(client, name, report(out));\n if (!gone) out.line(out.p.dim(`No warm base named ${name}.`));\n out.result(\"\", { name, deleted: gone });\n },\n }),\n },\n});\n\nfunction report(out: Awaited<ReturnType<typeof context>>[\"out\"]) {\n return (event: CiEvent) => {\n out.event({ ...event });\n switch (event.type) {\n case \"base.creating\":\n out.step(\"base\", `building ${event.name}`);\n break;\n case \"base.created\":\n out.step(\"base\", `${event.sandboxId} in ${duration(event.ms)}`);\n break;\n case \"base.setup\":\n out.step(\"setup\", event.command.length > 70 ? `${event.command.slice(0, 70)}…` : event.command);\n break;\n case \"base.paused\":\n out.step(\"paused\", duration(event.ms));\n break;\n case \"base.found\":\n out.step(\"base\", `${event.sandboxId} ${event.status}`);\n break;\n case \"fork.created\":\n out.step(\"fork\", `${event.sandboxId} in ${duration(event.ms)}`);\n break;\n case \"job.finished\":\n out.step(\"job\", `exit ${event.exitCode} in ${duration(event.ms)}`);\n break;\n case \"base.deleted\":\n out.step(\"deleted\", event.sandboxId);\n break;\n default:\n break;\n }\n };\n}\n","/** `munito login`, `logout` and `whoami`. */\n\nimport { defineCommand } from \"citty\";\n\nimport { Client } from \"../../api/client.ts\";\nimport * as keys from \"../../core/keys.ts\";\nimport { channel, commonArgs, context } from \"../context.ts\";\nimport { cube } from \"../theme.ts\";\n\nconst CONSOLE_KEYS = \"https://console.munito.ai/keys\";\n\nexport const login = defineCommand({\n meta: { name: \"login\", description: \"Save an API key for this machine.\" },\n args: {\n ...commonArgs,\n key: { type: \"string\", description: \"The key, when you cannot paste it at a prompt.\" },\n },\n async run({ args }) {\n const out = channel(args);\n const host = keys.resolveHost(args.host ?? args.region);\n\n let key = (args.key as string | undefined)?.trim();\n if (!key) {\n if (!process.stdin.isTTY) throw new Error(`No terminal to ask in. Pass --key, or set ${keys.ENV_KEY}.`);\n const clack = await import(\"@clack/prompts\");\n if (out.mode === \"rich\") {\n out.line();\n out.line(cube(out.p));\n }\n clack.intro(out.p.bold(\"Sign in to Munito AI\"));\n clack.note(`Create a key with the Inference permission at\\n${CONSOLE_KEYS}`, \"API key\");\n const answer = await clack.password({\n message: \"Paste your API key\",\n validate: (value) => ((value ?? \"\").trim().length < 8 ? \"That is too short for a key.\" : undefined),\n });\n if (clack.isCancel(answer)) {\n clack.cancel(\"Nothing saved.\");\n process.exitCode = 1;\n return;\n }\n key = String(answer).trim();\n }\n\n // Check the key before it is written, so a typo fails here and not in the next command.\n const probe = new Client({ apiKey: key, baseUrl: host, attempts: 1 });\n await probe.listSandboxes();\n\n const path = await keys.save(key, host);\n out.step(\"saved\", `${keys.mask(key)} for ${host}`);\n out.line(out.p.dim(` ${path}, readable by you only`));\n out.result(\"\", { saved: true, host });\n },\n});\n\nexport const logout = defineCommand({\n meta: { name: \"logout\", description: \"Remove the saved API key.\" },\n args: commonArgs,\n async run({ args }) {\n await keys.clear();\n channel(args).step(\"removed\", keys.authPath());\n },\n});\n\nexport const whoami = defineCommand({\n meta: { name: \"whoami\", description: \"Show which key and host this machine uses.\" },\n args: commonArgs,\n async run({ args }) {\n const ctx = await context(args);\n const sandboxes = await ctx.client.listSandboxes();\n const running = sandboxes.filter((box) => box.status === \"running\").length;\n ctx.out.step(\"host\", ctx.host);\n ctx.out.step(\"key\", `${ctx.source}`);\n ctx.out.step(\"sandboxes\", `${running} running, ${sandboxes.length} known`);\n ctx.out.result(\"\", { host: ctx.host, source: ctx.source, running, total: sandboxes.length });\n },\n});\n","/** `munito herdr add` — give herdr a Munito sandbox to run a coding agent on.\n\nherdr holds no compute: you bring machines and it reaches them over SSH. Our SSH is a plain byte pipe, so herdr's own\n`--install` copies its Linux build in with no helper, where Vercel Sandbox needs one. This command is the whole of\nthat recipe: make a persistent sandbox, mint a key for it, and hand herdr the connection.\n*/\n\nimport { spawn, spawnSync } from \"node:child_process\";\n\nimport { defineCommand } from \"citty\";\n\nimport { AGENT_TEMPLATE } from \"../../core/agents.ts\";\nimport { commonArgs, context } from \"../context.ts\";\n\nexport const herdr = defineCommand({\n meta: {\n name: \"herdr\",\n description: \"Run coding agents on Munito sandboxes from herdr.\",\n },\n subCommands: {\n add: defineCommand({\n meta: { name: \"add\", description: \"Create a sandbox and add it to herdr as a machine.\" },\n args: {\n ...commonArgs,\n name: { type: \"string\", description: \"The machine name in herdr. The default is the sandbox id.\" },\n template: { type: \"string\", description: \"A template. The default is the agent one.\" },\n size: { type: \"string\", description: \"tiny, small, default or large.\", default: \"default\" },\n timeout: { type: \"string\", description: \"Seconds the sandbox may live before it pauses.\" },\n print: { type: \"boolean\", description: \"Print the herdr command instead of running it.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as never);\n\n // Persistent, so a pause keeps the agent's terminal and conversation, and a resume brings them back.\n const box = await client.createSandbox({\n template: (args.template as string) || AGENT_TEMPLATE,\n size: (args.size as string) || \"default\",\n internet: true,\n persistent: true,\n timeout: args.timeout ? Number(args.timeout) : 86_400,\n metadata: { \"munito.cli\": \"herdr\" },\n });\n out.step(\"sandbox\", `${box.id}, persistent`);\n\n // The credential rides in the SSH user and expires, so a long-lived machine is told to mint a new one.\n const access = await client.createSshAccess(box.id);\n const via = `ssh -o StrictHostKeyChecking=accept-new ${access.user}@${access.host}`;\n const name = (args.name as string) || box.id;\n out.step(\"ssh\", `${access.host}, minted`);\n\n const present = spawnSync(\"hc\", [\"--version\"], { stdio: \"ignore\" });\n if (args.print || present.status !== 0) {\n if (present.status !== 0) out.warn(\"herdr-core (`hc`) is not on PATH. Run this where it is:\");\n out.line(`hc machine add --name ${name} --install --via '${via}'`);\n out.result(\"\", { sandbox_id: box.id, machine: name, via });\n return;\n }\n\n out.step(\"herdr\", `adding ${name}`);\n const child = spawn(\"hc\", [\"machine\", \"add\", \"--name\", name, \"--install\", \"--via\", via], { stdio: \"inherit\" });\n const code = await new Promise<number>((done) => child.on(\"close\", (c) => done(c ?? 0)));\n if (code !== 0) {\n out.error(`hc machine add exited ${code}. The sandbox is ${box.id}.`);\n process.exitCode = code;\n return;\n }\n out.line();\n out.step(\"ready\", name);\n out.line(out.p.dim(` hc run --bg --on ${name} --cwd /workspace --name agent claude`));\n out.line(out.p.dim(` munito pause ${box.id} # keeps the terminal and the conversation`));\n out.line(out.p.dim(` the SSH credential expires; run \\`munito herdr add\\` again for a new machine`));\n out.result(\"\", { sandbox_id: box.id, machine: name });\n },\n }),\n },\n});\n","/** `munito init <agent>` — configure a harness on this machine, from the same table the sandbox uses. */\n\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { dirname } from \"node:path\";\n\nimport { defineCommand } from \"citty\";\n\nimport {\n AGENTS,\n CLAUDE_MODEL,\n DEFAULT_MODEL,\n DEFAULT_SMALL_MODEL,\n PACKAGES,\n PLUGINS,\n PROVIDERS,\n wire,\n type AgentName,\n type AuthMode,\n type ProviderName,\n} from \"../../core/providers.ts\";\nimport { commonArgs, context } from \"../context.ts\";\n\nexport const init = defineCommand({\n meta: {\n name: \"init\",\n description: \"Point a coding agent on this machine at Munito AI.\",\n },\n args: {\n ...commonArgs,\n agent: { type: \"positional\", required: true, description: `Which harness: ${AGENTS.join(\", \")}.` },\n provider: {\n type: \"string\",\n description: `Where the model comes from: ${PROVIDERS.join(\", \")}.`,\n default: \"munito\",\n },\n auth: { type: \"string\", description: \"token or subscription.\", default: \"token\" },\n model: { type: \"string\", description: \"A model id, in place of the recommended one.\" },\n \"dry-run\": { type: \"boolean\", description: \"Show what would be written, and write nothing.\" },\n },\n async run({ args }) {\n const name = args.agent as AgentName;\n if (!AGENTS.includes(name)) throw new Error(`Unknown agent ${name}. One of: ${AGENTS.join(\", \")}`);\n\n const { client, out, host } = await context(args);\n const home = homedir();\n\n const guide = `https://docs.munito.ai/reference/agents/${name}`;\n const plugin = PLUGINS[name];\n if (plugin) {\n // The harness installs a plugin we publish, so there is no file for this tool to write.\n out.step(name, \"installs a Munito AI provider plugin\");\n out.line(`\\n ${out.p.primary(plugin)}\\n`);\n out.line(out.p.dim(` Then enter your key. See ${guide}`));\n out.result(\"\", { agent: name, plugin, guide });\n return;\n }\n\n const wiring = wire(\n name,\n args.provider as ProviderName,\n args.auth as AuthMode,\n {\n host,\n token: client.token,\n model: args.model ?? (name === \"claude\" ? CLAUDE_MODEL : DEFAULT_MODEL),\n smallModel: DEFAULT_SMALL_MODEL,\n },\n process.cwd(),\n home,\n );\n\n for (const file of wiring.files) {\n if (args[\"dry-run\"]) {\n out.step(\"would write\", file.path);\n continue;\n }\n await mkdir(dirname(file.path), { recursive: true });\n await writeFile(file.path, file.content, { mode: 0o600 });\n out.step(\"wrote\", file.path);\n }\n\n // A key never goes into a config file, so the shell has to carry it.\n const exports = Object.entries(wiring.env).filter(([, value]) => value);\n if (exports.length) {\n out.line();\n out.line(out.p.dim(\" Add these to your shell:\"));\n for (const [key, value] of exports) {\n const shown =\n key.toLowerCase().includes(\"token\") || key.toLowerCase().includes(\"key\") ? \"$MUNITO_API_KEY\" : value;\n out.line(` export ${key}=${shown}`);\n }\n }\n if (wiring.unset.length && !args[\"dry-run\"]) {\n out.line();\n out.line(out.p.dim(` Clear these if your shell sets them: ${wiring.unset.join(\", \")}`));\n }\n out.line();\n if (!PACKAGES[name]) {\n // We write its configuration, but we do not install the harness itself.\n out.line(out.p.dim(` Install ${name} itself first. See ${guide}`));\n out.line();\n }\n out.step(\"ready\", `run ${out.p.primary(name)}`);\n out.result(\"\", { agent: name, files: wiring.files.map((file) => file.path) });\n },\n});\n","/** `munito mcp` — the same commands as MCP tools, so a Claude or Codex session farms work out to our sandboxes.\n\nOne line adds it: `claude mcp add munito -- npx @munitoai/cli mcp`. The tools call `core/`, exactly as the commands do, so\nthere is no second implementation of anything.\n*/\n\nimport { defineCommand } from \"citty\";\n\nimport { runAgent } from \"../../core/agents.ts\";\nimport { AGENTS, PROVIDERS, type AgentName, type AuthMode, type ProviderName } from \"../../core/providers.ts\";\nimport { commonArgs, context, type CommonArgs } from \"../context.ts\";\n\n/** A tool answer, in the shape MCP expects. */\nfunction text(body: unknown): { content: { type: \"text\"; text: string }[]; isError?: boolean } {\n return { content: [{ type: \"text\", text: typeof body === \"string\" ? body : JSON.stringify(body, null, 2) }] };\n}\n\nfunction failed(message: string) {\n return { ...text(message), isError: true };\n}\n\ninterface RunAgentArgs {\n prompt: string;\n agent: AgentName;\n provider: ProviderName;\n model?: string;\n files?: { path: string; content: string }[];\n max_turns?: number;\n}\n\ninterface RunCommandArgs {\n command: string;\n template: string;\n internet: boolean;\n timeout: number;\n}\n\nexport const mcp = defineCommand({\n meta: {\n name: \"mcp\",\n description: \"Serve the Munito AI tools over MCP on stdio, for a coding agent to call.\",\n },\n args: commonArgs,\n async run({ args }) {\n // stdout is the protocol, so nothing else may write to it.\n const ctx = await context({ ...(args as CommonArgs), json: true });\n const { client } = ctx;\n\n const { McpServer } = await import(\"@modelcontextprotocol/sdk/server/mcp.js\");\n const { StdioServerTransport } = await import(\"@modelcontextprotocol/sdk/server/stdio.js\");\n const { z } = await import(\"zod\");\n\n const server = new McpServer({ name: \"munito\", version: \"0.1.0\" });\n // The SDK's generic inference over a zod shape blows the instantiation depth, so the shapes are registered\n // through a loose handle and each handler declares its own argument type.\n const register = server.registerTool.bind(server) as unknown as (\n name: string,\n config: Record<string, unknown>,\n handler: (args: never) => Promise<{ content: { type: \"text\"; text: string }[]; isError?: boolean }>,\n ) => void;\n\n register(\n \"run_agent\",\n {\n title: \"Run a coding agent in a sandbox\",\n description:\n \"Run a coding agent on a fresh Linux microVM and return its answer and a patch of what it changed. \" +\n \"The sandbox is deleted afterwards. Use this to do work in isolation, or to run several agents at once.\",\n inputSchema: {\n prompt: z.string().describe(\"What the agent should do.\"),\n agent: z.enum(AGENTS).default(\"claude\").describe(\"Which harness runs the task.\"),\n provider: z.enum(PROVIDERS).default(\"munito\").describe(\"Where the model comes from.\"),\n model: z.string().optional().describe(\"A model id, in place of the recommended one.\"),\n files: z\n .array(z.object({ path: z.string(), content: z.string() }))\n .optional()\n .describe(\"Files to put in /workspace before the agent starts.\"),\n max_turns: z.number().int().positive().optional(),\n },\n },\n (async ({ prompt, agent, provider, model, files, max_turns }: RunAgentArgs) => {\n try {\n const run = await runAgent(client, {\n agent: agent as AgentName,\n prompt,\n provider: provider as ProviderName,\n auth: \"token\" as AuthMode,\n model,\n files,\n maxTurns: max_turns,\n });\n return text({\n result: run.result,\n exit_code: run.exitCode,\n patch: run.patch || null,\n sandbox_id: run.sandboxId,\n duration_ms: run.durationMs,\n });\n } catch (error) {\n return failed(`The agent did not run: ${(error as Error).message}`);\n }\n }) as never,\n );\n\n register(\n \"run_command\",\n {\n title: \"Run a command in a sandbox\",\n description:\n \"Run one shell command on a fresh Linux microVM and return its output. The sandbox is deleted \" +\n \"afterwards. Use this for code you do not trust, or for a build that must start clean.\",\n inputSchema: {\n command: z.string().describe(\"The command, which runs in bash.\"),\n template: z\n .string()\n .default(\"base\")\n .describe(\"base, ubuntu, agent, desktop, or the name of a custom template.\"),\n internet: z.boolean().default(false).describe(\"Allow outbound connections.\"),\n timeout: z.number().int().positive().default(120).describe(\"Seconds the command may take.\"),\n },\n },\n (async ({ command, template, internet, timeout }: RunCommandArgs) => {\n let id = \"\";\n try {\n const box = await client.createSandbox({\n template,\n size: \"small\",\n internet,\n timeout: Math.max(timeout + 60, 120),\n metadata: { \"munito.cli\": \"mcp\" },\n });\n id = box.id;\n const out = await client.exec(id, { command, timeout });\n return text({ exit_code: out.exit_code, stdout: out.stdout, stderr: out.stderr });\n } catch (error) {\n return failed(`The command did not run: ${(error as Error).message}`);\n } finally {\n if (id) await client.deleteSandbox(id).catch(() => {});\n }\n }) as never,\n );\n\n register(\n \"list_agents\",\n {\n title: \"List the coding agents and providers\",\n description: \"Which harnesses run in a sandbox, and where their model can come from.\",\n inputSchema: {},\n },\n (async () => text({ agents: AGENTS, providers: PROVIDERS, host: ctx.host })) as never,\n );\n\n await server.connect(new StdioServerTransport());\n // The transport owns the process now: it ends when the client closes stdin.\n await new Promise<void>(() => {});\n },\n});\n","/** The machines: `ls`, `run`, `exec`, `ssh`, `open`, `rm`, `pause`, `resume`. */\n\nimport { spawn } from \"node:child_process\";\n\nimport { defineCommand } from \"citty\";\n\nimport type { CommandEvent, Sandbox } from \"../../api/types.ts\";\nimport { AGENT_TEMPLATE, createAgentSandbox } from \"../../core/agents.ts\";\nimport { AGENTS, PROVIDERS, type AgentName, type AuthMode, type ProviderName } from \"../../core/providers.ts\";\nimport { forwardSpec, sshArgv } from \"../../core/ssh.ts\";\nimport { commonArgs, context } from \"../context.ts\";\nimport { DESKTOP_PORT, openInBrowser } from \"../desktop.ts\";\nimport { duration, table } from \"../output.ts\";\n\nexport const ls = defineCommand({\n meta: { name: \"ls\", description: \"List your sandboxes.\" },\n args: { ...commonArgs, all: { type: \"boolean\", alias: \"a\", description: \"Stopped ones too.\" } },\n async run({ args }) {\n const { client, out } = await context(args);\n const boxes = await client.listSandboxes();\n const shown = args.all ? boxes : boxes.filter((box) => box.status !== \"stopped\");\n for (const box of shown) out.event({ type: \"sandbox\", ...box });\n if (out.mode === \"json\") return;\n if (!shown.length) {\n out.line(out.p.dim('No sandboxes. Start one with `munito agent \"...\"`.'));\n return;\n }\n const rows = [[\"ID\", \"STATUS\", \"TEMPLATE\", \"SIZE\", \"AGE\"], ...shown.map(row)];\n out.line(table(rows, out.p));\n },\n});\n\nfunction row(box: Sandbox): string[] {\n const age = box.created_at ? duration(Date.now() - box.created_at * 1000) : \"\";\n return [box.id, box.status, box.template, `${box.vcpus}c ${Math.round(box.memory_mib / 1024)}g`, age];\n}\n\nexport const run = defineCommand({\n meta: { name: \"run\", description: \"Run one command in a throwaway sandbox.\" },\n args: {\n ...commonArgs,\n command: { type: \"positional\", required: true, description: \"The command to run.\" },\n template: {\n type: \"string\",\n description: \"base, ubuntu, agent, desktop, or the name of a custom template. The default is base.\",\n default: \"base\",\n },\n size: { type: \"string\", description: \"tiny, small, default or large.\", default: \"small\" },\n internet: { type: \"boolean\", description: \"Allow outbound connections.\" },\n timeout: { type: \"string\", description: \"Seconds the command may take.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n const box = await client.createSandbox({\n template: args.template,\n size: args.size,\n internet: Boolean(args.internet),\n timeout: 600,\n metadata: { \"munito.cli\": \"run\" },\n });\n try {\n const exit = await stream(client, box.id, args.command as string, out, args.timeout);\n if (exit !== 0) process.exitCode = exit;\n } finally {\n await client.deleteSandbox(box.id).catch(() => {});\n }\n },\n});\n\nexport const exec = defineCommand({\n meta: { name: \"exec\", description: \"Run a command in a sandbox you already have.\" },\n args: {\n ...commonArgs,\n id: { type: \"positional\", required: true, description: \"The sandbox id.\" },\n command: { type: \"positional\", required: true, description: \"The command to run.\" },\n cwd: { type: \"string\", description: \"The working directory.\" },\n timeout: { type: \"string\", description: \"Seconds the command may take.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n const exit = await stream(client, args.id as string, args.command as string, out, args.timeout, args.cwd);\n if (exit !== 0) process.exitCode = exit;\n },\n});\n\nasync function stream(\n client: Awaited<ReturnType<typeof context>>[\"client\"],\n id: string,\n command: string,\n out: Awaited<ReturnType<typeof context>>[\"out\"],\n timeout?: string,\n cwd?: string,\n): Promise<number> {\n let exit = 0;\n const events = client.execStream(id, {\n command,\n cwd,\n timeout: timeout ? Number(timeout) : undefined,\n });\n for await (const event of events as AsyncGenerator<CommandEvent>) {\n if (event.type === \"stdout\") out.raw(event.data);\n else if (event.type === \"stderr\") out.raw(event.data, \"stderr\");\n else exit = event.exit_code;\n out.event({ ...event });\n }\n return exit;\n}\n\nexport const rm = defineCommand({\n meta: { name: \"rm\", description: \"Delete sandboxes.\" },\n args: { ...commonArgs, ids: { type: \"positional\", required: true, description: \"One or more sandbox ids.\" } },\n async run({ args, rawArgs }) {\n const { client, out } = await context(args);\n const ids = rawArgs.filter((value) => value.startsWith(\"sbx_\"));\n for (const id of ids.length ? ids : [args.ids as string]) {\n await client.deleteSandbox(id);\n out.step(\"deleted\", id);\n }\n },\n});\n\nexport const pause = defineCommand({\n meta: { name: \"pause\", description: \"Pause a persistent sandbox.\" },\n args: { ...commonArgs, id: { type: \"positional\", required: true, description: \"The sandbox id.\" } },\n async run({ args }) {\n const { client, out } = await context(args);\n const box = await client.pauseSandbox(args.id as string);\n out.step(\"paused\", box.id);\n },\n});\n\nexport const resume = defineCommand({\n meta: { name: \"resume\", description: \"Resume a paused sandbox.\" },\n args: { ...commonArgs, id: { type: \"positional\", required: true, description: \"The sandbox id.\" } },\n async run({ args }) {\n const { client, out } = await context(args);\n const box = await client.resumeSandbox(args.id as string);\n out.step(\"resumed\", box.id);\n },\n});\n\nexport const fork = defineCommand({\n meta: { name: \"fork\", description: \"Start new sandboxes from a persistent one, as it is now.\" },\n args: {\n ...commonArgs,\n id: { type: \"positional\", required: true, description: \"The sandbox to fork.\" },\n count: { type: \"string\", description: \"How many. The default is 1.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n const count = args.count ? Number(args.count) : 1;\n const started = Date.now();\n const answer = await client.forkSandbox(args.id as string, count);\n const forks = Array.isArray(answer) ? answer : (answer.data ?? []);\n out.step(\"forked\", `${forks.length} in ${duration(Date.now() - started)}`);\n for (const box of forks) out.line(out.p.dim(` ${box.id}`));\n out.result(\"\", { forks: forks.map((box) => box.id) });\n },\n});\n\nexport const ssh = defineCommand({\n meta: { name: \"ssh\", description: \"Open a shell in a sandbox.\" },\n args: {\n ...commonArgs,\n id: { type: \"positional\", required: true, description: \"The sandbox id.\" },\n forward: {\n type: \"string\",\n alias: \"L\",\n description: \"Forward a port: 3080, 3081:3080, or 3081:127.0.0.1:3080. Repeatable.\",\n },\n print: { type: \"boolean\", description: \"Print the command instead of connecting.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n // Checked before the request, so a typo costs no credential.\n const forwards = [args.forward ?? []].flat().filter(Boolean) as string[];\n const flags = forwards.flatMap((spec) => [\"-L\", forwardSpec(spec)]);\n // The credential rides in the SSH user and expires, so each call mints a fresh one. There is no key file.\n const access = await client.createSshAccess(args.id as string);\n if (args.print || !process.stdin.isTTY) {\n out.line(flags.length ? access.command.replace(/^ssh /, `ssh ${flags.join(\" \")} `) : access.command);\n return;\n }\n for (const spec of forwards) out.step(\"forwarding\", forwardSpec(spec));\n out.step(\"connecting\", access.host);\n const child = spawn(\"ssh\", sshArgv(access.user, access.host, forwards), {\n stdio: \"inherit\",\n });\n await new Promise<void>((done) =>\n child.on(\"close\", (code) => {\n process.exitCode = code ?? 0;\n done();\n }),\n );\n },\n});\n\nexport const open = defineCommand({\n meta: { name: \"open\", description: \"Open a sandbox port, or its desktop, in your browser.\" },\n args: {\n ...commonArgs,\n id: { type: \"positional\", required: true, description: \"The sandbox id.\" },\n port: { type: \"string\", description: `The port. The default is the desktop, ${DESKTOP_PORT}.` },\n expires: { type: \"string\", description: \"Seconds the link stays valid. The default is 3600.\" },\n print: { type: \"boolean\", description: \"Print the URL instead of opening it.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n const port = args.port ? Number(args.port) : DESKTOP_PORT;\n const signed = await client.signPortUrl(args.id as string, port, args.expires ? Number(args.expires) : 3600);\n out.event({ type: \"url\", url: signed.url, port });\n if (args.print || out.mode === \"json\" || !process.stdout.isTTY) {\n out.line(signed.url);\n return;\n }\n out.step(\"opening\", `port ${port}`);\n out.line(out.p.dim(` ${signed.url}`));\n openInBrowser(signed.url);\n },\n});\n\nexport const create = defineCommand({\n meta: { name: \"create\", description: \"Create a sandbox and leave it running.\" },\n args: {\n ...commonArgs,\n template: {\n type: \"string\",\n description: \"base, ubuntu, agent, desktop, or the name of a custom template.\",\n default: AGENT_TEMPLATE,\n },\n agent: { type: \"string\", description: `Point one harness at a provider: ${AGENTS.join(\", \")}.` },\n provider: { type: \"string\", description: `Where the model comes from: ${PROVIDERS.join(\", \")}.` },\n auth: { type: \"string\", description: \"token or subscription.\" },\n model: { type: \"string\", description: \"A model id, in place of the recommended one.\" },\n size: { type: \"string\", description: \"tiny, small, default or large.\", default: \"default\" },\n internet: { type: \"boolean\", description: \"Allow outbound connections.\", default: true },\n persistent: { type: \"boolean\", description: \"Keep files and processes across a pause.\" },\n timeout: { type: \"string\", description: \"Seconds the sandbox may live.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n const common = {\n template: args.template as string,\n size: args.size as string,\n internet: Boolean(args.internet),\n persistent: Boolean(args.persistent),\n timeout: args.timeout ? Number(args.timeout) : undefined,\n };\n const box = args.agent\n ? await createAgentSandbox(client, {\n ...common,\n agent: args.agent as AgentName,\n provider: args.provider as ProviderName | undefined,\n auth: args.auth as AuthMode | undefined,\n model: args.model as string | undefined,\n metadata: { \"munito.cli\": \"create\", \"munito.agent\": args.agent as string },\n })\n : await client.createSandbox({ ...common, metadata: { \"munito.cli\": \"create\" } });\n out.step(\"created\", box.id);\n out.line(out.p.dim(` munito ssh ${box.id}`));\n out.result(\"\", { sandbox_id: box.id });\n },\n});\n","/** Port forwards for an SSH connection to a sandbox. Pure: it builds argv, and runs nothing. */\n\nconst LOOPBACK = \"127.0.0.1\";\nconst PORT = /^[0-9]{1,5}$/;\n\nexport class ForwardError extends Error {}\n\nfunction port(value: string, spec: string): string {\n if (!PORT.test(value) || Number(value) < 1 || Number(value) > 65535) {\n throw new ForwardError(`\"${spec}\" is not a port forward. Use 3080, 3081:3080, or 3081:127.0.0.1:3080.`);\n }\n return value;\n}\n\n/**\n * One `-L` value from a short spec: `3080`, `3081:3080`, or a full `local:host:remote`.\n * The short forms bind the loopback of the sandbox, where a private server listens.\n */\nexport function forwardSpec(spec: string): string {\n const parts = spec.split(\":\");\n if (parts.length === 1) {\n const only = port(parts[0], spec);\n return `${only}:${LOOPBACK}:${only}`;\n }\n if (parts.length === 2) {\n return `${port(parts[0], spec)}:${LOOPBACK}:${port(parts[1], spec)}`;\n }\n if (parts.length === 3) {\n if (!parts[1]) throw new ForwardError(`\"${spec}\" names no host.`);\n return `${port(parts[0], spec)}:${parts[1]}:${port(parts[2], spec)}`;\n }\n throw new ForwardError(`\"${spec}\" is not a port forward. Use 3080, 3081:3080, or 3081:127.0.0.1:3080.`);\n}\n\n/** The argv of `ssh`, with one `-L` for each forward. */\nexport function sshArgv(user: string, host: string, forwards: readonly string[] = []): string[] {\n const argv = [\"-o\", \"StrictHostKeyChecking=accept-new\"];\n for (const spec of forwards) argv.push(\"-L\", forwardSpec(spec));\n argv.push(`${user}@${host}`);\n return argv;\n}\n","/** `munito templates`: deploy a container image as a sandbox template, list, read and delete templates. */\n\nimport { defineCommand } from \"citty\";\n\nimport type { Client } from \"../../api/client.ts\";\nimport type { Template } from \"../../api/types.ts\";\nimport {\n ENV_REGISTRY_TOKEN,\n TemplateError,\n deployBody,\n registryAuth,\n waitForBuild,\n type TemplateEvent,\n} from \"../../core/templates.ts\";\nimport { commonArgs, context, type CommonArgs } from \"../context.ts\";\nimport { bytes, table, type Out } from \"../output.ts\";\n\n/** citty loses its argument types inside subCommands, so a nested command reads them through this. */\nconst str = (value: unknown): string | undefined => (typeof value === \"string\" && value ? value : undefined);\n\nconst nameArg = {\n name: { type: \"positional\" as const, required: true, description: \"The name or the id of the template.\" },\n};\n\n/** The whole of standard input. A terminal is refused, because a token typed there shows on the screen. */\nasync function readStdin(): Promise<string> {\n if (process.stdin.isTTY) throw new TemplateError(`Pipe the token to --password-stdin, or set ${ENV_REGISTRY_TOKEN}.`);\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) chunks.push(Buffer.from(chunk as Uint8Array));\n return Buffer.concat(chunks).toString(\"utf8\");\n}\n\nconst deploy = defineCommand({\n meta: {\n name: \"deploy\",\n description: \"Build a container image into a template. A name that exists gets a new version.\",\n },\n args: {\n ...commonArgs,\n name: {\n type: \"positional\",\n required: true,\n description: \"The template name: lower case letters, digits and hyphens.\",\n },\n image: { type: \"positional\", required: true, description: \"The image, such as ghcr.io/acme/agent:1.4.\" },\n username: { type: \"string\", description: \"The user name of a private registry.\" },\n \"password-stdin\": {\n type: \"boolean\",\n description: `Read the registry password or token from standard input. Or set ${ENV_REGISTRY_TOKEN}.`,\n },\n wait: { type: \"boolean\", description: \"Wait until the build ends. Exit 1 when it fails.\" },\n },\n async run({ args }) {\n // A token in a flag stays in the shell history and the process list, so there is no such flag.\n if ((args as Record<string, unknown>).password !== undefined) {\n throw new TemplateError(`There is no --password. Use --password-stdin, or set ${ENV_REGISTRY_TOKEN}.`);\n }\n const { auth, ignored } = registryAuth({\n username: str(args.username),\n stdin: args[\"password-stdin\"] ? await readStdin() : undefined,\n env: process.env[ENV_REGISTRY_TOKEN],\n });\n const body = deployBody(String(args.name), String(args.image), auth);\n const { client, out } = await context(args as CommonArgs);\n if (ignored) out.warn(`${ENV_REGISTRY_TOKEN} is set without --username, so the deploy sends no credential.`);\n const template = await client.deployTemplate(body);\n out.event({ type: \"template\", ...template });\n out.step(\"deploying\", `${template.name} v${template.build.version} ${template.build.image}`);\n if (args.wait) {\n await follow(client, out, template.id);\n return;\n }\n out.line(out.p.dim(` munito templates get ${template.name} --wait`));\n out.result(\"\", { template: template.name, id: template.id, version: template.build.version });\n },\n});\n\nconst ls = defineCommand({\n meta: { name: \"ls\", description: \"List the templates of your workspace.\" },\n args: commonArgs,\n async run({ args }) {\n const { client, out } = await context(args);\n const templates = await client.listTemplates();\n for (const template of templates) out.event({ type: \"template\", ...template });\n if (out.mode === \"json\") return;\n if (!templates.length) {\n out.line(out.p.dim(\"No templates. Deploy one with `munito templates deploy <name> <image>`.\"));\n return;\n }\n const rows = [[\"NAME\", \"STATUS\", \"VERSION\", \"IMAGE\", \"SIZE\", \"NEWEST BUILD\"], ...templates.map(row)];\n out.line(table(rows, out.p));\n },\n});\n\nfunction row(template: Template): string[] {\n const serving = template.version ? `v${template.version}` : \"-\";\n const { build } = template;\n return [\n template.name,\n template.status,\n serving,\n template.image ?? \"-\",\n bytes(template.size_bytes),\n `v${build.version} ${build.status}`,\n ];\n}\n\nconst get = defineCommand({\n meta: { name: \"get\", description: \"Show a template and its newest build.\" },\n args: {\n ...commonArgs,\n ...nameArg,\n wait: { type: \"boolean\", description: \"Wait until the newest build ends. Exit 1 when it fails.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n if (args.wait) {\n await follow(client, out, String(args.name));\n return;\n }\n show(out, await client.getTemplate(String(args.name)));\n },\n});\n\nconst rm = defineCommand({\n meta: { name: \"rm\", description: \"Delete templates. Their running sandboxes keep running.\" },\n args: { ...commonArgs, names: { type: \"positional\", required: true, description: \"One or more template names.\" } },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const names = args._.length ? args._ : [String(args.names)];\n for (const name of names) {\n await client.deleteTemplate(name);\n out.event({ type: \"template.deleted\", name });\n out.step(\"deleted\", name);\n }\n },\n});\n\n/** Read the template until its newest build ends, then show it. A failed build is a failed command. */\nasync function follow(client: Client, out: Out, ref: string): Promise<void> {\n const template = await waitForBuild(client, ref, {\n onEvent: (event: TemplateEvent) => {\n out.event({ ...event });\n out.step(event.status, `${event.name} v${event.version}`);\n },\n });\n show(out, template);\n if (template.build.status === \"failed\") process.exitCode = 1;\n}\n\n/** The template, the version that new sandboxes start from, and its newest build with the reason of a failure. */\nfunction show(out: Out, template: Template): void {\n out.event({ type: \"template\", ...template });\n const { build } = template;\n out.result(\"\", {\n template: template.name,\n id: template.id,\n status: template.status,\n version: template.version ?? null,\n build: { version: build.version, status: build.status },\n });\n if (out.mode === \"json\") return;\n out.step(template.name, template.status);\n const facts = [\n [\"id\", template.id],\n [\"serving\", template.version ? `v${template.version} ${template.image ?? \"\"}` : \"none yet\"],\n [\"size\", bytes(template.size_bytes)],\n [\"digest\", template.digest ?? \"-\"],\n [\"build\", `v${build.version} ${build.status} ${build.image}`],\n ];\n if (build.error) facts.push([\"error\", build.error.message]);\n out.line(\n table(facts, out.p, false)\n .split(\"\\n\")\n .map((line) => ` ${line}`)\n .join(\"\\n\"),\n );\n if (build.status === \"failed\" && build.log) {\n out.line(out.p.dim(\" the end of the build output:\"));\n for (const line of build.log.replace(/\\n$/, \"\").split(\"\\n\")) out.line(out.p.dim(` ${line}`));\n }\n}\n\nexport const templates = defineCommand({\n meta: { name: \"templates\", description: \"Start sandboxes from your own container image.\" },\n subCommands: { deploy, ls, get, rm },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,YAAY,eAAe;;;ACGpC,SAAS,gBAAgB;AACzB,SAAS,SAAS,UAAU,IAAI,MAAM,iBAAiB;AACvD,SAAS,cAAc;AACvB,SAAS,MAAM,eAAe;AAC9B,SAAS,iBAAiB;AAI1B,IAAM,MAAM,UAAU,QAAQ;AAGvB,IAAM,YAAY;AAClB,IAAM,iBAAiB,KAAK;AAC5B,IAAM,kBAAkB,MAAM;AAE9B,IAAM,iBAAN,cAA6B,MAAM;AAAC;AAG3C,eAAsB,QAAQ,KAAqC;AACjE,QAAM,OAAO,QAAQ,OAAO,QAAQ,IAAI,CAAC;AACzC,QAAM,SAAS,MAAM,YAAY,IAAI;AACrC,MAAI,CAAC,OAAQ,QAAO,CAAC;AAErB,QAAM,QAAsB,CAAC;AAC7B,MAAI,QAAQ;AACZ,aAAW,YAAY,QAAQ;AAC7B,QAAI,MAAM,UAAU,UAAW;AAC/B,UAAM,WAAW,KAAK,MAAM,QAAQ;AACpC,QAAI;AACJ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AM,EAAE,QAAQ,CAAC,EAAE,MAAM,OAAO,UAAmB;AAClE,QAAI,iBAAiB,SAAS,MAAM,SAAS,WAAY,OAAM,QAAQ,IAAI;AAC3E,YAAQ,KAAKA,QAAO,KAAK,CAAC;AAAA,EAC5B,CAAC;","names":["bytes","defineCommand","stream","text","stream","text","row","channel","require","out","out","name","run","defineCommand","defineCommand","out","text","stream","defineCommand","defineCommand","out","spawn","defineCommand","defineCommand","out","spawn","writeFile","defineCommand","defineCommand","out","writeFile","defineCommand","defineCommand","agent","run","out","spawn","defineCommand","defineCommand","out","run","rm","rawArgs","spawn","port","defineCommand","str","nameArg","defineCommand","out","ls","templates","row","rm","defineCommand","run","rm","report","channel"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/core/workspace.ts","../src/cli/main.ts","../src/cli/commands/agent.ts","../src/cli/theme.ts","../src/cli/output.ts","../src/cli/context.ts","../src/cli/desktop.ts","../src/cli/commands/ci.ts","../src/cli/commands/auth.ts","../src/cli/commands/herdr.ts","../src/cli/commands/init.ts","../src/cli/commands/mcp.ts","../src/cli/commands/proxies.ts","../src/cli/commands/sandboxes.ts","../src/core/ssh.ts","../src/cli/commands/templates.ts"],"sourcesContent":["#!/usr/bin/env node\n/** The `munito` binary. One place turns a failure into a line a person can act on. */\n\nimport { runCommand, runMain } from \"citty\";\n\nimport { ApiError } from \"./api/client.ts\";\nimport { MissingKeyError } from \"./core/keys.ts\";\nimport { WiringError } from \"./core/providers.ts\";\nimport { TemplateError } from \"./core/templates.ts\";\nimport { WorkspaceError } from \"./core/workspace.ts\";\nimport { main } from \"./cli/main.ts\";\nimport { out } from \"./cli/output.ts\";\n\nconst CONSOLE_BILLING = \"https://console.munito.ai/billing\";\n\nfunction report(error: unknown): number {\n const channel = out(false);\n if (error instanceof MissingKeyError) {\n channel.error(error.message);\n return 2;\n }\n if (error instanceof WiringError || error instanceof WorkspaceError || error instanceof TemplateError) {\n channel.error(error.message);\n return 2;\n }\n if (error instanceof ApiError) {\n channel.error(error.message);\n if (error.status === 401) channel.line(channel.p.dim(\" The key is not valid here. Run `munito login`.\"));\n if (error.status === 402) channel.line(channel.p.dim(` Check your plan and credits at ${CONSOLE_BILLING}`));\n if (error.status === 429) channel.line(channel.p.dim(\" Too many at once. Wait, or ask for a larger plan.\"));\n if (error.requestId) channel.line(channel.p.dim(` request ${error.requestId}`));\n return error.status === 401 || error.status === 402 ? 2 : 1;\n }\n channel.error(error instanceof Error ? error.message : String(error));\n return 1;\n}\n\nprocess.on(\"unhandledRejection\", (reason) => {\n process.exit(report(reason));\n});\n\n// citty's runMain prints every failure with its stack and exits 1, so it runs only what it owns: help, the version,\n// and a usage error, which citty raises before any command runs. A second pass then prints the usage.\nconst rawArgs = process.argv.slice(2);\nconst own =\n rawArgs.some((arg) => arg === \"--help\" || arg === \"-h\") ||\n (rawArgs.length === 1 && (rawArgs[0] === \"--version\" || rawArgs[0] === \"-v\"));\nif (own) await runMain(main);\nelse\n await runCommand(main, { rawArgs }).catch(async (error: unknown) => {\n if (error instanceof Error && error.name === \"CLIError\") await runMain(main);\n process.exit(report(error));\n });\n","/** The local worktree that an agent should see, and the patch it sends back.\n\nOnly files that git already tracks or would track, so an ignored secret, a build directory and a venv never leave the\nmachine. Core code: no terminal output.\n*/\n\nimport { execFile } from \"node:child_process\";\nimport { mkdtemp, readFile, rm, stat, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { promisify } from \"node:util\";\n\nimport type { UploadFile } from \"./agents.ts\";\n\nconst run = promisify(execFile);\n\n/** Caps, so a stray directory cannot turn one command into a long upload. */\nexport const MAX_FILES = 2_000;\nexport const MAX_FILE_BYTES = 1 << 20;\nexport const MAX_TOTAL_BYTES = 16 << 20;\n\nexport class WorkspaceError extends Error {}\n\n/** The files of the git worktree at `dir`, or none when it is not a repository. */\nexport async function collect(dir?: string): Promise<UploadFile[]> {\n const root = resolve(dir ?? process.cwd());\n const listed = await listTracked(root);\n if (!listed) return [];\n\n const files: UploadFile[] = [];\n let total = 0;\n for (const relative of listed) {\n if (files.length >= MAX_FILES) break;\n const absolute = join(root, relative);\n let info;\n try {\n info = await stat(absolute);\n } catch {\n continue;\n }\n if (!info.isFile() || info.size > MAX_FILE_BYTES) continue;\n if (total + info.size > MAX_TOTAL_BYTES) break;\n const buffer = await readFile(absolute);\n if (isBinary(buffer)) continue;\n total += info.size;\n files.push({ path: relative, content: buffer.toString(\"utf8\") });\n }\n return files;\n}\n\nasync function listTracked(root: string): Promise<string[] | null> {\n try {\n // Tracked plus untracked, with .gitignore applied, so nothing ignored is ever uploaded.\n const { stdout } = await run(\"git\", [\"-C\", root, \"ls-files\", \"-co\", \"--exclude-standard\", \"-z\"], {\n maxBuffer: 32 << 20,\n });\n return stdout.split(\"\\0\").filter(Boolean);\n } catch {\n return null;\n }\n}\n\n/** A NUL byte in the first block is the same test git uses. */\nfunction isBinary(buffer: Buffer): boolean {\n return buffer.subarray(0, 8000).includes(0);\n}\n\nexport function describeUpload(files: UploadFile[]): string {\n const bytes = files.reduce((sum, file) => sum + Buffer.byteLength(file.content), 0);\n const size = bytes > 1 << 20 ? `${(bytes / (1 << 20)).toFixed(1)} MiB` : `${Math.ceil(bytes / 1024)} KiB`;\n return `${files.length} files, ${size}`;\n}\n\n/** Apply a unified diff to the worktree. Returns the files that changed, and changes nothing when it cannot. */\nexport async function applyPatch(patch: string, dir?: string): Promise<string[]> {\n const root = resolve(dir ?? process.cwd());\n if (!patch.trim()) return [];\n const file = join(await mkdtemp(join(tmpdir(), \"munito-\")), \"patch.diff\");\n await writeFile(file, patch);\n try {\n // --check first, so a patch that cannot apply leaves the worktree untouched.\n await run(\"git\", [\"-C\", root, \"apply\", \"--check\", file]);\n const { stdout } = await run(\"git\", [\"-C\", root, \"apply\", \"--numstat\", file]);\n await run(\"git\", [\"-C\", root, \"apply\", file]);\n return stdout\n .split(\"\\n\")\n .map((line) => line.split(\"\\t\").at(2))\n .filter((name): name is string => Boolean(name));\n } catch (error) {\n throw new WorkspaceError(`The patch did not apply: ${(error as Error).message}`);\n } finally {\n await rm(file, { force: true });\n }\n}\n","/** The command tree. Every command is a thin layer over core/, which does the work. */\n\nimport { defineCommand } from \"citty\";\n\nimport { agent } from \"./commands/agent.ts\";\nimport { ci } from \"./commands/ci.ts\";\nimport { login, logout, whoami } from \"./commands/auth.ts\";\nimport { herdr } from \"./commands/herdr.ts\";\nimport { init } from \"./commands/init.ts\";\nimport { mcp } from \"./commands/mcp.ts\";\nimport { proxies } from \"./commands/proxies.ts\";\nimport { create, exec, fork, ls, open, pause, resume, rm, run, ssh } from \"./commands/sandboxes.ts\";\nimport { templates } from \"./commands/templates.ts\";\n\n// The build replaces this with the version in package.json.\ndeclare const __MUNITO_VERSION__: string;\nconst VERSION = typeof __MUNITO_VERSION__ === \"string\" ? __MUNITO_VERSION__ : \"0.0.0-dev\";\n\nexport const main = defineCommand({\n meta: {\n name: \"munito\",\n // Without this, `munito --version` exits with \"No version specified\".\n version: VERSION,\n description: \"Run coding agents on European infrastructure, one command at a time.\",\n },\n subCommands: {\n agent,\n ci,\n herdr,\n init,\n mcp,\n login,\n logout,\n whoami,\n ls,\n create,\n run,\n exec,\n ssh,\n open,\n rm,\n pause,\n resume,\n fork,\n templates,\n proxies,\n },\n});\n","/** `munito agent` — the one command. */\n\nimport { defineCommand } from \"citty\";\n\nimport { runAgent, type AgentEvent } from \"../../core/agents.ts\";\nimport { AGENTS, PROVIDERS, type AgentName, type AuthMode, type ProviderName } from \"../../core/providers.ts\";\nimport { applyPatch, collect, describeUpload } from \"../../core/workspace.ts\";\nimport { commonArgs, context } from \"../context.ts\";\nimport { duration } from \"../output.ts\";\nimport { openDesktop } from \"../desktop.ts\";\n\nexport const agent = defineCommand({\n meta: {\n name: \"agent\",\n description: \"Run a coding agent in a sandbox and bring its work back.\",\n },\n args: {\n ...commonArgs,\n agent: {\n type: \"positional\",\n required: false,\n description: `Which harness: ${AGENTS.join(\", \")}. The default is claude.`,\n },\n prompt: { type: \"positional\", required: false, description: \"What the agent should do.\" },\n provider: {\n type: \"string\",\n description: `Where the model comes from: ${PROVIDERS.join(\", \")}.`,\n default: \"munito\",\n },\n auth: { type: \"string\", description: \"token or subscription.\", default: \"token\" },\n model: { type: \"string\", description: \"A model id, in place of the recommended one.\" },\n repo: { type: \"string\", description: \"A directory to upload. The default is the current git worktree.\" },\n \"no-upload\": { type: \"boolean\", description: \"Send no files at all.\" },\n size: { type: \"string\", description: \"tiny, small, default or large.\", default: \"default\" },\n template: { type: \"string\", description: \"A sandbox template, in place of the agent one.\" },\n timeout: { type: \"string\", description: \"Seconds the sandbox may live. The default is 3600.\" },\n \"max-turns\": { type: \"string\", description: \"Stop the agent after this many turns.\" },\n keep: { type: \"boolean\", description: \"Leave the sandbox running when the task ends.\" },\n desktop: { type: \"boolean\", description: \"Give the agent a screen, and open the viewer. Implies --keep.\" },\n \"no-apply\": { type: \"boolean\", description: \"Do not apply the agent's patch to your worktree.\" },\n },\n async run({ args }) {\n // One positional means the prompt, and claude runs it.\n let name = (args.agent ?? \"claude\") as AgentName;\n let prompt = args.prompt as string | undefined;\n if (!AGENTS.includes(name)) {\n prompt = [args.agent, prompt].filter(Boolean).join(\" \");\n name = \"claude\";\n }\n if (!prompt) throw new Error('Give the agent something to do: munito agent \"fix the failing test\"');\n\n const ctx = await context(args);\n const { out, client } = ctx;\n\n // The parser reads `--no-x` as `x: false`, so a flag named `no-x` never arrives under its own name.\n const off = (name: string) => args[`no-${name}`] === true || args[name] === false;\n const upload = off(\"upload\") ? [] : await collect(args.repo);\n const started = Date.now();\n // A screen is only useful while the machine lives, so a desktop run keeps it.\n const desktop = Boolean(args.desktop);\n const keep = Boolean(args.keep) || desktop;\n\n out.line();\n out.line(`${out.p.badge(\"munito\")} ${out.p.bold(name)} ${out.p.dim(`on ${args.provider}`)}`);\n out.line(out.p.dim(` ${prompt}`));\n out.line();\n if (upload.length) out.step(\"workspace\", describeUpload(upload));\n\n let streamed = false;\n const onEvent = (event: AgentEvent) => {\n out.event({ ...event });\n switch (event.type) {\n case \"sandbox.creating\":\n out.step(\"sandbox\", \"starting\");\n break;\n case \"sandbox.created\":\n out.step(\"sandbox\", `${event.sandboxId} in ${duration(event.ms)}`);\n if (desktop) void openDesktop(client, event.sandboxId, out);\n break;\n case \"files.uploaded\":\n out.step(\"uploaded\", `${event.count} files`);\n break;\n case \"harness.installing\":\n out.step(\"installing\", `${event.package}, once`);\n break;\n case \"harness.installed\":\n out.step(\"installed\", duration(event.ms));\n break;\n case \"agent.started\":\n out.step(\"running\", name);\n out.line();\n break;\n case \"output\":\n // Claude Code answers with one JSON envelope, so holding it back keeps the screen clean.\n if (name !== \"claude\") {\n streamed = true;\n out.raw(event.data, event.stream);\n }\n break;\n case \"agent.finished\":\n if (streamed) out.line();\n out.step(\"finished\", `exit ${event.exitCode} in ${duration(event.ms)}`);\n break;\n case \"sandbox.kept\":\n out.step(\"kept\", `${event.sandboxId} — munito ssh ${event.sandboxId}`);\n break;\n default:\n break;\n }\n };\n\n const run = await runAgent(client, {\n agent: name,\n prompt,\n provider: args.provider as ProviderName,\n auth: args.auth as AuthMode,\n model: args.model,\n size: args.size,\n template: args.template ?? (desktop ? \"desktop\" : undefined),\n timeout: args.timeout ? Number(args.timeout) : undefined,\n maxTurns: args[\"max-turns\"] ? Number(args[\"max-turns\"]) : undefined,\n keep,\n files: upload,\n onEvent,\n });\n\n if (!streamed && run.result && out.mode !== \"json\") {\n out.line();\n out.line(run.result);\n }\n\n let changed: string[] = [];\n if (run.patch && !off(\"apply\")) {\n try {\n changed = await applyPatch(run.patch, args.repo);\n out.line();\n out.step(\"applied\", `${changed.length} files`);\n for (const file of changed) out.line(out.p.dim(` ${file}`));\n } catch (error) {\n out.warn((error as Error).message);\n out.line(out.p.dim(\" The diff is in the JSON output: rerun with --json.\"));\n }\n } else if (run.patch) {\n out.step(\"patch\", `${Buffer.byteLength(run.patch)} bytes, not applied`);\n }\n\n out.line();\n out.step(\"done\", duration(Date.now() - started));\n out.result(run.result, {\n sandbox_id: run.sandboxId,\n exit_code: run.exitCode,\n session_id: run.sessionId,\n duration_ms: run.durationMs,\n files_changed: changed,\n patch: run.patch || undefined,\n });\n if (run.exitCode !== 0) process.exitCode = run.exitCode;\n },\n});\n","/** The Munito palette in a terminal, and the rule that decides whether to use it.\n\nThe brand violet `#702cf6` is unreadable as text on a dark terminal. The design system already answers this: in dark\nmode it swaps the text violet to the cube top. A terminal is dark mode, so the primary here is `#9a68fa`.\nSource: `typescript/packages/design-system/src/styles/tokens.css`, which copies the brand kit.\n*/\n\nexport const BRAND = {\n violet: [0x70, 0x2c, 0xf6],\n cubeTop: [0x9a, 0x68, 0xfa],\n cubeSide: [0x4a, 0x1f, 0xa8],\n lime: [0xd7, 0xfa, 0x4a],\n lilac: [0xa0, 0x81, 0xde],\n paper: [0xf0, 0xee, 0xf3],\n ink: [0x21, 0x16, 0x29],\n night: [0x14, 0x10, 0x19],\n} as const satisfies Record<string, readonly [number, number, number]>;\n\nexport type Depth = 0 | 4 | 8 | 24;\n\n/** What the stream can draw, from the environment that the user and their tools set. */\nexport function colorDepth(stream: NodeJS.WriteStream = process.stdout): Depth {\n if (process.env.NO_COLOR !== undefined && process.env.NO_COLOR !== \"\") return 0;\n const forced = process.env.FORCE_COLOR;\n if (forced !== undefined) {\n if (forced === \"0\" || forced === \"false\") return 0;\n if (forced === \"1\" || forced === \"true\") return 4;\n if (forced === \"2\") return 8;\n if (forced === \"3\") return 24;\n }\n if (!stream.isTTY) return 0;\n if (process.env.TERM === \"dumb\") return 0;\n const colorterm = process.env.COLORTERM ?? \"\";\n if (colorterm === \"truecolor\" || colorterm === \"24bit\") return 24;\n if (/-256(color)?$/i.test(process.env.TERM ?? \"\")) return 8;\n return 4;\n}\n\nconst RESET = \"\\u001b[39m\";\nconst BOLD = \"\\u001b[1m\";\nconst UNBOLD = \"\\u001b[22m\";\nconst DIM = \"\\u001b[2m\";\nconst UNDIM = \"\\u001b[22m\";\n\n/** The nearest xterm-256 index of a colour, through the 6x6x6 cube. */\nfunction to256([r, g, b]: readonly [number, number, number]): number {\n const step = (value: number) => (value < 48 ? 0 : value < 115 ? 1 : Math.min(5, Math.round((value - 35) / 40)));\n return 16 + 36 * step(r) + 6 * step(g) + step(b);\n}\n\n/** The nearest of the 8 basic colours. Violet and lilac land on magenta, lime on bright yellow. */\nfunction to16([r, g, b]: readonly [number, number, number]): number {\n const bright = Math.max(r, g, b) > 0xa0;\n const bit = (value: number) => (value > 0x7f ? 1 : 0);\n const code = bit(r) + bit(g) * 2 + bit(b) * 4;\n return (bright ? 90 : 30) + code;\n}\n\nexport interface Palette {\n readonly depth: Depth;\n primary(text: string): string;\n accent(text: string): string;\n dim(text: string): string;\n text(text: string): string;\n bold(text: string): string;\n /** Paper on brand violet, the one place the true brand violet reads well. */\n badge(text: string): string;\n}\n\nexport function palette(stream: NodeJS.WriteStream = process.stdout): Palette {\n const depth = colorDepth(stream);\n const fg = (color: readonly [number, number, number]) => {\n if (depth === 0) return (text: string) => text;\n if (depth === 24) return (text: string) => `\\u001b[38;2;${color[0]};${color[1]};${color[2]}m${text}${RESET}`;\n if (depth === 8) return (text: string) => `\\u001b[38;5;${to256(color)}m${text}${RESET}`;\n return (text: string) => `\\u001b[${to16(color)}m${text}${RESET}`;\n };\n const plain = depth === 0;\n return {\n depth,\n primary: fg(BRAND.cubeTop),\n accent: fg(BRAND.lime),\n dim: plain ? (text) => text : (text) => `${DIM}${fg(BRAND.lilac)(text)}${UNDIM}`,\n text: fg(BRAND.paper),\n bold: plain ? (text) => text : (text) => `${BOLD}${text}${UNBOLD}`,\n badge: plain\n ? (text) => text\n : (text) =>\n depth === 24\n ? `\\u001b[48;2;${BRAND.violet.join(\";\")}m\\u001b[38;2;${BRAND.paper.join(\";\")}m ${text} \\u001b[49m${RESET}`\n : `\\u001b[45m\\u001b[97m ${text} \\u001b[49m${RESET}`,\n };\n}\n\n/** The cube of the brand mark, in half blocks. The wordmark is the logo and does not belong in ASCII. */\nexport function cube(p: Palette): string {\n const top = p.primary(\"▄▄▄▄▄▄\");\n const body = p.primary(\"██████\");\n return [` ${top}`, ` ${body}`, ` ${p.dim(\"▀▀▀▀▀▀\")}`].join(\"\\n\");\n}\n","/** What reaches the terminal. Rich when it is a terminal, plain lines when it is not, NDJSON with --json.\n\nOur own agents call this CLI through a pipe, so every command has to be readable without a TTY.\n*/\n\nimport { palette, type Palette } from \"./theme.ts\";\n\nexport type Mode = \"rich\" | \"plain\" | \"json\";\n\nexport interface Out {\n readonly mode: Mode;\n readonly p: Palette;\n /** One line for a person. Silent in json mode. */\n line(text?: string): void;\n /** A labelled step, such as a created sandbox. */\n step(label: string, detail?: string): void;\n /** One machine-readable event. Printed only in json mode. */\n event(body: Record<string, unknown>): void;\n /** The machine-readable end of a command. Prints in json mode only: a person's copy is the caller's job. */\n result(text: string, body?: Record<string, unknown>): void;\n warn(text: string): void;\n error(text: string): void;\n /** Raw bytes of a child process, passed through with no decoration. */\n raw(text: string, stream?: \"stdout\" | \"stderr\"): void;\n}\n\nexport function out(json: boolean, stream: NodeJS.WriteStream = process.stdout): Out {\n const p = palette(stream);\n const mode: Mode = json ? \"json\" : p.depth === 0 ? \"plain\" : \"rich\";\n const write = (text: string) => stream.write(`${text}\\n`);\n return {\n mode,\n p,\n line(text = \"\") {\n if (mode !== \"json\") write(text);\n },\n step(label, detail) {\n if (mode === \"json\") return;\n const mark = mode === \"rich\" ? p.primary(\"›\") : \">\";\n write(detail ? `${mark} ${label} ${p.dim(detail)}` : `${mark} ${label}`);\n },\n event(body) {\n if (mode === \"json\") write(JSON.stringify(body));\n },\n result(text, body) {\n if (mode === \"json\") write(JSON.stringify({ type: \"result\", ...body, result: text }));\n },\n warn(text) {\n if (mode === \"json\") {\n process.stderr.write(`${JSON.stringify({ type: \"warning\", message: text })}\\n`);\n return;\n }\n process.stderr.write(`${mode === \"rich\" ? p.accent(\"!\") : \"!\"} ${text}\\n`);\n },\n error(text) {\n if (mode === \"json\") {\n process.stderr.write(`${JSON.stringify({ type: \"error\", message: text })}\\n`);\n return;\n }\n process.stderr.write(`${mode === \"rich\" ? \"\\u001b[31m✗\\u001b[39m\" : \"x\"} ${text}\\n`);\n },\n raw(text, target = \"stdout\") {\n if (mode === \"json\") return;\n (target === \"stderr\" ? process.stderr : stream).write(text);\n },\n };\n}\n\n/** Seconds with one decimal, or milliseconds below a second. */\nexport function duration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)} ms`;\n if (ms < 60_000) return `${(ms / 1000).toFixed(1)} s`;\n const minutes = Math.floor(ms / 60_000);\n return `${minutes} min ${Math.round((ms % 60_000) / 1000)} s`;\n}\n\n/** The size of the files of an image, as \"1.2 GiB\" or \"340 MiB\". */\nexport function bytes(value?: number | null): string {\n if (value === null || value === undefined) return \"-\";\n if (value >= 1024 ** 3) return `${(value / 1024 ** 3).toFixed(1)} GiB`;\n return `${Math.max(1, Math.round(value / 1024 ** 2))} MiB`;\n}\n\n/** A left-aligned table that stays readable with no colour. */\nexport function table(rows: string[][], p: Palette, heading = true): string {\n if (!rows.length) return \"\";\n const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => (row[column] ?? \"\").length)));\n return rows\n .map((row, index) => {\n const line = row\n .map((cell, column) => (cell ?? \"\").padEnd(widths[column]))\n .join(\" \")\n .trimEnd();\n return heading && index === 0 ? p.dim(line) : line;\n })\n .join(\"\\n\");\n}\n","/** What every command needs: the key, a client and an output channel. */\n\nimport { Client } from \"../api/client.ts\";\nimport * as keys from \"../core/keys.ts\";\nimport { out, type Out } from \"./output.ts\";\n\nexport interface CommonArgs {\n json?: boolean;\n region?: string;\n host?: string;\n}\n\nexport interface Context {\n client: Client;\n out: Out;\n host: string;\n source: string;\n}\n\n/** The shared flags, so every command declares them the same way. */\nexport const commonArgs = {\n json: { type: \"boolean\" as const, description: \"Print NDJSON events instead of text.\" },\n region: { type: \"string\" as const, description: \"global, eu or us. The default is global.\" },\n host: { type: \"string\" as const, description: \"A full API URL, in place of a region.\" },\n};\n\nexport async function context(args: CommonArgs): Promise<Context> {\n const channel = out(Boolean(args.json));\n const credentials = await keys.require(args.host ?? args.region);\n return {\n client: new Client({ apiKey: credentials.apiKey, baseUrl: credentials.host }),\n out: channel,\n host: credentials.host,\n source: credentials.source,\n };\n}\n\n/** An output channel before the key is known, for `login` and for failures. */\nexport function channel(args: CommonArgs): Out {\n return out(Boolean(args.json));\n}\n","/** Signing a port and handing it to a browser, shared by `munito open` and `munito agent --desktop`. */\n\nimport { spawn } from \"node:child_process\";\n\nimport type { Client } from \"../api/client.ts\";\nimport type { Out } from \"./output.ts\";\n\nexport const DESKTOP_PORT = 6080;\n\nexport function openInBrowser(url: string): void {\n const opener = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n spawn(opener, [url], { stdio: \"ignore\", detached: true }).unref();\n}\n\n/** A viewer for a running desktop sandbox. The sandbox has to be up, so a caller waits for its create first. */\nexport async function openDesktop(client: Client, sandboxId: string, out: Out, expiresIn = 3600): Promise<void> {\n try {\n const signed = await client.signPortUrl(sandboxId, DESKTOP_PORT, expiresIn);\n out.event({ type: \"url\", url: signed.url, port: DESKTOP_PORT });\n out.step(\"desktop\", signed.url);\n if (out.mode !== \"json\" && process.stdout.isTTY) openInBrowser(signed.url);\n } catch (error) {\n out.warn(`The desktop did not open: ${(error as Error).message}`);\n }\n}\n","/** `munito ci` — the warm-base CI recipe as three commands. */\n\nimport { defineCommand } from \"citty\";\n\nimport { DEFAULT_BASE_SIZE, DEFAULT_DISK_GIB, drop, findBase, job, warm, type CiEvent } from \"../../core/ci.ts\";\nimport { commonArgs, context, type CommonArgs } from \"../context.ts\";\nimport { duration } from \"../output.ts\";\n\nconst nameArg = {\n name: { type: \"string\" as const, description: \"Which warm base. The default is the repository name.\", default: \"\" },\n};\n\n/** citty loses its argument types inside subCommands, so a nested command reads them through these. */\nconst str = (value: unknown): string | undefined => (typeof value === \"string\" && value ? value : undefined);\nconst num = (value: unknown): number | undefined => (typeof value === \"string\" && value ? Number(value) : undefined);\n\n/** One base per repository unless the caller names another. */\nfunction baseName(given: string): string {\n if (given) return given;\n const repo = process.env.GITHUB_REPOSITORY ?? process.env.CI_PROJECT_PATH;\n if (repo) return repo.replaceAll(\"/\", \"-\");\n return process.cwd().split(\"/\").filter(Boolean).at(-1) ?? \"default\";\n}\n\nexport const ci = defineCommand({\n meta: { name: \"ci\", description: \"Run CI jobs on a warm sandbox that already holds your dependencies.\" },\n subCommands: {\n warm: defineCommand({\n meta: { name: \"warm\", description: \"Build the warm base and pause it.\" },\n args: {\n ...commonArgs,\n ...nameArg,\n setup: { type: \"positional\", required: true, description: \"The command that installs everything.\" },\n size: { type: \"string\", description: `The size of the base. The default is ${DEFAULT_BASE_SIZE}.` },\n disk: { type: \"string\", description: `Root disk in GiB. The default is ${DEFAULT_DISK_GIB}.` },\n template: { type: \"string\", description: \"A template. The default is ubuntu.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const name = baseName(str(args.name) ?? \"\");\n const result = await warm(client, {\n name,\n setup: String(args.setup),\n size: str(args.size),\n diskGib: num(args.disk),\n template: str(args.template),\n onEvent: report(out),\n });\n out.step(\"ready\", `base ${result.sandboxId} for ${name}`);\n out.line(out.p.dim(` munito ci run --name ${name} \"<your test command>\"`));\n out.result(\"\", { base: result.sandboxId, name });\n },\n }),\n\n run: defineCommand({\n meta: { name: \"run\", description: \"Fork the warm base, run one job, delete the fork.\" },\n args: {\n ...commonArgs,\n ...nameArg,\n command: { type: \"positional\", required: true, description: \"The job command.\" },\n cwd: { type: \"string\", description: \"The working directory in the sandbox.\" },\n timeout: { type: \"string\", description: \"Seconds the job may take.\" },\n keep: { type: \"boolean\", description: \"Keep the fork, to look at a failure.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const name = baseName(str(args.name) ?? \"\");\n const exit = await job(client, {\n name,\n command: String(args.command),\n cwd: str(args.cwd),\n timeout: num(args.timeout),\n keep: Boolean(args.keep),\n onOutput: (text, stream) => out.raw(text, stream),\n onEvent: report(out),\n });\n out.result(\"\", { exit_code: exit, name });\n if (exit !== 0) process.exitCode = exit;\n },\n }),\n\n status: defineCommand({\n meta: { name: \"status\", description: \"Show the warm base of this repository.\" },\n args: { ...commonArgs, ...nameArg },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const name = baseName(str(args.name) ?? \"\");\n const base = await findBase(client, name);\n if (!base) {\n out.line(out.p.dim(`No warm base named ${name}.`));\n out.result(\"\", { name, base: null });\n return;\n }\n out.step(name, `${base.id} ${base.status}`);\n out.result(\"\", { name, base: base.id, status: base.status });\n },\n }),\n\n drop: defineCommand({\n meta: { name: \"drop\", description: \"Delete the warm base.\" },\n args: { ...commonArgs, ...nameArg },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const name = baseName(str(args.name) ?? \"\");\n const gone = await drop(client, name, report(out));\n if (!gone) out.line(out.p.dim(`No warm base named ${name}.`));\n out.result(\"\", { name, deleted: gone });\n },\n }),\n },\n});\n\nfunction report(out: Awaited<ReturnType<typeof context>>[\"out\"]) {\n return (event: CiEvent) => {\n out.event({ ...event });\n switch (event.type) {\n case \"base.creating\":\n out.step(\"base\", `building ${event.name}`);\n break;\n case \"base.created\":\n out.step(\"base\", `${event.sandboxId} in ${duration(event.ms)}`);\n break;\n case \"base.setup\":\n out.step(\"setup\", event.command.length > 70 ? `${event.command.slice(0, 70)}…` : event.command);\n break;\n case \"base.paused\":\n out.step(\"paused\", duration(event.ms));\n break;\n case \"base.found\":\n out.step(\"base\", `${event.sandboxId} ${event.status}`);\n break;\n case \"fork.created\":\n out.step(\"fork\", `${event.sandboxId} in ${duration(event.ms)}`);\n break;\n case \"job.finished\":\n out.step(\"job\", `exit ${event.exitCode} in ${duration(event.ms)}`);\n break;\n case \"base.deleted\":\n out.step(\"deleted\", event.sandboxId);\n break;\n default:\n break;\n }\n };\n}\n","/** `munito login`, `logout` and `whoami`. */\n\nimport { defineCommand } from \"citty\";\n\nimport { Client } from \"../../api/client.ts\";\nimport * as keys from \"../../core/keys.ts\";\nimport { channel, commonArgs, context } from \"../context.ts\";\nimport { cube } from \"../theme.ts\";\n\nconst CONSOLE_KEYS = \"https://console.munito.ai/keys\";\n\nexport const login = defineCommand({\n meta: { name: \"login\", description: \"Save an API key for this machine.\" },\n args: {\n ...commonArgs,\n key: { type: \"string\", description: \"The key, when you cannot paste it at a prompt.\" },\n },\n async run({ args }) {\n const out = channel(args);\n const host = keys.resolveHost(args.host ?? args.region);\n\n let key = (args.key as string | undefined)?.trim();\n if (!key) {\n if (!process.stdin.isTTY) throw new Error(`No terminal to ask in. Pass --key, or set ${keys.ENV_KEY}.`);\n const clack = await import(\"@clack/prompts\");\n if (out.mode === \"rich\") {\n out.line();\n out.line(cube(out.p));\n }\n clack.intro(out.p.bold(\"Sign in to Munito AI\"));\n clack.note(`Create a key with the Inference permission at\\n${CONSOLE_KEYS}`, \"API key\");\n const answer = await clack.password({\n message: \"Paste your API key\",\n validate: (value) => ((value ?? \"\").trim().length < 8 ? \"That is too short for a key.\" : undefined),\n });\n if (clack.isCancel(answer)) {\n clack.cancel(\"Nothing saved.\");\n process.exitCode = 1;\n return;\n }\n key = String(answer).trim();\n }\n\n // Check the key before it is written, so a typo fails here and not in the next command.\n const probe = new Client({ apiKey: key, baseUrl: host, attempts: 1 });\n await probe.listSandboxes();\n\n const path = await keys.save(key, host);\n out.step(\"saved\", `${keys.mask(key)} for ${host}`);\n out.line(out.p.dim(` ${path}, readable by you only`));\n out.result(\"\", { saved: true, host });\n },\n});\n\nexport const logout = defineCommand({\n meta: { name: \"logout\", description: \"Remove the saved API key.\" },\n args: commonArgs,\n async run({ args }) {\n await keys.clear();\n channel(args).step(\"removed\", keys.authPath());\n },\n});\n\nexport const whoami = defineCommand({\n meta: { name: \"whoami\", description: \"Show which key and host this machine uses.\" },\n args: commonArgs,\n async run({ args }) {\n const ctx = await context(args);\n const sandboxes = await ctx.client.listSandboxes();\n const running = sandboxes.filter((box) => box.status === \"running\").length;\n ctx.out.step(\"host\", ctx.host);\n ctx.out.step(\"key\", `${ctx.source}`);\n ctx.out.step(\"sandboxes\", `${running} running, ${sandboxes.length} known`);\n ctx.out.result(\"\", { host: ctx.host, source: ctx.source, running, total: sandboxes.length });\n },\n});\n","/** `munito herdr add` — give herdr a Munito sandbox to run a coding agent on.\n\nherdr holds no compute: you bring machines and it reaches them over SSH. Our SSH is a plain byte pipe, so herdr's own\n`--install` copies its Linux build in with no helper, where Vercel Sandbox needs one. This command is the whole of\nthat recipe: make a persistent sandbox, mint a key for it, and hand herdr the connection.\n*/\n\nimport { spawn, spawnSync } from \"node:child_process\";\n\nimport { defineCommand } from \"citty\";\n\nimport { AGENT_TEMPLATE } from \"../../core/agents.ts\";\nimport { commonArgs, context } from \"../context.ts\";\n\nexport const herdr = defineCommand({\n meta: {\n name: \"herdr\",\n description: \"Run coding agents on Munito sandboxes from herdr.\",\n },\n subCommands: {\n add: defineCommand({\n meta: { name: \"add\", description: \"Create a sandbox and add it to herdr as a machine.\" },\n args: {\n ...commonArgs,\n name: { type: \"string\", description: \"The machine name in herdr. The default is the sandbox id.\" },\n template: { type: \"string\", description: \"A template. The default is the agent one.\" },\n size: { type: \"string\", description: \"tiny, small, default or large.\", default: \"default\" },\n timeout: { type: \"string\", description: \"Seconds the sandbox may live before it pauses.\" },\n print: { type: \"boolean\", description: \"Print the herdr command instead of running it.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as never);\n\n // Persistent, so a pause keeps the agent's terminal and conversation, and a resume brings them back.\n const box = await client.createSandbox({\n template: (args.template as string) || AGENT_TEMPLATE,\n size: (args.size as string) || \"default\",\n internet: true,\n persistent: true,\n timeout: args.timeout ? Number(args.timeout) : 86_400,\n metadata: { \"munito.cli\": \"herdr\" },\n });\n out.step(\"sandbox\", `${box.id}, persistent`);\n\n // The credential rides in the SSH user and expires, so a long-lived machine is told to mint a new one.\n const access = await client.createSshAccess(box.id);\n const via = `ssh -o StrictHostKeyChecking=accept-new ${access.user}@${access.host}`;\n const name = (args.name as string) || box.id;\n out.step(\"ssh\", `${access.host}, minted`);\n\n const present = spawnSync(\"hc\", [\"--version\"], { stdio: \"ignore\" });\n if (args.print || present.status !== 0) {\n if (present.status !== 0) out.warn(\"herdr-core (`hc`) is not on PATH. Run this where it is:\");\n out.line(`hc machine add --name ${name} --install --via '${via}'`);\n out.result(\"\", { sandbox_id: box.id, machine: name, via });\n return;\n }\n\n out.step(\"herdr\", `adding ${name}`);\n const child = spawn(\"hc\", [\"machine\", \"add\", \"--name\", name, \"--install\", \"--via\", via], { stdio: \"inherit\" });\n const code = await new Promise<number>((done) => child.on(\"close\", (c) => done(c ?? 0)));\n if (code !== 0) {\n out.error(`hc machine add exited ${code}. The sandbox is ${box.id}.`);\n process.exitCode = code;\n return;\n }\n out.line();\n out.step(\"ready\", name);\n out.line(out.p.dim(` hc run --bg --on ${name} --cwd /workspace --name agent claude`));\n out.line(out.p.dim(` munito pause ${box.id} # keeps the terminal and the conversation`));\n out.line(out.p.dim(` the SSH credential expires; run \\`munito herdr add\\` again for a new machine`));\n out.result(\"\", { sandbox_id: box.id, machine: name });\n },\n }),\n },\n});\n","/** `munito init <agent>` — configure a harness on this machine, from the same table the sandbox uses. */\n\nimport { execFile } from \"node:child_process\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { dirname } from \"node:path\";\nimport { promisify } from \"node:util\";\n\nimport { defineCommand } from \"citty\";\n\nimport {\n AGENTS,\n CLAUDE_MODEL,\n DEFAULT_MODEL,\n DEFAULT_SMALL_MODEL,\n PACKAGES,\n PLUGINS,\n PROVIDERS,\n opencodeMajor,\n wire,\n type AgentName,\n type AuthMode,\n type ProviderName,\n} from \"../../core/providers.ts\";\nimport { commonArgs, context } from \"../context.ts\";\n\n/** The major version of the OpenCode on this machine, or null when it has none. */\nasync function installedOpencode(): Promise<number | null> {\n try {\n const { stdout } = await promisify(execFile)(\"opencode\", [\"--version\"], { timeout: 10_000 });\n return opencodeMajor(stdout);\n } catch {\n return null;\n }\n}\n\nexport const init = defineCommand({\n meta: {\n name: \"init\",\n description: \"Point a coding agent on this machine at Munito AI.\",\n },\n args: {\n ...commonArgs,\n agent: { type: \"positional\", required: true, description: `Which harness: ${AGENTS.join(\", \")}.` },\n provider: {\n type: \"string\",\n description: `Where the model comes from: ${PROVIDERS.join(\", \")}.`,\n default: \"munito\",\n },\n auth: { type: \"string\", description: \"token or subscription.\", default: \"token\" },\n model: { type: \"string\", description: \"A model id, in place of the recommended one.\" },\n \"dry-run\": { type: \"boolean\", description: \"Show what would be written, and write nothing.\" },\n },\n async run({ args }) {\n const name = args.agent as AgentName;\n if (!AGENTS.includes(name)) throw new Error(`Unknown agent ${name}. One of: ${AGENTS.join(\", \")}`);\n\n const { client, out, host } = await context(args);\n const home = homedir();\n\n const guide = `https://docs.munito.ai/reference/agents/${name}`;\n const plugin = PLUGINS[name];\n if (plugin) {\n // The harness installs a plugin we publish, so there is no file for this tool to write.\n out.step(name, \"installs a Munito AI provider plugin\");\n out.line(`\\n ${out.p.primary(plugin)}\\n`);\n out.line(out.p.dim(` Then enter your key. See ${guide}`));\n out.result(\"\", { agent: name, plugin, guide });\n return;\n }\n\n // OpenCode 1 drops the provider of the file with no error, and then uses the global host.\n if (name === \"opencode\" && ((await installedOpencode()) ?? 2) < 2) {\n throw new Error(\n \"munito init needs OpenCode 2, and this machine has OpenCode 1. See https://opencode.ai/docs/#cli\",\n );\n }\n\n const wiring = wire(\n name,\n args.provider as ProviderName,\n args.auth as AuthMode,\n {\n host,\n token: client.token,\n model: args.model ?? (name === \"claude\" ? CLAUDE_MODEL : DEFAULT_MODEL),\n smallModel: DEFAULT_SMALL_MODEL,\n },\n process.cwd(),\n home,\n );\n\n for (const file of wiring.files) {\n if (args[\"dry-run\"]) {\n out.step(\"would write\", file.path);\n continue;\n }\n await mkdir(dirname(file.path), { recursive: true });\n await writeFile(file.path, file.content, { mode: 0o600 });\n out.step(\"wrote\", file.path);\n }\n\n // A key never goes into a config file, so the shell has to carry it.\n const exports = Object.entries(wiring.env).filter(([, value]) => value);\n if (exports.length) {\n out.line();\n out.line(out.p.dim(\" Add these to your shell:\"));\n for (const [key, value] of exports) {\n const shown =\n key.toLowerCase().includes(\"token\") || key.toLowerCase().includes(\"key\") ? \"$MUNITO_API_KEY\" : value;\n out.line(` export ${key}=${shown}`);\n }\n }\n if (name === \"opencode\" && exports.length) {\n // The background server of OpenCode reads the variable when it starts, not when a command runs.\n out.line(out.p.dim(\" Then restart the server of OpenCode: opencode service restart\"));\n }\n if (wiring.unset.length && !args[\"dry-run\"]) {\n out.line();\n out.line(out.p.dim(` Clear these if your shell sets them: ${wiring.unset.join(\", \")}`));\n }\n out.line();\n if (!PACKAGES[name]) {\n // We write its configuration, but we do not install the harness itself.\n out.line(out.p.dim(` Install ${name} itself first. See ${guide}`));\n out.line();\n }\n out.step(\"ready\", `run ${out.p.primary(name)}`);\n out.result(\"\", { agent: name, files: wiring.files.map((file) => file.path) });\n },\n});\n","/** `munito mcp` — the same commands as MCP tools, so a Claude or Codex session farms work out to our sandboxes.\n\nOne line adds it: `claude mcp add munito -- npx @munitoai/cli mcp`. The tools call `core/`, exactly as the commands do, so\nthere is no second implementation of anything.\n*/\n\nimport { defineCommand } from \"citty\";\n\nimport { runAgent } from \"../../core/agents.ts\";\nimport { AGENTS, PROVIDERS, type AgentName, type AuthMode, type ProviderName } from \"../../core/providers.ts\";\nimport { commonArgs, context, type CommonArgs } from \"../context.ts\";\n\n/** A tool answer, in the shape MCP expects. */\nfunction text(body: unknown): { content: { type: \"text\"; text: string }[]; isError?: boolean } {\n return { content: [{ type: \"text\", text: typeof body === \"string\" ? body : JSON.stringify(body, null, 2) }] };\n}\n\nfunction failed(message: string) {\n return { ...text(message), isError: true };\n}\n\ninterface RunAgentArgs {\n prompt: string;\n agent: AgentName;\n provider: ProviderName;\n model?: string;\n files?: { path: string; content: string }[];\n max_turns?: number;\n}\n\ninterface RunCommandArgs {\n command: string;\n template: string;\n internet: boolean;\n timeout: number;\n}\n\nexport const mcp = defineCommand({\n meta: {\n name: \"mcp\",\n description: \"Serve the Munito AI tools over MCP on stdio, for a coding agent to call.\",\n },\n args: commonArgs,\n async run({ args }) {\n // stdout is the protocol, so nothing else may write to it.\n const ctx = await context({ ...(args as CommonArgs), json: true });\n const { client } = ctx;\n\n const { McpServer } = await import(\"@modelcontextprotocol/sdk/server/mcp.js\");\n const { StdioServerTransport } = await import(\"@modelcontextprotocol/sdk/server/stdio.js\");\n const { z } = await import(\"zod\");\n\n const server = new McpServer({ name: \"munito\", version: \"0.1.0\" });\n // The SDK's generic inference over a zod shape blows the instantiation depth, so the shapes are registered\n // through a loose handle and each handler declares its own argument type.\n const register = server.registerTool.bind(server) as unknown as (\n name: string,\n config: Record<string, unknown>,\n handler: (args: never) => Promise<{ content: { type: \"text\"; text: string }[]; isError?: boolean }>,\n ) => void;\n\n register(\n \"run_agent\",\n {\n title: \"Run a coding agent in a sandbox\",\n description:\n \"Run a coding agent on a fresh Linux microVM and return its answer and a patch of what it changed. \" +\n \"The sandbox is deleted afterwards. Use this to do work in isolation, or to run several agents at once.\",\n inputSchema: {\n prompt: z.string().describe(\"What the agent should do.\"),\n agent: z.enum(AGENTS).default(\"claude\").describe(\"Which harness runs the task.\"),\n provider: z.enum(PROVIDERS).default(\"munito\").describe(\"Where the model comes from.\"),\n model: z.string().optional().describe(\"A model id, in place of the recommended one.\"),\n files: z\n .array(z.object({ path: z.string(), content: z.string() }))\n .optional()\n .describe(\"Files to put in /workspace before the agent starts.\"),\n max_turns: z.number().int().positive().optional(),\n },\n },\n (async ({ prompt, agent, provider, model, files, max_turns }: RunAgentArgs) => {\n try {\n const run = await runAgent(client, {\n agent: agent as AgentName,\n prompt,\n provider: provider as ProviderName,\n auth: \"token\" as AuthMode,\n model,\n files,\n maxTurns: max_turns,\n });\n return text({\n result: run.result,\n exit_code: run.exitCode,\n patch: run.patch || null,\n sandbox_id: run.sandboxId,\n duration_ms: run.durationMs,\n });\n } catch (error) {\n return failed(`The agent did not run: ${(error as Error).message}`);\n }\n }) as never,\n );\n\n register(\n \"run_command\",\n {\n title: \"Run a command in a sandbox\",\n description:\n \"Run one shell command on a fresh Linux microVM and return its output. The sandbox is deleted \" +\n \"afterwards. Use this for code you do not trust, or for a build that must start clean.\",\n inputSchema: {\n command: z.string().describe(\"The command, which runs in bash.\"),\n template: z\n .string()\n .default(\"base\")\n .describe(\"base, ubuntu, agent, desktop, or the name of a custom template.\"),\n internet: z.boolean().default(false).describe(\"Allow outbound connections.\"),\n timeout: z.number().int().positive().default(120).describe(\"Seconds the command may take.\"),\n },\n },\n (async ({ command, template, internet, timeout }: RunCommandArgs) => {\n let id = \"\";\n try {\n const box = await client.createSandbox({\n template,\n size: \"small\",\n internet,\n timeout: Math.max(timeout + 60, 120),\n metadata: { \"munito.cli\": \"mcp\" },\n });\n id = box.id;\n const out = await client.exec(id, { command, timeout });\n return text({ exit_code: out.exit_code, stdout: out.stdout, stderr: out.stderr });\n } catch (error) {\n return failed(`The command did not run: ${(error as Error).message}`);\n } finally {\n if (id) await client.deleteSandbox(id).catch(() => {});\n }\n }) as never,\n );\n\n register(\n \"list_agents\",\n {\n title: \"List the coding agents and providers\",\n description: \"Which harnesses run in a sandbox, and where their model can come from.\",\n inputSchema: {},\n },\n (async () => text({ agents: AGENTS, providers: PROVIDERS, host: ctx.host })) as never,\n );\n\n await server.connect(new StdioServerTransport());\n // The transport owns the process now: it ends when the client closes stdin.\n await new Promise<void>(() => {});\n },\n});\n","/** `munito proxies`: fixed public addresses for sandboxes. Create, list, read and delete proxies, and open ports. */\n\nimport { defineCommand } from \"citty\";\n\nimport type { Proxy } from \"../../api/types.ts\";\nimport { endpoints, findProxy } from \"../../core/proxies.ts\";\nimport { commonArgs, context, type CommonArgs } from \"../context.ts\";\nimport { table, type Out } from \"../output.ts\";\n\nconst proxyArg = {\n proxy: { type: \"positional\" as const, required: true, description: \"The name or the id of the proxy.\" },\n};\n\nconst create = defineCommand({\n meta: { name: \"create\", description: \"Create a proxy: fixed public addresses for your sandboxes.\" },\n args: {\n ...commonArgs,\n name: { type: \"positional\", required: true, description: \"The name: lower case letters, digits and hyphens.\" },\n dedicated: { type: \"boolean\", description: \"IPv4 addresses that no other customer uses, at a price.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const proxy = await client.createProxy({ name: String(args.name), ipv4: args.dedicated ? \"dedicated\" : \"shared\" });\n show(out, proxy);\n out.line(out.p.dim(` munito create --proxy ${proxy.name}`));\n },\n});\n\nconst ls = defineCommand({\n meta: { name: \"ls\", description: \"List the proxies of your workspace.\" },\n args: commonArgs,\n async run({ args }) {\n const { client, out } = await context(args);\n const proxies = await client.listProxies();\n for (const proxy of proxies) out.event({ type: \"proxy\", ...proxy });\n if (out.mode === \"json\") return;\n if (!proxies.length) {\n out.line(out.p.dim(\"No proxies. Create one with `munito proxies create <name>`.\"));\n return;\n }\n const rows = [\n [\"NAME\", \"IPV4\", \"ADDRESSES\", \"IPV6 BLOCK\", \"OPEN PORTS\"],\n ...proxies.map((proxy) => [\n proxy.name,\n proxy.ipv4.mode,\n proxy.ipv4.addresses.join(\" \") || \"-\",\n proxy.ipv6 ?? \"-\",\n String(proxy.ports.length),\n ]),\n ];\n out.line(table(rows, out.p));\n },\n});\n\nconst get = defineCommand({\n meta: { name: \"get\", description: \"Show a proxy, its addresses and its open ports.\" },\n args: { ...commonArgs, ...proxyArg },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n show(out, await findProxy(client, String(args.proxy)));\n },\n});\n\nconst rm = defineCommand({\n meta: { name: \"rm\", description: \"Delete proxies that no running or paused sandbox uses.\" },\n args: { ...commonArgs, proxies: { type: \"positional\", required: true, description: \"One or more proxies.\" } },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const refs = args._.length ? args._ : [String(args.proxies)];\n for (const ref of refs) {\n const proxy = await findProxy(client, ref);\n await client.deleteProxy(proxy.id);\n out.event({ type: \"proxy.deleted\", id: proxy.id, name: proxy.name });\n out.step(\"deleted\", proxy.name);\n }\n },\n});\n\nconst open = defineCommand({\n meta: { name: \"open\", description: \"Let the internet reach one port of a sandbox of the proxy.\" },\n args: {\n ...commonArgs,\n ...proxyArg,\n sandbox: { type: \"positional\", required: true, description: \"The sandbox id.\" },\n port: { type: \"positional\", required: true, description: \"The port that a server in the sandbox listens on.\" },\n udp: { type: \"boolean\", description: \"A UDP port. The default is TCP.\" },\n \"public-port\": { type: \"string\", description: \"The port outside, for a dedicated proxy. The default is the port.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const proxy = await findProxy(client, String(args.proxy));\n const sandbox = String(args.sandbox);\n const opened = await client.openProxyPort(proxy.id, {\n sandbox_id: sandbox,\n port: Number(args.port),\n protocol: args.udp ? \"udp\" : \"tcp\",\n public_port: args[\"public-port\"] ? Number(args[\"public-port\"]) : undefined,\n });\n // The IPv6 address is the sandbox's own, so one read of the sandbox gives it.\n const ipv6 = (await client.getSandbox(sandbox).catch(() => undefined))?.proxy?.ipv6;\n const reach = endpoints(proxy, opened, ipv6);\n out.event({ type: \"proxy.port\", ...opened, endpoints: reach });\n out.step(\"open\", `${opened.protocol} ${opened.port} of ${sandbox}`);\n for (const endpoint of reach) out.line(` ${endpoint}`);\n out.result(\"\", { port: opened.id, endpoints: reach });\n },\n});\n\nconst close = defineCommand({\n meta: { name: \"close\", description: \"Close an open port of a proxy.\" },\n args: {\n ...commonArgs,\n ...proxyArg,\n port: { type: \"positional\", required: true, description: \"The id of the open port, from `munito proxies get`.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const proxy = await findProxy(client, String(args.proxy));\n await client.closeProxyPort(proxy.id, String(args.port));\n out.event({ type: \"proxy.port.closed\", id: String(args.port) });\n out.step(\"closed\", String(args.port));\n },\n});\n\n/** The proxy, its addresses, and each open port with the place where the internet reaches it. */\nfunction show(out: Out, proxy: Proxy): void {\n out.event({ type: \"proxy\", ...proxy });\n out.result(\"\", { proxy: proxy.name, id: proxy.id, ipv4: proxy.ipv4.addresses, ipv6: proxy.ipv6 ?? null });\n if (out.mode === \"json\") return;\n out.step(proxy.name, proxy.ipv4.mode);\n const facts = [\n [\"id\", proxy.id],\n [\"ipv4\", proxy.ipv4.addresses.join(\" \") || \"-\"],\n [\"ipv6\", proxy.ipv6 ?? \"-\"],\n ];\n const lines = table(facts, out.p, false).split(\"\\n\");\n for (const line of lines) out.line(` ${line}`);\n if (!proxy.ports.length) return;\n const rows = [\n [\"PORT ID\", \"SANDBOX\", \"PROTOCOL\", \"PORT\", \"PUBLIC PORT\"],\n ...proxy.ports.map((port) => [\n port.id,\n port.sandbox_id,\n port.protocol,\n String(port.port),\n String(port.public_port),\n ]),\n ];\n for (const line of table(rows, out.p).split(\"\\n\")) out.line(` ${line}`);\n}\n\nexport const proxies = defineCommand({\n meta: { name: \"proxies\", description: \"Give sandboxes fixed public addresses. A preview.\" },\n subCommands: { create, ls, get, rm, open, close },\n});\n","/** The machines: `ls`, `run`, `exec`, `ssh`, `open`, `rm`, `pause`, `resume`. */\n\nimport { spawn } from \"node:child_process\";\n\nimport { defineCommand } from \"citty\";\n\nimport type { CommandEvent, Sandbox } from \"../../api/types.ts\";\nimport { AGENT_TEMPLATE, createAgentSandbox } from \"../../core/agents.ts\";\nimport { AGENTS, PROVIDERS, type AgentName, type AuthMode, type ProviderName } from \"../../core/providers.ts\";\nimport { findProxy } from \"../../core/proxies.ts\";\nimport { forwardSpec, sshArgv } from \"../../core/ssh.ts\";\nimport { commonArgs, context } from \"../context.ts\";\nimport { DESKTOP_PORT, openInBrowser } from \"../desktop.ts\";\nimport { duration, table } from \"../output.ts\";\n\nexport const ls = defineCommand({\n meta: { name: \"ls\", description: \"List your sandboxes.\" },\n args: { ...commonArgs, all: { type: \"boolean\", alias: \"a\", description: \"Stopped ones too.\" } },\n async run({ args }) {\n const { client, out } = await context(args);\n const boxes = await client.listSandboxes();\n const shown = args.all ? boxes : boxes.filter((box) => box.status !== \"stopped\");\n for (const box of shown) out.event({ type: \"sandbox\", ...box });\n if (out.mode === \"json\") return;\n if (!shown.length) {\n out.line(out.p.dim('No sandboxes. Start one with `munito agent \"...\"`.'));\n return;\n }\n const rows = [[\"ID\", \"STATUS\", \"TEMPLATE\", \"SIZE\", \"AGE\"], ...shown.map(row)];\n out.line(table(rows, out.p));\n },\n});\n\nconst PROXY_FLAG = \"The name or the id of a proxy: the sandbox gets its fixed public addresses. A preview.\";\n\nfunction row(box: Sandbox): string[] {\n const age = box.created_at ? duration(Date.now() - box.created_at * 1000) : \"\";\n return [box.id, box.status, box.template, `${box.vcpus}c ${Math.round(box.memory_mib / 1024)}g`, age];\n}\n\nexport const run = defineCommand({\n meta: { name: \"run\", description: \"Run one command in a throwaway sandbox.\" },\n args: {\n ...commonArgs,\n command: { type: \"positional\", required: true, description: \"The command to run.\" },\n template: {\n type: \"string\",\n description: \"base, ubuntu, agent, desktop, or the name of a custom template. The default is base.\",\n default: \"base\",\n },\n size: { type: \"string\", description: \"tiny, small, default or large.\", default: \"small\" },\n internet: { type: \"boolean\", description: \"Allow outbound connections.\" },\n proxy: { type: \"string\", description: PROXY_FLAG },\n timeout: { type: \"string\", description: \"Seconds the command may take.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n const proxy = args.proxy ? (await findProxy(client, args.proxy)).id : undefined;\n const box = await client.createSandbox({\n template: args.template,\n size: args.size,\n internet: Boolean(args.internet),\n timeout: 600,\n metadata: { \"munito.cli\": \"run\" },\n proxy,\n });\n try {\n const exit = await stream(client, box.id, args.command as string, out, args.timeout);\n if (exit !== 0) process.exitCode = exit;\n } finally {\n await client.deleteSandbox(box.id).catch(() => {});\n }\n },\n});\n\nexport const exec = defineCommand({\n meta: { name: \"exec\", description: \"Run a command in a sandbox you already have.\" },\n args: {\n ...commonArgs,\n id: { type: \"positional\", required: true, description: \"The sandbox id.\" },\n command: { type: \"positional\", required: true, description: \"The command to run.\" },\n cwd: { type: \"string\", description: \"The working directory.\" },\n timeout: { type: \"string\", description: \"Seconds the command may take.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n const exit = await stream(client, args.id as string, args.command as string, out, args.timeout, args.cwd);\n if (exit !== 0) process.exitCode = exit;\n },\n});\n\nasync function stream(\n client: Awaited<ReturnType<typeof context>>[\"client\"],\n id: string,\n command: string,\n out: Awaited<ReturnType<typeof context>>[\"out\"],\n timeout?: string,\n cwd?: string,\n): Promise<number> {\n let exit = 0;\n const events = client.execStream(id, {\n command,\n cwd,\n timeout: timeout ? Number(timeout) : undefined,\n });\n for await (const event of events as AsyncGenerator<CommandEvent>) {\n if (event.type === \"stdout\") out.raw(event.data);\n else if (event.type === \"stderr\") out.raw(event.data, \"stderr\");\n else exit = event.exit_code;\n out.event({ ...event });\n }\n return exit;\n}\n\nexport const rm = defineCommand({\n meta: { name: \"rm\", description: \"Delete sandboxes.\" },\n args: { ...commonArgs, ids: { type: \"positional\", required: true, description: \"One or more sandbox ids.\" } },\n async run({ args, rawArgs }) {\n const { client, out } = await context(args);\n const ids = rawArgs.filter((value) => value.startsWith(\"sbx_\"));\n for (const id of ids.length ? ids : [args.ids as string]) {\n await client.deleteSandbox(id);\n out.step(\"deleted\", id);\n }\n },\n});\n\nexport const pause = defineCommand({\n meta: { name: \"pause\", description: \"Pause a persistent sandbox.\" },\n args: { ...commonArgs, id: { type: \"positional\", required: true, description: \"The sandbox id.\" } },\n async run({ args }) {\n const { client, out } = await context(args);\n const box = await client.pauseSandbox(args.id as string);\n out.step(\"paused\", box.id);\n },\n});\n\nexport const resume = defineCommand({\n meta: { name: \"resume\", description: \"Resume a paused sandbox.\" },\n args: { ...commonArgs, id: { type: \"positional\", required: true, description: \"The sandbox id.\" } },\n async run({ args }) {\n const { client, out } = await context(args);\n const box = await client.resumeSandbox(args.id as string);\n out.step(\"resumed\", box.id);\n },\n});\n\nexport const fork = defineCommand({\n meta: { name: \"fork\", description: \"Start new sandboxes from a persistent one, as it is now.\" },\n args: {\n ...commonArgs,\n id: { type: \"positional\", required: true, description: \"The sandbox to fork.\" },\n count: { type: \"string\", description: \"How many. The default is 1.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n const count = args.count ? Number(args.count) : 1;\n const started = Date.now();\n const answer = await client.forkSandbox(args.id as string, count);\n const forks = Array.isArray(answer) ? answer : (answer.data ?? []);\n out.step(\"forked\", `${forks.length} in ${duration(Date.now() - started)}`);\n for (const box of forks) out.line(out.p.dim(` ${box.id}`));\n out.result(\"\", { forks: forks.map((box) => box.id) });\n },\n});\n\nexport const ssh = defineCommand({\n meta: { name: \"ssh\", description: \"Open a shell in a sandbox.\" },\n args: {\n ...commonArgs,\n id: { type: \"positional\", required: true, description: \"The sandbox id.\" },\n forward: {\n type: \"string\",\n alias: \"L\",\n description: \"Forward a port: 3080, 3081:3080, or 3081:127.0.0.1:3080. Repeatable.\",\n },\n print: { type: \"boolean\", description: \"Print the command instead of connecting.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n // Checked before the request, so a typo costs no credential.\n const forwards = [args.forward ?? []].flat().filter(Boolean) as string[];\n const flags = forwards.flatMap((spec) => [\"-L\", forwardSpec(spec)]);\n // The credential rides in the SSH user and expires, so each call mints a fresh one. There is no key file.\n const access = await client.createSshAccess(args.id as string);\n if (args.print || !process.stdin.isTTY) {\n out.line(flags.length ? access.command.replace(/^ssh /, `ssh ${flags.join(\" \")} `) : access.command);\n return;\n }\n for (const spec of forwards) out.step(\"forwarding\", forwardSpec(spec));\n out.step(\"connecting\", access.host);\n const child = spawn(\"ssh\", sshArgv(access.user, access.host, forwards), {\n stdio: \"inherit\",\n });\n await new Promise<void>((done) =>\n child.on(\"close\", (code) => {\n process.exitCode = code ?? 0;\n done();\n }),\n );\n },\n});\n\nexport const open = defineCommand({\n meta: { name: \"open\", description: \"Open a sandbox port, or its desktop, in your browser.\" },\n args: {\n ...commonArgs,\n id: { type: \"positional\", required: true, description: \"The sandbox id.\" },\n port: { type: \"string\", description: `The port. The default is the desktop, ${DESKTOP_PORT}.` },\n expires: { type: \"string\", description: \"Seconds the link stays valid. The default is 3600.\" },\n print: { type: \"boolean\", description: \"Print the URL instead of opening it.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n const port = args.port ? Number(args.port) : DESKTOP_PORT;\n const signed = await client.signPortUrl(args.id as string, port, args.expires ? Number(args.expires) : 3600);\n out.event({ type: \"url\", url: signed.url, port });\n if (args.print || out.mode === \"json\" || !process.stdout.isTTY) {\n out.line(signed.url);\n return;\n }\n out.step(\"opening\", `port ${port}`);\n out.line(out.p.dim(` ${signed.url}`));\n openInBrowser(signed.url);\n },\n});\n\nexport const create = defineCommand({\n meta: { name: \"create\", description: \"Create a sandbox and leave it running.\" },\n args: {\n ...commonArgs,\n template: {\n type: \"string\",\n description: \"base, ubuntu, agent, desktop, or the name of a custom template.\",\n default: AGENT_TEMPLATE,\n },\n agent: { type: \"string\", description: `Point one harness at a provider: ${AGENTS.join(\", \")}.` },\n provider: { type: \"string\", description: `Where the model comes from: ${PROVIDERS.join(\", \")}.` },\n auth: { type: \"string\", description: \"token or subscription.\" },\n model: { type: \"string\", description: \"A model id, in place of the recommended one.\" },\n size: { type: \"string\", description: \"tiny, small, default or large.\", default: \"default\" },\n internet: { type: \"boolean\", description: \"Allow outbound connections.\", default: true },\n persistent: { type: \"boolean\", description: \"Keep files and processes across a pause.\" },\n proxy: { type: \"string\", description: PROXY_FLAG },\n timeout: { type: \"string\", description: \"Seconds the sandbox may live.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args);\n if (args.proxy && args.agent) throw new Error(\"A sandbox with --agent takes no --proxy yet.\");\n const proxy = args.proxy ? (await findProxy(client, args.proxy as string)).id : undefined;\n const common = {\n template: args.template as string,\n size: args.size as string,\n internet: Boolean(args.internet),\n persistent: Boolean(args.persistent),\n timeout: args.timeout ? Number(args.timeout) : undefined,\n };\n const box = args.agent\n ? await createAgentSandbox(client, {\n ...common,\n agent: args.agent as AgentName,\n provider: args.provider as ProviderName | undefined,\n auth: args.auth as AuthMode | undefined,\n model: args.model as string | undefined,\n metadata: { \"munito.cli\": \"create\", \"munito.agent\": args.agent as string },\n })\n : await client.createSandbox({ ...common, metadata: { \"munito.cli\": \"create\" }, proxy });\n out.step(\"created\", box.id);\n if (box.proxy?.ipv6) out.line(out.p.dim(` ipv6 ${box.proxy.ipv6}`));\n out.line(out.p.dim(` munito ssh ${box.id}`));\n out.result(\"\", { sandbox_id: box.id, ...(box.proxy ? { proxy: box.proxy } : {}) });\n },\n});\n","/** Port forwards for an SSH connection to a sandbox. Pure: it builds argv, and runs nothing. */\n\nconst LOOPBACK = \"127.0.0.1\";\nconst PORT = /^[0-9]{1,5}$/;\n\nexport class ForwardError extends Error {}\n\nfunction port(value: string, spec: string): string {\n if (!PORT.test(value) || Number(value) < 1 || Number(value) > 65535) {\n throw new ForwardError(`\"${spec}\" is not a port forward. Use 3080, 3081:3080, or 3081:127.0.0.1:3080.`);\n }\n return value;\n}\n\n/**\n * One `-L` value from a short spec: `3080`, `3081:3080`, or a full `local:host:remote`.\n * The short forms bind the loopback of the sandbox, where a private server listens.\n */\nexport function forwardSpec(spec: string): string {\n const parts = spec.split(\":\");\n if (parts.length === 1) {\n const only = port(parts[0], spec);\n return `${only}:${LOOPBACK}:${only}`;\n }\n if (parts.length === 2) {\n return `${port(parts[0], spec)}:${LOOPBACK}:${port(parts[1], spec)}`;\n }\n if (parts.length === 3) {\n if (!parts[1]) throw new ForwardError(`\"${spec}\" names no host.`);\n return `${port(parts[0], spec)}:${parts[1]}:${port(parts[2], spec)}`;\n }\n throw new ForwardError(`\"${spec}\" is not a port forward. Use 3080, 3081:3080, or 3081:127.0.0.1:3080.`);\n}\n\n/** The argv of `ssh`, with one `-L` for each forward. */\nexport function sshArgv(user: string, host: string, forwards: readonly string[] = []): string[] {\n const argv = [\"-o\", \"StrictHostKeyChecking=accept-new\"];\n for (const spec of forwards) argv.push(\"-L\", forwardSpec(spec));\n argv.push(`${user}@${host}`);\n return argv;\n}\n","/** `munito templates`: deploy a container image as a sandbox template, list, read and delete templates. */\n\nimport { defineCommand } from \"citty\";\n\nimport type { Client } from \"../../api/client.ts\";\nimport type { Template } from \"../../api/types.ts\";\nimport {\n ENV_REGISTRY_TOKEN,\n TemplateError,\n deployBody,\n registryAuth,\n waitForBuild,\n type TemplateEvent,\n} from \"../../core/templates.ts\";\nimport { commonArgs, context, type CommonArgs } from \"../context.ts\";\nimport { bytes, table, type Out } from \"../output.ts\";\n\n/** citty loses its argument types inside subCommands, so a nested command reads them through this. */\nconst str = (value: unknown): string | undefined => (typeof value === \"string\" && value ? value : undefined);\n\nconst nameArg = {\n name: { type: \"positional\" as const, required: true, description: \"The name or the id of the template.\" },\n};\n\n/** The whole of standard input. A terminal is refused, because a token typed there shows on the screen. */\nasync function readStdin(): Promise<string> {\n if (process.stdin.isTTY) throw new TemplateError(`Pipe the token to --password-stdin, or set ${ENV_REGISTRY_TOKEN}.`);\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) chunks.push(Buffer.from(chunk as Uint8Array));\n return Buffer.concat(chunks).toString(\"utf8\");\n}\n\nconst deploy = defineCommand({\n meta: {\n name: \"deploy\",\n description: \"Build a container image into a template. A name that exists gets a new version.\",\n },\n args: {\n ...commonArgs,\n name: {\n type: \"positional\",\n required: true,\n description: \"The template name: lower case letters, digits and hyphens.\",\n },\n image: { type: \"positional\", required: true, description: \"The image, such as ghcr.io/acme/agent:1.4.\" },\n username: { type: \"string\", description: \"The user name of a private registry.\" },\n \"password-stdin\": {\n type: \"boolean\",\n description: `Read the registry password or token from standard input. Or set ${ENV_REGISTRY_TOKEN}.`,\n },\n wait: { type: \"boolean\", description: \"Wait until the build ends. Exit 1 when it fails.\" },\n },\n async run({ args }) {\n // A token in a flag stays in the shell history and the process list, so there is no such flag.\n if ((args as Record<string, unknown>).password !== undefined) {\n throw new TemplateError(`There is no --password. Use --password-stdin, or set ${ENV_REGISTRY_TOKEN}.`);\n }\n const { auth, ignored } = registryAuth({\n username: str(args.username),\n stdin: args[\"password-stdin\"] ? await readStdin() : undefined,\n env: process.env[ENV_REGISTRY_TOKEN],\n });\n const body = deployBody(String(args.name), String(args.image), auth);\n const { client, out } = await context(args as CommonArgs);\n if (ignored) out.warn(`${ENV_REGISTRY_TOKEN} is set without --username, so the deploy sends no credential.`);\n const template = await client.deployTemplate(body);\n out.event({ type: \"template\", ...template });\n out.step(\"deploying\", `${template.name} v${template.build.version} ${template.build.image}`);\n if (args.wait) {\n await follow(client, out, template.id);\n return;\n }\n out.line(out.p.dim(` munito templates get ${template.name} --wait`));\n out.result(\"\", { template: template.name, id: template.id, version: template.build.version });\n },\n});\n\nconst ls = defineCommand({\n meta: { name: \"ls\", description: \"List the templates of your workspace.\" },\n args: commonArgs,\n async run({ args }) {\n const { client, out } = await context(args);\n const templates = await client.listTemplates();\n for (const template of templates) out.event({ type: \"template\", ...template });\n if (out.mode === \"json\") return;\n if (!templates.length) {\n out.line(out.p.dim(\"No templates. Deploy one with `munito templates deploy <name> <image>`.\"));\n return;\n }\n const rows = [[\"NAME\", \"STATUS\", \"VERSION\", \"IMAGE\", \"SIZE\", \"NEWEST BUILD\"], ...templates.map(row)];\n out.line(table(rows, out.p));\n },\n});\n\nfunction row(template: Template): string[] {\n const serving = template.version ? `v${template.version}` : \"-\";\n const { build } = template;\n return [\n template.name,\n template.status,\n serving,\n template.image ?? \"-\",\n bytes(template.size_bytes),\n `v${build.version} ${build.status}`,\n ];\n}\n\nconst get = defineCommand({\n meta: { name: \"get\", description: \"Show a template and its newest build.\" },\n args: {\n ...commonArgs,\n ...nameArg,\n wait: { type: \"boolean\", description: \"Wait until the newest build ends. Exit 1 when it fails.\" },\n },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n if (args.wait) {\n await follow(client, out, String(args.name));\n return;\n }\n show(out, await client.getTemplate(String(args.name)));\n },\n});\n\nconst rm = defineCommand({\n meta: { name: \"rm\", description: \"Delete templates. Their running sandboxes keep running.\" },\n args: { ...commonArgs, names: { type: \"positional\", required: true, description: \"One or more template names.\" } },\n async run({ args }) {\n const { client, out } = await context(args as CommonArgs);\n const names = args._.length ? args._ : [String(args.names)];\n for (const name of names) {\n await client.deleteTemplate(name);\n out.event({ type: \"template.deleted\", name });\n out.step(\"deleted\", name);\n }\n },\n});\n\n/** Read the template until its newest build ends, then show it. A failed build is a failed command. */\nasync function follow(client: Client, out: Out, ref: string): Promise<void> {\n const template = await waitForBuild(client, ref, {\n onEvent: (event: TemplateEvent) => {\n out.event({ ...event });\n out.step(event.status, `${event.name} v${event.version}`);\n },\n });\n show(out, template);\n if (template.build.status === \"failed\") process.exitCode = 1;\n}\n\n/** The template, the version that new sandboxes start from, and its newest build with the reason of a failure. */\nfunction show(out: Out, template: Template): void {\n out.event({ type: \"template\", ...template });\n const { build } = template;\n out.result(\"\", {\n template: template.name,\n id: template.id,\n status: template.status,\n version: template.version ?? null,\n build: { version: build.version, status: build.status },\n });\n if (out.mode === \"json\") return;\n out.step(template.name, template.status);\n const facts = [\n [\"id\", template.id],\n [\"serving\", template.version ? `v${template.version} ${template.image ?? \"\"}` : \"none yet\"],\n [\"size\", bytes(template.size_bytes)],\n [\"digest\", template.digest ?? \"-\"],\n [\"build\", `v${build.version} ${build.status} ${build.image}`],\n ];\n if (build.error) facts.push([\"error\", build.error.message]);\n out.line(\n table(facts, out.p, false)\n .split(\"\\n\")\n .map((line) => ` ${line}`)\n .join(\"\\n\"),\n );\n if (build.status === \"failed\" && build.log) {\n out.line(out.p.dim(\" the end of the build output:\"));\n for (const line of build.log.replace(/\\n$/, \"\").split(\"\\n\")) out.line(out.p.dim(` ${line}`));\n }\n}\n\nexport const templates = defineCommand({\n meta: { name: \"templates\", description: \"Start sandboxes from your own container image.\" },\n subCommands: { deploy, ls, get, rm },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,YAAY,eAAe;;;ACGpC,SAAS,gBAAgB;AAC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3B,WAAO;AAAA,EACT;AACA,MAAI,iBAAiB,UAAU;AAC7B,IAAAA,SAAQ,MAAM,MAAM,OAAO;AAC3B,QAAI,MAAM,WAAW,IAAK,CAAAA,SAAQ,KAAKA,SAAQ,EAAE,IAAI,kDAAkD,CAAC;AACxG,QAAI,MAAM,WAAW,IAAK,CAAAA,SAAQ,KAAKA,SAAQ,EAAE,IAAI,oCAAoC,eAAe,EAAE,CAAC;AAC3G,QAAI,MAAM,WAAW,IAAK,CAAAA,SAAQ,KAAKA,SAAQ,EAAE,IAAI,qDAAqD,CAAC;AAC3G,QAAI,MAAM,UAAW,CAAAA,SAAQ,KAAKA,SAAQ,EAAE,IAAI,aAAa,MAAM,SAAS,EAAE,CAAC;AAC/E,WAAO,MAAM,WAAW,OAAO,MAAM,WAAW,MAAM,IAAI;AAAA,EAC5D;AACA,EAAAA,SAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AACpE,SAAO;AACT;AAEA,QAAQ,GAAG,sBAAsB,CAAC,WAAW;AAC3C,UAAQ,KAAKD,QAAO,MAAM,CAAC;AAC7B,CAAC;AAID,IAAM,UAAU,QAAQ,KAAK,MAAM,CAAC;AACpC,IAAM,MACJ,QAAQ,KAAK,CAAC,QAAQ,QAAQ,YAAY,QAAQ,IAAI,KACrD,QAAQ,WAAW,MAAM,QAAQ,CAAC,MAAM,eAAe,QAAQ,CAAC,MAAM;AACzE,IAAI,IAAK,OAAM,QAAQ,IAAI;AAAA;AAEzB,QAAM,WAAW,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,OAAO,UAAmB;AAClE,QAAI,iBAAiB,SAAS,MAAM,SAAS,WAAY,OAAM,QAAQ,IAAI;AAC3E,YAAQ,KAAKA,QAAO,KAAK,CAAC;AAAA,EAC5B,CAAC;","names":["bytes","defineCommand","stream","text","stream","text","row","channel","require","out","out","name","run","defineCommand","defineCommand","out","text","stream","defineCommand","defineCommand","out","spawn","defineCommand","defineCommand","out","spawn","execFile","writeFile","promisify","defineCommand","promisify","execFile","defineCommand","out","writeFile","defineCommand","defineCommand","agent","run","out","defineCommand","defineCommand","out","proxies","rm","port","spawn","defineCommand","ls","defineCommand","out","run","rm","rawArgs","spawn","open","port","create","defineCommand","str","nameArg","defineCommand","out","ls","templates","row","get","show","rm","defineCommand","ls","create","run","open","rm","report","channel"]}
|
package/dist/core/providers.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export type AuthMode = "token" | "subscription";
|
|
|
13
13
|
export declare const BAKED: readonly AgentName[];
|
|
14
14
|
/** Each harness's npm package, for the image and for an on-demand install. */
|
|
15
15
|
export declare const PACKAGES: Partial<Record<AgentName, string>>;
|
|
16
|
+
/** The packages whose command comes from their install script. npm wants each one named in `--allow-scripts`. */
|
|
17
|
+
export declare const INSTALL_SCRIPTS: readonly string[];
|
|
18
|
+
/** The major version in the output of `opencode --version`, such as `opencode v2.3.2` or `1.19.5`. */
|
|
19
|
+
export declare function opencodeMajor(output: string): number | null;
|
|
16
20
|
/** The provider plugins we publish. The `agent` template installs the pi and OpenClaw ones; Hermes offers only a
|
|
17
21
|
shell installer from its own domain, which no digest pins, so the image does not carry it. */
|
|
18
22
|
export declare const PLUGINS: Partial<Record<AgentName, string>>;
|