gigadrive 2.10.1 → 2.12.0
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/README.md +1 -0
- package/dist/index.cjs +73 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +73 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { Effect as Effect29, Layer, LogLevel, Logger } from "effect";
|
|
|
9
9
|
// package.json
|
|
10
10
|
var package_default = {
|
|
11
11
|
name: "gigadrive",
|
|
12
|
-
version: "2.
|
|
12
|
+
version: "2.12.0",
|
|
13
13
|
repository: {
|
|
14
14
|
type: "git",
|
|
15
15
|
url: "https://github.com/Gigadrive/sdk.git",
|
|
@@ -3062,7 +3062,7 @@ var describeMicroVm = (vm, now = Date.now()) => {
|
|
|
3062
3062
|
`Image: ${vm.image.name}`,
|
|
3063
3063
|
`Size: ${vm.vcpus} vCPU, ${formatMemory(vm.memoryMb)} memory, ${formatMemory(vm.diskMb)} disk`,
|
|
3064
3064
|
`Region: ${vm.region}`,
|
|
3065
|
-
`Network: ${vm.network.egress === "deny" ? "outbound traffic blocked" : vm.network.allow && vm.network.allow.length > 0 ? `only ${vm.network.allow.join(", ")}
|
|
3065
|
+
`Network: ${vm.network.egress === "deny" ? "outbound traffic blocked" : vm.network.allow && vm.network.allow.length > 0 ? `only ${vm.network.allow.join(", ")}` : "internet access"}`,
|
|
3066
3066
|
`Previews: ${vm.network.previews === "private" ? "private (preview token required)" : "public"}`,
|
|
3067
3067
|
`Application: ${vm.applicationId}`,
|
|
3068
3068
|
`Created: ${vm.createdAt}`
|
|
@@ -3323,27 +3323,32 @@ var withClient = (run) => Effect22.gen(function* () {
|
|
|
3323
3323
|
return yield* Effect22.tryPromise({ try: () => run(client), catch: toApiRequestError });
|
|
3324
3324
|
});
|
|
3325
3325
|
var signalOnInterrupt = (signal) => (command, exit) => Exit.isInterrupted(exit) ? Effect22.tryPromise(() => command.kill(signal)).pipe(Effect22.timeout("2 seconds"), Effect22.ignore) : Effect22.void;
|
|
3326
|
-
var
|
|
3327
|
-
|
|
3328
|
-
const metadata = yield* keyValues("--metadata", flags.metadata);
|
|
3329
|
-
const timeoutMs = yield* Option14.match(flags.timeout, {
|
|
3330
|
-
onNone: () => Effect22.succeed(void 0),
|
|
3331
|
-
onSome: (text) => parseLifetime("--timeout", text)
|
|
3332
|
-
});
|
|
3333
|
-
if (flags.denyEgress && flags.allowEgress.length > 0) {
|
|
3326
|
+
var checkEgressFlags = (denyEgress, allowEgress) => Effect22.gen(function* () {
|
|
3327
|
+
if (denyEgress && allowEgress.length > 0) {
|
|
3334
3328
|
return yield* new InvalidMicroVmOptionsError({
|
|
3335
3329
|
message: "--allow-egress cannot be combined with --deny-egress."
|
|
3336
3330
|
});
|
|
3337
3331
|
}
|
|
3338
|
-
if (
|
|
3339
|
-
return yield* new InvalidMicroVmOptionsError({ message: "--allow-egress takes at most 32
|
|
3332
|
+
if (allowEgress.length > 32) {
|
|
3333
|
+
return yield* new InvalidMicroVmOptionsError({ message: "--allow-egress takes at most 32 entries." });
|
|
3340
3334
|
}
|
|
3341
|
-
const
|
|
3342
|
-
|
|
3335
|
+
const network = /^\d{1,3}(\.\d{1,3}){3}\/\d{1,2}$/;
|
|
3336
|
+
const domain = /^(\*\.)?([a-z0-9-]+\.)+[a-z0-9-]*[a-z][a-z0-9-]*\.?$/i;
|
|
3337
|
+
const badEntry = allowEgress.find((entry) => !network.test(entry.trim()) && !domain.test(entry.trim()));
|
|
3338
|
+
if (badEntry !== void 0) {
|
|
3343
3339
|
return yield* new InvalidMicroVmOptionsError({
|
|
3344
|
-
message: `--allow-egress must be an IPv4 network such as 140.82.112.0/20 (got ${
|
|
3340
|
+
message: `--allow-egress must be a domain name such as api.openai.com or *.github.com, or an IPv4 network such as 140.82.112.0/20 (got ${badEntry}).`
|
|
3345
3341
|
});
|
|
3346
3342
|
}
|
|
3343
|
+
});
|
|
3344
|
+
var createInput = (flags) => Effect22.gen(function* () {
|
|
3345
|
+
const env = yield* keyValues("--env", flags.env);
|
|
3346
|
+
const metadata = yield* keyValues("--metadata", flags.metadata);
|
|
3347
|
+
const timeoutMs = yield* Option14.match(flags.timeout, {
|
|
3348
|
+
onNone: () => Effect22.succeed(void 0),
|
|
3349
|
+
onSome: (text) => parseLifetime("--timeout", text)
|
|
3350
|
+
});
|
|
3351
|
+
yield* checkEgressFlags(flags.denyEgress, flags.allowEgress);
|
|
3347
3352
|
const badPort = flags.ports.find((port) => !Number.isInteger(port) || port < 1 || port > 65535);
|
|
3348
3353
|
if (badPort !== void 0) {
|
|
3349
3354
|
return yield* new InvalidMicroVmOptionsError({ message: `--port must be between 1 and 65535 (got ${badPort}).` });
|
|
@@ -3359,6 +3364,8 @@ var createInput = (flags) => Effect22.gen(function* () {
|
|
|
3359
3364
|
...Option14.match(flags.memory, { onNone: () => ({}), onSome: (memoryMb) => ({ memoryMb }) }),
|
|
3360
3365
|
...Option14.match(flags.disk, { onNone: () => ({}), onSome: (diskMb) => ({ diskMb }) }),
|
|
3361
3366
|
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
3367
|
+
...flags.pauseOnTimeout ? { onTimeout: "pause" } : {},
|
|
3368
|
+
...flags.autoResume ? { autoResume: true } : {},
|
|
3362
3369
|
...flags.ports.length > 0 ? { ports: [...flags.ports] } : {},
|
|
3363
3370
|
...env ? { env } : {},
|
|
3364
3371
|
...metadata ? { metadata } : {},
|
|
@@ -3366,7 +3373,7 @@ var createInput = (flags) => Effect22.gen(function* () {
|
|
|
3366
3373
|
network: {
|
|
3367
3374
|
egress: flags.denyEgress ? "deny" : "allow",
|
|
3368
3375
|
...flags.privatePreviews ? { previews: "private" } : {},
|
|
3369
|
-
...flags.allowEgress.length > 0 ? { allow:
|
|
3376
|
+
...flags.allowEgress.length > 0 ? { allow: flags.allowEgress.map((entry) => entry.trim()) } : {}
|
|
3370
3377
|
}
|
|
3371
3378
|
} : {},
|
|
3372
3379
|
...Option14.match(flags.region, { onNone: () => ({}), onSome: (region) => ({ region }) })
|
|
@@ -3434,10 +3441,18 @@ var createCommand = Command12.make(
|
|
|
3434
3441
|
),
|
|
3435
3442
|
allowEgress: Options7.text("allow-egress").pipe(
|
|
3436
3443
|
Options7.withDescription(
|
|
3437
|
-
"Only reach this public IPv4 network
|
|
3444
|
+
"Only reach this domain name (api.openai.com, *.github.com for every subdomain) or public IPv4 network (140.82.112.0/20) (repeatable, up to 32)"
|
|
3438
3445
|
),
|
|
3439
3446
|
Options7.repeated
|
|
3440
3447
|
),
|
|
3448
|
+
pauseOnTimeout: Options7.boolean("pause-on-timeout").pipe(
|
|
3449
|
+
Options7.withDescription("Pause the microVM when its timeout ends instead of stopping it")
|
|
3450
|
+
),
|
|
3451
|
+
autoResume: Options7.boolean("auto-resume").pipe(
|
|
3452
|
+
Options7.withDescription(
|
|
3453
|
+
"Resume the paused microVM when a command, file call or public preview request reaches it"
|
|
3454
|
+
)
|
|
3455
|
+
),
|
|
3441
3456
|
region: Options7.text("region").pipe(Options7.withDescription("Region to place the microVM in"), Options7.optional),
|
|
3442
3457
|
json: jsonOption2
|
|
3443
3458
|
},
|
|
@@ -3754,6 +3769,46 @@ var extendCommand = Command12.make(
|
|
|
3754
3769
|
},
|
|
3755
3770
|
({ microvmId, duration }) => extendMicroVm(microvmId, duration).pipe(Effect22.asVoid, reportErrors2("extend the microVM"))
|
|
3756
3771
|
).pipe(Command12.withDescription("Set how long a microVM keeps running, counted from now"));
|
|
3772
|
+
var updateMicroVmNetwork = (microvmId, flags) => Effect22.gen(function* () {
|
|
3773
|
+
const chosen = [flags.denyEgress, flags.allowEgress.length > 0, flags.allowAllEgress].filter(Boolean).length;
|
|
3774
|
+
if (chosen !== 1) {
|
|
3775
|
+
return yield* new InvalidMicroVmOptionsError({
|
|
3776
|
+
message: "Pass exactly one of --deny-egress, --allow-egress or --allow-all-egress."
|
|
3777
|
+
});
|
|
3778
|
+
}
|
|
3779
|
+
yield* checkEgressFlags(flags.denyEgress, flags.allowEgress);
|
|
3780
|
+
const apiClient = yield* ApiClientService;
|
|
3781
|
+
const vm = yield* apiClient.request(
|
|
3782
|
+
(client) => client.microvms.updateNetwork(
|
|
3783
|
+
microvmId,
|
|
3784
|
+
flags.denyEgress ? { egress: "deny" } : flags.allowEgress.length > 0 ? { egress: "allow", allow: flags.allowEgress.map((entry) => entry.trim()) } : { egress: "allow" }
|
|
3785
|
+
)
|
|
3786
|
+
);
|
|
3787
|
+
const reach = vm.network.egress === "deny" ? "no outbound traffic" : vm.network.allow ? vm.network.allow.join(", ") : "the whole internet";
|
|
3788
|
+
yield* Console12.log(`${vm.id} now reaches ${reach}.`);
|
|
3789
|
+
return vm;
|
|
3790
|
+
});
|
|
3791
|
+
var networkCommand = Command12.make(
|
|
3792
|
+
"network",
|
|
3793
|
+
{
|
|
3794
|
+
microvmId: microvmIdArg,
|
|
3795
|
+
denyEgress: Options7.boolean("deny-egress").pipe(Options7.withDescription("Block all outbound network traffic")),
|
|
3796
|
+
allowEgress: Options7.text("allow-egress").pipe(
|
|
3797
|
+
Options7.withDescription(
|
|
3798
|
+
"Only reach this domain name (api.openai.com, *.github.com for every subdomain) or public IPv4 network (140.82.112.0/20) (repeatable, up to 32)"
|
|
3799
|
+
),
|
|
3800
|
+
Options7.repeated
|
|
3801
|
+
),
|
|
3802
|
+
allowAllEgress: Options7.boolean("allow-all-egress").pipe(
|
|
3803
|
+
Options7.withDescription("Reach the whole internet again (private networks stay blocked)")
|
|
3804
|
+
)
|
|
3805
|
+
},
|
|
3806
|
+
({ microvmId, ...flags }) => updateMicroVmNetwork(microvmId, flags).pipe(Effect22.asVoid, reportErrors2("update the microVM network"))
|
|
3807
|
+
).pipe(
|
|
3808
|
+
Command12.withDescription(
|
|
3809
|
+
"Change what a running or paused microVM may reach; connections the new rules no longer allow are closed"
|
|
3810
|
+
)
|
|
3811
|
+
);
|
|
3757
3812
|
var imagesListCommand = Command12.make(
|
|
3758
3813
|
"ls",
|
|
3759
3814
|
{ app: appOption6, json: jsonOption2 },
|
|
@@ -3860,6 +3915,7 @@ var SUBCOMMANDS = [
|
|
|
3860
3915
|
stopCommand,
|
|
3861
3916
|
removeCommand2,
|
|
3862
3917
|
extendCommand,
|
|
3918
|
+
networkCommand,
|
|
3863
3919
|
imagesCommand
|
|
3864
3920
|
];
|
|
3865
3921
|
var microvmsCommand = Command12.make("microvms", {}, () => Effect22.void).pipe(
|