@dudousxd/nestjs-agent-core 0.29.0 → 0.31.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,8 +1,8 @@
1
- import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, A as Actor, g as AiToolCtx, h as AgentStreamEvent, i as ThreadSummary, j as ThreadDetail, S as StoredMessage, k as ToolResult, l as MessageAttachment, m as MessageFeedback, n as ToolCallStatus, U as UsagePurpose, T as ToolSpec, Q as QuotaState, o as AgentRunInput, H as HumanReply, p as ToolKind, q as ToolCallApproval, a as ToolHandler, r as HistoryPolicy, P as PageContext, s as AgentDefinition, t as AgentDelegation, D as DetachedDelivery, u as ToolDescribeScope, v as PromptBuilder, w as PromptContributor, x as ToolTransientRetrySetting, y as AgentIntake, z as Decision, E as ElicitationRequest, L as LlmStepEnvelope, B as ToolStepEnvelope } from './tool-CON4ZOrD.cjs';
2
- export { C as ASK_TOOL_DESCRIPTION, F as ASK_TOOL_NAME, G as AgentApprovalRequest, I as AgentApprovalSettlement, J as AgentAttachmentConfig, K as AgentCatalogEntry, N as AgentClientConfig, O as AgentHistoryWindow, R as AskToolInput, V as DEFAULT_INTAKE_PREAMBLE, W as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, X as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, Y as ELICITATION_INPUT_TYPES, Z as ElicitationInput, _ as ElicitationInputType, $ as ElicitationOption, a0 as ElicitationOutcome, a1 as ElicitationQuestion, a2 as ElicitationReply, a3 as ElicitationResult, a4 as HistoryPolicyContext, a5 as HistorySelection, a6 as HistorySummary, a7 as InvokeWithTransientRetryOptions, a8 as MAX_ASK_QUESTIONS, a9 as MessageFeedbackValue, aa as MessageRole, ab as PromptContext, ac as QuotaView, ad as ToolCallApprovalStatus, ae as ToolCatalogEntry, af as ToolConfirmation, ag as ToolDescription, b as ToolPresentation, ah as ToolPresentationTone, ai as ToolResultField, aj as ToolResultView, ak as ToolStepCtx, al as ToolTransientRetryNumbers, am as ToolTransientRetryOptions, an as askInputSchema, ao as askToolDefinition, ap as decodeStreamEvent, aq as encodeStreamEvent, ar as invokeWithTransientRetry, as as isTransientToolError, at as isTypedQuestion, au as normalizeElicitationReply, av as questionOptions, aw as readElicitationInput, ax as readElicitationQuestions, ay as renderElicitationAnswers, az as resolveElicitation, aA as resolveToolTransientRetryNumbers, aB as settleElicitation, aC as validateElicitationAnswer, aD as validateElicitationValue } from './tool-CON4ZOrD.cjs';
1
+ import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, A as Actor, g as AiToolCtx, h as AgentStreamEvent, i as ThreadSummary, j as ThreadDetail, S as StoredMessage, k as ToolResult, l as MessageAttachment, m as MessageFeedback, n as ToolCallStatus, U as UsagePurpose, T as ToolSpec, Q as QuotaState, o as AgentRunInput, H as HumanReply, p as ToolKind, q as ToolCallApproval, a as ToolHandler, r as HistoryPolicy, P as PageContext, s as AgentDefinition, t as AgentDelegation, D as DetachedDelivery, u as ToolDescribeScope, v as PromptBuilder, w as PromptContributor, x as ToolTransientRetrySetting, y as AgentIntake, z as Decision, E as ElicitationRequest, L as LlmStepEnvelope, B as ToolStepEnvelope } from './tool-B0J4Fjyd.cjs';
2
+ export { C as ALL_AGENTS, F as ASK_TOOL_DESCRIPTION, G as ASK_TOOL_NAME, I as AgentApprovalRequest, J as AgentApprovalSettlement, K as AgentAttachmentConfig, N as AgentCatalogEntry, O as AgentClientConfig, R as AgentHistoryWindow, V as AskToolInput, W as DEFAULT_INTAKE_PREAMBLE, X as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, Y as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, Z as ELICITATION_INPUT_TYPES, _ as ElicitationInput, $ as ElicitationInputType, a0 as ElicitationOption, a1 as ElicitationOutcome, a2 as ElicitationQuestion, a3 as ElicitationReply, a4 as ElicitationResult, a5 as HistoryPolicyContext, a6 as HistorySelection, a7 as HistorySummary, a8 as InvokeWithTransientRetryOptions, a9 as MAX_ASK_QUESTIONS, aa as MessageFeedbackValue, ab as MessageRole, ac as PromptContext, ad as QuotaView, ae as ToolCallApprovalStatus, af as ToolCatalogEntry, ag as ToolConfirmation, ah as ToolDescription, b as ToolPresentation, ai as ToolPresentationTone, aj as ToolResultField, ak as ToolResultView, al as ToolStepCtx, am as ToolTransientRetryNumbers, an as ToolTransientRetryOptions, ao as askInputSchema, ap as askToolDefinition, aq as decodeStreamEvent, ar as encodeStreamEvent, as as invokeWithTransientRetry, at as isTransientToolError, au as isTypedQuestion, av as normalizeElicitationReply, aw as questionOptions, ax as readElicitationInput, ay as readElicitationQuestions, az as renderElicitationAnswers, aA as resolveElicitation, aB as resolveToolTransientRetryNumbers, aC as settleElicitation, aD as validateElicitationAnswer, aE as validateElicitationValue } from './tool-B0J4Fjyd.cjs';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
- import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-3FixaBnr.cjs';
5
- export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-3FixaBnr.cjs';
4
+ import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-DdnRmmlq.cjs';
5
+ export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-DdnRmmlq.cjs';
6
6
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
7
7
 
8
8
  /**
@@ -244,9 +244,22 @@ interface ModelCatalogProviderGroup {
244
244
  label: string;
245
245
  models: ModelCatalogEntry[];
246
246
  }
247
+ /** The agent always runs on one model: the picker shows it and offers no choice. */
248
+ interface ModelCatalogLock {
249
+ /** The catalog id every turn runs on. */
250
+ model: string;
251
+ /** Why, in words a picker can show ("This assistant always uses GPT-5"). */
252
+ reason?: string;
253
+ }
247
254
  /** What `GET <base>/models` answers. */
248
255
  interface ModelCatalogView {
249
256
  providers: ModelCatalogProviderGroup[];
257
+ /**
258
+ * Present when the agent is locked to one model. Every turn runs on `locked.model` — a send's own
259
+ * `model` and a thread's pin included — and a send naming another model is refused (`400`). List
260
+ * the other models as unavailable too, so an older client that ignores the lock cannot pick them.
261
+ */
262
+ locked?: ModelCatalogLock;
250
263
  /** The model a turn runs on when nobody picked one; `null` when the provider decides. */
251
264
  default: string | null;
252
265
  }
@@ -692,7 +705,11 @@ type QuotaPeriod = 'day' | 'month';
692
705
  /** One budget window: what was spent in it, and the ceiling when there is one. */
693
706
  interface QuotaWindow {
694
707
  period: QuotaPeriod;
695
- usedTokens: number;
708
+ /**
709
+ * Tokens used in the window. Absent → the budget does not count tokens (a USD-only spend cap, such
710
+ * as an AI gateway's) — never a fabricated `0`.
711
+ */
712
+ usedTokens?: number;
696
713
  /** Absent → no token ceiling on this window. */
697
714
  limitTokens?: number;
698
715
  usedUsd: number;
@@ -700,6 +717,11 @@ interface QuotaWindow {
700
717
  limitUsd?: number;
701
718
  /** ISO-8601 instant the window starts over (next UTC midnight, first of next month). */
702
719
  resetsAt?: string;
720
+ /**
721
+ * The soft limit: the share of a ceiling (`0..1`, e.g. `0.8`) past which a client should warn
722
+ * that the budget is running out. Absent → no warning for this window.
723
+ */
724
+ warnAt?: number;
703
725
  }
704
726
  /** Which window stopped the actor, when one did. */
705
727
  interface QuotaBlock {
@@ -707,11 +729,24 @@ interface QuotaBlock {
707
729
  /** Words a client can show ("Monthly AI budget reached"). */
708
730
  reason?: string;
709
731
  }
732
+ /** A window past its soft limit ({@link QuotaWindow.warnAt}) but not exhausted. */
733
+ interface QuotaWarning {
734
+ period: QuotaPeriod;
735
+ /** How much of the window's ceiling is used, `0..1` (the larger of spend and tokens). */
736
+ ratio: number;
737
+ /** Words a client can show ("80% of your monthly AI budget used"). */
738
+ reason?: string;
739
+ }
710
740
  /** What `GET <base>/quota` answers. */
711
741
  interface QuotaReport {
712
742
  windows: QuotaWindow[];
713
743
  /** Present when a window is exhausted — a send will be refused until it resets. */
714
744
  blocked?: QuotaBlock;
745
+ /**
746
+ * Present when a window crossed its `warnAt` and none is exhausted — the fullest one. A client
747
+ * may also derive it from the windows ({@link quotaWarning}); the server's wins.
748
+ */
749
+ warning?: QuotaWarning;
715
750
  }
716
751
  interface QuotaQuery {
717
752
  actor: Actor;
@@ -731,6 +766,13 @@ interface QuotaProvider {
731
766
  }
732
767
  /** The first window whose token or spend ceiling is reached, as a {@link QuotaBlock}. */
733
768
  declare function exhaustedWindow(windows: readonly QuotaWindow[]): QuotaBlock | undefined;
769
+ /** How much of `window`'s ceilings is used, `0..1+` (the larger of spend and tokens), or `null`. */
770
+ declare function quotaUsedRatio(window: QuotaWindow): number | null;
771
+ /**
772
+ * The fullest window past its `warnAt`, as a {@link QuotaWarning} — `undefined` when none is, or
773
+ * when one is exhausted (that is `blocked`, not a warning).
774
+ */
775
+ declare function quotaWarning(windows: readonly QuotaWindow[]): QuotaWarning | undefined;
734
776
  /** The UTC day range (`YYYY-MM-DD`, inclusive) and reset instant of `period` around `now`. */
735
777
  declare function quotaPeriodRange(period: QuotaPeriod, now: Date): {
736
778
  fromDay: string;
@@ -3702,4 +3744,4 @@ declare class InMemoryAgentStore implements AgentStore {
3702
3744
  private toSummary;
3703
3745
  }
3704
3746
 
3705
- 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_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 AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalDecisionRef, type ApprovalPolicy, type ApprovalRequirement, type ApprovalThreadRef, type ApprovalToolRef, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, 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, DefaultApprovalPolicy, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, 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, 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 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, type QuotaBlock, QuotaExceededError, type QuotaPeriod, type QuotaProvider, type QuotaQuery, type QuotaReport, QuotaState, type QuotaStore, type QuotaWindow, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, REQUESTER_APPROVER, 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, ToolCallApproval, type ToolCallApprovalColumns, type ToolCallApprovalState, 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, 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, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, exhaustedWindow, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, gateFollowUps, gateTail, 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, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticModelCatalog, staticSkillProvider, summarizeWithModel, tenantScope, toolCallApprovalFromRow, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, windowHistory, withAskTool, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
3747
+ 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_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 AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalDecisionRef, type ApprovalPolicy, type ApprovalRequirement, type ApprovalThreadRef, type ApprovalToolRef, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, 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, DefaultApprovalPolicy, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, 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, 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, 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, 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, ToolCallApproval, type ToolCallApprovalColumns, type ToolCallApprovalState, 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, 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, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, exhaustedWindow, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, gateFollowUps, gateTail, 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, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticModelCatalog, staticSkillProvider, summarizeWithModel, tenantScope, toolCallApprovalFromRow, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, windowHistory, withAskTool, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, A as Actor, g as AiToolCtx, h as AgentStreamEvent, i as ThreadSummary, j as ThreadDetail, S as StoredMessage, k as ToolResult, l as MessageAttachment, m as MessageFeedback, n as ToolCallStatus, U as UsagePurpose, T as ToolSpec, Q as QuotaState, o as AgentRunInput, H as HumanReply, p as ToolKind, q as ToolCallApproval, a as ToolHandler, r as HistoryPolicy, P as PageContext, s as AgentDefinition, t as AgentDelegation, D as DetachedDelivery, u as ToolDescribeScope, v as PromptBuilder, w as PromptContributor, x as ToolTransientRetrySetting, y as AgentIntake, z as Decision, E as ElicitationRequest, L as LlmStepEnvelope, B as ToolStepEnvelope } from './tool-CON4ZOrD.js';
2
- export { C as ASK_TOOL_DESCRIPTION, F as ASK_TOOL_NAME, G as AgentApprovalRequest, I as AgentApprovalSettlement, J as AgentAttachmentConfig, K as AgentCatalogEntry, N as AgentClientConfig, O as AgentHistoryWindow, R as AskToolInput, V as DEFAULT_INTAKE_PREAMBLE, W as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, X as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, Y as ELICITATION_INPUT_TYPES, Z as ElicitationInput, _ as ElicitationInputType, $ as ElicitationOption, a0 as ElicitationOutcome, a1 as ElicitationQuestion, a2 as ElicitationReply, a3 as ElicitationResult, a4 as HistoryPolicyContext, a5 as HistorySelection, a6 as HistorySummary, a7 as InvokeWithTransientRetryOptions, a8 as MAX_ASK_QUESTIONS, a9 as MessageFeedbackValue, aa as MessageRole, ab as PromptContext, ac as QuotaView, ad as ToolCallApprovalStatus, ae as ToolCatalogEntry, af as ToolConfirmation, ag as ToolDescription, b as ToolPresentation, ah as ToolPresentationTone, ai as ToolResultField, aj as ToolResultView, ak as ToolStepCtx, al as ToolTransientRetryNumbers, am as ToolTransientRetryOptions, an as askInputSchema, ao as askToolDefinition, ap as decodeStreamEvent, aq as encodeStreamEvent, ar as invokeWithTransientRetry, as as isTransientToolError, at as isTypedQuestion, au as normalizeElicitationReply, av as questionOptions, aw as readElicitationInput, ax as readElicitationQuestions, ay as renderElicitationAnswers, az as resolveElicitation, aA as resolveToolTransientRetryNumbers, aB as settleElicitation, aC as validateElicitationAnswer, aD as validateElicitationValue } from './tool-CON4ZOrD.js';
1
+ import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, A as Actor, g as AiToolCtx, h as AgentStreamEvent, i as ThreadSummary, j as ThreadDetail, S as StoredMessage, k as ToolResult, l as MessageAttachment, m as MessageFeedback, n as ToolCallStatus, U as UsagePurpose, T as ToolSpec, Q as QuotaState, o as AgentRunInput, H as HumanReply, p as ToolKind, q as ToolCallApproval, a as ToolHandler, r as HistoryPolicy, P as PageContext, s as AgentDefinition, t as AgentDelegation, D as DetachedDelivery, u as ToolDescribeScope, v as PromptBuilder, w as PromptContributor, x as ToolTransientRetrySetting, y as AgentIntake, z as Decision, E as ElicitationRequest, L as LlmStepEnvelope, B as ToolStepEnvelope } from './tool-B0J4Fjyd.js';
2
+ export { C as ALL_AGENTS, F as ASK_TOOL_DESCRIPTION, G as ASK_TOOL_NAME, I as AgentApprovalRequest, J as AgentApprovalSettlement, K as AgentAttachmentConfig, N as AgentCatalogEntry, O as AgentClientConfig, R as AgentHistoryWindow, V as AskToolInput, W as DEFAULT_INTAKE_PREAMBLE, X as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, Y as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, Z as ELICITATION_INPUT_TYPES, _ as ElicitationInput, $ as ElicitationInputType, a0 as ElicitationOption, a1 as ElicitationOutcome, a2 as ElicitationQuestion, a3 as ElicitationReply, a4 as ElicitationResult, a5 as HistoryPolicyContext, a6 as HistorySelection, a7 as HistorySummary, a8 as InvokeWithTransientRetryOptions, a9 as MAX_ASK_QUESTIONS, aa as MessageFeedbackValue, ab as MessageRole, ac as PromptContext, ad as QuotaView, ae as ToolCallApprovalStatus, af as ToolCatalogEntry, ag as ToolConfirmation, ah as ToolDescription, b as ToolPresentation, ai as ToolPresentationTone, aj as ToolResultField, ak as ToolResultView, al as ToolStepCtx, am as ToolTransientRetryNumbers, an as ToolTransientRetryOptions, ao as askInputSchema, ap as askToolDefinition, aq as decodeStreamEvent, ar as encodeStreamEvent, as as invokeWithTransientRetry, at as isTransientToolError, au as isTypedQuestion, av as normalizeElicitationReply, aw as questionOptions, ax as readElicitationInput, ay as readElicitationQuestions, az as renderElicitationAnswers, aA as resolveElicitation, aB as resolveToolTransientRetryNumbers, aC as settleElicitation, aD as validateElicitationAnswer, aE as validateElicitationValue } from './tool-B0J4Fjyd.js';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
- import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-BrGKQgLf.js';
5
- export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-BrGKQgLf.js';
4
+ import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-C3Qx3ZdF.js';
5
+ export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-C3Qx3ZdF.js';
6
6
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
7
7
 
8
8
  /**
@@ -244,9 +244,22 @@ interface ModelCatalogProviderGroup {
244
244
  label: string;
245
245
  models: ModelCatalogEntry[];
246
246
  }
247
+ /** The agent always runs on one model: the picker shows it and offers no choice. */
248
+ interface ModelCatalogLock {
249
+ /** The catalog id every turn runs on. */
250
+ model: string;
251
+ /** Why, in words a picker can show ("This assistant always uses GPT-5"). */
252
+ reason?: string;
253
+ }
247
254
  /** What `GET <base>/models` answers. */
248
255
  interface ModelCatalogView {
249
256
  providers: ModelCatalogProviderGroup[];
257
+ /**
258
+ * Present when the agent is locked to one model. Every turn runs on `locked.model` — a send's own
259
+ * `model` and a thread's pin included — and a send naming another model is refused (`400`). List
260
+ * the other models as unavailable too, so an older client that ignores the lock cannot pick them.
261
+ */
262
+ locked?: ModelCatalogLock;
250
263
  /** The model a turn runs on when nobody picked one; `null` when the provider decides. */
251
264
  default: string | null;
252
265
  }
@@ -692,7 +705,11 @@ type QuotaPeriod = 'day' | 'month';
692
705
  /** One budget window: what was spent in it, and the ceiling when there is one. */
693
706
  interface QuotaWindow {
694
707
  period: QuotaPeriod;
695
- usedTokens: number;
708
+ /**
709
+ * Tokens used in the window. Absent → the budget does not count tokens (a USD-only spend cap, such
710
+ * as an AI gateway's) — never a fabricated `0`.
711
+ */
712
+ usedTokens?: number;
696
713
  /** Absent → no token ceiling on this window. */
697
714
  limitTokens?: number;
698
715
  usedUsd: number;
@@ -700,6 +717,11 @@ interface QuotaWindow {
700
717
  limitUsd?: number;
701
718
  /** ISO-8601 instant the window starts over (next UTC midnight, first of next month). */
702
719
  resetsAt?: string;
720
+ /**
721
+ * The soft limit: the share of a ceiling (`0..1`, e.g. `0.8`) past which a client should warn
722
+ * that the budget is running out. Absent → no warning for this window.
723
+ */
724
+ warnAt?: number;
703
725
  }
704
726
  /** Which window stopped the actor, when one did. */
705
727
  interface QuotaBlock {
@@ -707,11 +729,24 @@ interface QuotaBlock {
707
729
  /** Words a client can show ("Monthly AI budget reached"). */
708
730
  reason?: string;
709
731
  }
732
+ /** A window past its soft limit ({@link QuotaWindow.warnAt}) but not exhausted. */
733
+ interface QuotaWarning {
734
+ period: QuotaPeriod;
735
+ /** How much of the window's ceiling is used, `0..1` (the larger of spend and tokens). */
736
+ ratio: number;
737
+ /** Words a client can show ("80% of your monthly AI budget used"). */
738
+ reason?: string;
739
+ }
710
740
  /** What `GET <base>/quota` answers. */
711
741
  interface QuotaReport {
712
742
  windows: QuotaWindow[];
713
743
  /** Present when a window is exhausted — a send will be refused until it resets. */
714
744
  blocked?: QuotaBlock;
745
+ /**
746
+ * Present when a window crossed its `warnAt` and none is exhausted — the fullest one. A client
747
+ * may also derive it from the windows ({@link quotaWarning}); the server's wins.
748
+ */
749
+ warning?: QuotaWarning;
715
750
  }
716
751
  interface QuotaQuery {
717
752
  actor: Actor;
@@ -731,6 +766,13 @@ interface QuotaProvider {
731
766
  }
732
767
  /** The first window whose token or spend ceiling is reached, as a {@link QuotaBlock}. */
733
768
  declare function exhaustedWindow(windows: readonly QuotaWindow[]): QuotaBlock | undefined;
769
+ /** How much of `window`'s ceilings is used, `0..1+` (the larger of spend and tokens), or `null`. */
770
+ declare function quotaUsedRatio(window: QuotaWindow): number | null;
771
+ /**
772
+ * The fullest window past its `warnAt`, as a {@link QuotaWarning} — `undefined` when none is, or
773
+ * when one is exhausted (that is `blocked`, not a warning).
774
+ */
775
+ declare function quotaWarning(windows: readonly QuotaWindow[]): QuotaWarning | undefined;
734
776
  /** The UTC day range (`YYYY-MM-DD`, inclusive) and reset instant of `period` around `now`. */
735
777
  declare function quotaPeriodRange(period: QuotaPeriod, now: Date): {
736
778
  fromDay: string;
@@ -3702,4 +3744,4 @@ declare class InMemoryAgentStore implements AgentStore {
3702
3744
  private toSummary;
3703
3745
  }
3704
3746
 
3705
- 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_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 AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalDecisionRef, type ApprovalPolicy, type ApprovalRequirement, type ApprovalThreadRef, type ApprovalToolRef, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, 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, DefaultApprovalPolicy, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, 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, 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 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, type QuotaBlock, QuotaExceededError, type QuotaPeriod, type QuotaProvider, type QuotaQuery, type QuotaReport, QuotaState, type QuotaStore, type QuotaWindow, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, REQUESTER_APPROVER, 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, ToolCallApproval, type ToolCallApprovalColumns, type ToolCallApprovalState, 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, 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, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, exhaustedWindow, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, gateFollowUps, gateTail, 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, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticModelCatalog, staticSkillProvider, summarizeWithModel, tenantScope, toolCallApprovalFromRow, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, windowHistory, withAskTool, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
3747
+ 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_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 AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalDecisionRef, type ApprovalPolicy, type ApprovalRequirement, type ApprovalThreadRef, type ApprovalToolRef, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, 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, DefaultApprovalPolicy, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, 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, 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, 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, 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, ToolCallApproval, type ToolCallApprovalColumns, type ToolCallApprovalState, 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, 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, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, exhaustedWindow, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, gateFollowUps, gateTail, 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, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticModelCatalog, staticSkillProvider, summarizeWithModel, tenantScope, toolCallApprovalFromRow, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, windowHistory, withAskTool, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
package/dist/index.js CHANGED
@@ -289,10 +289,13 @@ function mergeUi(...lists) {
289
289
  }
290
290
  __name(mergeUi, "mergeUi");
291
291
 
292
+ // src/tool-presentation.ts
293
+ var ALL_AGENTS = "*";
294
+
292
295
  // src/spi/quota-provider.ts
293
296
  function exhaustedWindow(windows) {
294
297
  for (const window of windows) {
295
- const tokensOut = window.limitTokens !== void 0 && window.usedTokens >= window.limitTokens;
298
+ const tokensOut = window.limitTokens !== void 0 && (window.usedTokens ?? 0) >= window.limitTokens;
296
299
  const spendOut = window.limitUsd !== void 0 && window.usedUsd >= window.limitUsd;
297
300
  if (tokensOut || spendOut) {
298
301
  return {
@@ -304,6 +307,34 @@ function exhaustedWindow(windows) {
304
307
  return void 0;
305
308
  }
306
309
  __name(exhaustedWindow, "exhaustedWindow");
310
+ function quotaUsedRatio(window) {
311
+ const ratios = [];
312
+ if (window.limitUsd !== void 0 && window.limitUsd > 0) {
313
+ ratios.push(window.usedUsd / window.limitUsd);
314
+ }
315
+ if (window.limitTokens !== void 0 && window.limitTokens > 0 && window.usedTokens !== void 0) {
316
+ ratios.push(window.usedTokens / window.limitTokens);
317
+ }
318
+ return ratios.length === 0 ? null : Math.max(...ratios);
319
+ }
320
+ __name(quotaUsedRatio, "quotaUsedRatio");
321
+ function quotaWarning(windows) {
322
+ if (exhaustedWindow(windows) !== void 0) return void 0;
323
+ let fullest;
324
+ for (const window of windows) {
325
+ if (window.warnAt === void 0) continue;
326
+ const ratio = quotaUsedRatio(window);
327
+ if (ratio === null || ratio < window.warnAt) continue;
328
+ if (fullest === void 0 || ratio > fullest.ratio) {
329
+ fullest = {
330
+ period: window.period,
331
+ ratio
332
+ };
333
+ }
334
+ }
335
+ return fullest;
336
+ }
337
+ __name(quotaWarning, "quotaWarning");
307
338
  function quotaPeriodRange(period, now) {
308
339
  const year = now.getUTCFullYear();
309
340
  const month = now.getUTCMonth();
@@ -1240,6 +1271,7 @@ function normalizeElicitationReply(reply) {
1240
1271
  return reply;
1241
1272
  }
1242
1273
  const answeredByRef = candidate.answeredByRef ?? candidate.executedByRef;
1274
+ const answeredVia = candidate.answeredVia ?? candidate.decidedVia;
1243
1275
  return {
1244
1276
  answers: {},
1245
1277
  ...candidate.approved === false || candidate.skipped === true ? {
@@ -1247,6 +1279,9 @@ function normalizeElicitationReply(reply) {
1247
1279
  } : {},
1248
1280
  ...answeredByRef !== void 0 ? {
1249
1281
  answeredByRef
1282
+ } : {},
1283
+ ...answeredVia !== void 0 ? {
1284
+ answeredVia
1250
1285
  } : {}
1251
1286
  };
1252
1287
  }
@@ -1270,7 +1305,13 @@ function resolveElicitation(request, raw) {
1270
1305
  return {
1271
1306
  answers,
1272
1307
  skipped: reply.skipped === true,
1273
- defaulted
1308
+ defaulted,
1309
+ ...reply.answeredByRef !== void 0 ? {
1310
+ answeredBy: reply.answeredByRef
1311
+ } : {},
1312
+ ...reply.answeredVia !== void 0 ? {
1313
+ answeredVia: reply.answeredVia
1314
+ } : {}
1274
1315
  };
1275
1316
  }
1276
1317
  __name(resolveElicitation, "resolveElicitation");
@@ -5338,6 +5379,7 @@ export {
5338
5379
  AGENT_SPAN_EVENTS,
5339
5380
  AGENT_STORE,
5340
5381
  AGENT_TOOL_REGISTRY,
5382
+ ALL_AGENTS,
5341
5383
  APPROVAL_EXPIRED_REASON,
5342
5384
  ASK_TOOL_DESCRIPTION,
5343
5385
  ASK_TOOL_NAME,
@@ -5441,6 +5483,8 @@ export {
5441
5483
  publishAgentToolRetry,
5442
5484
  questionOptions,
5443
5485
  quotaPeriodRange,
5486
+ quotaUsedRatio,
5487
+ quotaWarning,
5444
5488
  readElicitationInput,
5445
5489
  readElicitationQuestions,
5446
5490
  releaseGatedFrames,