import type { AgentAdapter, AgentCompactResult, Backend } from '../../agent-adapter/index.js'; import { buildAgentSpawnConfig, filterChannelScopedPlugins } from './spawn-config.js'; import type { AgentConfig, RunAgentOptions } from './spawn-config.js'; import type { ResolvedProfileConfig } from './profile-manager.js'; import type { AgentHandle, AgentResult } from '../../core/types/agent-types.js'; import { resolveRateLimitProvider, withRateLimitProvider } from './provider-run-lifecycle.js'; export { resolveRateLimitProvider }; /** Track error notices within one provider attempt so terminal handling is durable but not noisy. * runWithAdapter drains its event loop before rejecting, so any API Error from that attempt has * already reached this tracker. A fallback starts a new dedupe window because its terminal * failure must not be hidden by the previous provider's notice. * * Rate-limit API errors are HELD rather than forwarded on arrival: the backend surfaces a 429 as * an assistant message before the turn settles, and only the settle tells us whether it was a * failure (card) or a pause the resume registry already owns (auto-resume warning instead). */ declare class AttemptNoticeTracker { private readonly original; readonly options: RunAgentOptions; private readonly forward; private readonly generateNotices; private attemptHasErrorNotice; private heldError; constructor(original: RunAgentOptions); private observe; /** Release a held rate-limit card. Every settle path calls this except the resumable one, * which drops the card in favour of the auto-resume warning. */ private flushHeldError; /** The attempt produced a result: a turn that recovered from a mid-flight API error still * reports it, just once the outcome is known. */ settleSuccess(): void; private emitTerminal; private emitAutoResume; transitionToFallback(current: AgentConfig, next: AgentConfig, result: AgentResult | null, error?: Error): Promise; emitTerminalError(error: unknown): void; emitTerminalRateLimit(result: AgentResult): void; } declare function withTerminalNotices(handle: AgentHandle, notices: AttemptNoticeTracker): AgentHandle; export { buildAgentSpawnConfig, buildPiGatewaySubPath, CHANNEL_SCOPED_PLUGINS, filterChannelScopedPlugins, } from './spawn-config.js'; export type { AgentConfig, RunAgentOptions, RunObserver } from './spawn-config.js'; export declare function runWithAdapter(adapter: AgentAdapter, message: string, options: RunAgentOptions, config: AgentConfig, anthropicBaseUrl: string | undefined): AgentHandle; export interface CompactAgentRequest { sessionId: string; backend: Backend; backendSessionId: string; channel: string; profileName: string | null; projectId: string; sessionName: string; } interface CompactCostEntry { project: string; trigger: string; cost_usd: number | null; backend: string; mode: string; source: string; input_tokens: number; output_tokens: number; provider?: string; model?: string; } export interface CompactAgentDeps { resolveProfile: (profileName: string | null) => ResolvedProfileConfig; getAdapter: (backend: Backend) => AgentAdapter; configureMode: (mode: string, metadata?: Record) => string | undefined; recordCost: (entry: CompactCostEntry) => Promise; } export declare function isSessionCompactionSupported(session: { backend: string; profileName: string | null; }, resolve?: CompactAgentDeps['resolveProfile']): boolean; export declare function compactAgentContext(request: CompactAgentRequest, deps?: CompactAgentDeps): Promise; export declare function runAgentOnce(message: string, options: RunAgentOptions, config: AgentConfig): AgentHandle; export declare function runAgent(message: string, options?: RunAgentOptions): AgentHandle; /** Returns true when every mode in the profile's fallback chain is currently rate-limited. * Enables job runners to skip claiming/running when all paths are blocked. */ export declare function allConfigsRateLimited(profileName: string | null): boolean; export declare const _test: { runWithAdapter: typeof runWithAdapter; AttemptNoticeTracker: typeof AttemptNoticeTracker; withTerminalNotices: typeof withTerminalNotices; resolveRateLimitProvider: typeof resolveRateLimitProvider; withRateLimitProvider: typeof withRateLimitProvider; buildSpawnConfig: typeof buildAgentSpawnConfig; filterChannelScopedPlugins: typeof filterChannelScopedPlugins; }; export { closeSession, killSession, closeSessionsByPrefix, closeAllSessions, _test as claudeTest, } from '../../agent-adapter/claude/adapter.js'; export { getCurrentPlanFilePath } from '../../agent-adapter/claude/event-parser.js';