Replace remaining executable-code mevy assumptions with config-derived values. This updates operator messaging, runtime prompts, agent-task role defaults, inspect-system fallbacks, and OpenRouter metadata headers to follow PLATFORM_SERVICE_NAME, PLATFORM_ID, TENANT_ID, and PROJECT_ROOT instead of the live example tenant. --- Build: pass | Tests: FAIL — Tests 3 failed | 2089 passed (2092)
89 lines
2.3 KiB
TypeScript
89 lines
2.3 KiB
TypeScript
import { CONTROLPLANE_INTERNAL_DOMAIN, TENANT_ID } from '../src/config.js';
|
|
|
|
const API_PORT = parseInt(process.env.CONTROLPLANE_PORT ?? '3100', 10);
|
|
const API_HOST = process.env.CONTROLPLANE_BIND_HOST ?? '127.0.0.1';
|
|
|
|
const DEFAULT_ASSIGNED_TO = 'coordinator';
|
|
const KNOWN_ROLES = new Set([
|
|
'coordinator',
|
|
'sysadmin',
|
|
'db-admin',
|
|
'git-admin',
|
|
TENANT_ID,
|
|
]);
|
|
|
|
const arg1 = process.argv[2];
|
|
const argRest = process.argv.slice(3).join(' ').trim();
|
|
|
|
const assignedTo =
|
|
arg1 && KNOWN_ROLES.has(arg1) ? arg1 : DEFAULT_ASSIGNED_TO;
|
|
const title =
|
|
arg1 && KNOWN_ROLES.has(arg1)
|
|
? argRest
|
|
: process.argv.slice(2).join(' ').trim();
|
|
|
|
if (!title) {
|
|
console.error(
|
|
`Usage:
|
|
agent-task.ts <title...> # defaults assigned_to=${DEFAULT_ASSIGNED_TO}
|
|
agent-task.ts <role> <title...> # role in: ${Array.from(KNOWN_ROLES).join(', ')}`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
try {
|
|
const secret = process.env.CONTROLPLANE_SHARED_SECRET;
|
|
if (!secret) {
|
|
console.error('Missing CONTROLPLANE_SHARED_SECRET in environment');
|
|
process.exit(1);
|
|
}
|
|
|
|
const res = await fetch(
|
|
`http://${API_HOST}:${API_PORT}/api/controlplane/tasks`,
|
|
{
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
Authorization: `Bearer ${secret}`,
|
|
},
|
|
body: JSON.stringify({
|
|
title,
|
|
description: title,
|
|
assigned_to: assignedTo,
|
|
priority: 'medium',
|
|
}),
|
|
},
|
|
);
|
|
|
|
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 taskId = typeof data.task_id === 'string' ? data.task_id : '';
|
|
|
|
if (!taskId) {
|
|
console.log('Task created (no task_id returned)');
|
|
return;
|
|
}
|
|
|
|
console.log(`Task created: ${taskId}`);
|
|
console.log(` Assigned: ${assignedTo}`);
|
|
console.log(` Title: ${title}`);
|
|
} catch (err) {
|
|
const msg = err instanceof Error ? err.message : String(err);
|
|
if (msg.includes('ECONNREFUSED')) {
|
|
console.error(
|
|
`${CONTROLPLANE_INTERNAL_DOMAIN} controlplane API not reachable at`,
|
|
`${API_HOST}:${API_PORT}`,
|
|
);
|
|
} else {
|
|
console.error('Error:', msg);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
main();
|