gigadrive 2.11.0 → 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 +66 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +66 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
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",
|
|
@@ -3323,29 +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 (
|
|
3332
|
+
if (allowEgress.length > 32) {
|
|
3339
3333
|
return yield* new InvalidMicroVmOptionsError({ message: "--allow-egress takes at most 32 entries." });
|
|
3340
3334
|
}
|
|
3341
3335
|
const network = /^\d{1,3}(\.\d{1,3}){3}\/\d{1,2}$/;
|
|
3342
3336
|
const domain = /^(\*\.)?([a-z0-9-]+\.)+[a-z0-9-]*[a-z][a-z0-9-]*\.?$/i;
|
|
3343
|
-
const badEntry =
|
|
3337
|
+
const badEntry = allowEgress.find((entry) => !network.test(entry.trim()) && !domain.test(entry.trim()));
|
|
3344
3338
|
if (badEntry !== void 0) {
|
|
3345
3339
|
return yield* new InvalidMicroVmOptionsError({
|
|
3346
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}).`
|
|
3347
3341
|
});
|
|
3348
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);
|
|
3349
3352
|
const badPort = flags.ports.find((port) => !Number.isInteger(port) || port < 1 || port > 65535);
|
|
3350
3353
|
if (badPort !== void 0) {
|
|
3351
3354
|
return yield* new InvalidMicroVmOptionsError({ message: `--port must be between 1 and 65535 (got ${badPort}).` });
|
|
@@ -3361,6 +3364,8 @@ var createInput = (flags) => Effect22.gen(function* () {
|
|
|
3361
3364
|
...Option14.match(flags.memory, { onNone: () => ({}), onSome: (memoryMb) => ({ memoryMb }) }),
|
|
3362
3365
|
...Option14.match(flags.disk, { onNone: () => ({}), onSome: (diskMb) => ({ diskMb }) }),
|
|
3363
3366
|
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
3367
|
+
...flags.pauseOnTimeout ? { onTimeout: "pause" } : {},
|
|
3368
|
+
...flags.autoResume ? { autoResume: true } : {},
|
|
3364
3369
|
...flags.ports.length > 0 ? { ports: [...flags.ports] } : {},
|
|
3365
3370
|
...env ? { env } : {},
|
|
3366
3371
|
...metadata ? { metadata } : {},
|
|
@@ -3368,7 +3373,7 @@ var createInput = (flags) => Effect22.gen(function* () {
|
|
|
3368
3373
|
network: {
|
|
3369
3374
|
egress: flags.denyEgress ? "deny" : "allow",
|
|
3370
3375
|
...flags.privatePreviews ? { previews: "private" } : {},
|
|
3371
|
-
...flags.allowEgress.length > 0 ? { allow:
|
|
3376
|
+
...flags.allowEgress.length > 0 ? { allow: flags.allowEgress.map((entry) => entry.trim()) } : {}
|
|
3372
3377
|
}
|
|
3373
3378
|
} : {},
|
|
3374
3379
|
...Option14.match(flags.region, { onNone: () => ({}), onSome: (region) => ({ region }) })
|
|
@@ -3440,6 +3445,14 @@ var createCommand = Command12.make(
|
|
|
3440
3445
|
),
|
|
3441
3446
|
Options7.repeated
|
|
3442
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
|
+
),
|
|
3443
3456
|
region: Options7.text("region").pipe(Options7.withDescription("Region to place the microVM in"), Options7.optional),
|
|
3444
3457
|
json: jsonOption2
|
|
3445
3458
|
},
|
|
@@ -3756,6 +3769,46 @@ var extendCommand = Command12.make(
|
|
|
3756
3769
|
},
|
|
3757
3770
|
({ microvmId, duration }) => extendMicroVm(microvmId, duration).pipe(Effect22.asVoid, reportErrors2("extend the microVM"))
|
|
3758
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
|
+
);
|
|
3759
3812
|
var imagesListCommand = Command12.make(
|
|
3760
3813
|
"ls",
|
|
3761
3814
|
{ app: appOption6, json: jsonOption2 },
|
|
@@ -3862,6 +3915,7 @@ var SUBCOMMANDS = [
|
|
|
3862
3915
|
stopCommand,
|
|
3863
3916
|
removeCommand2,
|
|
3864
3917
|
extendCommand,
|
|
3918
|
+
networkCommand,
|
|
3865
3919
|
imagesCommand
|
|
3866
3920
|
];
|
|
3867
3921
|
var microvmsCommand = Command12.make("microvms", {}, () => Effect22.void).pipe(
|