clawdie-ai/scripts/agent-status.ts
Clawdie AI 2160e7859e feat(phase4): just front door + safety rules + bugfix (Sam & Claude)
Rewrites justfile with 8 groups, 35+ recipes with docstrings.

Creates 8 CLI helper scripts (jail-status, hostd-cli, system-health,

agent-status, agent-task, agent-task-status, agent-logs, jail-provision).

Adds 4 hostd safety rules to safety.yaml (destroy, rollback, zfs-destroy, pf).

Fixes task_create empty assigned_to bug in controlplane-tools.ts.

Build: pass | Tests: not run (Linux)
2026-04-14 01:28:31 +02:00

49 lines
1.3 KiB
TypeScript

const API_PORT = parseInt(process.env.CONTROLPLANE_PORT ?? '3100', 10);
const API_HOST = process.env.CONTROLPLANE_BIND_HOST ?? '127.0.0.1';
async function apiGet(path: string): Promise<unknown> {
const res = await fetch(`http://${API_HOST}:${API_PORT}${path}`);
if (!res.ok) throw new Error(`API ${res.status}: ${await res.text()}`);
return res.json();
}
async function main(): Promise<void> {
try {
const data = (await apiGet('/api/controlplane/state')) as Record<
string,
unknown
>;
const agents =
((data as Record<string, unknown>).agents as Array<
Record<string, unknown>
>) ?? [];
if (agents.length === 0) {
console.log('No registered agents.');
return;
}
console.log('Agent ID\t\tProfile\t\tStatus');
console.log('-'.repeat(50));
for (const a of agents) {
console.log(
`${a.id ?? '?'}\t\t${a.profile ?? '?'}\t\t${a.status ?? '?'}`,
);
}
console.log(`\n${agents.length} agent(s)`);
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
if (msg.includes('ECONNREFUSED')) {
console.error(
'Controlplane API not reachable at',
`${API_HOST}:${API_PORT}`,
);
console.error('Is the controlplane running?');
} else {
console.error('Error:', msg);
}
process.exit(1);
}
}
main();