@dudousxd/nestjs-agent-react 0.27.0 → 0.29.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 +55 -2
- package/dist/{client-DNM5Qm5N.d.cts → client-DhHEJi7c.d.cts} +19 -1
- package/dist/{client-DNM5Qm5N.d.ts → client-DhHEJi7c.d.ts} +19 -1
- package/dist/{generative-ui-jT9TYfCi.d.cts → generative-ui-VTZ1EADD.d.cts} +12 -0
- package/dist/{generative-ui-jT9TYfCi.d.ts → generative-ui-VTZ1EADD.d.ts} +12 -0
- package/dist/genui-json-render.cjs +202 -370
- package/dist/genui-json-render.cjs.map +1 -1
- package/dist/genui-json-render.d.cts +1 -1
- package/dist/genui-json-render.d.ts +1 -1
- package/dist/genui-json-render.js +209 -373
- package/dist/genui-json-render.js.map +1 -1
- package/dist/genui.cjs +178 -320
- package/dist/genui.cjs.map +1 -1
- package/dist/genui.d.cts +2 -2
- package/dist/genui.d.ts +2 -2
- package/dist/genui.js +185 -323
- package/dist/genui.js.map +1 -1
- package/dist/index.cjs +2044 -2729
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -12
- package/dist/index.d.ts +123 -12
- package/dist/index.js +2067 -2737
- package/dist/index.js.map +1 -1
- package/dist/markdown.cjs +23 -36
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.js +23 -28
- package/dist/markdown.js.map +1 -1
- package/dist/media.cjs +46 -79
- package/dist/media.cjs.map +1 -1
- package/dist/media.d.cts +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/media.js +46 -81
- package/dist/media.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,49 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } from 'ai';
|
|
3
|
-
import { A as AgentBackend, U as UploadAttachmentOptions, H as HttpErrorListener,
|
|
4
|
-
export {
|
|
3
|
+
import { A as AgentRequestError, a as AgentBackend, U as UploadAttachmentOptions, H as HttpErrorListener, b as AttachmentUploadStrategy } from './client-DhHEJi7c.cjs';
|
|
4
|
+
export { c as AgentBackendUnsupportedError, d as AgentClient, e as AgentClientOptions, f as AgentConnection, g as AgentHttpError, C as CancelResult, h as ChatStreamRequest, i as ChatStreamResponse, M as MessageFeedbackInput, Q as QueuedMessageUpdate, j as QueuedSendResult, R as ResumeStreamRequest, T as ThreadPatch, r as requireBackendMethod } from './client-DhHEJi7c.cjs';
|
|
5
5
|
import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, QueuePause, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
export { ALL_AGENTS, ChatQueueState, ElicitationInput, ElicitationInputType, QueuePause, QueuePauseReason, QueuedMessageView, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import React__default, { ReactNode, Context } from 'react';
|
|
9
|
-
import { o as GenuiProviderValue, T as TranscriptUiBlock, A as ApproveOptions, t as TranscriptBlock, U as UsageSummary, v as TimestampInfo, C as ChatStatus, w as TranscriptFile, M as MessageUsageInfo, x as ToolCatalog, y as AnyToolUIPart } from './generative-ui-
|
|
10
|
-
export { z as ApprovalBlockOptions, B as BuildBlocksOptions, D as CoercibleQuestion, E as DescribeToolCallOptions, F as ElicitationBlockOptions, H as GroupToolActivityOptions, I as RawAnswer, J as ResolvedReading, K as ResolvedResultView, L as RetrievedPassage, S as SettleAction, N as ToolActivityGroup, O as ToolCallDescription, P as ToolCallState, Q as ToolCallStatus, V as TranscriptApproval, W as TranscriptApprovalStatus, X as TranscriptElicitationBlock, Y as TranscriptElicitationOutcome, Z as TranscriptFilesBlock, _ as TranscriptQuestion, $ as TranscriptQuestionOption, a0 as TranscriptReasoningBlock, a1 as TranscriptSettleState, a2 as TranscriptSource, a3 as TranscriptSourcesBlock, a4 as TranscriptTextBlock, a5 as TranscriptToolBlock, a6 as TranscriptToolCall, a7 as buildTranscriptBlocks, a8 as coerceAnswer, a9 as correctedCallIds, aa as describeTimestamp, ab as describeToolCall, ac as describeUsage, ad as extractMessageText, ae as fillTemplate, af as formatRelativeTime, ag as groupToolActivity, ah as inferResultView, ai as isActionCall, aj as phraseFor, ak as readPath, al as resolveResultView, am as toolCallState, an as toolCatalogFrom } from './generative-ui-
|
|
9
|
+
import { o as GenuiProviderValue, T as TranscriptUiBlock, A as ApproveOptions, t as TranscriptBlock, U as UsageSummary, v as TimestampInfo, C as ChatStatus, w as TranscriptFile, M as MessageUsageInfo, x as ToolCatalog, y as AnyToolUIPart } from './generative-ui-VTZ1EADD.cjs';
|
|
10
|
+
export { z as ApprovalBlockOptions, B as BuildBlocksOptions, D as CoercibleQuestion, E as DescribeToolCallOptions, F as ElicitationBlockOptions, H as GroupToolActivityOptions, I as RawAnswer, J as ResolvedReading, K as ResolvedResultView, L as RetrievedPassage, S as SettleAction, N as ToolActivityGroup, O as ToolCallDescription, P as ToolCallState, Q as ToolCallStatus, V as TranscriptApproval, W as TranscriptApprovalStatus, X as TranscriptElicitationBlock, Y as TranscriptElicitationOutcome, Z as TranscriptFilesBlock, _ as TranscriptQuestion, $ as TranscriptQuestionOption, a0 as TranscriptReasoningBlock, a1 as TranscriptSettleState, a2 as TranscriptSource, a3 as TranscriptSourcesBlock, a4 as TranscriptTextBlock, a5 as TranscriptToolBlock, a6 as TranscriptToolCall, a7 as buildTranscriptBlocks, a8 as coerceAnswer, a9 as correctedCallIds, aa as describeTimestamp, ab as describeToolCall, ac as describeUsage, ad as extractMessageText, ae as fillTemplate, af as formatRelativeTime, ag as groupToolActivity, ah as inferResultView, ai as isActionCall, aj as phraseFor, ak as readPath, al as resolveResultView, am as toolCallState, an as toolCatalogFrom } from './generative-ui-VTZ1EADD.cjs';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `code`s this library's own loop closes a failed run's stream with (`event: error`). A client
|
|
14
|
+
* branches on the code and words the failure itself — the frame's `message` is a sentence in
|
|
15
|
+
* English, and for a crash deliberately a generic one.
|
|
16
|
+
*
|
|
17
|
+
* - `quota_exceeded` — the actor's budget is spent; `message` says which.
|
|
18
|
+
* - `output_rejected` — an output processor refused the answer.
|
|
19
|
+
* - `structured_output_invalid` — the answer never satisfied the agent's output schema.
|
|
20
|
+
* - `replay_diverged` — the durable runtime refused to resume the run (its journal and the
|
|
21
|
+
* deployed code disagree). The turn is over; sending again starts a new one.
|
|
22
|
+
* - `model_no_output` — a model call ended without producing anything.
|
|
23
|
+
* - `run_failed` — anything else.
|
|
24
|
+
*
|
|
25
|
+
* A host's own runner may send codes of its own, which is why {@link AgentRunFailure.code} is a
|
|
26
|
+
* plain string.
|
|
27
|
+
*/
|
|
28
|
+
declare const AGENT_RUN_ERROR_CODES: readonly ["quota_exceeded", "output_rejected", "structured_output_invalid", "replay_diverged", "model_no_output", "run_failed"];
|
|
29
|
+
type AgentRunErrorCode = (typeof AGENT_RUN_ERROR_CODES)[number];
|
|
30
|
+
/** How a run's stream said it failed: the `event: error` frame, read. */
|
|
31
|
+
interface AgentRunFailure {
|
|
32
|
+
/** The frame's machine-readable `code`; `undefined` when the server sent none. */
|
|
33
|
+
code: AgentRunErrorCode | (string & {}) | undefined;
|
|
34
|
+
/** The frame's `message` — the server's words, safe to show but not translated. */
|
|
35
|
+
message: string;
|
|
36
|
+
/** The run that failed, when the stream had named it. */
|
|
37
|
+
runId?: string;
|
|
38
|
+
}
|
|
39
|
+
/** The `code` a decision is refused with when the run it was for has ended (`409`). */
|
|
40
|
+
declare const RUN_NOT_ACTIVE_CODE = "run_not_active";
|
|
41
|
+
/**
|
|
42
|
+
* Whether `error` is the server refusing an approve / reject / answer / skip because the turn that
|
|
43
|
+
* asked is over (`409 { code: 'run_not_active' }`): nothing is waiting for the decision, and nothing
|
|
44
|
+
* will run. The card it was made on is stale — say so, and let the person send the message again.
|
|
45
|
+
*/
|
|
46
|
+
declare function isRunNotActiveError(error: unknown): error is AgentRequestError;
|
|
11
47
|
|
|
12
48
|
/** Identity surfaced by the backend's `meta` SSE frame / response headers. */
|
|
13
49
|
interface AgentStreamMeta {
|
|
@@ -100,6 +136,12 @@ interface AgentChatTransportOptions {
|
|
|
100
136
|
* what the run wrote — `useAgentChat` re-reads the thread.
|
|
101
137
|
*/
|
|
102
138
|
onResumeGone?: (runId: string) => void;
|
|
139
|
+
/**
|
|
140
|
+
* The run's stream ended with the backend's `event: error` frame — called with its `code` and
|
|
141
|
+
* `message` right before the stream is closed with an error chunk. The chunk can only carry the
|
|
142
|
+
* text; this is where the `code` reaches a caller, so it can word the failure itself.
|
|
143
|
+
*/
|
|
144
|
+
onRunError?: (failure: AgentRunFailure) => void;
|
|
103
145
|
/** Injectable for tests / non-browser runtimes. Defaults to global fetch. */
|
|
104
146
|
fetch?: typeof fetch;
|
|
105
147
|
}
|
|
@@ -195,6 +237,11 @@ interface MessageFile {
|
|
|
195
237
|
}
|
|
196
238
|
/** The {@link MessageFileKind} of a MIME type. */
|
|
197
239
|
declare function fileKind(mediaType: string): MessageFileKind;
|
|
240
|
+
/**
|
|
241
|
+
* An uploaded attachment as the {@link MessageFile} it is once its message is sent — so a message
|
|
242
|
+
* still waiting (in the queue, in the composer) draws its files with the same code a sent one does.
|
|
243
|
+
*/
|
|
244
|
+
declare function attachmentFile(attachment: MessageAttachment): MessageFile;
|
|
198
245
|
/**
|
|
199
246
|
* The files on a message — the user's attachments (live, or replayed from `StoredMessage.attachments`
|
|
200
247
|
* by `storedMessageToUiMessage`) and any the model produced — in part order. Data only: pair it with
|
|
@@ -660,12 +707,27 @@ declare function ChatInput({ onSubmit, disabled, placeholder, rows, enableSpeech
|
|
|
660
707
|
* - `'block'` — the composer refuses it (`blockedBy: 'busy'`), as before queues existed.
|
|
661
708
|
*/
|
|
662
709
|
type WhileRunning = 'queue' | 'interrupt' | 'block';
|
|
710
|
+
/**
|
|
711
|
+
* A per-call answer to "a turn is still running" — `composer.submit({ mode })`,
|
|
712
|
+
* `sendMessage(message, { mode })`. It overrides the chat's `whileRunning` for that one send
|
|
713
|
+
* (including `'block'`), and means nothing when no turn is running: the message is simply sent.
|
|
714
|
+
*/
|
|
715
|
+
interface SendWhileRunning {
|
|
716
|
+
/** `'queue'` — wait for the running turn. `'interrupt'` — cancel it and run this next. */
|
|
717
|
+
mode?: 'queue' | 'interrupt';
|
|
718
|
+
}
|
|
663
719
|
/** A message waiting in the thread's queue, as the chat shows it. */
|
|
664
720
|
interface QueuedChatMessage {
|
|
665
721
|
/** The server's id once it is queued; a local id while `state` is `'sending'`. */
|
|
666
722
|
id: string;
|
|
667
723
|
text: string;
|
|
724
|
+
/** The uploaded attachments as they were queued — what a re-send carries. */
|
|
668
725
|
attachments: MessageAttachment[];
|
|
726
|
+
/**
|
|
727
|
+
* The same attachments as {@link MessageFile}s — the shape `messageFiles()` gives for a sent
|
|
728
|
+
* message, so one renderer draws the files of a waiting message and of a sent one.
|
|
729
|
+
*/
|
|
730
|
+
files: MessageFile[];
|
|
669
731
|
/**
|
|
670
732
|
* `'sending'` — on its way to the server (it has no server id yet, so it cannot be edited).
|
|
671
733
|
* `'queued'` — waiting its turn.
|
|
@@ -692,6 +754,13 @@ interface ChatQueue {
|
|
|
692
754
|
mode?: 'queue' | 'interrupt';
|
|
693
755
|
}) => Promise<void>;
|
|
694
756
|
remove: (id: string) => Promise<void>;
|
|
757
|
+
/**
|
|
758
|
+
* Run a waiting message now: it moves to the head as an interrupt and the running turn is
|
|
759
|
+
* cancelled for it (with nothing running, it starts at once). One server call — the message keeps
|
|
760
|
+
* its id and never leaves the queue, unlike a `remove` followed by an `add`. Needs a backend with
|
|
761
|
+
* `interruptQueuedMessage`.
|
|
762
|
+
*/
|
|
763
|
+
interrupt: (id: string) => Promise<void>;
|
|
695
764
|
edit: (id: string, text: string) => Promise<void>;
|
|
696
765
|
/** Move a waiting message to `index` (0 → next). */
|
|
697
766
|
move: (id: string, index: number) => Promise<void>;
|
|
@@ -902,11 +971,16 @@ interface UseChatTranscriptOptions extends TranscriptItemOptions {
|
|
|
902
971
|
* after the transcript as {@link ChatTranscript.queued}: pending user messages, not yet sent.
|
|
903
972
|
*/
|
|
904
973
|
queue?: {
|
|
905
|
-
|
|
974
|
+
/** `files` may be left out by a host that builds these itself: it is derived from `attachments`. */
|
|
975
|
+
items: Array<Omit<QueuedChatMessage, 'files'> & {
|
|
976
|
+
files?: MessageFile[];
|
|
977
|
+
}>;
|
|
906
978
|
paused: QueuePause | null;
|
|
907
979
|
remove?: (id: string) => void | Promise<void>;
|
|
908
980
|
} | null;
|
|
909
981
|
}
|
|
982
|
+
/** One file on a waiting message: a sent message's {@link MessageFile}, and a `TranscriptFile`. */
|
|
983
|
+
type TranscriptQueuedFile = MessageFile & TranscriptFile;
|
|
910
984
|
/**
|
|
911
985
|
* A message waiting in the thread's queue, as the transcript shows it: a user message that has not
|
|
912
986
|
* been sent to the model yet. Render it after {@link ChatTranscript.items}, dimmed or tagged.
|
|
@@ -915,7 +989,12 @@ interface TranscriptQueuedItem {
|
|
|
915
989
|
id: string;
|
|
916
990
|
role: 'user';
|
|
917
991
|
text: string;
|
|
918
|
-
|
|
992
|
+
/**
|
|
993
|
+
* The message's files, in the shape a sent message's have: a {@link MessageFile} (what
|
|
994
|
+
* `messageFiles()` gives — `kind`, `extension`, `mediaId`) that is also a `TranscriptFile`
|
|
995
|
+
* (`isImage`), so either renderer takes it as it is.
|
|
996
|
+
*/
|
|
997
|
+
files: TranscriptQueuedFile[];
|
|
919
998
|
/**
|
|
920
999
|
* `'sending'` — on its way to the server. `'queued'` — waiting for the running turn.
|
|
921
1000
|
* `'paused'` — waiting, but the queue is paused (see {@link ChatTranscript.queuePaused}).
|
|
@@ -1592,7 +1671,8 @@ interface UseAgentChatOptions<B extends AgentBackend = AgentBackend> {
|
|
|
1592
1671
|
* the message waits in the thread's queue (server-side — it survives a reload) and runs when the
|
|
1593
1672
|
* turn settles; `chat.queue` lists and edits what is waiting. `'interrupt'` cancels the running
|
|
1594
1673
|
* turn and runs the message next. `'block'` refuses the send (`composer.blockedBy === 'busy'`).
|
|
1595
|
-
* A backend without `enqueueMessage` behaves as `'block'`.
|
|
1674
|
+
* A backend without `enqueueMessage` behaves as `'block'`. One send can answer differently:
|
|
1675
|
+
* `composer.submit({ mode })`, `sendMessage(message, { mode })`.
|
|
1596
1676
|
*/
|
|
1597
1677
|
whileRunning?: WhileRunning;
|
|
1598
1678
|
/**
|
|
@@ -1704,8 +1784,14 @@ interface ChatComposer {
|
|
|
1704
1784
|
canSend: boolean;
|
|
1705
1785
|
/** Why `canSend` is false, or `null`. */
|
|
1706
1786
|
blockedBy: ComposerBlock | null;
|
|
1707
|
-
/**
|
|
1708
|
-
|
|
1787
|
+
/**
|
|
1788
|
+
* Send the draft with the ready files attached, then clear both. A no-op while blocked.
|
|
1789
|
+
*
|
|
1790
|
+
* `submit({ mode })` says what to do if a turn is running, for this send only — `'interrupt'`
|
|
1791
|
+
* for a "send now" button next to a plain send that queues. It overrides `whileRunning`
|
|
1792
|
+
* (`'block'` included) and clears the draft like any other submit.
|
|
1793
|
+
*/
|
|
1794
|
+
submit: (options?: SendWhileRunning) => Promise<void>;
|
|
1709
1795
|
}
|
|
1710
1796
|
interface AddToolResultArgs {
|
|
1711
1797
|
tool: string;
|
|
@@ -1723,7 +1809,25 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
|
|
|
1723
1809
|
status: ChatStatus;
|
|
1724
1810
|
/** Where the live stream stands — see {@link StreamConnectionState}. */
|
|
1725
1811
|
connection: StreamConnectionState;
|
|
1726
|
-
sendMessage: (message?: (Omit<UIMessage<unknown, UIDataTypes, ai.UITools>, "id" | "role"> & {
|
|
1812
|
+
sendMessage: (message?: Parameters<(message?: (Omit<UIMessage<unknown, UIDataTypes, ai.UITools>, "id" | "role"> & {
|
|
1813
|
+
id?: string;
|
|
1814
|
+
role?: "user" | "assistant" | "system";
|
|
1815
|
+
} & {
|
|
1816
|
+
text?: never;
|
|
1817
|
+
files?: never;
|
|
1818
|
+
messageId?: string;
|
|
1819
|
+
}) | {
|
|
1820
|
+
text: string;
|
|
1821
|
+
files?: FileList | ai.FileUIPart[];
|
|
1822
|
+
metadata?: unknown;
|
|
1823
|
+
parts?: never;
|
|
1824
|
+
messageId?: string;
|
|
1825
|
+
} | {
|
|
1826
|
+
files: FileList | ai.FileUIPart[];
|
|
1827
|
+
metadata?: unknown;
|
|
1828
|
+
parts?: never;
|
|
1829
|
+
messageId?: string;
|
|
1830
|
+
} | undefined, options?: ai.ChatRequestOptions) => Promise<void>>[0], options?: Parameters<(message?: (Omit<UIMessage<unknown, UIDataTypes, ai.UITools>, "id" | "role"> & {
|
|
1727
1831
|
id?: string;
|
|
1728
1832
|
role?: "user" | "assistant" | "system";
|
|
1729
1833
|
} & {
|
|
@@ -1741,7 +1845,7 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
|
|
|
1741
1845
|
metadata?: unknown;
|
|
1742
1846
|
parts?: never;
|
|
1743
1847
|
messageId?: string;
|
|
1744
|
-
} | undefined, options?: ai.ChatRequestOptions) => Promise<void>;
|
|
1848
|
+
} | undefined, options?: ai.ChatRequestOptions) => Promise<void>>[1] & SendWhileRunning) => Promise<void>;
|
|
1745
1849
|
addToolResult: ({ tool, toolCallId, output }: AddToolResultArgs) => void | PromiseLike<void>;
|
|
1746
1850
|
/** Sub-agents this conversation started and did not wait for. */
|
|
1747
1851
|
background: ChatBackground;
|
|
@@ -1752,6 +1856,13 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
|
|
|
1752
1856
|
isLoadingHistory: boolean;
|
|
1753
1857
|
/** Reading the thread's history failed. */
|
|
1754
1858
|
historyError: Error | null;
|
|
1859
|
+
/**
|
|
1860
|
+
* How the last run's stream said it failed — the `event: error` frame's `code` and `message` —
|
|
1861
|
+
* or `null`. Cleared when the next attempt starts and when the chat moves to another thread.
|
|
1862
|
+
* `chat.error` still carries the message; this is where the `code` is, so the app can word each
|
|
1863
|
+
* failure itself (`replay_diverged`, `model_no_output`, `run_failed`, `quota_exceeded`, …).
|
|
1864
|
+
*/
|
|
1865
|
+
runError: AgentRunFailure | null;
|
|
1755
1866
|
/**
|
|
1756
1867
|
* The thread this chat is on right now: the `threadId` option, else the one the backend created
|
|
1757
1868
|
* on the first send. A getter, because the created id is learned mid-stream.
|
|
@@ -1805,4 +1916,4 @@ declare class QuotaBlockedError extends Error {
|
|
|
1805
1916
|
constructor(block: QuotaBlock);
|
|
1806
1917
|
}
|
|
1807
1918
|
|
|
1808
|
-
export { AgentBackend, AgentChatTransport, type AgentChatTransportOptions, type AgentConfigState, type AgentMessageMetadata, AgentProvider, type AgentProviderProps, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, type AmbientRenderUi, AmbientRenderUiContext, type AnswerInput, AnyToolUIPart, type ApprovalCountdown, type ApproveInput, ApproveOptions, type AttachmentRejection, AttachmentUploadStrategy, type AttachmentsState, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type ChatBackground, ChatInput, type ChatInputProps, type ChatQueue, ChatStatus, type ChatTranscript, type ClipboardLikeEvent, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type DragLikeEvent, type EditSubmitInput, HttpErrorListener, type MessageActionInput, type MessageFeedbackState, type MessageFile, type MessageFileKind, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type ModelOption, type ModelsState, type QueuedChatMessage, QuotaBlockedError, type QuotaState, type ReconnectOptions, type RejectInput, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SkipInput, type SpeechLanguage, type SpeechRecognitionHook, type StagedAttachment, type StagedAttachmentStatus, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadsEvent, type ThreadsState, TimestampInfo, ToolCatalog, type ToolCatalogState, type TranscriptActionState, TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, TranscriptFile, type TranscriptItem, type TranscriptItemOptions, type TranscriptQueuedItem, type TranscriptStopState, TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseAgentConfigOptions, type UseAgentsOptions, type UseApprovalCountdownOptions, type UseAttachmentsOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseModelsOptions, type UseQuotaOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, type WhileRunning, acceptsFile, applyCompletion, approvalCountdown, backgroundRunsFromThread, createSkillsSource, dragHasFiles, fileKind, filesFromClipboard, filterAutocompleteItems, findActiveTrigger, formatElapsed, loadStoredSpeechLang, messageFiles, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, storedMessageToUiMessage, storedThreadToUiMessages, useAgentBackend, useAgentChat, useAgentConfig, useAgents, useAmbientRenderUi, useApprovalCountdown, useAttachments, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|
|
1919
|
+
export { AGENT_RUN_ERROR_CODES, AgentBackend, AgentChatTransport, type AgentChatTransportOptions, type AgentConfigState, type AgentMessageMetadata, AgentProvider, type AgentProviderProps, AgentRequestError, type AgentRunErrorCode, type AgentRunFailure, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, type AmbientRenderUi, AmbientRenderUiContext, type AnswerInput, AnyToolUIPart, type ApprovalCountdown, type ApproveInput, ApproveOptions, type AttachmentRejection, AttachmentUploadStrategy, type AttachmentsState, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type ChatBackground, ChatInput, type ChatInputProps, type ChatQueue, ChatStatus, type ChatTranscript, type ClipboardLikeEvent, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type DragLikeEvent, type EditSubmitInput, HttpErrorListener, type MessageActionInput, type MessageFeedbackState, type MessageFile, type MessageFileKind, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type ModelOption, type ModelsState, type QueuedChatMessage, QuotaBlockedError, type QuotaState, RUN_NOT_ACTIVE_CODE, type ReconnectOptions, type RejectInput, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, SPEECH_LANGUAGES, type SendWhileRunning, type SkillSuggestionData, type SkillsSourceOptions, type SkipInput, type SpeechLanguage, type SpeechRecognitionHook, type StagedAttachment, type StagedAttachmentStatus, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadsEvent, type ThreadsState, TimestampInfo, ToolCatalog, type ToolCatalogState, type TranscriptActionState, TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, TranscriptFile, type TranscriptItem, type TranscriptItemOptions, type TranscriptQueuedFile, type TranscriptQueuedItem, type TranscriptStopState, TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseAgentConfigOptions, type UseAgentsOptions, type UseApprovalCountdownOptions, type UseAttachmentsOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseModelsOptions, type UseQuotaOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, type WhileRunning, acceptsFile, applyCompletion, approvalCountdown, attachmentFile, backgroundRunsFromThread, createSkillsSource, dragHasFiles, fileKind, filesFromClipboard, filterAutocompleteItems, findActiveTrigger, formatElapsed, isRunNotActiveError, loadStoredSpeechLang, messageFiles, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, storedMessageToUiMessage, storedThreadToUiMessages, useAgentBackend, useAgentChat, useAgentConfig, useAgents, useAmbientRenderUi, useApprovalCountdown, useAttachments, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,49 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } from 'ai';
|
|
3
|
-
import { A as AgentBackend, U as UploadAttachmentOptions, H as HttpErrorListener,
|
|
4
|
-
export {
|
|
3
|
+
import { A as AgentRequestError, a as AgentBackend, U as UploadAttachmentOptions, H as HttpErrorListener, b as AttachmentUploadStrategy } from './client-DhHEJi7c.js';
|
|
4
|
+
export { c as AgentBackendUnsupportedError, d as AgentClient, e as AgentClientOptions, f as AgentConnection, g as AgentHttpError, C as CancelResult, h as ChatStreamRequest, i as ChatStreamResponse, M as MessageFeedbackInput, Q as QueuedMessageUpdate, j as QueuedSendResult, R as ResumeStreamRequest, T as ThreadPatch, r as requireBackendMethod } from './client-DhHEJi7c.js';
|
|
5
5
|
import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, QueuePause, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
export { ALL_AGENTS, ChatQueueState, ElicitationInput, ElicitationInputType, QueuePause, QueuePauseReason, QueuedMessageView, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import React__default, { ReactNode, Context } from 'react';
|
|
9
|
-
import { o as GenuiProviderValue, T as TranscriptUiBlock, A as ApproveOptions, t as TranscriptBlock, U as UsageSummary, v as TimestampInfo, C as ChatStatus, w as TranscriptFile, M as MessageUsageInfo, x as ToolCatalog, y as AnyToolUIPart } from './generative-ui-
|
|
10
|
-
export { z as ApprovalBlockOptions, B as BuildBlocksOptions, D as CoercibleQuestion, E as DescribeToolCallOptions, F as ElicitationBlockOptions, H as GroupToolActivityOptions, I as RawAnswer, J as ResolvedReading, K as ResolvedResultView, L as RetrievedPassage, S as SettleAction, N as ToolActivityGroup, O as ToolCallDescription, P as ToolCallState, Q as ToolCallStatus, V as TranscriptApproval, W as TranscriptApprovalStatus, X as TranscriptElicitationBlock, Y as TranscriptElicitationOutcome, Z as TranscriptFilesBlock, _ as TranscriptQuestion, $ as TranscriptQuestionOption, a0 as TranscriptReasoningBlock, a1 as TranscriptSettleState, a2 as TranscriptSource, a3 as TranscriptSourcesBlock, a4 as TranscriptTextBlock, a5 as TranscriptToolBlock, a6 as TranscriptToolCall, a7 as buildTranscriptBlocks, a8 as coerceAnswer, a9 as correctedCallIds, aa as describeTimestamp, ab as describeToolCall, ac as describeUsage, ad as extractMessageText, ae as fillTemplate, af as formatRelativeTime, ag as groupToolActivity, ah as inferResultView, ai as isActionCall, aj as phraseFor, ak as readPath, al as resolveResultView, am as toolCallState, an as toolCatalogFrom } from './generative-ui-
|
|
9
|
+
import { o as GenuiProviderValue, T as TranscriptUiBlock, A as ApproveOptions, t as TranscriptBlock, U as UsageSummary, v as TimestampInfo, C as ChatStatus, w as TranscriptFile, M as MessageUsageInfo, x as ToolCatalog, y as AnyToolUIPart } from './generative-ui-VTZ1EADD.js';
|
|
10
|
+
export { z as ApprovalBlockOptions, B as BuildBlocksOptions, D as CoercibleQuestion, E as DescribeToolCallOptions, F as ElicitationBlockOptions, H as GroupToolActivityOptions, I as RawAnswer, J as ResolvedReading, K as ResolvedResultView, L as RetrievedPassage, S as SettleAction, N as ToolActivityGroup, O as ToolCallDescription, P as ToolCallState, Q as ToolCallStatus, V as TranscriptApproval, W as TranscriptApprovalStatus, X as TranscriptElicitationBlock, Y as TranscriptElicitationOutcome, Z as TranscriptFilesBlock, _ as TranscriptQuestion, $ as TranscriptQuestionOption, a0 as TranscriptReasoningBlock, a1 as TranscriptSettleState, a2 as TranscriptSource, a3 as TranscriptSourcesBlock, a4 as TranscriptTextBlock, a5 as TranscriptToolBlock, a6 as TranscriptToolCall, a7 as buildTranscriptBlocks, a8 as coerceAnswer, a9 as correctedCallIds, aa as describeTimestamp, ab as describeToolCall, ac as describeUsage, ad as extractMessageText, ae as fillTemplate, af as formatRelativeTime, ag as groupToolActivity, ah as inferResultView, ai as isActionCall, aj as phraseFor, ak as readPath, al as resolveResultView, am as toolCallState, an as toolCatalogFrom } from './generative-ui-VTZ1EADD.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `code`s this library's own loop closes a failed run's stream with (`event: error`). A client
|
|
14
|
+
* branches on the code and words the failure itself — the frame's `message` is a sentence in
|
|
15
|
+
* English, and for a crash deliberately a generic one.
|
|
16
|
+
*
|
|
17
|
+
* - `quota_exceeded` — the actor's budget is spent; `message` says which.
|
|
18
|
+
* - `output_rejected` — an output processor refused the answer.
|
|
19
|
+
* - `structured_output_invalid` — the answer never satisfied the agent's output schema.
|
|
20
|
+
* - `replay_diverged` — the durable runtime refused to resume the run (its journal and the
|
|
21
|
+
* deployed code disagree). The turn is over; sending again starts a new one.
|
|
22
|
+
* - `model_no_output` — a model call ended without producing anything.
|
|
23
|
+
* - `run_failed` — anything else.
|
|
24
|
+
*
|
|
25
|
+
* A host's own runner may send codes of its own, which is why {@link AgentRunFailure.code} is a
|
|
26
|
+
* plain string.
|
|
27
|
+
*/
|
|
28
|
+
declare const AGENT_RUN_ERROR_CODES: readonly ["quota_exceeded", "output_rejected", "structured_output_invalid", "replay_diverged", "model_no_output", "run_failed"];
|
|
29
|
+
type AgentRunErrorCode = (typeof AGENT_RUN_ERROR_CODES)[number];
|
|
30
|
+
/** How a run's stream said it failed: the `event: error` frame, read. */
|
|
31
|
+
interface AgentRunFailure {
|
|
32
|
+
/** The frame's machine-readable `code`; `undefined` when the server sent none. */
|
|
33
|
+
code: AgentRunErrorCode | (string & {}) | undefined;
|
|
34
|
+
/** The frame's `message` — the server's words, safe to show but not translated. */
|
|
35
|
+
message: string;
|
|
36
|
+
/** The run that failed, when the stream had named it. */
|
|
37
|
+
runId?: string;
|
|
38
|
+
}
|
|
39
|
+
/** The `code` a decision is refused with when the run it was for has ended (`409`). */
|
|
40
|
+
declare const RUN_NOT_ACTIVE_CODE = "run_not_active";
|
|
41
|
+
/**
|
|
42
|
+
* Whether `error` is the server refusing an approve / reject / answer / skip because the turn that
|
|
43
|
+
* asked is over (`409 { code: 'run_not_active' }`): nothing is waiting for the decision, and nothing
|
|
44
|
+
* will run. The card it was made on is stale — say so, and let the person send the message again.
|
|
45
|
+
*/
|
|
46
|
+
declare function isRunNotActiveError(error: unknown): error is AgentRequestError;
|
|
11
47
|
|
|
12
48
|
/** Identity surfaced by the backend's `meta` SSE frame / response headers. */
|
|
13
49
|
interface AgentStreamMeta {
|
|
@@ -100,6 +136,12 @@ interface AgentChatTransportOptions {
|
|
|
100
136
|
* what the run wrote — `useAgentChat` re-reads the thread.
|
|
101
137
|
*/
|
|
102
138
|
onResumeGone?: (runId: string) => void;
|
|
139
|
+
/**
|
|
140
|
+
* The run's stream ended with the backend's `event: error` frame — called with its `code` and
|
|
141
|
+
* `message` right before the stream is closed with an error chunk. The chunk can only carry the
|
|
142
|
+
* text; this is where the `code` reaches a caller, so it can word the failure itself.
|
|
143
|
+
*/
|
|
144
|
+
onRunError?: (failure: AgentRunFailure) => void;
|
|
103
145
|
/** Injectable for tests / non-browser runtimes. Defaults to global fetch. */
|
|
104
146
|
fetch?: typeof fetch;
|
|
105
147
|
}
|
|
@@ -195,6 +237,11 @@ interface MessageFile {
|
|
|
195
237
|
}
|
|
196
238
|
/** The {@link MessageFileKind} of a MIME type. */
|
|
197
239
|
declare function fileKind(mediaType: string): MessageFileKind;
|
|
240
|
+
/**
|
|
241
|
+
* An uploaded attachment as the {@link MessageFile} it is once its message is sent — so a message
|
|
242
|
+
* still waiting (in the queue, in the composer) draws its files with the same code a sent one does.
|
|
243
|
+
*/
|
|
244
|
+
declare function attachmentFile(attachment: MessageAttachment): MessageFile;
|
|
198
245
|
/**
|
|
199
246
|
* The files on a message — the user's attachments (live, or replayed from `StoredMessage.attachments`
|
|
200
247
|
* by `storedMessageToUiMessage`) and any the model produced — in part order. Data only: pair it with
|
|
@@ -660,12 +707,27 @@ declare function ChatInput({ onSubmit, disabled, placeholder, rows, enableSpeech
|
|
|
660
707
|
* - `'block'` — the composer refuses it (`blockedBy: 'busy'`), as before queues existed.
|
|
661
708
|
*/
|
|
662
709
|
type WhileRunning = 'queue' | 'interrupt' | 'block';
|
|
710
|
+
/**
|
|
711
|
+
* A per-call answer to "a turn is still running" — `composer.submit({ mode })`,
|
|
712
|
+
* `sendMessage(message, { mode })`. It overrides the chat's `whileRunning` for that one send
|
|
713
|
+
* (including `'block'`), and means nothing when no turn is running: the message is simply sent.
|
|
714
|
+
*/
|
|
715
|
+
interface SendWhileRunning {
|
|
716
|
+
/** `'queue'` — wait for the running turn. `'interrupt'` — cancel it and run this next. */
|
|
717
|
+
mode?: 'queue' | 'interrupt';
|
|
718
|
+
}
|
|
663
719
|
/** A message waiting in the thread's queue, as the chat shows it. */
|
|
664
720
|
interface QueuedChatMessage {
|
|
665
721
|
/** The server's id once it is queued; a local id while `state` is `'sending'`. */
|
|
666
722
|
id: string;
|
|
667
723
|
text: string;
|
|
724
|
+
/** The uploaded attachments as they were queued — what a re-send carries. */
|
|
668
725
|
attachments: MessageAttachment[];
|
|
726
|
+
/**
|
|
727
|
+
* The same attachments as {@link MessageFile}s — the shape `messageFiles()` gives for a sent
|
|
728
|
+
* message, so one renderer draws the files of a waiting message and of a sent one.
|
|
729
|
+
*/
|
|
730
|
+
files: MessageFile[];
|
|
669
731
|
/**
|
|
670
732
|
* `'sending'` — on its way to the server (it has no server id yet, so it cannot be edited).
|
|
671
733
|
* `'queued'` — waiting its turn.
|
|
@@ -692,6 +754,13 @@ interface ChatQueue {
|
|
|
692
754
|
mode?: 'queue' | 'interrupt';
|
|
693
755
|
}) => Promise<void>;
|
|
694
756
|
remove: (id: string) => Promise<void>;
|
|
757
|
+
/**
|
|
758
|
+
* Run a waiting message now: it moves to the head as an interrupt and the running turn is
|
|
759
|
+
* cancelled for it (with nothing running, it starts at once). One server call — the message keeps
|
|
760
|
+
* its id and never leaves the queue, unlike a `remove` followed by an `add`. Needs a backend with
|
|
761
|
+
* `interruptQueuedMessage`.
|
|
762
|
+
*/
|
|
763
|
+
interrupt: (id: string) => Promise<void>;
|
|
695
764
|
edit: (id: string, text: string) => Promise<void>;
|
|
696
765
|
/** Move a waiting message to `index` (0 → next). */
|
|
697
766
|
move: (id: string, index: number) => Promise<void>;
|
|
@@ -902,11 +971,16 @@ interface UseChatTranscriptOptions extends TranscriptItemOptions {
|
|
|
902
971
|
* after the transcript as {@link ChatTranscript.queued}: pending user messages, not yet sent.
|
|
903
972
|
*/
|
|
904
973
|
queue?: {
|
|
905
|
-
|
|
974
|
+
/** `files` may be left out by a host that builds these itself: it is derived from `attachments`. */
|
|
975
|
+
items: Array<Omit<QueuedChatMessage, 'files'> & {
|
|
976
|
+
files?: MessageFile[];
|
|
977
|
+
}>;
|
|
906
978
|
paused: QueuePause | null;
|
|
907
979
|
remove?: (id: string) => void | Promise<void>;
|
|
908
980
|
} | null;
|
|
909
981
|
}
|
|
982
|
+
/** One file on a waiting message: a sent message's {@link MessageFile}, and a `TranscriptFile`. */
|
|
983
|
+
type TranscriptQueuedFile = MessageFile & TranscriptFile;
|
|
910
984
|
/**
|
|
911
985
|
* A message waiting in the thread's queue, as the transcript shows it: a user message that has not
|
|
912
986
|
* been sent to the model yet. Render it after {@link ChatTranscript.items}, dimmed or tagged.
|
|
@@ -915,7 +989,12 @@ interface TranscriptQueuedItem {
|
|
|
915
989
|
id: string;
|
|
916
990
|
role: 'user';
|
|
917
991
|
text: string;
|
|
918
|
-
|
|
992
|
+
/**
|
|
993
|
+
* The message's files, in the shape a sent message's have: a {@link MessageFile} (what
|
|
994
|
+
* `messageFiles()` gives — `kind`, `extension`, `mediaId`) that is also a `TranscriptFile`
|
|
995
|
+
* (`isImage`), so either renderer takes it as it is.
|
|
996
|
+
*/
|
|
997
|
+
files: TranscriptQueuedFile[];
|
|
919
998
|
/**
|
|
920
999
|
* `'sending'` — on its way to the server. `'queued'` — waiting for the running turn.
|
|
921
1000
|
* `'paused'` — waiting, but the queue is paused (see {@link ChatTranscript.queuePaused}).
|
|
@@ -1592,7 +1671,8 @@ interface UseAgentChatOptions<B extends AgentBackend = AgentBackend> {
|
|
|
1592
1671
|
* the message waits in the thread's queue (server-side — it survives a reload) and runs when the
|
|
1593
1672
|
* turn settles; `chat.queue` lists and edits what is waiting. `'interrupt'` cancels the running
|
|
1594
1673
|
* turn and runs the message next. `'block'` refuses the send (`composer.blockedBy === 'busy'`).
|
|
1595
|
-
* A backend without `enqueueMessage` behaves as `'block'`.
|
|
1674
|
+
* A backend without `enqueueMessage` behaves as `'block'`. One send can answer differently:
|
|
1675
|
+
* `composer.submit({ mode })`, `sendMessage(message, { mode })`.
|
|
1596
1676
|
*/
|
|
1597
1677
|
whileRunning?: WhileRunning;
|
|
1598
1678
|
/**
|
|
@@ -1704,8 +1784,14 @@ interface ChatComposer {
|
|
|
1704
1784
|
canSend: boolean;
|
|
1705
1785
|
/** Why `canSend` is false, or `null`. */
|
|
1706
1786
|
blockedBy: ComposerBlock | null;
|
|
1707
|
-
/**
|
|
1708
|
-
|
|
1787
|
+
/**
|
|
1788
|
+
* Send the draft with the ready files attached, then clear both. A no-op while blocked.
|
|
1789
|
+
*
|
|
1790
|
+
* `submit({ mode })` says what to do if a turn is running, for this send only — `'interrupt'`
|
|
1791
|
+
* for a "send now" button next to a plain send that queues. It overrides `whileRunning`
|
|
1792
|
+
* (`'block'` included) and clears the draft like any other submit.
|
|
1793
|
+
*/
|
|
1794
|
+
submit: (options?: SendWhileRunning) => Promise<void>;
|
|
1709
1795
|
}
|
|
1710
1796
|
interface AddToolResultArgs {
|
|
1711
1797
|
tool: string;
|
|
@@ -1723,7 +1809,25 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
|
|
|
1723
1809
|
status: ChatStatus;
|
|
1724
1810
|
/** Where the live stream stands — see {@link StreamConnectionState}. */
|
|
1725
1811
|
connection: StreamConnectionState;
|
|
1726
|
-
sendMessage: (message?: (Omit<UIMessage<unknown, UIDataTypes, ai.UITools>, "id" | "role"> & {
|
|
1812
|
+
sendMessage: (message?: Parameters<(message?: (Omit<UIMessage<unknown, UIDataTypes, ai.UITools>, "id" | "role"> & {
|
|
1813
|
+
id?: string;
|
|
1814
|
+
role?: "user" | "assistant" | "system";
|
|
1815
|
+
} & {
|
|
1816
|
+
text?: never;
|
|
1817
|
+
files?: never;
|
|
1818
|
+
messageId?: string;
|
|
1819
|
+
}) | {
|
|
1820
|
+
text: string;
|
|
1821
|
+
files?: FileList | ai.FileUIPart[];
|
|
1822
|
+
metadata?: unknown;
|
|
1823
|
+
parts?: never;
|
|
1824
|
+
messageId?: string;
|
|
1825
|
+
} | {
|
|
1826
|
+
files: FileList | ai.FileUIPart[];
|
|
1827
|
+
metadata?: unknown;
|
|
1828
|
+
parts?: never;
|
|
1829
|
+
messageId?: string;
|
|
1830
|
+
} | undefined, options?: ai.ChatRequestOptions) => Promise<void>>[0], options?: Parameters<(message?: (Omit<UIMessage<unknown, UIDataTypes, ai.UITools>, "id" | "role"> & {
|
|
1727
1831
|
id?: string;
|
|
1728
1832
|
role?: "user" | "assistant" | "system";
|
|
1729
1833
|
} & {
|
|
@@ -1741,7 +1845,7 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
|
|
|
1741
1845
|
metadata?: unknown;
|
|
1742
1846
|
parts?: never;
|
|
1743
1847
|
messageId?: string;
|
|
1744
|
-
} | undefined, options?: ai.ChatRequestOptions) => Promise<void>;
|
|
1848
|
+
} | undefined, options?: ai.ChatRequestOptions) => Promise<void>>[1] & SendWhileRunning) => Promise<void>;
|
|
1745
1849
|
addToolResult: ({ tool, toolCallId, output }: AddToolResultArgs) => void | PromiseLike<void>;
|
|
1746
1850
|
/** Sub-agents this conversation started and did not wait for. */
|
|
1747
1851
|
background: ChatBackground;
|
|
@@ -1752,6 +1856,13 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
|
|
|
1752
1856
|
isLoadingHistory: boolean;
|
|
1753
1857
|
/** Reading the thread's history failed. */
|
|
1754
1858
|
historyError: Error | null;
|
|
1859
|
+
/**
|
|
1860
|
+
* How the last run's stream said it failed — the `event: error` frame's `code` and `message` —
|
|
1861
|
+
* or `null`. Cleared when the next attempt starts and when the chat moves to another thread.
|
|
1862
|
+
* `chat.error` still carries the message; this is where the `code` is, so the app can word each
|
|
1863
|
+
* failure itself (`replay_diverged`, `model_no_output`, `run_failed`, `quota_exceeded`, …).
|
|
1864
|
+
*/
|
|
1865
|
+
runError: AgentRunFailure | null;
|
|
1755
1866
|
/**
|
|
1756
1867
|
* The thread this chat is on right now: the `threadId` option, else the one the backend created
|
|
1757
1868
|
* on the first send. A getter, because the created id is learned mid-stream.
|
|
@@ -1805,4 +1916,4 @@ declare class QuotaBlockedError extends Error {
|
|
|
1805
1916
|
constructor(block: QuotaBlock);
|
|
1806
1917
|
}
|
|
1807
1918
|
|
|
1808
|
-
export { AgentBackend, AgentChatTransport, type AgentChatTransportOptions, type AgentConfigState, type AgentMessageMetadata, AgentProvider, type AgentProviderProps, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, type AmbientRenderUi, AmbientRenderUiContext, type AnswerInput, AnyToolUIPart, type ApprovalCountdown, type ApproveInput, ApproveOptions, type AttachmentRejection, AttachmentUploadStrategy, type AttachmentsState, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type ChatBackground, ChatInput, type ChatInputProps, type ChatQueue, ChatStatus, type ChatTranscript, type ClipboardLikeEvent, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type DragLikeEvent, type EditSubmitInput, HttpErrorListener, type MessageActionInput, type MessageFeedbackState, type MessageFile, type MessageFileKind, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type ModelOption, type ModelsState, type QueuedChatMessage, QuotaBlockedError, type QuotaState, type ReconnectOptions, type RejectInput, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SkipInput, type SpeechLanguage, type SpeechRecognitionHook, type StagedAttachment, type StagedAttachmentStatus, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadsEvent, type ThreadsState, TimestampInfo, ToolCatalog, type ToolCatalogState, type TranscriptActionState, TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, TranscriptFile, type TranscriptItem, type TranscriptItemOptions, type TranscriptQueuedItem, type TranscriptStopState, TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseAgentConfigOptions, type UseAgentsOptions, type UseApprovalCountdownOptions, type UseAttachmentsOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseModelsOptions, type UseQuotaOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, type WhileRunning, acceptsFile, applyCompletion, approvalCountdown, backgroundRunsFromThread, createSkillsSource, dragHasFiles, fileKind, filesFromClipboard, filterAutocompleteItems, findActiveTrigger, formatElapsed, loadStoredSpeechLang, messageFiles, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, storedMessageToUiMessage, storedThreadToUiMessages, useAgentBackend, useAgentChat, useAgentConfig, useAgents, useAmbientRenderUi, useApprovalCountdown, useAttachments, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|
|
1919
|
+
export { AGENT_RUN_ERROR_CODES, AgentBackend, AgentChatTransport, type AgentChatTransportOptions, type AgentConfigState, type AgentMessageMetadata, AgentProvider, type AgentProviderProps, AgentRequestError, type AgentRunErrorCode, type AgentRunFailure, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, type AmbientRenderUi, AmbientRenderUiContext, type AnswerInput, AnyToolUIPart, type ApprovalCountdown, type ApproveInput, ApproveOptions, type AttachmentRejection, AttachmentUploadStrategy, type AttachmentsState, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type ChatBackground, ChatInput, type ChatInputProps, type ChatQueue, ChatStatus, type ChatTranscript, type ClipboardLikeEvent, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type DragLikeEvent, type EditSubmitInput, HttpErrorListener, type MessageActionInput, type MessageFeedbackState, type MessageFile, type MessageFileKind, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type ModelOption, type ModelsState, type QueuedChatMessage, QuotaBlockedError, type QuotaState, RUN_NOT_ACTIVE_CODE, type ReconnectOptions, type RejectInput, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, SPEECH_LANGUAGES, type SendWhileRunning, type SkillSuggestionData, type SkillsSourceOptions, type SkipInput, type SpeechLanguage, type SpeechRecognitionHook, type StagedAttachment, type StagedAttachmentStatus, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadsEvent, type ThreadsState, TimestampInfo, ToolCatalog, type ToolCatalogState, type TranscriptActionState, TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, TranscriptFile, type TranscriptItem, type TranscriptItemOptions, type TranscriptQueuedFile, type TranscriptQueuedItem, type TranscriptStopState, TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseAgentConfigOptions, type UseAgentsOptions, type UseApprovalCountdownOptions, type UseAttachmentsOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseModelsOptions, type UseQuotaOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, type WhileRunning, acceptsFile, applyCompletion, approvalCountdown, attachmentFile, backgroundRunsFromThread, createSkillsSource, dragHasFiles, fileKind, filesFromClipboard, filterAutocompleteItems, findActiveTrigger, formatElapsed, isRunNotActiveError, loadStoredSpeechLang, messageFiles, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, storedMessageToUiMessage, storedThreadToUiMessages, useAgentBackend, useAgentChat, useAgentConfig, useAgents, useAmbientRenderUi, useApprovalCountdown, useAttachments, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|