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.

104 lines 5.42 kB
import type { Driver } from './driver/index.js'; import { type ChoicePick, type ChoiceRequest, type FrameworkEvent } from './events.js'; import { type BindProjectDeps, type RecordMessage } from './await-gate.js'; import { type EcoOptions } from './system-prompt.js'; import type { RunMessages } from './run-messages.js'; /** * The direct prompt path (#331): run *one prompt* through the driver and honor * its await gates — no scope/build scaffolding, no review loop. This * is what a review-shaped preset like [Research] needs: the prompt operates on * existing code, stops at `showChoices()` / `showMultiSelect()` + AWAIT, and * continues from the user's answer. Plumbing, not babysitting — the framework * adds nothing but the gate protocol and the usage/budget accounting. */ /** Options for {@link runPrompt}. */ export interface RunPromptOptions { /** The fully rendered prompt to run (see e.g. `renderResearchPrompt`). */ prompt: string; /** The driver wrapping the coding agent. */ driver: Driver; /** Workspace the agent works in. */ cwd: string; /** Receives every {@link FrameworkEvent} as it happens (dashboard, terminal, store). */ onEvent?: (event: FrameworkEvent) => void; /** * The interactive gate handler, exactly as in `RunFrameworkOptions` (#304). * Unlike a build run, a *headless* direct run still resolves each gate to its * defaults and continues — the prompt's post-gate steps must run either way. */ requestChoice?: (req: ChoiceRequest) => Promise<ChoicePick>; /** Abort to stop the run (Stop button / Ctrl+C / control channel). */ signal?: AbortSignal; /** Model override passed through to the driver. */ model?: string; /** A user SYSTEM.md to append to the built-in system prompt (#301). */ systemPrompt?: string; /** Include the built-in #326 system prompt. Default true (#301; the name is the historical config key). */ antiLazyPill?: boolean; /** This run has a real browser (#824), so the system channel says so. */ browser?: boolean; /** * This is a project-less "topic" run (#1120): advertise the bind gate (#1121) in the system * channel and wire {@link bind} so an `await-bind-project` / `await-create-project` gate resolves. */ topic?: boolean; /** The bind seams (#1121) a topic run's gate resolves against. Only meaningful with {@link topic}. */ bind?: BindProjectDeps; /** Transparent mode (#625): empty the system channel and pass the prompt verbatim (raw `claude -p`). */ transparent?: boolean; /** Whether autopilot mode is on: steers the #326 prompt's maintenance stance (#325). Default false. */ autopilot?: boolean; /** Eco fine-grained control (#314): drop the enabled #326 sections to save tokens. */ eco?: EcoOptions; /** In-context directories (#439): added as one `Context:` line to the system prompt. */ context?: readonly string[]; /** Stop the run once the agent has spent this much, in USD (#322). */ budgetUsd?: number; /** * Consult the consumption limits between turns (#531): return the limit that * has been reached to pause the run, or `null` to carry on. Same seam and same * fail-open as a build run — see `RunFrameworkOptions.consumptionGate`. */ consumptionGate?: () => string | null; /** Session link template for the dashboard, `{sessionId}` resolved when known. */ sessionLink?: string; /** * Live chat (#714): once the prompt settles, take the user's own messages, each * resuming the same session. The session then ends itself when the queue is idle * (#1390) unless {@link stayOpenChat} parks it. Unset for a headless run, which * ends when the agent stops asking — exactly as before. */ messages?: RunMessages; /** * Keep the chat parked for the next message instead of ending on an idle queue (#1390). * Only for a run whose own terminal dashboard is the single surface — it has no daemon * to resume the session through, so ending would leave its composer a dead end. */ stayOpenChat?: boolean; /** Record each chat turn to the committed conversation (#908). Best-effort; unset = not recorded. */ recordMessage?: RecordMessage; /** * Resume a finished run's conversation (#720): the captured agent session id to * continue. When set, the prompt is sent as a plain continuation message that * `--resume`s that session (full prior context), and the built-in system framing * is skipped (the resumed transcript already carries it). This is what the * dashboard sends when you message a run that has already ended. */ resumeSessionId?: string; } /** What {@link runPrompt} resolves with. */ export interface RunPromptResult { /** The final turn's text. */ text: string; /** Every event emitted, in order. */ events: FrameworkEvent[]; } /** * Run one prompt to completion through the driver, pausing on each await gate * (#337/#339) and re-prompting with the user's answer. Emits the same * {@link FrameworkEvent} stream a build run does (`session`, `driver`, `choice`, * `usage`, `end`), so the dashboard, the store, and the control channel (#344) * all work unchanged. */ export declare function runPrompt(opts: RunPromptOptions): Promise<RunPromptResult>; //# sourceMappingURL=prompt-run.d.ts.map