modal 0.3.15 → 0.3.17
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.cjs +508 -145
- package/dist/index.d.cts +173 -21
- package/dist/index.d.ts +173 -21
- package/dist/index.js +506 -145
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -15,6 +15,15 @@ declare enum ParameterType {
|
|
|
15
15
|
PARAM_TYPE_BOOL = 9,
|
|
16
16
|
UNRECOGNIZED = -1
|
|
17
17
|
}
|
|
18
|
+
declare enum RegistryAuthType {
|
|
19
|
+
/** REGISTRY_AUTH_TYPE_UNSPECIFIED - Older clients send this instead of "public". */
|
|
20
|
+
REGISTRY_AUTH_TYPE_UNSPECIFIED = 0,
|
|
21
|
+
REGISTRY_AUTH_TYPE_AWS = 1,
|
|
22
|
+
REGISTRY_AUTH_TYPE_GCP = 2,
|
|
23
|
+
REGISTRY_AUTH_TYPE_PUBLIC = 3,
|
|
24
|
+
REGISTRY_AUTH_TYPE_STATIC_CREDS = 4,
|
|
25
|
+
UNRECOGNIZED = -1
|
|
26
|
+
}
|
|
18
27
|
/** TODO: rename into NamedPayloadType or similar */
|
|
19
28
|
interface ClassParameterSpec {
|
|
20
29
|
name: string;
|
|
@@ -37,6 +46,11 @@ interface GenericPayloadType {
|
|
|
37
46
|
subTypes: GenericPayloadType[];
|
|
38
47
|
}
|
|
39
48
|
declare const GenericPayloadType: MessageFns<GenericPayloadType>;
|
|
49
|
+
interface ImageRegistryConfig {
|
|
50
|
+
registryAuthType: RegistryAuthType;
|
|
51
|
+
secretId: string;
|
|
52
|
+
}
|
|
53
|
+
declare const ImageRegistryConfig: MessageFns<ImageRegistryConfig>;
|
|
40
54
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
41
55
|
type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
42
56
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
@@ -50,11 +64,57 @@ interface MessageFns<T> {
|
|
|
50
64
|
fromPartial(object: DeepPartial<T>): T;
|
|
51
65
|
}
|
|
52
66
|
|
|
67
|
+
/** Options for `Secret.fromName()`. */
|
|
68
|
+
type SecretFromNameOptions = {
|
|
69
|
+
environment?: string;
|
|
70
|
+
requiredKeys?: string[];
|
|
71
|
+
};
|
|
72
|
+
/** Secrets provide a dictionary of environment variables for images. */
|
|
73
|
+
declare class Secret {
|
|
74
|
+
readonly secretId: string;
|
|
75
|
+
readonly name?: string;
|
|
76
|
+
/** @ignore */
|
|
77
|
+
constructor(secretId: string, name?: string);
|
|
78
|
+
/** Reference a Secret by its name. */
|
|
79
|
+
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
80
|
+
/** Create a Secret from a plain object of key-value pairs. */
|
|
81
|
+
static fromObject(entries: Record<string, string>, options?: {
|
|
82
|
+
environment?: string;
|
|
83
|
+
}): Promise<Secret>;
|
|
84
|
+
}
|
|
85
|
+
|
|
53
86
|
/** A container image, used for starting sandboxes. */
|
|
54
87
|
declare class Image {
|
|
55
|
-
|
|
88
|
+
#private;
|
|
56
89
|
/** @ignore */
|
|
57
|
-
constructor(imageId: string);
|
|
90
|
+
constructor(imageId: string, tag: string, imageRegistryConfig?: ImageRegistryConfig);
|
|
91
|
+
get imageId(): string;
|
|
92
|
+
/**
|
|
93
|
+
* Creates an `Image` instance from a raw registry tag, optionally using a secret for authentication.
|
|
94
|
+
*
|
|
95
|
+
* @param tag - The registry tag for the image.
|
|
96
|
+
* @param secret - Optional. A `Secret` instance containing credentials for registry authentication.
|
|
97
|
+
*/
|
|
98
|
+
static fromRegistry(tag: string, secret?: Secret): Image;
|
|
99
|
+
/**
|
|
100
|
+
* Creates an `Image` instance from a raw registry tag, optionally using a secret for authentication.
|
|
101
|
+
*
|
|
102
|
+
* @param tag - The registry tag for the image.
|
|
103
|
+
* @param secret - A `Secret` instance containing credentials for registry authentication.
|
|
104
|
+
*/
|
|
105
|
+
static fromAwsEcr(tag: string, secret: Secret): Image;
|
|
106
|
+
/**
|
|
107
|
+
* Creates an `Image` instance from a raw registry tag, optionally using a secret for authentication.
|
|
108
|
+
*
|
|
109
|
+
* @param tag - The registry tag for the image.
|
|
110
|
+
* @param secret - A `Secret` instance containing credentials for registry authentication.
|
|
111
|
+
*/
|
|
112
|
+
static fromGcpArtifactRegistry(tag: string, secret: Secret): Image;
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
* Build image object
|
|
116
|
+
*/
|
|
117
|
+
_build(appId: string): Promise<Image>;
|
|
58
118
|
}
|
|
59
119
|
|
|
60
120
|
/** File open modes supported by the filesystem API. */
|
|
@@ -124,20 +184,6 @@ interface ModalWriteStream<R = any> extends WritableStream<R> {
|
|
|
124
184
|
writeBytes(bytes: Uint8Array): Promise<void>;
|
|
125
185
|
}
|
|
126
186
|
|
|
127
|
-
/** Options for `Secret.fromName()`. */
|
|
128
|
-
type SecretFromNameOptions = {
|
|
129
|
-
environment?: string;
|
|
130
|
-
requiredKeys?: string[];
|
|
131
|
-
};
|
|
132
|
-
/** Secrets provide a dictionary of environment variables for images. */
|
|
133
|
-
declare class Secret {
|
|
134
|
-
readonly secretId: string;
|
|
135
|
-
/** @ignore */
|
|
136
|
-
constructor(secretId: string);
|
|
137
|
-
/** Reference a Secret by its name. */
|
|
138
|
-
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
187
|
/**
|
|
142
188
|
* Stdin is always present, but this option allow you to drop stdout or stderr
|
|
143
189
|
* if you don't need them. The default is "pipe", matching Node.js behavior.
|
|
@@ -151,6 +197,15 @@ type StdioBehavior = "pipe" | "ignore";
|
|
|
151
197
|
* means the data will be read as raw bytes (Uint8Array).
|
|
152
198
|
*/
|
|
153
199
|
type StreamMode = "text" | "binary";
|
|
200
|
+
/** Options for `Sandbox.list()`. */
|
|
201
|
+
type SandboxListOptions = {
|
|
202
|
+
/** Filter sandboxes for a specific app. */
|
|
203
|
+
appId?: string;
|
|
204
|
+
/** Only return sandboxes that include all specified tags. */
|
|
205
|
+
tags?: Record<string, string>;
|
|
206
|
+
/** Override environment for the request; defaults to current profile. */
|
|
207
|
+
environment?: string;
|
|
208
|
+
};
|
|
154
209
|
/** Options to configure a `Sandbox.exec()` operation. */
|
|
155
210
|
type ExecOptions = {
|
|
156
211
|
/** Specifies text or binary encoding for input and output streams. */
|
|
@@ -190,6 +245,13 @@ declare class Sandbox {
|
|
|
190
245
|
stderr: ModalReadStream<string>;
|
|
191
246
|
/** @ignore */
|
|
192
247
|
constructor(sandboxId: string);
|
|
248
|
+
/** Set tags (key-value pairs) on the Sandbox. Tags can be used to filter results in `Sandbox.list`. */
|
|
249
|
+
setTags(tags: Record<string, string>): Promise<void>;
|
|
250
|
+
/** Returns a running Sandbox object from an ID.
|
|
251
|
+
*
|
|
252
|
+
* @returns Sandbox with ID
|
|
253
|
+
*/
|
|
254
|
+
static fromId(sandboxId: string): Promise<Sandbox>;
|
|
193
255
|
/**
|
|
194
256
|
* Open a file in the sandbox filesystem.
|
|
195
257
|
* @param path - Path to the file to open
|
|
@@ -227,6 +289,11 @@ declare class Sandbox {
|
|
|
227
289
|
* Returns `null` if the Sandbox is still running, else returns the exit code.
|
|
228
290
|
*/
|
|
229
291
|
poll(): Promise<number | null>;
|
|
292
|
+
/**
|
|
293
|
+
* List all Sandboxes for the current Environment or App ID (if specified).
|
|
294
|
+
* If tags are specified, only Sandboxes that have at least those tags are returned.
|
|
295
|
+
*/
|
|
296
|
+
static list(options?: SandboxListOptions): AsyncGenerator<Sandbox, void, unknown>;
|
|
230
297
|
}
|
|
231
298
|
declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
232
299
|
#private;
|
|
@@ -247,9 +314,46 @@ type VolumeFromNameOptions = {
|
|
|
247
314
|
/** Volumes provide persistent storage that can be mounted in Modal functions. */
|
|
248
315
|
declare class Volume {
|
|
249
316
|
readonly volumeId: string;
|
|
317
|
+
readonly name?: string;
|
|
318
|
+
private _readOnly;
|
|
250
319
|
/** @ignore */
|
|
251
|
-
constructor(volumeId: string);
|
|
320
|
+
constructor(volumeId: string, name?: string, readOnly?: boolean);
|
|
252
321
|
static fromName(name: string, options?: VolumeFromNameOptions): Promise<Volume>;
|
|
322
|
+
/** Configure Volume to mount as read-only. */
|
|
323
|
+
readOnly(): Volume;
|
|
324
|
+
get isReadOnly(): boolean;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** Options for `Proxy.fromName()`. */
|
|
328
|
+
type ProxyFromNameOptions = {
|
|
329
|
+
environment?: string;
|
|
330
|
+
};
|
|
331
|
+
/** Proxy objects give your Modal containers a static outbound IP address. */
|
|
332
|
+
declare class Proxy {
|
|
333
|
+
readonly proxyId: string;
|
|
334
|
+
/** @ignore */
|
|
335
|
+
constructor(proxyId: string);
|
|
336
|
+
/** Reference a Proxy by its name. */
|
|
337
|
+
static fromName(name: string, options?: ProxyFromNameOptions): Promise<Proxy>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Cloud bucket mounts provide access to cloud storage buckets within Modal functions. */
|
|
341
|
+
declare class CloudBucketMount {
|
|
342
|
+
readonly bucketName: string;
|
|
343
|
+
readonly secret?: Secret;
|
|
344
|
+
readonly readOnly: boolean;
|
|
345
|
+
readonly requesterPays: boolean;
|
|
346
|
+
readonly bucketEndpointUrl?: string;
|
|
347
|
+
readonly keyPrefix?: string;
|
|
348
|
+
readonly oidcAuthRoleArn?: string;
|
|
349
|
+
constructor(bucketName: string, options?: {
|
|
350
|
+
secret?: Secret;
|
|
351
|
+
readOnly?: boolean;
|
|
352
|
+
requesterPays?: boolean;
|
|
353
|
+
bucketEndpointUrl?: string;
|
|
354
|
+
keyPrefix?: string;
|
|
355
|
+
oidcAuthRoleArn?: string;
|
|
356
|
+
});
|
|
253
357
|
}
|
|
254
358
|
|
|
255
359
|
/** Options for functions that find deployed Modal objects. */
|
|
@@ -271,8 +375,12 @@ type SandboxCreateOptions = {
|
|
|
271
375
|
cpu?: number;
|
|
272
376
|
/** Reservation of memory in MiB. */
|
|
273
377
|
memory?: number;
|
|
378
|
+
/** GPU reservation for the sandbox (e.g. "A100", "T4:2", "A100-80GB:4"). */
|
|
379
|
+
gpu?: string;
|
|
274
380
|
/** Timeout of the sandbox container, defaults to 10 minutes. */
|
|
275
381
|
timeout?: number;
|
|
382
|
+
/** Working directory of the sandbox. */
|
|
383
|
+
workdir?: string;
|
|
276
384
|
/**
|
|
277
385
|
* Sequence of program arguments for the main process.
|
|
278
386
|
* Default behavior is to sleep indefinitely until timeout or termination.
|
|
@@ -282,23 +390,47 @@ type SandboxCreateOptions = {
|
|
|
282
390
|
secrets?: Secret[];
|
|
283
391
|
/** Mount points for Modal Volumes. */
|
|
284
392
|
volumes?: Record<string, Volume>;
|
|
393
|
+
/** Mount points for cloud buckets. */
|
|
394
|
+
cloudBucketMounts?: Record<string, CloudBucketMount>;
|
|
285
395
|
/** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
|
|
286
396
|
encryptedPorts?: number[];
|
|
287
397
|
/** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
|
|
288
398
|
h2Ports?: number[];
|
|
289
399
|
/** List of ports to tunnel into the sandbox without encryption. */
|
|
290
400
|
unencryptedPorts?: number[];
|
|
401
|
+
/** Whether to block all network access from the sandbox. */
|
|
402
|
+
blockNetwork?: boolean;
|
|
403
|
+
/** List of CIDRs the sandbox is allowed to access. If None, all CIDRs are allowed. Cannot be used with blockNetwork. */
|
|
404
|
+
cidrAllowlist?: string[];
|
|
405
|
+
/** Cloud provider to run the sandbox on. */
|
|
406
|
+
cloud?: string;
|
|
407
|
+
/** Region(s) to run the sandbox on. */
|
|
408
|
+
regions?: string[];
|
|
409
|
+
/** Enable verbose logging. */
|
|
410
|
+
verbose?: boolean;
|
|
411
|
+
/** Reference to a Modal Proxy to use in front of this Sandbox. */
|
|
412
|
+
proxy?: Proxy;
|
|
291
413
|
};
|
|
292
414
|
/** Represents a deployed Modal App. */
|
|
293
415
|
declare class App {
|
|
294
416
|
readonly appId: string;
|
|
417
|
+
readonly name?: string;
|
|
295
418
|
/** @ignore */
|
|
296
|
-
constructor(appId: string);
|
|
419
|
+
constructor(appId: string, name?: string);
|
|
297
420
|
/** Lookup a deployed app by name, or create if it does not exist. */
|
|
298
421
|
static lookup(name: string, options?: LookupOptions): Promise<App>;
|
|
299
422
|
createSandbox(image: Image, options?: SandboxCreateOptions): Promise<Sandbox>;
|
|
423
|
+
/**
|
|
424
|
+
* @deprecated Use `Image.fromRegistry` instead.
|
|
425
|
+
*/
|
|
300
426
|
imageFromRegistry(tag: string, secret?: Secret): Promise<Image>;
|
|
427
|
+
/**
|
|
428
|
+
* @deprecated Use `Image.fromAwsEcr` instead.
|
|
429
|
+
*/
|
|
301
430
|
imageFromAwsEcr(tag: string, secret: Secret): Promise<Image>;
|
|
431
|
+
/**
|
|
432
|
+
* @deprecated Use `Image.fromGcpArtifactRegistry` instead.
|
|
433
|
+
*/
|
|
302
434
|
imageFromGcpArtifactRegistry(tag: string, secret: Secret): Promise<Image>;
|
|
303
435
|
}
|
|
304
436
|
|
|
@@ -341,16 +473,35 @@ declare class FunctionCall {
|
|
|
341
473
|
cancel(options?: FunctionCallCancelOptions): Promise<void>;
|
|
342
474
|
}
|
|
343
475
|
|
|
476
|
+
/** Simple data structure storing stats for a running Function. */
|
|
477
|
+
interface FunctionStats {
|
|
478
|
+
backlog: number;
|
|
479
|
+
numTotalRunners: number;
|
|
480
|
+
}
|
|
481
|
+
/** Options for overriding a Function's autoscaler behavior. */
|
|
482
|
+
interface UpdateAutoscalerOptions {
|
|
483
|
+
minContainers?: number;
|
|
484
|
+
maxContainers?: number;
|
|
485
|
+
bufferContainers?: number;
|
|
486
|
+
scaledownWindow?: number;
|
|
487
|
+
}
|
|
344
488
|
/** Represents a deployed Modal Function, which can be invoked remotely. */
|
|
345
489
|
declare class Function_ {
|
|
346
490
|
#private;
|
|
347
491
|
readonly functionId: string;
|
|
348
492
|
readonly methodName?: string;
|
|
349
493
|
/** @ignore */
|
|
350
|
-
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
|
|
494
|
+
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string, webUrl?: string);
|
|
351
495
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
352
496
|
remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
|
|
353
497
|
spawn(args?: any[], kwargs?: Record<string, any>): Promise<FunctionCall>;
|
|
498
|
+
getCurrentStats(): Promise<FunctionStats>;
|
|
499
|
+
updateAutoscaler(options: UpdateAutoscalerOptions): Promise<void>;
|
|
500
|
+
/**
|
|
501
|
+
* URL of a Function running as a web endpoint.
|
|
502
|
+
* @returns The web URL if this function is a web endpoint, otherwise undefined
|
|
503
|
+
*/
|
|
504
|
+
getWebUrl(): Promise<string | undefined>;
|
|
354
505
|
}
|
|
355
506
|
|
|
356
507
|
/** Represents a deployed Modal Cls. */
|
|
@@ -445,8 +596,9 @@ type QueueIterateOptions = {
|
|
|
445
596
|
declare class Queue {
|
|
446
597
|
#private;
|
|
447
598
|
readonly queueId: string;
|
|
599
|
+
readonly name?: string;
|
|
448
600
|
/** @ignore */
|
|
449
|
-
constructor(queueId: string, ephemeral?: boolean);
|
|
601
|
+
constructor(queueId: string, name?: string, ephemeral?: boolean);
|
|
450
602
|
/**
|
|
451
603
|
* Create a nameless, temporary queue.
|
|
452
604
|
* You will need to call `closeEphemeral()` to delete the queue.
|
|
@@ -502,4 +654,4 @@ declare class Queue {
|
|
|
502
654
|
iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
|
|
503
655
|
}
|
|
504
656
|
|
|
505
|
-
export { App, type ClientOptions, Cls, ClsInstance, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, FunctionTimeoutError, Function_, Image, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, SandboxTimeoutError, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Tunnel, Volume, type VolumeFromNameOptions, initializeClient };
|
|
657
|
+
export { App, type ClientOptions, CloudBucketMount, Cls, ClsInstance, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, type FunctionStats, FunctionTimeoutError, Function_, Image, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Proxy, type ProxyFromNameOptions, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, type SandboxListOptions, SandboxTimeoutError, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Tunnel, type UpdateAutoscalerOptions, Volume, type VolumeFromNameOptions, initializeClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,15 @@ declare enum ParameterType {
|
|
|
15
15
|
PARAM_TYPE_BOOL = 9,
|
|
16
16
|
UNRECOGNIZED = -1
|
|
17
17
|
}
|
|
18
|
+
declare enum RegistryAuthType {
|
|
19
|
+
/** REGISTRY_AUTH_TYPE_UNSPECIFIED - Older clients send this instead of "public". */
|
|
20
|
+
REGISTRY_AUTH_TYPE_UNSPECIFIED = 0,
|
|
21
|
+
REGISTRY_AUTH_TYPE_AWS = 1,
|
|
22
|
+
REGISTRY_AUTH_TYPE_GCP = 2,
|
|
23
|
+
REGISTRY_AUTH_TYPE_PUBLIC = 3,
|
|
24
|
+
REGISTRY_AUTH_TYPE_STATIC_CREDS = 4,
|
|
25
|
+
UNRECOGNIZED = -1
|
|
26
|
+
}
|
|
18
27
|
/** TODO: rename into NamedPayloadType or similar */
|
|
19
28
|
interface ClassParameterSpec {
|
|
20
29
|
name: string;
|
|
@@ -37,6 +46,11 @@ interface GenericPayloadType {
|
|
|
37
46
|
subTypes: GenericPayloadType[];
|
|
38
47
|
}
|
|
39
48
|
declare const GenericPayloadType: MessageFns<GenericPayloadType>;
|
|
49
|
+
interface ImageRegistryConfig {
|
|
50
|
+
registryAuthType: RegistryAuthType;
|
|
51
|
+
secretId: string;
|
|
52
|
+
}
|
|
53
|
+
declare const ImageRegistryConfig: MessageFns<ImageRegistryConfig>;
|
|
40
54
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
41
55
|
type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
42
56
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
@@ -50,11 +64,57 @@ interface MessageFns<T> {
|
|
|
50
64
|
fromPartial(object: DeepPartial<T>): T;
|
|
51
65
|
}
|
|
52
66
|
|
|
67
|
+
/** Options for `Secret.fromName()`. */
|
|
68
|
+
type SecretFromNameOptions = {
|
|
69
|
+
environment?: string;
|
|
70
|
+
requiredKeys?: string[];
|
|
71
|
+
};
|
|
72
|
+
/** Secrets provide a dictionary of environment variables for images. */
|
|
73
|
+
declare class Secret {
|
|
74
|
+
readonly secretId: string;
|
|
75
|
+
readonly name?: string;
|
|
76
|
+
/** @ignore */
|
|
77
|
+
constructor(secretId: string, name?: string);
|
|
78
|
+
/** Reference a Secret by its name. */
|
|
79
|
+
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
80
|
+
/** Create a Secret from a plain object of key-value pairs. */
|
|
81
|
+
static fromObject(entries: Record<string, string>, options?: {
|
|
82
|
+
environment?: string;
|
|
83
|
+
}): Promise<Secret>;
|
|
84
|
+
}
|
|
85
|
+
|
|
53
86
|
/** A container image, used for starting sandboxes. */
|
|
54
87
|
declare class Image {
|
|
55
|
-
|
|
88
|
+
#private;
|
|
56
89
|
/** @ignore */
|
|
57
|
-
constructor(imageId: string);
|
|
90
|
+
constructor(imageId: string, tag: string, imageRegistryConfig?: ImageRegistryConfig);
|
|
91
|
+
get imageId(): string;
|
|
92
|
+
/**
|
|
93
|
+
* Creates an `Image` instance from a raw registry tag, optionally using a secret for authentication.
|
|
94
|
+
*
|
|
95
|
+
* @param tag - The registry tag for the image.
|
|
96
|
+
* @param secret - Optional. A `Secret` instance containing credentials for registry authentication.
|
|
97
|
+
*/
|
|
98
|
+
static fromRegistry(tag: string, secret?: Secret): Image;
|
|
99
|
+
/**
|
|
100
|
+
* Creates an `Image` instance from a raw registry tag, optionally using a secret for authentication.
|
|
101
|
+
*
|
|
102
|
+
* @param tag - The registry tag for the image.
|
|
103
|
+
* @param secret - A `Secret` instance containing credentials for registry authentication.
|
|
104
|
+
*/
|
|
105
|
+
static fromAwsEcr(tag: string, secret: Secret): Image;
|
|
106
|
+
/**
|
|
107
|
+
* Creates an `Image` instance from a raw registry tag, optionally using a secret for authentication.
|
|
108
|
+
*
|
|
109
|
+
* @param tag - The registry tag for the image.
|
|
110
|
+
* @param secret - A `Secret` instance containing credentials for registry authentication.
|
|
111
|
+
*/
|
|
112
|
+
static fromGcpArtifactRegistry(tag: string, secret: Secret): Image;
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
* Build image object
|
|
116
|
+
*/
|
|
117
|
+
_build(appId: string): Promise<Image>;
|
|
58
118
|
}
|
|
59
119
|
|
|
60
120
|
/** File open modes supported by the filesystem API. */
|
|
@@ -124,20 +184,6 @@ interface ModalWriteStream<R = any> extends WritableStream<R> {
|
|
|
124
184
|
writeBytes(bytes: Uint8Array): Promise<void>;
|
|
125
185
|
}
|
|
126
186
|
|
|
127
|
-
/** Options for `Secret.fromName()`. */
|
|
128
|
-
type SecretFromNameOptions = {
|
|
129
|
-
environment?: string;
|
|
130
|
-
requiredKeys?: string[];
|
|
131
|
-
};
|
|
132
|
-
/** Secrets provide a dictionary of environment variables for images. */
|
|
133
|
-
declare class Secret {
|
|
134
|
-
readonly secretId: string;
|
|
135
|
-
/** @ignore */
|
|
136
|
-
constructor(secretId: string);
|
|
137
|
-
/** Reference a Secret by its name. */
|
|
138
|
-
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
187
|
/**
|
|
142
188
|
* Stdin is always present, but this option allow you to drop stdout or stderr
|
|
143
189
|
* if you don't need them. The default is "pipe", matching Node.js behavior.
|
|
@@ -151,6 +197,15 @@ type StdioBehavior = "pipe" | "ignore";
|
|
|
151
197
|
* means the data will be read as raw bytes (Uint8Array).
|
|
152
198
|
*/
|
|
153
199
|
type StreamMode = "text" | "binary";
|
|
200
|
+
/** Options for `Sandbox.list()`. */
|
|
201
|
+
type SandboxListOptions = {
|
|
202
|
+
/** Filter sandboxes for a specific app. */
|
|
203
|
+
appId?: string;
|
|
204
|
+
/** Only return sandboxes that include all specified tags. */
|
|
205
|
+
tags?: Record<string, string>;
|
|
206
|
+
/** Override environment for the request; defaults to current profile. */
|
|
207
|
+
environment?: string;
|
|
208
|
+
};
|
|
154
209
|
/** Options to configure a `Sandbox.exec()` operation. */
|
|
155
210
|
type ExecOptions = {
|
|
156
211
|
/** Specifies text or binary encoding for input and output streams. */
|
|
@@ -190,6 +245,13 @@ declare class Sandbox {
|
|
|
190
245
|
stderr: ModalReadStream<string>;
|
|
191
246
|
/** @ignore */
|
|
192
247
|
constructor(sandboxId: string);
|
|
248
|
+
/** Set tags (key-value pairs) on the Sandbox. Tags can be used to filter results in `Sandbox.list`. */
|
|
249
|
+
setTags(tags: Record<string, string>): Promise<void>;
|
|
250
|
+
/** Returns a running Sandbox object from an ID.
|
|
251
|
+
*
|
|
252
|
+
* @returns Sandbox with ID
|
|
253
|
+
*/
|
|
254
|
+
static fromId(sandboxId: string): Promise<Sandbox>;
|
|
193
255
|
/**
|
|
194
256
|
* Open a file in the sandbox filesystem.
|
|
195
257
|
* @param path - Path to the file to open
|
|
@@ -227,6 +289,11 @@ declare class Sandbox {
|
|
|
227
289
|
* Returns `null` if the Sandbox is still running, else returns the exit code.
|
|
228
290
|
*/
|
|
229
291
|
poll(): Promise<number | null>;
|
|
292
|
+
/**
|
|
293
|
+
* List all Sandboxes for the current Environment or App ID (if specified).
|
|
294
|
+
* If tags are specified, only Sandboxes that have at least those tags are returned.
|
|
295
|
+
*/
|
|
296
|
+
static list(options?: SandboxListOptions): AsyncGenerator<Sandbox, void, unknown>;
|
|
230
297
|
}
|
|
231
298
|
declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
232
299
|
#private;
|
|
@@ -247,9 +314,46 @@ type VolumeFromNameOptions = {
|
|
|
247
314
|
/** Volumes provide persistent storage that can be mounted in Modal functions. */
|
|
248
315
|
declare class Volume {
|
|
249
316
|
readonly volumeId: string;
|
|
317
|
+
readonly name?: string;
|
|
318
|
+
private _readOnly;
|
|
250
319
|
/** @ignore */
|
|
251
|
-
constructor(volumeId: string);
|
|
320
|
+
constructor(volumeId: string, name?: string, readOnly?: boolean);
|
|
252
321
|
static fromName(name: string, options?: VolumeFromNameOptions): Promise<Volume>;
|
|
322
|
+
/** Configure Volume to mount as read-only. */
|
|
323
|
+
readOnly(): Volume;
|
|
324
|
+
get isReadOnly(): boolean;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** Options for `Proxy.fromName()`. */
|
|
328
|
+
type ProxyFromNameOptions = {
|
|
329
|
+
environment?: string;
|
|
330
|
+
};
|
|
331
|
+
/** Proxy objects give your Modal containers a static outbound IP address. */
|
|
332
|
+
declare class Proxy {
|
|
333
|
+
readonly proxyId: string;
|
|
334
|
+
/** @ignore */
|
|
335
|
+
constructor(proxyId: string);
|
|
336
|
+
/** Reference a Proxy by its name. */
|
|
337
|
+
static fromName(name: string, options?: ProxyFromNameOptions): Promise<Proxy>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Cloud bucket mounts provide access to cloud storage buckets within Modal functions. */
|
|
341
|
+
declare class CloudBucketMount {
|
|
342
|
+
readonly bucketName: string;
|
|
343
|
+
readonly secret?: Secret;
|
|
344
|
+
readonly readOnly: boolean;
|
|
345
|
+
readonly requesterPays: boolean;
|
|
346
|
+
readonly bucketEndpointUrl?: string;
|
|
347
|
+
readonly keyPrefix?: string;
|
|
348
|
+
readonly oidcAuthRoleArn?: string;
|
|
349
|
+
constructor(bucketName: string, options?: {
|
|
350
|
+
secret?: Secret;
|
|
351
|
+
readOnly?: boolean;
|
|
352
|
+
requesterPays?: boolean;
|
|
353
|
+
bucketEndpointUrl?: string;
|
|
354
|
+
keyPrefix?: string;
|
|
355
|
+
oidcAuthRoleArn?: string;
|
|
356
|
+
});
|
|
253
357
|
}
|
|
254
358
|
|
|
255
359
|
/** Options for functions that find deployed Modal objects. */
|
|
@@ -271,8 +375,12 @@ type SandboxCreateOptions = {
|
|
|
271
375
|
cpu?: number;
|
|
272
376
|
/** Reservation of memory in MiB. */
|
|
273
377
|
memory?: number;
|
|
378
|
+
/** GPU reservation for the sandbox (e.g. "A100", "T4:2", "A100-80GB:4"). */
|
|
379
|
+
gpu?: string;
|
|
274
380
|
/** Timeout of the sandbox container, defaults to 10 minutes. */
|
|
275
381
|
timeout?: number;
|
|
382
|
+
/** Working directory of the sandbox. */
|
|
383
|
+
workdir?: string;
|
|
276
384
|
/**
|
|
277
385
|
* Sequence of program arguments for the main process.
|
|
278
386
|
* Default behavior is to sleep indefinitely until timeout or termination.
|
|
@@ -282,23 +390,47 @@ type SandboxCreateOptions = {
|
|
|
282
390
|
secrets?: Secret[];
|
|
283
391
|
/** Mount points for Modal Volumes. */
|
|
284
392
|
volumes?: Record<string, Volume>;
|
|
393
|
+
/** Mount points for cloud buckets. */
|
|
394
|
+
cloudBucketMounts?: Record<string, CloudBucketMount>;
|
|
285
395
|
/** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
|
|
286
396
|
encryptedPorts?: number[];
|
|
287
397
|
/** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
|
|
288
398
|
h2Ports?: number[];
|
|
289
399
|
/** List of ports to tunnel into the sandbox without encryption. */
|
|
290
400
|
unencryptedPorts?: number[];
|
|
401
|
+
/** Whether to block all network access from the sandbox. */
|
|
402
|
+
blockNetwork?: boolean;
|
|
403
|
+
/** List of CIDRs the sandbox is allowed to access. If None, all CIDRs are allowed. Cannot be used with blockNetwork. */
|
|
404
|
+
cidrAllowlist?: string[];
|
|
405
|
+
/** Cloud provider to run the sandbox on. */
|
|
406
|
+
cloud?: string;
|
|
407
|
+
/** Region(s) to run the sandbox on. */
|
|
408
|
+
regions?: string[];
|
|
409
|
+
/** Enable verbose logging. */
|
|
410
|
+
verbose?: boolean;
|
|
411
|
+
/** Reference to a Modal Proxy to use in front of this Sandbox. */
|
|
412
|
+
proxy?: Proxy;
|
|
291
413
|
};
|
|
292
414
|
/** Represents a deployed Modal App. */
|
|
293
415
|
declare class App {
|
|
294
416
|
readonly appId: string;
|
|
417
|
+
readonly name?: string;
|
|
295
418
|
/** @ignore */
|
|
296
|
-
constructor(appId: string);
|
|
419
|
+
constructor(appId: string, name?: string);
|
|
297
420
|
/** Lookup a deployed app by name, or create if it does not exist. */
|
|
298
421
|
static lookup(name: string, options?: LookupOptions): Promise<App>;
|
|
299
422
|
createSandbox(image: Image, options?: SandboxCreateOptions): Promise<Sandbox>;
|
|
423
|
+
/**
|
|
424
|
+
* @deprecated Use `Image.fromRegistry` instead.
|
|
425
|
+
*/
|
|
300
426
|
imageFromRegistry(tag: string, secret?: Secret): Promise<Image>;
|
|
427
|
+
/**
|
|
428
|
+
* @deprecated Use `Image.fromAwsEcr` instead.
|
|
429
|
+
*/
|
|
301
430
|
imageFromAwsEcr(tag: string, secret: Secret): Promise<Image>;
|
|
431
|
+
/**
|
|
432
|
+
* @deprecated Use `Image.fromGcpArtifactRegistry` instead.
|
|
433
|
+
*/
|
|
302
434
|
imageFromGcpArtifactRegistry(tag: string, secret: Secret): Promise<Image>;
|
|
303
435
|
}
|
|
304
436
|
|
|
@@ -341,16 +473,35 @@ declare class FunctionCall {
|
|
|
341
473
|
cancel(options?: FunctionCallCancelOptions): Promise<void>;
|
|
342
474
|
}
|
|
343
475
|
|
|
476
|
+
/** Simple data structure storing stats for a running Function. */
|
|
477
|
+
interface FunctionStats {
|
|
478
|
+
backlog: number;
|
|
479
|
+
numTotalRunners: number;
|
|
480
|
+
}
|
|
481
|
+
/** Options for overriding a Function's autoscaler behavior. */
|
|
482
|
+
interface UpdateAutoscalerOptions {
|
|
483
|
+
minContainers?: number;
|
|
484
|
+
maxContainers?: number;
|
|
485
|
+
bufferContainers?: number;
|
|
486
|
+
scaledownWindow?: number;
|
|
487
|
+
}
|
|
344
488
|
/** Represents a deployed Modal Function, which can be invoked remotely. */
|
|
345
489
|
declare class Function_ {
|
|
346
490
|
#private;
|
|
347
491
|
readonly functionId: string;
|
|
348
492
|
readonly methodName?: string;
|
|
349
493
|
/** @ignore */
|
|
350
|
-
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
|
|
494
|
+
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string, webUrl?: string);
|
|
351
495
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
352
496
|
remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
|
|
353
497
|
spawn(args?: any[], kwargs?: Record<string, any>): Promise<FunctionCall>;
|
|
498
|
+
getCurrentStats(): Promise<FunctionStats>;
|
|
499
|
+
updateAutoscaler(options: UpdateAutoscalerOptions): Promise<void>;
|
|
500
|
+
/**
|
|
501
|
+
* URL of a Function running as a web endpoint.
|
|
502
|
+
* @returns The web URL if this function is a web endpoint, otherwise undefined
|
|
503
|
+
*/
|
|
504
|
+
getWebUrl(): Promise<string | undefined>;
|
|
354
505
|
}
|
|
355
506
|
|
|
356
507
|
/** Represents a deployed Modal Cls. */
|
|
@@ -445,8 +596,9 @@ type QueueIterateOptions = {
|
|
|
445
596
|
declare class Queue {
|
|
446
597
|
#private;
|
|
447
598
|
readonly queueId: string;
|
|
599
|
+
readonly name?: string;
|
|
448
600
|
/** @ignore */
|
|
449
|
-
constructor(queueId: string, ephemeral?: boolean);
|
|
601
|
+
constructor(queueId: string, name?: string, ephemeral?: boolean);
|
|
450
602
|
/**
|
|
451
603
|
* Create a nameless, temporary queue.
|
|
452
604
|
* You will need to call `closeEphemeral()` to delete the queue.
|
|
@@ -502,4 +654,4 @@ declare class Queue {
|
|
|
502
654
|
iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
|
|
503
655
|
}
|
|
504
656
|
|
|
505
|
-
export { App, type ClientOptions, Cls, ClsInstance, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, FunctionTimeoutError, Function_, Image, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, SandboxTimeoutError, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Tunnel, Volume, type VolumeFromNameOptions, initializeClient };
|
|
657
|
+
export { App, type ClientOptions, CloudBucketMount, Cls, ClsInstance, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, type FunctionStats, FunctionTimeoutError, Function_, Image, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Proxy, type ProxyFromNameOptions, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, type SandboxListOptions, SandboxTimeoutError, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Tunnel, type UpdateAutoscalerOptions, Volume, type VolumeFromNameOptions, initializeClient };
|