modal 0.10.2-dev.1 → 0.10.2-dev.2

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
@@ -1599,6 +1599,7 @@ interface EndpointCreateRequest {
1599
1599
  environmentName: string;
1600
1600
  unauthenticated: boolean;
1601
1601
  servingMode: EndpointServingMode;
1602
+ sharedEndpointNoticeAcknowledged: boolean;
1602
1603
  }
1603
1604
  declare const EndpointCreateRequest: MessageFns$1<EndpointCreateRequest>;
1604
1605
  interface EndpointCreateResponse {
@@ -2000,10 +2001,6 @@ interface FunctionMessage {
2000
2001
  schedulerPlacement?: SchedulerPlacement | undefined;
2001
2002
  /** if "Function" is actually a class grouping multiple methods */
2002
2003
  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
2004
  classParameterInfo: ClassParameterInfo | undefined;
2008
2005
  /** Maximum number of inputs to fetch at once */
2009
2006
  batchMaxSize: number;
@@ -2271,10 +2268,6 @@ interface FunctionData {
2271
2268
  isClass: boolean;
2272
2269
  classParameterInfo: ClassParameterInfo | undefined;
2273
2270
  isMethod: boolean;
2274
- /** used for methods */
2275
- useFunctionId: string;
2276
- /** used for methods */
2277
- useMethodName: string;
2278
2271
  rankedFunctions: FunctionData_RankedFunction[];
2279
2272
  schedule: Schedule | undefined;
2280
2273
  /** If set, the function will be run in an untrusted environment. */
@@ -2523,8 +2516,6 @@ interface FunctionHandleMetadata {
2523
2516
  webUrl: string;
2524
2517
  isMethod: boolean;
2525
2518
  /** used for methods */
2526
- useFunctionId: string;
2527
- /** used for methods */
2528
2519
  useMethodName: string;
2529
2520
  definitionId: string;
2530
2521
  classParameterInfo: ClassParameterInfo | undefined;
@@ -2609,10 +2600,6 @@ interface FunctionPrecreateRequest {
2609
2600
  existingFunctionId: string;
2610
2601
  functionType: Function_FunctionType;
2611
2602
  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
2603
  /** Mapping of method names to method definitions, only non-empty for class service functions */
2617
2604
  methodDefinitions: {
2618
2605
  [key: string]: MethodDefinition;
@@ -2763,6 +2750,7 @@ interface HTTPConfig {
2763
2750
  h2Enabled: boolean;
2764
2751
  targetConcurrency: number;
2765
2752
  unauthenticated: boolean;
2753
+ liftAndShiftConfig?: LiftAndShiftConfig | undefined;
2766
2754
  }
2767
2755
  declare const HTTPConfig: MessageFns$1<HTTPConfig>;
2768
2756
  interface Image$1 {
@@ -3016,6 +3004,9 @@ interface InputInfo {
3016
3004
  taskFirstInput: boolean;
3017
3005
  }
3018
3006
  declare const InputInfo: MessageFns$1<InputInfo>;
3007
+ interface LiftAndShiftConfig {
3008
+ }
3009
+ declare const LiftAndShiftConfig: MessageFns$1<LiftAndShiftConfig>;
3019
3010
  interface ListPagination {
3020
3011
  maxObjects: number;
3021
3012
  createdBefore: number;
@@ -3242,11 +3233,11 @@ interface ObjectDependency {
3242
3233
  }
3243
3234
  declare const ObjectDependency: MessageFns$1<ObjectDependency>;
3244
3235
  /** Policy for outbound traffic from a sandbox. */
3245
- interface OutboundPolicy {
3236
+ interface OutboundPolicy$1 {
3246
3237
  /** Replace headers in outbound HTTPS requests, potentially with secret values. */
3247
3238
  headerReplacements: OutboundPolicy_HeaderReplacement[];
3248
3239
  }
3249
- declare const OutboundPolicy: MessageFns$1<OutboundPolicy>;
3240
+ declare const OutboundPolicy$1: MessageFns$1<OutboundPolicy$1>;
3250
3241
  interface OutboundPolicy_HeaderReplacement {
3251
3242
  /**
3252
3243
  * Domain that the header replacements are scoped to. Supports wildcards in
@@ -3641,7 +3632,7 @@ interface Sandbox$1 {
3641
3632
  */
3642
3633
  inboundCidrAllowlist: string[];
3643
3634
  environmentVariables: StringMap | undefined;
3644
- outboundPolicy?: OutboundPolicy | undefined;
3635
+ outboundPolicy?: OutboundPolicy$1 | undefined;
3645
3636
  /**
3646
3637
  * If set, the sandbox's main container is served an X.509-SVID over a
3647
3638
  * SPIFFE Workload API socket, addressed by SPIFFE_ENDPOINT_SOCKET. The
@@ -4376,6 +4367,7 @@ interface TaskLogsBatch {
4376
4367
  ptyExecId: string;
4377
4368
  rootFunctionId: string;
4378
4369
  ttlDays: number;
4370
+ sandboxId: string;
4379
4371
  }
4380
4372
  declare const TaskLogsBatch: MessageFns$1<TaskLogsBatch>;
4381
4373
  interface TaskProgress {
@@ -8191,6 +8183,12 @@ interface TaskSetNetworkAccessRequest {
8191
8183
  networkAccess: NetworkAccess | undefined;
8192
8184
  }
8193
8185
  declare const TaskSetNetworkAccessRequest: MessageFns<TaskSetNetworkAccessRequest>;
8186
+ interface TaskSetOutboundPolicyRequest {
8187
+ taskId: string;
8188
+ /** Replaces the task's outbound policy. */
8189
+ outboundPolicy: OutboundPolicy$1 | undefined;
8190
+ }
8191
+ declare const TaskSetOutboundPolicyRequest: MessageFns<TaskSetOutboundPolicyRequest>;
8194
8192
  interface TaskSnapshotDirectoryRequest {
8195
8193
  taskId: string;
8196
8194
  path: Uint8Array;
@@ -8444,6 +8442,7 @@ declare class TaskCommandRouterClientImpl {
8444
8442
  snapshotMemory(request: TaskSnapshotMemoryRequest, options?: TimeoutOptions): Promise<TaskSnapshotMemoryResponse>;
8445
8443
  unmountDirectory(request: TaskUnmountDirectoryRequest): Promise<void>;
8446
8444
  setNetworkAccess(request: TaskSetNetworkAccessRequest): Promise<void>;
8445
+ setOutboundPolicy(request: TaskSetOutboundPolicyRequest): Promise<void>;
8447
8446
  /**
8448
8447
  * Reload all Volumes mounted in the task to reflect their latest committed state.
8449
8448
  *
@@ -8467,6 +8466,80 @@ declare class TaskCommandRouterClientImpl {
8467
8466
  private streamSandboxStdio;
8468
8467
  }
8469
8468
 
8469
+ /**
8470
+ * Immutable configuration for replacing headers in outbound HTTPS traffic.
8471
+ */
8472
+
8473
+ /** @internal */
8474
+ type HeaderReplacement = {
8475
+ domain: string;
8476
+ headers: Record<string, string>;
8477
+ secret?: Secret;
8478
+ };
8479
+ /**
8480
+ * Immutable configuration for replacing headers in outbound HTTPS requests
8481
+ * from a Sandbox.
8482
+ *
8483
+ * Header values support templating with keys in a replacement's secret: a
8484
+ * `$`-prefixed key name in the secret is replaced with the secret value.
8485
+ * Literal `$` characters are written `$$`.
8486
+ *
8487
+ * Secret values never enter the Sandbox: they are resolved and injected into
8488
+ * matching requests outside the container.
8489
+ *
8490
+ * ```ts
8491
+ * const secret = await modal.secrets.fromName("api-token");
8492
+ *
8493
+ * const outboundPolicy = new modal.OutboundPolicy()
8494
+ * // Inject a secret-backed Authorization header.
8495
+ * .withHeaderReplacement({
8496
+ * domain: "example.com",
8497
+ * secret,
8498
+ * headers: { Authorization: "Bearer $API_TOKEN" },
8499
+ * })
8500
+ * // Inject a static header into requests to another domain.
8501
+ * .withHeaderReplacement({
8502
+ * domain: "modal.com",
8503
+ * headers: { "X-Trace-Token": "trace_abcd" },
8504
+ * });
8505
+ *
8506
+ * const sb = await modal.sandboxes.create(app, image, { outboundPolicy });
8507
+ * ```
8508
+ */
8509
+ declare class OutboundPolicy {
8510
+ /** @internal */
8511
+ readonly _replacements: readonly HeaderReplacement[];
8512
+ /** @internal */
8513
+ constructor(_replacements?: readonly HeaderReplacement[]);
8514
+ /**
8515
+ * Return a new {@link OutboundPolicy} with an added header replacement.
8516
+ *
8517
+ * @param params.domain Domain the replacements are scoped to. Supports `*.` wildcard
8518
+ * prefixes (matching the apex domain and subdomains) and a bare `"*"`.
8519
+ * @param params.headers Header name -> header value. Values support `$KEY` templates
8520
+ * referencing keys in the replacement's `secret`.
8521
+ * @param params.secret Named {@link Secret} (e.g. from `client.secrets.fromName`) whose
8522
+ * keys may be referenced in the header value templates. Static replacements pass no secret.
8523
+ */
8524
+ withHeaderReplacement(params: {
8525
+ domain: string;
8526
+ headers: Record<string, string>;
8527
+ secret?: Secret;
8528
+ }): OutboundPolicy;
8529
+ /** Check all replacements, throwing `InvalidError` on the first violation found.
8530
+ * @internal
8531
+ */
8532
+ _validate(): void;
8533
+ /** Deduplicated list of secrets referenced by the policy's replacements.
8534
+ * @internal
8535
+ */
8536
+ _secrets(): Secret[];
8537
+ /** Convert to the wire format. Referenced secrets must be hydrated first.
8538
+ * @internal
8539
+ */
8540
+ _toProto(): OutboundPolicy$1;
8541
+ }
8542
+
8470
8543
  /** Type of a filesystem entry. */
8471
8544
  type FileType = "file" | "directory" | "symlink";
8472
8545
  /** Metadata for a file or directory entry in a Sandbox. */
@@ -8996,6 +9069,10 @@ type SandboxCreateParams = {
8996
9069
  outboundCidrAllowlist?: string[];
8997
9070
  /** List of domain names the Sandbox is allowed to access. Supports wildcard prefixes (`*.example.com`). Cannot be used with blockNetwork. */
8998
9071
  outboundDomainAllowlist?: string[];
9072
+ /** Configuration for replacing headers in outbound HTTPS requests from the Sandbox.
9073
+ * Secrets referenced by the policy are resolved outside the Sandbox and are never
9074
+ * visible to the workload. See {@link OutboundPolicy}. */
9075
+ outboundPolicy?: OutboundPolicy;
8999
9076
  /** 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
9077
  inboundCidrAllowlist?: string[];
9001
9078
  /** Enable private IPv6 networking (i6pn) so Sandboxes in the same workspace can address each
@@ -9462,6 +9539,17 @@ declare class Sandbox {
9462
9539
  * @param params - Both `outboundCidrAllowlist` and `outboundDomainAllowlist` must be provided.
9463
9540
  */
9464
9541
  updateNetworkPolicy(params: SandboxUpdateNetworkPolicyParams): Promise<void>;
9542
+ /**
9543
+ * Replace the outbound policy of a running Sandbox.
9544
+ *
9545
+ * The new policy replaces all existing policy configuration on the
9546
+ * Sandbox; build a policy including any existing rules you want to keep.
9547
+ *
9548
+ * Only Sandboxes created with an `outboundPolicy` can be updated this
9549
+ * way; for Sandboxes created without one this fails, since header
9550
+ * replacement is only set up at creation time.
9551
+ */
9552
+ updateOutboundPolicy(outboundPolicy: OutboundPolicy): Promise<void>;
9465
9553
  /**
9466
9554
  * Reload all Volumes mounted in the Sandbox.
9467
9555
  *
@@ -9761,4 +9849,4 @@ declare class ClientClosedError extends Error {
9761
9849
 
9762
9850
  declare function checkForRenamedParams(params: any, renames: Record<string, string>): void;
9763
9851
 
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 };
9852
+ 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, OutboundPolicy, 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 };
package/dist/index.d.ts CHANGED
@@ -1599,6 +1599,7 @@ interface EndpointCreateRequest {
1599
1599
  environmentName: string;
1600
1600
  unauthenticated: boolean;
1601
1601
  servingMode: EndpointServingMode;
1602
+ sharedEndpointNoticeAcknowledged: boolean;
1602
1603
  }
1603
1604
  declare const EndpointCreateRequest: MessageFns$1<EndpointCreateRequest>;
1604
1605
  interface EndpointCreateResponse {
@@ -2000,10 +2001,6 @@ interface FunctionMessage {
2000
2001
  schedulerPlacement?: SchedulerPlacement | undefined;
2001
2002
  /** if "Function" is actually a class grouping multiple methods */
2002
2003
  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
2004
  classParameterInfo: ClassParameterInfo | undefined;
2008
2005
  /** Maximum number of inputs to fetch at once */
2009
2006
  batchMaxSize: number;
@@ -2271,10 +2268,6 @@ interface FunctionData {
2271
2268
  isClass: boolean;
2272
2269
  classParameterInfo: ClassParameterInfo | undefined;
2273
2270
  isMethod: boolean;
2274
- /** used for methods */
2275
- useFunctionId: string;
2276
- /** used for methods */
2277
- useMethodName: string;
2278
2271
  rankedFunctions: FunctionData_RankedFunction[];
2279
2272
  schedule: Schedule | undefined;
2280
2273
  /** If set, the function will be run in an untrusted environment. */
@@ -2523,8 +2516,6 @@ interface FunctionHandleMetadata {
2523
2516
  webUrl: string;
2524
2517
  isMethod: boolean;
2525
2518
  /** used for methods */
2526
- useFunctionId: string;
2527
- /** used for methods */
2528
2519
  useMethodName: string;
2529
2520
  definitionId: string;
2530
2521
  classParameterInfo: ClassParameterInfo | undefined;
@@ -2609,10 +2600,6 @@ interface FunctionPrecreateRequest {
2609
2600
  existingFunctionId: string;
2610
2601
  functionType: Function_FunctionType;
2611
2602
  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
2603
  /** Mapping of method names to method definitions, only non-empty for class service functions */
2617
2604
  methodDefinitions: {
2618
2605
  [key: string]: MethodDefinition;
@@ -2763,6 +2750,7 @@ interface HTTPConfig {
2763
2750
  h2Enabled: boolean;
2764
2751
  targetConcurrency: number;
2765
2752
  unauthenticated: boolean;
2753
+ liftAndShiftConfig?: LiftAndShiftConfig | undefined;
2766
2754
  }
2767
2755
  declare const HTTPConfig: MessageFns$1<HTTPConfig>;
2768
2756
  interface Image$1 {
@@ -3016,6 +3004,9 @@ interface InputInfo {
3016
3004
  taskFirstInput: boolean;
3017
3005
  }
3018
3006
  declare const InputInfo: MessageFns$1<InputInfo>;
3007
+ interface LiftAndShiftConfig {
3008
+ }
3009
+ declare const LiftAndShiftConfig: MessageFns$1<LiftAndShiftConfig>;
3019
3010
  interface ListPagination {
3020
3011
  maxObjects: number;
3021
3012
  createdBefore: number;
@@ -3242,11 +3233,11 @@ interface ObjectDependency {
3242
3233
  }
3243
3234
  declare const ObjectDependency: MessageFns$1<ObjectDependency>;
3244
3235
  /** Policy for outbound traffic from a sandbox. */
3245
- interface OutboundPolicy {
3236
+ interface OutboundPolicy$1 {
3246
3237
  /** Replace headers in outbound HTTPS requests, potentially with secret values. */
3247
3238
  headerReplacements: OutboundPolicy_HeaderReplacement[];
3248
3239
  }
3249
- declare const OutboundPolicy: MessageFns$1<OutboundPolicy>;
3240
+ declare const OutboundPolicy$1: MessageFns$1<OutboundPolicy$1>;
3250
3241
  interface OutboundPolicy_HeaderReplacement {
3251
3242
  /**
3252
3243
  * Domain that the header replacements are scoped to. Supports wildcards in
@@ -3641,7 +3632,7 @@ interface Sandbox$1 {
3641
3632
  */
3642
3633
  inboundCidrAllowlist: string[];
3643
3634
  environmentVariables: StringMap | undefined;
3644
- outboundPolicy?: OutboundPolicy | undefined;
3635
+ outboundPolicy?: OutboundPolicy$1 | undefined;
3645
3636
  /**
3646
3637
  * If set, the sandbox's main container is served an X.509-SVID over a
3647
3638
  * SPIFFE Workload API socket, addressed by SPIFFE_ENDPOINT_SOCKET. The
@@ -4376,6 +4367,7 @@ interface TaskLogsBatch {
4376
4367
  ptyExecId: string;
4377
4368
  rootFunctionId: string;
4378
4369
  ttlDays: number;
4370
+ sandboxId: string;
4379
4371
  }
4380
4372
  declare const TaskLogsBatch: MessageFns$1<TaskLogsBatch>;
4381
4373
  interface TaskProgress {
@@ -8191,6 +8183,12 @@ interface TaskSetNetworkAccessRequest {
8191
8183
  networkAccess: NetworkAccess | undefined;
8192
8184
  }
8193
8185
  declare const TaskSetNetworkAccessRequest: MessageFns<TaskSetNetworkAccessRequest>;
8186
+ interface TaskSetOutboundPolicyRequest {
8187
+ taskId: string;
8188
+ /** Replaces the task's outbound policy. */
8189
+ outboundPolicy: OutboundPolicy$1 | undefined;
8190
+ }
8191
+ declare const TaskSetOutboundPolicyRequest: MessageFns<TaskSetOutboundPolicyRequest>;
8194
8192
  interface TaskSnapshotDirectoryRequest {
8195
8193
  taskId: string;
8196
8194
  path: Uint8Array;
@@ -8444,6 +8442,7 @@ declare class TaskCommandRouterClientImpl {
8444
8442
  snapshotMemory(request: TaskSnapshotMemoryRequest, options?: TimeoutOptions): Promise<TaskSnapshotMemoryResponse>;
8445
8443
  unmountDirectory(request: TaskUnmountDirectoryRequest): Promise<void>;
8446
8444
  setNetworkAccess(request: TaskSetNetworkAccessRequest): Promise<void>;
8445
+ setOutboundPolicy(request: TaskSetOutboundPolicyRequest): Promise<void>;
8447
8446
  /**
8448
8447
  * Reload all Volumes mounted in the task to reflect their latest committed state.
8449
8448
  *
@@ -8467,6 +8466,80 @@ declare class TaskCommandRouterClientImpl {
8467
8466
  private streamSandboxStdio;
8468
8467
  }
8469
8468
 
8469
+ /**
8470
+ * Immutable configuration for replacing headers in outbound HTTPS traffic.
8471
+ */
8472
+
8473
+ /** @internal */
8474
+ type HeaderReplacement = {
8475
+ domain: string;
8476
+ headers: Record<string, string>;
8477
+ secret?: Secret;
8478
+ };
8479
+ /**
8480
+ * Immutable configuration for replacing headers in outbound HTTPS requests
8481
+ * from a Sandbox.
8482
+ *
8483
+ * Header values support templating with keys in a replacement's secret: a
8484
+ * `$`-prefixed key name in the secret is replaced with the secret value.
8485
+ * Literal `$` characters are written `$$`.
8486
+ *
8487
+ * Secret values never enter the Sandbox: they are resolved and injected into
8488
+ * matching requests outside the container.
8489
+ *
8490
+ * ```ts
8491
+ * const secret = await modal.secrets.fromName("api-token");
8492
+ *
8493
+ * const outboundPolicy = new modal.OutboundPolicy()
8494
+ * // Inject a secret-backed Authorization header.
8495
+ * .withHeaderReplacement({
8496
+ * domain: "example.com",
8497
+ * secret,
8498
+ * headers: { Authorization: "Bearer $API_TOKEN" },
8499
+ * })
8500
+ * // Inject a static header into requests to another domain.
8501
+ * .withHeaderReplacement({
8502
+ * domain: "modal.com",
8503
+ * headers: { "X-Trace-Token": "trace_abcd" },
8504
+ * });
8505
+ *
8506
+ * const sb = await modal.sandboxes.create(app, image, { outboundPolicy });
8507
+ * ```
8508
+ */
8509
+ declare class OutboundPolicy {
8510
+ /** @internal */
8511
+ readonly _replacements: readonly HeaderReplacement[];
8512
+ /** @internal */
8513
+ constructor(_replacements?: readonly HeaderReplacement[]);
8514
+ /**
8515
+ * Return a new {@link OutboundPolicy} with an added header replacement.
8516
+ *
8517
+ * @param params.domain Domain the replacements are scoped to. Supports `*.` wildcard
8518
+ * prefixes (matching the apex domain and subdomains) and a bare `"*"`.
8519
+ * @param params.headers Header name -> header value. Values support `$KEY` templates
8520
+ * referencing keys in the replacement's `secret`.
8521
+ * @param params.secret Named {@link Secret} (e.g. from `client.secrets.fromName`) whose
8522
+ * keys may be referenced in the header value templates. Static replacements pass no secret.
8523
+ */
8524
+ withHeaderReplacement(params: {
8525
+ domain: string;
8526
+ headers: Record<string, string>;
8527
+ secret?: Secret;
8528
+ }): OutboundPolicy;
8529
+ /** Check all replacements, throwing `InvalidError` on the first violation found.
8530
+ * @internal
8531
+ */
8532
+ _validate(): void;
8533
+ /** Deduplicated list of secrets referenced by the policy's replacements.
8534
+ * @internal
8535
+ */
8536
+ _secrets(): Secret[];
8537
+ /** Convert to the wire format. Referenced secrets must be hydrated first.
8538
+ * @internal
8539
+ */
8540
+ _toProto(): OutboundPolicy$1;
8541
+ }
8542
+
8470
8543
  /** Type of a filesystem entry. */
8471
8544
  type FileType = "file" | "directory" | "symlink";
8472
8545
  /** Metadata for a file or directory entry in a Sandbox. */
@@ -8996,6 +9069,10 @@ type SandboxCreateParams = {
8996
9069
  outboundCidrAllowlist?: string[];
8997
9070
  /** List of domain names the Sandbox is allowed to access. Supports wildcard prefixes (`*.example.com`). Cannot be used with blockNetwork. */
8998
9071
  outboundDomainAllowlist?: string[];
9072
+ /** Configuration for replacing headers in outbound HTTPS requests from the Sandbox.
9073
+ * Secrets referenced by the policy are resolved outside the Sandbox and are never
9074
+ * visible to the workload. See {@link OutboundPolicy}. */
9075
+ outboundPolicy?: OutboundPolicy;
8999
9076
  /** 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
9077
  inboundCidrAllowlist?: string[];
9001
9078
  /** Enable private IPv6 networking (i6pn) so Sandboxes in the same workspace can address each
@@ -9462,6 +9539,17 @@ declare class Sandbox {
9462
9539
  * @param params - Both `outboundCidrAllowlist` and `outboundDomainAllowlist` must be provided.
9463
9540
  */
9464
9541
  updateNetworkPolicy(params: SandboxUpdateNetworkPolicyParams): Promise<void>;
9542
+ /**
9543
+ * Replace the outbound policy of a running Sandbox.
9544
+ *
9545
+ * The new policy replaces all existing policy configuration on the
9546
+ * Sandbox; build a policy including any existing rules you want to keep.
9547
+ *
9548
+ * Only Sandboxes created with an `outboundPolicy` can be updated this
9549
+ * way; for Sandboxes created without one this fails, since header
9550
+ * replacement is only set up at creation time.
9551
+ */
9552
+ updateOutboundPolicy(outboundPolicy: OutboundPolicy): Promise<void>;
9465
9553
  /**
9466
9554
  * Reload all Volumes mounted in the Sandbox.
9467
9555
  *
@@ -9761,4 +9849,4 @@ declare class ClientClosedError extends Error {
9761
9849
 
9762
9850
  declare function checkForRenamedParams(params: any, renames: Record<string, string>): void;
9763
9851
 
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 };
9852
+ 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, OutboundPolicy, 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 };