@dudousxd/nestjs-agent-core 0.29.0 → 0.30.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-CfnSyIQf.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-CfnSyIQf.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-DdwZ0NFG.cjs';
5
+ export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-DdwZ0NFG.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-CfnSyIQf.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-CfnSyIQf.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-8c9g9J6R.js';
5
+ export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-8c9g9J6R.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
@@ -292,7 +292,7 @@ __name(mergeUi, "mergeUi");
292
292
  // src/spi/quota-provider.ts
293
293
  function exhaustedWindow(windows) {
294
294
  for (const window of windows) {
295
- const tokensOut = window.limitTokens !== void 0 && window.usedTokens >= window.limitTokens;
295
+ const tokensOut = window.limitTokens !== void 0 && (window.usedTokens ?? 0) >= window.limitTokens;
296
296
  const spendOut = window.limitUsd !== void 0 && window.usedUsd >= window.limitUsd;
297
297
  if (tokensOut || spendOut) {
298
298
  return {
@@ -304,6 +304,34 @@ function exhaustedWindow(windows) {
304
304
  return void 0;
305
305
  }
306
306
  __name(exhaustedWindow, "exhaustedWindow");
307
+ function quotaUsedRatio(window) {
308
+ const ratios = [];
309
+ if (window.limitUsd !== void 0 && window.limitUsd > 0) {
310
+ ratios.push(window.usedUsd / window.limitUsd);
311
+ }
312
+ if (window.limitTokens !== void 0 && window.limitTokens > 0 && window.usedTokens !== void 0) {
313
+ ratios.push(window.usedTokens / window.limitTokens);
314
+ }
315
+ return ratios.length === 0 ? null : Math.max(...ratios);
316
+ }
317
+ __name(quotaUsedRatio, "quotaUsedRatio");
318
+ function quotaWarning(windows) {
319
+ if (exhaustedWindow(windows) !== void 0) return void 0;
320
+ let fullest;
321
+ for (const window of windows) {
322
+ if (window.warnAt === void 0) continue;
323
+ const ratio = quotaUsedRatio(window);
324
+ if (ratio === null || ratio < window.warnAt) continue;
325
+ if (fullest === void 0 || ratio > fullest.ratio) {
326
+ fullest = {
327
+ period: window.period,
328
+ ratio
329
+ };
330
+ }
331
+ }
332
+ return fullest;
333
+ }
334
+ __name(quotaWarning, "quotaWarning");
307
335
  function quotaPeriodRange(period, now) {
308
336
  const year = now.getUTCFullYear();
309
337
  const month = now.getUTCMonth();
@@ -1240,6 +1268,7 @@ function normalizeElicitationReply(reply) {
1240
1268
  return reply;
1241
1269
  }
1242
1270
  const answeredByRef = candidate.answeredByRef ?? candidate.executedByRef;
1271
+ const answeredVia = candidate.answeredVia ?? candidate.decidedVia;
1243
1272
  return {
1244
1273
  answers: {},
1245
1274
  ...candidate.approved === false || candidate.skipped === true ? {
@@ -1247,6 +1276,9 @@ function normalizeElicitationReply(reply) {
1247
1276
  } : {},
1248
1277
  ...answeredByRef !== void 0 ? {
1249
1278
  answeredByRef
1279
+ } : {},
1280
+ ...answeredVia !== void 0 ? {
1281
+ answeredVia
1250
1282
  } : {}
1251
1283
  };
1252
1284
  }
@@ -1270,7 +1302,13 @@ function resolveElicitation(request, raw) {
1270
1302
  return {
1271
1303
  answers,
1272
1304
  skipped: reply.skipped === true,
1273
- defaulted
1305
+ defaulted,
1306
+ ...reply.answeredByRef !== void 0 ? {
1307
+ answeredBy: reply.answeredByRef
1308
+ } : {},
1309
+ ...reply.answeredVia !== void 0 ? {
1310
+ answeredVia: reply.answeredVia
1311
+ } : {}
1274
1312
  };
1275
1313
  }
1276
1314
  __name(resolveElicitation, "resolveElicitation");
@@ -5441,6 +5479,8 @@ export {
5441
5479
  publishAgentToolRetry,
5442
5480
  questionOptions,
5443
5481
  quotaPeriodRange,
5482
+ quotaUsedRatio,
5483
+ quotaWarning,
5444
5484
  readElicitationInput,
5445
5485
  readElicitationQuestions,
5446
5486
  releaseGatedFrames,