UNPKG

@phren/cli

Version:

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

99 lines (98 loc) • 5.33 kB
import { z } from "zod"; import { type Json } from "./protocol.js"; import type { PeerIdentity } from "./request-origin.js"; export declare const continuationLaunchSchema: z.ZodObject<{ workerDispatch: z.ZodOptional<z.ZodString>; worker: z.ZodDefault<z.ZodBoolean>; computerId: z.ZodString; project: z.ZodString; to: z.ZodObject<{ computer: z.ZodOptional<z.ZodString>; harness: z.ZodEnum<{ claude: "claude"; codex: "codex"; copilot: "copilot"; opencode: "opencode"; }>; account: z.ZodOptional<z.ZodString>; model: z.ZodOptional<z.ZodString>; effort: z.ZodOptional<z.ZodEnum<{ high: "high"; low: "low"; max: "max"; medium: "medium"; minimal: "minimal"; xhigh: "xhigh"; }>>; }, z.core.$strict>; label: z.ZodString; brief: z.ZodObject<{ id: z.ZodString; text: z.ZodString; }, z.core.$strict>; issue: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{ repo: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>; number: z.ZodNumber; }, z.core.$strict>, z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<{ repo: string; number: number; }, string>>, z.ZodObject<{ repo: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>; number: z.ZodNumber; }, z.core.$strict>>]>>; }, z.core.$strict>; export type ContinuationLaunch = z.infer<typeof continuationLaunchSchema>; type Placement = { hash: string; worker?: boolean; workerDispatch?: string; state: "uncertain" | "placed" | "not-placed"; createdAt?: number; server?: string; caller?: PeerIdentity; paneTarget?: Json; result?: Json; }; /** A durable intent precedes creation. An interrupted intent is reconciled by * its brief arrival, never by creating another pane. */ export declare function continuationPlacement(id: string, includeCreating?: boolean): Promise<Placement | undefined>; export declare function launchContinuation(input: unknown, launch: (data: ContinuationLaunch, placed: (paneTarget: Json) => Promise<void>) => Promise<Json>, authorization?: { caller?: PeerIdentity; server: string; }): Promise<Json>; export declare function saveContinuationIntent(input: Json): Promise<void>; export declare function continuationIntent(id: string): Promise<Json>; /** * The whole conversation a summary-by-target move copies to the receiving Hook, beside its intent: the source's * prompts and replies, already redacted the way a peer hand-off is. The brief only has room for its newest turns; * the receiving launch pulls this through the same intent route, in pages, and puts it in the new agent's brief * folder. A Hook that predates it ignores the page parameter and answers with the intent, which has no * `conversation`, so either side being older leaves the excerpt alone. */ export declare const CONVERSATION_LIMIT = 2000000; export declare const CONVERSATION_FILE = "conversation.md"; /** In a summary-by-target brief's opening line, so the receiving launch asks for a copy only for those moves. */ export declare const CONVERSATION_MARKER = "Phren copied its conversation instead"; /** * Removes the saved conversations and intents no move needs any more, as `done` decides from the move id and the * file's age (the move moved or failed, or it has no record at all), and any older than `maxAgeMs` whatever `done` * says. A destination reads a copy only while its launch runs, and a receiving Hook reads an intent only while its * move runs: both are over once the move is moved or failed. A write a crash left behind * (`<file>.<uuid>.tmp`) goes after an hour. Returns the move ids whose files were removed, once each. */ export declare function pruneContinuationFiles(done: (id: string, ageMs: number) => boolean | Promise<boolean>, now?: number, maxAgeMs?: number): Promise<string[]>; /** How long a file with no move record (or a write a crash left) is kept: a move in another process records itself first. */ export declare const ORPHAN_GRACE_MS: number; /** Saved once per move: a run of the move that starts again keeps the first copy, which a destination may be part way through reading. */ export declare function saveContinuationConversation(id: string, text: string): Promise<void>; /** One page of the saved conversation from character `offset`, with its whole length and hash to check against. */ export declare function continuationConversationPage(id: string, offset: number): Promise<Json>; /** * The receiving side: every page of the source's conversation through `page(offset)`, checked against its length * and hash and redacted again here, or undefined when the source has none (an older Hook, a move that never * built one) or it does not arrive whole. Never fails the launch: the brief's excerpt stands on its own. */ export declare function fetchContinuationConversation(page: (offset: number) => Promise<Json>, redact: (text: string) => string): Promise<string | undefined>; /** Where the copied conversation is, to tell the new agent; appended only when the brief has room for it. */ export declare function withConversationPointer(text: string, file: string, limit?: number): string; export {};