@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
23 lines (22 loc) • 1.43 kB
TypeScript
import { type Json, type Provider } from "./protocol.js";
/** The agent side of the Hook's callbacks: `hook <source>` reads the agent's
* payload and posts it to the daemon's local socket (agent-hooks.ts). */
/** What a Stop payload says about the turn it ends: the harness's last
* assistant message (Claude, Codex) and, from Claude Code, the background
* tasks still in flight, which will wake the conversation again when they
* finish. Absent fields are left out, so the Hook falls back to the transcript. */
export declare function stopFacts(value: Json): {
background?: number;
reply?: string;
};
/** One agent callback, run as `hook <source>`. Resolves "abandoned" when a
* tool call's callback ran out of its budget: the caller then exits at once,
* since a socket or a process read still pending would hold the agent. */
export declare function agentHook(source: Provider, elapsed?: () => number): Promise<void | "abandoned">;
/**
* Runs a callback's work. A PreToolUse or PostToolUse callback gets what is
* left of TOOL_HOOK_BUDGET_MS since its process started (hook-fast.ts says
* why): "abandoned" once that runs out, and the caller exits without an
* answer so the tool runs. Every other event runs to its own timeouts.
*/
export declare function withinToolBudget<T>(event: string, work: (left: () => number) => Promise<T>, elapsed?: () => number, budgetMs?: number): Promise<T | "abandoned">;