@folsom/fuse 0.24.0 → 0.26.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/index.d.ts CHANGED
@@ -610,7 +610,12 @@ declare class EnvironmentsService {
610
610
  /** Report whether the environment has a live display and at what geometry.
611
611
  * up is false with a reason on an image with no desktop. */
612
612
  computerDisplay(vmId: string, opts?: CallOptions): Promise<ComputerDisplay>;
613
- /** Gracefully drain an environment; returns the updated environment. */
613
+ /**
614
+ * Phase-1 only: quiesces the guest workload and moves the environment to
615
+ * "draining" so you can inspect its output, but does not destroy it. Call
616
+ * destroy() afterward to remove it - a drained environment left
617
+ * undestroyed keeps running (and billing) forever.
618
+ */
614
619
  drain(vmId: string, opts?: CallOptions): Promise<EnvironmentInfo>;
615
620
  /** Rotate the per-VM credentials and push them to the guest. */
616
621
  rotateToken(vmId: string, opts?: CallOptions): Promise<void>;
@@ -782,7 +787,7 @@ declare class FuseClient {
782
787
  constructor(options: FuseClientOptions);
783
788
  }
784
789
 
785
- declare const VERSION = "0.24.0";
790
+ declare const VERSION = "0.26.0";
786
791
 
787
792
  /** Stable, machine-readable error codes returned by the server. */
788
793
  declare const ErrorCode: {
package/dist/index.js CHANGED
@@ -548,7 +548,12 @@ var EnvironmentsService = class {
548
548
  { signal: opts.signal }
549
549
  );
550
550
  }
551
- /** Gracefully drain an environment; returns the updated environment. */
551
+ /**
552
+ * Phase-1 only: quiesces the guest workload and moves the environment to
553
+ * "draining" so you can inspect its output, but does not destroy it. Call
554
+ * destroy() afterward to remove it - a drained environment left
555
+ * undestroyed keeps running (and billing) forever.
556
+ */
552
557
  async drain(vmId, opts = {}) {
553
558
  requireArg(vmId, "vm id");
554
559
  return this.t.json(
@@ -791,7 +796,7 @@ var ApiKeysService = class {
791
796
  };
792
797
 
793
798
  // src/version.ts
794
- var VERSION = "0.24.0";
799
+ var VERSION = "0.26.0";
795
800
 
796
801
  // src/client.ts
797
802
  var FuseClient = class {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/transport.ts","../src/validate.ts","../src/types.ts","../src/events.ts","../src/environments.ts","../src/snapshots.ts","../src/hosts.ts","../src/apiKeys.ts","../src/version.ts","../src/client.ts"],"names":["REQUEST_ID_HEADER","MAX_PAGE_LIMIT"],"mappings":";AAIA,IAAM,iBAAA,GAAoB,cAAA;AAGnB,IAAM,SAAA,GAAY;AAAA,EACvB,QAAA,EAAU,WAAA;AAAA,EACV,QAAA,EAAU,UAAA;AAAA,EACV,eAAA,EAAiB,kBAAA;AAAA,EACjB,WAAA,EAAa,aAAA;AAAA,EACb,QAAA,EAAU,UAAA;AAAA,EACV,YAAA,EAAc;AAChB;AAIA,IAAM,WAAA,GAAsC;AAAA,EAC1C,GAAA,EAAK,aAAA;AAAA,EACL,GAAA,EAAK,cAAA;AAAA,EACL,GAAA,EAAK,WAAA;AAAA,EACL,GAAA,EAAK,WAAA;AAAA,EACL,GAAA,EAAK,UAAA;AAAA,EACL,GAAA,EAAK,uBAAA;AAAA,EACL,GAAA,EAAK,aAAA;AAAA,EACL,GAAA,EAAK;AACP,CAAA;AAEA,SAAS,WAAW,MAAA,EAAwB;AAC1C,EAAA,OAAO,WAAA,CAAY,MAAM,CAAA,IAAK,CAAA,OAAA,EAAU,MAAM,CAAA,CAAA;AAChD;AAWA,SAAS,cAAc,IAAA,EAAgC;AACrD,EAAA,MAAM,KAAA,GAAkB,CAAC,CAAA,OAAA,EAAU,IAAA,CAAK,MAAM,CAAA,CAAE,CAAA;AAChD,EAAA,IAAI,KAAK,IAAA,EAAM,KAAA,CAAM,KAAK,CAAA,KAAA,EAAQ,IAAA,CAAK,IAAI,CAAA,CAAE,CAAA;AAC7C,EAAA,IAAI,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,IAAA,CAAK,KAAK,OAAO,CAAA;AAAA,OACpC,KAAA,CAAM,IAAA,CAAK,UAAA,CAAW,IAAA,CAAK,MAAM,CAA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,CAAK,YAAA,GAAe,IAAI,mBAAA,CAAoB,SAAS,CAAA;AACrD,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,gBAAA,CAAiB,SAAS,CAAA;AAC/C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,YAAA,CAAa,SAAS,CAAA;AACvC,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,cAAA,CAAe,SAAS,CAAA;AAAA,EAC7C;AACF","file":"index.js","sourcesContent":["// Error types for the Fuse SDK, mirroring sdks/go/errors.go: a structured\n// FuseApiError for non-2xx responses plus code-checking helpers, and a\n// FuseError for transport/configuration failures.\n\nconst REQUEST_ID_HEADER = \"X-Request-ID\";\n\n/** Stable, machine-readable error codes returned by the server. */\nexport const ErrorCode = {\n NotFound: \"not_found\",\n Conflict: \"conflict\",\n InvalidArgument: \"invalid_argument\",\n Unavailable: \"unavailable\",\n Internal: \"internal\",\n Unauthorized: \"unauthorized\",\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nconst STATUS_TEXT: Record<number, string> = {\n 400: \"bad request\",\n 401: \"unauthorized\",\n 403: \"forbidden\",\n 404: \"not found\",\n 409: \"conflict\",\n 500: \"internal server error\",\n 502: \"bad gateway\",\n 503: \"service unavailable\",\n};\n\nfunction statusText(status: number): string {\n return STATUS_TEXT[status] ?? `status ${status}`;\n}\n\nexport interface FuseApiErrorInit {\n status: number;\n code?: string;\n message?: string;\n details?: Record<string, string>;\n requestId?: string;\n body?: string;\n}\n\nfunction formatMessage(init: FuseApiErrorInit): string {\n const parts: string[] = [`status=${init.status}`];\n if (init.code) parts.push(`code=${init.code}`);\n if (init.message) parts.push(init.message);\n else parts.push(statusText(init.status));\n if (init.requestId) parts.push(`request_id=${init.requestId}`);\n return \"fuse api error: \" + parts.join(\", \");\n}\n\n/** FuseApiError is a non-2xx response from the server. */\nexport class FuseApiError extends Error {\n readonly status: number;\n readonly code: string;\n readonly details?: Record<string, string>;\n readonly requestId?: string;\n /** Raw response body, when available. */\n readonly body?: string;\n\n constructor(init: FuseApiErrorInit) {\n super(formatMessage(init));\n this.name = \"FuseApiError\";\n this.status = init.status;\n this.code = init.code ?? \"\";\n this.details = init.details;\n this.requestId = init.requestId;\n this.body = init.body;\n // Restore the prototype chain so `instanceof` works after transpilation.\n Object.setPrototypeOf(this, FuseApiError.prototype);\n }\n}\n\n/** FuseError is a transport, configuration, or decoding failure (not an API error). */\nexport class FuseError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = \"FuseError\";\n Object.setPrototypeOf(this, FuseError.prototype);\n }\n}\n\n/** isFuseApiError is a type guard for FuseApiError. */\nexport function isFuseApiError(err: unknown): err is FuseApiError {\n return err instanceof FuseApiError;\n}\n\nfunction hasCode(err: unknown, code: string): boolean {\n return isFuseApiError(err) && err.code === code;\n}\n\n/** isNotFound reports whether err is a not_found api error. */\nexport function isNotFound(err: unknown): boolean {\n return hasCode(err, ErrorCode.NotFound);\n}\n\n/** isConflict reports whether err is a conflict api error. */\nexport function isConflict(err: unknown): boolean {\n return hasCode(err, ErrorCode.Conflict);\n}\n\n/** isUnauthorized reports whether err is an unauthorized api error. */\nexport function isUnauthorized(err: unknown): boolean {\n return hasCode(err, ErrorCode.Unauthorized);\n}\n\n/** isInvalidArgument reports whether err is an invalid_argument api error. */\nexport function isInvalidArgument(err: unknown): boolean {\n return hasCode(err, ErrorCode.InvalidArgument);\n}\n\n/** isUnavailable reports whether err is an unavailable api error. */\nexport function isUnavailable(err: unknown): boolean {\n return hasCode(err, ErrorCode.Unavailable);\n}\n\ninterface ErrorEnvelope {\n error?: {\n code?: string;\n message?: string;\n details?: Record<string, string>;\n };\n}\n\nfunction parseApiError(\n status: number,\n requestId: string | undefined,\n body: string,\n): FuseApiError {\n if (body) {\n try {\n const env = JSON.parse(body) as ErrorEnvelope;\n const e = env?.error;\n if (e && (e.code || e.message)) {\n return new FuseApiError({\n status,\n code: e.code,\n message: e.message,\n details: e.details,\n requestId,\n body,\n });\n }\n } catch {\n // fall through to the status-text error below\n }\n }\n return new FuseApiError({ status, message: statusText(status), requestId, body });\n}\n\n/**\n * errorFromResponse builds a FuseApiError from a non-2xx Response, parsing the\n * `{\"error\":{code,message,details}}` envelope and reading the X-Request-ID\n * response header for correlation.\n */\nexport async function errorFromResponse(res: Response): Promise<FuseApiError> {\n const requestId = res.headers.get(REQUEST_ID_HEADER) ?? undefined;\n let body = \"\";\n try {\n body = await res.text();\n } catch (err) {\n return new FuseApiError({\n status: res.status,\n message: `read error body: ${String(err)}`,\n requestId,\n });\n }\n return parseApiError(res.status, requestId, body);\n}\n","// The transport layer: builds requests (URL, headers, auth, X-Request-ID,\n// JSON body), applies an optional client-default timeout, executes fetch, and\n// turns non-2xx responses into FuseApiError. Mirrors the transport in\n// sdks/go/environments.go. SSE streams use stream() which deliberately applies\n// no timeout (the Go SDK uses a separate Timeout:0 client for events).\n\nimport { FuseError, errorFromResponse } from \"./errors.js\";\n\nconst REQUEST_ID_HEADER = \"X-Request-ID\";\n\n/** A minimal fetch signature, satisfied by the global fetch and most polyfills. */\nexport type FetchLike = (input: string | URL, init?: RequestInit) => Promise<Response>;\n\n/** Per-call options accepted by every service method. */\nexport interface CallOptions {\n /** Abort the request (and, for events, the stream). */\n signal?: AbortSignal;\n}\n\nexport interface TransportConfig {\n baseUrl: string;\n token?: string;\n fetch?: FetchLike;\n userAgent?: string;\n requestId?: () => string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n}\n\ntype Query = Record<string, string | undefined>;\n\ninterface RequestSpec {\n query?: Query;\n body?: unknown;\n signal?: AbortSignal;\n}\n\n/** Combine zero or more AbortSignals into one, without relying on AbortSignal.any (Node 20+). */\nfunction combineSignals(signals: Array<AbortSignal | undefined>): {\n signal?: AbortSignal;\n cleanup: () => void;\n} {\n const active = signals.filter((s): s is AbortSignal => s != null);\n if (active.length === 0) return { cleanup: () => {} };\n if (active.length === 1) return { signal: active[0], cleanup: () => {} };\n\n const controller = new AbortController();\n const onAbort = (event: Event) => {\n const target = event.target as AbortSignal;\n controller.abort(target.reason);\n cleanup();\n };\n const cleanup = () => {\n for (const s of active) s.removeEventListener(\"abort\", onAbort);\n };\n for (const s of active) {\n if (s.aborted) {\n controller.abort(s.reason);\n cleanup();\n return { signal: controller.signal, cleanup: () => {} };\n }\n s.addEventListener(\"abort\", onAbort);\n }\n return { signal: controller.signal, cleanup };\n}\n\nexport class Transport {\n private readonly baseUrl: URL;\n private readonly token?: string;\n private readonly fetchImpl: FetchLike;\n private readonly userAgent?: string;\n private readonly requestId?: () => string;\n private readonly timeoutMs?: number;\n private readonly defaultHeaders?: Record<string, string>;\n\n constructor(cfg: TransportConfig) {\n if (!cfg.baseUrl) {\n throw new FuseError(\"base url is required\");\n }\n let parsed: URL;\n try {\n parsed = new URL(cfg.baseUrl);\n } catch {\n throw new FuseError(\"base url is invalid\");\n }\n this.baseUrl = parsed;\n this.token = cfg.token;\n this.userAgent = cfg.userAgent;\n this.requestId = cfg.requestId;\n this.timeoutMs = cfg.timeoutMs;\n this.defaultHeaders = cfg.headers;\n\n const provided = cfg.fetch;\n if (provided) {\n this.fetchImpl = provided;\n } else if (typeof globalThis.fetch === \"function\") {\n this.fetchImpl = globalThis.fetch.bind(globalThis) as FetchLike;\n } else {\n throw new FuseError(\n \"global fetch is not available; pass a fetch implementation via the `fetch` option (Node 18+ required)\",\n );\n }\n }\n\n /** Perform a request and decode a JSON response body. */\n async json<T>(method: string, path: string, spec: RequestSpec = {}): Promise<T> {\n const { signal: combined, cleanup } = this.withTimeout(spec.signal);\n try {\n const res = await this.execute(method, path, spec, combined);\n if (!res.ok) throw await errorFromResponse(res);\n return await this.decodeJson<T>(res);\n } finally {\n cleanup();\n }\n }\n\n /** Perform a request that returns no body (e.g. 204 actions). */\n async noContent(method: string, path: string, spec: RequestSpec = {}): Promise<void> {\n const { signal: combined, cleanup } = this.withTimeout(spec.signal);\n try {\n const res = await this.execute(method, path, spec, combined);\n if (!res.ok) throw await errorFromResponse(res);\n // Release the connection even if the server sent a body.\n await res.body?.cancel().catch(() => {});\n } finally {\n cleanup();\n }\n }\n\n /**\n * Open a long-lived stream (SSE). Applies NO timeout — only the caller's\n * signal cancels it — and checks the status eagerly so connect-time errors\n * (404/401/...) surface as a FuseApiError before any iteration.\n */\n async stream(\n path: string,\n query: Query | undefined,\n signal?: AbortSignal,\n ): Promise<Response> {\n const res = await this.execute(\n \"GET\",\n path,\n { query, signal },\n signal,\n \"text/event-stream\",\n );\n if (!res.ok) throw await errorFromResponse(res);\n return res;\n }\n\n private async execute(\n method: string,\n path: string,\n spec: RequestSpec,\n signal: AbortSignal | undefined,\n accept?: string,\n ): Promise<Response> {\n const url = this.buildUrl(path, spec.query);\n const hasBody = spec.body !== undefined && spec.body !== null;\n const headers = this.buildHeaders(hasBody, accept);\n const init: RequestInit = { method, headers };\n if (hasBody) init.body = JSON.stringify(spec.body);\n if (signal) init.signal = signal;\n\n try {\n return await this.fetchImpl(url, init);\n } catch (err) {\n // A caller- or timeout-initiated abort propagates as-is; everything else\n // is wrapped so consumers get a consistent FuseError with a cause.\n if (signal?.aborted) throw err;\n throw new FuseError(`request failed: ${method} ${url}`, { cause: err });\n }\n }\n\n private buildUrl(path: string, query?: Query): string {\n const p = path.startsWith(\"/\") ? path : \"/\" + path;\n const u = new URL(p, this.baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined && value !== \"\") u.searchParams.set(key, value);\n }\n }\n return u.toString();\n }\n\n private buildHeaders(hasBody: boolean, accept?: string): Record<string, string> {\n const headers: Record<string, string> = { ...(this.defaultHeaders ?? {}) };\n if (hasBody) headers[\"Content-Type\"] = \"application/json\";\n if (this.token) headers[\"Authorization\"] = `Bearer ${this.token}`;\n if (this.userAgent) headers[\"User-Agent\"] = this.userAgent;\n if (this.requestId) {\n const id = this.requestId();\n if (id) headers[REQUEST_ID_HEADER] = id;\n }\n if (accept) headers[\"Accept\"] = accept;\n return headers;\n }\n\n private async decodeJson<T>(res: Response): Promise<T> {\n const text = await res.text();\n if (!text) return undefined as T;\n try {\n return JSON.parse(text) as T;\n } catch (err) {\n throw new FuseError(\"decode response body\", { cause: err });\n }\n }\n\n private withTimeout(callerSignal?: AbortSignal): {\n signal?: AbortSignal;\n cleanup: () => void;\n } {\n const signals: Array<AbortSignal | undefined> = [callerSignal];\n if (this.timeoutMs && this.timeoutMs > 0) {\n signals.push(AbortSignal.timeout(this.timeoutMs));\n }\n return combineSignals(signals);\n }\n}\n","import { FuseError } from \"./errors.js\";\n\n/**\n * requireArg throws a FuseError when a required path argument is missing,\n * mirroring the Go SDK's \"<thing> is required\" guards.\n */\nexport function requireArg(value: string | undefined | null, name: string): string {\n if (!value) {\n throw new FuseError(`${name} is required`);\n }\n return value;\n}\n","// Wire types for the Fuse API. Field names match the JSON sent on the wire\n// (snake_case), so request/response bodies pass through JSON.stringify /\n// JSON.parse untouched — a faithful 1:1 mirror of the Go SDK's struct tags\n// (see sdks/go/types.go). List *options* (see each service) use camelCase\n// keys and are translated to snake_case query params by the service.\n\n/** Spec is the hardware/runtime spec for a microVM. */\nexport interface Spec {\n cpus?: number;\n ram_mb?: number;\n storage_gb?: number;\n gpus?: number;\n gpu_kind?: string;\n /** Requests fractional GPU allocation: a MIG profile in mig-parted\n * vocabulary (e.g. \"1g.10gb\"). When set, gpus counts MIG instances of this\n * profile rather than whole devices. */\n gpu_profile?: string;\n region?: string;\n /** Restricts scheduling to hosts of this CPU architecture (\"amd64\",\n * \"arm64\"). Omitted means any host. */\n arch?: string;\n max_runtime_seconds?: number;\n /** Destroys the environment after this many seconds with no exec and no\n * attach session. Omitted or 0 means no idle expiry. Unlike\n * max_runtime_seconds (a ceiling measured from create), this is measured\n * from the last exec or attach. */\n idle_timeout_seconds?: number;\n image?: string;\n /** Pins the environment to an exact host id (the Fusefile's\n * placement.host). The pinned host still has to be active, run the right\n * backend, and fit the request. */\n host_id?: string;\n /** Placement label selectors (the Fusefile's placement.labels): every pair\n * must match the target host's declared labels. */\n labels?: Record<string, string>;\n}\n\n/** ExposeSpec requests that a guest port be published at boot. */\nexport interface ExposeSpec {\n port: number;\n as?: string;\n}\n\n/** Endpoint is a published port with its externally reachable URL. */\nexport interface Endpoint {\n as?: string;\n url: string;\n port: number;\n}\n\n/** HealthcheckHttp is an HTTP GET against a port inside the guest. The probe\n * runs in-guest, so the port needs no matching ExposeSpec. */\nexport interface HealthcheckHttp {\n port: number;\n /** Request path, which must start with a slash. Defaults to \"/\". */\n path?: string;\n}\n\n/**\n * HealthcheckSpec is the environment-level readiness probe (the Fusefile's\n * `healthcheck:` block). Exactly one of http and exec must be set; the server\n * rejects a request that sets both or neither.\n *\n * It is not the per-service compose healthcheck that can appear inside a\n * manifest: that one governs a single container and never reaches the control\n * plane. This one is evaluated by the guest agent over the environment as a\n * whole and its verdict comes back on EnvironmentInfo.health.\n *\n * Every duration is in seconds, and 0 means \"omitted, use the guest agent's\n * default\". The server substitutes no defaults of its own, because the probe\n * executes in the guest.\n */\nexport interface HealthcheckSpec {\n http?: HealthcheckHttp;\n /** An argv run inside the guest. Exit status 0 passes. */\n exec?: string[];\n /** Seconds between attempts. 0 for the guest agent default (10s). */\n interval_seconds?: number;\n /** Bound on one attempt, in seconds. 0 for the guest agent default (2s).\n * Attempts run one at a time, so a value above interval_seconds is\n * rejected rather than silently stretching the interval. */\n timeout_seconds?: number;\n /** Consecutive failures that flip the verdict to failing. 0 for the guest\n * agent default (3). */\n retries?: number;\n /** Grace window from the first attempt during which failures are not\n * counted. It ends for good once the probe passes once. */\n start_period_seconds?: number;\n}\n\n/**\n * DesktopSpec is the geometry of the environment's graphical session (the\n * Fusefile's `desktop:` block). It requires an image that carries the desktop\n * stack; on any other image the declaration is inert and the computer surface\n * reports the display as absent.\n *\n * Both fields are required, 320 to 3840 each: a guessed dimension would\n * silently shift every coordinate a computer-use model emits.\n */\nexport interface DesktopSpec {\n /** Display width in pixels. */\n width: number;\n /** Display height in pixels. */\n height: number;\n}\n\n/**\n * ComputerAction is one computer-use action, in the same shape Anthropic's\n * computer tool emits as tool_use input, so translating a tool_use block into\n * a call is mechanical. Only action is required; which other fields apply\n * depends on the action, and the guest agent enforces the full schema.\n */\nexport interface ComputerAction {\n /** The action to perform, e.g. \"screenshot\", \"left_click\", \"type\", \"key\",\n * \"scroll\", \"zoom\". */\n action: string;\n /** [x, y] target for pointer actions. */\n coordinate?: number[];\n /** [x, y] origin for left_click_drag. */\n start_coordinate?: number[];\n /** The payload for type, the keysym combo for key/hold_key, or modifiers\n * held during a click action. */\n text?: string;\n /** [x1, y1, x2, y2] crop for zoom. */\n region?: number[];\n /** Seconds for hold_key and wait, capped guest-side at 100. */\n duration?: number;\n scroll_direction?: \"up\" | \"down\" | \"left\" | \"right\";\n /** Wheel clicks for scroll, 1 to 100. */\n scroll_amount?: number;\n}\n\n/**\n * ComputerResult is the guest's answer to one action. screenshot is a base64\n * PNG, present on every action that implies one; for zoom it is the cropped\n * region at full resolution.\n */\nexport interface ComputerResult {\n output?: string;\n screenshot?: string;\n}\n\n/**\n * ComputerDisplay reports the environment's display: whether it is up and at\n * what geometry, so a caller can populate display_width_px /\n * display_height_px in its computer tool definition without hardcoding them.\n */\nexport interface ComputerDisplay {\n display?: string;\n up: boolean;\n /** Live display width in pixels, 0 when the display is down. */\n width: number;\n /** Live display height in pixels, 0 when the display is down. */\n height: number;\n /** Why the display is down, when it is. */\n error?: string;\n}\n\n/** ToolResultImageSource is a Messages-API base64 image source. */\nexport interface ToolResultImageSource {\n type: \"base64\";\n media_type: \"image/png\";\n data: string;\n}\n\n/**\n * ToolResultBlock is one content block of a Messages API tool_result. The\n * field names match the Messages API, so the blocks can be sent back verbatim\n * as the tool_result content.\n */\nexport interface ToolResultBlock {\n type: \"text\" | \"image\";\n text?: string;\n source?: ToolResultImageSource;\n}\n\n/**\n * ComputerToolResult is what goes back to Claude for one computer tool_use:\n * the content blocks and whether they describe an error. Map it onto the\n * tool_result block for the tool_use's id and the loop is closed.\n */\nexport interface ComputerToolResult {\n content: ToolResultBlock[];\n is_error?: boolean;\n}\n\n/**\n * Health is the last verdict of an environment's healthcheck.\n *\n * It is deliberately not folded into EnvironmentInfo.state: that vocabulary is\n * a closed set clients reason about, and an unhealthy environment is still a\n * running one. Nothing tears an environment down for a failing probe.\n */\nexport interface Health {\n /** \"starting\", \"passing\" or \"failing\". */\n state: string;\n /** When the probe entered this state. */\n since?: string;\n /** Consecutive failed attempts. Zero while passing. */\n failures?: number;\n /** The last attempt's failure detail. Empty while passing. */\n message?: string;\n}\n\n/** CreateRequest is the body for environments.create. */\nexport interface CreateRequest {\n task_id: string;\n spec?: Spec;\n manifest_inline?: string;\n secrets?: Record<string, string>;\n startup_script?: string;\n /**\n * Guest files written before the startup script runs, keyed by absolute\n * guest path with base64-encoded content. What a Fusefile's `copy` block\n * compiles to. Paths under /fuse are rejected, the total decoded size is\n * capped at 512 KiB, and permissions are not carried.\n */\n files?: Record<string, string>;\n gateway_url?: string;\n gateway_token?: string;\n expose?: ExposeSpec[];\n /** Environment-level readiness probe. Omit it for an environment with no\n * probe, in which case EnvironmentInfo.health is never populated. It is not\n * evaluated inside create: the call returns as soon as the VM is up, and\n * the verdict arrives on later reads. */\n healthcheck?: HealthcheckSpec;\n /** Graphical session geometry. Omit it for an environment with no desktop,\n * in which case a desktop image keeps its baked default geometry. */\n desktop?: DesktopSpec;\n}\n\n/** EnvironmentInfo is the server's view of a single microVM. */\nexport interface EnvironmentInfo {\n id: string;\n state: string;\n task_id: string;\n host_id?: string;\n url: string;\n spec: Spec;\n created_at: string;\n updated_at: string;\n error?: string;\n endpoints?: Endpoint[];\n /** Last verdict of the environment-level healthcheck. Absent when the\n * environment declared no healthcheck, and absent until the first verdict\n * has been read back from the guest. The server refreshes it on its\n * reconcile tick (30s by default), so it lags the guest by up to a tick. */\n health?: Health;\n}\n\n/** ForkOptions is the optional body for environments.fork. */\nexport interface ForkOptions {\n reuse_snapshot_id?: string;\n comment?: string;\n}\n\n/** ExecRequest is the body for environments.exec. Exactly one of cmd or shell must be set. */\nexport interface ExecRequest {\n /**\n * The argv to run in the guest, e.g. [\"ls\", \"-l\"]. Argv needs no quoting\n * rules and cannot be turned into an injection by interpolating a value, so\n * prefer it.\n */\n cmd?: string[];\n\n /**\n * Runs the string under `sh -lc`. Use it only for what argv cannot express:\n * pipelines, redirects, and globs.\n */\n shell?: string;\n\n /**\n * Bounds the command inside the guest. Zero or unset takes the server\n * default; the server clamps anything above its ceiling.\n */\n timeout_ms?: number;\n}\n\n/**\n * ExecResult is the outcome of a guest command.\n *\n * A non-zero exit_code is a successful call: the command ran and failed. Only a\n * thrown error means the command could not be run at all.\n */\nexport interface ExecResult {\n exit_code: number;\n stdout: string;\n stderr: string;\n}\n\n/**\n * Event is one item from environments.events. It matches the server's SSE\n * wire payload. Stream-level failures are thrown from the async iterator\n * rather than delivered as an in-band event.\n */\nexport interface Event {\n id: string;\n /** Event kind: \"state\" (an omitted kind means \"state\") or \"step\". */\n event: string;\n vm_id: string;\n state: string;\n url?: string;\n error?: string;\n updated_at: string;\n /** index of the setup step, 1-based. step events only. */\n index?: number;\n /** total number of setup steps. step events only. */\n total?: number;\n /** layer cache key for the step. step events only. */\n key?: string;\n /** whether the step was served from the layer cache. step events only. */\n cached?: boolean;\n /** why the step missed the cache. step events only. */\n miss_reason?: string;\n /** what changed, e.g. the input paths. step events only. */\n miss_detail?: string[];\n /** wall-clock duration of the step in milliseconds. step events only. */\n duration_ms?: number;\n /** exit code of the step. step events only. */\n exit_code?: number;\n}\n\n/** SnapshotRequest is the optional body for snapshots.create. */\nexport interface SnapshotRequest {\n comment?: string;\n mode?: string;\n retention_seconds?: number;\n metadata?: Record<string, string>;\n export_ref?: string;\n export_status?: string;\n /** Labels this snapshot as the artifact of one cacheable setup step, which is\n * what makes it findable by recipe rather than by its random id. Empty for an\n * ordinary snapshot. The scope it is filed under comes from how the caller\n * authenticated and is not settable here. */\n layer_key?: string;\n}\n\n/** ResolveSnapshotResponse is the wire envelope for a layer lookup. Internal:\n * resolve() returns Snapshot | null so the found flag never reaches callers. */\nexport interface ResolveSnapshotResponse {\n found: boolean;\n snapshot?: Snapshot;\n}\n\n/** SnapshotExport is an optional exported snapshot artifact. */\nexport interface SnapshotExport {\n destination: string;\n status?: string;\n requested_at?: string;\n updated_at?: string;\n last_error?: string;\n}\n\n/** Snapshot is a persisted snapshot record. */\nexport interface Snapshot {\n id: string;\n vm_id: string;\n task_id?: string;\n tenant_id?: string;\n parent_snapshot_id?: string;\n mode?: string;\n state?: string;\n comment?: string;\n /** The content-addressed cache key of the setup step this artifact was\n * taken after. Absent on anything that is not a build layer, and an empty\n * key never matches a lookup. */\n layer_key?: string;\n /** CPU architecture, in GOARCH vocabulary (\"amd64\", \"arm64\"), of the host\n * that actually built the artifact rather than of whoever asked for it. A\n * rootfs is not portable across architectures, so this is a real constraint\n * on whether the artifact can be booted; it is deliberately not folded into\n * layer_key, so a lookup has to filter on it separately. */\n arch?: string;\n /** Hex sha256 of the artifact rootfs. It verifies that a given copy of\n * those bytes is intact, and nothing more: it is not a cross-build\n * identity, because two builds of the same recipe produce different rootfs\n * bytes (timestamps, inode ordering, package caches). It can never be used\n * as a cache key. */\n digest?: string;\n size_bytes?: number;\n created_at: string;\n updated_at?: string;\n retention_until?: string;\n last_error?: string;\n export_ref?: string;\n exports?: SnapshotExport[];\n}\n\n/** HostCapacity is a host's resource envelope. */\nexport interface HostCapacity {\n cpus: number;\n ram_mb: number;\n storage_gb: number;\n vm_count: number;\n /** The host's CPU architecture in GOARCH vocabulary (\"amd64\", \"arm64\").\n * Omitted means amd64 (hosts registered before arch existed). */\n arch?: string;\n gpus?: number;\n gpu_kind?: string;\n /** Fractional GPU capacity: MIG instance count by profile name (e.g.\n * {\"1g.10gb\": 4}). Like gpus, it requires backend \"qemu\". When the host\n * reports per-instance MIG inventory (mig_instances), this map is a derived\n * summary; otherwise it is the scheduling unit. */\n mig_profiles?: Record<string, number>;\n /** Per-instance MIG inventory probed from the host agent (one entry per\n * carved MIG GPU instance). When non-empty, the orchestrator binds specific\n * instance uuids to VMs instead of decrementing a count. Strictly additive:\n * a host that reports no instances falls back to mig_profiles. Only\n * populated on capacity (not allocated) for qemu hosts. */\n mig_instances?: MIGInstance[];\n /** The set of MIG instance uuids currently bound to VMs. Populated only on\n * allocated, and only for hosts that report per-instance MIG inventory. */\n mig_instance_uuids?: string[];\n /** Per-device GPU detail probed from the host agent, carried alongside the\n * scalar gpus/gpu_kind counters. Only populated on capacity (not\n * allocated) for qemu hosts. */\n gpu_devices?: GPUDevice[];\n}\n\n/** GPUDevice is the per-device detail probed for a single GPU. Every field is\n * best-effort and omitted when the host agent could not determine it. */\nexport interface GPUDevice {\n uuid?: string;\n model?: string;\n pci_bus_id?: string;\n memory_mb?: number;\n driver_version?: string;\n cuda_version?: string;\n compute_cap?: string;\n mig_capable?: boolean;\n mig_mode?: string;\n iommu_group?: string;\n}\n\n/** MIGInstance is one carved MIG GPU instance probed from the host agent. The\n * orchestrator binds a specific instance uuid to a VM so it knows which\n * instance went to which VM. */\nexport interface MIGInstance {\n uuid?: string;\n profile?: string;\n kind?: string;\n parent_gpu_uuid?: string;\n}\n\n/** RegisterHostRequest is the body for hosts.register. */\nexport interface RegisterHostRequest {\n id: string;\n url: string;\n token?: string;\n region?: string;\n backend?: string;\n /** Operator-declared key/value pairs matched against a spec's placement\n * label selectors. Never probed from the host agent. */\n labels?: Record<string, string>;\n capacity?: HostCapacity;\n}\n\n/** Host is the server's view of a registered host. */\nexport interface Host {\n id: string;\n url: string;\n region?: string;\n state: string;\n backend?: string;\n labels?: Record<string, string>;\n capacity: HostCapacity;\n allocated: HostCapacity;\n last_seen: string;\n created_at: string;\n updated_at: string;\n /** Non-fatal registration notices (e.g. declared capacity exceeding the\n * probed value). Only ever populated on the response to hosts.register. */\n warnings?: string[];\n}\n\n/**\n * APIKey is a key's metadata. The raw secret appears only in\n * CreatedAPIKey.key, returned once at creation.\n */\nexport interface APIKey {\n id: string;\n label?: string;\n created_at: string;\n last_used_at?: string;\n revoked_at?: string;\n}\n\n/**\n * CreatedAPIKey is returned by apiKeys.create. `key` is the raw secret and is\n * unrecoverable after this response.\n */\nexport interface CreatedAPIKey extends APIKey {\n key: string;\n}\n\n/** Lifecycle states for EnvironmentInfo.state and Event.state. */\nexport const State = {\n Provisioning: \"provisioning\",\n Running: \"running\",\n Draining: \"draining\",\n Destroying: \"destroying\",\n Destroyed: \"destroyed\",\n Failed: \"failed\",\n} as const;\n\nexport type State = (typeof State)[keyof typeof State];\n\n/** isTerminalState reports whether state is a terminal lifecycle state. */\nexport function isTerminalState(state: string): boolean {\n return state === State.Destroyed || state === State.Failed;\n}\n\n/**\n * Verdicts carried in Health.state. Separate from State on purpose: a failing\n * probe reports, it does not move the environment anywhere new.\n */\nexport const HealthState = {\n /** The probe has not passed yet and is still inside its start period, so\n * failures are not being counted. */\n Starting: \"starting\",\n /** The most recent attempt succeeded. */\n Passing: \"passing\",\n /** The probe failed its configured retries in a row after the start period\n * ended. */\n Failing: \"failing\",\n} as const;\n\nexport type HealthState = (typeof HealthState)[keyof typeof HealthState];\n","// SSE event streaming, porting the state machine in sdks/go/events.go to an\n// async iterator. The stream is opened (and its status checked) eagerly; the\n// returned AsyncIterable yields each Event and ends after a terminal-state\n// event (destroyed/failed) or on clean EOF. Stream-level failures are thrown\n// from the iterator. Caller abort is treated as normal termination.\n\nimport type { Transport } from \"./transport.js\";\nimport { FuseError } from \"./errors.js\";\nimport { type Event, isTerminalState } from \"./types.js\";\n\nconst DATA_PREFIX = \"data:\";\n\n/** Open the SSE stream for an environment and return an async-iterable of events. */\nexport async function streamEvents(\n t: Transport,\n vmId: string,\n signal?: AbortSignal,\n): Promise<AsyncIterable<Event>> {\n const path = `/v1/environments/${encodeURIComponent(vmId)}/events`;\n const res = await t.stream(path, undefined, signal);\n return parseEventStream(res, signal);\n}\n\nfunction parseEventStream(res: Response, signal?: AbortSignal): AsyncIterable<Event> {\n return {\n async *[Symbol.asyncIterator](): AsyncGenerator<Event> {\n const body = res.body;\n if (!body) return;\n\n const reader = body.getReader();\n const decoder = new TextDecoder(\"utf-8\");\n let buffer = \"\";\n let data = \"\";\n let hasData = false;\n\n try {\n while (true) {\n let chunk;\n try {\n chunk = await reader.read();\n } catch (err) {\n // Caller-initiated abort is a clean end, not an error.\n if (signal?.aborted) return;\n throw new FuseError(\"event stream read failed\", { cause: err });\n }\n if (chunk.done) {\n // Clean EOF with no terminal state: just end (matches Go).\n return;\n }\n\n buffer += decoder.decode(chunk.value, { stream: true });\n\n let nl: number;\n while ((nl = buffer.indexOf(\"\\n\")) >= 0) {\n let line = buffer.slice(0, nl);\n buffer = buffer.slice(nl + 1);\n if (line.endsWith(\"\\r\")) line = line.slice(0, -1); // tolerate CRLF\n\n if (line === \"\") {\n // Blank line terminates the current event.\n if (!hasData) continue;\n const payload = data;\n data = \"\";\n hasData = false;\n\n let event: Event;\n try {\n event = JSON.parse(payload) as Event;\n } catch (err) {\n throw new FuseError(\"decode event\", { cause: err });\n }\n yield event;\n if (isTerminalState(event.state)) return;\n } else if (line.startsWith(\":\")) {\n // Comment / keepalive line — skip.\n continue;\n } else if (line.startsWith(DATA_PREFIX)) {\n // Strip the prefix and a single optional leading space; multiple\n // data: lines concatenate without a separator (matches server).\n let p = line.slice(DATA_PREFIX.length);\n if (p.startsWith(\" \")) p = p.slice(1);\n data += p;\n hasData = true;\n }\n // Other fields (id:, event:, ...) are ignored.\n }\n }\n } finally {\n // Release the underlying socket if the consumer breaks early.\n try {\n await reader.cancel();\n } catch {\n // ignore\n }\n }\n },\n };\n}\n","import type { CallOptions, Transport } from \"./transport.js\";\nimport type {\n ComputerAction,\n ComputerDisplay,\n ComputerResult,\n ComputerToolResult,\n CreateRequest,\n EnvironmentInfo,\n Event,\n ExecRequest,\n ExecResult,\n ForkOptions,\n ToolResultBlock,\n} from \"./types.js\";\nimport { FuseError, isFuseApiError } from \"./errors.js\";\nimport { requireArg } from \"./validate.js\";\nimport { streamEvents } from \"./events.js\";\n\n/** The server's max page size; list() requests this internally so it walks\n * every page in as few round trips as possible. */\nconst MAX_PAGE_LIMIT = 200;\n\n/** Filters (and pagination) for environments.list / environments.listPage. */\nexport interface ListEnvironmentsOptions {\n taskId?: string;\n state?: string;\n hostId?: string;\n /** Page size (server default 50, max 200). Only consulted by listPage —\n * list() always walks every page, so it ignores this and requests the\n * server's max page size. */\n limit?: number;\n /** Opaque cursor from a previous listPage() call's nextCursor. */\n cursor?: string;\n}\n\ninterface EnvironmentList {\n environments: EnvironmentInfo[];\n next_cursor?: string;\n}\n\n/** One page of environments.listPage, plus the cursor to fetch the next one. */\nexport interface EnvironmentPage {\n environments: EnvironmentInfo[];\n /** Empty/undefined once there are no more results. */\n nextCursor?: string;\n}\n\n/** EnvironmentsService manages microVM lifecycle. */\nexport class EnvironmentsService {\n constructor(private readonly t: Transport) {}\n\n /** List tracked environments, optionally filtered. Transparently walks\n * every result page. For explicit single-page control (e.g. a cursor from\n * a previous call), use listPage. */\n async list(\n options: ListEnvironmentsOptions = {},\n opts: CallOptions = {},\n ): Promise<EnvironmentInfo[]> {\n const out: EnvironmentInfo[] = [];\n let cursor = options.cursor;\n for (;;) {\n const page = await this.listPage(\n { ...options, limit: MAX_PAGE_LIMIT, cursor },\n opts,\n );\n out.push(...page.environments);\n if (!page.nextCursor) break;\n cursor = page.nextCursor;\n }\n return out;\n }\n\n /** List one page of tracked environments, optionally filtered. */\n async listPage(\n options: ListEnvironmentsOptions = {},\n opts: CallOptions = {},\n ): Promise<EnvironmentPage> {\n const out = await this.t.json<EnvironmentList>(\"GET\", \"/v1/environments\", {\n query: {\n task_id: options.taskId,\n state: options.state,\n host_id: options.hostId,\n limit: options.limit ? String(options.limit) : undefined,\n cursor: options.cursor,\n },\n signal: opts.signal,\n });\n return { environments: out.environments ?? [], nextCursor: out.next_cursor };\n }\n\n /** Fetch a single environment by VM id. */\n async get(vmId: string, opts: CallOptions = {}): Promise<EnvironmentInfo> {\n requireArg(vmId, \"vm id\");\n return this.t.json<EnvironmentInfo>(\n \"GET\",\n `/v1/environments/${encodeURIComponent(vmId)}`,\n { signal: opts.signal },\n );\n }\n\n /** Provision a new environment. Blocks until running or creation fails. */\n async create(body: CreateRequest, opts: CallOptions = {}): Promise<EnvironmentInfo> {\n return this.t.json<EnvironmentInfo>(\"POST\", \"/v1/environments\", {\n body,\n signal: opts.signal,\n });\n }\n\n /** Fork an environment into a new one; returns the new environment. */\n async fork(\n vmId: string,\n body: ForkOptions = {},\n opts: CallOptions = {},\n ): Promise<EnvironmentInfo> {\n requireArg(vmId, \"vm id\");\n return this.t.json<EnvironmentInfo>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}`,\n { query: { action: \"fork\" }, body, signal: opts.signal },\n );\n }\n\n /**\n * Run a command inside a running environment's guest and return its exit code\n * with stdout and stderr kept separate.\n *\n * A non-zero exit_code is resolved, not thrown: the command ran and failed.\n * A thrown error means the command could not be run at all.\n *\n * Exec requires the master token.\n *\n * @example\n * const out = await client.environments.exec(id, { cmd: [\"ls\", \"-l\"] });\n * if (out.exit_code !== 0) console.error(out.stderr);\n */\n async exec(\n vmId: string,\n body: ExecRequest,\n opts: CallOptions = {},\n ): Promise<ExecResult> {\n requireArg(vmId, \"vm id\");\n const hasCmd = (body.cmd?.length ?? 0) > 0;\n const hasShell = (body.shell ?? \"\") !== \"\";\n if (!hasCmd && !hasShell) {\n throw new FuseError(\"one of cmd or shell is required\");\n }\n if (hasCmd && hasShell) {\n throw new FuseError(\"cmd and shell are mutually exclusive\");\n }\n return this.t.json<ExecResult>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}`,\n { query: { action: \"exec\" }, body, signal: opts.signal },\n );\n }\n\n /**\n * Relay one computer-use action to the environment's desktop and return the\n * result, usually carrying a base64 PNG screenshot. Requires an environment\n * booted from a desktop image; on any other image the server answers 503\n * with a reason.\n *\n * @example\n * const res = await client.environments.computer(id, {\n * action: \"left_click\",\n * coordinate: [512, 384],\n * });\n */\n async computer(\n vmId: string,\n action: ComputerAction,\n opts: CallOptions = {},\n ): Promise<ComputerResult> {\n requireArg(vmId, \"vm id\");\n requireArg(action?.action, \"action\");\n return this.t.json<ComputerResult>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}/computer`,\n { body: action, signal: opts.signal },\n );\n }\n\n /**\n * Execute one computer tool_use against the environment and shape the\n * answer for the Messages API: the tool_use block's `input` goes in\n * verbatim (it is already the wire shape the computer endpoint takes), and\n * content blocks for the tool_result come out.\n *\n * An action the environment refuses (a malformed coordinate, a display\n * that is not up) resolves to `is_error` content rather than throwing: the\n * agent loop should feed it to the model, which is the party that can\n * correct it. A throw is reserved for failures the model cannot fix —\n * transport, auth, an unknown environment.\n *\n * @example\n * for (const block of msg.content) {\n * if (block.type === \"tool_use\" && block.name === \"computer\") {\n * const result = await client.environments.computerToolResult(id, block.input);\n * toolResults.push({ type: \"tool_result\", tool_use_id: block.id, ...result });\n * }\n * }\n */\n async computerToolResult(\n vmId: string,\n input: unknown,\n opts: CallOptions = {},\n ): Promise<ComputerToolResult> {\n requireArg(vmId, \"vm id\");\n const action = (input as { action?: string } | null)?.action ?? \"\";\n if (action === \"\") {\n return {\n is_error: true,\n content: [{ type: \"text\", text: \"tool input names no action\" }],\n };\n }\n let res: ComputerResult;\n try {\n res = await this.t.json<ComputerResult>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}/computer`,\n { body: input, signal: opts.signal },\n );\n } catch (err) {\n if (\n isFuseApiError(err) &&\n (err.status === 400 || err.status === 409 || err.status === 503)\n ) {\n return {\n is_error: true,\n content: [{ type: \"text\", text: err.message || \"the computer action failed\" }],\n };\n }\n throw err;\n }\n const content: ToolResultBlock[] = [];\n if (res.output) content.push({ type: \"text\", text: res.output });\n if (res.screenshot) {\n content.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: \"image/png\",\n data: res.screenshot,\n },\n });\n }\n if (content.length === 0) content.push({ type: \"text\", text: \"done\" });\n return { content };\n }\n\n /** Report whether the environment has a live display and at what geometry.\n * up is false with a reason on an image with no desktop. */\n async computerDisplay(vmId: string, opts: CallOptions = {}): Promise<ComputerDisplay> {\n requireArg(vmId, \"vm id\");\n return this.t.json<ComputerDisplay>(\n \"GET\",\n `/v1/environments/${encodeURIComponent(vmId)}/computer`,\n { signal: opts.signal },\n );\n }\n\n /** Gracefully drain an environment; returns the updated environment. */\n async drain(vmId: string, opts: CallOptions = {}): Promise<EnvironmentInfo> {\n requireArg(vmId, \"vm id\");\n return this.t.json<EnvironmentInfo>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}`,\n { query: { action: \"drain\" }, signal: opts.signal },\n );\n }\n\n /** Rotate the per-VM credentials and push them to the guest. */\n async rotateToken(vmId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(vmId, \"vm id\");\n await this.t.noContent(\"POST\", `/v1/environments/${encodeURIComponent(vmId)}`, {\n query: { action: \"rotate-token\" },\n signal: opts.signal,\n });\n }\n\n /** Forcefully destroy an environment. Idempotent. */\n async destroy(vmId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(vmId, \"vm id\");\n await this.t.noContent(\"DELETE\", `/v1/environments/${encodeURIComponent(vmId)}`, {\n signal: opts.signal,\n });\n }\n\n /**\n * Open the SSE event stream for an environment. The returned promise rejects\n * with a FuseApiError on a connect-time failure (e.g. not_found); on success\n * it resolves to an AsyncIterable that yields each Event and ends after a\n * terminal-state event. Pass `opts.signal` to cancel; there is no built-in\n * timeout on the stream.\n *\n * @example\n * for await (const ev of await client.environments.events(id)) {\n * console.log(ev.state);\n * }\n */\n async events(vmId: string, opts: CallOptions = {}): Promise<AsyncIterable<Event>> {\n requireArg(vmId, \"vm id\");\n return streamEvents(this.t, vmId, opts.signal);\n }\n}\n","import type { CallOptions, Transport } from \"./transport.js\";\nimport type { ResolveSnapshotResponse, Snapshot, SnapshotRequest } from \"./types.js\";\nimport { requireArg } from \"./validate.js\";\n\n/** The server's max page size; list() requests this internally so it walks\n * every page in as few round trips as possible. */\nconst MAX_PAGE_LIMIT = 200;\n\n/** Filters (and pagination) for snapshots.list / snapshots.listPage. */\nexport interface ListSnapshotsOptions {\n vmId?: string;\n taskId?: string;\n tenantId?: string;\n state?: string;\n /** Narrows to the build layers taken after one setup step. Unset means \"do\n * not filter\", never \"match artifacts with no layer key\". */\n layerKey?: string;\n /** Narrows to artifacts built on one architecture, in GOARCH vocabulary\n * (\"amd64\", \"arm64\"). It is a separate filter from layerKey rather than\n * part of it because a rootfs is not portable across architectures, so a\n * layer lookup that does not constrain arch can be served bytes it cannot\n * boot. */\n arch?: string;\n /** Page size (server default 50, max 200). Only consulted by listPage —\n * list() always walks every page, so it ignores this and requests the\n * server's max page size. */\n limit?: number;\n /** Opaque cursor from a previous listPage() call's nextCursor. */\n cursor?: string;\n}\n\ninterface SnapshotList {\n snapshots: Snapshot[];\n next_cursor?: string;\n}\n\n/** One page of snapshots.listPage, plus the cursor to fetch the next one. */\nexport interface SnapshotPage {\n snapshots: Snapshot[];\n /** Empty/undefined once there are no more results. */\n nextCursor?: string;\n}\n\n/** SnapshotsService manages microVM snapshots. */\nexport class SnapshotsService {\n constructor(private readonly t: Transport) {}\n\n /** Create a snapshot of a running environment. */\n async create(\n vmId: string,\n body: SnapshotRequest = {},\n opts: CallOptions = {},\n ): Promise<Snapshot> {\n requireArg(vmId, \"vm id\");\n return this.t.json<Snapshot>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}/snapshots`,\n { body, signal: opts.signal },\n );\n }\n\n /** List snapshots, optionally filtered. Transparently walks every result\n * page. For explicit single-page control (e.g. a cursor from a previous\n * call), use listPage. */\n async list(\n options: ListSnapshotsOptions = {},\n opts: CallOptions = {},\n ): Promise<Snapshot[]> {\n const out: Snapshot[] = [];\n let cursor = options.cursor;\n for (;;) {\n const page = await this.listPage(\n { ...options, limit: MAX_PAGE_LIMIT, cursor },\n opts,\n );\n out.push(...page.snapshots);\n if (!page.nextCursor) break;\n cursor = page.nextCursor;\n }\n return out;\n }\n\n /** List one page of snapshots, optionally filtered. */\n async listPage(\n options: ListSnapshotsOptions = {},\n opts: CallOptions = {},\n ): Promise<SnapshotPage> {\n const out = await this.t.json<SnapshotList>(\"GET\", \"/v1/snapshots\", {\n query: {\n vm_id: options.vmId,\n task_id: options.taskId,\n tenant_id: options.tenantId,\n state: options.state,\n layer_key: options.layerKey,\n arch: options.arch,\n limit: options.limit ? String(options.limit) : undefined,\n cursor: options.cursor,\n },\n signal: opts.signal,\n });\n return { snapshots: out.snapshots ?? [], nextCursor: out.next_cursor };\n }\n\n /**\n * Resolve one layer cache key and architecture to the newest ready build\n * artifact, or null when there is none.\n *\n * A miss is not an error and never rejects: a cold cache is the normal state\n * of a first build, and modelling it as a failure would make every caller\n * wrap this in a try/catch to discover nothing was wrong.\n *\n * arch is required rather than defaulted. An ext4 rootfs is not portable\n * across architectures, so resolving without one could hand back an artifact\n * the caller cannot boot, at the exact moment it believes it got a hit.\n *\n * The scope searched comes from how the client authenticated; there is\n * deliberately no tenant parameter.\n */\n async resolve(\n layerKey: string,\n arch: string,\n opts: CallOptions = {},\n ): Promise<Snapshot | null> {\n requireArg(layerKey, \"layer key\");\n requireArg(arch, \"arch\");\n const out = await this.t.json<ResolveSnapshotResponse>(\n \"GET\",\n \"/v1/snapshots/resolve\",\n { query: { layer_key: layerKey, arch }, signal: opts.signal },\n );\n return out.found && out.snapshot ? out.snapshot : null;\n }\n\n /** Fetch a single snapshot by id. */\n async get(snapshotId: string, opts: CallOptions = {}): Promise<Snapshot> {\n requireArg(snapshotId, \"snapshot id\");\n return this.t.json<Snapshot>(\n \"GET\",\n `/v1/snapshots/${encodeURIComponent(snapshotId)}`,\n { signal: opts.signal },\n );\n }\n\n /** Delete a snapshot. Idempotent; the snapshot must be a leaf. */\n async delete(snapshotId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(snapshotId, \"snapshot id\");\n await this.t.noContent(\"DELETE\", `/v1/snapshots/${encodeURIComponent(snapshotId)}`, {\n signal: opts.signal,\n });\n }\n\n /** Restore an environment from a snapshot. */\n async restore(snapshotId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(snapshotId, \"snapshot id\");\n await this.t.noContent(\"POST\", `/v1/snapshots/${encodeURIComponent(snapshotId)}`, {\n query: { action: \"restore\" },\n signal: opts.signal,\n });\n }\n}\n","import type { CallOptions, Transport } from \"./transport.js\";\nimport type { Host, RegisterHostRequest } from \"./types.js\";\nimport { requireArg } from \"./validate.js\";\n\n/** The server's max page size; list() requests this internally so it walks\n * every page in as few round trips as possible. */\nconst MAX_PAGE_LIMIT = 200;\n\n/** Pagination for hosts.listPage. */\nexport interface ListHostsOptions {\n /** Page size (server default 50, max 200). */\n limit?: number;\n /** Opaque cursor from a previous listPage() call's nextCursor. */\n cursor?: string;\n}\n\ninterface HostList {\n hosts: Host[];\n next_cursor?: string;\n}\n\n/** One page of hosts.listPage, plus the cursor to fetch the next one. */\nexport interface HostPage {\n hosts: Host[];\n /** Empty/undefined once there are no more results. */\n nextCursor?: string;\n}\n\n/** HostsService manages registered Firecracker hosts. */\nexport class HostsService {\n constructor(private readonly t: Transport) {}\n\n /** Register (or re-register) a host. Idempotent on id. */\n async register(body: RegisterHostRequest, opts: CallOptions = {}): Promise<Host> {\n return this.t.json<Host>(\"POST\", \"/v1/hosts\", { body, signal: opts.signal });\n }\n\n /** List registered hosts. Transparently walks every result page. For\n * explicit single-page control (e.g. a cursor from a previous call), use\n * listPage. */\n async list(opts: CallOptions = {}): Promise<Host[]> {\n const out: Host[] = [];\n let cursor: string | undefined;\n for (;;) {\n const page = await this.listPage({ limit: MAX_PAGE_LIMIT, cursor }, opts);\n out.push(...page.hosts);\n if (!page.nextCursor) break;\n cursor = page.nextCursor;\n }\n return out;\n }\n\n /** List one page of registered hosts. */\n async listPage(\n options: ListHostsOptions = {},\n opts: CallOptions = {},\n ): Promise<HostPage> {\n const out = await this.t.json<HostList>(\"GET\", \"/v1/hosts\", {\n query: {\n limit: options.limit ? String(options.limit) : undefined,\n cursor: options.cursor,\n },\n signal: opts.signal,\n });\n return { hosts: out.hosts ?? [], nextCursor: out.next_cursor };\n }\n\n /** Fetch a single host by id. */\n async get(hostId: string, opts: CallOptions = {}): Promise<Host> {\n requireArg(hostId, \"host id\");\n return this.t.json<Host>(\"GET\", `/v1/hosts/${encodeURIComponent(hostId)}`, {\n signal: opts.signal,\n });\n }\n\n /** Mark a host unschedulable; existing VMs keep running. */\n async cordon(hostId: string, opts: CallOptions = {}): Promise<void> {\n await this.action(hostId, \"cordon\", opts);\n }\n\n /** Return a cordoned host to active scheduling. */\n async uncordon(hostId: string, opts: CallOptions = {}): Promise<void> {\n await this.action(hostId, \"uncordon\", opts);\n }\n\n /** Remove a host. The host must have no running VMs. */\n async deregister(hostId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(hostId, \"host id\");\n await this.t.noContent(\"DELETE\", `/v1/hosts/${encodeURIComponent(hostId)}`, {\n signal: opts.signal,\n });\n }\n\n private async action(hostId: string, action: string, opts: CallOptions): Promise<void> {\n requireArg(hostId, \"host id\");\n await this.t.noContent(\"POST\", `/v1/hosts/${encodeURIComponent(hostId)}`, {\n query: { action },\n signal: opts.signal,\n });\n }\n}\n","import type { CallOptions, Transport } from \"./transport.js\";\nimport type { APIKey, CreatedAPIKey } from \"./types.js\";\nimport { requireArg } from \"./validate.js\";\n\ninterface APIKeyList {\n api_keys: APIKey[];\n}\n\n/**\n * ApiKeysService manages revocable API keys. These endpoints require the\n * master token; the server enforces this.\n */\nexport class ApiKeysService {\n constructor(private readonly t: Transport) {}\n\n /**\n * Issue a new API key. The raw secret is returned once in `key` and is\n * unrecoverable afterward.\n */\n async create(label?: string, opts: CallOptions = {}): Promise<CreatedAPIKey> {\n return this.t.json<CreatedAPIKey>(\"POST\", \"/v1/api-keys\", {\n body: label ? { label } : {},\n signal: opts.signal,\n });\n }\n\n /** List API key metadata. */\n async list(opts: CallOptions = {}): Promise<APIKey[]> {\n const out = await this.t.json<APIKeyList>(\"GET\", \"/v1/api-keys\", {\n signal: opts.signal,\n });\n return out.api_keys ?? [];\n }\n\n /** Revoke the API key with the given id. */\n async revoke(id: string, opts: CallOptions = {}): Promise<void> {\n requireArg(id, \"id\");\n await this.t.noContent(\"DELETE\", `/v1/api-keys/${encodeURIComponent(id)}`, {\n signal: opts.signal,\n });\n }\n}\n","// generated by scripts/gen-version.mjs. do not edit.\nexport const VERSION = \"0.24.0\";\n","import { Transport, type FetchLike } from \"./transport.js\";\nimport { EnvironmentsService } from \"./environments.js\";\nimport { SnapshotsService } from \"./snapshots.js\";\nimport { HostsService } from \"./hosts.js\";\nimport { ApiKeysService } from \"./apiKeys.js\";\nimport { VERSION } from \"./version.js\";\n\n/** Options for constructing a FuseClient. */\nexport interface FuseClientOptions {\n /** Base URL of the Fuse control plane, e.g. \"https://fuse.example.com\". Required. */\n baseUrl: string;\n /** Bearer token (master token or an API key). Omit for unauthenticated endpoints. */\n token?: string;\n /** Custom fetch implementation. Defaults to the global fetch (Node 18+). */\n fetch?: FetchLike;\n /** User-Agent header. Defaults to \"fuse-ts/<version>\". Ignored by browsers. */\n userAgent?: string;\n /** Generator for the X-Request-ID header, called once per request. Empty results are omitted. */\n requestId?: () => string;\n /** Default per-request timeout in milliseconds. Does NOT apply to events() streams. */\n timeoutMs?: number;\n /** Extra default headers merged into every request. */\n headers?: Record<string, string>;\n}\n\n/**\n * FuseClient is the entry point for the Fuse API. It groups the resource\n * services that share a single transport.\n *\n * @example\n * const client = new FuseClient({ baseUrl: \"https://fuse.example.com\", token });\n * const env = await client.environments.create({ task_id: \"task-1\" });\n */\nexport class FuseClient {\n readonly environments: EnvironmentsService;\n readonly snapshots: SnapshotsService;\n readonly hosts: HostsService;\n readonly apiKeys: ApiKeysService;\n\n constructor(options: FuseClientOptions) {\n const transport = new Transport({\n baseUrl: options.baseUrl,\n token: options.token,\n fetch: options.fetch,\n userAgent: options.userAgent ?? `fuse-ts/${VERSION}`,\n requestId: options.requestId,\n timeoutMs: options.timeoutMs,\n headers: options.headers,\n });\n this.environments = new EnvironmentsService(transport);\n this.snapshots = new SnapshotsService(transport);\n this.hosts = new HostsService(transport);\n this.apiKeys = new ApiKeysService(transport);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/transport.ts","../src/validate.ts","../src/types.ts","../src/events.ts","../src/environments.ts","../src/snapshots.ts","../src/hosts.ts","../src/apiKeys.ts","../src/version.ts","../src/client.ts"],"names":["REQUEST_ID_HEADER","MAX_PAGE_LIMIT"],"mappings":";AAIA,IAAM,iBAAA,GAAoB,cAAA;AAGnB,IAAM,SAAA,GAAY;AAAA,EACvB,QAAA,EAAU,WAAA;AAAA,EACV,QAAA,EAAU,UAAA;AAAA,EACV,eAAA,EAAiB,kBAAA;AAAA,EACjB,WAAA,EAAa,aAAA;AAAA,EACb,QAAA,EAAU,UAAA;AAAA,EACV,YAAA,EAAc;AAChB;AAIA,IAAM,WAAA,GAAsC;AAAA,EAC1C,GAAA,EAAK,aAAA;AAAA,EACL,GAAA,EAAK,cAAA;AAAA,EACL,GAAA,EAAK,WAAA;AAAA,EACL,GAAA,EAAK,WAAA;AAAA,EACL,GAAA,EAAK,UAAA;AAAA,EACL,GAAA,EAAK,uBAAA;AAAA,EACL,GAAA,EAAK,aAAA;AAAA,EACL,GAAA,EAAK;AACP,CAAA;AAEA,SAAS,WAAW,MAAA,EAAwB;AAC1C,EAAA,OAAO,WAAA,CAAY,MAAM,CAAA,IAAK,CAAA,OAAA,EAAU,MAAM,CAAA,CAAA;AAChD;AAWA,SAAS,cAAc,IAAA,EAAgC;AACrD,EAAA,MAAM,KAAA,GAAkB,CAAC,CAAA,OAAA,EAAU,IAAA,CAAK,MAAM,CAAA,CAAE,CAAA;AAChD,EAAA,IAAI,KAAK,IAAA,EAAM,KAAA,CAAM,KAAK,CAAA,KAAA,EAAQ,IAAA,CAAK,IAAI,CAAA,CAAE,CAAA;AAC7C,EAAA,IAAI,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,IAAA,CAAK,KAAK,OAAO,CAA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AAAA,MACnB,WAAW,OAAA,CAAQ,SAAA;AAAA,MACnB,SAAS,OAAA,CAAQ;AAAA,KAClB,CAAA;AACD,IAAA,IAAA,CAAK,YAAA,GAAe,IAAI,mBAAA,CAAoB,SAAS,CAAA;AACrD,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,gBAAA,CAAiB,SAAS,CAAA;AAC/C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,YAAA,CAAa,SAAS,CAAA;AACvC,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,cAAA,CAAe,SAAS,CAAA;AAAA,EAC7C;AACF","file":"index.js","sourcesContent":["// Error types for the Fuse SDK, mirroring sdks/go/errors.go: a structured\n// FuseApiError for non-2xx responses plus code-checking helpers, and a\n// FuseError for transport/configuration failures.\n\nconst REQUEST_ID_HEADER = \"X-Request-ID\";\n\n/** Stable, machine-readable error codes returned by the server. */\nexport const ErrorCode = {\n NotFound: \"not_found\",\n Conflict: \"conflict\",\n InvalidArgument: \"invalid_argument\",\n Unavailable: \"unavailable\",\n Internal: \"internal\",\n Unauthorized: \"unauthorized\",\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nconst STATUS_TEXT: Record<number, string> = {\n 400: \"bad request\",\n 401: \"unauthorized\",\n 403: \"forbidden\",\n 404: \"not found\",\n 409: \"conflict\",\n 500: \"internal server error\",\n 502: \"bad gateway\",\n 503: \"service unavailable\",\n};\n\nfunction statusText(status: number): string {\n return STATUS_TEXT[status] ?? `status ${status}`;\n}\n\nexport interface FuseApiErrorInit {\n status: number;\n code?: string;\n message?: string;\n details?: Record<string, string>;\n requestId?: string;\n body?: string;\n}\n\nfunction formatMessage(init: FuseApiErrorInit): string {\n const parts: string[] = [`status=${init.status}`];\n if (init.code) parts.push(`code=${init.code}`);\n if (init.message) parts.push(init.message);\n else parts.push(statusText(init.status));\n if (init.requestId) parts.push(`request_id=${init.requestId}`);\n return \"fuse api error: \" + parts.join(\", \");\n}\n\n/** FuseApiError is a non-2xx response from the server. */\nexport class FuseApiError extends Error {\n readonly status: number;\n readonly code: string;\n readonly details?: Record<string, string>;\n readonly requestId?: string;\n /** Raw response body, when available. */\n readonly body?: string;\n\n constructor(init: FuseApiErrorInit) {\n super(formatMessage(init));\n this.name = \"FuseApiError\";\n this.status = init.status;\n this.code = init.code ?? \"\";\n this.details = init.details;\n this.requestId = init.requestId;\n this.body = init.body;\n // Restore the prototype chain so `instanceof` works after transpilation.\n Object.setPrototypeOf(this, FuseApiError.prototype);\n }\n}\n\n/** FuseError is a transport, configuration, or decoding failure (not an API error). */\nexport class FuseError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = \"FuseError\";\n Object.setPrototypeOf(this, FuseError.prototype);\n }\n}\n\n/** isFuseApiError is a type guard for FuseApiError. */\nexport function isFuseApiError(err: unknown): err is FuseApiError {\n return err instanceof FuseApiError;\n}\n\nfunction hasCode(err: unknown, code: string): boolean {\n return isFuseApiError(err) && err.code === code;\n}\n\n/** isNotFound reports whether err is a not_found api error. */\nexport function isNotFound(err: unknown): boolean {\n return hasCode(err, ErrorCode.NotFound);\n}\n\n/** isConflict reports whether err is a conflict api error. */\nexport function isConflict(err: unknown): boolean {\n return hasCode(err, ErrorCode.Conflict);\n}\n\n/** isUnauthorized reports whether err is an unauthorized api error. */\nexport function isUnauthorized(err: unknown): boolean {\n return hasCode(err, ErrorCode.Unauthorized);\n}\n\n/** isInvalidArgument reports whether err is an invalid_argument api error. */\nexport function isInvalidArgument(err: unknown): boolean {\n return hasCode(err, ErrorCode.InvalidArgument);\n}\n\n/** isUnavailable reports whether err is an unavailable api error. */\nexport function isUnavailable(err: unknown): boolean {\n return hasCode(err, ErrorCode.Unavailable);\n}\n\ninterface ErrorEnvelope {\n error?: {\n code?: string;\n message?: string;\n details?: Record<string, string>;\n };\n}\n\nfunction parseApiError(\n status: number,\n requestId: string | undefined,\n body: string,\n): FuseApiError {\n if (body) {\n try {\n const env = JSON.parse(body) as ErrorEnvelope;\n const e = env?.error;\n if (e && (e.code || e.message)) {\n return new FuseApiError({\n status,\n code: e.code,\n message: e.message,\n details: e.details,\n requestId,\n body,\n });\n }\n } catch {\n // fall through to the status-text error below\n }\n }\n return new FuseApiError({ status, message: statusText(status), requestId, body });\n}\n\n/**\n * errorFromResponse builds a FuseApiError from a non-2xx Response, parsing the\n * `{\"error\":{code,message,details}}` envelope and reading the X-Request-ID\n * response header for correlation.\n */\nexport async function errorFromResponse(res: Response): Promise<FuseApiError> {\n const requestId = res.headers.get(REQUEST_ID_HEADER) ?? undefined;\n let body = \"\";\n try {\n body = await res.text();\n } catch (err) {\n return new FuseApiError({\n status: res.status,\n message: `read error body: ${String(err)}`,\n requestId,\n });\n }\n return parseApiError(res.status, requestId, body);\n}\n","// The transport layer: builds requests (URL, headers, auth, X-Request-ID,\n// JSON body), applies an optional client-default timeout, executes fetch, and\n// turns non-2xx responses into FuseApiError. Mirrors the transport in\n// sdks/go/environments.go. SSE streams use stream() which deliberately applies\n// no timeout (the Go SDK uses a separate Timeout:0 client for events).\n\nimport { FuseError, errorFromResponse } from \"./errors.js\";\n\nconst REQUEST_ID_HEADER = \"X-Request-ID\";\n\n/** A minimal fetch signature, satisfied by the global fetch and most polyfills. */\nexport type FetchLike = (input: string | URL, init?: RequestInit) => Promise<Response>;\n\n/** Per-call options accepted by every service method. */\nexport interface CallOptions {\n /** Abort the request (and, for events, the stream). */\n signal?: AbortSignal;\n}\n\nexport interface TransportConfig {\n baseUrl: string;\n token?: string;\n fetch?: FetchLike;\n userAgent?: string;\n requestId?: () => string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n}\n\ntype Query = Record<string, string | undefined>;\n\ninterface RequestSpec {\n query?: Query;\n body?: unknown;\n signal?: AbortSignal;\n}\n\n/** Combine zero or more AbortSignals into one, without relying on AbortSignal.any (Node 20+). */\nfunction combineSignals(signals: Array<AbortSignal | undefined>): {\n signal?: AbortSignal;\n cleanup: () => void;\n} {\n const active = signals.filter((s): s is AbortSignal => s != null);\n if (active.length === 0) return { cleanup: () => {} };\n if (active.length === 1) return { signal: active[0], cleanup: () => {} };\n\n const controller = new AbortController();\n const onAbort = (event: Event) => {\n const target = event.target as AbortSignal;\n controller.abort(target.reason);\n cleanup();\n };\n const cleanup = () => {\n for (const s of active) s.removeEventListener(\"abort\", onAbort);\n };\n for (const s of active) {\n if (s.aborted) {\n controller.abort(s.reason);\n cleanup();\n return { signal: controller.signal, cleanup: () => {} };\n }\n s.addEventListener(\"abort\", onAbort);\n }\n return { signal: controller.signal, cleanup };\n}\n\nexport class Transport {\n private readonly baseUrl: URL;\n private readonly token?: string;\n private readonly fetchImpl: FetchLike;\n private readonly userAgent?: string;\n private readonly requestId?: () => string;\n private readonly timeoutMs?: number;\n private readonly defaultHeaders?: Record<string, string>;\n\n constructor(cfg: TransportConfig) {\n if (!cfg.baseUrl) {\n throw new FuseError(\"base url is required\");\n }\n let parsed: URL;\n try {\n parsed = new URL(cfg.baseUrl);\n } catch {\n throw new FuseError(\"base url is invalid\");\n }\n this.baseUrl = parsed;\n this.token = cfg.token;\n this.userAgent = cfg.userAgent;\n this.requestId = cfg.requestId;\n this.timeoutMs = cfg.timeoutMs;\n this.defaultHeaders = cfg.headers;\n\n const provided = cfg.fetch;\n if (provided) {\n this.fetchImpl = provided;\n } else if (typeof globalThis.fetch === \"function\") {\n this.fetchImpl = globalThis.fetch.bind(globalThis) as FetchLike;\n } else {\n throw new FuseError(\n \"global fetch is not available; pass a fetch implementation via the `fetch` option (Node 18+ required)\",\n );\n }\n }\n\n /** Perform a request and decode a JSON response body. */\n async json<T>(method: string, path: string, spec: RequestSpec = {}): Promise<T> {\n const { signal: combined, cleanup } = this.withTimeout(spec.signal);\n try {\n const res = await this.execute(method, path, spec, combined);\n if (!res.ok) throw await errorFromResponse(res);\n return await this.decodeJson<T>(res);\n } finally {\n cleanup();\n }\n }\n\n /** Perform a request that returns no body (e.g. 204 actions). */\n async noContent(method: string, path: string, spec: RequestSpec = {}): Promise<void> {\n const { signal: combined, cleanup } = this.withTimeout(spec.signal);\n try {\n const res = await this.execute(method, path, spec, combined);\n if (!res.ok) throw await errorFromResponse(res);\n // Release the connection even if the server sent a body.\n await res.body?.cancel().catch(() => {});\n } finally {\n cleanup();\n }\n }\n\n /**\n * Open a long-lived stream (SSE). Applies NO timeout — only the caller's\n * signal cancels it — and checks the status eagerly so connect-time errors\n * (404/401/...) surface as a FuseApiError before any iteration.\n */\n async stream(\n path: string,\n query: Query | undefined,\n signal?: AbortSignal,\n ): Promise<Response> {\n const res = await this.execute(\n \"GET\",\n path,\n { query, signal },\n signal,\n \"text/event-stream\",\n );\n if (!res.ok) throw await errorFromResponse(res);\n return res;\n }\n\n private async execute(\n method: string,\n path: string,\n spec: RequestSpec,\n signal: AbortSignal | undefined,\n accept?: string,\n ): Promise<Response> {\n const url = this.buildUrl(path, spec.query);\n const hasBody = spec.body !== undefined && spec.body !== null;\n const headers = this.buildHeaders(hasBody, accept);\n const init: RequestInit = { method, headers };\n if (hasBody) init.body = JSON.stringify(spec.body);\n if (signal) init.signal = signal;\n\n try {\n return await this.fetchImpl(url, init);\n } catch (err) {\n // A caller- or timeout-initiated abort propagates as-is; everything else\n // is wrapped so consumers get a consistent FuseError with a cause.\n if (signal?.aborted) throw err;\n throw new FuseError(`request failed: ${method} ${url}`, { cause: err });\n }\n }\n\n private buildUrl(path: string, query?: Query): string {\n const p = path.startsWith(\"/\") ? path : \"/\" + path;\n const u = new URL(p, this.baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined && value !== \"\") u.searchParams.set(key, value);\n }\n }\n return u.toString();\n }\n\n private buildHeaders(hasBody: boolean, accept?: string): Record<string, string> {\n const headers: Record<string, string> = { ...(this.defaultHeaders ?? {}) };\n if (hasBody) headers[\"Content-Type\"] = \"application/json\";\n if (this.token) headers[\"Authorization\"] = `Bearer ${this.token}`;\n if (this.userAgent) headers[\"User-Agent\"] = this.userAgent;\n if (this.requestId) {\n const id = this.requestId();\n if (id) headers[REQUEST_ID_HEADER] = id;\n }\n if (accept) headers[\"Accept\"] = accept;\n return headers;\n }\n\n private async decodeJson<T>(res: Response): Promise<T> {\n const text = await res.text();\n if (!text) return undefined as T;\n try {\n return JSON.parse(text) as T;\n } catch (err) {\n throw new FuseError(\"decode response body\", { cause: err });\n }\n }\n\n private withTimeout(callerSignal?: AbortSignal): {\n signal?: AbortSignal;\n cleanup: () => void;\n } {\n const signals: Array<AbortSignal | undefined> = [callerSignal];\n if (this.timeoutMs && this.timeoutMs > 0) {\n signals.push(AbortSignal.timeout(this.timeoutMs));\n }\n return combineSignals(signals);\n }\n}\n","import { FuseError } from \"./errors.js\";\n\n/**\n * requireArg throws a FuseError when a required path argument is missing,\n * mirroring the Go SDK's \"<thing> is required\" guards.\n */\nexport function requireArg(value: string | undefined | null, name: string): string {\n if (!value) {\n throw new FuseError(`${name} is required`);\n }\n return value;\n}\n","// Wire types for the Fuse API. Field names match the JSON sent on the wire\n// (snake_case), so request/response bodies pass through JSON.stringify /\n// JSON.parse untouched — a faithful 1:1 mirror of the Go SDK's struct tags\n// (see sdks/go/types.go). List *options* (see each service) use camelCase\n// keys and are translated to snake_case query params by the service.\n\n/** Spec is the hardware/runtime spec for a microVM. */\nexport interface Spec {\n cpus?: number;\n ram_mb?: number;\n storage_gb?: number;\n gpus?: number;\n gpu_kind?: string;\n /** Requests fractional GPU allocation: a MIG profile in mig-parted\n * vocabulary (e.g. \"1g.10gb\"). When set, gpus counts MIG instances of this\n * profile rather than whole devices. */\n gpu_profile?: string;\n region?: string;\n /** Restricts scheduling to hosts of this CPU architecture (\"amd64\",\n * \"arm64\"). Omitted means any host. */\n arch?: string;\n max_runtime_seconds?: number;\n /** Destroys the environment after this many seconds with no exec and no\n * attach session. Omitted or 0 means no idle expiry. Unlike\n * max_runtime_seconds (a ceiling measured from create), this is measured\n * from the last exec or attach. */\n idle_timeout_seconds?: number;\n image?: string;\n /** Pins the environment to an exact host id (the Fusefile's\n * placement.host). The pinned host still has to be active, run the right\n * backend, and fit the request. */\n host_id?: string;\n /** Placement label selectors (the Fusefile's placement.labels): every pair\n * must match the target host's declared labels. */\n labels?: Record<string, string>;\n}\n\n/** ExposeSpec requests that a guest port be published at boot. */\nexport interface ExposeSpec {\n port: number;\n as?: string;\n}\n\n/** Endpoint is a published port with its externally reachable URL. */\nexport interface Endpoint {\n as?: string;\n url: string;\n port: number;\n}\n\n/** HealthcheckHttp is an HTTP GET against a port inside the guest. The probe\n * runs in-guest, so the port needs no matching ExposeSpec. */\nexport interface HealthcheckHttp {\n port: number;\n /** Request path, which must start with a slash. Defaults to \"/\". */\n path?: string;\n}\n\n/**\n * HealthcheckSpec is the environment-level readiness probe (the Fusefile's\n * `healthcheck:` block). Exactly one of http and exec must be set; the server\n * rejects a request that sets both or neither.\n *\n * It is not the per-service compose healthcheck that can appear inside a\n * manifest: that one governs a single container and never reaches the control\n * plane. This one is evaluated by the guest agent over the environment as a\n * whole and its verdict comes back on EnvironmentInfo.health.\n *\n * Every duration is in seconds, and 0 means \"omitted, use the guest agent's\n * default\". The server substitutes no defaults of its own, because the probe\n * executes in the guest.\n */\nexport interface HealthcheckSpec {\n http?: HealthcheckHttp;\n /** An argv run inside the guest. Exit status 0 passes. */\n exec?: string[];\n /** Seconds between attempts. 0 for the guest agent default (10s). */\n interval_seconds?: number;\n /** Bound on one attempt, in seconds. 0 for the guest agent default (2s).\n * Attempts run one at a time, so a value above interval_seconds is\n * rejected rather than silently stretching the interval. */\n timeout_seconds?: number;\n /** Consecutive failures that flip the verdict to failing. 0 for the guest\n * agent default (3). */\n retries?: number;\n /** Grace window from the first attempt during which failures are not\n * counted. It ends for good once the probe passes once. */\n start_period_seconds?: number;\n}\n\n/**\n * DesktopSpec is the geometry of the environment's graphical session (the\n * Fusefile's `desktop:` block). It requires an image that carries the desktop\n * stack; on any other image the declaration is inert and the computer surface\n * reports the display as absent.\n *\n * Both fields are required, 320 to 3840 each: a guessed dimension would\n * silently shift every coordinate a computer-use model emits.\n */\nexport interface DesktopSpec {\n /** Display width in pixels. */\n width: number;\n /** Display height in pixels. */\n height: number;\n}\n\n/**\n * ComputerAction is one computer-use action, in the same shape Anthropic's\n * computer tool emits as tool_use input, so translating a tool_use block into\n * a call is mechanical. Only action is required; which other fields apply\n * depends on the action, and the guest agent enforces the full schema.\n */\nexport interface ComputerAction {\n /** The action to perform, e.g. \"screenshot\", \"left_click\", \"type\", \"key\",\n * \"scroll\", \"zoom\". */\n action: string;\n /** [x, y] target for pointer actions. */\n coordinate?: number[];\n /** [x, y] origin for left_click_drag. */\n start_coordinate?: number[];\n /** The payload for type, the keysym combo for key/hold_key, or modifiers\n * held during a click action. */\n text?: string;\n /** [x1, y1, x2, y2] crop for zoom. */\n region?: number[];\n /** Seconds for hold_key and wait, capped guest-side at 100. */\n duration?: number;\n scroll_direction?: \"up\" | \"down\" | \"left\" | \"right\";\n /** Wheel clicks for scroll, 1 to 100. */\n scroll_amount?: number;\n}\n\n/**\n * ComputerResult is the guest's answer to one action. screenshot is a base64\n * PNG, present on every action that implies one; for zoom it is the cropped\n * region at full resolution.\n */\nexport interface ComputerResult {\n output?: string;\n screenshot?: string;\n}\n\n/**\n * ComputerDisplay reports the environment's display: whether it is up and at\n * what geometry, so a caller can populate display_width_px /\n * display_height_px in its computer tool definition without hardcoding them.\n */\nexport interface ComputerDisplay {\n display?: string;\n up: boolean;\n /** Live display width in pixels, 0 when the display is down. */\n width: number;\n /** Live display height in pixels, 0 when the display is down. */\n height: number;\n /** Why the display is down, when it is. */\n error?: string;\n}\n\n/** ToolResultImageSource is a Messages-API base64 image source. */\nexport interface ToolResultImageSource {\n type: \"base64\";\n media_type: \"image/png\";\n data: string;\n}\n\n/**\n * ToolResultBlock is one content block of a Messages API tool_result. The\n * field names match the Messages API, so the blocks can be sent back verbatim\n * as the tool_result content.\n */\nexport interface ToolResultBlock {\n type: \"text\" | \"image\";\n text?: string;\n source?: ToolResultImageSource;\n}\n\n/**\n * ComputerToolResult is what goes back to Claude for one computer tool_use:\n * the content blocks and whether they describe an error. Map it onto the\n * tool_result block for the tool_use's id and the loop is closed.\n */\nexport interface ComputerToolResult {\n content: ToolResultBlock[];\n is_error?: boolean;\n}\n\n/**\n * Health is the last verdict of an environment's healthcheck.\n *\n * It is deliberately not folded into EnvironmentInfo.state: that vocabulary is\n * a closed set clients reason about, and an unhealthy environment is still a\n * running one. Nothing tears an environment down for a failing probe.\n */\nexport interface Health {\n /** \"starting\", \"passing\" or \"failing\". */\n state: string;\n /** When the probe entered this state. */\n since?: string;\n /** Consecutive failed attempts. Zero while passing. */\n failures?: number;\n /** The last attempt's failure detail. Empty while passing. */\n message?: string;\n}\n\n/** CreateRequest is the body for environments.create. */\nexport interface CreateRequest {\n task_id: string;\n spec?: Spec;\n manifest_inline?: string;\n secrets?: Record<string, string>;\n startup_script?: string;\n /**\n * Guest files written before the startup script runs, keyed by absolute\n * guest path with base64-encoded content. What a Fusefile's `copy` block\n * compiles to. Paths under /fuse are rejected, the total decoded size is\n * capped at 512 KiB, and permissions are not carried.\n */\n files?: Record<string, string>;\n gateway_url?: string;\n gateway_token?: string;\n expose?: ExposeSpec[];\n /** Environment-level readiness probe. Omit it for an environment with no\n * probe, in which case EnvironmentInfo.health is never populated. It is not\n * evaluated inside create: the call returns as soon as the VM is up, and\n * the verdict arrives on later reads. */\n healthcheck?: HealthcheckSpec;\n /** Graphical session geometry. Omit it for an environment with no desktop,\n * in which case a desktop image keeps its baked default geometry. */\n desktop?: DesktopSpec;\n}\n\n/** EnvironmentInfo is the server's view of a single microVM. */\nexport interface EnvironmentInfo {\n id: string;\n state: string;\n task_id: string;\n host_id?: string;\n url: string;\n spec: Spec;\n created_at: string;\n updated_at: string;\n error?: string;\n endpoints?: Endpoint[];\n /** Last verdict of the environment-level healthcheck. Absent when the\n * environment declared no healthcheck, and absent until the first verdict\n * has been read back from the guest. The server refreshes it on its\n * reconcile tick (30s by default), so it lags the guest by up to a tick. */\n health?: Health;\n}\n\n/** ForkOptions is the optional body for environments.fork. */\nexport interface ForkOptions {\n reuse_snapshot_id?: string;\n comment?: string;\n}\n\n/** ExecRequest is the body for environments.exec. Exactly one of cmd or shell must be set. */\nexport interface ExecRequest {\n /**\n * The argv to run in the guest, e.g. [\"ls\", \"-l\"]. Argv needs no quoting\n * rules and cannot be turned into an injection by interpolating a value, so\n * prefer it.\n */\n cmd?: string[];\n\n /**\n * Runs the string under `sh -lc`. Use it only for what argv cannot express:\n * pipelines, redirects, and globs.\n */\n shell?: string;\n\n /**\n * Bounds the command inside the guest. Zero or unset takes the server\n * default; the server clamps anything above its ceiling.\n */\n timeout_ms?: number;\n}\n\n/**\n * ExecResult is the outcome of a guest command.\n *\n * A non-zero exit_code is a successful call: the command ran and failed. Only a\n * thrown error means the command could not be run at all.\n */\nexport interface ExecResult {\n exit_code: number;\n stdout: string;\n stderr: string;\n}\n\n/**\n * Event is one item from environments.events. It matches the server's SSE\n * wire payload. Stream-level failures are thrown from the async iterator\n * rather than delivered as an in-band event.\n */\nexport interface Event {\n id: string;\n /** Event kind: \"state\" (an omitted kind means \"state\") or \"step\". */\n event: string;\n vm_id: string;\n state: string;\n url?: string;\n error?: string;\n updated_at: string;\n /** index of the setup step, 1-based. step events only. */\n index?: number;\n /** total number of setup steps. step events only. */\n total?: number;\n /** layer cache key for the step. step events only. */\n key?: string;\n /** whether the step was served from the layer cache. step events only. */\n cached?: boolean;\n /** why the step missed the cache. step events only. */\n miss_reason?: string;\n /** what changed, e.g. the input paths. step events only. */\n miss_detail?: string[];\n /** wall-clock duration of the step in milliseconds. step events only. */\n duration_ms?: number;\n /** exit code of the step. step events only. */\n exit_code?: number;\n}\n\n/** SnapshotRequest is the optional body for snapshots.create. */\nexport interface SnapshotRequest {\n comment?: string;\n mode?: string;\n retention_seconds?: number;\n metadata?: Record<string, string>;\n export_ref?: string;\n export_status?: string;\n /** Labels this snapshot as the artifact of one cacheable setup step, which is\n * what makes it findable by recipe rather than by its random id. Empty for an\n * ordinary snapshot. The scope it is filed under comes from how the caller\n * authenticated and is not settable here. */\n layer_key?: string;\n}\n\n/** ResolveSnapshotResponse is the wire envelope for a layer lookup. Internal:\n * resolve() returns Snapshot | null so the found flag never reaches callers. */\nexport interface ResolveSnapshotResponse {\n found: boolean;\n snapshot?: Snapshot;\n}\n\n/** SnapshotExport is an optional exported snapshot artifact. */\nexport interface SnapshotExport {\n destination: string;\n status?: string;\n requested_at?: string;\n updated_at?: string;\n last_error?: string;\n}\n\n/** Snapshot is a persisted snapshot record. */\nexport interface Snapshot {\n id: string;\n vm_id: string;\n task_id?: string;\n tenant_id?: string;\n parent_snapshot_id?: string;\n mode?: string;\n state?: string;\n comment?: string;\n /** The content-addressed cache key of the setup step this artifact was\n * taken after. Absent on anything that is not a build layer, and an empty\n * key never matches a lookup. */\n layer_key?: string;\n /** CPU architecture, in GOARCH vocabulary (\"amd64\", \"arm64\"), of the host\n * that actually built the artifact rather than of whoever asked for it. A\n * rootfs is not portable across architectures, so this is a real constraint\n * on whether the artifact can be booted; it is deliberately not folded into\n * layer_key, so a lookup has to filter on it separately. */\n arch?: string;\n /** Hex sha256 of the artifact rootfs. It verifies that a given copy of\n * those bytes is intact, and nothing more: it is not a cross-build\n * identity, because two builds of the same recipe produce different rootfs\n * bytes (timestamps, inode ordering, package caches). It can never be used\n * as a cache key. */\n digest?: string;\n size_bytes?: number;\n created_at: string;\n updated_at?: string;\n retention_until?: string;\n last_error?: string;\n export_ref?: string;\n exports?: SnapshotExport[];\n}\n\n/** HostCapacity is a host's resource envelope. */\nexport interface HostCapacity {\n cpus: number;\n ram_mb: number;\n storage_gb: number;\n vm_count: number;\n /** The host's CPU architecture in GOARCH vocabulary (\"amd64\", \"arm64\").\n * Omitted means amd64 (hosts registered before arch existed). */\n arch?: string;\n gpus?: number;\n gpu_kind?: string;\n /** Fractional GPU capacity: MIG instance count by profile name (e.g.\n * {\"1g.10gb\": 4}). Like gpus, it requires backend \"qemu\". When the host\n * reports per-instance MIG inventory (mig_instances), this map is a derived\n * summary; otherwise it is the scheduling unit. */\n mig_profiles?: Record<string, number>;\n /** Per-instance MIG inventory probed from the host agent (one entry per\n * carved MIG GPU instance). When non-empty, the orchestrator binds specific\n * instance uuids to VMs instead of decrementing a count. Strictly additive:\n * a host that reports no instances falls back to mig_profiles. Only\n * populated on capacity (not allocated) for qemu hosts. */\n mig_instances?: MIGInstance[];\n /** The set of MIG instance uuids currently bound to VMs. Populated only on\n * allocated, and only for hosts that report per-instance MIG inventory. */\n mig_instance_uuids?: string[];\n /** Per-device GPU detail probed from the host agent, carried alongside the\n * scalar gpus/gpu_kind counters. Only populated on capacity (not\n * allocated) for qemu hosts. */\n gpu_devices?: GPUDevice[];\n}\n\n/** GPUDevice is the per-device detail probed for a single GPU. Every field is\n * best-effort and omitted when the host agent could not determine it. */\nexport interface GPUDevice {\n uuid?: string;\n model?: string;\n pci_bus_id?: string;\n memory_mb?: number;\n driver_version?: string;\n cuda_version?: string;\n compute_cap?: string;\n mig_capable?: boolean;\n mig_mode?: string;\n iommu_group?: string;\n}\n\n/** MIGInstance is one carved MIG GPU instance probed from the host agent. The\n * orchestrator binds a specific instance uuid to a VM so it knows which\n * instance went to which VM. */\nexport interface MIGInstance {\n uuid?: string;\n profile?: string;\n kind?: string;\n parent_gpu_uuid?: string;\n}\n\n/** RegisterHostRequest is the body for hosts.register. */\nexport interface RegisterHostRequest {\n id: string;\n url: string;\n token?: string;\n region?: string;\n backend?: string;\n /** Operator-declared key/value pairs matched against a spec's placement\n * label selectors. Never probed from the host agent. */\n labels?: Record<string, string>;\n capacity?: HostCapacity;\n}\n\n/** Host is the server's view of a registered host. */\nexport interface Host {\n id: string;\n url: string;\n region?: string;\n state: string;\n backend?: string;\n labels?: Record<string, string>;\n capacity: HostCapacity;\n allocated: HostCapacity;\n last_seen: string;\n created_at: string;\n updated_at: string;\n /** Non-fatal registration notices (e.g. declared capacity exceeding the\n * probed value). Only ever populated on the response to hosts.register. */\n warnings?: string[];\n}\n\n/**\n * APIKey is a key's metadata. The raw secret appears only in\n * CreatedAPIKey.key, returned once at creation.\n */\nexport interface APIKey {\n id: string;\n label?: string;\n created_at: string;\n last_used_at?: string;\n revoked_at?: string;\n}\n\n/**\n * CreatedAPIKey is returned by apiKeys.create. `key` is the raw secret and is\n * unrecoverable after this response.\n */\nexport interface CreatedAPIKey extends APIKey {\n key: string;\n}\n\n/** Lifecycle states for EnvironmentInfo.state and Event.state. */\nexport const State = {\n Provisioning: \"provisioning\",\n Running: \"running\",\n Draining: \"draining\",\n Destroying: \"destroying\",\n Destroyed: \"destroyed\",\n Failed: \"failed\",\n} as const;\n\nexport type State = (typeof State)[keyof typeof State];\n\n/** isTerminalState reports whether state is a terminal lifecycle state. */\nexport function isTerminalState(state: string): boolean {\n return state === State.Destroyed || state === State.Failed;\n}\n\n/**\n * Verdicts carried in Health.state. Separate from State on purpose: a failing\n * probe reports, it does not move the environment anywhere new.\n */\nexport const HealthState = {\n /** The probe has not passed yet and is still inside its start period, so\n * failures are not being counted. */\n Starting: \"starting\",\n /** The most recent attempt succeeded. */\n Passing: \"passing\",\n /** The probe failed its configured retries in a row after the start period\n * ended. */\n Failing: \"failing\",\n} as const;\n\nexport type HealthState = (typeof HealthState)[keyof typeof HealthState];\n","// SSE event streaming, porting the state machine in sdks/go/events.go to an\n// async iterator. The stream is opened (and its status checked) eagerly; the\n// returned AsyncIterable yields each Event and ends after a terminal-state\n// event (destroyed/failed) or on clean EOF. Stream-level failures are thrown\n// from the iterator. Caller abort is treated as normal termination.\n\nimport type { Transport } from \"./transport.js\";\nimport { FuseError } from \"./errors.js\";\nimport { type Event, isTerminalState } from \"./types.js\";\n\nconst DATA_PREFIX = \"data:\";\n\n/** Open the SSE stream for an environment and return an async-iterable of events. */\nexport async function streamEvents(\n t: Transport,\n vmId: string,\n signal?: AbortSignal,\n): Promise<AsyncIterable<Event>> {\n const path = `/v1/environments/${encodeURIComponent(vmId)}/events`;\n const res = await t.stream(path, undefined, signal);\n return parseEventStream(res, signal);\n}\n\nfunction parseEventStream(res: Response, signal?: AbortSignal): AsyncIterable<Event> {\n return {\n async *[Symbol.asyncIterator](): AsyncGenerator<Event> {\n const body = res.body;\n if (!body) return;\n\n const reader = body.getReader();\n const decoder = new TextDecoder(\"utf-8\");\n let buffer = \"\";\n let data = \"\";\n let hasData = false;\n\n try {\n while (true) {\n let chunk;\n try {\n chunk = await reader.read();\n } catch (err) {\n // Caller-initiated abort is a clean end, not an error.\n if (signal?.aborted) return;\n throw new FuseError(\"event stream read failed\", { cause: err });\n }\n if (chunk.done) {\n // Clean EOF with no terminal state: just end (matches Go).\n return;\n }\n\n buffer += decoder.decode(chunk.value, { stream: true });\n\n let nl: number;\n while ((nl = buffer.indexOf(\"\\n\")) >= 0) {\n let line = buffer.slice(0, nl);\n buffer = buffer.slice(nl + 1);\n if (line.endsWith(\"\\r\")) line = line.slice(0, -1); // tolerate CRLF\n\n if (line === \"\") {\n // Blank line terminates the current event.\n if (!hasData) continue;\n const payload = data;\n data = \"\";\n hasData = false;\n\n let event: Event;\n try {\n event = JSON.parse(payload) as Event;\n } catch (err) {\n throw new FuseError(\"decode event\", { cause: err });\n }\n yield event;\n if (isTerminalState(event.state)) return;\n } else if (line.startsWith(\":\")) {\n // Comment / keepalive line — skip.\n continue;\n } else if (line.startsWith(DATA_PREFIX)) {\n // Strip the prefix and a single optional leading space; multiple\n // data: lines concatenate without a separator (matches server).\n let p = line.slice(DATA_PREFIX.length);\n if (p.startsWith(\" \")) p = p.slice(1);\n data += p;\n hasData = true;\n }\n // Other fields (id:, event:, ...) are ignored.\n }\n }\n } finally {\n // Release the underlying socket if the consumer breaks early.\n try {\n await reader.cancel();\n } catch {\n // ignore\n }\n }\n },\n };\n}\n","import type { CallOptions, Transport } from \"./transport.js\";\nimport type {\n ComputerAction,\n ComputerDisplay,\n ComputerResult,\n ComputerToolResult,\n CreateRequest,\n EnvironmentInfo,\n Event,\n ExecRequest,\n ExecResult,\n ForkOptions,\n ToolResultBlock,\n} from \"./types.js\";\nimport { FuseError, isFuseApiError } from \"./errors.js\";\nimport { requireArg } from \"./validate.js\";\nimport { streamEvents } from \"./events.js\";\n\n/** The server's max page size; list() requests this internally so it walks\n * every page in as few round trips as possible. */\nconst MAX_PAGE_LIMIT = 200;\n\n/** Filters (and pagination) for environments.list / environments.listPage. */\nexport interface ListEnvironmentsOptions {\n taskId?: string;\n state?: string;\n hostId?: string;\n /** Page size (server default 50, max 200). Only consulted by listPage —\n * list() always walks every page, so it ignores this and requests the\n * server's max page size. */\n limit?: number;\n /** Opaque cursor from a previous listPage() call's nextCursor. */\n cursor?: string;\n}\n\ninterface EnvironmentList {\n environments: EnvironmentInfo[];\n next_cursor?: string;\n}\n\n/** One page of environments.listPage, plus the cursor to fetch the next one. */\nexport interface EnvironmentPage {\n environments: EnvironmentInfo[];\n /** Empty/undefined once there are no more results. */\n nextCursor?: string;\n}\n\n/** EnvironmentsService manages microVM lifecycle. */\nexport class EnvironmentsService {\n constructor(private readonly t: Transport) {}\n\n /** List tracked environments, optionally filtered. Transparently walks\n * every result page. For explicit single-page control (e.g. a cursor from\n * a previous call), use listPage. */\n async list(\n options: ListEnvironmentsOptions = {},\n opts: CallOptions = {},\n ): Promise<EnvironmentInfo[]> {\n const out: EnvironmentInfo[] = [];\n let cursor = options.cursor;\n for (;;) {\n const page = await this.listPage(\n { ...options, limit: MAX_PAGE_LIMIT, cursor },\n opts,\n );\n out.push(...page.environments);\n if (!page.nextCursor) break;\n cursor = page.nextCursor;\n }\n return out;\n }\n\n /** List one page of tracked environments, optionally filtered. */\n async listPage(\n options: ListEnvironmentsOptions = {},\n opts: CallOptions = {},\n ): Promise<EnvironmentPage> {\n const out = await this.t.json<EnvironmentList>(\"GET\", \"/v1/environments\", {\n query: {\n task_id: options.taskId,\n state: options.state,\n host_id: options.hostId,\n limit: options.limit ? String(options.limit) : undefined,\n cursor: options.cursor,\n },\n signal: opts.signal,\n });\n return { environments: out.environments ?? [], nextCursor: out.next_cursor };\n }\n\n /** Fetch a single environment by VM id. */\n async get(vmId: string, opts: CallOptions = {}): Promise<EnvironmentInfo> {\n requireArg(vmId, \"vm id\");\n return this.t.json<EnvironmentInfo>(\n \"GET\",\n `/v1/environments/${encodeURIComponent(vmId)}`,\n { signal: opts.signal },\n );\n }\n\n /** Provision a new environment. Blocks until running or creation fails. */\n async create(body: CreateRequest, opts: CallOptions = {}): Promise<EnvironmentInfo> {\n return this.t.json<EnvironmentInfo>(\"POST\", \"/v1/environments\", {\n body,\n signal: opts.signal,\n });\n }\n\n /** Fork an environment into a new one; returns the new environment. */\n async fork(\n vmId: string,\n body: ForkOptions = {},\n opts: CallOptions = {},\n ): Promise<EnvironmentInfo> {\n requireArg(vmId, \"vm id\");\n return this.t.json<EnvironmentInfo>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}`,\n { query: { action: \"fork\" }, body, signal: opts.signal },\n );\n }\n\n /**\n * Run a command inside a running environment's guest and return its exit code\n * with stdout and stderr kept separate.\n *\n * A non-zero exit_code is resolved, not thrown: the command ran and failed.\n * A thrown error means the command could not be run at all.\n *\n * Exec requires the master token.\n *\n * @example\n * const out = await client.environments.exec(id, { cmd: [\"ls\", \"-l\"] });\n * if (out.exit_code !== 0) console.error(out.stderr);\n */\n async exec(\n vmId: string,\n body: ExecRequest,\n opts: CallOptions = {},\n ): Promise<ExecResult> {\n requireArg(vmId, \"vm id\");\n const hasCmd = (body.cmd?.length ?? 0) > 0;\n const hasShell = (body.shell ?? \"\") !== \"\";\n if (!hasCmd && !hasShell) {\n throw new FuseError(\"one of cmd or shell is required\");\n }\n if (hasCmd && hasShell) {\n throw new FuseError(\"cmd and shell are mutually exclusive\");\n }\n return this.t.json<ExecResult>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}`,\n { query: { action: \"exec\" }, body, signal: opts.signal },\n );\n }\n\n /**\n * Relay one computer-use action to the environment's desktop and return the\n * result, usually carrying a base64 PNG screenshot. Requires an environment\n * booted from a desktop image; on any other image the server answers 503\n * with a reason.\n *\n * @example\n * const res = await client.environments.computer(id, {\n * action: \"left_click\",\n * coordinate: [512, 384],\n * });\n */\n async computer(\n vmId: string,\n action: ComputerAction,\n opts: CallOptions = {},\n ): Promise<ComputerResult> {\n requireArg(vmId, \"vm id\");\n requireArg(action?.action, \"action\");\n return this.t.json<ComputerResult>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}/computer`,\n { body: action, signal: opts.signal },\n );\n }\n\n /**\n * Execute one computer tool_use against the environment and shape the\n * answer for the Messages API: the tool_use block's `input` goes in\n * verbatim (it is already the wire shape the computer endpoint takes), and\n * content blocks for the tool_result come out.\n *\n * An action the environment refuses (a malformed coordinate, a display\n * that is not up) resolves to `is_error` content rather than throwing: the\n * agent loop should feed it to the model, which is the party that can\n * correct it. A throw is reserved for failures the model cannot fix —\n * transport, auth, an unknown environment.\n *\n * @example\n * for (const block of msg.content) {\n * if (block.type === \"tool_use\" && block.name === \"computer\") {\n * const result = await client.environments.computerToolResult(id, block.input);\n * toolResults.push({ type: \"tool_result\", tool_use_id: block.id, ...result });\n * }\n * }\n */\n async computerToolResult(\n vmId: string,\n input: unknown,\n opts: CallOptions = {},\n ): Promise<ComputerToolResult> {\n requireArg(vmId, \"vm id\");\n const action = (input as { action?: string } | null)?.action ?? \"\";\n if (action === \"\") {\n return {\n is_error: true,\n content: [{ type: \"text\", text: \"tool input names no action\" }],\n };\n }\n let res: ComputerResult;\n try {\n res = await this.t.json<ComputerResult>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}/computer`,\n { body: input, signal: opts.signal },\n );\n } catch (err) {\n if (\n isFuseApiError(err) &&\n (err.status === 400 || err.status === 409 || err.status === 503)\n ) {\n return {\n is_error: true,\n content: [{ type: \"text\", text: err.message || \"the computer action failed\" }],\n };\n }\n throw err;\n }\n const content: ToolResultBlock[] = [];\n if (res.output) content.push({ type: \"text\", text: res.output });\n if (res.screenshot) {\n content.push({\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: \"image/png\",\n data: res.screenshot,\n },\n });\n }\n if (content.length === 0) content.push({ type: \"text\", text: \"done\" });\n return { content };\n }\n\n /** Report whether the environment has a live display and at what geometry.\n * up is false with a reason on an image with no desktop. */\n async computerDisplay(vmId: string, opts: CallOptions = {}): Promise<ComputerDisplay> {\n requireArg(vmId, \"vm id\");\n return this.t.json<ComputerDisplay>(\n \"GET\",\n `/v1/environments/${encodeURIComponent(vmId)}/computer`,\n { signal: opts.signal },\n );\n }\n\n /**\n * Phase-1 only: quiesces the guest workload and moves the environment to\n * \"draining\" so you can inspect its output, but does not destroy it. Call\n * destroy() afterward to remove it - a drained environment left\n * undestroyed keeps running (and billing) forever.\n */\n async drain(vmId: string, opts: CallOptions = {}): Promise<EnvironmentInfo> {\n requireArg(vmId, \"vm id\");\n return this.t.json<EnvironmentInfo>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}`,\n { query: { action: \"drain\" }, signal: opts.signal },\n );\n }\n\n /** Rotate the per-VM credentials and push them to the guest. */\n async rotateToken(vmId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(vmId, \"vm id\");\n await this.t.noContent(\"POST\", `/v1/environments/${encodeURIComponent(vmId)}`, {\n query: { action: \"rotate-token\" },\n signal: opts.signal,\n });\n }\n\n /** Forcefully destroy an environment. Idempotent. */\n async destroy(vmId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(vmId, \"vm id\");\n await this.t.noContent(\"DELETE\", `/v1/environments/${encodeURIComponent(vmId)}`, {\n signal: opts.signal,\n });\n }\n\n /**\n * Open the SSE event stream for an environment. The returned promise rejects\n * with a FuseApiError on a connect-time failure (e.g. not_found); on success\n * it resolves to an AsyncIterable that yields each Event and ends after a\n * terminal-state event. Pass `opts.signal` to cancel; there is no built-in\n * timeout on the stream.\n *\n * @example\n * for await (const ev of await client.environments.events(id)) {\n * console.log(ev.state);\n * }\n */\n async events(vmId: string, opts: CallOptions = {}): Promise<AsyncIterable<Event>> {\n requireArg(vmId, \"vm id\");\n return streamEvents(this.t, vmId, opts.signal);\n }\n}\n","import type { CallOptions, Transport } from \"./transport.js\";\nimport type { ResolveSnapshotResponse, Snapshot, SnapshotRequest } from \"./types.js\";\nimport { requireArg } from \"./validate.js\";\n\n/** The server's max page size; list() requests this internally so it walks\n * every page in as few round trips as possible. */\nconst MAX_PAGE_LIMIT = 200;\n\n/** Filters (and pagination) for snapshots.list / snapshots.listPage. */\nexport interface ListSnapshotsOptions {\n vmId?: string;\n taskId?: string;\n tenantId?: string;\n state?: string;\n /** Narrows to the build layers taken after one setup step. Unset means \"do\n * not filter\", never \"match artifacts with no layer key\". */\n layerKey?: string;\n /** Narrows to artifacts built on one architecture, in GOARCH vocabulary\n * (\"amd64\", \"arm64\"). It is a separate filter from layerKey rather than\n * part of it because a rootfs is not portable across architectures, so a\n * layer lookup that does not constrain arch can be served bytes it cannot\n * boot. */\n arch?: string;\n /** Page size (server default 50, max 200). Only consulted by listPage —\n * list() always walks every page, so it ignores this and requests the\n * server's max page size. */\n limit?: number;\n /** Opaque cursor from a previous listPage() call's nextCursor. */\n cursor?: string;\n}\n\ninterface SnapshotList {\n snapshots: Snapshot[];\n next_cursor?: string;\n}\n\n/** One page of snapshots.listPage, plus the cursor to fetch the next one. */\nexport interface SnapshotPage {\n snapshots: Snapshot[];\n /** Empty/undefined once there are no more results. */\n nextCursor?: string;\n}\n\n/** SnapshotsService manages microVM snapshots. */\nexport class SnapshotsService {\n constructor(private readonly t: Transport) {}\n\n /** Create a snapshot of a running environment. */\n async create(\n vmId: string,\n body: SnapshotRequest = {},\n opts: CallOptions = {},\n ): Promise<Snapshot> {\n requireArg(vmId, \"vm id\");\n return this.t.json<Snapshot>(\n \"POST\",\n `/v1/environments/${encodeURIComponent(vmId)}/snapshots`,\n { body, signal: opts.signal },\n );\n }\n\n /** List snapshots, optionally filtered. Transparently walks every result\n * page. For explicit single-page control (e.g. a cursor from a previous\n * call), use listPage. */\n async list(\n options: ListSnapshotsOptions = {},\n opts: CallOptions = {},\n ): Promise<Snapshot[]> {\n const out: Snapshot[] = [];\n let cursor = options.cursor;\n for (;;) {\n const page = await this.listPage(\n { ...options, limit: MAX_PAGE_LIMIT, cursor },\n opts,\n );\n out.push(...page.snapshots);\n if (!page.nextCursor) break;\n cursor = page.nextCursor;\n }\n return out;\n }\n\n /** List one page of snapshots, optionally filtered. */\n async listPage(\n options: ListSnapshotsOptions = {},\n opts: CallOptions = {},\n ): Promise<SnapshotPage> {\n const out = await this.t.json<SnapshotList>(\"GET\", \"/v1/snapshots\", {\n query: {\n vm_id: options.vmId,\n task_id: options.taskId,\n tenant_id: options.tenantId,\n state: options.state,\n layer_key: options.layerKey,\n arch: options.arch,\n limit: options.limit ? String(options.limit) : undefined,\n cursor: options.cursor,\n },\n signal: opts.signal,\n });\n return { snapshots: out.snapshots ?? [], nextCursor: out.next_cursor };\n }\n\n /**\n * Resolve one layer cache key and architecture to the newest ready build\n * artifact, or null when there is none.\n *\n * A miss is not an error and never rejects: a cold cache is the normal state\n * of a first build, and modelling it as a failure would make every caller\n * wrap this in a try/catch to discover nothing was wrong.\n *\n * arch is required rather than defaulted. An ext4 rootfs is not portable\n * across architectures, so resolving without one could hand back an artifact\n * the caller cannot boot, at the exact moment it believes it got a hit.\n *\n * The scope searched comes from how the client authenticated; there is\n * deliberately no tenant parameter.\n */\n async resolve(\n layerKey: string,\n arch: string,\n opts: CallOptions = {},\n ): Promise<Snapshot | null> {\n requireArg(layerKey, \"layer key\");\n requireArg(arch, \"arch\");\n const out = await this.t.json<ResolveSnapshotResponse>(\n \"GET\",\n \"/v1/snapshots/resolve\",\n { query: { layer_key: layerKey, arch }, signal: opts.signal },\n );\n return out.found && out.snapshot ? out.snapshot : null;\n }\n\n /** Fetch a single snapshot by id. */\n async get(snapshotId: string, opts: CallOptions = {}): Promise<Snapshot> {\n requireArg(snapshotId, \"snapshot id\");\n return this.t.json<Snapshot>(\n \"GET\",\n `/v1/snapshots/${encodeURIComponent(snapshotId)}`,\n { signal: opts.signal },\n );\n }\n\n /** Delete a snapshot. Idempotent; the snapshot must be a leaf. */\n async delete(snapshotId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(snapshotId, \"snapshot id\");\n await this.t.noContent(\"DELETE\", `/v1/snapshots/${encodeURIComponent(snapshotId)}`, {\n signal: opts.signal,\n });\n }\n\n /** Restore an environment from a snapshot. */\n async restore(snapshotId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(snapshotId, \"snapshot id\");\n await this.t.noContent(\"POST\", `/v1/snapshots/${encodeURIComponent(snapshotId)}`, {\n query: { action: \"restore\" },\n signal: opts.signal,\n });\n }\n}\n","import type { CallOptions, Transport } from \"./transport.js\";\nimport type { Host, RegisterHostRequest } from \"./types.js\";\nimport { requireArg } from \"./validate.js\";\n\n/** The server's max page size; list() requests this internally so it walks\n * every page in as few round trips as possible. */\nconst MAX_PAGE_LIMIT = 200;\n\n/** Pagination for hosts.listPage. */\nexport interface ListHostsOptions {\n /** Page size (server default 50, max 200). */\n limit?: number;\n /** Opaque cursor from a previous listPage() call's nextCursor. */\n cursor?: string;\n}\n\ninterface HostList {\n hosts: Host[];\n next_cursor?: string;\n}\n\n/** One page of hosts.listPage, plus the cursor to fetch the next one. */\nexport interface HostPage {\n hosts: Host[];\n /** Empty/undefined once there are no more results. */\n nextCursor?: string;\n}\n\n/** HostsService manages registered Firecracker hosts. */\nexport class HostsService {\n constructor(private readonly t: Transport) {}\n\n /** Register (or re-register) a host. Idempotent on id. */\n async register(body: RegisterHostRequest, opts: CallOptions = {}): Promise<Host> {\n return this.t.json<Host>(\"POST\", \"/v1/hosts\", { body, signal: opts.signal });\n }\n\n /** List registered hosts. Transparently walks every result page. For\n * explicit single-page control (e.g. a cursor from a previous call), use\n * listPage. */\n async list(opts: CallOptions = {}): Promise<Host[]> {\n const out: Host[] = [];\n let cursor: string | undefined;\n for (;;) {\n const page = await this.listPage({ limit: MAX_PAGE_LIMIT, cursor }, opts);\n out.push(...page.hosts);\n if (!page.nextCursor) break;\n cursor = page.nextCursor;\n }\n return out;\n }\n\n /** List one page of registered hosts. */\n async listPage(\n options: ListHostsOptions = {},\n opts: CallOptions = {},\n ): Promise<HostPage> {\n const out = await this.t.json<HostList>(\"GET\", \"/v1/hosts\", {\n query: {\n limit: options.limit ? String(options.limit) : undefined,\n cursor: options.cursor,\n },\n signal: opts.signal,\n });\n return { hosts: out.hosts ?? [], nextCursor: out.next_cursor };\n }\n\n /** Fetch a single host by id. */\n async get(hostId: string, opts: CallOptions = {}): Promise<Host> {\n requireArg(hostId, \"host id\");\n return this.t.json<Host>(\"GET\", `/v1/hosts/${encodeURIComponent(hostId)}`, {\n signal: opts.signal,\n });\n }\n\n /** Mark a host unschedulable; existing VMs keep running. */\n async cordon(hostId: string, opts: CallOptions = {}): Promise<void> {\n await this.action(hostId, \"cordon\", opts);\n }\n\n /** Return a cordoned host to active scheduling. */\n async uncordon(hostId: string, opts: CallOptions = {}): Promise<void> {\n await this.action(hostId, \"uncordon\", opts);\n }\n\n /** Remove a host. The host must have no running VMs. */\n async deregister(hostId: string, opts: CallOptions = {}): Promise<void> {\n requireArg(hostId, \"host id\");\n await this.t.noContent(\"DELETE\", `/v1/hosts/${encodeURIComponent(hostId)}`, {\n signal: opts.signal,\n });\n }\n\n private async action(hostId: string, action: string, opts: CallOptions): Promise<void> {\n requireArg(hostId, \"host id\");\n await this.t.noContent(\"POST\", `/v1/hosts/${encodeURIComponent(hostId)}`, {\n query: { action },\n signal: opts.signal,\n });\n }\n}\n","import type { CallOptions, Transport } from \"./transport.js\";\nimport type { APIKey, CreatedAPIKey } from \"./types.js\";\nimport { requireArg } from \"./validate.js\";\n\ninterface APIKeyList {\n api_keys: APIKey[];\n}\n\n/**\n * ApiKeysService manages revocable API keys. These endpoints require the\n * master token; the server enforces this.\n */\nexport class ApiKeysService {\n constructor(private readonly t: Transport) {}\n\n /**\n * Issue a new API key. The raw secret is returned once in `key` and is\n * unrecoverable afterward.\n */\n async create(label?: string, opts: CallOptions = {}): Promise<CreatedAPIKey> {\n return this.t.json<CreatedAPIKey>(\"POST\", \"/v1/api-keys\", {\n body: label ? { label } : {},\n signal: opts.signal,\n });\n }\n\n /** List API key metadata. */\n async list(opts: CallOptions = {}): Promise<APIKey[]> {\n const out = await this.t.json<APIKeyList>(\"GET\", \"/v1/api-keys\", {\n signal: opts.signal,\n });\n return out.api_keys ?? [];\n }\n\n /** Revoke the API key with the given id. */\n async revoke(id: string, opts: CallOptions = {}): Promise<void> {\n requireArg(id, \"id\");\n await this.t.noContent(\"DELETE\", `/v1/api-keys/${encodeURIComponent(id)}`, {\n signal: opts.signal,\n });\n }\n}\n","// generated by scripts/gen-version.mjs. do not edit.\nexport const VERSION = \"0.26.0\";\n","import { Transport, type FetchLike } from \"./transport.js\";\nimport { EnvironmentsService } from \"./environments.js\";\nimport { SnapshotsService } from \"./snapshots.js\";\nimport { HostsService } from \"./hosts.js\";\nimport { ApiKeysService } from \"./apiKeys.js\";\nimport { VERSION } from \"./version.js\";\n\n/** Options for constructing a FuseClient. */\nexport interface FuseClientOptions {\n /** Base URL of the Fuse control plane, e.g. \"https://fuse.example.com\". Required. */\n baseUrl: string;\n /** Bearer token (master token or an API key). Omit for unauthenticated endpoints. */\n token?: string;\n /** Custom fetch implementation. Defaults to the global fetch (Node 18+). */\n fetch?: FetchLike;\n /** User-Agent header. Defaults to \"fuse-ts/<version>\". Ignored by browsers. */\n userAgent?: string;\n /** Generator for the X-Request-ID header, called once per request. Empty results are omitted. */\n requestId?: () => string;\n /** Default per-request timeout in milliseconds. Does NOT apply to events() streams. */\n timeoutMs?: number;\n /** Extra default headers merged into every request. */\n headers?: Record<string, string>;\n}\n\n/**\n * FuseClient is the entry point for the Fuse API. It groups the resource\n * services that share a single transport.\n *\n * @example\n * const client = new FuseClient({ baseUrl: \"https://fuse.example.com\", token });\n * const env = await client.environments.create({ task_id: \"task-1\" });\n */\nexport class FuseClient {\n readonly environments: EnvironmentsService;\n readonly snapshots: SnapshotsService;\n readonly hosts: HostsService;\n readonly apiKeys: ApiKeysService;\n\n constructor(options: FuseClientOptions) {\n const transport = new Transport({\n baseUrl: options.baseUrl,\n token: options.token,\n fetch: options.fetch,\n userAgent: options.userAgent ?? `fuse-ts/${VERSION}`,\n requestId: options.requestId,\n timeoutMs: options.timeoutMs,\n headers: options.headers,\n });\n this.environments = new EnvironmentsService(transport);\n this.snapshots = new SnapshotsService(transport);\n this.hosts = new HostsService(transport);\n this.apiKeys = new ApiKeysService(transport);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@folsom/fuse",
3
- "version": "0.24.0",
3
+ "version": "0.26.0",
4
4
  "description": "TypeScript SDK for the Fuse microVM control plane",
5
5
  "license": "MIT",
6
6
  "author": "andrewn6",