UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

47 lines (46 loc) • 3.12 kB
import { type Json, type Target } from "./protocol.js"; import type { Schedule, ScheduleLauncher, ScheduleLaunchContext, ScheduleLaunchRecord, ScheduleLaunchResult, ScheduleRun, ScheduleRunOutcome } from "./schedule-format.js"; import { realTranscriptStamp, watchHerdrRun } from "./schedule-watch.js"; type HerdrLauncher = (server: string, data: Json) => Promise<Json>; /** Types a prompt into a live session: the Hook's hand-off queue. */ export type ScheduleDeliver = (target: Target, text: string, deliveryId: string) => Promise<Json>; export declare function createScheduleLauncher(launchHerdr: HerdrLauncher, store?: string, deliver?: ScheduleDeliver): ScheduleLauncher; export interface ContinueEnv { panes?: (server: string) => Promise<Json[]>; transcriptStamp?: typeof realTranscriptStamp; watch?: typeof watchHerdrRun; /** The conversation a pane runs, for a record that never learned its id. */ identity?: (server: string, pane: Json) => Promise<string | undefined>; /** The pane's visible lines, to see a dialog that would swallow the prompt. */ screen?: (server: string, pane: string) => Promise<string>; keys?: (server: string, pane: string, keys: string[]) => Promise<void>; /** Closes a finished pane of this schedule once a newer one has taken the firing. */ close?: (server: string, pane: Json) => Promise<void>; } /** * `session: reuse`: types the prompt into the newest session of this schedule * whose pane still runs its harness (`previous`, newest first). A busy newest * session is skipped rather than given a second prompt; a pane whose prompt * cannot be delivered (a dialog that will not dismiss, a refused delivery) * passes the firing to the next older one. Once a pane has taken the firing, * the schedule's older finished panes are closed. Undefined when no session is * left (the panes closed, their agents exited, their conversations were * replaced), so the caller starts a new one, which the next firing continues. */ export declare function continueSession(context: ScheduleLaunchContext, previous: ScheduleLaunchRecord[], deliver: ScheduleDeliver, signal: AbortSignal, env?: ContinueEnv): Promise<ScheduleLaunchResult | undefined>; /** * The outcome of a run a previous Hook process launched and never saw finish * (a restart or crash mid-run). A Herdr pane is followed again to its real * end; a headless job's manifest says how it ended, if it got that far. A run * whose end cannot be known fails with that reason rather than staying open, * since an open run blocks its schedule for good. */ export declare function resumeScheduleRun(run: ScheduleRun, schedule: Schedule, signal: AbortSignal, watch?: typeof watchHerdrRun): Promise<ScheduleRunOutcome>; /** The environment a headless run gets: this Hook's, SUDO_ASKPASS, plus the chosen Claude account's config directory. */ export declare function headlessEnv(schedule: Schedule, env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv; export declare function headlessCommand(schedule: Schedule, cwd: string): { file: string; args: string[]; cwd: string; }; export {};