modal 0.3.16 → 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 +481 -138
- package/dist/index.d.cts +168 -21
- package/dist/index.d.ts +168 -21
- package/dist/index.js +479 -138
- 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,8 @@ 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>;
|
|
193
250
|
/** Returns a running Sandbox object from an ID.
|
|
194
251
|
*
|
|
195
252
|
* @returns Sandbox with ID
|
|
@@ -232,6 +289,11 @@ declare class Sandbox {
|
|
|
232
289
|
* Returns `null` if the Sandbox is still running, else returns the exit code.
|
|
233
290
|
*/
|
|
234
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>;
|
|
235
297
|
}
|
|
236
298
|
declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
237
299
|
#private;
|
|
@@ -252,9 +314,46 @@ type VolumeFromNameOptions = {
|
|
|
252
314
|
/** Volumes provide persistent storage that can be mounted in Modal functions. */
|
|
253
315
|
declare class Volume {
|
|
254
316
|
readonly volumeId: string;
|
|
317
|
+
readonly name?: string;
|
|
318
|
+
private _readOnly;
|
|
255
319
|
/** @ignore */
|
|
256
|
-
constructor(volumeId: string);
|
|
320
|
+
constructor(volumeId: string, name?: string, readOnly?: boolean);
|
|
257
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
|
+
});
|
|
258
357
|
}
|
|
259
358
|
|
|
260
359
|
/** Options for functions that find deployed Modal objects. */
|
|
@@ -276,8 +375,12 @@ type SandboxCreateOptions = {
|
|
|
276
375
|
cpu?: number;
|
|
277
376
|
/** Reservation of memory in MiB. */
|
|
278
377
|
memory?: number;
|
|
378
|
+
/** GPU reservation for the sandbox (e.g. "A100", "T4:2", "A100-80GB:4"). */
|
|
379
|
+
gpu?: string;
|
|
279
380
|
/** Timeout of the sandbox container, defaults to 10 minutes. */
|
|
280
381
|
timeout?: number;
|
|
382
|
+
/** Working directory of the sandbox. */
|
|
383
|
+
workdir?: string;
|
|
281
384
|
/**
|
|
282
385
|
* Sequence of program arguments for the main process.
|
|
283
386
|
* Default behavior is to sleep indefinitely until timeout or termination.
|
|
@@ -287,23 +390,47 @@ type SandboxCreateOptions = {
|
|
|
287
390
|
secrets?: Secret[];
|
|
288
391
|
/** Mount points for Modal Volumes. */
|
|
289
392
|
volumes?: Record<string, Volume>;
|
|
393
|
+
/** Mount points for cloud buckets. */
|
|
394
|
+
cloudBucketMounts?: Record<string, CloudBucketMount>;
|
|
290
395
|
/** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
|
|
291
396
|
encryptedPorts?: number[];
|
|
292
397
|
/** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
|
|
293
398
|
h2Ports?: number[];
|
|
294
399
|
/** List of ports to tunnel into the sandbox without encryption. */
|
|
295
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;
|
|
296
413
|
};
|
|
297
414
|
/** Represents a deployed Modal App. */
|
|
298
415
|
declare class App {
|
|
299
416
|
readonly appId: string;
|
|
417
|
+
readonly name?: string;
|
|
300
418
|
/** @ignore */
|
|
301
|
-
constructor(appId: string);
|
|
419
|
+
constructor(appId: string, name?: string);
|
|
302
420
|
/** Lookup a deployed app by name, or create if it does not exist. */
|
|
303
421
|
static lookup(name: string, options?: LookupOptions): Promise<App>;
|
|
304
422
|
createSandbox(image: Image, options?: SandboxCreateOptions): Promise<Sandbox>;
|
|
423
|
+
/**
|
|
424
|
+
* @deprecated Use `Image.fromRegistry` instead.
|
|
425
|
+
*/
|
|
305
426
|
imageFromRegistry(tag: string, secret?: Secret): Promise<Image>;
|
|
427
|
+
/**
|
|
428
|
+
* @deprecated Use `Image.fromAwsEcr` instead.
|
|
429
|
+
*/
|
|
306
430
|
imageFromAwsEcr(tag: string, secret: Secret): Promise<Image>;
|
|
431
|
+
/**
|
|
432
|
+
* @deprecated Use `Image.fromGcpArtifactRegistry` instead.
|
|
433
|
+
*/
|
|
307
434
|
imageFromGcpArtifactRegistry(tag: string, secret: Secret): Promise<Image>;
|
|
308
435
|
}
|
|
309
436
|
|
|
@@ -346,16 +473,35 @@ declare class FunctionCall {
|
|
|
346
473
|
cancel(options?: FunctionCallCancelOptions): Promise<void>;
|
|
347
474
|
}
|
|
348
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
|
+
}
|
|
349
488
|
/** Represents a deployed Modal Function, which can be invoked remotely. */
|
|
350
489
|
declare class Function_ {
|
|
351
490
|
#private;
|
|
352
491
|
readonly functionId: string;
|
|
353
492
|
readonly methodName?: string;
|
|
354
493
|
/** @ignore */
|
|
355
|
-
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
|
|
494
|
+
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string, webUrl?: string);
|
|
356
495
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
357
496
|
remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
|
|
358
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>;
|
|
359
505
|
}
|
|
360
506
|
|
|
361
507
|
/** Represents a deployed Modal Cls. */
|
|
@@ -450,8 +596,9 @@ type QueueIterateOptions = {
|
|
|
450
596
|
declare class Queue {
|
|
451
597
|
#private;
|
|
452
598
|
readonly queueId: string;
|
|
599
|
+
readonly name?: string;
|
|
453
600
|
/** @ignore */
|
|
454
|
-
constructor(queueId: string, ephemeral?: boolean);
|
|
601
|
+
constructor(queueId: string, name?: string, ephemeral?: boolean);
|
|
455
602
|
/**
|
|
456
603
|
* Create a nameless, temporary queue.
|
|
457
604
|
* You will need to call `closeEphemeral()` to delete the queue.
|
|
@@ -507,4 +654,4 @@ declare class Queue {
|
|
|
507
654
|
iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
|
|
508
655
|
}
|
|
509
656
|
|
|
510
|
-
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,8 @@ 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>;
|
|
193
250
|
/** Returns a running Sandbox object from an ID.
|
|
194
251
|
*
|
|
195
252
|
* @returns Sandbox with ID
|
|
@@ -232,6 +289,11 @@ declare class Sandbox {
|
|
|
232
289
|
* Returns `null` if the Sandbox is still running, else returns the exit code.
|
|
233
290
|
*/
|
|
234
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>;
|
|
235
297
|
}
|
|
236
298
|
declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
237
299
|
#private;
|
|
@@ -252,9 +314,46 @@ type VolumeFromNameOptions = {
|
|
|
252
314
|
/** Volumes provide persistent storage that can be mounted in Modal functions. */
|
|
253
315
|
declare class Volume {
|
|
254
316
|
readonly volumeId: string;
|
|
317
|
+
readonly name?: string;
|
|
318
|
+
private _readOnly;
|
|
255
319
|
/** @ignore */
|
|
256
|
-
constructor(volumeId: string);
|
|
320
|
+
constructor(volumeId: string, name?: string, readOnly?: boolean);
|
|
257
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
|
+
});
|
|
258
357
|
}
|
|
259
358
|
|
|
260
359
|
/** Options for functions that find deployed Modal objects. */
|
|
@@ -276,8 +375,12 @@ type SandboxCreateOptions = {
|
|
|
276
375
|
cpu?: number;
|
|
277
376
|
/** Reservation of memory in MiB. */
|
|
278
377
|
memory?: number;
|
|
378
|
+
/** GPU reservation for the sandbox (e.g. "A100", "T4:2", "A100-80GB:4"). */
|
|
379
|
+
gpu?: string;
|
|
279
380
|
/** Timeout of the sandbox container, defaults to 10 minutes. */
|
|
280
381
|
timeout?: number;
|
|
382
|
+
/** Working directory of the sandbox. */
|
|
383
|
+
workdir?: string;
|
|
281
384
|
/**
|
|
282
385
|
* Sequence of program arguments for the main process.
|
|
283
386
|
* Default behavior is to sleep indefinitely until timeout or termination.
|
|
@@ -287,23 +390,47 @@ type SandboxCreateOptions = {
|
|
|
287
390
|
secrets?: Secret[];
|
|
288
391
|
/** Mount points for Modal Volumes. */
|
|
289
392
|
volumes?: Record<string, Volume>;
|
|
393
|
+
/** Mount points for cloud buckets. */
|
|
394
|
+
cloudBucketMounts?: Record<string, CloudBucketMount>;
|
|
290
395
|
/** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
|
|
291
396
|
encryptedPorts?: number[];
|
|
292
397
|
/** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
|
|
293
398
|
h2Ports?: number[];
|
|
294
399
|
/** List of ports to tunnel into the sandbox without encryption. */
|
|
295
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;
|
|
296
413
|
};
|
|
297
414
|
/** Represents a deployed Modal App. */
|
|
298
415
|
declare class App {
|
|
299
416
|
readonly appId: string;
|
|
417
|
+
readonly name?: string;
|
|
300
418
|
/** @ignore */
|
|
301
|
-
constructor(appId: string);
|
|
419
|
+
constructor(appId: string, name?: string);
|
|
302
420
|
/** Lookup a deployed app by name, or create if it does not exist. */
|
|
303
421
|
static lookup(name: string, options?: LookupOptions): Promise<App>;
|
|
304
422
|
createSandbox(image: Image, options?: SandboxCreateOptions): Promise<Sandbox>;
|
|
423
|
+
/**
|
|
424
|
+
* @deprecated Use `Image.fromRegistry` instead.
|
|
425
|
+
*/
|
|
305
426
|
imageFromRegistry(tag: string, secret?: Secret): Promise<Image>;
|
|
427
|
+
/**
|
|
428
|
+
* @deprecated Use `Image.fromAwsEcr` instead.
|
|
429
|
+
*/
|
|
306
430
|
imageFromAwsEcr(tag: string, secret: Secret): Promise<Image>;
|
|
431
|
+
/**
|
|
432
|
+
* @deprecated Use `Image.fromGcpArtifactRegistry` instead.
|
|
433
|
+
*/
|
|
307
434
|
imageFromGcpArtifactRegistry(tag: string, secret: Secret): Promise<Image>;
|
|
308
435
|
}
|
|
309
436
|
|
|
@@ -346,16 +473,35 @@ declare class FunctionCall {
|
|
|
346
473
|
cancel(options?: FunctionCallCancelOptions): Promise<void>;
|
|
347
474
|
}
|
|
348
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
|
+
}
|
|
349
488
|
/** Represents a deployed Modal Function, which can be invoked remotely. */
|
|
350
489
|
declare class Function_ {
|
|
351
490
|
#private;
|
|
352
491
|
readonly functionId: string;
|
|
353
492
|
readonly methodName?: string;
|
|
354
493
|
/** @ignore */
|
|
355
|
-
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
|
|
494
|
+
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string, webUrl?: string);
|
|
356
495
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
357
496
|
remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
|
|
358
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>;
|
|
359
505
|
}
|
|
360
506
|
|
|
361
507
|
/** Represents a deployed Modal Cls. */
|
|
@@ -450,8 +596,9 @@ type QueueIterateOptions = {
|
|
|
450
596
|
declare class Queue {
|
|
451
597
|
#private;
|
|
452
598
|
readonly queueId: string;
|
|
599
|
+
readonly name?: string;
|
|
453
600
|
/** @ignore */
|
|
454
|
-
constructor(queueId: string, ephemeral?: boolean);
|
|
601
|
+
constructor(queueId: string, name?: string, ephemeral?: boolean);
|
|
455
602
|
/**
|
|
456
603
|
* Create a nameless, temporary queue.
|
|
457
604
|
* You will need to call `closeEphemeral()` to delete the queue.
|
|
@@ -507,4 +654,4 @@ declare class Queue {
|
|
|
507
654
|
iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
|
|
508
655
|
}
|
|
509
656
|
|
|
510
|
-
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 };
|