Merge branch 'fix/central-status'
This commit is contained in:
@@ -25,3 +25,4 @@ npm-debug.log*
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
temp/
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …).
|
||||
|
||||
## agent@1.0.1 - 2026-11-18
|
||||
|
||||
- A `status` job on the central server is answered by the agent itself (its stats, frps and
|
||||
the agent version). It used to run `crosscode status`, which central servers don't have, and
|
||||
failed with `spawn /usr/local/bin/crosscode ENOENT`.
|
||||
|
||||
## events@2.3.0, contracts@1.3.0, agent@1.0.0 - 2026-11-17
|
||||
|
||||
Phase 1c (authenticator-app sign-in) and phase 1d (docs/AGENT-1.0-PLAN.md): installs, updates and
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/agent",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"private": true,
|
||||
"description": "The server agent: runs the crosscode script for signed jobs from Cross Code Hub, reports stats (docs/AGENT-1.0-PLAN.md)",
|
||||
"license": "UNLICENSED",
|
||||
|
||||
@@ -159,6 +159,15 @@ export class Agent {
|
||||
}
|
||||
case "export":
|
||||
return await this.runExport(job, limit);
|
||||
case "status":
|
||||
// The central server has no crosscode script (install.sh --central): its status is the
|
||||
// agent's own stats, with frps.
|
||||
if (this.deps.config.mode === "central") {
|
||||
const stats = await (this.deps.stats ?? (() => collectStats("central")))();
|
||||
const warning = stats.central && !stats.central.frpsRunning ? "frps isn't running." : undefined;
|
||||
return { status: "succeeded", steps: [], result: { stats } as unknown as Record<string, unknown>, message: warning, log: [], startedAt, finishedAt: new Date().toISOString() };
|
||||
}
|
||||
return await this.run(crosscodeArgs(job)!, job, limit);
|
||||
default: {
|
||||
const args = crosscodeArgs(job);
|
||||
if (!args) throw new Error(`No command for ${job.type}`);
|
||||
|
||||
@@ -12,7 +12,7 @@ import { paths } from "./paths";
|
||||
* the tools that are there; anything missing is null rather than an error.
|
||||
*/
|
||||
|
||||
export const AGENT_VERSION = "1.0.0";
|
||||
export const AGENT_VERSION = "1.0.1";
|
||||
|
||||
function run(cmd: string, args: string[], timeoutMs = 10_000): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
|
||||
@@ -104,6 +104,24 @@ describe("the agent loop", () => {
|
||||
expect(fs.readdirSync(path.join(state, "exports"))).toEqual([]);
|
||||
});
|
||||
|
||||
it("status on the central server: its own stats, without crosscode (which isn't installed there)", async () => {
|
||||
const h = fakeHub([job({ type: "status", args: {} })]);
|
||||
const run = jest.fn<ReturnType<Run>, Parameters<Run>>(async () => ok());
|
||||
const stats = { schema: "crosscode.agent-stats/1", central: { proxyBindAddr: "127.0.0.1", allowPorts: null, frpsRunning: true } } as unknown as agent.AgentStats;
|
||||
const a = new Agent({ config: { ...config, mode: "central" }, keys: { ed25519Pem: serverKeys.ed25519.privateKeyPem, x25519Pem: serverKeys.x25519.privateKeyPem }, hub: h.hub, seen: new SeenJobs(path.join(state, `seen-${Math.random()}.json`)), run, stats: async () => stats, now: () => NOW });
|
||||
await a.pollOnce();
|
||||
expect(run).not.toHaveBeenCalled();
|
||||
const r = reports(h.posts)[0]!;
|
||||
expect(r).toMatchObject({ type: "status", status: "succeeded", result: { stats } });
|
||||
expect(agent.agentReportSchema.safeParse(r).success).toBe(true);
|
||||
});
|
||||
|
||||
it("status on a church server runs crosscode status", async () => {
|
||||
const { a, run } = make([job({ type: "status", args: {} })]);
|
||||
await a.pollOnce();
|
||||
expect(run.mock.calls[0]![0]).toEqual(["status", "--no-fetch"]);
|
||||
});
|
||||
|
||||
it("a job that throws is reported as failed", async () => {
|
||||
const { a, posts } = make([job()], jest.fn<ReturnType<Run>, Parameters<Run>>(async () => { throw new Error("boom"); }));
|
||||
await a.pollOnce();
|
||||
|
||||
Generated
+1
-1
@@ -40,7 +40,7 @@
|
||||
},
|
||||
"apps/agent": {
|
||||
"name": "@crosscode/agent",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@crosscode/contracts": "*",
|
||||
|
||||
Reference in New Issue
Block a user