@miosa/sdk 1.2.1 → 1.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
@@ -38,7 +38,7 @@ console.log(result.stdout); // hello from miosa
38
38
 
39
39
  // Expose a live preview URL
40
40
  const url = await sbx.expose(3000);
41
- console.log(url); // https://3000-<slug>.sandbox.<tenant-domain>
41
+ console.log(url); // https://3000-<slug>.sandbox.miosa.ai
42
42
 
43
43
  await sbx.destroy();
44
44
  ```
package/dist/index.d.ts CHANGED
@@ -155,6 +155,13 @@ declare class Admin {
155
155
  optimalStatus(): Promise<Json>;
156
156
  listOptimalModels(): Promise<Json>;
157
157
  switchOptimalModel(modelId: string): Promise<Json>;
158
+ /** POST /api/v1/admin/impersonate — returns {token, expires_at}. */
159
+ impersonate(externalUserId: string, options?: {
160
+ ttlSec?: number;
161
+ }): Promise<{
162
+ token: string;
163
+ expires_at: string;
164
+ }>;
158
165
  }
159
166
 
160
167
  /**
@@ -221,6 +228,12 @@ declare class ApiKeys {
221
228
  constructor(http: HttpClient);
222
229
  list(params?: ApiKeyListParams): Promise<ApiKeyData[]>;
223
230
  create(params: ApiKeyCreateParams): Promise<ApiKeyCreateResult>;
231
+ /** POST /api/v1/api-keys/scoped — L2 delegation token bound to one external user. */
232
+ createScoped(params: {
233
+ externalUserId: string;
234
+ scopes: string[];
235
+ expiresAt?: string;
236
+ }): Promise<ApiKeyCreateResult>;
224
237
  delete(keyId: string): Promise<void>;
225
238
  }
226
239
 
@@ -639,7 +652,7 @@ interface CustomDomainData$1 {
639
652
  * // 1. Register the domain
640
653
  * const domain = await computer.domains.register("app.example.com");
641
654
  * console.log(domain.instructions);
642
- * // => "Add a CNAME record: app.example.com → <slug>.sandbox.<tenant-domain>"
655
+ * // => "Add a CNAME record: app.example.com → <slug>.sandbox.miosa.ai"
643
656
  *
644
657
  * // 2. Add the CNAME in your DNS registrar, then...
645
658
  *
@@ -755,9 +768,9 @@ interface ComputerData {
755
768
  id: ComputerId;
756
769
  name: string;
757
770
  /**
758
- * URL-safe identifier used in preview URLs:
759
- * `https://{port}-{slug}.sandbox.{preview_domain}`.
760
- * Falls back to the computer id when no slug is assigned.
771
+ * URL-safe identifier used in preview URLs: `https://{port}-{slug}.sandbox.{preview_domain}`.
772
+ * Falls back to the computer id when no slug is assigned. The domain is the
773
+ * tenant's white-label `preview_domain` (server-provided) never hardcode it.
761
774
  */
762
775
  slug: string;
763
776
  status: ComputerStatus;
@@ -768,9 +781,9 @@ interface ComputerData {
768
781
  metadata: Record<string, string>;
769
782
  /** Controls who can access the HTTP preview URL. Defaults to `"public"`. */
770
783
  visibility: ComputerVisibility;
771
- /** Public ingress root, e.g. `https://<slug>.sandbox.<preview_domain>`. */
784
+ /** Public ingress root, e.g. `https://<slug>.sandbox.<preview_domain>` (server-provided). */
772
785
  sandbox_url?: string;
773
- /** Tenant's white-label preview/base domain, e.g. `cliniciq.com`. */
786
+ /** Tenant's white-label preview/base domain (e.g. `cliniciq.com`). Use to build preview URLs. */
774
787
  preview_domain?: string;
775
788
  /** KasmVNC URL for desktop templates. */
776
789
  desktop_url?: string;
@@ -2566,6 +2579,7 @@ type DeploymentState = "pending" | "building" | "running" | "stopped" | "failed"
2566
2579
  type DeploymentVersionKind = "static" | "dynamic" | "sandbox_backed";
2567
2580
  type DeploymentVersionState = "created" | "building" | "ready" | "failed" | "archived";
2568
2581
  type DeploymentSourceType = "repo" | "sandbox" | "upload";
2582
+ type DeploymentProduct = "miosa_deploy" | "docker_deploy";
2569
2583
  type DeploymentServiceType = "static_web" | "web" | "api" | "function" | "worker" | "cron" | "postgres" | "redis" | "bucket" | "volume";
2570
2584
  type RuntimeInstanceState = "provisioning" | "starting" | "healthy" | "unhealthy" | "error" | "stopped" | "destroyed";
2571
2585
  interface ExternalAttribution {
@@ -2599,6 +2613,8 @@ interface DeploymentData {
2599
2613
  auto_deploy?: boolean;
2600
2614
  custom_domain_id?: string | null;
2601
2615
  linked_database_id?: string | null;
2616
+ deployment_product?: DeploymentProduct | string | null;
2617
+ docker_deploy_host_id?: string | null;
2602
2618
  metadata?: Record<string, unknown>;
2603
2619
  external_workspace_id?: string | null;
2604
2620
  external_user_id?: string | null;
@@ -2608,7 +2624,7 @@ interface DeploymentData {
2608
2624
  updated_at?: string;
2609
2625
  }
2610
2626
  type DeploymentDatabaseRequest = boolean | {
2611
- engine?: "postgresql" | "mysql" | "redis";
2627
+ engine?: "postgresql" | "mysql" | "redis" | "qdrant";
2612
2628
  size?: "xs" | "small" | "medium" | "large";
2613
2629
  storage_mb?: number;
2614
2630
  region?: string;
@@ -2760,6 +2776,8 @@ interface DeploymentCreateParams extends ExternalAttribution {
2760
2776
  metadata?: Record<string, unknown>;
2761
2777
  idempotencyKey?: string;
2762
2778
  }
2779
+ interface DockerDeployCreateParams extends DeploymentCreateParams {
2780
+ }
2763
2781
  interface DeploymentUpdateParams {
2764
2782
  name?: string;
2765
2783
  branch?: string;
@@ -2884,6 +2902,12 @@ declare class Deployments {
2884
2902
  list(params?: DeploymentListParams): Promise<DeploymentData[]>;
2885
2903
  get(deploymentId: string): Promise<DeploymentData>;
2886
2904
  create(params: DeploymentCreateParams): Promise<DeploymentData>;
2905
+ /**
2906
+ * Create a deployment that runs on the workspace's dedicated Docker Deploy
2907
+ * runtime. It uses the same /deployments API as MIOSA Deploy, but marks the
2908
+ * deployment so the control plane attaches it to the workspace Docker host.
2909
+ */
2910
+ createDockerDeploy(params: DockerDeployCreateParams): Promise<DeploymentData>;
2887
2911
  update(deploymentId: string, params: DeploymentUpdateParams): Promise<DeploymentData>;
2888
2912
  delete(deploymentId: string): Promise<void>;
2889
2913
  publish(deploymentId: string, params: PublishParams): Promise<PublishResult>;
@@ -4552,6 +4576,21 @@ interface SandboxDeployParams {
4552
4576
  sourceSnapshotPath?: string;
4553
4577
  source_snapshot_path?: string;
4554
4578
  entrypoint?: string;
4579
+ buildCommand?: string;
4580
+ build_command?: string;
4581
+ runCommand?: string;
4582
+ run_command?: string;
4583
+ startCommand?: string;
4584
+ start_command?: string;
4585
+ port?: number;
4586
+ healthCheckPath?: string;
4587
+ health_check_path?: string;
4588
+ deploymentType?: "miosa_deploy" | "docker_deploy" | "docker-deploy" | string;
4589
+ deployment_type?: "miosa_deploy" | "docker_deploy" | "docker-deploy" | string;
4590
+ type?: "static" | "dynamic" | "server" | string;
4591
+ mode?: "static" | "dynamic" | "server" | string;
4592
+ database?: boolean | Record<string, unknown>;
4593
+ resources?: Record<string, unknown>;
4555
4594
  domain?: string;
4556
4595
  customDomain?: string;
4557
4596
  custom_domain?: string;
@@ -4743,6 +4782,7 @@ declare class Sandbox {
4743
4782
  pause(): Promise<Sandbox>;
4744
4783
  resume(): Promise<Sandbox>;
4745
4784
  deploy(params?: SandboxDeployParams): Promise<Record<string, unknown>>;
4785
+ deployDocker(params?: SandboxDeployParams): Promise<Record<string, unknown>>;
4746
4786
  /** Check readiness of the sandbox (GET /sandboxes/:id/readiness). */
4747
4787
  readiness(): Promise<Record<string, unknown>>;
4748
4788
  /**
@@ -5131,10 +5171,34 @@ declare class OrgInvites {
5131
5171
  interface TenantPlan {
5132
5172
  id?: string;
5133
5173
  name?: string;
5174
+ preview_domain?: string | null;
5175
+ deployment_domain?: string | null;
5176
+ fallback_miosa_domain?: string | null;
5134
5177
  limits?: Record<string, unknown>;
5135
5178
  usage?: Record<string, unknown>;
5136
5179
  [key: string]: unknown;
5137
5180
  }
5181
+ interface BrandingData {
5182
+ logo_url?: string | null;
5183
+ primary_color?: string | null;
5184
+ wordmark?: string | null;
5185
+ favicon_url?: string | null;
5186
+ [key: string]: unknown;
5187
+ }
5188
+ interface PreviewDomainData {
5189
+ preview_domain?: string | null;
5190
+ deployment_domain?: string | null;
5191
+ fallback_miosa_domain?: string | null;
5192
+ status?: string;
5193
+ [key: string]: unknown;
5194
+ }
5195
+ interface TenantBrandingUpdateParams {
5196
+ logo_url?: string | null;
5197
+ primary_color?: string | null;
5198
+ wordmark?: string | null;
5199
+ favicon_url?: string | null;
5200
+ [key: string]: unknown;
5201
+ }
5138
5202
  declare class Tenant {
5139
5203
  private readonly http;
5140
5204
  constructor(http: HttpClient);
@@ -5277,8 +5341,20 @@ interface WebhookUpdateParams {
5277
5341
  enabled?: boolean;
5278
5342
  [key: string]: unknown;
5279
5343
  }
5344
+ interface WebhookSignatureVerifyOptions {
5345
+ /** Maximum age for the webhook timestamp in seconds. Defaults to 300. */
5346
+ toleranceSeconds?: number;
5347
+ }
5348
+ /**
5349
+ * Verify a MIOSA webhook signature header.
5350
+ *
5351
+ * Header format: `t=<unix_seconds>,v1=<hex_hmac_sha256>`.
5352
+ */
5353
+ declare function verifySignature(body: string | Buffer | Uint8Array, header: string, secret: string, options?: WebhookSignatureVerifyOptions): boolean;
5280
5354
  declare class Webhooks {
5281
5355
  private readonly http;
5356
+ static verifySignature: typeof verifySignature;
5357
+ static verify_signature: typeof verifySignature;
5282
5358
  constructor(http: HttpClient);
5283
5359
  list(params?: WebhookListParams): Promise<WebhookData[]>;
5284
5360
  get(webhookId: string): Promise<WebhookData>;
@@ -5666,4 +5742,4 @@ declare class NetworkError extends MiosaError {
5666
5742
  constructor(message: string, cause: Error);
5667
5743
  }
5668
5744
 
5669
- export { type AcceptOrgInviteResponse, type AcceptWorkspaceInviteResponse, type AddDomainParams, type AddWorkspaceMemberParams, Admin, type AgentDispatchParams, type AgentEvent$1 as AgentEvent, type AgentEventType, type AgentSessionCreateParams, type AgentSessionData, type AgentSessionListResponse$1 as AgentSessionListResponse, type AgentSessionStatus$1 as AgentSessionStatus, type AllowParams, Analytics, type AnalyticsFilters, type ApiKeyCreateParams, type ApiKeyCreateResult, type ApiKeyData, type ApiKeyId, type ApiKeyListParams, ApiKeys, type AppCatalogEntry, type AppInstallData, type AppInstallEvent, type AuditListParams, AuditLog, type AuditLogEvent, type AuditLogListParams, type AuditTailParams, AuthError, type BenchmarkCompareParams, type BenchmarkCreateParams, Benchmarks, type BindingCreateParams, type BindingListParams, 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, type ClusterCreateParams, type ClusterData, type ClusterEvent, type ClusterId, type ClusterListResponse, type ClusterStatus, CommandCenter, Community, type CompletionCreateParams, type CompletionCreateStreamParams, Completions, Computer, ComputerAudit, ComputerAutoStop, 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 CopyParams, type CreateAdminApiKeyParams, 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, Dashboard, type DashboardSummary, type DatabaseCreateParams, type DatabaseCredentials, type DatabaseData, type DatabaseId, type DatabaseListParams, type DatabaseLogsParams, type DatabaseLogsResult, Databases, type DeploymentBuildData, type DeploymentCreateParams, type DeploymentData, DeploymentDomains, type DeploymentId, type DeploymentListParams, 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 DirEntry, type DirListResult, type DiscordSendTestParams, type DoubleClickParams, type DragParams, type EgressAllowlistRule, EgressAudit, type EgressAuditEvent, type EgressBindingData, 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, 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, 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, Mcp, type McpDispatchParams, Miosa, type MiosaClientConfig, MiosaError, 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 OverviewData, type PolicyCreateParams, type PolicyListParams, type PolicyUpdateParams, type PresignParams, type PresignResult, ProjectAuth, type ProjectAuthEnableParams, type ProjectAuthStatus, type ProjectAuthUpdateParams, type ProjectIntegrationCatalogEntry, type ProjectIntegrationCreateParams, type ProjectIntegrationData, type ProjectIntegrationListParams, type ProjectIntegrationUpdateParams, ProjectIntegrations, ProviderDefaults, type ProviderKeyUpsertParams, type PublishFromSandboxParams, type PublishParams, type PublishResult, RateLimitError, type RegionData, Regions, type RollbackParams, type RulesListParams, type RuntimeInstanceData, type RuntimeInstanceId, type RuntimeInstanceState, type RuntimeLogsResult, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, type SandboxBuildSpec, type SandboxBuildSpecError, type SandboxBuildSpecValidation, SandboxCommands, type SandboxCreateParams, type SandboxData, SandboxEnv, SandboxEvents, type SandboxExecOptions, type SandboxExecResult, SandboxFiles, 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, 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, type SuggestionsParams, type TemplateBuildCreateParams, type TemplateCreateParams, type TemplateData, Tenant, type TenantId, type TenantPlan, type TenantSummary, type TerminalCreateParams, TimeoutError, type TimeseriesParams, 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, ValidationError, type VersionListParams, 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 };
5745
+ export { type AcceptOrgInviteResponse, type AcceptWorkspaceInviteResponse, type AddDomainParams, type AddWorkspaceMemberParams, Admin, type AgentDispatchParams, type AgentEvent$1 as AgentEvent, type AgentEventType, type AgentSessionCreateParams, type AgentSessionData, type AgentSessionListResponse$1 as AgentSessionListResponse, type AgentSessionStatus$1 as AgentSessionStatus, type AllowParams, Analytics, type AnalyticsFilters, type ApiKeyCreateParams, type ApiKeyCreateResult, type ApiKeyData, type ApiKeyId, type ApiKeyListParams, ApiKeys, type AppCatalogEntry, type AppInstallData, type AppInstallEvent, type AuditListParams, AuditLog, type AuditLogEvent, type AuditLogListParams, type AuditTailParams, AuthError, 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, type ClusterCreateParams, type ClusterData, type ClusterEvent, type ClusterId, type ClusterListResponse, type ClusterStatus, CommandCenter, Community, type CompletionCreateParams, type CompletionCreateStreamParams, Completions, Computer, ComputerAudit, ComputerAutoStop, 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 CopyParams, type CreateAdminApiKeyParams, 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, Dashboard, type DashboardSummary, type DatabaseCreateParams, type DatabaseCredentials, type DatabaseData, type DatabaseId, type DatabaseListParams, type DatabaseLogsParams, type DatabaseLogsResult, Databases, type DeploymentBuildData, type DeploymentCreateParams, type DeploymentData, DeploymentDomains, type DeploymentId, type DeploymentListParams, type DeploymentProduct, 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 DirEntry, type DirListResult, type DiscordSendTestParams, type DockerDeployCreateParams, type DoubleClickParams, type DragParams, type EgressAllowlistRule, EgressAudit, type EgressAuditEvent, type EgressBindingData, 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, 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, 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, Mcp, type McpDispatchParams, Miosa, type MiosaClientConfig, MiosaError, 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 OverviewData, type PolicyCreateParams, type PolicyListParams, type PolicyUpdateParams, type PresignParams, type PresignResult, type PreviewDomainData, ProjectAuth, type ProjectAuthEnableParams, type ProjectAuthStatus, type ProjectAuthUpdateParams, type ProjectIntegrationCatalogEntry, type ProjectIntegrationCreateParams, type ProjectIntegrationData, type ProjectIntegrationListParams, type ProjectIntegrationUpdateParams, ProjectIntegrations, ProviderDefaults, type ProviderKeyUpsertParams, type PublishFromSandboxParams, type PublishParams, type PublishResult, RateLimitError, type RegionData, Regions, type RollbackParams, type RulesListParams, type RuntimeInstanceData, type RuntimeInstanceId, type RuntimeInstanceState, type RuntimeLogsResult, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, type SandboxBuildSpec, type SandboxBuildSpecError, type SandboxBuildSpecValidation, SandboxCommands, type SandboxCreateParams, type SandboxData, SandboxEnv, SandboxEvents, type SandboxExecOptions, type SandboxExecResult, SandboxFiles, 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, 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, type SuggestionsParams, type TemplateBuildCreateParams, type TemplateCreateParams, type TemplateData, Tenant, type TenantBrandingUpdateParams, type TenantId, type TenantPlan, type TenantSummary, type TerminalCreateParams, TimeoutError, type TimeseriesParams, 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, ValidationError, type VersionListParams, 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, verifySignature };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { randomUUID } from 'crypto';
1
+ import { createHmac, timingSafeEqual, randomUUID } from 'crypto';
2
2
  import EventEmitter from 'events';
3
3
 
4
4
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
@@ -592,6 +592,13 @@ var Admin = class {
592
592
  model_id: modelId
593
593
  });
594
594
  }
595
+ /** POST /api/v1/admin/impersonate — returns {token, expires_at}. */
596
+ impersonate(externalUserId, options = {}) {
597
+ return this.http.post("/admin/impersonate", {
598
+ external_user_id: externalUserId,
599
+ ttl_sec: options.ttlSec ?? 3600
600
+ });
601
+ }
595
602
  };
596
603
 
597
604
  // src/resources/analytics.ts
@@ -674,6 +681,17 @@ var ApiKeys = class {
674
681
  });
675
682
  return unwrap2(data);
676
683
  }
684
+ /** POST /api/v1/api-keys/scoped — L2 delegation token bound to one external user. */
685
+ async createScoped(params) {
686
+ const body = stripUndefined2({
687
+ external_user_id: params.externalUserId,
688
+ scopes: params.scopes,
689
+ expires_at: params.expiresAt
690
+ });
691
+ return unwrap2(
692
+ await this.http.post("/api-keys/scoped", body)
693
+ );
694
+ }
677
695
  async delete(keyId) {
678
696
  await this.http.delete(`/api-keys/${keyId}`);
679
697
  }
@@ -3621,6 +3639,12 @@ function stripUndefined10(input) {
3621
3639
  Object.entries(input).filter(([, v]) => v !== void 0)
3622
3640
  );
3623
3641
  }
3642
+ function dockerDeployMetadata(metadata) {
3643
+ return {
3644
+ ...metadata ?? {},
3645
+ deployment_product: "docker_deploy"
3646
+ };
3647
+ }
3624
3648
  var DeploymentVersions = class {
3625
3649
  constructor(http, deploymentId) {
3626
3650
  this.http = http;
@@ -3803,6 +3827,17 @@ var Deployments = class {
3803
3827
  });
3804
3828
  return unwrap23(data);
3805
3829
  }
3830
+ /**
3831
+ * Create a deployment that runs on the workspace's dedicated Docker Deploy
3832
+ * runtime. It uses the same /deployments API as MIOSA Deploy, but marks the
3833
+ * deployment so the control plane attaches it to the workspace Docker host.
3834
+ */
3835
+ async createDockerDeploy(params) {
3836
+ return this.create({
3837
+ ...params,
3838
+ metadata: dockerDeployMetadata(params.metadata)
3839
+ });
3840
+ }
3806
3841
  async update(deploymentId, params) {
3807
3842
  const body = stripUndefined10({
3808
3843
  name: params.name,
@@ -6033,6 +6068,16 @@ var Sandbox = class _Sandbox {
6033
6068
  output_path: params.outputPath ?? params.output_path ?? params.path ?? params.sourcePath ?? params.source_path,
6034
6069
  source_snapshot_path: params.sourceSnapshotPath ?? params.source_snapshot_path,
6035
6070
  entrypoint: params.entrypoint,
6071
+ build_command: params.buildCommand ?? params.build_command,
6072
+ run_command: params.runCommand ?? params.run_command,
6073
+ start_command: params.startCommand ?? params.start_command,
6074
+ port: params.port,
6075
+ health_check_path: params.healthCheckPath ?? params.health_check_path,
6076
+ deployment_type: params.deploymentType ?? params.deployment_type,
6077
+ type: params.type,
6078
+ mode: params.mode,
6079
+ database: params.database,
6080
+ resources: params.resources,
6036
6081
  domain: params.domain,
6037
6082
  custom_domain: params.customDomain ?? params.custom_domain
6038
6083
  })
@@ -6047,6 +6092,9 @@ var Sandbox = class _Sandbox {
6047
6092
  )
6048
6093
  );
6049
6094
  }
6095
+ async deployDocker(params = {}) {
6096
+ return this.deploy({ ...params, deploymentType: "docker_deploy" });
6097
+ }
6050
6098
  /** Check readiness of the sandbox (GET /sandboxes/:id/readiness). */
6051
6099
  async readiness() {
6052
6100
  return unwrap36(
@@ -6842,11 +6890,51 @@ function stripUndefined25(input) {
6842
6890
  function idempotencyKey10(key) {
6843
6891
  return key ?? randomUUID();
6844
6892
  }
6893
+ function parseSignatureHeader(header) {
6894
+ const parts = header.split(",").map((part) => part.trim());
6895
+ let timestamp = null;
6896
+ const signatures = [];
6897
+ for (const part of parts) {
6898
+ const [key, value] = part.split("=", 2);
6899
+ if (!key || !value) continue;
6900
+ if (key === "t") {
6901
+ const parsed = Number(value);
6902
+ if (Number.isFinite(parsed)) timestamp = parsed;
6903
+ } else if (key === "v1") {
6904
+ signatures.push(value);
6905
+ }
6906
+ }
6907
+ if (timestamp == null || signatures.length === 0) return null;
6908
+ return { timestamp, signatures };
6909
+ }
6910
+ function verifySignature(body, header, secret, options = {}) {
6911
+ const parsed = parseSignatureHeader(header);
6912
+ if (!parsed) return false;
6913
+ const toleranceSeconds = options.toleranceSeconds ?? 300;
6914
+ const ageSeconds = Math.abs(Math.floor(Date.now() / 1e3) - parsed.timestamp);
6915
+ if (ageSeconds > toleranceSeconds) {
6916
+ throw new Error("Webhook signature timestamp is too old");
6917
+ }
6918
+ const bodyBuffer = Buffer.isBuffer(body) ? body : Buffer.from(body);
6919
+ const signedPayload = Buffer.concat([
6920
+ Buffer.from(`${parsed.timestamp}.`),
6921
+ bodyBuffer
6922
+ ]);
6923
+ const expected = createHmac("sha256", secret).update(signedPayload).digest("hex");
6924
+ const expectedBuffer = Buffer.from(expected, "hex");
6925
+ return parsed.signatures.some((signature) => {
6926
+ const actualBuffer = Buffer.from(signature, "hex");
6927
+ if (actualBuffer.length !== expectedBuffer.length) return false;
6928
+ return timingSafeEqual(actualBuffer, expectedBuffer);
6929
+ });
6930
+ }
6845
6931
  var Webhooks = class {
6846
6932
  constructor(http) {
6847
6933
  this.http = http;
6848
6934
  }
6849
6935
  http;
6936
+ static verifySignature = verifySignature;
6937
+ static verify_signature = verifySignature;
6850
6938
  async list(params = {}) {
6851
6939
  const query = stripUndefined25({ ...params });
6852
6940
  const data = await this.http.get("/webhooks", query);
@@ -7221,6 +7309,6 @@ var Miosa = class {
7221
7309
  }
7222
7310
  };
7223
7311
 
7224
- export { Admin, Analytics, ApiKeys, AuditLog, AuthError, Benchmarks, BuilderSessions, Channels, Checkpoints, CommandCenter, Community, Completions, Computer, ComputerAudit, ComputerAutoStop, ComputerEnv, ComputerInbox, ComputerLogs, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, ComputerTerminal, ComputerVolumes, Computers, Credits, CronJobs, Dashboard, Databases, DeploymentDomains, DeploymentReleases, DeploymentRuntimeInstances, DeploymentVersions, Deployments, Desktop, EgressAudit, EgressNetwork, EgressSecrets, Email, EmailCampaigns, EmailInbox, EmailTemplates, Embeddings, Exec, ExternalKeys, Files, FlatCustomDomains, Functions, HealthChecks, InsufficientCreditsError, Integrations, Mcp, Miosa, MiosaError, Models, NetworkError, NetworkPolicy, NotFoundError, OAuthFlow, OpenComputers, OrgInvites, ProjectAuth, ProjectIntegrations, ProviderDefaults, RateLimitError, Regions, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, SandboxCommands, SandboxEnv, SandboxEvents, SandboxFiles, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, SandboxTags, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, Settings, SnapshotsStandalone, Storage, Tenant, TimeoutError, Usage, ValidationError, Volumes, Webhooks, WorkspaceInvites, WorkspaceMembers };
7312
+ export { Admin, Analytics, ApiKeys, AuditLog, AuthError, Benchmarks, BuilderSessions, Channels, Checkpoints, CommandCenter, Community, Completions, Computer, ComputerAudit, ComputerAutoStop, ComputerEnv, ComputerInbox, ComputerLogs, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, ComputerTerminal, ComputerVolumes, Computers, Credits, CronJobs, Dashboard, Databases, DeploymentDomains, DeploymentReleases, DeploymentRuntimeInstances, DeploymentVersions, Deployments, Desktop, EgressAudit, EgressNetwork, EgressSecrets, Email, EmailCampaigns, EmailInbox, EmailTemplates, Embeddings, Exec, ExternalKeys, Files, FlatCustomDomains, Functions, HealthChecks, InsufficientCreditsError, Integrations, Mcp, Miosa, MiosaError, Models, NetworkError, NetworkPolicy, NotFoundError, OAuthFlow, OpenComputers, OrgInvites, ProjectAuth, ProjectIntegrations, ProviderDefaults, RateLimitError, Regions, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, SandboxCommands, SandboxEnv, SandboxEvents, SandboxFiles, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, SandboxTags, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, Settings, SnapshotsStandalone, Storage, Tenant, TimeoutError, Usage, ValidationError, Volumes, Webhooks, WorkspaceInvites, WorkspaceMembers, verifySignature };
7225
7313
  //# sourceMappingURL=index.js.map
7226
7314
  //# sourceMappingURL=index.js.map