UNPKG

framework

Version:

The (AI) Framework: turnkey, zero-config AI orchestration that wraps a coding-agent CLI (Claude Code) as a black box and takes you from an idea to a running app. Vite for AI.

37 lines 1.65 kB
import { readFile } from 'node:fs/promises'; import { resolve } from 'node:path'; // The pieces every driver session needs but that are not agent-specific: emitting events // without letting a listener throw into the agent, folding the session + per-call signals and // framing, and reading a workspace file. The agent-specific parts (argv, the output parser, // how framing is delivered) stay in each driver; these do not, so a second driver reuses // them rather than copying them. /** * A {@link DriverStartOptions.onEvent} caller that never lets a listener throw into the * driver — a throwing dashboard handler must not abort the agent. An absent `onEvent` * is a no-op. `driver` names it in the swallow log so a thrown handler stays traceable. */ export function makeEmit(onEvent, driver) { if (!onEvent) return () => { }; return event => { try { onEvent(event); } catch (err) { console.error(`[framework] ${driver} onEvent threw; ignoring:`, err); } }; } /** The live AbortSignals for a prompt — the session's and the per-call one, minus the absent. */ export function combineSignals(...signals) { return signals.filter((s) => s != null); } /** Fold a session's framing and a per-call system prompt into one blank-line-separated block. */ export function combineFraming(...parts) { return parts.filter(Boolean).join('\n\n'); } /** Read a workspace file relative to the session cwd — the driver's `readCode`. */ export function readWorkspaceFile(cwd, path) { return readFile(resolve(cwd, path), 'utf8'); } //# sourceMappingURL=session-support.js.map