@munitoai/cli 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,82 @@
1
- # Temporary Holding Version
1
+ # munito
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Run a coding agent in a Linux microVM with one command, on European infrastructure.
4
+
5
+ ```bash
6
+ npm install -g @munitoai/cli
7
+ munito login
8
+ munito agent "fix the failing test"
9
+ ```
10
+
11
+ That creates a sandbox, uploads your git worktree, runs the agent, applies the patch back to your working copy and
12
+ deletes the machine. One key pays for the machine and for the tokens, and both stay in the EU.
13
+
14
+ ```bash
15
+ munito agent codex "add a retry to the client" # any of the harnesses
16
+ munito agent claude --provider anthropic # your own Anthropic key
17
+ munito agent claude --auth subscription # your own Claude plan
18
+ munito agent claude --desktop # with a screen you can watch
19
+ ```
20
+
21
+ ## The harnesses
22
+
23
+ The `agent` template carries Claude Code, Codex, OpenCode, DeepSeek Harness, pi and OpenClaw, each pointed at the
24
+ open models of Munito AI. Name one as the first word: `munito agent dsh "…"`.
25
+
26
+ | field | values |
27
+ | ---------- | --------------------------------------------------------------- |
28
+ | `agent` | `claude`, `codex`, `opencode`, `dsh`, `pi`, `openclaw`, `prime` |
29
+ | `provider` | `munito`, `anthropic`, `openai` |
30
+ | `auth` | `token`, `subscription` |
31
+
32
+ On `--provider anthropic` or `openai` the tool clears every Munito AI variable, so your own key reaches your own
33
+ vendor and nothing else. On `--auth subscription` it sets no credential at all: you sign in inside the sandbox,
34
+ and the sign-in stays there.
35
+
36
+ ## The machines
37
+
38
+ ```bash
39
+ munito ls # your sandboxes
40
+ munito create --agent codex # one that stays, with the harness pointed at us
41
+ munito run "pytest -q" # one command in a throwaway sandbox
42
+ munito exec <id> "ls /workspace" # a command in a sandbox you have
43
+ munito ssh <id> # a shell
44
+ munito ssh <id> --forward 3080 # a shell, and a private port on your machine
45
+ munito open <id> # its desktop, in your browser
46
+ munito pause <id> # keep its files and processes
47
+ munito fork <id> --count 8 # eight copies of a paused sandbox
48
+ munito rm <id>
49
+ ```
50
+
51
+ ## As an SDK
52
+
53
+ The package is the library as well as the binary.
54
+
55
+ ```ts
56
+ import { Munito } from "@munitoai/cli";
57
+
58
+ const munito = new Munito({ apiKey: process.env.MUNITO_API_KEY!, region: "eu" });
59
+
60
+ const run = await munito.agent.run({ agent: "claude", prompt: "fix the failing test" });
61
+ console.log(run.result, run.patch);
62
+
63
+ const box = await munito.sandboxes.create({ template: "agent", agent: "codex", internet: true });
64
+ await munito.sandboxes.exec(box.id, { command: "pytest -q", cwd: "/workspace" });
65
+ await munito.sandboxes.delete(box.id);
66
+ ```
67
+
68
+ ## From another coding agent
69
+
70
+ ```bash
71
+ claude mcp add munito -- npx @munitoai/cli mcp
72
+ ```
73
+
74
+ A Claude Code or Codex session then farms a task out to a sandbox instead of running it where it already is.
75
+
76
+ ## Documentation
77
+
78
+ - [The command line tool](https://docs.munito.ai/reference/cli)
79
+ - [Cloud Agents](https://docs.munito.ai/sandboxes/cloud-agents)
80
+ - [Sandboxes](https://docs.munito.ai/sandboxes)
81
+
82
+ Node 22.12 or later. Apache-2.0.
@@ -0,0 +1,57 @@
1
+ /** The HTTP client of the Sandboxes API. No terminal output: every failure is an ApiError. */
2
+ import type { CommandEvent, CommandResult, CreateSandbox, ExecCommand, PortUrl, Sandbox, SshAccess } from "./types.ts";
3
+ export declare const DEFAULT_BASE_URL = "https://api.munito.ai";
4
+ export declare const REGIONS: Record<string, string>;
5
+ export declare class ApiError extends Error {
6
+ readonly status: number;
7
+ readonly code: string;
8
+ readonly requestId: string | undefined;
9
+ constructor(status: number, code: string, message: string, requestId?: string);
10
+ /** Whether another attempt of the same request can succeed. */
11
+ get retryable(): boolean;
12
+ }
13
+ export interface ClientOptions {
14
+ apiKey: string;
15
+ baseUrl?: string;
16
+ /** Attempts for a retryable failure, the first included. */
17
+ attempts?: number;
18
+ fetch?: typeof globalThis.fetch;
19
+ }
20
+ export declare class Client {
21
+ readonly baseUrl: string;
22
+ private readonly apiKey;
23
+ private readonly attempts;
24
+ private readonly doFetch;
25
+ constructor(options: ClientOptions);
26
+ /** What this deployment has refused, so one process does not ask again. Per client: two clients can face two
27
+ * deployments. */
28
+ readonly lacks: {
29
+ wiring: boolean;
30
+ template: boolean;
31
+ };
32
+ /** The caller's own key. The wiring of a harness has to put it in the guest's environment. */
33
+ get token(): string;
34
+ private headers;
35
+ private raw;
36
+ request<T>(method: string, path: string, body?: unknown, signal?: AbortSignal): Promise<T>;
37
+ createSandbox(spec: CreateSandbox, signal?: AbortSignal): Promise<Sandbox>;
38
+ getSandbox(id: string): Promise<Sandbox>;
39
+ listSandboxes(): Promise<Sandbox[]>;
40
+ deleteSandbox(id: string): Promise<void>;
41
+ pauseSandbox(id: string): Promise<Sandbox>;
42
+ resumeSandbox(id: string): Promise<Sandbox>;
43
+ forkSandbox(id: string, count?: number): Promise<{
44
+ data?: Sandbox[];
45
+ } | Sandbox[]>;
46
+ exec(id: string, spec: ExecCommand, signal?: AbortSignal): Promise<CommandResult>;
47
+ /** The same command, as the events arrive. The last event is always `exit`. */
48
+ execStream(id: string, spec: ExecCommand, signal?: AbortSignal): AsyncGenerator<CommandEvent>;
49
+ readFile(id: string, path: string): Promise<string>;
50
+ writeFile(id: string, path: string, content: string): Promise<void>;
51
+ signPortUrl(id: string, port: number, expiresIn?: number): Promise<PortUrl>;
52
+ setPort(id: string, port: number, isPublic: boolean): Promise<unknown>;
53
+ createSshAccess(id: string): Promise<SshAccess>;
54
+ getSsh(id: string): Promise<SshAccess>;
55
+ }
56
+ /** Each complete line of an NDJSON body, parsed. A half line at the end is dropped. */
57
+ export declare function ndjson(body: ReadableStream<Uint8Array>): AsyncGenerator<unknown>;
@@ -0,0 +1,78 @@
1
+ /** The shapes of the Sandboxes API that this package uses. A generated client replaces this file. */
2
+ export type SandboxStatus = "pending" | "running" | "paused" | "stopped";
3
+ export interface Sandbox {
4
+ id: string;
5
+ status: SandboxStatus;
6
+ template: string;
7
+ vcpus: number;
8
+ memory_mib: number;
9
+ disk_gib?: number;
10
+ internet: boolean;
11
+ persistent?: boolean;
12
+ metadata?: Record<string, string>;
13
+ created_at?: number;
14
+ expires_at?: number;
15
+ started_at?: number;
16
+ ended_at?: number;
17
+ end_reason?: string;
18
+ command?: CommandResult;
19
+ }
20
+ export interface CommandResult {
21
+ exit_code: number;
22
+ stdout: string;
23
+ stderr: string;
24
+ duration_ms: number;
25
+ timed_out: boolean;
26
+ truncated: boolean;
27
+ }
28
+ /** One NDJSON line of a streamed command. */
29
+ export type CommandEvent = {
30
+ type: "stdout";
31
+ data: string;
32
+ } | {
33
+ type: "stderr";
34
+ data: string;
35
+ } | {
36
+ type: "exit";
37
+ exit_code: number;
38
+ timed_out?: boolean;
39
+ duration_ms?: number;
40
+ };
41
+ export interface CreateSandbox {
42
+ template?: string;
43
+ size?: string;
44
+ vcpus?: number;
45
+ memory_mib?: number;
46
+ disk_gib?: number;
47
+ internet?: boolean;
48
+ persistent?: boolean;
49
+ timeout?: number;
50
+ env?: Record<string, string>;
51
+ metadata?: Record<string, string>;
52
+ command?: string | string[];
53
+ ssh_keys?: string[];
54
+ /** A coding agent to wire. The API writes the environment that this harness needs. */
55
+ agent?: string;
56
+ provider?: string;
57
+ auth?: string;
58
+ model?: string;
59
+ }
60
+ export interface ExecCommand {
61
+ command: string | string[];
62
+ cwd?: string;
63
+ env?: Record<string, string>;
64
+ timeout?: number;
65
+ stream?: boolean;
66
+ }
67
+ export interface SshAccess {
68
+ command: string;
69
+ host: string;
70
+ /** The credential rides in the user: `sbh_<id>.<issued>.<token>`. There is no key file. */
71
+ user: string;
72
+ host_key?: string;
73
+ expires_at?: number;
74
+ }
75
+ export interface PortUrl {
76
+ url: string;
77
+ expires_at?: number;
78
+ }
@@ -0,0 +1,11 @@
1
+ /** Small string work on URLs and paths, without a regular expression.
2
+
3
+ `replace(/\/+$/, "")` is quadratic on a string of many slashes, and every caller here takes its input from a flag, a
4
+ file or an environment variable. These loops are linear.
5
+ */
6
+ /** `value` with every trailing slash removed. */
7
+ export declare function trimTrailingSlash(value: string): string;
8
+ /** `value` with one leading `./` or `/` removed, so a path joins under a base. */
9
+ export declare function trimLeadingSlash(value: string): string;
10
+ /** `path` under `base`, with one slash between them. */
11
+ export declare function joinPath(base: string, path: string): string;