modal 0.10.2-dev.6 → 0.10.2-dev.8

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.js CHANGED
@@ -5491,7 +5491,7 @@ var AppGetInfoResponse = {
5491
5491
  }
5492
5492
  };
5493
5493
  function createBaseAppGetInfoResponse_FunctionInfoSummary() {
5494
- return { gpuConfig: [], schedule: void 0, webFunction: false, requiresProxyAuth: void 0 };
5494
+ return { gpuConfig: [], schedule: void 0, webFunction: false, requiresProxyAuth: void 0, isSessioned: false };
5495
5495
  }
5496
5496
  var AppGetInfoResponse_FunctionInfoSummary = {
5497
5497
  encode(message, writer = new BinaryWriter()) {
@@ -5507,6 +5507,9 @@ var AppGetInfoResponse_FunctionInfoSummary = {
5507
5507
  if (message.requiresProxyAuth !== void 0) {
5508
5508
  writer.uint32(32).bool(message.requiresProxyAuth);
5509
5509
  }
5510
+ if (message.isSessioned !== false) {
5511
+ writer.uint32(40).bool(message.isSessioned);
5512
+ }
5510
5513
  return writer;
5511
5514
  },
5512
5515
  decode(input, length) {
@@ -5544,6 +5547,13 @@ var AppGetInfoResponse_FunctionInfoSummary = {
5544
5547
  message.requiresProxyAuth = reader.bool();
5545
5548
  continue;
5546
5549
  }
5550
+ case 5: {
5551
+ if (tag !== 40) {
5552
+ break;
5553
+ }
5554
+ message.isSessioned = reader.bool();
5555
+ continue;
5556
+ }
5547
5557
  }
5548
5558
  if ((tag & 7) === 4 || tag === 0) {
5549
5559
  break;
@@ -5557,7 +5567,8 @@ var AppGetInfoResponse_FunctionInfoSummary = {
5557
5567
  gpuConfig: globalThis.Array.isArray(object?.gpuConfig) ? object.gpuConfig.map((e) => GPUConfig.fromJSON(e)) : [],
5558
5568
  schedule: isSet5(object.schedule) ? Schedule.fromJSON(object.schedule) : void 0,
5559
5569
  webFunction: isSet5(object.webFunction) ? globalThis.Boolean(object.webFunction) : false,
5560
- requiresProxyAuth: isSet5(object.requiresProxyAuth) ? globalThis.Boolean(object.requiresProxyAuth) : void 0
5570
+ requiresProxyAuth: isSet5(object.requiresProxyAuth) ? globalThis.Boolean(object.requiresProxyAuth) : void 0,
5571
+ isSessioned: isSet5(object.isSessioned) ? globalThis.Boolean(object.isSessioned) : false
5561
5572
  };
5562
5573
  },
5563
5574
  toJSON(message) {
@@ -5574,6 +5585,9 @@ var AppGetInfoResponse_FunctionInfoSummary = {
5574
5585
  if (message.requiresProxyAuth !== void 0) {
5575
5586
  obj.requiresProxyAuth = message.requiresProxyAuth;
5576
5587
  }
5588
+ if (message.isSessioned !== false) {
5589
+ obj.isSessioned = message.isSessioned;
5590
+ }
5577
5591
  return obj;
5578
5592
  },
5579
5593
  create(base) {
@@ -5585,6 +5599,7 @@ var AppGetInfoResponse_FunctionInfoSummary = {
5585
5599
  message.schedule = object.schedule !== void 0 && object.schedule !== null ? Schedule.fromPartial(object.schedule) : void 0;
5586
5600
  message.webFunction = object.webFunction ?? false;
5587
5601
  message.requiresProxyAuth = object.requiresProxyAuth ?? void 0;
5602
+ message.isSessioned = object.isSessioned ?? false;
5588
5603
  return message;
5589
5604
  }
5590
5605
  };
@@ -47974,6 +47989,108 @@ var SecretDeleteRequest = {
47974
47989
  return message;
47975
47990
  }
47976
47991
  };
47992
+ function createBaseSecretGetInfoRequest() {
47993
+ return { secretId: "" };
47994
+ }
47995
+ var SecretGetInfoRequest = {
47996
+ encode(message, writer = new BinaryWriter()) {
47997
+ if (message.secretId !== "") {
47998
+ writer.uint32(10).string(message.secretId);
47999
+ }
48000
+ return writer;
48001
+ },
48002
+ decode(input, length) {
48003
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
48004
+ let end = length === void 0 ? reader.len : reader.pos + length;
48005
+ const message = createBaseSecretGetInfoRequest();
48006
+ while (reader.pos < end) {
48007
+ const tag = reader.uint32();
48008
+ switch (tag >>> 3) {
48009
+ case 1: {
48010
+ if (tag !== 10) {
48011
+ break;
48012
+ }
48013
+ message.secretId = reader.string();
48014
+ continue;
48015
+ }
48016
+ }
48017
+ if ((tag & 7) === 4 || tag === 0) {
48018
+ break;
48019
+ }
48020
+ reader.skip(tag & 7);
48021
+ }
48022
+ return message;
48023
+ },
48024
+ fromJSON(object) {
48025
+ return { secretId: isSet5(object.secretId) ? globalThis.String(object.secretId) : "" };
48026
+ },
48027
+ toJSON(message) {
48028
+ const obj = {};
48029
+ if (message.secretId !== "") {
48030
+ obj.secretId = message.secretId;
48031
+ }
48032
+ return obj;
48033
+ },
48034
+ create(base) {
48035
+ return SecretGetInfoRequest.fromPartial(base ?? {});
48036
+ },
48037
+ fromPartial(object) {
48038
+ const message = createBaseSecretGetInfoRequest();
48039
+ message.secretId = object.secretId ?? "";
48040
+ return message;
48041
+ }
48042
+ };
48043
+ function createBaseSecretGetInfoResponse() {
48044
+ return { metadata: void 0 };
48045
+ }
48046
+ var SecretGetInfoResponse = {
48047
+ encode(message, writer = new BinaryWriter()) {
48048
+ if (message.metadata !== void 0) {
48049
+ SecretMetadata.encode(message.metadata, writer.uint32(10).fork()).join();
48050
+ }
48051
+ return writer;
48052
+ },
48053
+ decode(input, length) {
48054
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
48055
+ let end = length === void 0 ? reader.len : reader.pos + length;
48056
+ const message = createBaseSecretGetInfoResponse();
48057
+ while (reader.pos < end) {
48058
+ const tag = reader.uint32();
48059
+ switch (tag >>> 3) {
48060
+ case 1: {
48061
+ if (tag !== 10) {
48062
+ break;
48063
+ }
48064
+ message.metadata = SecretMetadata.decode(reader, reader.uint32());
48065
+ continue;
48066
+ }
48067
+ }
48068
+ if ((tag & 7) === 4 || tag === 0) {
48069
+ break;
48070
+ }
48071
+ reader.skip(tag & 7);
48072
+ }
48073
+ return message;
48074
+ },
48075
+ fromJSON(object) {
48076
+ return { metadata: isSet5(object.metadata) ? SecretMetadata.fromJSON(object.metadata) : void 0 };
48077
+ },
48078
+ toJSON(message) {
48079
+ const obj = {};
48080
+ if (message.metadata !== void 0) {
48081
+ obj.metadata = SecretMetadata.toJSON(message.metadata);
48082
+ }
48083
+ return obj;
48084
+ },
48085
+ create(base) {
48086
+ return SecretGetInfoResponse.fromPartial(base ?? {});
48087
+ },
48088
+ fromPartial(object) {
48089
+ const message = createBaseSecretGetInfoResponse();
48090
+ message.metadata = object.metadata !== void 0 && object.metadata !== null ? SecretMetadata.fromPartial(object.metadata) : void 0;
48091
+ return message;
48092
+ }
48093
+ };
47977
48094
  function createBaseSecretGetOrCreateRequest() {
47978
48095
  return { deploymentName: "", environmentName: "", objectCreationType: 0, envDict: {}, appId: "", requiredKeys: [] };
47979
48096
  }
@@ -48520,7 +48637,7 @@ var SecretListResponse = {
48520
48637
  }
48521
48638
  };
48522
48639
  function createBaseSecretMetadata() {
48523
- return { name: "", creationInfo: void 0, keys: [] };
48640
+ return { name: "", creationInfo: void 0, keys: [], environmentName: "" };
48524
48641
  }
48525
48642
  var SecretMetadata = {
48526
48643
  encode(message, writer = new BinaryWriter()) {
@@ -48533,6 +48650,9 @@ var SecretMetadata = {
48533
48650
  for (const v of message.keys) {
48534
48651
  writer.uint32(26).string(v);
48535
48652
  }
48653
+ if (message.environmentName !== "") {
48654
+ writer.uint32(34).string(message.environmentName);
48655
+ }
48536
48656
  return writer;
48537
48657
  },
48538
48658
  decode(input, length) {
@@ -48563,6 +48683,13 @@ var SecretMetadata = {
48563
48683
  message.keys.push(reader.string());
48564
48684
  continue;
48565
48685
  }
48686
+ case 4: {
48687
+ if (tag !== 34) {
48688
+ break;
48689
+ }
48690
+ message.environmentName = reader.string();
48691
+ continue;
48692
+ }
48566
48693
  }
48567
48694
  if ((tag & 7) === 4 || tag === 0) {
48568
48695
  break;
@@ -48575,7 +48702,8 @@ var SecretMetadata = {
48575
48702
  return {
48576
48703
  name: isSet5(object.name) ? globalThis.String(object.name) : "",
48577
48704
  creationInfo: isSet5(object.creationInfo) ? CreationInfo.fromJSON(object.creationInfo) : void 0,
48578
- keys: globalThis.Array.isArray(object?.keys) ? object.keys.map((e) => globalThis.String(e)) : []
48705
+ keys: globalThis.Array.isArray(object?.keys) ? object.keys.map((e) => globalThis.String(e)) : [],
48706
+ environmentName: isSet5(object.environmentName) ? globalThis.String(object.environmentName) : ""
48579
48707
  };
48580
48708
  },
48581
48709
  toJSON(message) {
@@ -48589,6 +48717,9 @@ var SecretMetadata = {
48589
48717
  if (message.keys?.length) {
48590
48718
  obj.keys = message.keys;
48591
48719
  }
48720
+ if (message.environmentName !== "") {
48721
+ obj.environmentName = message.environmentName;
48722
+ }
48592
48723
  return obj;
48593
48724
  },
48594
48725
  create(base) {
@@ -48599,6 +48730,7 @@ var SecretMetadata = {
48599
48730
  message.name = object.name ?? "";
48600
48731
  message.creationInfo = object.creationInfo !== void 0 && object.creationInfo !== null ? CreationInfo.fromPartial(object.creationInfo) : void 0;
48601
48732
  message.keys = object.keys?.map((e) => e) || [];
48733
+ message.environmentName = object.environmentName ?? "";
48602
48734
  return message;
48603
48735
  }
48604
48736
  };
@@ -58453,6 +58585,74 @@ var WebhookTokenListResponse = {
58453
58585
  return message;
58454
58586
  }
58455
58587
  };
58588
+ function createBaseWebhookTokenUpdateRequest() {
58589
+ return { tokenId: "", name: void 0 };
58590
+ }
58591
+ var WebhookTokenUpdateRequest = {
58592
+ encode(message, writer = new BinaryWriter()) {
58593
+ if (message.tokenId !== "") {
58594
+ writer.uint32(10).string(message.tokenId);
58595
+ }
58596
+ if (message.name !== void 0) {
58597
+ writer.uint32(18).string(message.name);
58598
+ }
58599
+ return writer;
58600
+ },
58601
+ decode(input, length) {
58602
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
58603
+ let end = length === void 0 ? reader.len : reader.pos + length;
58604
+ const message = createBaseWebhookTokenUpdateRequest();
58605
+ while (reader.pos < end) {
58606
+ const tag = reader.uint32();
58607
+ switch (tag >>> 3) {
58608
+ case 1: {
58609
+ if (tag !== 10) {
58610
+ break;
58611
+ }
58612
+ message.tokenId = reader.string();
58613
+ continue;
58614
+ }
58615
+ case 2: {
58616
+ if (tag !== 18) {
58617
+ break;
58618
+ }
58619
+ message.name = reader.string();
58620
+ continue;
58621
+ }
58622
+ }
58623
+ if ((tag & 7) === 4 || tag === 0) {
58624
+ break;
58625
+ }
58626
+ reader.skip(tag & 7);
58627
+ }
58628
+ return message;
58629
+ },
58630
+ fromJSON(object) {
58631
+ return {
58632
+ tokenId: isSet5(object.tokenId) ? globalThis.String(object.tokenId) : "",
58633
+ name: isSet5(object.name) ? globalThis.String(object.name) : void 0
58634
+ };
58635
+ },
58636
+ toJSON(message) {
58637
+ const obj = {};
58638
+ if (message.tokenId !== "") {
58639
+ obj.tokenId = message.tokenId;
58640
+ }
58641
+ if (message.name !== void 0) {
58642
+ obj.name = message.name;
58643
+ }
58644
+ return obj;
58645
+ },
58646
+ create(base) {
58647
+ return WebhookTokenUpdateRequest.fromPartial(base ?? {});
58648
+ },
58649
+ fromPartial(object) {
58650
+ const message = createBaseWebhookTokenUpdateRequest();
58651
+ message.tokenId = object.tokenId ?? "";
58652
+ message.name = object.name ?? void 0;
58653
+ return message;
58654
+ }
58655
+ };
58456
58656
  function createBaseWorkspaceBillingRatesRequest() {
58457
58657
  return {};
58458
58658
  }
@@ -61983,6 +62183,14 @@ var ModalClientDefinition = {
61983
62183
  responseStream: false,
61984
62184
  options: {}
61985
62185
  },
62186
+ secretGetInfo: {
62187
+ name: "SecretGetInfo",
62188
+ requestType: SecretGetInfoRequest,
62189
+ requestStream: false,
62190
+ responseType: SecretGetInfoResponse,
62191
+ responseStream: false,
62192
+ options: {}
62193
+ },
61986
62194
  secretGetOrCreate: {
61987
62195
  name: "SecretGetOrCreate",
61988
62196
  requestType: SecretGetOrCreateRequest,
@@ -62417,6 +62625,14 @@ var ModalClientDefinition = {
62417
62625
  responseStream: false,
62418
62626
  options: {}
62419
62627
  },
62628
+ webhookTokenUpdate: {
62629
+ name: "WebhookTokenUpdate",
62630
+ requestType: WebhookTokenUpdateRequest,
62631
+ requestStream: false,
62632
+ responseType: WebhookToken,
62633
+ responseStream: false,
62634
+ options: {}
62635
+ },
62420
62636
  /** Workspaces */
62421
62637
  workspaceBillingRates: {
62422
62638
  name: "WorkspaceBillingRates",
@@ -71146,6 +71362,7 @@ var SandboxSnapshotService = class {
71146
71362
  var SB_LOGS_INITIAL_DELAY_MS = 10;
71147
71363
  var SB_LOGS_DELAY_FACTOR = 2;
71148
71364
  var SB_LOGS_MAX_RETRIES = 10;
71365
+ var SB_LOGS_TASK_ID_TIMEOUT_SECONDS = 0.5;
71149
71366
  var TTL_NO_EXPIRY_SENTINEL = -1;
71150
71367
  var CUSTOMER_SUPPLIED_ENCRYPTION_KEY_MIN_LENGTH = 16;
71151
71368
  var CUSTOMER_SUPPLIED_ENCRYPTION_KEY_MAX_LENGTH = 512;
@@ -71195,6 +71412,19 @@ function getSandboxVersion(sandboxId) {
71195
71412
  }
71196
71413
  return "V2" /* V2 */;
71197
71414
  }
71415
+ function sandboxRuntimeToProto(runtime) {
71416
+ switch (runtime) {
71417
+ case void 0:
71418
+ return void 0;
71419
+ case "gvisor":
71420
+ case "vm":
71421
+ return runtime;
71422
+ default:
71423
+ throw new Error(
71424
+ `runtime must be "gvisor" or "vm", got ${JSON.stringify(runtime)}`
71425
+ );
71426
+ }
71427
+ }
71198
71428
  var Probe2 = class _Probe {
71199
71429
  #tcpPort;
71200
71430
  #execArgv;
@@ -71328,6 +71558,7 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
71328
71558
  if (params.workdir && !params.workdir.startsWith("/")) {
71329
71559
  throw new Error(`workdir must be an absolute path, got: ${params.workdir}`);
71330
71560
  }
71561
+ const runtime = sandboxRuntimeToProto(params.runtime);
71331
71562
  const volumeMounts = params.volumes ? Object.entries(params.volumes).map(
71332
71563
  ([mountPath, volume]) => volumeToMountProto(mountPath, volume)
71333
71564
  ) : [];
@@ -71379,16 +71610,16 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
71379
71610
  );
71380
71611
  }
71381
71612
  }
71382
- if (params.outboundPolicy !== void 0) {
71383
- params.outboundPolicy._validate();
71613
+ if (params.experimentalOutboundPolicy !== void 0) {
71614
+ params.experimentalOutboundPolicy._validate();
71384
71615
  if (params.blockNetwork) {
71385
71616
  throw new InvalidError(
71386
- "outboundPolicy cannot be used when blockNetwork is enabled"
71617
+ "experimentalOutboundPolicy cannot be used when blockNetwork is enabled"
71387
71618
  );
71388
71619
  }
71389
71620
  if (params.outboundDomainAllowlist && params.outboundDomainAllowlist.length > 0) {
71390
71621
  throw new InvalidError(
71391
- "outboundPolicy cannot be used with outboundDomainAllowlist"
71622
+ "experimentalOutboundPolicy cannot be used with outboundDomainAllowlist"
71392
71623
  );
71393
71624
  }
71394
71625
  }
@@ -71472,7 +71703,7 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
71472
71703
  idleTimeoutSecs: params.idleTimeoutMs != void 0 ? params.idleTimeoutMs / 1e3 : void 0,
71473
71704
  workdir: params.workdir ?? void 0,
71474
71705
  networkAccess,
71475
- outboundPolicy: params.outboundPolicy?._toProto(),
71706
+ outboundPolicy: params.experimentalOutboundPolicy?._toProto(),
71476
71707
  resources: Resources.create({
71477
71708
  milliCpu,
71478
71709
  milliCpuMax,
@@ -71496,7 +71727,8 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
71496
71727
  includeOidcIdentityToken: params.includeOidcIdentityToken ?? false,
71497
71728
  inboundCidrAllowlist: params.inboundCidrAllowlist ?? [],
71498
71729
  i6pnEnabled: params.i6pn ?? false,
71499
- enableSnapshot: params.experimentalEnableSnapshot ?? false
71730
+ enableSnapshot: params.experimentalEnableSnapshot ?? false,
71731
+ runtime
71500
71732
  }
71501
71733
  });
71502
71734
  }
@@ -71533,7 +71765,10 @@ var SandboxService = class {
71533
71765
  );
71534
71766
  await hydrateSandboxSecrets(
71535
71767
  this.#client,
71536
- [...mergedSecrets, ...params.outboundPolicy?._secrets() ?? []],
71768
+ [
71769
+ ...mergedSecrets,
71770
+ ...params.experimentalOutboundPolicy?._secrets() ?? []
71771
+ ],
71537
71772
  params.cloudBucketMounts
71538
71773
  );
71539
71774
  const mergedParams = {
@@ -71594,7 +71829,10 @@ var SandboxService = class {
71594
71829
  Object.assign(envDict, params.env ?? {});
71595
71830
  await hydrateSandboxSecrets(
71596
71831
  this.#client,
71597
- [...resolvableSecrets, ...params.outboundPolicy?._secrets() ?? []],
71832
+ [
71833
+ ...resolvableSecrets,
71834
+ ...params.experimentalOutboundPolicy?._secrets() ?? []
71835
+ ],
71598
71836
  params.cloudBucketMounts
71599
71837
  );
71600
71838
  const mergedParams = {
@@ -72003,6 +72241,7 @@ function buildTaskSnapshotDirectoryRequestProto(taskId, path2, snapshotId, ttlSe
72003
72241
  var Sandbox2 = class _Sandbox {
72004
72242
  #client;
72005
72243
  sandboxId;
72244
+ #appId;
72006
72245
  #stdin;
72007
72246
  #stdout;
72008
72247
  #stderr;
@@ -72049,6 +72288,25 @@ var Sandbox2 = class _Sandbox {
72049
72288
  }
72050
72289
  return this.#stderr;
72051
72290
  }
72291
+ /**
72292
+ * Access persisted entrypoint logs emitted by this Sandbox.
72293
+ *
72294
+ * Use {@link SandboxLogsManager#fetch fetch()} to read logs from a UTC time
72295
+ * range and {@link SandboxLogsManager#tail tail()} to read the most recent
72296
+ * logs.
72297
+ *
72298
+ * This is separate from {@link Sandbox#stdout stdout} and
72299
+ * {@link Sandbox#stderr stderr}, which expose the Sandbox's live output
72300
+ * streams.
72301
+ */
72302
+ get logs() {
72303
+ return new SandboxLogsManager(
72304
+ this.#client,
72305
+ this.sandboxId,
72306
+ () => this.#getAppId(),
72307
+ () => this.#resolveTaskIdForLogs()
72308
+ );
72309
+ }
72052
72310
  #outputStream(fileDescriptor) {
72053
72311
  if (this.#isV2) {
72054
72312
  this.#ensureAttached();
@@ -72281,8 +72539,11 @@ var Sandbox2 = class _Sandbox {
72281
72539
  }
72282
72540
  return this.#client.cpClient.sandboxWait(req);
72283
72541
  }
72284
- #sandboxGetTaskId(signal) {
72285
- const req = { sandboxId: this.sandboxId };
72542
+ #sandboxGetTaskId(signal, timeout) {
72543
+ const req = SandboxGetTaskIdRequest.create({
72544
+ sandboxId: this.sandboxId,
72545
+ timeout
72546
+ });
72286
72547
  if (this.#isV2) {
72287
72548
  return this.#client.cpClient.sandboxGetTaskIdV2(req, { signal });
72288
72549
  }
@@ -72312,6 +72573,42 @@ var Sandbox2 = class _Sandbox {
72312
72573
  }
72313
72574
  static #maxGetTaskIdAttempts = 600;
72314
72575
  // 5 minutes at 500ms intervals
72576
+ async #getAppId() {
72577
+ if (this.#appId !== void 0) {
72578
+ return this.#appId;
72579
+ }
72580
+ const resp = await this.#sandboxWait(0);
72581
+ const appId = resp.metadata?.appId;
72582
+ if (!appId) {
72583
+ throw new ExecutionError(
72584
+ "Sandbox app ID should have been set during hydration"
72585
+ );
72586
+ }
72587
+ this.#appId = appId;
72588
+ return appId;
72589
+ }
72590
+ async #resolveTaskIdForLogs() {
72591
+ if (this.#taskId !== void 0) {
72592
+ return this.#taskId;
72593
+ }
72594
+ let resp;
72595
+ try {
72596
+ resp = await this.#sandboxGetTaskId(
72597
+ void 0,
72598
+ SB_LOGS_TASK_ID_TIMEOUT_SECONDS
72599
+ );
72600
+ } catch (error) {
72601
+ if (error instanceof ClientError11 && error.code === Status11.DEADLINE_EXCEEDED) {
72602
+ throw new ExecutionError("Sandbox task ID is not available yet.");
72603
+ }
72604
+ throw error;
72605
+ }
72606
+ if (!resp.taskId) {
72607
+ throw new ExecutionError("Sandbox task ID is not available.");
72608
+ }
72609
+ this.#taskId = resp.taskId;
72610
+ return this.#taskId;
72611
+ }
72315
72612
  async #getTaskId(signal) {
72316
72613
  if (this.#taskId !== void 0) {
72317
72614
  return this.#taskId;
@@ -72743,14 +73040,16 @@ var Sandbox2 = class _Sandbox {
72743
73040
  /**
72744
73041
  * Replace the outbound policy of a running Sandbox.
72745
73042
  *
73043
+ * EXPERIMENTAL: the API is subject to change.
73044
+ *
72746
73045
  * The new policy replaces all existing policy configuration on the
72747
73046
  * Sandbox; build a policy including any existing rules you want to keep.
72748
73047
  *
72749
- * Only Sandboxes created with an `outboundPolicy` can be updated this
73048
+ * Only Sandboxes created with an `experimentalOutboundPolicy` can be updated this
72750
73049
  * way; for Sandboxes created without one this fails, since header
72751
73050
  * replacement is only set up at creation time.
72752
73051
  */
72753
- async updateOutboundPolicy(outboundPolicy) {
73052
+ async experimentalUpdateOutboundPolicy(outboundPolicy) {
72754
73053
  this.#ensureAttached();
72755
73054
  outboundPolicy._validate();
72756
73055
  const [, [taskId, commandRouterClient]] = await Promise.all([
@@ -73320,7 +73619,7 @@ var AuthTokenManager = class {
73320
73619
  };
73321
73620
 
73322
73621
  // src/version.ts
73323
- var SDK_VERSION = "0.10.2-dev.6";
73622
+ var SDK_VERSION = "0.10.2-dev.8";
73324
73623
  function getSDKVersion() {
73325
73624
  return SDK_VERSION;
73326
73625
  }
@@ -74066,6 +74365,8 @@ function contextIds(batch, item, ObjectId) {
74066
74365
  item.inputId || batch.inputId,
74067
74366
  item.containerId || batch.taskId
74068
74367
  ].filter((id) => id);
74368
+ case "sb":
74369
+ return [item.containerId || batch.taskId].filter((id) => id);
74069
74370
  default:
74070
74371
  return [];
74071
74372
  }
@@ -74886,6 +75187,97 @@ var FunctionCallLogsManager = class extends LogsManager {
74886
75187
  );
74887
75188
  }
74888
75189
  };
75190
+ var SandboxLogsManager = class {
75191
+ /** @ignore */
75192
+ constructor(client, sandboxId, getAppId, getTaskId) {
75193
+ this.client = client;
75194
+ this.sandboxId = sandboxId;
75195
+ this.getAppId = getAppId;
75196
+ this.getTaskId = getTaskId;
75197
+ }
75198
+ /**
75199
+ * Fetch Sandbox entrypoint logs corresponding to a UTC time range and
75200
+ * optional filters.
75201
+ *
75202
+ * Entries are returned in chronological order.
75203
+ *
75204
+ * @returns An async iterable of {@link LogEntry} objects.
75205
+ *
75206
+ * @example
75207
+ * ```typescript
75208
+ * import { ModalClient } from "modal";
75209
+ *
75210
+ * const modal = new ModalClient();
75211
+ * const sandbox = await modal.sandboxes.fromId("sb-...");
75212
+ *
75213
+ * for await (const entry of sandbox.logs.fetch({
75214
+ * since: new Date(Date.now() - 60 * 60 * 1_000),
75215
+ * source: "stdout",
75216
+ * })) {
75217
+ * process.stdout.write(entry.message);
75218
+ * }
75219
+ * ```
75220
+ */
75221
+ async *fetch(params) {
75222
+ const [appId, taskId] = await Promise.all([
75223
+ this.getAppId(),
75224
+ this.getTaskId()
75225
+ ]);
75226
+ if (!taskId) {
75227
+ throw new ExecutionError(
75228
+ "Cannot resolve Sandbox metadata needed for fetching logs. Wait for the Sandbox to be scheduled."
75229
+ );
75230
+ }
75231
+ yield* fetchLogs(
75232
+ this.client,
75233
+ {
75234
+ appId,
75235
+ objectId: this.sandboxId,
75236
+ taskId,
75237
+ source: sourceToFileDescriptor(params.source),
75238
+ searchText: params.searchText
75239
+ },
75240
+ params.since,
75241
+ params.until
75242
+ );
75243
+ }
75244
+ /**
75245
+ * Fetch the most recent Sandbox entrypoint logs.
75246
+ *
75247
+ * Entries are returned in chronological order.
75248
+ *
75249
+ * @returns An async iterable of {@link LogEntry} objects.
75250
+ *
75251
+ * @example
75252
+ * ```typescript
75253
+ * import { ModalClient } from "modal";
75254
+ *
75255
+ * const modal = new ModalClient();
75256
+ * const sandbox = await modal.sandboxes.fromId("sb-...");
75257
+ *
75258
+ * for await (const entry of sandbox.logs.tail({ entries: 20 })) {
75259
+ * process.stdout.write(entry.message);
75260
+ * }
75261
+ * ```
75262
+ */
75263
+ async *tail(params = {}) {
75264
+ const [appId, taskId] = await Promise.all([
75265
+ this.getAppId(),
75266
+ this.getTaskId()
75267
+ ]);
75268
+ if (!taskId) {
75269
+ throw new ExecutionError(
75270
+ "Sandbox task ID cannot be empty when fetching logs. Wait for the Sandbox to be scheduled."
75271
+ );
75272
+ }
75273
+ yield* tailLogs(this.client, params.entries ?? 100, {
75274
+ appId,
75275
+ objectId: this.sandboxId,
75276
+ taskId,
75277
+ source: sourceToFileDescriptor(params.source)
75278
+ });
75279
+ }
75280
+ };
74889
75281
 
74890
75282
  // src/function_call.ts
74891
75283
  var FunctionCallService = class {
@@ -75683,7 +76075,7 @@ function templateReferencesKey(template) {
75683
76075
  }
75684
76076
  return false;
75685
76077
  }
75686
- var OutboundPolicy2 = class _OutboundPolicy {
76078
+ var ExperimentalOutboundPolicy = class _ExperimentalOutboundPolicy {
75687
76079
  /** @internal */
75688
76080
  _replacements;
75689
76081
  /** @internal */
@@ -75691,7 +76083,7 @@ var OutboundPolicy2 = class _OutboundPolicy {
75691
76083
  this._replacements = _replacements;
75692
76084
  }
75693
76085
  /**
75694
- * Return a new {@link OutboundPolicy} with an added header replacement.
76086
+ * Return a new {@link ExperimentalOutboundPolicy} with an added header replacement.
75695
76087
  *
75696
76088
  * @param params.domain Domain the replacements are scoped to. Supports `*.` wildcard
75697
76089
  * prefixes (matching the apex domain and subdomains) and a bare `"*"`.
@@ -75702,7 +76094,7 @@ var OutboundPolicy2 = class _OutboundPolicy {
75702
76094
  */
75703
76095
  withHeaderReplacement(params) {
75704
76096
  const { domain, headers, secret } = params;
75705
- return new _OutboundPolicy([
76097
+ return new _ExperimentalOutboundPolicy([
75706
76098
  ...this._replacements,
75707
76099
  { domain, headers: { ...headers }, secret }
75708
76100
  ]);
@@ -75789,6 +76181,7 @@ export {
75789
76181
  ConflictError,
75790
76182
  ContainerProcess2 as ContainerProcess,
75791
76183
  ExecutionError,
76184
+ ExperimentalOutboundPolicy,
75792
76185
  FunctionCall,
75793
76186
  FunctionCallLogsManager,
75794
76187
  FunctionCallService,
@@ -75802,7 +76195,6 @@ export {
75802
76195
  InvalidError,
75803
76196
  ModalClient,
75804
76197
  NotFoundError,
75805
- OutboundPolicy2 as OutboundPolicy,
75806
76198
  Probe2 as Probe,
75807
76199
  Proxy2 as Proxy,
75808
76200
  ProxyService,
@@ -75822,6 +76214,7 @@ export {
75822
76214
  SandboxFilesystemNotFoundError,
75823
76215
  SandboxFilesystemPathAlreadyExistsError,
75824
76216
  SandboxFilesystemPermissionError,
76217
+ SandboxLogsManager,
75825
76218
  SandboxService,
75826
76219
  SandboxSnapshot,
75827
76220
  SandboxSnapshotService,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modal",
3
- "version": "0.10.2-dev.6",
3
+ "version": "0.10.2-dev.8",
4
4
  "description": "Modal SDK for JavaScript/TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://modal.com/docs/guide/sdk-javascript-go",