/** * Code Mode adoption guard (#35, 2026-10-06). * * The v2 retirement moved the file/command ladder onto the HOST's native * `read` / `grep` / `glob` / `shell`, and the host's `execute` (Code Mode) is the * one program that folds N governed calls into a single round-trip. A model that * keeps reaching for the native tools one at a time pays N rounds for what one * `execute` program answers — the exact inefficiency the retirement was supposed * to remove, wearing the opposite face. * * This is an ADOPTION HINT, not a gate: after a run of consecutive native * file/command calls it APPENDS one line to the next result naming `execute`. * It never rewrites the body, never touches args, never refuses a call — the * same shape as `src/tm/dupe-guard.ts` (append a directive + count + trajectory * event), minus the escalation, because a hint that blocks would cost the user * the very round it is trying to save. * * Discipline, copied from the layers beside it: * - Team-scoped through the shared `scope.decide` gate — a foreign session's * result is nobody's to annotate; * - it may NEVER throw into somebody's tool call: a failure is swallowed and * COUNTED (`threw`), and the host's verbatim result passes through; * - the append is IDEMPOTENT (a marker check), because the host reloads plugins * in-process and a replayed hook must not stack two lines. */ import type { V2Registration } from "./v2-types.js"; import type { TeamScope } from "./v2-scope.js"; /** The native tools whose repeated use is what `execute` folds into one program. * A closed list on purpose: `question`, `edit`, `subagent` … are not "one more * read", and counting them would make the streak mean nothing. */ export declare const NATIVE_CHAIN_TOOLS: ReadonlySet; /** The tool that RESETS the streak: it is the alternative the hint points at, so * using it is the behaviour the guard exists to encourage. */ export declare const CHAIN_RESET_TOOL = "execute"; /** Stable marker so a replayed hook cannot append the line twice. */ export declare const PROBE_CHAIN_MARKER = "\uFF08Code Mode \u91C7\u7528\u7387\u63D0\u793A\uFF09"; export declare const DEFAULT_PROBE_CHAIN_AFTER = 3; export interface ProbeChainReport { /** chain-tool calls observed in a Team session */ seen: number; /** results that actually got the appended line */ advised: number; /** `execute` calls that reset the streak */ reset: number; /** non-Team sessions left completely alone */ foreignSkipped: number; /** a throw inside the hook, swallowed and counted (never a reason to fail a call) */ threw: number; } export interface ProbeChainVerdict { /** the current run of consecutive native file/command calls */ count: number; /** should the line be appended to THIS result? */ advise: boolean; } /** * The pure ledger. `threshold` is the number of consecutive native calls after * which the NEXT result carries the hint: with the default 3, calls 1-3 are * silent and the 4th (and every one after it, until a reset) is advised. A * non-chain tool is transparent — it neither counts nor resets — and `execute` * resets, because it is the alternative. */ export declare function createProbeChain(threshold: number): { observe: (tool: string) => ProbeChainVerdict; streak: () => number; }; /** The appended line, in the tool-output language the tm_* strings use. */ export declare function renderProbeChainNote(count: number): string; /** * Append the line to the result's first text part, byte-exact otherwise. Returns * true only when a line was actually added — an unknown result shape, a missing * text part, or an already-marked body all return false (the caller counts the * difference). The body is never rewritten: the original text is preserved * verbatim and the line is appended after it. */ export declare function appendProbeChainNote(result: unknown, line: string): boolean; export interface ProbeChainDeps { /** Team-scope isolation: a foreign or unattributable session is left alone. */ scope?: TeamScope; /** The resolved runtime config (probeChain / probeChainAfter). */ config?: { probeChain: string; probeChainAfter: number; }; /** the trajectory sink — wired in v2.ts, same shape as the browser gate's `onSerp` */ onAdvise?: (info: { tool: string; count: number; sessionID?: unknown; }) => void; } export declare function applyV2ProbeChain(ctx: unknown, deps: ProbeChainDeps): { registrations: Promise[]; report: ProbeChainReport; active: boolean; }; //# sourceMappingURL=v2-probe-chain.d.ts.map