Agent 1.4.0 + contracts 1.15.0: frp config anywhere, edited from the Hub; ports probed before installs
- The agent finds frps/frpc's config (Hub path, systemd -c, usual places) and reads INI and TOML. - New jobs frp-read, frp-write (secrets kept on the server, verify, backup, restart, roll back) and probe-ports (which ports are free here), on central and church servers. - Stats report frpConfigPath; crosscode gets FRPC_INI on church servers. - Website plan versions move up to contracts 1.16.0 and Hub 2.12.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+23
-3
@@ -2,7 +2,8 @@ import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { agent } from "@crosscode/contracts";
|
||||
import { encryptExport } from "@crosscode/contracts/signing";
|
||||
import { checkPorts, listeningNow, readFrps } from "./central";
|
||||
import { checkPorts, listeningNow } from "./central";
|
||||
import { currentSettings, findConfig, probePorts, readConfig, writeConfig } from "./frp";
|
||||
import { crosscodeArgs } from "./command";
|
||||
import type { AgentConfig, Keys } from "./config";
|
||||
import { type HubClient, HubRequestError } from "./hub";
|
||||
@@ -153,10 +154,25 @@ export class Agent {
|
||||
return { status: u.status, steps: u.steps, result: u.result, message: u.message, log: [], startedAt, finishedAt: new Date().toISOString(), restart: u.restart };
|
||||
}
|
||||
case "check-ports": {
|
||||
const res = checkPorts(job.args.ports, readFrps(), await listeningNow());
|
||||
const { path: configPath, settings } = await currentSettings("central");
|
||||
const res = checkPorts(job.args.ports, settings, await listeningNow(), configPath);
|
||||
const ok = res.ports.every((p) => p.ok) && res.warnings.length === 0;
|
||||
return { status: ok ? "succeeded" : "failed", steps: [], result: res as unknown as Record<string, unknown>, message: res.warnings.join(" ") || undefined, log: [], startedAt, finishedAt: new Date().toISOString() };
|
||||
}
|
||||
case "frp-read": {
|
||||
const result = await readConfig(this.deps.config.mode, { path: job.args.path });
|
||||
const message = result.found ? undefined : `No ${result.service} config found${result.path ? ` at ${result.path}` : ""}.`;
|
||||
return { status: result.found ? "succeeded" : "failed", steps: [], result: result as unknown as Record<string, unknown>, message, log: [], startedAt, finishedAt: new Date().toISOString() };
|
||||
}
|
||||
case "frp-write": {
|
||||
const w = await writeConfig(this.deps.config.mode, job.args);
|
||||
return { status: w.status, steps: w.steps, result: w.result, message: w.message, log: [], startedAt, finishedAt: new Date().toISOString() };
|
||||
}
|
||||
case "probe-ports": {
|
||||
const { path: configPath, settings } = await currentSettings(this.deps.config.mode);
|
||||
const result = probePorts(job.args.ports, this.deps.config.mode, settings, await listeningNow(), configPath);
|
||||
return { status: "succeeded", steps: [], result: result as unknown as Record<string, unknown>, log: [], startedAt, finishedAt: new Date().toISOString() };
|
||||
}
|
||||
case "export":
|
||||
return await this.runExport(job, limit);
|
||||
case "status":
|
||||
@@ -181,7 +197,11 @@ export class Agent {
|
||||
|
||||
private run(args: string[], job: agent.AgentJob, limit: number): Promise<RunResult> {
|
||||
if (this.deps.run) return this.deps.run(args, job);
|
||||
return runCrosscode({ args, sealedConfig: job.config ?? null, x25519Pem: this.deps.keys.x25519Pem, timeLimitMinutes: limit });
|
||||
return (async () => {
|
||||
// crosscode edits frpc's config on installs: tell it where the file is (agent 1.4.0).
|
||||
const frpc = this.deps.config.mode === "church" ? (await findConfig("church").catch(() => null))?.path : null;
|
||||
return runCrosscode({ args, sealedConfig: job.config ?? null, x25519Pem: this.deps.keys.x25519Pem, timeLimitMinutes: limit, env: frpc ? { FRPC_INI: frpc } : {} });
|
||||
})();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user