modal 0.10.2-dev.1 → 0.10.2-dev.10

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
@@ -233,6 +233,20 @@ declare enum FileDescriptor {
233
233
  FILE_DESCRIPTOR_INFO = 3,
234
234
  UNRECOGNIZED = -1
235
235
  }
236
+ declare enum FunctionCallInputStatus {
237
+ FUNCTION_CALL_INPUT_STATUS_UNSPECIFIED = 0,
238
+ FUNCTION_CALL_INPUT_STATUS_PENDING = 1,
239
+ FUNCTION_CALL_INPUT_STATUS_RUNNING = 2,
240
+ FUNCTION_CALL_INPUT_STATUS_SUCCESS = 3,
241
+ FUNCTION_CALL_INPUT_STATUS_FAILURE = 4,
242
+ FUNCTION_CALL_INPUT_STATUS_TIMEOUT = 5,
243
+ FUNCTION_CALL_INPUT_STATUS_TERMINATED = 6,
244
+ FUNCTION_CALL_INPUT_STATUS_INIT_FAILURE = 7,
245
+ FUNCTION_CALL_INPUT_STATUS_INTERNAL_FAILURE = 8,
246
+ FUNCTION_CALL_INPUT_STATUS_IDLE_TIMEOUT = 9,
247
+ FUNCTION_CALL_INPUT_STATUS_MEMORY_MANAGER_EVICTION = 10,
248
+ UNRECOGNIZED = -1
249
+ }
236
250
  declare enum FunctionCallInvocationType {
237
251
  FUNCTION_CALL_INVOCATION_TYPE_UNSPECIFIED = 0,
238
252
  FUNCTION_CALL_INVOCATION_TYPE_SYNC_LEGACY = 1,
@@ -530,6 +544,11 @@ declare enum SandboxGetExitSnapshotResponse_ErrorCode {
530
544
  ERROR_CODE_UNSPECIFIED = 0,
531
545
  ERROR_CODE_TIMEOUT = 1,
532
546
  ERROR_CODE_INTERNAL = 2,
547
+ /**
548
+ * ERROR_CODE_FILESYSTEM_INCONSISTENT - The sandbox exited without leaving a consistent filesystem (e.g. killed
549
+ * before it could flush) and recovery failed, so no exit snapshot exists.
550
+ */
551
+ ERROR_CODE_FILESYSTEM_INCONSISTENT = 3,
533
552
  UNRECOGNIZED = -1
534
553
  }
535
554
  declare enum SandboxRestoreRequest_SandboxNameOverrideType {
@@ -683,6 +702,8 @@ interface AppGetInfoResponse_FunctionInfoSummary {
683
702
  /** True for Web Functions and classes with web methods; false for Servers. */
684
703
  webFunction: boolean;
685
704
  requiresProxyAuth?: boolean | undefined;
705
+ /** True for Sessioned Servers. */
706
+ isSessioned: boolean;
686
707
  }
687
708
  declare const AppGetInfoResponse_FunctionInfoSummary: MessageFns$1<AppGetInfoResponse_FunctionInfoSummary>;
688
709
  interface AppGetLayoutRequest {
@@ -1599,6 +1620,7 @@ interface EndpointCreateRequest {
1599
1620
  environmentName: string;
1600
1621
  unauthenticated: boolean;
1601
1622
  servingMode: EndpointServingMode;
1623
+ sharedEndpointNoticeAcknowledged: boolean;
1602
1624
  }
1603
1625
  declare const EndpointCreateRequest: MessageFns$1<EndpointCreateRequest>;
1604
1626
  interface EndpointCreateResponse {
@@ -1712,7 +1734,7 @@ interface EnvironmentBillingSummaryResponse {
1712
1734
  * at the workspace level
1713
1735
  */
1714
1736
  meteredCost: string;
1715
- /** keyed by deployed, ephemeral, volume, notebook */
1737
+ /** keyed by app type (deployed, ephemeral, notebook, endpoint, ...), volume, tokens, network egress */
1716
1738
  meteredCostBreakdown: {
1717
1739
  [key: string]: string;
1718
1740
  };
@@ -2000,10 +2022,6 @@ interface FunctionMessage {
2000
2022
  schedulerPlacement?: SchedulerPlacement | undefined;
2001
2023
  /** if "Function" is actually a class grouping multiple methods */
2002
2024
  isClass: boolean;
2003
- /** for class methods use this function id instead for invocations - the *referenced* function should have is_class=True */
2004
- useFunctionId: string;
2005
- /** for class methods - this method name needs to be included in the FunctionInput */
2006
- useMethodName: string;
2007
2025
  classParameterInfo: ClassParameterInfo | undefined;
2008
2026
  /** Maximum number of inputs to fetch at once */
2009
2027
  batchMaxSize: number;
@@ -2030,13 +2048,6 @@ interface FunctionMessage {
2030
2048
  untrusted: boolean;
2031
2049
  /** To be replaced by autoscaler_settings.buffer_containers */
2032
2050
  ExperimentalBufferContainers: number;
2033
- /**
2034
- * _experimental_proxy_ip -> ProxyInfo
2035
- * TODO: deprecate.
2036
- *
2037
- * @deprecated
2038
- */
2039
- ExperimentalProxyIp?: string | undefined;
2040
2051
  /** For internal debugging use only. */
2041
2052
  runtimePerfRecord: boolean;
2042
2053
  schedule: Schedule | undefined;
@@ -2132,6 +2143,23 @@ interface FunctionCallCancelRequest {
2132
2143
  functionId?: string | undefined;
2133
2144
  }
2134
2145
  declare const FunctionCallCancelRequest: MessageFns$1<FunctionCallCancelRequest>;
2146
+ interface FunctionCallFetchRequest {
2147
+ functionId: string;
2148
+ tail?: FunctionCallFetchRequest_Tail | undefined;
2149
+ /** Include the root Function and its eligible variants. */
2150
+ allVariants: boolean;
2151
+ }
2152
+ declare const FunctionCallFetchRequest: MessageFns$1<FunctionCallFetchRequest>;
2153
+ interface FunctionCallFetchRequest_Tail {
2154
+ /** Number of most recent inputs to return. Must be between 1 and 1000. */
2155
+ count: number;
2156
+ }
2157
+ declare const FunctionCallFetchRequest_Tail: MessageFns$1<FunctionCallFetchRequest_Tail>;
2158
+ interface FunctionCallFetchResponse {
2159
+ /** The requested number of most recent inputs from the last seven days, ordered from newest to oldest. */
2160
+ functionCallInputs: FunctionCallInputInfo[];
2161
+ }
2162
+ declare const FunctionCallFetchResponse: MessageFns$1<FunctionCallFetchResponse>;
2135
2163
  interface FunctionCallFromIdRequest {
2136
2164
  functionCallId: string;
2137
2165
  }
@@ -2178,6 +2206,17 @@ interface FunctionCallInfo {
2178
2206
  totalInputs: number;
2179
2207
  }
2180
2208
  declare const FunctionCallInfo: MessageFns$1<FunctionCallInfo>;
2209
+ interface FunctionCallInputInfo {
2210
+ enqueuedAt: Date | undefined;
2211
+ startedAt?: Date | undefined;
2212
+ containerId?: string | undefined;
2213
+ startupTimeSeconds?: number | undefined;
2214
+ executionTimeSeconds?: number | undefined;
2215
+ status: FunctionCallInputStatus;
2216
+ functionCallId: string;
2217
+ serviceMethodName?: string | undefined;
2218
+ }
2219
+ declare const FunctionCallInputInfo: MessageFns$1<FunctionCallInputInfo>;
2181
2220
  interface FunctionCallListRequest {
2182
2221
  functionId: string;
2183
2222
  }
@@ -2255,13 +2294,6 @@ interface FunctionData {
2255
2294
  webUrlInfo: WebUrlInfo | undefined;
2256
2295
  webhookConfig: WebhookConfig | undefined;
2257
2296
  customDomainInfo: CustomDomainInfo[];
2258
- /**
2259
- * _experimental_proxy_ip -> ProxyInfo
2260
- * TODO: deprecate.
2261
- *
2262
- * @deprecated
2263
- */
2264
- ExperimentalProxyIp?: string | undefined;
2265
2297
  /** Mapping of method names to method definitions, only non-empty for class service functions */
2266
2298
  methodDefinitions: {
2267
2299
  [key: string]: MethodDefinition;
@@ -2271,10 +2303,6 @@ interface FunctionData {
2271
2303
  isClass: boolean;
2272
2304
  classParameterInfo: ClassParameterInfo | undefined;
2273
2305
  isMethod: boolean;
2274
- /** used for methods */
2275
- useFunctionId: string;
2276
- /** used for methods */
2277
- useMethodName: string;
2278
2306
  rankedFunctions: FunctionData_RankedFunction[];
2279
2307
  schedule: Schedule | undefined;
2280
2308
  /** If set, the function will be run in an untrusted environment. */
@@ -2523,8 +2551,6 @@ interface FunctionHandleMetadata {
2523
2551
  webUrl: string;
2524
2552
  isMethod: boolean;
2525
2553
  /** used for methods */
2526
- useFunctionId: string;
2527
- /** used for methods */
2528
2554
  useMethodName: string;
2529
2555
  definitionId: string;
2530
2556
  classParameterInfo: ClassParameterInfo | undefined;
@@ -2557,6 +2583,20 @@ interface FunctionInput {
2557
2583
  methodName?: string | undefined;
2558
2584
  }
2559
2585
  declare const FunctionInput: MessageFns$1<FunctionInput>;
2586
+ interface FunctionListVariantsRequest {
2587
+ functionId: string;
2588
+ cursor: FunctionVariantCursor | undefined;
2589
+ limit: number;
2590
+ }
2591
+ declare const FunctionListVariantsRequest: MessageFns$1<FunctionListVariantsRequest>;
2592
+ interface FunctionListVariantsResponse {
2593
+ infos: FunctionVariantInfo[];
2594
+ /** Pass back as cursor to fetch the next page. Unset once the listing is complete. */
2595
+ nextCursor: FunctionVariantCursor | undefined;
2596
+ /** Set by the server when it ordered the variants by how many tasks each is running, busiest first. */
2597
+ orderedByTaskCount: boolean;
2598
+ }
2599
+ declare const FunctionListVariantsResponse: MessageFns$1<FunctionListVariantsResponse>;
2560
2600
  interface FunctionMapRequest {
2561
2601
  functionId: string;
2562
2602
  parentInputId: string;
@@ -2609,10 +2649,6 @@ interface FunctionPrecreateRequest {
2609
2649
  existingFunctionId: string;
2610
2650
  functionType: Function_FunctionType;
2611
2651
  webhookConfig: WebhookConfig | undefined;
2612
- /** for class methods - use this function id instead for invocations - the *referenced* function should have is_class=True */
2613
- useFunctionId: string;
2614
- /** for class methods - this method name needs to be included in the FunctionInput */
2615
- useMethodName: string;
2616
2652
  /** Mapping of method names to method definitions, only non-empty for class service functions */
2617
2653
  methodDefinitions: {
2618
2654
  [key: string]: MethodDefinition;
@@ -2720,6 +2756,17 @@ interface FunctionUpdateSchedulingParamsResponse {
2720
2756
  currentSettings: AutoscalerSettings | undefined;
2721
2757
  }
2722
2758
  declare const FunctionUpdateSchedulingParamsResponse: MessageFns$1<FunctionUpdateSchedulingParamsResponse>;
2759
+ interface FunctionVariantCursor {
2760
+ createdBefore: number;
2761
+ functionId: string;
2762
+ }
2763
+ declare const FunctionVariantCursor: MessageFns$1<FunctionVariantCursor>;
2764
+ interface FunctionVariantInfo {
2765
+ functionId: string;
2766
+ serializedParams: Uint8Array;
2767
+ functionOptions: FunctionOptions$1 | undefined;
2768
+ }
2769
+ declare const FunctionVariantInfo: MessageFns$1<FunctionVariantInfo>;
2723
2770
  interface GPUConfig {
2724
2771
  /** Deprecated, at some point */
2725
2772
  type: GPUType;
@@ -2763,6 +2810,7 @@ interface HTTPConfig {
2763
2810
  h2Enabled: boolean;
2764
2811
  targetConcurrency: number;
2765
2812
  unauthenticated: boolean;
2813
+ liftAndShiftConfig?: LiftAndShiftConfig | undefined;
2766
2814
  }
2767
2815
  declare const HTTPConfig: MessageFns$1<HTTPConfig>;
2768
2816
  interface Image$1 {
@@ -3016,6 +3064,9 @@ interface InputInfo {
3016
3064
  taskFirstInput: boolean;
3017
3065
  }
3018
3066
  declare const InputInfo: MessageFns$1<InputInfo>;
3067
+ interface LiftAndShiftConfig {
3068
+ }
3069
+ declare const LiftAndShiftConfig: MessageFns$1<LiftAndShiftConfig>;
3019
3070
  interface ListPagination {
3020
3071
  maxObjects: number;
3021
3072
  createdBefore: number;
@@ -3591,7 +3642,10 @@ interface Sandbox$1 {
3591
3642
  * Set by the backend at snapshot creation time.
3592
3643
  */
3593
3644
  runscRuntimeVersion?: string | undefined;
3594
- /** If set, overrides the runtime used by the function, either "runc" or "gvisor". */
3645
+ /**
3646
+ * Runtime the sandbox runs in: "vm" for a virtual machine, or a container
3647
+ * runtime such as "gvisor". Leave it unset to let Modal pick.
3648
+ */
3595
3649
  runtime?: string | undefined;
3596
3650
  /** If set, the sandbox will be created with verbose logging enabled. */
3597
3651
  verbose: boolean;
@@ -4034,6 +4088,14 @@ interface SecretDeleteRequest {
4034
4088
  secretId: string;
4035
4089
  }
4036
4090
  declare const SecretDeleteRequest: MessageFns$1<SecretDeleteRequest>;
4091
+ interface SecretGetInfoRequest {
4092
+ secretId: string;
4093
+ }
4094
+ declare const SecretGetInfoRequest: MessageFns$1<SecretGetInfoRequest>;
4095
+ interface SecretGetInfoResponse {
4096
+ metadata: SecretMetadata | undefined;
4097
+ }
4098
+ declare const SecretGetInfoResponse: MessageFns$1<SecretGetInfoResponse>;
4037
4099
  interface SecretGetOrCreateRequest {
4038
4100
  deploymentName: string;
4039
4101
  environmentName: string;
@@ -4076,6 +4138,8 @@ declare const SecretListResponse: MessageFns$1<SecretListResponse>;
4076
4138
  interface SecretMetadata {
4077
4139
  name: string;
4078
4140
  creationInfo: CreationInfo | undefined;
4141
+ keys: string[];
4142
+ environmentName: string;
4079
4143
  }
4080
4144
  declare const SecretMetadata: MessageFns$1<SecretMetadata>;
4081
4145
  interface SecretUpdateRequest {
@@ -4154,6 +4218,29 @@ interface ServerGetTimeRangeStatsResponse_ServerStatusCodeCount {
4154
4218
  count: number;
4155
4219
  }
4156
4220
  declare const ServerGetTimeRangeStatsResponse_ServerStatusCodeCount: MessageFns$1<ServerGetTimeRangeStatsResponse_ServerStatusCodeCount>;
4221
+ interface ServerRequestFetchRequest {
4222
+ functionId: string;
4223
+ tail?: ServerRequestFetchRequest_Tail | undefined;
4224
+ }
4225
+ declare const ServerRequestFetchRequest: MessageFns$1<ServerRequestFetchRequest>;
4226
+ interface ServerRequestFetchRequest_Tail {
4227
+ /** Number of most recent requests to return. Must be between 1 and 1000. */
4228
+ count: number;
4229
+ }
4230
+ declare const ServerRequestFetchRequest_Tail: MessageFns$1<ServerRequestFetchRequest_Tail>;
4231
+ interface ServerRequestFetchResponse {
4232
+ /** The requested number of most recent requests from the last seven days, ordered from newest to oldest. */
4233
+ requests: ServerRequestInfo[];
4234
+ }
4235
+ declare const ServerRequestFetchResponse: MessageFns$1<ServerRequestFetchResponse>;
4236
+ interface ServerRequestInfo {
4237
+ route: string;
4238
+ timestamp: Date | undefined;
4239
+ containerId: string;
4240
+ durationSeconds: number;
4241
+ status: number;
4242
+ }
4243
+ declare const ServerRequestInfo: MessageFns$1<ServerRequestInfo>;
4157
4244
  interface ServiceUser {
4158
4245
  name: string;
4159
4246
  tokenId: string;
@@ -4376,6 +4463,7 @@ interface TaskLogsBatch {
4376
4463
  ptyExecId: string;
4377
4464
  rootFunctionId: string;
4378
4465
  ttlDays: number;
4466
+ sandboxId: string;
4379
4467
  }
4380
4468
  declare const TaskLogsBatch: MessageFns$1<TaskLogsBatch>;
4381
4469
  interface TaskProgress {
@@ -4435,6 +4523,7 @@ interface TokenFlowCreateRequest {
4435
4523
  utmSource: string;
4436
4524
  localhostPort: number;
4437
4525
  nextUrl: string;
4526
+ expiresInSeconds: number;
4438
4527
  }
4439
4528
  declare const TokenFlowCreateRequest: MessageFns$1<TokenFlowCreateRequest>;
4440
4529
  interface TokenFlowCreateResponse {
@@ -4870,6 +4959,11 @@ interface WebhookTokenListResponse {
4870
4959
  tokens: WebhookToken[];
4871
4960
  }
4872
4961
  declare const WebhookTokenListResponse: MessageFns$1<WebhookTokenListResponse>;
4962
+ interface WebhookTokenUpdateRequest {
4963
+ tokenId: string;
4964
+ name?: string | undefined;
4965
+ }
4966
+ declare const WebhookTokenUpdateRequest: MessageFns$1<WebhookTokenUpdateRequest>;
4873
4967
  interface WorkspaceBillingRatesRequest {
4874
4968
  }
4875
4969
  declare const WorkspaceBillingRatesRequest: MessageFns$1<WorkspaceBillingRatesRequest>;
@@ -4926,7 +5020,7 @@ interface WorkspaceBillingSummaryResponse {
4926
5020
  meteredCostBreakdown: {
4927
5021
  [key: string]: string;
4928
5022
  };
4929
- /** keyed by plan, credits, reservations, storage */
5023
+ /** keyed by plan, credits, reservations, storage, network egress allowance */
4930
5024
  adjustments: {
4931
5025
  [key: string]: string;
4932
5026
  };
@@ -5725,6 +5819,14 @@ declare const ModalClientDefinition: {
5725
5819
  readonly responseStream: false;
5726
5820
  readonly options: {};
5727
5821
  };
5822
+ readonly functionCallFetch: {
5823
+ readonly name: "FunctionCallFetch";
5824
+ readonly requestType: MessageFns$1<FunctionCallFetchRequest>;
5825
+ readonly requestStream: false;
5826
+ readonly responseType: MessageFns$1<FunctionCallFetchResponse>;
5827
+ readonly responseStream: false;
5828
+ readonly options: {};
5829
+ };
5728
5830
  readonly functionCallFromId: {
5729
5831
  readonly name: "FunctionCallFromId";
5730
5832
  readonly requestType: MessageFns$1<FunctionCallFromIdRequest>;
@@ -5880,6 +5982,14 @@ declare const ModalClientDefinition: {
5880
5982
  readonly responseStream: false;
5881
5983
  readonly options: {};
5882
5984
  };
5985
+ readonly functionListVariants: {
5986
+ readonly name: "FunctionListVariants";
5987
+ readonly requestType: MessageFns$1<FunctionListVariantsRequest>;
5988
+ readonly requestStream: false;
5989
+ readonly responseType: MessageFns$1<FunctionListVariantsResponse>;
5990
+ readonly responseStream: false;
5991
+ readonly options: {};
5992
+ };
5883
5993
  readonly functionMap: {
5884
5994
  readonly name: "FunctionMap";
5885
5995
  readonly requestType: MessageFns$1<FunctionMapRequest>;
@@ -6514,6 +6624,14 @@ declare const ModalClientDefinition: {
6514
6624
  readonly responseStream: false;
6515
6625
  readonly options: {};
6516
6626
  };
6627
+ readonly secretGetInfo: {
6628
+ readonly name: "SecretGetInfo";
6629
+ readonly requestType: MessageFns$1<SecretGetInfoRequest>;
6630
+ readonly requestStream: false;
6631
+ readonly responseType: MessageFns$1<SecretGetInfoResponse>;
6632
+ readonly responseStream: false;
6633
+ readonly options: {};
6634
+ };
6517
6635
  readonly secretGetOrCreate: {
6518
6636
  readonly name: "SecretGetOrCreate";
6519
6637
  readonly requestType: MessageFns$1<SecretGetOrCreateRequest>;
@@ -6547,6 +6665,14 @@ declare const ModalClientDefinition: {
6547
6665
  readonly responseStream: false;
6548
6666
  readonly options: {};
6549
6667
  };
6668
+ readonly serverRequestFetch: {
6669
+ readonly name: "ServerRequestFetch";
6670
+ readonly requestType: MessageFns$1<ServerRequestFetchRequest>;
6671
+ readonly requestStream: false;
6672
+ readonly responseType: MessageFns$1<ServerRequestFetchResponse>;
6673
+ readonly responseStream: false;
6674
+ readonly options: {};
6675
+ };
6550
6676
  /** Service users */
6551
6677
  readonly serviceUserList: {
6552
6678
  readonly name: "ServiceUserList";
@@ -6940,6 +7066,14 @@ declare const ModalClientDefinition: {
6940
7066
  readonly responseStream: false;
6941
7067
  readonly options: {};
6942
7068
  };
7069
+ readonly webhookTokenUpdate: {
7070
+ readonly name: "WebhookTokenUpdate";
7071
+ readonly requestType: MessageFns$1<WebhookTokenUpdateRequest>;
7072
+ readonly requestStream: false;
7073
+ readonly responseType: MessageFns$1<WebhookToken>;
7074
+ readonly responseStream: false;
7075
+ readonly options: {};
7076
+ };
6943
7077
  /** Workspaces */
6944
7078
  readonly workspaceBillingRates: {
6945
7079
  readonly name: "WorkspaceBillingRates";
@@ -7206,6 +7340,8 @@ interface FunctionCallLogFetchParams {
7206
7340
  /** Filter by text contained in the log message. */
7207
7341
  searchText?: string;
7208
7342
  }
7343
+ type SandboxLogFetchParams = FunctionLogFetchParams;
7344
+ type SandboxLogTailParams = FunctionLogTailParams;
7209
7345
  interface FunctionLogs {
7210
7346
  fetch(params: FunctionLogFetchParams): AsyncIterable<LogEntry>;
7211
7347
  tail(params?: FunctionLogTailParams): AsyncIterable<LogEntry>;
@@ -7216,6 +7352,10 @@ interface FunctionCallLogs extends Omit<FunctionLogs, "fetch"> {
7216
7352
  tail(params?: FunctionCallLogTailParams): AsyncIterable<LogEntry>;
7217
7353
  stream(params?: FunctionCallLogStreamParams): AsyncIterable<LogEntry>;
7218
7354
  }
7355
+ interface SandboxLogs {
7356
+ fetch(params: SandboxLogFetchParams): AsyncIterable<LogEntry>;
7357
+ tail(params?: SandboxLogTailParams): AsyncIterable<LogEntry>;
7358
+ }
7219
7359
  interface LogQueryParams {
7220
7360
  client: ModalClient;
7221
7361
  objectId: string;
@@ -7368,6 +7508,59 @@ declare class FunctionCallLogsManager extends LogsManager implements FunctionCal
7368
7508
  */
7369
7509
  stream(params?: FunctionCallLogStreamParams): AsyncIterable<LogEntry>;
7370
7510
  }
7511
+ /** Namespace for Sandbox entrypoint log APIs. */
7512
+ declare class SandboxLogsManager implements SandboxLogs {
7513
+ private readonly client;
7514
+ private readonly sandboxId;
7515
+ private readonly getAppId;
7516
+ private readonly getTaskId;
7517
+ /** @ignore */
7518
+ constructor(client: ModalClient, sandboxId: string, getAppId: () => Promise<string>, getTaskId: () => Promise<string>);
7519
+ /**
7520
+ * Fetch Sandbox entrypoint logs corresponding to a UTC time range and
7521
+ * optional filters.
7522
+ *
7523
+ * Entries are returned in chronological order.
7524
+ *
7525
+ * @returns An async iterable of {@link LogEntry} objects.
7526
+ *
7527
+ * @example
7528
+ * ```typescript
7529
+ * import { ModalClient } from "modal";
7530
+ *
7531
+ * const modal = new ModalClient();
7532
+ * const sandbox = await modal.sandboxes.fromId("sb-...");
7533
+ *
7534
+ * for await (const entry of sandbox.logs.fetch({
7535
+ * since: new Date(Date.now() - 60 * 60 * 1_000),
7536
+ * source: "stdout",
7537
+ * })) {
7538
+ * process.stdout.write(entry.message);
7539
+ * }
7540
+ * ```
7541
+ */
7542
+ fetch(params: SandboxLogFetchParams): AsyncIterable<LogEntry>;
7543
+ /**
7544
+ * Fetch the most recent Sandbox entrypoint logs.
7545
+ *
7546
+ * Entries are returned in chronological order.
7547
+ *
7548
+ * @returns An async iterable of {@link LogEntry} objects.
7549
+ *
7550
+ * @example
7551
+ * ```typescript
7552
+ * import { ModalClient } from "modal";
7553
+ *
7554
+ * const modal = new ModalClient();
7555
+ * const sandbox = await modal.sandboxes.fromId("sb-...");
7556
+ *
7557
+ * for await (const entry of sandbox.logs.tail({ entries: 20 })) {
7558
+ * process.stdout.write(entry.message);
7559
+ * }
7560
+ * ```
7561
+ */
7562
+ tail(params?: SandboxLogTailParams): AsyncIterable<LogEntry>;
7563
+ }
7371
7564
 
7372
7565
  /**
7373
7566
  * Service for managing {@link FunctionCall}s.
@@ -8032,6 +8225,12 @@ interface TaskContainerCreateRequest {
8032
8225
  networkAccess?: NetworkAccess | undefined;
8033
8226
  /** Optional PTY info for sidecar. */
8034
8227
  ptyInfo?: PTYInfo | undefined;
8228
+ /**
8229
+ * Memory, in MiB, the sidecar consumes from the sandbox's sidecar memory
8230
+ * reserve (experimental option vm_sidecar_memory_reserve_mib); unset
8231
+ * consumes whatever is left of it. Ignored without a reserve.
8232
+ */
8233
+ memoryReserveConsumeMib?: number | undefined;
8035
8234
  }
8036
8235
  declare const TaskContainerCreateRequest: MessageFns<TaskContainerCreateRequest>;
8037
8236
  interface TaskContainerCreateResponse {
@@ -8191,6 +8390,12 @@ interface TaskSetNetworkAccessRequest {
8191
8390
  networkAccess: NetworkAccess | undefined;
8192
8391
  }
8193
8392
  declare const TaskSetNetworkAccessRequest: MessageFns<TaskSetNetworkAccessRequest>;
8393
+ interface TaskSetOutboundPolicyRequest {
8394
+ taskId: string;
8395
+ /** Replaces the task's outbound policy. */
8396
+ outboundPolicy: OutboundPolicy | undefined;
8397
+ }
8398
+ declare const TaskSetOutboundPolicyRequest: MessageFns<TaskSetOutboundPolicyRequest>;
8194
8399
  interface TaskSnapshotDirectoryRequest {
8195
8400
  taskId: string;
8196
8401
  path: Uint8Array;
@@ -8309,7 +8514,7 @@ interface Profile {
8309
8514
  sandboxChannelIdleTimeoutMs: number;
8310
8515
  /**
8311
8516
  * Set by the MODAL_SANDBOX_V2 environment variable or the sandbox_v2
8312
- * profile key in .modal.toml.
8517
+ * profile key in .modal.toml. Defaults to true when neither is set.
8313
8518
  */
8314
8519
  sandboxV2: boolean;
8315
8520
  }
@@ -8444,6 +8649,7 @@ declare class TaskCommandRouterClientImpl {
8444
8649
  snapshotMemory(request: TaskSnapshotMemoryRequest, options?: TimeoutOptions): Promise<TaskSnapshotMemoryResponse>;
8445
8650
  unmountDirectory(request: TaskUnmountDirectoryRequest): Promise<void>;
8446
8651
  setNetworkAccess(request: TaskSetNetworkAccessRequest): Promise<void>;
8652
+ setOutboundPolicy(request: TaskSetOutboundPolicyRequest): Promise<void>;
8447
8653
  /**
8448
8654
  * Reload all Volumes mounted in the task to reflect their latest committed state.
8449
8655
  *
@@ -8467,6 +8673,84 @@ declare class TaskCommandRouterClientImpl {
8467
8673
  private streamSandboxStdio;
8468
8674
  }
8469
8675
 
8676
+ /**
8677
+ * Immutable configuration for replacing headers in outbound HTTPS traffic.
8678
+ */
8679
+
8680
+ /** @internal */
8681
+ type HeaderReplacement = {
8682
+ domain: string;
8683
+ headers: Record<string, string>;
8684
+ secret?: Secret;
8685
+ };
8686
+ /**
8687
+ * Immutable configuration for replacing headers in outbound HTTPS requests
8688
+ * from a Sandbox.
8689
+ *
8690
+ * EXPERIMENTAL: the API is subject to change.
8691
+ *
8692
+ * Header values support templating with keys in a replacement's secret: a
8693
+ * `$`-prefixed key name in the secret is replaced with the secret value.
8694
+ * Literal `$` characters are written `$$`.
8695
+ *
8696
+ * Secret values never enter the Sandbox: they are resolved and injected into
8697
+ * matching requests outside the container.
8698
+ *
8699
+ * ```ts
8700
+ * const secret = await modal.secrets.fromName("api-token");
8701
+ *
8702
+ * const outboundPolicy = new modal.ExperimentalOutboundPolicy()
8703
+ * // Inject a secret-backed Authorization header.
8704
+ * .withHeaderReplacement({
8705
+ * domain: "example.com",
8706
+ * secret,
8707
+ * headers: { Authorization: "Bearer $API_TOKEN" },
8708
+ * })
8709
+ * // Inject a static header into requests to another domain.
8710
+ * .withHeaderReplacement({
8711
+ * domain: "modal.com",
8712
+ * headers: { "X-Trace-Token": "trace_abcd" },
8713
+ * });
8714
+ *
8715
+ * const sb = await modal.sandboxes.create(app, image, {
8716
+ * experimentalOutboundPolicy: outboundPolicy,
8717
+ * });
8718
+ * ```
8719
+ */
8720
+ declare class ExperimentalOutboundPolicy {
8721
+ /** @internal */
8722
+ readonly _replacements: readonly HeaderReplacement[];
8723
+ /** @internal */
8724
+ constructor(_replacements?: readonly HeaderReplacement[]);
8725
+ /**
8726
+ * Return a new {@link ExperimentalOutboundPolicy} with an added header replacement.
8727
+ *
8728
+ * @param params.domain Domain the replacements are scoped to. Supports `*.` wildcard
8729
+ * prefixes (matching the apex domain and subdomains) and a bare `"*"`.
8730
+ * @param params.headers Header name -> header value. Values support `$KEY` templates
8731
+ * referencing keys in the replacement's `secret`.
8732
+ * @param params.secret Named {@link Secret} (e.g. from `client.secrets.fromName`) whose
8733
+ * keys may be referenced in the header value templates. Static replacements pass no secret.
8734
+ */
8735
+ withHeaderReplacement(params: {
8736
+ domain: string;
8737
+ headers: Record<string, string>;
8738
+ secret?: Secret;
8739
+ }): ExperimentalOutboundPolicy;
8740
+ /** Check all replacements, throwing `InvalidError` on the first violation found.
8741
+ * @internal
8742
+ */
8743
+ _validate(): void;
8744
+ /** Deduplicated list of secrets referenced by the policy's replacements.
8745
+ * @internal
8746
+ */
8747
+ _secrets(): Secret[];
8748
+ /** Convert to the wire format. Referenced secrets must be hydrated first.
8749
+ * @internal
8750
+ */
8751
+ _toProto(): OutboundPolicy;
8752
+ }
8753
+
8470
8754
  /** Type of a filesystem entry. */
8471
8755
  type FileType = "file" | "directory" | "symlink";
8472
8756
  /** Metadata for a file or directory entry in a Sandbox. */
@@ -8699,6 +8983,8 @@ type SidecarCreateParams = {
8699
8983
  secrets?: Secret[];
8700
8984
  /** Working directory of the sidecar container. */
8701
8985
  workdir?: string;
8986
+ /** Mount points for Modal {@link Volume}s. */
8987
+ volumes?: Record<string, Volume>;
8702
8988
  /**
8703
8989
  * List of CIDRs the sidecar is allowed to access. Independent of the main
8704
8990
  * container; if not set, all CIDRs are allowed. An empty list blocks all
@@ -8712,6 +8998,13 @@ type SidecarCreateParams = {
8712
8998
  outboundDomainAllowlist?: string[];
8713
8999
  /** Enable a PTY for the sidecar. */
8714
9000
  pty?: boolean;
9001
+ /**
9002
+ * Memory, in MiB, the sidecar consumes from the Sandbox's sidecar memory
9003
+ * reserve (the `vm_sidecar_memory_reserve_mib` experimental option); unset
9004
+ * consumes whatever is left of it. Ignored by Sandboxes without a reserve.
9005
+ * Experimental.
9006
+ */
9007
+ experimentalMemoryReserveConsumeMiB?: number;
8715
9008
  };
8716
9009
  /** Options for {@link SidecarService#get SidecarService.get()}. */
8717
9010
  type SidecarGetParams = {
@@ -8937,6 +9230,8 @@ type StdioBehavior = "pipe" | "ignore";
8937
9230
  * means the data will be read as raw bytes (Uint8Array).
8938
9231
  */
8939
9232
  type StreamMode = "text" | "binary";
9233
+ /** Runtime a Sandbox runs in: a virtual machine, or gVisor. */
9234
+ type SandboxRuntime = "gvisor" | "vm";
8940
9235
  /** Optional parameters for {@link Probe.withTcp} and {@link Probe.withExec}. */
8941
9236
  type ProbeParams = {
8942
9237
  intervalMs: number;
@@ -8960,6 +9255,8 @@ type SandboxCreateParams = {
8960
9255
  memoryMiB?: number;
8961
9256
  /** Hard limit of memory in MiB. */
8962
9257
  memoryLimitMiB?: number;
9258
+ /** Runtime under which the Sandbox executes, or undefined to let Modal pick. */
9259
+ runtime?: SandboxRuntime;
8963
9260
  /** GPU reservation for the Sandbox (e.g. "A100", "T4:2", "A100-80GB:4"). */
8964
9261
  gpu?: string;
8965
9262
  /** Maximum lifetime of the Sandbox in milliseconds. Defaults to 5 minutes. */
@@ -8996,6 +9293,11 @@ type SandboxCreateParams = {
8996
9293
  outboundCidrAllowlist?: string[];
8997
9294
  /** List of domain names the Sandbox is allowed to access. Supports wildcard prefixes (`*.example.com`). Cannot be used with blockNetwork. */
8998
9295
  outboundDomainAllowlist?: string[];
9296
+ /** Configuration for replacing headers in outbound HTTPS requests from the Sandbox.
9297
+ * Secrets referenced by the policy are resolved outside the Sandbox and are never
9298
+ * visible to the workload. See {@link ExperimentalOutboundPolicy}.
9299
+ * EXPERIMENTAL: the API is subject to change. */
9300
+ experimentalOutboundPolicy?: ExperimentalOutboundPolicy;
8999
9301
  /** List of CIDRs allowed to connect inbound to the Sandbox (tunnels and connection tokens). If not set, all IPs are allowed. Cannot be used with blockNetwork. */
9000
9302
  inboundCidrAllowlist?: string[];
9001
9303
  /** Enable private IPv6 networking (i6pn) so Sandboxes in the same workspace can address each
@@ -9304,6 +9606,18 @@ declare class Sandbox {
9304
9606
  get stdin(): ModalWriteStream<string>;
9305
9607
  get stdout(): ModalReadStream<string>;
9306
9608
  get stderr(): ModalReadStream<string>;
9609
+ /**
9610
+ * Access persisted entrypoint logs emitted by this Sandbox.
9611
+ *
9612
+ * Use {@link SandboxLogsManager#fetch fetch()} to read logs from a UTC time
9613
+ * range and {@link SandboxLogsManager#tail tail()} to read the most recent
9614
+ * logs.
9615
+ *
9616
+ * This is separate from {@link Sandbox#stdout stdout} and
9617
+ * {@link Sandbox#stderr stderr}, which expose the Sandbox's live output
9618
+ * streams.
9619
+ */
9620
+ get logs(): SandboxLogsManager;
9307
9621
  get filesystem(): SandboxFilesystem;
9308
9622
  /**
9309
9623
  * Operations for managing sidecar containers that run alongside the
@@ -9343,6 +9657,15 @@ declare class Sandbox {
9343
9657
  exec(command: string[], params: SandboxExecParams & {
9344
9658
  mode: "binary";
9345
9659
  }): Promise<ContainerProcess<Uint8Array>>;
9660
+ /**
9661
+ * Blocks until the Sandbox has a task. If the wait fails, the Sandbox is
9662
+ * terminated so a queued one cannot start later with no caller. A timeout
9663
+ * surfaces as a ResourceExhaustedError.
9664
+ *
9665
+ * @internal
9666
+ * @hidden
9667
+ */
9668
+ _waitForScheduling(timeoutMs: number): Promise<void>;
9346
9669
  /**
9347
9670
  * Create a token for making HTTP connections to the Sandbox.
9348
9671
  */
@@ -9462,6 +9785,19 @@ declare class Sandbox {
9462
9785
  * @param params - Both `outboundCidrAllowlist` and `outboundDomainAllowlist` must be provided.
9463
9786
  */
9464
9787
  updateNetworkPolicy(params: SandboxUpdateNetworkPolicyParams): Promise<void>;
9788
+ /**
9789
+ * Replace the outbound policy of a running Sandbox.
9790
+ *
9791
+ * EXPERIMENTAL: the API is subject to change.
9792
+ *
9793
+ * The new policy replaces all existing policy configuration on the
9794
+ * Sandbox; build a policy including any existing rules you want to keep.
9795
+ *
9796
+ * Only Sandboxes created with an `experimentalOutboundPolicy` can be updated this
9797
+ * way; for Sandboxes created without one this fails, since header
9798
+ * replacement is only set up at creation time.
9799
+ */
9800
+ experimentalUpdateOutboundPolicy(outboundPolicy: ExperimentalOutboundPolicy): Promise<void>;
9465
9801
  /**
9466
9802
  * Reload all Volumes mounted in the Sandbox.
9467
9803
  *
@@ -9714,6 +10050,10 @@ declare class QueueEmptyError extends Error {
9714
10050
  declare class QueueFullError extends Error {
9715
10051
  constructor(message: string);
9716
10052
  }
10053
+ /** A server-side resource has been exhausted, such as capacity, a quota, or a rate limit. */
10054
+ declare class ResourceExhaustedError extends Error {
10055
+ constructor(message: string);
10056
+ }
9717
10057
  /** Errors from invalid Sandbox FileSystem operations. */
9718
10058
  declare class SandboxFilesystemError extends Error {
9719
10059
  constructor(message: string);
@@ -9761,4 +10101,4 @@ declare class ClientClosedError extends Error {
9761
10101
 
9762
10102
  declare function checkForRenamedParams(params: any, renames: Record<string, string>): void;
9763
10103
 
9764
- export { AlreadyExistsError, App, type AppFromNameParams, AppService, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, ExecutionError, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, FunctionService, type FunctionStats, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxMountImageParams, type SandboxReloadVolumesParams, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StdioBehavior, type StreamMode, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };
10104
+ export { AlreadyExistsError, App, type AppFromNameParams, AppService, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, ExecutionError, ExperimentalOutboundPolicy, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, FunctionService, type FunctionStats, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, ResourceExhaustedError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxLogFetchParams, type SandboxLogTailParams, SandboxLogsManager, type SandboxMountImageParams, type SandboxReloadVolumesParams, type SandboxRuntime, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StdioBehavior, type StreamMode, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };