@dudousxd/nestjs-agent-core 0.37.0 → 0.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,10 +1,10 @@
1
- import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, a as Actor, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, g as AgentRunInput, H as HumanReply, h as MessageAttachment, i as ToolKind, j as ToolCallStatus, k as ToolCallApproval, l as HistoryPolicy, P as PageContext, m as AgentDefinition, n as AgentStore, o as AgentDelegation, D as DetachedDelivery, p as PromptBuilder, q as PromptContributor, r as ToolTransientRetrySetting, s as AgentIntake, t as Decision, E as ElicitationRequest, L as LlmStepEnvelope, u as ToolStepEnvelope, C as ChatQueueStore, v as CreateThreadInput, w as ThreadSummary, x as ThreadDetail, y as ToolCallApprovalState, U as UpdateThreadInput, R as RecordRunStartInput, z as EnqueueMessageInput, B as QueuedMessage, F as QueuedMessagePatch, G as QueuePause, I as AppendMessageInput, S as StoredMessage, J as ToolResult, K as MessageFeedback, N as RecordToolCallInput, O as ToolCallOutcome, V as UpdateToolCallInput, W as RecordUsageInput } from './stream-events-CgWqAI-1.cjs';
2
- export { X as ALL_AGENTS, Y as ASK_TOOL_DESCRIPTION, Z as ASK_TOOL_NAME, _ as AgentApprovalRequest, $ as AgentApprovalSettlement, a0 as AgentAttachmentConfig, a1 as AgentCatalogEntry, a2 as AgentClientConfig, a3 as AgentHistoryWindow, a4 as AgentStreamErrorCode, a5 as AskToolInput, a6 as ChatQueueState, a7 as DEFAULT_INTAKE_PREAMBLE, a8 as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, a9 as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aa as ELICITATION_INPUT_TYPES, ab as ElicitationInput, ac as ElicitationInputType, ad as ElicitationOption, ae as ElicitationOutcome, af as ElicitationQuestion, ag as ElicitationReply, ah as ElicitationResult, ai as HistoryPolicyContext, aj as HistorySelection, ak as HistorySummary, al as InvokeWithTransientRetryOptions, am as MAX_ASK_QUESTIONS, an as MessageFeedbackValue, ao as MessageRole, ap as PromptContext, aq as QueuePauseReason, ar as QueuedMessageView, as as QuotaView, at as RUN_ENDED_BEFORE_TOOL_CALL, au as RecordRunEndInput, av as ThreadTurnPage, aw as ThreadTurnQuery, ax as ThreadTurnReader, ay as ToolCallApprovalStatus, az as ToolCatalogEntry, aA as ToolConfirmation, b as ToolPresentation, aB as ToolPresentationTone, aC as ToolResultField, aD as ToolResultView, aE as ToolStepCtx, aF as ToolTransientRetryNumbers, aG as ToolTransientRetryOptions, aH as UNFINISHED_TOOL_CALL, aI as UsagePurpose, aJ as askInputSchema, aK as askToolDefinition, aL as danglingToolCallIds, aM as decodeStreamEvent, aN as encodeStreamEvent, aO as invokeWithTransientRetry, aP as isChatQueueStore, aQ as isTransientToolError, aR as isTypedQuestion, aS as normalizeElicitationReply, aT as questionOptions, aU as queuedMessageView, aV as readElicitationInput, aW as readElicitationQuestions, aX as releaseThreadRun, aY as renderElicitationAnswers, aZ as resolveElicitation, a_ as resolveToolTransientRetryNumbers, a$ as settleDanglingToolCalls, b0 as settleElicitation, b1 as validateElicitationAnswer, b2 as validateElicitationValue } from './stream-events-CgWqAI-1.cjs';
3
- import { A as AiToolCtx, T as ToolHandler, a as ToolDescribeScope } from './tool-DuJ-_qXM.cjs';
4
- export { b as ToolDescription } from './tool-DuJ-_qXM.cjs';
1
+ import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, a as Actor, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, g as AgentRunInput, H as HumanReply, h as MessageAttachment, i as ToolKind, j as ToolCallStatus, k as ToolCallApproval, l as HistoryPolicy, P as PageContext, m as AgentDefinition, n as AgentStore, o as AgentDelegation, D as DetachedDelivery, p as PromptBuilder, q as PromptContributor, r as ToolTransientRetrySetting, s as AgentIntake, t as Decision, E as ElicitationRequest, L as LlmStepEnvelope, u as ToolStepEnvelope, C as ChatQueueStore, v as CreateThreadInput, w as ThreadSummary, x as ThreadDetail, y as ToolCallApprovalState, U as UpdateThreadInput, R as RecordRunStartInput, z as EnqueueMessageInput, B as QueuedMessage, F as QueuedMessagePatch, G as QueuePause, I as AppendMessageInput, S as StoredMessage, J as ToolResult, K as MessageFeedback, N as RecordToolCallInput, O as ToolCallOutcome, V as UpdateToolCallInput, W as RecordUsageInput } from './stream-events-rpd3d6gh.cjs';
2
+ export { X as ALL_AGENTS, Y as ASK_TOOL_DESCRIPTION, Z as ASK_TOOL_NAME, _ as AgentApprovalRequest, $ as AgentApprovalSettlement, a0 as AgentAttachmentConfig, a1 as AgentCatalogEntry, a2 as AgentClientConfig, a3 as AgentHistoryWindow, a4 as AgentStreamErrorCode, a5 as AskToolInput, a6 as ChatQueueState, a7 as DEFAULT_INTAKE_PREAMBLE, a8 as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, a9 as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aa as ELICITATION_INPUT_TYPES, ab as ElicitationInput, ac as ElicitationInputType, ad as ElicitationOption, ae as ElicitationOutcome, af as ElicitationQuestion, ag as ElicitationReply, ah as ElicitationResult, ai as HistoryPolicyContext, aj as HistorySelection, ak as HistorySummary, al as InvokeWithTransientRetryOptions, am as MAX_ASK_QUESTIONS, an as MessageFeedbackValue, ao as MessageRole, ap as PromptContext, aq as QueuePauseReason, ar as QueuedMessageView, as as QuotaView, at as RUN_ENDED_BEFORE_TOOL_CALL, au as RecordRunEndInput, av as ThreadTurnPage, aw as ThreadTurnQuery, ax as ThreadTurnReader, ay as ToolCallApprovalStatus, az as ToolCatalogEntry, aA as ToolConfirmation, b as ToolPresentation, aB as ToolPresentationTone, aC as ToolResultField, aD as ToolResultView, aE as ToolStepCtx, aF as ToolTransientRetryNumbers, aG as ToolTransientRetryOptions, aH as UNFINISHED_TOOL_CALL, aI as UsagePurpose, aJ as askInputSchema, aK as askToolDefinition, aL as danglingToolCallIds, aM as decodeStreamEvent, aN as encodeStreamEvent, aO as invokeWithTransientRetry, aP as isChatQueueStore, aQ as isTransientToolError, aR as isTypedQuestion, aS as normalizeElicitationReply, aT as questionOptions, aU as queuedMessageView, aV as readElicitationInput, aW as readElicitationQuestions, aX as releaseThreadRun, aY as renderElicitationAnswers, aZ as resolveElicitation, a_ as resolveToolTransientRetryNumbers, a$ as settleDanglingToolCalls, b0 as settleElicitation, b1 as validateElicitationAnswer, b2 as validateElicitationValue } from './stream-events-rpd3d6gh.cjs';
3
+ import { A as AiToolCtx, T as ToolHandler, a as ToolDescribeScope } from './tool-Dp8HA_f4.cjs';
4
+ export { b as ToolDescription } from './tool-Dp8HA_f4.cjs';
5
5
  import { StandardSchemaV1 } from '@standard-schema/spec';
6
- import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-C0snQzZJ.cjs';
7
- export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-C0snQzZJ.cjs';
6
+ import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-CAVevaYJ.cjs';
7
+ export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-CAVevaYJ.cjs';
8
8
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
9
9
 
10
10
  /**
@@ -107,6 +107,13 @@ interface SinkWriter {
107
107
  * — so the transport can surface a typed failure frame instead of leaking it as assistant text.
108
108
  */
109
109
  fail(error: StreamError): void | Promise<void>;
110
+ /**
111
+ * OPTIONAL: write out anything this writer is still holding back, without ending the stream. Only
112
+ * a sink that gathers frames before writing them (the SQL sink coalesces text) has anything to do
113
+ * here; a delegated run's child writer calls it where it would have ended the stream, so nothing
114
+ * of the delegate's is still held back when its parent — possibly on another replica — writes next.
115
+ */
116
+ flush?(): void | Promise<void>;
110
117
  }
111
118
  /** A machine-readable stream failure. `code` is a stable slug; `message` is human-facing. */
112
119
  interface StreamError {
@@ -2481,6 +2488,11 @@ declare function detachedUnsettled(args: {
2481
2488
  *
2482
2489
  * Called by the RUNNER, never the loop — a run that crashed or was stopped cannot record its own
2483
2490
  * ending. Skipped entirely when the thread is gone, for the same reason delivery is.
2491
+ *
2492
+ * Settles ONCE: a thread that already holds a message from this run (its answer, or an earlier
2493
+ * settlement) is left alone. A Stop can be settled from two places — the run's own body when it
2494
+ * observes the cancel, and the runner for a run parked where its body never runs again — and a
2495
+ * Stop on a run that already answered must not write "stopped" under its answer.
2484
2496
  */
2485
2497
  declare function settleUnsettledDelegation(args: {
2486
2498
  store: AgentStore;
@@ -3509,7 +3521,8 @@ declare class InMemoryAgentStore implements AgentStore, ChatQueueStore {
3509
3521
  setMessageFeedback(messageId: string, feedback: MessageFeedback | null): Promise<void>;
3510
3522
  truncateFrom(threadId: string, messageId: string): Promise<void>;
3511
3523
  /**
3512
- * Of `mediaIds`, the ones a surviving message in one of this actor's threads still carries.
3524
+ * Of `mediaIds`, the ones a surviving message — or a message waiting in the queue — in one of
3525
+ * this actor's threads still carries.
3513
3526
  * Re-derived from the messages each call, so a media whose message was truncated away reads as
3514
3527
  * unreferenced again.
3515
3528
  */
@@ -3815,4 +3828,138 @@ interface ConfirmedTool {
3815
3828
  handler: ToolHandler;
3816
3829
  }
3817
3830
 
3818
- export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_CONFIRM_TOKEN_STORE, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_MODEL_CATALOG, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_PROVIDER, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, APPROVAL_EXPIRED_REASON, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStartOptions, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, AppendMessageInput, type ApprovalDecisionRef, type ApprovalPolicy, type ApprovalRequirement, type ApprovalThreadRef, type ApprovalToolRef, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, CONFIRM_JSON_SCHEMA_PROPERTIES, ChatQueueStore, ClosedRolesPolicy, type ConfirmFields, type ConfirmTokenClaim, ConfirmTokenError, type ConfirmTokenStore, type ConfirmTokenSubject, type ConfirmedTool, type ConfirmedToolDone, type ConfirmedToolMessages, type ConfirmedToolOptions, type ConfirmedToolOutcome, type ConfirmedToolPreview, type ConfirmedToolResult, type ConfirmedToolSteps, type CostUsage, CreateThreadInput, type CurrentModelPrice, DEFAULT_CONFIRM_TTL_MS, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultApprovalPolicy, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, type EmptyRoles, EnqueueMessageInput, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernanceMessageRow, type GovernancePage, type GovernancePageQuery, type GovernancePendingApprovalRow, type GovernanceRange, type GovernanceRunDetail, type GovernanceRunRow, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceThreadRow, type GovernanceToolCallRow, type GovernanceUsageInput, type GovernanceUsageRow, HistoryPolicy, HumanReply, InMemoryAgentStore, InMemoryConfirmTokenStore, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageFeedback, MessageUsage, ModelAnswer, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogLock, type ModelCatalogProviderGroup, type ModelCatalogQuery, type ModelCatalogView, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QueuePause, QueuedMessage, QueuedMessagePatch, type QuotaBlock, QuotaExceededError, type QuotaPeriod, type QuotaProvider, type QuotaQuery, type QuotaReport, QuotaState, type QuotaStore, type QuotaWarning, type QuotaWindow, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, REQUESTER_APPROVER, RUN_FAILED_MESSAGE, RUN_NOT_ACTIVE_CODE, RUN_NOT_ACTIVE_MESSAGE, RUN_NO_LONGER_RUNNING, type RecentRunRow, RecordRunStartInput, RecordToolCallInput, RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RolesPolicyOptions, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SCHEMA_EXTENSION, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type SchemaExtension, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, type SettleDeadRunInput, type SettledTask, type SinkWriter, type Skill, type SkillAuthor, type SkillCatalogEntry, type SkillContext, type SkillLoadOutcome, type SkillOffer, type SkillProvider, type SkillSummary, type SkillToolInput, type SkillWriteRequest, type SkillWriteVerdict, type SkillsConfig, type StageAttachmentInput, type StagedAttachment, type StoreMemoryInput, StoredMessage, type StreamError, type StructuredOutcome, StructuredOutputError, THREAD_DETAIL_CONTENT_CHARS, type ThreadActivityRow, ThreadDetail, type ThreadMessageRow, type ThreadMeta, type ThreadSpendRow, ThreadSummary, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallApproval, type ToolCallApprovalColumns, ToolCallApprovalState, ToolCallOutcome, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDescribeScope, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, ToolKind, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UiCollector, UpdateThreadInput, UpdateToolCallInput, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, canonicalJson, closeEmptyRoles, compositeSkillProvider, confirmTokenExpiry, createFrameBuffer, createIncrementalGate, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, defineConfirmedTool, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, exhaustedWindow, exposeStreamErrorDetails, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, gateFollowUps, gateTail, hashConfirmToken, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, mayDecideApproval, memoryForgetVerdict, memoryWriteVerdict, mergeUi, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, quotaPeriodRange, quotaUsedRatio, quotaWarning, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, schemaExtensionOf, seedModelPrices, settleAll, settleDeadRun, settleUnsettledDelegation, signConfirmToken, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticModelCatalog, staticSkillProvider, streamFailure, summarizeWithModel, tenantScope, toolCallApprovalFromRow, toolCallContext, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, verifyConfirmToken, windowHistory, withAskTool, withConfirmFields, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
3831
+ /** One stored row of a run's stream. `frame` is `null` on the terminal row. */
3832
+ interface StreamFrameRow {
3833
+ seq: number;
3834
+ /** One NDJSON line (`{...}\n`) as the writer wrote it; `null` marks the end of the run. */
3835
+ frame: string | null;
3836
+ /** On the terminal row of a FAILED run: the `StreamError` as JSON. `null` otherwise. */
3837
+ error: string | null;
3838
+ }
3839
+ /**
3840
+ * The table a {@link SqlTokenStreamSink} keeps its rows in — the only part of it that speaks SQL, so
3841
+ * a store package implements this and inherits the rest (coalescing, ordering, polling, TTL).
3842
+ * `@dudousxd/nestjs-agent-store-drizzle` and `-store-mikro-orm` ship one each, over
3843
+ * `agent_stream_frame` (`run_id`, `seq`, `frame`, `error`, `created_at`; primary key
3844
+ * `(run_id, seq)`).
3845
+ */
3846
+ interface StreamFrameTable {
3847
+ /**
3848
+ * Insert the run's NEXT row: `seq = MAX(seq) + 1` for the run, taken in the SAME statement as the
3849
+ * insert, so the `(run_id, seq)` primary key settles two writers that ask at once. Throws on that
3850
+ * collision ({@link isUniqueViolation} says which errors are one) — the sink retries.
3851
+ */
3852
+ append(runId: string, row: {
3853
+ frame: string | null;
3854
+ error: string | null;
3855
+ createdAt: number;
3856
+ }): Promise<void>;
3857
+ /** The run's rows with `seq > after`, ascending, at most `limit`. */
3858
+ read(runId: string, after: number, limit: number): Promise<StreamFrameRow[]>;
3859
+ /** Does the table hold any row for the run? */
3860
+ has(runId: string): Promise<boolean>;
3861
+ /** Delete every row of these runs. */
3862
+ remove(runIds: readonly string[]): Promise<void>;
3863
+ /** Runs whose LAST row was written before `cutoff` (epoch-ms). */
3864
+ lapsedRuns(cutoff: number): Promise<string[]>;
3865
+ /** Is this error a lost race for a `(run_id, seq)` — and nothing else (a missing table, a dead connection)? */
3866
+ isUniqueViolation(error: unknown): boolean;
3867
+ }
3868
+ interface SqlTokenStreamSinkOptions {
3869
+ /**
3870
+ * Gap (ms) between two reads of a run a subscriber is following — the most a frame waits in the
3871
+ * table before a browser sees it. Default 250.
3872
+ */
3873
+ pollIntervalMs?: number;
3874
+ /**
3875
+ * Gap (ms) between two reads once the run has written nothing for five seconds (parked on a
3876
+ * person, a slow tool), so an open SSE connection on a quiet run costs one query a second. The
3877
+ * first frame to arrive puts the subscriber back on `pollIntervalMs`. Default 1000; never below
3878
+ * `pollIntervalMs`.
3879
+ */
3880
+ idlePollIntervalMs?: number;
3881
+ /**
3882
+ * Window (ms) consecutive `text` frames are gathered over and written as ONE row — a model
3883
+ * streams token by token, and a row per token is more writes than a database should take for a
3884
+ * chat answer. Any other frame, `end()`, `fail()` and `flush()` write what is gathered first, so
3885
+ * order is kept. Default 50. `0` writes every frame as its own row.
3886
+ */
3887
+ flushMs?: number;
3888
+ /**
3889
+ * TTL (seconds) of a run's rows, counted from its LAST write — a long run stays, a run that
3890
+ * crashed without ending still lapses. {@link SqlTokenStreamSink.purgeExpired} deletes them.
3891
+ * Default 3600 (1h). `0` keeps rows until `close()`.
3892
+ */
3893
+ ttlSeconds?: number;
3894
+ /**
3895
+ * Purge lapsed runs as a side effect of ending a run, at most once a minute, so the table stays
3896
+ * bounded in an app that never schedules {@link SqlTokenStreamSink.purgeExpired}. Default `true`.
3897
+ */
3898
+ autoPurge?: boolean;
3899
+ }
3900
+ /**
3901
+ * A multi-replica {@link TokenStreamSink} over the app's SQL database — for a deployment with
3902
+ * several replicas and NO Redis. The replica running the turn appends each frame as a row; any
3903
+ * replica serves the run's SSE by reading the rows past its cursor, in order, until the terminal
3904
+ * row. A late subscriber replays from the first row, as with the in-process and Redis sinks, and a
3905
+ * run that `fail()`ed throws its {@link AgentStreamError} after the replay.
3906
+ *
3907
+ * Two things differ from the Redis sink, both the price of having no broker:
3908
+ *
3909
+ * - **Delivery is polled** — a frame waits up to `pollIntervalMs` before a browser sees it.
3910
+ * - **Text is coalesced on the way in.** Consecutive `text` frames written within `flushMs` are
3911
+ * stored as ONE `text` frame. The stored rows ARE the run's stream: every subscriber, on every
3912
+ * replica, reads the same rows in the same order, so the SSE ids `chat/:runId/stream` numbers
3913
+ * them with — and an `?after=` cursor — stay exact across replicas.
3914
+ *
3915
+ * Sequence numbers are per run, start at 1 and have no gaps (see {@link StreamFrameTable.append}).
3916
+ * Text a writer is still gathering lives in the process for at most `flushMs`; a process that dies
3917
+ * in that window loses it from the LIVE stream (the persisted message is unaffected).
3918
+ *
3919
+ * Framework- and dialect-free: the SQL is the {@link StreamFrameTable}'s. Use
3920
+ * `DrizzleTokenStreamSink` / `MikroOrmTokenStreamSink` from the store packages.
3921
+ */
3922
+ declare class SqlTokenStreamSink implements TokenStreamSink {
3923
+ private readonly table;
3924
+ private readonly pollIntervalMs;
3925
+ private readonly idlePollIntervalMs;
3926
+ private readonly flushMs;
3927
+ private readonly ttlSeconds;
3928
+ private readonly autoPurge;
3929
+ private readonly writes;
3930
+ private lastAutoPurge;
3931
+ constructor(table: StreamFrameTable, options?: SqlTokenStreamSinkOptions);
3932
+ private runWrites;
3933
+ /** Forget a run's write state once nothing is gathered, queued or left to report. */
3934
+ private release;
3935
+ /** Queue `work` behind every write already queued for the run, so rows land in call order. */
3936
+ private enqueue;
3937
+ /** Queue the gathered text (if any) as one `text` row. */
3938
+ private flushText;
3939
+ /** Raise, once, a gathered write that failed with nobody awaiting it. */
3940
+ private raiseFailure;
3941
+ /** Append one row — a frame, or the terminal row (`frame: null`, with `error` on a failure). */
3942
+ private append;
3943
+ /** Write out what is gathered, then a terminal row; raise a failure nobody saw. */
3944
+ private terminate;
3945
+ /**
3946
+ * The run's writer. Writers opened for the same run in one process share what they are gathering,
3947
+ * so a delegated run's text (forwarded through a child writer) and its parent's next frame keep
3948
+ * the order they were written in.
3949
+ */
3950
+ open(runId: string): SinkWriter;
3951
+ subscribe(runId: string): AsyncIterable<Uint8Array>;
3952
+ /** Does the table hold anything for the run — a frame, or its end? */
3953
+ has(runId: string): Promise<boolean>;
3954
+ close(runId: string): Promise<void>;
3955
+ /**
3956
+ * Delete every run whose last write is older than `ttlSeconds` at `now` (epoch-ms) — ended runs
3957
+ * past their replay window and runs that crashed without ending alike. Returns how many runs went.
3958
+ * Safe from any replica, and from several at once. A no-op under `ttlSeconds: 0`.
3959
+ */
3960
+ purgeExpired(now?: number): Promise<number>;
3961
+ /** {@link purgeExpired}, unawaited and at most once a minute. Its failure is not the run's. */
3962
+ private purgeInBackground;
3963
+ }
3964
+
3965
+ export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_CONFIRM_TOKEN_STORE, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_MODEL_CATALOG, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_PROVIDER, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, APPROVAL_EXPIRED_REASON, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStartOptions, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, AppendMessageInput, type ApprovalDecisionRef, type ApprovalPolicy, type ApprovalRequirement, type ApprovalThreadRef, type ApprovalToolRef, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, CONFIRM_JSON_SCHEMA_PROPERTIES, ChatQueueStore, ClosedRolesPolicy, type ConfirmFields, type ConfirmTokenClaim, ConfirmTokenError, type ConfirmTokenStore, type ConfirmTokenSubject, type ConfirmedTool, type ConfirmedToolDone, type ConfirmedToolMessages, type ConfirmedToolOptions, type ConfirmedToolOutcome, type ConfirmedToolPreview, type ConfirmedToolResult, type ConfirmedToolSteps, type CostUsage, CreateThreadInput, type CurrentModelPrice, DEFAULT_CONFIRM_TTL_MS, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultApprovalPolicy, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, type EmptyRoles, EnqueueMessageInput, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernanceMessageRow, type GovernancePage, type GovernancePageQuery, type GovernancePendingApprovalRow, type GovernanceRange, type GovernanceRunDetail, type GovernanceRunRow, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceThreadRow, type GovernanceToolCallRow, type GovernanceUsageInput, type GovernanceUsageRow, HistoryPolicy, HumanReply, InMemoryAgentStore, InMemoryConfirmTokenStore, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageFeedback, MessageUsage, ModelAnswer, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogLock, type ModelCatalogProviderGroup, type ModelCatalogQuery, type ModelCatalogView, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QueuePause, QueuedMessage, QueuedMessagePatch, type QuotaBlock, QuotaExceededError, type QuotaPeriod, type QuotaProvider, type QuotaQuery, type QuotaReport, QuotaState, type QuotaStore, type QuotaWarning, type QuotaWindow, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, REQUESTER_APPROVER, RUN_FAILED_MESSAGE, RUN_NOT_ACTIVE_CODE, RUN_NOT_ACTIVE_MESSAGE, RUN_NO_LONGER_RUNNING, type RecentRunRow, RecordRunStartInput, RecordToolCallInput, RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RolesPolicyOptions, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SCHEMA_EXTENSION, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type SchemaExtension, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, type SettleDeadRunInput, type SettledTask, type SinkWriter, type Skill, type SkillAuthor, type SkillCatalogEntry, type SkillContext, type SkillLoadOutcome, type SkillOffer, type SkillProvider, type SkillSummary, type SkillToolInput, type SkillWriteRequest, type SkillWriteVerdict, type SkillsConfig, SqlTokenStreamSink, type SqlTokenStreamSinkOptions, type StageAttachmentInput, type StagedAttachment, type StoreMemoryInput, StoredMessage, type StreamError, type StreamFrameRow, type StreamFrameTable, type StructuredOutcome, StructuredOutputError, THREAD_DETAIL_CONTENT_CHARS, type ThreadActivityRow, ThreadDetail, type ThreadMessageRow, type ThreadMeta, type ThreadSpendRow, ThreadSummary, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallApproval, type ToolCallApprovalColumns, ToolCallApprovalState, ToolCallOutcome, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDescribeScope, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, ToolKind, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UiCollector, UpdateThreadInput, UpdateToolCallInput, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, canonicalJson, closeEmptyRoles, compositeSkillProvider, confirmTokenExpiry, createFrameBuffer, createIncrementalGate, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, defineConfirmedTool, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, exhaustedWindow, exposeStreamErrorDetails, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, gateFollowUps, gateTail, hashConfirmToken, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, mayDecideApproval, memoryForgetVerdict, memoryWriteVerdict, mergeUi, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, quotaPeriodRange, quotaUsedRatio, quotaWarning, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, schemaExtensionOf, seedModelPrices, settleAll, settleDeadRun, settleUnsettledDelegation, signConfirmToken, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticModelCatalog, staticSkillProvider, streamFailure, summarizeWithModel, tenantScope, toolCallApprovalFromRow, toolCallContext, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, verifyConfirmToken, windowHistory, withAskTool, withConfirmFields, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, a as Actor, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, g as AgentRunInput, H as HumanReply, h as MessageAttachment, i as ToolKind, j as ToolCallStatus, k as ToolCallApproval, l as HistoryPolicy, P as PageContext, m as AgentDefinition, n as AgentStore, o as AgentDelegation, D as DetachedDelivery, p as PromptBuilder, q as PromptContributor, r as ToolTransientRetrySetting, s as AgentIntake, t as Decision, E as ElicitationRequest, L as LlmStepEnvelope, u as ToolStepEnvelope, C as ChatQueueStore, v as CreateThreadInput, w as ThreadSummary, x as ThreadDetail, y as ToolCallApprovalState, U as UpdateThreadInput, R as RecordRunStartInput, z as EnqueueMessageInput, B as QueuedMessage, F as QueuedMessagePatch, G as QueuePause, I as AppendMessageInput, S as StoredMessage, J as ToolResult, K as MessageFeedback, N as RecordToolCallInput, O as ToolCallOutcome, V as UpdateToolCallInput, W as RecordUsageInput } from './stream-events-CgWqAI-1.js';
2
- export { X as ALL_AGENTS, Y as ASK_TOOL_DESCRIPTION, Z as ASK_TOOL_NAME, _ as AgentApprovalRequest, $ as AgentApprovalSettlement, a0 as AgentAttachmentConfig, a1 as AgentCatalogEntry, a2 as AgentClientConfig, a3 as AgentHistoryWindow, a4 as AgentStreamErrorCode, a5 as AskToolInput, a6 as ChatQueueState, a7 as DEFAULT_INTAKE_PREAMBLE, a8 as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, a9 as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aa as ELICITATION_INPUT_TYPES, ab as ElicitationInput, ac as ElicitationInputType, ad as ElicitationOption, ae as ElicitationOutcome, af as ElicitationQuestion, ag as ElicitationReply, ah as ElicitationResult, ai as HistoryPolicyContext, aj as HistorySelection, ak as HistorySummary, al as InvokeWithTransientRetryOptions, am as MAX_ASK_QUESTIONS, an as MessageFeedbackValue, ao as MessageRole, ap as PromptContext, aq as QueuePauseReason, ar as QueuedMessageView, as as QuotaView, at as RUN_ENDED_BEFORE_TOOL_CALL, au as RecordRunEndInput, av as ThreadTurnPage, aw as ThreadTurnQuery, ax as ThreadTurnReader, ay as ToolCallApprovalStatus, az as ToolCatalogEntry, aA as ToolConfirmation, b as ToolPresentation, aB as ToolPresentationTone, aC as ToolResultField, aD as ToolResultView, aE as ToolStepCtx, aF as ToolTransientRetryNumbers, aG as ToolTransientRetryOptions, aH as UNFINISHED_TOOL_CALL, aI as UsagePurpose, aJ as askInputSchema, aK as askToolDefinition, aL as danglingToolCallIds, aM as decodeStreamEvent, aN as encodeStreamEvent, aO as invokeWithTransientRetry, aP as isChatQueueStore, aQ as isTransientToolError, aR as isTypedQuestion, aS as normalizeElicitationReply, aT as questionOptions, aU as queuedMessageView, aV as readElicitationInput, aW as readElicitationQuestions, aX as releaseThreadRun, aY as renderElicitationAnswers, aZ as resolveElicitation, a_ as resolveToolTransientRetryNumbers, a$ as settleDanglingToolCalls, b0 as settleElicitation, b1 as validateElicitationAnswer, b2 as validateElicitationValue } from './stream-events-CgWqAI-1.js';
3
- import { A as AiToolCtx, T as ToolHandler, a as ToolDescribeScope } from './tool-DklsS3JX.js';
4
- export { b as ToolDescription } from './tool-DklsS3JX.js';
1
+ import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, a as Actor, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, g as AgentRunInput, H as HumanReply, h as MessageAttachment, i as ToolKind, j as ToolCallStatus, k as ToolCallApproval, l as HistoryPolicy, P as PageContext, m as AgentDefinition, n as AgentStore, o as AgentDelegation, D as DetachedDelivery, p as PromptBuilder, q as PromptContributor, r as ToolTransientRetrySetting, s as AgentIntake, t as Decision, E as ElicitationRequest, L as LlmStepEnvelope, u as ToolStepEnvelope, C as ChatQueueStore, v as CreateThreadInput, w as ThreadSummary, x as ThreadDetail, y as ToolCallApprovalState, U as UpdateThreadInput, R as RecordRunStartInput, z as EnqueueMessageInput, B as QueuedMessage, F as QueuedMessagePatch, G as QueuePause, I as AppendMessageInput, S as StoredMessage, J as ToolResult, K as MessageFeedback, N as RecordToolCallInput, O as ToolCallOutcome, V as UpdateToolCallInput, W as RecordUsageInput } from './stream-events-rpd3d6gh.js';
2
+ export { X as ALL_AGENTS, Y as ASK_TOOL_DESCRIPTION, Z as ASK_TOOL_NAME, _ as AgentApprovalRequest, $ as AgentApprovalSettlement, a0 as AgentAttachmentConfig, a1 as AgentCatalogEntry, a2 as AgentClientConfig, a3 as AgentHistoryWindow, a4 as AgentStreamErrorCode, a5 as AskToolInput, a6 as ChatQueueState, a7 as DEFAULT_INTAKE_PREAMBLE, a8 as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, a9 as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aa as ELICITATION_INPUT_TYPES, ab as ElicitationInput, ac as ElicitationInputType, ad as ElicitationOption, ae as ElicitationOutcome, af as ElicitationQuestion, ag as ElicitationReply, ah as ElicitationResult, ai as HistoryPolicyContext, aj as HistorySelection, ak as HistorySummary, al as InvokeWithTransientRetryOptions, am as MAX_ASK_QUESTIONS, an as MessageFeedbackValue, ao as MessageRole, ap as PromptContext, aq as QueuePauseReason, ar as QueuedMessageView, as as QuotaView, at as RUN_ENDED_BEFORE_TOOL_CALL, au as RecordRunEndInput, av as ThreadTurnPage, aw as ThreadTurnQuery, ax as ThreadTurnReader, ay as ToolCallApprovalStatus, az as ToolCatalogEntry, aA as ToolConfirmation, b as ToolPresentation, aB as ToolPresentationTone, aC as ToolResultField, aD as ToolResultView, aE as ToolStepCtx, aF as ToolTransientRetryNumbers, aG as ToolTransientRetryOptions, aH as UNFINISHED_TOOL_CALL, aI as UsagePurpose, aJ as askInputSchema, aK as askToolDefinition, aL as danglingToolCallIds, aM as decodeStreamEvent, aN as encodeStreamEvent, aO as invokeWithTransientRetry, aP as isChatQueueStore, aQ as isTransientToolError, aR as isTypedQuestion, aS as normalizeElicitationReply, aT as questionOptions, aU as queuedMessageView, aV as readElicitationInput, aW as readElicitationQuestions, aX as releaseThreadRun, aY as renderElicitationAnswers, aZ as resolveElicitation, a_ as resolveToolTransientRetryNumbers, a$ as settleDanglingToolCalls, b0 as settleElicitation, b1 as validateElicitationAnswer, b2 as validateElicitationValue } from './stream-events-rpd3d6gh.js';
3
+ import { A as AiToolCtx, T as ToolHandler, a as ToolDescribeScope } from './tool-hhssZ_HW.js';
4
+ export { b as ToolDescription } from './tool-hhssZ_HW.js';
5
5
  import { StandardSchemaV1 } from '@standard-schema/spec';
6
- import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-D5110pit.js';
7
- export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-D5110pit.js';
6
+ import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-C-FP4nDy.js';
7
+ export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-C-FP4nDy.js';
8
8
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
9
9
 
10
10
  /**
@@ -107,6 +107,13 @@ interface SinkWriter {
107
107
  * — so the transport can surface a typed failure frame instead of leaking it as assistant text.
108
108
  */
109
109
  fail(error: StreamError): void | Promise<void>;
110
+ /**
111
+ * OPTIONAL: write out anything this writer is still holding back, without ending the stream. Only
112
+ * a sink that gathers frames before writing them (the SQL sink coalesces text) has anything to do
113
+ * here; a delegated run's child writer calls it where it would have ended the stream, so nothing
114
+ * of the delegate's is still held back when its parent — possibly on another replica — writes next.
115
+ */
116
+ flush?(): void | Promise<void>;
110
117
  }
111
118
  /** A machine-readable stream failure. `code` is a stable slug; `message` is human-facing. */
112
119
  interface StreamError {
@@ -2481,6 +2488,11 @@ declare function detachedUnsettled(args: {
2481
2488
  *
2482
2489
  * Called by the RUNNER, never the loop — a run that crashed or was stopped cannot record its own
2483
2490
  * ending. Skipped entirely when the thread is gone, for the same reason delivery is.
2491
+ *
2492
+ * Settles ONCE: a thread that already holds a message from this run (its answer, or an earlier
2493
+ * settlement) is left alone. A Stop can be settled from two places — the run's own body when it
2494
+ * observes the cancel, and the runner for a run parked where its body never runs again — and a
2495
+ * Stop on a run that already answered must not write "stopped" under its answer.
2484
2496
  */
2485
2497
  declare function settleUnsettledDelegation(args: {
2486
2498
  store: AgentStore;
@@ -3509,7 +3521,8 @@ declare class InMemoryAgentStore implements AgentStore, ChatQueueStore {
3509
3521
  setMessageFeedback(messageId: string, feedback: MessageFeedback | null): Promise<void>;
3510
3522
  truncateFrom(threadId: string, messageId: string): Promise<void>;
3511
3523
  /**
3512
- * Of `mediaIds`, the ones a surviving message in one of this actor's threads still carries.
3524
+ * Of `mediaIds`, the ones a surviving message — or a message waiting in the queue — in one of
3525
+ * this actor's threads still carries.
3513
3526
  * Re-derived from the messages each call, so a media whose message was truncated away reads as
3514
3527
  * unreferenced again.
3515
3528
  */
@@ -3815,4 +3828,138 @@ interface ConfirmedTool {
3815
3828
  handler: ToolHandler;
3816
3829
  }
3817
3830
 
3818
- export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_CONFIRM_TOKEN_STORE, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_MODEL_CATALOG, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_PROVIDER, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, APPROVAL_EXPIRED_REASON, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStartOptions, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, AppendMessageInput, type ApprovalDecisionRef, type ApprovalPolicy, type ApprovalRequirement, type ApprovalThreadRef, type ApprovalToolRef, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, CONFIRM_JSON_SCHEMA_PROPERTIES, ChatQueueStore, ClosedRolesPolicy, type ConfirmFields, type ConfirmTokenClaim, ConfirmTokenError, type ConfirmTokenStore, type ConfirmTokenSubject, type ConfirmedTool, type ConfirmedToolDone, type ConfirmedToolMessages, type ConfirmedToolOptions, type ConfirmedToolOutcome, type ConfirmedToolPreview, type ConfirmedToolResult, type ConfirmedToolSteps, type CostUsage, CreateThreadInput, type CurrentModelPrice, DEFAULT_CONFIRM_TTL_MS, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultApprovalPolicy, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, type EmptyRoles, EnqueueMessageInput, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernanceMessageRow, type GovernancePage, type GovernancePageQuery, type GovernancePendingApprovalRow, type GovernanceRange, type GovernanceRunDetail, type GovernanceRunRow, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceThreadRow, type GovernanceToolCallRow, type GovernanceUsageInput, type GovernanceUsageRow, HistoryPolicy, HumanReply, InMemoryAgentStore, InMemoryConfirmTokenStore, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageFeedback, MessageUsage, ModelAnswer, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogLock, type ModelCatalogProviderGroup, type ModelCatalogQuery, type ModelCatalogView, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QueuePause, QueuedMessage, QueuedMessagePatch, type QuotaBlock, QuotaExceededError, type QuotaPeriod, type QuotaProvider, type QuotaQuery, type QuotaReport, QuotaState, type QuotaStore, type QuotaWarning, type QuotaWindow, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, REQUESTER_APPROVER, RUN_FAILED_MESSAGE, RUN_NOT_ACTIVE_CODE, RUN_NOT_ACTIVE_MESSAGE, RUN_NO_LONGER_RUNNING, type RecentRunRow, RecordRunStartInput, RecordToolCallInput, RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RolesPolicyOptions, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SCHEMA_EXTENSION, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type SchemaExtension, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, type SettleDeadRunInput, type SettledTask, type SinkWriter, type Skill, type SkillAuthor, type SkillCatalogEntry, type SkillContext, type SkillLoadOutcome, type SkillOffer, type SkillProvider, type SkillSummary, type SkillToolInput, type SkillWriteRequest, type SkillWriteVerdict, type SkillsConfig, type StageAttachmentInput, type StagedAttachment, type StoreMemoryInput, StoredMessage, type StreamError, type StructuredOutcome, StructuredOutputError, THREAD_DETAIL_CONTENT_CHARS, type ThreadActivityRow, ThreadDetail, type ThreadMessageRow, type ThreadMeta, type ThreadSpendRow, ThreadSummary, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallApproval, type ToolCallApprovalColumns, ToolCallApprovalState, ToolCallOutcome, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDescribeScope, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, ToolKind, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UiCollector, UpdateThreadInput, UpdateToolCallInput, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, canonicalJson, closeEmptyRoles, compositeSkillProvider, confirmTokenExpiry, createFrameBuffer, createIncrementalGate, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, defineConfirmedTool, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, exhaustedWindow, exposeStreamErrorDetails, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, gateFollowUps, gateTail, hashConfirmToken, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, mayDecideApproval, memoryForgetVerdict, memoryWriteVerdict, mergeUi, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, quotaPeriodRange, quotaUsedRatio, quotaWarning, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, schemaExtensionOf, seedModelPrices, settleAll, settleDeadRun, settleUnsettledDelegation, signConfirmToken, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticModelCatalog, staticSkillProvider, streamFailure, summarizeWithModel, tenantScope, toolCallApprovalFromRow, toolCallContext, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, verifyConfirmToken, windowHistory, withAskTool, withConfirmFields, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
3831
+ /** One stored row of a run's stream. `frame` is `null` on the terminal row. */
3832
+ interface StreamFrameRow {
3833
+ seq: number;
3834
+ /** One NDJSON line (`{...}\n`) as the writer wrote it; `null` marks the end of the run. */
3835
+ frame: string | null;
3836
+ /** On the terminal row of a FAILED run: the `StreamError` as JSON. `null` otherwise. */
3837
+ error: string | null;
3838
+ }
3839
+ /**
3840
+ * The table a {@link SqlTokenStreamSink} keeps its rows in — the only part of it that speaks SQL, so
3841
+ * a store package implements this and inherits the rest (coalescing, ordering, polling, TTL).
3842
+ * `@dudousxd/nestjs-agent-store-drizzle` and `-store-mikro-orm` ship one each, over
3843
+ * `agent_stream_frame` (`run_id`, `seq`, `frame`, `error`, `created_at`; primary key
3844
+ * `(run_id, seq)`).
3845
+ */
3846
+ interface StreamFrameTable {
3847
+ /**
3848
+ * Insert the run's NEXT row: `seq = MAX(seq) + 1` for the run, taken in the SAME statement as the
3849
+ * insert, so the `(run_id, seq)` primary key settles two writers that ask at once. Throws on that
3850
+ * collision ({@link isUniqueViolation} says which errors are one) — the sink retries.
3851
+ */
3852
+ append(runId: string, row: {
3853
+ frame: string | null;
3854
+ error: string | null;
3855
+ createdAt: number;
3856
+ }): Promise<void>;
3857
+ /** The run's rows with `seq > after`, ascending, at most `limit`. */
3858
+ read(runId: string, after: number, limit: number): Promise<StreamFrameRow[]>;
3859
+ /** Does the table hold any row for the run? */
3860
+ has(runId: string): Promise<boolean>;
3861
+ /** Delete every row of these runs. */
3862
+ remove(runIds: readonly string[]): Promise<void>;
3863
+ /** Runs whose LAST row was written before `cutoff` (epoch-ms). */
3864
+ lapsedRuns(cutoff: number): Promise<string[]>;
3865
+ /** Is this error a lost race for a `(run_id, seq)` — and nothing else (a missing table, a dead connection)? */
3866
+ isUniqueViolation(error: unknown): boolean;
3867
+ }
3868
+ interface SqlTokenStreamSinkOptions {
3869
+ /**
3870
+ * Gap (ms) between two reads of a run a subscriber is following — the most a frame waits in the
3871
+ * table before a browser sees it. Default 250.
3872
+ */
3873
+ pollIntervalMs?: number;
3874
+ /**
3875
+ * Gap (ms) between two reads once the run has written nothing for five seconds (parked on a
3876
+ * person, a slow tool), so an open SSE connection on a quiet run costs one query a second. The
3877
+ * first frame to arrive puts the subscriber back on `pollIntervalMs`. Default 1000; never below
3878
+ * `pollIntervalMs`.
3879
+ */
3880
+ idlePollIntervalMs?: number;
3881
+ /**
3882
+ * Window (ms) consecutive `text` frames are gathered over and written as ONE row — a model
3883
+ * streams token by token, and a row per token is more writes than a database should take for a
3884
+ * chat answer. Any other frame, `end()`, `fail()` and `flush()` write what is gathered first, so
3885
+ * order is kept. Default 50. `0` writes every frame as its own row.
3886
+ */
3887
+ flushMs?: number;
3888
+ /**
3889
+ * TTL (seconds) of a run's rows, counted from its LAST write — a long run stays, a run that
3890
+ * crashed without ending still lapses. {@link SqlTokenStreamSink.purgeExpired} deletes them.
3891
+ * Default 3600 (1h). `0` keeps rows until `close()`.
3892
+ */
3893
+ ttlSeconds?: number;
3894
+ /**
3895
+ * Purge lapsed runs as a side effect of ending a run, at most once a minute, so the table stays
3896
+ * bounded in an app that never schedules {@link SqlTokenStreamSink.purgeExpired}. Default `true`.
3897
+ */
3898
+ autoPurge?: boolean;
3899
+ }
3900
+ /**
3901
+ * A multi-replica {@link TokenStreamSink} over the app's SQL database — for a deployment with
3902
+ * several replicas and NO Redis. The replica running the turn appends each frame as a row; any
3903
+ * replica serves the run's SSE by reading the rows past its cursor, in order, until the terminal
3904
+ * row. A late subscriber replays from the first row, as with the in-process and Redis sinks, and a
3905
+ * run that `fail()`ed throws its {@link AgentStreamError} after the replay.
3906
+ *
3907
+ * Two things differ from the Redis sink, both the price of having no broker:
3908
+ *
3909
+ * - **Delivery is polled** — a frame waits up to `pollIntervalMs` before a browser sees it.
3910
+ * - **Text is coalesced on the way in.** Consecutive `text` frames written within `flushMs` are
3911
+ * stored as ONE `text` frame. The stored rows ARE the run's stream: every subscriber, on every
3912
+ * replica, reads the same rows in the same order, so the SSE ids `chat/:runId/stream` numbers
3913
+ * them with — and an `?after=` cursor — stay exact across replicas.
3914
+ *
3915
+ * Sequence numbers are per run, start at 1 and have no gaps (see {@link StreamFrameTable.append}).
3916
+ * Text a writer is still gathering lives in the process for at most `flushMs`; a process that dies
3917
+ * in that window loses it from the LIVE stream (the persisted message is unaffected).
3918
+ *
3919
+ * Framework- and dialect-free: the SQL is the {@link StreamFrameTable}'s. Use
3920
+ * `DrizzleTokenStreamSink` / `MikroOrmTokenStreamSink` from the store packages.
3921
+ */
3922
+ declare class SqlTokenStreamSink implements TokenStreamSink {
3923
+ private readonly table;
3924
+ private readonly pollIntervalMs;
3925
+ private readonly idlePollIntervalMs;
3926
+ private readonly flushMs;
3927
+ private readonly ttlSeconds;
3928
+ private readonly autoPurge;
3929
+ private readonly writes;
3930
+ private lastAutoPurge;
3931
+ constructor(table: StreamFrameTable, options?: SqlTokenStreamSinkOptions);
3932
+ private runWrites;
3933
+ /** Forget a run's write state once nothing is gathered, queued or left to report. */
3934
+ private release;
3935
+ /** Queue `work` behind every write already queued for the run, so rows land in call order. */
3936
+ private enqueue;
3937
+ /** Queue the gathered text (if any) as one `text` row. */
3938
+ private flushText;
3939
+ /** Raise, once, a gathered write that failed with nobody awaiting it. */
3940
+ private raiseFailure;
3941
+ /** Append one row — a frame, or the terminal row (`frame: null`, with `error` on a failure). */
3942
+ private append;
3943
+ /** Write out what is gathered, then a terminal row; raise a failure nobody saw. */
3944
+ private terminate;
3945
+ /**
3946
+ * The run's writer. Writers opened for the same run in one process share what they are gathering,
3947
+ * so a delegated run's text (forwarded through a child writer) and its parent's next frame keep
3948
+ * the order they were written in.
3949
+ */
3950
+ open(runId: string): SinkWriter;
3951
+ subscribe(runId: string): AsyncIterable<Uint8Array>;
3952
+ /** Does the table hold anything for the run — a frame, or its end? */
3953
+ has(runId: string): Promise<boolean>;
3954
+ close(runId: string): Promise<void>;
3955
+ /**
3956
+ * Delete every run whose last write is older than `ttlSeconds` at `now` (epoch-ms) — ended runs
3957
+ * past their replay window and runs that crashed without ending alike. Returns how many runs went.
3958
+ * Safe from any replica, and from several at once. A no-op under `ttlSeconds: 0`.
3959
+ */
3960
+ purgeExpired(now?: number): Promise<number>;
3961
+ /** {@link purgeExpired}, unawaited and at most once a minute. Its failure is not the run's. */
3962
+ private purgeInBackground;
3963
+ }
3964
+
3965
+ export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_CONFIRM_TOKEN_STORE, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_MODEL_CATALOG, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_PROVIDER, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, APPROVAL_EXPIRED_REASON, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStartOptions, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, AppendMessageInput, type ApprovalDecisionRef, type ApprovalPolicy, type ApprovalRequirement, type ApprovalThreadRef, type ApprovalToolRef, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, CONFIRM_JSON_SCHEMA_PROPERTIES, ChatQueueStore, ClosedRolesPolicy, type ConfirmFields, type ConfirmTokenClaim, ConfirmTokenError, type ConfirmTokenStore, type ConfirmTokenSubject, type ConfirmedTool, type ConfirmedToolDone, type ConfirmedToolMessages, type ConfirmedToolOptions, type ConfirmedToolOutcome, type ConfirmedToolPreview, type ConfirmedToolResult, type ConfirmedToolSteps, type CostUsage, CreateThreadInput, type CurrentModelPrice, DEFAULT_CONFIRM_TTL_MS, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultApprovalPolicy, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, type EmptyRoles, EnqueueMessageInput, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernanceMessageRow, type GovernancePage, type GovernancePageQuery, type GovernancePendingApprovalRow, type GovernanceRange, type GovernanceRunDetail, type GovernanceRunRow, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceThreadRow, type GovernanceToolCallRow, type GovernanceUsageInput, type GovernanceUsageRow, HistoryPolicy, HumanReply, InMemoryAgentStore, InMemoryConfirmTokenStore, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageFeedback, MessageUsage, ModelAnswer, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogLock, type ModelCatalogProviderGroup, type ModelCatalogQuery, type ModelCatalogView, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QueuePause, QueuedMessage, QueuedMessagePatch, type QuotaBlock, QuotaExceededError, type QuotaPeriod, type QuotaProvider, type QuotaQuery, type QuotaReport, QuotaState, type QuotaStore, type QuotaWarning, type QuotaWindow, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, REQUESTER_APPROVER, RUN_FAILED_MESSAGE, RUN_NOT_ACTIVE_CODE, RUN_NOT_ACTIVE_MESSAGE, RUN_NO_LONGER_RUNNING, type RecentRunRow, RecordRunStartInput, RecordToolCallInput, RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RolesPolicyOptions, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SCHEMA_EXTENSION, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type SchemaExtension, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, type SettleDeadRunInput, type SettledTask, type SinkWriter, type Skill, type SkillAuthor, type SkillCatalogEntry, type SkillContext, type SkillLoadOutcome, type SkillOffer, type SkillProvider, type SkillSummary, type SkillToolInput, type SkillWriteRequest, type SkillWriteVerdict, type SkillsConfig, SqlTokenStreamSink, type SqlTokenStreamSinkOptions, type StageAttachmentInput, type StagedAttachment, type StoreMemoryInput, StoredMessage, type StreamError, type StreamFrameRow, type StreamFrameTable, type StructuredOutcome, StructuredOutputError, THREAD_DETAIL_CONTENT_CHARS, type ThreadActivityRow, ThreadDetail, type ThreadMessageRow, type ThreadMeta, type ThreadSpendRow, ThreadSummary, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallApproval, type ToolCallApprovalColumns, ToolCallApprovalState, ToolCallOutcome, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDescribeScope, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, ToolKind, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UiCollector, UpdateThreadInput, UpdateToolCallInput, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, canonicalJson, closeEmptyRoles, compositeSkillProvider, confirmTokenExpiry, createFrameBuffer, createIncrementalGate, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, defineConfirmedTool, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, exhaustedWindow, exposeStreamErrorDetails, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, gateFollowUps, gateTail, hashConfirmToken, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, mayDecideApproval, memoryForgetVerdict, memoryWriteVerdict, mergeUi, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, quotaPeriodRange, quotaUsedRatio, quotaWarning, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, schemaExtensionOf, seedModelPrices, settleAll, settleDeadRun, settleUnsettledDelegation, signConfirmToken, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticModelCatalog, staticSkillProvider, streamFailure, summarizeWithModel, tenantScope, toolCallApprovalFromRow, toolCallContext, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, verifyConfirmToken, windowHistory, withAskTool, withConfirmFields, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };