The new app reached a real LLM but never ran an agent: the kickoff task_run sat queued forever and runTask was a single text completion with no tools. This adds the missing runtime: - provider-tool-turn: OpenAI Responses + Anthropic Messages tool-use turns - agent-tools + deliverable-writer: hire_agent, create_task, update_task_status, write_deliverable (workspace-scoped, traversal-safe) - agent-run-loop: real tool-use loop, capped iterations - task-queue-worker: claims queued runs in a transaction and executes them task-execution now drives the loop; a background worker auto-runs the bootstrap CEO run so it hires its team, delegates tasks, and writes the first deliverable into the bound workspace. Autonomy is gated by AGENTCOMPANY_NEW_AUTORUN (tests run with it off to stay hermetic).
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import { mkdirSync, writeFileSync } from "node:fs";
|
|
import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
|
|
/**
|
|
* Writes an agent deliverable into the run's bound workspace folder.
|
|
*
|
|
* The target path is resolved against the workspace root and rejected if it
|
|
* escapes that root (path traversal / absolute paths), so an agent can only
|
|
* write inside the folder the operator bound to the company.
|
|
*/
|
|
export function writeDeliverable(input: { workspaceRoot: string; relativePath: string; content: string }): string {
|
|
const root = resolve(input.workspaceRoot);
|
|
const requested = input.relativePath.trim().replace(/^[\\/]+/, "");
|
|
if (!requested) throw new Error("Deliverable path is required.");
|
|
if (isAbsolute(requested)) throw new Error("Deliverable path must be relative to the workspace.");
|
|
const target = resolve(root, requested);
|
|
const rel = relative(root, target);
|
|
if (rel === "" || rel.startsWith("..") || isAbsolute(rel)) {
|
|
throw new Error("Deliverable path escapes the workspace root.");
|
|
}
|
|
mkdirSync(dirname(target), { recursive: true });
|
|
writeFileSync(target, input.content, "utf8");
|
|
return rel.split(sep).join("/");
|
|
}
|