/** * Worker-side handle for an agent session homed on another thread (the main * thread or a sibling worker). * * One canonical instance per instance key (see `./session-directory`), built * by the `"agent-session"` codec. Every synchronous member is a `callSync` to * the main thread's bridge, which answers from its local session or its * `RemoteAgentSession` mirror; commands go to main asynchronously and main * routes them to the home thread. `subscribe`/`subscribeRunState` keep one * main-side forwarding subscription each, shared by every local listener. */ import type { AgentMessage, ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, Model } from "@oh-my-pi/pi-ai"; import type { IrcMessage } from "@oh-my-pi/pi-tui/tools/irc"; import type { EffectiveExtensionRoots } from "../capability/types.js"; import type { AgentSessionAdvisorOverview, AgentSessionHandle, AgentSessionLoopHandle, AgentSessionManagerHandle } from "../session/agent-session-handle.js"; import type { AgentSessionEventListener } from "../session/agent-session-events.js"; import type { AgentSessionDisposeOptions, PromptOptions, SessionStats, SteerOptions } from "../session/agent-session-types.js"; import type { CustomMessage } from "../session/messages.js"; import type { ServingModel } from "../session/retry-fallback-chains.js"; import type { AgentDefinition } from "../task/types.js"; import type { WorkPoolYieldItem } from "../task/workpool-yield.js"; import type { ThreadId } from "./identity.js"; import type { SessionAbortOptions, SessionBridgeClient, SessionRunState } from "./session-mirror.js"; /** Worker boot only: the main thread's session bridge every peer handle talks through. */ export declare function installPeerBridge(client: SessionBridgeClient): void; /** Canonical worker-side handle for the session `key` homed on `home` (another thread). */ export declare function peerAgentSession(key: string, home: ThreadId): PeerAgentSession; /** {@link AgentSessionHandle} for a session homed on another thread; see the module doc. */ export declare class PeerAgentSession implements AgentSessionHandle { #private; readonly instanceKey: string; /** Thread the session lives on. */ readonly home: ThreadId; readonly agent: AgentSessionLoopHandle; readonly sessionManager: AgentSessionManagerHandle; /** Use {@link peerAgentSession}; direct construction breaks identity. */ constructor(key: string, home: ThreadId); get isStreaming(): boolean; get runStartedAt(): number | undefined; get ircWakesPending(): boolean; get messages(): AgentMessage[]; get sessionFile(): string | undefined; get model(): Model | undefined; get thinkingLevel(): ThinkingLevel | undefined; get servingModel(): ServingModel | undefined; get effectiveExtensionRoots(): EffectiveExtensionRoots; get hindsightActive(): boolean; getSessionStats(): SessionStats; getAdvisorStatusOverview(): AgentSessionAdvisorOverview; getSessionAgents(): AgentDefinition[]; hasQueuedIrcFrom(from: string): boolean; /** Only ever called on the caller's own session; a peer is never that. */ drainPendingIrcInboxMessages(_agentId: string, _opts?: { ifAny?: (msg: IrcMessage) => boolean; }): IrcMessage[]; emitIrcRelayObservation(record: CustomMessage): void; subscribe(listener: AgentSessionEventListener): () => void; subscribeRunState(listener: (state: SessionRunState) => void): () => void; deliverIrcMessage(msg: IrcMessage): Promise<"injected" | "woken">; waitForIrcReplies(): Promise; prompt(text: string, options?: PromptOptions): Promise; steer(text: string, images?: ImageContent[], options?: SteerOptions): Promise; abort(options?: SessionAbortOptions): Promise; setWorkPoolYieldItems(items: readonly WorkPoolYieldItem[]): Promise; dispose(options?: AgentSessionDisposeOptions): Promise; }