@declaw/sdk 1.0.4 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -75,6 +75,12 @@ declare class ApiClient {
75
75
  streamGet(path: string, opts?: RequestOpts): Promise<Response>;
76
76
  /**
77
77
  * Abort all in-flight requests and release resources.
78
+ *
79
+ * Since 1.1.1 the SDK maintains a process-wide shared ApiClient cache
80
+ * for hot class-method paths (Sandbox.create, Volumes.*, Template.*).
81
+ * Calling `close()` on a shared instance aborts its AbortController,
82
+ * which would cancel any concurrent in-flight call. Prefer
83
+ * `resetSharedClients()` if you want to tear down every cached client.
78
84
  */
79
85
  close(): void;
80
86
  private buildUrl;
@@ -87,6 +93,8 @@ declare class ApiClient {
87
93
  */
88
94
  private delay;
89
95
  }
96
+ declare function getSharedClient(config: ConnectionConfig): ApiClient;
97
+ declare function resetSharedClients(): void;
90
98
 
91
99
  /** CIDR for all traffic. */
92
100
  declare const ALL_TRAFFIC = "0.0.0.0/0";
@@ -924,6 +932,27 @@ declare class Pty {
924
932
  resize(pid: number, size: PtySize, requestTimeout?: number): Promise<void>;
925
933
  }
926
934
 
935
+ /** Request-side shape of a volume attachment on Sandbox.create. */
936
+ interface VolumeAttachment {
937
+ volumeId: string;
938
+ mountPath: string;
939
+ }
940
+ /** Server-side metadata for a single volume. */
941
+ interface VolumeInfo {
942
+ volumeId: string;
943
+ ownerId: string;
944
+ name: string;
945
+ blobKey: string;
946
+ sizeBytes: number;
947
+ contentType: string;
948
+ metadata: Record<string, string>;
949
+ createdAt: string;
950
+ }
951
+ /** Convert a wire-format volume row into a VolumeInfo. */
952
+ declare function parseVolumeInfo(data: Record<string, unknown>): VolumeInfo;
953
+ /** Render a VolumeAttachment in wire (snake_case) form. */
954
+ declare function volumeAttachmentToJSON(att: VolumeAttachment): Record<string, string>;
955
+
927
956
  /** Options for creating a sandbox. */
928
957
  interface SandboxOpts {
929
958
  /** Template to use. Defaults to 'base'. */
@@ -944,6 +973,11 @@ interface SandboxOpts {
944
973
  security?: SecurityPolicy;
945
974
  /** Lifecycle configuration. */
946
975
  lifecycle?: SandboxLifecycle;
976
+ /** Volumes to attach at sandbox-boot time. Each {volumeId, mountPath}
977
+ * references a blob uploaded via `Volumes.create`; the orchestrator
978
+ * materializes its contents under `mountPath` before the first command
979
+ * is dispatched. */
980
+ volumes?: VolumeAttachment[];
947
981
  /** API key override. */
948
982
  apiKey?: string;
949
983
  /** Domain override (supports "host:port" format, e.g. "104.198.24.180:8080"). */
@@ -1159,7 +1193,11 @@ declare class Sandbox {
1159
1193
  requestTimeout?: number;
1160
1194
  }): Promise<Sandbox>;
1161
1195
  /**
1162
- * Close the underlying HTTP client and release resources.
1196
+ * Historically closed the sandbox's HTTP client; since 1.1.1 the SDK
1197
+ * maintains a process-wide shared ApiClient (see `getSharedClient` in
1198
+ * api/client.ts) so per-sandbox close no longer tears the connection
1199
+ * pool down. Kept as a no-op for backwards compatibility — call
1200
+ * `resetSharedClients()` if you want to force a full teardown.
1163
1201
  */
1164
1202
  close(): void;
1165
1203
  /**
@@ -1407,4 +1445,35 @@ declare class Template {
1407
1445
  static getBuildStatus(buildId: string, opts?: GetBuildStatusOpts): Promise<TemplateBuildStatus>;
1408
1446
  }
1409
1447
 
1410
- export { ALL_TRAFFIC, ApiClient, type AuditConfig, type AuditEntry, AuthenticationError, BuildError, type BuildInfo, type CodeSecurityConfig, CommandExitError, CommandHandle, type CommandResult, type CommandWaitOpts, Commands, ConnectionConfig, type ConnectionConfigOptions, type CopyItem, DEFAULT_MASK_PATTERNS, type EntryInfo, type EnvSecurityConfig, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOpts, GitAuthError, GitUpstreamError, InjectionAction, type InjectionDefenseConfig, InjectionSensitivity, InvalidArgumentError, type InvisibleTextConfig, type NetworkPolicy, NotEnoughSpaceError, NotFoundError, type PIIConfig, PIIType, type ProcessInfo, Pty, type PtyConnectOpts, type PtyCreateOpts, PtyHandle, type PtyOutput, type PtyResult, type PtySize, RedactionAction, type RequestOpts, type RunOpts, type RunStreamOpts, Sandbox, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxMetrics, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxQuery, SandboxState, type SecureEnvVar, type SecurityPolicy, type Snapshot, type SnapshotInfo, SnapshotPaginator, type SnapshotSource, type Stderr, type Stdout, Template, TemplateBase, type TemplateBuildOpts, type TemplateBuildStatus, TemplateError, TimeoutError, type ToxicityConfig, TransformDirection, type TransformationRule, WatchHandle, type WriteEntry, type WriteInfo, applyTransformation, codeSecurityConfigToJSON, createAuditConfig, createCodeSecurityConfig, createEnvSecurityConfig, createInjectionDefenseConfig, createInvisibleTextConfig, createNetworkPolicy, createPIIConfig, createSecurityPolicy, createToxicityConfig, createTransformationRule, domainMatches, invisibleTextConfigToJSON, isSensitive, networkPolicyToOpts, parseAuditConfig, parseAuditEntry, parseBuildInfo, parseCodeSecurityConfig, parseCommandResult, parseEntryInfo, parseEnvSecurityConfig, parseFilesystemEvent, parseInjectionDefenseConfig, parseInvisibleTextConfig, parseNetworkPolicy, parsePIIConfig, parseProcessInfo, parseSandboxInfo, parseSandboxLifecycle, parseSandboxMetrics, parseSecurityPolicy, parseSnapshot, parseSnapshotInfo, parseTemplateBuildStatus, parseToxicityConfig, parseWriteInfo, requiresTlsInterception, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry };
1448
+ /** Shared per-call options. */
1449
+ interface VolumeRequestOpts {
1450
+ apiKey?: string;
1451
+ domain?: string;
1452
+ apiUrl?: string;
1453
+ requestTimeout?: number;
1454
+ }
1455
+ /** Options for Volumes.create. */
1456
+ interface VolumeCreateOpts extends VolumeRequestOpts {
1457
+ /** Override the Content-Type header. Defaults to application/gzip. */
1458
+ contentType?: string;
1459
+ }
1460
+ /**
1461
+ * Volumes: upload a tarball once and attach it to one or many sandboxes.
1462
+ *
1463
+ * Phase 1: the body must be a gzip-compressed tar archive; the server
1464
+ * materializes regular-file entries inside the sandbox filesystem under
1465
+ * the attachment's mount_path. Symlinks, hardlinks, and device nodes
1466
+ * are dropped on the server for safety.
1467
+ */
1468
+ declare class Volumes {
1469
+ /** Create a volume by streaming a tarball to the server. */
1470
+ static create(name: string, data: Uint8Array | ArrayBuffer, opts?: VolumeCreateOpts): Promise<VolumeInfo>;
1471
+ /** Fetch metadata for a single volume. */
1472
+ static get(volumeId: string, opts?: VolumeRequestOpts): Promise<VolumeInfo>;
1473
+ /** List all volumes owned by the caller, newest first. */
1474
+ static list(opts?: VolumeRequestOpts): Promise<VolumeInfo[]>;
1475
+ /** Delete a volume and its blob. Idempotent on the wire. */
1476
+ static delete(volumeId: string, opts?: VolumeRequestOpts): Promise<void>;
1477
+ }
1478
+
1479
+ export { ALL_TRAFFIC, ApiClient, type AuditConfig, type AuditEntry, AuthenticationError, BuildError, type BuildInfo, type CodeSecurityConfig, CommandExitError, CommandHandle, type CommandResult, type CommandWaitOpts, Commands, ConnectionConfig, type ConnectionConfigOptions, type CopyItem, DEFAULT_MASK_PATTERNS, type EntryInfo, type EnvSecurityConfig, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOpts, GitAuthError, GitUpstreamError, InjectionAction, type InjectionDefenseConfig, InjectionSensitivity, InvalidArgumentError, type InvisibleTextConfig, type NetworkPolicy, NotEnoughSpaceError, NotFoundError, type PIIConfig, PIIType, type ProcessInfo, Pty, type PtyConnectOpts, type PtyCreateOpts, PtyHandle, type PtyOutput, type PtyResult, type PtySize, RedactionAction, type RequestOpts, type RunOpts, type RunStreamOpts, Sandbox, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxMetrics, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxQuery, SandboxState, type SecureEnvVar, type SecurityPolicy, type Snapshot, type SnapshotInfo, SnapshotPaginator, type SnapshotSource, type Stderr, type Stdout, Template, TemplateBase, type TemplateBuildOpts, type TemplateBuildStatus, TemplateError, TimeoutError, type ToxicityConfig, TransformDirection, type TransformationRule, type VolumeAttachment, type VolumeCreateOpts, type VolumeInfo, type VolumeRequestOpts, Volumes, WatchHandle, type WriteEntry, type WriteInfo, applyTransformation, codeSecurityConfigToJSON, createAuditConfig, createCodeSecurityConfig, createEnvSecurityConfig, createInjectionDefenseConfig, createInvisibleTextConfig, createNetworkPolicy, createPIIConfig, createSecurityPolicy, createToxicityConfig, createTransformationRule, domainMatches, getSharedClient, invisibleTextConfigToJSON, isSensitive, networkPolicyToOpts, parseAuditConfig, parseAuditEntry, parseBuildInfo, parseCodeSecurityConfig, parseCommandResult, parseEntryInfo, parseEnvSecurityConfig, parseFilesystemEvent, parseInjectionDefenseConfig, parseInvisibleTextConfig, parseNetworkPolicy, parsePIIConfig, parseProcessInfo, parseSandboxInfo, parseSandboxLifecycle, parseSandboxMetrics, parseSecurityPolicy, parseSnapshot, parseSnapshotInfo, parseTemplateBuildStatus, parseToxicityConfig, parseVolumeInfo, parseWriteInfo, requiresTlsInterception, resetSharedClients, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry, volumeAttachmentToJSON };
package/dist/index.d.ts CHANGED
@@ -75,6 +75,12 @@ declare class ApiClient {
75
75
  streamGet(path: string, opts?: RequestOpts): Promise<Response>;
76
76
  /**
77
77
  * Abort all in-flight requests and release resources.
78
+ *
79
+ * Since 1.1.1 the SDK maintains a process-wide shared ApiClient cache
80
+ * for hot class-method paths (Sandbox.create, Volumes.*, Template.*).
81
+ * Calling `close()` on a shared instance aborts its AbortController,
82
+ * which would cancel any concurrent in-flight call. Prefer
83
+ * `resetSharedClients()` if you want to tear down every cached client.
78
84
  */
79
85
  close(): void;
80
86
  private buildUrl;
@@ -87,6 +93,8 @@ declare class ApiClient {
87
93
  */
88
94
  private delay;
89
95
  }
96
+ declare function getSharedClient(config: ConnectionConfig): ApiClient;
97
+ declare function resetSharedClients(): void;
90
98
 
91
99
  /** CIDR for all traffic. */
92
100
  declare const ALL_TRAFFIC = "0.0.0.0/0";
@@ -924,6 +932,27 @@ declare class Pty {
924
932
  resize(pid: number, size: PtySize, requestTimeout?: number): Promise<void>;
925
933
  }
926
934
 
935
+ /** Request-side shape of a volume attachment on Sandbox.create. */
936
+ interface VolumeAttachment {
937
+ volumeId: string;
938
+ mountPath: string;
939
+ }
940
+ /** Server-side metadata for a single volume. */
941
+ interface VolumeInfo {
942
+ volumeId: string;
943
+ ownerId: string;
944
+ name: string;
945
+ blobKey: string;
946
+ sizeBytes: number;
947
+ contentType: string;
948
+ metadata: Record<string, string>;
949
+ createdAt: string;
950
+ }
951
+ /** Convert a wire-format volume row into a VolumeInfo. */
952
+ declare function parseVolumeInfo(data: Record<string, unknown>): VolumeInfo;
953
+ /** Render a VolumeAttachment in wire (snake_case) form. */
954
+ declare function volumeAttachmentToJSON(att: VolumeAttachment): Record<string, string>;
955
+
927
956
  /** Options for creating a sandbox. */
928
957
  interface SandboxOpts {
929
958
  /** Template to use. Defaults to 'base'. */
@@ -944,6 +973,11 @@ interface SandboxOpts {
944
973
  security?: SecurityPolicy;
945
974
  /** Lifecycle configuration. */
946
975
  lifecycle?: SandboxLifecycle;
976
+ /** Volumes to attach at sandbox-boot time. Each {volumeId, mountPath}
977
+ * references a blob uploaded via `Volumes.create`; the orchestrator
978
+ * materializes its contents under `mountPath` before the first command
979
+ * is dispatched. */
980
+ volumes?: VolumeAttachment[];
947
981
  /** API key override. */
948
982
  apiKey?: string;
949
983
  /** Domain override (supports "host:port" format, e.g. "104.198.24.180:8080"). */
@@ -1159,7 +1193,11 @@ declare class Sandbox {
1159
1193
  requestTimeout?: number;
1160
1194
  }): Promise<Sandbox>;
1161
1195
  /**
1162
- * Close the underlying HTTP client and release resources.
1196
+ * Historically closed the sandbox's HTTP client; since 1.1.1 the SDK
1197
+ * maintains a process-wide shared ApiClient (see `getSharedClient` in
1198
+ * api/client.ts) so per-sandbox close no longer tears the connection
1199
+ * pool down. Kept as a no-op for backwards compatibility — call
1200
+ * `resetSharedClients()` if you want to force a full teardown.
1163
1201
  */
1164
1202
  close(): void;
1165
1203
  /**
@@ -1407,4 +1445,35 @@ declare class Template {
1407
1445
  static getBuildStatus(buildId: string, opts?: GetBuildStatusOpts): Promise<TemplateBuildStatus>;
1408
1446
  }
1409
1447
 
1410
- export { ALL_TRAFFIC, ApiClient, type AuditConfig, type AuditEntry, AuthenticationError, BuildError, type BuildInfo, type CodeSecurityConfig, CommandExitError, CommandHandle, type CommandResult, type CommandWaitOpts, Commands, ConnectionConfig, type ConnectionConfigOptions, type CopyItem, DEFAULT_MASK_PATTERNS, type EntryInfo, type EnvSecurityConfig, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOpts, GitAuthError, GitUpstreamError, InjectionAction, type InjectionDefenseConfig, InjectionSensitivity, InvalidArgumentError, type InvisibleTextConfig, type NetworkPolicy, NotEnoughSpaceError, NotFoundError, type PIIConfig, PIIType, type ProcessInfo, Pty, type PtyConnectOpts, type PtyCreateOpts, PtyHandle, type PtyOutput, type PtyResult, type PtySize, RedactionAction, type RequestOpts, type RunOpts, type RunStreamOpts, Sandbox, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxMetrics, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxQuery, SandboxState, type SecureEnvVar, type SecurityPolicy, type Snapshot, type SnapshotInfo, SnapshotPaginator, type SnapshotSource, type Stderr, type Stdout, Template, TemplateBase, type TemplateBuildOpts, type TemplateBuildStatus, TemplateError, TimeoutError, type ToxicityConfig, TransformDirection, type TransformationRule, WatchHandle, type WriteEntry, type WriteInfo, applyTransformation, codeSecurityConfigToJSON, createAuditConfig, createCodeSecurityConfig, createEnvSecurityConfig, createInjectionDefenseConfig, createInvisibleTextConfig, createNetworkPolicy, createPIIConfig, createSecurityPolicy, createToxicityConfig, createTransformationRule, domainMatches, invisibleTextConfigToJSON, isSensitive, networkPolicyToOpts, parseAuditConfig, parseAuditEntry, parseBuildInfo, parseCodeSecurityConfig, parseCommandResult, parseEntryInfo, parseEnvSecurityConfig, parseFilesystemEvent, parseInjectionDefenseConfig, parseInvisibleTextConfig, parseNetworkPolicy, parsePIIConfig, parseProcessInfo, parseSandboxInfo, parseSandboxLifecycle, parseSandboxMetrics, parseSecurityPolicy, parseSnapshot, parseSnapshotInfo, parseTemplateBuildStatus, parseToxicityConfig, parseWriteInfo, requiresTlsInterception, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry };
1448
+ /** Shared per-call options. */
1449
+ interface VolumeRequestOpts {
1450
+ apiKey?: string;
1451
+ domain?: string;
1452
+ apiUrl?: string;
1453
+ requestTimeout?: number;
1454
+ }
1455
+ /** Options for Volumes.create. */
1456
+ interface VolumeCreateOpts extends VolumeRequestOpts {
1457
+ /** Override the Content-Type header. Defaults to application/gzip. */
1458
+ contentType?: string;
1459
+ }
1460
+ /**
1461
+ * Volumes: upload a tarball once and attach it to one or many sandboxes.
1462
+ *
1463
+ * Phase 1: the body must be a gzip-compressed tar archive; the server
1464
+ * materializes regular-file entries inside the sandbox filesystem under
1465
+ * the attachment's mount_path. Symlinks, hardlinks, and device nodes
1466
+ * are dropped on the server for safety.
1467
+ */
1468
+ declare class Volumes {
1469
+ /** Create a volume by streaming a tarball to the server. */
1470
+ static create(name: string, data: Uint8Array | ArrayBuffer, opts?: VolumeCreateOpts): Promise<VolumeInfo>;
1471
+ /** Fetch metadata for a single volume. */
1472
+ static get(volumeId: string, opts?: VolumeRequestOpts): Promise<VolumeInfo>;
1473
+ /** List all volumes owned by the caller, newest first. */
1474
+ static list(opts?: VolumeRequestOpts): Promise<VolumeInfo[]>;
1475
+ /** Delete a volume and its blob. Idempotent on the wire. */
1476
+ static delete(volumeId: string, opts?: VolumeRequestOpts): Promise<void>;
1477
+ }
1478
+
1479
+ export { ALL_TRAFFIC, ApiClient, type AuditConfig, type AuditEntry, AuthenticationError, BuildError, type BuildInfo, type CodeSecurityConfig, CommandExitError, CommandHandle, type CommandResult, type CommandWaitOpts, Commands, ConnectionConfig, type ConnectionConfigOptions, type CopyItem, DEFAULT_MASK_PATTERNS, type EntryInfo, type EnvSecurityConfig, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOpts, GitAuthError, GitUpstreamError, InjectionAction, type InjectionDefenseConfig, InjectionSensitivity, InvalidArgumentError, type InvisibleTextConfig, type NetworkPolicy, NotEnoughSpaceError, NotFoundError, type PIIConfig, PIIType, type ProcessInfo, Pty, type PtyConnectOpts, type PtyCreateOpts, PtyHandle, type PtyOutput, type PtyResult, type PtySize, RedactionAction, type RequestOpts, type RunOpts, type RunStreamOpts, Sandbox, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxMetrics, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxQuery, SandboxState, type SecureEnvVar, type SecurityPolicy, type Snapshot, type SnapshotInfo, SnapshotPaginator, type SnapshotSource, type Stderr, type Stdout, Template, TemplateBase, type TemplateBuildOpts, type TemplateBuildStatus, TemplateError, TimeoutError, type ToxicityConfig, TransformDirection, type TransformationRule, type VolumeAttachment, type VolumeCreateOpts, type VolumeInfo, type VolumeRequestOpts, Volumes, WatchHandle, type WriteEntry, type WriteInfo, applyTransformation, codeSecurityConfigToJSON, createAuditConfig, createCodeSecurityConfig, createEnvSecurityConfig, createInjectionDefenseConfig, createInvisibleTextConfig, createNetworkPolicy, createPIIConfig, createSecurityPolicy, createToxicityConfig, createTransformationRule, domainMatches, getSharedClient, invisibleTextConfigToJSON, isSensitive, networkPolicyToOpts, parseAuditConfig, parseAuditEntry, parseBuildInfo, parseCodeSecurityConfig, parseCommandResult, parseEntryInfo, parseEnvSecurityConfig, parseFilesystemEvent, parseInjectionDefenseConfig, parseInvisibleTextConfig, parseNetworkPolicy, parsePIIConfig, parseProcessInfo, parseSandboxInfo, parseSandboxLifecycle, parseSandboxMetrics, parseSecurityPolicy, parseSnapshot, parseSnapshotInfo, parseTemplateBuildStatus, parseToxicityConfig, parseVolumeInfo, parseWriteInfo, requiresTlsInterception, resetSharedClients, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry, volumeAttachmentToJSON };