/** * ExtensionRegistry — manages AgentExtension registrations. * * Extensions are called in registration order at each lifecycle phase. * Each extension hook failure is caught and logged independently so * one bad extension can't take down the agent. */ import type { TextBlock } from '../types/blocks.js'; import type { Logger } from '../types/logger.js'; import type { SystemPromptContributor } from '../types/system-prompt-contributor.js'; import type { AfterIterationHook, AfterRunHook, AfterToolExecutionHook, AgentExtension, BeforeIterationHook, BeforeRunHook, BeforeToolExecutionHook, OnErrorHook, ProviderRunnerFn } from './extension-points.js'; export declare class ExtensionRegistry { private readonly extensions; private readonly promptContributors; private log; setLogger(log: Logger): void; /** * Register a system prompt contributor. Returns an unregister function. * Contributors are called on every system prompt build in registration * order. Their output blocks are inserted after the core environment * block, before the mode and plan blocks. */ registerSystemPromptContributor(c: SystemPromptContributor): () => void; /** * Build all registered system prompt contributions. * Failures are caught and logged — one bad contributor doesn't * break the prompt assembly. */ buildSystemPromptContributions(ctx: Parameters[0]): Promise; /** * Returns the live array of contributors (readonly snapshot for * passing to DefaultSystemPromptBuilder at build time). */ listSystemPromptContributors(): readonly SystemPromptContributor[]; /** * Register an extension. Duplicate names are rejected. * Returns an unregister function. */ register(ext: AgentExtension): () => void; /** * Register an extension, silently replacing any previous registration * with the same name. Use this when overriding a default extension. */ registerOrReplace(ext: AgentExtension): () => void; /** * Unregister an extension by name. Returns true if found. */ unregister(name: string): boolean; /** * List registered extension names in order. */ list(): readonly string[]; /** * Check if an extension with the given name is registered. */ has(name: string): boolean; /** * Remove all registered extensions and contributors. */ clear(): void; runBeforeRun(...args: Parameters): Promise; runAfterRun(...args: Parameters): Promise; runBeforeIteration(...args: Parameters): Promise; runAfterIteration(...args: Parameters): Promise; /** * Run onError hooks in order. The first hook that returns a non-void * result wins; subsequent hooks are skipped. */ runOnError(...args: Parameters): Promise<{ action: 'retry'; model?: string | undefined; } | { action: 'fail'; } | { action: 'continue'; } | void>; /** * Build a composed provider runner. Extensions with `wrapProviderRunner` * form a middleware-style chain: the innermost extension wraps the * default runner, each subsequent wrapper wraps the previous. */ wrapProviderRunner(inner: ProviderRunnerFn): ProviderRunnerFn; runBeforeToolExecution(...args: Parameters): Promise[1]>; runAfterToolExecution(...args: Parameters): Promise; } //# sourceMappingURL=registry.d.ts.map