Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Merge origin/main: the box channel's state record beside the home's secrets folder

milind-sonib56e8774d8c0
diff --cc connector/src/state.ts
index c318a61a30,1c62b6efd7..978116d60a
--- a/connector/src/state.ts
+++ b/connector/src/state.ts
@@@ -1,17 -1,18 +1,21 @@@
// The connector's state volume: small JSON files, each written whole (temp file, then rename) and readable by root only,
- // in a folder only root may enter. The agent token and the home's environment live here and nowhere else; the home's
- // secrets are also in their own folder, the only one a container (the home, read-only) ever mounts.
-// in a folder only root may enter. The box's private key and the home's environment live here and nowhere else.
++// in a folder only root may enter. The box's private key and the home's environment live here and nowhere else; the
++// home's secrets are also in their own folder, the only one a container (the home, read-only) ever mounts.
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
import { join } from "node:path";
+import { HOME_SECRET_ENV, HOME_SECRETS_DIR, HOME_SECRETS_FILE } from "./settings.ts";
+
export interface AgentRecord {
- version: 1;
+ version: 2;
admin: string;
- serverId: string;
- cloudId: string;
- agentToken: string;
+ boxId: string;
+ teamId: string;
+ /** The box key: its public half as the Admin has it, and its private half (PKCS #8, base64url), a secret. */
+ publicKey: string;
+ privateKey: string;
+ /** The Admin's signing keys by id, pinned at enrolment; only a hello signed by one of them replaces them. */
+ adminKeys: Record<string, string>;
enrolledAt: number;
}
diff --cc connector/test/protocol.test.ts
index 5bc8aeca10,9e82d55e52..c680d1adb5
--- a/connector/test/protocol.test.ts
+++ b/connector/test/protocol.test.ts
@@@ -1,10 -1,11 +1,13 @@@
import { describe, expect, it } from "vitest";
-import { cloudRequestSignature as homeSignature } from "../../server/cloud-home.ts";
+import { CLOUD_HOME_SECRET_KEYS, cloudRequestSignature as homeSignature } from "../../server/cloud-home.ts";
+import { CAPS_DROPPED_ENV, CLOUD_SECRETS_FILE, CLOUD_SECRETS_FILE_KEYS } from "../../server/cloud-home-start.ts";
+import { HOME_SECRET_ENV, HOME_SECRETS_FILE, HOME_SECRETS_TARGET } from "../src/settings.ts";
import { cloudRequestSignature, summarizeHealth } from "../src/home-health.ts";
- import { checkEnrollCode, checkEnrollResponse, checkHomeEnv, checkJob, checkTransferUrl, JOB_TYPES, REQUIRED_HOME_ENV } from "../src/protocol.ts";
+ import {
+ checkConfig, checkEnrollCode, checkEnrollResponse, checkHello, checkHomeEnv, checkJob, checkJobPayload, checkTransferUrl, JOB_LIFETIME_MS, JOB_TYPES, REQUIRED_HOME_ENV,
+ } from "../src/protocol.ts";
+ import { generateKeyPair, seal, unseal } from "../src/signed.ts";
const HOME = `ghcr.io/milind-soni/openmausbot-cloud-home@sha256:${"a".repeat(64)}`;
const CONNECTOR = `ghcr.io/milind-soni/mausbot-connector@sha256:${"b".repeat(64)}`;