@dudousxd/nestjs-agent-react 0.10.0 → 0.11.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/README.md +16 -2
- package/dist/index.cjs +222 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -9
- package/dist/index.d.ts +72 -9
- package/dist/index.js +200 -34
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -74,6 +74,8 @@ interface AgentChatTransportOptions {
|
|
|
74
74
|
* - `ui` → `data-ui` part, `id` = the component id (a repeat id updates it in place)
|
|
75
75
|
* - `approval-requested` → `data-approval-requested` part keyed by the call id, plus the SDK's
|
|
76
76
|
* native `tool-approval-request` (the part moves to `approval-requested`)
|
|
77
|
+
* - `approval-settled` → `data-approval-settled` part keyed by the call id (who decided, through
|
|
78
|
+
* what, remembered or not); the outcome still rides the call's own output
|
|
77
79
|
* - `title`, `cancelled` → transient `data-title` / `data-cancelled` (never stored on the message)
|
|
78
80
|
* - any other kind → `data-<kind>` part carrying the frame minus `kind`, keyed by its `id`
|
|
79
81
|
* when it has one — forwarded, never dropped
|
|
@@ -233,12 +235,19 @@ declare class AgentClient {
|
|
|
233
235
|
truncateFromMessage(threadId: string, messageId: string): Promise<OkResult>;
|
|
234
236
|
getQuotaToday(): Promise<QuotaToday>;
|
|
235
237
|
cancelStream(runId: string): Promise<CancelResult>;
|
|
238
|
+
/**
|
|
239
|
+
* `remember` approves later calls of the same tool in the same thread; `via` names the surface
|
|
240
|
+
* the decision came through (the server records `'web'` when omitted).
|
|
241
|
+
*/
|
|
236
242
|
approveToolCall(input: {
|
|
237
243
|
toolCallId: string;
|
|
244
|
+
remember?: boolean;
|
|
245
|
+
via?: string;
|
|
238
246
|
}): Promise<void>;
|
|
239
247
|
rejectToolCall(input: {
|
|
240
248
|
toolCallId: string;
|
|
241
249
|
reason?: string;
|
|
250
|
+
via?: string;
|
|
242
251
|
}): Promise<void>;
|
|
243
252
|
/**
|
|
244
253
|
* Settle a parked question set. `answers` is questionId → chosen option values; a question left
|
|
@@ -540,16 +549,38 @@ interface TranscriptSettleState {
|
|
|
540
549
|
isSubmitting: boolean;
|
|
541
550
|
run: () => void;
|
|
542
551
|
}
|
|
552
|
+
/** How an approval stands. */
|
|
553
|
+
type TranscriptApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
|
|
543
554
|
/**
|
|
544
|
-
* Who has to settle a parked call,
|
|
555
|
+
* Who has to settle a parked call, until when, and — once it settled — how. From the stream's
|
|
556
|
+
* `approval-requested` / `approval-settled` frames, or the same parts a reloaded thread carries.
|
|
545
557
|
* `null` on a call whose runner never said (the call can still be awaiting approval).
|
|
546
558
|
*/
|
|
547
559
|
interface TranscriptApproval {
|
|
548
560
|
/** Open vocabulary the host defines: `'requester'`, `'admin'`, a role… */
|
|
549
561
|
approver: string;
|
|
550
|
-
/** ISO-8601; `null` when the request never lapses. */
|
|
562
|
+
/** ISO-8601; `null` when the request never lapses. Pair with `useApprovalCountdown`. */
|
|
551
563
|
expiresAt: string | null;
|
|
564
|
+
/** Why the call needs a person, when the runner said. */
|
|
552
565
|
reason: string | null;
|
|
566
|
+
/**
|
|
567
|
+
* `pending` until a settlement arrives; then what it said. Falls back to the call's own state
|
|
568
|
+
* (denied → `rejected`, an output → `approved`) for a runner that streams no settlement.
|
|
569
|
+
*/
|
|
570
|
+
status: TranscriptApprovalStatus;
|
|
571
|
+
/** The approval also covers later calls of this tool in this thread. */
|
|
572
|
+
remember: boolean;
|
|
573
|
+
/** Opaque ref of who decided; `null` while pending, on an expiry, or when the runner did not say. */
|
|
574
|
+
decidedBy: string | null;
|
|
575
|
+
/** The surface the decision came through (`'web'`, `'slack'`, `'remembered'`, …). */
|
|
576
|
+
decidedVia: string | null;
|
|
577
|
+
/** What the person said when declining. */
|
|
578
|
+
decisionReason: string | null;
|
|
579
|
+
}
|
|
580
|
+
/** What an approval can carry beyond yes. */
|
|
581
|
+
interface ApproveOptions {
|
|
582
|
+
/** Approve later calls of the same tool in the same thread without asking again. */
|
|
583
|
+
remember?: boolean;
|
|
553
584
|
}
|
|
554
585
|
/** One call in a tool run, with whatever human decision it is parked on. */
|
|
555
586
|
interface TranscriptToolCall {
|
|
@@ -578,7 +609,10 @@ interface TranscriptToolCall {
|
|
|
578
609
|
* IS the pending approval.
|
|
579
610
|
*/
|
|
580
611
|
isAwaitingApproval: boolean;
|
|
581
|
-
|
|
612
|
+
/** `run({ remember: true })` approves this tool for the rest of the thread. */
|
|
613
|
+
approve: TranscriptSettleState & {
|
|
614
|
+
run: (options?: ApproveOptions) => void;
|
|
615
|
+
};
|
|
582
616
|
reject: TranscriptSettleState;
|
|
583
617
|
/** A failed decision — the call is still parked, so the affordance stays live. */
|
|
584
618
|
error: string | null;
|
|
@@ -729,7 +763,7 @@ interface ElicitationBlockOptions {
|
|
|
729
763
|
interface ApprovalBlockOptions {
|
|
730
764
|
canApprove: boolean;
|
|
731
765
|
canReject: boolean;
|
|
732
|
-
approve: (toolCallId: string) => void;
|
|
766
|
+
approve: (toolCallId: string, options?: ApproveOptions) => void;
|
|
733
767
|
reject: (toolCallId: string) => void;
|
|
734
768
|
/** Which decision this call is sending, or `null` for none. */
|
|
735
769
|
submitting: (toolCallId: string) => SettleAction | null;
|
|
@@ -904,8 +938,11 @@ interface TranscriptItemOptions {
|
|
|
904
938
|
onAnswer?: (toolCallId: string, answers: Record<string, string[]>) => void | Promise<void>;
|
|
905
939
|
/** Decline the question set and let the agent proceed on its own picks — `useAgentChat`'s `skip`. */
|
|
906
940
|
onSkip?: (toolCallId: string) => void | Promise<void>;
|
|
907
|
-
/**
|
|
908
|
-
|
|
941
|
+
/**
|
|
942
|
+
* Settle a tool call parked on a human — `useAgentChat`'s `approve` / `reject`. `options.remember`
|
|
943
|
+
* is what `call.approve.run({ remember: true })` passed.
|
|
944
|
+
*/
|
|
945
|
+
onApprove?: (toolCallId: string, options?: ApproveOptions) => void | Promise<void>;
|
|
909
946
|
onReject?: (toolCallId: string) => void | Promise<void>;
|
|
910
947
|
}
|
|
911
948
|
interface TranscriptWindow {
|
|
@@ -1374,6 +1411,28 @@ interface ToolCatalogState {
|
|
|
1374
1411
|
*/
|
|
1375
1412
|
declare function useToolCatalog(options: UseToolCatalogOptions): ToolCatalogState;
|
|
1376
1413
|
|
|
1414
|
+
interface ApprovalCountdown {
|
|
1415
|
+
/** Milliseconds until the request lapses, floored at 0; `null` when it never does. */
|
|
1416
|
+
remainingMs: number | null;
|
|
1417
|
+
/** The instant has passed. Always `false` for a request with no expiry. */
|
|
1418
|
+
isExpired: boolean;
|
|
1419
|
+
}
|
|
1420
|
+
interface UseApprovalCountdownOptions {
|
|
1421
|
+
/** How often the value re-renders while counting. Default 1000 — a seconds label needs no more. */
|
|
1422
|
+
intervalMs?: number;
|
|
1423
|
+
/** Injectable clock for tests. */
|
|
1424
|
+
now?: () => number;
|
|
1425
|
+
}
|
|
1426
|
+
/** What {@link useApprovalCountdown} reads for `expiresAt` at `now`, without the ticking. */
|
|
1427
|
+
declare function approvalCountdown(expiresAt: string | null | undefined, now?: number): ApprovalCountdown;
|
|
1428
|
+
/**
|
|
1429
|
+
* Time left on an approval request (`call.approval.expiresAt`), ticking until it lapses and then
|
|
1430
|
+
* holding at zero. Headless: pair `remainingMs` with `formatElapsed` or any label of your own, and
|
|
1431
|
+
* use `isExpired` to stop offering buttons the server would refuse (`410 Gone`). The server stays
|
|
1432
|
+
* the authority — a lapse is final only once the call settles `expired`.
|
|
1433
|
+
*/
|
|
1434
|
+
declare function useApprovalCountdown(expiresAt: string | null | undefined, options?: UseApprovalCountdownOptions): ApprovalCountdown;
|
|
1435
|
+
|
|
1377
1436
|
/** The thinking time stamped on a reasoning part, or `null` when it carries none. */
|
|
1378
1437
|
declare function readReasoningMs(part: {
|
|
1379
1438
|
providerMetadata?: unknown;
|
|
@@ -1621,12 +1680,16 @@ declare function useAgentChat(options: UseAgentChatOptions): {
|
|
|
1621
1680
|
quota: _dudousxd_nestjs_agent_core.QuotaView | null;
|
|
1622
1681
|
loadQuota: () => Promise<QuotaToday>;
|
|
1623
1682
|
cancel: () => Promise<void>;
|
|
1624
|
-
approve: ({ toolCallId }: {
|
|
1683
|
+
approve: ({ toolCallId, remember, via, }: {
|
|
1625
1684
|
toolCallId: string;
|
|
1685
|
+
/** Approve later calls of the same tool in this thread without asking. */
|
|
1686
|
+
remember?: boolean;
|
|
1687
|
+
via?: string;
|
|
1626
1688
|
}) => Promise<void>;
|
|
1627
|
-
reject: ({ toolCallId, reason, }: {
|
|
1689
|
+
reject: ({ toolCallId, reason, via, }: {
|
|
1628
1690
|
toolCallId: string;
|
|
1629
1691
|
reason?: string;
|
|
1692
|
+
via?: string;
|
|
1630
1693
|
}) => Promise<void>;
|
|
1631
1694
|
answer: ({ toolCallId, answers, }: {
|
|
1632
1695
|
toolCallId: string;
|
|
@@ -1648,4 +1711,4 @@ declare function useAgentChat(options: UseAgentChatOptions): {
|
|
|
1648
1711
|
clearError: () => void;
|
|
1649
1712
|
};
|
|
1650
1713
|
|
|
1651
|
-
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 DescribeToolCallOptions, type ElicitationBlockOptions, type GroupToolActivityOptions, 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 RenderUiFn, type ResolvedReading, type ResolvedResultView, 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 ToolActivityGroup, type ToolCallDescription, type ToolCallState, type ToolCallStatus, type ToolCatalog, type ToolCatalogState, type TranscriptActionState, type TranscriptApproval, 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 TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseSpeechRecognitionOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, backgroundRunsFromThread, buildTranscriptBlocks, correctedCallIds, createSkillsSource, describeTimestamp, describeToolCall, describeUsage, extractMessageText, fillTemplate, filterAutocompleteItems, findActiveTrigger, formatElapsed, formatRelativeTime, groupToolActivity, inferResultView, isActionCall, loadStoredSpeechLang, persistSpeechLang, phraseFor, readPath, readReasoningMs, resolveResultView, storedMessageToUiMessage, storedThreadToUiMessages, toolCallState, toolCatalogFrom, useAgentChat, useChatTranscript, useComposerAutocomplete, useElapsed, useSpeechRecognition, useStickToBottom, useToolCatalog, useTranscriptItem };
|
|
1714
|
+
export { AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentStreamMeta, type AggregatedTurnUsage, type AnyToolUIPart, type ApprovalBlockOptions, type ApprovalCountdown, type ApproveOptions, 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 DescribeToolCallOptions, type ElicitationBlockOptions, type GroupToolActivityOptions, 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 RenderUiFn, type ResolvedReading, type ResolvedResultView, 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 ToolActivityGroup, type ToolCallDescription, type ToolCallState, type ToolCallStatus, type ToolCatalog, type ToolCatalogState, type TranscriptActionState, type TranscriptApproval, type TranscriptApprovalStatus, 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 TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseApprovalCountdownOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseSpeechRecognitionOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, approvalCountdown, backgroundRunsFromThread, buildTranscriptBlocks, correctedCallIds, createSkillsSource, describeTimestamp, describeToolCall, describeUsage, extractMessageText, fillTemplate, filterAutocompleteItems, findActiveTrigger, formatElapsed, formatRelativeTime, groupToolActivity, inferResultView, isActionCall, loadStoredSpeechLang, persistSpeechLang, phraseFor, readPath, readReasoningMs, resolveResultView, storedMessageToUiMessage, storedThreadToUiMessages, toolCallState, toolCatalogFrom, useAgentChat, useApprovalCountdown, useChatTranscript, useComposerAutocomplete, useElapsed, useSpeechRecognition, useStickToBottom, useToolCatalog, useTranscriptItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -74,6 +74,8 @@ interface AgentChatTransportOptions {
|
|
|
74
74
|
* - `ui` → `data-ui` part, `id` = the component id (a repeat id updates it in place)
|
|
75
75
|
* - `approval-requested` → `data-approval-requested` part keyed by the call id, plus the SDK's
|
|
76
76
|
* native `tool-approval-request` (the part moves to `approval-requested`)
|
|
77
|
+
* - `approval-settled` → `data-approval-settled` part keyed by the call id (who decided, through
|
|
78
|
+
* what, remembered or not); the outcome still rides the call's own output
|
|
77
79
|
* - `title`, `cancelled` → transient `data-title` / `data-cancelled` (never stored on the message)
|
|
78
80
|
* - any other kind → `data-<kind>` part carrying the frame minus `kind`, keyed by its `id`
|
|
79
81
|
* when it has one — forwarded, never dropped
|
|
@@ -233,12 +235,19 @@ declare class AgentClient {
|
|
|
233
235
|
truncateFromMessage(threadId: string, messageId: string): Promise<OkResult>;
|
|
234
236
|
getQuotaToday(): Promise<QuotaToday>;
|
|
235
237
|
cancelStream(runId: string): Promise<CancelResult>;
|
|
238
|
+
/**
|
|
239
|
+
* `remember` approves later calls of the same tool in the same thread; `via` names the surface
|
|
240
|
+
* the decision came through (the server records `'web'` when omitted).
|
|
241
|
+
*/
|
|
236
242
|
approveToolCall(input: {
|
|
237
243
|
toolCallId: string;
|
|
244
|
+
remember?: boolean;
|
|
245
|
+
via?: string;
|
|
238
246
|
}): Promise<void>;
|
|
239
247
|
rejectToolCall(input: {
|
|
240
248
|
toolCallId: string;
|
|
241
249
|
reason?: string;
|
|
250
|
+
via?: string;
|
|
242
251
|
}): Promise<void>;
|
|
243
252
|
/**
|
|
244
253
|
* Settle a parked question set. `answers` is questionId → chosen option values; a question left
|
|
@@ -540,16 +549,38 @@ interface TranscriptSettleState {
|
|
|
540
549
|
isSubmitting: boolean;
|
|
541
550
|
run: () => void;
|
|
542
551
|
}
|
|
552
|
+
/** How an approval stands. */
|
|
553
|
+
type TranscriptApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
|
|
543
554
|
/**
|
|
544
|
-
* Who has to settle a parked call,
|
|
555
|
+
* Who has to settle a parked call, until when, and — once it settled — how. From the stream's
|
|
556
|
+
* `approval-requested` / `approval-settled` frames, or the same parts a reloaded thread carries.
|
|
545
557
|
* `null` on a call whose runner never said (the call can still be awaiting approval).
|
|
546
558
|
*/
|
|
547
559
|
interface TranscriptApproval {
|
|
548
560
|
/** Open vocabulary the host defines: `'requester'`, `'admin'`, a role… */
|
|
549
561
|
approver: string;
|
|
550
|
-
/** ISO-8601; `null` when the request never lapses. */
|
|
562
|
+
/** ISO-8601; `null` when the request never lapses. Pair with `useApprovalCountdown`. */
|
|
551
563
|
expiresAt: string | null;
|
|
564
|
+
/** Why the call needs a person, when the runner said. */
|
|
552
565
|
reason: string | null;
|
|
566
|
+
/**
|
|
567
|
+
* `pending` until a settlement arrives; then what it said. Falls back to the call's own state
|
|
568
|
+
* (denied → `rejected`, an output → `approved`) for a runner that streams no settlement.
|
|
569
|
+
*/
|
|
570
|
+
status: TranscriptApprovalStatus;
|
|
571
|
+
/** The approval also covers later calls of this tool in this thread. */
|
|
572
|
+
remember: boolean;
|
|
573
|
+
/** Opaque ref of who decided; `null` while pending, on an expiry, or when the runner did not say. */
|
|
574
|
+
decidedBy: string | null;
|
|
575
|
+
/** The surface the decision came through (`'web'`, `'slack'`, `'remembered'`, …). */
|
|
576
|
+
decidedVia: string | null;
|
|
577
|
+
/** What the person said when declining. */
|
|
578
|
+
decisionReason: string | null;
|
|
579
|
+
}
|
|
580
|
+
/** What an approval can carry beyond yes. */
|
|
581
|
+
interface ApproveOptions {
|
|
582
|
+
/** Approve later calls of the same tool in the same thread without asking again. */
|
|
583
|
+
remember?: boolean;
|
|
553
584
|
}
|
|
554
585
|
/** One call in a tool run, with whatever human decision it is parked on. */
|
|
555
586
|
interface TranscriptToolCall {
|
|
@@ -578,7 +609,10 @@ interface TranscriptToolCall {
|
|
|
578
609
|
* IS the pending approval.
|
|
579
610
|
*/
|
|
580
611
|
isAwaitingApproval: boolean;
|
|
581
|
-
|
|
612
|
+
/** `run({ remember: true })` approves this tool for the rest of the thread. */
|
|
613
|
+
approve: TranscriptSettleState & {
|
|
614
|
+
run: (options?: ApproveOptions) => void;
|
|
615
|
+
};
|
|
582
616
|
reject: TranscriptSettleState;
|
|
583
617
|
/** A failed decision — the call is still parked, so the affordance stays live. */
|
|
584
618
|
error: string | null;
|
|
@@ -729,7 +763,7 @@ interface ElicitationBlockOptions {
|
|
|
729
763
|
interface ApprovalBlockOptions {
|
|
730
764
|
canApprove: boolean;
|
|
731
765
|
canReject: boolean;
|
|
732
|
-
approve: (toolCallId: string) => void;
|
|
766
|
+
approve: (toolCallId: string, options?: ApproveOptions) => void;
|
|
733
767
|
reject: (toolCallId: string) => void;
|
|
734
768
|
/** Which decision this call is sending, or `null` for none. */
|
|
735
769
|
submitting: (toolCallId: string) => SettleAction | null;
|
|
@@ -904,8 +938,11 @@ interface TranscriptItemOptions {
|
|
|
904
938
|
onAnswer?: (toolCallId: string, answers: Record<string, string[]>) => void | Promise<void>;
|
|
905
939
|
/** Decline the question set and let the agent proceed on its own picks — `useAgentChat`'s `skip`. */
|
|
906
940
|
onSkip?: (toolCallId: string) => void | Promise<void>;
|
|
907
|
-
/**
|
|
908
|
-
|
|
941
|
+
/**
|
|
942
|
+
* Settle a tool call parked on a human — `useAgentChat`'s `approve` / `reject`. `options.remember`
|
|
943
|
+
* is what `call.approve.run({ remember: true })` passed.
|
|
944
|
+
*/
|
|
945
|
+
onApprove?: (toolCallId: string, options?: ApproveOptions) => void | Promise<void>;
|
|
909
946
|
onReject?: (toolCallId: string) => void | Promise<void>;
|
|
910
947
|
}
|
|
911
948
|
interface TranscriptWindow {
|
|
@@ -1374,6 +1411,28 @@ interface ToolCatalogState {
|
|
|
1374
1411
|
*/
|
|
1375
1412
|
declare function useToolCatalog(options: UseToolCatalogOptions): ToolCatalogState;
|
|
1376
1413
|
|
|
1414
|
+
interface ApprovalCountdown {
|
|
1415
|
+
/** Milliseconds until the request lapses, floored at 0; `null` when it never does. */
|
|
1416
|
+
remainingMs: number | null;
|
|
1417
|
+
/** The instant has passed. Always `false` for a request with no expiry. */
|
|
1418
|
+
isExpired: boolean;
|
|
1419
|
+
}
|
|
1420
|
+
interface UseApprovalCountdownOptions {
|
|
1421
|
+
/** How often the value re-renders while counting. Default 1000 — a seconds label needs no more. */
|
|
1422
|
+
intervalMs?: number;
|
|
1423
|
+
/** Injectable clock for tests. */
|
|
1424
|
+
now?: () => number;
|
|
1425
|
+
}
|
|
1426
|
+
/** What {@link useApprovalCountdown} reads for `expiresAt` at `now`, without the ticking. */
|
|
1427
|
+
declare function approvalCountdown(expiresAt: string | null | undefined, now?: number): ApprovalCountdown;
|
|
1428
|
+
/**
|
|
1429
|
+
* Time left on an approval request (`call.approval.expiresAt`), ticking until it lapses and then
|
|
1430
|
+
* holding at zero. Headless: pair `remainingMs` with `formatElapsed` or any label of your own, and
|
|
1431
|
+
* use `isExpired` to stop offering buttons the server would refuse (`410 Gone`). The server stays
|
|
1432
|
+
* the authority — a lapse is final only once the call settles `expired`.
|
|
1433
|
+
*/
|
|
1434
|
+
declare function useApprovalCountdown(expiresAt: string | null | undefined, options?: UseApprovalCountdownOptions): ApprovalCountdown;
|
|
1435
|
+
|
|
1377
1436
|
/** The thinking time stamped on a reasoning part, or `null` when it carries none. */
|
|
1378
1437
|
declare function readReasoningMs(part: {
|
|
1379
1438
|
providerMetadata?: unknown;
|
|
@@ -1621,12 +1680,16 @@ declare function useAgentChat(options: UseAgentChatOptions): {
|
|
|
1621
1680
|
quota: _dudousxd_nestjs_agent_core.QuotaView | null;
|
|
1622
1681
|
loadQuota: () => Promise<QuotaToday>;
|
|
1623
1682
|
cancel: () => Promise<void>;
|
|
1624
|
-
approve: ({ toolCallId }: {
|
|
1683
|
+
approve: ({ toolCallId, remember, via, }: {
|
|
1625
1684
|
toolCallId: string;
|
|
1685
|
+
/** Approve later calls of the same tool in this thread without asking. */
|
|
1686
|
+
remember?: boolean;
|
|
1687
|
+
via?: string;
|
|
1626
1688
|
}) => Promise<void>;
|
|
1627
|
-
reject: ({ toolCallId, reason, }: {
|
|
1689
|
+
reject: ({ toolCallId, reason, via, }: {
|
|
1628
1690
|
toolCallId: string;
|
|
1629
1691
|
reason?: string;
|
|
1692
|
+
via?: string;
|
|
1630
1693
|
}) => Promise<void>;
|
|
1631
1694
|
answer: ({ toolCallId, answers, }: {
|
|
1632
1695
|
toolCallId: string;
|
|
@@ -1648,4 +1711,4 @@ declare function useAgentChat(options: UseAgentChatOptions): {
|
|
|
1648
1711
|
clearError: () => void;
|
|
1649
1712
|
};
|
|
1650
1713
|
|
|
1651
|
-
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 DescribeToolCallOptions, type ElicitationBlockOptions, type GroupToolActivityOptions, 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 RenderUiFn, type ResolvedReading, type ResolvedResultView, 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 ToolActivityGroup, type ToolCallDescription, type ToolCallState, type ToolCallStatus, type ToolCatalog, type ToolCatalogState, type TranscriptActionState, type TranscriptApproval, 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 TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseSpeechRecognitionOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, backgroundRunsFromThread, buildTranscriptBlocks, correctedCallIds, createSkillsSource, describeTimestamp, describeToolCall, describeUsage, extractMessageText, fillTemplate, filterAutocompleteItems, findActiveTrigger, formatElapsed, formatRelativeTime, groupToolActivity, inferResultView, isActionCall, loadStoredSpeechLang, persistSpeechLang, phraseFor, readPath, readReasoningMs, resolveResultView, storedMessageToUiMessage, storedThreadToUiMessages, toolCallState, toolCatalogFrom, useAgentChat, useChatTranscript, useComposerAutocomplete, useElapsed, useSpeechRecognition, useStickToBottom, useToolCatalog, useTranscriptItem };
|
|
1714
|
+
export { AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentStreamMeta, type AggregatedTurnUsage, type AnyToolUIPart, type ApprovalBlockOptions, type ApprovalCountdown, type ApproveOptions, 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 DescribeToolCallOptions, type ElicitationBlockOptions, type GroupToolActivityOptions, 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 RenderUiFn, type ResolvedReading, type ResolvedResultView, 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 ToolActivityGroup, type ToolCallDescription, type ToolCallState, type ToolCallStatus, type ToolCatalog, type ToolCatalogState, type TranscriptActionState, type TranscriptApproval, type TranscriptApprovalStatus, 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 TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseApprovalCountdownOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseSpeechRecognitionOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, approvalCountdown, backgroundRunsFromThread, buildTranscriptBlocks, correctedCallIds, createSkillsSource, describeTimestamp, describeToolCall, describeUsage, extractMessageText, fillTemplate, filterAutocompleteItems, findActiveTrigger, formatElapsed, formatRelativeTime, groupToolActivity, inferResultView, isActionCall, loadStoredSpeechLang, persistSpeechLang, phraseFor, readPath, readReasoningMs, resolveResultView, storedMessageToUiMessage, storedThreadToUiMessages, toolCallState, toolCatalogFrom, useAgentChat, useApprovalCountdown, useChatTranscript, useComposerAutocomplete, useElapsed, useSpeechRecognition, useStickToBottom, useToolCatalog, useTranscriptItem };
|