modal 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1684,6 +1684,36 @@ function appStopSourceToJSON(object) {
1684
1684
  return "UNRECOGNIZED";
1685
1685
  }
1686
1686
  }
1687
+ function archFromJSON(object) {
1688
+ switch (object) {
1689
+ case 0:
1690
+ case "ARCH_UNSPECIFIED":
1691
+ return 0 /* ARCH_UNSPECIFIED */;
1692
+ case 1:
1693
+ case "ARCH_X86_64":
1694
+ return 1 /* ARCH_X86_64 */;
1695
+ case 2:
1696
+ case "ARCH_AARCH64":
1697
+ return 2 /* ARCH_AARCH64 */;
1698
+ case -1:
1699
+ case "UNRECOGNIZED":
1700
+ default:
1701
+ return -1 /* UNRECOGNIZED */;
1702
+ }
1703
+ }
1704
+ function archToJSON(object) {
1705
+ switch (object) {
1706
+ case 0 /* ARCH_UNSPECIFIED */:
1707
+ return "ARCH_UNSPECIFIED";
1708
+ case 1 /* ARCH_X86_64 */:
1709
+ return "ARCH_X86_64";
1710
+ case 2 /* ARCH_AARCH64 */:
1711
+ return "ARCH_AARCH64";
1712
+ case -1 /* UNRECOGNIZED */:
1713
+ default:
1714
+ return "UNRECOGNIZED";
1715
+ }
1716
+ }
1687
1717
  function certificateStatusFromJSON(object) {
1688
1718
  switch (object) {
1689
1719
  case 0:
@@ -2154,6 +2184,41 @@ function endpointStopSourceToJSON(object) {
2154
2184
  return "UNRECOGNIZED";
2155
2185
  }
2156
2186
  }
2187
+ function environmentBlockUnauthenticatedResourcesFromJSON(object) {
2188
+ switch (object) {
2189
+ case 0:
2190
+ case "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_UNSPECIFIED":
2191
+ return 0 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_UNSPECIFIED */;
2192
+ case 1:
2193
+ case "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_INHERIT":
2194
+ return 1 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_INHERIT */;
2195
+ case 2:
2196
+ case "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_BLOCK":
2197
+ return 2 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_BLOCK */;
2198
+ case 3:
2199
+ case "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_ALLOW":
2200
+ return 3 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_ALLOW */;
2201
+ case -1:
2202
+ case "UNRECOGNIZED":
2203
+ default:
2204
+ return -1 /* UNRECOGNIZED */;
2205
+ }
2206
+ }
2207
+ function environmentBlockUnauthenticatedResourcesToJSON(object) {
2208
+ switch (object) {
2209
+ case 0 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_UNSPECIFIED */:
2210
+ return "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_UNSPECIFIED";
2211
+ case 1 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_INHERIT */:
2212
+ return "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_INHERIT";
2213
+ case 2 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_BLOCK */:
2214
+ return "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_BLOCK";
2215
+ case 3 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_ALLOW */:
2216
+ return "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_ALLOW";
2217
+ case -1 /* UNRECOGNIZED */:
2218
+ default:
2219
+ return "UNRECOGNIZED";
2220
+ }
2221
+ }
2157
2222
  function environmentRoleFromJSON(object) {
2158
2223
  switch (object) {
2159
2224
  case 0:
@@ -5179,6 +5244,108 @@ var AppGetByDeploymentNameResponse = {
5179
5244
  return message;
5180
5245
  }
5181
5246
  };
5247
+ function createBaseAppGetInfoRequest() {
5248
+ return { appId: "" };
5249
+ }
5250
+ var AppGetInfoRequest = {
5251
+ encode(message, writer = new BinaryWriter()) {
5252
+ if (message.appId !== "") {
5253
+ writer.uint32(10).string(message.appId);
5254
+ }
5255
+ return writer;
5256
+ },
5257
+ decode(input, length) {
5258
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
5259
+ let end = length === void 0 ? reader.len : reader.pos + length;
5260
+ const message = createBaseAppGetInfoRequest();
5261
+ while (reader.pos < end) {
5262
+ const tag = reader.uint32();
5263
+ switch (tag >>> 3) {
5264
+ case 1: {
5265
+ if (tag !== 10) {
5266
+ break;
5267
+ }
5268
+ message.appId = reader.string();
5269
+ continue;
5270
+ }
5271
+ }
5272
+ if ((tag & 7) === 4 || tag === 0) {
5273
+ break;
5274
+ }
5275
+ reader.skip(tag & 7);
5276
+ }
5277
+ return message;
5278
+ },
5279
+ fromJSON(object) {
5280
+ return { appId: isSet5(object.appId) ? globalThis.String(object.appId) : "" };
5281
+ },
5282
+ toJSON(message) {
5283
+ const obj = {};
5284
+ if (message.appId !== "") {
5285
+ obj.appId = message.appId;
5286
+ }
5287
+ return obj;
5288
+ },
5289
+ create(base) {
5290
+ return AppGetInfoRequest.fromPartial(base ?? {});
5291
+ },
5292
+ fromPartial(object) {
5293
+ const message = createBaseAppGetInfoRequest();
5294
+ message.appId = object.appId ?? "";
5295
+ return message;
5296
+ }
5297
+ };
5298
+ function createBaseAppGetInfoResponse() {
5299
+ return { info: void 0 };
5300
+ }
5301
+ var AppGetInfoResponse = {
5302
+ encode(message, writer = new BinaryWriter()) {
5303
+ if (message.info !== void 0) {
5304
+ AppHandleMetadata.encode(message.info, writer.uint32(10).fork()).join();
5305
+ }
5306
+ return writer;
5307
+ },
5308
+ decode(input, length) {
5309
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
5310
+ let end = length === void 0 ? reader.len : reader.pos + length;
5311
+ const message = createBaseAppGetInfoResponse();
5312
+ while (reader.pos < end) {
5313
+ const tag = reader.uint32();
5314
+ switch (tag >>> 3) {
5315
+ case 1: {
5316
+ if (tag !== 10) {
5317
+ break;
5318
+ }
5319
+ message.info = AppHandleMetadata.decode(reader, reader.uint32());
5320
+ continue;
5321
+ }
5322
+ }
5323
+ if ((tag & 7) === 4 || tag === 0) {
5324
+ break;
5325
+ }
5326
+ reader.skip(tag & 7);
5327
+ }
5328
+ return message;
5329
+ },
5330
+ fromJSON(object) {
5331
+ return { info: isSet5(object.info) ? AppHandleMetadata.fromJSON(object.info) : void 0 };
5332
+ },
5333
+ toJSON(message) {
5334
+ const obj = {};
5335
+ if (message.info !== void 0) {
5336
+ obj.info = AppHandleMetadata.toJSON(message.info);
5337
+ }
5338
+ return obj;
5339
+ },
5340
+ create(base) {
5341
+ return AppGetInfoResponse.fromPartial(base ?? {});
5342
+ },
5343
+ fromPartial(object) {
5344
+ const message = createBaseAppGetInfoResponse();
5345
+ message.info = object.info !== void 0 && object.info !== null ? AppHandleMetadata.fromPartial(object.info) : void 0;
5346
+ return message;
5347
+ }
5348
+ };
5182
5349
  function createBaseAppGetLayoutRequest() {
5183
5350
  return { appId: "" };
5184
5351
  }
@@ -5886,13 +6053,16 @@ var AppGetOrCreateRequest = {
5886
6053
  }
5887
6054
  };
5888
6055
  function createBaseAppGetOrCreateResponse() {
5889
- return { appId: "" };
6056
+ return { appId: "", handleMetadata: void 0 };
5890
6057
  }
5891
6058
  var AppGetOrCreateResponse = {
5892
6059
  encode(message, writer = new BinaryWriter()) {
5893
6060
  if (message.appId !== "") {
5894
6061
  writer.uint32(10).string(message.appId);
5895
6062
  }
6063
+ if (message.handleMetadata !== void 0) {
6064
+ AppHandleMetadata.encode(message.handleMetadata, writer.uint32(18).fork()).join();
6065
+ }
5896
6066
  return writer;
5897
6067
  },
5898
6068
  decode(input, length) {
@@ -5909,6 +6079,13 @@ var AppGetOrCreateResponse = {
5909
6079
  message.appId = reader.string();
5910
6080
  continue;
5911
6081
  }
6082
+ case 2: {
6083
+ if (tag !== 18) {
6084
+ break;
6085
+ }
6086
+ message.handleMetadata = AppHandleMetadata.decode(reader, reader.uint32());
6087
+ continue;
6088
+ }
5912
6089
  }
5913
6090
  if ((tag & 7) === 4 || tag === 0) {
5914
6091
  break;
@@ -5918,13 +6095,19 @@ var AppGetOrCreateResponse = {
5918
6095
  return message;
5919
6096
  },
5920
6097
  fromJSON(object) {
5921
- return { appId: isSet5(object.appId) ? globalThis.String(object.appId) : "" };
6098
+ return {
6099
+ appId: isSet5(object.appId) ? globalThis.String(object.appId) : "",
6100
+ handleMetadata: isSet5(object.handleMetadata) ? AppHandleMetadata.fromJSON(object.handleMetadata) : void 0
6101
+ };
5922
6102
  },
5923
6103
  toJSON(message) {
5924
6104
  const obj = {};
5925
6105
  if (message.appId !== "") {
5926
6106
  obj.appId = message.appId;
5927
6107
  }
6108
+ if (message.handleMetadata !== void 0) {
6109
+ obj.handleMetadata = AppHandleMetadata.toJSON(message.handleMetadata);
6110
+ }
5928
6111
  return obj;
5929
6112
  },
5930
6113
  create(base) {
@@ -5933,6 +6116,7 @@ var AppGetOrCreateResponse = {
5933
6116
  fromPartial(object) {
5934
6117
  const message = createBaseAppGetOrCreateResponse();
5935
6118
  message.appId = object.appId ?? "";
6119
+ message.handleMetadata = object.handleMetadata !== void 0 && object.handleMetadata !== null ? AppHandleMetadata.fromPartial(object.handleMetadata) : void 0;
5936
6120
  return message;
5937
6121
  }
5938
6122
  };
@@ -6125,77 +6309,35 @@ var AppGetTagsResponse_TagsEntry = {
6125
6309
  return message;
6126
6310
  }
6127
6311
  };
6128
- function createBaseAppHeartbeatRequest() {
6129
- return { appId: "" };
6312
+ function createBaseAppHandleMetadata() {
6313
+ return { description: "", appId: "", environmentName: "", lifecycle: void 0, functions: {}, servers: {} };
6130
6314
  }
6131
- var AppHeartbeatRequest = {
6315
+ var AppHandleMetadata = {
6132
6316
  encode(message, writer = new BinaryWriter()) {
6133
- if (message.appId !== "") {
6134
- writer.uint32(10).string(message.appId);
6135
- }
6136
- return writer;
6137
- },
6138
- decode(input, length) {
6139
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6140
- let end = length === void 0 ? reader.len : reader.pos + length;
6141
- const message = createBaseAppHeartbeatRequest();
6142
- while (reader.pos < end) {
6143
- const tag = reader.uint32();
6144
- switch (tag >>> 3) {
6145
- case 1: {
6146
- if (tag !== 10) {
6147
- break;
6148
- }
6149
- message.appId = reader.string();
6150
- continue;
6151
- }
6152
- }
6153
- if ((tag & 7) === 4 || tag === 0) {
6154
- break;
6155
- }
6156
- reader.skip(tag & 7);
6317
+ if (message.description !== "") {
6318
+ writer.uint32(10).string(message.description);
6157
6319
  }
6158
- return message;
6159
- },
6160
- fromJSON(object) {
6161
- return { appId: isSet5(object.appId) ? globalThis.String(object.appId) : "" };
6162
- },
6163
- toJSON(message) {
6164
- const obj = {};
6165
6320
  if (message.appId !== "") {
6166
- obj.appId = message.appId;
6321
+ writer.uint32(18).string(message.appId);
6167
6322
  }
6168
- return obj;
6169
- },
6170
- create(base) {
6171
- return AppHeartbeatRequest.fromPartial(base ?? {});
6172
- },
6173
- fromPartial(object) {
6174
- const message = createBaseAppHeartbeatRequest();
6175
- message.appId = object.appId ?? "";
6176
- return message;
6177
- }
6178
- };
6179
- function createBaseAppLayout() {
6180
- return { objects: [], functionIds: {}, classIds: {} };
6181
- }
6182
- var AppLayout = {
6183
- encode(message, writer = new BinaryWriter()) {
6184
- for (const v of message.objects) {
6185
- Object_.encode(v, writer.uint32(10).fork()).join();
6323
+ if (message.environmentName !== "") {
6324
+ writer.uint32(26).string(message.environmentName);
6186
6325
  }
6187
- Object.entries(message.functionIds).forEach(([key, value]) => {
6188
- AppLayout_FunctionIdsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
6326
+ if (message.lifecycle !== void 0) {
6327
+ AppLifecycle.encode(message.lifecycle, writer.uint32(34).fork()).join();
6328
+ }
6329
+ Object.entries(message.functions).forEach(([key, value]) => {
6330
+ AppHandleMetadata_FunctionsEntry.encode({ key, value }, writer.uint32(42).fork()).join();
6189
6331
  });
6190
- Object.entries(message.classIds).forEach(([key, value]) => {
6191
- AppLayout_ClassIdsEntry.encode({ key, value }, writer.uint32(26).fork()).join();
6332
+ Object.entries(message.servers).forEach(([key, value]) => {
6333
+ AppHandleMetadata_ServersEntry.encode({ key, value }, writer.uint32(50).fork()).join();
6192
6334
  });
6193
6335
  return writer;
6194
6336
  },
6195
6337
  decode(input, length) {
6196
6338
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6197
6339
  let end = length === void 0 ? reader.len : reader.pos + length;
6198
- const message = createBaseAppLayout();
6340
+ const message = createBaseAppHandleMetadata();
6199
6341
  while (reader.pos < end) {
6200
6342
  const tag = reader.uint32();
6201
6343
  switch (tag >>> 3) {
@@ -6203,26 +6345,47 @@ var AppLayout = {
6203
6345
  if (tag !== 10) {
6204
6346
  break;
6205
6347
  }
6206
- message.objects.push(Object_.decode(reader, reader.uint32()));
6348
+ message.description = reader.string();
6207
6349
  continue;
6208
6350
  }
6209
6351
  case 2: {
6210
6352
  if (tag !== 18) {
6211
6353
  break;
6212
6354
  }
6213
- const entry2 = AppLayout_FunctionIdsEntry.decode(reader, reader.uint32());
6214
- if (entry2.value !== void 0) {
6215
- message.functionIds[entry2.key] = entry2.value;
6216
- }
6355
+ message.appId = reader.string();
6217
6356
  continue;
6218
6357
  }
6219
6358
  case 3: {
6220
6359
  if (tag !== 26) {
6221
6360
  break;
6222
6361
  }
6223
- const entry3 = AppLayout_ClassIdsEntry.decode(reader, reader.uint32());
6224
- if (entry3.value !== void 0) {
6225
- message.classIds[entry3.key] = entry3.value;
6362
+ message.environmentName = reader.string();
6363
+ continue;
6364
+ }
6365
+ case 4: {
6366
+ if (tag !== 34) {
6367
+ break;
6368
+ }
6369
+ message.lifecycle = AppLifecycle.decode(reader, reader.uint32());
6370
+ continue;
6371
+ }
6372
+ case 5: {
6373
+ if (tag !== 42) {
6374
+ break;
6375
+ }
6376
+ const entry5 = AppHandleMetadata_FunctionsEntry.decode(reader, reader.uint32());
6377
+ if (entry5.value !== void 0) {
6378
+ message.functions[entry5.key] = entry5.value;
6379
+ }
6380
+ continue;
6381
+ }
6382
+ case 6: {
6383
+ if (tag !== 50) {
6384
+ break;
6385
+ }
6386
+ const entry6 = AppHandleMetadata_ServersEntry.decode(reader, reader.uint32());
6387
+ if (entry6.value !== void 0) {
6388
+ message.servers[entry6.key] = entry6.value;
6226
6389
  }
6227
6390
  continue;
6228
6391
  }
@@ -6236,12 +6399,15 @@ var AppLayout = {
6236
6399
  },
6237
6400
  fromJSON(object) {
6238
6401
  return {
6239
- objects: globalThis.Array.isArray(object?.objects) ? object.objects.map((e) => Object_.fromJSON(e)) : [],
6240
- functionIds: isObject2(object.functionIds) ? Object.entries(object.functionIds).reduce((acc, [key, value]) => {
6402
+ description: isSet5(object.description) ? globalThis.String(object.description) : "",
6403
+ appId: isSet5(object.appId) ? globalThis.String(object.appId) : "",
6404
+ environmentName: isSet5(object.environmentName) ? globalThis.String(object.environmentName) : "",
6405
+ lifecycle: isSet5(object.lifecycle) ? AppLifecycle.fromJSON(object.lifecycle) : void 0,
6406
+ functions: isObject2(object.functions) ? Object.entries(object.functions).reduce((acc, [key, value]) => {
6241
6407
  acc[key] = String(value);
6242
6408
  return acc;
6243
6409
  }, {}) : {},
6244
- classIds: isObject2(object.classIds) ? Object.entries(object.classIds).reduce((acc, [key, value]) => {
6410
+ servers: isObject2(object.servers) ? Object.entries(object.servers).reduce((acc, [key, value]) => {
6245
6411
  acc[key] = String(value);
6246
6412
  return acc;
6247
6413
  }, {}) : {}
@@ -6249,36 +6415,48 @@ var AppLayout = {
6249
6415
  },
6250
6416
  toJSON(message) {
6251
6417
  const obj = {};
6252
- if (message.objects?.length) {
6253
- obj.objects = message.objects.map((e) => Object_.toJSON(e));
6418
+ if (message.description !== "") {
6419
+ obj.description = message.description;
6254
6420
  }
6255
- if (message.functionIds) {
6256
- const entries = Object.entries(message.functionIds);
6421
+ if (message.appId !== "") {
6422
+ obj.appId = message.appId;
6423
+ }
6424
+ if (message.environmentName !== "") {
6425
+ obj.environmentName = message.environmentName;
6426
+ }
6427
+ if (message.lifecycle !== void 0) {
6428
+ obj.lifecycle = AppLifecycle.toJSON(message.lifecycle);
6429
+ }
6430
+ if (message.functions) {
6431
+ const entries = Object.entries(message.functions);
6257
6432
  if (entries.length > 0) {
6258
- obj.functionIds = {};
6433
+ obj.functions = {};
6259
6434
  entries.forEach(([k, v]) => {
6260
- obj.functionIds[k] = v;
6435
+ obj.functions[k] = v;
6261
6436
  });
6262
6437
  }
6263
6438
  }
6264
- if (message.classIds) {
6265
- const entries = Object.entries(message.classIds);
6439
+ if (message.servers) {
6440
+ const entries = Object.entries(message.servers);
6266
6441
  if (entries.length > 0) {
6267
- obj.classIds = {};
6442
+ obj.servers = {};
6268
6443
  entries.forEach(([k, v]) => {
6269
- obj.classIds[k] = v;
6444
+ obj.servers[k] = v;
6270
6445
  });
6271
6446
  }
6272
6447
  }
6273
6448
  return obj;
6274
6449
  },
6275
6450
  create(base) {
6276
- return AppLayout.fromPartial(base ?? {});
6451
+ return AppHandleMetadata.fromPartial(base ?? {});
6277
6452
  },
6278
6453
  fromPartial(object) {
6279
- const message = createBaseAppLayout();
6280
- message.objects = object.objects?.map((e) => Object_.fromPartial(e)) || [];
6281
- message.functionIds = Object.entries(object.functionIds ?? {}).reduce(
6454
+ const message = createBaseAppHandleMetadata();
6455
+ message.description = object.description ?? "";
6456
+ message.appId = object.appId ?? "";
6457
+ message.environmentName = object.environmentName ?? "";
6458
+ message.lifecycle = object.lifecycle !== void 0 && object.lifecycle !== null ? AppLifecycle.fromPartial(object.lifecycle) : void 0;
6459
+ message.functions = Object.entries(object.functions ?? {}).reduce(
6282
6460
  (acc, [key, value]) => {
6283
6461
  if (value !== void 0) {
6284
6462
  acc[key] = globalThis.String(value);
@@ -6287,7 +6465,7 @@ var AppLayout = {
6287
6465
  },
6288
6466
  {}
6289
6467
  );
6290
- message.classIds = Object.entries(object.classIds ?? {}).reduce((acc, [key, value]) => {
6468
+ message.servers = Object.entries(object.servers ?? {}).reduce((acc, [key, value]) => {
6291
6469
  if (value !== void 0) {
6292
6470
  acc[key] = globalThis.String(value);
6293
6471
  }
@@ -6296,10 +6474,10 @@ var AppLayout = {
6296
6474
  return message;
6297
6475
  }
6298
6476
  };
6299
- function createBaseAppLayout_FunctionIdsEntry() {
6477
+ function createBaseAppHandleMetadata_FunctionsEntry() {
6300
6478
  return { key: "", value: "" };
6301
6479
  }
6302
- var AppLayout_FunctionIdsEntry = {
6480
+ var AppHandleMetadata_FunctionsEntry = {
6303
6481
  encode(message, writer = new BinaryWriter()) {
6304
6482
  if (message.key !== "") {
6305
6483
  writer.uint32(10).string(message.key);
@@ -6312,7 +6490,314 @@ var AppLayout_FunctionIdsEntry = {
6312
6490
  decode(input, length) {
6313
6491
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6314
6492
  let end = length === void 0 ? reader.len : reader.pos + length;
6315
- const message = createBaseAppLayout_FunctionIdsEntry();
6493
+ const message = createBaseAppHandleMetadata_FunctionsEntry();
6494
+ while (reader.pos < end) {
6495
+ const tag = reader.uint32();
6496
+ switch (tag >>> 3) {
6497
+ case 1: {
6498
+ if (tag !== 10) {
6499
+ break;
6500
+ }
6501
+ message.key = reader.string();
6502
+ continue;
6503
+ }
6504
+ case 2: {
6505
+ if (tag !== 18) {
6506
+ break;
6507
+ }
6508
+ message.value = reader.string();
6509
+ continue;
6510
+ }
6511
+ }
6512
+ if ((tag & 7) === 4 || tag === 0) {
6513
+ break;
6514
+ }
6515
+ reader.skip(tag & 7);
6516
+ }
6517
+ return message;
6518
+ },
6519
+ fromJSON(object) {
6520
+ return {
6521
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
6522
+ value: isSet5(object.value) ? globalThis.String(object.value) : ""
6523
+ };
6524
+ },
6525
+ toJSON(message) {
6526
+ const obj = {};
6527
+ if (message.key !== "") {
6528
+ obj.key = message.key;
6529
+ }
6530
+ if (message.value !== "") {
6531
+ obj.value = message.value;
6532
+ }
6533
+ return obj;
6534
+ },
6535
+ create(base) {
6536
+ return AppHandleMetadata_FunctionsEntry.fromPartial(base ?? {});
6537
+ },
6538
+ fromPartial(object) {
6539
+ const message = createBaseAppHandleMetadata_FunctionsEntry();
6540
+ message.key = object.key ?? "";
6541
+ message.value = object.value ?? "";
6542
+ return message;
6543
+ }
6544
+ };
6545
+ function createBaseAppHandleMetadata_ServersEntry() {
6546
+ return { key: "", value: "" };
6547
+ }
6548
+ var AppHandleMetadata_ServersEntry = {
6549
+ encode(message, writer = new BinaryWriter()) {
6550
+ if (message.key !== "") {
6551
+ writer.uint32(10).string(message.key);
6552
+ }
6553
+ if (message.value !== "") {
6554
+ writer.uint32(18).string(message.value);
6555
+ }
6556
+ return writer;
6557
+ },
6558
+ decode(input, length) {
6559
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6560
+ let end = length === void 0 ? reader.len : reader.pos + length;
6561
+ const message = createBaseAppHandleMetadata_ServersEntry();
6562
+ while (reader.pos < end) {
6563
+ const tag = reader.uint32();
6564
+ switch (tag >>> 3) {
6565
+ case 1: {
6566
+ if (tag !== 10) {
6567
+ break;
6568
+ }
6569
+ message.key = reader.string();
6570
+ continue;
6571
+ }
6572
+ case 2: {
6573
+ if (tag !== 18) {
6574
+ break;
6575
+ }
6576
+ message.value = reader.string();
6577
+ continue;
6578
+ }
6579
+ }
6580
+ if ((tag & 7) === 4 || tag === 0) {
6581
+ break;
6582
+ }
6583
+ reader.skip(tag & 7);
6584
+ }
6585
+ return message;
6586
+ },
6587
+ fromJSON(object) {
6588
+ return {
6589
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
6590
+ value: isSet5(object.value) ? globalThis.String(object.value) : ""
6591
+ };
6592
+ },
6593
+ toJSON(message) {
6594
+ const obj = {};
6595
+ if (message.key !== "") {
6596
+ obj.key = message.key;
6597
+ }
6598
+ if (message.value !== "") {
6599
+ obj.value = message.value;
6600
+ }
6601
+ return obj;
6602
+ },
6603
+ create(base) {
6604
+ return AppHandleMetadata_ServersEntry.fromPartial(base ?? {});
6605
+ },
6606
+ fromPartial(object) {
6607
+ const message = createBaseAppHandleMetadata_ServersEntry();
6608
+ message.key = object.key ?? "";
6609
+ message.value = object.value ?? "";
6610
+ return message;
6611
+ }
6612
+ };
6613
+ function createBaseAppHeartbeatRequest() {
6614
+ return { appId: "" };
6615
+ }
6616
+ var AppHeartbeatRequest = {
6617
+ encode(message, writer = new BinaryWriter()) {
6618
+ if (message.appId !== "") {
6619
+ writer.uint32(10).string(message.appId);
6620
+ }
6621
+ return writer;
6622
+ },
6623
+ decode(input, length) {
6624
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6625
+ let end = length === void 0 ? reader.len : reader.pos + length;
6626
+ const message = createBaseAppHeartbeatRequest();
6627
+ while (reader.pos < end) {
6628
+ const tag = reader.uint32();
6629
+ switch (tag >>> 3) {
6630
+ case 1: {
6631
+ if (tag !== 10) {
6632
+ break;
6633
+ }
6634
+ message.appId = reader.string();
6635
+ continue;
6636
+ }
6637
+ }
6638
+ if ((tag & 7) === 4 || tag === 0) {
6639
+ break;
6640
+ }
6641
+ reader.skip(tag & 7);
6642
+ }
6643
+ return message;
6644
+ },
6645
+ fromJSON(object) {
6646
+ return { appId: isSet5(object.appId) ? globalThis.String(object.appId) : "" };
6647
+ },
6648
+ toJSON(message) {
6649
+ const obj = {};
6650
+ if (message.appId !== "") {
6651
+ obj.appId = message.appId;
6652
+ }
6653
+ return obj;
6654
+ },
6655
+ create(base) {
6656
+ return AppHeartbeatRequest.fromPartial(base ?? {});
6657
+ },
6658
+ fromPartial(object) {
6659
+ const message = createBaseAppHeartbeatRequest();
6660
+ message.appId = object.appId ?? "";
6661
+ return message;
6662
+ }
6663
+ };
6664
+ function createBaseAppLayout() {
6665
+ return { objects: [], functionIds: {}, classIds: {} };
6666
+ }
6667
+ var AppLayout = {
6668
+ encode(message, writer = new BinaryWriter()) {
6669
+ for (const v of message.objects) {
6670
+ Object_.encode(v, writer.uint32(10).fork()).join();
6671
+ }
6672
+ Object.entries(message.functionIds).forEach(([key, value]) => {
6673
+ AppLayout_FunctionIdsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
6674
+ });
6675
+ Object.entries(message.classIds).forEach(([key, value]) => {
6676
+ AppLayout_ClassIdsEntry.encode({ key, value }, writer.uint32(26).fork()).join();
6677
+ });
6678
+ return writer;
6679
+ },
6680
+ decode(input, length) {
6681
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6682
+ let end = length === void 0 ? reader.len : reader.pos + length;
6683
+ const message = createBaseAppLayout();
6684
+ while (reader.pos < end) {
6685
+ const tag = reader.uint32();
6686
+ switch (tag >>> 3) {
6687
+ case 1: {
6688
+ if (tag !== 10) {
6689
+ break;
6690
+ }
6691
+ message.objects.push(Object_.decode(reader, reader.uint32()));
6692
+ continue;
6693
+ }
6694
+ case 2: {
6695
+ if (tag !== 18) {
6696
+ break;
6697
+ }
6698
+ const entry2 = AppLayout_FunctionIdsEntry.decode(reader, reader.uint32());
6699
+ if (entry2.value !== void 0) {
6700
+ message.functionIds[entry2.key] = entry2.value;
6701
+ }
6702
+ continue;
6703
+ }
6704
+ case 3: {
6705
+ if (tag !== 26) {
6706
+ break;
6707
+ }
6708
+ const entry3 = AppLayout_ClassIdsEntry.decode(reader, reader.uint32());
6709
+ if (entry3.value !== void 0) {
6710
+ message.classIds[entry3.key] = entry3.value;
6711
+ }
6712
+ continue;
6713
+ }
6714
+ }
6715
+ if ((tag & 7) === 4 || tag === 0) {
6716
+ break;
6717
+ }
6718
+ reader.skip(tag & 7);
6719
+ }
6720
+ return message;
6721
+ },
6722
+ fromJSON(object) {
6723
+ return {
6724
+ objects: globalThis.Array.isArray(object?.objects) ? object.objects.map((e) => Object_.fromJSON(e)) : [],
6725
+ functionIds: isObject2(object.functionIds) ? Object.entries(object.functionIds).reduce((acc, [key, value]) => {
6726
+ acc[key] = String(value);
6727
+ return acc;
6728
+ }, {}) : {},
6729
+ classIds: isObject2(object.classIds) ? Object.entries(object.classIds).reduce((acc, [key, value]) => {
6730
+ acc[key] = String(value);
6731
+ return acc;
6732
+ }, {}) : {}
6733
+ };
6734
+ },
6735
+ toJSON(message) {
6736
+ const obj = {};
6737
+ if (message.objects?.length) {
6738
+ obj.objects = message.objects.map((e) => Object_.toJSON(e));
6739
+ }
6740
+ if (message.functionIds) {
6741
+ const entries = Object.entries(message.functionIds);
6742
+ if (entries.length > 0) {
6743
+ obj.functionIds = {};
6744
+ entries.forEach(([k, v]) => {
6745
+ obj.functionIds[k] = v;
6746
+ });
6747
+ }
6748
+ }
6749
+ if (message.classIds) {
6750
+ const entries = Object.entries(message.classIds);
6751
+ if (entries.length > 0) {
6752
+ obj.classIds = {};
6753
+ entries.forEach(([k, v]) => {
6754
+ obj.classIds[k] = v;
6755
+ });
6756
+ }
6757
+ }
6758
+ return obj;
6759
+ },
6760
+ create(base) {
6761
+ return AppLayout.fromPartial(base ?? {});
6762
+ },
6763
+ fromPartial(object) {
6764
+ const message = createBaseAppLayout();
6765
+ message.objects = object.objects?.map((e) => Object_.fromPartial(e)) || [];
6766
+ message.functionIds = Object.entries(object.functionIds ?? {}).reduce(
6767
+ (acc, [key, value]) => {
6768
+ if (value !== void 0) {
6769
+ acc[key] = globalThis.String(value);
6770
+ }
6771
+ return acc;
6772
+ },
6773
+ {}
6774
+ );
6775
+ message.classIds = Object.entries(object.classIds ?? {}).reduce((acc, [key, value]) => {
6776
+ if (value !== void 0) {
6777
+ acc[key] = globalThis.String(value);
6778
+ }
6779
+ return acc;
6780
+ }, {});
6781
+ return message;
6782
+ }
6783
+ };
6784
+ function createBaseAppLayout_FunctionIdsEntry() {
6785
+ return { key: "", value: "" };
6786
+ }
6787
+ var AppLayout_FunctionIdsEntry = {
6788
+ encode(message, writer = new BinaryWriter()) {
6789
+ if (message.key !== "") {
6790
+ writer.uint32(10).string(message.key);
6791
+ }
6792
+ if (message.value !== "") {
6793
+ writer.uint32(18).string(message.value);
6794
+ }
6795
+ return writer;
6796
+ },
6797
+ decode(input, length) {
6798
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6799
+ let end = length === void 0 ? reader.len : reader.pos + length;
6800
+ const message = createBaseAppLayout_FunctionIdsEntry();
6316
6801
  while (reader.pos < end) {
6317
6802
  const tag = reader.uint32();
6318
6803
  switch (tag >>> 3) {
@@ -17463,7 +17948,8 @@ function createBaseEndpointListItem() {
17463
17948
  createdByAvatarUrl: "",
17464
17949
  provisioningStatus: 0,
17465
17950
  status: "",
17466
- servingMode: 0
17951
+ servingMode: 0,
17952
+ unauthenticated: false
17467
17953
  };
17468
17954
  }
17469
17955
  var EndpointListItem = {
@@ -17504,6 +17990,9 @@ var EndpointListItem = {
17504
17990
  if (message.servingMode !== 0) {
17505
17991
  writer.uint32(96).int32(message.servingMode);
17506
17992
  }
17993
+ if (message.unauthenticated !== false) {
17994
+ writer.uint32(104).bool(message.unauthenticated);
17995
+ }
17507
17996
  return writer;
17508
17997
  },
17509
17998
  decode(input, length) {
@@ -17597,6 +18086,13 @@ var EndpointListItem = {
17597
18086
  message.servingMode = reader.int32();
17598
18087
  continue;
17599
18088
  }
18089
+ case 13: {
18090
+ if (tag !== 104) {
18091
+ break;
18092
+ }
18093
+ message.unauthenticated = reader.bool();
18094
+ continue;
18095
+ }
17600
18096
  }
17601
18097
  if ((tag & 7) === 4 || tag === 0) {
17602
18098
  break;
@@ -17618,7 +18114,8 @@ var EndpointListItem = {
17618
18114
  createdByAvatarUrl: isSet5(object.createdByAvatarUrl) ? globalThis.String(object.createdByAvatarUrl) : "",
17619
18115
  provisioningStatus: isSet5(object.provisioningStatus) ? endpointProvisioningStatusFromJSON(object.provisioningStatus) : 0,
17620
18116
  status: isSet5(object.status) ? globalThis.String(object.status) : "",
17621
- servingMode: isSet5(object.servingMode) ? endpointServingModeFromJSON(object.servingMode) : 0
18117
+ servingMode: isSet5(object.servingMode) ? endpointServingModeFromJSON(object.servingMode) : 0,
18118
+ unauthenticated: isSet5(object.unauthenticated) ? globalThis.Boolean(object.unauthenticated) : false
17622
18119
  };
17623
18120
  },
17624
18121
  toJSON(message) {
@@ -17659,6 +18156,9 @@ var EndpointListItem = {
17659
18156
  if (message.servingMode !== 0) {
17660
18157
  obj.servingMode = endpointServingModeToJSON(message.servingMode);
17661
18158
  }
18159
+ if (message.unauthenticated !== false) {
18160
+ obj.unauthenticated = message.unauthenticated;
18161
+ }
17662
18162
  return obj;
17663
18163
  },
17664
18164
  create(base) {
@@ -17678,6 +18178,7 @@ var EndpointListItem = {
17678
18178
  message.provisioningStatus = object.provisioningStatus ?? 0;
17679
18179
  message.status = object.status ?? "";
17680
18180
  message.servingMode = object.servingMode ?? 0;
18181
+ message.unauthenticated = object.unauthenticated ?? false;
17681
18182
  return message;
17682
18183
  }
17683
18184
  };
@@ -19593,7 +20094,8 @@ function createBaseEnvironmentListItem() {
19593
20094
  currentCycleUsage: 0,
19594
20095
  spendLimitReached: false,
19595
20096
  environmentType: 0,
19596
- defaultMemberRole: void 0
20097
+ defaultMemberRole: void 0,
20098
+ blockUnauthenticatedResources: void 0
19597
20099
  };
19598
20100
  }
19599
20101
  var EnvironmentListItem = {
@@ -19646,6 +20148,9 @@ var EnvironmentListItem = {
19646
20148
  if (message.defaultMemberRole !== void 0) {
19647
20149
  writer.uint32(128).int32(message.defaultMemberRole);
19648
20150
  }
20151
+ if (message.blockUnauthenticatedResources !== void 0) {
20152
+ writer.uint32(136).bool(message.blockUnauthenticatedResources);
20153
+ }
19649
20154
  return writer;
19650
20155
  },
19651
20156
  decode(input, length) {
@@ -19767,6 +20272,13 @@ var EnvironmentListItem = {
19767
20272
  message.defaultMemberRole = reader.int32();
19768
20273
  continue;
19769
20274
  }
20275
+ case 17: {
20276
+ if (tag !== 136) {
20277
+ break;
20278
+ }
20279
+ message.blockUnauthenticatedResources = reader.bool();
20280
+ continue;
20281
+ }
19770
20282
  }
19771
20283
  if ((tag & 7) === 4 || tag === 0) {
19772
20284
  break;
@@ -19792,7 +20304,8 @@ var EnvironmentListItem = {
19792
20304
  currentCycleUsage: isSet5(object.currentCycleUsage) ? globalThis.Number(object.currentCycleUsage) : 0,
19793
20305
  spendLimitReached: isSet5(object.spendLimitReached) ? globalThis.Boolean(object.spendLimitReached) : false,
19794
20306
  environmentType: isSet5(object.environmentType) ? environmentTypeFromJSON(object.environmentType) : 0,
19795
- defaultMemberRole: isSet5(object.defaultMemberRole) ? environmentRoleFromJSON(object.defaultMemberRole) : void 0
20307
+ defaultMemberRole: isSet5(object.defaultMemberRole) ? environmentRoleFromJSON(object.defaultMemberRole) : void 0,
20308
+ blockUnauthenticatedResources: isSet5(object.blockUnauthenticatedResources) ? globalThis.Boolean(object.blockUnauthenticatedResources) : void 0
19796
20309
  };
19797
20310
  },
19798
20311
  toJSON(message) {
@@ -19845,6 +20358,9 @@ var EnvironmentListItem = {
19845
20358
  if (message.defaultMemberRole !== void 0) {
19846
20359
  obj.defaultMemberRole = environmentRoleToJSON(message.defaultMemberRole);
19847
20360
  }
20361
+ if (message.blockUnauthenticatedResources !== void 0) {
20362
+ obj.blockUnauthenticatedResources = message.blockUnauthenticatedResources;
20363
+ }
19848
20364
  return obj;
19849
20365
  },
19850
20366
  create(base) {
@@ -19868,6 +20384,7 @@ var EnvironmentListItem = {
19868
20384
  message.spendLimitReached = object.spendLimitReached ?? false;
19869
20385
  message.environmentType = object.environmentType ?? 0;
19870
20386
  message.defaultMemberRole = object.defaultMemberRole ?? void 0;
20387
+ message.blockUnauthenticatedResources = object.blockUnauthenticatedResources ?? void 0;
19871
20388
  return message;
19872
20389
  }
19873
20390
  };
@@ -20355,7 +20872,13 @@ var EnvironmentSetManagedRequest = {
20355
20872
  }
20356
20873
  };
20357
20874
  function createBaseEnvironmentSettings() {
20358
- return { imageBuilderVersion: "", webhookSuffix: "", maxConcurrentGpus: void 0, maxConcurrentTasks: void 0 };
20875
+ return {
20876
+ imageBuilderVersion: "",
20877
+ webhookSuffix: "",
20878
+ maxConcurrentGpus: void 0,
20879
+ maxConcurrentTasks: void 0,
20880
+ blockUnauthenticatedResources: void 0
20881
+ };
20359
20882
  }
20360
20883
  var EnvironmentSettings = {
20361
20884
  encode(message, writer = new BinaryWriter()) {
@@ -20371,6 +20894,9 @@ var EnvironmentSettings = {
20371
20894
  if (message.maxConcurrentTasks !== void 0) {
20372
20895
  writer.uint32(32).int32(message.maxConcurrentTasks);
20373
20896
  }
20897
+ if (message.blockUnauthenticatedResources !== void 0) {
20898
+ writer.uint32(40).bool(message.blockUnauthenticatedResources);
20899
+ }
20374
20900
  return writer;
20375
20901
  },
20376
20902
  decode(input, length) {
@@ -20408,6 +20934,13 @@ var EnvironmentSettings = {
20408
20934
  message.maxConcurrentTasks = reader.int32();
20409
20935
  continue;
20410
20936
  }
20937
+ case 5: {
20938
+ if (tag !== 40) {
20939
+ break;
20940
+ }
20941
+ message.blockUnauthenticatedResources = reader.bool();
20942
+ continue;
20943
+ }
20411
20944
  }
20412
20945
  if ((tag & 7) === 4 || tag === 0) {
20413
20946
  break;
@@ -20421,7 +20954,8 @@ var EnvironmentSettings = {
20421
20954
  imageBuilderVersion: isSet5(object.imageBuilderVersion) ? globalThis.String(object.imageBuilderVersion) : "",
20422
20955
  webhookSuffix: isSet5(object.webhookSuffix) ? globalThis.String(object.webhookSuffix) : "",
20423
20956
  maxConcurrentGpus: isSet5(object.maxConcurrentGpus) ? globalThis.Number(object.maxConcurrentGpus) : void 0,
20424
- maxConcurrentTasks: isSet5(object.maxConcurrentTasks) ? globalThis.Number(object.maxConcurrentTasks) : void 0
20957
+ maxConcurrentTasks: isSet5(object.maxConcurrentTasks) ? globalThis.Number(object.maxConcurrentTasks) : void 0,
20958
+ blockUnauthenticatedResources: isSet5(object.blockUnauthenticatedResources) ? globalThis.Boolean(object.blockUnauthenticatedResources) : void 0
20425
20959
  };
20426
20960
  },
20427
20961
  toJSON(message) {
@@ -20438,6 +20972,9 @@ var EnvironmentSettings = {
20438
20972
  if (message.maxConcurrentTasks !== void 0) {
20439
20973
  obj.maxConcurrentTasks = Math.round(message.maxConcurrentTasks);
20440
20974
  }
20975
+ if (message.blockUnauthenticatedResources !== void 0) {
20976
+ obj.blockUnauthenticatedResources = message.blockUnauthenticatedResources;
20977
+ }
20441
20978
  return obj;
20442
20979
  },
20443
20980
  create(base) {
@@ -20449,6 +20986,7 @@ var EnvironmentSettings = {
20449
20986
  message.webhookSuffix = object.webhookSuffix ?? "";
20450
20987
  message.maxConcurrentGpus = object.maxConcurrentGpus ?? void 0;
20451
20988
  message.maxConcurrentTasks = object.maxConcurrentTasks ?? void 0;
20989
+ message.blockUnauthenticatedResources = object.blockUnauthenticatedResources ?? void 0;
20452
20990
  return message;
20453
20991
  }
20454
20992
  };
@@ -20458,7 +20996,8 @@ function createBaseEnvironmentUpdateRequest() {
20458
20996
  name: void 0,
20459
20997
  webSuffix: void 0,
20460
20998
  maxConcurrentTasks: void 0,
20461
- maxConcurrentGpus: void 0
20999
+ maxConcurrentGpus: void 0,
21000
+ blockUnauthenticatedResources: void 0
20462
21001
  };
20463
21002
  }
20464
21003
  var EnvironmentUpdateRequest = {
@@ -20478,6 +21017,9 @@ var EnvironmentUpdateRequest = {
20478
21017
  if (message.maxConcurrentGpus !== void 0) {
20479
21018
  writer.uint32(40).int32(message.maxConcurrentGpus);
20480
21019
  }
21020
+ if (message.blockUnauthenticatedResources !== void 0) {
21021
+ writer.uint32(48).int32(message.blockUnauthenticatedResources);
21022
+ }
20481
21023
  return writer;
20482
21024
  },
20483
21025
  decode(input, length) {
@@ -20522,6 +21064,13 @@ var EnvironmentUpdateRequest = {
20522
21064
  message.maxConcurrentGpus = reader.int32();
20523
21065
  continue;
20524
21066
  }
21067
+ case 6: {
21068
+ if (tag !== 48) {
21069
+ break;
21070
+ }
21071
+ message.blockUnauthenticatedResources = reader.int32();
21072
+ continue;
21073
+ }
20525
21074
  }
20526
21075
  if ((tag & 7) === 4 || tag === 0) {
20527
21076
  break;
@@ -20536,7 +21085,8 @@ var EnvironmentUpdateRequest = {
20536
21085
  name: isSet5(object.name) ? String(object.name) : void 0,
20537
21086
  webSuffix: isSet5(object.webSuffix) ? String(object.webSuffix) : void 0,
20538
21087
  maxConcurrentTasks: isSet5(object.maxConcurrentTasks) ? globalThis.Number(object.maxConcurrentTasks) : void 0,
20539
- maxConcurrentGpus: isSet5(object.maxConcurrentGpus) ? globalThis.Number(object.maxConcurrentGpus) : void 0
21088
+ maxConcurrentGpus: isSet5(object.maxConcurrentGpus) ? globalThis.Number(object.maxConcurrentGpus) : void 0,
21089
+ blockUnauthenticatedResources: isSet5(object.blockUnauthenticatedResources) ? environmentBlockUnauthenticatedResourcesFromJSON(object.blockUnauthenticatedResources) : void 0
20540
21090
  };
20541
21091
  },
20542
21092
  toJSON(message) {
@@ -20556,6 +21106,11 @@ var EnvironmentUpdateRequest = {
20556
21106
  if (message.maxConcurrentGpus !== void 0) {
20557
21107
  obj.maxConcurrentGpus = Math.round(message.maxConcurrentGpus);
20558
21108
  }
21109
+ if (message.blockUnauthenticatedResources !== void 0) {
21110
+ obj.blockUnauthenticatedResources = environmentBlockUnauthenticatedResourcesToJSON(
21111
+ message.blockUnauthenticatedResources
21112
+ );
21113
+ }
20559
21114
  return obj;
20560
21115
  },
20561
21116
  create(base) {
@@ -20568,6 +21123,7 @@ var EnvironmentUpdateRequest = {
20568
21123
  message.webSuffix = object.webSuffix ?? void 0;
20569
21124
  message.maxConcurrentTasks = object.maxConcurrentTasks ?? void 0;
20570
21125
  message.maxConcurrentGpus = object.maxConcurrentGpus ?? void 0;
21126
+ message.blockUnauthenticatedResources = object.blockUnauthenticatedResources ?? void 0;
20571
21127
  return message;
20572
21128
  }
20573
21129
  };
@@ -25442,6 +25998,125 @@ var FunctionFinishInputsRequest = {
25442
25998
  return message;
25443
25999
  }
25444
26000
  };
26001
+ function createBaseFunctionGetByIdRequest() {
26002
+ return { functionId: "" };
26003
+ }
26004
+ var FunctionGetByIdRequest = {
26005
+ encode(message, writer = new BinaryWriter()) {
26006
+ if (message.functionId !== "") {
26007
+ writer.uint32(10).string(message.functionId);
26008
+ }
26009
+ return writer;
26010
+ },
26011
+ decode(input, length) {
26012
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
26013
+ let end = length === void 0 ? reader.len : reader.pos + length;
26014
+ const message = createBaseFunctionGetByIdRequest();
26015
+ while (reader.pos < end) {
26016
+ const tag = reader.uint32();
26017
+ switch (tag >>> 3) {
26018
+ case 1: {
26019
+ if (tag !== 10) {
26020
+ break;
26021
+ }
26022
+ message.functionId = reader.string();
26023
+ continue;
26024
+ }
26025
+ }
26026
+ if ((tag & 7) === 4 || tag === 0) {
26027
+ break;
26028
+ }
26029
+ reader.skip(tag & 7);
26030
+ }
26031
+ return message;
26032
+ },
26033
+ fromJSON(object) {
26034
+ return { functionId: isSet5(object.functionId) ? globalThis.String(object.functionId) : "" };
26035
+ },
26036
+ toJSON(message) {
26037
+ const obj = {};
26038
+ if (message.functionId !== "") {
26039
+ obj.functionId = message.functionId;
26040
+ }
26041
+ return obj;
26042
+ },
26043
+ create(base) {
26044
+ return FunctionGetByIdRequest.fromPartial(base ?? {});
26045
+ },
26046
+ fromPartial(object) {
26047
+ const message = createBaseFunctionGetByIdRequest();
26048
+ message.functionId = object.functionId ?? "";
26049
+ return message;
26050
+ }
26051
+ };
26052
+ function createBaseFunctionGetByIdResponse() {
26053
+ return { function: void 0, handleMetadata: void 0 };
26054
+ }
26055
+ var FunctionGetByIdResponse = {
26056
+ encode(message, writer = new BinaryWriter()) {
26057
+ if (message.function !== void 0) {
26058
+ FunctionData.encode(message.function, writer.uint32(10).fork()).join();
26059
+ }
26060
+ if (message.handleMetadata !== void 0) {
26061
+ FunctionHandleMetadata.encode(message.handleMetadata, writer.uint32(18).fork()).join();
26062
+ }
26063
+ return writer;
26064
+ },
26065
+ decode(input, length) {
26066
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
26067
+ let end = length === void 0 ? reader.len : reader.pos + length;
26068
+ const message = createBaseFunctionGetByIdResponse();
26069
+ while (reader.pos < end) {
26070
+ const tag = reader.uint32();
26071
+ switch (tag >>> 3) {
26072
+ case 1: {
26073
+ if (tag !== 10) {
26074
+ break;
26075
+ }
26076
+ message.function = FunctionData.decode(reader, reader.uint32());
26077
+ continue;
26078
+ }
26079
+ case 2: {
26080
+ if (tag !== 18) {
26081
+ break;
26082
+ }
26083
+ message.handleMetadata = FunctionHandleMetadata.decode(reader, reader.uint32());
26084
+ continue;
26085
+ }
26086
+ }
26087
+ if ((tag & 7) === 4 || tag === 0) {
26088
+ break;
26089
+ }
26090
+ reader.skip(tag & 7);
26091
+ }
26092
+ return message;
26093
+ },
26094
+ fromJSON(object) {
26095
+ return {
26096
+ function: isSet5(object.function) ? FunctionData.fromJSON(object.function) : void 0,
26097
+ handleMetadata: isSet5(object.handleMetadata) ? FunctionHandleMetadata.fromJSON(object.handleMetadata) : void 0
26098
+ };
26099
+ },
26100
+ toJSON(message) {
26101
+ const obj = {};
26102
+ if (message.function !== void 0) {
26103
+ obj.function = FunctionData.toJSON(message.function);
26104
+ }
26105
+ if (message.handleMetadata !== void 0) {
26106
+ obj.handleMetadata = FunctionHandleMetadata.toJSON(message.handleMetadata);
26107
+ }
26108
+ return obj;
26109
+ },
26110
+ create(base) {
26111
+ return FunctionGetByIdResponse.fromPartial(base ?? {});
26112
+ },
26113
+ fromPartial(object) {
26114
+ const message = createBaseFunctionGetByIdResponse();
26115
+ message.function = object.function !== void 0 && object.function !== null ? FunctionData.fromPartial(object.function) : void 0;
26116
+ message.handleMetadata = object.handleMetadata !== void 0 && object.handleMetadata !== null ? FunctionHandleMetadata.fromPartial(object.handleMetadata) : void 0;
26117
+ return message;
26118
+ }
26119
+ };
25445
26120
  function createBaseFunctionGetCallGraphRequest() {
25446
26121
  return { functionCallId: "" };
25447
26122
  }
@@ -25494,7 +26169,7 @@ var FunctionGetCallGraphRequest = {
25494
26169
  }
25495
26170
  };
25496
26171
  function createBaseFunctionGetCallGraphResponse() {
25497
- return { inputs: [], functionCalls: [] };
26172
+ return { inputs: [], functionCalls: [], truncated: false };
25498
26173
  }
25499
26174
  var FunctionGetCallGraphResponse = {
25500
26175
  encode(message, writer = new BinaryWriter()) {
@@ -25504,6 +26179,9 @@ var FunctionGetCallGraphResponse = {
25504
26179
  for (const v of message.functionCalls) {
25505
26180
  FunctionCallCallGraphInfo.encode(v, writer.uint32(18).fork()).join();
25506
26181
  }
26182
+ if (message.truncated !== false) {
26183
+ writer.uint32(24).bool(message.truncated);
26184
+ }
25507
26185
  return writer;
25508
26186
  },
25509
26187
  decode(input, length) {
@@ -25527,6 +26205,13 @@ var FunctionGetCallGraphResponse = {
25527
26205
  message.functionCalls.push(FunctionCallCallGraphInfo.decode(reader, reader.uint32()));
25528
26206
  continue;
25529
26207
  }
26208
+ case 3: {
26209
+ if (tag !== 24) {
26210
+ break;
26211
+ }
26212
+ message.truncated = reader.bool();
26213
+ continue;
26214
+ }
25530
26215
  }
25531
26216
  if ((tag & 7) === 4 || tag === 0) {
25532
26217
  break;
@@ -25538,7 +26223,8 @@ var FunctionGetCallGraphResponse = {
25538
26223
  fromJSON(object) {
25539
26224
  return {
25540
26225
  inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => InputCallGraphInfo.fromJSON(e)) : [],
25541
- functionCalls: globalThis.Array.isArray(object?.functionCalls) ? object.functionCalls.map((e) => FunctionCallCallGraphInfo.fromJSON(e)) : []
26226
+ functionCalls: globalThis.Array.isArray(object?.functionCalls) ? object.functionCalls.map((e) => FunctionCallCallGraphInfo.fromJSON(e)) : [],
26227
+ truncated: isSet5(object.truncated) ? globalThis.Boolean(object.truncated) : false
25542
26228
  };
25543
26229
  },
25544
26230
  toJSON(message) {
@@ -25549,6 +26235,9 @@ var FunctionGetCallGraphResponse = {
25549
26235
  if (message.functionCalls?.length) {
25550
26236
  obj.functionCalls = message.functionCalls.map((e) => FunctionCallCallGraphInfo.toJSON(e));
25551
26237
  }
26238
+ if (message.truncated !== false) {
26239
+ obj.truncated = message.truncated;
26240
+ }
25552
26241
  return obj;
25553
26242
  },
25554
26243
  create(base) {
@@ -25558,6 +26247,7 @@ var FunctionGetCallGraphResponse = {
25558
26247
  const message = createBaseFunctionGetCallGraphResponse();
25559
26248
  message.inputs = object.inputs?.map((e) => InputCallGraphInfo.fromPartial(e)) || [];
25560
26249
  message.functionCalls = object.functionCalls?.map((e) => FunctionCallCallGraphInfo.fromPartial(e)) || [];
26250
+ message.truncated = object.truncated ?? false;
25561
26251
  return message;
25562
26252
  }
25563
26253
  };
@@ -25746,6 +26436,108 @@ var FunctionGetDynamicConcurrencyResponse = {
25746
26436
  return message;
25747
26437
  }
25748
26438
  };
26439
+ function createBaseFunctionGetFlashAuthTokenRequest() {
26440
+ return { functionId: "" };
26441
+ }
26442
+ var FunctionGetFlashAuthTokenRequest = {
26443
+ encode(message, writer = new BinaryWriter()) {
26444
+ if (message.functionId !== "") {
26445
+ writer.uint32(10).string(message.functionId);
26446
+ }
26447
+ return writer;
26448
+ },
26449
+ decode(input, length) {
26450
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
26451
+ let end = length === void 0 ? reader.len : reader.pos + length;
26452
+ const message = createBaseFunctionGetFlashAuthTokenRequest();
26453
+ while (reader.pos < end) {
26454
+ const tag = reader.uint32();
26455
+ switch (tag >>> 3) {
26456
+ case 1: {
26457
+ if (tag !== 10) {
26458
+ break;
26459
+ }
26460
+ message.functionId = reader.string();
26461
+ continue;
26462
+ }
26463
+ }
26464
+ if ((tag & 7) === 4 || tag === 0) {
26465
+ break;
26466
+ }
26467
+ reader.skip(tag & 7);
26468
+ }
26469
+ return message;
26470
+ },
26471
+ fromJSON(object) {
26472
+ return { functionId: isSet5(object.functionId) ? globalThis.String(object.functionId) : "" };
26473
+ },
26474
+ toJSON(message) {
26475
+ const obj = {};
26476
+ if (message.functionId !== "") {
26477
+ obj.functionId = message.functionId;
26478
+ }
26479
+ return obj;
26480
+ },
26481
+ create(base) {
26482
+ return FunctionGetFlashAuthTokenRequest.fromPartial(base ?? {});
26483
+ },
26484
+ fromPartial(object) {
26485
+ const message = createBaseFunctionGetFlashAuthTokenRequest();
26486
+ message.functionId = object.functionId ?? "";
26487
+ return message;
26488
+ }
26489
+ };
26490
+ function createBaseFunctionGetFlashAuthTokenResponse() {
26491
+ return { token: "" };
26492
+ }
26493
+ var FunctionGetFlashAuthTokenResponse = {
26494
+ encode(message, writer = new BinaryWriter()) {
26495
+ if (message.token !== "") {
26496
+ writer.uint32(10).string(message.token);
26497
+ }
26498
+ return writer;
26499
+ },
26500
+ decode(input, length) {
26501
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
26502
+ let end = length === void 0 ? reader.len : reader.pos + length;
26503
+ const message = createBaseFunctionGetFlashAuthTokenResponse();
26504
+ while (reader.pos < end) {
26505
+ const tag = reader.uint32();
26506
+ switch (tag >>> 3) {
26507
+ case 1: {
26508
+ if (tag !== 10) {
26509
+ break;
26510
+ }
26511
+ message.token = reader.string();
26512
+ continue;
26513
+ }
26514
+ }
26515
+ if ((tag & 7) === 4 || tag === 0) {
26516
+ break;
26517
+ }
26518
+ reader.skip(tag & 7);
26519
+ }
26520
+ return message;
26521
+ },
26522
+ fromJSON(object) {
26523
+ return { token: isSet5(object.token) ? globalThis.String(object.token) : "" };
26524
+ },
26525
+ toJSON(message) {
26526
+ const obj = {};
26527
+ if (message.token !== "") {
26528
+ obj.token = message.token;
26529
+ }
26530
+ return obj;
26531
+ },
26532
+ create(base) {
26533
+ return FunctionGetFlashAuthTokenResponse.fromPartial(base ?? {});
26534
+ },
26535
+ fromPartial(object) {
26536
+ const message = createBaseFunctionGetFlashAuthTokenResponse();
26537
+ message.token = object.token ?? "";
26538
+ return message;
26539
+ }
26540
+ };
25749
26541
  function createBaseFunctionGetInputsItem() {
25750
26542
  return {
25751
26543
  inputId: "",
@@ -26884,7 +27676,7 @@ var FunctionGetSerializedResponse = {
26884
27676
  }
26885
27677
  };
26886
27678
  function createBaseFunctionGetTimeRangeStatsRequest() {
26887
- return { functionId: "", since: void 0, until: void 0, rollup: false };
27679
+ return { functionId: "", since: void 0, until: void 0, rollup: false, containerId: void 0 };
26888
27680
  }
26889
27681
  var FunctionGetTimeRangeStatsRequest = {
26890
27682
  encode(message, writer = new BinaryWriter()) {
@@ -26900,6 +27692,9 @@ var FunctionGetTimeRangeStatsRequest = {
26900
27692
  if (message.rollup !== false) {
26901
27693
  writer.uint32(32).bool(message.rollup);
26902
27694
  }
27695
+ if (message.containerId !== void 0) {
27696
+ writer.uint32(42).string(message.containerId);
27697
+ }
26903
27698
  return writer;
26904
27699
  },
26905
27700
  decode(input, length) {
@@ -26937,6 +27732,13 @@ var FunctionGetTimeRangeStatsRequest = {
26937
27732
  message.rollup = reader.bool();
26938
27733
  continue;
26939
27734
  }
27735
+ case 5: {
27736
+ if (tag !== 42) {
27737
+ break;
27738
+ }
27739
+ message.containerId = reader.string();
27740
+ continue;
27741
+ }
26940
27742
  }
26941
27743
  if ((tag & 7) === 4 || tag === 0) {
26942
27744
  break;
@@ -26950,7 +27752,8 @@ var FunctionGetTimeRangeStatsRequest = {
26950
27752
  functionId: isSet5(object.functionId) ? globalThis.String(object.functionId) : "",
26951
27753
  since: isSet5(object.since) ? fromJsonTimestamp(object.since) : void 0,
26952
27754
  until: isSet5(object.until) ? fromJsonTimestamp(object.until) : void 0,
26953
- rollup: isSet5(object.rollup) ? globalThis.Boolean(object.rollup) : false
27755
+ rollup: isSet5(object.rollup) ? globalThis.Boolean(object.rollup) : false,
27756
+ containerId: isSet5(object.containerId) ? globalThis.String(object.containerId) : void 0
26954
27757
  };
26955
27758
  },
26956
27759
  toJSON(message) {
@@ -26967,6 +27770,9 @@ var FunctionGetTimeRangeStatsRequest = {
26967
27770
  if (message.rollup !== false) {
26968
27771
  obj.rollup = message.rollup;
26969
27772
  }
27773
+ if (message.containerId !== void 0) {
27774
+ obj.containerId = message.containerId;
27775
+ }
26970
27776
  return obj;
26971
27777
  },
26972
27778
  create(base) {
@@ -26978,6 +27784,7 @@ var FunctionGetTimeRangeStatsRequest = {
26978
27784
  message.since = object.since ?? void 0;
26979
27785
  message.until = object.until ?? void 0;
26980
27786
  message.rollup = object.rollup ?? false;
27787
+ message.containerId = object.containerId ?? void 0;
26981
27788
  return message;
26982
27789
  }
26983
27790
  };
@@ -26985,16 +27792,15 @@ function createBaseFunctionGetTimeRangeStatsResponse() {
26985
27792
  return {
26986
27793
  since: void 0,
26987
27794
  until: void 0,
26988
- executionTimeSeconds: void 0,
26989
- queueTimeSeconds: void 0,
26990
- endToEndLatencySeconds: void 0,
26991
- containerStartupTimeSeconds: void 0,
26992
27795
  inputSuccessCount: 0,
26993
27796
  inputFailureCount: 0,
26994
27797
  inputTimeoutCount: 0,
26995
- cpuUtilization: void 0,
26996
- memoryUtilization: void 0,
26997
- gpuUtilization: void 0,
27798
+ inputRunningAtEndCount: 0,
27799
+ inputPercentileStats: {},
27800
+ containerStartedCount: 0,
27801
+ containerErrorCount: 0,
27802
+ containerCreatingAtEndCount: 0,
27803
+ containerPercentileStats: {},
26998
27804
  variantCount: 0
26999
27805
  };
27000
27806
  }
@@ -27006,38 +27812,41 @@ var FunctionGetTimeRangeStatsResponse = {
27006
27812
  if (message.until !== void 0) {
27007
27813
  Timestamp.encode(toTimestamp(message.until), writer.uint32(18).fork()).join();
27008
27814
  }
27009
- if (message.executionTimeSeconds !== void 0) {
27010
- FunctionStatsPercentiles.encode(message.executionTimeSeconds, writer.uint32(26).fork()).join();
27011
- }
27012
- if (message.queueTimeSeconds !== void 0) {
27013
- FunctionStatsPercentiles.encode(message.queueTimeSeconds, writer.uint32(34).fork()).join();
27014
- }
27015
- if (message.endToEndLatencySeconds !== void 0) {
27016
- FunctionStatsPercentiles.encode(message.endToEndLatencySeconds, writer.uint32(42).fork()).join();
27017
- }
27018
- if (message.containerStartupTimeSeconds !== void 0) {
27019
- FunctionStatsPercentiles.encode(message.containerStartupTimeSeconds, writer.uint32(50).fork()).join();
27020
- }
27021
27815
  if (message.inputSuccessCount !== 0) {
27022
- writer.uint32(56).uint64(message.inputSuccessCount);
27816
+ writer.uint32(24).uint64(message.inputSuccessCount);
27023
27817
  }
27024
27818
  if (message.inputFailureCount !== 0) {
27025
- writer.uint32(64).uint64(message.inputFailureCount);
27819
+ writer.uint32(32).uint64(message.inputFailureCount);
27026
27820
  }
27027
27821
  if (message.inputTimeoutCount !== 0) {
27028
- writer.uint32(72).uint64(message.inputTimeoutCount);
27822
+ writer.uint32(40).uint64(message.inputTimeoutCount);
27029
27823
  }
27030
- if (message.cpuUtilization !== void 0) {
27031
- FunctionStatsPercentiles.encode(message.cpuUtilization, writer.uint32(82).fork()).join();
27824
+ if (message.inputRunningAtEndCount !== 0) {
27825
+ writer.uint32(48).uint64(message.inputRunningAtEndCount);
27826
+ }
27827
+ Object.entries(message.inputPercentileStats).forEach(([key, value]) => {
27828
+ FunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry.encode(
27829
+ { key, value },
27830
+ writer.uint32(58).fork()
27831
+ ).join();
27832
+ });
27833
+ if (message.containerStartedCount !== 0) {
27834
+ writer.uint32(64).uint64(message.containerStartedCount);
27032
27835
  }
27033
- if (message.memoryUtilization !== void 0) {
27034
- FunctionStatsPercentiles.encode(message.memoryUtilization, writer.uint32(90).fork()).join();
27836
+ if (message.containerErrorCount !== 0) {
27837
+ writer.uint32(72).uint64(message.containerErrorCount);
27035
27838
  }
27036
- if (message.gpuUtilization !== void 0) {
27037
- FunctionStatsPercentiles.encode(message.gpuUtilization, writer.uint32(98).fork()).join();
27839
+ if (message.containerCreatingAtEndCount !== 0) {
27840
+ writer.uint32(80).uint64(message.containerCreatingAtEndCount);
27038
27841
  }
27842
+ Object.entries(message.containerPercentileStats).forEach(([key, value]) => {
27843
+ FunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry.encode(
27844
+ { key, value },
27845
+ writer.uint32(90).fork()
27846
+ ).join();
27847
+ });
27039
27848
  if (message.variantCount !== 0) {
27040
- writer.uint32(104).uint32(message.variantCount);
27849
+ writer.uint32(96).uint32(message.variantCount);
27041
27850
  }
27042
27851
  return writer;
27043
27852
  },
@@ -27063,77 +27872,79 @@ var FunctionGetTimeRangeStatsResponse = {
27063
27872
  continue;
27064
27873
  }
27065
27874
  case 3: {
27066
- if (tag !== 26) {
27875
+ if (tag !== 24) {
27067
27876
  break;
27068
27877
  }
27069
- message.executionTimeSeconds = FunctionStatsPercentiles.decode(reader, reader.uint32());
27878
+ message.inputSuccessCount = longToNumber2(reader.uint64());
27070
27879
  continue;
27071
27880
  }
27072
27881
  case 4: {
27073
- if (tag !== 34) {
27882
+ if (tag !== 32) {
27074
27883
  break;
27075
27884
  }
27076
- message.queueTimeSeconds = FunctionStatsPercentiles.decode(reader, reader.uint32());
27885
+ message.inputFailureCount = longToNumber2(reader.uint64());
27077
27886
  continue;
27078
27887
  }
27079
27888
  case 5: {
27080
- if (tag !== 42) {
27889
+ if (tag !== 40) {
27081
27890
  break;
27082
27891
  }
27083
- message.endToEndLatencySeconds = FunctionStatsPercentiles.decode(reader, reader.uint32());
27892
+ message.inputTimeoutCount = longToNumber2(reader.uint64());
27084
27893
  continue;
27085
27894
  }
27086
27895
  case 6: {
27087
- if (tag !== 50) {
27896
+ if (tag !== 48) {
27088
27897
  break;
27089
27898
  }
27090
- message.containerStartupTimeSeconds = FunctionStatsPercentiles.decode(reader, reader.uint32());
27899
+ message.inputRunningAtEndCount = longToNumber2(reader.uint64());
27091
27900
  continue;
27092
27901
  }
27093
27902
  case 7: {
27094
- if (tag !== 56) {
27903
+ if (tag !== 58) {
27095
27904
  break;
27096
27905
  }
27097
- message.inputSuccessCount = longToNumber2(reader.uint64());
27906
+ const entry7 = FunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry.decode(reader, reader.uint32());
27907
+ if (entry7.value !== void 0) {
27908
+ message.inputPercentileStats[entry7.key] = entry7.value;
27909
+ }
27098
27910
  continue;
27099
27911
  }
27100
27912
  case 8: {
27101
27913
  if (tag !== 64) {
27102
27914
  break;
27103
27915
  }
27104
- message.inputFailureCount = longToNumber2(reader.uint64());
27916
+ message.containerStartedCount = longToNumber2(reader.uint64());
27105
27917
  continue;
27106
27918
  }
27107
27919
  case 9: {
27108
27920
  if (tag !== 72) {
27109
27921
  break;
27110
27922
  }
27111
- message.inputTimeoutCount = longToNumber2(reader.uint64());
27923
+ message.containerErrorCount = longToNumber2(reader.uint64());
27112
27924
  continue;
27113
27925
  }
27114
27926
  case 10: {
27115
- if (tag !== 82) {
27927
+ if (tag !== 80) {
27116
27928
  break;
27117
27929
  }
27118
- message.cpuUtilization = FunctionStatsPercentiles.decode(reader, reader.uint32());
27930
+ message.containerCreatingAtEndCount = longToNumber2(reader.uint64());
27119
27931
  continue;
27120
27932
  }
27121
27933
  case 11: {
27122
27934
  if (tag !== 90) {
27123
27935
  break;
27124
27936
  }
27125
- message.memoryUtilization = FunctionStatsPercentiles.decode(reader, reader.uint32());
27126
- continue;
27127
- }
27128
- case 12: {
27129
- if (tag !== 98) {
27130
- break;
27937
+ const entry11 = FunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry.decode(
27938
+ reader,
27939
+ reader.uint32()
27940
+ );
27941
+ if (entry11.value !== void 0) {
27942
+ message.containerPercentileStats[entry11.key] = entry11.value;
27131
27943
  }
27132
- message.gpuUtilization = FunctionStatsPercentiles.decode(reader, reader.uint32());
27133
27944
  continue;
27134
27945
  }
27135
- case 13: {
27136
- if (tag !== 104) {
27946
+ case 12: {
27947
+ if (tag !== 96) {
27137
27948
  break;
27138
27949
  }
27139
27950
  message.variantCount = reader.uint32();
@@ -27151,16 +27962,27 @@ var FunctionGetTimeRangeStatsResponse = {
27151
27962
  return {
27152
27963
  since: isSet5(object.since) ? fromJsonTimestamp(object.since) : void 0,
27153
27964
  until: isSet5(object.until) ? fromJsonTimestamp(object.until) : void 0,
27154
- executionTimeSeconds: isSet5(object.executionTimeSeconds) ? FunctionStatsPercentiles.fromJSON(object.executionTimeSeconds) : void 0,
27155
- queueTimeSeconds: isSet5(object.queueTimeSeconds) ? FunctionStatsPercentiles.fromJSON(object.queueTimeSeconds) : void 0,
27156
- endToEndLatencySeconds: isSet5(object.endToEndLatencySeconds) ? FunctionStatsPercentiles.fromJSON(object.endToEndLatencySeconds) : void 0,
27157
- containerStartupTimeSeconds: isSet5(object.containerStartupTimeSeconds) ? FunctionStatsPercentiles.fromJSON(object.containerStartupTimeSeconds) : void 0,
27158
27965
  inputSuccessCount: isSet5(object.inputSuccessCount) ? globalThis.Number(object.inputSuccessCount) : 0,
27159
27966
  inputFailureCount: isSet5(object.inputFailureCount) ? globalThis.Number(object.inputFailureCount) : 0,
27160
27967
  inputTimeoutCount: isSet5(object.inputTimeoutCount) ? globalThis.Number(object.inputTimeoutCount) : 0,
27161
- cpuUtilization: isSet5(object.cpuUtilization) ? FunctionStatsPercentiles.fromJSON(object.cpuUtilization) : void 0,
27162
- memoryUtilization: isSet5(object.memoryUtilization) ? FunctionStatsPercentiles.fromJSON(object.memoryUtilization) : void 0,
27163
- gpuUtilization: isSet5(object.gpuUtilization) ? FunctionStatsPercentiles.fromJSON(object.gpuUtilization) : void 0,
27968
+ inputRunningAtEndCount: isSet5(object.inputRunningAtEndCount) ? globalThis.Number(object.inputRunningAtEndCount) : 0,
27969
+ inputPercentileStats: isObject2(object.inputPercentileStats) ? Object.entries(object.inputPercentileStats).reduce(
27970
+ (acc, [key, value]) => {
27971
+ acc[key] = StatsPercentileDistribution.fromJSON(value);
27972
+ return acc;
27973
+ },
27974
+ {}
27975
+ ) : {},
27976
+ containerStartedCount: isSet5(object.containerStartedCount) ? globalThis.Number(object.containerStartedCount) : 0,
27977
+ containerErrorCount: isSet5(object.containerErrorCount) ? globalThis.Number(object.containerErrorCount) : 0,
27978
+ containerCreatingAtEndCount: isSet5(object.containerCreatingAtEndCount) ? globalThis.Number(object.containerCreatingAtEndCount) : 0,
27979
+ containerPercentileStats: isObject2(object.containerPercentileStats) ? Object.entries(object.containerPercentileStats).reduce(
27980
+ (acc, [key, value]) => {
27981
+ acc[key] = StatsPercentileDistribution.fromJSON(value);
27982
+ return acc;
27983
+ },
27984
+ {}
27985
+ ) : {},
27164
27986
  variantCount: isSet5(object.variantCount) ? globalThis.Number(object.variantCount) : 0
27165
27987
  };
27166
27988
  },
@@ -27172,18 +27994,6 @@ var FunctionGetTimeRangeStatsResponse = {
27172
27994
  if (message.until !== void 0) {
27173
27995
  obj.until = message.until.toISOString();
27174
27996
  }
27175
- if (message.executionTimeSeconds !== void 0) {
27176
- obj.executionTimeSeconds = FunctionStatsPercentiles.toJSON(message.executionTimeSeconds);
27177
- }
27178
- if (message.queueTimeSeconds !== void 0) {
27179
- obj.queueTimeSeconds = FunctionStatsPercentiles.toJSON(message.queueTimeSeconds);
27180
- }
27181
- if (message.endToEndLatencySeconds !== void 0) {
27182
- obj.endToEndLatencySeconds = FunctionStatsPercentiles.toJSON(message.endToEndLatencySeconds);
27183
- }
27184
- if (message.containerStartupTimeSeconds !== void 0) {
27185
- obj.containerStartupTimeSeconds = FunctionStatsPercentiles.toJSON(message.containerStartupTimeSeconds);
27186
- }
27187
27997
  if (message.inputSuccessCount !== 0) {
27188
27998
  obj.inputSuccessCount = Math.round(message.inputSuccessCount);
27189
27999
  }
@@ -27193,14 +28003,35 @@ var FunctionGetTimeRangeStatsResponse = {
27193
28003
  if (message.inputTimeoutCount !== 0) {
27194
28004
  obj.inputTimeoutCount = Math.round(message.inputTimeoutCount);
27195
28005
  }
27196
- if (message.cpuUtilization !== void 0) {
27197
- obj.cpuUtilization = FunctionStatsPercentiles.toJSON(message.cpuUtilization);
28006
+ if (message.inputRunningAtEndCount !== 0) {
28007
+ obj.inputRunningAtEndCount = Math.round(message.inputRunningAtEndCount);
28008
+ }
28009
+ if (message.inputPercentileStats) {
28010
+ const entries = Object.entries(message.inputPercentileStats);
28011
+ if (entries.length > 0) {
28012
+ obj.inputPercentileStats = {};
28013
+ entries.forEach(([k, v]) => {
28014
+ obj.inputPercentileStats[k] = StatsPercentileDistribution.toJSON(v);
28015
+ });
28016
+ }
28017
+ }
28018
+ if (message.containerStartedCount !== 0) {
28019
+ obj.containerStartedCount = Math.round(message.containerStartedCount);
27198
28020
  }
27199
- if (message.memoryUtilization !== void 0) {
27200
- obj.memoryUtilization = FunctionStatsPercentiles.toJSON(message.memoryUtilization);
28021
+ if (message.containerErrorCount !== 0) {
28022
+ obj.containerErrorCount = Math.round(message.containerErrorCount);
27201
28023
  }
27202
- if (message.gpuUtilization !== void 0) {
27203
- obj.gpuUtilization = FunctionStatsPercentiles.toJSON(message.gpuUtilization);
28024
+ if (message.containerCreatingAtEndCount !== 0) {
28025
+ obj.containerCreatingAtEndCount = Math.round(message.containerCreatingAtEndCount);
28026
+ }
28027
+ if (message.containerPercentileStats) {
28028
+ const entries = Object.entries(message.containerPercentileStats);
28029
+ if (entries.length > 0) {
28030
+ obj.containerPercentileStats = {};
28031
+ entries.forEach(([k, v]) => {
28032
+ obj.containerPercentileStats[k] = StatsPercentileDistribution.toJSON(v);
28033
+ });
28034
+ }
27204
28035
  }
27205
28036
  if (message.variantCount !== 0) {
27206
28037
  obj.variantCount = Math.round(message.variantCount);
@@ -27214,20 +28045,165 @@ var FunctionGetTimeRangeStatsResponse = {
27214
28045
  const message = createBaseFunctionGetTimeRangeStatsResponse();
27215
28046
  message.since = object.since ?? void 0;
27216
28047
  message.until = object.until ?? void 0;
27217
- message.executionTimeSeconds = object.executionTimeSeconds !== void 0 && object.executionTimeSeconds !== null ? FunctionStatsPercentiles.fromPartial(object.executionTimeSeconds) : void 0;
27218
- message.queueTimeSeconds = object.queueTimeSeconds !== void 0 && object.queueTimeSeconds !== null ? FunctionStatsPercentiles.fromPartial(object.queueTimeSeconds) : void 0;
27219
- message.endToEndLatencySeconds = object.endToEndLatencySeconds !== void 0 && object.endToEndLatencySeconds !== null ? FunctionStatsPercentiles.fromPartial(object.endToEndLatencySeconds) : void 0;
27220
- message.containerStartupTimeSeconds = object.containerStartupTimeSeconds !== void 0 && object.containerStartupTimeSeconds !== null ? FunctionStatsPercentiles.fromPartial(object.containerStartupTimeSeconds) : void 0;
27221
28048
  message.inputSuccessCount = object.inputSuccessCount ?? 0;
27222
28049
  message.inputFailureCount = object.inputFailureCount ?? 0;
27223
28050
  message.inputTimeoutCount = object.inputTimeoutCount ?? 0;
27224
- message.cpuUtilization = object.cpuUtilization !== void 0 && object.cpuUtilization !== null ? FunctionStatsPercentiles.fromPartial(object.cpuUtilization) : void 0;
27225
- message.memoryUtilization = object.memoryUtilization !== void 0 && object.memoryUtilization !== null ? FunctionStatsPercentiles.fromPartial(object.memoryUtilization) : void 0;
27226
- message.gpuUtilization = object.gpuUtilization !== void 0 && object.gpuUtilization !== null ? FunctionStatsPercentiles.fromPartial(object.gpuUtilization) : void 0;
28051
+ message.inputRunningAtEndCount = object.inputRunningAtEndCount ?? 0;
28052
+ message.inputPercentileStats = Object.entries(object.inputPercentileStats ?? {}).reduce((acc, [key, value]) => {
28053
+ if (value !== void 0) {
28054
+ acc[key] = StatsPercentileDistribution.fromPartial(value);
28055
+ }
28056
+ return acc;
28057
+ }, {});
28058
+ message.containerStartedCount = object.containerStartedCount ?? 0;
28059
+ message.containerErrorCount = object.containerErrorCount ?? 0;
28060
+ message.containerCreatingAtEndCount = object.containerCreatingAtEndCount ?? 0;
28061
+ message.containerPercentileStats = Object.entries(object.containerPercentileStats ?? {}).reduce((acc, [key, value]) => {
28062
+ if (value !== void 0) {
28063
+ acc[key] = StatsPercentileDistribution.fromPartial(value);
28064
+ }
28065
+ return acc;
28066
+ }, {});
27227
28067
  message.variantCount = object.variantCount ?? 0;
27228
28068
  return message;
27229
28069
  }
27230
28070
  };
28071
+ function createBaseFunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry() {
28072
+ return { key: "", value: void 0 };
28073
+ }
28074
+ var FunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry = {
28075
+ encode(message, writer = new BinaryWriter()) {
28076
+ if (message.key !== "") {
28077
+ writer.uint32(10).string(message.key);
28078
+ }
28079
+ if (message.value !== void 0) {
28080
+ StatsPercentileDistribution.encode(message.value, writer.uint32(18).fork()).join();
28081
+ }
28082
+ return writer;
28083
+ },
28084
+ decode(input, length) {
28085
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
28086
+ let end = length === void 0 ? reader.len : reader.pos + length;
28087
+ const message = createBaseFunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry();
28088
+ while (reader.pos < end) {
28089
+ const tag = reader.uint32();
28090
+ switch (tag >>> 3) {
28091
+ case 1: {
28092
+ if (tag !== 10) {
28093
+ break;
28094
+ }
28095
+ message.key = reader.string();
28096
+ continue;
28097
+ }
28098
+ case 2: {
28099
+ if (tag !== 18) {
28100
+ break;
28101
+ }
28102
+ message.value = StatsPercentileDistribution.decode(reader, reader.uint32());
28103
+ continue;
28104
+ }
28105
+ }
28106
+ if ((tag & 7) === 4 || tag === 0) {
28107
+ break;
28108
+ }
28109
+ reader.skip(tag & 7);
28110
+ }
28111
+ return message;
28112
+ },
28113
+ fromJSON(object) {
28114
+ return {
28115
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
28116
+ value: isSet5(object.value) ? StatsPercentileDistribution.fromJSON(object.value) : void 0
28117
+ };
28118
+ },
28119
+ toJSON(message) {
28120
+ const obj = {};
28121
+ if (message.key !== "") {
28122
+ obj.key = message.key;
28123
+ }
28124
+ if (message.value !== void 0) {
28125
+ obj.value = StatsPercentileDistribution.toJSON(message.value);
28126
+ }
28127
+ return obj;
28128
+ },
28129
+ create(base) {
28130
+ return FunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry.fromPartial(base ?? {});
28131
+ },
28132
+ fromPartial(object) {
28133
+ const message = createBaseFunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry();
28134
+ message.key = object.key ?? "";
28135
+ message.value = object.value !== void 0 && object.value !== null ? StatsPercentileDistribution.fromPartial(object.value) : void 0;
28136
+ return message;
28137
+ }
28138
+ };
28139
+ function createBaseFunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry() {
28140
+ return { key: "", value: void 0 };
28141
+ }
28142
+ var FunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry = {
28143
+ encode(message, writer = new BinaryWriter()) {
28144
+ if (message.key !== "") {
28145
+ writer.uint32(10).string(message.key);
28146
+ }
28147
+ if (message.value !== void 0) {
28148
+ StatsPercentileDistribution.encode(message.value, writer.uint32(18).fork()).join();
28149
+ }
28150
+ return writer;
28151
+ },
28152
+ decode(input, length) {
28153
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
28154
+ let end = length === void 0 ? reader.len : reader.pos + length;
28155
+ const message = createBaseFunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry();
28156
+ while (reader.pos < end) {
28157
+ const tag = reader.uint32();
28158
+ switch (tag >>> 3) {
28159
+ case 1: {
28160
+ if (tag !== 10) {
28161
+ break;
28162
+ }
28163
+ message.key = reader.string();
28164
+ continue;
28165
+ }
28166
+ case 2: {
28167
+ if (tag !== 18) {
28168
+ break;
28169
+ }
28170
+ message.value = StatsPercentileDistribution.decode(reader, reader.uint32());
28171
+ continue;
28172
+ }
28173
+ }
28174
+ if ((tag & 7) === 4 || tag === 0) {
28175
+ break;
28176
+ }
28177
+ reader.skip(tag & 7);
28178
+ }
28179
+ return message;
28180
+ },
28181
+ fromJSON(object) {
28182
+ return {
28183
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
28184
+ value: isSet5(object.value) ? StatsPercentileDistribution.fromJSON(object.value) : void 0
28185
+ };
28186
+ },
28187
+ toJSON(message) {
28188
+ const obj = {};
28189
+ if (message.key !== "") {
28190
+ obj.key = message.key;
28191
+ }
28192
+ if (message.value !== void 0) {
28193
+ obj.value = StatsPercentileDistribution.toJSON(message.value);
28194
+ }
28195
+ return obj;
28196
+ },
28197
+ create(base) {
28198
+ return FunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry.fromPartial(base ?? {});
28199
+ },
28200
+ fromPartial(object) {
28201
+ const message = createBaseFunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry();
28202
+ message.key = object.key ?? "";
28203
+ message.value = object.value !== void 0 && object.value !== null ? StatsPercentileDistribution.fromPartial(object.value) : void 0;
28204
+ return message;
28205
+ }
28206
+ };
27231
28207
  function createBaseFunctionHandleMetadata() {
27232
28208
  return {
27233
28209
  functionName: "",
@@ -29888,74 +30864,6 @@ var FunctionStats = {
29888
30864
  return message;
29889
30865
  }
29890
30866
  };
29891
- function createBaseFunctionStatsPercentiles() {
29892
- return { p50: 0, p90: 0 };
29893
- }
29894
- var FunctionStatsPercentiles = {
29895
- encode(message, writer = new BinaryWriter()) {
29896
- if (message.p50 !== 0) {
29897
- writer.uint32(9).double(message.p50);
29898
- }
29899
- if (message.p90 !== 0) {
29900
- writer.uint32(17).double(message.p90);
29901
- }
29902
- return writer;
29903
- },
29904
- decode(input, length) {
29905
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
29906
- let end = length === void 0 ? reader.len : reader.pos + length;
29907
- const message = createBaseFunctionStatsPercentiles();
29908
- while (reader.pos < end) {
29909
- const tag = reader.uint32();
29910
- switch (tag >>> 3) {
29911
- case 1: {
29912
- if (tag !== 9) {
29913
- break;
29914
- }
29915
- message.p50 = reader.double();
29916
- continue;
29917
- }
29918
- case 2: {
29919
- if (tag !== 17) {
29920
- break;
29921
- }
29922
- message.p90 = reader.double();
29923
- continue;
29924
- }
29925
- }
29926
- if ((tag & 7) === 4 || tag === 0) {
29927
- break;
29928
- }
29929
- reader.skip(tag & 7);
29930
- }
29931
- return message;
29932
- },
29933
- fromJSON(object) {
29934
- return {
29935
- p50: isSet5(object.p50) ? globalThis.Number(object.p50) : 0,
29936
- p90: isSet5(object.p90) ? globalThis.Number(object.p90) : 0
29937
- };
29938
- },
29939
- toJSON(message) {
29940
- const obj = {};
29941
- if (message.p50 !== 0) {
29942
- obj.p50 = message.p50;
29943
- }
29944
- if (message.p90 !== 0) {
29945
- obj.p90 = message.p90;
29946
- }
29947
- return obj;
29948
- },
29949
- create(base) {
29950
- return FunctionStatsPercentiles.fromPartial(base ?? {});
29951
- },
29952
- fromPartial(object) {
29953
- const message = createBaseFunctionStatsPercentiles();
29954
- message.p50 = object.p50 ?? 0;
29955
- message.p90 = object.p90 ?? 0;
29956
- return message;
29957
- }
29958
- };
29959
30867
  function createBaseFunctionUpdateSchedulingParamsRequest() {
29960
30868
  return { functionId: "", warmPoolSizeOverride: 0, settings: void 0 };
29961
30869
  }
@@ -30644,7 +31552,8 @@ function createBaseImage() {
30644
31552
  runtimeDebug: false,
30645
31553
  buildFunction: void 0,
30646
31554
  buildArgs: {},
30647
- volumeMounts: []
31555
+ volumeMounts: [],
31556
+ arch: 0
30648
31557
  };
30649
31558
  }
30650
31559
  var Image = {
@@ -30694,6 +31603,9 @@ var Image = {
30694
31603
  for (const v of message.volumeMounts) {
30695
31604
  VolumeMount.encode(v, writer.uint32(186).fork()).join();
30696
31605
  }
31606
+ if (message.arch !== 0) {
31607
+ writer.uint32(192).int32(message.arch);
31608
+ }
30697
31609
  return writer;
30698
31610
  },
30699
31611
  decode(input, length) {
@@ -30811,6 +31723,13 @@ var Image = {
30811
31723
  message.volumeMounts.push(VolumeMount.decode(reader, reader.uint32()));
30812
31724
  continue;
30813
31725
  }
31726
+ case 24: {
31727
+ if (tag !== 192) {
31728
+ break;
31729
+ }
31730
+ message.arch = reader.int32();
31731
+ continue;
31732
+ }
30814
31733
  }
30815
31734
  if ((tag & 7) === 4 || tag === 0) {
30816
31735
  break;
@@ -30838,7 +31757,8 @@ var Image = {
30838
31757
  acc[key] = String(value);
30839
31758
  return acc;
30840
31759
  }, {}) : {},
30841
- volumeMounts: globalThis.Array.isArray(object?.volumeMounts) ? object.volumeMounts.map((e) => VolumeMount.fromJSON(e)) : []
31760
+ volumeMounts: globalThis.Array.isArray(object?.volumeMounts) ? object.volumeMounts.map((e) => VolumeMount.fromJSON(e)) : [],
31761
+ arch: isSet5(object.arch) ? archFromJSON(object.arch) : 0
30842
31762
  };
30843
31763
  },
30844
31764
  toJSON(message) {
@@ -30894,6 +31814,9 @@ var Image = {
30894
31814
  if (message.volumeMounts?.length) {
30895
31815
  obj.volumeMounts = message.volumeMounts.map((e) => VolumeMount.toJSON(e));
30896
31816
  }
31817
+ if (message.arch !== 0) {
31818
+ obj.arch = archToJSON(message.arch);
31819
+ }
30897
31820
  return obj;
30898
31821
  },
30899
31822
  create(base) {
@@ -30924,6 +31847,7 @@ var Image = {
30924
31847
  {}
30925
31848
  );
30926
31849
  message.volumeMounts = object.volumeMounts?.map((e) => VolumeMount.fromPartial(e)) || [];
31850
+ message.arch = object.arch ?? 0;
30927
31851
  return message;
30928
31852
  }
30929
31853
  };
@@ -35971,6 +36895,157 @@ var ObjectDependency = {
35971
36895
  return message;
35972
36896
  }
35973
36897
  };
36898
+ function createBaseOutboundPolicy() {
36899
+ return { headerReplacements: [] };
36900
+ }
36901
+ var OutboundPolicy = {
36902
+ encode(message, writer = new BinaryWriter()) {
36903
+ for (const v of message.headerReplacements) {
36904
+ OutboundPolicy_HeaderReplacement.encode(v, writer.uint32(10).fork()).join();
36905
+ }
36906
+ return writer;
36907
+ },
36908
+ decode(input, length) {
36909
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
36910
+ let end = length === void 0 ? reader.len : reader.pos + length;
36911
+ const message = createBaseOutboundPolicy();
36912
+ while (reader.pos < end) {
36913
+ const tag = reader.uint32();
36914
+ switch (tag >>> 3) {
36915
+ case 1: {
36916
+ if (tag !== 10) {
36917
+ break;
36918
+ }
36919
+ message.headerReplacements.push(OutboundPolicy_HeaderReplacement.decode(reader, reader.uint32()));
36920
+ continue;
36921
+ }
36922
+ }
36923
+ if ((tag & 7) === 4 || tag === 0) {
36924
+ break;
36925
+ }
36926
+ reader.skip(tag & 7);
36927
+ }
36928
+ return message;
36929
+ },
36930
+ fromJSON(object) {
36931
+ return {
36932
+ headerReplacements: globalThis.Array.isArray(object?.headerReplacements) ? object.headerReplacements.map((e) => OutboundPolicy_HeaderReplacement.fromJSON(e)) : []
36933
+ };
36934
+ },
36935
+ toJSON(message) {
36936
+ const obj = {};
36937
+ if (message.headerReplacements?.length) {
36938
+ obj.headerReplacements = message.headerReplacements.map((e) => OutboundPolicy_HeaderReplacement.toJSON(e));
36939
+ }
36940
+ return obj;
36941
+ },
36942
+ create(base) {
36943
+ return OutboundPolicy.fromPartial(base ?? {});
36944
+ },
36945
+ fromPartial(object) {
36946
+ const message = createBaseOutboundPolicy();
36947
+ message.headerReplacements = object.headerReplacements?.map((e) => OutboundPolicy_HeaderReplacement.fromPartial(e)) || [];
36948
+ return message;
36949
+ }
36950
+ };
36951
+ function createBaseOutboundPolicy_HeaderReplacement() {
36952
+ return { domain: "", headerName: "", headerValue: "", secretId: "" };
36953
+ }
36954
+ var OutboundPolicy_HeaderReplacement = {
36955
+ encode(message, writer = new BinaryWriter()) {
36956
+ if (message.domain !== "") {
36957
+ writer.uint32(10).string(message.domain);
36958
+ }
36959
+ if (message.headerName !== "") {
36960
+ writer.uint32(18).string(message.headerName);
36961
+ }
36962
+ if (message.headerValue !== "") {
36963
+ writer.uint32(26).string(message.headerValue);
36964
+ }
36965
+ if (message.secretId !== "") {
36966
+ writer.uint32(34).string(message.secretId);
36967
+ }
36968
+ return writer;
36969
+ },
36970
+ decode(input, length) {
36971
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
36972
+ let end = length === void 0 ? reader.len : reader.pos + length;
36973
+ const message = createBaseOutboundPolicy_HeaderReplacement();
36974
+ while (reader.pos < end) {
36975
+ const tag = reader.uint32();
36976
+ switch (tag >>> 3) {
36977
+ case 1: {
36978
+ if (tag !== 10) {
36979
+ break;
36980
+ }
36981
+ message.domain = reader.string();
36982
+ continue;
36983
+ }
36984
+ case 2: {
36985
+ if (tag !== 18) {
36986
+ break;
36987
+ }
36988
+ message.headerName = reader.string();
36989
+ continue;
36990
+ }
36991
+ case 3: {
36992
+ if (tag !== 26) {
36993
+ break;
36994
+ }
36995
+ message.headerValue = reader.string();
36996
+ continue;
36997
+ }
36998
+ case 4: {
36999
+ if (tag !== 34) {
37000
+ break;
37001
+ }
37002
+ message.secretId = reader.string();
37003
+ continue;
37004
+ }
37005
+ }
37006
+ if ((tag & 7) === 4 || tag === 0) {
37007
+ break;
37008
+ }
37009
+ reader.skip(tag & 7);
37010
+ }
37011
+ return message;
37012
+ },
37013
+ fromJSON(object) {
37014
+ return {
37015
+ domain: isSet5(object.domain) ? globalThis.String(object.domain) : "",
37016
+ headerName: isSet5(object.headerName) ? globalThis.String(object.headerName) : "",
37017
+ headerValue: isSet5(object.headerValue) ? globalThis.String(object.headerValue) : "",
37018
+ secretId: isSet5(object.secretId) ? globalThis.String(object.secretId) : ""
37019
+ };
37020
+ },
37021
+ toJSON(message) {
37022
+ const obj = {};
37023
+ if (message.domain !== "") {
37024
+ obj.domain = message.domain;
37025
+ }
37026
+ if (message.headerName !== "") {
37027
+ obj.headerName = message.headerName;
37028
+ }
37029
+ if (message.headerValue !== "") {
37030
+ obj.headerValue = message.headerValue;
37031
+ }
37032
+ if (message.secretId !== "") {
37033
+ obj.secretId = message.secretId;
37034
+ }
37035
+ return obj;
37036
+ },
37037
+ create(base) {
37038
+ return OutboundPolicy_HeaderReplacement.fromPartial(base ?? {});
37039
+ },
37040
+ fromPartial(object) {
37041
+ const message = createBaseOutboundPolicy_HeaderReplacement();
37042
+ message.domain = object.domain ?? "";
37043
+ message.headerName = object.headerName ?? "";
37044
+ message.headerValue = object.headerValue ?? "";
37045
+ message.secretId = object.secretId ?? "";
37046
+ return message;
37047
+ }
37048
+ };
35974
37049
  function createBasePTYInfo() {
35975
37050
  return {
35976
37051
  enabled: false,
@@ -39661,7 +40736,8 @@ function createBaseSandbox() {
39661
40736
  includeOidcIdentityToken: false,
39662
40737
  readinessProbe: void 0,
39663
40738
  inboundCidrAllowlist: [],
39664
- environmentVariables: void 0
40739
+ environmentVariables: void 0,
40740
+ outboundPolicy: void 0
39665
40741
  };
39666
40742
  }
39667
40743
  var Sandbox = {
@@ -39783,6 +40859,9 @@ var Sandbox = {
39783
40859
  if (message.environmentVariables !== void 0) {
39784
40860
  StringMap.encode(message.environmentVariables, writer.uint32(322).fork()).join();
39785
40861
  }
40862
+ if (message.outboundPolicy !== void 0) {
40863
+ OutboundPolicy.encode(message.outboundPolicy, writer.uint32(338).fork()).join();
40864
+ }
39786
40865
  return writer;
39787
40866
  },
39788
40867
  decode(input, length) {
@@ -40071,6 +41150,13 @@ var Sandbox = {
40071
41150
  message.environmentVariables = StringMap.decode(reader, reader.uint32());
40072
41151
  continue;
40073
41152
  }
41153
+ case 42: {
41154
+ if (tag !== 338) {
41155
+ break;
41156
+ }
41157
+ message.outboundPolicy = OutboundPolicy.decode(reader, reader.uint32());
41158
+ continue;
41159
+ }
40074
41160
  }
40075
41161
  if ((tag & 7) === 4 || tag === 0) {
40076
41162
  break;
@@ -40125,7 +41211,8 @@ var Sandbox = {
40125
41211
  includeOidcIdentityToken: isSet5(object.includeOidcIdentityToken) ? globalThis.Boolean(object.includeOidcIdentityToken) : false,
40126
41212
  readinessProbe: isSet5(object.readinessProbe) ? Probe.fromJSON(object.readinessProbe) : void 0,
40127
41213
  inboundCidrAllowlist: globalThis.Array.isArray(object?.inboundCidrAllowlist) ? object.inboundCidrAllowlist.map((e) => globalThis.String(e)) : [],
40128
- environmentVariables: isSet5(object.environmentVariables) ? StringMap.fromJSON(object.environmentVariables) : void 0
41214
+ environmentVariables: isSet5(object.environmentVariables) ? StringMap.fromJSON(object.environmentVariables) : void 0,
41215
+ outboundPolicy: isSet5(object.outboundPolicy) ? OutboundPolicy.fromJSON(object.outboundPolicy) : void 0
40129
41216
  };
40130
41217
  },
40131
41218
  toJSON(message) {
@@ -40259,6 +41346,9 @@ var Sandbox = {
40259
41346
  if (message.environmentVariables !== void 0) {
40260
41347
  obj.environmentVariables = StringMap.toJSON(message.environmentVariables);
40261
41348
  }
41349
+ if (message.outboundPolicy !== void 0) {
41350
+ obj.outboundPolicy = OutboundPolicy.toJSON(message.outboundPolicy);
41351
+ }
40262
41352
  return obj;
40263
41353
  },
40264
41354
  create(base) {
@@ -40318,6 +41408,7 @@ var Sandbox = {
40318
41408
  message.readinessProbe = object.readinessProbe !== void 0 && object.readinessProbe !== null ? Probe.fromPartial(object.readinessProbe) : void 0;
40319
41409
  message.inboundCidrAllowlist = object.inboundCidrAllowlist?.map((e) => e) || [];
40320
41410
  message.environmentVariables = object.environmentVariables !== void 0 && object.environmentVariables !== null ? StringMap.fromPartial(object.environmentVariables) : void 0;
41411
+ message.outboundPolicy = object.outboundPolicy !== void 0 && object.outboundPolicy !== null ? OutboundPolicy.fromPartial(object.outboundPolicy) : void 0;
40321
41412
  return message;
40322
41413
  }
40323
41414
  };
@@ -40457,6 +41548,287 @@ var Sandbox_ExperimentalOptionsV2Entry = {
40457
41548
  return message;
40458
41549
  }
40459
41550
  };
41551
+ function createBaseSandboxContainerCreateV2Request() {
41552
+ return {
41553
+ sandboxId: "",
41554
+ containerName: "",
41555
+ definition: void 0,
41556
+ ephemeralSecrets: void 0,
41557
+ cloudBucketMountCredentials: {}
41558
+ };
41559
+ }
41560
+ var SandboxContainerCreateV2Request = {
41561
+ encode(message, writer = new BinaryWriter()) {
41562
+ if (message.sandboxId !== "") {
41563
+ writer.uint32(10).string(message.sandboxId);
41564
+ }
41565
+ if (message.containerName !== "") {
41566
+ writer.uint32(18).string(message.containerName);
41567
+ }
41568
+ if (message.definition !== void 0) {
41569
+ Sandbox.encode(message.definition, writer.uint32(26).fork()).join();
41570
+ }
41571
+ if (message.ephemeralSecrets !== void 0) {
41572
+ StringMap.encode(message.ephemeralSecrets, writer.uint32(34).fork()).join();
41573
+ }
41574
+ Object.entries(message.cloudBucketMountCredentials).forEach(([key, value]) => {
41575
+ SandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry.encode(
41576
+ { key, value },
41577
+ writer.uint32(42).fork()
41578
+ ).join();
41579
+ });
41580
+ return writer;
41581
+ },
41582
+ decode(input, length) {
41583
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
41584
+ let end = length === void 0 ? reader.len : reader.pos + length;
41585
+ const message = createBaseSandboxContainerCreateV2Request();
41586
+ while (reader.pos < end) {
41587
+ const tag = reader.uint32();
41588
+ switch (tag >>> 3) {
41589
+ case 1: {
41590
+ if (tag !== 10) {
41591
+ break;
41592
+ }
41593
+ message.sandboxId = reader.string();
41594
+ continue;
41595
+ }
41596
+ case 2: {
41597
+ if (tag !== 18) {
41598
+ break;
41599
+ }
41600
+ message.containerName = reader.string();
41601
+ continue;
41602
+ }
41603
+ case 3: {
41604
+ if (tag !== 26) {
41605
+ break;
41606
+ }
41607
+ message.definition = Sandbox.decode(reader, reader.uint32());
41608
+ continue;
41609
+ }
41610
+ case 4: {
41611
+ if (tag !== 34) {
41612
+ break;
41613
+ }
41614
+ message.ephemeralSecrets = StringMap.decode(reader, reader.uint32());
41615
+ continue;
41616
+ }
41617
+ case 5: {
41618
+ if (tag !== 42) {
41619
+ break;
41620
+ }
41621
+ const entry5 = SandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry.decode(
41622
+ reader,
41623
+ reader.uint32()
41624
+ );
41625
+ if (entry5.value !== void 0) {
41626
+ message.cloudBucketMountCredentials[entry5.key] = entry5.value;
41627
+ }
41628
+ continue;
41629
+ }
41630
+ }
41631
+ if ((tag & 7) === 4 || tag === 0) {
41632
+ break;
41633
+ }
41634
+ reader.skip(tag & 7);
41635
+ }
41636
+ return message;
41637
+ },
41638
+ fromJSON(object) {
41639
+ return {
41640
+ sandboxId: isSet5(object.sandboxId) ? globalThis.String(object.sandboxId) : "",
41641
+ containerName: isSet5(object.containerName) ? globalThis.String(object.containerName) : "",
41642
+ definition: isSet5(object.definition) ? Sandbox.fromJSON(object.definition) : void 0,
41643
+ ephemeralSecrets: isSet5(object.ephemeralSecrets) ? StringMap.fromJSON(object.ephemeralSecrets) : void 0,
41644
+ cloudBucketMountCredentials: isObject2(object.cloudBucketMountCredentials) ? Object.entries(object.cloudBucketMountCredentials).reduce(
41645
+ (acc, [key, value]) => {
41646
+ acc[key] = StringMap.fromJSON(value);
41647
+ return acc;
41648
+ },
41649
+ {}
41650
+ ) : {}
41651
+ };
41652
+ },
41653
+ toJSON(message) {
41654
+ const obj = {};
41655
+ if (message.sandboxId !== "") {
41656
+ obj.sandboxId = message.sandboxId;
41657
+ }
41658
+ if (message.containerName !== "") {
41659
+ obj.containerName = message.containerName;
41660
+ }
41661
+ if (message.definition !== void 0) {
41662
+ obj.definition = Sandbox.toJSON(message.definition);
41663
+ }
41664
+ if (message.ephemeralSecrets !== void 0) {
41665
+ obj.ephemeralSecrets = StringMap.toJSON(message.ephemeralSecrets);
41666
+ }
41667
+ if (message.cloudBucketMountCredentials) {
41668
+ const entries = Object.entries(message.cloudBucketMountCredentials);
41669
+ if (entries.length > 0) {
41670
+ obj.cloudBucketMountCredentials = {};
41671
+ entries.forEach(([k, v]) => {
41672
+ obj.cloudBucketMountCredentials[k] = StringMap.toJSON(v);
41673
+ });
41674
+ }
41675
+ }
41676
+ return obj;
41677
+ },
41678
+ create(base) {
41679
+ return SandboxContainerCreateV2Request.fromPartial(base ?? {});
41680
+ },
41681
+ fromPartial(object) {
41682
+ const message = createBaseSandboxContainerCreateV2Request();
41683
+ message.sandboxId = object.sandboxId ?? "";
41684
+ message.containerName = object.containerName ?? "";
41685
+ message.definition = object.definition !== void 0 && object.definition !== null ? Sandbox.fromPartial(object.definition) : void 0;
41686
+ message.ephemeralSecrets = object.ephemeralSecrets !== void 0 && object.ephemeralSecrets !== null ? StringMap.fromPartial(object.ephemeralSecrets) : void 0;
41687
+ message.cloudBucketMountCredentials = Object.entries(object.cloudBucketMountCredentials ?? {}).reduce((acc, [key, value]) => {
41688
+ if (value !== void 0) {
41689
+ acc[key] = StringMap.fromPartial(value);
41690
+ }
41691
+ return acc;
41692
+ }, {});
41693
+ return message;
41694
+ }
41695
+ };
41696
+ function createBaseSandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry() {
41697
+ return { key: "", value: void 0 };
41698
+ }
41699
+ var SandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry = {
41700
+ encode(message, writer = new BinaryWriter()) {
41701
+ if (message.key !== "") {
41702
+ writer.uint32(10).string(message.key);
41703
+ }
41704
+ if (message.value !== void 0) {
41705
+ StringMap.encode(message.value, writer.uint32(18).fork()).join();
41706
+ }
41707
+ return writer;
41708
+ },
41709
+ decode(input, length) {
41710
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
41711
+ let end = length === void 0 ? reader.len : reader.pos + length;
41712
+ const message = createBaseSandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry();
41713
+ while (reader.pos < end) {
41714
+ const tag = reader.uint32();
41715
+ switch (tag >>> 3) {
41716
+ case 1: {
41717
+ if (tag !== 10) {
41718
+ break;
41719
+ }
41720
+ message.key = reader.string();
41721
+ continue;
41722
+ }
41723
+ case 2: {
41724
+ if (tag !== 18) {
41725
+ break;
41726
+ }
41727
+ message.value = StringMap.decode(reader, reader.uint32());
41728
+ continue;
41729
+ }
41730
+ }
41731
+ if ((tag & 7) === 4 || tag === 0) {
41732
+ break;
41733
+ }
41734
+ reader.skip(tag & 7);
41735
+ }
41736
+ return message;
41737
+ },
41738
+ fromJSON(object) {
41739
+ return {
41740
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
41741
+ value: isSet5(object.value) ? StringMap.fromJSON(object.value) : void 0
41742
+ };
41743
+ },
41744
+ toJSON(message) {
41745
+ const obj = {};
41746
+ if (message.key !== "") {
41747
+ obj.key = message.key;
41748
+ }
41749
+ if (message.value !== void 0) {
41750
+ obj.value = StringMap.toJSON(message.value);
41751
+ }
41752
+ return obj;
41753
+ },
41754
+ create(base) {
41755
+ return SandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry.fromPartial(base ?? {});
41756
+ },
41757
+ fromPartial(object) {
41758
+ const message = createBaseSandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry();
41759
+ message.key = object.key ?? "";
41760
+ message.value = object.value !== void 0 && object.value !== null ? StringMap.fromPartial(object.value) : void 0;
41761
+ return message;
41762
+ }
41763
+ };
41764
+ function createBaseSandboxContainerCreateV2Response() {
41765
+ return { containerId: "", containerName: "" };
41766
+ }
41767
+ var SandboxContainerCreateV2Response = {
41768
+ encode(message, writer = new BinaryWriter()) {
41769
+ if (message.containerId !== "") {
41770
+ writer.uint32(10).string(message.containerId);
41771
+ }
41772
+ if (message.containerName !== "") {
41773
+ writer.uint32(18).string(message.containerName);
41774
+ }
41775
+ return writer;
41776
+ },
41777
+ decode(input, length) {
41778
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
41779
+ let end = length === void 0 ? reader.len : reader.pos + length;
41780
+ const message = createBaseSandboxContainerCreateV2Response();
41781
+ while (reader.pos < end) {
41782
+ const tag = reader.uint32();
41783
+ switch (tag >>> 3) {
41784
+ case 1: {
41785
+ if (tag !== 10) {
41786
+ break;
41787
+ }
41788
+ message.containerId = reader.string();
41789
+ continue;
41790
+ }
41791
+ case 2: {
41792
+ if (tag !== 18) {
41793
+ break;
41794
+ }
41795
+ message.containerName = reader.string();
41796
+ continue;
41797
+ }
41798
+ }
41799
+ if ((tag & 7) === 4 || tag === 0) {
41800
+ break;
41801
+ }
41802
+ reader.skip(tag & 7);
41803
+ }
41804
+ return message;
41805
+ },
41806
+ fromJSON(object) {
41807
+ return {
41808
+ containerId: isSet5(object.containerId) ? globalThis.String(object.containerId) : "",
41809
+ containerName: isSet5(object.containerName) ? globalThis.String(object.containerName) : ""
41810
+ };
41811
+ },
41812
+ toJSON(message) {
41813
+ const obj = {};
41814
+ if (message.containerId !== "") {
41815
+ obj.containerId = message.containerId;
41816
+ }
41817
+ if (message.containerName !== "") {
41818
+ obj.containerName = message.containerName;
41819
+ }
41820
+ return obj;
41821
+ },
41822
+ create(base) {
41823
+ return SandboxContainerCreateV2Response.fromPartial(base ?? {});
41824
+ },
41825
+ fromPartial(object) {
41826
+ const message = createBaseSandboxContainerCreateV2Response();
41827
+ message.containerId = object.containerId ?? "";
41828
+ message.containerName = object.containerName ?? "";
41829
+ return message;
41830
+ }
41831
+ };
40460
41832
  function createBaseSandboxCreateConnectTokenRequest() {
40461
41833
  return { sandboxId: "", userMetadata: "", port: void 0 };
40462
41834
  }
@@ -47259,6 +48631,142 @@ var SharedVolumeRemoveFileRequest = {
47259
48631
  return message;
47260
48632
  }
47261
48633
  };
48634
+ function createBaseStatsPercentile() {
48635
+ return { percentileBasisPoints: 0, value: 0 };
48636
+ }
48637
+ var StatsPercentile = {
48638
+ encode(message, writer = new BinaryWriter()) {
48639
+ if (message.percentileBasisPoints !== 0) {
48640
+ writer.uint32(8).uint32(message.percentileBasisPoints);
48641
+ }
48642
+ if (message.value !== 0) {
48643
+ writer.uint32(17).double(message.value);
48644
+ }
48645
+ return writer;
48646
+ },
48647
+ decode(input, length) {
48648
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
48649
+ let end = length === void 0 ? reader.len : reader.pos + length;
48650
+ const message = createBaseStatsPercentile();
48651
+ while (reader.pos < end) {
48652
+ const tag = reader.uint32();
48653
+ switch (tag >>> 3) {
48654
+ case 1: {
48655
+ if (tag !== 8) {
48656
+ break;
48657
+ }
48658
+ message.percentileBasisPoints = reader.uint32();
48659
+ continue;
48660
+ }
48661
+ case 2: {
48662
+ if (tag !== 17) {
48663
+ break;
48664
+ }
48665
+ message.value = reader.double();
48666
+ continue;
48667
+ }
48668
+ }
48669
+ if ((tag & 7) === 4 || tag === 0) {
48670
+ break;
48671
+ }
48672
+ reader.skip(tag & 7);
48673
+ }
48674
+ return message;
48675
+ },
48676
+ fromJSON(object) {
48677
+ return {
48678
+ percentileBasisPoints: isSet5(object.percentileBasisPoints) ? globalThis.Number(object.percentileBasisPoints) : 0,
48679
+ value: isSet5(object.value) ? globalThis.Number(object.value) : 0
48680
+ };
48681
+ },
48682
+ toJSON(message) {
48683
+ const obj = {};
48684
+ if (message.percentileBasisPoints !== 0) {
48685
+ obj.percentileBasisPoints = Math.round(message.percentileBasisPoints);
48686
+ }
48687
+ if (message.value !== 0) {
48688
+ obj.value = message.value;
48689
+ }
48690
+ return obj;
48691
+ },
48692
+ create(base) {
48693
+ return StatsPercentile.fromPartial(base ?? {});
48694
+ },
48695
+ fromPartial(object) {
48696
+ const message = createBaseStatsPercentile();
48697
+ message.percentileBasisPoints = object.percentileBasisPoints ?? 0;
48698
+ message.value = object.value ?? 0;
48699
+ return message;
48700
+ }
48701
+ };
48702
+ function createBaseStatsPercentileDistribution() {
48703
+ return { unit: "", percentiles: [] };
48704
+ }
48705
+ var StatsPercentileDistribution = {
48706
+ encode(message, writer = new BinaryWriter()) {
48707
+ if (message.unit !== "") {
48708
+ writer.uint32(10).string(message.unit);
48709
+ }
48710
+ for (const v of message.percentiles) {
48711
+ StatsPercentile.encode(v, writer.uint32(18).fork()).join();
48712
+ }
48713
+ return writer;
48714
+ },
48715
+ decode(input, length) {
48716
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
48717
+ let end = length === void 0 ? reader.len : reader.pos + length;
48718
+ const message = createBaseStatsPercentileDistribution();
48719
+ while (reader.pos < end) {
48720
+ const tag = reader.uint32();
48721
+ switch (tag >>> 3) {
48722
+ case 1: {
48723
+ if (tag !== 10) {
48724
+ break;
48725
+ }
48726
+ message.unit = reader.string();
48727
+ continue;
48728
+ }
48729
+ case 2: {
48730
+ if (tag !== 18) {
48731
+ break;
48732
+ }
48733
+ message.percentiles.push(StatsPercentile.decode(reader, reader.uint32()));
48734
+ continue;
48735
+ }
48736
+ }
48737
+ if ((tag & 7) === 4 || tag === 0) {
48738
+ break;
48739
+ }
48740
+ reader.skip(tag & 7);
48741
+ }
48742
+ return message;
48743
+ },
48744
+ fromJSON(object) {
48745
+ return {
48746
+ unit: isSet5(object.unit) ? globalThis.String(object.unit) : "",
48747
+ percentiles: globalThis.Array.isArray(object?.percentiles) ? object.percentiles.map((e) => StatsPercentile.fromJSON(e)) : []
48748
+ };
48749
+ },
48750
+ toJSON(message) {
48751
+ const obj = {};
48752
+ if (message.unit !== "") {
48753
+ obj.unit = message.unit;
48754
+ }
48755
+ if (message.percentiles?.length) {
48756
+ obj.percentiles = message.percentiles.map((e) => StatsPercentile.toJSON(e));
48757
+ }
48758
+ return obj;
48759
+ },
48760
+ create(base) {
48761
+ return StatsPercentileDistribution.fromPartial(base ?? {});
48762
+ },
48763
+ fromPartial(object) {
48764
+ const message = createBaseStatsPercentileDistribution();
48765
+ message.unit = object.unit ?? "";
48766
+ message.percentiles = object.percentiles?.map((e) => StatsPercentile.fromPartial(e)) || [];
48767
+ return message;
48768
+ }
48769
+ };
47262
48770
  function createBaseStringMap() {
47263
48771
  return { contents: {} };
47264
48772
  }
@@ -51160,7 +52668,7 @@ var VolumeGetByIdResponse = {
51160
52668
  }
51161
52669
  };
51162
52670
  function createBaseVolumeGetFile2Request() {
51163
- return { volumeId: "", path: "", start: 0, len: 0 };
52671
+ return { volumeId: "", path: "", start: 0, len: 0, clientPadsBlocks: false };
51164
52672
  }
51165
52673
  var VolumeGetFile2Request = {
51166
52674
  encode(message, writer = new BinaryWriter()) {
@@ -51176,6 +52684,9 @@ var VolumeGetFile2Request = {
51176
52684
  if (message.len !== 0) {
51177
52685
  writer.uint32(32).uint64(message.len);
51178
52686
  }
52687
+ if (message.clientPadsBlocks !== false) {
52688
+ writer.uint32(40).bool(message.clientPadsBlocks);
52689
+ }
51179
52690
  return writer;
51180
52691
  },
51181
52692
  decode(input, length) {
@@ -51213,6 +52724,13 @@ var VolumeGetFile2Request = {
51213
52724
  message.len = longToNumber2(reader.uint64());
51214
52725
  continue;
51215
52726
  }
52727
+ case 5: {
52728
+ if (tag !== 40) {
52729
+ break;
52730
+ }
52731
+ message.clientPadsBlocks = reader.bool();
52732
+ continue;
52733
+ }
51216
52734
  }
51217
52735
  if ((tag & 7) === 4 || tag === 0) {
51218
52736
  break;
@@ -51226,7 +52744,8 @@ var VolumeGetFile2Request = {
51226
52744
  volumeId: isSet5(object.volumeId) ? globalThis.String(object.volumeId) : "",
51227
52745
  path: isSet5(object.path) ? globalThis.String(object.path) : "",
51228
52746
  start: isSet5(object.start) ? globalThis.Number(object.start) : 0,
51229
- len: isSet5(object.len) ? globalThis.Number(object.len) : 0
52747
+ len: isSet5(object.len) ? globalThis.Number(object.len) : 0,
52748
+ clientPadsBlocks: isSet5(object.clientPadsBlocks) ? globalThis.Boolean(object.clientPadsBlocks) : false
51230
52749
  };
51231
52750
  },
51232
52751
  toJSON(message) {
@@ -51243,6 +52762,9 @@ var VolumeGetFile2Request = {
51243
52762
  if (message.len !== 0) {
51244
52763
  obj.len = Math.round(message.len);
51245
52764
  }
52765
+ if (message.clientPadsBlocks !== false) {
52766
+ obj.clientPadsBlocks = message.clientPadsBlocks;
52767
+ }
51246
52768
  return obj;
51247
52769
  },
51248
52770
  create(base) {
@@ -51254,6 +52776,7 @@ var VolumeGetFile2Request = {
51254
52776
  message.path = object.path ?? "";
51255
52777
  message.start = object.start ?? 0;
51256
52778
  message.len = object.len ?? 0;
52779
+ message.clientPadsBlocks = object.clientPadsBlocks ?? false;
51257
52780
  return message;
51258
52781
  }
51259
52782
  };
@@ -56095,6 +57618,14 @@ var ModalClientDefinition = {
56095
57618
  responseStream: false,
56096
57619
  options: {}
56097
57620
  },
57621
+ appGetInfo: {
57622
+ name: "AppGetInfo",
57623
+ requestType: AppGetInfoRequest,
57624
+ requestStream: false,
57625
+ responseType: AppGetInfoResponse,
57626
+ responseStream: false,
57627
+ options: {}
57628
+ },
56098
57629
  appGetLayout: {
56099
57630
  name: "AppGetLayout",
56100
57631
  requestType: AppGetLayoutRequest,
@@ -56830,6 +58361,14 @@ var ModalClientDefinition = {
56830
58361
  responseStream: false,
56831
58362
  options: {}
56832
58363
  },
58364
+ functionGetById: {
58365
+ name: "FunctionGetById",
58366
+ requestType: FunctionGetByIdRequest,
58367
+ requestStream: false,
58368
+ responseType: FunctionGetByIdResponse,
58369
+ responseStream: false,
58370
+ options: {}
58371
+ },
56833
58372
  functionGetCallGraph: {
56834
58373
  name: "FunctionGetCallGraph",
56835
58374
  requestType: FunctionGetCallGraphRequest,
@@ -56854,6 +58393,14 @@ var ModalClientDefinition = {
56854
58393
  responseStream: false,
56855
58394
  options: {}
56856
58395
  },
58396
+ functionGetFlashAuthToken: {
58397
+ name: "FunctionGetFlashAuthToken",
58398
+ requestType: FunctionGetFlashAuthTokenRequest,
58399
+ requestStream: false,
58400
+ responseType: FunctionGetFlashAuthTokenResponse,
58401
+ responseStream: false,
58402
+ options: {}
58403
+ },
56857
58404
  /** For containers to request next call */
56858
58405
  functionGetInputs: {
56859
58406
  name: "FunctionGetInputs",
@@ -57216,6 +58763,14 @@ var ModalClientDefinition = {
57216
58763
  options: {}
57217
58764
  },
57218
58765
  /** Sandboxes */
58766
+ sandboxContainerCreateV2: {
58767
+ name: "SandboxContainerCreateV2",
58768
+ requestType: SandboxContainerCreateV2Request,
58769
+ requestStream: false,
58770
+ responseType: SandboxContainerCreateV2Response,
58771
+ responseStream: false,
58772
+ options: {}
58773
+ },
57219
58774
  sandboxCreate: {
57220
58775
  name: "SandboxCreate",
57221
58776
  requestType: SandboxCreateRequest,
@@ -58573,7 +60128,7 @@ function checkForRenamedParams(params, renames) {
58573
60128
  }
58574
60129
 
58575
60130
  // src/client.ts
58576
- var import_uuid2 = require("uuid");
60131
+ var import_uuid4 = require("uuid");
58577
60132
  var import_nice_grpc14 = require("nice-grpc");
58578
60133
 
58579
60134
  // src/cloud_bucket_mount.ts
@@ -60024,6 +61579,33 @@ var Queue = class _Queue {
60024
61579
  var import_nice_grpc12 = require("nice-grpc");
60025
61580
  var import_promises3 = require("timers/promises");
60026
61581
 
61582
+ // src/idle_countdown.ts
61583
+ var IdleCountdown = class {
61584
+ #timer;
61585
+ /** Ends the countdown in progress. */
61586
+ stop() {
61587
+ if (this.#timer !== void 0) {
61588
+ globalThis.clearTimeout(this.#timer);
61589
+ this.#timer = void 0;
61590
+ }
61591
+ }
61592
+ /**
61593
+ * Starts the countdown again, calling `release` when it elapses. A timeout of
61594
+ * zero or less leaves it stopped.
61595
+ */
61596
+ arm(timeoutMs, release) {
61597
+ this.stop();
61598
+ if (timeoutMs <= 0) {
61599
+ return;
61600
+ }
61601
+ this.#timer = globalThis.setTimeout(() => {
61602
+ this.#timer = void 0;
61603
+ release();
61604
+ }, timeoutMs);
61605
+ this.#timer.unref?.();
61606
+ }
61607
+ };
61608
+
60027
61609
  // proto/modal_proto/task_command_router.ts
60028
61610
  function sandboxStdioFileDescriptorFromJSON(object) {
60029
61611
  switch (object) {
@@ -63108,6 +64690,111 @@ var TaskSetNetworkAccessResponse = {
63108
64690
  return message;
63109
64691
  }
63110
64692
  };
64693
+ function createBaseTaskSetOutboundPolicyRequest() {
64694
+ return { taskId: "", outboundPolicy: void 0 };
64695
+ }
64696
+ var TaskSetOutboundPolicyRequest = {
64697
+ encode(message, writer = new BinaryWriter()) {
64698
+ if (message.taskId !== "") {
64699
+ writer.uint32(10).string(message.taskId);
64700
+ }
64701
+ if (message.outboundPolicy !== void 0) {
64702
+ OutboundPolicy.encode(message.outboundPolicy, writer.uint32(18).fork()).join();
64703
+ }
64704
+ return writer;
64705
+ },
64706
+ decode(input, length) {
64707
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
64708
+ let end = length === void 0 ? reader.len : reader.pos + length;
64709
+ const message = createBaseTaskSetOutboundPolicyRequest();
64710
+ while (reader.pos < end) {
64711
+ const tag = reader.uint32();
64712
+ switch (tag >>> 3) {
64713
+ case 1: {
64714
+ if (tag !== 10) {
64715
+ break;
64716
+ }
64717
+ message.taskId = reader.string();
64718
+ continue;
64719
+ }
64720
+ case 2: {
64721
+ if (tag !== 18) {
64722
+ break;
64723
+ }
64724
+ message.outboundPolicy = OutboundPolicy.decode(reader, reader.uint32());
64725
+ continue;
64726
+ }
64727
+ }
64728
+ if ((tag & 7) === 4 || tag === 0) {
64729
+ break;
64730
+ }
64731
+ reader.skip(tag & 7);
64732
+ }
64733
+ return message;
64734
+ },
64735
+ fromJSON(object) {
64736
+ return {
64737
+ taskId: isSet6(object.taskId) ? globalThis.String(object.taskId) : "",
64738
+ outboundPolicy: isSet6(object.outboundPolicy) ? OutboundPolicy.fromJSON(object.outboundPolicy) : void 0
64739
+ };
64740
+ },
64741
+ toJSON(message) {
64742
+ const obj = {};
64743
+ if (message.taskId !== "") {
64744
+ obj.taskId = message.taskId;
64745
+ }
64746
+ if (message.outboundPolicy !== void 0) {
64747
+ obj.outboundPolicy = OutboundPolicy.toJSON(message.outboundPolicy);
64748
+ }
64749
+ return obj;
64750
+ },
64751
+ create(base) {
64752
+ return TaskSetOutboundPolicyRequest.fromPartial(base ?? {});
64753
+ },
64754
+ fromPartial(object) {
64755
+ const message = createBaseTaskSetOutboundPolicyRequest();
64756
+ message.taskId = object.taskId ?? "";
64757
+ message.outboundPolicy = object.outboundPolicy !== void 0 && object.outboundPolicy !== null ? OutboundPolicy.fromPartial(object.outboundPolicy) : void 0;
64758
+ return message;
64759
+ }
64760
+ };
64761
+ function createBaseTaskSetOutboundPolicyResponse() {
64762
+ return {};
64763
+ }
64764
+ var TaskSetOutboundPolicyResponse = {
64765
+ encode(_, writer = new BinaryWriter()) {
64766
+ return writer;
64767
+ },
64768
+ decode(input, length) {
64769
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
64770
+ let end = length === void 0 ? reader.len : reader.pos + length;
64771
+ const message = createBaseTaskSetOutboundPolicyResponse();
64772
+ while (reader.pos < end) {
64773
+ const tag = reader.uint32();
64774
+ switch (tag >>> 3) {
64775
+ }
64776
+ if ((tag & 7) === 4 || tag === 0) {
64777
+ break;
64778
+ }
64779
+ reader.skip(tag & 7);
64780
+ }
64781
+ return message;
64782
+ },
64783
+ fromJSON(_) {
64784
+ return {};
64785
+ },
64786
+ toJSON(_) {
64787
+ const obj = {};
64788
+ return obj;
64789
+ },
64790
+ create(base) {
64791
+ return TaskSetOutboundPolicyResponse.fromPartial(base ?? {});
64792
+ },
64793
+ fromPartial(_) {
64794
+ const message = createBaseTaskSetOutboundPolicyResponse();
64795
+ return message;
64796
+ }
64797
+ };
63111
64798
  function createBaseTaskSnapshotDirectoryRequest() {
63112
64799
  return {
63113
64800
  taskId: "",
@@ -63837,6 +65524,15 @@ var TaskCommandRouterDefinition = {
63837
65524
  responseStream: false,
63838
65525
  options: {}
63839
65526
  },
65527
+ /** Replace the task's outbound policy. */
65528
+ taskSetOutboundPolicy: {
65529
+ name: "TaskSetOutboundPolicy",
65530
+ requestType: TaskSetOutboundPolicyRequest,
65531
+ requestStream: false,
65532
+ responseType: TaskSetOutboundPolicyResponse,
65533
+ responseStream: false,
65534
+ options: {}
65535
+ },
63840
65536
  /** Snapshot a directory with a mounted image, including any local changes, into a new image. */
63841
65537
  taskSnapshotDirectory: {
63842
65538
  name: "TaskSnapshotDirectory",
@@ -63930,6 +65626,8 @@ var import_node_fs = require("fs");
63930
65626
  var import_node_os = require("os");
63931
65627
  var import_node_path = __toESM(require("path"), 1);
63932
65628
  var import_smol_toml = require("smol-toml");
65629
+ var DEFAULT_SANDBOX_CHANNEL_IDLE_TIMEOUT_MS = 3e4;
65630
+ var MAX_TIMEOUT_MS = 2147483647;
63933
65631
  function isLocalhost(profile) {
63934
65632
  const url = new URL(profile.serverUrl);
63935
65633
  const hostname = url.hostname;
@@ -63957,6 +65655,12 @@ function readConfigFile() {
63957
65655
  }
63958
65656
  }
63959
65657
  var config = readConfigFile();
65658
+ function resolveOAuthClientAuth(secretEnv, jwtKeyEnv, secretFile, jwtKeyFile) {
65659
+ if (secretEnv || jwtKeyEnv) {
65660
+ return { oauthClientSecret: secretEnv, oauthJwtKey: jwtKeyEnv };
65661
+ }
65662
+ return { oauthClientSecret: secretFile, oauthJwtKey: jwtKeyFile };
65663
+ }
63960
65664
  function getProfile(profileName) {
63961
65665
  if (!profileName) {
63962
65666
  for (const [name, profileData2] of Object.entries(config)) {
@@ -63971,8 +65675,16 @@ function getProfile(profileName) {
63971
65675
  serverUrl: process.env["MODAL_SERVER_URL"] || profileData.server_url || "https://api.modal.com:443",
63972
65676
  tokenId: process.env["MODAL_TOKEN_ID"] || profileData.token_id,
63973
65677
  tokenSecret: process.env["MODAL_TOKEN_SECRET"] || profileData.token_secret,
65678
+ oauthRefreshToken: process.env["MODAL_OAUTH_REFRESH_TOKEN"] || profileData.oauth_refresh_token,
65679
+ oauthClientId: process.env["MODAL_OAUTH_CLIENT_ID"] || profileData.oauth_client_id,
65680
+ ...resolveOAuthClientAuth(
65681
+ process.env["MODAL_OAUTH_CLIENT_SECRET"],
65682
+ process.env["MODAL_OAUTH_JWT_KEY"],
65683
+ profileData.oauth_client_secret,
65684
+ profileData.oauth_jwt_key
65685
+ ),
63974
65686
  environment: process.env["MODAL_ENVIRONMENT"] || profileData.environment,
63975
- imageBuilderVersion: process.env["MODAL_IMAGE_BUILDER_VERSION"] || profileData.imageBuilderVersion,
65687
+ imageBuilderVersion: process.env["MODAL_IMAGE_BUILDER_VERSION"] || profileData.image_builder_version,
63976
65688
  logLevel: process.env["MODAL_LOGLEVEL"] || profileData.loglevel,
63977
65689
  maxThrottleWaitSecs: (() => {
63978
65690
  const val = process.env["MODAL_MAX_THROTTLE_WAIT"];
@@ -63985,10 +65697,28 @@ function getProfile(profileName) {
63985
65697
  return void 0;
63986
65698
  }
63987
65699
  return parsed;
63988
- })()
65700
+ })(),
65701
+ sandboxChannelIdleTimeoutMs: (() => {
65702
+ const val = process.env["MODAL_SANDBOX_CHANNEL_IDLE_TIMEOUT"];
65703
+ if (!val) return DEFAULT_SANDBOX_CHANNEL_IDLE_TIMEOUT_MS;
65704
+ const parsed = Number(val);
65705
+ if (!Number.isFinite(parsed) || parsed < 0 || parsed * 1e3 > MAX_TIMEOUT_MS) {
65706
+ (0, import_node_console.warn)(
65707
+ `MODAL_SANDBOX_CHANNEL_IDLE_TIMEOUT="${val}" is not a valid non-negative number of seconds; ignoring.`
65708
+ );
65709
+ return DEFAULT_SANDBOX_CHANNEL_IDLE_TIMEOUT_MS;
65710
+ }
65711
+ const ms = Math.round(parsed * 1e3);
65712
+ return parsed > 0 && ms === 0 ? 1 : ms;
65713
+ })(),
65714
+ sandboxV2: process.env["MODAL_SANDBOX_V2"] ? parseBooleanFlag(process.env["MODAL_SANDBOX_V2"]) : parseBooleanFlag(profileData.sandbox_v2)
63989
65715
  };
63990
65716
  return profile;
63991
65717
  }
65718
+ function parseBooleanFlag(value) {
65719
+ if (!value) return false;
65720
+ return !["0", "false"].includes(String(value).toLowerCase());
65721
+ }
63992
65722
 
63993
65723
  // src/task_command_router_client.ts
63994
65724
  function parseJwtExpiration(jwtToken, logger2) {
@@ -64059,7 +65789,37 @@ async function callWithRetriesOnTransientErrors(func, baseDelayMs = 10, delayFac
64059
65789
  }
64060
65790
  var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64061
65791
  stub;
65792
+ /**
65793
+ * The connection, absent while it is released. It is dialled again by the
65794
+ * next operation, so nothing may hold `stub` across one.
65795
+ */
64062
65796
  channel;
65797
+ dial;
65798
+ factory;
65799
+ /**
65800
+ * How many operations are using the connection. A count rather than a flag
65801
+ * because operations overlap: only the last one out starts the idle clock.
65802
+ */
65803
+ inFlight = 0;
65804
+ idle = new IdleCountdown();
65805
+ /**
65806
+ * Bumped every time a connection is dialled. A stream opened on an earlier
65807
+ * one is stale: the connection under it has since been given up.
65808
+ */
65809
+ generation = 0;
65810
+ /**
65811
+ * Streams open right now, tracked so they can be ended on release.
65812
+ *
65813
+ * grpc-js does not cancel a call in flight when its channel is closed, and a
65814
+ * subchannel with a live call on it is never collected - so closing alone
65815
+ * leaves the socket up. Aborting the calls first is what actually frees it.
65816
+ */
65817
+ liveStreams = /* @__PURE__ */ new Set();
65818
+ /**
65819
+ * How long the client may go unused before its connection is given up. Zero
65820
+ * keeps it up until the client is closed. Overridable in tests.
65821
+ */
65822
+ idleTimeoutMs = DEFAULT_SANDBOX_CHANNEL_IDLE_TIMEOUT_MS;
64063
65823
  serverClient;
64064
65824
  taskId;
64065
65825
  sandboxId;
@@ -64070,6 +65830,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64070
65830
  jwtRefreshLock = Promise.resolve();
64071
65831
  logger;
64072
65832
  closed = false;
65833
+ draining = false;
64073
65834
  /**
64074
65835
  * `access` is the router access returned by SandboxCreateV2, which lets a
64075
65836
  * freshly created sandbox connect without a round-trip. Pass undefined to look
@@ -64121,23 +65882,17 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64121
65882
  "grpc.keepalive_timeout_ms": 1e4,
64122
65883
  "grpc.keepalive_permit_without_calls": 1
64123
65884
  };
64124
- let channel;
64125
- if (isLocalhost(profile)) {
65885
+ const insecure = isLocalhost(profile);
65886
+ if (insecure) {
64126
65887
  logger2.warn(
64127
65888
  "Using insecure TLS (skip certificate verification) for task command router"
64128
65889
  );
64129
- channel = (0, import_nice_grpc7.createChannel)(
64130
- serverUrl,
64131
- import_nice_grpc7.ChannelCredentials.createInsecure(),
64132
- channelConfig
64133
- );
64134
- } else {
64135
- channel = (0, import_nice_grpc7.createChannel)(
64136
- serverUrl,
64137
- import_nice_grpc7.ChannelCredentials.createSsl(),
64138
- channelConfig
64139
- );
64140
65890
  }
65891
+ const dial = () => (0, import_nice_grpc7.createChannel)(
65892
+ serverUrl,
65893
+ insecure ? import_nice_grpc7.ChannelCredentials.createInsecure() : import_nice_grpc7.ChannelCredentials.createSsl(),
65894
+ channelConfig
65895
+ );
64141
65896
  const client = new _TaskCommandRouterClientImpl(
64142
65897
  serverClient,
64143
65898
  taskId,
@@ -64145,8 +65900,9 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64145
65900
  isV2,
64146
65901
  resp.url,
64147
65902
  resp.jwt,
64148
- channel,
64149
- logger2
65903
+ dial,
65904
+ logger2,
65905
+ profile.sandboxChannelIdleTimeoutMs
64150
65906
  );
64151
65907
  logger2.debug(
64152
65908
  "Successfully initialized command router client",
@@ -64155,7 +65911,14 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64155
65911
  );
64156
65912
  return client;
64157
65913
  }
64158
- constructor(serverClient, taskId, sandboxId, isV2, serverUrl, jwt, channel, logger2) {
65914
+ /**
65915
+ * Builds a client around an already-resolved connection. Public so a test can
65916
+ * construct one without the control-plane round trip `tryInit` makes; the
65917
+ * class is not exported from the package, so this is not API surface.
65918
+ */
65919
+ constructor(serverClient, taskId, sandboxId, isV2, serverUrl, jwt, dial, logger2, idleTimeoutMs) {
65920
+ this.dial = dial;
65921
+ this.idleTimeoutMs = idleTimeoutMs;
64159
65922
  this.serverClient = serverClient;
64160
65923
  this.taskId = taskId;
64161
65924
  this.sandboxId = sandboxId;
@@ -64164,25 +65927,110 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64164
65927
  this.jwt = jwt;
64165
65928
  this.jwtExp = parseJwtExpiration(jwt, logger2);
64166
65929
  this.logger = logger2;
64167
- this.channel = channel;
65930
+ this.channel = dial();
64168
65931
  const self = this;
64169
65932
  const factory = (0, import_nice_grpc7.createClientFactory)().use(timeoutMiddleware).use(async function* authMiddleware(call, options) {
64170
65933
  options.metadata ??= new import_nice_grpc7.Metadata();
64171
65934
  options.metadata.set("authorization", `Bearer ${self.jwt}`);
64172
65935
  return yield* call.next(call.request, options);
64173
65936
  });
64174
- this.stub = factory.create(TaskCommandRouterDefinition, channel);
65937
+ this.factory = factory;
65938
+ this.stub = factory.create(TaskCommandRouterDefinition, this.channel);
65939
+ this.armIdleTimer();
65940
+ }
65941
+ /**
65942
+ * Says the client is about to be used: holds off the idle timer, and dials
65943
+ * again if the connection was already given up. Returns the generation being
65944
+ * used; pair every call with endOp.
65945
+ */
65946
+ beginOp() {
65947
+ if (this.closed || this.draining) {
65948
+ throw new ClientClosedError();
65949
+ }
65950
+ this.idle.stop();
65951
+ if (this.channel === void 0) {
65952
+ this.channel = this.dial();
65953
+ this.stub = this.factory.create(
65954
+ TaskCommandRouterDefinition,
65955
+ this.channel
65956
+ );
65957
+ this.generation++;
65958
+ this.logger.debug(
65959
+ "Reconnected to the command router after an idle release",
65960
+ "task_id",
65961
+ this.taskId
65962
+ );
65963
+ }
65964
+ this.inFlight = (this.inFlight ?? 0) + 1;
65965
+ return this.generation;
65966
+ }
65967
+ /** Says the caller is done. The last one out starts the clock. */
65968
+ endOp() {
65969
+ this.inFlight--;
65970
+ if (this.inFlight > 0) {
65971
+ return;
65972
+ }
65973
+ if (this.draining) {
65974
+ this.close();
65975
+ } else {
65976
+ this.armIdleTimer();
65977
+ }
65978
+ }
65979
+ /**
65980
+ * Starts the countdown to giving the connection back. Call it with nothing
65981
+ * in flight.
65982
+ */
65983
+ armIdleTimer() {
65984
+ if (this.closed) {
65985
+ return;
65986
+ }
65987
+ this.idle.arm(this.idleTimeoutMs, () => {
65988
+ if (this.inFlight > 0 || this.channel === void 0) {
65989
+ return;
65990
+ }
65991
+ this.logger.debug(
65992
+ "Releasing the command router connection to an idle Sandbox",
65993
+ "task_id",
65994
+ this.taskId
65995
+ );
65996
+ for (const stream of this.liveStreams) {
65997
+ stream.abort();
65998
+ }
65999
+ this.liveStreams.clear();
66000
+ this.channel.close();
66001
+ this.channel = void 0;
66002
+ });
66003
+ }
66004
+ /** Refuse new operations and release resources after current operations finish. */
66005
+ closeWhenIdle() {
66006
+ this.draining = true;
66007
+ this.idle.stop();
66008
+ if (this.inFlight === 0) this.close();
64175
66009
  }
64176
66010
  close() {
64177
66011
  if (this.closed) {
64178
66012
  return;
64179
66013
  }
64180
66014
  this.closed = true;
64181
- this.channel.close();
66015
+ this.idle.stop();
66016
+ for (const stream of this.liveStreams) {
66017
+ stream.abort();
66018
+ }
66019
+ this.liveStreams.clear();
66020
+ this.channel?.close();
66021
+ this.channel = void 0;
66022
+ }
66023
+ async callWithRetries(...args) {
66024
+ this.beginOp();
66025
+ try {
66026
+ return await callWithRetriesOnTransientErrors(...args);
66027
+ } finally {
66028
+ this.endOp();
66029
+ }
64182
66030
  }
64183
66031
  /** Run a unary RPC against the command router with the default retry policy. */
64184
66032
  async callUnary(fn) {
64185
- return await callWithRetriesOnTransientErrors(
66033
+ return await this.callWithRetries(
64186
66034
  () => this.callWithAuthRetry(fn),
64187
66035
  10,
64188
66036
  // baseDelayMs
@@ -64213,7 +66061,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64213
66061
  async containerWait(request) {
64214
66062
  return await this.callUnary(() => this.stub.taskContainerWait(request));
64215
66063
  }
64216
- async *execStdioRead(taskId, execId, fileDescriptor, deadline = null) {
66064
+ async *execStdioRead(taskId, execId, fileDescriptor, deadline = null, signal) {
64217
66065
  let srFd;
64218
66066
  if (fileDescriptor === 1 /* FILE_DESCRIPTOR_STDOUT */) {
64219
66067
  srFd = 0 /* TASK_EXEC_STDIO_FILE_DESCRIPTOR_STDOUT */;
@@ -64224,7 +66072,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64224
66072
  } else {
64225
66073
  throw new Error(`Invalid file descriptor: ${fileDescriptor}`);
64226
66074
  }
64227
- yield* this.streamStdio(taskId, execId, srFd, deadline);
66075
+ yield* this.streamExecStdio(taskId, execId, srFd, deadline, signal);
64228
66076
  }
64229
66077
  async execStdinWrite(taskId, execId, offset, data, eof) {
64230
66078
  const request = TaskExecStdinWriteRequest.create({
@@ -64256,76 +66104,100 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64256
66104
  * stream from that point. Returns the total bytes streamed.
64257
66105
  */
64258
66106
  async execStdinWriteStream(taskId, execId, source, chunkSize = STREAMING_STDIN_CHUNK_SIZE, maxResumeAttempts = 9) {
64259
- let offset = 0;
64260
- let attempt = 0;
64261
- while (true) {
64262
- let bytesRead = offset;
64263
- let sourceExhausted = false;
64264
- let sourceError;
64265
- const requests = async function* () {
64266
- yield TaskExecStdinWriteStreamRequest.create({
64267
- start: { taskId, execId, offset }
64268
- });
64269
- const chunks = async function* () {
64270
- try {
64271
- yield* source.readFrom(offset);
64272
- } catch (err) {
64273
- sourceError = err;
66107
+ this.beginOp();
66108
+ try {
66109
+ let offset = 0;
66110
+ let attempt = 0;
66111
+ while (true) {
66112
+ let bytesRead = offset;
66113
+ let sourceExhausted = false;
66114
+ let sourceError;
66115
+ const requests = async function* () {
66116
+ yield TaskExecStdinWriteStreamRequest.create({
66117
+ start: { taskId, execId, offset }
66118
+ });
66119
+ const chunks = async function* () {
66120
+ try {
66121
+ yield* source.readFrom(offset);
66122
+ } catch (err) {
66123
+ sourceError = err;
66124
+ throw err;
66125
+ }
66126
+ }();
66127
+ for await (const chunk of chunks) {
66128
+ for (let i = 0; i < chunk.length; i += chunkSize) {
66129
+ const data = chunk.subarray(i, i + chunkSize);
66130
+ if (data.length === 0) continue;
66131
+ bytesRead += data.length;
66132
+ yield TaskExecStdinWriteStreamRequest.create({ data });
66133
+ }
66134
+ }
66135
+ sourceExhausted = true;
66136
+ yield TaskExecStdinWriteStreamRequest.create({ end: {} });
66137
+ };
66138
+ const abort = new AbortController();
66139
+ this.liveStreams.add(abort);
66140
+ try {
66141
+ await this.stub.taskExecStdinWriteStream(requests(), {
66142
+ signal: abort.signal
66143
+ });
66144
+ return bytesRead;
66145
+ } catch (err) {
66146
+ if (sourceError !== void 0) {
66147
+ throw sourceError;
66148
+ }
66149
+ if (err instanceof import_nice_grpc7.ClientError && err.code === import_nice_grpc7.Status.CANCELLED && this.closed) {
66150
+ throw new ClientClosedError();
66151
+ }
66152
+ if (!isResumableStreamingStdinError(err)) {
64274
66153
  throw err;
64275
66154
  }
64276
- }();
64277
- for await (const chunk of chunks) {
64278
- for (let i = 0; i < chunk.length; i += chunkSize) {
64279
- const data = chunk.subarray(i, i + chunkSize);
64280
- if (data.length === 0) continue;
64281
- bytesRead += data.length;
64282
- yield TaskExecStdinWriteStreamRequest.create({ data });
66155
+ attempt++;
66156
+ if (attempt > maxResumeAttempts) {
66157
+ throw err;
64283
66158
  }
64284
- }
64285
- sourceExhausted = true;
64286
- yield TaskExecStdinWriteStreamRequest.create({ end: {} });
64287
- };
64288
- try {
64289
- await this.stub.taskExecStdinWriteStream(requests());
64290
- return bytesRead;
64291
- } catch (err) {
64292
- if (sourceError !== void 0) {
64293
- throw sourceError;
64294
- }
64295
- if (err instanceof import_nice_grpc7.ClientError && err.code === import_nice_grpc7.Status.CANCELLED && this.closed) {
64296
- throw new ClientClosedError();
64297
- }
64298
- if (!isResumableStreamingStdinError(err)) {
64299
- throw err;
64300
- }
64301
- attempt++;
64302
- if (attempt > maxResumeAttempts) {
64303
- throw err;
64304
- }
64305
- if (err instanceof import_nice_grpc7.ClientError && err.code === import_nice_grpc7.Status.UNAUTHENTICATED) {
64306
- await this.refreshJwt();
64307
- }
64308
- const status = await this.execStdinStatus(taskId, execId);
64309
- if (status.closed) {
64310
- if (sourceExhausted && status.numBytesWritten === bytesRead) {
64311
- this.logger.debug(
64312
- "execStdinWriteStream completed but response was lost",
64313
- "error",
64314
- err
64315
- );
64316
- return bytesRead;
66159
+ if (err instanceof import_nice_grpc7.ClientError && err.code === import_nice_grpc7.Status.UNAUTHENTICATED) {
66160
+ await this.refreshJwt();
66161
+ }
66162
+ const status = await callWithRetriesOnTransientErrors(
66163
+ () => this.callWithAuthRetry(
66164
+ () => this.stub.taskExecStdinStatus(
66165
+ TaskExecStdinStatusRequest.create({ taskId, execId })
66166
+ )
66167
+ ),
66168
+ 10,
66169
+ 2,
66170
+ 10,
66171
+ null,
66172
+ () => this.closed
66173
+ );
66174
+ if (status.closed) {
66175
+ if (sourceExhausted && status.numBytesWritten === bytesRead) {
66176
+ this.logger.debug(
66177
+ "execStdinWriteStream completed but response was lost",
66178
+ "error",
66179
+ err
66180
+ );
66181
+ return bytesRead;
66182
+ }
66183
+ throw err;
66184
+ }
66185
+ offset = status.numBytesWritten;
66186
+ this.logger.debug(
66187
+ "execStdinWriteStream resuming after error",
66188
+ "offset",
66189
+ offset,
66190
+ "error",
66191
+ err
66192
+ );
66193
+ } finally {
66194
+ if (this.liveStreams.delete(abort)) {
66195
+ abort.abort();
64317
66196
  }
64318
- throw err;
64319
66197
  }
64320
- offset = status.numBytesWritten;
64321
- this.logger.debug(
64322
- "execStdinWriteStream resuming after error",
64323
- "offset",
64324
- offset,
64325
- "error",
64326
- err
64327
- );
64328
66198
  }
66199
+ } finally {
66200
+ this.endOp();
64329
66201
  }
64330
66202
  }
64331
66203
  async execPoll(taskId, execId, deadline = null) {
@@ -64334,7 +66206,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64334
66206
  throw new Error(`Deadline exceeded while polling for exec ${execId}`);
64335
66207
  }
64336
66208
  try {
64337
- return await callWithRetriesOnTransientErrors(
66209
+ return await this.callWithRetries(
64338
66210
  () => this.callWithAuthRetry(() => this.stub.taskExecPoll(request)),
64339
66211
  10,
64340
66212
  // baseDelayMs
@@ -64359,7 +66231,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64359
66231
  throw new Error(`Deadline exceeded while waiting for exec ${execId}`);
64360
66232
  }
64361
66233
  try {
64362
- return await callWithRetriesOnTransientErrors(
66234
+ return await this.callWithRetries(
64363
66235
  () => this.callWithAuthRetry(
64364
66236
  () => this.stub.taskExecWait(request, {
64365
66237
  timeoutMs: 6e4
@@ -64388,7 +66260,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64388
66260
  async snapshotDirectory(request, options) {
64389
66261
  const overallDeadlineMs = options?.timeoutMs !== void 0 ? Date.now() + options.timeoutMs : null;
64390
66262
  try {
64391
- return await callWithRetriesOnTransientErrors(
66263
+ return await this.callWithRetries(
64392
66264
  () => this.callWithAuthRetry(() => {
64393
66265
  const remainingMs = overallDeadlineMs !== null ? Math.max(1, overallDeadlineMs - Date.now()) : options?.timeoutMs;
64394
66266
  return this.stub.taskSnapshotDirectory(request, {
@@ -64413,7 +66285,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64413
66285
  async snapshotFilesystem(request, options) {
64414
66286
  const overallDeadlineMs = options?.timeoutMs !== void 0 ? Date.now() + options.timeoutMs : null;
64415
66287
  try {
64416
- return await callWithRetriesOnTransientErrors(
66288
+ return await this.callWithRetries(
64417
66289
  () => this.callWithAuthRetry(() => {
64418
66290
  const remainingMs = overallDeadlineMs !== null ? Math.max(1, overallDeadlineMs - Date.now()) : options?.timeoutMs;
64419
66291
  return this.stub.taskSnapshotFilesystem(request, {
@@ -64438,7 +66310,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64438
66310
  async snapshotMemory(request, options) {
64439
66311
  const overallDeadlineMs = options?.timeoutMs !== void 0 ? Date.now() + options.timeoutMs : null;
64440
66312
  try {
64441
- return await callWithRetriesOnTransientErrors(
66313
+ return await this.callWithRetries(
64442
66314
  () => this.callWithAuthRetry(() => {
64443
66315
  const remainingMs = overallDeadlineMs !== null ? Math.max(1, overallDeadlineMs - Date.now()) : options?.timeoutMs;
64444
66316
  return this.stub.taskSnapshotMemory(request, {
@@ -64475,7 +66347,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64475
66347
  async reloadVolumes(request, options) {
64476
66348
  const overallDeadlineMs = options?.timeoutMs !== void 0 ? Date.now() + options.timeoutMs : null;
64477
66349
  try {
64478
- await callWithRetriesOnTransientErrors(
66350
+ await this.callWithRetries(
64479
66351
  () => this.callWithAuthRetry(() => {
64480
66352
  const remainingMs = overallDeadlineMs !== null ? Math.max(1, overallDeadlineMs - Date.now()) : options?.timeoutMs;
64481
66353
  return this.stub.taskReloadVolumes(request, {
@@ -64497,10 +66369,32 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64497
66369
  throw err;
64498
66370
  }
64499
66371
  }
66372
+ async *sandboxStdioReadV2(taskId, fileDescriptor, signal) {
66373
+ let srFd;
66374
+ if (fileDescriptor === 1 /* FILE_DESCRIPTOR_STDOUT */) {
66375
+ srFd = 0 /* SANDBOX_STDIO_FILE_DESCRIPTOR_STDOUT */;
66376
+ } else if (fileDescriptor === 2 /* FILE_DESCRIPTOR_STDERR */) {
66377
+ srFd = 1 /* SANDBOX_STDIO_FILE_DESCRIPTOR_STDERR */;
66378
+ } else if (fileDescriptor === 3 /* FILE_DESCRIPTOR_INFO */ || fileDescriptor === 0 /* FILE_DESCRIPTOR_UNSPECIFIED */) {
66379
+ throw new Error(`Unsupported file descriptor: ${fileDescriptor}`);
66380
+ } else {
66381
+ throw new Error(`Invalid file descriptor: ${fileDescriptor}`);
66382
+ }
66383
+ yield* this.streamSandboxStdio(taskId, srFd, signal);
66384
+ }
66385
+ async sandboxStdinWriteV2(taskId, offset, data, eof) {
66386
+ const request = SandboxStdinWriteV2Request.create({
66387
+ taskId,
66388
+ offset,
66389
+ data,
66390
+ eof
66391
+ });
66392
+ return await this.callUnary(() => this.stub.sandboxStdinWriteV2(request));
66393
+ }
64500
66394
  async sandboxWaitUntilReady(taskId, timeoutMs) {
64501
66395
  const deadlineMs = Date.now() + timeoutMs;
64502
66396
  try {
64503
- return await callWithRetriesOnTransientErrors(
66397
+ return await this.callWithRetries(
64504
66398
  () => this.callWithAuthRetry(() => {
64505
66399
  const remainingMs = Math.max(1, deadlineMs - Date.now());
64506
66400
  const request = SandboxWaitUntilReadyTcrRequest.create({
@@ -64559,6 +66453,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64559
66453
  throw error;
64560
66454
  }
64561
66455
  }
66456
+ /** The caller holds an operation lease across authentication and all retries. */
64562
66457
  async callWithAuthRetry(func) {
64563
66458
  try {
64564
66459
  return await func();
@@ -64570,68 +66465,133 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64570
66465
  throw err;
64571
66466
  }
64572
66467
  }
64573
- async *streamStdio(taskId, execId, fileDescriptor, deadline) {
64574
- let offset = 0;
64575
- let delayMs = 10;
66468
+ /**
66469
+ * Yields the next chunk of stdio, opening or reopening the stream as it needs
66470
+ * to, and determining whether or not to retry a failed open or read. It waits
66471
+ * out the backoff itself.
66472
+ */
66473
+ async *streamStdioWithRetries(spec) {
66474
+ const baseDelayMs = 10;
64576
66475
  const delayFactor = 2;
64577
- let numRetriesRemaining = 10;
66476
+ const maxRetries = 10;
66477
+ let offset = 0;
66478
+ let delayMs = baseDelayMs;
66479
+ let numRetriesRemaining = maxRetries;
64578
66480
  let didAuthRetry = false;
64579
- while (true) {
64580
- try {
64581
- const timeoutMs = deadline !== null ? Math.max(0, deadline - Date.now()) : void 0;
64582
- const request = TaskExecStdioReadRequest.create({
64583
- taskId,
64584
- execId,
64585
- offset,
64586
- fileDescriptor
64587
- });
64588
- const stream = this.stub.taskExecStdioRead(request, {
64589
- timeoutMs
64590
- });
66481
+ let generation = this.beginOp();
66482
+ let leased = true;
66483
+ try {
66484
+ attempts: while (true) {
66485
+ spec.signal?.throwIfAborted();
66486
+ const abort = new AbortController();
66487
+ const abortWithCaller = () => abort.abort();
66488
+ spec.signal?.addEventListener("abort", abortWithCaller, { once: true });
64591
66489
  try {
64592
- for await (const item of stream) {
64593
- if (didAuthRetry) {
64594
- didAuthRetry = false;
66490
+ const streamGeneration = generation;
66491
+ this.liveStreams.add(abort);
66492
+ const stream = spec.open(offset, abort.signal);
66493
+ try {
66494
+ const items = stream[Symbol.asyncIterator]();
66495
+ let firstOfAttempt = true;
66496
+ while (true) {
66497
+ if (generation !== streamGeneration) {
66498
+ continue attempts;
66499
+ }
66500
+ const next = await items.next();
66501
+ if (next.done) {
66502
+ return;
66503
+ }
66504
+ const item = next.value;
66505
+ if (didAuthRetry) {
66506
+ didAuthRetry = false;
66507
+ }
66508
+ delayMs = baseDelayMs;
66509
+ numRetriesRemaining = maxRetries;
66510
+ offset = spec.nextOffset(item, offset, firstOfAttempt);
66511
+ firstOfAttempt = false;
66512
+ this.endOp();
66513
+ leased = false;
66514
+ yield item;
66515
+ generation = this.beginOp();
66516
+ leased = true;
64595
66517
  }
64596
- delayMs = 10;
64597
- offset += item.data.length;
64598
- yield item;
66518
+ } catch (err) {
66519
+ if (err instanceof import_nice_grpc7.ClientError && err.code === import_nice_grpc7.Status.UNAUTHENTICATED && !didAuthRetry) {
66520
+ await this.refreshJwt();
66521
+ didAuthRetry = true;
66522
+ continue;
66523
+ }
66524
+ throw err;
64599
66525
  }
64600
- return;
64601
66526
  } catch (err) {
64602
- if (err instanceof import_nice_grpc7.ClientError && err.code === import_nice_grpc7.Status.UNAUTHENTICATED && !didAuthRetry) {
64603
- await this.refreshJwt();
64604
- didAuthRetry = true;
64605
- continue;
66527
+ if (spec.signal?.aborted) {
66528
+ throw err;
64606
66529
  }
64607
- throw err;
64608
- }
64609
- } catch (err) {
64610
- if (err instanceof import_nice_grpc7.ClientError && err.code === import_nice_grpc7.Status.CANCELLED && this.closed) {
64611
- throw new ClientClosedError();
64612
- }
64613
- if (err instanceof import_nice_grpc7.ClientError && RETRYABLE_GRPC_STATUS_CODES.has(err.code) && numRetriesRemaining > 0) {
64614
- if (deadline && deadline - Date.now() <= delayMs) {
64615
- throw new Error(
64616
- `Deadline exceeded while streaming stdio for exec ${execId}`
66530
+ if (err instanceof import_nice_grpc7.ClientError && err.code === import_nice_grpc7.Status.CANCELLED && this.closed) {
66531
+ throw new ClientClosedError();
66532
+ }
66533
+ if (err instanceof import_nice_grpc7.ClientError && RETRYABLE_GRPC_STATUS_CODES.has(err.code) && numRetriesRemaining > 0) {
66534
+ if (spec.deadline && spec.deadline - Date.now() <= delayMs) {
66535
+ throw new Error(
66536
+ `Deadline exceeded while streaming stdio for ${spec.label}`
66537
+ );
66538
+ }
66539
+ this.logger.debug(
66540
+ "Retrying stdio read with delay",
66541
+ "delay_ms",
66542
+ delayMs,
66543
+ "error",
66544
+ err
64617
66545
  );
66546
+ await (0, import_promises.setTimeout)(delayMs, void 0, { signal: spec.signal });
66547
+ delayMs *= delayFactor;
66548
+ numRetriesRemaining--;
66549
+ } else {
66550
+ throw err;
66551
+ }
66552
+ } finally {
66553
+ spec.signal?.removeEventListener("abort", abortWithCaller);
66554
+ if (this.liveStreams.delete(abort)) {
66555
+ abort.abort();
64618
66556
  }
64619
- this.logger.debug(
64620
- "Retrying stdio read with delay",
64621
- "delay_ms",
64622
- delayMs,
64623
- "error",
64624
- err
64625
- );
64626
- await (0, import_promises.setTimeout)(delayMs);
64627
- delayMs *= delayFactor;
64628
- numRetriesRemaining--;
64629
- } else {
64630
- throw err;
64631
66557
  }
64632
66558
  }
66559
+ } finally {
66560
+ if (leased) this.endOp();
64633
66561
  }
64634
66562
  }
66563
+ streamExecStdio(taskId, execId, fileDescriptor, deadline, signal) {
66564
+ return this.streamStdioWithRetries({
66565
+ open: (offset, signal2) => this.stub.taskExecStdioRead(
66566
+ TaskExecStdioReadRequest.create({
66567
+ taskId,
66568
+ execId,
66569
+ offset,
66570
+ fileDescriptor
66571
+ }),
66572
+ {
66573
+ timeoutMs: deadline !== null ? Math.max(0, deadline - Date.now()) : void 0,
66574
+ signal: signal2
66575
+ }
66576
+ ),
66577
+ nextOffset: (item, offset) => offset + item.data.length,
66578
+ deadline,
66579
+ label: `exec ${execId}`,
66580
+ signal
66581
+ });
66582
+ }
66583
+ streamSandboxStdio(taskId, fileDescriptor, signal) {
66584
+ return this.streamStdioWithRetries({
66585
+ open: (offset, signal2) => this.stub.sandboxStdioReadV2(
66586
+ SandboxStdioReadV2Request.create({ taskId, offset, fileDescriptor }),
66587
+ { signal: signal2 }
66588
+ ),
66589
+ nextOffset: (item, offset, firstOfAttempt) => (firstOfAttempt ? item.startingOffset : offset) + item.data.length,
66590
+ deadline: null,
66591
+ label: `Sandbox task ${taskId}`,
66592
+ signal
66593
+ });
66594
+ }
64635
66595
  };
64636
66596
  async function getCommandRouterAccess(serverClient, taskId, sandboxId, isV2) {
64637
66597
  if (isV2) {
@@ -64647,7 +66607,7 @@ async function getCommandRouterAccess(serverClient, taskId, sandboxId, isV2) {
64647
66607
  }
64648
66608
 
64649
66609
  // src/sandbox.ts
64650
- var import_uuid = require("uuid");
66610
+ var import_uuid2 = require("uuid");
64651
66611
 
64652
66612
  // src/sandbox_fs.ts
64653
66613
  var import_node_crypto2 = require("crypto");
@@ -65561,6 +67521,7 @@ var SandboxFilesystem = class {
65561
67521
 
65562
67522
  // src/sandbox_sidecar.ts
65563
67523
  var import_nice_grpc10 = require("nice-grpc");
67524
+ var import_uuid = require("uuid");
65564
67525
  var MAIN_CONTAINER_NAME = "main";
65565
67526
  var CONTAINER_WAIT_POLL_TIMEOUT_SECONDS = 10;
65566
67527
  function validateSidecarName(name) {
@@ -65775,6 +67736,10 @@ var SidecarContainer = class {
65775
67736
  return this.wait();
65776
67737
  }
65777
67738
  }
67739
+ /** Snapshot this Sidecar container's filesystem into an Image. */
67740
+ async snapshotFilesystem(params) {
67741
+ return this.#access.snapshotFilesystem(this.containerId, params);
67742
+ }
65778
67743
  /**
65779
67744
  * Reload all Volumes mounted in this sidecar container.
65780
67745
  *
@@ -65784,6 +67749,80 @@ var SidecarContainer = class {
65784
67749
  async reloadVolumes(params) {
65785
67750
  await this.#access.reloadVolumes(this.containerId, params);
65786
67751
  }
67752
+ /**
67753
+ * Mount an {@link Image} at a path in this Sidecar container's filesystem.
67754
+ *
67755
+ * @param path - The path where the directory should be mounted
67756
+ * @param image - Optional {@link Image} to mount. If undefined, mounts an empty directory.
67757
+ * @param params - Optional parameters; see {@link SidecarMountImageParams}.
67758
+ */
67759
+ async mountImage(path2, image, params) {
67760
+ const imageId = resolveMountImageId(image);
67761
+ const [taskId, client] = await this.#access.commandRouter();
67762
+ await client.mountDirectory(
67763
+ buildTaskMountDirectoryRequestProto(
67764
+ taskId,
67765
+ path2,
67766
+ imageId,
67767
+ params,
67768
+ this.containerId
67769
+ )
67770
+ );
67771
+ }
67772
+ /**
67773
+ * Unmounts an {@link Image} previously mounted at a path in this Sidecar container's filesystem.
67774
+ *
67775
+ * @param path - The mount path to unmount
67776
+ */
67777
+ async unmountImage(path2, _params) {
67778
+ const [taskId, client] = await this.#access.commandRouter();
67779
+ await client.unmountDirectory(
67780
+ TaskUnmountDirectoryRequest.create({
67781
+ taskId,
67782
+ path: new TextEncoder().encode(path2),
67783
+ containerId: this.containerId
67784
+ })
67785
+ );
67786
+ }
67787
+ /**
67788
+ * Snapshots and creates a new {@link Image} from a directory in the running Sidecar container.
67789
+ *
67790
+ * The resulting Image is retained for `ttlMs` (default: 30 days),
67791
+ * as a hard cutoff measured from creation — usage does not extend
67792
+ * the lifetime. Pass `ttlMs: null` to retain indefinitely.
67793
+ *
67794
+ * The call has an overall `timeoutMs` budget (default: 55000). If it
67795
+ * elapses before a snapshot completes, the call is cancelled and an
67796
+ * error is thrown.
67797
+ *
67798
+ * The Image can be used anywhere an Image is accepted, including as a mount
67799
+ * or as the base filesystem for another container.
67800
+ *
67801
+ * @param path - The path of the directory to snapshot
67802
+ * @param params - Optional parameters; see {@link SidecarSnapshotDirectoryParams}.
67803
+ * @returns Promise that resolves to an {@link Image}
67804
+ */
67805
+ async snapshotDirectory(path2, params) {
67806
+ const timeoutMs = params?.timeoutMs || 55e3;
67807
+ const [taskId, client] = await this.#access.commandRouter();
67808
+ const response = await client.snapshotDirectory(
67809
+ buildTaskSnapshotDirectoryRequestProto(
67810
+ taskId,
67811
+ path2,
67812
+ (0, import_uuid.v4)(),
67813
+ resolveTtlSeconds(params?.ttlMs),
67814
+ params,
67815
+ this.containerId
67816
+ ),
67817
+ { timeoutMs }
67818
+ );
67819
+ if (!response.imageId) {
67820
+ throw new InternalFailure(
67821
+ "Sidecar snapshot directory response missing `imageId`"
67822
+ );
67823
+ }
67824
+ return new Image2(this.#access.client, response.imageId, "");
67825
+ }
65787
67826
  };
65788
67827
 
65789
67828
  // src/streams.ts
@@ -65804,7 +67843,7 @@ var readMixin = {
65804
67843
  if (value) {
65805
67844
  if (typeof value === "string") chunks.push(value);
65806
67845
  else {
65807
- chunks.push(decoder2.decode(value.buffer, { stream: true }));
67846
+ chunks.push(decoder2.decode(value, { stream: true }));
65808
67847
  }
65809
67848
  }
65810
67849
  if (done) {
@@ -65889,12 +67928,26 @@ function streamConsumingIter(iterable, onCancel) {
65889
67928
  }
65890
67929
  }
65891
67930
  },
65892
- new ByteLengthQueuingStrategy({
65893
- highWaterMark: 64 * 1024
65894
- // 64 KiB
65895
- })
67931
+ // The high water mark is set to zero intentionally to not run any
67932
+ // background buffering of data, since that would eagerly start streams etc.
67933
+ // If users want a buffered stream they can add buffing on top of the returned
67934
+ // streams instead.
67935
+ new CountQueuingStrategy({ highWaterMark: 0 })
65896
67936
  );
65897
67937
  }
67938
+ async function* decodeTextIter(source) {
67939
+ const decoder2 = new TextDecoder();
67940
+ for await (const chunk of source) {
67941
+ const text = decoder2.decode(chunk, { stream: true });
67942
+ if (text) {
67943
+ yield text;
67944
+ }
67945
+ }
67946
+ const rest = decoder2.decode();
67947
+ if (rest) {
67948
+ yield rest;
67949
+ }
67950
+ }
65898
67951
 
65899
67952
  // src/sandbox_snapshot.ts
65900
67953
  var SandboxSnapshot = class {
@@ -66447,6 +68500,9 @@ var SandboxService = class {
66447
68500
  * Create a new {@link Sandbox} in the {@link App} with the specified {@link Image} and options.
66448
68501
  */
66449
68502
  async create(app, image, params = {}) {
68503
+ if (this.#client.profile.sandboxV2 && !params.gpu) {
68504
+ return await this.experimentalCreate(app, image, params);
68505
+ }
66450
68506
  await image.build(app);
66451
68507
  const mergedSecrets = await mergeEnvIntoSecrets(
66452
68508
  this.#client,
@@ -66574,6 +68630,13 @@ var SandboxService = class {
66574
68630
  * @returns Promise that resolves to a Sandbox
66575
68631
  */
66576
68632
  async fromName(appName, name, params) {
68633
+ if (this.#client.profile.sandboxV2) {
68634
+ try {
68635
+ return await this.experimentalFromName(appName, name, params);
68636
+ } catch (err) {
68637
+ if (!(err instanceof NotFoundError)) throw err;
68638
+ }
68639
+ }
66577
68640
  try {
66578
68641
  const resp = await this.#client.cpClient.sandboxGetFromName({
66579
68642
  sandboxName: name,
@@ -66672,6 +68735,10 @@ var SandboxService = class {
66672
68735
  * If tags are specified, only Sandboxes that have at least those tags are returned.
66673
68736
  */
66674
68737
  async *list(params = {}) {
68738
+ if (this.#client.profile.sandboxV2) {
68739
+ yield* this.experimentalList(params);
68740
+ return;
68741
+ }
66675
68742
  const env = this.#client.environmentName(params.environment);
66676
68743
  const tagsList = params.tags ? Object.entries(params.tags).map(([tagName, tagValue]) => ({
66677
68744
  tagName,
@@ -66728,20 +68795,27 @@ var SandboxService = class {
66728
68795
  })) : [];
66729
68796
  let beforeTimestamp = void 0;
66730
68797
  while (true) {
66731
- const resp = await this.#client.cpClient.sandboxListV2({
66732
- appId: params.appId,
66733
- beforeTimestamp,
66734
- environmentName,
66735
- includeFinished: false,
66736
- tags: tagsList
66737
- });
66738
- if (!resp.sandboxes || resp.sandboxes.length === 0) {
66739
- return;
66740
- }
66741
- for (const info of resp.sandboxes) {
66742
- yield new Sandbox2(this.#client, info.id);
68798
+ try {
68799
+ const resp = await this.#client.cpClient.sandboxListV2({
68800
+ appId: params.appId,
68801
+ beforeTimestamp,
68802
+ environmentName,
68803
+ includeFinished: false,
68804
+ tags: tagsList
68805
+ });
68806
+ if (!resp.sandboxes || resp.sandboxes.length === 0) {
68807
+ return;
68808
+ }
68809
+ for (const info of resp.sandboxes) {
68810
+ yield new Sandbox2(this.#client, info.id);
68811
+ }
68812
+ beforeTimestamp = resp.sandboxes[resp.sandboxes.length - 1].createdAt;
68813
+ } catch (err) {
68814
+ if (err instanceof import_nice_grpc12.ClientError && err.code === import_nice_grpc12.Status.INVALID_ARGUMENT) {
68815
+ throw new InvalidError(err.details || err.message);
68816
+ }
68817
+ throw err;
66743
68818
  }
66744
- beforeTimestamp = resp.sandboxes[resp.sandboxes.length - 1].createdAt;
66745
68819
  }
66746
68820
  }
66747
68821
  };
@@ -66873,17 +68947,26 @@ function buildTaskExecStartRequestProto(taskId, execId, command, params, contain
66873
68947
  containerId: containerId ?? ""
66874
68948
  });
66875
68949
  }
66876
- function buildTaskMountDirectoryRequestProto(taskId, path2, imageId, params) {
68950
+ function buildTaskMountDirectoryRequestProto(taskId, path2, imageId, params, containerId = "") {
66877
68951
  return TaskMountDirectoryRequest.create({
66878
68952
  taskId,
66879
68953
  path: new TextEncoder().encode(path2),
66880
68954
  imageId,
66881
68955
  customerSuppliedEncryptionKey: validateExperimentalEncryptionKey(
66882
68956
  params?.experimentalEncryptionKey
66883
- )
68957
+ ),
68958
+ containerId
66884
68959
  });
66885
68960
  }
66886
- function buildTaskSnapshotDirectoryRequestProto(taskId, path2, snapshotId, ttlSeconds, params) {
68961
+ function resolveMountImageId(image) {
68962
+ if (image && !image.imageId) {
68963
+ throw new Error(
68964
+ "Image must be built before mounting. Call `image.build(app)` first."
68965
+ );
68966
+ }
68967
+ return image?.imageId ?? "";
68968
+ }
68969
+ function buildTaskSnapshotDirectoryRequestProto(taskId, path2, snapshotId, ttlSeconds, params, containerId = "") {
66887
68970
  return TaskSnapshotDirectoryRequest.create({
66888
68971
  taskId,
66889
68972
  path: new TextEncoder().encode(path2),
@@ -66891,7 +68974,8 @@ function buildTaskSnapshotDirectoryRequestProto(taskId, path2, snapshotId, ttlSe
66891
68974
  ttlSeconds,
66892
68975
  customerSuppliedEncryptionKey: validateExperimentalEncryptionKey(
66893
68976
  params?.experimentalEncryptionKey
66894
- )
68977
+ ),
68978
+ containerId
66895
68979
  });
66896
68980
  }
66897
68981
  var Sandbox2 = class _Sandbox {
@@ -66900,8 +68984,6 @@ var Sandbox2 = class _Sandbox {
66900
68984
  #stdin;
66901
68985
  #stdout;
66902
68986
  #stderr;
66903
- #stdoutAbort;
66904
- #stderrAbort;
66905
68987
  #taskId;
66906
68988
  #tunnels;
66907
68989
  #isV2;
@@ -66926,51 +69008,57 @@ var Sandbox2 = class _Sandbox {
66926
69008
  this.#initCommandRouterAccess = params.initCommandRouterAccess;
66927
69009
  }
66928
69010
  get stdin() {
66929
- this.#ensureV1("stdin");
66930
69011
  if (!this.#stdin) {
66931
69012
  this.#stdin = toModalWriteStream(
66932
- inputStreamSb(this.#client.cpClient, this.sandboxId)
69013
+ this.#isV2 ? inputStreamSbV2(() => this.#getCommandRouter()) : inputStreamSb(this.#client.cpClient, this.sandboxId)
66933
69014
  );
66934
69015
  }
66935
69016
  return this.#stdin;
66936
69017
  }
66937
69018
  get stdout() {
66938
- this.#ensureV1("stdout");
66939
69019
  if (!this.#stdout) {
66940
- this.#stdoutAbort = new AbortController();
66941
- const bytesStream = streamConsumingIter(
66942
- outputStreamSb(
66943
- this.#client.cpClient,
66944
- this.sandboxId,
66945
- 1 /* FILE_DESCRIPTOR_STDOUT */,
66946
- this.#stdoutAbort.signal
66947
- ),
66948
- () => this.#stdoutAbort?.abort()
66949
- );
66950
- this.#stdout = toModalReadStream(
66951
- bytesStream.pipeThrough(new TextDecoderStream())
66952
- );
69020
+ this.#stdout = this.#outputStream(1 /* FILE_DESCRIPTOR_STDOUT */);
66953
69021
  }
66954
69022
  return this.#stdout;
66955
69023
  }
66956
69024
  get stderr() {
66957
- this.#ensureV1("stderr");
66958
69025
  if (!this.#stderr) {
66959
- this.#stderrAbort = new AbortController();
66960
- const bytesStream = streamConsumingIter(
69026
+ this.#stderr = this.#outputStream(2 /* FILE_DESCRIPTOR_STDERR */);
69027
+ }
69028
+ return this.#stderr;
69029
+ }
69030
+ #outputStream(fileDescriptor) {
69031
+ if (this.#isV2) {
69032
+ this.#ensureAttached();
69033
+ const v2Abort = new AbortController();
69034
+ return toModalReadStream(
69035
+ streamConsumingIter(
69036
+ decodeTextIter(
69037
+ outputStreamSbV2(
69038
+ () => this.#getCommandRouter(v2Abort.signal),
69039
+ this.sandboxId,
69040
+ fileDescriptor,
69041
+ this.#client.logger,
69042
+ v2Abort.signal
69043
+ )
69044
+ ),
69045
+ () => v2Abort.abort()
69046
+ )
69047
+ );
69048
+ }
69049
+ const abort = new AbortController();
69050
+ return toModalReadStream(
69051
+ streamConsumingIter(
66961
69052
  outputStreamSb(
66962
69053
  this.#client.cpClient,
66963
69054
  this.sandboxId,
66964
- 2 /* FILE_DESCRIPTOR_STDERR */,
66965
- this.#stderrAbort.signal
69055
+ fileDescriptor,
69056
+ this.#client.profile.sandboxChannelIdleTimeoutMs,
69057
+ abort.signal
66966
69058
  ),
66967
- () => this.#stderrAbort?.abort()
66968
- );
66969
- this.#stderr = toModalReadStream(
66970
- bytesStream.pipeThrough(new TextDecoderStream())
66971
- );
66972
- }
66973
- return this.#stderr;
69059
+ () => abort.abort()
69060
+ )
69061
+ );
66974
69062
  }
66975
69063
  get filesystem() {
66976
69064
  this.#ensureAttached();
@@ -66994,7 +69082,8 @@ var Sandbox2 = class _Sandbox {
66994
69082
  client: this.#client,
66995
69083
  exec: (command, params, containerId) => this.#execInternal(command, params, containerId),
66996
69084
  commandRouter: () => this.#getCommandRouter(),
66997
- reloadVolumes: (containerId, params) => this.#reloadVolumes(containerId, params)
69085
+ reloadVolumes: (containerId, params) => this.#reloadVolumes(containerId, params),
69086
+ snapshotFilesystem: (containerId, params) => this.#snapshotFilesystem(containerId, params)
66998
69087
  });
66999
69088
  }
67000
69089
  return this.#sidecars;
@@ -67114,7 +69203,7 @@ var Sandbox2 = class _Sandbox {
67114
69203
  secrets: resolvableSecrets
67115
69204
  };
67116
69205
  const [taskId, commandRouterClient] = await this.#getCommandRouter();
67117
- const execId = (0, import_uuid.v4)();
69206
+ const execId = (0, import_uuid2.v4)();
67118
69207
  const request = buildTaskExecStartRequestProto(
67119
69208
  taskId,
67120
69209
  execId,
@@ -67143,9 +69232,9 @@ var Sandbox2 = class _Sandbox {
67143
69232
  deadline
67144
69233
  );
67145
69234
  }
67146
- async #getCommandRouter() {
69235
+ async #getCommandRouter(signal) {
67147
69236
  this.#ensureAttached();
67148
- const taskId = await this.#getTaskId();
69237
+ const taskId = await this.#getTaskId(signal);
67149
69238
  const client = await this.#getOrCreateCommandRouterClient(taskId);
67150
69239
  return [taskId, client];
67151
69240
  }
@@ -67154,13 +69243,6 @@ var Sandbox2 = class _Sandbox {
67154
69243
  throw new ClientClosedError();
67155
69244
  }
67156
69245
  }
67157
- #ensureV1(methodName) {
67158
- if (this.#isV2) {
67159
- throw new InvalidError(
67160
- `Sandbox.${methodName} is not supported for V2 sandboxes`
67161
- );
67162
- }
67163
- }
67164
69246
  #ensureV2(methodName) {
67165
69247
  if (!this.#isV2) {
67166
69248
  throw new InvalidError(
@@ -67175,12 +69257,12 @@ var Sandbox2 = class _Sandbox {
67175
69257
  }
67176
69258
  return this.#client.cpClient.sandboxWait(req);
67177
69259
  }
67178
- #sandboxGetTaskId() {
69260
+ #sandboxGetTaskId(signal) {
67179
69261
  const req = { sandboxId: this.sandboxId };
67180
69262
  if (this.#isV2) {
67181
- return this.#client.cpClient.sandboxGetTaskIdV2(req);
69263
+ return this.#client.cpClient.sandboxGetTaskIdV2(req, { signal });
67182
69264
  }
67183
- return this.#client.cpClient.sandboxGetTaskId(req);
69265
+ return this.#client.cpClient.sandboxGetTaskId(req, { signal });
67184
69266
  }
67185
69267
  #sandboxGetTunnels(timeoutMs) {
67186
69268
  const req = { sandboxId: this.sandboxId, timeout: timeoutMs / 1e3 };
@@ -67206,12 +69288,16 @@ var Sandbox2 = class _Sandbox {
67206
69288
  }
67207
69289
  static #maxGetTaskIdAttempts = 600;
67208
69290
  // 5 minutes at 500ms intervals
67209
- async #getTaskId() {
69291
+ async #getTaskId(signal) {
67210
69292
  if (this.#taskId !== void 0) {
67211
69293
  return this.#taskId;
67212
69294
  }
67213
69295
  for (let i = 0; i < _Sandbox.#maxGetTaskIdAttempts; i++) {
67214
- const resp = await this.#sandboxGetTaskId();
69296
+ const resp = await this.#sandboxGetTaskId(signal);
69297
+ if (resp.taskId) {
69298
+ this.#taskId = resp.taskId;
69299
+ return this.#taskId;
69300
+ }
67215
69301
  if (resp.taskResult) {
67216
69302
  if (resp.taskResult.status === 1 /* GENERIC_STATUS_SUCCESS */ || !resp.taskResult.exception) {
67217
69303
  throw new Error(`Sandbox ${this.sandboxId} has already completed`);
@@ -67220,11 +69306,7 @@ var Sandbox2 = class _Sandbox {
67220
69306
  `Sandbox ${this.sandboxId} has already completed with result: exception:"${resp.taskResult.exception}"`
67221
69307
  );
67222
69308
  }
67223
- if (resp.taskId) {
67224
- this.#taskId = resp.taskId;
67225
- return this.#taskId;
67226
- }
67227
- await (0, import_promises3.setTimeout)(500);
69309
+ await (0, import_promises3.setTimeout)(500, void 0, { signal });
67228
69310
  }
67229
69311
  throw new Error(
67230
69312
  `Timed out waiting for task ID for Sandbox ${this.sandboxId}`
@@ -67297,18 +69379,19 @@ var Sandbox2 = class _Sandbox {
67297
69379
  if (params?.wait) {
67298
69380
  exitCode = await this.wait();
67299
69381
  }
67300
- this.#taskId = void 0;
67301
- this.detach();
67302
69382
  return exitCode;
67303
69383
  }
67304
69384
  /**
67305
69385
  * Disconnect from the Sandbox, cleaning up local resources.
67306
69386
  * The Sandbox continues running on Modal's infrastructure.
67307
69387
  * After calling detach(), most operations on this Sandbox object will throw.
69388
+ *
69389
+ * This does not block on or interrupt ongoing reads or calls. Connection
69390
+ * resources are closed promptly once those operations finish.
67308
69391
  */
67309
69392
  detach() {
67310
- this.#commandRouterClient?.close();
67311
69393
  this.#attached = false;
69394
+ this.#commandRouterClient?.closeWhenIdle();
67312
69395
  this.#commandRouterClient = void 0;
67313
69396
  this.#commandRouterClientPromise = void 0;
67314
69397
  }
@@ -67387,13 +69470,17 @@ var Sandbox2 = class _Sandbox {
67387
69470
  */
67388
69471
  async snapshotFilesystem(params) {
67389
69472
  this.#ensureAttached();
69473
+ return this.#snapshotFilesystem("", params);
69474
+ }
69475
+ async #snapshotFilesystem(containerId, params) {
67390
69476
  const wireTtlSeconds = resolveTtlSeconds(params?.ttlMs);
67391
69477
  const timeoutMs = params?.timeoutMs || 55e3;
67392
69478
  const [taskId, commandRouterClient] = await this.#getCommandRouter();
67393
69479
  const request = TaskSnapshotFilesystemRequest.create({
67394
69480
  taskId,
67395
- snapshotId: (0, import_uuid.v4)(),
67396
- ttlSeconds: wireTtlSeconds
69481
+ snapshotId: (0, import_uuid2.v4)(),
69482
+ ttlSeconds: wireTtlSeconds,
69483
+ containerId
67397
69484
  });
67398
69485
  const response = await commandRouterClient.snapshotFilesystem(request, {
67399
69486
  timeoutMs
@@ -67406,13 +69493,39 @@ var Sandbox2 = class _Sandbox {
67406
69493
  /**
67407
69494
  * Get the exit filesystem snapshot image.
67408
69495
  *
69496
+ * An exit snapshot captures the Sandbox filesystem when the Sandbox exits,
69497
+ * whether its entrypoint finishes gracefully, abruptly, or it is stopped with
69498
+ * {@link Sandbox#terminate}. The resulting {@link Image} can be passed to
69499
+ * {@link SandboxService#create client.sandboxes.create()} to start a new
69500
+ * Sandbox from the saved filesystem.
69501
+ *
69502
+ * Exit snapshots are opt-in: the Sandbox must have been created with
69503
+ * `experimentalOptions: { enable_exit_snapshot: true }`. Calling this on a
69504
+ * Sandbox created without that option throws an {@link InvalidError}.
69505
+ *
69506
+ * @example
69507
+ * ```ts
69508
+ * const sb = await modal.sandboxes.create(app, image, {
69509
+ * experimentalOptions: { enable_exit_snapshot: true },
69510
+ * });
69511
+ * // ... use the Sandbox ...
69512
+ * await sb.terminate();
69513
+ * const image = await sb.experimentalGetExitSnapshot();
69514
+ * const sb2 = await modal.sandboxes.create(app, image);
69515
+ * ```
69516
+ *
67409
69517
  * EXPERIMENTAL: the API is subject to change.
67410
69518
  *
67411
69519
  * @param params - Optional parameters; see SandboxExperimentalGetExitSnapshotParams.
67412
69520
  * @returns The exit snapshot Image.
69521
+ * @throws {InvalidError} If `timeoutMs` is negative, or if exit snapshots
69522
+ * were not enabled when the Sandbox was created.
67413
69523
  * @throws {TimeoutError} If `timeoutMs` elapses before the snapshot
67414
69524
  * reaches a terminal state. This includes `timeoutMs = 0` when the
67415
69525
  * snapshot is still pending.
69526
+ * @throws {SnapshotCreationError} Snapshot operation is done and failed.
69527
+ * Polling again will not produce an Image; filesystem state is gone.
69528
+ * @throws {NotFoundError} If the Sandbox does not exist.
67416
69529
  */
67417
69530
  async experimentalGetExitSnapshot(params) {
67418
69531
  const timeoutMs = params?.timeoutMs;
@@ -67524,8 +69637,8 @@ var Sandbox2 = class _Sandbox {
67524
69637
  if (this.#isV2) {
67525
69638
  const [taskId, commandRouterClient] = await this.#getCommandRouter();
67526
69639
  const resp = await commandRouterClient.snapshotMemory(
67527
- TaskSnapshotMemoryRequest.create({ taskId, idempotencyKey: (0, import_uuid.v4)() }),
67528
- { timeoutMs: 55e3 }
69640
+ TaskSnapshotMemoryRequest.create({ taskId, idempotencyKey: (0, import_uuid2.v4)() }),
69641
+ { timeoutMs: 165e3 }
67529
69642
  );
67530
69643
  snapshotId = resp.snapshotId;
67531
69644
  } else {
@@ -67554,12 +69667,7 @@ var Sandbox2 = class _Sandbox {
67554
69667
  async mountImage(path2, image, params) {
67555
69668
  this.#ensureAttached();
67556
69669
  const [taskId, commandRouterClient] = await this.#getCommandRouter();
67557
- if (image && !image.imageId) {
67558
- throw new Error(
67559
- "Image must be built before mounting. Call `image.build(app)` first."
67560
- );
67561
- }
67562
- const imageId = image?.imageId ?? "";
69670
+ const imageId = resolveMountImageId(image);
67563
69671
  const request = buildTaskMountDirectoryRequestProto(
67564
69672
  taskId,
67565
69673
  path2,
@@ -67655,7 +69763,7 @@ var Sandbox2 = class _Sandbox {
67655
69763
  const request = buildTaskSnapshotDirectoryRequestProto(
67656
69764
  taskId,
67657
69765
  path2,
67658
- (0, import_uuid.v4)(),
69766
+ (0, import_uuid2.v4)(),
67659
69767
  wireTtlSeconds,
67660
69768
  params
67661
69769
  );
@@ -67698,35 +69806,28 @@ var ContainerProcess2 = class {
67698
69806
  this.stdin = toModalWriteStream(
67699
69807
  inputStreamCp(commandRouterClient, taskId, execId)
67700
69808
  );
67701
- const stdoutStream = stdout === "ignore" ? ReadableStream.from([]) : streamConsumingIter(
67702
- outputStreamCp(
69809
+ const output = (behavior, fileDescriptor) => {
69810
+ if (behavior === "ignore") {
69811
+ return ReadableStream.from([]);
69812
+ }
69813
+ const abort = new AbortController();
69814
+ const bytes = outputStreamCp(
67703
69815
  commandRouterClient,
67704
69816
  taskId,
67705
69817
  execId,
67706
- 1 /* FILE_DESCRIPTOR_STDOUT */,
67707
- this.#deadline
67708
- )
69818
+ fileDescriptor,
69819
+ this.#deadline,
69820
+ abort.signal
69821
+ );
69822
+ const stream = mode === "text" ? streamConsumingIter(decodeTextIter(bytes), () => abort.abort()) : streamConsumingIter(bytes, () => abort.abort());
69823
+ return stream;
69824
+ };
69825
+ this.stdout = toModalReadStream(
69826
+ output(stdout, 1 /* FILE_DESCRIPTOR_STDOUT */)
67709
69827
  );
67710
- const stderrStream = stderr === "ignore" ? ReadableStream.from([]) : streamConsumingIter(
67711
- outputStreamCp(
67712
- commandRouterClient,
67713
- taskId,
67714
- execId,
67715
- 2 /* FILE_DESCRIPTOR_STDERR */,
67716
- this.#deadline
67717
- )
69828
+ this.stderr = toModalReadStream(
69829
+ output(stderr, 2 /* FILE_DESCRIPTOR_STDERR */)
67718
69830
  );
67719
- if (mode === "text") {
67720
- this.stdout = toModalReadStream(
67721
- stdoutStream.pipeThrough(new TextDecoderStream())
67722
- );
67723
- this.stderr = toModalReadStream(
67724
- stderrStream.pipeThrough(new TextDecoderStream())
67725
- );
67726
- } else {
67727
- this.stdout = toModalReadStream(stdoutStream);
67728
- this.stderr = toModalReadStream(stderrStream);
67729
- }
67730
69831
  }
67731
69832
  /**
67732
69833
  * @ignore
@@ -67789,12 +69890,20 @@ var ContainerProcess2 = class {
67789
69890
  }
67790
69891
  }
67791
69892
  };
67792
- async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, signal) {
69893
+ async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, idleTimeoutMs, signal) {
67793
69894
  let lastIndex = "0-0";
67794
69895
  let completed = false;
67795
69896
  let retriesRemaining = SB_LOGS_MAX_RETRIES;
67796
69897
  let delayMs = SB_LOGS_INITIAL_DELAY_MS;
67797
69898
  while (!completed) {
69899
+ if (signal?.aborted) return;
69900
+ const idle = new IdleCountdown();
69901
+ const idleAbort = new AbortController();
69902
+ const releaseIfIdle = () => {
69903
+ idle.stop();
69904
+ idleAbort.abort();
69905
+ };
69906
+ const callSignal = signal === void 0 ? idleAbort.signal : AbortSignal.any([signal, idleAbort.signal]);
67798
69907
  try {
67799
69908
  const outputIterator = cpClient.sandboxGetLogs(
67800
69909
  {
@@ -67803,13 +69912,22 @@ async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, signal) {
67803
69912
  timeout: 55,
67804
69913
  lastEntryId: lastIndex
67805
69914
  },
67806
- { signal }
69915
+ { signal: callSignal }
67807
69916
  );
67808
69917
  for await (const batch of outputIterator) {
67809
69918
  delayMs = SB_LOGS_INITIAL_DELAY_MS;
67810
69919
  retriesRemaining = SB_LOGS_MAX_RETRIES;
67811
69920
  lastIndex = batch.entryId;
67812
- yield* batch.items.map((item) => new TextEncoder().encode(item.data));
69921
+ for (const item of batch.items) {
69922
+ if (!idleAbort.signal.aborted) {
69923
+ idle.arm(idleTimeoutMs, releaseIfIdle);
69924
+ }
69925
+ try {
69926
+ yield item.data;
69927
+ } finally {
69928
+ idle.stop();
69929
+ }
69930
+ }
67813
69931
  if (batch.eof) {
67814
69932
  completed = true;
67815
69933
  break;
@@ -67817,11 +69935,20 @@ async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, signal) {
67817
69935
  if (signal?.aborted) {
67818
69936
  return;
67819
69937
  }
69938
+ if (idleAbort.signal.aborted) {
69939
+ break;
69940
+ }
69941
+ }
69942
+ if (idleAbort.signal.aborted) {
69943
+ continue;
67820
69944
  }
67821
69945
  } catch (err) {
67822
69946
  if (signal?.aborted) {
67823
69947
  return;
67824
69948
  }
69949
+ if (idleAbort.signal.aborted) {
69950
+ continue;
69951
+ }
67825
69952
  if (isRetryableGrpc(err) && retriesRemaining > 0) {
67826
69953
  try {
67827
69954
  await (0, import_promises3.setTimeout)(delayMs, void 0, { signal });
@@ -67834,7 +69961,37 @@ async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, signal) {
67834
69961
  } else {
67835
69962
  throw err;
67836
69963
  }
69964
+ } finally {
69965
+ idle.stop();
69966
+ }
69967
+ }
69968
+ }
69969
+ async function* outputStreamSbV2(getCommandRouter, sandboxId, fileDescriptor, logger2, signal) {
69970
+ const [taskId, commandRouterClient] = await getCommandRouter();
69971
+ let firstChunk = true;
69972
+ for await (const item of commandRouterClient.sandboxStdioReadV2(
69973
+ taskId,
69974
+ fileDescriptor,
69975
+ signal
69976
+ )) {
69977
+ if (item.data.length === 0) {
69978
+ throw new Error(
69979
+ `Received empty message streaming stdio from Sandbox ${sandboxId}`
69980
+ );
69981
+ }
69982
+ if (firstChunk) {
69983
+ firstChunk = false;
69984
+ if (item.startingOffset > 0) {
69985
+ logger2.warn(
69986
+ "V2 Sandbox stdio: dropped bytes. Only the most recent portion of output is retained",
69987
+ "sandbox_id",
69988
+ sandboxId,
69989
+ "dropped_bytes",
69990
+ item.startingOffset
69991
+ );
69992
+ }
67837
69993
  }
69994
+ yield item.data;
67838
69995
  }
67839
69996
  }
67840
69997
  function inputStreamSb(cpClient, sandboxId) {
@@ -67857,12 +70014,40 @@ function inputStreamSb(cpClient, sandboxId) {
67857
70014
  }
67858
70015
  });
67859
70016
  }
67860
- async function* outputStreamCp(commandRouterClient, taskId, execId, fileDescriptor, deadline) {
70017
+ function inputStreamSbV2(getCommandRouter) {
70018
+ let offset = 0;
70019
+ return new WritableStream({
70020
+ async write(chunk) {
70021
+ const [taskId, commandRouterClient] = await getCommandRouter();
70022
+ const data = encodeIfString(chunk);
70023
+ await commandRouterClient.sandboxStdinWriteV2(
70024
+ taskId,
70025
+ offset,
70026
+ data,
70027
+ false
70028
+ // eof
70029
+ );
70030
+ offset += data.length;
70031
+ },
70032
+ async close() {
70033
+ const [taskId, commandRouterClient] = await getCommandRouter();
70034
+ await commandRouterClient.sandboxStdinWriteV2(
70035
+ taskId,
70036
+ offset,
70037
+ new Uint8Array(0),
70038
+ true
70039
+ // eof
70040
+ );
70041
+ }
70042
+ });
70043
+ }
70044
+ async function* outputStreamCp(commandRouterClient, taskId, execId, fileDescriptor, deadline, signal) {
67861
70045
  for await (const batch of commandRouterClient.execStdioRead(
67862
70046
  taskId,
67863
70047
  execId,
67864
70048
  fileDescriptor,
67865
- deadline
70049
+ deadline,
70050
+ signal
67866
70051
  )) {
67867
70052
  yield batch.data;
67868
70053
  }
@@ -68089,7 +70274,7 @@ var AuthTokenManager = class {
68089
70274
  };
68090
70275
 
68091
70276
  // src/version.ts
68092
- var SDK_VERSION = "0.10.0";
70277
+ var SDK_VERSION = "0.10.1";
68093
70278
  function getSDKVersion() {
68094
70279
  return SDK_VERSION;
68095
70280
  }
@@ -68153,6 +70338,57 @@ var EnvironmentManager = class {
68153
70338
  }
68154
70339
  };
68155
70340
 
70341
+ // src/oauth.ts
70342
+ var import_node_crypto3 = require("crypto");
70343
+ var import_uuid3 = require("uuid");
70344
+ var OAUTH_CLIENT_ASSERTION_AUDIENCE = "modal-server";
70345
+ var OAUTH_CLIENT_ASSERTION_LIFETIME_SECONDS = 5 * 60;
70346
+ var MIN_RSA_KEY_SIZE = 2048;
70347
+ var INVALID_KEY_MESSAGE = "oauth_jwt_key must be an unencrypted RSA private key encoded as PEM.";
70348
+ function parseOAuthJwtKey(privateKeyPem) {
70349
+ let key;
70350
+ try {
70351
+ key = (0, import_node_crypto3.createPrivateKey)(privateKeyPem.replaceAll("\\n", "\n"));
70352
+ } catch {
70353
+ throw new InvalidError(INVALID_KEY_MESSAGE);
70354
+ }
70355
+ if (key.asymmetricKeyType !== "rsa") {
70356
+ throw new InvalidError(INVALID_KEY_MESSAGE);
70357
+ }
70358
+ if ((key.asymmetricKeyDetails?.modulusLength ?? 0) < MIN_RSA_KEY_SIZE) {
70359
+ throw new InvalidError("oauth_jwt_key must be at least 2048 bits.");
70360
+ }
70361
+ return key;
70362
+ }
70363
+ function rsaJwkThumbprint(key) {
70364
+ const publicKey = key.type === "public" ? key : (0, import_node_crypto3.createPublicKey)(key);
70365
+ const jwk = publicKey.export({ format: "jwk" });
70366
+ const canonical = JSON.stringify({ e: jwk.e, kty: "RSA", n: jwk.n });
70367
+ return (0, import_node_crypto3.createHash)("sha256").update(canonical).digest("base64url");
70368
+ }
70369
+ function base64UrlJson(value) {
70370
+ return Buffer.from(JSON.stringify(value), "utf-8").toString("base64url");
70371
+ }
70372
+ function mintOAuthClientAssertion(clientId, key) {
70373
+ const issuedAt = Math.floor(Date.now() / 1e3);
70374
+ const header = base64UrlJson({
70375
+ alg: "RS256",
70376
+ typ: "JWT",
70377
+ kid: rsaJwkThumbprint(key)
70378
+ });
70379
+ const payload = base64UrlJson({
70380
+ iss: clientId,
70381
+ sub: clientId,
70382
+ aud: OAUTH_CLIENT_ASSERTION_AUDIENCE,
70383
+ iat: issuedAt,
70384
+ exp: issuedAt + OAUTH_CLIENT_ASSERTION_LIFETIME_SECONDS,
70385
+ jti: (0, import_uuid3.v4)()
70386
+ });
70387
+ const signingInput = `${header}.${payload}`;
70388
+ const signature = (0, import_node_crypto3.createSign)("RSA-SHA256").update(signingInput).sign(key).toString("base64url");
70389
+ return `${signingInput}.${signature}`;
70390
+ }
70391
+
68156
70392
  // src/client.ts
68157
70393
  var ModalClient = class {
68158
70394
  apps;
@@ -68175,18 +70411,40 @@ var ModalClient = class {
68175
70411
  authTokenManager = null;
68176
70412
  customMiddleware;
68177
70413
  environmentManager;
70414
+ oauthJwtKey;
68178
70415
  constructor(params) {
68179
70416
  checkForRenamedParams(params, { timeout: "timeoutMs" });
68180
70417
  const baseProfile = getProfile(process.env["MODAL_PROFILE"]);
70418
+ const hasTokenParams = params?.tokenId !== void 0 || params?.tokenSecret !== void 0;
70419
+ const hasOAuthParams = params?.oauthRefreshToken !== void 0 || params?.oauthClientId !== void 0 || params?.oauthClientSecret !== void 0 || params?.oauthJwtKey !== void 0;
68181
70420
  this.profile = {
68182
70421
  ...baseProfile,
68183
- ...params?.tokenId && { tokenId: params.tokenId },
68184
- ...params?.tokenSecret && { tokenSecret: params.tokenSecret },
68185
70422
  ...params?.environment && { environment: params.environment },
68186
70423
  ...params?.maxThrottleWaitSecs !== void 0 && {
68187
70424
  maxThrottleWaitSecs: params.maxThrottleWaitSecs
68188
70425
  }
68189
70426
  };
70427
+ if (hasTokenParams) {
70428
+ if (params?.tokenId !== void 0) {
70429
+ this.profile.tokenId = params.tokenId;
70430
+ }
70431
+ if (params?.tokenSecret !== void 0) {
70432
+ this.profile.tokenSecret = params.tokenSecret;
70433
+ }
70434
+ this.profile.oauthRefreshToken = void 0;
70435
+ this.profile.oauthClientId = void 0;
70436
+ this.profile.oauthClientSecret = void 0;
70437
+ this.profile.oauthJwtKey = void 0;
70438
+ } else if (hasOAuthParams) {
70439
+ this.profile.tokenId = void 0;
70440
+ this.profile.tokenSecret = void 0;
70441
+ this.profile.oauthRefreshToken = params?.oauthRefreshToken;
70442
+ this.profile.oauthClientId = params?.oauthClientId;
70443
+ this.profile.oauthClientSecret = params?.oauthClientSecret;
70444
+ this.profile.oauthJwtKey = params?.oauthJwtKey;
70445
+ }
70446
+ this.validateProfileCredentials(hasOAuthParams);
70447
+ this.oauthJwtKey = this.profile.oauthJwtKey ? parseOAuthJwtKey(this.profile.oauthJwtKey) : void 0;
68190
70448
  const logLevelValue = params?.logLevel || this.profile.logLevel || "";
68191
70449
  this.logger = createLogger(params?.logger, logLevelValue);
68192
70450
  this.logger.debug(
@@ -68220,6 +70478,24 @@ var ModalClient = class {
68220
70478
  environmentName(environment) {
68221
70479
  return environment || this.profile.environment || "";
68222
70480
  }
70481
+ validateProfileCredentials(hasExplicitOAuthCredentials) {
70482
+ const hasTokenCredentials = Boolean(
70483
+ this.profile.tokenId || this.profile.tokenSecret
70484
+ );
70485
+ const hasOAuthCredentials = hasExplicitOAuthCredentials || Boolean(
70486
+ this.profile.oauthRefreshToken || this.profile.oauthClientId || this.profile.oauthClientSecret || this.profile.oauthJwtKey
70487
+ );
70488
+ if (hasTokenCredentials && hasOAuthCredentials) {
70489
+ throw new InvalidError(
70490
+ "Modal token credentials and OAuth credentials cannot both be configured."
70491
+ );
70492
+ }
70493
+ if (hasOAuthCredentials && (!this.profile.oauthRefreshToken || !this.profile.oauthClientId || Boolean(this.profile.oauthClientSecret) === Boolean(this.profile.oauthJwtKey))) {
70494
+ throw new InvalidError(
70495
+ "OAuth refresh token, client ID, and exactly one of client secret or JWT key must all be configured."
70496
+ );
70497
+ }
70498
+ }
68223
70499
  /**
68224
70500
  * Returns the image builder version by querying the server where the local profile takes
68225
70501
  * precedence.
@@ -68286,13 +70562,13 @@ var ModalClient = class {
68286
70562
  ...restOptions
68287
70563
  } = options;
68288
70564
  if (call.requestStream || call.responseStream || !retries) {
68289
- return yield* call.next(call.request, restOptions);
70565
+ return yield* call.next(call.request, { ...restOptions, signal });
68290
70566
  }
68291
70567
  const retryableCodes = /* @__PURE__ */ new Set([
68292
70568
  ...retryableGrpcStatusCodes,
68293
70569
  ...additionalStatusCodes
68294
70570
  ]);
68295
- const idempotencyKey = (0, import_uuid2.v4)();
70571
+ const idempotencyKey = (0, import_uuid4.v4)();
68296
70572
  const throttleEnabled = maxThrottleWaitSecs !== 0;
68297
70573
  const startTime = Date.now();
68298
70574
  let attempt = 0;
@@ -68437,13 +70713,16 @@ var ModalClient = class {
68437
70713
  }
68438
70714
  return this.authTokenManager;
68439
70715
  };
70716
+ const oauthJwtKey = this.oauthJwtKey;
68440
70717
  return async function* authMiddleware(call, options) {
68441
- if (!profile.tokenId || !profile.tokenSecret) {
70718
+ const hasOAuthCredentials = Boolean(
70719
+ profile.oauthRefreshToken && profile.oauthClientId && (profile.oauthClientSecret || oauthJwtKey)
70720
+ );
70721
+ if (!hasOAuthCredentials && (!profile.tokenId || !profile.tokenSecret)) {
68442
70722
  throw new Error(
68443
- `Profile is missing token_id or token_secret. Please set them in .modal.toml, or as environment variables, or via ModalClient constructor.`
70723
+ `Profile is missing credentials. Please set them in .modal.toml, as environment variables, or via the ModalClient constructor.`
68444
70724
  );
68445
70725
  }
68446
- const { tokenId, tokenSecret } = profile;
68447
70726
  options.metadata ??= new import_nice_grpc14.Metadata();
68448
70727
  options.metadata.set(
68449
70728
  "x-modal-client-type",
@@ -68454,8 +70733,27 @@ var ModalClient = class {
68454
70733
  "x-modal-libmodal-version",
68455
70734
  `modal-js/${getSDKVersion()}`
68456
70735
  );
68457
- options.metadata.set("x-modal-token-id", tokenId);
68458
- options.metadata.set("x-modal-token-secret", tokenSecret);
70736
+ if (hasOAuthCredentials) {
70737
+ options.metadata.set(
70738
+ "x-modal-refresh-token",
70739
+ profile.oauthRefreshToken
70740
+ );
70741
+ options.metadata.set("x-modal-oauth-client-id", profile.oauthClientId);
70742
+ if (oauthJwtKey) {
70743
+ options.metadata.set(
70744
+ "x-modal-oauth-client-assertion",
70745
+ mintOAuthClientAssertion(profile.oauthClientId, oauthJwtKey)
70746
+ );
70747
+ } else {
70748
+ options.metadata.set(
70749
+ "x-modal-oauth-client-secret",
70750
+ profile.oauthClientSecret
70751
+ );
70752
+ }
70753
+ } else {
70754
+ options.metadata.set("x-modal-token-id", profile.tokenId);
70755
+ options.metadata.set("x-modal-token-secret", profile.tokenSecret);
70756
+ }
68459
70757
  if (call.method.path !== "/modal.client.ModalClient/AuthTokenGet") {
68460
70758
  const tokenManager = getOrCreateAuthTokenManager();
68461
70759
  const token = await tokenManager.getToken();
@@ -68463,6 +70761,7 @@ var ModalClient = class {
68463
70761
  options.metadata.set("x-modal-auth-token", token);
68464
70762
  }
68465
70763
  }
70764
+ options.signal?.throwIfAborted();
68466
70765
  return yield* call.next(call.request, options);
68467
70766
  };
68468
70767
  }