@folsom/fuse 0.13.0 → 0.13.1
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 +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -465,7 +465,7 @@ declare class FuseClient {
|
|
|
465
465
|
constructor(options: FuseClientOptions);
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
declare const VERSION = "0.13.
|
|
468
|
+
declare const VERSION = "0.13.1";
|
|
469
469
|
|
|
470
470
|
/** Stable, machine-readable error codes returned by the server. */
|
|
471
471
|
declare const ErrorCode: {
|
package/dist/index.js
CHANGED
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"],"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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,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 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/** 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 gateway_url?: string;\n gateway_token?: string;\n expose?: ExposeSpec[];\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}\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}\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 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 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","// 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 CreateRequest,\n EnvironmentInfo,\n Event,\n ExecRequest,\n ExecResult,\n ForkOptions,\n} from \"./types.js\";\nimport { FuseError } from \"./errors.js\";\nimport { requireArg } from \"./validate.js\";\nimport { streamEvents } from \"./events.js\";\n\n/** Filters for environments.list. */\nexport interface ListEnvironmentsOptions {\n taskId?: string;\n state?: string;\n hostId?: string;\n}\n\ninterface EnvironmentList {\n environments: EnvironmentInfo[];\n}\n\n/** EnvironmentsService manages microVM lifecycle. */\nexport class EnvironmentsService {\n constructor(private readonly t: Transport) {}\n\n /** List tracked environments, optionally filtered. */\n async list(\n options: ListEnvironmentsOptions = {},\n opts: CallOptions = {},\n ): Promise<EnvironmentInfo[]> {\n const out = await this.t.json<EnvironmentList>(\"GET\", \"/v1/environments\", {\n query: { task_id: options.taskId, state: options.state, host_id: options.hostId },\n signal: opts.signal,\n });\n return out.environments ?? [];\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 /** 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 { Snapshot, SnapshotRequest } from \"./types.js\";\nimport { requireArg } from \"./validate.js\";\n\n/** Filters for snapshots.list. */\nexport interface ListSnapshotsOptions {\n vmId?: string;\n taskId?: string;\n tenantId?: string;\n state?: string;\n}\n\ninterface SnapshotList {\n snapshots: Snapshot[];\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. */\n async list(\n options: ListSnapshotsOptions = {},\n opts: CallOptions = {},\n ): Promise<Snapshot[]> {\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 },\n signal: opts.signal,\n });\n return out.snapshots ?? [];\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\ninterface HostList {\n hosts: Host[];\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. */\n async list(opts: CallOptions = {}): Promise<Host[]> {\n const out = await this.t.json<HostList>(\"GET\", \"/v1/hosts\", { signal: opts.signal });\n return out.hosts ?? [];\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.13.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"],"mappings":";AAIA,IAAM,iBAAA,GAAoB,cAAA;AAGnB,IAAM,SAAA,GAAY;AAAA,EACvB,QAAA,EAAU,WAAA;AAAA,EACV,QAAA,EAAU,UAAA;AAAA,EACV,eAAA,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AAA;AAAA,MACf,SAAA,EAAW,OAAA,CAAQ,SAAA,IAAa,CAAA,QAAA,EAAW,OAAO,CAAA,CAAA;AAAA,MAClD,WAAW,OAAA,CAAQ,SAAA;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 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/** 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 gateway_url?: string;\n gateway_token?: string;\n expose?: ExposeSpec[];\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}\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}\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 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 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","// 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 CreateRequest,\n EnvironmentInfo,\n Event,\n ExecRequest,\n ExecResult,\n ForkOptions,\n} from \"./types.js\";\nimport { FuseError } from \"./errors.js\";\nimport { requireArg } from \"./validate.js\";\nimport { streamEvents } from \"./events.js\";\n\n/** Filters for environments.list. */\nexport interface ListEnvironmentsOptions {\n taskId?: string;\n state?: string;\n hostId?: string;\n}\n\ninterface EnvironmentList {\n environments: EnvironmentInfo[];\n}\n\n/** EnvironmentsService manages microVM lifecycle. */\nexport class EnvironmentsService {\n constructor(private readonly t: Transport) {}\n\n /** List tracked environments, optionally filtered. */\n async list(\n options: ListEnvironmentsOptions = {},\n opts: CallOptions = {},\n ): Promise<EnvironmentInfo[]> {\n const out = await this.t.json<EnvironmentList>(\"GET\", \"/v1/environments\", {\n query: { task_id: options.taskId, state: options.state, host_id: options.hostId },\n signal: opts.signal,\n });\n return out.environments ?? [];\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 /** 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 { Snapshot, SnapshotRequest } from \"./types.js\";\nimport { requireArg } from \"./validate.js\";\n\n/** Filters for snapshots.list. */\nexport interface ListSnapshotsOptions {\n vmId?: string;\n taskId?: string;\n tenantId?: string;\n state?: string;\n}\n\ninterface SnapshotList {\n snapshots: Snapshot[];\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. */\n async list(\n options: ListSnapshotsOptions = {},\n opts: CallOptions = {},\n ): Promise<Snapshot[]> {\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 },\n signal: opts.signal,\n });\n return out.snapshots ?? [];\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\ninterface HostList {\n hosts: Host[];\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. */\n async list(opts: CallOptions = {}): Promise<Host[]> {\n const out = await this.t.json<HostList>(\"GET\", \"/v1/hosts\", { signal: opts.signal });\n return out.hosts ?? [];\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.13.1\";\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"]}
|