modal 0.3.22 → 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +375 -121
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +375 -121
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -283,6 +283,8 @@ type ExecOptions = {
|
|
|
283
283
|
timeout?: number;
|
|
284
284
|
/** Secrets with environment variables for the command. */
|
|
285
285
|
secrets?: Secret[];
|
|
286
|
+
/** Enable a PTY for the command. */
|
|
287
|
+
pty?: boolean;
|
|
286
288
|
};
|
|
287
289
|
/** A port forwarded from within a running Modal Sandbox. */
|
|
288
290
|
declare class Tunnel {
|
|
@@ -485,6 +487,8 @@ type SandboxCreateOptions = {
|
|
|
485
487
|
volumes?: Record<string, Volume>;
|
|
486
488
|
/** Mount points for cloud buckets. */
|
|
487
489
|
cloudBucketMounts?: Record<string, CloudBucketMount>;
|
|
490
|
+
/** Enable a PTY for the Sandbox. */
|
|
491
|
+
pty?: boolean;
|
|
488
492
|
/** List of ports to tunnel into the Sandbox. Encrypted ports are tunneled with TLS. */
|
|
489
493
|
encryptedPorts?: number[];
|
|
490
494
|
/** List of encrypted ports to tunnel into the Sandbox, using HTTP/2. */
|
package/dist/index.js
CHANGED
|
@@ -24355,13 +24355,16 @@ var ListPagination = {
|
|
|
24355
24355
|
}
|
|
24356
24356
|
};
|
|
24357
24357
|
function createBaseMapAwaitRequest() {
|
|
24358
|
-
return { functionCallId:
|
|
24358
|
+
return { functionCallId: void 0, mapToken: void 0, lastEntryId: "", requestedAt: 0, timeout: 0 };
|
|
24359
24359
|
}
|
|
24360
24360
|
var MapAwaitRequest = {
|
|
24361
24361
|
encode(message, writer = new BinaryWriter()) {
|
|
24362
|
-
if (message.functionCallId !==
|
|
24362
|
+
if (message.functionCallId !== void 0) {
|
|
24363
24363
|
writer.uint32(10).string(message.functionCallId);
|
|
24364
24364
|
}
|
|
24365
|
+
if (message.mapToken !== void 0) {
|
|
24366
|
+
writer.uint32(42).string(message.mapToken);
|
|
24367
|
+
}
|
|
24365
24368
|
if (message.lastEntryId !== "") {
|
|
24366
24369
|
writer.uint32(18).string(message.lastEntryId);
|
|
24367
24370
|
}
|
|
@@ -24387,6 +24390,13 @@ var MapAwaitRequest = {
|
|
|
24387
24390
|
message.functionCallId = reader.string();
|
|
24388
24391
|
continue;
|
|
24389
24392
|
}
|
|
24393
|
+
case 5: {
|
|
24394
|
+
if (tag !== 42) {
|
|
24395
|
+
break;
|
|
24396
|
+
}
|
|
24397
|
+
message.mapToken = reader.string();
|
|
24398
|
+
continue;
|
|
24399
|
+
}
|
|
24390
24400
|
case 2: {
|
|
24391
24401
|
if (tag !== 18) {
|
|
24392
24402
|
break;
|
|
@@ -24418,7 +24428,8 @@ var MapAwaitRequest = {
|
|
|
24418
24428
|
},
|
|
24419
24429
|
fromJSON(object) {
|
|
24420
24430
|
return {
|
|
24421
|
-
functionCallId: isSet3(object.functionCallId) ? globalThis.String(object.functionCallId) :
|
|
24431
|
+
functionCallId: isSet3(object.functionCallId) ? globalThis.String(object.functionCallId) : void 0,
|
|
24432
|
+
mapToken: isSet3(object.mapToken) ? globalThis.String(object.mapToken) : void 0,
|
|
24422
24433
|
lastEntryId: isSet3(object.lastEntryId) ? globalThis.String(object.lastEntryId) : "",
|
|
24423
24434
|
requestedAt: isSet3(object.requestedAt) ? globalThis.Number(object.requestedAt) : 0,
|
|
24424
24435
|
timeout: isSet3(object.timeout) ? globalThis.Number(object.timeout) : 0
|
|
@@ -24426,9 +24437,12 @@ var MapAwaitRequest = {
|
|
|
24426
24437
|
},
|
|
24427
24438
|
toJSON(message) {
|
|
24428
24439
|
const obj = {};
|
|
24429
|
-
if (message.functionCallId !==
|
|
24440
|
+
if (message.functionCallId !== void 0) {
|
|
24430
24441
|
obj.functionCallId = message.functionCallId;
|
|
24431
24442
|
}
|
|
24443
|
+
if (message.mapToken !== void 0) {
|
|
24444
|
+
obj.mapToken = message.mapToken;
|
|
24445
|
+
}
|
|
24432
24446
|
if (message.lastEntryId !== "") {
|
|
24433
24447
|
obj.lastEntryId = message.lastEntryId;
|
|
24434
24448
|
}
|
|
@@ -24445,7 +24459,8 @@ var MapAwaitRequest = {
|
|
|
24445
24459
|
},
|
|
24446
24460
|
fromPartial(object) {
|
|
24447
24461
|
const message = createBaseMapAwaitRequest();
|
|
24448
|
-
message.functionCallId = object.functionCallId ??
|
|
24462
|
+
message.functionCallId = object.functionCallId ?? void 0;
|
|
24463
|
+
message.mapToken = object.mapToken ?? void 0;
|
|
24449
24464
|
message.lastEntryId = object.lastEntryId ?? "";
|
|
24450
24465
|
message.requestedAt = object.requestedAt ?? 0;
|
|
24451
24466
|
message.timeout = object.timeout ?? 0;
|
|
@@ -24732,7 +24747,7 @@ var MapStartOrContinueItem = {
|
|
|
24732
24747
|
}
|
|
24733
24748
|
};
|
|
24734
24749
|
function createBaseMapStartOrContinueRequest() {
|
|
24735
|
-
return { functionId: "", parentInputId: "", functionCallId: void 0, items: [] };
|
|
24750
|
+
return { functionId: "", parentInputId: "", functionCallId: void 0, mapToken: void 0, items: [] };
|
|
24736
24751
|
}
|
|
24737
24752
|
var MapStartOrContinueRequest = {
|
|
24738
24753
|
encode(message, writer = new BinaryWriter()) {
|
|
@@ -24745,6 +24760,9 @@ var MapStartOrContinueRequest = {
|
|
|
24745
24760
|
if (message.functionCallId !== void 0) {
|
|
24746
24761
|
writer.uint32(26).string(message.functionCallId);
|
|
24747
24762
|
}
|
|
24763
|
+
if (message.mapToken !== void 0) {
|
|
24764
|
+
writer.uint32(42).string(message.mapToken);
|
|
24765
|
+
}
|
|
24748
24766
|
for (const v of message.items) {
|
|
24749
24767
|
MapStartOrContinueItem.encode(v, writer.uint32(34).fork()).join();
|
|
24750
24768
|
}
|
|
@@ -24778,6 +24796,13 @@ var MapStartOrContinueRequest = {
|
|
|
24778
24796
|
message.functionCallId = reader.string();
|
|
24779
24797
|
continue;
|
|
24780
24798
|
}
|
|
24799
|
+
case 5: {
|
|
24800
|
+
if (tag !== 42) {
|
|
24801
|
+
break;
|
|
24802
|
+
}
|
|
24803
|
+
message.mapToken = reader.string();
|
|
24804
|
+
continue;
|
|
24805
|
+
}
|
|
24781
24806
|
case 4: {
|
|
24782
24807
|
if (tag !== 34) {
|
|
24783
24808
|
break;
|
|
@@ -24798,6 +24823,7 @@ var MapStartOrContinueRequest = {
|
|
|
24798
24823
|
functionId: isSet3(object.functionId) ? globalThis.String(object.functionId) : "",
|
|
24799
24824
|
parentInputId: isSet3(object.parentInputId) ? globalThis.String(object.parentInputId) : "",
|
|
24800
24825
|
functionCallId: isSet3(object.functionCallId) ? globalThis.String(object.functionCallId) : void 0,
|
|
24826
|
+
mapToken: isSet3(object.mapToken) ? globalThis.String(object.mapToken) : void 0,
|
|
24801
24827
|
items: globalThis.Array.isArray(object?.items) ? object.items.map((e) => MapStartOrContinueItem.fromJSON(e)) : []
|
|
24802
24828
|
};
|
|
24803
24829
|
},
|
|
@@ -24812,6 +24838,9 @@ var MapStartOrContinueRequest = {
|
|
|
24812
24838
|
if (message.functionCallId !== void 0) {
|
|
24813
24839
|
obj.functionCallId = message.functionCallId;
|
|
24814
24840
|
}
|
|
24841
|
+
if (message.mapToken !== void 0) {
|
|
24842
|
+
obj.mapToken = message.mapToken;
|
|
24843
|
+
}
|
|
24815
24844
|
if (message.items?.length) {
|
|
24816
24845
|
obj.items = message.items.map((e) => MapStartOrContinueItem.toJSON(e));
|
|
24817
24846
|
}
|
|
@@ -24825,15 +24854,26 @@ var MapStartOrContinueRequest = {
|
|
|
24825
24854
|
message.functionId = object.functionId ?? "";
|
|
24826
24855
|
message.parentInputId = object.parentInputId ?? "";
|
|
24827
24856
|
message.functionCallId = object.functionCallId ?? void 0;
|
|
24857
|
+
message.mapToken = object.mapToken ?? void 0;
|
|
24828
24858
|
message.items = object.items?.map((e) => MapStartOrContinueItem.fromPartial(e)) || [];
|
|
24829
24859
|
return message;
|
|
24830
24860
|
}
|
|
24831
24861
|
};
|
|
24832
24862
|
function createBaseMapStartOrContinueResponse() {
|
|
24833
|
-
return {
|
|
24863
|
+
return {
|
|
24864
|
+
mapToken: "",
|
|
24865
|
+
functionId: "",
|
|
24866
|
+
functionCallId: "",
|
|
24867
|
+
maxInputsOutstanding: 0,
|
|
24868
|
+
attemptTokens: [],
|
|
24869
|
+
retryPolicy: void 0
|
|
24870
|
+
};
|
|
24834
24871
|
}
|
|
24835
24872
|
var MapStartOrContinueResponse = {
|
|
24836
24873
|
encode(message, writer = new BinaryWriter()) {
|
|
24874
|
+
if (message.mapToken !== "") {
|
|
24875
|
+
writer.uint32(50).string(message.mapToken);
|
|
24876
|
+
}
|
|
24837
24877
|
if (message.functionId !== "") {
|
|
24838
24878
|
writer.uint32(10).string(message.functionId);
|
|
24839
24879
|
}
|
|
@@ -24858,6 +24898,13 @@ var MapStartOrContinueResponse = {
|
|
|
24858
24898
|
while (reader.pos < end) {
|
|
24859
24899
|
const tag = reader.uint32();
|
|
24860
24900
|
switch (tag >>> 3) {
|
|
24901
|
+
case 6: {
|
|
24902
|
+
if (tag !== 50) {
|
|
24903
|
+
break;
|
|
24904
|
+
}
|
|
24905
|
+
message.mapToken = reader.string();
|
|
24906
|
+
continue;
|
|
24907
|
+
}
|
|
24861
24908
|
case 1: {
|
|
24862
24909
|
if (tag !== 10) {
|
|
24863
24910
|
break;
|
|
@@ -24903,6 +24950,7 @@ var MapStartOrContinueResponse = {
|
|
|
24903
24950
|
},
|
|
24904
24951
|
fromJSON(object) {
|
|
24905
24952
|
return {
|
|
24953
|
+
mapToken: isSet3(object.mapToken) ? globalThis.String(object.mapToken) : "",
|
|
24906
24954
|
functionId: isSet3(object.functionId) ? globalThis.String(object.functionId) : "",
|
|
24907
24955
|
functionCallId: isSet3(object.functionCallId) ? globalThis.String(object.functionCallId) : "",
|
|
24908
24956
|
maxInputsOutstanding: isSet3(object.maxInputsOutstanding) ? globalThis.Number(object.maxInputsOutstanding) : 0,
|
|
@@ -24912,6 +24960,9 @@ var MapStartOrContinueResponse = {
|
|
|
24912
24960
|
},
|
|
24913
24961
|
toJSON(message) {
|
|
24914
24962
|
const obj = {};
|
|
24963
|
+
if (message.mapToken !== "") {
|
|
24964
|
+
obj.mapToken = message.mapToken;
|
|
24965
|
+
}
|
|
24915
24966
|
if (message.functionId !== "") {
|
|
24916
24967
|
obj.functionId = message.functionId;
|
|
24917
24968
|
}
|
|
@@ -24934,6 +24985,7 @@ var MapStartOrContinueResponse = {
|
|
|
24934
24985
|
},
|
|
24935
24986
|
fromPartial(object) {
|
|
24936
24987
|
const message = createBaseMapStartOrContinueResponse();
|
|
24988
|
+
message.mapToken = object.mapToken ?? "";
|
|
24937
24989
|
message.functionId = object.functionId ?? "";
|
|
24938
24990
|
message.functionCallId = object.functionCallId ?? "";
|
|
24939
24991
|
message.maxInputsOutstanding = object.maxInputsOutstanding ?? 0;
|
|
@@ -26629,7 +26681,16 @@ var ObjectDependency = {
|
|
|
26629
26681
|
}
|
|
26630
26682
|
};
|
|
26631
26683
|
function createBasePTYInfo() {
|
|
26632
|
-
return {
|
|
26684
|
+
return {
|
|
26685
|
+
enabled: false,
|
|
26686
|
+
winszRows: 0,
|
|
26687
|
+
winszCols: 0,
|
|
26688
|
+
envTerm: "",
|
|
26689
|
+
envColorterm: "",
|
|
26690
|
+
envTermProgram: "",
|
|
26691
|
+
ptyType: 0,
|
|
26692
|
+
noTerminateOnIdleStdin: false
|
|
26693
|
+
};
|
|
26633
26694
|
}
|
|
26634
26695
|
var PTYInfo = {
|
|
26635
26696
|
encode(message, writer = new BinaryWriter()) {
|
|
@@ -26654,6 +26715,9 @@ var PTYInfo = {
|
|
|
26654
26715
|
if (message.ptyType !== 0) {
|
|
26655
26716
|
writer.uint32(56).int32(message.ptyType);
|
|
26656
26717
|
}
|
|
26718
|
+
if (message.noTerminateOnIdleStdin !== false) {
|
|
26719
|
+
writer.uint32(64).bool(message.noTerminateOnIdleStdin);
|
|
26720
|
+
}
|
|
26657
26721
|
return writer;
|
|
26658
26722
|
},
|
|
26659
26723
|
decode(input, length) {
|
|
@@ -26712,6 +26776,13 @@ var PTYInfo = {
|
|
|
26712
26776
|
message.ptyType = reader.int32();
|
|
26713
26777
|
continue;
|
|
26714
26778
|
}
|
|
26779
|
+
case 8: {
|
|
26780
|
+
if (tag !== 64) {
|
|
26781
|
+
break;
|
|
26782
|
+
}
|
|
26783
|
+
message.noTerminateOnIdleStdin = reader.bool();
|
|
26784
|
+
continue;
|
|
26785
|
+
}
|
|
26715
26786
|
}
|
|
26716
26787
|
if ((tag & 7) === 4 || tag === 0) {
|
|
26717
26788
|
break;
|
|
@@ -26728,7 +26799,8 @@ var PTYInfo = {
|
|
|
26728
26799
|
envTerm: isSet3(object.envTerm) ? globalThis.String(object.envTerm) : "",
|
|
26729
26800
|
envColorterm: isSet3(object.envColorterm) ? globalThis.String(object.envColorterm) : "",
|
|
26730
26801
|
envTermProgram: isSet3(object.envTermProgram) ? globalThis.String(object.envTermProgram) : "",
|
|
26731
|
-
ptyType: isSet3(object.ptyType) ? pTYInfo_PTYTypeFromJSON(object.ptyType) : 0
|
|
26802
|
+
ptyType: isSet3(object.ptyType) ? pTYInfo_PTYTypeFromJSON(object.ptyType) : 0,
|
|
26803
|
+
noTerminateOnIdleStdin: isSet3(object.noTerminateOnIdleStdin) ? globalThis.Boolean(object.noTerminateOnIdleStdin) : false
|
|
26732
26804
|
};
|
|
26733
26805
|
},
|
|
26734
26806
|
toJSON(message) {
|
|
@@ -26754,6 +26826,9 @@ var PTYInfo = {
|
|
|
26754
26826
|
if (message.ptyType !== 0) {
|
|
26755
26827
|
obj.ptyType = pTYInfo_PTYTypeToJSON(message.ptyType);
|
|
26756
26828
|
}
|
|
26829
|
+
if (message.noTerminateOnIdleStdin !== false) {
|
|
26830
|
+
obj.noTerminateOnIdleStdin = message.noTerminateOnIdleStdin;
|
|
26831
|
+
}
|
|
26757
26832
|
return obj;
|
|
26758
26833
|
},
|
|
26759
26834
|
create(base) {
|
|
@@ -26768,6 +26843,7 @@ var PTYInfo = {
|
|
|
26768
26843
|
message.envColorterm = object.envColorterm ?? "";
|
|
26769
26844
|
message.envTermProgram = object.envTermProgram ?? "";
|
|
26770
26845
|
message.ptyType = object.ptyType ?? 0;
|
|
26846
|
+
message.noTerminateOnIdleStdin = object.noTerminateOnIdleStdin ?? false;
|
|
26771
26847
|
return message;
|
|
26772
26848
|
}
|
|
26773
26849
|
};
|
|
@@ -30264,6 +30340,142 @@ var Sandbox_ExperimentalOptionsEntry = {
|
|
|
30264
30340
|
return message;
|
|
30265
30341
|
}
|
|
30266
30342
|
};
|
|
30343
|
+
function createBaseSandboxCreateConnectTokenRequest() {
|
|
30344
|
+
return { sandboxId: "", metadata: "" };
|
|
30345
|
+
}
|
|
30346
|
+
var SandboxCreateConnectTokenRequest = {
|
|
30347
|
+
encode(message, writer = new BinaryWriter()) {
|
|
30348
|
+
if (message.sandboxId !== "") {
|
|
30349
|
+
writer.uint32(10).string(message.sandboxId);
|
|
30350
|
+
}
|
|
30351
|
+
if (message.metadata !== "") {
|
|
30352
|
+
writer.uint32(18).string(message.metadata);
|
|
30353
|
+
}
|
|
30354
|
+
return writer;
|
|
30355
|
+
},
|
|
30356
|
+
decode(input, length) {
|
|
30357
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
30358
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
30359
|
+
const message = createBaseSandboxCreateConnectTokenRequest();
|
|
30360
|
+
while (reader.pos < end) {
|
|
30361
|
+
const tag = reader.uint32();
|
|
30362
|
+
switch (tag >>> 3) {
|
|
30363
|
+
case 1: {
|
|
30364
|
+
if (tag !== 10) {
|
|
30365
|
+
break;
|
|
30366
|
+
}
|
|
30367
|
+
message.sandboxId = reader.string();
|
|
30368
|
+
continue;
|
|
30369
|
+
}
|
|
30370
|
+
case 2: {
|
|
30371
|
+
if (tag !== 18) {
|
|
30372
|
+
break;
|
|
30373
|
+
}
|
|
30374
|
+
message.metadata = reader.string();
|
|
30375
|
+
continue;
|
|
30376
|
+
}
|
|
30377
|
+
}
|
|
30378
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
30379
|
+
break;
|
|
30380
|
+
}
|
|
30381
|
+
reader.skip(tag & 7);
|
|
30382
|
+
}
|
|
30383
|
+
return message;
|
|
30384
|
+
},
|
|
30385
|
+
fromJSON(object) {
|
|
30386
|
+
return {
|
|
30387
|
+
sandboxId: isSet3(object.sandboxId) ? globalThis.String(object.sandboxId) : "",
|
|
30388
|
+
metadata: isSet3(object.metadata) ? globalThis.String(object.metadata) : ""
|
|
30389
|
+
};
|
|
30390
|
+
},
|
|
30391
|
+
toJSON(message) {
|
|
30392
|
+
const obj = {};
|
|
30393
|
+
if (message.sandboxId !== "") {
|
|
30394
|
+
obj.sandboxId = message.sandboxId;
|
|
30395
|
+
}
|
|
30396
|
+
if (message.metadata !== "") {
|
|
30397
|
+
obj.metadata = message.metadata;
|
|
30398
|
+
}
|
|
30399
|
+
return obj;
|
|
30400
|
+
},
|
|
30401
|
+
create(base) {
|
|
30402
|
+
return SandboxCreateConnectTokenRequest.fromPartial(base ?? {});
|
|
30403
|
+
},
|
|
30404
|
+
fromPartial(object) {
|
|
30405
|
+
const message = createBaseSandboxCreateConnectTokenRequest();
|
|
30406
|
+
message.sandboxId = object.sandboxId ?? "";
|
|
30407
|
+
message.metadata = object.metadata ?? "";
|
|
30408
|
+
return message;
|
|
30409
|
+
}
|
|
30410
|
+
};
|
|
30411
|
+
function createBaseSandboxCreateConnectTokenResponse() {
|
|
30412
|
+
return { url: "", token: "" };
|
|
30413
|
+
}
|
|
30414
|
+
var SandboxCreateConnectTokenResponse = {
|
|
30415
|
+
encode(message, writer = new BinaryWriter()) {
|
|
30416
|
+
if (message.url !== "") {
|
|
30417
|
+
writer.uint32(10).string(message.url);
|
|
30418
|
+
}
|
|
30419
|
+
if (message.token !== "") {
|
|
30420
|
+
writer.uint32(18).string(message.token);
|
|
30421
|
+
}
|
|
30422
|
+
return writer;
|
|
30423
|
+
},
|
|
30424
|
+
decode(input, length) {
|
|
30425
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
30426
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
30427
|
+
const message = createBaseSandboxCreateConnectTokenResponse();
|
|
30428
|
+
while (reader.pos < end) {
|
|
30429
|
+
const tag = reader.uint32();
|
|
30430
|
+
switch (tag >>> 3) {
|
|
30431
|
+
case 1: {
|
|
30432
|
+
if (tag !== 10) {
|
|
30433
|
+
break;
|
|
30434
|
+
}
|
|
30435
|
+
message.url = reader.string();
|
|
30436
|
+
continue;
|
|
30437
|
+
}
|
|
30438
|
+
case 2: {
|
|
30439
|
+
if (tag !== 18) {
|
|
30440
|
+
break;
|
|
30441
|
+
}
|
|
30442
|
+
message.token = reader.string();
|
|
30443
|
+
continue;
|
|
30444
|
+
}
|
|
30445
|
+
}
|
|
30446
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
30447
|
+
break;
|
|
30448
|
+
}
|
|
30449
|
+
reader.skip(tag & 7);
|
|
30450
|
+
}
|
|
30451
|
+
return message;
|
|
30452
|
+
},
|
|
30453
|
+
fromJSON(object) {
|
|
30454
|
+
return {
|
|
30455
|
+
url: isSet3(object.url) ? globalThis.String(object.url) : "",
|
|
30456
|
+
token: isSet3(object.token) ? globalThis.String(object.token) : ""
|
|
30457
|
+
};
|
|
30458
|
+
},
|
|
30459
|
+
toJSON(message) {
|
|
30460
|
+
const obj = {};
|
|
30461
|
+
if (message.url !== "") {
|
|
30462
|
+
obj.url = message.url;
|
|
30463
|
+
}
|
|
30464
|
+
if (message.token !== "") {
|
|
30465
|
+
obj.token = message.token;
|
|
30466
|
+
}
|
|
30467
|
+
return obj;
|
|
30468
|
+
},
|
|
30469
|
+
create(base) {
|
|
30470
|
+
return SandboxCreateConnectTokenResponse.fromPartial(base ?? {});
|
|
30471
|
+
},
|
|
30472
|
+
fromPartial(object) {
|
|
30473
|
+
const message = createBaseSandboxCreateConnectTokenResponse();
|
|
30474
|
+
message.url = object.url ?? "";
|
|
30475
|
+
message.token = object.token ?? "";
|
|
30476
|
+
return message;
|
|
30477
|
+
}
|
|
30478
|
+
};
|
|
30267
30479
|
function createBaseSandboxCreateRequest() {
|
|
30268
30480
|
return { appId: "", definition: void 0, environmentName: "" };
|
|
30269
30481
|
}
|
|
@@ -40867,6 +41079,14 @@ var ModalClientDefinition = {
|
|
|
40867
41079
|
responseStream: false,
|
|
40868
41080
|
options: {}
|
|
40869
41081
|
},
|
|
41082
|
+
sandboxCreateConnectToken: {
|
|
41083
|
+
name: "SandboxCreateConnectToken",
|
|
41084
|
+
requestType: SandboxCreateConnectTokenRequest,
|
|
41085
|
+
requestStream: false,
|
|
41086
|
+
responseType: SandboxCreateConnectTokenResponse,
|
|
41087
|
+
responseStream: false,
|
|
41088
|
+
options: {}
|
|
41089
|
+
},
|
|
40870
41090
|
sandboxGetFromName: {
|
|
40871
41091
|
name: "SandboxGetFromName",
|
|
40872
41092
|
requestType: SandboxGetFromNameRequest,
|
|
@@ -42183,6 +42403,33 @@ var Tunnel = class {
|
|
|
42183
42403
|
return [this.unencryptedHost, this.unencryptedPort];
|
|
42184
42404
|
}
|
|
42185
42405
|
};
|
|
42406
|
+
function defaultSandboxPTYInfo() {
|
|
42407
|
+
return PTYInfo.create({
|
|
42408
|
+
enabled: true,
|
|
42409
|
+
winszRows: 24,
|
|
42410
|
+
winszCols: 80,
|
|
42411
|
+
envTerm: "xterm-256color",
|
|
42412
|
+
envColorterm: "truecolor",
|
|
42413
|
+
envTermProgram: "",
|
|
42414
|
+
ptyType: 2 /* PTY_TYPE_SHELL */,
|
|
42415
|
+
noTerminateOnIdleStdin: true
|
|
42416
|
+
});
|
|
42417
|
+
}
|
|
42418
|
+
function containerExecRequestProto(taskId, command, options) {
|
|
42419
|
+
const secretIds = options?.secrets ? options.secrets.map((secret) => secret.secretId) : [];
|
|
42420
|
+
let ptyInfo;
|
|
42421
|
+
if (options?.pty) {
|
|
42422
|
+
ptyInfo = defaultSandboxPTYInfo();
|
|
42423
|
+
}
|
|
42424
|
+
return ContainerExecRequest.create({
|
|
42425
|
+
taskId,
|
|
42426
|
+
command,
|
|
42427
|
+
workdir: options?.workdir,
|
|
42428
|
+
timeoutSecs: options?.timeout ? options.timeout / 1e3 : 0,
|
|
42429
|
+
secretIds,
|
|
42430
|
+
ptyInfo
|
|
42431
|
+
});
|
|
42432
|
+
}
|
|
42186
42433
|
var Sandbox2 = class _Sandbox {
|
|
42187
42434
|
sandboxId;
|
|
42188
42435
|
stdin;
|
|
@@ -42287,14 +42534,8 @@ var Sandbox2 = class _Sandbox {
|
|
|
42287
42534
|
}
|
|
42288
42535
|
async exec(command, options) {
|
|
42289
42536
|
const taskId = await this.#getTaskId();
|
|
42290
|
-
const
|
|
42291
|
-
const resp = await client.containerExec(
|
|
42292
|
-
taskId,
|
|
42293
|
-
command,
|
|
42294
|
-
workdir: options?.workdir,
|
|
42295
|
-
timeoutSecs: options?.timeout ? options.timeout / 1e3 : 0,
|
|
42296
|
-
secretIds
|
|
42297
|
-
});
|
|
42537
|
+
const req = containerExecRequestProto(taskId, command, options);
|
|
42538
|
+
const resp = await client.containerExec(req);
|
|
42298
42539
|
return new ContainerProcess(resp.execId, options);
|
|
42299
42540
|
}
|
|
42300
42541
|
async #getTaskId() {
|
|
@@ -42681,6 +42922,117 @@ function parseGpuConfig(gpu) {
|
|
|
42681
42922
|
gpuType: gpuType.toUpperCase()
|
|
42682
42923
|
};
|
|
42683
42924
|
}
|
|
42925
|
+
function sandboxCreateRequestProto(appId, imageId, options = {}) {
|
|
42926
|
+
const gpuConfig = parseGpuConfig(options.gpu);
|
|
42927
|
+
if (options.timeout && options.timeout % 1e3 !== 0) {
|
|
42928
|
+
throw new Error(
|
|
42929
|
+
`timeout must be a multiple of 1000ms, got ${options.timeout}`
|
|
42930
|
+
);
|
|
42931
|
+
}
|
|
42932
|
+
if (options.idleTimeout && options.idleTimeout % 1e3 !== 0) {
|
|
42933
|
+
throw new Error(
|
|
42934
|
+
`idleTimeout must be a multiple of 1000ms, got ${options.idleTimeout}`
|
|
42935
|
+
);
|
|
42936
|
+
}
|
|
42937
|
+
if (options.workdir && !options.workdir.startsWith("/")) {
|
|
42938
|
+
throw new Error(
|
|
42939
|
+
`workdir must be an absolute path, got: ${options.workdir}`
|
|
42940
|
+
);
|
|
42941
|
+
}
|
|
42942
|
+
const volumeMounts = options.volumes ? Object.entries(options.volumes).map(([mountPath, volume]) => ({
|
|
42943
|
+
volumeId: volume.volumeId,
|
|
42944
|
+
mountPath,
|
|
42945
|
+
allowBackgroundCommits: true,
|
|
42946
|
+
readOnly: volume.isReadOnly
|
|
42947
|
+
})) : [];
|
|
42948
|
+
const cloudBucketMounts = options.cloudBucketMounts ? Object.entries(options.cloudBucketMounts).map(
|
|
42949
|
+
([mountPath, mount]) => cloudBucketMountToProto(mount, mountPath)
|
|
42950
|
+
) : [];
|
|
42951
|
+
const openPorts = [];
|
|
42952
|
+
if (options.encryptedPorts) {
|
|
42953
|
+
openPorts.push(
|
|
42954
|
+
...options.encryptedPorts.map((port) => ({
|
|
42955
|
+
port,
|
|
42956
|
+
unencrypted: false
|
|
42957
|
+
}))
|
|
42958
|
+
);
|
|
42959
|
+
}
|
|
42960
|
+
if (options.h2Ports) {
|
|
42961
|
+
openPorts.push(
|
|
42962
|
+
...options.h2Ports.map((port) => ({
|
|
42963
|
+
port,
|
|
42964
|
+
unencrypted: false,
|
|
42965
|
+
tunnelType: 1 /* TUNNEL_TYPE_H2 */
|
|
42966
|
+
}))
|
|
42967
|
+
);
|
|
42968
|
+
}
|
|
42969
|
+
if (options.unencryptedPorts) {
|
|
42970
|
+
openPorts.push(
|
|
42971
|
+
...options.unencryptedPorts.map((port) => ({
|
|
42972
|
+
port,
|
|
42973
|
+
unencrypted: true
|
|
42974
|
+
}))
|
|
42975
|
+
);
|
|
42976
|
+
}
|
|
42977
|
+
const secretIds = options.secrets ? options.secrets.map((secret) => secret.secretId) : [];
|
|
42978
|
+
let networkAccess;
|
|
42979
|
+
if (options.blockNetwork) {
|
|
42980
|
+
if (options.cidrAllowlist) {
|
|
42981
|
+
throw new Error(
|
|
42982
|
+
"cidrAllowlist cannot be used when blockNetwork is enabled"
|
|
42983
|
+
);
|
|
42984
|
+
}
|
|
42985
|
+
networkAccess = {
|
|
42986
|
+
networkAccessType: 2 /* BLOCKED */,
|
|
42987
|
+
allowedCidrs: []
|
|
42988
|
+
};
|
|
42989
|
+
} else if (options.cidrAllowlist) {
|
|
42990
|
+
networkAccess = {
|
|
42991
|
+
networkAccessType: 3 /* ALLOWLIST */,
|
|
42992
|
+
allowedCidrs: options.cidrAllowlist
|
|
42993
|
+
};
|
|
42994
|
+
} else {
|
|
42995
|
+
networkAccess = {
|
|
42996
|
+
networkAccessType: 1 /* OPEN */,
|
|
42997
|
+
allowedCidrs: []
|
|
42998
|
+
};
|
|
42999
|
+
}
|
|
43000
|
+
const schedulerPlacement = SchedulerPlacement.create({
|
|
43001
|
+
regions: options.regions ?? []
|
|
43002
|
+
});
|
|
43003
|
+
let ptyInfo;
|
|
43004
|
+
if (options.pty) {
|
|
43005
|
+
ptyInfo = defaultSandboxPTYInfo();
|
|
43006
|
+
}
|
|
43007
|
+
return SandboxCreateRequest.create({
|
|
43008
|
+
appId,
|
|
43009
|
+
definition: {
|
|
43010
|
+
// Sleep default is implicit in image builder version <=2024.10
|
|
43011
|
+
entrypointArgs: options.command ?? ["sleep", "48h"],
|
|
43012
|
+
imageId,
|
|
43013
|
+
timeoutSecs: options.timeout != void 0 ? options.timeout / 1e3 : 600,
|
|
43014
|
+
idleTimeoutSecs: options.idleTimeout != void 0 ? options.idleTimeout / 1e3 : void 0,
|
|
43015
|
+
workdir: options.workdir ?? void 0,
|
|
43016
|
+
networkAccess,
|
|
43017
|
+
resources: {
|
|
43018
|
+
// https://modal.com/docs/guide/resources
|
|
43019
|
+
milliCpu: Math.round(1e3 * (options.cpu ?? 0.125)),
|
|
43020
|
+
memoryMb: options.memory ?? 128,
|
|
43021
|
+
gpuConfig
|
|
43022
|
+
},
|
|
43023
|
+
volumeMounts,
|
|
43024
|
+
cloudBucketMounts,
|
|
43025
|
+
ptyInfo,
|
|
43026
|
+
secretIds,
|
|
43027
|
+
openPorts: openPorts.length > 0 ? { ports: openPorts } : void 0,
|
|
43028
|
+
cloudProviderStr: options.cloud ?? "",
|
|
43029
|
+
schedulerPlacement,
|
|
43030
|
+
verbose: options.verbose ?? false,
|
|
43031
|
+
proxyId: options.proxy?.proxyId,
|
|
43032
|
+
name: options.name
|
|
43033
|
+
}
|
|
43034
|
+
});
|
|
43035
|
+
}
|
|
42684
43036
|
var App2 = class _App {
|
|
42685
43037
|
appId;
|
|
42686
43038
|
name;
|
|
@@ -42705,113 +43057,15 @@ var App2 = class _App {
|
|
|
42705
43057
|
}
|
|
42706
43058
|
}
|
|
42707
43059
|
async createSandbox(image, options = {}) {
|
|
42708
|
-
const gpuConfig = parseGpuConfig(options.gpu);
|
|
42709
|
-
if (options.timeout && options.timeout % 1e3 !== 0) {
|
|
42710
|
-
throw new Error(
|
|
42711
|
-
`timeout must be a multiple of 1000ms, got ${options.timeout}`
|
|
42712
|
-
);
|
|
42713
|
-
}
|
|
42714
|
-
if (options.idleTimeout && options.idleTimeout % 1e3 !== 0) {
|
|
42715
|
-
throw new Error(
|
|
42716
|
-
`idleTimeout must be a multiple of 1000ms, got ${options.idleTimeout}`
|
|
42717
|
-
);
|
|
42718
|
-
}
|
|
42719
43060
|
await image.build(this);
|
|
42720
|
-
|
|
42721
|
-
|
|
42722
|
-
|
|
42723
|
-
|
|
42724
|
-
|
|
42725
|
-
const volumeMounts = options.volumes ? Object.entries(options.volumes).map(([mountPath, volume]) => ({
|
|
42726
|
-
volumeId: volume.volumeId,
|
|
42727
|
-
mountPath,
|
|
42728
|
-
allowBackgroundCommits: true,
|
|
42729
|
-
readOnly: volume.isReadOnly
|
|
42730
|
-
})) : [];
|
|
42731
|
-
const cloudBucketMounts = options.cloudBucketMounts ? Object.entries(options.cloudBucketMounts).map(
|
|
42732
|
-
([mountPath, mount]) => cloudBucketMountToProto(mount, mountPath)
|
|
42733
|
-
) : [];
|
|
42734
|
-
const openPorts = [];
|
|
42735
|
-
if (options.encryptedPorts) {
|
|
42736
|
-
openPorts.push(
|
|
42737
|
-
...options.encryptedPorts.map((port) => ({
|
|
42738
|
-
port,
|
|
42739
|
-
unencrypted: false
|
|
42740
|
-
}))
|
|
42741
|
-
);
|
|
42742
|
-
}
|
|
42743
|
-
if (options.h2Ports) {
|
|
42744
|
-
openPorts.push(
|
|
42745
|
-
...options.h2Ports.map((port) => ({
|
|
42746
|
-
port,
|
|
42747
|
-
unencrypted: false,
|
|
42748
|
-
tunnelType: 1 /* TUNNEL_TYPE_H2 */
|
|
42749
|
-
}))
|
|
42750
|
-
);
|
|
42751
|
-
}
|
|
42752
|
-
if (options.unencryptedPorts) {
|
|
42753
|
-
openPorts.push(
|
|
42754
|
-
...options.unencryptedPorts.map((port) => ({
|
|
42755
|
-
port,
|
|
42756
|
-
unencrypted: true
|
|
42757
|
-
}))
|
|
42758
|
-
);
|
|
42759
|
-
}
|
|
42760
|
-
const secretIds = options.secrets ? options.secrets.map((secret) => secret.secretId) : [];
|
|
42761
|
-
let networkAccess;
|
|
42762
|
-
if (options.blockNetwork) {
|
|
42763
|
-
if (options.cidrAllowlist) {
|
|
42764
|
-
throw new Error(
|
|
42765
|
-
"cidrAllowlist cannot be used when blockNetwork is enabled"
|
|
42766
|
-
);
|
|
42767
|
-
}
|
|
42768
|
-
networkAccess = {
|
|
42769
|
-
networkAccessType: 2 /* BLOCKED */,
|
|
42770
|
-
allowedCidrs: []
|
|
42771
|
-
};
|
|
42772
|
-
} else if (options.cidrAllowlist) {
|
|
42773
|
-
networkAccess = {
|
|
42774
|
-
networkAccessType: 3 /* ALLOWLIST */,
|
|
42775
|
-
allowedCidrs: options.cidrAllowlist
|
|
42776
|
-
};
|
|
42777
|
-
} else {
|
|
42778
|
-
networkAccess = {
|
|
42779
|
-
networkAccessType: 1 /* OPEN */,
|
|
42780
|
-
allowedCidrs: []
|
|
42781
|
-
};
|
|
42782
|
-
}
|
|
42783
|
-
const schedulerPlacement = SchedulerPlacement.create({
|
|
42784
|
-
regions: options.regions ?? []
|
|
42785
|
-
});
|
|
43061
|
+
const createReq = sandboxCreateRequestProto(
|
|
43062
|
+
this.appId,
|
|
43063
|
+
image.imageId,
|
|
43064
|
+
options
|
|
43065
|
+
);
|
|
42786
43066
|
let createResp;
|
|
42787
43067
|
try {
|
|
42788
|
-
createResp = await client.sandboxCreate(
|
|
42789
|
-
appId: this.appId,
|
|
42790
|
-
definition: {
|
|
42791
|
-
// Sleep default is implicit in image builder version <=2024.10
|
|
42792
|
-
entrypointArgs: options.command ?? ["sleep", "48h"],
|
|
42793
|
-
imageId: image.imageId,
|
|
42794
|
-
timeoutSecs: options.timeout != void 0 ? options.timeout / 1e3 : 600,
|
|
42795
|
-
idleTimeoutSecs: options.idleTimeout != void 0 ? options.idleTimeout / 1e3 : void 0,
|
|
42796
|
-
workdir: options.workdir ?? void 0,
|
|
42797
|
-
networkAccess,
|
|
42798
|
-
resources: {
|
|
42799
|
-
// https://modal.com/docs/guide/resources
|
|
42800
|
-
milliCpu: Math.round(1e3 * (options.cpu ?? 0.125)),
|
|
42801
|
-
memoryMb: options.memory ?? 128,
|
|
42802
|
-
gpuConfig
|
|
42803
|
-
},
|
|
42804
|
-
volumeMounts,
|
|
42805
|
-
cloudBucketMounts,
|
|
42806
|
-
secretIds,
|
|
42807
|
-
openPorts: openPorts.length > 0 ? { ports: openPorts } : void 0,
|
|
42808
|
-
cloudProviderStr: options.cloud ?? "",
|
|
42809
|
-
schedulerPlacement,
|
|
42810
|
-
verbose: options.verbose ?? false,
|
|
42811
|
-
proxyId: options.proxy?.proxyId,
|
|
42812
|
-
name: options.name
|
|
42813
|
-
}
|
|
42814
|
-
});
|
|
43068
|
+
createResp = await client.sandboxCreate(createReq);
|
|
42815
43069
|
} catch (err) {
|
|
42816
43070
|
if (err instanceof ClientError5 && err.code === Status5.ALREADY_EXISTS) {
|
|
42817
43071
|
throw new AlreadyExistsError(err.details || err.message);
|