import type { ToolCallOutcome } from '../dangling-tool-calls.js'; import type { GenuiCallRow, RecordGenuiCallInput } from '../genui-telemetry.js'; import type { AgentRunStatus, AgentStore, AppendMessageInput, CostSource, CreateThreadInput, MessageFeedback, RecordRunEndInput, RecordRunStartInput, RecordToolCallInput, RecordUsageInput, StoredMessage, ThreadDetail, ThreadSummary, ToolCallStatus, ToolResult, UpdateThreadInput, UpdateToolCallInput } from '../index.js'; import type { ActionProposalOutcomeLease, ActionProposalOutcomeStore } from '../spi/action-proposal-outcome-store.js'; import { type UsageTotals } from '../spi/agent-store.js'; import { type ToolCallApprovalState } from '../spi/approval-policy.js'; import type { ChatQueueStore, EnqueueMessageInput, QueuedMessage, QueuedMessagePatch, QueuePause } from '../spi/chat-queue.js'; import type { AgentUiComponent } from '../stream-events.js'; import { InMemoryActionProposalStore } from './in-memory-action-proposal-store.js'; /** A recorded usage row exposed to the governance read-model (input/output split + thread/day). */ export interface GovernanceUsageRow { actorRef: string; threadId: string; runId?: string; modelId: string; purpose?: string; inputTokens: number; outputTokens: number; /** Subset of `inputTokens` written to the prompt cache this turn; undefined when not reported. */ cacheWriteTokens?: number; /** Subset of `inputTokens` served from the prompt cache this turn; undefined when not reported. */ cacheReadTokens?: number; /** The turn's cost as recorded (reported, or estimated at write time); undefined → estimate from pricing. */ costUsd?: number; /** Where `costUsd` came from; undefined with a `costUsd` → a row from before estimates were stored (reported). */ costSource?: CostSource; day: string; createdAt: string; } /** A recorded tool call exposed to the governance read-model (thread resolved, with timestamp). */ export interface GovernanceToolCallRow { toolCallId: string; toolName: string; toolType: 'read' | 'action'; status: ToolCallStatus; threadId: string; runId?: string; input: unknown; output?: unknown; error?: string; executionMs?: number; createdAt: string; } /** A recorded run exposed to the governance read-model (full lifecycle + rollups). */ export interface GovernanceRunRow { runId: string; threadId: string; actorRef: string; tenantRef?: string; agentName?: string; /** The run that delegated this one; unset for a turn a person started. */ parentRunId?: string; status: AgentRunStatus; startedAt: string; finishedAt?: string; stepCount: number; inputTokens: number; outputTokens: number; costUsd?: number; error?: string; ttftMs?: number; errorCode?: string; modelId?: string; durable: boolean; } /** A recorded message exposed to the governance read-model (for run-detail assembly). */ export interface GovernanceMessageRow { id: string; threadId: string; runId?: string; role: string; content: string; createdAt: string; } /** Thread metadata exposed to the governance read-model (title/actor/count/last activity). */ export interface GovernanceThreadRow { threadId: string; title: string; actorRef: string; messageCount: number; updatedAt: string; } /** A fully in-memory `AgentStore` for tests and the offline demo. */ export declare class InMemoryAgentStore extends InMemoryActionProposalStore implements AgentStore, ChatQueueStore { private readonly threads; /** Each thread's waiting messages, in run order. */ private readonly queues; private readonly pauses; /** Keyed by message and model-supplied id: two responses can be handed the same id (see `toolCallKey`). */ private readonly toolCalls; private readonly usage; private readonly genuiCalls; private readonly runs; private now; createThread(input: CreateThreadInput): Promise; getThread(threadId: string): Promise; getThreadActionProposalScope(threadId: string): Promise<{ threadId: string; actorRef: string; tenantRef: string | null; } | null>; getThreadActorRef(threadId: string): Promise; listThreads(actorRef: string, limit?: number): Promise; promoteThread(threadId: string): Promise; softDeleteThread(threadId: string): Promise; forkThread(threadId: string, fromMessageId: string): Promise; setTitle(threadId: string, title: string): Promise; updateThread(threadId: string, patch: UpdateThreadInput): Promise; defaultAgentForThread(threadId: string): Promise; personaForThread(threadId: string): Promise; clearActiveStream(threadId: string, runId: string): Promise; activeRunForThread(threadId: string): Promise; threadHeldByRun(runId: string): Promise; claimActiveStream(threadId: string, runId: string, options?: { replacing?: string; }): Promise; releaseActiveStream(threadId: string, runId: string): Promise; enqueueMessage(input: EnqueueMessageInput): Promise; listQueue(threadId: string): Promise; getQueuedMessage(id: string): Promise; updateQueuedMessage(id: string, patch: QueuedMessagePatch): Promise; moveQueuedMessage(id: string, index: number): Promise; removeQueuedMessage(id: string): Promise; clearQueue(threadId: string): Promise; queuePause(threadId: string): Promise; setQueuePause(threadId: string, pause: QueuePause | null): Promise; private findQueued; setActiveStream(threadId: string, runId: string | null): Promise; admitActionProposalOutcome(command: ActionProposalOutcomeLease): ReturnType; appendMessage(input: AppendMessageInput): Promise; setMessageUi(messageId: string, ui: AgentUiComponent[]): Promise; setMessageToolResults(messageId: string, results: ToolResult[]): Promise; truncateFrom(threadId: string, messageId: string): Promise; /** * Of `mediaIds`, the ones a surviving (or queued) message in one of this actor's threads still * carries. Re-derived from the messages each call, so a media whose message was truncated away reads as * unreferenced again. */ referencedMediaIds(actorRef: string, mediaIds: readonly string[]): Promise; threadOfMessage(messageId: string): Promise; setMessageFeedback(messageId: string, feedback: MessageFeedback | null): Promise; /** * A provider only promises a call id is unique within one response (one assistant message), so a * call is keyed by its message too — as `LucidAgentStore` keys its rows. */ private toolCallKey; /** * The newest call `runId` recorded under `toolCallId`, or without a run the newest overall — the * same rule as `LucidAgentStore`. Insertion order is recording order. */ private findToolCall; toolCallInput(toolCallId: string, runId?: string): Promise; getToolCallRunId(toolCallId: string): Promise; toolCallOutcomes(toolCallIds: string[]): Promise; failUnsettledToolCalls(runId: string, error: string): Promise; recordToolCall(input: RecordToolCallInput): Promise; updateToolCall(input: UpdateToolCallInput): Promise; rememberedApprovals(threadId: string): Promise; toolCallApproval(toolCallId: string, runId?: string): Promise; /** A message with the approval record of every call on it that was put to a person. */ private withApprovals; recordGenuiCalls(rows: readonly RecordGenuiCallInput[]): Promise; /** Generative-UI telemetry rows, oldest first (test helper; the governance feed). */ genuiCallRows(): GenuiCallRow[]; recordUsage(input: RecordUsageInput): Promise; getRunActorRef(runId: string): Promise; recordRunStart(input: RecordRunStartInput): Promise; recordRunEnd(input: RecordRunEndInput): Promise; usageBetween(actorRef: string, fromDay: string, toDay: string): Promise; quotaToday(actorRef: string, day: string): Promise<{ usedTokens: number; }>; /** Test helper: read the recorded usage rows (modelId + purpose + token totals). */ usageRows(): { actorRef: string; tokens: number; modelId: string; purpose: string; }[]; /** Governance read-model feed: recorded usage rows with the input/output split + thread/day. */ governanceUsage(): GovernanceUsageRow[]; /** Governance read-model feed: recorded tool calls with the resolved thread + timestamp. */ governanceToolCalls(): GovernanceToolCallRow[]; /** Governance read-model feed: recorded runs (full lifecycle + rollups). */ governanceRuns(): GovernanceRunRow[]; /** Governance read-model feed: recorded messages with their thread + run correlation. */ governanceMessages(): GovernanceMessageRow[]; /** Governance read-model feed: thread metadata (title/actor/message count/last activity). */ governanceThreads(): GovernanceThreadRow[]; private threadIdForMessage; /** Test helper: read the recorded tool-call rows. */ toolCallRows(): { toolCallId: string; runId?: string; toolName: string; status: ToolCallStatus; output?: unknown; }[]; private toSummary; } //# sourceMappingURL=in-memory-store.d.ts.map