@dudousxd/nestjs-agent-core 0.38.0 → 0.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,10 +1,10 @@
1
- import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, a as Actor, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, g as AgentRunInput, H as HumanReply, h as MessageAttachment, i as ToolKind, j as ToolCallStatus, k as ToolCallApproval, l as HistoryPolicy, P as PageContext, m as AgentDefinition, n as AgentStore, o as AgentDelegation, D as DetachedDelivery, p as PromptBuilder, q as PromptContributor, r as ToolTransientRetrySetting, s as AgentIntake, t as Decision, E as ElicitationRequest, L as LlmStepEnvelope, u as ToolStepEnvelope, C as ChatQueueStore, v as CreateThreadInput, w as ThreadSummary, x as ThreadDetail, y as ToolCallApprovalState, U as UpdateThreadInput, R as RecordRunStartInput, z as EnqueueMessageInput, B as QueuedMessage, F as QueuedMessagePatch, G as QueuePause, I as AppendMessageInput, S as StoredMessage, J as ToolResult, K as MessageFeedback, N as RecordToolCallInput, O as ToolCallOutcome, V as UpdateToolCallInput, W as RecordUsageInput } from './stream-events-CgWqAI-1.cjs';
2
- export { X as ALL_AGENTS, Y as ASK_TOOL_DESCRIPTION, Z as ASK_TOOL_NAME, _ as AgentApprovalRequest, $ as AgentApprovalSettlement, a0 as AgentAttachmentConfig, a1 as AgentCatalogEntry, a2 as AgentClientConfig, a3 as AgentHistoryWindow, a4 as AgentStreamErrorCode, a5 as AskToolInput, a6 as ChatQueueState, a7 as DEFAULT_INTAKE_PREAMBLE, a8 as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, a9 as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aa as ELICITATION_INPUT_TYPES, ab as ElicitationInput, ac as ElicitationInputType, ad as ElicitationOption, ae as ElicitationOutcome, af as ElicitationQuestion, ag as ElicitationReply, ah as ElicitationResult, ai as HistoryPolicyContext, aj as HistorySelection, ak as HistorySummary, al as InvokeWithTransientRetryOptions, am as MAX_ASK_QUESTIONS, an as MessageFeedbackValue, ao as MessageRole, ap as PromptContext, aq as QueuePauseReason, ar as QueuedMessageView, as as QuotaView, at as RUN_ENDED_BEFORE_TOOL_CALL, au as RecordRunEndInput, av as ThreadTurnPage, aw as ThreadTurnQuery, ax as ThreadTurnReader, ay as ToolCallApprovalStatus, az as ToolCatalogEntry, aA as ToolConfirmation, b as ToolPresentation, aB as ToolPresentationTone, aC as ToolResultField, aD as ToolResultView, aE as ToolStepCtx, aF as ToolTransientRetryNumbers, aG as ToolTransientRetryOptions, aH as UNFINISHED_TOOL_CALL, aI as UsagePurpose, aJ as askInputSchema, aK as askToolDefinition, aL as danglingToolCallIds, aM as decodeStreamEvent, aN as encodeStreamEvent, aO as invokeWithTransientRetry, aP as isChatQueueStore, aQ as isTransientToolError, aR as isTypedQuestion, aS as normalizeElicitationReply, aT as questionOptions, aU as queuedMessageView, aV as readElicitationInput, aW as readElicitationQuestions, aX as releaseThreadRun, aY as renderElicitationAnswers, aZ as resolveElicitation, a_ as resolveToolTransientRetryNumbers, a$ as settleDanglingToolCalls, b0 as settleElicitation, b1 as validateElicitationAnswer, b2 as validateElicitationValue } from './stream-events-CgWqAI-1.cjs';
3
- import { A as AiToolCtx, T as ToolHandler, a as ToolDescribeScope } from './tool-DuJ-_qXM.cjs';
4
- export { b as ToolDescription } from './tool-DuJ-_qXM.cjs';
1
+ import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, a as Actor, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, g as AgentRunInput, H as HumanReply, h as MessageAttachment, i as ToolKind, j as ToolCallStatus, k as ToolCallApproval, l as HistoryPolicy, P as PageContext, m as AgentDefinition, n as AgentStore, o as AgentDelegation, D as DetachedDelivery, p as PromptBuilder, q as PromptContributor, r as ToolTransientRetrySetting, s as AgentIntake, t as Decision, E as ElicitationRequest, L as LlmStepEnvelope, u as ToolStepEnvelope, C as ChatQueueStore, v as CreateThreadInput, w as ThreadSummary, x as ThreadDetail, y as ToolCallApprovalState, U as UpdateThreadInput, R as RecordRunStartInput, z as EnqueueMessageInput, B as QueuedMessage, F as QueuedMessagePatch, G as QueuePause, I as AppendMessageInput, S as StoredMessage, J as ToolResult, K as MessageFeedback, N as RecordToolCallInput, O as ToolCallOutcome, V as UpdateToolCallInput, W as RecordUsageInput } from './stream-events-rpd3d6gh.cjs';
2
+ export { X as ALL_AGENTS, Y as ASK_TOOL_DESCRIPTION, Z as ASK_TOOL_NAME, _ as AgentApprovalRequest, $ as AgentApprovalSettlement, a0 as AgentAttachmentConfig, a1 as AgentCatalogEntry, a2 as AgentClientConfig, a3 as AgentHistoryWindow, a4 as AgentStreamErrorCode, a5 as AskToolInput, a6 as ChatQueueState, a7 as DEFAULT_INTAKE_PREAMBLE, a8 as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, a9 as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aa as ELICITATION_INPUT_TYPES, ab as ElicitationInput, ac as ElicitationInputType, ad as ElicitationOption, ae as ElicitationOutcome, af as ElicitationQuestion, ag as ElicitationReply, ah as ElicitationResult, ai as HistoryPolicyContext, aj as HistorySelection, ak as HistorySummary, al as InvokeWithTransientRetryOptions, am as MAX_ASK_QUESTIONS, an as MessageFeedbackValue, ao as MessageRole, ap as PromptContext, aq as QueuePauseReason, ar as QueuedMessageView, as as QuotaView, at as RUN_ENDED_BEFORE_TOOL_CALL, au as RecordRunEndInput, av as ThreadTurnPage, aw as ThreadTurnQuery, ax as ThreadTurnReader, ay as ToolCallApprovalStatus, az as ToolCatalogEntry, aA as ToolConfirmation, b as ToolPresentation, aB as ToolPresentationTone, aC as ToolResultField, aD as ToolResultView, aE as ToolStepCtx, aF as ToolTransientRetryNumbers, aG as ToolTransientRetryOptions, aH as UNFINISHED_TOOL_CALL, aI as UsagePurpose, aJ as askInputSchema, aK as askToolDefinition, aL as danglingToolCallIds, aM as decodeStreamEvent, aN as encodeStreamEvent, aO as invokeWithTransientRetry, aP as isChatQueueStore, aQ as isTransientToolError, aR as isTypedQuestion, aS as normalizeElicitationReply, aT as questionOptions, aU as queuedMessageView, aV as readElicitationInput, aW as readElicitationQuestions, aX as releaseThreadRun, aY as renderElicitationAnswers, aZ as resolveElicitation, a_ as resolveToolTransientRetryNumbers, a$ as settleDanglingToolCalls, b0 as settleElicitation, b1 as validateElicitationAnswer, b2 as validateElicitationValue } from './stream-events-rpd3d6gh.cjs';
3
+ import { A as AiToolCtx, T as ToolHandler, a as ToolDescribeScope } from './tool-Dp8HA_f4.cjs';
4
+ export { b as ToolDescription } from './tool-Dp8HA_f4.cjs';
5
5
  import { StandardSchemaV1 } from '@standard-schema/spec';
6
- import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-C0snQzZJ.cjs';
7
- export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-C0snQzZJ.cjs';
6
+ import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-CAVevaYJ.cjs';
7
+ export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-CAVevaYJ.cjs';
8
8
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
9
9
 
10
10
  /**
@@ -2488,6 +2488,11 @@ declare function detachedUnsettled(args: {
2488
2488
  *
2489
2489
  * Called by the RUNNER, never the loop — a run that crashed or was stopped cannot record its own
2490
2490
  * ending. Skipped entirely when the thread is gone, for the same reason delivery is.
2491
+ *
2492
+ * Settles ONCE: a thread that already holds a message from this run (its answer, or an earlier
2493
+ * settlement) is left alone. A Stop can be settled from two places — the run's own body when it
2494
+ * observes the cancel, and the runner for a run parked where its body never runs again — and a
2495
+ * Stop on a run that already answered must not write "stopped" under its answer.
2491
2496
  */
2492
2497
  declare function settleUnsettledDelegation(args: {
2493
2498
  store: AgentStore;
@@ -3516,7 +3521,8 @@ declare class InMemoryAgentStore implements AgentStore, ChatQueueStore {
3516
3521
  setMessageFeedback(messageId: string, feedback: MessageFeedback | null): Promise<void>;
3517
3522
  truncateFrom(threadId: string, messageId: string): Promise<void>;
3518
3523
  /**
3519
- * Of `mediaIds`, the ones a surviving message in one of this actor's threads still carries.
3524
+ * Of `mediaIds`, the ones a surviving message — or a message waiting in the queue — in one of
3525
+ * this actor's threads still carries.
3520
3526
  * Re-derived from the messages each call, so a media whose message was truncated away reads as
3521
3527
  * unreferenced again.
3522
3528
  */
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, a as Actor, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, g as AgentRunInput, H as HumanReply, h as MessageAttachment, i as ToolKind, j as ToolCallStatus, k as ToolCallApproval, l as HistoryPolicy, P as PageContext, m as AgentDefinition, n as AgentStore, o as AgentDelegation, D as DetachedDelivery, p as PromptBuilder, q as PromptContributor, r as ToolTransientRetrySetting, s as AgentIntake, t as Decision, E as ElicitationRequest, L as LlmStepEnvelope, u as ToolStepEnvelope, C as ChatQueueStore, v as CreateThreadInput, w as ThreadSummary, x as ThreadDetail, y as ToolCallApprovalState, U as UpdateThreadInput, R as RecordRunStartInput, z as EnqueueMessageInput, B as QueuedMessage, F as QueuedMessagePatch, G as QueuePause, I as AppendMessageInput, S as StoredMessage, J as ToolResult, K as MessageFeedback, N as RecordToolCallInput, O as ToolCallOutcome, V as UpdateToolCallInput, W as RecordUsageInput } from './stream-events-CgWqAI-1.js';
2
- export { X as ALL_AGENTS, Y as ASK_TOOL_DESCRIPTION, Z as ASK_TOOL_NAME, _ as AgentApprovalRequest, $ as AgentApprovalSettlement, a0 as AgentAttachmentConfig, a1 as AgentCatalogEntry, a2 as AgentClientConfig, a3 as AgentHistoryWindow, a4 as AgentStreamErrorCode, a5 as AskToolInput, a6 as ChatQueueState, a7 as DEFAULT_INTAKE_PREAMBLE, a8 as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, a9 as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aa as ELICITATION_INPUT_TYPES, ab as ElicitationInput, ac as ElicitationInputType, ad as ElicitationOption, ae as ElicitationOutcome, af as ElicitationQuestion, ag as ElicitationReply, ah as ElicitationResult, ai as HistoryPolicyContext, aj as HistorySelection, ak as HistorySummary, al as InvokeWithTransientRetryOptions, am as MAX_ASK_QUESTIONS, an as MessageFeedbackValue, ao as MessageRole, ap as PromptContext, aq as QueuePauseReason, ar as QueuedMessageView, as as QuotaView, at as RUN_ENDED_BEFORE_TOOL_CALL, au as RecordRunEndInput, av as ThreadTurnPage, aw as ThreadTurnQuery, ax as ThreadTurnReader, ay as ToolCallApprovalStatus, az as ToolCatalogEntry, aA as ToolConfirmation, b as ToolPresentation, aB as ToolPresentationTone, aC as ToolResultField, aD as ToolResultView, aE as ToolStepCtx, aF as ToolTransientRetryNumbers, aG as ToolTransientRetryOptions, aH as UNFINISHED_TOOL_CALL, aI as UsagePurpose, aJ as askInputSchema, aK as askToolDefinition, aL as danglingToolCallIds, aM as decodeStreamEvent, aN as encodeStreamEvent, aO as invokeWithTransientRetry, aP as isChatQueueStore, aQ as isTransientToolError, aR as isTypedQuestion, aS as normalizeElicitationReply, aT as questionOptions, aU as queuedMessageView, aV as readElicitationInput, aW as readElicitationQuestions, aX as releaseThreadRun, aY as renderElicitationAnswers, aZ as resolveElicitation, a_ as resolveToolTransientRetryNumbers, a$ as settleDanglingToolCalls, b0 as settleElicitation, b1 as validateElicitationAnswer, b2 as validateElicitationValue } from './stream-events-CgWqAI-1.js';
3
- import { A as AiToolCtx, T as ToolHandler, a as ToolDescribeScope } from './tool-DklsS3JX.js';
4
- export { b as ToolDescription } from './tool-DklsS3JX.js';
1
+ import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, a as Actor, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, g as AgentRunInput, H as HumanReply, h as MessageAttachment, i as ToolKind, j as ToolCallStatus, k as ToolCallApproval, l as HistoryPolicy, P as PageContext, m as AgentDefinition, n as AgentStore, o as AgentDelegation, D as DetachedDelivery, p as PromptBuilder, q as PromptContributor, r as ToolTransientRetrySetting, s as AgentIntake, t as Decision, E as ElicitationRequest, L as LlmStepEnvelope, u as ToolStepEnvelope, C as ChatQueueStore, v as CreateThreadInput, w as ThreadSummary, x as ThreadDetail, y as ToolCallApprovalState, U as UpdateThreadInput, R as RecordRunStartInput, z as EnqueueMessageInput, B as QueuedMessage, F as QueuedMessagePatch, G as QueuePause, I as AppendMessageInput, S as StoredMessage, J as ToolResult, K as MessageFeedback, N as RecordToolCallInput, O as ToolCallOutcome, V as UpdateToolCallInput, W as RecordUsageInput } from './stream-events-rpd3d6gh.js';
2
+ export { X as ALL_AGENTS, Y as ASK_TOOL_DESCRIPTION, Z as ASK_TOOL_NAME, _ as AgentApprovalRequest, $ as AgentApprovalSettlement, a0 as AgentAttachmentConfig, a1 as AgentCatalogEntry, a2 as AgentClientConfig, a3 as AgentHistoryWindow, a4 as AgentStreamErrorCode, a5 as AskToolInput, a6 as ChatQueueState, a7 as DEFAULT_INTAKE_PREAMBLE, a8 as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, a9 as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aa as ELICITATION_INPUT_TYPES, ab as ElicitationInput, ac as ElicitationInputType, ad as ElicitationOption, ae as ElicitationOutcome, af as ElicitationQuestion, ag as ElicitationReply, ah as ElicitationResult, ai as HistoryPolicyContext, aj as HistorySelection, ak as HistorySummary, al as InvokeWithTransientRetryOptions, am as MAX_ASK_QUESTIONS, an as MessageFeedbackValue, ao as MessageRole, ap as PromptContext, aq as QueuePauseReason, ar as QueuedMessageView, as as QuotaView, at as RUN_ENDED_BEFORE_TOOL_CALL, au as RecordRunEndInput, av as ThreadTurnPage, aw as ThreadTurnQuery, ax as ThreadTurnReader, ay as ToolCallApprovalStatus, az as ToolCatalogEntry, aA as ToolConfirmation, b as ToolPresentation, aB as ToolPresentationTone, aC as ToolResultField, aD as ToolResultView, aE as ToolStepCtx, aF as ToolTransientRetryNumbers, aG as ToolTransientRetryOptions, aH as UNFINISHED_TOOL_CALL, aI as UsagePurpose, aJ as askInputSchema, aK as askToolDefinition, aL as danglingToolCallIds, aM as decodeStreamEvent, aN as encodeStreamEvent, aO as invokeWithTransientRetry, aP as isChatQueueStore, aQ as isTransientToolError, aR as isTypedQuestion, aS as normalizeElicitationReply, aT as questionOptions, aU as queuedMessageView, aV as readElicitationInput, aW as readElicitationQuestions, aX as releaseThreadRun, aY as renderElicitationAnswers, aZ as resolveElicitation, a_ as resolveToolTransientRetryNumbers, a$ as settleDanglingToolCalls, b0 as settleElicitation, b1 as validateElicitationAnswer, b2 as validateElicitationValue } from './stream-events-rpd3d6gh.js';
3
+ import { A as AiToolCtx, T as ToolHandler, a as ToolDescribeScope } from './tool-hhssZ_HW.js';
4
+ export { b as ToolDescription } from './tool-hhssZ_HW.js';
5
5
  import { StandardSchemaV1 } from '@standard-schema/spec';
6
- import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-D5110pit.js';
7
- export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-D5110pit.js';
6
+ import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-C-FP4nDy.js';
7
+ export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-C-FP4nDy.js';
8
8
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
9
9
 
10
10
  /**
@@ -2488,6 +2488,11 @@ declare function detachedUnsettled(args: {
2488
2488
  *
2489
2489
  * Called by the RUNNER, never the loop — a run that crashed or was stopped cannot record its own
2490
2490
  * ending. Skipped entirely when the thread is gone, for the same reason delivery is.
2491
+ *
2492
+ * Settles ONCE: a thread that already holds a message from this run (its answer, or an earlier
2493
+ * settlement) is left alone. A Stop can be settled from two places — the run's own body when it
2494
+ * observes the cancel, and the runner for a run parked where its body never runs again — and a
2495
+ * Stop on a run that already answered must not write "stopped" under its answer.
2491
2496
  */
2492
2497
  declare function settleUnsettledDelegation(args: {
2493
2498
  store: AgentStore;
@@ -3516,7 +3521,8 @@ declare class InMemoryAgentStore implements AgentStore, ChatQueueStore {
3516
3521
  setMessageFeedback(messageId: string, feedback: MessageFeedback | null): Promise<void>;
3517
3522
  truncateFrom(threadId: string, messageId: string): Promise<void>;
3518
3523
  /**
3519
- * Of `mediaIds`, the ones a surviving message in one of this actor's threads still carries.
3524
+ * Of `mediaIds`, the ones a surviving message — or a message waiting in the queue — in one of
3525
+ * this actor's threads still carries.
3520
3526
  * Re-derived from the messages each call, so a media whose message was truncated away reads as
3521
3527
  * unreferenced again.
3522
3528
  */
package/dist/index.js CHANGED
@@ -2511,7 +2511,8 @@ function detachedUnsettled(args) {
2511
2511
  __name(detachedUnsettled, "detachedUnsettled");
2512
2512
  async function settleUnsettledDelegation(args) {
2513
2513
  const { store, delivery, agent, runId, status } = args;
2514
- if (await store.getThread(delivery.threadId) === null) {
2514
+ const thread = await store.getThread(delivery.threadId);
2515
+ if (thread === null || thread.messages.some((message) => message.runId === runId)) {
2515
2516
  return;
2516
2517
  }
2517
2518
  await store.appendMessage({
@@ -5441,7 +5442,8 @@ var InMemoryAgentStore = class {
5441
5442
  }
5442
5443
  }
5443
5444
  /**
5444
- * Of `mediaIds`, the ones a surviving message in one of this actor's threads still carries.
5445
+ * Of `mediaIds`, the ones a surviving message — or a message waiting in the queue — in one of
5446
+ * this actor's threads still carries.
5445
5447
  * Re-derived from the messages each call, so a media whose message was truncated away reads as
5446
5448
  * unreferenced again.
5447
5449
  */
@@ -5455,7 +5457,11 @@ var InMemoryAgentStore = class {
5455
5457
  if (thread.actorRef !== actorRef) {
5456
5458
  continue;
5457
5459
  }
5458
- for (const message of thread.messages) {
5460
+ const queued = this.queues.get(thread.id) ?? [];
5461
+ for (const message of [
5462
+ ...thread.messages,
5463
+ ...queued
5464
+ ]) {
5459
5465
  for (const attachment of message.attachments ?? []) {
5460
5466
  if (wanted.has(attachment.mediaId)) {
5461
5467
  found.add(attachment.mediaId);