clawdie-ai/scripts/agent-task.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';
const description = process.argv[2];
if (!description) {
console.error('Usage: agent-task.ts <description>');
process.exit(1);
}
async function main(): Promise<void> {
try {
const res = await fetch(
`http://${API_HOST}:${API_PORT}/api/controlplane/tasks`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title: description, description }),
},
);
if (!res.ok) {
console.error(`API error ${res.status}: ${await res.text()}`);
process.exit(1);
}
const data = (await res.json()) as Record<string, unknown>;
const task = data.task as Record<string, unknown> | undefined;
if (task?.id) {
console.log(`Task created: ${task.id}`);
console.log(` Title: ${description}`);
} else {
console.log('Task created (no id returned)');
}
} 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}`,
);
} else {
console.error('Error:', msg);
}
process.exit(1);
}
}
main();