@dudousxd/nestjs-agent-core 0.17.0 → 0.18.0

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,5 +1,5 @@
1
- import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, E as ElicitationRequest, A as Actor, d as ThreadSummary, e as ThreadDetail, S as StoredMessage, f as ToolResult, g as MessageAttachment, h as ToolCallStatus, U as UsagePurpose, i as ToolSpec, Q as QuotaState, j as AgentRunInput, H as HumanReply, T as ToolHandler, k as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, l as ProcessedPrompt, m as ModelAnswer, n as PageContext, o as AgentDefinition, p as AgentDelegation, D as DetachedDelivery, q as AiToolCtx, r as PromptBuilder, s as PromptContributor, t as ToolTransientRetrySetting, u as AgentIntake, v as Decision, L as LlmStepEnvelope, w as ToolStepEnvelope } from './tool-CL9oEytW.cjs';
2
- export { x as ASK_TOOL_DESCRIPTION, y as ASK_TOOL_NAME, z as AgentCatalogEntry, B as AgentHistoryWindow, C as AskToolInput, F as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, G as DEFAULT_INTAKE_PREAMBLE, J as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, K as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, N as ElicitationOption, R as ElicitationOutcome, V as ElicitationQuestion, W as ElicitationReply, X as ElicitationResult, Y as HistoryPolicyContext, Z as HistorySelection, _ as HistorySummary, $ as IncrementalGating, a0 as InvokeWithTransientRetryOptions, a1 as MAX_ASK_QUESTIONS, a2 as MessageRole, a3 as OutputRejectedError, a4 as OutputVerdict, a5 as ProcessorFailedError, a6 as PromptContext, a7 as QuotaView, a8 as ToolKind, a9 as ToolStepCtx, aa as ToolTransientRetryNumbers, ab as ToolTransientRetryOptions, ac as askInputSchema, ad as askToolDefinition, ae as invokeWithTransientRetry, af as isTransientToolError, ag as normalizeElicitationReply, ah as renderElicitationAnswers, ai as resolveElicitation, aj as resolveToolTransientRetryNumbers, ak as settleElicitation } from './tool-CL9oEytW.cjs';
1
+ import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as ThreadSummary, f as ThreadDetail, S as StoredMessage, g as ToolResult, h as MessageAttachment, i as ToolCallStatus, U as UsagePurpose, j as ToolSpec, Q as QuotaState, k as AgentRunInput, H as HumanReply, T as ToolHandler, l as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, m as ProcessedPrompt, n as ModelAnswer, o as PageContext, p as AgentDefinition, q as AgentDelegation, D as DetachedDelivery, r as AiToolCtx, s as PromptBuilder, t as PromptContributor, u as ToolTransientRetrySetting, v as AgentIntake, w as Decision, E as ElicitationRequest, L as LlmStepEnvelope, x as ToolStepEnvelope } from './tool-CHIw-aTx.cjs';
2
+ export { y as ASK_TOOL_DESCRIPTION, z as ASK_TOOL_NAME, B as AgentApprovalRequest, C as AgentCatalogEntry, F as AgentHistoryWindow, G as AgentStreamEvent, J as AskToolInput, K as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, N as DEFAULT_INTAKE_PREAMBLE, R as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, V as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, W as ElicitationOption, X as ElicitationOutcome, Y as ElicitationQuestion, Z as ElicitationReply, _ as ElicitationResult, $ as HistoryPolicyContext, a0 as HistorySelection, a1 as HistorySummary, a2 as IncrementalGating, a3 as InvokeWithTransientRetryOptions, a4 as MAX_ASK_QUESTIONS, a5 as MessageRole, a6 as OutputRejectedError, a7 as OutputVerdict, a8 as ProcessorFailedError, a9 as PromptContext, aa as QuotaView, ab as ToolKind, ac as ToolStepCtx, ad as ToolTransientRetryNumbers, ae as ToolTransientRetryOptions, af as askInputSchema, ag as askToolDefinition, ah as decodeStreamEvent, ai as encodeStreamEvent, aj as invokeWithTransientRetry, ak as isTransientToolError, al as normalizeElicitationReply, am as renderElicitationAnswers, an as resolveElicitation, ao as resolveToolTransientRetryNumbers, ap as settleElicitation } from './tool-CHIw-aTx.cjs';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
5
5
 
@@ -160,6 +160,16 @@ interface ModelTurnResult {
160
160
  * the JSON out of `text`) is always correct.
161
161
  */
162
162
  object?: unknown;
163
+ /**
164
+ * The model's thinking this turn, as streamed. Optional: the loop derives it from the `reasoning`
165
+ * frames the provider wrote to the sink (see `observeTurnFrames`), so a provider only sets it to
166
+ * override that — e.g. one that receives reasoning it does not stream.
167
+ */
168
+ reasoning?: string;
169
+ /** Time spent thinking this turn, in ms. Derived like {@link reasoning} when omitted. */
170
+ reasoningMs?: number;
171
+ /** Components pushed during this turn (`ui` frames). Derived like {@link reasoning} when omitted. */
172
+ ui?: AgentUiComponent[];
163
173
  }
164
174
  /**
165
175
  * A model turn whose live frames were HELD instead of streamed, because an output processor has to
@@ -201,187 +211,33 @@ interface ModelProvider {
201
211
  runTurn(args: ModelTurnArgs): Promise<ModelTurnResult>;
202
212
  }
203
213
 
204
- /**
205
- * The structured live-stream vocabulary carried over the {@link SinkWriter} byte channel.
206
- *
207
- * The model turn (via the AI-SDK adapter) and the agent loop write these events as NDJSON — one
208
- * `JSON.stringify(event)\n` per {@link SinkWriter.write}. The HTTP layer forwards each line as an
209
- * SSE `data:` frame, and the client transport maps them back to the AI SDK UI-message chunk
210
- * protocol so the browser renders text, reasoning, and tool cards (input + output) LIVE — the same
211
- * rich rendering a raw `streamText().toUIMessageStream()` would give, but reconstructed on the
212
- * client so the sink stays a format-agnostic byte buffer (durable buffering/replay is untouched).
213
- *
214
- * Keeping this vocabulary neutral (not AI-SDK `UIMessageChunk`) means core never depends on `ai`:
215
- * the adapter owns model-parts → event, the transport owns event → UI-chunk.
216
- *
217
- * The vocabulary is also a CONTRACT for runners that are not this library's loop: anything that
218
- * writes these frames (one JSON object per SSE `data:` line) gets the React transport, transcript
219
- * model and hooks for free. Two rules keep it evolvable:
220
- * - every frame is a JSON object with a string `kind`; a reader MUST tolerate kinds it does not
221
- * know (the React transport forwards them as `data-<kind>` parts rather than dropping them);
222
- * - fields are only ever added, and new fields are optional.
223
- */
224
-
225
- /**
226
- * A component the server pushed into the conversation: generative UI that is NOT a tool call's
227
- * rendering. It is addressed by `component` (a key in the client's own component registry), never
228
- * by a tool name, so a runner can emit one from anywhere — a tool body, a post-processing step, a
229
- * sandboxed agent that renders through its own protocol.
230
- *
231
- * `id` is the component's identity within the message: a second frame with the same `id` REPLACES
232
- * the first (streaming props into a chart, flipping a card from "loading" to "ready"), it never
233
- * adds a second component.
234
- */
235
- interface AgentUiComponent {
236
- id: string;
237
- /** Registry key the client resolves to its own renderer, e.g. `data-table`. */
238
- component: string;
239
- props: Record<string, unknown>;
240
- /** Schema version of `props`, so a client can keep rendering components persisted by an older server. */
241
- version?: number;
242
- }
243
- /**
244
- * Who has to settle an action tool call, and until when. Metadata only: the call itself is still
245
- * settled through the tool-call approve/reject routes, by its `toolCallId`.
246
- */
247
- interface AgentApprovalRequest {
248
- /** The tool call awaiting the decision — the `id` of a call already announced on this stream. */
249
- id: string;
250
- /**
251
- * Who may decide. Open vocabulary the host defines — `'requester'` (the person chatting),
252
- * `'admin'`, a role name, a team. A client uses it to say "waiting on an admin" instead of
253
- * offering buttons the viewer cannot use.
254
- */
255
- approver: string;
256
- /** ISO-8601 instant after which the request lapses. Absent → it never expires. */
257
- expiresAt?: string;
258
- /** Why this call needs a person, in words for that person. */
259
- reason?: string;
260
- }
261
- type AgentStreamEvent = {
262
- kind: 'step-start';
263
- }
264
- /**
265
- * Closes the step opened by the matching `step-start`. Carries the model call's token usage and
266
- * `costUsd` (an estimate from the bound pricing store, or `null` when unpriced/unbound — never a
267
- * fabricated `0`) so a live client can render running cost without waiting for a thread re-fetch.
268
- */
269
- | {
270
- kind: 'step-finish';
271
- usage?: MessageUsage;
272
- costUsd?: number | null;
273
- } | {
274
- kind: 'text';
275
- text: string;
276
- } | {
277
- kind: 'reasoning';
278
- text: string;
279
- }
280
- /**
281
- * `toolKind` collapses `ToolKind`'s `'agent'` into `'read'` — delegation tools auto-execute like a read tool.
282
- *
283
- * `parentId` nests this call under another call on the same stream: the inner calls a code-mode
284
- * `execute` makes, the tools a delegated sub-agent runs. The parent must be announced first. A
285
- * call's parent is fixed by its first frame that names one; later frames may omit it.
286
- */
287
- | {
288
- kind: 'tool-input-start';
289
- id: string;
290
- name: string;
291
- toolKind: 'read' | 'action';
292
- parentId?: string;
293
- } | {
294
- kind: 'tool-input-delta';
295
- id: string;
296
- delta: string;
297
- } | {
298
- kind: 'tool-input-available';
299
- id: string;
300
- name: string;
301
- input: unknown;
302
- toolKind: 'read' | 'action';
303
- /** Same as on `tool-input-start`, for a runner that announces a call without streaming its input. */
304
- parentId?: string;
305
- } | {
306
- kind: 'tool-output';
307
- id: string;
308
- output: unknown;
309
- } | {
310
- kind: 'tool-output-error';
311
- id: string;
312
- error: string;
313
- }
314
- /**
315
- * A person was asked to approve an action tool and declined it. Its own frame, NOT
316
- * `tool-output-error`: a refusal is a decision with a known outcome — nothing ran — while a
317
- * failure is an outcome nobody chose and whose effects are unknown. Rendering them the same way
318
- * tells an operator their own "no" was a malfunction. Maps onto the SDK's `output-denied` tool
319
- * part state, which a client reads without knowing any tool's name.
320
- */
321
- | {
322
- kind: 'tool-output-denied';
323
- id: string;
324
- reason?: string;
325
- }
326
- /**
327
- * The run has put a question set to the user and is parked until someone answers it (or skips).
328
- * Written by the LOOP for both elicitation surfaces — the configured intake and the model's `ask`
329
- * tool — so a client renders one form either way rather than learning to recognise a tool name.
330
- * The matching `tool-output` frame, under the same `id`, carries the settled answers.
331
- */
332
- | {
333
- kind: 'elicitation';
334
- id: string;
335
- request: ElicitationRequest;
336
- }
337
- /**
338
- * An action tool call (already announced by `tool-input-start`/`tool-input-available` under the
339
- * same `id`) is parked on a person. Optional: a client still treats an `action` call stuck at
340
- * its input as pending — this frame adds WHO has to decide and UNTIL WHEN, and moves the call
341
- * into the AI SDK's native `approval-requested` state.
342
- */
343
- | ({
344
- kind: 'approval-requested';
345
- } & AgentApprovalRequest)
346
- /**
347
- * Server-pushed generative UI, positioned in the message where it arrives. Not tied to a tool
348
- * call. See {@link AgentUiComponent}.
349
- */
350
- | ({
351
- kind: 'ui';
352
- } & AgentUiComponent)
353
- /**
354
- * The thread's title was set or changed while this run streamed (typically derived from the
355
- * first exchange). Thread-level, not message content: a client updates its header/sidebar and
356
- * does not render it in the transcript.
357
- */
358
- | {
359
- kind: 'title';
360
- title: string;
214
+ /** What a model turn streamed that the persisted message keeps, beyond its text and tool calls. */
215
+ interface TurnFrameSummary {
216
+ reasoning?: string;
217
+ reasoningMs?: number;
218
+ ui?: AgentUiComponent[];
219
+ }
220
+ interface ObservedTurnFrames {
221
+ /** Hand THIS to the provider: every write passes through to the wrapped writer unchanged. */
222
+ writer: SinkWriter;
223
+ /** What was seen so far. Closes an open thinking burst at the moment it is called. */
224
+ summary(): TurnFrameSummary;
361
225
  }
362
226
  /**
363
- * Someone stopped this run. The stream's LAST frame, written by the runner that settled the
364
- * cancel, immediately before a normal `end()` — never a `fail()`, because a cancel is not an
365
- * error and a client that retries on a failed stream must not retry this.
227
+ * Watch the frames a model turn writes, to learn what the stream showed that the provider's result
228
+ * does not carry: the model's thinking (text and how long it took) and any pushed UI components.
366
229
  *
367
- * A run that simply ends wrote everything it had; one that ends after this frame did not, and the
368
- * difference is the whole point: without it a reader cannot tell a truncated answer from a
369
- * complete one. Consumers that predate the frame ignore it and see the `end()` they always saw.
370
- */
371
- | {
372
- kind: 'cancelled';
373
- };
374
- /** Encode one event as an NDJSON line (`{...}\n`) for {@link SinkWriter.write}. */
375
- declare function encodeStreamEvent(event: AgentStreamEvent): Uint8Array;
376
- /**
377
- * Read one NDJSON line back, or `null` when the line is not a stream event at all.
230
+ * Derived from the FRAMES rather than asked of each provider, so every provider that streams the
231
+ * vocabulary gets reasoning persisted without implementing anything. Thinking time is the sum of
232
+ * each burst of consecutive `reasoning` frames — from the first one to the next frame that is not
233
+ * reasoning (or the end of the turn) — which is what a reader watched as "thinking".
378
234
  *
379
- * `null` covers a genuinely opaque chunk, not just malformed JSON: the sink is a byte channel, so a
380
- * model provider is free to write anything into it and some write bare text. A caller that has to
381
- * CLASSIFY a chunk — the output gate, which may only forward what it can prove is not the answer —
382
- * treats an unreadable frame as unclassifiable rather than guessing.
235
+ * Call it inside the step that runs the model, so the summary rides that step's journaled result
236
+ * and a replay reads the same numbers back instead of re-measuring a turn that is not happening.
383
237
  */
384
- declare function decodeStreamEvent(line: string): AgentStreamEvent | null;
238
+ declare function observeTurnFrames(writer: SinkWriter, now?: () => number): ObservedTurnFrames;
239
+ /** Fill what a provider did not report from what its frames showed. A provider's own value wins. */
240
+ declare function withTurnFrames<T extends ModelTurnResult>(result: T, frames: TurnFrameSummary): T;
385
241
 
386
242
  interface CreateThreadInput {
387
243
  actor: Actor;
@@ -408,6 +264,12 @@ interface AppendMessageInput {
408
264
  * run) can omit it; the store persists it as `null` when absent.
409
265
  */
410
266
  runId?: string;
267
+ /** The step's streamed thinking. See {@link StoredMessage.reasoning}. */
268
+ reasoning?: string;
269
+ /** Time spent thinking in this step, in ms. See {@link StoredMessage.reasoningMs}. */
270
+ reasoningMs?: number;
271
+ /** Components pushed during this step. See {@link StoredMessage.ui}. */
272
+ ui?: AgentUiComponent[];
411
273
  }
412
274
  interface RecordToolCallInput {
413
275
  toolCallId: string;
@@ -3279,4 +3141,4 @@ type AgentDiagnosticKey = `agent:${AgentDiagnosticEvent}`;
3279
3141
  */
3280
3142
  declare function agentDiagnosticKey(event: AgentDiagnosticEvent): AgentDiagnosticKey;
3281
3143
 
3282
- export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, 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, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, type AgentApprovalRequest, 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 AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, type AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, type AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalWhere, type AttachmentRef, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, type CostUsage, type CreateThreadInput, type CurrentModelPrice, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, 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, MessageUsage, ModelAnswer, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QuotaExceededError, QuotaState, type QuotaStore, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, type RecentRunRow, type RecordRunEndInput, type RecordRunStartInput, type RecordToolCallInput, type RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, 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 ThreadTurnPage, type ThreadTurnQuery, type ThreadTurnReader, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type UpdateThreadInput, type UpdateToolCallInput, UsagePurpose, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, compositeSkillProvider, createFrameBuffer, createIncrementalGate, dayBoundsUtc, decodeStreamEvent, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, encodeStreamEvent, estimateCost, estimateMessageTokens, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, gateFollowUps, gateTail, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, memoryForgetVerdict, memoryWriteVerdict, normalizeDelegation, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticSkillProvider, summarizeWithModel, tenantScope, traceLlmTurn, traceToolExecution, truncateDetailContent, validateStructured, windowHistory, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, writeMemory };
3144
+ export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, 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, 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 AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalWhere, type AttachmentRef, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, type CostUsage, type CreateThreadInput, type CurrentModelPrice, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, 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, MessageUsage, ModelAnswer, 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, QuotaExceededError, QuotaState, type QuotaStore, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, type RecentRunRow, type RecordRunEndInput, type RecordRunStartInput, type RecordToolCallInput, type RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, 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 ThreadTurnPage, type ThreadTurnQuery, type ThreadTurnReader, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UpdateThreadInput, type UpdateToolCallInput, UsagePurpose, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, compositeSkillProvider, createFrameBuffer, createIncrementalGate, dayBoundsUtc, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, gateFollowUps, gateTail, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, memoryForgetVerdict, memoryWriteVerdict, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticSkillProvider, summarizeWithModel, tenantScope, traceLlmTurn, traceToolExecution, truncateDetailContent, validateStructured, windowHistory, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, writeMemory };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, E as ElicitationRequest, A as Actor, d as ThreadSummary, e as ThreadDetail, S as StoredMessage, f as ToolResult, g as MessageAttachment, h as ToolCallStatus, U as UsagePurpose, i as ToolSpec, Q as QuotaState, j as AgentRunInput, H as HumanReply, T as ToolHandler, k as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, l as ProcessedPrompt, m as ModelAnswer, n as PageContext, o as AgentDefinition, p as AgentDelegation, D as DetachedDelivery, q as AiToolCtx, r as PromptBuilder, s as PromptContributor, t as ToolTransientRetrySetting, u as AgentIntake, v as Decision, L as LlmStepEnvelope, w as ToolStepEnvelope } from './tool-CL9oEytW.js';
2
- export { x as ASK_TOOL_DESCRIPTION, y as ASK_TOOL_NAME, z as AgentCatalogEntry, B as AgentHistoryWindow, C as AskToolInput, F as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, G as DEFAULT_INTAKE_PREAMBLE, J as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, K as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, N as ElicitationOption, R as ElicitationOutcome, V as ElicitationQuestion, W as ElicitationReply, X as ElicitationResult, Y as HistoryPolicyContext, Z as HistorySelection, _ as HistorySummary, $ as IncrementalGating, a0 as InvokeWithTransientRetryOptions, a1 as MAX_ASK_QUESTIONS, a2 as MessageRole, a3 as OutputRejectedError, a4 as OutputVerdict, a5 as ProcessorFailedError, a6 as PromptContext, a7 as QuotaView, a8 as ToolKind, a9 as ToolStepCtx, aa as ToolTransientRetryNumbers, ab as ToolTransientRetryOptions, ac as askInputSchema, ad as askToolDefinition, ae as invokeWithTransientRetry, af as isTransientToolError, ag as normalizeElicitationReply, ah as renderElicitationAnswers, ai as resolveElicitation, aj as resolveToolTransientRetryNumbers, ak as settleElicitation } from './tool-CL9oEytW.js';
1
+ import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as ThreadSummary, f as ThreadDetail, S as StoredMessage, g as ToolResult, h as MessageAttachment, i as ToolCallStatus, U as UsagePurpose, j as ToolSpec, Q as QuotaState, k as AgentRunInput, H as HumanReply, T as ToolHandler, l as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, m as ProcessedPrompt, n as ModelAnswer, o as PageContext, p as AgentDefinition, q as AgentDelegation, D as DetachedDelivery, r as AiToolCtx, s as PromptBuilder, t as PromptContributor, u as ToolTransientRetrySetting, v as AgentIntake, w as Decision, E as ElicitationRequest, L as LlmStepEnvelope, x as ToolStepEnvelope } from './tool-CHIw-aTx.js';
2
+ export { y as ASK_TOOL_DESCRIPTION, z as ASK_TOOL_NAME, B as AgentApprovalRequest, C as AgentCatalogEntry, F as AgentHistoryWindow, G as AgentStreamEvent, J as AskToolInput, K as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, N as DEFAULT_INTAKE_PREAMBLE, R as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, V as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, W as ElicitationOption, X as ElicitationOutcome, Y as ElicitationQuestion, Z as ElicitationReply, _ as ElicitationResult, $ as HistoryPolicyContext, a0 as HistorySelection, a1 as HistorySummary, a2 as IncrementalGating, a3 as InvokeWithTransientRetryOptions, a4 as MAX_ASK_QUESTIONS, a5 as MessageRole, a6 as OutputRejectedError, a7 as OutputVerdict, a8 as ProcessorFailedError, a9 as PromptContext, aa as QuotaView, ab as ToolKind, ac as ToolStepCtx, ad as ToolTransientRetryNumbers, ae as ToolTransientRetryOptions, af as askInputSchema, ag as askToolDefinition, ah as decodeStreamEvent, ai as encodeStreamEvent, aj as invokeWithTransientRetry, ak as isTransientToolError, al as normalizeElicitationReply, am as renderElicitationAnswers, an as resolveElicitation, ao as resolveToolTransientRetryNumbers, ap as settleElicitation } from './tool-CHIw-aTx.js';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
5
5
 
@@ -160,6 +160,16 @@ interface ModelTurnResult {
160
160
  * the JSON out of `text`) is always correct.
161
161
  */
162
162
  object?: unknown;
163
+ /**
164
+ * The model's thinking this turn, as streamed. Optional: the loop derives it from the `reasoning`
165
+ * frames the provider wrote to the sink (see `observeTurnFrames`), so a provider only sets it to
166
+ * override that — e.g. one that receives reasoning it does not stream.
167
+ */
168
+ reasoning?: string;
169
+ /** Time spent thinking this turn, in ms. Derived like {@link reasoning} when omitted. */
170
+ reasoningMs?: number;
171
+ /** Components pushed during this turn (`ui` frames). Derived like {@link reasoning} when omitted. */
172
+ ui?: AgentUiComponent[];
163
173
  }
164
174
  /**
165
175
  * A model turn whose live frames were HELD instead of streamed, because an output processor has to
@@ -201,187 +211,33 @@ interface ModelProvider {
201
211
  runTurn(args: ModelTurnArgs): Promise<ModelTurnResult>;
202
212
  }
203
213
 
204
- /**
205
- * The structured live-stream vocabulary carried over the {@link SinkWriter} byte channel.
206
- *
207
- * The model turn (via the AI-SDK adapter) and the agent loop write these events as NDJSON — one
208
- * `JSON.stringify(event)\n` per {@link SinkWriter.write}. The HTTP layer forwards each line as an
209
- * SSE `data:` frame, and the client transport maps them back to the AI SDK UI-message chunk
210
- * protocol so the browser renders text, reasoning, and tool cards (input + output) LIVE — the same
211
- * rich rendering a raw `streamText().toUIMessageStream()` would give, but reconstructed on the
212
- * client so the sink stays a format-agnostic byte buffer (durable buffering/replay is untouched).
213
- *
214
- * Keeping this vocabulary neutral (not AI-SDK `UIMessageChunk`) means core never depends on `ai`:
215
- * the adapter owns model-parts → event, the transport owns event → UI-chunk.
216
- *
217
- * The vocabulary is also a CONTRACT for runners that are not this library's loop: anything that
218
- * writes these frames (one JSON object per SSE `data:` line) gets the React transport, transcript
219
- * model and hooks for free. Two rules keep it evolvable:
220
- * - every frame is a JSON object with a string `kind`; a reader MUST tolerate kinds it does not
221
- * know (the React transport forwards them as `data-<kind>` parts rather than dropping them);
222
- * - fields are only ever added, and new fields are optional.
223
- */
224
-
225
- /**
226
- * A component the server pushed into the conversation: generative UI that is NOT a tool call's
227
- * rendering. It is addressed by `component` (a key in the client's own component registry), never
228
- * by a tool name, so a runner can emit one from anywhere — a tool body, a post-processing step, a
229
- * sandboxed agent that renders through its own protocol.
230
- *
231
- * `id` is the component's identity within the message: a second frame with the same `id` REPLACES
232
- * the first (streaming props into a chart, flipping a card from "loading" to "ready"), it never
233
- * adds a second component.
234
- */
235
- interface AgentUiComponent {
236
- id: string;
237
- /** Registry key the client resolves to its own renderer, e.g. `data-table`. */
238
- component: string;
239
- props: Record<string, unknown>;
240
- /** Schema version of `props`, so a client can keep rendering components persisted by an older server. */
241
- version?: number;
242
- }
243
- /**
244
- * Who has to settle an action tool call, and until when. Metadata only: the call itself is still
245
- * settled through the tool-call approve/reject routes, by its `toolCallId`.
246
- */
247
- interface AgentApprovalRequest {
248
- /** The tool call awaiting the decision — the `id` of a call already announced on this stream. */
249
- id: string;
250
- /**
251
- * Who may decide. Open vocabulary the host defines — `'requester'` (the person chatting),
252
- * `'admin'`, a role name, a team. A client uses it to say "waiting on an admin" instead of
253
- * offering buttons the viewer cannot use.
254
- */
255
- approver: string;
256
- /** ISO-8601 instant after which the request lapses. Absent → it never expires. */
257
- expiresAt?: string;
258
- /** Why this call needs a person, in words for that person. */
259
- reason?: string;
260
- }
261
- type AgentStreamEvent = {
262
- kind: 'step-start';
263
- }
264
- /**
265
- * Closes the step opened by the matching `step-start`. Carries the model call's token usage and
266
- * `costUsd` (an estimate from the bound pricing store, or `null` when unpriced/unbound — never a
267
- * fabricated `0`) so a live client can render running cost without waiting for a thread re-fetch.
268
- */
269
- | {
270
- kind: 'step-finish';
271
- usage?: MessageUsage;
272
- costUsd?: number | null;
273
- } | {
274
- kind: 'text';
275
- text: string;
276
- } | {
277
- kind: 'reasoning';
278
- text: string;
279
- }
280
- /**
281
- * `toolKind` collapses `ToolKind`'s `'agent'` into `'read'` — delegation tools auto-execute like a read tool.
282
- *
283
- * `parentId` nests this call under another call on the same stream: the inner calls a code-mode
284
- * `execute` makes, the tools a delegated sub-agent runs. The parent must be announced first. A
285
- * call's parent is fixed by its first frame that names one; later frames may omit it.
286
- */
287
- | {
288
- kind: 'tool-input-start';
289
- id: string;
290
- name: string;
291
- toolKind: 'read' | 'action';
292
- parentId?: string;
293
- } | {
294
- kind: 'tool-input-delta';
295
- id: string;
296
- delta: string;
297
- } | {
298
- kind: 'tool-input-available';
299
- id: string;
300
- name: string;
301
- input: unknown;
302
- toolKind: 'read' | 'action';
303
- /** Same as on `tool-input-start`, for a runner that announces a call without streaming its input. */
304
- parentId?: string;
305
- } | {
306
- kind: 'tool-output';
307
- id: string;
308
- output: unknown;
309
- } | {
310
- kind: 'tool-output-error';
311
- id: string;
312
- error: string;
313
- }
314
- /**
315
- * A person was asked to approve an action tool and declined it. Its own frame, NOT
316
- * `tool-output-error`: a refusal is a decision with a known outcome — nothing ran — while a
317
- * failure is an outcome nobody chose and whose effects are unknown. Rendering them the same way
318
- * tells an operator their own "no" was a malfunction. Maps onto the SDK's `output-denied` tool
319
- * part state, which a client reads without knowing any tool's name.
320
- */
321
- | {
322
- kind: 'tool-output-denied';
323
- id: string;
324
- reason?: string;
325
- }
326
- /**
327
- * The run has put a question set to the user and is parked until someone answers it (or skips).
328
- * Written by the LOOP for both elicitation surfaces — the configured intake and the model's `ask`
329
- * tool — so a client renders one form either way rather than learning to recognise a tool name.
330
- * The matching `tool-output` frame, under the same `id`, carries the settled answers.
331
- */
332
- | {
333
- kind: 'elicitation';
334
- id: string;
335
- request: ElicitationRequest;
336
- }
337
- /**
338
- * An action tool call (already announced by `tool-input-start`/`tool-input-available` under the
339
- * same `id`) is parked on a person. Optional: a client still treats an `action` call stuck at
340
- * its input as pending — this frame adds WHO has to decide and UNTIL WHEN, and moves the call
341
- * into the AI SDK's native `approval-requested` state.
342
- */
343
- | ({
344
- kind: 'approval-requested';
345
- } & AgentApprovalRequest)
346
- /**
347
- * Server-pushed generative UI, positioned in the message where it arrives. Not tied to a tool
348
- * call. See {@link AgentUiComponent}.
349
- */
350
- | ({
351
- kind: 'ui';
352
- } & AgentUiComponent)
353
- /**
354
- * The thread's title was set or changed while this run streamed (typically derived from the
355
- * first exchange). Thread-level, not message content: a client updates its header/sidebar and
356
- * does not render it in the transcript.
357
- */
358
- | {
359
- kind: 'title';
360
- title: string;
214
+ /** What a model turn streamed that the persisted message keeps, beyond its text and tool calls. */
215
+ interface TurnFrameSummary {
216
+ reasoning?: string;
217
+ reasoningMs?: number;
218
+ ui?: AgentUiComponent[];
219
+ }
220
+ interface ObservedTurnFrames {
221
+ /** Hand THIS to the provider: every write passes through to the wrapped writer unchanged. */
222
+ writer: SinkWriter;
223
+ /** What was seen so far. Closes an open thinking burst at the moment it is called. */
224
+ summary(): TurnFrameSummary;
361
225
  }
362
226
  /**
363
- * Someone stopped this run. The stream's LAST frame, written by the runner that settled the
364
- * cancel, immediately before a normal `end()` — never a `fail()`, because a cancel is not an
365
- * error and a client that retries on a failed stream must not retry this.
227
+ * Watch the frames a model turn writes, to learn what the stream showed that the provider's result
228
+ * does not carry: the model's thinking (text and how long it took) and any pushed UI components.
366
229
  *
367
- * A run that simply ends wrote everything it had; one that ends after this frame did not, and the
368
- * difference is the whole point: without it a reader cannot tell a truncated answer from a
369
- * complete one. Consumers that predate the frame ignore it and see the `end()` they always saw.
370
- */
371
- | {
372
- kind: 'cancelled';
373
- };
374
- /** Encode one event as an NDJSON line (`{...}\n`) for {@link SinkWriter.write}. */
375
- declare function encodeStreamEvent(event: AgentStreamEvent): Uint8Array;
376
- /**
377
- * Read one NDJSON line back, or `null` when the line is not a stream event at all.
230
+ * Derived from the FRAMES rather than asked of each provider, so every provider that streams the
231
+ * vocabulary gets reasoning persisted without implementing anything. Thinking time is the sum of
232
+ * each burst of consecutive `reasoning` frames — from the first one to the next frame that is not
233
+ * reasoning (or the end of the turn) — which is what a reader watched as "thinking".
378
234
  *
379
- * `null` covers a genuinely opaque chunk, not just malformed JSON: the sink is a byte channel, so a
380
- * model provider is free to write anything into it and some write bare text. A caller that has to
381
- * CLASSIFY a chunk — the output gate, which may only forward what it can prove is not the answer —
382
- * treats an unreadable frame as unclassifiable rather than guessing.
235
+ * Call it inside the step that runs the model, so the summary rides that step's journaled result
236
+ * and a replay reads the same numbers back instead of re-measuring a turn that is not happening.
383
237
  */
384
- declare function decodeStreamEvent(line: string): AgentStreamEvent | null;
238
+ declare function observeTurnFrames(writer: SinkWriter, now?: () => number): ObservedTurnFrames;
239
+ /** Fill what a provider did not report from what its frames showed. A provider's own value wins. */
240
+ declare function withTurnFrames<T extends ModelTurnResult>(result: T, frames: TurnFrameSummary): T;
385
241
 
386
242
  interface CreateThreadInput {
387
243
  actor: Actor;
@@ -408,6 +264,12 @@ interface AppendMessageInput {
408
264
  * run) can omit it; the store persists it as `null` when absent.
409
265
  */
410
266
  runId?: string;
267
+ /** The step's streamed thinking. See {@link StoredMessage.reasoning}. */
268
+ reasoning?: string;
269
+ /** Time spent thinking in this step, in ms. See {@link StoredMessage.reasoningMs}. */
270
+ reasoningMs?: number;
271
+ /** Components pushed during this step. See {@link StoredMessage.ui}. */
272
+ ui?: AgentUiComponent[];
411
273
  }
412
274
  interface RecordToolCallInput {
413
275
  toolCallId: string;
@@ -3279,4 +3141,4 @@ type AgentDiagnosticKey = `agent:${AgentDiagnosticEvent}`;
3279
3141
  */
3280
3142
  declare function agentDiagnosticKey(event: AgentDiagnosticEvent): AgentDiagnosticKey;
3281
3143
 
3282
- export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, 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, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, type AgentApprovalRequest, 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 AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, type AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, type AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalWhere, type AttachmentRef, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, type CostUsage, type CreateThreadInput, type CurrentModelPrice, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, 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, MessageUsage, ModelAnswer, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QuotaExceededError, QuotaState, type QuotaStore, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, type RecentRunRow, type RecordRunEndInput, type RecordRunStartInput, type RecordToolCallInput, type RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, 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 ThreadTurnPage, type ThreadTurnQuery, type ThreadTurnReader, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type UpdateThreadInput, type UpdateToolCallInput, UsagePurpose, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, compositeSkillProvider, createFrameBuffer, createIncrementalGate, dayBoundsUtc, decodeStreamEvent, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, encodeStreamEvent, estimateCost, estimateMessageTokens, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, gateFollowUps, gateTail, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, memoryForgetVerdict, memoryWriteVerdict, normalizeDelegation, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticSkillProvider, summarizeWithModel, tenantScope, traceLlmTurn, traceToolExecution, truncateDetailContent, validateStructured, windowHistory, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, writeMemory };
3144
+ export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, 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, 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 AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalWhere, type AttachmentRef, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, type CostUsage, type CreateThreadInput, type CurrentModelPrice, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, 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, MessageUsage, ModelAnswer, 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, QuotaExceededError, QuotaState, type QuotaStore, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, type RecentRunRow, type RecordRunEndInput, type RecordRunStartInput, type RecordToolCallInput, type RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, 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 ThreadTurnPage, type ThreadTurnQuery, type ThreadTurnReader, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UpdateThreadInput, type UpdateToolCallInput, UsagePurpose, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, compositeSkillProvider, createFrameBuffer, createIncrementalGate, dayBoundsUtc, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, gateFollowUps, gateTail, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, memoryForgetVerdict, memoryWriteVerdict, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticSkillProvider, summarizeWithModel, tenantScope, traceLlmTurn, traceToolExecution, truncateDetailContent, validateStructured, windowHistory, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, writeMemory };