@declaw/sdk 1.0.4 → 1.1.0
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/CHANGELOG.md +23 -0
- package/dist/index.cjs +119 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -1
- package/dist/index.d.ts +58 -1
- package/dist/index.js +115 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -924,6 +924,27 @@ declare class Pty {
|
|
|
924
924
|
resize(pid: number, size: PtySize, requestTimeout?: number): Promise<void>;
|
|
925
925
|
}
|
|
926
926
|
|
|
927
|
+
/** Request-side shape of a volume attachment on Sandbox.create. */
|
|
928
|
+
interface VolumeAttachment {
|
|
929
|
+
volumeId: string;
|
|
930
|
+
mountPath: string;
|
|
931
|
+
}
|
|
932
|
+
/** Server-side metadata for a single volume. */
|
|
933
|
+
interface VolumeInfo {
|
|
934
|
+
volumeId: string;
|
|
935
|
+
ownerId: string;
|
|
936
|
+
name: string;
|
|
937
|
+
blobKey: string;
|
|
938
|
+
sizeBytes: number;
|
|
939
|
+
contentType: string;
|
|
940
|
+
metadata: Record<string, string>;
|
|
941
|
+
createdAt: string;
|
|
942
|
+
}
|
|
943
|
+
/** Convert a wire-format volume row into a VolumeInfo. */
|
|
944
|
+
declare function parseVolumeInfo(data: Record<string, unknown>): VolumeInfo;
|
|
945
|
+
/** Render a VolumeAttachment in wire (snake_case) form. */
|
|
946
|
+
declare function volumeAttachmentToJSON(att: VolumeAttachment): Record<string, string>;
|
|
947
|
+
|
|
927
948
|
/** Options for creating a sandbox. */
|
|
928
949
|
interface SandboxOpts {
|
|
929
950
|
/** Template to use. Defaults to 'base'. */
|
|
@@ -944,6 +965,11 @@ interface SandboxOpts {
|
|
|
944
965
|
security?: SecurityPolicy;
|
|
945
966
|
/** Lifecycle configuration. */
|
|
946
967
|
lifecycle?: SandboxLifecycle;
|
|
968
|
+
/** Volumes to attach at sandbox-boot time. Each {volumeId, mountPath}
|
|
969
|
+
* references a blob uploaded via `Volumes.create`; the orchestrator
|
|
970
|
+
* materializes its contents under `mountPath` before the first command
|
|
971
|
+
* is dispatched. */
|
|
972
|
+
volumes?: VolumeAttachment[];
|
|
947
973
|
/** API key override. */
|
|
948
974
|
apiKey?: string;
|
|
949
975
|
/** Domain override (supports "host:port" format, e.g. "104.198.24.180:8080"). */
|
|
@@ -1407,4 +1433,35 @@ declare class Template {
|
|
|
1407
1433
|
static getBuildStatus(buildId: string, opts?: GetBuildStatusOpts): Promise<TemplateBuildStatus>;
|
|
1408
1434
|
}
|
|
1409
1435
|
|
|
1410
|
-
|
|
1436
|
+
/** Shared per-call options. */
|
|
1437
|
+
interface VolumeRequestOpts {
|
|
1438
|
+
apiKey?: string;
|
|
1439
|
+
domain?: string;
|
|
1440
|
+
apiUrl?: string;
|
|
1441
|
+
requestTimeout?: number;
|
|
1442
|
+
}
|
|
1443
|
+
/** Options for Volumes.create. */
|
|
1444
|
+
interface VolumeCreateOpts extends VolumeRequestOpts {
|
|
1445
|
+
/** Override the Content-Type header. Defaults to application/gzip. */
|
|
1446
|
+
contentType?: string;
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Volumes: upload a tarball once and attach it to one or many sandboxes.
|
|
1450
|
+
*
|
|
1451
|
+
* Phase 1: the body must be a gzip-compressed tar archive; the server
|
|
1452
|
+
* materializes regular-file entries inside the sandbox filesystem under
|
|
1453
|
+
* the attachment's mount_path. Symlinks, hardlinks, and device nodes
|
|
1454
|
+
* are dropped on the server for safety.
|
|
1455
|
+
*/
|
|
1456
|
+
declare class Volumes {
|
|
1457
|
+
/** Create a volume by streaming a tarball to the server. */
|
|
1458
|
+
static create(name: string, data: Uint8Array | ArrayBuffer, opts?: VolumeCreateOpts): Promise<VolumeInfo>;
|
|
1459
|
+
/** Fetch metadata for a single volume. */
|
|
1460
|
+
static get(volumeId: string, opts?: VolumeRequestOpts): Promise<VolumeInfo>;
|
|
1461
|
+
/** List all volumes owned by the caller, newest first. */
|
|
1462
|
+
static list(opts?: VolumeRequestOpts): Promise<VolumeInfo[]>;
|
|
1463
|
+
/** Delete a volume and its blob. Idempotent on the wire. */
|
|
1464
|
+
static delete(volumeId: string, opts?: VolumeRequestOpts): Promise<void>;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
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, 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, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry, volumeAttachmentToJSON };
|
package/dist/index.d.ts
CHANGED
|
@@ -924,6 +924,27 @@ declare class Pty {
|
|
|
924
924
|
resize(pid: number, size: PtySize, requestTimeout?: number): Promise<void>;
|
|
925
925
|
}
|
|
926
926
|
|
|
927
|
+
/** Request-side shape of a volume attachment on Sandbox.create. */
|
|
928
|
+
interface VolumeAttachment {
|
|
929
|
+
volumeId: string;
|
|
930
|
+
mountPath: string;
|
|
931
|
+
}
|
|
932
|
+
/** Server-side metadata for a single volume. */
|
|
933
|
+
interface VolumeInfo {
|
|
934
|
+
volumeId: string;
|
|
935
|
+
ownerId: string;
|
|
936
|
+
name: string;
|
|
937
|
+
blobKey: string;
|
|
938
|
+
sizeBytes: number;
|
|
939
|
+
contentType: string;
|
|
940
|
+
metadata: Record<string, string>;
|
|
941
|
+
createdAt: string;
|
|
942
|
+
}
|
|
943
|
+
/** Convert a wire-format volume row into a VolumeInfo. */
|
|
944
|
+
declare function parseVolumeInfo(data: Record<string, unknown>): VolumeInfo;
|
|
945
|
+
/** Render a VolumeAttachment in wire (snake_case) form. */
|
|
946
|
+
declare function volumeAttachmentToJSON(att: VolumeAttachment): Record<string, string>;
|
|
947
|
+
|
|
927
948
|
/** Options for creating a sandbox. */
|
|
928
949
|
interface SandboxOpts {
|
|
929
950
|
/** Template to use. Defaults to 'base'. */
|
|
@@ -944,6 +965,11 @@ interface SandboxOpts {
|
|
|
944
965
|
security?: SecurityPolicy;
|
|
945
966
|
/** Lifecycle configuration. */
|
|
946
967
|
lifecycle?: SandboxLifecycle;
|
|
968
|
+
/** Volumes to attach at sandbox-boot time. Each {volumeId, mountPath}
|
|
969
|
+
* references a blob uploaded via `Volumes.create`; the orchestrator
|
|
970
|
+
* materializes its contents under `mountPath` before the first command
|
|
971
|
+
* is dispatched. */
|
|
972
|
+
volumes?: VolumeAttachment[];
|
|
947
973
|
/** API key override. */
|
|
948
974
|
apiKey?: string;
|
|
949
975
|
/** Domain override (supports "host:port" format, e.g. "104.198.24.180:8080"). */
|
|
@@ -1407,4 +1433,35 @@ declare class Template {
|
|
|
1407
1433
|
static getBuildStatus(buildId: string, opts?: GetBuildStatusOpts): Promise<TemplateBuildStatus>;
|
|
1408
1434
|
}
|
|
1409
1435
|
|
|
1410
|
-
|
|
1436
|
+
/** Shared per-call options. */
|
|
1437
|
+
interface VolumeRequestOpts {
|
|
1438
|
+
apiKey?: string;
|
|
1439
|
+
domain?: string;
|
|
1440
|
+
apiUrl?: string;
|
|
1441
|
+
requestTimeout?: number;
|
|
1442
|
+
}
|
|
1443
|
+
/** Options for Volumes.create. */
|
|
1444
|
+
interface VolumeCreateOpts extends VolumeRequestOpts {
|
|
1445
|
+
/** Override the Content-Type header. Defaults to application/gzip. */
|
|
1446
|
+
contentType?: string;
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Volumes: upload a tarball once and attach it to one or many sandboxes.
|
|
1450
|
+
*
|
|
1451
|
+
* Phase 1: the body must be a gzip-compressed tar archive; the server
|
|
1452
|
+
* materializes regular-file entries inside the sandbox filesystem under
|
|
1453
|
+
* the attachment's mount_path. Symlinks, hardlinks, and device nodes
|
|
1454
|
+
* are dropped on the server for safety.
|
|
1455
|
+
*/
|
|
1456
|
+
declare class Volumes {
|
|
1457
|
+
/** Create a volume by streaming a tarball to the server. */
|
|
1458
|
+
static create(name: string, data: Uint8Array | ArrayBuffer, opts?: VolumeCreateOpts): Promise<VolumeInfo>;
|
|
1459
|
+
/** Fetch metadata for a single volume. */
|
|
1460
|
+
static get(volumeId: string, opts?: VolumeRequestOpts): Promise<VolumeInfo>;
|
|
1461
|
+
/** List all volumes owned by the caller, newest first. */
|
|
1462
|
+
static list(opts?: VolumeRequestOpts): Promise<VolumeInfo[]>;
|
|
1463
|
+
/** Delete a volume and its blob. Idempotent on the wire. */
|
|
1464
|
+
static delete(volumeId: string, opts?: VolumeRequestOpts): Promise<void>;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
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, 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, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry, volumeAttachmentToJSON };
|
package/dist/index.js
CHANGED
|
@@ -1693,6 +1693,23 @@ var Pty = class {
|
|
|
1693
1693
|
}
|
|
1694
1694
|
};
|
|
1695
1695
|
|
|
1696
|
+
// src/volumes/models.ts
|
|
1697
|
+
function parseVolumeInfo(data) {
|
|
1698
|
+
return {
|
|
1699
|
+
volumeId: String(data.volume_id ?? ""),
|
|
1700
|
+
ownerId: String(data.owner_id ?? ""),
|
|
1701
|
+
name: String(data.name ?? ""),
|
|
1702
|
+
blobKey: String(data.blob_key ?? ""),
|
|
1703
|
+
sizeBytes: Number(data.size_bytes ?? 0),
|
|
1704
|
+
contentType: String(data.content_type ?? ""),
|
|
1705
|
+
metadata: data.metadata ?? {},
|
|
1706
|
+
createdAt: String(data.created_at ?? "")
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
function volumeAttachmentToJSON(att) {
|
|
1710
|
+
return { volume_id: att.volumeId, mount_path: att.mountPath };
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1696
1713
|
// src/sandbox/sandbox.ts
|
|
1697
1714
|
var DEFAULT_TEMPLATE = "base";
|
|
1698
1715
|
var DEFAULT_TIMEOUT = 300;
|
|
@@ -1849,6 +1866,9 @@ var Sandbox = class _Sandbox {
|
|
|
1849
1866
|
if (opts?.lifecycle) {
|
|
1850
1867
|
body.lifecycle = lifecycleToJSON(opts.lifecycle);
|
|
1851
1868
|
}
|
|
1869
|
+
if (opts?.volumes && opts.volumes.length > 0) {
|
|
1870
|
+
body.volumes = opts.volumes.map(volumeAttachmentToJSON);
|
|
1871
|
+
}
|
|
1852
1872
|
const data = await client.post("/sandboxes", {
|
|
1853
1873
|
json: body,
|
|
1854
1874
|
timeout: opts?.requestTimeout
|
|
@@ -2442,6 +2462,97 @@ var Template = class {
|
|
|
2442
2462
|
}
|
|
2443
2463
|
}
|
|
2444
2464
|
};
|
|
2465
|
+
|
|
2466
|
+
// src/volumes/volumes.ts
|
|
2467
|
+
var VALID_VOLUME_ID_RE = /^[a-zA-Z0-9_-]+$/;
|
|
2468
|
+
function assertValidVolumeId(id) {
|
|
2469
|
+
if (!id || !VALID_VOLUME_ID_RE.test(id)) {
|
|
2470
|
+
throw new InvalidArgumentError(
|
|
2471
|
+
`Invalid volume ID: "${id}". Must be alphanumeric with hyphens/underscores only.`
|
|
2472
|
+
);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
var Volumes = class {
|
|
2476
|
+
/** Create a volume by streaming a tarball to the server. */
|
|
2477
|
+
static async create(name, data, opts) {
|
|
2478
|
+
if (!name) {
|
|
2479
|
+
throw new InvalidArgumentError("volume name is required");
|
|
2480
|
+
}
|
|
2481
|
+
const config = new ConnectionConfig({
|
|
2482
|
+
apiKey: opts?.apiKey,
|
|
2483
|
+
domain: opts?.domain,
|
|
2484
|
+
apiUrl: opts?.apiUrl,
|
|
2485
|
+
requestTimeout: opts?.requestTimeout
|
|
2486
|
+
});
|
|
2487
|
+
const client = new ApiClient(config);
|
|
2488
|
+
try {
|
|
2489
|
+
const body = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
2490
|
+
const resp = await client.post("/volumes", {
|
|
2491
|
+
params: { name },
|
|
2492
|
+
body,
|
|
2493
|
+
headers: { "Content-Type": opts?.contentType ?? "application/gzip" },
|
|
2494
|
+
timeout: opts?.requestTimeout
|
|
2495
|
+
});
|
|
2496
|
+
return parseVolumeInfo(resp);
|
|
2497
|
+
} finally {
|
|
2498
|
+
client.close();
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
/** Fetch metadata for a single volume. */
|
|
2502
|
+
static async get(volumeId, opts) {
|
|
2503
|
+
assertValidVolumeId(volumeId);
|
|
2504
|
+
const config = new ConnectionConfig({
|
|
2505
|
+
apiKey: opts?.apiKey,
|
|
2506
|
+
domain: opts?.domain,
|
|
2507
|
+
apiUrl: opts?.apiUrl,
|
|
2508
|
+
requestTimeout: opts?.requestTimeout
|
|
2509
|
+
});
|
|
2510
|
+
const client = new ApiClient(config);
|
|
2511
|
+
try {
|
|
2512
|
+
const resp = await client.get(`/volumes/${volumeId}`, {
|
|
2513
|
+
timeout: opts?.requestTimeout
|
|
2514
|
+
});
|
|
2515
|
+
return parseVolumeInfo(resp);
|
|
2516
|
+
} finally {
|
|
2517
|
+
client.close();
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
/** List all volumes owned by the caller, newest first. */
|
|
2521
|
+
static async list(opts) {
|
|
2522
|
+
const config = new ConnectionConfig({
|
|
2523
|
+
apiKey: opts?.apiKey,
|
|
2524
|
+
domain: opts?.domain,
|
|
2525
|
+
apiUrl: opts?.apiUrl,
|
|
2526
|
+
requestTimeout: opts?.requestTimeout
|
|
2527
|
+
});
|
|
2528
|
+
const client = new ApiClient(config);
|
|
2529
|
+
try {
|
|
2530
|
+
const resp = await client.get("/volumes", {
|
|
2531
|
+
timeout: opts?.requestTimeout
|
|
2532
|
+
});
|
|
2533
|
+
const rows = resp.volumes ?? [];
|
|
2534
|
+
return rows.map(parseVolumeInfo);
|
|
2535
|
+
} finally {
|
|
2536
|
+
client.close();
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
/** Delete a volume and its blob. Idempotent on the wire. */
|
|
2540
|
+
static async delete(volumeId, opts) {
|
|
2541
|
+
assertValidVolumeId(volumeId);
|
|
2542
|
+
const config = new ConnectionConfig({
|
|
2543
|
+
apiKey: opts?.apiKey,
|
|
2544
|
+
domain: opts?.domain,
|
|
2545
|
+
apiUrl: opts?.apiUrl,
|
|
2546
|
+
requestTimeout: opts?.requestTimeout
|
|
2547
|
+
});
|
|
2548
|
+
const client = new ApiClient(config);
|
|
2549
|
+
try {
|
|
2550
|
+
await client.delete(`/volumes/${volumeId}`, { timeout: opts?.requestTimeout });
|
|
2551
|
+
} finally {
|
|
2552
|
+
client.close();
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
};
|
|
2445
2556
|
export {
|
|
2446
2557
|
ALL_TRAFFIC,
|
|
2447
2558
|
ApiClient,
|
|
@@ -2477,6 +2588,7 @@ export {
|
|
|
2477
2588
|
TemplateError,
|
|
2478
2589
|
TimeoutError,
|
|
2479
2590
|
TransformDirection,
|
|
2591
|
+
Volumes,
|
|
2480
2592
|
WatchHandle,
|
|
2481
2593
|
applyTransformation,
|
|
2482
2594
|
codeSecurityConfigToJSON,
|
|
@@ -2515,10 +2627,12 @@ export {
|
|
|
2515
2627
|
parseSnapshotInfo,
|
|
2516
2628
|
parseTemplateBuildStatus,
|
|
2517
2629
|
parseToxicityConfig,
|
|
2630
|
+
parseVolumeInfo,
|
|
2518
2631
|
parseWriteInfo,
|
|
2519
2632
|
requiresTlsInterception,
|
|
2520
2633
|
securityPolicyToJSON,
|
|
2521
2634
|
toxicityConfigToJSON,
|
|
2522
|
-
validateNetworkEntry
|
|
2635
|
+
validateNetworkEntry,
|
|
2636
|
+
volumeAttachmentToJSON
|
|
2523
2637
|
};
|
|
2524
2638
|
//# sourceMappingURL=index.js.map
|