alasio 7.0.0 → 9.0.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/dist/cli/src/api-server.js +18 -0
- package/dist/cli/src/api-server.js.map +1 -0
- package/dist/cli/src/branches.js +123 -46
- package/dist/cli/src/branches.js.map +1 -1
- package/dist/cli/src/cluster/docker.js +25 -10
- package/dist/cli/src/cluster/docker.js.map +1 -1
- package/dist/cli/src/cluster/host.js +33 -7
- package/dist/cli/src/cluster/host.js.map +1 -1
- package/dist/cli/src/cluster/k3s.js +51 -12
- package/dist/cli/src/cluster/k3s.js.map +1 -1
- package/dist/cli/src/cluster/node.js +115 -33
- package/dist/cli/src/cluster/node.js.map +1 -1
- package/dist/cli/src/cluster/stargz.js +55 -0
- package/dist/cli/src/cluster/stargz.js.map +1 -0
- package/dist/cli/src/commands/branch.js +5 -4
- package/dist/cli/src/commands/branch.js.map +1 -1
- package/dist/cli/src/commands/common.js +9 -3
- package/dist/cli/src/commands/common.js.map +1 -1
- package/dist/cli/src/commands/folder.js +14 -0
- package/dist/cli/src/commands/folder.js.map +1 -0
- package/dist/cli/src/commands/init.js +54 -4
- package/dist/cli/src/commands/init.js.map +1 -1
- package/dist/cli/src/commands/lake.js +40 -6
- package/dist/cli/src/commands/lake.js.map +1 -1
- package/dist/cli/src/commands/restore-filer-store.js +40 -8
- package/dist/cli/src/commands/restore-filer-store.js.map +1 -1
- package/dist/cli/src/commands/status.js +216 -20
- package/dist/cli/src/commands/status.js.map +1 -1
- package/dist/cli/src/commands/uninstall.js +8 -9
- package/dist/cli/src/commands/uninstall.js.map +1 -1
- package/dist/cli/src/commands/up.js +11 -3
- package/dist/cli/src/commands/up.js.map +1 -1
- package/dist/cli/src/commands/upgrade.js +1 -1
- package/dist/cli/src/commands/upgrade.js.map +1 -1
- package/dist/cli/src/commands.js +2 -1
- package/dist/cli/src/commands.js.map +1 -1
- package/dist/cli/src/config.js +24 -9
- package/dist/cli/src/config.js.map +1 -1
- package/dist/cli/src/cpu-baseline.js +8 -4
- package/dist/cli/src/cpu-baseline.js.map +1 -1
- package/dist/cli/src/folders.js +67 -0
- package/dist/cli/src/folders.js.map +1 -0
- package/dist/cli/src/gateway-calls.js +58 -0
- package/dist/cli/src/gateway-calls.js.map +1 -0
- package/dist/cli/src/install.js +119 -17
- package/dist/cli/src/install.js.map +1 -1
- package/dist/cli/src/kept-releases.js +27 -20
- package/dist/cli/src/kept-releases.js.map +1 -1
- package/dist/cli/src/kube/api.js +11 -5
- package/dist/cli/src/kube/api.js.map +1 -1
- package/dist/cli/src/kube/apply.js +16 -73
- package/dist/cli/src/kube/apply.js.map +1 -1
- package/dist/cli/src/kube/rollout.js +84 -26
- package/dist/cli/src/kube/rollout.js.map +1 -1
- package/dist/cli/src/lake.js +124 -0
- package/dist/cli/src/lake.js.map +1 -0
- package/dist/cli/src/manifests/admission.js +381 -223
- package/dist/cli/src/manifests/admission.js.map +1 -1
- package/dist/cli/src/manifests/alasio.js +79 -362
- package/dist/cli/src/manifests/alasio.js.map +1 -1
- package/dist/cli/src/manifests/branch.js +10 -26
- package/dist/cli/src/manifests/branch.js.map +1 -1
- package/dist/cli/src/manifests/collector.js +250 -135
- package/dist/cli/src/manifests/collector.js.map +1 -1
- package/dist/cli/src/manifests/common.js +32 -2
- package/dist/cli/src/manifests/common.js.map +1 -1
- package/dist/cli/src/manifests/config.js +256 -92
- package/dist/cli/src/manifests/config.js.map +1 -1
- package/dist/cli/src/manifests/disruption.js +10 -0
- package/dist/cli/src/manifests/disruption.js.map +1 -1
- package/dist/cli/src/manifests/folders.js +128 -0
- package/dist/cli/src/manifests/folders.js.map +1 -0
- package/dist/cli/src/manifests/grafana.js +4 -2
- package/dist/cli/src/manifests/grafana.js.map +1 -1
- package/dist/cli/src/manifests/index.js +15 -8
- package/dist/cli/src/manifests/index.js.map +1 -1
- package/dist/cli/src/manifests/keda.js +2 -1
- package/dist/cli/src/manifests/keda.js.map +1 -1
- package/dist/cli/src/manifests/lake.js +350 -73
- package/dist/cli/src/manifests/lake.js.map +1 -1
- package/dist/cli/src/manifests/log.js +316 -0
- package/dist/cli/src/manifests/log.js.map +1 -0
- package/dist/cli/src/manifests/neon.js +128 -49
- package/dist/cli/src/manifests/neon.js.map +1 -1
- package/dist/cli/src/manifests/network-policies.js +263 -100
- package/dist/cli/src/manifests/network-policies.js.map +1 -1
- package/dist/cli/src/manifests/node-agent.js +24 -8
- package/dist/cli/src/manifests/node-agent.js.map +1 -1
- package/dist/cli/src/manifests/object-store.js +4 -2
- package/dist/cli/src/manifests/object-store.js.map +1 -1
- package/dist/cli/src/manifests/sandbox-gateway.js +663 -0
- package/dist/cli/src/manifests/sandbox-gateway.js.map +1 -0
- package/dist/cli/src/manifests/scalers.js +16 -5
- package/dist/cli/src/manifests/scalers.js.map +1 -1
- package/dist/cli/src/manifests/sizing.js +16 -8
- package/dist/cli/src/manifests/sizing.js.map +1 -1
- package/dist/cli/src/manifests/valkey.js +11 -5
- package/dist/cli/src/manifests/valkey.js.map +1 -1
- package/dist/cli/src/manifests/vpa.js +3 -1
- package/dist/cli/src/manifests/vpa.js.map +1 -1
- package/dist/cli/src/manifests/webhook.js +102 -0
- package/dist/cli/src/manifests/webhook.js.map +1 -0
- package/dist/cli/src/manifests/workspace-storage.js +174 -89
- package/dist/cli/src/manifests/workspace-storage.js.map +1 -1
- package/dist/cli/src/neon-storage.js +155 -0
- package/dist/cli/src/neon-storage.js.map +1 -0
- package/dist/cli/src/release.js +9 -6
- package/dist/cli/src/release.js.map +1 -1
- package/dist/cli/src/secrets.js +45 -4
- package/dist/cli/src/secrets.js.map +1 -1
- package/dist/cli/src/target.js +1 -1
- package/dist/cli/src/target.js.map +1 -1
- package/dist/cli/src/telegram.js +56 -10
- package/dist/cli/src/telegram.js.map +1 -1
- package/dist/cli/src/webhook.js +182 -0
- package/dist/cli/src/webhook.js.map +1 -0
- package/dist/cluster/node/pins.json +12 -2
- package/dist/neon/control/branches.js +126 -21
- package/dist/neon/control/branches.js.map +1 -1
- package/dist/neon/control/endpoints.js +9 -0
- package/dist/neon/control/endpoints.js.map +1 -1
- package/dist/neon/control/jwt.js +16 -3
- package/dist/neon/control/jwt.js.map +1 -1
- package/dist/neon/control/secrets.js +51 -7
- package/dist/neon/control/secrets.js.map +1 -1
- package/dist/src/binder/names.js +33 -0
- package/dist/src/binder/names.js.map +1 -0
- package/dist/src/binder/tokens.js +58 -0
- package/dist/src/binder/tokens.js.map +1 -0
- package/dist/src/branch/names.js +12 -2
- package/dist/src/branch/names.js.map +1 -1
- package/dist/src/events/names.js +7 -0
- package/dist/src/events/names.js.map +1 -0
- package/dist/src/gateway/names.js +201 -0
- package/dist/src/gateway/names.js.map +1 -0
- package/dist/src/harness/names.js +49 -0
- package/dist/src/harness/names.js.map +1 -0
- package/dist/src/kube/sandbox-shape.js +19 -69
- package/dist/src/kube/sandbox-shape.js.map +1 -1
- package/dist/src/node-agent/names.js +118 -2
- package/dist/src/node-agent/names.js.map +1 -1
- package/dist/src/sandbox/names.js +12 -20
- package/dist/src/sandbox/names.js.map +1 -1
- package/dist/src/sandbox/otlp-resource.js +173 -0
- package/dist/src/sandbox/otlp-resource.js.map +1 -0
- package/dist/src/sandbox/telemetry.js +43 -0
- package/dist/src/sandbox/telemetry.js.map +1 -0
- package/dist/src/telegram/deliveries.js +40 -0
- package/dist/src/telegram/deliveries.js.map +1 -0
- package/dist/src/telemetry/config.js +131 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/forward.js +154 -0
- package/dist/src/telemetry/forward.js.map +1 -0
- package/package.json +1 -1
- package/dist/cli/src/manifests/agent-sandbox.js +0 -92
- package/dist/cli/src/manifests/agent-sandbox.js.map +0 -1
- package/dist/cli/src/manifests/juicefs-csi.js +0 -319
- package/dist/cli/src/manifests/juicefs-csi.js.map +0 -1
- package/dist/cli/src/manifests/sandboxes.agents.x-k8s.io.json +0 -6295
- package/dist/src/kube/config.js +0 -143
- package/dist/src/kube/config.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The binder's tokens, which say what they are for and are checked by the key that signed
|
|
3
|
+
* them alone, so whatever checks one holds no store of them, as the binder holds no state:
|
|
4
|
+
* `<claims>.<signature>`, the claims base64url JSON, the signature their HMAC-SHA256 under the
|
|
5
|
+
* key, base64url, compared in constant time.
|
|
6
|
+
*
|
|
7
|
+
* A caller's token names the key it may reach, when it stops, and what its key is bound with:
|
|
8
|
+
* what the binder's callers present, which the binder checks and never forwards. A binding's
|
|
9
|
+
* token names the key, the binding, its Lease's uid, so one minted for a binding is no
|
|
10
|
+
* other's, even of the same key, and the namespace its Lease is in: what the bound pod is
|
|
11
|
+
* given, to take its calls, and its telemetry, by (bindingToken).
|
|
12
|
+
*/
|
|
13
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
14
|
+
import { Option, Schema } from "effect";
|
|
15
|
+
/**
|
|
16
|
+
* What a token says: the key it is for; the binding, and its Lease's namespace, for a
|
|
17
|
+
* binding's; and, for a caller's, the time it stops, in ms, and what its key is bound with
|
|
18
|
+
* where it is not bound yet, which the binder's gateway reads (as a session's environment and
|
|
19
|
+
* internet).
|
|
20
|
+
*/
|
|
21
|
+
export const TokenClaims = Schema.Struct({
|
|
22
|
+
key: Schema.String,
|
|
23
|
+
binding: Schema.optional(Schema.String),
|
|
24
|
+
namespace: Schema.optional(Schema.String),
|
|
25
|
+
expires: Schema.optional(Schema.Number),
|
|
26
|
+
options: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
27
|
+
});
|
|
28
|
+
const decodeClaims = Schema.decodeUnknownOption(Schema.fromJsonString(TokenClaims));
|
|
29
|
+
const signatureOf = (secret, claims) => createHmac("sha256", secret).update(claims).digest();
|
|
30
|
+
/** A token of `claims`, signed with `secret`. */
|
|
31
|
+
export function mintToken(secret, claims) {
|
|
32
|
+
const encoded = Buffer.from(JSON.stringify(claims)).toString("base64url");
|
|
33
|
+
return `${encoded}.${signatureOf(secret, encoded).toString("base64url")}`;
|
|
34
|
+
}
|
|
35
|
+
/** The token of the binding `binding` of `key`, its Lease in `namespace`: the same text wherever it is minted, as its pod compares it whole. */
|
|
36
|
+
export const bindingToken = (secret, { key, binding, namespace }) => mintToken(secret, { key, binding, namespace });
|
|
37
|
+
/**
|
|
38
|
+
* What `token` says, where the key `secret` names of what it says signed it, as a key the
|
|
39
|
+
* claims choose (./names.ts environmentKey's), and it has not stopped by `now`; else null. Its claims
|
|
40
|
+
* are trusted only once its signature is checked by the key they named.
|
|
41
|
+
*/
|
|
42
|
+
export function verifyToken(secret, token, now) {
|
|
43
|
+
const dot = token.indexOf(".");
|
|
44
|
+
if (dot < 0)
|
|
45
|
+
return null;
|
|
46
|
+
const [encoded, signature] = [token.slice(0, dot), Buffer.from(token.slice(dot + 1), "base64url")];
|
|
47
|
+
const claims = decodeClaims(Buffer.from(encoded, "base64url").toString("utf8"));
|
|
48
|
+
if (Option.isNone(claims))
|
|
49
|
+
return null;
|
|
50
|
+
const key = typeof secret === "function" ? secret(claims.value) : secret;
|
|
51
|
+
if (key === null)
|
|
52
|
+
return null;
|
|
53
|
+
const expected = signatureOf(key, encoded);
|
|
54
|
+
if (signature.length !== expected.length || !timingSafeEqual(signature, expected))
|
|
55
|
+
return null;
|
|
56
|
+
return claims.value.expires !== undefined && claims.value.expires <= now ? null : claims.value;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../src/binder/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,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IAC/G,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;IACnG,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAChF,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,MAAM,GAAG,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACzE,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3C,IAAI,SAAS,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/F,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AACjG,CAAC"}
|
package/dist/src/branch/names.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What a branch environment is called, and what it is known by, as alasio and its command
|
|
3
|
-
* line both say it: its namespaces
|
|
4
|
-
* token to ask with (./fork.ts). Free of anything but Node's own, so the command line
|
|
3
|
+
* line both say it: its namespaces and the label they and its objects carry, the port its
|
|
4
|
+
* parent forks its sessions on, and its token to ask with (./fork.ts). Free of anything but Node's own, so the command line
|
|
5
5
|
* takes it without the server.
|
|
6
6
|
*/
|
|
7
7
|
import { createHmac } from "node:crypto";
|
|
8
|
+
/** The label of a branch environment's objects and namespaces, whose value is its name. */
|
|
9
|
+
export const BRANCH_LABEL = "alasio.dev/branch";
|
|
10
|
+
/**
|
|
11
|
+
* The label of a branch environment's sessions' namespace whose value is the environment it
|
|
12
|
+
* was branched from, its parent's, main's: the one the sandbox gateway forks sessions into it
|
|
13
|
+
* for (src/gateway/sessions.ts).
|
|
14
|
+
*/
|
|
15
|
+
export const BRANCH_PARENT_LABEL = "alasio.dev/branch-parent";
|
|
16
|
+
/** The name of main's environment, as its sessions are told apart from a branch's. */
|
|
17
|
+
export const MAIN_ENVIRONMENT_NAME = "main";
|
|
8
18
|
/** The port an alasio forks its sessions for its branch environments on. */
|
|
9
19
|
export const BRANCH_FORK_PORT = 4319;
|
|
10
20
|
/** The namespace of the branch environment `branch`: its alasio, its compute and its lake, and their Secrets. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/branch/names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,iHAAiH;AACjH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,iBAAiB,MAAM,EAAE,CAAC;AAErF,mEAAmE;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC;AAEzG,gGAAgG;AAChG,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,MAAc;IACnD,OAAO,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,sBAAsB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC9F,CAAC"}
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/branch/names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAE9D,sFAAsF;AACtF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE5C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,iHAAiH;AACjH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,iBAAiB,MAAM,EAAE,CAAC;AAErF,mEAAmE;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC;AAEzG,gGAAgG;AAChG,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,MAAc;IACnD,OAAO,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,sBAAsB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an environment's events (./events.ts) are known by: their topic in the log. Free of
|
|
3
|
+
* anything but itself, so the command line, which makes the topic, takes it without the events.
|
|
4
|
+
*/
|
|
5
|
+
/** The events topic of the environment `environment`: main's, or its branch's. */
|
|
6
|
+
export const eventsTopic = (environment) => `events.${environment}`;
|
|
7
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/events/names.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,WAAmB,EAAU,EAAE,CAAC,UAAU,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the sandbox gateway (./gateway.ts) and the session telemetry receiver
|
|
3
|
+
* (../receiver/receiver.ts) are configured by: their variables, and the gateway's
|
|
4
|
+
* configuration file. Free of anything but Effect's Schema and Node's own, so the command
|
|
5
|
+
* line, which renders them, takes it without either.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { posix } from "node:path";
|
|
9
|
+
import { Schema } from "effect";
|
|
10
|
+
import { keyHash } from "../binder/names.js";
|
|
11
|
+
import { sanitizePathToken } from "../kube/sandbox-shape.js";
|
|
12
|
+
import { ATTACH_ROOT } from "../node-agent/names.js";
|
|
13
|
+
export { RESTORE_POD } from "../node-agent/names.js";
|
|
14
|
+
/** The variable of the path of the gateway's configuration, a GatewayConfig as JSON. */
|
|
15
|
+
export const GATEWAY_CONFIG_VARIABLE = "ALASIO_GATEWAY_CONFIG";
|
|
16
|
+
/** The variables of the keys callers' tokens, and bindings', are signed with: the keys' text, as the stack's setup makes them. */
|
|
17
|
+
export const CALLER_KEY_VARIABLE = "CALLER_KEY";
|
|
18
|
+
export const BINDING_KEY_VARIABLE = "BINDING_KEY";
|
|
19
|
+
/**
|
|
20
|
+
* The variables alasio reaches its environment's sessions through the gateway by: the gateway's
|
|
21
|
+
* address, its environment's name, as its callers' tokens name it, and its environment's own key
|
|
22
|
+
* of the gateway's caller key, which signs them (../binder/names.ts environmentKey).
|
|
23
|
+
*/
|
|
24
|
+
export const ALASIO_GATEWAY_URL_VARIABLE = "ALASIO_GATEWAY_URL";
|
|
25
|
+
export const ALASIO_GATEWAY_ENVIRONMENT_VARIABLE = "ALASIO_GATEWAY_ENVIRONMENT";
|
|
26
|
+
export const ALASIO_GATEWAY_CALLER_KEY_VARIABLE = "ALASIO_GATEWAY_CALLER_KEY";
|
|
27
|
+
/** The variable that says the gateway serves alasio's folder workspaces' instances too: "1" where it does. */
|
|
28
|
+
export const ALASIO_GATEWAY_FOLDERS_VARIABLE = "ALASIO_GATEWAY_FOLDERS";
|
|
29
|
+
/** The variables of where the gateway tells of events (../events/events.ts): the log's brokers, its principal's name, and the file of its password. */
|
|
30
|
+
export const EVENTS_BROKERS_VARIABLE = "EVENTS_BROKERS";
|
|
31
|
+
export const EVENTS_USERNAME_VARIABLE = "EVENTS_USERNAME";
|
|
32
|
+
export const EVENTS_PASSWORD_FILE_VARIABLE = "EVENTS_PASSWORD_FILE";
|
|
33
|
+
/** The variables of the receiver's port, and of main's sessions' namespace, beside which it takes branch environments' bindings. */
|
|
34
|
+
export const RECEIVER_PORT_VARIABLE = "RECEIVER_PORT";
|
|
35
|
+
export const SESSIONS_NAMESPACE_VARIABLE = "SESSIONS_NAMESPACE";
|
|
36
|
+
/** The variable of the folder namespace, whose folder conversations' instances' bindings the receiver takes too; empty where there are none. */
|
|
37
|
+
export const FOLDERS_NAMESPACE_VARIABLE = "FOLDERS_NAMESPACE";
|
|
38
|
+
/** The hash of `template`, of its JSON with every object's keys in order, as a pool's template records its own (cli/src/manifests/sandbox-gateway.ts poolTemplate). */
|
|
39
|
+
export function templateHash(template) {
|
|
40
|
+
const sorted = (_key, value) => typeof value === "object" && value !== null && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) : value;
|
|
41
|
+
return createHash("sha256").update(JSON.stringify(template, sorted)).digest("hex");
|
|
42
|
+
}
|
|
43
|
+
/** The name of a restore's pod of the pool `pool`, by its random part, `suffix`, seven of base 36's digits, as RESTORE_POD matches it. */
|
|
44
|
+
export const restorePodName = (pool, suffix) => `${pool}-restore-${suffix}`;
|
|
45
|
+
/** The volume of a pool's pod's own directory on its node, which its workspace is attached under (cli/src/manifests/sandbox-gateway.ts poolTemplate). */
|
|
46
|
+
export const ATTACH_VOLUME = "attach";
|
|
47
|
+
/**
|
|
48
|
+
* The spec `spec`, a pool's template's, of a restore's pod named `name` in `namespace`: its own
|
|
49
|
+
* directory on its node named by its volume's path, not by a subpath of the directory of every
|
|
50
|
+
* pod's. A subpath is
|
|
51
|
+
* bound into its container alone, without what is mounted beneath it, as kubelet binds one; a
|
|
52
|
+
* volume's path is bound with it, so the workspace attached there before the pod is made is
|
|
53
|
+
* there as its restore reopens the files it held open.
|
|
54
|
+
*/
|
|
55
|
+
export function ownDirectory(spec, namespace, name) {
|
|
56
|
+
const unsubpathed = (container) => ({
|
|
57
|
+
...container,
|
|
58
|
+
...(container.volumeMounts
|
|
59
|
+
? {
|
|
60
|
+
volumeMounts: container.volumeMounts.map((mount) => {
|
|
61
|
+
if (mount.name !== ATTACH_VOLUME)
|
|
62
|
+
return mount;
|
|
63
|
+
const { subPathExpr: _subPath, ...own } = mount;
|
|
64
|
+
return own;
|
|
65
|
+
}),
|
|
66
|
+
}
|
|
67
|
+
: {}),
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
...spec,
|
|
71
|
+
containers: spec.containers.map(unsubpathed),
|
|
72
|
+
...(spec.initContainers ? { initContainers: spec.initContainers.map(unsubpathed) } : {}),
|
|
73
|
+
// One there already, as its node's agent made it, its workspace attached; kubelet makes none, so the pod starts not where it is not there.
|
|
74
|
+
...(spec.volumes ? { volumes: spec.volumes.map((volume) => (volume.name === ATTACH_VOLUME ? { name: ATTACH_VOLUME, hostPath: { path: `${ATTACH_ROOT}/${namespace}/${name}`, type: "Directory" } } : volume)) } : {}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** The pool of folder instances, by its name, in the folder namespace: its Leases' and its pods' label (./folders.ts). */
|
|
78
|
+
export const FOLDER_POOL = "folder";
|
|
79
|
+
/** What a folder instance's key begins with: `folder:<harness>:<conversation>` (./folders.ts). */
|
|
80
|
+
export const FOLDER_KEY_PREFIX = "folder:";
|
|
81
|
+
/** A harness's name, as a folder instance's key carries it. */
|
|
82
|
+
const HARNESS = /^[a-z][a-z0-9-]{0,30}$/u;
|
|
83
|
+
/** The key of the folder instance of the conversation `conversation` under the harness `harness`. */
|
|
84
|
+
export const folderKey = (harness, conversation) => `${FOLDER_KEY_PREFIX}${harness}:${conversation}`;
|
|
85
|
+
/** The harness and conversation of the folder instance `key` is of; null where it is no folder instance's. */
|
|
86
|
+
export function folderOfKey(key) {
|
|
87
|
+
if (!key.startsWith(FOLDER_KEY_PREFIX))
|
|
88
|
+
return null;
|
|
89
|
+
const rest = key.slice(FOLDER_KEY_PREFIX.length);
|
|
90
|
+
const at = rest.indexOf(":");
|
|
91
|
+
const [harness, conversation] = [rest.slice(0, Math.max(at, 0)), rest.slice(at + 1)];
|
|
92
|
+
return at > 0 && HARNESS.test(harness) && conversation.length > 0 && conversation.length <= 512 ? { harness, conversation } : null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Where the folder instance of `conversation` under `harness` keeps its state, under
|
|
96
|
+
* `stateRoot`: bayma leases its state directory to a single server, and a Codex thread keeps
|
|
97
|
+
* its server alive after the conversation switches to Claude, so the directory is keyed by
|
|
98
|
+
* harness as well as conversation.
|
|
99
|
+
*/
|
|
100
|
+
export const folderStateDir = (stateRoot, harness, conversation) => posix.join(stateRoot, sanitizePathToken(harness), sanitizePathToken(conversation));
|
|
101
|
+
/** The name of a folder instance's pod of `key`, by its random part, `suffix`, five of base 36's digits, as FOLDER_POD matches it. */
|
|
102
|
+
export const folderPodName = (key, suffix) => `bayma-${keyHash(key).slice(0, 16)}-${suffix}`;
|
|
103
|
+
export const FOLDER_POD = /^bayma-[0-9a-f]{16}-[0-9a-z]{5}$/u;
|
|
104
|
+
/** The Secret of a folder instance's pod `pod`'s binding's token, which its bayma takes requests with, mounted where FOLDER_TOKEN_FILE is. */
|
|
105
|
+
export const folderTokenSecret = (pod) => `${pod}-bayma-token`;
|
|
106
|
+
const FOLDER_TOKEN_VOLUME = "alasio-bayma-token";
|
|
107
|
+
const FOLDER_TOKEN_DIRECTORY = "/run/alasio/bayma";
|
|
108
|
+
export const FOLDER_TOKEN_FILE = `${FOLDER_TOKEN_DIRECTORY}/token`;
|
|
109
|
+
/**
|
|
110
|
+
* How long a folder instance's pod is given to stop: its bayma's CRIU dumps of its idle REPL
|
|
111
|
+
* sessions, one at a time, each within bayma's own 120 s; a state of the box's size is dumped
|
|
112
|
+
* in well under a minute (gate G8, program/13.4-folder-instances.md).
|
|
113
|
+
*/
|
|
114
|
+
export const FOLDER_STOP_SECONDS = 600;
|
|
115
|
+
/** How long a folder instance's release, or its next bind, waits for its pod to be gone, past its stop. */
|
|
116
|
+
export const FOLDER_GONE_MS = (FOLDER_STOP_SECONDS + 60) * 1000;
|
|
117
|
+
/** How long a folder instance's bind gives its pod to run, and its bayma, once it runs, to answer. */
|
|
118
|
+
export const FOLDER_START_MS = 120_000;
|
|
119
|
+
/** How long it gives its pod to run while its image is still being pulled, as a node that has never run it pulls it first. */
|
|
120
|
+
export const FOLDER_PULL_MS = 8 * 60_000;
|
|
121
|
+
/**
|
|
122
|
+
* How long a folder instance's bind may take in all, given `pullMs` and `startMs`: a release
|
|
123
|
+
* of it under way, or its pod before, gone first; then its pod run, its image pulled; then its
|
|
124
|
+
* bayma answering. A bind of the key meanwhile waits as long for it.
|
|
125
|
+
*/
|
|
126
|
+
export const folderBindMs = (pullMs = FOLDER_PULL_MS, startMs = FOLDER_START_MS) => FOLDER_GONE_MS + pullMs + startMs;
|
|
127
|
+
/**
|
|
128
|
+
* The spec of a folder instance's pod, `pod`, of the folder template's `spec`: its bayma
|
|
129
|
+
* given its binding's token, from its Secret, and its state directory, `stateDir`; stopped
|
|
130
|
+
* within FOLDER_STOP_SECONDS; and never started again, as a bayma that ended is a binding to
|
|
131
|
+
* release, not a container to start. Pure, as the gateway makes it and the folder pods' policy
|
|
132
|
+
* pins it (cli/src/manifests/admission.ts folderPodPolicy).
|
|
133
|
+
*/
|
|
134
|
+
export function folderPodSpec(spec, pod, stateDir) {
|
|
135
|
+
return {
|
|
136
|
+
...spec,
|
|
137
|
+
terminationGracePeriodSeconds: FOLDER_STOP_SECONDS,
|
|
138
|
+
restartPolicy: "Never",
|
|
139
|
+
containers: spec.containers.map((container) => container.name !== "bayma" ? container : {
|
|
140
|
+
...container,
|
|
141
|
+
args: [...(container.args ?? []), "--token-file", FOLDER_TOKEN_FILE, "--state-dir", stateDir],
|
|
142
|
+
volumeMounts: [...(container.volumeMounts ?? []), { name: FOLDER_TOKEN_VOLUME, mountPath: FOLDER_TOKEN_DIRECTORY, readOnly: true }],
|
|
143
|
+
}),
|
|
144
|
+
volumes: [...(spec.volumes ?? []), { name: FOLDER_TOKEN_VOLUME, secret: { secretName: folderTokenSecret(pod), defaultMode: 0o440 } }],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** A pod template, as the gateway's configuration holds one: an object, as the API server takes it. */
|
|
148
|
+
const Template = Schema.Record(Schema.String, Schema.Unknown);
|
|
149
|
+
/**
|
|
150
|
+
* How main's sessions are snapshotted (./snapshots.ts), as alasio's own were: how often one whose
|
|
151
|
+
* execs run is saved live, the gVisor releases a snapshot is restored under, each by its
|
|
152
|
+
* RuntimeClass, the current one first, and each pool's template, by its sessions' internet, as
|
|
153
|
+
* `alasio up` renders it now and as it rendered it before it last changed, which a snapshot taken
|
|
154
|
+
* on it still restores onto, and nothing older.
|
|
155
|
+
*/
|
|
156
|
+
export const GatewaySnapshots = Schema.Struct({
|
|
157
|
+
liveEverySeconds: Schema.Number,
|
|
158
|
+
/** Each kept release, its RuntimeClass, and the checkpoint gofer a restore of a snapshot it took asks for, if any (../node-agent/names.ts goferOf). */
|
|
159
|
+
releases: Schema.Array(Schema.Struct({
|
|
160
|
+
release: Schema.String,
|
|
161
|
+
runtimeClassName: Schema.String,
|
|
162
|
+
gofer: Schema.NullOr(Schema.Struct({ transport: Schema.Literals(["socket", "tcp"]), pagesRetry: Schema.Boolean })),
|
|
163
|
+
})),
|
|
164
|
+
templates: Schema.Struct({
|
|
165
|
+
none: Schema.Struct({ current: Template, previous: Schema.NullOr(Template) }),
|
|
166
|
+
full: Schema.Struct({ current: Template, previous: Schema.NullOr(Template) }),
|
|
167
|
+
}),
|
|
168
|
+
});
|
|
169
|
+
/** The sandbox pods' policy, which holds every pod of a sessions' namespace to its pools' templates (cli/src/manifests/admission.ts sandboxPodPolicy). */
|
|
170
|
+
export const SANDBOX_POD_POLICY = "alasio-sandbox-pods";
|
|
171
|
+
/** The gateway's configuration, as `alasio up` renders it (cli/src/manifests/sandbox-gateway.ts). */
|
|
172
|
+
export const GatewayConfig = Schema.Struct({
|
|
173
|
+
/** The port it serves on, and the host its replicas' headless Service resolves to, each at that port. */
|
|
174
|
+
port: Schema.Number,
|
|
175
|
+
peers: Schema.String,
|
|
176
|
+
/** The port pool pods' bayma serves on. */
|
|
177
|
+
podPort: Schema.Number,
|
|
178
|
+
/** How long a bind waits for a free pod, and an idle pod is kept. */
|
|
179
|
+
waitSeconds: Schema.Number,
|
|
180
|
+
releaseAfterSeconds: Schema.Number,
|
|
181
|
+
/** main's environment of sessions, by its name, and the namespace its pools are in; branch environments' are found (./environments.ts). */
|
|
182
|
+
environment: Schema.Struct({ name: Schema.String, namespace: Schema.String }),
|
|
183
|
+
/** The quota of a workspace the gateway makes, in bytes. */
|
|
184
|
+
quotaBytes: Schema.Number,
|
|
185
|
+
/** How main's sessions are snapshotted; none where they are not. */
|
|
186
|
+
snapshots: Schema.NullOr(GatewaySnapshots),
|
|
187
|
+
/** Each pool's name, by its sessions' internet. */
|
|
188
|
+
pools: Schema.Struct({ none: Schema.String, full: Schema.String }),
|
|
189
|
+
/** Where the node agents are. */
|
|
190
|
+
nodeAgents: Schema.Struct({ namespace: Schema.String, selector: Schema.String, port: Schema.Number }),
|
|
191
|
+
/** Where bound pods' bayma exports its telemetry, the session telemetry receiver's Service, by its name and port; none where none runs. */
|
|
192
|
+
receiver: Schema.NullOr(Schema.Struct({ host: Schema.String, port: Schema.Number })),
|
|
193
|
+
/**
|
|
194
|
+
* Folder conversations' instances (./folders.ts): the namespace they run in, the template of
|
|
195
|
+
* their pods, as `alasio up` renders it of the host profile, the directory under which each
|
|
196
|
+
* keeps its state, and how long an idle one is kept; none where the installation has no
|
|
197
|
+
* folder workspaces.
|
|
198
|
+
*/
|
|
199
|
+
folders: Schema.NullOr(Schema.Struct({ namespace: Schema.String, template: Template, stateRoot: Schema.String, releaseAfterSeconds: Schema.Number })),
|
|
200
|
+
});
|
|
201
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/gateway/names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,wFAAwF;AACxF,MAAM,CAAC,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAC/D,kIAAkI;AAClI,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG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AC,MAAM,CAAC,gBAAgB,CAAC;IAC1C,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IAClE,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACrG,2IAA2I;IAC3I,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACpF;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;CACtJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness identifiers shared by persistence, operator controls, and runtime selection.
|
|
3
|
+
*
|
|
4
|
+
* A harness is the agent runtime alasio drives for a Telegram conversation. Each
|
|
5
|
+
* conversation has at most one active harness at a time; the other harness keeps
|
|
6
|
+
* its own parked session pointer so switching never mounts a foreign session.
|
|
7
|
+
*
|
|
8
|
+
* A conversation starts with no harness mounted. Until the operator chooses one
|
|
9
|
+
* through /service, alasio only ever answers with the service picker. The
|
|
10
|
+
* `null` harness is therefore a real state, not a fallback, and callers must
|
|
11
|
+
* not coerce it to a default.
|
|
12
|
+
*/
|
|
13
|
+
export const CODEX_HARNESS = "codex";
|
|
14
|
+
export const CLAUDE_HARNESS = "claude";
|
|
15
|
+
export const HARNESS_NAMES = Object.freeze([CODEX_HARNESS, CLAUDE_HARNESS]);
|
|
16
|
+
const DISPLAY_NAMES = Object.freeze({
|
|
17
|
+
[CODEX_HARNESS]: "Codex",
|
|
18
|
+
[CLAUDE_HARNESS]: "Claude",
|
|
19
|
+
});
|
|
20
|
+
export function isHarnessName(candidate) {
|
|
21
|
+
const names = HARNESS_NAMES;
|
|
22
|
+
return typeof candidate === "string" && names.includes(candidate);
|
|
23
|
+
}
|
|
24
|
+
export function normalizeHarnessName(candidate, fallback = CODEX_HARNESS) {
|
|
25
|
+
if (typeof candidate !== "string") {
|
|
26
|
+
return fallback;
|
|
27
|
+
}
|
|
28
|
+
const lowered = candidate.trim().toLowerCase();
|
|
29
|
+
if (lowered === "claude" || lowered === "claude-code" || lowered === "claude_code" || lowered === "claudecode" || lowered === "claude code") {
|
|
30
|
+
return CLAUDE_HARNESS;
|
|
31
|
+
}
|
|
32
|
+
if (lowered === "codex") {
|
|
33
|
+
return CODEX_HARNESS;
|
|
34
|
+
}
|
|
35
|
+
return fallback;
|
|
36
|
+
}
|
|
37
|
+
export function harnessDisplayName(harness) {
|
|
38
|
+
return (harness && DISPLAY_NAMES[harness]) ?? DISPLAY_NAMES[CODEX_HARNESS];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Harness pre-mounted on newly created conversations.
|
|
42
|
+
*
|
|
43
|
+
* Neutral by default: returns null unless ALASIO_DEFAULT_HARNESS opts into a
|
|
44
|
+
* harness, in which case new conversations skip the picker.
|
|
45
|
+
*/
|
|
46
|
+
export function getDefaultHarness(env = process.env) {
|
|
47
|
+
return normalizeHarnessName(env["ALASIO_DEFAULT_HARNESS"], null);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/harness/names.ts"],"names":[],"mappings":"AAA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,iBAAiB,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IACpE,OAAO,oBAAoB,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE,IAAI,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -1,49 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What alasio
|
|
3
|
-
* (../
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* that holds alasio to its templates (cli/src/manifests/admission.ts) knows it as they do.
|
|
2
|
+
* What alasio's pods of bayma carry, beyond their templates, that more than one of its
|
|
3
|
+
* parts knows: the gateway that binds them (../gateway/), the node agents that snapshot and
|
|
4
|
+
* restore them (../node-agent/), and the admission policies that hold them to what alasio
|
|
5
|
+
* up renders (cli/src/manifests/admission.ts). In one place, with no dependency, so the
|
|
6
|
+
* command line takes it as it is.
|
|
8
7
|
*/
|
|
9
|
-
/** The container
|
|
8
|
+
/** The container of a session's or a folder instance's pod that runs bayma. */
|
|
10
9
|
export const BAYMA_CONTAINER = "bayma";
|
|
11
|
-
/** Where a Sandbox's token Secret is mounted in its bayma container, its key, and its volume. */
|
|
12
|
-
export const TOKEN_DIR = "/run/alasio/bayma";
|
|
13
|
-
export const TOKEN_KEY = "token";
|
|
14
|
-
export const TOKEN_VOLUME = "alasio-bayma-token";
|
|
15
|
-
/** The token volume's files' mode: readable by the pod's group, which is how a non-root bayma reads it. */
|
|
16
|
-
export const TOKEN_MODE = 0o440;
|
|
17
|
-
/** The file bayma reads its token from, which a restored Sandbox's new token replaces. */
|
|
18
|
-
export const TOKEN_FILE = `${TOKEN_DIR}/${TOKEN_KEY}`;
|
|
19
|
-
/** The arguments bayma is given after its template's: where its token is. */
|
|
20
|
-
export const TOKEN_FILE_ARGS = ["--token-file", TOKEN_FILE];
|
|
21
|
-
/** The arguments a session's bayma is given after those when it exports telemetry: the token it exports with, read from the same file for each export. */
|
|
22
|
-
export const TELEMETRY_TOKEN_FILE_ARGS = ["--telemetry-token-file", TOKEN_FILE];
|
|
23
|
-
/** The name of a Sandbox's token Secret. */
|
|
24
|
-
export function tokenSecretName(name) {
|
|
25
|
-
return `${name}-bayma-token`;
|
|
26
|
-
}
|
|
27
|
-
/** The label every object alasio makes carries, and the one that names its Sandbox. */
|
|
28
|
-
export const MANAGED_BY = { "app.kubernetes.io/managed-by": "alasio" };
|
|
29
|
-
export const SANDBOX_LABEL = "alasio.dev/sandbox";
|
|
30
|
-
/** What a Sandbox's pod is to alasio: a session's, or a folder's bayma's. */
|
|
31
|
-
export const WORKLOAD_LABEL = "alasio.dev/workload";
|
|
32
10
|
/** A session's internet, `none` or `full`, which its NetworkPolicies follow. */
|
|
33
11
|
export const NET_MODE_LABEL = "alasio.dev/net-mode";
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The argument a session's bayma is given how long it holds a stop by, for alasio to
|
|
14
|
+
* snapshot it first (bayma's mcp-http help): a bayma run without it holds none.
|
|
15
|
+
*/
|
|
16
|
+
export const STOP_WAIT_ARG = "--stop-wait-ms";
|
|
17
|
+
/** How long a session's bayma takes to stop once it holds its stop no more: it persists its sessions. */
|
|
18
|
+
export const BAYMA_STOP_SECONDS = 30;
|
|
40
19
|
/** A path segment from `value`: never empty, nor starting with a dot. */
|
|
41
20
|
export function sanitizePathToken(value) {
|
|
42
21
|
return String(value).replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^[-.]+|-+$/g, "") || "default";
|
|
43
22
|
}
|
|
44
23
|
/**
|
|
45
24
|
* What a session's pod template carries of its whole-sandbox snapshots
|
|
46
|
-
* (../
|
|
25
|
+
* (../gateway/snapshots.ts): the hash of the template it was made from, which its
|
|
47
26
|
* snapshots record; the CPU features its sandbox is held to; and, of a pod restored from
|
|
48
27
|
* a snapshot, the image it is restored from, on its node under the snapshot cache, left
|
|
49
28
|
* paused until its node's agent resumes it, which its readiness gate waits for.
|
|
@@ -57,42 +36,13 @@ export const RESTORE_ANNOTATION = "dev.gvisor.internal.restore.host-image-path";
|
|
|
57
36
|
export const RESTORE_PAUSED_ANNOTATION = "dev.gvisor.internal.restore.paused";
|
|
58
37
|
/** The condition of a restored pod's readiness gate, which alasio sets once its sandbox is resumed. */
|
|
59
38
|
export const RESUMED_CONDITION = "alasio.dev/resumed";
|
|
60
|
-
/**
|
|
61
|
-
* The annotation of a suspended Sandbox naming the snapshot its pod was saved into, which
|
|
62
|
-
* alone it may be restored from: set as it is suspended, removed as it is next resumed,
|
|
63
|
-
* from that snapshot or not, so a snapshot outlives no resume of its Sandbox's.
|
|
64
|
-
*/
|
|
65
|
-
export const SNAPSHOT_ANNOTATION = "alasio.dev/snapshot";
|
|
66
|
-
/**
|
|
67
|
-
* The annotation naming the gVisor release that took the snapshot SNAPSHOT_ANNOTATION
|
|
68
|
-
* names, beside it, the only one that restores it: `alasio up` keeps every release one
|
|
69
|
-
* names (cli/src/kept-releases.ts).
|
|
70
|
-
*/
|
|
71
|
-
export const SNAPSHOT_RELEASE_ANNOTATION = "alasio.dev/snapshot-release";
|
|
72
39
|
/** Where a node agent keeps the snapshots it prepares, as `<environment>/<workspace>/<snapshot>` (../node-agent/cache.ts). */
|
|
73
40
|
export const SNAPSHOT_CACHE_DIR = "/var/lib/alasio/snapshots";
|
|
74
|
-
/** A snapshot's id, as a node agent names it: when it was taken, then 32 random bits. */
|
|
75
|
-
export const SNAPSHOT_ID = "[0-9]{8}T[0-9]{6}Z-[0-9a-f]{8}";
|
|
76
|
-
/** A DNS label: an environment's name (its sessions' namespace) and a workspace's (its Sandbox's), as the snapshot cache's directories are named. */
|
|
77
|
-
export const NAME = /^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?$/u;
|
|
78
|
-
/** The init container that holds a session's pod until its egress is confined: its name, and its resources. */
|
|
79
|
-
export const EGRESS_GATE = { name: "egress-gate", resources: { requests: { cpu: "10m", memory: "32Mi" }, limits: { memory: "64Mi" } } };
|
|
80
41
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* image's Node.
|
|
42
|
+
* A snapshot's id, as a node agent names it: when it was taken, to the millisecond, so a
|
|
43
|
+
* workspace's ids sort as its snapshots were taken, then 32 random bits.
|
|
84
44
|
*/
|
|
85
|
-
export const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"const deadline = Date.now() + 120000; let refused = 0;",
|
|
89
|
-
"(function probe() {",
|
|
90
|
-
" const socket = net.connect({ host, port, timeout: 1000 });",
|
|
91
|
-
" const next = (blocked) => { socket.destroy(); refused = blocked ? refused + 1 : 0;",
|
|
92
|
-
" if (refused >= 3) process.exit(0);",
|
|
93
|
-
" if (Date.now() > deadline) { console.error('egress is not confined: is NetworkPolicy enforced in this cluster?'); process.exit(1); }",
|
|
94
|
-
" setTimeout(probe, 250); };",
|
|
95
|
-
" socket.once('connect', () => next(false)); socket.once('timeout', () => next(true)); socket.once('error', () => next(true));",
|
|
96
|
-
"})();",
|
|
97
|
-
].join("\n");
|
|
45
|
+
export const SNAPSHOT_ID = "[0-9]{8}T[0-9]{9}Z-[0-9a-f]{8}";
|
|
46
|
+
/** A DNS label: an environment's name (its sessions' namespace) and a workspace's, as the snapshot cache's directories are named. */
|
|
47
|
+
export const NAME = /^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?$/u;
|
|
98
48
|
//# sourceMappingURL=sandbox-shape.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-shape.js","sourceRoot":"","sources":["../../../../src/kube/sandbox-shape.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sandbox-shape.js","sourceRoot":"","sources":["../../../../src/kube/sandbox-shape.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEvC,gFAAgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAE9C,yGAAyG;AACzG,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,yEAAyE;AACzE,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC;AACjG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,6BAA6B,CAAC;AACzE,oGAAoG;AACpG,MAAM,CAAC,MAAM,uBAAuB,GAAG,iCAAiC,CAAC;AACzE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,kBAAkB,GAAG,6CAA6C,CAAC;AAChF,yGAAyG;AACzG,MAAM,CAAC,MAAM,yBAAyB,GAAG,oCAAoC,CAAC;AAC9E,uGAAuG;AACvG,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AACtD,8HAA8H;AAC9H,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAC9D;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAC5D,qIAAqI;AACrI,MAAM,CAAC,MAAM,IAAI,GAAG,uCAAuC,CAAC"}
|