import type { JsonValue } from "@earendil-works/pi-ai";
import type { ExtensionRunner } from "../../core/extensions/runner.ts";
import type { TwoSidedHome } from "./loopless-tool-handlers.ts";
import type { LoopHookCall } from "./loop-hook-call.ts";
/** The loop events a hand that is its extensions' home runs for a loop that runs elsewhere (S33, C8/K5). */
export type LooplessLoopHooks = (event: string, payload: JsonValue) => Promise<JsonValue>;
/**
 * The loop hooks of this runtime's own extensions, on the same runner (so the same extension instances) that runs its
 * tool calls: a two-sided extension keeps one state across its loop and tool hooks. Only a hand that is its extensions'
 * home (`twoSidedHome: "hand"`) runs them; any other hand refuses, because its extensions' loop hooks run where the loop
 * runs. Every event runs only the user's loop hooks (`userLoopHooks`: non-builtin extensions the loader did not ship,
 * plus the hooks builtin); the loop's own builtins run where the loop runs. The loop forwards, in a session's order:
 * - `session_start`: the user's SessionStart hooks and extensions' `session_start` handlers;
 * - `input` (the hooks builtin's UserPromptSubmit runs there), whose result (`continue`, `handled`, or `transform`
 *   with the new text) the loop returns from its own `input` handler, so its session acts on it as on a local one;
 * - `before_agent_start` with the prompt the session now has, whose combined result the loop returns from its own;
 * - `before_provider_request` (CK21), whose reply's `output` carries the payload the user's hooks produced;
 * - `agent_end`, carrying the session port's read half, where the user's Stop hooks run.
 * Each reply also carries what its handlers did beyond the result: messages (`sent`, which the loop sends with the same
 * options), notices, session writes (`entries`, `userMessages`), and failures (`errors`). What a call's work does after
 * the call ended goes to the loop as a durable wake instead (H3), never in a later reply.
 */
export declare function extensionLoopHooks(runner: ExtensionRunner, twoSidedHome: TwoSidedHome, cwd: string, call: LoopHookCall): LooplessLoopHooks;
/**
 * The user's loop hooks, which a hand runs for a hosted loop: its non-builtin extensions (C7(c), K5) and the hooks
 * builtin, which runs the user's shell hooks (C8). Every other builtin is the loop's own machinery (model, compaction,
 * todo, search): each side loads its own builtins, so those run where the loop runs, as S29 never forwards builtins.
 */
export declare const isUserLoopHook: (extensionPath: string) => boolean;
//# sourceMappingURL=loopless-loop-hooks.d.ts.map