@dudousxd/nestjs-agent-core 0.22.0 → 0.24.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/guardrails/index.d.cts +1 -1
- package/dist/guardrails/index.d.ts +1 -1
- package/dist/index.cjs +43 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -4
- package/dist/index.d.ts +81 -4
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/dist/{tool-BQqFt06V.d.cts → tool-fLRLs_f3.d.cts} +29 -1
- package/dist/{tool-BQqFt06V.d.ts → tool-fLRLs_f3.d.ts} +29 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent,
|
|
2
|
-
export {
|
|
1
|
+
import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as AiToolCtx, f as AgentStreamEvent, g as ThreadSummary, h as ThreadDetail, S as StoredMessage, i as ToolResult, j as MessageAttachment, k as MessageFeedback, l as ToolCallStatus, U as UsagePurpose, m as ToolSpec, Q as QuotaState, n as AgentRunInput, H as HumanReply, o as ToolKind, p as ToolCallApproval, T as ToolHandler, q as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, r as ProcessedPrompt, s as ModelAnswer, t as PageContext, u as AgentDefinition, v as AgentDelegation, D as DetachedDelivery, w as PromptBuilder, x as PromptContributor, y as ToolTransientRetrySetting, z as AgentIntake, B as Decision, E as ElicitationRequest, L as LlmStepEnvelope, C as ToolStepEnvelope } from './tool-fLRLs_f3.cjs';
|
|
2
|
+
export { F as ASK_TOOL_DESCRIPTION, G as ASK_TOOL_NAME, J as AgentApprovalRequest, K as AgentApprovalSettlement, N as AgentCatalogEntry, R as AgentHistoryWindow, V as AskToolInput, W as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, X as DEFAULT_INTAKE_PREAMBLE, Y as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, Z as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, _ as ELICITATION_INPUT_TYPES, $ as ElicitationInput, a0 as ElicitationInputType, a1 as ElicitationOption, a2 as ElicitationOutcome, a3 as ElicitationQuestion, a4 as ElicitationReply, a5 as ElicitationResult, a6 as HistoryPolicyContext, a7 as HistorySelection, a8 as HistorySummary, a9 as IncrementalGating, aa as InvokeWithTransientRetryOptions, ab as MAX_ASK_QUESTIONS, ac as MessageFeedbackValue, ad as MessageRole, ae as OutputRejectedError, af as OutputVerdict, ag as ProcessorFailedError, ah as PromptContext, ai as QuotaView, aj as ToolCallApprovalStatus, ak as ToolCatalogEntry, al as ToolConfirmation, am as ToolPresentation, an as ToolPresentationTone, ao as ToolResultField, ap as ToolResultView, aq as ToolStepCtx, ar as ToolTransientRetryNumbers, as as ToolTransientRetryOptions, at as askInputSchema, au as askToolDefinition, av as decodeStreamEvent, aw as encodeStreamEvent, ax as invokeWithTransientRetry, ay as isTransientToolError, az as isTypedQuestion, aA as normalizeElicitationReply, aB as questionOptions, aC as readElicitationInput, aD as readElicitationQuestions, aE as renderElicitationAnswers, aF as resolveElicitation, aG as resolveToolTransientRetryNumbers, aH as settleElicitation, aI as validateElicitationAnswer, aJ as validateElicitationValue } from './tool-fLRLs_f3.cjs';
|
|
3
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
4
|
import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
|
|
5
5
|
|
|
@@ -32,6 +32,8 @@ declare const AGENT_REGISTRY: unique symbol;
|
|
|
32
32
|
declare const AGENT_ACTOR_RESOLVER: unique symbol;
|
|
33
33
|
/** The governance read-model (usage/spend/threads), consumed by the dashboard + telescope surfaces. */
|
|
34
34
|
declare const AGENT_GOVERNANCE_QUERIES: unique symbol;
|
|
35
|
+
/** The `ModelCatalog` behind `GET <base>/models` and the model a send may name. Optional. */
|
|
36
|
+
declare const AGENT_MODEL_CATALOG: unique symbol;
|
|
35
37
|
/** The pricing WRITE side (`AgentPricingStore`) — seeds/updates the per-model rates cost is priced against. */
|
|
36
38
|
declare const AGENT_PRICING_STORE: unique symbol;
|
|
37
39
|
/** The RAG retrieval seam (`Retriever`) — vector/keyword search behind the agentic tool or inject mode. */
|
|
@@ -134,6 +136,12 @@ interface ModelTurnArgs {
|
|
|
134
136
|
* the reply against the same schema either way, so ignoring it costs reliability, not safety.
|
|
135
137
|
*/
|
|
136
138
|
outputSchema?: StandardSchemaV1;
|
|
139
|
+
/**
|
|
140
|
+
* The model the caller picked for this turn — a {@link import('./model-catalog.js').ModelCatalogEntry}
|
|
141
|
+
* id the server already checked against the catalog (a per-send `model`, else the thread's pinned
|
|
142
|
+
* one). Absent → the provider's own default. A provider serving a single model may ignore it.
|
|
143
|
+
*/
|
|
144
|
+
model?: string;
|
|
137
145
|
}
|
|
138
146
|
/** The outcome of ONE assistant turn. The loop — not the model — drives tool execution. */
|
|
139
147
|
interface ModelTurnResult {
|
|
@@ -211,6 +219,61 @@ interface ModelProvider {
|
|
|
211
219
|
runTurn(args: ModelTurnArgs): Promise<ModelTurnResult>;
|
|
212
220
|
}
|
|
213
221
|
|
|
222
|
+
/** One model a caller may pick. */
|
|
223
|
+
interface ModelCatalogEntry {
|
|
224
|
+
/** What a client sends as `model` — and what the {@link ModelProvider} receives as `args.model`. */
|
|
225
|
+
id: string;
|
|
226
|
+
label: string;
|
|
227
|
+
description?: string;
|
|
228
|
+
/** Short tags a picker can render as chips — `'fast'`, `'reasoning'`, `'vision'`, `'new'`, … */
|
|
229
|
+
badges?: string[];
|
|
230
|
+
/** `false` → listed but not selectable right now (plan, quota, outage); a send naming it is refused. */
|
|
231
|
+
available: boolean;
|
|
232
|
+
/** Why it is unavailable, in words a picker can show. */
|
|
233
|
+
unavailableReason?: string;
|
|
234
|
+
/** Context window, in tokens, when the host knows it. */
|
|
235
|
+
contextWindow?: number;
|
|
236
|
+
}
|
|
237
|
+
/** Models grouped under the provider that serves them. */
|
|
238
|
+
interface ModelCatalogProviderGroup {
|
|
239
|
+
id: string;
|
|
240
|
+
label: string;
|
|
241
|
+
models: ModelCatalogEntry[];
|
|
242
|
+
}
|
|
243
|
+
/** What `GET <base>/models` answers. */
|
|
244
|
+
interface ModelCatalogView {
|
|
245
|
+
providers: ModelCatalogProviderGroup[];
|
|
246
|
+
/** The model a turn runs on when nobody picked one; `null` when the provider decides. */
|
|
247
|
+
default: string | null;
|
|
248
|
+
}
|
|
249
|
+
interface ModelCatalogQuery {
|
|
250
|
+
actor: Actor;
|
|
251
|
+
/** The agent the picker is for; omitted → the default agent. */
|
|
252
|
+
agent?: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Which models a caller may run a turn on — the picker's data and the send's gate. The server
|
|
256
|
+
* refuses a `model` (on a send, or pinned on a thread) that this does not list as `available` for
|
|
257
|
+
* the actor and agent, so a client cannot pick a model the host did not offer it.
|
|
258
|
+
*
|
|
259
|
+
* Bind with `AgentModule.forRoot({ models })`. Without one, `GET <base>/models` answers an empty
|
|
260
|
+
* catalog and a request naming a model is refused.
|
|
261
|
+
*/
|
|
262
|
+
interface ModelCatalog {
|
|
263
|
+
list(query: ModelCatalogQuery): ModelCatalogView | Promise<ModelCatalogView>;
|
|
264
|
+
}
|
|
265
|
+
/** A catalog that answers the same view to everyone — for a fixed list of models. */
|
|
266
|
+
declare function staticModelCatalog(view: ModelCatalogView): ModelCatalog;
|
|
267
|
+
/** The entry `id` names in `view`, or `undefined`. */
|
|
268
|
+
declare function findCatalogModel(view: ModelCatalogView, id: string): ModelCatalogEntry | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* A provider that runs every turn on `model` — what the loop wraps the bound provider in when a
|
|
271
|
+
* turn has a selected model, so every call it makes (the answer, a structured-output pass, the
|
|
272
|
+
* follow-up suggestions) goes to the same one. A provider that does not read `args.model` runs its
|
|
273
|
+
* own default, unchanged.
|
|
274
|
+
*/
|
|
275
|
+
declare function withSelectedModel(provider: ModelProvider, model: string): ModelProvider;
|
|
276
|
+
|
|
214
277
|
/** What a model turn streamed that the persisted message keeps, beyond its text and tool calls. */
|
|
215
278
|
interface TurnFrameSummary {
|
|
216
279
|
reasoning?: string;
|
|
@@ -344,6 +407,8 @@ interface UpdateThreadInput {
|
|
|
344
407
|
title?: string;
|
|
345
408
|
/** `null` clears the thread's default agent (falls back to the module default). */
|
|
346
409
|
defaultAgent?: string | null;
|
|
410
|
+
/** `null` unpins the thread's model (turns run on the provider default). */
|
|
411
|
+
model?: string | null;
|
|
347
412
|
}
|
|
348
413
|
interface RecordUsageInput {
|
|
349
414
|
threadId: string;
|
|
@@ -512,6 +577,18 @@ interface AgentStore {
|
|
|
512
577
|
*/
|
|
513
578
|
setMessageUi?(messageId: string, ui: AgentUiComponent[]): Promise<void>;
|
|
514
579
|
truncateFrom(threadId: string, messageId: string): Promise<void>;
|
|
580
|
+
/**
|
|
581
|
+
* OPTIONAL: the thread a message belongs to, or `null` when there is no such message. The
|
|
582
|
+
* authorization seam for message-scoped routes (feedback): the service resolves the thread's owner
|
|
583
|
+
* from it. Implement it together with {@link setMessageFeedback}.
|
|
584
|
+
*/
|
|
585
|
+
threadOfMessage?(messageId: string): Promise<string | null>;
|
|
586
|
+
/**
|
|
587
|
+
* OPTIONAL: set (or, with `null`, clear) the rating on a message — see
|
|
588
|
+
* {@link import('../types.js').StoredMessage.feedback}. Absent → `POST /messages/:id/feedback`
|
|
589
|
+
* answers `501`.
|
|
590
|
+
*/
|
|
591
|
+
setMessageFeedback?(messageId: string, feedback: MessageFeedback | null): Promise<void>;
|
|
515
592
|
recordToolCall(input: RecordToolCallInput): Promise<void>;
|
|
516
593
|
updateToolCall(input: UpdateToolCallInput): Promise<void>;
|
|
517
594
|
/**
|
|
@@ -3097,7 +3174,7 @@ interface AgentLoopResult<TOutput = unknown> {
|
|
|
3097
3174
|
* It drives the model→tools→model iteration; the runner supplies the `step`/`awaitApproval`
|
|
3098
3175
|
* hooks that make the same loop body either in-process or a replay-safe durable workflow.
|
|
3099
3176
|
*/
|
|
3100
|
-
declare function runAgentLoop<TOutput = unknown>(
|
|
3177
|
+
declare function runAgentLoop<TOutput = unknown>(boundDeps: AgentLoopDeps<TOutput>, input: AgentRunInput, hooks: AgentLoopHooks): Promise<AgentLoopResult<TOutput>>;
|
|
3101
3178
|
|
|
3102
3179
|
/** Payloads carried on each `aviary:agent:*` channel. */
|
|
3103
3180
|
interface AgentRunStarted {
|
|
@@ -3331,4 +3408,4 @@ type AgentDiagnosticKey = `agent:${AgentDiagnosticEvent}`;
|
|
|
3331
3408
|
*/
|
|
3332
3409
|
declare function agentDiagnosticKey(event: AgentDiagnosticEvent): AgentDiagnosticKey;
|
|
3333
3410
|
|
|
3334
|
-
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, 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 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 GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageUsage, ModelAnswer, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QuotaExceededError, QuotaState, type QuotaStore, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, 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, 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, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, 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, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticSkillProvider, summarizeWithModel, tenantScope, toolCallApprovalFromRow, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, windowHistory, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
|
|
3411
|
+
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_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 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 GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, 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, QuotaExceededError, QuotaState, type QuotaStore, 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, 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, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, 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, 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,5 +1,5 @@
|
|
|
1
|
-
import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent,
|
|
2
|
-
export {
|
|
1
|
+
import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as AiToolCtx, f as AgentStreamEvent, g as ThreadSummary, h as ThreadDetail, S as StoredMessage, i as ToolResult, j as MessageAttachment, k as MessageFeedback, l as ToolCallStatus, U as UsagePurpose, m as ToolSpec, Q as QuotaState, n as AgentRunInput, H as HumanReply, o as ToolKind, p as ToolCallApproval, T as ToolHandler, q as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, r as ProcessedPrompt, s as ModelAnswer, t as PageContext, u as AgentDefinition, v as AgentDelegation, D as DetachedDelivery, w as PromptBuilder, x as PromptContributor, y as ToolTransientRetrySetting, z as AgentIntake, B as Decision, E as ElicitationRequest, L as LlmStepEnvelope, C as ToolStepEnvelope } from './tool-fLRLs_f3.js';
|
|
2
|
+
export { F as ASK_TOOL_DESCRIPTION, G as ASK_TOOL_NAME, J as AgentApprovalRequest, K as AgentApprovalSettlement, N as AgentCatalogEntry, R as AgentHistoryWindow, V as AskToolInput, W as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, X as DEFAULT_INTAKE_PREAMBLE, Y as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, Z as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, _ as ELICITATION_INPUT_TYPES, $ as ElicitationInput, a0 as ElicitationInputType, a1 as ElicitationOption, a2 as ElicitationOutcome, a3 as ElicitationQuestion, a4 as ElicitationReply, a5 as ElicitationResult, a6 as HistoryPolicyContext, a7 as HistorySelection, a8 as HistorySummary, a9 as IncrementalGating, aa as InvokeWithTransientRetryOptions, ab as MAX_ASK_QUESTIONS, ac as MessageFeedbackValue, ad as MessageRole, ae as OutputRejectedError, af as OutputVerdict, ag as ProcessorFailedError, ah as PromptContext, ai as QuotaView, aj as ToolCallApprovalStatus, ak as ToolCatalogEntry, al as ToolConfirmation, am as ToolPresentation, an as ToolPresentationTone, ao as ToolResultField, ap as ToolResultView, aq as ToolStepCtx, ar as ToolTransientRetryNumbers, as as ToolTransientRetryOptions, at as askInputSchema, au as askToolDefinition, av as decodeStreamEvent, aw as encodeStreamEvent, ax as invokeWithTransientRetry, ay as isTransientToolError, az as isTypedQuestion, aA as normalizeElicitationReply, aB as questionOptions, aC as readElicitationInput, aD as readElicitationQuestions, aE as renderElicitationAnswers, aF as resolveElicitation, aG as resolveToolTransientRetryNumbers, aH as settleElicitation, aI as validateElicitationAnswer, aJ as validateElicitationValue } from './tool-fLRLs_f3.js';
|
|
3
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
4
|
import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
|
|
5
5
|
|
|
@@ -32,6 +32,8 @@ declare const AGENT_REGISTRY: unique symbol;
|
|
|
32
32
|
declare const AGENT_ACTOR_RESOLVER: unique symbol;
|
|
33
33
|
/** The governance read-model (usage/spend/threads), consumed by the dashboard + telescope surfaces. */
|
|
34
34
|
declare const AGENT_GOVERNANCE_QUERIES: unique symbol;
|
|
35
|
+
/** The `ModelCatalog` behind `GET <base>/models` and the model a send may name. Optional. */
|
|
36
|
+
declare const AGENT_MODEL_CATALOG: unique symbol;
|
|
35
37
|
/** The pricing WRITE side (`AgentPricingStore`) — seeds/updates the per-model rates cost is priced against. */
|
|
36
38
|
declare const AGENT_PRICING_STORE: unique symbol;
|
|
37
39
|
/** The RAG retrieval seam (`Retriever`) — vector/keyword search behind the agentic tool or inject mode. */
|
|
@@ -134,6 +136,12 @@ interface ModelTurnArgs {
|
|
|
134
136
|
* the reply against the same schema either way, so ignoring it costs reliability, not safety.
|
|
135
137
|
*/
|
|
136
138
|
outputSchema?: StandardSchemaV1;
|
|
139
|
+
/**
|
|
140
|
+
* The model the caller picked for this turn — a {@link import('./model-catalog.js').ModelCatalogEntry}
|
|
141
|
+
* id the server already checked against the catalog (a per-send `model`, else the thread's pinned
|
|
142
|
+
* one). Absent → the provider's own default. A provider serving a single model may ignore it.
|
|
143
|
+
*/
|
|
144
|
+
model?: string;
|
|
137
145
|
}
|
|
138
146
|
/** The outcome of ONE assistant turn. The loop — not the model — drives tool execution. */
|
|
139
147
|
interface ModelTurnResult {
|
|
@@ -211,6 +219,61 @@ interface ModelProvider {
|
|
|
211
219
|
runTurn(args: ModelTurnArgs): Promise<ModelTurnResult>;
|
|
212
220
|
}
|
|
213
221
|
|
|
222
|
+
/** One model a caller may pick. */
|
|
223
|
+
interface ModelCatalogEntry {
|
|
224
|
+
/** What a client sends as `model` — and what the {@link ModelProvider} receives as `args.model`. */
|
|
225
|
+
id: string;
|
|
226
|
+
label: string;
|
|
227
|
+
description?: string;
|
|
228
|
+
/** Short tags a picker can render as chips — `'fast'`, `'reasoning'`, `'vision'`, `'new'`, … */
|
|
229
|
+
badges?: string[];
|
|
230
|
+
/** `false` → listed but not selectable right now (plan, quota, outage); a send naming it is refused. */
|
|
231
|
+
available: boolean;
|
|
232
|
+
/** Why it is unavailable, in words a picker can show. */
|
|
233
|
+
unavailableReason?: string;
|
|
234
|
+
/** Context window, in tokens, when the host knows it. */
|
|
235
|
+
contextWindow?: number;
|
|
236
|
+
}
|
|
237
|
+
/** Models grouped under the provider that serves them. */
|
|
238
|
+
interface ModelCatalogProviderGroup {
|
|
239
|
+
id: string;
|
|
240
|
+
label: string;
|
|
241
|
+
models: ModelCatalogEntry[];
|
|
242
|
+
}
|
|
243
|
+
/** What `GET <base>/models` answers. */
|
|
244
|
+
interface ModelCatalogView {
|
|
245
|
+
providers: ModelCatalogProviderGroup[];
|
|
246
|
+
/** The model a turn runs on when nobody picked one; `null` when the provider decides. */
|
|
247
|
+
default: string | null;
|
|
248
|
+
}
|
|
249
|
+
interface ModelCatalogQuery {
|
|
250
|
+
actor: Actor;
|
|
251
|
+
/** The agent the picker is for; omitted → the default agent. */
|
|
252
|
+
agent?: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Which models a caller may run a turn on — the picker's data and the send's gate. The server
|
|
256
|
+
* refuses a `model` (on a send, or pinned on a thread) that this does not list as `available` for
|
|
257
|
+
* the actor and agent, so a client cannot pick a model the host did not offer it.
|
|
258
|
+
*
|
|
259
|
+
* Bind with `AgentModule.forRoot({ models })`. Without one, `GET <base>/models` answers an empty
|
|
260
|
+
* catalog and a request naming a model is refused.
|
|
261
|
+
*/
|
|
262
|
+
interface ModelCatalog {
|
|
263
|
+
list(query: ModelCatalogQuery): ModelCatalogView | Promise<ModelCatalogView>;
|
|
264
|
+
}
|
|
265
|
+
/** A catalog that answers the same view to everyone — for a fixed list of models. */
|
|
266
|
+
declare function staticModelCatalog(view: ModelCatalogView): ModelCatalog;
|
|
267
|
+
/** The entry `id` names in `view`, or `undefined`. */
|
|
268
|
+
declare function findCatalogModel(view: ModelCatalogView, id: string): ModelCatalogEntry | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* A provider that runs every turn on `model` — what the loop wraps the bound provider in when a
|
|
271
|
+
* turn has a selected model, so every call it makes (the answer, a structured-output pass, the
|
|
272
|
+
* follow-up suggestions) goes to the same one. A provider that does not read `args.model` runs its
|
|
273
|
+
* own default, unchanged.
|
|
274
|
+
*/
|
|
275
|
+
declare function withSelectedModel(provider: ModelProvider, model: string): ModelProvider;
|
|
276
|
+
|
|
214
277
|
/** What a model turn streamed that the persisted message keeps, beyond its text and tool calls. */
|
|
215
278
|
interface TurnFrameSummary {
|
|
216
279
|
reasoning?: string;
|
|
@@ -344,6 +407,8 @@ interface UpdateThreadInput {
|
|
|
344
407
|
title?: string;
|
|
345
408
|
/** `null` clears the thread's default agent (falls back to the module default). */
|
|
346
409
|
defaultAgent?: string | null;
|
|
410
|
+
/** `null` unpins the thread's model (turns run on the provider default). */
|
|
411
|
+
model?: string | null;
|
|
347
412
|
}
|
|
348
413
|
interface RecordUsageInput {
|
|
349
414
|
threadId: string;
|
|
@@ -512,6 +577,18 @@ interface AgentStore {
|
|
|
512
577
|
*/
|
|
513
578
|
setMessageUi?(messageId: string, ui: AgentUiComponent[]): Promise<void>;
|
|
514
579
|
truncateFrom(threadId: string, messageId: string): Promise<void>;
|
|
580
|
+
/**
|
|
581
|
+
* OPTIONAL: the thread a message belongs to, or `null` when there is no such message. The
|
|
582
|
+
* authorization seam for message-scoped routes (feedback): the service resolves the thread's owner
|
|
583
|
+
* from it. Implement it together with {@link setMessageFeedback}.
|
|
584
|
+
*/
|
|
585
|
+
threadOfMessage?(messageId: string): Promise<string | null>;
|
|
586
|
+
/**
|
|
587
|
+
* OPTIONAL: set (or, with `null`, clear) the rating on a message — see
|
|
588
|
+
* {@link import('../types.js').StoredMessage.feedback}. Absent → `POST /messages/:id/feedback`
|
|
589
|
+
* answers `501`.
|
|
590
|
+
*/
|
|
591
|
+
setMessageFeedback?(messageId: string, feedback: MessageFeedback | null): Promise<void>;
|
|
515
592
|
recordToolCall(input: RecordToolCallInput): Promise<void>;
|
|
516
593
|
updateToolCall(input: UpdateToolCallInput): Promise<void>;
|
|
517
594
|
/**
|
|
@@ -3097,7 +3174,7 @@ interface AgentLoopResult<TOutput = unknown> {
|
|
|
3097
3174
|
* It drives the model→tools→model iteration; the runner supplies the `step`/`awaitApproval`
|
|
3098
3175
|
* hooks that make the same loop body either in-process or a replay-safe durable workflow.
|
|
3099
3176
|
*/
|
|
3100
|
-
declare function runAgentLoop<TOutput = unknown>(
|
|
3177
|
+
declare function runAgentLoop<TOutput = unknown>(boundDeps: AgentLoopDeps<TOutput>, input: AgentRunInput, hooks: AgentLoopHooks): Promise<AgentLoopResult<TOutput>>;
|
|
3101
3178
|
|
|
3102
3179
|
/** Payloads carried on each `aviary:agent:*` channel. */
|
|
3103
3180
|
interface AgentRunStarted {
|
|
@@ -3331,4 +3408,4 @@ type AgentDiagnosticKey = `agent:${AgentDiagnosticEvent}`;
|
|
|
3331
3408
|
*/
|
|
3332
3409
|
declare function agentDiagnosticKey(event: AgentDiagnosticEvent): AgentDiagnosticKey;
|
|
3333
3410
|
|
|
3334
|
-
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, 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 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 GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageUsage, ModelAnswer, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QuotaExceededError, QuotaState, type QuotaStore, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, 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, 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, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, 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, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticSkillProvider, summarizeWithModel, tenantScope, toolCallApprovalFromRow, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, windowHistory, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
|
|
3411
|
+
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_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 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 GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, 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, QuotaExceededError, QuotaState, type QuotaStore, 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, 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, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, 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, 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
|
@@ -14,6 +14,7 @@ var AGENT_TOOL_REGISTRY = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:too
|
|
|
14
14
|
var AGENT_REGISTRY = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:agent-registry");
|
|
15
15
|
var AGENT_ACTOR_RESOLVER = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:actor-resolver");
|
|
16
16
|
var AGENT_GOVERNANCE_QUERIES = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:governance-queries");
|
|
17
|
+
var AGENT_MODEL_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:model-catalog");
|
|
17
18
|
var AGENT_PRICING_STORE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:pricing-store");
|
|
18
19
|
var AGENT_RETRIEVER = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:retriever");
|
|
19
20
|
var AGENT_EMBEDDING_PROVIDER = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:embedding-provider");
|
|
@@ -26,6 +27,31 @@ var AGENT_SKILLS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skills");
|
|
|
26
27
|
var AGENT_MEMORY = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:memory");
|
|
27
28
|
var AGENT_SKILL_SOURCES = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-sources");
|
|
28
29
|
|
|
30
|
+
// src/spi/model-catalog.ts
|
|
31
|
+
function staticModelCatalog(view) {
|
|
32
|
+
return {
|
|
33
|
+
list: /* @__PURE__ */ __name(() => view, "list")
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
__name(staticModelCatalog, "staticModelCatalog");
|
|
37
|
+
function findCatalogModel(view, id) {
|
|
38
|
+
for (const group of view.providers) {
|
|
39
|
+
const found = group.models.find((model) => model.id === id);
|
|
40
|
+
if (found !== void 0) return found;
|
|
41
|
+
}
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
__name(findCatalogModel, "findCatalogModel");
|
|
45
|
+
function withSelectedModel(provider, model) {
|
|
46
|
+
return {
|
|
47
|
+
runTurn: /* @__PURE__ */ __name((args) => provider.runTurn({
|
|
48
|
+
...args,
|
|
49
|
+
model
|
|
50
|
+
}), "runTurn")
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
__name(withSelectedModel, "withSelectedModel");
|
|
54
|
+
|
|
29
55
|
// src/spi/token-stream-sink.ts
|
|
30
56
|
var AgentStreamError = class extends Error {
|
|
31
57
|
static {
|
|
@@ -3922,7 +3948,12 @@ async function invokeClaimedToolsTogether(turn, parallel, claimed) {
|
|
|
3922
3948
|
return results;
|
|
3923
3949
|
}
|
|
3924
3950
|
__name(invokeClaimedToolsTogether, "invokeClaimedToolsTogether");
|
|
3925
|
-
async function runAgentLoop(
|
|
3951
|
+
async function runAgentLoop(boundDeps, input, hooks) {
|
|
3952
|
+
const deps = input.model === void 0 ? boundDeps : {
|
|
3953
|
+
...boundDeps,
|
|
3954
|
+
model: withSelectedModel(boundDeps.model, input.model),
|
|
3955
|
+
modelId: input.model
|
|
3956
|
+
};
|
|
3926
3957
|
const maxSteps = deps.maxSteps ?? 8;
|
|
3927
3958
|
let system = await resolveSystemPrompt(deps, input);
|
|
3928
3959
|
const inputProcessors = deps.inputProcessors ?? [];
|
|
@@ -4119,6 +4150,9 @@ ${block}`;
|
|
|
4119
4150
|
actor: input.actor,
|
|
4120
4151
|
...gated ? {
|
|
4121
4152
|
bufferOutput: true
|
|
4153
|
+
} : {},
|
|
4154
|
+
...input.model !== void 0 ? {
|
|
4155
|
+
model: input.model
|
|
4122
4156
|
} : {}
|
|
4123
4157
|
});
|
|
4124
4158
|
} else {
|
|
@@ -4537,6 +4571,7 @@ export {
|
|
|
4537
4571
|
AGENT_GOVERNANCE_QUERIES,
|
|
4538
4572
|
AGENT_MEMORY,
|
|
4539
4573
|
AGENT_MODEL,
|
|
4574
|
+
AGENT_MODEL_CATALOG,
|
|
4540
4575
|
AGENT_OPTIONS,
|
|
4541
4576
|
AGENT_PRICING_STORE,
|
|
4542
4577
|
AGENT_PROMPT_CONTRIBUTORS,
|
|
@@ -4618,6 +4653,7 @@ export {
|
|
|
4618
4653
|
filterToolsByCanUse,
|
|
4619
4654
|
filterToolsByEnabled,
|
|
4620
4655
|
filterToolsByRole,
|
|
4656
|
+
findCatalogModel,
|
|
4621
4657
|
gateFollowUps,
|
|
4622
4658
|
gateTail,
|
|
4623
4659
|
invokeWithTransientRetry,
|
|
@@ -4674,6 +4710,7 @@ export {
|
|
|
4674
4710
|
skillToolDefinition,
|
|
4675
4711
|
skillWriteVerdict,
|
|
4676
4712
|
stampToolKinds,
|
|
4713
|
+
staticModelCatalog,
|
|
4677
4714
|
staticSkillProvider,
|
|
4678
4715
|
summarizeWithModel,
|
|
4679
4716
|
tenantScope,
|
|
@@ -4688,6 +4725,7 @@ export {
|
|
|
4688
4725
|
windowHistory,
|
|
4689
4726
|
withAskTool,
|
|
4690
4727
|
withMemoryTool,
|
|
4728
|
+
withSelectedModel,
|
|
4691
4729
|
withSkillTool,
|
|
4692
4730
|
withToolTimeout,
|
|
4693
4731
|
withTurnFrames,
|