alasio 8.0.0 → 10.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/bound-harnesses.js +98 -0
- package/dist/cli/src/bound-harnesses.js.map +1 -0
- package/dist/cli/src/branches.js +79 -22
- package/dist/cli/src/branches.js.map +1 -1
- package/dist/cli/src/cluster/docker.js +40 -15
- package/dist/cli/src/cluster/docker.js.map +1 -1
- package/dist/cli/src/cluster/host.js +38 -8
- package/dist/cli/src/cluster/host.js.map +1 -1
- package/dist/cli/src/cluster/k3s.js +105 -14
- package/dist/cli/src/cluster/k3s.js.map +1 -1
- package/dist/cli/src/cluster/node.js +142 -33
- package/dist/cli/src/cluster/node.js.map +1 -1
- package/dist/cli/src/cluster/stargz.js +92 -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 +11 -5
- 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/lake.js +1 -1
- package/dist/cli/src/commands/lake.js.map +1 -1
- package/dist/cli/src/commands/login-relay.js +91 -0
- package/dist/cli/src/commands/login-relay.js.map +1 -0
- package/dist/cli/src/commands/login.js +11 -10
- package/dist/cli/src/commands/login.js.map +1 -1
- package/dist/cli/src/commands/logs.js +89 -6
- package/dist/cli/src/commands/logs.js.map +1 -1
- package/dist/cli/src/commands/restart.js +10 -4
- package/dist/cli/src/commands/restart.js.map +1 -1
- package/dist/cli/src/commands/restore-filer-store.js +27 -10
- package/dist/cli/src/commands/restore-filer-store.js.map +1 -1
- package/dist/cli/src/commands/status.js +119 -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 +20 -9
- package/dist/cli/src/commands/up.js.map +1 -1
- package/dist/cli/src/commands/upgrade.js +22 -6
- 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 +4 -1
- 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 +63 -0
- package/dist/cli/src/folders.js.map +1 -0
- package/dist/cli/src/gateway-calls.js +64 -0
- package/dist/cli/src/gateway-calls.js.map +1 -0
- package/dist/cli/src/install.js +45 -31
- 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 +61 -15
- package/dist/cli/src/kube/api.js.map +1 -1
- package/dist/cli/src/kube/apply.js +122 -81
- package/dist/cli/src/kube/apply.js.map +1 -1
- package/dist/cli/src/kube/rollout.js +43 -21
- package/dist/cli/src/kube/rollout.js.map +1 -1
- package/dist/cli/src/main.js +2 -1
- package/dist/cli/src/main.js.map +1 -1
- package/dist/cli/src/manifests/admission.js +558 -222
- package/dist/cli/src/manifests/admission.js.map +1 -1
- package/dist/cli/src/manifests/alasio.js +180 -428
- package/dist/cli/src/manifests/alasio.js.map +1 -1
- package/dist/cli/src/manifests/branch.js +16 -27
- package/dist/cli/src/manifests/branch.js.map +1 -1
- package/dist/cli/src/manifests/codex-login.js +101 -0
- package/dist/cli/src/manifests/codex-login.js.map +1 -0
- package/dist/cli/src/manifests/collector.js +83 -62
- package/dist/cli/src/manifests/collector.js.map +1 -1
- package/dist/cli/src/manifests/common.js +82 -25
- package/dist/cli/src/manifests/common.js.map +1 -1
- package/dist/cli/src/manifests/config.js +137 -105
- package/dist/cli/src/manifests/config.js.map +1 -1
- package/dist/cli/src/manifests/disruption.js +18 -3
- package/dist/cli/src/manifests/disruption.js.map +1 -1
- package/dist/cli/src/manifests/folders.js +131 -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/harness-pools.js +236 -0
- package/dist/cli/src/manifests/harness-pools.js.map +1 -0
- package/dist/cli/src/manifests/image-holder.js +61 -0
- package/dist/cli/src/manifests/image-holder.js.map +1 -0
- package/dist/cli/src/manifests/index.js +14 -7
- package/dist/cli/src/manifests/index.js.map +1 -1
- package/dist/cli/src/manifests/keda.js +4 -2
- package/dist/cli/src/manifests/keda.js.map +1 -1
- package/dist/cli/src/manifests/lake.js +18 -20
- package/dist/cli/src/manifests/lake.js.map +1 -1
- package/dist/cli/src/manifests/log.js +84 -19
- package/dist/cli/src/manifests/log.js.map +1 -1
- package/dist/cli/src/manifests/neon.js +60 -80
- package/dist/cli/src/manifests/neon.js.map +1 -1
- package/dist/cli/src/manifests/network-policies.js +232 -94
- package/dist/cli/src/manifests/network-policies.js.map +1 -1
- package/dist/cli/src/manifests/node-agent.js +42 -15
- package/dist/cli/src/manifests/node-agent.js.map +1 -1
- package/dist/cli/src/manifests/object-store.js +99 -25
- package/dist/cli/src/manifests/object-store.js.map +1 -1
- package/dist/cli/src/manifests/sandbox-gateway.js +761 -0
- package/dist/cli/src/manifests/sandbox-gateway.js.map +1 -0
- package/dist/cli/src/manifests/scalers.js +17 -5
- package/dist/cli/src/manifests/scalers.js.map +1 -1
- package/dist/cli/src/manifests/sizing.js +17 -9
- package/dist/cli/src/manifests/sizing.js.map +1 -1
- package/dist/cli/src/manifests/valkey.js +30 -10
- package/dist/cli/src/manifests/valkey.js.map +1 -1
- package/dist/cli/src/manifests/volume-lock.js +43 -0
- package/dist/cli/src/manifests/volume-lock.js.map +1 -0
- package/dist/cli/src/manifests/vpa.js +15 -2
- package/dist/cli/src/manifests/vpa.js.map +1 -1
- package/dist/cli/src/manifests/workspace-storage.js +182 -94
- package/dist/cli/src/manifests/workspace-storage.js.map +1 -1
- package/dist/cli/src/neon-storage.js +54 -16
- package/dist/cli/src/neon-storage.js.map +1 -1
- package/dist/cli/src/release.js +9 -9
- package/dist/cli/src/release.js.map +1 -1
- package/dist/cli/src/setup-pod.js +44 -0
- package/dist/cli/src/setup-pod.js.map +1 -0
- package/dist/cli/src/target.js +2 -2
- package/dist/cli/src/target.js.map +1 -1
- package/dist/cli/src/telegram.js +13 -4
- package/dist/cli/src/telegram.js.map +1 -1
- package/dist/cli/src/wakes.js +68 -0
- package/dist/cli/src/wakes.js.map +1 -0
- package/dist/cli/src/webhook.js +5 -2
- package/dist/cli/src/webhook.js.map +1 -1
- package/dist/cluster/node/pins.json +11 -5
- package/dist/neon/control/branches.js +13 -6
- package/dist/neon/control/branches.js.map +1 -1
- package/dist/neon/control/endpoints.js +81 -10
- package/dist/neon/control/endpoints.js.map +1 -1
- package/dist/neon/control/secrets.js +24 -8
- package/dist/neon/control/secrets.js.map +1 -1
- package/dist/src/binder/bindings.js +195 -0
- package/dist/src/binder/bindings.js.map +1 -0
- package/dist/src/binder/names.js +63 -0
- package/dist/src/binder/names.js.map +1 -0
- package/dist/src/binder/tokens.js +71 -0
- package/dist/src/binder/tokens.js.map +1 -0
- package/dist/src/branch/names.js +20 -6
- package/dist/src/branch/names.js.map +1 -1
- package/dist/src/events/names.js +28 -0
- package/dist/src/events/names.js.map +1 -0
- package/dist/src/gateway/names.js +240 -0
- package/dist/src/gateway/names.js.map +1 -0
- package/dist/src/harness/names.js +67 -0
- package/dist/src/harness/names.js.map +1 -0
- package/dist/src/kube/client.js +212 -0
- package/dist/src/kube/client.js.map +1 -0
- package/dist/src/kube/sandbox-shape.js +14 -68
- package/dist/src/kube/sandbox-shape.js.map +1 -1
- package/dist/src/kube/started-map.js +12 -0
- package/dist/src/kube/started-map.js.map +1 -0
- package/dist/src/node-agent/names.js +62 -5
- 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/bot-commands.js +17 -0
- package/dist/src/telegram/bot-commands.js.map +1 -0
- package/dist/src/telegram/stop.js +12 -0
- package/dist/src/telegram/stop.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 -320
- 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 -145
- package/dist/src/kube/config.js.map +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
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; or, held to a
|
|
9
|
+
* binding of another key (`held`), as a harness elsewhere is given its workspace's, no time it
|
|
10
|
+
* stops, but good only for as long as that binding is held. A binding's
|
|
11
|
+
* token names the key, the binding, its Lease's uid, so one minted for a binding is no
|
|
12
|
+
* other's, even of the same key, and the namespace its Lease is in: what the bound pod is
|
|
13
|
+
* given, to take its calls, and its telemetry, by (bindingToken).
|
|
14
|
+
*/
|
|
15
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
16
|
+
import { Option, Schema } from "effect";
|
|
17
|
+
/**
|
|
18
|
+
* What a token says: the key it is for; the binding, and its Lease's namespace, for a
|
|
19
|
+
* binding's; and, for a caller's, the time it stops, in ms, or the binding it is held to in its
|
|
20
|
+
* place (HeldTo) and when it was minted, in ms, and what its key is bound with where it is not
|
|
21
|
+
* bound yet, which the binder's gateway reads (as a session's environment and internet).
|
|
22
|
+
*/
|
|
23
|
+
export const TokenClaims = Schema.Struct({
|
|
24
|
+
key: Schema.String,
|
|
25
|
+
binding: Schema.optional(Schema.String),
|
|
26
|
+
namespace: Schema.optional(Schema.String),
|
|
27
|
+
expires: Schema.optional(Schema.Number),
|
|
28
|
+
held: Schema.optional(Schema.Struct({ key: Schema.String, binding: Schema.String, namespace: Schema.String })),
|
|
29
|
+
issued: Schema.optional(Schema.Number),
|
|
30
|
+
options: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
31
|
+
});
|
|
32
|
+
const decodeClaims = Schema.decodeUnknownOption(Schema.fromJsonString(TokenClaims));
|
|
33
|
+
const signatureOf = (secret, claims) => createHmac("sha256", secret).update(claims).digest();
|
|
34
|
+
/**
|
|
35
|
+
* What `token` says, its signature unchecked: of a token its holder was given where it trusts
|
|
36
|
+
* it to come from, as a pod reads its own binding's token from beside it (../harness/program.ts);
|
|
37
|
+
* null where it says nothing a token does. Never of a token a caller presents (verifyToken).
|
|
38
|
+
*/
|
|
39
|
+
export function claimsOf(token) {
|
|
40
|
+
const dot = token.indexOf(".");
|
|
41
|
+
return dot < 0 ? null : Option.getOrNull(decodeClaims(Buffer.from(token.slice(0, dot), "base64url").toString("utf8")));
|
|
42
|
+
}
|
|
43
|
+
/** A token of `claims`, signed with `secret`. */
|
|
44
|
+
export function mintToken(secret, claims) {
|
|
45
|
+
const encoded = Buffer.from(JSON.stringify(claims)).toString("base64url");
|
|
46
|
+
return `${encoded}.${signatureOf(secret, encoded).toString("base64url")}`;
|
|
47
|
+
}
|
|
48
|
+
/** 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. */
|
|
49
|
+
export const bindingToken = (secret, { key, binding, namespace }) => mintToken(secret, { key, binding, namespace });
|
|
50
|
+
/**
|
|
51
|
+
* What `token` says, where the key `secret` names of what it says signed it, as a key the
|
|
52
|
+
* claims choose (./names.ts environmentKey's), and it has not stopped by `now`; else null. Its claims
|
|
53
|
+
* are trusted only once its signature is checked by the key they named.
|
|
54
|
+
*/
|
|
55
|
+
export function verifyToken(secret, token, now) {
|
|
56
|
+
const dot = token.indexOf(".");
|
|
57
|
+
if (dot < 0)
|
|
58
|
+
return null;
|
|
59
|
+
const [encoded, signature] = [token.slice(0, dot), Buffer.from(token.slice(dot + 1), "base64url")];
|
|
60
|
+
const claims = decodeClaims(Buffer.from(encoded, "base64url").toString("utf8"));
|
|
61
|
+
if (Option.isNone(claims))
|
|
62
|
+
return null;
|
|
63
|
+
const key = typeof secret === "function" ? secret(claims.value) : secret;
|
|
64
|
+
if (key === null)
|
|
65
|
+
return null;
|
|
66
|
+
const expected = signatureOf(key, encoded);
|
|
67
|
+
if (signature.length !== expected.length || !timingSafeEqual(signature, expected))
|
|
68
|
+
return null;
|
|
69
|
+
return claims.value.expires !== undefined && claims.value.expires <= now ? null : claims.value;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../src/binder/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;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,CAA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AC,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,16 +1,30 @@
|
|
|
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).
|
|
5
|
-
* takes it without the server.
|
|
3
|
+
* line both say it: its namespaces and the label they and its objects carry, the topic and
|
|
4
|
+
* group its parent is asked to fork its sessions on, and its token to ask with (./fork.ts).
|
|
5
|
+
* Free of anything but Node's own, so the command line takes it without the server.
|
|
6
6
|
*/
|
|
7
7
|
import { createHmac } from "node:crypto";
|
|
8
|
-
/** The
|
|
9
|
-
export const
|
|
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";
|
|
18
|
+
/** The topic of the log the environment `environment`'s branches ask it on to fork its sessions for them: a branch writes it, its alasio reads it. */
|
|
19
|
+
export const forksTopic = (environment) => `forks.${environment}`;
|
|
20
|
+
/** The consumer group the environment `environment`'s alasio reads its branches' fork requests in. */
|
|
21
|
+
export const forksGroup = (environment) => `alasio-forks.${environment}`;
|
|
10
22
|
/** The namespace of the branch environment `branch`: its alasio, its compute and its lake, and their Secrets. */
|
|
11
23
|
export const branchNamespace = (branch) => `alasio-branch-${branch}`;
|
|
24
|
+
/** What ends the name of a branch environment's sessions' namespace, after its own's. */
|
|
25
|
+
export const SESSIONS_SUFFIX = "-sessions";
|
|
12
26
|
/** The namespace of the branch environment `branch`'s sessions. */
|
|
13
|
-
export const branchSessionsNamespace = (branch) => `${branchNamespace(branch)}
|
|
27
|
+
export const branchSessionsNamespace = (branch) => `${branchNamespace(branch)}${SESSIONS_SUFFIX}`;
|
|
14
28
|
/** The token the branch `branch` forks its parent's sessions with: `key`'s HMAC of its name. */
|
|
15
29
|
export function forkToken(key, branch) {
|
|
16
30
|
return createHmac("sha256", key).update(`alasio-branch-fork:${branch}`).digest("base64url");
|
|
@@ -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,
|
|
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,sJAAsJ;AACtJ,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAAmB,EAAU,EAAE,CAAC,SAAS,WAAW,EAAE,CAAC;AAElF,sGAAsG;AACtG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAAmB,EAAU,EAAE,CAAC,gBAAgB,WAAW,EAAE,CAAC;AAEzF,iHAAiH;AACjH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,iBAAiB,MAAM,EAAE,CAAC;AAErF,yFAAyF;AACzF,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C,mEAAmE;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,eAAe,EAAE,CAAC;AAElH,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,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an environment's events (./events.ts) are known by: their topic in the log, the group
|
|
3
|
+
* its alasio reads it in, and the variables that say where a program tells of them. Free of
|
|
4
|
+
* anything but itself, so the command line, which makes the topic and its principal's access,
|
|
5
|
+
* takes it without the events.
|
|
6
|
+
*/
|
|
7
|
+
/** What every environment's events topic is named with first. */
|
|
8
|
+
export const EVENTS_TOPIC_PREFIX = "events.";
|
|
9
|
+
/** The events topic of the environment `environment`: main's, or its branch's. */
|
|
10
|
+
export const eventsTopic = (environment) => `${EVENTS_TOPIC_PREFIX}${environment}`;
|
|
11
|
+
/** The consumer group the environment `environment`'s alasio reads its events topic in, apart from its Telegram updates' group, so neither holds the other back. */
|
|
12
|
+
export const eventsGroup = (environment) => `alasio-events.${environment}`;
|
|
13
|
+
/** How long an environment's events topic keeps what it is told: a week, past any wait of its alasio's to read it. */
|
|
14
|
+
export const EVENTS_RETENTION_MS = 7 * 86_400_000;
|
|
15
|
+
/**
|
|
16
|
+
* How long an alasio keeps the record of each event it handled (../persistence/store.ts
|
|
17
|
+
* withEventHandled): a day past what its topic keeps, as the log deletes a segment, closed at
|
|
18
|
+
* the hour, only once all of it is older than the topic's retention. A group the log forgot
|
|
19
|
+
* the offsets of, idle as long, reads its topic again from where it reads one told of none (a
|
|
20
|
+
* branch's from its first record kept, ./consume.ts), and finds each event it handled still
|
|
21
|
+
* recorded, so handles none again.
|
|
22
|
+
*/
|
|
23
|
+
export const EVENTS_HANDLED_KEPT_MS = EVENTS_RETENTION_MS + 86_400_000;
|
|
24
|
+
/** The variables of where a program tells of events (./events.ts Events.fromEnvironment): the log's brokers, its principal's name, and the file of its password. */
|
|
25
|
+
export const EVENTS_BROKERS_VARIABLE = "EVENTS_BROKERS";
|
|
26
|
+
export const EVENTS_USERNAME_VARIABLE = "EVENTS_USERNAME";
|
|
27
|
+
export const EVENTS_PASSWORD_FILE_VARIABLE = "EVENTS_PASSWORD_FILE";
|
|
28
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/events/names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE7C,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,WAAmB,EAAU,EAAE,CAAC,GAAG,mBAAmB,GAAG,WAAW,EAAE,CAAC;AAEnG,oKAAoK;AACpK,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,WAAmB,EAAU,EAAE,CAAC,iBAAiB,WAAW,EAAE,CAAC;AAE3F,sHAAsH;AACtH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,UAAU,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,GAAG,UAAU,CAAC;AAEvE,oKAAoK;AACpK,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AAC1D,MAAM,CAAC,MAAM,6BAA6B,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
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 { HARNESS_NAMES } from "../harness/names.js";
|
|
12
|
+
import { sanitizePathToken } from "../kube/sandbox-shape.js";
|
|
13
|
+
import { ATTACH_ROOT } from "../node-agent/names.js";
|
|
14
|
+
import { volumeIdOfKey } from "../sandbox/names.js";
|
|
15
|
+
export { RESTORE_POD } from "../node-agent/names.js";
|
|
16
|
+
/** The variable of the path of the gateway's configuration, a GatewayConfig as JSON. */
|
|
17
|
+
export const GATEWAY_CONFIG_VARIABLE = "ALASIO_GATEWAY_CONFIG";
|
|
18
|
+
/** The variables of the keys callers' tokens, and bindings', are signed with: the keys' text, as the stack's setup makes them. */
|
|
19
|
+
export const CALLER_KEY_VARIABLE = "CALLER_KEY";
|
|
20
|
+
export const BINDING_KEY_VARIABLE = "BINDING_KEY";
|
|
21
|
+
/**
|
|
22
|
+
* The variables alasio reaches its environment's sessions through the gateway by: the gateway's
|
|
23
|
+
* address, its environment's name, as its callers' tokens name it, and its environment's own key
|
|
24
|
+
* of the gateway's caller key, which signs them (../binder/names.ts environmentKey).
|
|
25
|
+
*/
|
|
26
|
+
export const ALASIO_GATEWAY_URL_VARIABLE = "ALASIO_GATEWAY_URL";
|
|
27
|
+
export const ALASIO_GATEWAY_ENVIRONMENT_VARIABLE = "ALASIO_GATEWAY_ENVIRONMENT";
|
|
28
|
+
export const ALASIO_GATEWAY_CALLER_KEY_VARIABLE = "ALASIO_GATEWAY_CALLER_KEY";
|
|
29
|
+
/** The variable that says the gateway serves alasio's folder workspaces' instances too: "1" where it does. */
|
|
30
|
+
export const ALASIO_GATEWAY_FOLDERS_VARIABLE = "ALASIO_GATEWAY_FOLDERS";
|
|
31
|
+
/** The variables of the receiver's port, and of main's sessions' namespace, beside which it takes branch environments' bindings. */
|
|
32
|
+
export const RECEIVER_PORT_VARIABLE = "RECEIVER_PORT";
|
|
33
|
+
export const SESSIONS_NAMESPACE_VARIABLE = "SESSIONS_NAMESPACE";
|
|
34
|
+
/** The variable of the folder namespace, whose folder conversations' instances' bindings the receiver takes too; empty where there are none. */
|
|
35
|
+
export const FOLDERS_NAMESPACE_VARIABLE = "FOLDERS_NAMESPACE";
|
|
36
|
+
/** 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). */
|
|
37
|
+
export function templateHash(template) {
|
|
38
|
+
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;
|
|
39
|
+
return createHash("sha256").update(JSON.stringify(template, sorted)).digest("hex");
|
|
40
|
+
}
|
|
41
|
+
/** 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. */
|
|
42
|
+
export const restorePodName = (pool, suffix) => `${pool}-restore-${suffix}`;
|
|
43
|
+
/** 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). */
|
|
44
|
+
export const ATTACH_VOLUME = "attach";
|
|
45
|
+
/**
|
|
46
|
+
* The spec `spec`, a pool's template's, of a restore's pod named `name` in `namespace`: its own
|
|
47
|
+
* directory on its node named by its volume's path, not by a subpath of the directory of every
|
|
48
|
+
* pod's. A subpath is
|
|
49
|
+
* bound into its container alone, without what is mounted beneath it, as kubelet binds one; a
|
|
50
|
+
* volume's path is bound with it, so the workspace attached there before the pod is made is
|
|
51
|
+
* there as its restore reopens the files it held open.
|
|
52
|
+
*/
|
|
53
|
+
export function ownDirectory(spec, namespace, name) {
|
|
54
|
+
const unsubpathed = (container) => ({
|
|
55
|
+
...container,
|
|
56
|
+
...(container.volumeMounts
|
|
57
|
+
? {
|
|
58
|
+
volumeMounts: container.volumeMounts.map((mount) => {
|
|
59
|
+
if (mount.name !== ATTACH_VOLUME)
|
|
60
|
+
return mount;
|
|
61
|
+
const { subPathExpr: _subPath, ...own } = mount;
|
|
62
|
+
return own;
|
|
63
|
+
}),
|
|
64
|
+
}
|
|
65
|
+
: {}),
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
...spec,
|
|
69
|
+
containers: spec.containers.map(unsubpathed),
|
|
70
|
+
...(spec.initContainers ? { initContainers: spec.initContainers.map(unsubpathed) } : {}),
|
|
71
|
+
// 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.
|
|
72
|
+
...(spec.volumes ? { volumes: spec.volumes.map((volume) => (volume.name === ATTACH_VOLUME ? { name: ATTACH_VOLUME, hostPath: { path: `${ATTACH_ROOT}/${namespace}/${name}`, type: "Directory" } } : volume)) } : {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** The pool of folder instances, by its name, in the folder namespace: its Leases' and its pods' label (./folders.ts). */
|
|
76
|
+
export const FOLDER_POOL = "folder";
|
|
77
|
+
/** What a folder instance's key begins with: `folder:<harness>:<conversation>` (./folders.ts). */
|
|
78
|
+
export const FOLDER_KEY_PREFIX = "folder:";
|
|
79
|
+
/** A harness's name, as a folder instance's key carries it. */
|
|
80
|
+
const HARNESS = /^[a-z][a-z0-9-]{0,30}$/u;
|
|
81
|
+
/** The key of the folder instance of the conversation `conversation` under the harness `harness`. */
|
|
82
|
+
export const folderKey = (harness, conversation) => `${FOLDER_KEY_PREFIX}${harness}:${conversation}`;
|
|
83
|
+
/** The harness and conversation of the folder instance `key` is of; null where it is no folder instance's. */
|
|
84
|
+
export function folderOfKey(key) {
|
|
85
|
+
if (!key.startsWith(FOLDER_KEY_PREFIX))
|
|
86
|
+
return null;
|
|
87
|
+
const rest = key.slice(FOLDER_KEY_PREFIX.length);
|
|
88
|
+
const at = rest.indexOf(":");
|
|
89
|
+
const [harness, conversation] = [rest.slice(0, Math.max(at, 0)), rest.slice(at + 1)];
|
|
90
|
+
return at > 0 && HARNESS.test(harness) && conversation.length > 0 && conversation.length <= 512 ? { harness, conversation } : null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Where the folder instance of `conversation` under `harness` keeps its state, under
|
|
94
|
+
* `stateRoot`: bayma leases its state directory to a single server, and a Codex thread keeps
|
|
95
|
+
* its server alive after the conversation switches to Claude, so the directory is keyed by
|
|
96
|
+
* harness as well as conversation.
|
|
97
|
+
*/
|
|
98
|
+
export const folderStateDir = (stateRoot, harness, conversation) => posix.join(stateRoot, sanitizePathToken(harness), sanitizePathToken(conversation));
|
|
99
|
+
/** 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. */
|
|
100
|
+
export const folderPodName = (key, suffix) => `bayma-${keyHash(key).slice(0, 16)}-${suffix}`;
|
|
101
|
+
export const FOLDER_POD = /^bayma-[0-9a-f]{16}-[0-9a-z]{5}$/u;
|
|
102
|
+
/** 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. */
|
|
103
|
+
export const folderTokenSecret = (pod) => `${pod}-bayma-token`;
|
|
104
|
+
const FOLDER_TOKEN_VOLUME = "alasio-bayma-token";
|
|
105
|
+
const FOLDER_TOKEN_DIRECTORY = "/run/alasio/bayma";
|
|
106
|
+
export const FOLDER_TOKEN_FILE = `${FOLDER_TOKEN_DIRECTORY}/token`;
|
|
107
|
+
/**
|
|
108
|
+
* How long a folder instance's pod is given to stop: its bayma's CRIU dumps of its idle REPL
|
|
109
|
+
* sessions, one at a time, each within bayma's own 120 s; a state of the box's size is dumped
|
|
110
|
+
* in well under a minute.
|
|
111
|
+
*/
|
|
112
|
+
export const FOLDER_STOP_SECONDS = 600;
|
|
113
|
+
/** How long a folder instance's release, or its next bind, waits for its pod to be gone, past its stop. */
|
|
114
|
+
export const FOLDER_GONE_MS = (FOLDER_STOP_SECONDS + 60) * 1000;
|
|
115
|
+
/** How long a folder instance's bind gives its pod to run, and its bayma, once it runs, to answer. */
|
|
116
|
+
export const FOLDER_START_MS = 120_000;
|
|
117
|
+
/** 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. */
|
|
118
|
+
export const FOLDER_PULL_MS = 8 * 60_000;
|
|
119
|
+
/**
|
|
120
|
+
* How long a folder instance's bind may take in all, given `pullMs` and `startMs`: a release
|
|
121
|
+
* of it under way, or its pod before, gone first; then its pod run, its image pulled; then its
|
|
122
|
+
* bayma answering. A bind of the key meanwhile waits as long for it.
|
|
123
|
+
*/
|
|
124
|
+
export const folderBindMs = (pullMs = FOLDER_PULL_MS, startMs = FOLDER_START_MS) => FOLDER_GONE_MS + pullMs + startMs;
|
|
125
|
+
/**
|
|
126
|
+
* The spec of a folder instance's pod, `pod`, of the folder template's `spec`: its bayma
|
|
127
|
+
* given its binding's token, from its Secret, and its state directory, `stateDir`; stopped
|
|
128
|
+
* within FOLDER_STOP_SECONDS; and never started again, as a bayma that ended is a binding to
|
|
129
|
+
* release, not a container to start. Pure, as the gateway makes it and the folder pods' policy
|
|
130
|
+
* pins it (cli/src/manifests/admission.ts folderPodPolicy).
|
|
131
|
+
*/
|
|
132
|
+
export function folderPodSpec(spec, pod, stateDir) {
|
|
133
|
+
return {
|
|
134
|
+
...spec,
|
|
135
|
+
terminationGracePeriodSeconds: FOLDER_STOP_SECONDS,
|
|
136
|
+
restartPolicy: "Never",
|
|
137
|
+
containers: spec.containers.map((container) => container.name !== "bayma" ? container : {
|
|
138
|
+
...container,
|
|
139
|
+
args: [...(container.args ?? []), "--token-file", FOLDER_TOKEN_FILE, "--state-dir", stateDir],
|
|
140
|
+
volumeMounts: [...(container.volumeMounts ?? []), { name: FOLDER_TOKEN_VOLUME, mountPath: FOLDER_TOKEN_DIRECTORY, readOnly: true }],
|
|
141
|
+
}),
|
|
142
|
+
volumes: [...(spec.volumes ?? []), { name: FOLDER_TOKEN_VOLUME, secret: { secretName: folderTokenSecret(pod), defaultMode: 0o440 } }],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/** The container of a harness pool's pod that runs its host, `alasio harness` (cli/src/manifests/harness-pools.ts). */
|
|
146
|
+
export const HARNESS_CONTAINER = "harness";
|
|
147
|
+
/** What a conversation's harness's key begins with: `harness:<conversation>` (./harnesses.ts). */
|
|
148
|
+
const HARNESS_KEY_PREFIX = "harness:";
|
|
149
|
+
/** The key of the harness of the conversation `conversation`, which its caller's token says the harness and workspace of. */
|
|
150
|
+
export const harnessKey = (conversation) => `${HARNESS_KEY_PREFIX}${conversation}`;
|
|
151
|
+
/** The conversation whose harness `key` is; null where it is no harness's. */
|
|
152
|
+
export function conversationOfHarnessKey(key) {
|
|
153
|
+
const conversation = key.startsWith(HARNESS_KEY_PREFIX) ? key.slice(HARNESS_KEY_PREFIX.length) : "";
|
|
154
|
+
return conversation.length > 0 && conversation.length <= 512 ? conversation : null;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Whether a caller's token of `key` may be held to the binding of `heldKey` in place of a time
|
|
158
|
+
* it stops (../binder/server.ts grants): a workspace's held to its conversation's harness's, as
|
|
159
|
+
* alasio gives a harness bound in a pool its workspace's bayma: a session's, or the
|
|
160
|
+
* conversation's own folder instance's, and no other key's.
|
|
161
|
+
*/
|
|
162
|
+
export function heldToHarness(key, heldKey) {
|
|
163
|
+
const conversation = conversationOfHarnessKey(heldKey);
|
|
164
|
+
if (conversation === null)
|
|
165
|
+
return false;
|
|
166
|
+
return volumeIdOfKey(key) !== null || folderOfKey(key)?.conversation === conversation;
|
|
167
|
+
}
|
|
168
|
+
/** A pod template, as the gateway's configuration holds one: an object, as the API server takes it. */
|
|
169
|
+
const Template = Schema.Record(Schema.String, Schema.Unknown);
|
|
170
|
+
/**
|
|
171
|
+
* How main's sessions are snapshotted (./snapshots.ts), as alasio's own were: how often one whose
|
|
172
|
+
* execs run is saved live, the gVisor releases a snapshot is restored under, each by its
|
|
173
|
+
* RuntimeClass, the current one first, and each pool's template, by its sessions' internet, as
|
|
174
|
+
* `alasio up` renders it now and as it rendered it before it last changed, which a snapshot taken
|
|
175
|
+
* on it still restores onto, and nothing older.
|
|
176
|
+
*/
|
|
177
|
+
export const GatewaySnapshots = Schema.Struct({
|
|
178
|
+
liveEverySeconds: Schema.Number,
|
|
179
|
+
/** 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). */
|
|
180
|
+
releases: Schema.Array(Schema.Struct({
|
|
181
|
+
release: Schema.String,
|
|
182
|
+
runtimeClassName: Schema.String,
|
|
183
|
+
gofer: Schema.NullOr(Schema.Struct({ transport: Schema.Literals(["socket", "tcp"]), pagesRetry: Schema.Boolean })),
|
|
184
|
+
})),
|
|
185
|
+
templates: Schema.Struct({
|
|
186
|
+
none: Schema.Struct({ current: Template, previous: Schema.NullOr(Template) }),
|
|
187
|
+
full: Schema.Struct({ current: Template, previous: Schema.NullOr(Template) }),
|
|
188
|
+
}),
|
|
189
|
+
});
|
|
190
|
+
/** The user and group a pod runs as, as the node agents write its binding (../node-agent/workspaces.ts PodOwner). */
|
|
191
|
+
const PodOwner = Schema.Struct({ uid: Schema.Number, gid: Schema.Number });
|
|
192
|
+
/** The sandbox pods' policy, which holds every pod of a sessions' namespace to its pools' templates (cli/src/manifests/admission.ts sandboxPodPolicy). */
|
|
193
|
+
export const SANDBOX_POD_POLICY = "alasio-sandbox-pods";
|
|
194
|
+
/** The gateway's configuration, as `alasio up` renders it (cli/src/manifests/sandbox-gateway.ts). */
|
|
195
|
+
export const GatewayConfig = Schema.Struct({
|
|
196
|
+
/** The port it serves on, and the host its replicas' headless Service resolves to, each at that port. */
|
|
197
|
+
port: Schema.Number,
|
|
198
|
+
peers: Schema.String,
|
|
199
|
+
/** The port pool pods' bayma serves on. */
|
|
200
|
+
podPort: Schema.Number,
|
|
201
|
+
/** How long a bind waits for a free pod, and an idle pod is kept. */
|
|
202
|
+
waitSeconds: Schema.Number,
|
|
203
|
+
releaseAfterSeconds: Schema.Number,
|
|
204
|
+
/** main's environment of sessions, by its name, and the namespace its pools are in; branch environments' are found (./environments.ts). */
|
|
205
|
+
environment: Schema.Struct({ name: Schema.String, namespace: Schema.String }),
|
|
206
|
+
/** The quota of a workspace the gateway makes, in bytes. */
|
|
207
|
+
quotaBytes: Schema.Number,
|
|
208
|
+
/** How main's sessions are snapshotted; none where they are not. */
|
|
209
|
+
snapshots: Schema.NullOr(GatewaySnapshots),
|
|
210
|
+
/** Each pool's name, by its sessions' internet. */
|
|
211
|
+
pools: Schema.Struct({ none: Schema.String, full: Schema.String }),
|
|
212
|
+
/** Where the node agents are. */
|
|
213
|
+
nodeAgents: Schema.Struct({ namespace: Schema.String, selector: Schema.String, port: Schema.Number }),
|
|
214
|
+
/** Where bound pods' bayma exports its telemetry, the session telemetry receiver's Service, by its name and port; none where none runs. */
|
|
215
|
+
receiver: Schema.NullOr(Schema.Struct({ host: Schema.String, port: Schema.Number })),
|
|
216
|
+
/**
|
|
217
|
+
* Folder conversations' instances (./folders.ts): the namespace they run in, the template of
|
|
218
|
+
* their pods, as `alasio up` renders it of the host profile, the directory under which each
|
|
219
|
+
* keeps its state, and how long an idle one is kept; none where the installation has no
|
|
220
|
+
* folder workspaces.
|
|
221
|
+
*/
|
|
222
|
+
folders: Schema.NullOr(Schema.Struct({ namespace: Schema.String, template: Template, stateRoot: Schema.String, releaseAfterSeconds: Schema.Number })),
|
|
223
|
+
/**
|
|
224
|
+
* Conversations' harnesses' pools (./harnesses.ts): each harness's pool's name, in each
|
|
225
|
+
* environment's own namespace, main's `namespace`, a branch's its own; the port and user
|
|
226
|
+
* their pods' hosts run on; how long an idle one is kept, and how long its host is given to
|
|
227
|
+
* drain as it is let go of; and, main's alone, each harness's pool of folder conversations,
|
|
228
|
+
* in main's namespace too, and their pods' user, the host profile's.
|
|
229
|
+
*/
|
|
230
|
+
harnesses: Schema.Struct({
|
|
231
|
+
namespace: Schema.String,
|
|
232
|
+
pools: Schema.Record(Schema.Literals(HARNESS_NAMES), Schema.String),
|
|
233
|
+
podPort: Schema.Number,
|
|
234
|
+
owner: PodOwner,
|
|
235
|
+
releaseAfterSeconds: Schema.Number,
|
|
236
|
+
drainSeconds: Schema.Number,
|
|
237
|
+
folders: Schema.NullOr(Schema.Struct({ pools: Schema.Record(Schema.Literals(HARNESS_NAMES), Schema.String), owner: PodOwner })),
|
|
238
|
+
}),
|
|
239
|
+
});
|
|
240
|
+
//# 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,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE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EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;KAChI,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
import { createHmac } from "node:crypto";
|
|
14
|
+
export const CODEX_HARNESS = "codex";
|
|
15
|
+
export const CLAUDE_HARNESS = "claude";
|
|
16
|
+
export const HARNESS_NAMES = Object.freeze([CODEX_HARNESS, CLAUDE_HARNESS]);
|
|
17
|
+
/** The port alasio relays its Codex login to its harness pools' pods on (../codex/login-relay.ts). */
|
|
18
|
+
export const CODEX_LOGIN_PORT = 4320;
|
|
19
|
+
/**
|
|
20
|
+
* How long the relay of the Codex login, told to stop, lets the requests it passes on run to
|
|
21
|
+
* their end, a model's answer streaming as long as it does, before it cuts those left
|
|
22
|
+
* (../codex/login-relay.ts): its pod is given this and a little more to stop in.
|
|
23
|
+
*/
|
|
24
|
+
export const CODEX_LOGIN_DRAIN_SECONDS = 120;
|
|
25
|
+
/** The variable the relay of the Codex login is given the key it checks the turns' tokens by in, in hexadecimal (poolLoginKey). */
|
|
26
|
+
export const CODEX_LOGIN_KEY_VARIABLE = "ALASIO_CODEX_LOGIN_KEY";
|
|
27
|
+
/**
|
|
28
|
+
* The key alasio's pool login tokens, which the relay of the Codex login checks
|
|
29
|
+
* (../codex/login-relay.ts), are signed with: its environment's own key of the gateway's caller
|
|
30
|
+
* key's, made apart, so a token of one is never the other, and the relay, holding it alone, signs
|
|
31
|
+
* none of the environment's sessions' tokens.
|
|
32
|
+
*/
|
|
33
|
+
export const poolLoginKey = (environmentKey) => createHmac("sha256", environmentKey).update("codex-login").digest();
|
|
34
|
+
const DISPLAY_NAMES = Object.freeze({
|
|
35
|
+
[CODEX_HARNESS]: "Codex",
|
|
36
|
+
[CLAUDE_HARNESS]: "Claude",
|
|
37
|
+
});
|
|
38
|
+
export function isHarnessName(candidate) {
|
|
39
|
+
const names = HARNESS_NAMES;
|
|
40
|
+
return typeof candidate === "string" && names.includes(candidate);
|
|
41
|
+
}
|
|
42
|
+
export function normalizeHarnessName(candidate, fallback = CODEX_HARNESS) {
|
|
43
|
+
if (typeof candidate !== "string") {
|
|
44
|
+
return fallback;
|
|
45
|
+
}
|
|
46
|
+
const lowered = candidate.trim().toLowerCase();
|
|
47
|
+
if (lowered === "claude" || lowered === "claude-code" || lowered === "claude_code" || lowered === "claudecode" || lowered === "claude code") {
|
|
48
|
+
return CLAUDE_HARNESS;
|
|
49
|
+
}
|
|
50
|
+
if (lowered === "codex") {
|
|
51
|
+
return CODEX_HARNESS;
|
|
52
|
+
}
|
|
53
|
+
return fallback;
|
|
54
|
+
}
|
|
55
|
+
export function harnessDisplayName(harness) {
|
|
56
|
+
return (harness && DISPLAY_NAMES[harness]) ?? DISPLAY_NAMES[CODEX_HARNESS];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Harness pre-mounted on newly created conversations.
|
|
60
|
+
*
|
|
61
|
+
* Neutral by default: returns null unless ALASIO_DEFAULT_HARNESS opts into a
|
|
62
|
+
* harness, in which case new conversations skip the picker.
|
|
63
|
+
*/
|
|
64
|
+
export function getDefaultHarness(env = process.env) {
|
|
65
|
+
return normalizeHarnessName(env["ALASIO_DEFAULT_HARNESS"], null);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