UNPKG

@luxorai/sandbox

Version:

TypeScript SDK for Luxor Sandbox: cloud sandboxes (microVMs) for AI agents on Luxor Agent Cloud

49 lines (48 loc) • 2.27 kB
import { type BatchGetSessionCostsResponse, type SessionCost as ProtoSessionCost } from "./internal/proto/tenki/sandbox/v1/sandbox_pb.js"; /** * `ACCRUING`: metering is still running and amounts can grow. `FINAL`: the * session has ended and amounts will not change. `UNAVAILABLE`: the session * started before per-session cost tracking, so no amounts are reported. */ export type SessionCostStatus = "UNSPECIFIED" | "ACCRUING" | "FINAL" | "UNAVAILABLE"; /** `DISK` is disk above the included allowance; `PAUSED_STORAGE` is storage kept while paused. */ export type SessionCostItem = "UNSPECIFIED" | "CPU" | "MEMORY" | "DISK" | "PAUSED_STORAGE"; /** 1 GiB = 2^30 bytes. */ export type SessionCostUnit = "UNSPECIFIED" | "VCPU_SECOND" | "GIB_SECOND"; export interface SessionCostLine { item: SessionCostItem; /** Decimal quantity in `unit`, for example cores times seconds. */ quantity: string; unit: SessionCostUnit; /** Decimal USD. */ amountUsd: string; /** Start of the period that contains this line's usage. */ startedAt?: Date; /** Unset while the cost is `ACCRUING`. */ endedAt?: Date; } /** Returned by {@link TenkiSandbox.getSessionCost} and {@link Session.cost}. */ export interface SessionCost { sessionId: string; status: SessionCostStatus; /** * Decimal USD at list price before credits, the sum of `lines`. Unset while * `ACCRUING` with nothing metered yet; `"0"` means nothing was billed. */ totalUsd?: string; lines: SessionCostLine[]; /** Usage up to this time is counted. Unset until the first metering tick. */ asOf?: Date; /** Whole seconds billed as running compute. */ billedRunningSeconds: number; /** Whole seconds billed as paused storage. */ billedPausedSeconds: number; } /** Returned by {@link TenkiSandbox.batchGetSessionCosts}. */ export interface SessionCostBatch { costs: SessionCost[]; /** Requested sessions that are not in the workspace or not visible to the caller. */ missingSessionIds: string[]; } export declare function sessionCostFromProto(cost: ProtoSessionCost | undefined, sessionId?: string): SessionCost; export declare function sessionCostBatchFromProto(resp: BatchGetSessionCostsResponse): SessionCostBatch;