Agent 1.0.0: polls the Hub for signed jobs, runs crosscode, sends reports and stats
apps/agent (docs/AGENT-1.0-PLAN.md §3-4, §10): listens on nothing; checks every job (pinned Hub key, server, time window, replays for 90 days, type per mode, strict arguments) before running crosscode with an argument array; opens the sealed config into a root-only file only for the job; redacts log lines; keeps unsent reports in an outbox; encrypts exports before upload; check-ports on the central server (read-only); self-update with automatic revert. One bundled dist/cli.js, a systemd unit and the install script that joins a server with a one-time token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { generateEd25519, generateX25519, signJob } from "@crosscode/contracts/signing";
|
||||
import type { AgentConfig } from "../src/config";
|
||||
|
||||
export const hubKeys = generateEd25519();
|
||||
export const serverKeys = { ed25519: generateEd25519(), x25519: generateX25519() };
|
||||
|
||||
export const config: AgentConfig = {
|
||||
hubUrl: "https://hub.test",
|
||||
serverId: "srv_test00001",
|
||||
mode: "church",
|
||||
hubJobKey: hubKeys.publicKey,
|
||||
pollSeconds: 30,
|
||||
statsSeconds: 60,
|
||||
joinedAt: "2026-11-20T00:00:00.000Z",
|
||||
};
|
||||
|
||||
export const NOW = new Date("2026-11-20T12:05:00.000Z");
|
||||
|
||||
let n = 0;
|
||||
export function job(over: Record<string, unknown> = {}, key = hubKeys.privateKeyPem) {
|
||||
n++;
|
||||
return signJob({
|
||||
schema: "crosscode.agent-job/1",
|
||||
id: `job_test${String(n).padStart(6, "0")}`,
|
||||
serverId: config.serverId,
|
||||
type: "deploy",
|
||||
args: { church: "hope", products: ["events"], versions: ["events@2.4.1"] },
|
||||
config: null,
|
||||
notBefore: "2026-11-20T12:00:00.000Z",
|
||||
expiresAt: "2026-11-20T12:15:00.000Z",
|
||||
...over,
|
||||
}, key);
|
||||
}
|
||||
|
||||
/** A temporary state folder per test file. */
|
||||
export function tempState(): string {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "agent-test-"));
|
||||
process.env.CROSSCODE_AGENT_STATE_DIR = dir;
|
||||
process.env.CROSSCODE_AGENT_RUN_DIR = path.join(dir, "run");
|
||||
return dir;
|
||||
}
|
||||
Reference in New Issue
Block a user