UNPKG

@phren/cli

Version:

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

62 lines (61 loc) • 4.24 kB
import { type Json } from "./protocol.js"; import type { ChildAgentRelation } from "./transcripts.js"; import { type TurnRecord } from "./turn-records.js"; /** The checkout a Claude sub-agent edits in. Claude Code writes the isolated * worktree into the child's `.meta.json`; an older child falls back to the * `cwd` its own first rows record. Preserve shared and missing checkout paths * too: Git routes must fail explicitly when a checkout disappears, never * substitute the parent repository. */ export declare function claudeChildCheckout(file: string): Promise<Pick<ChildAgentRelation, "cwd" | "worktreeName" | "branch">>; /** How long after a Stop its list of running background agents is believed: a session that exits leaves its * last Stop behind, and an agent of it that never finished must not run forever. */ export declare const CLAUDE_STOP_TRUST_MS: number; export declare function claudeChildAgents(file: string, session: string, knownStop?: TurnRecord["stop"]): Promise<ChildAgentRelation[]>; /** How long a background skill's transcript may sit unchanged before it is * taken as finished: the parent records no end for it, and a session that * exited mid-skill leaves it without a final reply. */ export declare const CLAUDE_SKILL_QUIET_MS: number; /** State one newest-first pass over a Claude transcript keeps so a * content-free `dequeue` can name the prompt turn it delivered: the queue key * of that turn, whether the agent's own schedule (a cron, /loop or * ScheduleWakeup fire, or an auto-continuation) injected it, and the phone * delivery the Hook's records bound to that turn. `offset` is the raw row's * byte offset, so a queue occurrence can be named exactly (`deliveryFor`). */ export interface ClaudeQueueState { key?: string; scheduled?: boolean; delivery?: string; offset?: number; /** The phone delivery a queue row was bound to, from the Hook's delivery records. */ deliveryFor?: (raw: Json, offset: number | undefined) => string | undefined; } export declare const harnessPreamble: (text: string) => boolean; export declare function unwrapPastedContent(text: string): string; /** A thinking block Claude marks as narration for the person watching: its * signature is a length-prefixed field reading "narration" (private * reasoning reads "thinking" and is stored without text). */ export declare function isNarration(block: Record<string, unknown>): boolean; /** What a Skill call loaded. Claude Code answers the call itself with only * "Launching skill: <name>" and writes the skill's text as a hidden user row * pointing back at the call (`sourceToolUseID`). That row alone crosses, as a * second result for the same call, so the phone can show what the skill said; * every other hidden row stays private. */ export declare function skillBody(raw: Json): Json | undefined; /** A message another agent sent this session (a teammate, a subagent's * hand-back or another Claude session), which Claude Code delivers as a hidden * user row when the agent is idle, or a queued_command attachment mid-turn, * both naming it with `origin.kind: "peer"`. The terminal shows it as * "Message from @name"; only the sender's name and the words cross, never the * envelope, socket path or ids. */ export declare function peerMessage(raw: Json, includeSidechain?: boolean): Json | undefined; /** A phren UserPromptSubmit injection, as `{ type: "phren_hook_context", * parentUuid, content }`, or undefined for any other row. */ export declare function phrenHookContext(raw: Json, includeSidechain?: boolean): Json | undefined; /** The normalized prompt identity of a displayed Claude user prompt. Tool * results, hidden/meta or scheduled turns, sidechains, compaction summaries, * queue placeholders and synthetic rows never carry one. */ export declare function claudePromptIdentity(original: Json, projected: Json | undefined): string | undefined; /** Claude Code rows the phone may see: user, assistant and system turns with * private reasoning redacted, queued phone messages, background task * notifications and compaction markers. */ export declare function visibleClaudeEvent(raw: Json, includeSidechain?: boolean, queue?: ClaudeQueueState): Json | undefined;