import type { AgentEvent, BasicLogger } from "@cline/shared"; import type { TeamEvent } from "../../../extensions/tools/team"; import { type AgentEventContext } from "../../../services/agent-events"; import type { CoreSessionConfig } from "../../../types/config"; import type { CoreSessionEvent } from "../../../types/events"; import type { ActiveSession } from "../../../types/session"; import type { SessionAccumulatedUsage } from "../runtime-host"; export interface AgentEventBridgeDeps { getSession(sessionId: string): ActiveSession | undefined; usageBySession: Map; aggregateUsageBySession: Map; emit(event: CoreSessionEvent): void; persistMessages: AgentEventContext["persistMessages"]; enqueuePendingPrompt(sessionId: string, entry: { prompt: string; delivery: "queue" | "steer"; }): void; invokeBackendOptional(method: string, ...args: unknown[]): Promise; } export declare class AgentEventBridge { private readonly deps; constructor(deps: AgentEventBridgeDeps); /** * Last agent identity stamped on each session's events while the session * was still registered. A session's agent can keep emitting after the host * removes it from the sessions map (teardown deletes the entry before the * run fully drains), and without this snapshot those late events reach * telemetry with no agent identity at all. Bounded FIFO so a long-lived * host doesn't accumulate entries forever. */ private readonly lastKnownIdentityBySession; private static readonly MAX_IDENTITY_SNAPSHOTS; dispatchAgentEvent(sessionId: string, config: CoreSessionConfig, event: AgentEvent): void; private rememberSessionIdentity; handleTeamEvent(rootSessionId: string, event: TeamEvent): Promise; handlePluginEvent(rootSessionId: string, event: { name: string; payload?: unknown; }, fallbackAutomation?: NonNullable["automation"], fallbackTelemetry?: CoreSessionConfig["telemetry"]): Promise; /** * Route `plugin_telemetry` events emitted by the sandbox-side telemetry * bridge into the host telemetry service. Sandboxed plugins cannot hold * the live service (it is not JSON-serializable across the IPC boundary), * so their capture/record calls arrive as events. All plugin events are * namespaced under `plugin.` and stamped with the plugin name so they * cannot impersonate first-party events. */ handlePluginTelemetry(rootSessionId: string, payload: unknown, fallbackTelemetry?: CoreSessionConfig["telemetry"]): void; handlePluginLog(rootSessionId: string, payload: unknown, fallbackLogger?: BasicLogger): void; }