@miosa/sdk 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -171,6 +171,10 @@ const preview = await sbx.previews.create(3000);
171
171
  console.log(preview.url);
172
172
  ```
173
173
 
174
+ With `waitUntilReady: true` the returned sandbox has been refreshed and verified
175
+ executable. A readiness timeout throws `SANDBOX_READY_TIMEOUT` instead of
176
+ returning a sandbox that is not yet ready.
177
+
174
178
  For platform agents that plan work outside the sandbox and then hand execution
175
179
  to a runtime inside the sandbox/computer, use the unified device API:
176
180
 
@@ -404,11 +408,13 @@ try {
404
408
  } catch (e) {
405
409
  if (e instanceof MiosaError) {
406
410
  console.error(`${e.status} ${e.code}: ${e.message}`);
411
+ if (e.retryable) scheduleRetry(e.requestId);
407
412
  }
408
413
  }
409
414
  ```
410
415
 
411
416
  The SDK retries `429` and `5xx` automatically (3 retries, exponential backoff + jitter). Set `maxRetries: 0` to disable.
417
+ Every `MiosaError` carries `retryable` (server-supplied when present, otherwise `true` for 408/429/5xx and transport failures) and `requestId` for support correlation.
412
418
 
413
419
  ## Configuration
414
420
 
package/dist/index.d.ts CHANGED
@@ -5214,6 +5214,7 @@ interface MiosaErrorBody {
5214
5214
  code?: string;
5215
5215
  message?: string;
5216
5216
  details?: unknown;
5217
+ retryable?: boolean;
5217
5218
  };
5218
5219
  message?: string;
5219
5220
  code?: string;
@@ -5221,30 +5222,32 @@ interface MiosaErrorBody {
5221
5222
  details?: unknown;
5222
5223
  reason?: string;
5223
5224
  request_id?: string;
5225
+ retryable?: boolean;
5224
5226
  }
5225
5227
  declare class MiosaError extends Error {
5226
5228
  readonly status: number;
5227
5229
  readonly code: string;
5228
5230
  readonly details: unknown;
5229
5231
  readonly requestId: string | undefined;
5230
- constructor(message: string, status: number, code: string, details?: unknown, requestId?: string);
5232
+ readonly retryable: boolean;
5233
+ constructor(message: string, status: number, code: string, details?: unknown, requestId?: string, retryable?: boolean);
5231
5234
  static fromResponse(status: number, body: MiosaErrorBody, requestId?: string): MiosaError;
5232
5235
  }
5233
5236
  declare class AuthError extends MiosaError {
5234
- constructor(message: string, status?: number, code?: string, details?: unknown, requestId?: string);
5237
+ constructor(message: string, status?: number, code?: string, details?: unknown, requestId?: string, retryable?: boolean);
5235
5238
  }
5236
5239
  declare class NotFoundError extends MiosaError {
5237
- constructor(message: string, code?: string, details?: unknown, requestId?: string);
5240
+ constructor(message: string, code?: string, details?: unknown, requestId?: string, retryable?: boolean);
5238
5241
  }
5239
5242
  declare class RateLimitError extends MiosaError {
5240
5243
  readonly retryAfter: number | undefined;
5241
- constructor(message: string, details?: unknown, requestId?: string, retryAfter?: number);
5244
+ constructor(message: string, details?: unknown, requestId?: string, retryAfter?: number, retryable?: boolean);
5242
5245
  }
5243
5246
  declare class InsufficientCreditsError extends MiosaError {
5244
- constructor(message: string, details?: unknown, requestId?: string);
5247
+ constructor(message: string, details?: unknown, requestId?: string, retryable?: boolean);
5245
5248
  }
5246
5249
  declare class ValidationError extends MiosaError {
5247
- constructor(message: string, status: number, code?: string, details?: unknown, requestId?: string);
5250
+ constructor(message: string, status: number, code?: string, details?: unknown, requestId?: string, retryable?: boolean);
5248
5251
  }
5249
5252
  declare class TimeoutError extends MiosaError {
5250
5253
  constructor(message?: string);
@@ -5254,28 +5257,28 @@ declare class NetworkError extends MiosaError {
5254
5257
  constructor(message: string, cause: Error);
5255
5258
  }
5256
5259
  declare class ProjectNotLinkedError extends MiosaError {
5257
- constructor(message: string, status?: number, details?: unknown, requestId?: string);
5260
+ constructor(message: string, status?: number, details?: unknown, requestId?: string, retryable?: boolean);
5258
5261
  }
5259
5262
  declare class SubjectNotAllowedError extends MiosaError {
5260
- constructor(message: string, status?: number, details?: unknown, requestId?: string);
5263
+ constructor(message: string, status?: number, details?: unknown, requestId?: string, retryable?: boolean);
5261
5264
  }
5262
5265
  declare class ScopeNotAllowedError extends MiosaError {
5263
- constructor(message: string, status?: number, details?: unknown, requestId?: string);
5266
+ constructor(message: string, status?: number, details?: unknown, requestId?: string, retryable?: boolean);
5264
5267
  }
5265
5268
  declare class ManagedProviderBindingOnlyError extends MiosaError {
5266
- constructor(message: string, status?: number, details?: unknown, requestId?: string);
5269
+ constructor(message: string, status?: number, details?: unknown, requestId?: string, retryable?: boolean);
5267
5270
  }
5268
5271
  declare class InstallationRequiredError extends MiosaError {
5269
- constructor(message: string, status?: number, details?: unknown, requestId?: string);
5272
+ constructor(message: string, status?: number, details?: unknown, requestId?: string, retryable?: boolean);
5270
5273
  }
5271
5274
  declare class UserAuthorizationRequiredError extends MiosaError {
5272
- constructor(message: string, status?: number, details?: unknown, requestId?: string);
5275
+ constructor(message: string, status?: number, details?: unknown, requestId?: string, retryable?: boolean);
5273
5276
  }
5274
5277
  declare class EgressHostNotAllowedError extends MiosaError {
5275
- constructor(message: string, status?: number, details?: unknown, requestId?: string);
5278
+ constructor(message: string, status?: number, details?: unknown, requestId?: string, retryable?: boolean);
5276
5279
  }
5277
5280
  declare class TokenRefreshFailedError extends MiosaError {
5278
- constructor(message: string, status?: number, details?: unknown, requestId?: string);
5281
+ constructor(message: string, status?: number, details?: unknown, requestId?: string, retryable?: boolean);
5279
5282
  }
5280
5283
 
5281
5284
  type ForgeRepositoryId = string & {
@@ -6822,7 +6825,14 @@ interface SandboxGetOrCreateParams extends SandboxCreateParams {
6822
6825
  name: string;
6823
6826
  /** Resume an existing paused sandbox before returning it. Defaults to true. */
6824
6827
  resume?: boolean;
6825
- /** Wait for readiness before returning a created/resumed sandbox. Defaults to false. */
6828
+ /**
6829
+ * Wait for readiness before returning a created/resumed sandbox. Defaults to false.
6830
+ *
6831
+ * When true the returned sandbox has been refreshed and verified executable
6832
+ * (`running` and command-ready). Throws `SANDBOX_READY_TIMEOUT` (504,
6833
+ * retryable) if readiness is not reached within `waitTimeoutSec`, and
6834
+ * `SANDBOX_NOT_READY` (409) if the refreshed record is not executable.
6835
+ */
6826
6836
  waitUntilReady?: boolean;
6827
6837
  /** Readiness wait timeout in seconds. Defaults to 60 when waitUntilReady is true. */
6828
6838
  waitTimeoutSec?: number;
@@ -7224,16 +7234,44 @@ declare class SandboxSnapshots {
7224
7234
  restore(snapshotId: string): Promise<Sandbox>;
7225
7235
  delete(snapshotId: string): Promise<void>;
7226
7236
  }
7237
+ /** Options for a `miosa-terminal-v1` PTY session. */
7238
+ interface SandboxTerminalCreateParams {
7239
+ cols?: number;
7240
+ rows?: number;
7241
+ shell?: string;
7242
+ cwd?: string;
7243
+ env?: Record<string, string>;
7244
+ }
7245
+ /**
7246
+ * A short-lived ticket for a `miosa-terminal-v1` WebSocket session.
7247
+ *
7248
+ * Connect to `wsUrl` with the `miosa-terminal-v1` subprotocol and provide
7249
+ * `streamAuth` as the Bearer credential. See docs/api/sandbox-terminal-v1.md
7250
+ * in the MIOSA runtime repository for the frame protocol.
7251
+ *
7252
+ * Every field is carried both as its wire (snake_case) key and its camelCase
7253
+ * alias, so callers that consumed the raw record keep working.
7254
+ *
7255
+ * Declared as a type alias rather than an interface so it stays assignable to
7256
+ * the `Record<string, unknown>` return type that `terminal.create()` exposed
7257
+ * before 3.2.1 (interfaces carry no implicit index signature).
7258
+ */
7259
+ type SandboxTerminalSession = {
7260
+ sessionId: string;
7261
+ wsUrl: string;
7262
+ streamAuth: string;
7263
+ streamAuthExpiresAt: number;
7264
+ expiresAt: number;
7265
+ session_id: string;
7266
+ ws_url: string;
7267
+ stream_auth: string;
7268
+ stream_auth_expires_at: number;
7269
+ expires_at: number;
7270
+ };
7227
7271
  declare class SandboxTerminal {
7228
7272
  private readonly sandbox;
7229
7273
  constructor(sandbox: Sandbox);
7230
- create(params?: {
7231
- cols?: number;
7232
- rows?: number;
7233
- shell?: string;
7234
- cwd?: string;
7235
- env?: Record<string, string>;
7236
- }): Promise<Record<string, unknown>>;
7274
+ create(params?: SandboxTerminalCreateParams): Promise<SandboxTerminalSession>;
7237
7275
  delete(sessionId: string): Promise<void>;
7238
7276
  }
7239
7277
  declare class SandboxEvents {
@@ -8846,4 +8884,4 @@ declare class AppAuth {
8846
8884
  private _post;
8847
8885
  }
8848
8886
 
8849
- export { AGENT_BUILD_KIND_SPECS, type AcceptOrgInviteResponse, type AcceptWorkspaceInviteResponse, type AddDomainParams, type AddWorkspaceMemberParams, Admin, type AgentBuildExecutionPacket, type AgentBuildFileSpec, type AgentBuildKind, type AgentBuildKindSpec, type AgentBuildPlannerDocument, type AgentDefinitionCreateParams, type AgentDefinitionData, type AgentDefinitionListParams, type AgentDefinitionUpdateParams, AgentDefinitions, type AgentDispatchParams, type AgentEvent$1 as AgentEvent, type AgentEventType, AgentRuntimeProfiles, type AgentSessionCreateParams, type AgentSessionData, type AgentSessionListResponse$1 as AgentSessionListResponse, type AgentSessionStatus$1 as AgentSessionStatus, type AgentVersionData, type AllowParams, Analytics, type AnalyticsFilters, type ApiKeyCreateParams, type ApiKeyCreateResult, type ApiKeyData, type ApiKeyId, type ApiKeyListParams, ApiKeys, type AppActionDecision, AppAuth, type AppAuthConfig, type AppAuthResourceType, type AppAuthSession, type AppAuthTokenPayload, type AppAutomationRun, type AppCatalogEntry, type AppCollectionRecord, type AppDocument, type AppDocumentCreateParams, type AppDocumentDiagnostics, type AppDocumentRecord, type AppDocumentUpdateParams, AppDocuments, type AppInstallData, type AppInstallEvent, type AppJson, type AppReleaseApproval, type AppReleaseCandidate, type AttachAwsRoleParams, type AuditListParams, AuditLog, type AuditLogEvent, type AuditLogListParams, type AuditTailParams, AuthError, type AuthToken, type BenchmarkCompareParams, type BenchmarkCreateParams, Benchmarks, type BindingCreateParams, type BindingListParams, type BrandingData, type BrandingUpdateParams, type BucketCreateParams, type BucketData, type BucketId, type BuilderSessionListParams, BuilderSessions, type BulkUserActionParams, type ChannelCreateParams, type ChannelData, type ChannelListParams, type ChannelUpdateParams, Channels, type ChatCompletionCreateParams, type ChatCompletionCreateStreamParams, Checkpoints, type ClickParams, Cloud, type CloudAccount, type CloudAccountCreateParams, type CloudAccountMode, type CloudAccountStatus, type CloudCredentialType, type CloudListParams, type CloudPlacementScope, type CloudPool, type CloudPoolCreateParams, type CloudPoolKind, type CloudPreflightRecordParams, type CloudPreflightRun, type CloudPreflightStatus, type CloudProvider, type CloudRegion, type CloudRegionCreateParams, type ClusterCreateParams, type ClusterData, type ClusterEvent, type ClusterId, type ClusterListResponse, type ClusterStatus, CommandCenter, Community, type CompletionCreateParams, type CompletionCreateStreamParams, Completions, type ComputeProduct, Computer, ComputerAudit, ComputerAutoStop, ComputerConnectors, type ComputerCreateParams, type ComputerData, ComputerEnv, type ComputerId, ComputerInbox, type ComputerListParams, type ComputerListResponse, ComputerLogs, type ComputerLogsGetParams, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, type ComputerSize, type ComputerStatus, type ComputerTemplateType, ComputerTerminal, type ComputerUpdateParams, type ComputerVisibility, ComputerVolumes, Computers, type ConnectorApplicableDefaultParams, type ConnectorCreateParams, type ConnectorData, type ConnectorDefault, type ConnectorDefaultListParams, type ConnectorDefaultParams, type ConnectorListParams, type ConnectorSubject, type ConnectorTokenParams, type ConnectorTokenResponse, Connectors, type CopyParams, type CreateAdminApiKeyParams, type CreateAgentBuildPacketParams, type CreateBuildRunParams, type CreateOrgInviteParams, type CreateWorkspaceInviteParams, type CreateWorkspaceInviteResponse, type CreditBalance, type CreditTransaction, type CreditTransactionListResponse, type CreditUsage, Credits, type CronJobCreateParams, type CronJobData, type CronJobExecutionData, type CronJobExecutionId, type CronJobId, type CronJobListParams, type CronJobUpdateParams, CronJobs, type CursorInfo, type CustomDomainCreateParams, type CustomDomainData, type CustomDomainId, type CustomDomainListParams, DEFAULT_AGENT_BUILD_OUTPUT_ROOT, DEFAULT_AGENT_BUILD_PACKET_VERSION, Dashboard, type DashboardSummary, type DatabaseCreateParams, type DatabaseCredentials, type DatabaseData, type DatabaseId, type DatabaseListParams, type DatabaseLogsParams, type DatabaseLogsResult, Databases, type DeploymentBuildData, DeploymentConnectors, type DeploymentCreateParams, type DeploymentData, DeploymentDomains, type DeploymentId, type DeploymentListParams, type DeploymentProduct, type DeploymentProofCheck, type DeploymentProofParams, type DeploymentProofProbe, type DeploymentProofResult, type DeploymentReleaseData, type DeploymentReleaseId, DeploymentReleases, DeploymentRuntimeInstances, type DeploymentServiceData, type DeploymentServiceId, type DeploymentServiceType, type DeploymentSourceType, type DeploymentState, type DeploymentUpdateParams, type DeploymentVersionData, type DeploymentVersionId, type DeploymentVersionKind, type DeploymentVersionState, DeploymentVersions, Deployments, Desktop$1 as Desktop, type DesktopActionResult, type DeviceBootstrapParams, type DeviceBootstrapResult, type DeviceBrowserResult, type DeviceCapabilities, type DeviceData, type DeviceExecParams, type DeviceExecResult, type DeviceExposeParams, type DeviceExposeResult, type DeviceExtendParams, type DeviceFileEntry, type DeviceFileListParams, type DeviceKind, type DeviceLifecycleResult, type DeviceListParams, type DeviceReadFileParams, type DeviceReadFileResult, type DeviceWriteFileParams, type DeviceWriteFileResult, Devices, type DirEntry, type DirListResult, type DiscordSendTestParams, DockerDeploy, type DockerDeployApplianceStatus, type DockerDeployCreateParams, type DockerDeployDoctorCheck, type DockerDeployDoctorParams, type DockerDeployDoctorProbe, type DockerDeployDoctorResult, type DockerDeployHostData, type DockerDeployHostEnsureParams, type DockerDeployHostId, type DockerDeployHostListParams, type DockerDeployHostListResponse, type DockerDeployHostResponse, type DockerDeployHostStatus, type DoubleClickParams, type DragParams, type EgressAllowlistRule, EgressAudit, type EgressAuditEvent, type EgressBindingData, EgressHostNotAllowedError, EgressNetwork, type EgressPolicyData, type EgressPolicyMode, type EgressRuleEffect, type EgressSecretData, type EgressSecretScope, type EgressSecretType, EgressSecrets, type EgressSuggestion, Email, EmailCampaigns, EmailInbox, EmailTemplates, type EmbeddingCreateParams, Embeddings, Exec, type ExecParams, type ExecPythonParams, type ExecResult, type ExternalAttribution, type ExternalKeyCreateParams, type ExternalKeyData, ExternalKeys, type FileDeleteParams, type FileDownloadParams, type FileEntry, type FileExportParams, type FileExportResult, type FileListParams, type FileListResult, type FileStat, Files, FlatCustomDomains, Forge, ForgeContractError, type ForgeDeleteReceipt, type ForgeOrganizationId, ForgePolicyViolationError, ForgeRepositories, type ForgeRepository, type ForgeRepositoryCreateParams, type ForgeRepositoryDeleteOptions, type ForgeRepositoryId, type ForgeRepositoryState, type ForgeRepositoryUpdateParams, type ForgeRepositoryVisibility, ForgeStorageError, ForgeUnavailableError, type FsEntry, type FsListResponse, type FsStat, type FunctionCreateParams, type FunctionData, type FunctionId, type FunctionInvokeParams, type FunctionListParams, type FunctionUpdateParams, Functions, type GithubRepo, type GithubSshKey, type HealthCheckCreateParams, type HealthCheckData, type HealthCheckId, type HealthCheckListParams, type HealthCheckUpdateParams, HealthChecks, type HostCreateParams, type HostData, type HostEvent, type HostId, type HostListResponse, type HostStatus, type HostUpdateParams, InstallationRequiredError, InsufficientCreditsError, type IntegrationCatalogEntry, type IntegrationData, Integrations, type JobData, type JobEvent, type JobEventType, type JobId, type JobListResponse, type JobRunParams, type JobStatus, type KeyParams, type LaunchParams, type LinearCreateIssueParams, type ListAdminApiKeysParams, type ListAdminComputersParams, type ListAdminTenantsParams, type ListAdminUsersParams, ManagedProviderBindingOnlyError, Mcp, type McpDispatchParams, Miosa, type MiosaClientConfig, MiosaError, type MiosaErrorBody, type MkdirParams, type ModeParams, Models, type MouseButton, NetworkError, NetworkPolicy, type NetworkPolicyData, type NetworkPolicyEffect, type NetworkPolicyProtocol, type NetworkPolicyRule, type NetworkPolicySetParams, NotFoundError, type NotificationPrefsUpdateParams, OAuthFlow, type OauthConnectParams, type OauthProvider, type OauthStartResult, type OauthStatusResult, type ObjectListParams, type AgentEvent as OcAgentEvent, type OcAgentSessionData, type AgentSessionListResponse as OcAgentSessionListResponse, type OcWorkspaceCreateParams, type OcWorkspaceData, type OcWorkspaceEvent, type OcWorkspaceListResponse, type OcWorkspaceStatus, type OcWorkspaceUpdateParams, OpenComputers, type OrgInvite, type OrgInviteCreated, type OrgInviteCreatedResponse, type OrgInviteListResponse, type OrgInvitePreview, type OrgInviteRevokeResponse, OrgInvites, type OrgRole, type OrganizationMember, type OrganizationMemberList, type OrganizationMemberRemoved, OrganizationMembers, type OrganizationRole, type OrganizationSummary, type OrganizationSwitchResult, Organizations, type OverviewData, type PolicyCreateParams, type PolicyListParams, type PolicyUpdateParams, type PresignParams, type PresignResult, type PreviewDomainData, type ProductCatalogEntry, type ProductTemplate, type ProductTemplateCatalog, ProjectAuth, type ProjectAuthEnableParams, type ProjectAuthStatus, type ProjectAuthUpdateParams, type ProjectIntegrationCatalogEntry, type ProjectIntegrationCreateParams, type ProjectIntegrationData, type ProjectIntegrationListParams, type ProjectIntegrationUpdateParams, ProjectIntegrations, ProjectNotLinkedError, ProviderDefaults, type ProviderKeyUpsertParams, type PublishFromSandboxParams, type PublishParams, type PublishResult, RateLimitError, type RegionData, Regions, type RollbackParams, type RulesListParams, type Run, type RunActivity, type RunCommandOutput, type RunCreateParams, type RunDiagnostic, type RunDownload, type RunFile, type RunGroup, type RunGroupActivity, type RunGroupCounts, type RunGroupCreateParams, type RunGroupDispatchEntry, type RunGroupDispatchResult, type RunGroupFile, type RunGroupListParams, type RunGroupStatus, type RunGroupWaitOptions, RunGroups, type RunListParams, type RunMessage, type RunOutputs, type RunPreview, type RunStatus, type RunTargetKind, type RunWaitOptions, Runs, type RuntimeCapabilities, RuntimeCapabilitiesResource, RuntimeEnv, type RuntimeEnvListParams, type RuntimeEnvScope, type RuntimeEnvSetParams, type RuntimeEnvTarget, type RuntimeEnvVar, type RuntimeInstanceData, type RuntimeInstanceId, type RuntimeInstanceState, type RuntimeLogsResult, SANDBOX_TEMPLATE, Sandbox, SandboxAudit, type SandboxBuildSpec, type SandboxBuildSpecError, type SandboxBuildSpecValidation, SandboxCommands, type SandboxConnectorAttachParams, type SandboxConnectorBinding, type SandboxConnectorPreflightParams, type SandboxConnectorPreflightResult, SandboxConnectors, type SandboxCreateParams, type SandboxData, SandboxEnv, SandboxEvents, type SandboxExecEvent, type SandboxExecOptions, type SandboxExecResult, type SandboxExecRunner, SandboxFiles, type SandboxGetOrCreateParams, type SandboxId, type SandboxListParams, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, type SandboxState, SandboxTags, type SandboxTemplate, type SandboxTemplateBuild, type SandboxTemplateBuildCreateParams, type SandboxTemplateBuildResourceData, type SandboxTemplateBuildResourceId, type SandboxTemplateCreateParams, type SandboxTemplateList, type SandboxTemplateListParams, type SandboxTemplateResourceData, type SandboxTemplateResourceId, SandboxTemplates, SandboxTerminal, Sandboxes, ScopeNotAllowedError, ScopedFs, type ScrollDirection, type ScrollParams, type SecretCreateParams, type SecretData, type SecretId, type SecretListParams, type SecretRotateParams, type SecretSetParams, type SecretUpdateParams, type SessionId, Settings, type SettingsUpdateParams, type SizeData, type SlackSendTestParams, type SnapshotCreateParams, type SnapshotData, type SnapshotListResponse, type SnapshotProgressEvent, type SnapshotRestoreResult, type SnapshotStatus, SnapshotsStandalone, Storage, type StorageObjectData, SubjectNotAllowedError, type SuggestionsParams, type TemplateBenchmarkLane, type TemplateBuildCreateParams, type TemplateCreateParams, type TemplateData, type TemplateReadinessContract, type TemplateReadinessState, type TemplateSizeReadiness, Templates, type TemplatesListParams, Tenant, type TenantBrandingUpdateParams, type TenantId, type TenantPlan, type TenantSummary, type TerminalCreateParams, TimeoutError, type TimeseriesParams, TokenRefreshFailedError, type TunnelAuthMode, type TunnelCreateParams, type TunnelData, type TunnelId, type TunnelListResponse, type TunnelUpdateParams, type TypeParams, type UpdateWorkspaceMemberRoleParams, Usage, type UsageReportParams, type UsageSession, type UsageSessionsParams, type UsageSummary, UserAuthorizationRequiredError, type UserId, ValidationError, type VersionListParams, type VolumeAttachParams, type VolumeAttachmentData, type VolumeCreateParams, type VolumeData, type VolumeId, type VolumeListParams, Volumes, type WaitParams, type WebhookCreateParams, type WebhookData, type WebhookDeliveryData, type WebhookDeliveryId, type WebhookId, type WebhookListParams, type WebhookUpdateParams, Webhooks, type WindowFocusParams, type WindowInfo, type WorkspaceId, type WorkspaceInvite, type WorkspaceInviteCreatedResponse, type WorkspaceInviteListResponse, type WorkspaceInvitePreview, type WorkspaceInviteRevokeResponse, WorkspaceInvites, type WorkspaceMember, type WorkspaceMemberAddedResponse, type WorkspaceMemberDeleteResponse, type WorkspaceMemberListResponse, type WorkspaceMemberRecord, type WorkspaceMemberRecordResponse, WorkspaceMembers, type WorkspaceRole, type WsTicket, createAgentBuildExecutionPacket, createAgentBuildExpectedOutputs, createAgentBuildPrompt, createBuildRunParams, getAgentBuildKindSpec, resolveAgentBuildKind, verifySignature };
8887
+ export { AGENT_BUILD_KIND_SPECS, type AcceptOrgInviteResponse, type AcceptWorkspaceInviteResponse, type AddDomainParams, type AddWorkspaceMemberParams, Admin, type AgentBuildExecutionPacket, type AgentBuildFileSpec, type AgentBuildKind, type AgentBuildKindSpec, type AgentBuildPlannerDocument, type AgentDefinitionCreateParams, type AgentDefinitionData, type AgentDefinitionListParams, type AgentDefinitionUpdateParams, AgentDefinitions, type AgentDispatchParams, type AgentEvent$1 as AgentEvent, type AgentEventType, AgentRuntimeProfiles, type AgentSessionCreateParams, type AgentSessionData, type AgentSessionListResponse$1 as AgentSessionListResponse, type AgentSessionStatus$1 as AgentSessionStatus, type AgentVersionData, type AllowParams, Analytics, type AnalyticsFilters, type ApiKeyCreateParams, type ApiKeyCreateResult, type ApiKeyData, type ApiKeyId, type ApiKeyListParams, ApiKeys, type AppActionDecision, AppAuth, type AppAuthConfig, type AppAuthResourceType, type AppAuthSession, type AppAuthTokenPayload, type AppAutomationRun, type AppCatalogEntry, type AppCollectionRecord, type AppDocument, type AppDocumentCreateParams, type AppDocumentDiagnostics, type AppDocumentRecord, type AppDocumentUpdateParams, AppDocuments, type AppInstallData, type AppInstallEvent, type AppJson, type AppReleaseApproval, type AppReleaseCandidate, type AttachAwsRoleParams, type AuditListParams, AuditLog, type AuditLogEvent, type AuditLogListParams, type AuditTailParams, AuthError, type AuthToken, type BenchmarkCompareParams, type BenchmarkCreateParams, Benchmarks, type BindingCreateParams, type BindingListParams, type BrandingData, type BrandingUpdateParams, type BucketCreateParams, type BucketData, type BucketId, type BuilderSessionListParams, BuilderSessions, type BulkUserActionParams, type ChannelCreateParams, type ChannelData, type ChannelListParams, type ChannelUpdateParams, Channels, type ChatCompletionCreateParams, type ChatCompletionCreateStreamParams, Checkpoints, type ClickParams, Cloud, type CloudAccount, type CloudAccountCreateParams, type CloudAccountMode, type CloudAccountStatus, type CloudCredentialType, type CloudListParams, type CloudPlacementScope, type CloudPool, type CloudPoolCreateParams, type CloudPoolKind, type CloudPreflightRecordParams, type CloudPreflightRun, type CloudPreflightStatus, type CloudProvider, type CloudRegion, type CloudRegionCreateParams, type ClusterCreateParams, type ClusterData, type ClusterEvent, type ClusterId, type ClusterListResponse, type ClusterStatus, CommandCenter, Community, type CompletionCreateParams, type CompletionCreateStreamParams, Completions, type ComputeProduct, Computer, ComputerAudit, ComputerAutoStop, ComputerConnectors, type ComputerCreateParams, type ComputerData, ComputerEnv, type ComputerId, ComputerInbox, type ComputerListParams, type ComputerListResponse, ComputerLogs, type ComputerLogsGetParams, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, type ComputerSize, type ComputerStatus, type ComputerTemplateType, ComputerTerminal, type ComputerUpdateParams, type ComputerVisibility, ComputerVolumes, Computers, type ConnectorApplicableDefaultParams, type ConnectorCreateParams, type ConnectorData, type ConnectorDefault, type ConnectorDefaultListParams, type ConnectorDefaultParams, type ConnectorListParams, type ConnectorSubject, type ConnectorTokenParams, type ConnectorTokenResponse, Connectors, type CopyParams, type CreateAdminApiKeyParams, type CreateAgentBuildPacketParams, type CreateBuildRunParams, type CreateOrgInviteParams, type CreateWorkspaceInviteParams, type CreateWorkspaceInviteResponse, type CreditBalance, type CreditTransaction, type CreditTransactionListResponse, type CreditUsage, Credits, type CronJobCreateParams, type CronJobData, type CronJobExecutionData, type CronJobExecutionId, type CronJobId, type CronJobListParams, type CronJobUpdateParams, CronJobs, type CursorInfo, type CustomDomainCreateParams, type CustomDomainData, type CustomDomainId, type CustomDomainListParams, DEFAULT_AGENT_BUILD_OUTPUT_ROOT, DEFAULT_AGENT_BUILD_PACKET_VERSION, Dashboard, type DashboardSummary, type DatabaseCreateParams, type DatabaseCredentials, type DatabaseData, type DatabaseId, type DatabaseListParams, type DatabaseLogsParams, type DatabaseLogsResult, Databases, type DeploymentBuildData, DeploymentConnectors, type DeploymentCreateParams, type DeploymentData, DeploymentDomains, type DeploymentId, type DeploymentListParams, type DeploymentProduct, type DeploymentProofCheck, type DeploymentProofParams, type DeploymentProofProbe, type DeploymentProofResult, type DeploymentReleaseData, type DeploymentReleaseId, DeploymentReleases, DeploymentRuntimeInstances, type DeploymentServiceData, type DeploymentServiceId, type DeploymentServiceType, type DeploymentSourceType, type DeploymentState, type DeploymentUpdateParams, type DeploymentVersionData, type DeploymentVersionId, type DeploymentVersionKind, type DeploymentVersionState, DeploymentVersions, Deployments, Desktop$1 as Desktop, type DesktopActionResult, type DeviceBootstrapParams, type DeviceBootstrapResult, type DeviceBrowserResult, type DeviceCapabilities, type DeviceData, type DeviceExecParams, type DeviceExecResult, type DeviceExposeParams, type DeviceExposeResult, type DeviceExtendParams, type DeviceFileEntry, type DeviceFileListParams, type DeviceKind, type DeviceLifecycleResult, type DeviceListParams, type DeviceReadFileParams, type DeviceReadFileResult, type DeviceWriteFileParams, type DeviceWriteFileResult, Devices, type DirEntry, type DirListResult, type DiscordSendTestParams, DockerDeploy, type DockerDeployApplianceStatus, type DockerDeployCreateParams, type DockerDeployDoctorCheck, type DockerDeployDoctorParams, type DockerDeployDoctorProbe, type DockerDeployDoctorResult, type DockerDeployHostData, type DockerDeployHostEnsureParams, type DockerDeployHostId, type DockerDeployHostListParams, type DockerDeployHostListResponse, type DockerDeployHostResponse, type DockerDeployHostStatus, type DoubleClickParams, type DragParams, type EgressAllowlistRule, EgressAudit, type EgressAuditEvent, type EgressBindingData, EgressHostNotAllowedError, EgressNetwork, type EgressPolicyData, type EgressPolicyMode, type EgressRuleEffect, type EgressSecretData, type EgressSecretScope, type EgressSecretType, EgressSecrets, type EgressSuggestion, Email, EmailCampaigns, EmailInbox, EmailTemplates, type EmbeddingCreateParams, Embeddings, Exec, type ExecParams, type ExecPythonParams, type ExecResult, type ExternalAttribution, type ExternalKeyCreateParams, type ExternalKeyData, ExternalKeys, type FileDeleteParams, type FileDownloadParams, type FileEntry, type FileExportParams, type FileExportResult, type FileListParams, type FileListResult, type FileStat, Files, FlatCustomDomains, Forge, ForgeContractError, type ForgeDeleteReceipt, type ForgeOrganizationId, ForgePolicyViolationError, ForgeRepositories, type ForgeRepository, type ForgeRepositoryCreateParams, type ForgeRepositoryDeleteOptions, type ForgeRepositoryId, type ForgeRepositoryState, type ForgeRepositoryUpdateParams, type ForgeRepositoryVisibility, ForgeStorageError, ForgeUnavailableError, type FsEntry, type FsListResponse, type FsStat, type FunctionCreateParams, type FunctionData, type FunctionId, type FunctionInvokeParams, type FunctionListParams, type FunctionUpdateParams, Functions, type GithubRepo, type GithubSshKey, type HealthCheckCreateParams, type HealthCheckData, type HealthCheckId, type HealthCheckListParams, type HealthCheckUpdateParams, HealthChecks, type HostCreateParams, type HostData, type HostEvent, type HostId, type HostListResponse, type HostStatus, type HostUpdateParams, InstallationRequiredError, InsufficientCreditsError, type IntegrationCatalogEntry, type IntegrationData, Integrations, type JobData, type JobEvent, type JobEventType, type JobId, type JobListResponse, type JobRunParams, type JobStatus, type KeyParams, type LaunchParams, type LinearCreateIssueParams, type ListAdminApiKeysParams, type ListAdminComputersParams, type ListAdminTenantsParams, type ListAdminUsersParams, ManagedProviderBindingOnlyError, Mcp, type McpDispatchParams, Miosa, type MiosaClientConfig, MiosaError, type MiosaErrorBody, type MkdirParams, type ModeParams, Models, type MouseButton, NetworkError, NetworkPolicy, type NetworkPolicyData, type NetworkPolicyEffect, type NetworkPolicyProtocol, type NetworkPolicyRule, type NetworkPolicySetParams, NotFoundError, type NotificationPrefsUpdateParams, OAuthFlow, type OauthConnectParams, type OauthProvider, type OauthStartResult, type OauthStatusResult, type ObjectListParams, type AgentEvent as OcAgentEvent, type OcAgentSessionData, type AgentSessionListResponse as OcAgentSessionListResponse, type OcWorkspaceCreateParams, type OcWorkspaceData, type OcWorkspaceEvent, type OcWorkspaceListResponse, type OcWorkspaceStatus, type OcWorkspaceUpdateParams, OpenComputers, type OrgInvite, type OrgInviteCreated, type OrgInviteCreatedResponse, type OrgInviteListResponse, type OrgInvitePreview, type OrgInviteRevokeResponse, OrgInvites, type OrgRole, type OrganizationMember, type OrganizationMemberList, type OrganizationMemberRemoved, OrganizationMembers, type OrganizationRole, type OrganizationSummary, type OrganizationSwitchResult, Organizations, type OverviewData, type PolicyCreateParams, type PolicyListParams, type PolicyUpdateParams, type PresignParams, type PresignResult, type PreviewDomainData, type ProductCatalogEntry, type ProductTemplate, type ProductTemplateCatalog, ProjectAuth, type ProjectAuthEnableParams, type ProjectAuthStatus, type ProjectAuthUpdateParams, type ProjectIntegrationCatalogEntry, type ProjectIntegrationCreateParams, type ProjectIntegrationData, type ProjectIntegrationListParams, type ProjectIntegrationUpdateParams, ProjectIntegrations, ProjectNotLinkedError, ProviderDefaults, type ProviderKeyUpsertParams, type PublishFromSandboxParams, type PublishParams, type PublishResult, RateLimitError, type RegionData, Regions, type RollbackParams, type RulesListParams, type Run, type RunActivity, type RunCommandOutput, type RunCreateParams, type RunDiagnostic, type RunDownload, type RunFile, type RunGroup, type RunGroupActivity, type RunGroupCounts, type RunGroupCreateParams, type RunGroupDispatchEntry, type RunGroupDispatchResult, type RunGroupFile, type RunGroupListParams, type RunGroupStatus, type RunGroupWaitOptions, RunGroups, type RunListParams, type RunMessage, type RunOutputs, type RunPreview, type RunStatus, type RunTargetKind, type RunWaitOptions, Runs, type RuntimeCapabilities, RuntimeCapabilitiesResource, RuntimeEnv, type RuntimeEnvListParams, type RuntimeEnvScope, type RuntimeEnvSetParams, type RuntimeEnvTarget, type RuntimeEnvVar, type RuntimeInstanceData, type RuntimeInstanceId, type RuntimeInstanceState, type RuntimeLogsResult, SANDBOX_TEMPLATE, Sandbox, SandboxAudit, type SandboxBuildSpec, type SandboxBuildSpecError, type SandboxBuildSpecValidation, SandboxCommands, type SandboxConnectorAttachParams, type SandboxConnectorBinding, type SandboxConnectorPreflightParams, type SandboxConnectorPreflightResult, SandboxConnectors, type SandboxCreateParams, type SandboxData, SandboxEnv, SandboxEvents, type SandboxExecEvent, type SandboxExecOptions, type SandboxExecResult, type SandboxExecRunner, SandboxFiles, type SandboxGetOrCreateParams, type SandboxId, type SandboxListParams, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, type SandboxState, SandboxTags, type SandboxTemplate, type SandboxTemplateBuild, type SandboxTemplateBuildCreateParams, type SandboxTemplateBuildResourceData, type SandboxTemplateBuildResourceId, type SandboxTemplateCreateParams, type SandboxTemplateList, type SandboxTemplateListParams, type SandboxTemplateResourceData, type SandboxTemplateResourceId, SandboxTemplates, SandboxTerminal, type SandboxTerminalCreateParams, type SandboxTerminalSession, Sandboxes, ScopeNotAllowedError, ScopedFs, type ScrollDirection, type ScrollParams, type SecretCreateParams, type SecretData, type SecretId, type SecretListParams, type SecretRotateParams, type SecretSetParams, type SecretUpdateParams, type SessionId, Settings, type SettingsUpdateParams, type SizeData, type SlackSendTestParams, type SnapshotCreateParams, type SnapshotData, type SnapshotListResponse, type SnapshotProgressEvent, type SnapshotRestoreResult, type SnapshotStatus, SnapshotsStandalone, Storage, type StorageObjectData, SubjectNotAllowedError, type SuggestionsParams, type TemplateBenchmarkLane, type TemplateBuildCreateParams, type TemplateCreateParams, type TemplateData, type TemplateReadinessContract, type TemplateReadinessState, type TemplateSizeReadiness, Templates, type TemplatesListParams, Tenant, type TenantBrandingUpdateParams, type TenantId, type TenantPlan, type TenantSummary, type TerminalCreateParams, TimeoutError, type TimeseriesParams, TokenRefreshFailedError, type TunnelAuthMode, type TunnelCreateParams, type TunnelData, type TunnelId, type TunnelListResponse, type TunnelUpdateParams, type TypeParams, type UpdateWorkspaceMemberRoleParams, Usage, type UsageReportParams, type UsageSession, type UsageSessionsParams, type UsageSummary, UserAuthorizationRequiredError, type UserId, ValidationError, type VersionListParams, type VolumeAttachParams, type VolumeAttachmentData, type VolumeCreateParams, type VolumeData, type VolumeId, type VolumeListParams, Volumes, type WaitParams, type WebhookCreateParams, type WebhookData, type WebhookDeliveryData, type WebhookDeliveryId, type WebhookId, type WebhookListParams, type WebhookUpdateParams, Webhooks, type WindowFocusParams, type WindowInfo, type WorkspaceId, type WorkspaceInvite, type WorkspaceInviteCreatedResponse, type WorkspaceInviteListResponse, type WorkspaceInvitePreview, type WorkspaceInviteRevokeResponse, WorkspaceInvites, type WorkspaceMember, type WorkspaceMemberAddedResponse, type WorkspaceMemberDeleteResponse, type WorkspaceMemberListResponse, type WorkspaceMemberRecord, type WorkspaceMemberRecordResponse, WorkspaceMembers, type WorkspaceRole, type WsTicket, createAgentBuildExecutionPacket, createAgentBuildExpectedOutputs, createAgentBuildPrompt, createBuildRunParams, getAgentBuildKindSpec, resolveAgentBuildKind, verifySignature };
package/dist/index.js CHANGED
@@ -9,18 +9,23 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
9
9
  });
10
10
 
11
11
  // src/errors.ts
12
+ function defaultRetryable(status) {
13
+ return status === 408 || status === 429 || status >= 500;
14
+ }
12
15
  var MiosaError = class _MiosaError extends Error {
13
16
  status;
14
17
  code;
15
18
  details;
16
19
  requestId;
17
- constructor(message, status, code, details, requestId) {
20
+ retryable;
21
+ constructor(message, status, code, details, requestId, retryable = defaultRetryable(status)) {
18
22
  super(message);
19
23
  this.name = "MiosaError";
20
24
  this.status = status;
21
25
  this.code = code;
22
26
  this.details = details;
23
27
  this.requestId = requestId;
28
+ this.retryable = retryable;
24
29
  }
25
30
  static fromResponse(status, body5, requestId) {
26
31
  const nested = typeof body5.error === "object" ? body5.error : void 0;
@@ -30,145 +35,146 @@ var MiosaError = class _MiosaError extends Error {
30
35
  const code = nested?.code ?? body5.code ?? (flatErrorIsCode ? flatError : "UNKNOWN_ERROR");
31
36
  const details = nested?.details ?? body5.details ?? (body5.detail || body5.reason ? { detail: body5.detail, reason: body5.reason } : void 0);
32
37
  requestId ??= body5.request_id;
33
- const connectError = connectErrorFromCode(code, message, status, details, requestId);
38
+ const retryable = nested?.retryable ?? body5.retryable ?? defaultRetryable(status);
39
+ const connectError = connectErrorFromCode(code, message, status, details, requestId, retryable);
34
40
  if (connectError) return connectError;
35
41
  if (status === 401 || status === 403) {
36
- return new AuthError(message, status, code, details, requestId);
42
+ return new AuthError(message, status, code, details, requestId, retryable);
37
43
  }
38
44
  if (status === 404) {
39
- return new NotFoundError(message, code, details, requestId);
45
+ return new NotFoundError(message, code, details, requestId, retryable);
40
46
  }
41
47
  if (status === 429) {
42
- return new RateLimitError(message, details, requestId);
48
+ return new RateLimitError(message, details, requestId, void 0, retryable);
43
49
  }
44
50
  if (status === 402) {
45
- return new InsufficientCreditsError(message, details, requestId);
51
+ return new InsufficientCreditsError(message, details, requestId, retryable);
46
52
  }
47
53
  if (status >= 400 && status < 500) {
48
- return new ValidationError(message, status, code, details, requestId);
54
+ return new ValidationError(message, status, code, details, requestId, retryable);
49
55
  }
50
- return new _MiosaError(message, status, code, details, requestId);
56
+ return new _MiosaError(message, status, code, details, requestId, retryable);
51
57
  }
52
58
  };
53
- function connectErrorFromCode(code, message, status, details, requestId) {
59
+ function connectErrorFromCode(code, message, status, details, requestId, retryable) {
54
60
  switch (code) {
55
61
  case "PROJECT_NOT_LINKED":
56
- return new ProjectNotLinkedError(message, status, details, requestId);
62
+ return new ProjectNotLinkedError(message, status, details, requestId, retryable);
57
63
  case "SUBJECT_NOT_ALLOWED":
58
- return new SubjectNotAllowedError(message, status, details, requestId);
64
+ return new SubjectNotAllowedError(message, status, details, requestId, retryable);
59
65
  case "SCOPE_NOT_ALLOWED":
60
- return new ScopeNotAllowedError(message, status, details, requestId);
66
+ return new ScopeNotAllowedError(message, status, details, requestId, retryable);
61
67
  case "MANAGED_PROVIDER_BINDING_ONLY":
62
- return new ManagedProviderBindingOnlyError(message, status, details, requestId);
68
+ return new ManagedProviderBindingOnlyError(message, status, details, requestId, retryable);
63
69
  case "INSTALLATION_REQUIRED":
64
- return new InstallationRequiredError(message, status, details, requestId);
70
+ return new InstallationRequiredError(message, status, details, requestId, retryable);
65
71
  case "USER_AUTHORIZATION_REQUIRED":
66
- return new UserAuthorizationRequiredError(message, status, details, requestId);
72
+ return new UserAuthorizationRequiredError(message, status, details, requestId, retryable);
67
73
  case "EGRESS_HOST_NOT_ALLOWED":
68
- return new EgressHostNotAllowedError(message, status, details, requestId);
74
+ return new EgressHostNotAllowedError(message, status, details, requestId, retryable);
69
75
  case "TOKEN_REFRESH_FAILED":
70
- return new TokenRefreshFailedError(message, status, details, requestId);
76
+ return new TokenRefreshFailedError(message, status, details, requestId, retryable);
71
77
  default:
72
78
  return void 0;
73
79
  }
74
80
  }
75
81
  var AuthError = class extends MiosaError {
76
- constructor(message, status = 401, code = "UNAUTHORIZED", details, requestId) {
77
- super(message, status, code, details, requestId);
82
+ constructor(message, status = 401, code = "UNAUTHORIZED", details, requestId, retryable) {
83
+ super(message, status, code, details, requestId, retryable);
78
84
  this.name = "AuthError";
79
85
  }
80
86
  };
81
87
  var NotFoundError = class extends MiosaError {
82
- constructor(message, code = "NOT_FOUND", details, requestId) {
83
- super(message, 404, code, details, requestId);
88
+ constructor(message, code = "NOT_FOUND", details, requestId, retryable) {
89
+ super(message, 404, code, details, requestId, retryable);
84
90
  this.name = "NotFoundError";
85
91
  }
86
92
  };
87
93
  var RateLimitError = class extends MiosaError {
88
94
  retryAfter;
89
- constructor(message, details, requestId, retryAfter) {
90
- super(message, 429, "RATE_LIMITED", details, requestId);
95
+ constructor(message, details, requestId, retryAfter, retryable) {
96
+ super(message, 429, "RATE_LIMITED", details, requestId, retryable);
91
97
  this.name = "RateLimitError";
92
98
  this.retryAfter = retryAfter;
93
99
  }
94
100
  };
95
101
  var InsufficientCreditsError = class extends MiosaError {
96
- constructor(message, details, requestId) {
97
- super(message, 402, "INSUFFICIENT_CREDITS", details, requestId);
102
+ constructor(message, details, requestId, retryable) {
103
+ super(message, 402, "INSUFFICIENT_CREDITS", details, requestId, retryable);
98
104
  this.name = "InsufficientCreditsError";
99
105
  }
100
106
  };
101
107
  var ValidationError = class extends MiosaError {
102
- constructor(message, status, code = "VALIDATION_ERROR", details, requestId) {
103
- super(message, status, code, details, requestId);
108
+ constructor(message, status, code = "VALIDATION_ERROR", details, requestId, retryable) {
109
+ super(message, status, code, details, requestId, retryable);
104
110
  this.name = "ValidationError";
105
111
  }
106
112
  };
107
113
  var TimeoutError = class extends MiosaError {
108
114
  constructor(message = "Request timed out") {
109
- super(message, 408, "TIMEOUT");
115
+ super(message, 408, "TIMEOUT", void 0, void 0, true);
110
116
  this.name = "TimeoutError";
111
117
  }
112
118
  };
113
119
  var NetworkError = class extends MiosaError {
114
120
  cause;
115
121
  constructor(message, cause) {
116
- super(message, 0, "NETWORK_ERROR");
122
+ super(message, 0, "NETWORK_ERROR", void 0, void 0, true);
117
123
  this.name = "NetworkError";
118
124
  this.cause = cause;
119
125
  }
120
126
  };
121
127
  var ProjectNotLinkedError = class extends MiosaError {
122
- constructor(message, status = 403, details, requestId) {
123
- super(message, status, "PROJECT_NOT_LINKED", details, requestId);
128
+ constructor(message, status = 403, details, requestId, retryable) {
129
+ super(message, status, "PROJECT_NOT_LINKED", details, requestId, retryable);
124
130
  this.name = "ProjectNotLinkedError";
125
131
  }
126
132
  };
127
133
  var SubjectNotAllowedError = class extends MiosaError {
128
- constructor(message, status = 403, details, requestId) {
129
- super(message, status, "SUBJECT_NOT_ALLOWED", details, requestId);
134
+ constructor(message, status = 403, details, requestId, retryable) {
135
+ super(message, status, "SUBJECT_NOT_ALLOWED", details, requestId, retryable);
130
136
  this.name = "SubjectNotAllowedError";
131
137
  }
132
138
  };
133
139
  var ScopeNotAllowedError = class extends MiosaError {
134
- constructor(message, status = 403, details, requestId) {
135
- super(message, status, "SCOPE_NOT_ALLOWED", details, requestId);
140
+ constructor(message, status = 403, details, requestId, retryable) {
141
+ super(message, status, "SCOPE_NOT_ALLOWED", details, requestId, retryable);
136
142
  this.name = "ScopeNotAllowedError";
137
143
  }
138
144
  };
139
145
  var ManagedProviderBindingOnlyError = class extends MiosaError {
140
- constructor(message, status = 403, details, requestId) {
141
- super(message, status, "MANAGED_PROVIDER_BINDING_ONLY", details, requestId);
146
+ constructor(message, status = 403, details, requestId, retryable) {
147
+ super(message, status, "MANAGED_PROVIDER_BINDING_ONLY", details, requestId, retryable);
142
148
  this.name = "ManagedProviderBindingOnlyError";
143
149
  }
144
150
  };
145
151
  var InstallationRequiredError = class extends MiosaError {
146
- constructor(message, status = 409, details, requestId) {
147
- super(message, status, "INSTALLATION_REQUIRED", details, requestId);
152
+ constructor(message, status = 409, details, requestId, retryable) {
153
+ super(message, status, "INSTALLATION_REQUIRED", details, requestId, retryable);
148
154
  this.name = "InstallationRequiredError";
149
155
  }
150
156
  };
151
157
  var UserAuthorizationRequiredError = class extends MiosaError {
152
- constructor(message, status = 403, details, requestId) {
153
- super(message, status, "USER_AUTHORIZATION_REQUIRED", details, requestId);
158
+ constructor(message, status = 403, details, requestId, retryable) {
159
+ super(message, status, "USER_AUTHORIZATION_REQUIRED", details, requestId, retryable);
154
160
  this.name = "UserAuthorizationRequiredError";
155
161
  }
156
162
  };
157
163
  var EgressHostNotAllowedError = class extends MiosaError {
158
- constructor(message, status = 403, details, requestId) {
159
- super(message, status, "EGRESS_HOST_NOT_ALLOWED", details, requestId);
164
+ constructor(message, status = 403, details, requestId, retryable) {
165
+ super(message, status, "EGRESS_HOST_NOT_ALLOWED", details, requestId, retryable);
160
166
  this.name = "EgressHostNotAllowedError";
161
167
  }
162
168
  };
163
169
  var TokenRefreshFailedError = class extends MiosaError {
164
- constructor(message, status = 502, details, requestId) {
165
- super(message, status, "TOKEN_REFRESH_FAILED", details, requestId);
170
+ constructor(message, status = 502, details, requestId, retryable) {
171
+ super(message, status, "TOKEN_REFRESH_FAILED", details, requestId, retryable);
166
172
  this.name = "TokenRefreshFailedError";
167
173
  }
168
174
  };
169
175
 
170
176
  // src/version.ts
171
- var SDK_VERSION = "3.2.1";
177
+ var SDK_VERSION = "3.2.2";
172
178
  var SDK_USER_AGENT = `@miosa/sdk/${SDK_VERSION}`;
173
179
 
174
180
  // src/http.ts
@@ -331,7 +337,14 @@ var HttpClient = class {
331
337
  throw err;
332
338
  }
333
339
  }
334
- throw lastError ?? new MiosaError("Max retries exceeded", 0, "MAX_RETRIES_EXCEEDED");
340
+ throw lastError ?? new MiosaError(
341
+ "Max retries exceeded",
342
+ 0,
343
+ "MAX_RETRIES_EXCEEDED",
344
+ void 0,
345
+ void 0,
346
+ true
347
+ );
335
348
  }
336
349
  async get(path, query3) {
337
350
  let fullPath = path;
@@ -8784,7 +8797,7 @@ var SandboxTerminal = class {
8784
8797
  const response = unwrap48(
8785
8798
  await this.sandbox.http.post(`/sandboxes/${this.sandbox.id}/terminal`, body5)
8786
8799
  );
8787
- return response;
8800
+ return normalizeTerminalSession(response);
8788
8801
  }
8789
8802
  async delete(sessionId) {
8790
8803
  await this.sandbox.http.delete(
@@ -8792,6 +8805,35 @@ var SandboxTerminal = class {
8792
8805
  );
8793
8806
  }
8794
8807
  };
8808
+ function normalizeTerminalSession(payload) {
8809
+ const sessionId = payload.session_id;
8810
+ const wsUrl = payload.ws_url;
8811
+ const streamAuth = payload.stream_auth;
8812
+ const streamAuthExpiresAt = payload.stream_auth_expires_at;
8813
+ const expiresAt = payload.expires_at;
8814
+ if (typeof sessionId !== "string" || typeof wsUrl !== "string" || typeof streamAuth !== "string" || typeof streamAuthExpiresAt !== "number" || typeof expiresAt !== "number") {
8815
+ throw new MiosaError(
8816
+ "Terminal create response did not contain a valid miosa-terminal-v1 session",
8817
+ 502,
8818
+ "INVALID_TERMINAL_SESSION",
8819
+ { received: Object.keys(payload) },
8820
+ void 0,
8821
+ false
8822
+ );
8823
+ }
8824
+ return {
8825
+ sessionId,
8826
+ wsUrl,
8827
+ streamAuth,
8828
+ streamAuthExpiresAt,
8829
+ expiresAt,
8830
+ session_id: sessionId,
8831
+ ws_url: wsUrl,
8832
+ stream_auth: streamAuth,
8833
+ stream_auth_expires_at: streamAuthExpiresAt,
8834
+ expires_at: expiresAt
8835
+ };
8836
+ }
8795
8837
  var SandboxEvents = class {
8796
8838
  constructor(sandbox) {
8797
8839
  this.sandbox = sandbox;
@@ -9520,7 +9562,9 @@ var Sandbox = class _Sandbox {
9520
9562
  `Sandbox ${this.id} entered terminal state '${state}' while waiting for readiness`,
9521
9563
  502,
9522
9564
  "SANDBOX_BOOT_FAILED",
9523
- { sandbox_id: this.id, state }
9565
+ { sandbox_id: this.id, state },
9566
+ void 0,
9567
+ false
9524
9568
  );
9525
9569
  }
9526
9570
  /** Best-effort final check so an SSE `event: timeout` does not mask a boot failure that just landed. */
@@ -9754,7 +9798,25 @@ var Sandboxes = class {
9754
9798
  await sandbox.resume();
9755
9799
  }
9756
9800
  if (params.waitUntilReady === true) {
9757
- await sandbox.waitUntilReady({ timeout: params.waitTimeoutSec ?? 60 });
9801
+ const ready = await sandbox.waitUntilReady({
9802
+ timeout: params.waitTimeoutSec ?? 60
9803
+ });
9804
+ if (!ready) {
9805
+ throw new MiosaError(
9806
+ `Sandbox ${sandbox.id} did not become ready before the timeout`,
9807
+ 504,
9808
+ "SANDBOX_READY_TIMEOUT"
9809
+ );
9810
+ }
9811
+ await sandbox.refresh();
9812
+ const executable = sandbox.state === "running" && (sandbox.ready || isCommandReady(await sandbox.readiness()));
9813
+ if (!executable) {
9814
+ throw new MiosaError(
9815
+ `Sandbox ${sandbox.id} reported readiness but is not executable`,
9816
+ 409,
9817
+ "SANDBOX_NOT_READY"
9818
+ );
9819
+ }
9758
9820
  }
9759
9821
  return sandbox;
9760
9822
  }