@dudousxd/nestjs-agent-react 0.6.4 → 0.7.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
@@ -338,7 +338,14 @@ interface TranscriptReasoningBlock {
338
338
  isOpen: boolean;
339
339
  toggle: (open?: boolean) => void;
340
340
  }
341
- /** An action a run is waiting on a human for: approve, reject, answer, skip. */
341
+ /**
342
+ * A decision a run is waiting on a human for, and which one a parked call is currently sending.
343
+ *
344
+ * One call settles one way at a time, and WHICH one is what lets a surface report progress on the
345
+ * affordance the person pressed instead of on all of them.
346
+ */
347
+ type SettleAction = 'approve' | 'reject' | 'answer' | 'skip';
348
+ /** One such decision: whether it can be made, whether it is on its way, and how to send it. */
342
349
  interface TranscriptSettleState {
343
350
  available: boolean;
344
351
  /** True from the click until the run resumes and settles the call. */
@@ -475,7 +482,8 @@ interface ElicitationBlockOptions {
475
482
  canSkip: boolean;
476
483
  answer: (toolCallId: string) => void;
477
484
  skip: (toolCallId: string) => void;
478
- isSubmitting: (toolCallId: string) => boolean;
485
+ /** Which decision this call is sending, or `null` for none. */
486
+ submitting: (toolCallId: string) => SettleAction | null;
479
487
  errorOf: (toolCallId: string) => string | null;
480
488
  }
481
489
  /** Where an approval decision is sent, and what the last one did. */
@@ -484,7 +492,8 @@ interface ApprovalBlockOptions {
484
492
  canReject: boolean;
485
493
  approve: (toolCallId: string) => void;
486
494
  reject: (toolCallId: string) => void;
487
- isSubmitting: (toolCallId: string) => boolean;
495
+ /** Which decision this call is sending, or `null` for none. */
496
+ submitting: (toolCallId: string) => SettleAction | null;
488
497
  errorOf: (toolCallId: string) => string | null;
489
498
  }
490
499
  interface BuildBlocksOptions {
@@ -1335,4 +1344,4 @@ declare function useAgentChat(options: UseAgentChatOptions): {
1335
1344
  clearError: () => void;
1336
1345
  };
1337
1346
 
1338
- export { AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentStreamMeta, type AggregatedTurnUsage, type AnyToolUIPart, type ApprovalBlockOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type BuildBlocksOptions, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, type ChatStatus, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type ElicitationBlockOptions, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, type MessageUsageInfo, type QuotaToday, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RetrievedPassage, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type ThreadPatch, type TimestampInfo, type TranscriptActionState, type TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, type TranscriptElicitationBlock, type TranscriptElicitationOutcome, type TranscriptFile, type TranscriptFilesBlock, type TranscriptItem, type TranscriptItemOptions, type TranscriptQuestion, type TranscriptQuestionOption, type TranscriptReasoningBlock, type TranscriptSettleState, type TranscriptSource, type TranscriptSourcesBlock, type TranscriptStopState, type TranscriptTextBlock, type TranscriptToolBlock, type TranscriptToolCall, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseSpeechRecognitionOptions, type UseTranscriptItemOptions, applyCompletion, backgroundRunsFromThread, buildTranscriptBlocks, createSkillsSource, describeTimestamp, describeUsage, extractMessageText, filterAutocompleteItems, findActiveTrigger, formatRelativeTime, loadStoredSpeechLang, persistSpeechLang, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useChatTranscript, useComposerAutocomplete, useSpeechRecognition, useStickToBottom, useTranscriptItem };
1347
+ export { AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentStreamMeta, type AggregatedTurnUsage, type AnyToolUIPart, type ApprovalBlockOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type BuildBlocksOptions, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, type ChatStatus, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type ElicitationBlockOptions, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, type MessageUsageInfo, type QuotaToday, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RetrievedPassage, SPEECH_LANGUAGES, type SettleAction, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type ThreadPatch, type TimestampInfo, type TranscriptActionState, type TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, type TranscriptElicitationBlock, type TranscriptElicitationOutcome, type TranscriptFile, type TranscriptFilesBlock, type TranscriptItem, type TranscriptItemOptions, type TranscriptQuestion, type TranscriptQuestionOption, type TranscriptReasoningBlock, type TranscriptSettleState, type TranscriptSource, type TranscriptSourcesBlock, type TranscriptStopState, type TranscriptTextBlock, type TranscriptToolBlock, type TranscriptToolCall, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseSpeechRecognitionOptions, type UseTranscriptItemOptions, applyCompletion, backgroundRunsFromThread, buildTranscriptBlocks, createSkillsSource, describeTimestamp, describeUsage, extractMessageText, filterAutocompleteItems, findActiveTrigger, formatRelativeTime, loadStoredSpeechLang, persistSpeechLang, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useChatTranscript, useComposerAutocomplete, useSpeechRecognition, useStickToBottom, useTranscriptItem };
package/dist/index.d.ts CHANGED
@@ -338,7 +338,14 @@ interface TranscriptReasoningBlock {
338
338
  isOpen: boolean;
339
339
  toggle: (open?: boolean) => void;
340
340
  }
341
- /** An action a run is waiting on a human for: approve, reject, answer, skip. */
341
+ /**
342
+ * A decision a run is waiting on a human for, and which one a parked call is currently sending.
343
+ *
344
+ * One call settles one way at a time, and WHICH one is what lets a surface report progress on the
345
+ * affordance the person pressed instead of on all of them.
346
+ */
347
+ type SettleAction = 'approve' | 'reject' | 'answer' | 'skip';
348
+ /** One such decision: whether it can be made, whether it is on its way, and how to send it. */
342
349
  interface TranscriptSettleState {
343
350
  available: boolean;
344
351
  /** True from the click until the run resumes and settles the call. */
@@ -475,7 +482,8 @@ interface ElicitationBlockOptions {
475
482
  canSkip: boolean;
476
483
  answer: (toolCallId: string) => void;
477
484
  skip: (toolCallId: string) => void;
478
- isSubmitting: (toolCallId: string) => boolean;
485
+ /** Which decision this call is sending, or `null` for none. */
486
+ submitting: (toolCallId: string) => SettleAction | null;
479
487
  errorOf: (toolCallId: string) => string | null;
480
488
  }
481
489
  /** Where an approval decision is sent, and what the last one did. */
@@ -484,7 +492,8 @@ interface ApprovalBlockOptions {
484
492
  canReject: boolean;
485
493
  approve: (toolCallId: string) => void;
486
494
  reject: (toolCallId: string) => void;
487
- isSubmitting: (toolCallId: string) => boolean;
495
+ /** Which decision this call is sending, or `null` for none. */
496
+ submitting: (toolCallId: string) => SettleAction | null;
488
497
  errorOf: (toolCallId: string) => string | null;
489
498
  }
490
499
  interface BuildBlocksOptions {
@@ -1335,4 +1344,4 @@ declare function useAgentChat(options: UseAgentChatOptions): {
1335
1344
  clearError: () => void;
1336
1345
  };
1337
1346
 
1338
- export { AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentStreamMeta, type AggregatedTurnUsage, type AnyToolUIPart, type ApprovalBlockOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type BuildBlocksOptions, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, type ChatStatus, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type ElicitationBlockOptions, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, type MessageUsageInfo, type QuotaToday, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RetrievedPassage, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type ThreadPatch, type TimestampInfo, type TranscriptActionState, type TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, type TranscriptElicitationBlock, type TranscriptElicitationOutcome, type TranscriptFile, type TranscriptFilesBlock, type TranscriptItem, type TranscriptItemOptions, type TranscriptQuestion, type TranscriptQuestionOption, type TranscriptReasoningBlock, type TranscriptSettleState, type TranscriptSource, type TranscriptSourcesBlock, type TranscriptStopState, type TranscriptTextBlock, type TranscriptToolBlock, type TranscriptToolCall, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseSpeechRecognitionOptions, type UseTranscriptItemOptions, applyCompletion, backgroundRunsFromThread, buildTranscriptBlocks, createSkillsSource, describeTimestamp, describeUsage, extractMessageText, filterAutocompleteItems, findActiveTrigger, formatRelativeTime, loadStoredSpeechLang, persistSpeechLang, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useChatTranscript, useComposerAutocomplete, useSpeechRecognition, useStickToBottom, useTranscriptItem };
1347
+ export { AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentStreamMeta, type AggregatedTurnUsage, type AnyToolUIPart, type ApprovalBlockOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type BuildBlocksOptions, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, type ChatStatus, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type ElicitationBlockOptions, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, type MessageUsageInfo, type QuotaToday, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RetrievedPassage, SPEECH_LANGUAGES, type SettleAction, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type ThreadPatch, type TimestampInfo, type TranscriptActionState, type TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, type TranscriptElicitationBlock, type TranscriptElicitationOutcome, type TranscriptFile, type TranscriptFilesBlock, type TranscriptItem, type TranscriptItemOptions, type TranscriptQuestion, type TranscriptQuestionOption, type TranscriptReasoningBlock, type TranscriptSettleState, type TranscriptSource, type TranscriptSourcesBlock, type TranscriptStopState, type TranscriptTextBlock, type TranscriptToolBlock, type TranscriptToolCall, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseSpeechRecognitionOptions, type UseTranscriptItemOptions, applyCompletion, backgroundRunsFromThread, buildTranscriptBlocks, createSkillsSource, describeTimestamp, describeUsage, extractMessageText, filterAutocompleteItems, findActiveTrigger, formatRelativeTime, loadStoredSpeechLang, persistSpeechLang, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useChatTranscript, useComposerAutocomplete, useSpeechRecognition, useStickToBottom, useTranscriptItem };
package/dist/index.js CHANGED
@@ -995,7 +995,7 @@ __name(isAwaitingApproval, "isAwaitingApproval");
995
995
  function buildToolCall(part, options) {
996
996
  const toolCallId = part.toolCallId;
997
997
  const awaiting = isAwaitingApproval(part);
998
- const isSubmitting = awaiting && options?.isSubmitting(toolCallId) === true;
998
+ const sending = awaiting ? options?.submitting(toolCallId) ?? null : null;
999
999
  return {
1000
1000
  part,
1001
1001
  toolCallId,
@@ -1003,12 +1003,12 @@ function buildToolCall(part, options) {
1003
1003
  isAwaitingApproval: awaiting,
1004
1004
  approve: {
1005
1005
  available: awaiting && options?.canApprove === true,
1006
- isSubmitting,
1006
+ isSubmitting: sending === "approve",
1007
1007
  run: /* @__PURE__ */ __name(() => options?.approve(toolCallId), "run")
1008
1008
  },
1009
1009
  reject: {
1010
1010
  available: awaiting && options?.canReject === true,
1011
- isSubmitting,
1011
+ isSubmitting: sending === "reject",
1012
1012
  run: /* @__PURE__ */ __name(() => options?.reject(toolCallId), "run")
1013
1013
  },
1014
1014
  error: options?.errorOf(toolCallId) ?? null
@@ -1106,7 +1106,7 @@ function buildElicitationBlock(key, part, request, options) {
1106
1106
  }))
1107
1107
  };
1108
1108
  });
1109
- const isSubmitting = isPending && options.isSubmitting(toolCallId);
1109
+ const sending = isPending ? options.submitting(toolCallId) : null;
1110
1110
  return {
1111
1111
  kind: "elicitation",
1112
1112
  key,
@@ -1119,12 +1119,12 @@ function buildElicitationBlock(key, part, request, options) {
1119
1119
  error: options.errorOf(toolCallId),
1120
1120
  answer: {
1121
1121
  available: isPending && options.canAnswer,
1122
- isSubmitting,
1122
+ isSubmitting: sending === "answer",
1123
1123
  run: /* @__PURE__ */ __name(() => options.answer(toolCallId), "run")
1124
1124
  },
1125
1125
  skip: {
1126
1126
  available: isPending && options.canSkip,
1127
- isSubmitting,
1127
+ isSubmitting: sending === "skip",
1128
1128
  run: /* @__PURE__ */ __name(() => options.skip(toolCallId), "run")
1129
1129
  }
1130
1130
  };
@@ -1413,7 +1413,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
1413
1413
  const [copied, setCopied] = useState4(() => /* @__PURE__ */ new Set());
1414
1414
  const [openReasoning, setOpenReasoning] = useState4(() => /* @__PURE__ */ new Map());
1415
1415
  const [picks, setPicks] = useState4(() => /* @__PURE__ */ new Map());
1416
- const [settling, setSettling] = useState4(() => /* @__PURE__ */ new Set());
1416
+ const [settling, setSettling] = useState4(() => /* @__PURE__ */ new Map());
1417
1417
  const [settleErrors, setSettleErrors] = useState4(() => /* @__PURE__ */ new Map());
1418
1418
  const latest = useRef3({
1419
1419
  options,
@@ -1456,7 +1456,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
1456
1456
  const pick = useCallback3((toolCallId, questionId, values) => {
1457
1457
  setPicks((current) => new Map(current).set(pickKey(toolCallId, questionId), values));
1458
1458
  }, []);
1459
- const settle = useCallback3((toolCallId, send) => {
1459
+ const settle = useCallback3((toolCallId, action, send) => {
1460
1460
  setSettleErrors((current) => {
1461
1461
  if (!current.has(toolCallId)) {
1462
1462
  return current;
@@ -1465,10 +1465,10 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
1465
1465
  next.delete(toolCallId);
1466
1466
  return next;
1467
1467
  });
1468
- setSettling((current) => new Set(current).add(toolCallId));
1468
+ setSettling((current) => new Map(current).set(toolCallId, action));
1469
1469
  const failed = /* @__PURE__ */ __name((error) => {
1470
1470
  setSettling((current) => {
1471
- const next = new Set(current);
1471
+ const next = new Map(current);
1472
1472
  next.delete(toolCallId);
1473
1473
  return next;
1474
1474
  });
@@ -1486,14 +1486,14 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
1486
1486
  if (!onAnswer) {
1487
1487
  return;
1488
1488
  }
1489
- settle(toolCallId, () => onAnswer(toolCallId, answersFor(current.picks, toolCallId)));
1489
+ settle(toolCallId, "answer", () => onAnswer(toolCallId, answersFor(current.picks, toolCallId)));
1490
1490
  }, [
1491
1491
  settle
1492
1492
  ]);
1493
1493
  const skip = useCallback3((toolCallId) => {
1494
1494
  const onSkip = latest.current.options.onSkip;
1495
1495
  if (onSkip) {
1496
- settle(toolCallId, () => onSkip(toolCallId));
1496
+ settle(toolCallId, "skip", () => onSkip(toolCallId));
1497
1497
  }
1498
1498
  }, [
1499
1499
  settle
@@ -1501,7 +1501,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
1501
1501
  const approve = useCallback3((toolCallId) => {
1502
1502
  const onApprove = latest.current.options.onApprove;
1503
1503
  if (onApprove) {
1504
- settle(toolCallId, () => onApprove(toolCallId));
1504
+ settle(toolCallId, "approve", () => onApprove(toolCallId));
1505
1505
  }
1506
1506
  }, [
1507
1507
  settle
@@ -1509,7 +1509,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
1509
1509
  const reject = useCallback3((toolCallId) => {
1510
1510
  const onReject = latest.current.options.onReject;
1511
1511
  if (onReject) {
1512
- settle(toolCallId, () => onReject(toolCallId));
1512
+ settle(toolCallId, "reject", () => onReject(toolCallId));
1513
1513
  }
1514
1514
  }, [
1515
1515
  settle
@@ -1634,7 +1634,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
1634
1634
  canSkip: options.onSkip !== void 0,
1635
1635
  answer,
1636
1636
  skip,
1637
- isSubmitting: /* @__PURE__ */ __name((toolCallId) => settling.has(toolCallId), "isSubmitting"),
1637
+ submitting: /* @__PURE__ */ __name((toolCallId) => settling.get(toolCallId) ?? null, "submitting"),
1638
1638
  errorOf: /* @__PURE__ */ __name((toolCallId) => settleErrors.get(toolCallId) ?? null, "errorOf")
1639
1639
  }
1640
1640
  } : {},
@@ -1644,7 +1644,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
1644
1644
  canReject: options.onReject !== void 0,
1645
1645
  approve,
1646
1646
  reject,
1647
- isSubmitting: /* @__PURE__ */ __name((toolCallId) => settling.has(toolCallId), "isSubmitting"),
1647
+ submitting: /* @__PURE__ */ __name((toolCallId) => settling.get(toolCallId) ?? null, "submitting"),
1648
1648
  errorOf: /* @__PURE__ */ __name((toolCallId) => settleErrors.get(toolCallId) ?? null, "errorOf")
1649
1649
  }
1650
1650
  } : {}