/** * Canonical session context boundaries. * * The SessionManager projection is the authoritative model context: every provider * request is built from it, recovery paths omit failed attempts through append-only * `context_edit` entries instead of slicing agent state, and extensions get two * actionable boundaries (`turn_end`, `agent_before_settle`) that may append entries and * request one explicit continuation. */ import type { AssistantMessage, ToolResultMessage } from "@bastani/pi-ai/compat"; import type { AgentMessage } from "@earendil-works/pi-agent-core"; import type { AgentSessionInternalSurface as AgentSession } from "./agent-session-methods.ts"; import type { AgentActivityOutcome, BoundaryContextPreview, SessionBoundaryDraft } from "./extensions/index.js"; import { type SessionEntry, SessionManager } from "./session-manager.ts"; type BoundaryKind = "turn_end" | "agent_before_settle"; /** * Materialize the canonical projection as finalized context. Atomic repairs tool-call * pairing in derived context only (a resumed session may end on a tool call whose engine * died before recording its result) and applies the session's configured projection * transform; the durable transcript is never rewritten. */ export declare function _projectFinalizedMessages(this: AgentSession): AgentMessage[]; /** Refresh the public finalized transcript from the canonical session projection. */ export declare function _refreshFinalizedContext(this: AgentSession): void; /** Refresh the public finalized transcript from the canonical session projection. */ export declare function refreshContext(this: AgentSession): void; /** Route every provider request through the canonical session projection. */ export declare function _installAgentRequestProjection(this: AgentSession): void; /** Dispatch the actionable `turn_end` boundary from `finishTurn`, before agent-core's own `turn_end`. */ export declare function _installAgentBoundaryHooks(this: AgentSession): void; export declare function _dispatchTurnEndBoundary(this: AgentSession, message: AssistantMessage, toolResults: ToolResultMessage[], awaitPersistence?: boolean): Promise; export declare function _applyBoundaryDrafts(this: AgentSession, manager: SessionManager, drafts: SessionBoundaryDraft[]): Promise; export declare function _createBoundaryPreviewManager(this: AgentSession, drafts: SessionBoundaryDraft[]): Promise; export declare function _getPendingBoundaryMessages(this: AgentSession): AgentMessage[]; export declare function _buildBoundaryContext(this: AgentSession, drafts: SessionBoundaryDraft[], boundary: BoundaryKind): Promise; export declare function _commitBoundaryDrafts(this: AgentSession, drafts: SessionBoundaryDraft[]): Promise; export declare function _reportInvalidBoundaryContinuation(this: AgentSession, event: BoundaryKind): void; export declare function _findPersistedMessageEntryId(this: AgentSession, message: AgentMessage): string | undefined; /** Keep a failed attempt in raw history while durably omitting it from model projection. */ export declare function _omitRecoveryAttempt(this: AgentSession, message: AssistantMessage, toolResults?: AgentMessage[]): Promise; /** * Omit the trailing assistant attempt (and any tool results it produced) from model * projection when the loop must resume from the preceding input. Returns true when an * assistant attempt was omitted. */ export declare function _omitTrailingAssistantAttempt(this: AgentSession, accept?: (message: AssistantMessage) => boolean): Promise; /** Run the pre-settlement boundary. Returns true when the run must continue once more. */ export declare function _runBeforeSettleBoundary(this: AgentSession): Promise; export declare const agentSessionBoundaryMethods: { _refreshFinalizedContext: typeof _refreshFinalizedContext; _projectFinalizedMessages: typeof _projectFinalizedMessages; refreshContext: typeof refreshContext; _installAgentRequestProjection: typeof _installAgentRequestProjection; _installAgentBoundaryHooks: typeof _installAgentBoundaryHooks; _dispatchTurnEndBoundary: typeof _dispatchTurnEndBoundary; _applyBoundaryDrafts: typeof _applyBoundaryDrafts; _createBoundaryPreviewManager: typeof _createBoundaryPreviewManager; _getPendingBoundaryMessages: typeof _getPendingBoundaryMessages; _buildBoundaryContext: typeof _buildBoundaryContext; _commitBoundaryDrafts: typeof _commitBoundaryDrafts; _reportInvalidBoundaryContinuation: typeof _reportInvalidBoundaryContinuation; _findPersistedMessageEntryId: typeof _findPersistedMessageEntryId; _omitRecoveryAttempt: typeof _omitRecoveryAttempt; _omitTrailingAssistantAttempt: typeof _omitTrailingAssistantAttempt; _runBeforeSettleBoundary: typeof _runBeforeSettleBoundary; }; export type { AgentActivityOutcome }; //# sourceMappingURL=agent-session-boundaries.d.ts.map