@lizard-build/sdk 0.1.67 → 0.1.68

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.mts CHANGED
@@ -1401,6 +1401,7 @@ interface MetricPoint {
1401
1401
  }
1402
1402
  interface ServiceMetrics {
1403
1403
  cpu: MetricPoint[];
1404
+ /** Working set: what the service holds, without the file cache the kernel frees on demand. */
1404
1405
  memory: MetricPoint[];
1405
1406
  networkRx: MetricPoint[];
1406
1407
  networkTx: MetricPoint[];
@@ -2251,6 +2252,38 @@ declare class PaymentRequiredError extends LizardError {
2251
2252
  /** The one page to open next for this {@link paymentStatus}. */
2252
2253
  get url(): string | undefined;
2253
2254
  }
2255
+ /**
2256
+ * A limit was reached (HTTP 429). {@link LizardError.code} says which:
2257
+ * - `SANDBOX_LIMIT_REACHED` / `SANDBOX_RATE_LIMITED`: the account's sandbox limits (running at
2258
+ * once, starts per minute/hour/day); {@link retryAfterS} says when to try again.
2259
+ * - `WORKSPACE_SANDBOX_LIMIT`: the workspace's own cap on running sandboxes
2260
+ * (`workspaces.setLimits`).
2261
+ * - `WORKSPACE_USAGE_LIMIT`: the workspace's apps and databases use as much CPU or memory as its
2262
+ * cap; {@link usage} and {@link limits} carry both.
2263
+ * Still a {@link LizardError}, so existing `catch` blocks keep working.
2264
+ */
2265
+ declare class LimitExceededError extends LizardError {
2266
+ /** The limit that was reached (sandbox counts). */
2267
+ limit?: number;
2268
+ /** How many were running when it was refused. */
2269
+ running?: number;
2270
+ /** Seconds until a rate limit lets the next start through. */
2271
+ retryAfterS?: number;
2272
+ /** `WORKSPACE_USAGE_LIMIT`: the workspace's current use. */
2273
+ usage?: {
2274
+ runningSandboxes: number;
2275
+ cpuVcpus: number;
2276
+ memoryMb: number;
2277
+ measuredAt: number | null;
2278
+ };
2279
+ /** `WORKSPACE_USAGE_LIMIT`: the workspace's limits. */
2280
+ limits?: {
2281
+ maxRunningSandboxes: number | null;
2282
+ maxCpuVcpus: number | null;
2283
+ maxMemoryMb: number | null;
2284
+ };
2285
+ constructor(message?: string);
2286
+ }
2254
2287
 
2255
2288
  /** A single output item produced during code execution. */
2256
2289
  type OutputItem = {
@@ -2426,4 +2459,4 @@ declare class LizardCLI {
2426
2459
  }): Promise<CLIResult>;
2427
2460
  }
2428
2461
 
2429
- export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CLIOptions, type CLIResult, type CheckoutSession, type ClickOpts, type CodeContext, CodeSandbox, ConfigApplyError, type ConfigResult, ConflictError, type ConnectionOpts, type CostMetrics, type CreateAddonOpts, type CreateApiKeyOpts, type CreateContextOpts, type CreateProjectOpts, type CreateServiceOpts, type CreateVolumeOpts, type CreateWorkspaceOpts, type CreatedApiKey, type DeployEvent, DeployHandle, Desktop, type DesktopInfo, type DesktopStartOpts, type DomainInfo, type DomainStatus, DomainsAPI, Execution, ExecutionError, type ExposedPort, type FileInfo, type ForkResult, type FsEvent, type FsOpts, GitHubAPI, type ListTransactionsOpts, Lizard, LizardCLI, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, type MouseButton, NotFoundError, PaymentRequiredError, type Plan, PlatformClient, type ProcessInfo, type ProcessOpts, type ProcessResult, type ProcessSignal, type Project, type ProjectConfig, type ProjectCost, ProjectsAPI, type PromoRedemption, type RawMetrics, type Region, RegionsAPI, type ResaleMultipliers, type ResalePricing, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type SandboxSnapshot, type ScaleOpts, type ScrollDirection, type Secret, SecretsAPI, type Service, type ServiceMetrics, type ServiceUpdate, ServicesAPI, type SetSecretOpts, type SnapshotOpts, type SnapshotScope, type SnapshotWaitOpts, type StartCheckoutOpts, type StartProNowResult, StorageAPI, type StreamEvent, type Subscription, type SubscriptionStatus, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, type WorkspaceLimits, type WorkspaceLimitsInfo, type WorkspaceUsage, WorkspacesAPI, resolveProjectId };
2462
+ export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CLIOptions, type CLIResult, type CheckoutSession, type ClickOpts, type CodeContext, CodeSandbox, ConfigApplyError, type ConfigResult, ConflictError, type ConnectionOpts, type CostMetrics, type CreateAddonOpts, type CreateApiKeyOpts, type CreateContextOpts, type CreateProjectOpts, type CreateServiceOpts, type CreateVolumeOpts, type CreateWorkspaceOpts, type CreatedApiKey, type DeployEvent, DeployHandle, Desktop, type DesktopInfo, type DesktopStartOpts, type DomainInfo, type DomainStatus, DomainsAPI, Execution, ExecutionError, type ExposedPort, type FileInfo, type ForkResult, type FsEvent, type FsOpts, GitHubAPI, LimitExceededError, type ListTransactionsOpts, Lizard, LizardCLI, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, type MouseButton, NotFoundError, PaymentRequiredError, type Plan, PlatformClient, type ProcessInfo, type ProcessOpts, type ProcessResult, type ProcessSignal, type Project, type ProjectConfig, type ProjectCost, ProjectsAPI, type PromoRedemption, type RawMetrics, type Region, RegionsAPI, type ResaleMultipliers, type ResalePricing, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type SandboxSnapshot, type ScaleOpts, type ScrollDirection, type Secret, SecretsAPI, type Service, type ServiceMetrics, type ServiceUpdate, ServicesAPI, type SetSecretOpts, type SnapshotOpts, type SnapshotScope, type SnapshotWaitOpts, type StartCheckoutOpts, type StartProNowResult, StorageAPI, type StreamEvent, type Subscription, type SubscriptionStatus, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, type WorkspaceLimits, type WorkspaceLimitsInfo, type WorkspaceUsage, WorkspacesAPI, resolveProjectId };
package/dist/index.d.ts CHANGED
@@ -1401,6 +1401,7 @@ interface MetricPoint {
1401
1401
  }
1402
1402
  interface ServiceMetrics {
1403
1403
  cpu: MetricPoint[];
1404
+ /** Working set: what the service holds, without the file cache the kernel frees on demand. */
1404
1405
  memory: MetricPoint[];
1405
1406
  networkRx: MetricPoint[];
1406
1407
  networkTx: MetricPoint[];
@@ -2251,6 +2252,38 @@ declare class PaymentRequiredError extends LizardError {
2251
2252
  /** The one page to open next for this {@link paymentStatus}. */
2252
2253
  get url(): string | undefined;
2253
2254
  }
2255
+ /**
2256
+ * A limit was reached (HTTP 429). {@link LizardError.code} says which:
2257
+ * - `SANDBOX_LIMIT_REACHED` / `SANDBOX_RATE_LIMITED`: the account's sandbox limits (running at
2258
+ * once, starts per minute/hour/day); {@link retryAfterS} says when to try again.
2259
+ * - `WORKSPACE_SANDBOX_LIMIT`: the workspace's own cap on running sandboxes
2260
+ * (`workspaces.setLimits`).
2261
+ * - `WORKSPACE_USAGE_LIMIT`: the workspace's apps and databases use as much CPU or memory as its
2262
+ * cap; {@link usage} and {@link limits} carry both.
2263
+ * Still a {@link LizardError}, so existing `catch` blocks keep working.
2264
+ */
2265
+ declare class LimitExceededError extends LizardError {
2266
+ /** The limit that was reached (sandbox counts). */
2267
+ limit?: number;
2268
+ /** How many were running when it was refused. */
2269
+ running?: number;
2270
+ /** Seconds until a rate limit lets the next start through. */
2271
+ retryAfterS?: number;
2272
+ /** `WORKSPACE_USAGE_LIMIT`: the workspace's current use. */
2273
+ usage?: {
2274
+ runningSandboxes: number;
2275
+ cpuVcpus: number;
2276
+ memoryMb: number;
2277
+ measuredAt: number | null;
2278
+ };
2279
+ /** `WORKSPACE_USAGE_LIMIT`: the workspace's limits. */
2280
+ limits?: {
2281
+ maxRunningSandboxes: number | null;
2282
+ maxCpuVcpus: number | null;
2283
+ maxMemoryMb: number | null;
2284
+ };
2285
+ constructor(message?: string);
2286
+ }
2254
2287
 
2255
2288
  /** A single output item produced during code execution. */
2256
2289
  type OutputItem = {
@@ -2426,4 +2459,4 @@ declare class LizardCLI {
2426
2459
  }): Promise<CLIResult>;
2427
2460
  }
2428
2461
 
2429
- export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CLIOptions, type CLIResult, type CheckoutSession, type ClickOpts, type CodeContext, CodeSandbox, ConfigApplyError, type ConfigResult, ConflictError, type ConnectionOpts, type CostMetrics, type CreateAddonOpts, type CreateApiKeyOpts, type CreateContextOpts, type CreateProjectOpts, type CreateServiceOpts, type CreateVolumeOpts, type CreateWorkspaceOpts, type CreatedApiKey, type DeployEvent, DeployHandle, Desktop, type DesktopInfo, type DesktopStartOpts, type DomainInfo, type DomainStatus, DomainsAPI, Execution, ExecutionError, type ExposedPort, type FileInfo, type ForkResult, type FsEvent, type FsOpts, GitHubAPI, type ListTransactionsOpts, Lizard, LizardCLI, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, type MouseButton, NotFoundError, PaymentRequiredError, type Plan, PlatformClient, type ProcessInfo, type ProcessOpts, type ProcessResult, type ProcessSignal, type Project, type ProjectConfig, type ProjectCost, ProjectsAPI, type PromoRedemption, type RawMetrics, type Region, RegionsAPI, type ResaleMultipliers, type ResalePricing, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type SandboxSnapshot, type ScaleOpts, type ScrollDirection, type Secret, SecretsAPI, type Service, type ServiceMetrics, type ServiceUpdate, ServicesAPI, type SetSecretOpts, type SnapshotOpts, type SnapshotScope, type SnapshotWaitOpts, type StartCheckoutOpts, type StartProNowResult, StorageAPI, type StreamEvent, type Subscription, type SubscriptionStatus, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, type WorkspaceLimits, type WorkspaceLimitsInfo, type WorkspaceUsage, WorkspacesAPI, resolveProjectId };
2462
+ export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CLIOptions, type CLIResult, type CheckoutSession, type ClickOpts, type CodeContext, CodeSandbox, ConfigApplyError, type ConfigResult, ConflictError, type ConnectionOpts, type CostMetrics, type CreateAddonOpts, type CreateApiKeyOpts, type CreateContextOpts, type CreateProjectOpts, type CreateServiceOpts, type CreateVolumeOpts, type CreateWorkspaceOpts, type CreatedApiKey, type DeployEvent, DeployHandle, Desktop, type DesktopInfo, type DesktopStartOpts, type DomainInfo, type DomainStatus, DomainsAPI, Execution, ExecutionError, type ExposedPort, type FileInfo, type ForkResult, type FsEvent, type FsOpts, GitHubAPI, LimitExceededError, type ListTransactionsOpts, Lizard, LizardCLI, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, type MouseButton, NotFoundError, PaymentRequiredError, type Plan, PlatformClient, type ProcessInfo, type ProcessOpts, type ProcessResult, type ProcessSignal, type Project, type ProjectConfig, type ProjectCost, ProjectsAPI, type PromoRedemption, type RawMetrics, type Region, RegionsAPI, type ResaleMultipliers, type ResalePricing, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type SandboxSnapshot, type ScaleOpts, type ScrollDirection, type Secret, SecretsAPI, type Service, type ServiceMetrics, type ServiceUpdate, ServicesAPI, type SetSecretOpts, type SnapshotOpts, type SnapshotScope, type SnapshotWaitOpts, type StartCheckoutOpts, type StartProNowResult, StorageAPI, type StreamEvent, type Subscription, type SubscriptionStatus, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, type WorkspaceLimits, type WorkspaceLimitsInfo, type WorkspaceUsage, WorkspacesAPI, resolveProjectId };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ __export(index_exports, {
31
31
  Desktop: () => Desktop,
32
32
  DomainsAPI: () => DomainsAPI,
33
33
  GitHubAPI: () => GitHubAPI,
34
+ LimitExceededError: () => LimitExceededError,
34
35
  Lizard: () => Lizard,
35
36
  LizardCLI: () => LizardCLI,
36
37
  LizardError: () => LizardError,
@@ -126,6 +127,12 @@ var PaymentRequiredError = class extends LizardError {
126
127
  return this.billingUrl ?? this.subscribeUrl ?? this.topupUrl;
127
128
  }
128
129
  };
130
+ var LimitExceededError = class extends LizardError {
131
+ constructor(message = "Limit reached") {
132
+ super(message);
133
+ this.name = "LimitExceededError";
134
+ }
135
+ };
129
136
  var PREPAID_STATUSES = /* @__PURE__ */ new Set(["grace", "frozen", "card_required", "credits_required"]);
130
137
  var ERROR_CODE = /^[A-Z][A-Z0-9_]*$/;
131
138
  async function handleApiError(res) {
@@ -153,7 +160,17 @@ async function handleApiError(res) {
153
160
  else if (res.status === 404) err = new NotFoundError(message);
154
161
  else if (res.status === 409) err = new ConflictError(message);
155
162
  else if (res.status === 408 || res.status === 504) err = new TimeoutError(message);
156
- else err = new LizardError(`API error ${res.status}: ${message}`);
163
+ else if (res.status === 429) {
164
+ const limited = new LimitExceededError(message);
165
+ const n = (key) => typeof body[key] === "number" ? body[key] : void 0;
166
+ limited.limit = n("limit");
167
+ limited.running = n("running");
168
+ const retry = n("retryAfterS") ?? (Number(res.headers?.get?.("retry-after")) || void 0);
169
+ limited.retryAfterS = retry;
170
+ if (body.usage && typeof body.usage === "object") limited.usage = body.usage;
171
+ if (body.limits && typeof body.limits === "object") limited.limits = body.limits;
172
+ err = limited;
173
+ } else err = new LizardError(`API error ${res.status}: ${message}`);
157
174
  err.status = res.status;
158
175
  err.code = code;
159
176
  throw err;
@@ -2689,6 +2706,7 @@ var LizardCLI = class {
2689
2706
  Desktop,
2690
2707
  DomainsAPI,
2691
2708
  GitHubAPI,
2709
+ LimitExceededError,
2692
2710
  Lizard,
2693
2711
  LizardCLI,
2694
2712
  LizardError,
package/dist/index.mjs CHANGED
@@ -73,6 +73,12 @@ var PaymentRequiredError = class extends LizardError {
73
73
  return this.billingUrl ?? this.subscribeUrl ?? this.topupUrl;
74
74
  }
75
75
  };
76
+ var LimitExceededError = class extends LizardError {
77
+ constructor(message = "Limit reached") {
78
+ super(message);
79
+ this.name = "LimitExceededError";
80
+ }
81
+ };
76
82
  var PREPAID_STATUSES = /* @__PURE__ */ new Set(["grace", "frozen", "card_required", "credits_required"]);
77
83
  var ERROR_CODE = /^[A-Z][A-Z0-9_]*$/;
78
84
  async function handleApiError(res) {
@@ -100,7 +106,17 @@ async function handleApiError(res) {
100
106
  else if (res.status === 404) err = new NotFoundError(message);
101
107
  else if (res.status === 409) err = new ConflictError(message);
102
108
  else if (res.status === 408 || res.status === 504) err = new TimeoutError(message);
103
- else err = new LizardError(`API error ${res.status}: ${message}`);
109
+ else if (res.status === 429) {
110
+ const limited = new LimitExceededError(message);
111
+ const n = (key) => typeof body[key] === "number" ? body[key] : void 0;
112
+ limited.limit = n("limit");
113
+ limited.running = n("running");
114
+ const retry = n("retryAfterS") ?? (Number(res.headers?.get?.("retry-after")) || void 0);
115
+ limited.retryAfterS = retry;
116
+ if (body.usage && typeof body.usage === "object") limited.usage = body.usage;
117
+ if (body.limits && typeof body.limits === "object") limited.limits = body.limits;
118
+ err = limited;
119
+ } else err = new LizardError(`API error ${res.status}: ${message}`);
104
120
  err.status = res.status;
105
121
  err.code = code;
106
122
  throw err;
@@ -2635,6 +2651,7 @@ export {
2635
2651
  Desktop,
2636
2652
  DomainsAPI,
2637
2653
  GitHubAPI,
2654
+ LimitExceededError,
2638
2655
  Lizard,
2639
2656
  LizardCLI,
2640
2657
  LizardError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lizard-build/sdk",
3
- "version": "0.1.67",
3
+ "version": "0.1.68",
4
4
  "description": "TypeScript SDK for Lizard: Firecracker microVM sandboxes, code execution and cloud apps.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",