import type { AgentEvent, AgentMessage, AgentToolResult, ThinkingLevel } from '@earendil-works/pi-agent-core'; import type { AssistantMessageEvent, Model, Api, ImageContent } from '@earendil-works/pi-ai'; import type { TurnOutcome } from '@xopcai/gateway-contract'; import type { SessionStore } from '../../session/store.js'; import type { EmbeddedTranscriptRuntime } from './transcript-runtime.js'; import type { AgentTurnPolicy } from '../orchestration/agent-turn-policy.js'; export type EmbeddedStreamEvent = { type: 'agent_start'; runId?: string; } | { type: 'agent_end'; runId?: string; } | { type: 'message_start'; runId?: string; message: AgentMessage; } | { type: 'message_update'; runId?: string; message: AgentMessage; assistantMessageEvent?: AssistantMessageEvent; } | { type: 'message_end'; runId?: string; message: AgentMessage; } | { type: 'tool_execution_start'; runId?: string; toolCallId: string; toolName: string; args: unknown; } | { type: 'tool_execution_update'; runId?: string; toolCallId: string; toolName: string; args: unknown; partialResult: AgentToolResult; } | { type: 'tool_execution_end'; runId?: string; toolCallId: string; toolName: string; result: AgentToolResult; isError: boolean; } | { type: 'progress'; runId?: string; stage: string; message: string; } | { type: 'error'; runId?: string; content: string; } | { type: 'turn_outcome'; runId?: string; outcome: TurnOutcome; } | { type: 'compaction'; runId?: string; status: 'started' | 'completed' | 'skipped'; tokensBefore?: number; tokensAfter?: number; summary?: string; }; export type RunXopcEmbeddedTurnParams = { sessionKey: string; runId: string; userMessage: AgentMessage; model: Model; modelRef: string; tools: import('@earendil-works/pi-agent-core').AgentTool[]; systemPrompt: string; thinkingLevel?: ThinkingLevel; promptCachePolicy?: import('../../providers/prompt-cache-plan.js').PromptCachePolicy; workspaceDir: string; sessionStore?: SessionStore; transcriptRuntime?: EmbeddedTranscriptRuntime; timeoutMs: number; turnPolicy?: AgentTurnPolicy; abortSignal?: AbortSignal; onEvent?: (event: EmbeddedStreamEvent) => void; onAgentEvent?: (event: AgentEvent) => void; images?: ImageContent[]; /** Continue from the persisted trailing user row instead of appending it again. */ resumeLastUserMessage?: boolean; verifyChanges?: boolean; }; export type RunXopcEmbeddedTurnResult = { ok: boolean; stopReason?: 'connection_required' | 'clarification_required'; /** False for harness failures that must not trigger another model attempt. */ retryable?: boolean; errorMessage?: string; lastAssistantText?: string; };