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.js CHANGED
@@ -1592,6 +1592,36 @@ function appStopSourceToJSON(object) {
1592
1592
  return "UNRECOGNIZED";
1593
1593
  }
1594
1594
  }
1595
+ function archFromJSON(object) {
1596
+ switch (object) {
1597
+ case 0:
1598
+ case "ARCH_UNSPECIFIED":
1599
+ return 0 /* ARCH_UNSPECIFIED */;
1600
+ case 1:
1601
+ case "ARCH_X86_64":
1602
+ return 1 /* ARCH_X86_64 */;
1603
+ case 2:
1604
+ case "ARCH_AARCH64":
1605
+ return 2 /* ARCH_AARCH64 */;
1606
+ case -1:
1607
+ case "UNRECOGNIZED":
1608
+ default:
1609
+ return -1 /* UNRECOGNIZED */;
1610
+ }
1611
+ }
1612
+ function archToJSON(object) {
1613
+ switch (object) {
1614
+ case 0 /* ARCH_UNSPECIFIED */:
1615
+ return "ARCH_UNSPECIFIED";
1616
+ case 1 /* ARCH_X86_64 */:
1617
+ return "ARCH_X86_64";
1618
+ case 2 /* ARCH_AARCH64 */:
1619
+ return "ARCH_AARCH64";
1620
+ case -1 /* UNRECOGNIZED */:
1621
+ default:
1622
+ return "UNRECOGNIZED";
1623
+ }
1624
+ }
1595
1625
  function certificateStatusFromJSON(object) {
1596
1626
  switch (object) {
1597
1627
  case 0:
@@ -2062,6 +2092,41 @@ function endpointStopSourceToJSON(object) {
2062
2092
  return "UNRECOGNIZED";
2063
2093
  }
2064
2094
  }
2095
+ function environmentBlockUnauthenticatedResourcesFromJSON(object) {
2096
+ switch (object) {
2097
+ case 0:
2098
+ case "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_UNSPECIFIED":
2099
+ return 0 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_UNSPECIFIED */;
2100
+ case 1:
2101
+ case "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_INHERIT":
2102
+ return 1 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_INHERIT */;
2103
+ case 2:
2104
+ case "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_BLOCK":
2105
+ return 2 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_BLOCK */;
2106
+ case 3:
2107
+ case "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_ALLOW":
2108
+ return 3 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_ALLOW */;
2109
+ case -1:
2110
+ case "UNRECOGNIZED":
2111
+ default:
2112
+ return -1 /* UNRECOGNIZED */;
2113
+ }
2114
+ }
2115
+ function environmentBlockUnauthenticatedResourcesToJSON(object) {
2116
+ switch (object) {
2117
+ case 0 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_UNSPECIFIED */:
2118
+ return "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_UNSPECIFIED";
2119
+ case 1 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_INHERIT */:
2120
+ return "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_INHERIT";
2121
+ case 2 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_BLOCK */:
2122
+ return "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_BLOCK";
2123
+ case 3 /* ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_ALLOW */:
2124
+ return "ENVIRONMENT_BLOCK_UNAUTHENTICATED_RESOURCES_ALLOW";
2125
+ case -1 /* UNRECOGNIZED */:
2126
+ default:
2127
+ return "UNRECOGNIZED";
2128
+ }
2129
+ }
2065
2130
  function environmentRoleFromJSON(object) {
2066
2131
  switch (object) {
2067
2132
  case 0:
@@ -5087,6 +5152,108 @@ var AppGetByDeploymentNameResponse = {
5087
5152
  return message;
5088
5153
  }
5089
5154
  };
5155
+ function createBaseAppGetInfoRequest() {
5156
+ return { appId: "" };
5157
+ }
5158
+ var AppGetInfoRequest = {
5159
+ encode(message, writer = new BinaryWriter()) {
5160
+ if (message.appId !== "") {
5161
+ writer.uint32(10).string(message.appId);
5162
+ }
5163
+ return writer;
5164
+ },
5165
+ decode(input, length) {
5166
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
5167
+ let end = length === void 0 ? reader.len : reader.pos + length;
5168
+ const message = createBaseAppGetInfoRequest();
5169
+ while (reader.pos < end) {
5170
+ const tag = reader.uint32();
5171
+ switch (tag >>> 3) {
5172
+ case 1: {
5173
+ if (tag !== 10) {
5174
+ break;
5175
+ }
5176
+ message.appId = reader.string();
5177
+ continue;
5178
+ }
5179
+ }
5180
+ if ((tag & 7) === 4 || tag === 0) {
5181
+ break;
5182
+ }
5183
+ reader.skip(tag & 7);
5184
+ }
5185
+ return message;
5186
+ },
5187
+ fromJSON(object) {
5188
+ return { appId: isSet5(object.appId) ? globalThis.String(object.appId) : "" };
5189
+ },
5190
+ toJSON(message) {
5191
+ const obj = {};
5192
+ if (message.appId !== "") {
5193
+ obj.appId = message.appId;
5194
+ }
5195
+ return obj;
5196
+ },
5197
+ create(base) {
5198
+ return AppGetInfoRequest.fromPartial(base ?? {});
5199
+ },
5200
+ fromPartial(object) {
5201
+ const message = createBaseAppGetInfoRequest();
5202
+ message.appId = object.appId ?? "";
5203
+ return message;
5204
+ }
5205
+ };
5206
+ function createBaseAppGetInfoResponse() {
5207
+ return { info: void 0 };
5208
+ }
5209
+ var AppGetInfoResponse = {
5210
+ encode(message, writer = new BinaryWriter()) {
5211
+ if (message.info !== void 0) {
5212
+ AppHandleMetadata.encode(message.info, writer.uint32(10).fork()).join();
5213
+ }
5214
+ return writer;
5215
+ },
5216
+ decode(input, length) {
5217
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
5218
+ let end = length === void 0 ? reader.len : reader.pos + length;
5219
+ const message = createBaseAppGetInfoResponse();
5220
+ while (reader.pos < end) {
5221
+ const tag = reader.uint32();
5222
+ switch (tag >>> 3) {
5223
+ case 1: {
5224
+ if (tag !== 10) {
5225
+ break;
5226
+ }
5227
+ message.info = AppHandleMetadata.decode(reader, reader.uint32());
5228
+ continue;
5229
+ }
5230
+ }
5231
+ if ((tag & 7) === 4 || tag === 0) {
5232
+ break;
5233
+ }
5234
+ reader.skip(tag & 7);
5235
+ }
5236
+ return message;
5237
+ },
5238
+ fromJSON(object) {
5239
+ return { info: isSet5(object.info) ? AppHandleMetadata.fromJSON(object.info) : void 0 };
5240
+ },
5241
+ toJSON(message) {
5242
+ const obj = {};
5243
+ if (message.info !== void 0) {
5244
+ obj.info = AppHandleMetadata.toJSON(message.info);
5245
+ }
5246
+ return obj;
5247
+ },
5248
+ create(base) {
5249
+ return AppGetInfoResponse.fromPartial(base ?? {});
5250
+ },
5251
+ fromPartial(object) {
5252
+ const message = createBaseAppGetInfoResponse();
5253
+ message.info = object.info !== void 0 && object.info !== null ? AppHandleMetadata.fromPartial(object.info) : void 0;
5254
+ return message;
5255
+ }
5256
+ };
5090
5257
  function createBaseAppGetLayoutRequest() {
5091
5258
  return { appId: "" };
5092
5259
  }
@@ -5794,13 +5961,16 @@ var AppGetOrCreateRequest = {
5794
5961
  }
5795
5962
  };
5796
5963
  function createBaseAppGetOrCreateResponse() {
5797
- return { appId: "" };
5964
+ return { appId: "", handleMetadata: void 0 };
5798
5965
  }
5799
5966
  var AppGetOrCreateResponse = {
5800
5967
  encode(message, writer = new BinaryWriter()) {
5801
5968
  if (message.appId !== "") {
5802
5969
  writer.uint32(10).string(message.appId);
5803
5970
  }
5971
+ if (message.handleMetadata !== void 0) {
5972
+ AppHandleMetadata.encode(message.handleMetadata, writer.uint32(18).fork()).join();
5973
+ }
5804
5974
  return writer;
5805
5975
  },
5806
5976
  decode(input, length) {
@@ -5817,6 +5987,13 @@ var AppGetOrCreateResponse = {
5817
5987
  message.appId = reader.string();
5818
5988
  continue;
5819
5989
  }
5990
+ case 2: {
5991
+ if (tag !== 18) {
5992
+ break;
5993
+ }
5994
+ message.handleMetadata = AppHandleMetadata.decode(reader, reader.uint32());
5995
+ continue;
5996
+ }
5820
5997
  }
5821
5998
  if ((tag & 7) === 4 || tag === 0) {
5822
5999
  break;
@@ -5826,13 +6003,19 @@ var AppGetOrCreateResponse = {
5826
6003
  return message;
5827
6004
  },
5828
6005
  fromJSON(object) {
5829
- return { appId: isSet5(object.appId) ? globalThis.String(object.appId) : "" };
6006
+ return {
6007
+ appId: isSet5(object.appId) ? globalThis.String(object.appId) : "",
6008
+ handleMetadata: isSet5(object.handleMetadata) ? AppHandleMetadata.fromJSON(object.handleMetadata) : void 0
6009
+ };
5830
6010
  },
5831
6011
  toJSON(message) {
5832
6012
  const obj = {};
5833
6013
  if (message.appId !== "") {
5834
6014
  obj.appId = message.appId;
5835
6015
  }
6016
+ if (message.handleMetadata !== void 0) {
6017
+ obj.handleMetadata = AppHandleMetadata.toJSON(message.handleMetadata);
6018
+ }
5836
6019
  return obj;
5837
6020
  },
5838
6021
  create(base) {
@@ -5841,6 +6024,7 @@ var AppGetOrCreateResponse = {
5841
6024
  fromPartial(object) {
5842
6025
  const message = createBaseAppGetOrCreateResponse();
5843
6026
  message.appId = object.appId ?? "";
6027
+ message.handleMetadata = object.handleMetadata !== void 0 && object.handleMetadata !== null ? AppHandleMetadata.fromPartial(object.handleMetadata) : void 0;
5844
6028
  return message;
5845
6029
  }
5846
6030
  };
@@ -6033,77 +6217,35 @@ var AppGetTagsResponse_TagsEntry = {
6033
6217
  return message;
6034
6218
  }
6035
6219
  };
6036
- function createBaseAppHeartbeatRequest() {
6037
- return { appId: "" };
6220
+ function createBaseAppHandleMetadata() {
6221
+ return { description: "", appId: "", environmentName: "", lifecycle: void 0, functions: {}, servers: {} };
6038
6222
  }
6039
- var AppHeartbeatRequest = {
6223
+ var AppHandleMetadata = {
6040
6224
  encode(message, writer = new BinaryWriter()) {
6041
- if (message.appId !== "") {
6042
- writer.uint32(10).string(message.appId);
6043
- }
6044
- return writer;
6045
- },
6046
- decode(input, length) {
6047
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6048
- let end = length === void 0 ? reader.len : reader.pos + length;
6049
- const message = createBaseAppHeartbeatRequest();
6050
- while (reader.pos < end) {
6051
- const tag = reader.uint32();
6052
- switch (tag >>> 3) {
6053
- case 1: {
6054
- if (tag !== 10) {
6055
- break;
6056
- }
6057
- message.appId = reader.string();
6058
- continue;
6059
- }
6060
- }
6061
- if ((tag & 7) === 4 || tag === 0) {
6062
- break;
6063
- }
6064
- reader.skip(tag & 7);
6225
+ if (message.description !== "") {
6226
+ writer.uint32(10).string(message.description);
6065
6227
  }
6066
- return message;
6067
- },
6068
- fromJSON(object) {
6069
- return { appId: isSet5(object.appId) ? globalThis.String(object.appId) : "" };
6070
- },
6071
- toJSON(message) {
6072
- const obj = {};
6073
6228
  if (message.appId !== "") {
6074
- obj.appId = message.appId;
6229
+ writer.uint32(18).string(message.appId);
6075
6230
  }
6076
- return obj;
6077
- },
6078
- create(base) {
6079
- return AppHeartbeatRequest.fromPartial(base ?? {});
6080
- },
6081
- fromPartial(object) {
6082
- const message = createBaseAppHeartbeatRequest();
6083
- message.appId = object.appId ?? "";
6084
- return message;
6085
- }
6086
- };
6087
- function createBaseAppLayout() {
6088
- return { objects: [], functionIds: {}, classIds: {} };
6089
- }
6090
- var AppLayout = {
6091
- encode(message, writer = new BinaryWriter()) {
6092
- for (const v of message.objects) {
6093
- Object_.encode(v, writer.uint32(10).fork()).join();
6231
+ if (message.environmentName !== "") {
6232
+ writer.uint32(26).string(message.environmentName);
6094
6233
  }
6095
- Object.entries(message.functionIds).forEach(([key, value]) => {
6096
- AppLayout_FunctionIdsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
6234
+ if (message.lifecycle !== void 0) {
6235
+ AppLifecycle.encode(message.lifecycle, writer.uint32(34).fork()).join();
6236
+ }
6237
+ Object.entries(message.functions).forEach(([key, value]) => {
6238
+ AppHandleMetadata_FunctionsEntry.encode({ key, value }, writer.uint32(42).fork()).join();
6097
6239
  });
6098
- Object.entries(message.classIds).forEach(([key, value]) => {
6099
- AppLayout_ClassIdsEntry.encode({ key, value }, writer.uint32(26).fork()).join();
6240
+ Object.entries(message.servers).forEach(([key, value]) => {
6241
+ AppHandleMetadata_ServersEntry.encode({ key, value }, writer.uint32(50).fork()).join();
6100
6242
  });
6101
6243
  return writer;
6102
6244
  },
6103
6245
  decode(input, length) {
6104
6246
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6105
6247
  let end = length === void 0 ? reader.len : reader.pos + length;
6106
- const message = createBaseAppLayout();
6248
+ const message = createBaseAppHandleMetadata();
6107
6249
  while (reader.pos < end) {
6108
6250
  const tag = reader.uint32();
6109
6251
  switch (tag >>> 3) {
@@ -6111,26 +6253,47 @@ var AppLayout = {
6111
6253
  if (tag !== 10) {
6112
6254
  break;
6113
6255
  }
6114
- message.objects.push(Object_.decode(reader, reader.uint32()));
6256
+ message.description = reader.string();
6115
6257
  continue;
6116
6258
  }
6117
6259
  case 2: {
6118
6260
  if (tag !== 18) {
6119
6261
  break;
6120
6262
  }
6121
- const entry2 = AppLayout_FunctionIdsEntry.decode(reader, reader.uint32());
6122
- if (entry2.value !== void 0) {
6123
- message.functionIds[entry2.key] = entry2.value;
6124
- }
6263
+ message.appId = reader.string();
6125
6264
  continue;
6126
6265
  }
6127
6266
  case 3: {
6128
6267
  if (tag !== 26) {
6129
6268
  break;
6130
6269
  }
6131
- const entry3 = AppLayout_ClassIdsEntry.decode(reader, reader.uint32());
6132
- if (entry3.value !== void 0) {
6133
- message.classIds[entry3.key] = entry3.value;
6270
+ message.environmentName = reader.string();
6271
+ continue;
6272
+ }
6273
+ case 4: {
6274
+ if (tag !== 34) {
6275
+ break;
6276
+ }
6277
+ message.lifecycle = AppLifecycle.decode(reader, reader.uint32());
6278
+ continue;
6279
+ }
6280
+ case 5: {
6281
+ if (tag !== 42) {
6282
+ break;
6283
+ }
6284
+ const entry5 = AppHandleMetadata_FunctionsEntry.decode(reader, reader.uint32());
6285
+ if (entry5.value !== void 0) {
6286
+ message.functions[entry5.key] = entry5.value;
6287
+ }
6288
+ continue;
6289
+ }
6290
+ case 6: {
6291
+ if (tag !== 50) {
6292
+ break;
6293
+ }
6294
+ const entry6 = AppHandleMetadata_ServersEntry.decode(reader, reader.uint32());
6295
+ if (entry6.value !== void 0) {
6296
+ message.servers[entry6.key] = entry6.value;
6134
6297
  }
6135
6298
  continue;
6136
6299
  }
@@ -6144,12 +6307,15 @@ var AppLayout = {
6144
6307
  },
6145
6308
  fromJSON(object) {
6146
6309
  return {
6147
- objects: globalThis.Array.isArray(object?.objects) ? object.objects.map((e) => Object_.fromJSON(e)) : [],
6148
- functionIds: isObject2(object.functionIds) ? Object.entries(object.functionIds).reduce((acc, [key, value]) => {
6310
+ description: isSet5(object.description) ? globalThis.String(object.description) : "",
6311
+ appId: isSet5(object.appId) ? globalThis.String(object.appId) : "",
6312
+ environmentName: isSet5(object.environmentName) ? globalThis.String(object.environmentName) : "",
6313
+ lifecycle: isSet5(object.lifecycle) ? AppLifecycle.fromJSON(object.lifecycle) : void 0,
6314
+ functions: isObject2(object.functions) ? Object.entries(object.functions).reduce((acc, [key, value]) => {
6149
6315
  acc[key] = String(value);
6150
6316
  return acc;
6151
6317
  }, {}) : {},
6152
- classIds: isObject2(object.classIds) ? Object.entries(object.classIds).reduce((acc, [key, value]) => {
6318
+ servers: isObject2(object.servers) ? Object.entries(object.servers).reduce((acc, [key, value]) => {
6153
6319
  acc[key] = String(value);
6154
6320
  return acc;
6155
6321
  }, {}) : {}
@@ -6157,36 +6323,48 @@ var AppLayout = {
6157
6323
  },
6158
6324
  toJSON(message) {
6159
6325
  const obj = {};
6160
- if (message.objects?.length) {
6161
- obj.objects = message.objects.map((e) => Object_.toJSON(e));
6326
+ if (message.description !== "") {
6327
+ obj.description = message.description;
6162
6328
  }
6163
- if (message.functionIds) {
6164
- const entries = Object.entries(message.functionIds);
6329
+ if (message.appId !== "") {
6330
+ obj.appId = message.appId;
6331
+ }
6332
+ if (message.environmentName !== "") {
6333
+ obj.environmentName = message.environmentName;
6334
+ }
6335
+ if (message.lifecycle !== void 0) {
6336
+ obj.lifecycle = AppLifecycle.toJSON(message.lifecycle);
6337
+ }
6338
+ if (message.functions) {
6339
+ const entries = Object.entries(message.functions);
6165
6340
  if (entries.length > 0) {
6166
- obj.functionIds = {};
6341
+ obj.functions = {};
6167
6342
  entries.forEach(([k, v]) => {
6168
- obj.functionIds[k] = v;
6343
+ obj.functions[k] = v;
6169
6344
  });
6170
6345
  }
6171
6346
  }
6172
- if (message.classIds) {
6173
- const entries = Object.entries(message.classIds);
6347
+ if (message.servers) {
6348
+ const entries = Object.entries(message.servers);
6174
6349
  if (entries.length > 0) {
6175
- obj.classIds = {};
6350
+ obj.servers = {};
6176
6351
  entries.forEach(([k, v]) => {
6177
- obj.classIds[k] = v;
6352
+ obj.servers[k] = v;
6178
6353
  });
6179
6354
  }
6180
6355
  }
6181
6356
  return obj;
6182
6357
  },
6183
6358
  create(base) {
6184
- return AppLayout.fromPartial(base ?? {});
6359
+ return AppHandleMetadata.fromPartial(base ?? {});
6185
6360
  },
6186
6361
  fromPartial(object) {
6187
- const message = createBaseAppLayout();
6188
- message.objects = object.objects?.map((e) => Object_.fromPartial(e)) || [];
6189
- message.functionIds = Object.entries(object.functionIds ?? {}).reduce(
6362
+ const message = createBaseAppHandleMetadata();
6363
+ message.description = object.description ?? "";
6364
+ message.appId = object.appId ?? "";
6365
+ message.environmentName = object.environmentName ?? "";
6366
+ message.lifecycle = object.lifecycle !== void 0 && object.lifecycle !== null ? AppLifecycle.fromPartial(object.lifecycle) : void 0;
6367
+ message.functions = Object.entries(object.functions ?? {}).reduce(
6190
6368
  (acc, [key, value]) => {
6191
6369
  if (value !== void 0) {
6192
6370
  acc[key] = globalThis.String(value);
@@ -6195,7 +6373,7 @@ var AppLayout = {
6195
6373
  },
6196
6374
  {}
6197
6375
  );
6198
- message.classIds = Object.entries(object.classIds ?? {}).reduce((acc, [key, value]) => {
6376
+ message.servers = Object.entries(object.servers ?? {}).reduce((acc, [key, value]) => {
6199
6377
  if (value !== void 0) {
6200
6378
  acc[key] = globalThis.String(value);
6201
6379
  }
@@ -6204,10 +6382,10 @@ var AppLayout = {
6204
6382
  return message;
6205
6383
  }
6206
6384
  };
6207
- function createBaseAppLayout_FunctionIdsEntry() {
6385
+ function createBaseAppHandleMetadata_FunctionsEntry() {
6208
6386
  return { key: "", value: "" };
6209
6387
  }
6210
- var AppLayout_FunctionIdsEntry = {
6388
+ var AppHandleMetadata_FunctionsEntry = {
6211
6389
  encode(message, writer = new BinaryWriter()) {
6212
6390
  if (message.key !== "") {
6213
6391
  writer.uint32(10).string(message.key);
@@ -6220,7 +6398,314 @@ var AppLayout_FunctionIdsEntry = {
6220
6398
  decode(input, length) {
6221
6399
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6222
6400
  let end = length === void 0 ? reader.len : reader.pos + length;
6223
- const message = createBaseAppLayout_FunctionIdsEntry();
6401
+ const message = createBaseAppHandleMetadata_FunctionsEntry();
6402
+ while (reader.pos < end) {
6403
+ const tag = reader.uint32();
6404
+ switch (tag >>> 3) {
6405
+ case 1: {
6406
+ if (tag !== 10) {
6407
+ break;
6408
+ }
6409
+ message.key = reader.string();
6410
+ continue;
6411
+ }
6412
+ case 2: {
6413
+ if (tag !== 18) {
6414
+ break;
6415
+ }
6416
+ message.value = reader.string();
6417
+ continue;
6418
+ }
6419
+ }
6420
+ if ((tag & 7) === 4 || tag === 0) {
6421
+ break;
6422
+ }
6423
+ reader.skip(tag & 7);
6424
+ }
6425
+ return message;
6426
+ },
6427
+ fromJSON(object) {
6428
+ return {
6429
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
6430
+ value: isSet5(object.value) ? globalThis.String(object.value) : ""
6431
+ };
6432
+ },
6433
+ toJSON(message) {
6434
+ const obj = {};
6435
+ if (message.key !== "") {
6436
+ obj.key = message.key;
6437
+ }
6438
+ if (message.value !== "") {
6439
+ obj.value = message.value;
6440
+ }
6441
+ return obj;
6442
+ },
6443
+ create(base) {
6444
+ return AppHandleMetadata_FunctionsEntry.fromPartial(base ?? {});
6445
+ },
6446
+ fromPartial(object) {
6447
+ const message = createBaseAppHandleMetadata_FunctionsEntry();
6448
+ message.key = object.key ?? "";
6449
+ message.value = object.value ?? "";
6450
+ return message;
6451
+ }
6452
+ };
6453
+ function createBaseAppHandleMetadata_ServersEntry() {
6454
+ return { key: "", value: "" };
6455
+ }
6456
+ var AppHandleMetadata_ServersEntry = {
6457
+ encode(message, writer = new BinaryWriter()) {
6458
+ if (message.key !== "") {
6459
+ writer.uint32(10).string(message.key);
6460
+ }
6461
+ if (message.value !== "") {
6462
+ writer.uint32(18).string(message.value);
6463
+ }
6464
+ return writer;
6465
+ },
6466
+ decode(input, length) {
6467
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6468
+ let end = length === void 0 ? reader.len : reader.pos + length;
6469
+ const message = createBaseAppHandleMetadata_ServersEntry();
6470
+ while (reader.pos < end) {
6471
+ const tag = reader.uint32();
6472
+ switch (tag >>> 3) {
6473
+ case 1: {
6474
+ if (tag !== 10) {
6475
+ break;
6476
+ }
6477
+ message.key = reader.string();
6478
+ continue;
6479
+ }
6480
+ case 2: {
6481
+ if (tag !== 18) {
6482
+ break;
6483
+ }
6484
+ message.value = reader.string();
6485
+ continue;
6486
+ }
6487
+ }
6488
+ if ((tag & 7) === 4 || tag === 0) {
6489
+ break;
6490
+ }
6491
+ reader.skip(tag & 7);
6492
+ }
6493
+ return message;
6494
+ },
6495
+ fromJSON(object) {
6496
+ return {
6497
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
6498
+ value: isSet5(object.value) ? globalThis.String(object.value) : ""
6499
+ };
6500
+ },
6501
+ toJSON(message) {
6502
+ const obj = {};
6503
+ if (message.key !== "") {
6504
+ obj.key = message.key;
6505
+ }
6506
+ if (message.value !== "") {
6507
+ obj.value = message.value;
6508
+ }
6509
+ return obj;
6510
+ },
6511
+ create(base) {
6512
+ return AppHandleMetadata_ServersEntry.fromPartial(base ?? {});
6513
+ },
6514
+ fromPartial(object) {
6515
+ const message = createBaseAppHandleMetadata_ServersEntry();
6516
+ message.key = object.key ?? "";
6517
+ message.value = object.value ?? "";
6518
+ return message;
6519
+ }
6520
+ };
6521
+ function createBaseAppHeartbeatRequest() {
6522
+ return { appId: "" };
6523
+ }
6524
+ var AppHeartbeatRequest = {
6525
+ encode(message, writer = new BinaryWriter()) {
6526
+ if (message.appId !== "") {
6527
+ writer.uint32(10).string(message.appId);
6528
+ }
6529
+ return writer;
6530
+ },
6531
+ decode(input, length) {
6532
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6533
+ let end = length === void 0 ? reader.len : reader.pos + length;
6534
+ const message = createBaseAppHeartbeatRequest();
6535
+ while (reader.pos < end) {
6536
+ const tag = reader.uint32();
6537
+ switch (tag >>> 3) {
6538
+ case 1: {
6539
+ if (tag !== 10) {
6540
+ break;
6541
+ }
6542
+ message.appId = reader.string();
6543
+ continue;
6544
+ }
6545
+ }
6546
+ if ((tag & 7) === 4 || tag === 0) {
6547
+ break;
6548
+ }
6549
+ reader.skip(tag & 7);
6550
+ }
6551
+ return message;
6552
+ },
6553
+ fromJSON(object) {
6554
+ return { appId: isSet5(object.appId) ? globalThis.String(object.appId) : "" };
6555
+ },
6556
+ toJSON(message) {
6557
+ const obj = {};
6558
+ if (message.appId !== "") {
6559
+ obj.appId = message.appId;
6560
+ }
6561
+ return obj;
6562
+ },
6563
+ create(base) {
6564
+ return AppHeartbeatRequest.fromPartial(base ?? {});
6565
+ },
6566
+ fromPartial(object) {
6567
+ const message = createBaseAppHeartbeatRequest();
6568
+ message.appId = object.appId ?? "";
6569
+ return message;
6570
+ }
6571
+ };
6572
+ function createBaseAppLayout() {
6573
+ return { objects: [], functionIds: {}, classIds: {} };
6574
+ }
6575
+ var AppLayout = {
6576
+ encode(message, writer = new BinaryWriter()) {
6577
+ for (const v of message.objects) {
6578
+ Object_.encode(v, writer.uint32(10).fork()).join();
6579
+ }
6580
+ Object.entries(message.functionIds).forEach(([key, value]) => {
6581
+ AppLayout_FunctionIdsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
6582
+ });
6583
+ Object.entries(message.classIds).forEach(([key, value]) => {
6584
+ AppLayout_ClassIdsEntry.encode({ key, value }, writer.uint32(26).fork()).join();
6585
+ });
6586
+ return writer;
6587
+ },
6588
+ decode(input, length) {
6589
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6590
+ let end = length === void 0 ? reader.len : reader.pos + length;
6591
+ const message = createBaseAppLayout();
6592
+ while (reader.pos < end) {
6593
+ const tag = reader.uint32();
6594
+ switch (tag >>> 3) {
6595
+ case 1: {
6596
+ if (tag !== 10) {
6597
+ break;
6598
+ }
6599
+ message.objects.push(Object_.decode(reader, reader.uint32()));
6600
+ continue;
6601
+ }
6602
+ case 2: {
6603
+ if (tag !== 18) {
6604
+ break;
6605
+ }
6606
+ const entry2 = AppLayout_FunctionIdsEntry.decode(reader, reader.uint32());
6607
+ if (entry2.value !== void 0) {
6608
+ message.functionIds[entry2.key] = entry2.value;
6609
+ }
6610
+ continue;
6611
+ }
6612
+ case 3: {
6613
+ if (tag !== 26) {
6614
+ break;
6615
+ }
6616
+ const entry3 = AppLayout_ClassIdsEntry.decode(reader, reader.uint32());
6617
+ if (entry3.value !== void 0) {
6618
+ message.classIds[entry3.key] = entry3.value;
6619
+ }
6620
+ continue;
6621
+ }
6622
+ }
6623
+ if ((tag & 7) === 4 || tag === 0) {
6624
+ break;
6625
+ }
6626
+ reader.skip(tag & 7);
6627
+ }
6628
+ return message;
6629
+ },
6630
+ fromJSON(object) {
6631
+ return {
6632
+ objects: globalThis.Array.isArray(object?.objects) ? object.objects.map((e) => Object_.fromJSON(e)) : [],
6633
+ functionIds: isObject2(object.functionIds) ? Object.entries(object.functionIds).reduce((acc, [key, value]) => {
6634
+ acc[key] = String(value);
6635
+ return acc;
6636
+ }, {}) : {},
6637
+ classIds: isObject2(object.classIds) ? Object.entries(object.classIds).reduce((acc, [key, value]) => {
6638
+ acc[key] = String(value);
6639
+ return acc;
6640
+ }, {}) : {}
6641
+ };
6642
+ },
6643
+ toJSON(message) {
6644
+ const obj = {};
6645
+ if (message.objects?.length) {
6646
+ obj.objects = message.objects.map((e) => Object_.toJSON(e));
6647
+ }
6648
+ if (message.functionIds) {
6649
+ const entries = Object.entries(message.functionIds);
6650
+ if (entries.length > 0) {
6651
+ obj.functionIds = {};
6652
+ entries.forEach(([k, v]) => {
6653
+ obj.functionIds[k] = v;
6654
+ });
6655
+ }
6656
+ }
6657
+ if (message.classIds) {
6658
+ const entries = Object.entries(message.classIds);
6659
+ if (entries.length > 0) {
6660
+ obj.classIds = {};
6661
+ entries.forEach(([k, v]) => {
6662
+ obj.classIds[k] = v;
6663
+ });
6664
+ }
6665
+ }
6666
+ return obj;
6667
+ },
6668
+ create(base) {
6669
+ return AppLayout.fromPartial(base ?? {});
6670
+ },
6671
+ fromPartial(object) {
6672
+ const message = createBaseAppLayout();
6673
+ message.objects = object.objects?.map((e) => Object_.fromPartial(e)) || [];
6674
+ message.functionIds = Object.entries(object.functionIds ?? {}).reduce(
6675
+ (acc, [key, value]) => {
6676
+ if (value !== void 0) {
6677
+ acc[key] = globalThis.String(value);
6678
+ }
6679
+ return acc;
6680
+ },
6681
+ {}
6682
+ );
6683
+ message.classIds = Object.entries(object.classIds ?? {}).reduce((acc, [key, value]) => {
6684
+ if (value !== void 0) {
6685
+ acc[key] = globalThis.String(value);
6686
+ }
6687
+ return acc;
6688
+ }, {});
6689
+ return message;
6690
+ }
6691
+ };
6692
+ function createBaseAppLayout_FunctionIdsEntry() {
6693
+ return { key: "", value: "" };
6694
+ }
6695
+ var AppLayout_FunctionIdsEntry = {
6696
+ encode(message, writer = new BinaryWriter()) {
6697
+ if (message.key !== "") {
6698
+ writer.uint32(10).string(message.key);
6699
+ }
6700
+ if (message.value !== "") {
6701
+ writer.uint32(18).string(message.value);
6702
+ }
6703
+ return writer;
6704
+ },
6705
+ decode(input, length) {
6706
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6707
+ let end = length === void 0 ? reader.len : reader.pos + length;
6708
+ const message = createBaseAppLayout_FunctionIdsEntry();
6224
6709
  while (reader.pos < end) {
6225
6710
  const tag = reader.uint32();
6226
6711
  switch (tag >>> 3) {
@@ -17371,7 +17856,8 @@ function createBaseEndpointListItem() {
17371
17856
  createdByAvatarUrl: "",
17372
17857
  provisioningStatus: 0,
17373
17858
  status: "",
17374
- servingMode: 0
17859
+ servingMode: 0,
17860
+ unauthenticated: false
17375
17861
  };
17376
17862
  }
17377
17863
  var EndpointListItem = {
@@ -17412,6 +17898,9 @@ var EndpointListItem = {
17412
17898
  if (message.servingMode !== 0) {
17413
17899
  writer.uint32(96).int32(message.servingMode);
17414
17900
  }
17901
+ if (message.unauthenticated !== false) {
17902
+ writer.uint32(104).bool(message.unauthenticated);
17903
+ }
17415
17904
  return writer;
17416
17905
  },
17417
17906
  decode(input, length) {
@@ -17505,6 +17994,13 @@ var EndpointListItem = {
17505
17994
  message.servingMode = reader.int32();
17506
17995
  continue;
17507
17996
  }
17997
+ case 13: {
17998
+ if (tag !== 104) {
17999
+ break;
18000
+ }
18001
+ message.unauthenticated = reader.bool();
18002
+ continue;
18003
+ }
17508
18004
  }
17509
18005
  if ((tag & 7) === 4 || tag === 0) {
17510
18006
  break;
@@ -17526,7 +18022,8 @@ var EndpointListItem = {
17526
18022
  createdByAvatarUrl: isSet5(object.createdByAvatarUrl) ? globalThis.String(object.createdByAvatarUrl) : "",
17527
18023
  provisioningStatus: isSet5(object.provisioningStatus) ? endpointProvisioningStatusFromJSON(object.provisioningStatus) : 0,
17528
18024
  status: isSet5(object.status) ? globalThis.String(object.status) : "",
17529
- servingMode: isSet5(object.servingMode) ? endpointServingModeFromJSON(object.servingMode) : 0
18025
+ servingMode: isSet5(object.servingMode) ? endpointServingModeFromJSON(object.servingMode) : 0,
18026
+ unauthenticated: isSet5(object.unauthenticated) ? globalThis.Boolean(object.unauthenticated) : false
17530
18027
  };
17531
18028
  },
17532
18029
  toJSON(message) {
@@ -17567,6 +18064,9 @@ var EndpointListItem = {
17567
18064
  if (message.servingMode !== 0) {
17568
18065
  obj.servingMode = endpointServingModeToJSON(message.servingMode);
17569
18066
  }
18067
+ if (message.unauthenticated !== false) {
18068
+ obj.unauthenticated = message.unauthenticated;
18069
+ }
17570
18070
  return obj;
17571
18071
  },
17572
18072
  create(base) {
@@ -17586,6 +18086,7 @@ var EndpointListItem = {
17586
18086
  message.provisioningStatus = object.provisioningStatus ?? 0;
17587
18087
  message.status = object.status ?? "";
17588
18088
  message.servingMode = object.servingMode ?? 0;
18089
+ message.unauthenticated = object.unauthenticated ?? false;
17589
18090
  return message;
17590
18091
  }
17591
18092
  };
@@ -19501,7 +20002,8 @@ function createBaseEnvironmentListItem() {
19501
20002
  currentCycleUsage: 0,
19502
20003
  spendLimitReached: false,
19503
20004
  environmentType: 0,
19504
- defaultMemberRole: void 0
20005
+ defaultMemberRole: void 0,
20006
+ blockUnauthenticatedResources: void 0
19505
20007
  };
19506
20008
  }
19507
20009
  var EnvironmentListItem = {
@@ -19554,6 +20056,9 @@ var EnvironmentListItem = {
19554
20056
  if (message.defaultMemberRole !== void 0) {
19555
20057
  writer.uint32(128).int32(message.defaultMemberRole);
19556
20058
  }
20059
+ if (message.blockUnauthenticatedResources !== void 0) {
20060
+ writer.uint32(136).bool(message.blockUnauthenticatedResources);
20061
+ }
19557
20062
  return writer;
19558
20063
  },
19559
20064
  decode(input, length) {
@@ -19675,6 +20180,13 @@ var EnvironmentListItem = {
19675
20180
  message.defaultMemberRole = reader.int32();
19676
20181
  continue;
19677
20182
  }
20183
+ case 17: {
20184
+ if (tag !== 136) {
20185
+ break;
20186
+ }
20187
+ message.blockUnauthenticatedResources = reader.bool();
20188
+ continue;
20189
+ }
19678
20190
  }
19679
20191
  if ((tag & 7) === 4 || tag === 0) {
19680
20192
  break;
@@ -19700,7 +20212,8 @@ var EnvironmentListItem = {
19700
20212
  currentCycleUsage: isSet5(object.currentCycleUsage) ? globalThis.Number(object.currentCycleUsage) : 0,
19701
20213
  spendLimitReached: isSet5(object.spendLimitReached) ? globalThis.Boolean(object.spendLimitReached) : false,
19702
20214
  environmentType: isSet5(object.environmentType) ? environmentTypeFromJSON(object.environmentType) : 0,
19703
- defaultMemberRole: isSet5(object.defaultMemberRole) ? environmentRoleFromJSON(object.defaultMemberRole) : void 0
20215
+ defaultMemberRole: isSet5(object.defaultMemberRole) ? environmentRoleFromJSON(object.defaultMemberRole) : void 0,
20216
+ blockUnauthenticatedResources: isSet5(object.blockUnauthenticatedResources) ? globalThis.Boolean(object.blockUnauthenticatedResources) : void 0
19704
20217
  };
19705
20218
  },
19706
20219
  toJSON(message) {
@@ -19753,6 +20266,9 @@ var EnvironmentListItem = {
19753
20266
  if (message.defaultMemberRole !== void 0) {
19754
20267
  obj.defaultMemberRole = environmentRoleToJSON(message.defaultMemberRole);
19755
20268
  }
20269
+ if (message.blockUnauthenticatedResources !== void 0) {
20270
+ obj.blockUnauthenticatedResources = message.blockUnauthenticatedResources;
20271
+ }
19756
20272
  return obj;
19757
20273
  },
19758
20274
  create(base) {
@@ -19776,6 +20292,7 @@ var EnvironmentListItem = {
19776
20292
  message.spendLimitReached = object.spendLimitReached ?? false;
19777
20293
  message.environmentType = object.environmentType ?? 0;
19778
20294
  message.defaultMemberRole = object.defaultMemberRole ?? void 0;
20295
+ message.blockUnauthenticatedResources = object.blockUnauthenticatedResources ?? void 0;
19779
20296
  return message;
19780
20297
  }
19781
20298
  };
@@ -20263,7 +20780,13 @@ var EnvironmentSetManagedRequest = {
20263
20780
  }
20264
20781
  };
20265
20782
  function createBaseEnvironmentSettings() {
20266
- return { imageBuilderVersion: "", webhookSuffix: "", maxConcurrentGpus: void 0, maxConcurrentTasks: void 0 };
20783
+ return {
20784
+ imageBuilderVersion: "",
20785
+ webhookSuffix: "",
20786
+ maxConcurrentGpus: void 0,
20787
+ maxConcurrentTasks: void 0,
20788
+ blockUnauthenticatedResources: void 0
20789
+ };
20267
20790
  }
20268
20791
  var EnvironmentSettings = {
20269
20792
  encode(message, writer = new BinaryWriter()) {
@@ -20279,6 +20802,9 @@ var EnvironmentSettings = {
20279
20802
  if (message.maxConcurrentTasks !== void 0) {
20280
20803
  writer.uint32(32).int32(message.maxConcurrentTasks);
20281
20804
  }
20805
+ if (message.blockUnauthenticatedResources !== void 0) {
20806
+ writer.uint32(40).bool(message.blockUnauthenticatedResources);
20807
+ }
20282
20808
  return writer;
20283
20809
  },
20284
20810
  decode(input, length) {
@@ -20316,6 +20842,13 @@ var EnvironmentSettings = {
20316
20842
  message.maxConcurrentTasks = reader.int32();
20317
20843
  continue;
20318
20844
  }
20845
+ case 5: {
20846
+ if (tag !== 40) {
20847
+ break;
20848
+ }
20849
+ message.blockUnauthenticatedResources = reader.bool();
20850
+ continue;
20851
+ }
20319
20852
  }
20320
20853
  if ((tag & 7) === 4 || tag === 0) {
20321
20854
  break;
@@ -20329,7 +20862,8 @@ var EnvironmentSettings = {
20329
20862
  imageBuilderVersion: isSet5(object.imageBuilderVersion) ? globalThis.String(object.imageBuilderVersion) : "",
20330
20863
  webhookSuffix: isSet5(object.webhookSuffix) ? globalThis.String(object.webhookSuffix) : "",
20331
20864
  maxConcurrentGpus: isSet5(object.maxConcurrentGpus) ? globalThis.Number(object.maxConcurrentGpus) : void 0,
20332
- maxConcurrentTasks: isSet5(object.maxConcurrentTasks) ? globalThis.Number(object.maxConcurrentTasks) : void 0
20865
+ maxConcurrentTasks: isSet5(object.maxConcurrentTasks) ? globalThis.Number(object.maxConcurrentTasks) : void 0,
20866
+ blockUnauthenticatedResources: isSet5(object.blockUnauthenticatedResources) ? globalThis.Boolean(object.blockUnauthenticatedResources) : void 0
20333
20867
  };
20334
20868
  },
20335
20869
  toJSON(message) {
@@ -20346,6 +20880,9 @@ var EnvironmentSettings = {
20346
20880
  if (message.maxConcurrentTasks !== void 0) {
20347
20881
  obj.maxConcurrentTasks = Math.round(message.maxConcurrentTasks);
20348
20882
  }
20883
+ if (message.blockUnauthenticatedResources !== void 0) {
20884
+ obj.blockUnauthenticatedResources = message.blockUnauthenticatedResources;
20885
+ }
20349
20886
  return obj;
20350
20887
  },
20351
20888
  create(base) {
@@ -20357,6 +20894,7 @@ var EnvironmentSettings = {
20357
20894
  message.webhookSuffix = object.webhookSuffix ?? "";
20358
20895
  message.maxConcurrentGpus = object.maxConcurrentGpus ?? void 0;
20359
20896
  message.maxConcurrentTasks = object.maxConcurrentTasks ?? void 0;
20897
+ message.blockUnauthenticatedResources = object.blockUnauthenticatedResources ?? void 0;
20360
20898
  return message;
20361
20899
  }
20362
20900
  };
@@ -20366,7 +20904,8 @@ function createBaseEnvironmentUpdateRequest() {
20366
20904
  name: void 0,
20367
20905
  webSuffix: void 0,
20368
20906
  maxConcurrentTasks: void 0,
20369
- maxConcurrentGpus: void 0
20907
+ maxConcurrentGpus: void 0,
20908
+ blockUnauthenticatedResources: void 0
20370
20909
  };
20371
20910
  }
20372
20911
  var EnvironmentUpdateRequest = {
@@ -20386,6 +20925,9 @@ var EnvironmentUpdateRequest = {
20386
20925
  if (message.maxConcurrentGpus !== void 0) {
20387
20926
  writer.uint32(40).int32(message.maxConcurrentGpus);
20388
20927
  }
20928
+ if (message.blockUnauthenticatedResources !== void 0) {
20929
+ writer.uint32(48).int32(message.blockUnauthenticatedResources);
20930
+ }
20389
20931
  return writer;
20390
20932
  },
20391
20933
  decode(input, length) {
@@ -20430,6 +20972,13 @@ var EnvironmentUpdateRequest = {
20430
20972
  message.maxConcurrentGpus = reader.int32();
20431
20973
  continue;
20432
20974
  }
20975
+ case 6: {
20976
+ if (tag !== 48) {
20977
+ break;
20978
+ }
20979
+ message.blockUnauthenticatedResources = reader.int32();
20980
+ continue;
20981
+ }
20433
20982
  }
20434
20983
  if ((tag & 7) === 4 || tag === 0) {
20435
20984
  break;
@@ -20444,7 +20993,8 @@ var EnvironmentUpdateRequest = {
20444
20993
  name: isSet5(object.name) ? String(object.name) : void 0,
20445
20994
  webSuffix: isSet5(object.webSuffix) ? String(object.webSuffix) : void 0,
20446
20995
  maxConcurrentTasks: isSet5(object.maxConcurrentTasks) ? globalThis.Number(object.maxConcurrentTasks) : void 0,
20447
- maxConcurrentGpus: isSet5(object.maxConcurrentGpus) ? globalThis.Number(object.maxConcurrentGpus) : void 0
20996
+ maxConcurrentGpus: isSet5(object.maxConcurrentGpus) ? globalThis.Number(object.maxConcurrentGpus) : void 0,
20997
+ blockUnauthenticatedResources: isSet5(object.blockUnauthenticatedResources) ? environmentBlockUnauthenticatedResourcesFromJSON(object.blockUnauthenticatedResources) : void 0
20448
20998
  };
20449
20999
  },
20450
21000
  toJSON(message) {
@@ -20464,6 +21014,11 @@ var EnvironmentUpdateRequest = {
20464
21014
  if (message.maxConcurrentGpus !== void 0) {
20465
21015
  obj.maxConcurrentGpus = Math.round(message.maxConcurrentGpus);
20466
21016
  }
21017
+ if (message.blockUnauthenticatedResources !== void 0) {
21018
+ obj.blockUnauthenticatedResources = environmentBlockUnauthenticatedResourcesToJSON(
21019
+ message.blockUnauthenticatedResources
21020
+ );
21021
+ }
20467
21022
  return obj;
20468
21023
  },
20469
21024
  create(base) {
@@ -20476,6 +21031,7 @@ var EnvironmentUpdateRequest = {
20476
21031
  message.webSuffix = object.webSuffix ?? void 0;
20477
21032
  message.maxConcurrentTasks = object.maxConcurrentTasks ?? void 0;
20478
21033
  message.maxConcurrentGpus = object.maxConcurrentGpus ?? void 0;
21034
+ message.blockUnauthenticatedResources = object.blockUnauthenticatedResources ?? void 0;
20479
21035
  return message;
20480
21036
  }
20481
21037
  };
@@ -25350,6 +25906,125 @@ var FunctionFinishInputsRequest = {
25350
25906
  return message;
25351
25907
  }
25352
25908
  };
25909
+ function createBaseFunctionGetByIdRequest() {
25910
+ return { functionId: "" };
25911
+ }
25912
+ var FunctionGetByIdRequest = {
25913
+ encode(message, writer = new BinaryWriter()) {
25914
+ if (message.functionId !== "") {
25915
+ writer.uint32(10).string(message.functionId);
25916
+ }
25917
+ return writer;
25918
+ },
25919
+ decode(input, length) {
25920
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
25921
+ let end = length === void 0 ? reader.len : reader.pos + length;
25922
+ const message = createBaseFunctionGetByIdRequest();
25923
+ while (reader.pos < end) {
25924
+ const tag = reader.uint32();
25925
+ switch (tag >>> 3) {
25926
+ case 1: {
25927
+ if (tag !== 10) {
25928
+ break;
25929
+ }
25930
+ message.functionId = reader.string();
25931
+ continue;
25932
+ }
25933
+ }
25934
+ if ((tag & 7) === 4 || tag === 0) {
25935
+ break;
25936
+ }
25937
+ reader.skip(tag & 7);
25938
+ }
25939
+ return message;
25940
+ },
25941
+ fromJSON(object) {
25942
+ return { functionId: isSet5(object.functionId) ? globalThis.String(object.functionId) : "" };
25943
+ },
25944
+ toJSON(message) {
25945
+ const obj = {};
25946
+ if (message.functionId !== "") {
25947
+ obj.functionId = message.functionId;
25948
+ }
25949
+ return obj;
25950
+ },
25951
+ create(base) {
25952
+ return FunctionGetByIdRequest.fromPartial(base ?? {});
25953
+ },
25954
+ fromPartial(object) {
25955
+ const message = createBaseFunctionGetByIdRequest();
25956
+ message.functionId = object.functionId ?? "";
25957
+ return message;
25958
+ }
25959
+ };
25960
+ function createBaseFunctionGetByIdResponse() {
25961
+ return { function: void 0, handleMetadata: void 0 };
25962
+ }
25963
+ var FunctionGetByIdResponse = {
25964
+ encode(message, writer = new BinaryWriter()) {
25965
+ if (message.function !== void 0) {
25966
+ FunctionData.encode(message.function, writer.uint32(10).fork()).join();
25967
+ }
25968
+ if (message.handleMetadata !== void 0) {
25969
+ FunctionHandleMetadata.encode(message.handleMetadata, writer.uint32(18).fork()).join();
25970
+ }
25971
+ return writer;
25972
+ },
25973
+ decode(input, length) {
25974
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
25975
+ let end = length === void 0 ? reader.len : reader.pos + length;
25976
+ const message = createBaseFunctionGetByIdResponse();
25977
+ while (reader.pos < end) {
25978
+ const tag = reader.uint32();
25979
+ switch (tag >>> 3) {
25980
+ case 1: {
25981
+ if (tag !== 10) {
25982
+ break;
25983
+ }
25984
+ message.function = FunctionData.decode(reader, reader.uint32());
25985
+ continue;
25986
+ }
25987
+ case 2: {
25988
+ if (tag !== 18) {
25989
+ break;
25990
+ }
25991
+ message.handleMetadata = FunctionHandleMetadata.decode(reader, reader.uint32());
25992
+ continue;
25993
+ }
25994
+ }
25995
+ if ((tag & 7) === 4 || tag === 0) {
25996
+ break;
25997
+ }
25998
+ reader.skip(tag & 7);
25999
+ }
26000
+ return message;
26001
+ },
26002
+ fromJSON(object) {
26003
+ return {
26004
+ function: isSet5(object.function) ? FunctionData.fromJSON(object.function) : void 0,
26005
+ handleMetadata: isSet5(object.handleMetadata) ? FunctionHandleMetadata.fromJSON(object.handleMetadata) : void 0
26006
+ };
26007
+ },
26008
+ toJSON(message) {
26009
+ const obj = {};
26010
+ if (message.function !== void 0) {
26011
+ obj.function = FunctionData.toJSON(message.function);
26012
+ }
26013
+ if (message.handleMetadata !== void 0) {
26014
+ obj.handleMetadata = FunctionHandleMetadata.toJSON(message.handleMetadata);
26015
+ }
26016
+ return obj;
26017
+ },
26018
+ create(base) {
26019
+ return FunctionGetByIdResponse.fromPartial(base ?? {});
26020
+ },
26021
+ fromPartial(object) {
26022
+ const message = createBaseFunctionGetByIdResponse();
26023
+ message.function = object.function !== void 0 && object.function !== null ? FunctionData.fromPartial(object.function) : void 0;
26024
+ message.handleMetadata = object.handleMetadata !== void 0 && object.handleMetadata !== null ? FunctionHandleMetadata.fromPartial(object.handleMetadata) : void 0;
26025
+ return message;
26026
+ }
26027
+ };
25353
26028
  function createBaseFunctionGetCallGraphRequest() {
25354
26029
  return { functionCallId: "" };
25355
26030
  }
@@ -25402,7 +26077,7 @@ var FunctionGetCallGraphRequest = {
25402
26077
  }
25403
26078
  };
25404
26079
  function createBaseFunctionGetCallGraphResponse() {
25405
- return { inputs: [], functionCalls: [] };
26080
+ return { inputs: [], functionCalls: [], truncated: false };
25406
26081
  }
25407
26082
  var FunctionGetCallGraphResponse = {
25408
26083
  encode(message, writer = new BinaryWriter()) {
@@ -25412,6 +26087,9 @@ var FunctionGetCallGraphResponse = {
25412
26087
  for (const v of message.functionCalls) {
25413
26088
  FunctionCallCallGraphInfo.encode(v, writer.uint32(18).fork()).join();
25414
26089
  }
26090
+ if (message.truncated !== false) {
26091
+ writer.uint32(24).bool(message.truncated);
26092
+ }
25415
26093
  return writer;
25416
26094
  },
25417
26095
  decode(input, length) {
@@ -25435,6 +26113,13 @@ var FunctionGetCallGraphResponse = {
25435
26113
  message.functionCalls.push(FunctionCallCallGraphInfo.decode(reader, reader.uint32()));
25436
26114
  continue;
25437
26115
  }
26116
+ case 3: {
26117
+ if (tag !== 24) {
26118
+ break;
26119
+ }
26120
+ message.truncated = reader.bool();
26121
+ continue;
26122
+ }
25438
26123
  }
25439
26124
  if ((tag & 7) === 4 || tag === 0) {
25440
26125
  break;
@@ -25446,7 +26131,8 @@ var FunctionGetCallGraphResponse = {
25446
26131
  fromJSON(object) {
25447
26132
  return {
25448
26133
  inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => InputCallGraphInfo.fromJSON(e)) : [],
25449
- functionCalls: globalThis.Array.isArray(object?.functionCalls) ? object.functionCalls.map((e) => FunctionCallCallGraphInfo.fromJSON(e)) : []
26134
+ functionCalls: globalThis.Array.isArray(object?.functionCalls) ? object.functionCalls.map((e) => FunctionCallCallGraphInfo.fromJSON(e)) : [],
26135
+ truncated: isSet5(object.truncated) ? globalThis.Boolean(object.truncated) : false
25450
26136
  };
25451
26137
  },
25452
26138
  toJSON(message) {
@@ -25457,6 +26143,9 @@ var FunctionGetCallGraphResponse = {
25457
26143
  if (message.functionCalls?.length) {
25458
26144
  obj.functionCalls = message.functionCalls.map((e) => FunctionCallCallGraphInfo.toJSON(e));
25459
26145
  }
26146
+ if (message.truncated !== false) {
26147
+ obj.truncated = message.truncated;
26148
+ }
25460
26149
  return obj;
25461
26150
  },
25462
26151
  create(base) {
@@ -25466,6 +26155,7 @@ var FunctionGetCallGraphResponse = {
25466
26155
  const message = createBaseFunctionGetCallGraphResponse();
25467
26156
  message.inputs = object.inputs?.map((e) => InputCallGraphInfo.fromPartial(e)) || [];
25468
26157
  message.functionCalls = object.functionCalls?.map((e) => FunctionCallCallGraphInfo.fromPartial(e)) || [];
26158
+ message.truncated = object.truncated ?? false;
25469
26159
  return message;
25470
26160
  }
25471
26161
  };
@@ -25654,6 +26344,108 @@ var FunctionGetDynamicConcurrencyResponse = {
25654
26344
  return message;
25655
26345
  }
25656
26346
  };
26347
+ function createBaseFunctionGetFlashAuthTokenRequest() {
26348
+ return { functionId: "" };
26349
+ }
26350
+ var FunctionGetFlashAuthTokenRequest = {
26351
+ encode(message, writer = new BinaryWriter()) {
26352
+ if (message.functionId !== "") {
26353
+ writer.uint32(10).string(message.functionId);
26354
+ }
26355
+ return writer;
26356
+ },
26357
+ decode(input, length) {
26358
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
26359
+ let end = length === void 0 ? reader.len : reader.pos + length;
26360
+ const message = createBaseFunctionGetFlashAuthTokenRequest();
26361
+ while (reader.pos < end) {
26362
+ const tag = reader.uint32();
26363
+ switch (tag >>> 3) {
26364
+ case 1: {
26365
+ if (tag !== 10) {
26366
+ break;
26367
+ }
26368
+ message.functionId = reader.string();
26369
+ continue;
26370
+ }
26371
+ }
26372
+ if ((tag & 7) === 4 || tag === 0) {
26373
+ break;
26374
+ }
26375
+ reader.skip(tag & 7);
26376
+ }
26377
+ return message;
26378
+ },
26379
+ fromJSON(object) {
26380
+ return { functionId: isSet5(object.functionId) ? globalThis.String(object.functionId) : "" };
26381
+ },
26382
+ toJSON(message) {
26383
+ const obj = {};
26384
+ if (message.functionId !== "") {
26385
+ obj.functionId = message.functionId;
26386
+ }
26387
+ return obj;
26388
+ },
26389
+ create(base) {
26390
+ return FunctionGetFlashAuthTokenRequest.fromPartial(base ?? {});
26391
+ },
26392
+ fromPartial(object) {
26393
+ const message = createBaseFunctionGetFlashAuthTokenRequest();
26394
+ message.functionId = object.functionId ?? "";
26395
+ return message;
26396
+ }
26397
+ };
26398
+ function createBaseFunctionGetFlashAuthTokenResponse() {
26399
+ return { token: "" };
26400
+ }
26401
+ var FunctionGetFlashAuthTokenResponse = {
26402
+ encode(message, writer = new BinaryWriter()) {
26403
+ if (message.token !== "") {
26404
+ writer.uint32(10).string(message.token);
26405
+ }
26406
+ return writer;
26407
+ },
26408
+ decode(input, length) {
26409
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
26410
+ let end = length === void 0 ? reader.len : reader.pos + length;
26411
+ const message = createBaseFunctionGetFlashAuthTokenResponse();
26412
+ while (reader.pos < end) {
26413
+ const tag = reader.uint32();
26414
+ switch (tag >>> 3) {
26415
+ case 1: {
26416
+ if (tag !== 10) {
26417
+ break;
26418
+ }
26419
+ message.token = reader.string();
26420
+ continue;
26421
+ }
26422
+ }
26423
+ if ((tag & 7) === 4 || tag === 0) {
26424
+ break;
26425
+ }
26426
+ reader.skip(tag & 7);
26427
+ }
26428
+ return message;
26429
+ },
26430
+ fromJSON(object) {
26431
+ return { token: isSet5(object.token) ? globalThis.String(object.token) : "" };
26432
+ },
26433
+ toJSON(message) {
26434
+ const obj = {};
26435
+ if (message.token !== "") {
26436
+ obj.token = message.token;
26437
+ }
26438
+ return obj;
26439
+ },
26440
+ create(base) {
26441
+ return FunctionGetFlashAuthTokenResponse.fromPartial(base ?? {});
26442
+ },
26443
+ fromPartial(object) {
26444
+ const message = createBaseFunctionGetFlashAuthTokenResponse();
26445
+ message.token = object.token ?? "";
26446
+ return message;
26447
+ }
26448
+ };
25657
26449
  function createBaseFunctionGetInputsItem() {
25658
26450
  return {
25659
26451
  inputId: "",
@@ -26792,7 +27584,7 @@ var FunctionGetSerializedResponse = {
26792
27584
  }
26793
27585
  };
26794
27586
  function createBaseFunctionGetTimeRangeStatsRequest() {
26795
- return { functionId: "", since: void 0, until: void 0, rollup: false };
27587
+ return { functionId: "", since: void 0, until: void 0, rollup: false, containerId: void 0 };
26796
27588
  }
26797
27589
  var FunctionGetTimeRangeStatsRequest = {
26798
27590
  encode(message, writer = new BinaryWriter()) {
@@ -26808,6 +27600,9 @@ var FunctionGetTimeRangeStatsRequest = {
26808
27600
  if (message.rollup !== false) {
26809
27601
  writer.uint32(32).bool(message.rollup);
26810
27602
  }
27603
+ if (message.containerId !== void 0) {
27604
+ writer.uint32(42).string(message.containerId);
27605
+ }
26811
27606
  return writer;
26812
27607
  },
26813
27608
  decode(input, length) {
@@ -26845,6 +27640,13 @@ var FunctionGetTimeRangeStatsRequest = {
26845
27640
  message.rollup = reader.bool();
26846
27641
  continue;
26847
27642
  }
27643
+ case 5: {
27644
+ if (tag !== 42) {
27645
+ break;
27646
+ }
27647
+ message.containerId = reader.string();
27648
+ continue;
27649
+ }
26848
27650
  }
26849
27651
  if ((tag & 7) === 4 || tag === 0) {
26850
27652
  break;
@@ -26858,7 +27660,8 @@ var FunctionGetTimeRangeStatsRequest = {
26858
27660
  functionId: isSet5(object.functionId) ? globalThis.String(object.functionId) : "",
26859
27661
  since: isSet5(object.since) ? fromJsonTimestamp(object.since) : void 0,
26860
27662
  until: isSet5(object.until) ? fromJsonTimestamp(object.until) : void 0,
26861
- rollup: isSet5(object.rollup) ? globalThis.Boolean(object.rollup) : false
27663
+ rollup: isSet5(object.rollup) ? globalThis.Boolean(object.rollup) : false,
27664
+ containerId: isSet5(object.containerId) ? globalThis.String(object.containerId) : void 0
26862
27665
  };
26863
27666
  },
26864
27667
  toJSON(message) {
@@ -26875,6 +27678,9 @@ var FunctionGetTimeRangeStatsRequest = {
26875
27678
  if (message.rollup !== false) {
26876
27679
  obj.rollup = message.rollup;
26877
27680
  }
27681
+ if (message.containerId !== void 0) {
27682
+ obj.containerId = message.containerId;
27683
+ }
26878
27684
  return obj;
26879
27685
  },
26880
27686
  create(base) {
@@ -26886,6 +27692,7 @@ var FunctionGetTimeRangeStatsRequest = {
26886
27692
  message.since = object.since ?? void 0;
26887
27693
  message.until = object.until ?? void 0;
26888
27694
  message.rollup = object.rollup ?? false;
27695
+ message.containerId = object.containerId ?? void 0;
26889
27696
  return message;
26890
27697
  }
26891
27698
  };
@@ -26893,16 +27700,15 @@ function createBaseFunctionGetTimeRangeStatsResponse() {
26893
27700
  return {
26894
27701
  since: void 0,
26895
27702
  until: void 0,
26896
- executionTimeSeconds: void 0,
26897
- queueTimeSeconds: void 0,
26898
- endToEndLatencySeconds: void 0,
26899
- containerStartupTimeSeconds: void 0,
26900
27703
  inputSuccessCount: 0,
26901
27704
  inputFailureCount: 0,
26902
27705
  inputTimeoutCount: 0,
26903
- cpuUtilization: void 0,
26904
- memoryUtilization: void 0,
26905
- gpuUtilization: void 0,
27706
+ inputRunningAtEndCount: 0,
27707
+ inputPercentileStats: {},
27708
+ containerStartedCount: 0,
27709
+ containerErrorCount: 0,
27710
+ containerCreatingAtEndCount: 0,
27711
+ containerPercentileStats: {},
26906
27712
  variantCount: 0
26907
27713
  };
26908
27714
  }
@@ -26914,38 +27720,41 @@ var FunctionGetTimeRangeStatsResponse = {
26914
27720
  if (message.until !== void 0) {
26915
27721
  Timestamp.encode(toTimestamp(message.until), writer.uint32(18).fork()).join();
26916
27722
  }
26917
- if (message.executionTimeSeconds !== void 0) {
26918
- FunctionStatsPercentiles.encode(message.executionTimeSeconds, writer.uint32(26).fork()).join();
26919
- }
26920
- if (message.queueTimeSeconds !== void 0) {
26921
- FunctionStatsPercentiles.encode(message.queueTimeSeconds, writer.uint32(34).fork()).join();
26922
- }
26923
- if (message.endToEndLatencySeconds !== void 0) {
26924
- FunctionStatsPercentiles.encode(message.endToEndLatencySeconds, writer.uint32(42).fork()).join();
26925
- }
26926
- if (message.containerStartupTimeSeconds !== void 0) {
26927
- FunctionStatsPercentiles.encode(message.containerStartupTimeSeconds, writer.uint32(50).fork()).join();
26928
- }
26929
27723
  if (message.inputSuccessCount !== 0) {
26930
- writer.uint32(56).uint64(message.inputSuccessCount);
27724
+ writer.uint32(24).uint64(message.inputSuccessCount);
26931
27725
  }
26932
27726
  if (message.inputFailureCount !== 0) {
26933
- writer.uint32(64).uint64(message.inputFailureCount);
27727
+ writer.uint32(32).uint64(message.inputFailureCount);
26934
27728
  }
26935
27729
  if (message.inputTimeoutCount !== 0) {
26936
- writer.uint32(72).uint64(message.inputTimeoutCount);
27730
+ writer.uint32(40).uint64(message.inputTimeoutCount);
26937
27731
  }
26938
- if (message.cpuUtilization !== void 0) {
26939
- FunctionStatsPercentiles.encode(message.cpuUtilization, writer.uint32(82).fork()).join();
27732
+ if (message.inputRunningAtEndCount !== 0) {
27733
+ writer.uint32(48).uint64(message.inputRunningAtEndCount);
27734
+ }
27735
+ Object.entries(message.inputPercentileStats).forEach(([key, value]) => {
27736
+ FunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry.encode(
27737
+ { key, value },
27738
+ writer.uint32(58).fork()
27739
+ ).join();
27740
+ });
27741
+ if (message.containerStartedCount !== 0) {
27742
+ writer.uint32(64).uint64(message.containerStartedCount);
26940
27743
  }
26941
- if (message.memoryUtilization !== void 0) {
26942
- FunctionStatsPercentiles.encode(message.memoryUtilization, writer.uint32(90).fork()).join();
27744
+ if (message.containerErrorCount !== 0) {
27745
+ writer.uint32(72).uint64(message.containerErrorCount);
26943
27746
  }
26944
- if (message.gpuUtilization !== void 0) {
26945
- FunctionStatsPercentiles.encode(message.gpuUtilization, writer.uint32(98).fork()).join();
27747
+ if (message.containerCreatingAtEndCount !== 0) {
27748
+ writer.uint32(80).uint64(message.containerCreatingAtEndCount);
26946
27749
  }
27750
+ Object.entries(message.containerPercentileStats).forEach(([key, value]) => {
27751
+ FunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry.encode(
27752
+ { key, value },
27753
+ writer.uint32(90).fork()
27754
+ ).join();
27755
+ });
26947
27756
  if (message.variantCount !== 0) {
26948
- writer.uint32(104).uint32(message.variantCount);
27757
+ writer.uint32(96).uint32(message.variantCount);
26949
27758
  }
26950
27759
  return writer;
26951
27760
  },
@@ -26971,77 +27780,79 @@ var FunctionGetTimeRangeStatsResponse = {
26971
27780
  continue;
26972
27781
  }
26973
27782
  case 3: {
26974
- if (tag !== 26) {
27783
+ if (tag !== 24) {
26975
27784
  break;
26976
27785
  }
26977
- message.executionTimeSeconds = FunctionStatsPercentiles.decode(reader, reader.uint32());
27786
+ message.inputSuccessCount = longToNumber2(reader.uint64());
26978
27787
  continue;
26979
27788
  }
26980
27789
  case 4: {
26981
- if (tag !== 34) {
27790
+ if (tag !== 32) {
26982
27791
  break;
26983
27792
  }
26984
- message.queueTimeSeconds = FunctionStatsPercentiles.decode(reader, reader.uint32());
27793
+ message.inputFailureCount = longToNumber2(reader.uint64());
26985
27794
  continue;
26986
27795
  }
26987
27796
  case 5: {
26988
- if (tag !== 42) {
27797
+ if (tag !== 40) {
26989
27798
  break;
26990
27799
  }
26991
- message.endToEndLatencySeconds = FunctionStatsPercentiles.decode(reader, reader.uint32());
27800
+ message.inputTimeoutCount = longToNumber2(reader.uint64());
26992
27801
  continue;
26993
27802
  }
26994
27803
  case 6: {
26995
- if (tag !== 50) {
27804
+ if (tag !== 48) {
26996
27805
  break;
26997
27806
  }
26998
- message.containerStartupTimeSeconds = FunctionStatsPercentiles.decode(reader, reader.uint32());
27807
+ message.inputRunningAtEndCount = longToNumber2(reader.uint64());
26999
27808
  continue;
27000
27809
  }
27001
27810
  case 7: {
27002
- if (tag !== 56) {
27811
+ if (tag !== 58) {
27003
27812
  break;
27004
27813
  }
27005
- message.inputSuccessCount = longToNumber2(reader.uint64());
27814
+ const entry7 = FunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry.decode(reader, reader.uint32());
27815
+ if (entry7.value !== void 0) {
27816
+ message.inputPercentileStats[entry7.key] = entry7.value;
27817
+ }
27006
27818
  continue;
27007
27819
  }
27008
27820
  case 8: {
27009
27821
  if (tag !== 64) {
27010
27822
  break;
27011
27823
  }
27012
- message.inputFailureCount = longToNumber2(reader.uint64());
27824
+ message.containerStartedCount = longToNumber2(reader.uint64());
27013
27825
  continue;
27014
27826
  }
27015
27827
  case 9: {
27016
27828
  if (tag !== 72) {
27017
27829
  break;
27018
27830
  }
27019
- message.inputTimeoutCount = longToNumber2(reader.uint64());
27831
+ message.containerErrorCount = longToNumber2(reader.uint64());
27020
27832
  continue;
27021
27833
  }
27022
27834
  case 10: {
27023
- if (tag !== 82) {
27835
+ if (tag !== 80) {
27024
27836
  break;
27025
27837
  }
27026
- message.cpuUtilization = FunctionStatsPercentiles.decode(reader, reader.uint32());
27838
+ message.containerCreatingAtEndCount = longToNumber2(reader.uint64());
27027
27839
  continue;
27028
27840
  }
27029
27841
  case 11: {
27030
27842
  if (tag !== 90) {
27031
27843
  break;
27032
27844
  }
27033
- message.memoryUtilization = FunctionStatsPercentiles.decode(reader, reader.uint32());
27034
- continue;
27035
- }
27036
- case 12: {
27037
- if (tag !== 98) {
27038
- break;
27845
+ const entry11 = FunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry.decode(
27846
+ reader,
27847
+ reader.uint32()
27848
+ );
27849
+ if (entry11.value !== void 0) {
27850
+ message.containerPercentileStats[entry11.key] = entry11.value;
27039
27851
  }
27040
- message.gpuUtilization = FunctionStatsPercentiles.decode(reader, reader.uint32());
27041
27852
  continue;
27042
27853
  }
27043
- case 13: {
27044
- if (tag !== 104) {
27854
+ case 12: {
27855
+ if (tag !== 96) {
27045
27856
  break;
27046
27857
  }
27047
27858
  message.variantCount = reader.uint32();
@@ -27059,16 +27870,27 @@ var FunctionGetTimeRangeStatsResponse = {
27059
27870
  return {
27060
27871
  since: isSet5(object.since) ? fromJsonTimestamp(object.since) : void 0,
27061
27872
  until: isSet5(object.until) ? fromJsonTimestamp(object.until) : void 0,
27062
- executionTimeSeconds: isSet5(object.executionTimeSeconds) ? FunctionStatsPercentiles.fromJSON(object.executionTimeSeconds) : void 0,
27063
- queueTimeSeconds: isSet5(object.queueTimeSeconds) ? FunctionStatsPercentiles.fromJSON(object.queueTimeSeconds) : void 0,
27064
- endToEndLatencySeconds: isSet5(object.endToEndLatencySeconds) ? FunctionStatsPercentiles.fromJSON(object.endToEndLatencySeconds) : void 0,
27065
- containerStartupTimeSeconds: isSet5(object.containerStartupTimeSeconds) ? FunctionStatsPercentiles.fromJSON(object.containerStartupTimeSeconds) : void 0,
27066
27873
  inputSuccessCount: isSet5(object.inputSuccessCount) ? globalThis.Number(object.inputSuccessCount) : 0,
27067
27874
  inputFailureCount: isSet5(object.inputFailureCount) ? globalThis.Number(object.inputFailureCount) : 0,
27068
27875
  inputTimeoutCount: isSet5(object.inputTimeoutCount) ? globalThis.Number(object.inputTimeoutCount) : 0,
27069
- cpuUtilization: isSet5(object.cpuUtilization) ? FunctionStatsPercentiles.fromJSON(object.cpuUtilization) : void 0,
27070
- memoryUtilization: isSet5(object.memoryUtilization) ? FunctionStatsPercentiles.fromJSON(object.memoryUtilization) : void 0,
27071
- gpuUtilization: isSet5(object.gpuUtilization) ? FunctionStatsPercentiles.fromJSON(object.gpuUtilization) : void 0,
27876
+ inputRunningAtEndCount: isSet5(object.inputRunningAtEndCount) ? globalThis.Number(object.inputRunningAtEndCount) : 0,
27877
+ inputPercentileStats: isObject2(object.inputPercentileStats) ? Object.entries(object.inputPercentileStats).reduce(
27878
+ (acc, [key, value]) => {
27879
+ acc[key] = StatsPercentileDistribution.fromJSON(value);
27880
+ return acc;
27881
+ },
27882
+ {}
27883
+ ) : {},
27884
+ containerStartedCount: isSet5(object.containerStartedCount) ? globalThis.Number(object.containerStartedCount) : 0,
27885
+ containerErrorCount: isSet5(object.containerErrorCount) ? globalThis.Number(object.containerErrorCount) : 0,
27886
+ containerCreatingAtEndCount: isSet5(object.containerCreatingAtEndCount) ? globalThis.Number(object.containerCreatingAtEndCount) : 0,
27887
+ containerPercentileStats: isObject2(object.containerPercentileStats) ? Object.entries(object.containerPercentileStats).reduce(
27888
+ (acc, [key, value]) => {
27889
+ acc[key] = StatsPercentileDistribution.fromJSON(value);
27890
+ return acc;
27891
+ },
27892
+ {}
27893
+ ) : {},
27072
27894
  variantCount: isSet5(object.variantCount) ? globalThis.Number(object.variantCount) : 0
27073
27895
  };
27074
27896
  },
@@ -27080,18 +27902,6 @@ var FunctionGetTimeRangeStatsResponse = {
27080
27902
  if (message.until !== void 0) {
27081
27903
  obj.until = message.until.toISOString();
27082
27904
  }
27083
- if (message.executionTimeSeconds !== void 0) {
27084
- obj.executionTimeSeconds = FunctionStatsPercentiles.toJSON(message.executionTimeSeconds);
27085
- }
27086
- if (message.queueTimeSeconds !== void 0) {
27087
- obj.queueTimeSeconds = FunctionStatsPercentiles.toJSON(message.queueTimeSeconds);
27088
- }
27089
- if (message.endToEndLatencySeconds !== void 0) {
27090
- obj.endToEndLatencySeconds = FunctionStatsPercentiles.toJSON(message.endToEndLatencySeconds);
27091
- }
27092
- if (message.containerStartupTimeSeconds !== void 0) {
27093
- obj.containerStartupTimeSeconds = FunctionStatsPercentiles.toJSON(message.containerStartupTimeSeconds);
27094
- }
27095
27905
  if (message.inputSuccessCount !== 0) {
27096
27906
  obj.inputSuccessCount = Math.round(message.inputSuccessCount);
27097
27907
  }
@@ -27101,14 +27911,35 @@ var FunctionGetTimeRangeStatsResponse = {
27101
27911
  if (message.inputTimeoutCount !== 0) {
27102
27912
  obj.inputTimeoutCount = Math.round(message.inputTimeoutCount);
27103
27913
  }
27104
- if (message.cpuUtilization !== void 0) {
27105
- obj.cpuUtilization = FunctionStatsPercentiles.toJSON(message.cpuUtilization);
27914
+ if (message.inputRunningAtEndCount !== 0) {
27915
+ obj.inputRunningAtEndCount = Math.round(message.inputRunningAtEndCount);
27916
+ }
27917
+ if (message.inputPercentileStats) {
27918
+ const entries = Object.entries(message.inputPercentileStats);
27919
+ if (entries.length > 0) {
27920
+ obj.inputPercentileStats = {};
27921
+ entries.forEach(([k, v]) => {
27922
+ obj.inputPercentileStats[k] = StatsPercentileDistribution.toJSON(v);
27923
+ });
27924
+ }
27925
+ }
27926
+ if (message.containerStartedCount !== 0) {
27927
+ obj.containerStartedCount = Math.round(message.containerStartedCount);
27106
27928
  }
27107
- if (message.memoryUtilization !== void 0) {
27108
- obj.memoryUtilization = FunctionStatsPercentiles.toJSON(message.memoryUtilization);
27929
+ if (message.containerErrorCount !== 0) {
27930
+ obj.containerErrorCount = Math.round(message.containerErrorCount);
27109
27931
  }
27110
- if (message.gpuUtilization !== void 0) {
27111
- obj.gpuUtilization = FunctionStatsPercentiles.toJSON(message.gpuUtilization);
27932
+ if (message.containerCreatingAtEndCount !== 0) {
27933
+ obj.containerCreatingAtEndCount = Math.round(message.containerCreatingAtEndCount);
27934
+ }
27935
+ if (message.containerPercentileStats) {
27936
+ const entries = Object.entries(message.containerPercentileStats);
27937
+ if (entries.length > 0) {
27938
+ obj.containerPercentileStats = {};
27939
+ entries.forEach(([k, v]) => {
27940
+ obj.containerPercentileStats[k] = StatsPercentileDistribution.toJSON(v);
27941
+ });
27942
+ }
27112
27943
  }
27113
27944
  if (message.variantCount !== 0) {
27114
27945
  obj.variantCount = Math.round(message.variantCount);
@@ -27122,20 +27953,165 @@ var FunctionGetTimeRangeStatsResponse = {
27122
27953
  const message = createBaseFunctionGetTimeRangeStatsResponse();
27123
27954
  message.since = object.since ?? void 0;
27124
27955
  message.until = object.until ?? void 0;
27125
- message.executionTimeSeconds = object.executionTimeSeconds !== void 0 && object.executionTimeSeconds !== null ? FunctionStatsPercentiles.fromPartial(object.executionTimeSeconds) : void 0;
27126
- message.queueTimeSeconds = object.queueTimeSeconds !== void 0 && object.queueTimeSeconds !== null ? FunctionStatsPercentiles.fromPartial(object.queueTimeSeconds) : void 0;
27127
- message.endToEndLatencySeconds = object.endToEndLatencySeconds !== void 0 && object.endToEndLatencySeconds !== null ? FunctionStatsPercentiles.fromPartial(object.endToEndLatencySeconds) : void 0;
27128
- message.containerStartupTimeSeconds = object.containerStartupTimeSeconds !== void 0 && object.containerStartupTimeSeconds !== null ? FunctionStatsPercentiles.fromPartial(object.containerStartupTimeSeconds) : void 0;
27129
27956
  message.inputSuccessCount = object.inputSuccessCount ?? 0;
27130
27957
  message.inputFailureCount = object.inputFailureCount ?? 0;
27131
27958
  message.inputTimeoutCount = object.inputTimeoutCount ?? 0;
27132
- message.cpuUtilization = object.cpuUtilization !== void 0 && object.cpuUtilization !== null ? FunctionStatsPercentiles.fromPartial(object.cpuUtilization) : void 0;
27133
- message.memoryUtilization = object.memoryUtilization !== void 0 && object.memoryUtilization !== null ? FunctionStatsPercentiles.fromPartial(object.memoryUtilization) : void 0;
27134
- message.gpuUtilization = object.gpuUtilization !== void 0 && object.gpuUtilization !== null ? FunctionStatsPercentiles.fromPartial(object.gpuUtilization) : void 0;
27959
+ message.inputRunningAtEndCount = object.inputRunningAtEndCount ?? 0;
27960
+ message.inputPercentileStats = Object.entries(object.inputPercentileStats ?? {}).reduce((acc, [key, value]) => {
27961
+ if (value !== void 0) {
27962
+ acc[key] = StatsPercentileDistribution.fromPartial(value);
27963
+ }
27964
+ return acc;
27965
+ }, {});
27966
+ message.containerStartedCount = object.containerStartedCount ?? 0;
27967
+ message.containerErrorCount = object.containerErrorCount ?? 0;
27968
+ message.containerCreatingAtEndCount = object.containerCreatingAtEndCount ?? 0;
27969
+ message.containerPercentileStats = Object.entries(object.containerPercentileStats ?? {}).reduce((acc, [key, value]) => {
27970
+ if (value !== void 0) {
27971
+ acc[key] = StatsPercentileDistribution.fromPartial(value);
27972
+ }
27973
+ return acc;
27974
+ }, {});
27135
27975
  message.variantCount = object.variantCount ?? 0;
27136
27976
  return message;
27137
27977
  }
27138
27978
  };
27979
+ function createBaseFunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry() {
27980
+ return { key: "", value: void 0 };
27981
+ }
27982
+ var FunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry = {
27983
+ encode(message, writer = new BinaryWriter()) {
27984
+ if (message.key !== "") {
27985
+ writer.uint32(10).string(message.key);
27986
+ }
27987
+ if (message.value !== void 0) {
27988
+ StatsPercentileDistribution.encode(message.value, writer.uint32(18).fork()).join();
27989
+ }
27990
+ return writer;
27991
+ },
27992
+ decode(input, length) {
27993
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
27994
+ let end = length === void 0 ? reader.len : reader.pos + length;
27995
+ const message = createBaseFunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry();
27996
+ while (reader.pos < end) {
27997
+ const tag = reader.uint32();
27998
+ switch (tag >>> 3) {
27999
+ case 1: {
28000
+ if (tag !== 10) {
28001
+ break;
28002
+ }
28003
+ message.key = reader.string();
28004
+ continue;
28005
+ }
28006
+ case 2: {
28007
+ if (tag !== 18) {
28008
+ break;
28009
+ }
28010
+ message.value = StatsPercentileDistribution.decode(reader, reader.uint32());
28011
+ continue;
28012
+ }
28013
+ }
28014
+ if ((tag & 7) === 4 || tag === 0) {
28015
+ break;
28016
+ }
28017
+ reader.skip(tag & 7);
28018
+ }
28019
+ return message;
28020
+ },
28021
+ fromJSON(object) {
28022
+ return {
28023
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
28024
+ value: isSet5(object.value) ? StatsPercentileDistribution.fromJSON(object.value) : void 0
28025
+ };
28026
+ },
28027
+ toJSON(message) {
28028
+ const obj = {};
28029
+ if (message.key !== "") {
28030
+ obj.key = message.key;
28031
+ }
28032
+ if (message.value !== void 0) {
28033
+ obj.value = StatsPercentileDistribution.toJSON(message.value);
28034
+ }
28035
+ return obj;
28036
+ },
28037
+ create(base) {
28038
+ return FunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry.fromPartial(base ?? {});
28039
+ },
28040
+ fromPartial(object) {
28041
+ const message = createBaseFunctionGetTimeRangeStatsResponse_InputPercentileStatsEntry();
28042
+ message.key = object.key ?? "";
28043
+ message.value = object.value !== void 0 && object.value !== null ? StatsPercentileDistribution.fromPartial(object.value) : void 0;
28044
+ return message;
28045
+ }
28046
+ };
28047
+ function createBaseFunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry() {
28048
+ return { key: "", value: void 0 };
28049
+ }
28050
+ var FunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry = {
28051
+ encode(message, writer = new BinaryWriter()) {
28052
+ if (message.key !== "") {
28053
+ writer.uint32(10).string(message.key);
28054
+ }
28055
+ if (message.value !== void 0) {
28056
+ StatsPercentileDistribution.encode(message.value, writer.uint32(18).fork()).join();
28057
+ }
28058
+ return writer;
28059
+ },
28060
+ decode(input, length) {
28061
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
28062
+ let end = length === void 0 ? reader.len : reader.pos + length;
28063
+ const message = createBaseFunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry();
28064
+ while (reader.pos < end) {
28065
+ const tag = reader.uint32();
28066
+ switch (tag >>> 3) {
28067
+ case 1: {
28068
+ if (tag !== 10) {
28069
+ break;
28070
+ }
28071
+ message.key = reader.string();
28072
+ continue;
28073
+ }
28074
+ case 2: {
28075
+ if (tag !== 18) {
28076
+ break;
28077
+ }
28078
+ message.value = StatsPercentileDistribution.decode(reader, reader.uint32());
28079
+ continue;
28080
+ }
28081
+ }
28082
+ if ((tag & 7) === 4 || tag === 0) {
28083
+ break;
28084
+ }
28085
+ reader.skip(tag & 7);
28086
+ }
28087
+ return message;
28088
+ },
28089
+ fromJSON(object) {
28090
+ return {
28091
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
28092
+ value: isSet5(object.value) ? StatsPercentileDistribution.fromJSON(object.value) : void 0
28093
+ };
28094
+ },
28095
+ toJSON(message) {
28096
+ const obj = {};
28097
+ if (message.key !== "") {
28098
+ obj.key = message.key;
28099
+ }
28100
+ if (message.value !== void 0) {
28101
+ obj.value = StatsPercentileDistribution.toJSON(message.value);
28102
+ }
28103
+ return obj;
28104
+ },
28105
+ create(base) {
28106
+ return FunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry.fromPartial(base ?? {});
28107
+ },
28108
+ fromPartial(object) {
28109
+ const message = createBaseFunctionGetTimeRangeStatsResponse_ContainerPercentileStatsEntry();
28110
+ message.key = object.key ?? "";
28111
+ message.value = object.value !== void 0 && object.value !== null ? StatsPercentileDistribution.fromPartial(object.value) : void 0;
28112
+ return message;
28113
+ }
28114
+ };
27139
28115
  function createBaseFunctionHandleMetadata() {
27140
28116
  return {
27141
28117
  functionName: "",
@@ -29796,74 +30772,6 @@ var FunctionStats = {
29796
30772
  return message;
29797
30773
  }
29798
30774
  };
29799
- function createBaseFunctionStatsPercentiles() {
29800
- return { p50: 0, p90: 0 };
29801
- }
29802
- var FunctionStatsPercentiles = {
29803
- encode(message, writer = new BinaryWriter()) {
29804
- if (message.p50 !== 0) {
29805
- writer.uint32(9).double(message.p50);
29806
- }
29807
- if (message.p90 !== 0) {
29808
- writer.uint32(17).double(message.p90);
29809
- }
29810
- return writer;
29811
- },
29812
- decode(input, length) {
29813
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
29814
- let end = length === void 0 ? reader.len : reader.pos + length;
29815
- const message = createBaseFunctionStatsPercentiles();
29816
- while (reader.pos < end) {
29817
- const tag = reader.uint32();
29818
- switch (tag >>> 3) {
29819
- case 1: {
29820
- if (tag !== 9) {
29821
- break;
29822
- }
29823
- message.p50 = reader.double();
29824
- continue;
29825
- }
29826
- case 2: {
29827
- if (tag !== 17) {
29828
- break;
29829
- }
29830
- message.p90 = reader.double();
29831
- continue;
29832
- }
29833
- }
29834
- if ((tag & 7) === 4 || tag === 0) {
29835
- break;
29836
- }
29837
- reader.skip(tag & 7);
29838
- }
29839
- return message;
29840
- },
29841
- fromJSON(object) {
29842
- return {
29843
- p50: isSet5(object.p50) ? globalThis.Number(object.p50) : 0,
29844
- p90: isSet5(object.p90) ? globalThis.Number(object.p90) : 0
29845
- };
29846
- },
29847
- toJSON(message) {
29848
- const obj = {};
29849
- if (message.p50 !== 0) {
29850
- obj.p50 = message.p50;
29851
- }
29852
- if (message.p90 !== 0) {
29853
- obj.p90 = message.p90;
29854
- }
29855
- return obj;
29856
- },
29857
- create(base) {
29858
- return FunctionStatsPercentiles.fromPartial(base ?? {});
29859
- },
29860
- fromPartial(object) {
29861
- const message = createBaseFunctionStatsPercentiles();
29862
- message.p50 = object.p50 ?? 0;
29863
- message.p90 = object.p90 ?? 0;
29864
- return message;
29865
- }
29866
- };
29867
30775
  function createBaseFunctionUpdateSchedulingParamsRequest() {
29868
30776
  return { functionId: "", warmPoolSizeOverride: 0, settings: void 0 };
29869
30777
  }
@@ -30552,7 +31460,8 @@ function createBaseImage() {
30552
31460
  runtimeDebug: false,
30553
31461
  buildFunction: void 0,
30554
31462
  buildArgs: {},
30555
- volumeMounts: []
31463
+ volumeMounts: [],
31464
+ arch: 0
30556
31465
  };
30557
31466
  }
30558
31467
  var Image = {
@@ -30602,6 +31511,9 @@ var Image = {
30602
31511
  for (const v of message.volumeMounts) {
30603
31512
  VolumeMount.encode(v, writer.uint32(186).fork()).join();
30604
31513
  }
31514
+ if (message.arch !== 0) {
31515
+ writer.uint32(192).int32(message.arch);
31516
+ }
30605
31517
  return writer;
30606
31518
  },
30607
31519
  decode(input, length) {
@@ -30719,6 +31631,13 @@ var Image = {
30719
31631
  message.volumeMounts.push(VolumeMount.decode(reader, reader.uint32()));
30720
31632
  continue;
30721
31633
  }
31634
+ case 24: {
31635
+ if (tag !== 192) {
31636
+ break;
31637
+ }
31638
+ message.arch = reader.int32();
31639
+ continue;
31640
+ }
30722
31641
  }
30723
31642
  if ((tag & 7) === 4 || tag === 0) {
30724
31643
  break;
@@ -30746,7 +31665,8 @@ var Image = {
30746
31665
  acc[key] = String(value);
30747
31666
  return acc;
30748
31667
  }, {}) : {},
30749
- volumeMounts: globalThis.Array.isArray(object?.volumeMounts) ? object.volumeMounts.map((e) => VolumeMount.fromJSON(e)) : []
31668
+ volumeMounts: globalThis.Array.isArray(object?.volumeMounts) ? object.volumeMounts.map((e) => VolumeMount.fromJSON(e)) : [],
31669
+ arch: isSet5(object.arch) ? archFromJSON(object.arch) : 0
30750
31670
  };
30751
31671
  },
30752
31672
  toJSON(message) {
@@ -30802,6 +31722,9 @@ var Image = {
30802
31722
  if (message.volumeMounts?.length) {
30803
31723
  obj.volumeMounts = message.volumeMounts.map((e) => VolumeMount.toJSON(e));
30804
31724
  }
31725
+ if (message.arch !== 0) {
31726
+ obj.arch = archToJSON(message.arch);
31727
+ }
30805
31728
  return obj;
30806
31729
  },
30807
31730
  create(base) {
@@ -30832,6 +31755,7 @@ var Image = {
30832
31755
  {}
30833
31756
  );
30834
31757
  message.volumeMounts = object.volumeMounts?.map((e) => VolumeMount.fromPartial(e)) || [];
31758
+ message.arch = object.arch ?? 0;
30835
31759
  return message;
30836
31760
  }
30837
31761
  };
@@ -35879,6 +36803,157 @@ var ObjectDependency = {
35879
36803
  return message;
35880
36804
  }
35881
36805
  };
36806
+ function createBaseOutboundPolicy() {
36807
+ return { headerReplacements: [] };
36808
+ }
36809
+ var OutboundPolicy = {
36810
+ encode(message, writer = new BinaryWriter()) {
36811
+ for (const v of message.headerReplacements) {
36812
+ OutboundPolicy_HeaderReplacement.encode(v, writer.uint32(10).fork()).join();
36813
+ }
36814
+ return writer;
36815
+ },
36816
+ decode(input, length) {
36817
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
36818
+ let end = length === void 0 ? reader.len : reader.pos + length;
36819
+ const message = createBaseOutboundPolicy();
36820
+ while (reader.pos < end) {
36821
+ const tag = reader.uint32();
36822
+ switch (tag >>> 3) {
36823
+ case 1: {
36824
+ if (tag !== 10) {
36825
+ break;
36826
+ }
36827
+ message.headerReplacements.push(OutboundPolicy_HeaderReplacement.decode(reader, reader.uint32()));
36828
+ continue;
36829
+ }
36830
+ }
36831
+ if ((tag & 7) === 4 || tag === 0) {
36832
+ break;
36833
+ }
36834
+ reader.skip(tag & 7);
36835
+ }
36836
+ return message;
36837
+ },
36838
+ fromJSON(object) {
36839
+ return {
36840
+ headerReplacements: globalThis.Array.isArray(object?.headerReplacements) ? object.headerReplacements.map((e) => OutboundPolicy_HeaderReplacement.fromJSON(e)) : []
36841
+ };
36842
+ },
36843
+ toJSON(message) {
36844
+ const obj = {};
36845
+ if (message.headerReplacements?.length) {
36846
+ obj.headerReplacements = message.headerReplacements.map((e) => OutboundPolicy_HeaderReplacement.toJSON(e));
36847
+ }
36848
+ return obj;
36849
+ },
36850
+ create(base) {
36851
+ return OutboundPolicy.fromPartial(base ?? {});
36852
+ },
36853
+ fromPartial(object) {
36854
+ const message = createBaseOutboundPolicy();
36855
+ message.headerReplacements = object.headerReplacements?.map((e) => OutboundPolicy_HeaderReplacement.fromPartial(e)) || [];
36856
+ return message;
36857
+ }
36858
+ };
36859
+ function createBaseOutboundPolicy_HeaderReplacement() {
36860
+ return { domain: "", headerName: "", headerValue: "", secretId: "" };
36861
+ }
36862
+ var OutboundPolicy_HeaderReplacement = {
36863
+ encode(message, writer = new BinaryWriter()) {
36864
+ if (message.domain !== "") {
36865
+ writer.uint32(10).string(message.domain);
36866
+ }
36867
+ if (message.headerName !== "") {
36868
+ writer.uint32(18).string(message.headerName);
36869
+ }
36870
+ if (message.headerValue !== "") {
36871
+ writer.uint32(26).string(message.headerValue);
36872
+ }
36873
+ if (message.secretId !== "") {
36874
+ writer.uint32(34).string(message.secretId);
36875
+ }
36876
+ return writer;
36877
+ },
36878
+ decode(input, length) {
36879
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
36880
+ let end = length === void 0 ? reader.len : reader.pos + length;
36881
+ const message = createBaseOutboundPolicy_HeaderReplacement();
36882
+ while (reader.pos < end) {
36883
+ const tag = reader.uint32();
36884
+ switch (tag >>> 3) {
36885
+ case 1: {
36886
+ if (tag !== 10) {
36887
+ break;
36888
+ }
36889
+ message.domain = reader.string();
36890
+ continue;
36891
+ }
36892
+ case 2: {
36893
+ if (tag !== 18) {
36894
+ break;
36895
+ }
36896
+ message.headerName = reader.string();
36897
+ continue;
36898
+ }
36899
+ case 3: {
36900
+ if (tag !== 26) {
36901
+ break;
36902
+ }
36903
+ message.headerValue = reader.string();
36904
+ continue;
36905
+ }
36906
+ case 4: {
36907
+ if (tag !== 34) {
36908
+ break;
36909
+ }
36910
+ message.secretId = reader.string();
36911
+ continue;
36912
+ }
36913
+ }
36914
+ if ((tag & 7) === 4 || tag === 0) {
36915
+ break;
36916
+ }
36917
+ reader.skip(tag & 7);
36918
+ }
36919
+ return message;
36920
+ },
36921
+ fromJSON(object) {
36922
+ return {
36923
+ domain: isSet5(object.domain) ? globalThis.String(object.domain) : "",
36924
+ headerName: isSet5(object.headerName) ? globalThis.String(object.headerName) : "",
36925
+ headerValue: isSet5(object.headerValue) ? globalThis.String(object.headerValue) : "",
36926
+ secretId: isSet5(object.secretId) ? globalThis.String(object.secretId) : ""
36927
+ };
36928
+ },
36929
+ toJSON(message) {
36930
+ const obj = {};
36931
+ if (message.domain !== "") {
36932
+ obj.domain = message.domain;
36933
+ }
36934
+ if (message.headerName !== "") {
36935
+ obj.headerName = message.headerName;
36936
+ }
36937
+ if (message.headerValue !== "") {
36938
+ obj.headerValue = message.headerValue;
36939
+ }
36940
+ if (message.secretId !== "") {
36941
+ obj.secretId = message.secretId;
36942
+ }
36943
+ return obj;
36944
+ },
36945
+ create(base) {
36946
+ return OutboundPolicy_HeaderReplacement.fromPartial(base ?? {});
36947
+ },
36948
+ fromPartial(object) {
36949
+ const message = createBaseOutboundPolicy_HeaderReplacement();
36950
+ message.domain = object.domain ?? "";
36951
+ message.headerName = object.headerName ?? "";
36952
+ message.headerValue = object.headerValue ?? "";
36953
+ message.secretId = object.secretId ?? "";
36954
+ return message;
36955
+ }
36956
+ };
35882
36957
  function createBasePTYInfo() {
35883
36958
  return {
35884
36959
  enabled: false,
@@ -39569,7 +40644,8 @@ function createBaseSandbox() {
39569
40644
  includeOidcIdentityToken: false,
39570
40645
  readinessProbe: void 0,
39571
40646
  inboundCidrAllowlist: [],
39572
- environmentVariables: void 0
40647
+ environmentVariables: void 0,
40648
+ outboundPolicy: void 0
39573
40649
  };
39574
40650
  }
39575
40651
  var Sandbox = {
@@ -39691,6 +40767,9 @@ var Sandbox = {
39691
40767
  if (message.environmentVariables !== void 0) {
39692
40768
  StringMap.encode(message.environmentVariables, writer.uint32(322).fork()).join();
39693
40769
  }
40770
+ if (message.outboundPolicy !== void 0) {
40771
+ OutboundPolicy.encode(message.outboundPolicy, writer.uint32(338).fork()).join();
40772
+ }
39694
40773
  return writer;
39695
40774
  },
39696
40775
  decode(input, length) {
@@ -39979,6 +41058,13 @@ var Sandbox = {
39979
41058
  message.environmentVariables = StringMap.decode(reader, reader.uint32());
39980
41059
  continue;
39981
41060
  }
41061
+ case 42: {
41062
+ if (tag !== 338) {
41063
+ break;
41064
+ }
41065
+ message.outboundPolicy = OutboundPolicy.decode(reader, reader.uint32());
41066
+ continue;
41067
+ }
39982
41068
  }
39983
41069
  if ((tag & 7) === 4 || tag === 0) {
39984
41070
  break;
@@ -40033,7 +41119,8 @@ var Sandbox = {
40033
41119
  includeOidcIdentityToken: isSet5(object.includeOidcIdentityToken) ? globalThis.Boolean(object.includeOidcIdentityToken) : false,
40034
41120
  readinessProbe: isSet5(object.readinessProbe) ? Probe.fromJSON(object.readinessProbe) : void 0,
40035
41121
  inboundCidrAllowlist: globalThis.Array.isArray(object?.inboundCidrAllowlist) ? object.inboundCidrAllowlist.map((e) => globalThis.String(e)) : [],
40036
- environmentVariables: isSet5(object.environmentVariables) ? StringMap.fromJSON(object.environmentVariables) : void 0
41122
+ environmentVariables: isSet5(object.environmentVariables) ? StringMap.fromJSON(object.environmentVariables) : void 0,
41123
+ outboundPolicy: isSet5(object.outboundPolicy) ? OutboundPolicy.fromJSON(object.outboundPolicy) : void 0
40037
41124
  };
40038
41125
  },
40039
41126
  toJSON(message) {
@@ -40167,6 +41254,9 @@ var Sandbox = {
40167
41254
  if (message.environmentVariables !== void 0) {
40168
41255
  obj.environmentVariables = StringMap.toJSON(message.environmentVariables);
40169
41256
  }
41257
+ if (message.outboundPolicy !== void 0) {
41258
+ obj.outboundPolicy = OutboundPolicy.toJSON(message.outboundPolicy);
41259
+ }
40170
41260
  return obj;
40171
41261
  },
40172
41262
  create(base) {
@@ -40226,6 +41316,7 @@ var Sandbox = {
40226
41316
  message.readinessProbe = object.readinessProbe !== void 0 && object.readinessProbe !== null ? Probe.fromPartial(object.readinessProbe) : void 0;
40227
41317
  message.inboundCidrAllowlist = object.inboundCidrAllowlist?.map((e) => e) || [];
40228
41318
  message.environmentVariables = object.environmentVariables !== void 0 && object.environmentVariables !== null ? StringMap.fromPartial(object.environmentVariables) : void 0;
41319
+ message.outboundPolicy = object.outboundPolicy !== void 0 && object.outboundPolicy !== null ? OutboundPolicy.fromPartial(object.outboundPolicy) : void 0;
40229
41320
  return message;
40230
41321
  }
40231
41322
  };
@@ -40365,6 +41456,287 @@ var Sandbox_ExperimentalOptionsV2Entry = {
40365
41456
  return message;
40366
41457
  }
40367
41458
  };
41459
+ function createBaseSandboxContainerCreateV2Request() {
41460
+ return {
41461
+ sandboxId: "",
41462
+ containerName: "",
41463
+ definition: void 0,
41464
+ ephemeralSecrets: void 0,
41465
+ cloudBucketMountCredentials: {}
41466
+ };
41467
+ }
41468
+ var SandboxContainerCreateV2Request = {
41469
+ encode(message, writer = new BinaryWriter()) {
41470
+ if (message.sandboxId !== "") {
41471
+ writer.uint32(10).string(message.sandboxId);
41472
+ }
41473
+ if (message.containerName !== "") {
41474
+ writer.uint32(18).string(message.containerName);
41475
+ }
41476
+ if (message.definition !== void 0) {
41477
+ Sandbox.encode(message.definition, writer.uint32(26).fork()).join();
41478
+ }
41479
+ if (message.ephemeralSecrets !== void 0) {
41480
+ StringMap.encode(message.ephemeralSecrets, writer.uint32(34).fork()).join();
41481
+ }
41482
+ Object.entries(message.cloudBucketMountCredentials).forEach(([key, value]) => {
41483
+ SandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry.encode(
41484
+ { key, value },
41485
+ writer.uint32(42).fork()
41486
+ ).join();
41487
+ });
41488
+ return writer;
41489
+ },
41490
+ decode(input, length) {
41491
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
41492
+ let end = length === void 0 ? reader.len : reader.pos + length;
41493
+ const message = createBaseSandboxContainerCreateV2Request();
41494
+ while (reader.pos < end) {
41495
+ const tag = reader.uint32();
41496
+ switch (tag >>> 3) {
41497
+ case 1: {
41498
+ if (tag !== 10) {
41499
+ break;
41500
+ }
41501
+ message.sandboxId = reader.string();
41502
+ continue;
41503
+ }
41504
+ case 2: {
41505
+ if (tag !== 18) {
41506
+ break;
41507
+ }
41508
+ message.containerName = reader.string();
41509
+ continue;
41510
+ }
41511
+ case 3: {
41512
+ if (tag !== 26) {
41513
+ break;
41514
+ }
41515
+ message.definition = Sandbox.decode(reader, reader.uint32());
41516
+ continue;
41517
+ }
41518
+ case 4: {
41519
+ if (tag !== 34) {
41520
+ break;
41521
+ }
41522
+ message.ephemeralSecrets = StringMap.decode(reader, reader.uint32());
41523
+ continue;
41524
+ }
41525
+ case 5: {
41526
+ if (tag !== 42) {
41527
+ break;
41528
+ }
41529
+ const entry5 = SandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry.decode(
41530
+ reader,
41531
+ reader.uint32()
41532
+ );
41533
+ if (entry5.value !== void 0) {
41534
+ message.cloudBucketMountCredentials[entry5.key] = entry5.value;
41535
+ }
41536
+ continue;
41537
+ }
41538
+ }
41539
+ if ((tag & 7) === 4 || tag === 0) {
41540
+ break;
41541
+ }
41542
+ reader.skip(tag & 7);
41543
+ }
41544
+ return message;
41545
+ },
41546
+ fromJSON(object) {
41547
+ return {
41548
+ sandboxId: isSet5(object.sandboxId) ? globalThis.String(object.sandboxId) : "",
41549
+ containerName: isSet5(object.containerName) ? globalThis.String(object.containerName) : "",
41550
+ definition: isSet5(object.definition) ? Sandbox.fromJSON(object.definition) : void 0,
41551
+ ephemeralSecrets: isSet5(object.ephemeralSecrets) ? StringMap.fromJSON(object.ephemeralSecrets) : void 0,
41552
+ cloudBucketMountCredentials: isObject2(object.cloudBucketMountCredentials) ? Object.entries(object.cloudBucketMountCredentials).reduce(
41553
+ (acc, [key, value]) => {
41554
+ acc[key] = StringMap.fromJSON(value);
41555
+ return acc;
41556
+ },
41557
+ {}
41558
+ ) : {}
41559
+ };
41560
+ },
41561
+ toJSON(message) {
41562
+ const obj = {};
41563
+ if (message.sandboxId !== "") {
41564
+ obj.sandboxId = message.sandboxId;
41565
+ }
41566
+ if (message.containerName !== "") {
41567
+ obj.containerName = message.containerName;
41568
+ }
41569
+ if (message.definition !== void 0) {
41570
+ obj.definition = Sandbox.toJSON(message.definition);
41571
+ }
41572
+ if (message.ephemeralSecrets !== void 0) {
41573
+ obj.ephemeralSecrets = StringMap.toJSON(message.ephemeralSecrets);
41574
+ }
41575
+ if (message.cloudBucketMountCredentials) {
41576
+ const entries = Object.entries(message.cloudBucketMountCredentials);
41577
+ if (entries.length > 0) {
41578
+ obj.cloudBucketMountCredentials = {};
41579
+ entries.forEach(([k, v]) => {
41580
+ obj.cloudBucketMountCredentials[k] = StringMap.toJSON(v);
41581
+ });
41582
+ }
41583
+ }
41584
+ return obj;
41585
+ },
41586
+ create(base) {
41587
+ return SandboxContainerCreateV2Request.fromPartial(base ?? {});
41588
+ },
41589
+ fromPartial(object) {
41590
+ const message = createBaseSandboxContainerCreateV2Request();
41591
+ message.sandboxId = object.sandboxId ?? "";
41592
+ message.containerName = object.containerName ?? "";
41593
+ message.definition = object.definition !== void 0 && object.definition !== null ? Sandbox.fromPartial(object.definition) : void 0;
41594
+ message.ephemeralSecrets = object.ephemeralSecrets !== void 0 && object.ephemeralSecrets !== null ? StringMap.fromPartial(object.ephemeralSecrets) : void 0;
41595
+ message.cloudBucketMountCredentials = Object.entries(object.cloudBucketMountCredentials ?? {}).reduce((acc, [key, value]) => {
41596
+ if (value !== void 0) {
41597
+ acc[key] = StringMap.fromPartial(value);
41598
+ }
41599
+ return acc;
41600
+ }, {});
41601
+ return message;
41602
+ }
41603
+ };
41604
+ function createBaseSandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry() {
41605
+ return { key: "", value: void 0 };
41606
+ }
41607
+ var SandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry = {
41608
+ encode(message, writer = new BinaryWriter()) {
41609
+ if (message.key !== "") {
41610
+ writer.uint32(10).string(message.key);
41611
+ }
41612
+ if (message.value !== void 0) {
41613
+ StringMap.encode(message.value, writer.uint32(18).fork()).join();
41614
+ }
41615
+ return writer;
41616
+ },
41617
+ decode(input, length) {
41618
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
41619
+ let end = length === void 0 ? reader.len : reader.pos + length;
41620
+ const message = createBaseSandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry();
41621
+ while (reader.pos < end) {
41622
+ const tag = reader.uint32();
41623
+ switch (tag >>> 3) {
41624
+ case 1: {
41625
+ if (tag !== 10) {
41626
+ break;
41627
+ }
41628
+ message.key = reader.string();
41629
+ continue;
41630
+ }
41631
+ case 2: {
41632
+ if (tag !== 18) {
41633
+ break;
41634
+ }
41635
+ message.value = StringMap.decode(reader, reader.uint32());
41636
+ continue;
41637
+ }
41638
+ }
41639
+ if ((tag & 7) === 4 || tag === 0) {
41640
+ break;
41641
+ }
41642
+ reader.skip(tag & 7);
41643
+ }
41644
+ return message;
41645
+ },
41646
+ fromJSON(object) {
41647
+ return {
41648
+ key: isSet5(object.key) ? globalThis.String(object.key) : "",
41649
+ value: isSet5(object.value) ? StringMap.fromJSON(object.value) : void 0
41650
+ };
41651
+ },
41652
+ toJSON(message) {
41653
+ const obj = {};
41654
+ if (message.key !== "") {
41655
+ obj.key = message.key;
41656
+ }
41657
+ if (message.value !== void 0) {
41658
+ obj.value = StringMap.toJSON(message.value);
41659
+ }
41660
+ return obj;
41661
+ },
41662
+ create(base) {
41663
+ return SandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry.fromPartial(base ?? {});
41664
+ },
41665
+ fromPartial(object) {
41666
+ const message = createBaseSandboxContainerCreateV2Request_CloudBucketMountCredentialsEntry();
41667
+ message.key = object.key ?? "";
41668
+ message.value = object.value !== void 0 && object.value !== null ? StringMap.fromPartial(object.value) : void 0;
41669
+ return message;
41670
+ }
41671
+ };
41672
+ function createBaseSandboxContainerCreateV2Response() {
41673
+ return { containerId: "", containerName: "" };
41674
+ }
41675
+ var SandboxContainerCreateV2Response = {
41676
+ encode(message, writer = new BinaryWriter()) {
41677
+ if (message.containerId !== "") {
41678
+ writer.uint32(10).string(message.containerId);
41679
+ }
41680
+ if (message.containerName !== "") {
41681
+ writer.uint32(18).string(message.containerName);
41682
+ }
41683
+ return writer;
41684
+ },
41685
+ decode(input, length) {
41686
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
41687
+ let end = length === void 0 ? reader.len : reader.pos + length;
41688
+ const message = createBaseSandboxContainerCreateV2Response();
41689
+ while (reader.pos < end) {
41690
+ const tag = reader.uint32();
41691
+ switch (tag >>> 3) {
41692
+ case 1: {
41693
+ if (tag !== 10) {
41694
+ break;
41695
+ }
41696
+ message.containerId = reader.string();
41697
+ continue;
41698
+ }
41699
+ case 2: {
41700
+ if (tag !== 18) {
41701
+ break;
41702
+ }
41703
+ message.containerName = reader.string();
41704
+ continue;
41705
+ }
41706
+ }
41707
+ if ((tag & 7) === 4 || tag === 0) {
41708
+ break;
41709
+ }
41710
+ reader.skip(tag & 7);
41711
+ }
41712
+ return message;
41713
+ },
41714
+ fromJSON(object) {
41715
+ return {
41716
+ containerId: isSet5(object.containerId) ? globalThis.String(object.containerId) : "",
41717
+ containerName: isSet5(object.containerName) ? globalThis.String(object.containerName) : ""
41718
+ };
41719
+ },
41720
+ toJSON(message) {
41721
+ const obj = {};
41722
+ if (message.containerId !== "") {
41723
+ obj.containerId = message.containerId;
41724
+ }
41725
+ if (message.containerName !== "") {
41726
+ obj.containerName = message.containerName;
41727
+ }
41728
+ return obj;
41729
+ },
41730
+ create(base) {
41731
+ return SandboxContainerCreateV2Response.fromPartial(base ?? {});
41732
+ },
41733
+ fromPartial(object) {
41734
+ const message = createBaseSandboxContainerCreateV2Response();
41735
+ message.containerId = object.containerId ?? "";
41736
+ message.containerName = object.containerName ?? "";
41737
+ return message;
41738
+ }
41739
+ };
40368
41740
  function createBaseSandboxCreateConnectTokenRequest() {
40369
41741
  return { sandboxId: "", userMetadata: "", port: void 0 };
40370
41742
  }
@@ -47167,6 +48539,142 @@ var SharedVolumeRemoveFileRequest = {
47167
48539
  return message;
47168
48540
  }
47169
48541
  };
48542
+ function createBaseStatsPercentile() {
48543
+ return { percentileBasisPoints: 0, value: 0 };
48544
+ }
48545
+ var StatsPercentile = {
48546
+ encode(message, writer = new BinaryWriter()) {
48547
+ if (message.percentileBasisPoints !== 0) {
48548
+ writer.uint32(8).uint32(message.percentileBasisPoints);
48549
+ }
48550
+ if (message.value !== 0) {
48551
+ writer.uint32(17).double(message.value);
48552
+ }
48553
+ return writer;
48554
+ },
48555
+ decode(input, length) {
48556
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
48557
+ let end = length === void 0 ? reader.len : reader.pos + length;
48558
+ const message = createBaseStatsPercentile();
48559
+ while (reader.pos < end) {
48560
+ const tag = reader.uint32();
48561
+ switch (tag >>> 3) {
48562
+ case 1: {
48563
+ if (tag !== 8) {
48564
+ break;
48565
+ }
48566
+ message.percentileBasisPoints = reader.uint32();
48567
+ continue;
48568
+ }
48569
+ case 2: {
48570
+ if (tag !== 17) {
48571
+ break;
48572
+ }
48573
+ message.value = reader.double();
48574
+ continue;
48575
+ }
48576
+ }
48577
+ if ((tag & 7) === 4 || tag === 0) {
48578
+ break;
48579
+ }
48580
+ reader.skip(tag & 7);
48581
+ }
48582
+ return message;
48583
+ },
48584
+ fromJSON(object) {
48585
+ return {
48586
+ percentileBasisPoints: isSet5(object.percentileBasisPoints) ? globalThis.Number(object.percentileBasisPoints) : 0,
48587
+ value: isSet5(object.value) ? globalThis.Number(object.value) : 0
48588
+ };
48589
+ },
48590
+ toJSON(message) {
48591
+ const obj = {};
48592
+ if (message.percentileBasisPoints !== 0) {
48593
+ obj.percentileBasisPoints = Math.round(message.percentileBasisPoints);
48594
+ }
48595
+ if (message.value !== 0) {
48596
+ obj.value = message.value;
48597
+ }
48598
+ return obj;
48599
+ },
48600
+ create(base) {
48601
+ return StatsPercentile.fromPartial(base ?? {});
48602
+ },
48603
+ fromPartial(object) {
48604
+ const message = createBaseStatsPercentile();
48605
+ message.percentileBasisPoints = object.percentileBasisPoints ?? 0;
48606
+ message.value = object.value ?? 0;
48607
+ return message;
48608
+ }
48609
+ };
48610
+ function createBaseStatsPercentileDistribution() {
48611
+ return { unit: "", percentiles: [] };
48612
+ }
48613
+ var StatsPercentileDistribution = {
48614
+ encode(message, writer = new BinaryWriter()) {
48615
+ if (message.unit !== "") {
48616
+ writer.uint32(10).string(message.unit);
48617
+ }
48618
+ for (const v of message.percentiles) {
48619
+ StatsPercentile.encode(v, writer.uint32(18).fork()).join();
48620
+ }
48621
+ return writer;
48622
+ },
48623
+ decode(input, length) {
48624
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
48625
+ let end = length === void 0 ? reader.len : reader.pos + length;
48626
+ const message = createBaseStatsPercentileDistribution();
48627
+ while (reader.pos < end) {
48628
+ const tag = reader.uint32();
48629
+ switch (tag >>> 3) {
48630
+ case 1: {
48631
+ if (tag !== 10) {
48632
+ break;
48633
+ }
48634
+ message.unit = reader.string();
48635
+ continue;
48636
+ }
48637
+ case 2: {
48638
+ if (tag !== 18) {
48639
+ break;
48640
+ }
48641
+ message.percentiles.push(StatsPercentile.decode(reader, reader.uint32()));
48642
+ continue;
48643
+ }
48644
+ }
48645
+ if ((tag & 7) === 4 || tag === 0) {
48646
+ break;
48647
+ }
48648
+ reader.skip(tag & 7);
48649
+ }
48650
+ return message;
48651
+ },
48652
+ fromJSON(object) {
48653
+ return {
48654
+ unit: isSet5(object.unit) ? globalThis.String(object.unit) : "",
48655
+ percentiles: globalThis.Array.isArray(object?.percentiles) ? object.percentiles.map((e) => StatsPercentile.fromJSON(e)) : []
48656
+ };
48657
+ },
48658
+ toJSON(message) {
48659
+ const obj = {};
48660
+ if (message.unit !== "") {
48661
+ obj.unit = message.unit;
48662
+ }
48663
+ if (message.percentiles?.length) {
48664
+ obj.percentiles = message.percentiles.map((e) => StatsPercentile.toJSON(e));
48665
+ }
48666
+ return obj;
48667
+ },
48668
+ create(base) {
48669
+ return StatsPercentileDistribution.fromPartial(base ?? {});
48670
+ },
48671
+ fromPartial(object) {
48672
+ const message = createBaseStatsPercentileDistribution();
48673
+ message.unit = object.unit ?? "";
48674
+ message.percentiles = object.percentiles?.map((e) => StatsPercentile.fromPartial(e)) || [];
48675
+ return message;
48676
+ }
48677
+ };
47170
48678
  function createBaseStringMap() {
47171
48679
  return { contents: {} };
47172
48680
  }
@@ -51068,7 +52576,7 @@ var VolumeGetByIdResponse = {
51068
52576
  }
51069
52577
  };
51070
52578
  function createBaseVolumeGetFile2Request() {
51071
- return { volumeId: "", path: "", start: 0, len: 0 };
52579
+ return { volumeId: "", path: "", start: 0, len: 0, clientPadsBlocks: false };
51072
52580
  }
51073
52581
  var VolumeGetFile2Request = {
51074
52582
  encode(message, writer = new BinaryWriter()) {
@@ -51084,6 +52592,9 @@ var VolumeGetFile2Request = {
51084
52592
  if (message.len !== 0) {
51085
52593
  writer.uint32(32).uint64(message.len);
51086
52594
  }
52595
+ if (message.clientPadsBlocks !== false) {
52596
+ writer.uint32(40).bool(message.clientPadsBlocks);
52597
+ }
51087
52598
  return writer;
51088
52599
  },
51089
52600
  decode(input, length) {
@@ -51121,6 +52632,13 @@ var VolumeGetFile2Request = {
51121
52632
  message.len = longToNumber2(reader.uint64());
51122
52633
  continue;
51123
52634
  }
52635
+ case 5: {
52636
+ if (tag !== 40) {
52637
+ break;
52638
+ }
52639
+ message.clientPadsBlocks = reader.bool();
52640
+ continue;
52641
+ }
51124
52642
  }
51125
52643
  if ((tag & 7) === 4 || tag === 0) {
51126
52644
  break;
@@ -51134,7 +52652,8 @@ var VolumeGetFile2Request = {
51134
52652
  volumeId: isSet5(object.volumeId) ? globalThis.String(object.volumeId) : "",
51135
52653
  path: isSet5(object.path) ? globalThis.String(object.path) : "",
51136
52654
  start: isSet5(object.start) ? globalThis.Number(object.start) : 0,
51137
- len: isSet5(object.len) ? globalThis.Number(object.len) : 0
52655
+ len: isSet5(object.len) ? globalThis.Number(object.len) : 0,
52656
+ clientPadsBlocks: isSet5(object.clientPadsBlocks) ? globalThis.Boolean(object.clientPadsBlocks) : false
51138
52657
  };
51139
52658
  },
51140
52659
  toJSON(message) {
@@ -51151,6 +52670,9 @@ var VolumeGetFile2Request = {
51151
52670
  if (message.len !== 0) {
51152
52671
  obj.len = Math.round(message.len);
51153
52672
  }
52673
+ if (message.clientPadsBlocks !== false) {
52674
+ obj.clientPadsBlocks = message.clientPadsBlocks;
52675
+ }
51154
52676
  return obj;
51155
52677
  },
51156
52678
  create(base) {
@@ -51162,6 +52684,7 @@ var VolumeGetFile2Request = {
51162
52684
  message.path = object.path ?? "";
51163
52685
  message.start = object.start ?? 0;
51164
52686
  message.len = object.len ?? 0;
52687
+ message.clientPadsBlocks = object.clientPadsBlocks ?? false;
51165
52688
  return message;
51166
52689
  }
51167
52690
  };
@@ -56003,6 +57526,14 @@ var ModalClientDefinition = {
56003
57526
  responseStream: false,
56004
57527
  options: {}
56005
57528
  },
57529
+ appGetInfo: {
57530
+ name: "AppGetInfo",
57531
+ requestType: AppGetInfoRequest,
57532
+ requestStream: false,
57533
+ responseType: AppGetInfoResponse,
57534
+ responseStream: false,
57535
+ options: {}
57536
+ },
56006
57537
  appGetLayout: {
56007
57538
  name: "AppGetLayout",
56008
57539
  requestType: AppGetLayoutRequest,
@@ -56738,6 +58269,14 @@ var ModalClientDefinition = {
56738
58269
  responseStream: false,
56739
58270
  options: {}
56740
58271
  },
58272
+ functionGetById: {
58273
+ name: "FunctionGetById",
58274
+ requestType: FunctionGetByIdRequest,
58275
+ requestStream: false,
58276
+ responseType: FunctionGetByIdResponse,
58277
+ responseStream: false,
58278
+ options: {}
58279
+ },
56741
58280
  functionGetCallGraph: {
56742
58281
  name: "FunctionGetCallGraph",
56743
58282
  requestType: FunctionGetCallGraphRequest,
@@ -56762,6 +58301,14 @@ var ModalClientDefinition = {
56762
58301
  responseStream: false,
56763
58302
  options: {}
56764
58303
  },
58304
+ functionGetFlashAuthToken: {
58305
+ name: "FunctionGetFlashAuthToken",
58306
+ requestType: FunctionGetFlashAuthTokenRequest,
58307
+ requestStream: false,
58308
+ responseType: FunctionGetFlashAuthTokenResponse,
58309
+ responseStream: false,
58310
+ options: {}
58311
+ },
56765
58312
  /** For containers to request next call */
56766
58313
  functionGetInputs: {
56767
58314
  name: "FunctionGetInputs",
@@ -57124,6 +58671,14 @@ var ModalClientDefinition = {
57124
58671
  options: {}
57125
58672
  },
57126
58673
  /** Sandboxes */
58674
+ sandboxContainerCreateV2: {
58675
+ name: "SandboxContainerCreateV2",
58676
+ requestType: SandboxContainerCreateV2Request,
58677
+ requestStream: false,
58678
+ responseType: SandboxContainerCreateV2Response,
58679
+ responseStream: false,
58680
+ options: {}
58681
+ },
57127
58682
  sandboxCreate: {
57128
58683
  name: "SandboxCreate",
57129
58684
  requestType: SandboxCreateRequest,
@@ -58481,7 +60036,7 @@ function checkForRenamedParams(params, renames) {
58481
60036
  }
58482
60037
 
58483
60038
  // src/client.ts
58484
- import { v4 as uuidv42 } from "uuid";
60039
+ import { v4 as uuidv44 } from "uuid";
58485
60040
  import {
58486
60041
  ClientError as ClientError13,
58487
60042
  createChannel as createChannel2,
@@ -59938,6 +61493,33 @@ var Queue = class _Queue {
59938
61493
  import { ClientError as ClientError11, Status as Status11 } from "nice-grpc";
59939
61494
  import { setTimeout as setTimeout3 } from "timers/promises";
59940
61495
 
61496
+ // src/idle_countdown.ts
61497
+ var IdleCountdown = class {
61498
+ #timer;
61499
+ /** Ends the countdown in progress. */
61500
+ stop() {
61501
+ if (this.#timer !== void 0) {
61502
+ globalThis.clearTimeout(this.#timer);
61503
+ this.#timer = void 0;
61504
+ }
61505
+ }
61506
+ /**
61507
+ * Starts the countdown again, calling `release` when it elapses. A timeout of
61508
+ * zero or less leaves it stopped.
61509
+ */
61510
+ arm(timeoutMs, release) {
61511
+ this.stop();
61512
+ if (timeoutMs <= 0) {
61513
+ return;
61514
+ }
61515
+ this.#timer = globalThis.setTimeout(() => {
61516
+ this.#timer = void 0;
61517
+ release();
61518
+ }, timeoutMs);
61519
+ this.#timer.unref?.();
61520
+ }
61521
+ };
61522
+
59941
61523
  // proto/modal_proto/task_command_router.ts
59942
61524
  function sandboxStdioFileDescriptorFromJSON(object) {
59943
61525
  switch (object) {
@@ -63022,6 +64604,111 @@ var TaskSetNetworkAccessResponse = {
63022
64604
  return message;
63023
64605
  }
63024
64606
  };
64607
+ function createBaseTaskSetOutboundPolicyRequest() {
64608
+ return { taskId: "", outboundPolicy: void 0 };
64609
+ }
64610
+ var TaskSetOutboundPolicyRequest = {
64611
+ encode(message, writer = new BinaryWriter()) {
64612
+ if (message.taskId !== "") {
64613
+ writer.uint32(10).string(message.taskId);
64614
+ }
64615
+ if (message.outboundPolicy !== void 0) {
64616
+ OutboundPolicy.encode(message.outboundPolicy, writer.uint32(18).fork()).join();
64617
+ }
64618
+ return writer;
64619
+ },
64620
+ decode(input, length) {
64621
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
64622
+ let end = length === void 0 ? reader.len : reader.pos + length;
64623
+ const message = createBaseTaskSetOutboundPolicyRequest();
64624
+ while (reader.pos < end) {
64625
+ const tag = reader.uint32();
64626
+ switch (tag >>> 3) {
64627
+ case 1: {
64628
+ if (tag !== 10) {
64629
+ break;
64630
+ }
64631
+ message.taskId = reader.string();
64632
+ continue;
64633
+ }
64634
+ case 2: {
64635
+ if (tag !== 18) {
64636
+ break;
64637
+ }
64638
+ message.outboundPolicy = OutboundPolicy.decode(reader, reader.uint32());
64639
+ continue;
64640
+ }
64641
+ }
64642
+ if ((tag & 7) === 4 || tag === 0) {
64643
+ break;
64644
+ }
64645
+ reader.skip(tag & 7);
64646
+ }
64647
+ return message;
64648
+ },
64649
+ fromJSON(object) {
64650
+ return {
64651
+ taskId: isSet6(object.taskId) ? globalThis.String(object.taskId) : "",
64652
+ outboundPolicy: isSet6(object.outboundPolicy) ? OutboundPolicy.fromJSON(object.outboundPolicy) : void 0
64653
+ };
64654
+ },
64655
+ toJSON(message) {
64656
+ const obj = {};
64657
+ if (message.taskId !== "") {
64658
+ obj.taskId = message.taskId;
64659
+ }
64660
+ if (message.outboundPolicy !== void 0) {
64661
+ obj.outboundPolicy = OutboundPolicy.toJSON(message.outboundPolicy);
64662
+ }
64663
+ return obj;
64664
+ },
64665
+ create(base) {
64666
+ return TaskSetOutboundPolicyRequest.fromPartial(base ?? {});
64667
+ },
64668
+ fromPartial(object) {
64669
+ const message = createBaseTaskSetOutboundPolicyRequest();
64670
+ message.taskId = object.taskId ?? "";
64671
+ message.outboundPolicy = object.outboundPolicy !== void 0 && object.outboundPolicy !== null ? OutboundPolicy.fromPartial(object.outboundPolicy) : void 0;
64672
+ return message;
64673
+ }
64674
+ };
64675
+ function createBaseTaskSetOutboundPolicyResponse() {
64676
+ return {};
64677
+ }
64678
+ var TaskSetOutboundPolicyResponse = {
64679
+ encode(_, writer = new BinaryWriter()) {
64680
+ return writer;
64681
+ },
64682
+ decode(input, length) {
64683
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
64684
+ let end = length === void 0 ? reader.len : reader.pos + length;
64685
+ const message = createBaseTaskSetOutboundPolicyResponse();
64686
+ while (reader.pos < end) {
64687
+ const tag = reader.uint32();
64688
+ switch (tag >>> 3) {
64689
+ }
64690
+ if ((tag & 7) === 4 || tag === 0) {
64691
+ break;
64692
+ }
64693
+ reader.skip(tag & 7);
64694
+ }
64695
+ return message;
64696
+ },
64697
+ fromJSON(_) {
64698
+ return {};
64699
+ },
64700
+ toJSON(_) {
64701
+ const obj = {};
64702
+ return obj;
64703
+ },
64704
+ create(base) {
64705
+ return TaskSetOutboundPolicyResponse.fromPartial(base ?? {});
64706
+ },
64707
+ fromPartial(_) {
64708
+ const message = createBaseTaskSetOutboundPolicyResponse();
64709
+ return message;
64710
+ }
64711
+ };
63025
64712
  function createBaseTaskSnapshotDirectoryRequest() {
63026
64713
  return {
63027
64714
  taskId: "",
@@ -63751,6 +65438,15 @@ var TaskCommandRouterDefinition = {
63751
65438
  responseStream: false,
63752
65439
  options: {}
63753
65440
  },
65441
+ /** Replace the task's outbound policy. */
65442
+ taskSetOutboundPolicy: {
65443
+ name: "TaskSetOutboundPolicy",
65444
+ requestType: TaskSetOutboundPolicyRequest,
65445
+ requestStream: false,
65446
+ responseType: TaskSetOutboundPolicyResponse,
65447
+ responseStream: false,
65448
+ options: {}
65449
+ },
63754
65450
  /** Snapshot a directory with a mounted image, including any local changes, into a new image. */
63755
65451
  taskSnapshotDirectory: {
63756
65452
  name: "TaskSnapshotDirectory",
@@ -63851,6 +65547,8 @@ import { readFileSync } from "node:fs";
63851
65547
  import { homedir } from "node:os";
63852
65548
  import path from "node:path";
63853
65549
  import { parse as parseToml } from "smol-toml";
65550
+ var DEFAULT_SANDBOX_CHANNEL_IDLE_TIMEOUT_MS = 3e4;
65551
+ var MAX_TIMEOUT_MS = 2147483647;
63854
65552
  function isLocalhost(profile) {
63855
65553
  const url = new URL(profile.serverUrl);
63856
65554
  const hostname = url.hostname;
@@ -63878,6 +65576,12 @@ function readConfigFile() {
63878
65576
  }
63879
65577
  }
63880
65578
  var config = readConfigFile();
65579
+ function resolveOAuthClientAuth(secretEnv, jwtKeyEnv, secretFile, jwtKeyFile) {
65580
+ if (secretEnv || jwtKeyEnv) {
65581
+ return { oauthClientSecret: secretEnv, oauthJwtKey: jwtKeyEnv };
65582
+ }
65583
+ return { oauthClientSecret: secretFile, oauthJwtKey: jwtKeyFile };
65584
+ }
63881
65585
  function getProfile(profileName) {
63882
65586
  if (!profileName) {
63883
65587
  for (const [name, profileData2] of Object.entries(config)) {
@@ -63892,8 +65596,16 @@ function getProfile(profileName) {
63892
65596
  serverUrl: process.env["MODAL_SERVER_URL"] || profileData.server_url || "https://api.modal.com:443",
63893
65597
  tokenId: process.env["MODAL_TOKEN_ID"] || profileData.token_id,
63894
65598
  tokenSecret: process.env["MODAL_TOKEN_SECRET"] || profileData.token_secret,
65599
+ oauthRefreshToken: process.env["MODAL_OAUTH_REFRESH_TOKEN"] || profileData.oauth_refresh_token,
65600
+ oauthClientId: process.env["MODAL_OAUTH_CLIENT_ID"] || profileData.oauth_client_id,
65601
+ ...resolveOAuthClientAuth(
65602
+ process.env["MODAL_OAUTH_CLIENT_SECRET"],
65603
+ process.env["MODAL_OAUTH_JWT_KEY"],
65604
+ profileData.oauth_client_secret,
65605
+ profileData.oauth_jwt_key
65606
+ ),
63895
65607
  environment: process.env["MODAL_ENVIRONMENT"] || profileData.environment,
63896
- imageBuilderVersion: process.env["MODAL_IMAGE_BUILDER_VERSION"] || profileData.imageBuilderVersion,
65608
+ imageBuilderVersion: process.env["MODAL_IMAGE_BUILDER_VERSION"] || profileData.image_builder_version,
63897
65609
  logLevel: process.env["MODAL_LOGLEVEL"] || profileData.loglevel,
63898
65610
  maxThrottleWaitSecs: (() => {
63899
65611
  const val = process.env["MODAL_MAX_THROTTLE_WAIT"];
@@ -63906,10 +65618,28 @@ function getProfile(profileName) {
63906
65618
  return void 0;
63907
65619
  }
63908
65620
  return parsed;
63909
- })()
65621
+ })(),
65622
+ sandboxChannelIdleTimeoutMs: (() => {
65623
+ const val = process.env["MODAL_SANDBOX_CHANNEL_IDLE_TIMEOUT"];
65624
+ if (!val) return DEFAULT_SANDBOX_CHANNEL_IDLE_TIMEOUT_MS;
65625
+ const parsed = Number(val);
65626
+ if (!Number.isFinite(parsed) || parsed < 0 || parsed * 1e3 > MAX_TIMEOUT_MS) {
65627
+ warn(
65628
+ `MODAL_SANDBOX_CHANNEL_IDLE_TIMEOUT="${val}" is not a valid non-negative number of seconds; ignoring.`
65629
+ );
65630
+ return DEFAULT_SANDBOX_CHANNEL_IDLE_TIMEOUT_MS;
65631
+ }
65632
+ const ms = Math.round(parsed * 1e3);
65633
+ return parsed > 0 && ms === 0 ? 1 : ms;
65634
+ })(),
65635
+ sandboxV2: process.env["MODAL_SANDBOX_V2"] ? parseBooleanFlag(process.env["MODAL_SANDBOX_V2"]) : parseBooleanFlag(profileData.sandbox_v2)
63910
65636
  };
63911
65637
  return profile;
63912
65638
  }
65639
+ function parseBooleanFlag(value) {
65640
+ if (!value) return false;
65641
+ return !["0", "false"].includes(String(value).toLowerCase());
65642
+ }
63913
65643
 
63914
65644
  // src/task_command_router_client.ts
63915
65645
  function parseJwtExpiration(jwtToken, logger2) {
@@ -63980,7 +65710,37 @@ async function callWithRetriesOnTransientErrors(func, baseDelayMs = 10, delayFac
63980
65710
  }
63981
65711
  var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
63982
65712
  stub;
65713
+ /**
65714
+ * The connection, absent while it is released. It is dialled again by the
65715
+ * next operation, so nothing may hold `stub` across one.
65716
+ */
63983
65717
  channel;
65718
+ dial;
65719
+ factory;
65720
+ /**
65721
+ * How many operations are using the connection. A count rather than a flag
65722
+ * because operations overlap: only the last one out starts the idle clock.
65723
+ */
65724
+ inFlight = 0;
65725
+ idle = new IdleCountdown();
65726
+ /**
65727
+ * Bumped every time a connection is dialled. A stream opened on an earlier
65728
+ * one is stale: the connection under it has since been given up.
65729
+ */
65730
+ generation = 0;
65731
+ /**
65732
+ * Streams open right now, tracked so they can be ended on release.
65733
+ *
65734
+ * grpc-js does not cancel a call in flight when its channel is closed, and a
65735
+ * subchannel with a live call on it is never collected - so closing alone
65736
+ * leaves the socket up. Aborting the calls first is what actually frees it.
65737
+ */
65738
+ liveStreams = /* @__PURE__ */ new Set();
65739
+ /**
65740
+ * How long the client may go unused before its connection is given up. Zero
65741
+ * keeps it up until the client is closed. Overridable in tests.
65742
+ */
65743
+ idleTimeoutMs = DEFAULT_SANDBOX_CHANNEL_IDLE_TIMEOUT_MS;
63984
65744
  serverClient;
63985
65745
  taskId;
63986
65746
  sandboxId;
@@ -63991,6 +65751,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
63991
65751
  jwtRefreshLock = Promise.resolve();
63992
65752
  logger;
63993
65753
  closed = false;
65754
+ draining = false;
63994
65755
  /**
63995
65756
  * `access` is the router access returned by SandboxCreateV2, which lets a
63996
65757
  * freshly created sandbox connect without a round-trip. Pass undefined to look
@@ -64042,23 +65803,17 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64042
65803
  "grpc.keepalive_timeout_ms": 1e4,
64043
65804
  "grpc.keepalive_permit_without_calls": 1
64044
65805
  };
64045
- let channel;
64046
- if (isLocalhost(profile)) {
65806
+ const insecure = isLocalhost(profile);
65807
+ if (insecure) {
64047
65808
  logger2.warn(
64048
65809
  "Using insecure TLS (skip certificate verification) for task command router"
64049
65810
  );
64050
- channel = createChannel(
64051
- serverUrl,
64052
- ChannelCredentials.createInsecure(),
64053
- channelConfig
64054
- );
64055
- } else {
64056
- channel = createChannel(
64057
- serverUrl,
64058
- ChannelCredentials.createSsl(),
64059
- channelConfig
64060
- );
64061
65811
  }
65812
+ const dial = () => createChannel(
65813
+ serverUrl,
65814
+ insecure ? ChannelCredentials.createInsecure() : ChannelCredentials.createSsl(),
65815
+ channelConfig
65816
+ );
64062
65817
  const client = new _TaskCommandRouterClientImpl(
64063
65818
  serverClient,
64064
65819
  taskId,
@@ -64066,8 +65821,9 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64066
65821
  isV2,
64067
65822
  resp.url,
64068
65823
  resp.jwt,
64069
- channel,
64070
- logger2
65824
+ dial,
65825
+ logger2,
65826
+ profile.sandboxChannelIdleTimeoutMs
64071
65827
  );
64072
65828
  logger2.debug(
64073
65829
  "Successfully initialized command router client",
@@ -64076,7 +65832,14 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64076
65832
  );
64077
65833
  return client;
64078
65834
  }
64079
- constructor(serverClient, taskId, sandboxId, isV2, serverUrl, jwt, channel, logger2) {
65835
+ /**
65836
+ * Builds a client around an already-resolved connection. Public so a test can
65837
+ * construct one without the control-plane round trip `tryInit` makes; the
65838
+ * class is not exported from the package, so this is not API surface.
65839
+ */
65840
+ constructor(serverClient, taskId, sandboxId, isV2, serverUrl, jwt, dial, logger2, idleTimeoutMs) {
65841
+ this.dial = dial;
65842
+ this.idleTimeoutMs = idleTimeoutMs;
64080
65843
  this.serverClient = serverClient;
64081
65844
  this.taskId = taskId;
64082
65845
  this.sandboxId = sandboxId;
@@ -64085,25 +65848,110 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64085
65848
  this.jwt = jwt;
64086
65849
  this.jwtExp = parseJwtExpiration(jwt, logger2);
64087
65850
  this.logger = logger2;
64088
- this.channel = channel;
65851
+ this.channel = dial();
64089
65852
  const self = this;
64090
65853
  const factory = createClientFactory().use(timeoutMiddleware).use(async function* authMiddleware(call, options) {
64091
65854
  options.metadata ??= new Metadata();
64092
65855
  options.metadata.set("authorization", `Bearer ${self.jwt}`);
64093
65856
  return yield* call.next(call.request, options);
64094
65857
  });
64095
- this.stub = factory.create(TaskCommandRouterDefinition, channel);
65858
+ this.factory = factory;
65859
+ this.stub = factory.create(TaskCommandRouterDefinition, this.channel);
65860
+ this.armIdleTimer();
65861
+ }
65862
+ /**
65863
+ * Says the client is about to be used: holds off the idle timer, and dials
65864
+ * again if the connection was already given up. Returns the generation being
65865
+ * used; pair every call with endOp.
65866
+ */
65867
+ beginOp() {
65868
+ if (this.closed || this.draining) {
65869
+ throw new ClientClosedError();
65870
+ }
65871
+ this.idle.stop();
65872
+ if (this.channel === void 0) {
65873
+ this.channel = this.dial();
65874
+ this.stub = this.factory.create(
65875
+ TaskCommandRouterDefinition,
65876
+ this.channel
65877
+ );
65878
+ this.generation++;
65879
+ this.logger.debug(
65880
+ "Reconnected to the command router after an idle release",
65881
+ "task_id",
65882
+ this.taskId
65883
+ );
65884
+ }
65885
+ this.inFlight = (this.inFlight ?? 0) + 1;
65886
+ return this.generation;
65887
+ }
65888
+ /** Says the caller is done. The last one out starts the clock. */
65889
+ endOp() {
65890
+ this.inFlight--;
65891
+ if (this.inFlight > 0) {
65892
+ return;
65893
+ }
65894
+ if (this.draining) {
65895
+ this.close();
65896
+ } else {
65897
+ this.armIdleTimer();
65898
+ }
65899
+ }
65900
+ /**
65901
+ * Starts the countdown to giving the connection back. Call it with nothing
65902
+ * in flight.
65903
+ */
65904
+ armIdleTimer() {
65905
+ if (this.closed) {
65906
+ return;
65907
+ }
65908
+ this.idle.arm(this.idleTimeoutMs, () => {
65909
+ if (this.inFlight > 0 || this.channel === void 0) {
65910
+ return;
65911
+ }
65912
+ this.logger.debug(
65913
+ "Releasing the command router connection to an idle Sandbox",
65914
+ "task_id",
65915
+ this.taskId
65916
+ );
65917
+ for (const stream of this.liveStreams) {
65918
+ stream.abort();
65919
+ }
65920
+ this.liveStreams.clear();
65921
+ this.channel.close();
65922
+ this.channel = void 0;
65923
+ });
65924
+ }
65925
+ /** Refuse new operations and release resources after current operations finish. */
65926
+ closeWhenIdle() {
65927
+ this.draining = true;
65928
+ this.idle.stop();
65929
+ if (this.inFlight === 0) this.close();
64096
65930
  }
64097
65931
  close() {
64098
65932
  if (this.closed) {
64099
65933
  return;
64100
65934
  }
64101
65935
  this.closed = true;
64102
- this.channel.close();
65936
+ this.idle.stop();
65937
+ for (const stream of this.liveStreams) {
65938
+ stream.abort();
65939
+ }
65940
+ this.liveStreams.clear();
65941
+ this.channel?.close();
65942
+ this.channel = void 0;
65943
+ }
65944
+ async callWithRetries(...args) {
65945
+ this.beginOp();
65946
+ try {
65947
+ return await callWithRetriesOnTransientErrors(...args);
65948
+ } finally {
65949
+ this.endOp();
65950
+ }
64103
65951
  }
64104
65952
  /** Run a unary RPC against the command router with the default retry policy. */
64105
65953
  async callUnary(fn) {
64106
- return await callWithRetriesOnTransientErrors(
65954
+ return await this.callWithRetries(
64107
65955
  () => this.callWithAuthRetry(fn),
64108
65956
  10,
64109
65957
  // baseDelayMs
@@ -64134,7 +65982,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64134
65982
  async containerWait(request) {
64135
65983
  return await this.callUnary(() => this.stub.taskContainerWait(request));
64136
65984
  }
64137
- async *execStdioRead(taskId, execId, fileDescriptor, deadline = null) {
65985
+ async *execStdioRead(taskId, execId, fileDescriptor, deadline = null, signal) {
64138
65986
  let srFd;
64139
65987
  if (fileDescriptor === 1 /* FILE_DESCRIPTOR_STDOUT */) {
64140
65988
  srFd = 0 /* TASK_EXEC_STDIO_FILE_DESCRIPTOR_STDOUT */;
@@ -64145,7 +65993,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64145
65993
  } else {
64146
65994
  throw new Error(`Invalid file descriptor: ${fileDescriptor}`);
64147
65995
  }
64148
- yield* this.streamStdio(taskId, execId, srFd, deadline);
65996
+ yield* this.streamExecStdio(taskId, execId, srFd, deadline, signal);
64149
65997
  }
64150
65998
  async execStdinWrite(taskId, execId, offset, data, eof) {
64151
65999
  const request = TaskExecStdinWriteRequest.create({
@@ -64177,76 +66025,100 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64177
66025
  * stream from that point. Returns the total bytes streamed.
64178
66026
  */
64179
66027
  async execStdinWriteStream(taskId, execId, source, chunkSize = STREAMING_STDIN_CHUNK_SIZE, maxResumeAttempts = 9) {
64180
- let offset = 0;
64181
- let attempt = 0;
64182
- while (true) {
64183
- let bytesRead = offset;
64184
- let sourceExhausted = false;
64185
- let sourceError;
64186
- const requests = async function* () {
64187
- yield TaskExecStdinWriteStreamRequest.create({
64188
- start: { taskId, execId, offset }
64189
- });
64190
- const chunks = async function* () {
64191
- try {
64192
- yield* source.readFrom(offset);
64193
- } catch (err) {
64194
- sourceError = err;
66028
+ this.beginOp();
66029
+ try {
66030
+ let offset = 0;
66031
+ let attempt = 0;
66032
+ while (true) {
66033
+ let bytesRead = offset;
66034
+ let sourceExhausted = false;
66035
+ let sourceError;
66036
+ const requests = async function* () {
66037
+ yield TaskExecStdinWriteStreamRequest.create({
66038
+ start: { taskId, execId, offset }
66039
+ });
66040
+ const chunks = async function* () {
66041
+ try {
66042
+ yield* source.readFrom(offset);
66043
+ } catch (err) {
66044
+ sourceError = err;
66045
+ throw err;
66046
+ }
66047
+ }();
66048
+ for await (const chunk of chunks) {
66049
+ for (let i = 0; i < chunk.length; i += chunkSize) {
66050
+ const data = chunk.subarray(i, i + chunkSize);
66051
+ if (data.length === 0) continue;
66052
+ bytesRead += data.length;
66053
+ yield TaskExecStdinWriteStreamRequest.create({ data });
66054
+ }
66055
+ }
66056
+ sourceExhausted = true;
66057
+ yield TaskExecStdinWriteStreamRequest.create({ end: {} });
66058
+ };
66059
+ const abort = new AbortController();
66060
+ this.liveStreams.add(abort);
66061
+ try {
66062
+ await this.stub.taskExecStdinWriteStream(requests(), {
66063
+ signal: abort.signal
66064
+ });
66065
+ return bytesRead;
66066
+ } catch (err) {
66067
+ if (sourceError !== void 0) {
66068
+ throw sourceError;
66069
+ }
66070
+ if (err instanceof ClientError6 && err.code === Status6.CANCELLED && this.closed) {
66071
+ throw new ClientClosedError();
66072
+ }
66073
+ if (!isResumableStreamingStdinError(err)) {
64195
66074
  throw err;
64196
66075
  }
64197
- }();
64198
- for await (const chunk of chunks) {
64199
- for (let i = 0; i < chunk.length; i += chunkSize) {
64200
- const data = chunk.subarray(i, i + chunkSize);
64201
- if (data.length === 0) continue;
64202
- bytesRead += data.length;
64203
- yield TaskExecStdinWriteStreamRequest.create({ data });
66076
+ attempt++;
66077
+ if (attempt > maxResumeAttempts) {
66078
+ throw err;
64204
66079
  }
64205
- }
64206
- sourceExhausted = true;
64207
- yield TaskExecStdinWriteStreamRequest.create({ end: {} });
64208
- };
64209
- try {
64210
- await this.stub.taskExecStdinWriteStream(requests());
64211
- return bytesRead;
64212
- } catch (err) {
64213
- if (sourceError !== void 0) {
64214
- throw sourceError;
64215
- }
64216
- if (err instanceof ClientError6 && err.code === Status6.CANCELLED && this.closed) {
64217
- throw new ClientClosedError();
64218
- }
64219
- if (!isResumableStreamingStdinError(err)) {
64220
- throw err;
64221
- }
64222
- attempt++;
64223
- if (attempt > maxResumeAttempts) {
64224
- throw err;
64225
- }
64226
- if (err instanceof ClientError6 && err.code === Status6.UNAUTHENTICATED) {
64227
- await this.refreshJwt();
64228
- }
64229
- const status = await this.execStdinStatus(taskId, execId);
64230
- if (status.closed) {
64231
- if (sourceExhausted && status.numBytesWritten === bytesRead) {
64232
- this.logger.debug(
64233
- "execStdinWriteStream completed but response was lost",
64234
- "error",
64235
- err
64236
- );
64237
- return bytesRead;
66080
+ if (err instanceof ClientError6 && err.code === Status6.UNAUTHENTICATED) {
66081
+ await this.refreshJwt();
66082
+ }
66083
+ const status = await callWithRetriesOnTransientErrors(
66084
+ () => this.callWithAuthRetry(
66085
+ () => this.stub.taskExecStdinStatus(
66086
+ TaskExecStdinStatusRequest.create({ taskId, execId })
66087
+ )
66088
+ ),
66089
+ 10,
66090
+ 2,
66091
+ 10,
66092
+ null,
66093
+ () => this.closed
66094
+ );
66095
+ if (status.closed) {
66096
+ if (sourceExhausted && status.numBytesWritten === bytesRead) {
66097
+ this.logger.debug(
66098
+ "execStdinWriteStream completed but response was lost",
66099
+ "error",
66100
+ err
66101
+ );
66102
+ return bytesRead;
66103
+ }
66104
+ throw err;
66105
+ }
66106
+ offset = status.numBytesWritten;
66107
+ this.logger.debug(
66108
+ "execStdinWriteStream resuming after error",
66109
+ "offset",
66110
+ offset,
66111
+ "error",
66112
+ err
66113
+ );
66114
+ } finally {
66115
+ if (this.liveStreams.delete(abort)) {
66116
+ abort.abort();
64238
66117
  }
64239
- throw err;
64240
66118
  }
64241
- offset = status.numBytesWritten;
64242
- this.logger.debug(
64243
- "execStdinWriteStream resuming after error",
64244
- "offset",
64245
- offset,
64246
- "error",
64247
- err
64248
- );
64249
66119
  }
66120
+ } finally {
66121
+ this.endOp();
64250
66122
  }
64251
66123
  }
64252
66124
  async execPoll(taskId, execId, deadline = null) {
@@ -64255,7 +66127,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64255
66127
  throw new Error(`Deadline exceeded while polling for exec ${execId}`);
64256
66128
  }
64257
66129
  try {
64258
- return await callWithRetriesOnTransientErrors(
66130
+ return await this.callWithRetries(
64259
66131
  () => this.callWithAuthRetry(() => this.stub.taskExecPoll(request)),
64260
66132
  10,
64261
66133
  // baseDelayMs
@@ -64280,7 +66152,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64280
66152
  throw new Error(`Deadline exceeded while waiting for exec ${execId}`);
64281
66153
  }
64282
66154
  try {
64283
- return await callWithRetriesOnTransientErrors(
66155
+ return await this.callWithRetries(
64284
66156
  () => this.callWithAuthRetry(
64285
66157
  () => this.stub.taskExecWait(request, {
64286
66158
  timeoutMs: 6e4
@@ -64309,7 +66181,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64309
66181
  async snapshotDirectory(request, options) {
64310
66182
  const overallDeadlineMs = options?.timeoutMs !== void 0 ? Date.now() + options.timeoutMs : null;
64311
66183
  try {
64312
- return await callWithRetriesOnTransientErrors(
66184
+ return await this.callWithRetries(
64313
66185
  () => this.callWithAuthRetry(() => {
64314
66186
  const remainingMs = overallDeadlineMs !== null ? Math.max(1, overallDeadlineMs - Date.now()) : options?.timeoutMs;
64315
66187
  return this.stub.taskSnapshotDirectory(request, {
@@ -64334,7 +66206,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64334
66206
  async snapshotFilesystem(request, options) {
64335
66207
  const overallDeadlineMs = options?.timeoutMs !== void 0 ? Date.now() + options.timeoutMs : null;
64336
66208
  try {
64337
- return await callWithRetriesOnTransientErrors(
66209
+ return await this.callWithRetries(
64338
66210
  () => this.callWithAuthRetry(() => {
64339
66211
  const remainingMs = overallDeadlineMs !== null ? Math.max(1, overallDeadlineMs - Date.now()) : options?.timeoutMs;
64340
66212
  return this.stub.taskSnapshotFilesystem(request, {
@@ -64359,7 +66231,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64359
66231
  async snapshotMemory(request, options) {
64360
66232
  const overallDeadlineMs = options?.timeoutMs !== void 0 ? Date.now() + options.timeoutMs : null;
64361
66233
  try {
64362
- return await callWithRetriesOnTransientErrors(
66234
+ return await this.callWithRetries(
64363
66235
  () => this.callWithAuthRetry(() => {
64364
66236
  const remainingMs = overallDeadlineMs !== null ? Math.max(1, overallDeadlineMs - Date.now()) : options?.timeoutMs;
64365
66237
  return this.stub.taskSnapshotMemory(request, {
@@ -64396,7 +66268,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64396
66268
  async reloadVolumes(request, options) {
64397
66269
  const overallDeadlineMs = options?.timeoutMs !== void 0 ? Date.now() + options.timeoutMs : null;
64398
66270
  try {
64399
- await callWithRetriesOnTransientErrors(
66271
+ await this.callWithRetries(
64400
66272
  () => this.callWithAuthRetry(() => {
64401
66273
  const remainingMs = overallDeadlineMs !== null ? Math.max(1, overallDeadlineMs - Date.now()) : options?.timeoutMs;
64402
66274
  return this.stub.taskReloadVolumes(request, {
@@ -64418,10 +66290,32 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64418
66290
  throw err;
64419
66291
  }
64420
66292
  }
66293
+ async *sandboxStdioReadV2(taskId, fileDescriptor, signal) {
66294
+ let srFd;
66295
+ if (fileDescriptor === 1 /* FILE_DESCRIPTOR_STDOUT */) {
66296
+ srFd = 0 /* SANDBOX_STDIO_FILE_DESCRIPTOR_STDOUT */;
66297
+ } else if (fileDescriptor === 2 /* FILE_DESCRIPTOR_STDERR */) {
66298
+ srFd = 1 /* SANDBOX_STDIO_FILE_DESCRIPTOR_STDERR */;
66299
+ } else if (fileDescriptor === 3 /* FILE_DESCRIPTOR_INFO */ || fileDescriptor === 0 /* FILE_DESCRIPTOR_UNSPECIFIED */) {
66300
+ throw new Error(`Unsupported file descriptor: ${fileDescriptor}`);
66301
+ } else {
66302
+ throw new Error(`Invalid file descriptor: ${fileDescriptor}`);
66303
+ }
66304
+ yield* this.streamSandboxStdio(taskId, srFd, signal);
66305
+ }
66306
+ async sandboxStdinWriteV2(taskId, offset, data, eof) {
66307
+ const request = SandboxStdinWriteV2Request.create({
66308
+ taskId,
66309
+ offset,
66310
+ data,
66311
+ eof
66312
+ });
66313
+ return await this.callUnary(() => this.stub.sandboxStdinWriteV2(request));
66314
+ }
64421
66315
  async sandboxWaitUntilReady(taskId, timeoutMs) {
64422
66316
  const deadlineMs = Date.now() + timeoutMs;
64423
66317
  try {
64424
- return await callWithRetriesOnTransientErrors(
66318
+ return await this.callWithRetries(
64425
66319
  () => this.callWithAuthRetry(() => {
64426
66320
  const remainingMs = Math.max(1, deadlineMs - Date.now());
64427
66321
  const request = SandboxWaitUntilReadyTcrRequest.create({
@@ -64480,6 +66374,7 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64480
66374
  throw error;
64481
66375
  }
64482
66376
  }
66377
+ /** The caller holds an operation lease across authentication and all retries. */
64483
66378
  async callWithAuthRetry(func) {
64484
66379
  try {
64485
66380
  return await func();
@@ -64491,68 +66386,133 @@ var TaskCommandRouterClientImpl = class _TaskCommandRouterClientImpl {
64491
66386
  throw err;
64492
66387
  }
64493
66388
  }
64494
- async *streamStdio(taskId, execId, fileDescriptor, deadline) {
64495
- let offset = 0;
64496
- let delayMs = 10;
66389
+ /**
66390
+ * Yields the next chunk of stdio, opening or reopening the stream as it needs
66391
+ * to, and determining whether or not to retry a failed open or read. It waits
66392
+ * out the backoff itself.
66393
+ */
66394
+ async *streamStdioWithRetries(spec) {
66395
+ const baseDelayMs = 10;
64497
66396
  const delayFactor = 2;
64498
- let numRetriesRemaining = 10;
66397
+ const maxRetries = 10;
66398
+ let offset = 0;
66399
+ let delayMs = baseDelayMs;
66400
+ let numRetriesRemaining = maxRetries;
64499
66401
  let didAuthRetry = false;
64500
- while (true) {
64501
- try {
64502
- const timeoutMs = deadline !== null ? Math.max(0, deadline - Date.now()) : void 0;
64503
- const request = TaskExecStdioReadRequest.create({
64504
- taskId,
64505
- execId,
64506
- offset,
64507
- fileDescriptor
64508
- });
64509
- const stream = this.stub.taskExecStdioRead(request, {
64510
- timeoutMs
64511
- });
66402
+ let generation = this.beginOp();
66403
+ let leased = true;
66404
+ try {
66405
+ attempts: while (true) {
66406
+ spec.signal?.throwIfAborted();
66407
+ const abort = new AbortController();
66408
+ const abortWithCaller = () => abort.abort();
66409
+ spec.signal?.addEventListener("abort", abortWithCaller, { once: true });
64512
66410
  try {
64513
- for await (const item of stream) {
64514
- if (didAuthRetry) {
64515
- didAuthRetry = false;
66411
+ const streamGeneration = generation;
66412
+ this.liveStreams.add(abort);
66413
+ const stream = spec.open(offset, abort.signal);
66414
+ try {
66415
+ const items = stream[Symbol.asyncIterator]();
66416
+ let firstOfAttempt = true;
66417
+ while (true) {
66418
+ if (generation !== streamGeneration) {
66419
+ continue attempts;
66420
+ }
66421
+ const next = await items.next();
66422
+ if (next.done) {
66423
+ return;
66424
+ }
66425
+ const item = next.value;
66426
+ if (didAuthRetry) {
66427
+ didAuthRetry = false;
66428
+ }
66429
+ delayMs = baseDelayMs;
66430
+ numRetriesRemaining = maxRetries;
66431
+ offset = spec.nextOffset(item, offset, firstOfAttempt);
66432
+ firstOfAttempt = false;
66433
+ this.endOp();
66434
+ leased = false;
66435
+ yield item;
66436
+ generation = this.beginOp();
66437
+ leased = true;
64516
66438
  }
64517
- delayMs = 10;
64518
- offset += item.data.length;
64519
- yield item;
66439
+ } catch (err) {
66440
+ if (err instanceof ClientError6 && err.code === Status6.UNAUTHENTICATED && !didAuthRetry) {
66441
+ await this.refreshJwt();
66442
+ didAuthRetry = true;
66443
+ continue;
66444
+ }
66445
+ throw err;
64520
66446
  }
64521
- return;
64522
66447
  } catch (err) {
64523
- if (err instanceof ClientError6 && err.code === Status6.UNAUTHENTICATED && !didAuthRetry) {
64524
- await this.refreshJwt();
64525
- didAuthRetry = true;
64526
- continue;
66448
+ if (spec.signal?.aborted) {
66449
+ throw err;
64527
66450
  }
64528
- throw err;
64529
- }
64530
- } catch (err) {
64531
- if (err instanceof ClientError6 && err.code === Status6.CANCELLED && this.closed) {
64532
- throw new ClientClosedError();
64533
- }
64534
- if (err instanceof ClientError6 && RETRYABLE_GRPC_STATUS_CODES.has(err.code) && numRetriesRemaining > 0) {
64535
- if (deadline && deadline - Date.now() <= delayMs) {
64536
- throw new Error(
64537
- `Deadline exceeded while streaming stdio for exec ${execId}`
66451
+ if (err instanceof ClientError6 && err.code === Status6.CANCELLED && this.closed) {
66452
+ throw new ClientClosedError();
66453
+ }
66454
+ if (err instanceof ClientError6 && RETRYABLE_GRPC_STATUS_CODES.has(err.code) && numRetriesRemaining > 0) {
66455
+ if (spec.deadline && spec.deadline - Date.now() <= delayMs) {
66456
+ throw new Error(
66457
+ `Deadline exceeded while streaming stdio for ${spec.label}`
66458
+ );
66459
+ }
66460
+ this.logger.debug(
66461
+ "Retrying stdio read with delay",
66462
+ "delay_ms",
66463
+ delayMs,
66464
+ "error",
66465
+ err
64538
66466
  );
66467
+ await setTimeout2(delayMs, void 0, { signal: spec.signal });
66468
+ delayMs *= delayFactor;
66469
+ numRetriesRemaining--;
66470
+ } else {
66471
+ throw err;
66472
+ }
66473
+ } finally {
66474
+ spec.signal?.removeEventListener("abort", abortWithCaller);
66475
+ if (this.liveStreams.delete(abort)) {
66476
+ abort.abort();
64539
66477
  }
64540
- this.logger.debug(
64541
- "Retrying stdio read with delay",
64542
- "delay_ms",
64543
- delayMs,
64544
- "error",
64545
- err
64546
- );
64547
- await setTimeout2(delayMs);
64548
- delayMs *= delayFactor;
64549
- numRetriesRemaining--;
64550
- } else {
64551
- throw err;
64552
66478
  }
64553
66479
  }
66480
+ } finally {
66481
+ if (leased) this.endOp();
64554
66482
  }
64555
66483
  }
66484
+ streamExecStdio(taskId, execId, fileDescriptor, deadline, signal) {
66485
+ return this.streamStdioWithRetries({
66486
+ open: (offset, signal2) => this.stub.taskExecStdioRead(
66487
+ TaskExecStdioReadRequest.create({
66488
+ taskId,
66489
+ execId,
66490
+ offset,
66491
+ fileDescriptor
66492
+ }),
66493
+ {
66494
+ timeoutMs: deadline !== null ? Math.max(0, deadline - Date.now()) : void 0,
66495
+ signal: signal2
66496
+ }
66497
+ ),
66498
+ nextOffset: (item, offset) => offset + item.data.length,
66499
+ deadline,
66500
+ label: `exec ${execId}`,
66501
+ signal
66502
+ });
66503
+ }
66504
+ streamSandboxStdio(taskId, fileDescriptor, signal) {
66505
+ return this.streamStdioWithRetries({
66506
+ open: (offset, signal2) => this.stub.sandboxStdioReadV2(
66507
+ SandboxStdioReadV2Request.create({ taskId, offset, fileDescriptor }),
66508
+ { signal: signal2 }
66509
+ ),
66510
+ nextOffset: (item, offset, firstOfAttempt) => (firstOfAttempt ? item.startingOffset : offset) + item.data.length,
66511
+ deadline: null,
66512
+ label: `Sandbox task ${taskId}`,
66513
+ signal
66514
+ });
66515
+ }
64556
66516
  };
64557
66517
  async function getCommandRouterAccess(serverClient, taskId, sandboxId, isV2) {
64558
66518
  if (isV2) {
@@ -64568,7 +66528,7 @@ async function getCommandRouterAccess(serverClient, taskId, sandboxId, isV2) {
64568
66528
  }
64569
66529
 
64570
66530
  // src/sandbox.ts
64571
- import { v4 as uuidv4 } from "uuid";
66531
+ import { v4 as uuidv42 } from "uuid";
64572
66532
 
64573
66533
  // src/sandbox_fs.ts
64574
66534
  import { randomBytes } from "node:crypto";
@@ -65482,6 +67442,7 @@ var SandboxFilesystem = class {
65482
67442
 
65483
67443
  // src/sandbox_sidecar.ts
65484
67444
  import { ClientError as ClientError9, Status as Status9 } from "nice-grpc";
67445
+ import { v4 as uuidv4 } from "uuid";
65485
67446
  var MAIN_CONTAINER_NAME = "main";
65486
67447
  var CONTAINER_WAIT_POLL_TIMEOUT_SECONDS = 10;
65487
67448
  function validateSidecarName(name) {
@@ -65696,6 +67657,10 @@ var SidecarContainer = class {
65696
67657
  return this.wait();
65697
67658
  }
65698
67659
  }
67660
+ /** Snapshot this Sidecar container's filesystem into an Image. */
67661
+ async snapshotFilesystem(params) {
67662
+ return this.#access.snapshotFilesystem(this.containerId, params);
67663
+ }
65699
67664
  /**
65700
67665
  * Reload all Volumes mounted in this sidecar container.
65701
67666
  *
@@ -65705,6 +67670,80 @@ var SidecarContainer = class {
65705
67670
  async reloadVolumes(params) {
65706
67671
  await this.#access.reloadVolumes(this.containerId, params);
65707
67672
  }
67673
+ /**
67674
+ * Mount an {@link Image} at a path in this Sidecar container's filesystem.
67675
+ *
67676
+ * @param path - The path where the directory should be mounted
67677
+ * @param image - Optional {@link Image} to mount. If undefined, mounts an empty directory.
67678
+ * @param params - Optional parameters; see {@link SidecarMountImageParams}.
67679
+ */
67680
+ async mountImage(path2, image, params) {
67681
+ const imageId = resolveMountImageId(image);
67682
+ const [taskId, client] = await this.#access.commandRouter();
67683
+ await client.mountDirectory(
67684
+ buildTaskMountDirectoryRequestProto(
67685
+ taskId,
67686
+ path2,
67687
+ imageId,
67688
+ params,
67689
+ this.containerId
67690
+ )
67691
+ );
67692
+ }
67693
+ /**
67694
+ * Unmounts an {@link Image} previously mounted at a path in this Sidecar container's filesystem.
67695
+ *
67696
+ * @param path - The mount path to unmount
67697
+ */
67698
+ async unmountImage(path2, _params) {
67699
+ const [taskId, client] = await this.#access.commandRouter();
67700
+ await client.unmountDirectory(
67701
+ TaskUnmountDirectoryRequest.create({
67702
+ taskId,
67703
+ path: new TextEncoder().encode(path2),
67704
+ containerId: this.containerId
67705
+ })
67706
+ );
67707
+ }
67708
+ /**
67709
+ * Snapshots and creates a new {@link Image} from a directory in the running Sidecar container.
67710
+ *
67711
+ * The resulting Image is retained for `ttlMs` (default: 30 days),
67712
+ * as a hard cutoff measured from creation — usage does not extend
67713
+ * the lifetime. Pass `ttlMs: null` to retain indefinitely.
67714
+ *
67715
+ * The call has an overall `timeoutMs` budget (default: 55000). If it
67716
+ * elapses before a snapshot completes, the call is cancelled and an
67717
+ * error is thrown.
67718
+ *
67719
+ * The Image can be used anywhere an Image is accepted, including as a mount
67720
+ * or as the base filesystem for another container.
67721
+ *
67722
+ * @param path - The path of the directory to snapshot
67723
+ * @param params - Optional parameters; see {@link SidecarSnapshotDirectoryParams}.
67724
+ * @returns Promise that resolves to an {@link Image}
67725
+ */
67726
+ async snapshotDirectory(path2, params) {
67727
+ const timeoutMs = params?.timeoutMs || 55e3;
67728
+ const [taskId, client] = await this.#access.commandRouter();
67729
+ const response = await client.snapshotDirectory(
67730
+ buildTaskSnapshotDirectoryRequestProto(
67731
+ taskId,
67732
+ path2,
67733
+ uuidv4(),
67734
+ resolveTtlSeconds(params?.ttlMs),
67735
+ params,
67736
+ this.containerId
67737
+ ),
67738
+ { timeoutMs }
67739
+ );
67740
+ if (!response.imageId) {
67741
+ throw new InternalFailure(
67742
+ "Sidecar snapshot directory response missing `imageId`"
67743
+ );
67744
+ }
67745
+ return new Image2(this.#access.client, response.imageId, "");
67746
+ }
65708
67747
  };
65709
67748
 
65710
67749
  // src/streams.ts
@@ -65725,7 +67764,7 @@ var readMixin = {
65725
67764
  if (value) {
65726
67765
  if (typeof value === "string") chunks.push(value);
65727
67766
  else {
65728
- chunks.push(decoder2.decode(value.buffer, { stream: true }));
67767
+ chunks.push(decoder2.decode(value, { stream: true }));
65729
67768
  }
65730
67769
  }
65731
67770
  if (done) {
@@ -65810,12 +67849,26 @@ function streamConsumingIter(iterable, onCancel) {
65810
67849
  }
65811
67850
  }
65812
67851
  },
65813
- new ByteLengthQueuingStrategy({
65814
- highWaterMark: 64 * 1024
65815
- // 64 KiB
65816
- })
67852
+ // The high water mark is set to zero intentionally to not run any
67853
+ // background buffering of data, since that would eagerly start streams etc.
67854
+ // If users want a buffered stream they can add buffing on top of the returned
67855
+ // streams instead.
67856
+ new CountQueuingStrategy({ highWaterMark: 0 })
65817
67857
  );
65818
67858
  }
67859
+ async function* decodeTextIter(source) {
67860
+ const decoder2 = new TextDecoder();
67861
+ for await (const chunk of source) {
67862
+ const text = decoder2.decode(chunk, { stream: true });
67863
+ if (text) {
67864
+ yield text;
67865
+ }
67866
+ }
67867
+ const rest = decoder2.decode();
67868
+ if (rest) {
67869
+ yield rest;
67870
+ }
67871
+ }
65819
67872
 
65820
67873
  // src/sandbox_snapshot.ts
65821
67874
  var SandboxSnapshot = class {
@@ -66368,6 +68421,9 @@ var SandboxService = class {
66368
68421
  * Create a new {@link Sandbox} in the {@link App} with the specified {@link Image} and options.
66369
68422
  */
66370
68423
  async create(app, image, params = {}) {
68424
+ if (this.#client.profile.sandboxV2 && !params.gpu) {
68425
+ return await this.experimentalCreate(app, image, params);
68426
+ }
66371
68427
  await image.build(app);
66372
68428
  const mergedSecrets = await mergeEnvIntoSecrets(
66373
68429
  this.#client,
@@ -66495,6 +68551,13 @@ var SandboxService = class {
66495
68551
  * @returns Promise that resolves to a Sandbox
66496
68552
  */
66497
68553
  async fromName(appName, name, params) {
68554
+ if (this.#client.profile.sandboxV2) {
68555
+ try {
68556
+ return await this.experimentalFromName(appName, name, params);
68557
+ } catch (err) {
68558
+ if (!(err instanceof NotFoundError)) throw err;
68559
+ }
68560
+ }
66498
68561
  try {
66499
68562
  const resp = await this.#client.cpClient.sandboxGetFromName({
66500
68563
  sandboxName: name,
@@ -66593,6 +68656,10 @@ var SandboxService = class {
66593
68656
  * If tags are specified, only Sandboxes that have at least those tags are returned.
66594
68657
  */
66595
68658
  async *list(params = {}) {
68659
+ if (this.#client.profile.sandboxV2) {
68660
+ yield* this.experimentalList(params);
68661
+ return;
68662
+ }
66596
68663
  const env = this.#client.environmentName(params.environment);
66597
68664
  const tagsList = params.tags ? Object.entries(params.tags).map(([tagName, tagValue]) => ({
66598
68665
  tagName,
@@ -66649,20 +68716,27 @@ var SandboxService = class {
66649
68716
  })) : [];
66650
68717
  let beforeTimestamp = void 0;
66651
68718
  while (true) {
66652
- const resp = await this.#client.cpClient.sandboxListV2({
66653
- appId: params.appId,
66654
- beforeTimestamp,
66655
- environmentName,
66656
- includeFinished: false,
66657
- tags: tagsList
66658
- });
66659
- if (!resp.sandboxes || resp.sandboxes.length === 0) {
66660
- return;
66661
- }
66662
- for (const info of resp.sandboxes) {
66663
- yield new Sandbox2(this.#client, info.id);
68719
+ try {
68720
+ const resp = await this.#client.cpClient.sandboxListV2({
68721
+ appId: params.appId,
68722
+ beforeTimestamp,
68723
+ environmentName,
68724
+ includeFinished: false,
68725
+ tags: tagsList
68726
+ });
68727
+ if (!resp.sandboxes || resp.sandboxes.length === 0) {
68728
+ return;
68729
+ }
68730
+ for (const info of resp.sandboxes) {
68731
+ yield new Sandbox2(this.#client, info.id);
68732
+ }
68733
+ beforeTimestamp = resp.sandboxes[resp.sandboxes.length - 1].createdAt;
68734
+ } catch (err) {
68735
+ if (err instanceof ClientError11 && err.code === Status11.INVALID_ARGUMENT) {
68736
+ throw new InvalidError(err.details || err.message);
68737
+ }
68738
+ throw err;
66664
68739
  }
66665
- beforeTimestamp = resp.sandboxes[resp.sandboxes.length - 1].createdAt;
66666
68740
  }
66667
68741
  }
66668
68742
  };
@@ -66794,17 +68868,26 @@ function buildTaskExecStartRequestProto(taskId, execId, command, params, contain
66794
68868
  containerId: containerId ?? ""
66795
68869
  });
66796
68870
  }
66797
- function buildTaskMountDirectoryRequestProto(taskId, path2, imageId, params) {
68871
+ function buildTaskMountDirectoryRequestProto(taskId, path2, imageId, params, containerId = "") {
66798
68872
  return TaskMountDirectoryRequest.create({
66799
68873
  taskId,
66800
68874
  path: new TextEncoder().encode(path2),
66801
68875
  imageId,
66802
68876
  customerSuppliedEncryptionKey: validateExperimentalEncryptionKey(
66803
68877
  params?.experimentalEncryptionKey
66804
- )
68878
+ ),
68879
+ containerId
66805
68880
  });
66806
68881
  }
66807
- function buildTaskSnapshotDirectoryRequestProto(taskId, path2, snapshotId, ttlSeconds, params) {
68882
+ function resolveMountImageId(image) {
68883
+ if (image && !image.imageId) {
68884
+ throw new Error(
68885
+ "Image must be built before mounting. Call `image.build(app)` first."
68886
+ );
68887
+ }
68888
+ return image?.imageId ?? "";
68889
+ }
68890
+ function buildTaskSnapshotDirectoryRequestProto(taskId, path2, snapshotId, ttlSeconds, params, containerId = "") {
66808
68891
  return TaskSnapshotDirectoryRequest.create({
66809
68892
  taskId,
66810
68893
  path: new TextEncoder().encode(path2),
@@ -66812,7 +68895,8 @@ function buildTaskSnapshotDirectoryRequestProto(taskId, path2, snapshotId, ttlSe
66812
68895
  ttlSeconds,
66813
68896
  customerSuppliedEncryptionKey: validateExperimentalEncryptionKey(
66814
68897
  params?.experimentalEncryptionKey
66815
- )
68898
+ ),
68899
+ containerId
66816
68900
  });
66817
68901
  }
66818
68902
  var Sandbox2 = class _Sandbox {
@@ -66821,8 +68905,6 @@ var Sandbox2 = class _Sandbox {
66821
68905
  #stdin;
66822
68906
  #stdout;
66823
68907
  #stderr;
66824
- #stdoutAbort;
66825
- #stderrAbort;
66826
68908
  #taskId;
66827
68909
  #tunnels;
66828
68910
  #isV2;
@@ -66847,51 +68929,57 @@ var Sandbox2 = class _Sandbox {
66847
68929
  this.#initCommandRouterAccess = params.initCommandRouterAccess;
66848
68930
  }
66849
68931
  get stdin() {
66850
- this.#ensureV1("stdin");
66851
68932
  if (!this.#stdin) {
66852
68933
  this.#stdin = toModalWriteStream(
66853
- inputStreamSb(this.#client.cpClient, this.sandboxId)
68934
+ this.#isV2 ? inputStreamSbV2(() => this.#getCommandRouter()) : inputStreamSb(this.#client.cpClient, this.sandboxId)
66854
68935
  );
66855
68936
  }
66856
68937
  return this.#stdin;
66857
68938
  }
66858
68939
  get stdout() {
66859
- this.#ensureV1("stdout");
66860
68940
  if (!this.#stdout) {
66861
- this.#stdoutAbort = new AbortController();
66862
- const bytesStream = streamConsumingIter(
66863
- outputStreamSb(
66864
- this.#client.cpClient,
66865
- this.sandboxId,
66866
- 1 /* FILE_DESCRIPTOR_STDOUT */,
66867
- this.#stdoutAbort.signal
66868
- ),
66869
- () => this.#stdoutAbort?.abort()
66870
- );
66871
- this.#stdout = toModalReadStream(
66872
- bytesStream.pipeThrough(new TextDecoderStream())
66873
- );
68941
+ this.#stdout = this.#outputStream(1 /* FILE_DESCRIPTOR_STDOUT */);
66874
68942
  }
66875
68943
  return this.#stdout;
66876
68944
  }
66877
68945
  get stderr() {
66878
- this.#ensureV1("stderr");
66879
68946
  if (!this.#stderr) {
66880
- this.#stderrAbort = new AbortController();
66881
- const bytesStream = streamConsumingIter(
68947
+ this.#stderr = this.#outputStream(2 /* FILE_DESCRIPTOR_STDERR */);
68948
+ }
68949
+ return this.#stderr;
68950
+ }
68951
+ #outputStream(fileDescriptor) {
68952
+ if (this.#isV2) {
68953
+ this.#ensureAttached();
68954
+ const v2Abort = new AbortController();
68955
+ return toModalReadStream(
68956
+ streamConsumingIter(
68957
+ decodeTextIter(
68958
+ outputStreamSbV2(
68959
+ () => this.#getCommandRouter(v2Abort.signal),
68960
+ this.sandboxId,
68961
+ fileDescriptor,
68962
+ this.#client.logger,
68963
+ v2Abort.signal
68964
+ )
68965
+ ),
68966
+ () => v2Abort.abort()
68967
+ )
68968
+ );
68969
+ }
68970
+ const abort = new AbortController();
68971
+ return toModalReadStream(
68972
+ streamConsumingIter(
66882
68973
  outputStreamSb(
66883
68974
  this.#client.cpClient,
66884
68975
  this.sandboxId,
66885
- 2 /* FILE_DESCRIPTOR_STDERR */,
66886
- this.#stderrAbort.signal
68976
+ fileDescriptor,
68977
+ this.#client.profile.sandboxChannelIdleTimeoutMs,
68978
+ abort.signal
66887
68979
  ),
66888
- () => this.#stderrAbort?.abort()
66889
- );
66890
- this.#stderr = toModalReadStream(
66891
- bytesStream.pipeThrough(new TextDecoderStream())
66892
- );
66893
- }
66894
- return this.#stderr;
68980
+ () => abort.abort()
68981
+ )
68982
+ );
66895
68983
  }
66896
68984
  get filesystem() {
66897
68985
  this.#ensureAttached();
@@ -66915,7 +69003,8 @@ var Sandbox2 = class _Sandbox {
66915
69003
  client: this.#client,
66916
69004
  exec: (command, params, containerId) => this.#execInternal(command, params, containerId),
66917
69005
  commandRouter: () => this.#getCommandRouter(),
66918
- reloadVolumes: (containerId, params) => this.#reloadVolumes(containerId, params)
69006
+ reloadVolumes: (containerId, params) => this.#reloadVolumes(containerId, params),
69007
+ snapshotFilesystem: (containerId, params) => this.#snapshotFilesystem(containerId, params)
66919
69008
  });
66920
69009
  }
66921
69010
  return this.#sidecars;
@@ -67035,7 +69124,7 @@ var Sandbox2 = class _Sandbox {
67035
69124
  secrets: resolvableSecrets
67036
69125
  };
67037
69126
  const [taskId, commandRouterClient] = await this.#getCommandRouter();
67038
- const execId = uuidv4();
69127
+ const execId = uuidv42();
67039
69128
  const request = buildTaskExecStartRequestProto(
67040
69129
  taskId,
67041
69130
  execId,
@@ -67064,9 +69153,9 @@ var Sandbox2 = class _Sandbox {
67064
69153
  deadline
67065
69154
  );
67066
69155
  }
67067
- async #getCommandRouter() {
69156
+ async #getCommandRouter(signal) {
67068
69157
  this.#ensureAttached();
67069
- const taskId = await this.#getTaskId();
69158
+ const taskId = await this.#getTaskId(signal);
67070
69159
  const client = await this.#getOrCreateCommandRouterClient(taskId);
67071
69160
  return [taskId, client];
67072
69161
  }
@@ -67075,13 +69164,6 @@ var Sandbox2 = class _Sandbox {
67075
69164
  throw new ClientClosedError();
67076
69165
  }
67077
69166
  }
67078
- #ensureV1(methodName) {
67079
- if (this.#isV2) {
67080
- throw new InvalidError(
67081
- `Sandbox.${methodName} is not supported for V2 sandboxes`
67082
- );
67083
- }
67084
- }
67085
69167
  #ensureV2(methodName) {
67086
69168
  if (!this.#isV2) {
67087
69169
  throw new InvalidError(
@@ -67096,12 +69178,12 @@ var Sandbox2 = class _Sandbox {
67096
69178
  }
67097
69179
  return this.#client.cpClient.sandboxWait(req);
67098
69180
  }
67099
- #sandboxGetTaskId() {
69181
+ #sandboxGetTaskId(signal) {
67100
69182
  const req = { sandboxId: this.sandboxId };
67101
69183
  if (this.#isV2) {
67102
- return this.#client.cpClient.sandboxGetTaskIdV2(req);
69184
+ return this.#client.cpClient.sandboxGetTaskIdV2(req, { signal });
67103
69185
  }
67104
- return this.#client.cpClient.sandboxGetTaskId(req);
69186
+ return this.#client.cpClient.sandboxGetTaskId(req, { signal });
67105
69187
  }
67106
69188
  #sandboxGetTunnels(timeoutMs) {
67107
69189
  const req = { sandboxId: this.sandboxId, timeout: timeoutMs / 1e3 };
@@ -67127,12 +69209,16 @@ var Sandbox2 = class _Sandbox {
67127
69209
  }
67128
69210
  static #maxGetTaskIdAttempts = 600;
67129
69211
  // 5 minutes at 500ms intervals
67130
- async #getTaskId() {
69212
+ async #getTaskId(signal) {
67131
69213
  if (this.#taskId !== void 0) {
67132
69214
  return this.#taskId;
67133
69215
  }
67134
69216
  for (let i = 0; i < _Sandbox.#maxGetTaskIdAttempts; i++) {
67135
- const resp = await this.#sandboxGetTaskId();
69217
+ const resp = await this.#sandboxGetTaskId(signal);
69218
+ if (resp.taskId) {
69219
+ this.#taskId = resp.taskId;
69220
+ return this.#taskId;
69221
+ }
67136
69222
  if (resp.taskResult) {
67137
69223
  if (resp.taskResult.status === 1 /* GENERIC_STATUS_SUCCESS */ || !resp.taskResult.exception) {
67138
69224
  throw new Error(`Sandbox ${this.sandboxId} has already completed`);
@@ -67141,11 +69227,7 @@ var Sandbox2 = class _Sandbox {
67141
69227
  `Sandbox ${this.sandboxId} has already completed with result: exception:"${resp.taskResult.exception}"`
67142
69228
  );
67143
69229
  }
67144
- if (resp.taskId) {
67145
- this.#taskId = resp.taskId;
67146
- return this.#taskId;
67147
- }
67148
- await setTimeout3(500);
69230
+ await setTimeout3(500, void 0, { signal });
67149
69231
  }
67150
69232
  throw new Error(
67151
69233
  `Timed out waiting for task ID for Sandbox ${this.sandboxId}`
@@ -67218,18 +69300,19 @@ var Sandbox2 = class _Sandbox {
67218
69300
  if (params?.wait) {
67219
69301
  exitCode = await this.wait();
67220
69302
  }
67221
- this.#taskId = void 0;
67222
- this.detach();
67223
69303
  return exitCode;
67224
69304
  }
67225
69305
  /**
67226
69306
  * Disconnect from the Sandbox, cleaning up local resources.
67227
69307
  * The Sandbox continues running on Modal's infrastructure.
67228
69308
  * After calling detach(), most operations on this Sandbox object will throw.
69309
+ *
69310
+ * This does not block on or interrupt ongoing reads or calls. Connection
69311
+ * resources are closed promptly once those operations finish.
67229
69312
  */
67230
69313
  detach() {
67231
- this.#commandRouterClient?.close();
67232
69314
  this.#attached = false;
69315
+ this.#commandRouterClient?.closeWhenIdle();
67233
69316
  this.#commandRouterClient = void 0;
67234
69317
  this.#commandRouterClientPromise = void 0;
67235
69318
  }
@@ -67308,13 +69391,17 @@ var Sandbox2 = class _Sandbox {
67308
69391
  */
67309
69392
  async snapshotFilesystem(params) {
67310
69393
  this.#ensureAttached();
69394
+ return this.#snapshotFilesystem("", params);
69395
+ }
69396
+ async #snapshotFilesystem(containerId, params) {
67311
69397
  const wireTtlSeconds = resolveTtlSeconds(params?.ttlMs);
67312
69398
  const timeoutMs = params?.timeoutMs || 55e3;
67313
69399
  const [taskId, commandRouterClient] = await this.#getCommandRouter();
67314
69400
  const request = TaskSnapshotFilesystemRequest.create({
67315
69401
  taskId,
67316
- snapshotId: uuidv4(),
67317
- ttlSeconds: wireTtlSeconds
69402
+ snapshotId: uuidv42(),
69403
+ ttlSeconds: wireTtlSeconds,
69404
+ containerId
67318
69405
  });
67319
69406
  const response = await commandRouterClient.snapshotFilesystem(request, {
67320
69407
  timeoutMs
@@ -67327,13 +69414,39 @@ var Sandbox2 = class _Sandbox {
67327
69414
  /**
67328
69415
  * Get the exit filesystem snapshot image.
67329
69416
  *
69417
+ * An exit snapshot captures the Sandbox filesystem when the Sandbox exits,
69418
+ * whether its entrypoint finishes gracefully, abruptly, or it is stopped with
69419
+ * {@link Sandbox#terminate}. The resulting {@link Image} can be passed to
69420
+ * {@link SandboxService#create client.sandboxes.create()} to start a new
69421
+ * Sandbox from the saved filesystem.
69422
+ *
69423
+ * Exit snapshots are opt-in: the Sandbox must have been created with
69424
+ * `experimentalOptions: { enable_exit_snapshot: true }`. Calling this on a
69425
+ * Sandbox created without that option throws an {@link InvalidError}.
69426
+ *
69427
+ * @example
69428
+ * ```ts
69429
+ * const sb = await modal.sandboxes.create(app, image, {
69430
+ * experimentalOptions: { enable_exit_snapshot: true },
69431
+ * });
69432
+ * // ... use the Sandbox ...
69433
+ * await sb.terminate();
69434
+ * const image = await sb.experimentalGetExitSnapshot();
69435
+ * const sb2 = await modal.sandboxes.create(app, image);
69436
+ * ```
69437
+ *
67330
69438
  * EXPERIMENTAL: the API is subject to change.
67331
69439
  *
67332
69440
  * @param params - Optional parameters; see SandboxExperimentalGetExitSnapshotParams.
67333
69441
  * @returns The exit snapshot Image.
69442
+ * @throws {InvalidError} If `timeoutMs` is negative, or if exit snapshots
69443
+ * were not enabled when the Sandbox was created.
67334
69444
  * @throws {TimeoutError} If `timeoutMs` elapses before the snapshot
67335
69445
  * reaches a terminal state. This includes `timeoutMs = 0` when the
67336
69446
  * snapshot is still pending.
69447
+ * @throws {SnapshotCreationError} Snapshot operation is done and failed.
69448
+ * Polling again will not produce an Image; filesystem state is gone.
69449
+ * @throws {NotFoundError} If the Sandbox does not exist.
67337
69450
  */
67338
69451
  async experimentalGetExitSnapshot(params) {
67339
69452
  const timeoutMs = params?.timeoutMs;
@@ -67445,8 +69558,8 @@ var Sandbox2 = class _Sandbox {
67445
69558
  if (this.#isV2) {
67446
69559
  const [taskId, commandRouterClient] = await this.#getCommandRouter();
67447
69560
  const resp = await commandRouterClient.snapshotMemory(
67448
- TaskSnapshotMemoryRequest.create({ taskId, idempotencyKey: uuidv4() }),
67449
- { timeoutMs: 55e3 }
69561
+ TaskSnapshotMemoryRequest.create({ taskId, idempotencyKey: uuidv42() }),
69562
+ { timeoutMs: 165e3 }
67450
69563
  );
67451
69564
  snapshotId = resp.snapshotId;
67452
69565
  } else {
@@ -67475,12 +69588,7 @@ var Sandbox2 = class _Sandbox {
67475
69588
  async mountImage(path2, image, params) {
67476
69589
  this.#ensureAttached();
67477
69590
  const [taskId, commandRouterClient] = await this.#getCommandRouter();
67478
- if (image && !image.imageId) {
67479
- throw new Error(
67480
- "Image must be built before mounting. Call `image.build(app)` first."
67481
- );
67482
- }
67483
- const imageId = image?.imageId ?? "";
69591
+ const imageId = resolveMountImageId(image);
67484
69592
  const request = buildTaskMountDirectoryRequestProto(
67485
69593
  taskId,
67486
69594
  path2,
@@ -67576,7 +69684,7 @@ var Sandbox2 = class _Sandbox {
67576
69684
  const request = buildTaskSnapshotDirectoryRequestProto(
67577
69685
  taskId,
67578
69686
  path2,
67579
- uuidv4(),
69687
+ uuidv42(),
67580
69688
  wireTtlSeconds,
67581
69689
  params
67582
69690
  );
@@ -67619,35 +69727,28 @@ var ContainerProcess2 = class {
67619
69727
  this.stdin = toModalWriteStream(
67620
69728
  inputStreamCp(commandRouterClient, taskId, execId)
67621
69729
  );
67622
- const stdoutStream = stdout === "ignore" ? ReadableStream.from([]) : streamConsumingIter(
67623
- outputStreamCp(
69730
+ const output = (behavior, fileDescriptor) => {
69731
+ if (behavior === "ignore") {
69732
+ return ReadableStream.from([]);
69733
+ }
69734
+ const abort = new AbortController();
69735
+ const bytes = outputStreamCp(
67624
69736
  commandRouterClient,
67625
69737
  taskId,
67626
69738
  execId,
67627
- 1 /* FILE_DESCRIPTOR_STDOUT */,
67628
- this.#deadline
67629
- )
69739
+ fileDescriptor,
69740
+ this.#deadline,
69741
+ abort.signal
69742
+ );
69743
+ const stream = mode === "text" ? streamConsumingIter(decodeTextIter(bytes), () => abort.abort()) : streamConsumingIter(bytes, () => abort.abort());
69744
+ return stream;
69745
+ };
69746
+ this.stdout = toModalReadStream(
69747
+ output(stdout, 1 /* FILE_DESCRIPTOR_STDOUT */)
67630
69748
  );
67631
- const stderrStream = stderr === "ignore" ? ReadableStream.from([]) : streamConsumingIter(
67632
- outputStreamCp(
67633
- commandRouterClient,
67634
- taskId,
67635
- execId,
67636
- 2 /* FILE_DESCRIPTOR_STDERR */,
67637
- this.#deadline
67638
- )
69749
+ this.stderr = toModalReadStream(
69750
+ output(stderr, 2 /* FILE_DESCRIPTOR_STDERR */)
67639
69751
  );
67640
- if (mode === "text") {
67641
- this.stdout = toModalReadStream(
67642
- stdoutStream.pipeThrough(new TextDecoderStream())
67643
- );
67644
- this.stderr = toModalReadStream(
67645
- stderrStream.pipeThrough(new TextDecoderStream())
67646
- );
67647
- } else {
67648
- this.stdout = toModalReadStream(stdoutStream);
67649
- this.stderr = toModalReadStream(stderrStream);
67650
- }
67651
69752
  }
67652
69753
  /**
67653
69754
  * @ignore
@@ -67710,12 +69811,20 @@ var ContainerProcess2 = class {
67710
69811
  }
67711
69812
  }
67712
69813
  };
67713
- async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, signal) {
69814
+ async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, idleTimeoutMs, signal) {
67714
69815
  let lastIndex = "0-0";
67715
69816
  let completed = false;
67716
69817
  let retriesRemaining = SB_LOGS_MAX_RETRIES;
67717
69818
  let delayMs = SB_LOGS_INITIAL_DELAY_MS;
67718
69819
  while (!completed) {
69820
+ if (signal?.aborted) return;
69821
+ const idle = new IdleCountdown();
69822
+ const idleAbort = new AbortController();
69823
+ const releaseIfIdle = () => {
69824
+ idle.stop();
69825
+ idleAbort.abort();
69826
+ };
69827
+ const callSignal = signal === void 0 ? idleAbort.signal : AbortSignal.any([signal, idleAbort.signal]);
67719
69828
  try {
67720
69829
  const outputIterator = cpClient.sandboxGetLogs(
67721
69830
  {
@@ -67724,13 +69833,22 @@ async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, signal) {
67724
69833
  timeout: 55,
67725
69834
  lastEntryId: lastIndex
67726
69835
  },
67727
- { signal }
69836
+ { signal: callSignal }
67728
69837
  );
67729
69838
  for await (const batch of outputIterator) {
67730
69839
  delayMs = SB_LOGS_INITIAL_DELAY_MS;
67731
69840
  retriesRemaining = SB_LOGS_MAX_RETRIES;
67732
69841
  lastIndex = batch.entryId;
67733
- yield* batch.items.map((item) => new TextEncoder().encode(item.data));
69842
+ for (const item of batch.items) {
69843
+ if (!idleAbort.signal.aborted) {
69844
+ idle.arm(idleTimeoutMs, releaseIfIdle);
69845
+ }
69846
+ try {
69847
+ yield item.data;
69848
+ } finally {
69849
+ idle.stop();
69850
+ }
69851
+ }
67734
69852
  if (batch.eof) {
67735
69853
  completed = true;
67736
69854
  break;
@@ -67738,11 +69856,20 @@ async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, signal) {
67738
69856
  if (signal?.aborted) {
67739
69857
  return;
67740
69858
  }
69859
+ if (idleAbort.signal.aborted) {
69860
+ break;
69861
+ }
69862
+ }
69863
+ if (idleAbort.signal.aborted) {
69864
+ continue;
67741
69865
  }
67742
69866
  } catch (err) {
67743
69867
  if (signal?.aborted) {
67744
69868
  return;
67745
69869
  }
69870
+ if (idleAbort.signal.aborted) {
69871
+ continue;
69872
+ }
67746
69873
  if (isRetryableGrpc(err) && retriesRemaining > 0) {
67747
69874
  try {
67748
69875
  await setTimeout3(delayMs, void 0, { signal });
@@ -67755,7 +69882,37 @@ async function* outputStreamSb(cpClient, sandboxId, fileDescriptor, signal) {
67755
69882
  } else {
67756
69883
  throw err;
67757
69884
  }
69885
+ } finally {
69886
+ idle.stop();
69887
+ }
69888
+ }
69889
+ }
69890
+ async function* outputStreamSbV2(getCommandRouter, sandboxId, fileDescriptor, logger2, signal) {
69891
+ const [taskId, commandRouterClient] = await getCommandRouter();
69892
+ let firstChunk = true;
69893
+ for await (const item of commandRouterClient.sandboxStdioReadV2(
69894
+ taskId,
69895
+ fileDescriptor,
69896
+ signal
69897
+ )) {
69898
+ if (item.data.length === 0) {
69899
+ throw new Error(
69900
+ `Received empty message streaming stdio from Sandbox ${sandboxId}`
69901
+ );
69902
+ }
69903
+ if (firstChunk) {
69904
+ firstChunk = false;
69905
+ if (item.startingOffset > 0) {
69906
+ logger2.warn(
69907
+ "V2 Sandbox stdio: dropped bytes. Only the most recent portion of output is retained",
69908
+ "sandbox_id",
69909
+ sandboxId,
69910
+ "dropped_bytes",
69911
+ item.startingOffset
69912
+ );
69913
+ }
67758
69914
  }
69915
+ yield item.data;
67759
69916
  }
67760
69917
  }
67761
69918
  function inputStreamSb(cpClient, sandboxId) {
@@ -67778,12 +69935,40 @@ function inputStreamSb(cpClient, sandboxId) {
67778
69935
  }
67779
69936
  });
67780
69937
  }
67781
- async function* outputStreamCp(commandRouterClient, taskId, execId, fileDescriptor, deadline) {
69938
+ function inputStreamSbV2(getCommandRouter) {
69939
+ let offset = 0;
69940
+ return new WritableStream({
69941
+ async write(chunk) {
69942
+ const [taskId, commandRouterClient] = await getCommandRouter();
69943
+ const data = encodeIfString(chunk);
69944
+ await commandRouterClient.sandboxStdinWriteV2(
69945
+ taskId,
69946
+ offset,
69947
+ data,
69948
+ false
69949
+ // eof
69950
+ );
69951
+ offset += data.length;
69952
+ },
69953
+ async close() {
69954
+ const [taskId, commandRouterClient] = await getCommandRouter();
69955
+ await commandRouterClient.sandboxStdinWriteV2(
69956
+ taskId,
69957
+ offset,
69958
+ new Uint8Array(0),
69959
+ true
69960
+ // eof
69961
+ );
69962
+ }
69963
+ });
69964
+ }
69965
+ async function* outputStreamCp(commandRouterClient, taskId, execId, fileDescriptor, deadline, signal) {
67782
69966
  for await (const batch of commandRouterClient.execStdioRead(
67783
69967
  taskId,
67784
69968
  execId,
67785
69969
  fileDescriptor,
67786
- deadline
69970
+ deadline,
69971
+ signal
67787
69972
  )) {
67788
69973
  yield batch.data;
67789
69974
  }
@@ -68010,7 +70195,7 @@ var AuthTokenManager = class {
68010
70195
  };
68011
70196
 
68012
70197
  // src/version.ts
68013
- var SDK_VERSION = "0.10.0";
70198
+ var SDK_VERSION = "0.10.1";
68014
70199
  function getSDKVersion() {
68015
70200
  return SDK_VERSION;
68016
70201
  }
@@ -68074,6 +70259,62 @@ var EnvironmentManager = class {
68074
70259
  }
68075
70260
  };
68076
70261
 
70262
+ // src/oauth.ts
70263
+ import {
70264
+ createHash as createHash2,
70265
+ createPrivateKey,
70266
+ createPublicKey,
70267
+ createSign
70268
+ } from "node:crypto";
70269
+ import { v4 as uuidv43 } from "uuid";
70270
+ var OAUTH_CLIENT_ASSERTION_AUDIENCE = "modal-server";
70271
+ var OAUTH_CLIENT_ASSERTION_LIFETIME_SECONDS = 5 * 60;
70272
+ var MIN_RSA_KEY_SIZE = 2048;
70273
+ var INVALID_KEY_MESSAGE = "oauth_jwt_key must be an unencrypted RSA private key encoded as PEM.";
70274
+ function parseOAuthJwtKey(privateKeyPem) {
70275
+ let key;
70276
+ try {
70277
+ key = createPrivateKey(privateKeyPem.replaceAll("\\n", "\n"));
70278
+ } catch {
70279
+ throw new InvalidError(INVALID_KEY_MESSAGE);
70280
+ }
70281
+ if (key.asymmetricKeyType !== "rsa") {
70282
+ throw new InvalidError(INVALID_KEY_MESSAGE);
70283
+ }
70284
+ if ((key.asymmetricKeyDetails?.modulusLength ?? 0) < MIN_RSA_KEY_SIZE) {
70285
+ throw new InvalidError("oauth_jwt_key must be at least 2048 bits.");
70286
+ }
70287
+ return key;
70288
+ }
70289
+ function rsaJwkThumbprint(key) {
70290
+ const publicKey = key.type === "public" ? key : createPublicKey(key);
70291
+ const jwk = publicKey.export({ format: "jwk" });
70292
+ const canonical = JSON.stringify({ e: jwk.e, kty: "RSA", n: jwk.n });
70293
+ return createHash2("sha256").update(canonical).digest("base64url");
70294
+ }
70295
+ function base64UrlJson(value) {
70296
+ return Buffer.from(JSON.stringify(value), "utf-8").toString("base64url");
70297
+ }
70298
+ function mintOAuthClientAssertion(clientId, key) {
70299
+ const issuedAt = Math.floor(Date.now() / 1e3);
70300
+ const header = base64UrlJson({
70301
+ alg: "RS256",
70302
+ typ: "JWT",
70303
+ kid: rsaJwkThumbprint(key)
70304
+ });
70305
+ const payload = base64UrlJson({
70306
+ iss: clientId,
70307
+ sub: clientId,
70308
+ aud: OAUTH_CLIENT_ASSERTION_AUDIENCE,
70309
+ iat: issuedAt,
70310
+ exp: issuedAt + OAUTH_CLIENT_ASSERTION_LIFETIME_SECONDS,
70311
+ jti: uuidv43()
70312
+ });
70313
+ const signingInput = `${header}.${payload}`;
70314
+ const signature = createSign("RSA-SHA256").update(signingInput).sign(key).toString("base64url");
70315
+ return `${signingInput}.${signature}`;
70316
+ }
70317
+
68077
70318
  // src/client.ts
68078
70319
  var ModalClient = class {
68079
70320
  apps;
@@ -68096,18 +70337,40 @@ var ModalClient = class {
68096
70337
  authTokenManager = null;
68097
70338
  customMiddleware;
68098
70339
  environmentManager;
70340
+ oauthJwtKey;
68099
70341
  constructor(params) {
68100
70342
  checkForRenamedParams(params, { timeout: "timeoutMs" });
68101
70343
  const baseProfile = getProfile(process.env["MODAL_PROFILE"]);
70344
+ const hasTokenParams = params?.tokenId !== void 0 || params?.tokenSecret !== void 0;
70345
+ const hasOAuthParams = params?.oauthRefreshToken !== void 0 || params?.oauthClientId !== void 0 || params?.oauthClientSecret !== void 0 || params?.oauthJwtKey !== void 0;
68102
70346
  this.profile = {
68103
70347
  ...baseProfile,
68104
- ...params?.tokenId && { tokenId: params.tokenId },
68105
- ...params?.tokenSecret && { tokenSecret: params.tokenSecret },
68106
70348
  ...params?.environment && { environment: params.environment },
68107
70349
  ...params?.maxThrottleWaitSecs !== void 0 && {
68108
70350
  maxThrottleWaitSecs: params.maxThrottleWaitSecs
68109
70351
  }
68110
70352
  };
70353
+ if (hasTokenParams) {
70354
+ if (params?.tokenId !== void 0) {
70355
+ this.profile.tokenId = params.tokenId;
70356
+ }
70357
+ if (params?.tokenSecret !== void 0) {
70358
+ this.profile.tokenSecret = params.tokenSecret;
70359
+ }
70360
+ this.profile.oauthRefreshToken = void 0;
70361
+ this.profile.oauthClientId = void 0;
70362
+ this.profile.oauthClientSecret = void 0;
70363
+ this.profile.oauthJwtKey = void 0;
70364
+ } else if (hasOAuthParams) {
70365
+ this.profile.tokenId = void 0;
70366
+ this.profile.tokenSecret = void 0;
70367
+ this.profile.oauthRefreshToken = params?.oauthRefreshToken;
70368
+ this.profile.oauthClientId = params?.oauthClientId;
70369
+ this.profile.oauthClientSecret = params?.oauthClientSecret;
70370
+ this.profile.oauthJwtKey = params?.oauthJwtKey;
70371
+ }
70372
+ this.validateProfileCredentials(hasOAuthParams);
70373
+ this.oauthJwtKey = this.profile.oauthJwtKey ? parseOAuthJwtKey(this.profile.oauthJwtKey) : void 0;
68111
70374
  const logLevelValue = params?.logLevel || this.profile.logLevel || "";
68112
70375
  this.logger = createLogger(params?.logger, logLevelValue);
68113
70376
  this.logger.debug(
@@ -68141,6 +70404,24 @@ var ModalClient = class {
68141
70404
  environmentName(environment) {
68142
70405
  return environment || this.profile.environment || "";
68143
70406
  }
70407
+ validateProfileCredentials(hasExplicitOAuthCredentials) {
70408
+ const hasTokenCredentials = Boolean(
70409
+ this.profile.tokenId || this.profile.tokenSecret
70410
+ );
70411
+ const hasOAuthCredentials = hasExplicitOAuthCredentials || Boolean(
70412
+ this.profile.oauthRefreshToken || this.profile.oauthClientId || this.profile.oauthClientSecret || this.profile.oauthJwtKey
70413
+ );
70414
+ if (hasTokenCredentials && hasOAuthCredentials) {
70415
+ throw new InvalidError(
70416
+ "Modal token credentials and OAuth credentials cannot both be configured."
70417
+ );
70418
+ }
70419
+ if (hasOAuthCredentials && (!this.profile.oauthRefreshToken || !this.profile.oauthClientId || Boolean(this.profile.oauthClientSecret) === Boolean(this.profile.oauthJwtKey))) {
70420
+ throw new InvalidError(
70421
+ "OAuth refresh token, client ID, and exactly one of client secret or JWT key must all be configured."
70422
+ );
70423
+ }
70424
+ }
68144
70425
  /**
68145
70426
  * Returns the image builder version by querying the server where the local profile takes
68146
70427
  * precedence.
@@ -68207,13 +70488,13 @@ var ModalClient = class {
68207
70488
  ...restOptions
68208
70489
  } = options;
68209
70490
  if (call.requestStream || call.responseStream || !retries) {
68210
- return yield* call.next(call.request, restOptions);
70491
+ return yield* call.next(call.request, { ...restOptions, signal });
68211
70492
  }
68212
70493
  const retryableCodes = /* @__PURE__ */ new Set([
68213
70494
  ...retryableGrpcStatusCodes,
68214
70495
  ...additionalStatusCodes
68215
70496
  ]);
68216
- const idempotencyKey = uuidv42();
70497
+ const idempotencyKey = uuidv44();
68217
70498
  const throttleEnabled = maxThrottleWaitSecs !== 0;
68218
70499
  const startTime = Date.now();
68219
70500
  let attempt = 0;
@@ -68358,13 +70639,16 @@ var ModalClient = class {
68358
70639
  }
68359
70640
  return this.authTokenManager;
68360
70641
  };
70642
+ const oauthJwtKey = this.oauthJwtKey;
68361
70643
  return async function* authMiddleware(call, options) {
68362
- if (!profile.tokenId || !profile.tokenSecret) {
70644
+ const hasOAuthCredentials = Boolean(
70645
+ profile.oauthRefreshToken && profile.oauthClientId && (profile.oauthClientSecret || oauthJwtKey)
70646
+ );
70647
+ if (!hasOAuthCredentials && (!profile.tokenId || !profile.tokenSecret)) {
68363
70648
  throw new Error(
68364
- `Profile is missing token_id or token_secret. Please set them in .modal.toml, or as environment variables, or via ModalClient constructor.`
70649
+ `Profile is missing credentials. Please set them in .modal.toml, as environment variables, or via the ModalClient constructor.`
68365
70650
  );
68366
70651
  }
68367
- const { tokenId, tokenSecret } = profile;
68368
70652
  options.metadata ??= new Metadata2();
68369
70653
  options.metadata.set(
68370
70654
  "x-modal-client-type",
@@ -68375,8 +70659,27 @@ var ModalClient = class {
68375
70659
  "x-modal-libmodal-version",
68376
70660
  `modal-js/${getSDKVersion()}`
68377
70661
  );
68378
- options.metadata.set("x-modal-token-id", tokenId);
68379
- options.metadata.set("x-modal-token-secret", tokenSecret);
70662
+ if (hasOAuthCredentials) {
70663
+ options.metadata.set(
70664
+ "x-modal-refresh-token",
70665
+ profile.oauthRefreshToken
70666
+ );
70667
+ options.metadata.set("x-modal-oauth-client-id", profile.oauthClientId);
70668
+ if (oauthJwtKey) {
70669
+ options.metadata.set(
70670
+ "x-modal-oauth-client-assertion",
70671
+ mintOAuthClientAssertion(profile.oauthClientId, oauthJwtKey)
70672
+ );
70673
+ } else {
70674
+ options.metadata.set(
70675
+ "x-modal-oauth-client-secret",
70676
+ profile.oauthClientSecret
70677
+ );
70678
+ }
70679
+ } else {
70680
+ options.metadata.set("x-modal-token-id", profile.tokenId);
70681
+ options.metadata.set("x-modal-token-secret", profile.tokenSecret);
70682
+ }
68380
70683
  if (call.method.path !== "/modal.client.ModalClient/AuthTokenGet") {
68381
70684
  const tokenManager = getOrCreateAuthTokenManager();
68382
70685
  const token = await tokenManager.getToken();
@@ -68384,6 +70687,7 @@ var ModalClient = class {
68384
70687
  options.metadata.set("x-modal-auth-token", token);
68385
70688
  }
68386
70689
  }
70690
+ options.signal?.throwIfAborted();
68387
70691
  return yield* call.next(call.request, options);
68388
70692
  };
68389
70693
  }