import type { LlmMessage, ToolCallRequest } from './provider-base.js'; import type { DispatcherResult } from './tool-dispatcher.js'; import type { AgentLoopInput, AgentLoopPolicy, AgentLoopPrepareNextTurnContext, AgentLoopStopAfterTurnContext, AgentLoopStopDecision, AgentToolPolicy, AgentToolPolicyContext, ApprovalGate, ToolCallReport } from './agent-loop-types.js'; export declare function normalizeLoopPolicies(policy: AgentLoopInput['loopPolicy']): readonly AgentLoopPolicy[]; export declare function prepareNextTurn(policies: readonly AgentLoopPolicy[], ctx: AgentLoopPrepareNextTurnContext): Promise; export declare function shouldStopAfterTurn(policies: readonly AgentLoopPolicy[], ctx: AgentLoopStopAfterTurnContext): Promise; type ResolvedToolAccess = { decision: 'allow' | 'deny'; source: 'policy' | 'approval'; reason?: string; }; export declare function decideToolAccess(policy: AgentToolPolicy | undefined, approve: ApprovalGate, ctx: AgentToolPolicyContext): Promise; /** * v1.2.118 — race a dispatcher against a per-tool wall timeout. The * outer abort signal (loop timeout / user cancel) is forwarded to the * dispatcher so it can clean up; on timeout we abort the dispatcher's * signal AND return a structured "timed out" tool-result so the model * sees a tool-level failure (not a thrown rejection). * * `timeoutMs === 0` disables the per-tool cap for explicitly slow calls. * `detachOnAbort` (default true): return immediately on timeout/abort * (retired loop / read-only). False waits for the dispatcher to settle * so mutations cannot land after the caller has moved on. */ export declare function dispatchWithTimeout(invoke: (signal: AbortSignal) => Promise, outerSignal: AbortSignal, timeoutMs: number, toolName: string, detachOnAbort?: boolean): Promise; export declare function mergeUsage(acc: import('./provider-base.js').LlmUsage, add: import('./provider-base.js').LlmUsage): void; export declare function clampInt(n: number, lo: number, hi: number): number; export declare function mergeSignal(userSignal: AbortSignal | undefined, timeoutMs: number | undefined): { signal: AbortSignal; cleanup: () => void; }; /** T2 — run the caller's per-call concurrency classifier, fail-closed. * A classifier that throws (or any non-true return) means "serial" so a * buggy predicate degrades throughput rather than crashing the turn. */ export declare function classifyParallelSafe(classifier: (call: ToolCallRequest) => boolean, call: ToolCallRequest): boolean; export declare function safeApprove(gate: ApprovalGate, call: ToolCallRequest, attempt: number, signal?: AbortSignal): Promise<'allow' | 'deny'>; export declare function writeIterAudit(audit: AgentLoopInput['audit'] | undefined, startedAt: number, promptLen: number, responseLen: number, success: boolean, error?: string, cost?: number): void; /** v1.2.111 — one row per tool call (deny / schema-validation / * dispatched) so post-hoc trace analysis can reconstruct the full * chain inside a turn. Intent is `tool.` so queries can group * per tool; agent is the original `audit.agent` so a tool call still * shows under the parent agent in cost / topN aggregates. promptLen * carries argsKey length (a rough "how much did the model send") * bound, responseLen carries result preview length. error carries the * validator/dispatcher's errorType so a failure mode aggregates * cleanly in the audit dashboard. */ export declare function writeToolCallAudit(audit: AgentLoopInput['audit'] | undefined, report: ToolCallReport): void; /** Truncate tool-result text with a clear marker so the model knows * bytes were dropped. Single-pass over text; cap === 0 disables. */ export declare function truncateToolResult(text: string, cap: number, toolName: string): { text: string; truncated: boolean; }; export {}; //# sourceMappingURL=agent-loop-helpers.d.ts.map