@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
87 lines (86 loc) • 3.02 kB
TypeScript
import { z } from "zod";
import { type Target } from "./protocol.js";
import type { DeliveryStatus } from "./prompt-deliveries.js";
import { type TurnRecord } from "./turn-records.js";
declare const itemSchema: z.ZodObject<{
id: z.ZodString;
target: z.ZodObject<{
server: z.ZodString;
workspace: z.ZodString;
tab: z.ZodString;
pane: z.ZodString;
source: z.ZodEnum<{
claude: "claude";
codex: "codex";
copilot: "copilot";
opencode: "opencode";
phren: "phren";
}>;
session: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
}, z.core.$strip>;
terminal: z.ZodString;
text: z.ZodString;
state: z.ZodEnum<{
cancelled: "cancelled";
delivered: "delivered";
failed: "failed";
queued: "queued";
sending: "sending";
unknown: "unknown";
}>;
reason: z.ZodOptional<z.ZodEnum<{
"agent-restarted": "agent-restarted";
"conversation-changed": "conversation-changed";
"delivery-failed": "delivery-failed";
"pane-closed": "pane-closed";
}>>;
detail: z.ZodOptional<z.ZodString>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
}, z.core.$strip>;
export type TurnQueueItem = z.infer<typeof itemSchema>;
export interface TurnQueuePane {
terminal: string;
source: string;
session?: string;
record?: TurnRecord;
/** Includes session-activity's awaited shells and running children. */
background: number;
held: boolean;
ready: boolean;
}
export interface TurnQueueDeps {
/** Undefined means confirmed absent; transport/read failures must throw. */
current(target: Target): Promise<TurnQueuePane | undefined>;
send(target: Target, text: string, id: string, typing: () => Promise<void>): Promise<Record<string, unknown>>;
delivery(target: Target, id: string): DeliveryStatus;
/** During the typing recheck, exclude only this item’s own reservation. */
holding(target: Target, exceptId?: string): boolean;
}
export declare class TurnQueue {
private file;
private deps;
private items;
private boundaries;
private serial;
private ticking?;
constructor(file: string, deps: TurnQueueDeps);
private run;
private save;
private prune;
count(server: string, pane: string): number;
list(target: Target): TurnQueueItem[];
private find;
enqueue(target: Target, id: string, text: string): Promise<TurnQueueItem>;
change(target: Target, id: string, text?: string): Promise<TurnQueueItem>;
private fail;
private settle;
private eligible;
tick(): Promise<void>;
private reconcilable;
private drain;
}
/** POST siblings of /v1/prompt, with its full authenticated target contract.
* Listing/editing/cancelling use the original target even after its pane closes. */
export declare function turnQueueRoute(queue: TurnQueue, route: string, data: unknown): Promise<unknown>;
export {};