@dudousxd/nestjs-agent-react 0.23.0 → 0.25.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 +7 -4
- package/dist/{client-ioKDyV2q.d.cts → client-D4ZSbZJ8.d.cts} +56 -4
- package/dist/{client-ioKDyV2q.d.ts → client-D4ZSbZJ8.d.ts} +56 -4
- package/dist/{generative-ui-9AJNVKBZ.d.cts → generative-ui-BejHxxbR.d.cts} +4 -0
- package/dist/{generative-ui-9AJNVKBZ.d.ts → generative-ui-BejHxxbR.d.ts} +4 -0
- package/dist/genui-json-render.d.cts +1 -1
- package/dist/genui-json-render.d.ts +1 -1
- package/dist/genui.d.cts +2 -2
- package/dist/genui.d.ts +2 -2
- package/dist/index.cjs +175 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -16
- package/dist/index.d.ts +62 -16
- package/dist/index.js +167 -23
- package/dist/index.js.map +1 -1
- package/dist/media.cjs +67 -3
- package/dist/media.cjs.map +1 -1
- package/dist/media.d.cts +9 -6
- package/dist/media.d.ts +9 -6
- package/dist/media.js +67 -3
- package/dist/media.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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, a as AttachmentUploadStrategy } from './client-
|
|
4
|
-
export { b as AgentBackendUnsupportedError, c as AgentClient, d as AgentClientOptions, e as AgentConnection, f as AgentHttpError, C as CancelResult,
|
|
5
|
-
import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, QuotaReport, QuotaWindow, QuotaBlock, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
|
|
3
|
+
import { A as AgentBackend, U as UploadAttachmentOptions, H as HttpErrorListener, a as AttachmentUploadStrategy } from './client-D4ZSbZJ8.cjs';
|
|
4
|
+
export { b as AgentBackendUnsupportedError, c as AgentClient, d as AgentClientOptions, e as AgentConnection, f as AgentHttpError, g as AgentRequestError, C as CancelResult, h as ChatStreamRequest, i as ChatStreamResponse, M as MessageFeedbackInput, R as ResumeStreamRequest, T as ThreadPatch, r as requireBackendMethod } from './client-D4ZSbZJ8.cjs';
|
|
5
|
+
import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
export { ElicitationInput, ElicitationInputType, 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, M as MessageUsageInfo, w as ToolCatalog, x as AnyToolUIPart, y as TranscriptFile } 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, M as MessageUsageInfo, w as ToolCatalog, x as AnyToolUIPart, y as TranscriptFile } from './generative-ui-BejHxxbR.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-BejHxxbR.cjs';
|
|
11
11
|
|
|
12
12
|
/** Identity surfaced by the backend's `meta` SSE frame / response headers. */
|
|
13
13
|
interface AgentStreamMeta {
|
|
@@ -329,6 +329,12 @@ interface AgentProviderProps {
|
|
|
329
329
|
credentials?: RequestCredentials;
|
|
330
330
|
/** Injectable for tests / non-browser runtimes. */
|
|
331
331
|
fetch?: typeof fetch;
|
|
332
|
+
/**
|
|
333
|
+
* Every error answer of the built-in client (an `AgentHttpError`, or a `MediaUploadError` from
|
|
334
|
+
* `mediaAttachments()`), right before it is thrown — for app-wide reactions such as "401 → sign
|
|
335
|
+
* in again". Read at call time, so it may change between renders.
|
|
336
|
+
*/
|
|
337
|
+
onHttpError?: HttpErrorListener;
|
|
332
338
|
/** Attachment uploads of the built-in client. */
|
|
333
339
|
attachments?: {
|
|
334
340
|
/** e.g. `mediaAttachments()` from `@dudousxd/nestjs-agent-react/media`. */
|
|
@@ -354,7 +360,7 @@ interface AgentProviderProps {
|
|
|
354
360
|
*
|
|
355
361
|
* Without a provider every hook shares one same-origin client on `/agent`.
|
|
356
362
|
*/
|
|
357
|
-
declare function AgentProvider({ backend, baseUrl, path, headers, getHeaders, credentials, fetch, attachments, genui, children, }: AgentProviderProps): React.JSX.Element;
|
|
363
|
+
declare function AgentProvider({ backend, baseUrl, path, headers, getHeaders, credentials, fetch, onHttpError, attachments, genui, children, }: AgentProviderProps): React.JSX.Element;
|
|
358
364
|
/**
|
|
359
365
|
* The backend a hook talks to: `own` when given, else the enclosing {@link AgentProvider}'s, else a
|
|
360
366
|
* shared same-origin client on `/agent`. For your own hooks over the same connection.
|
|
@@ -421,6 +427,11 @@ interface ModelsState {
|
|
|
421
427
|
models: ModelOption[];
|
|
422
428
|
/** The model a turn runs on when none is picked, or `null` when the provider decides. */
|
|
423
429
|
defaultModel: string | null;
|
|
430
|
+
/**
|
|
431
|
+
* The agent always runs on one model (`{ model, reason? }`), or `null`. A picker shows it
|
|
432
|
+
* read-only: the server runs every turn on it and refuses any other.
|
|
433
|
+
*/
|
|
434
|
+
locked: ModelCatalogLock | null;
|
|
424
435
|
/** The entry for `id`, or `undefined`. */
|
|
425
436
|
find: (id: string | null | undefined) => ModelOption | undefined;
|
|
426
437
|
isLoading: boolean;
|
|
@@ -430,8 +441,8 @@ interface ModelsState {
|
|
|
430
441
|
/**
|
|
431
442
|
* The models this caller may pick (`GET <base>/models?agent=`), with badges and availability — the
|
|
432
443
|
* data behind a model picker. Headless: render the options however you like, then send the pick
|
|
433
|
-
* as `useAgentChat({ model })
|
|
434
|
-
* with `chat.
|
|
444
|
+
* as `useAgentChat({ model })` or `sendMessage(msg, { body: { model } })` (that turn only), or
|
|
445
|
+
* pin it on the thread with `chat.models.pinToThread(id)`.
|
|
435
446
|
*/
|
|
436
447
|
declare function useModels(options?: UseModelsOptions): ModelsState;
|
|
437
448
|
|
|
@@ -452,6 +463,11 @@ interface QuotaState {
|
|
|
452
463
|
month: QuotaWindow | undefined;
|
|
453
464
|
/** The window that blocks sends, or `null` — pass it to `useAgentChat({ blocked })`. */
|
|
454
465
|
blocked: QuotaBlock | null;
|
|
466
|
+
/**
|
|
467
|
+
* The soft limit: the fullest window past its `warnAt` (`{ period, ratio, reason? }`), or `null`.
|
|
468
|
+
* The server's `warning`, else derived from the windows; never set while `blocked`.
|
|
469
|
+
*/
|
|
470
|
+
warning: QuotaWarning | null;
|
|
455
471
|
isLoading: boolean;
|
|
456
472
|
error: Error | null;
|
|
457
473
|
refresh: () => Promise<void>;
|
|
@@ -723,10 +739,14 @@ interface MessageActionInput {
|
|
|
723
739
|
interface AnswerInput {
|
|
724
740
|
toolCallId: string;
|
|
725
741
|
answers?: Record<string, string[]>;
|
|
742
|
+
/** The surface the answer came through; the server records `'web'` when omitted. */
|
|
743
|
+
via?: string;
|
|
726
744
|
}
|
|
727
745
|
/** Declining a parked question set. */
|
|
728
746
|
interface SkipInput {
|
|
729
747
|
toolCallId: string;
|
|
748
|
+
/** The surface the skip came through; the server records `'web'` when omitted. */
|
|
749
|
+
via?: string;
|
|
730
750
|
}
|
|
731
751
|
/** Approving a tool call parked on a human. */
|
|
732
752
|
interface ApproveInput extends ApproveOptions {
|
|
@@ -1340,6 +1360,8 @@ interface AgentMessageMetadata extends Partial<StoredTurnMetadata> {
|
|
|
1340
1360
|
costUsd?: number | null;
|
|
1341
1361
|
/** ISO timestamp: the stored row's `createdAt` (a merged turn: its first row's), or when a live turn started streaming. */
|
|
1342
1362
|
createdAt?: string;
|
|
1363
|
+
/** Host-defined keys: `StoredMessage.metadata` and the stream's `message-metadata` frames. */
|
|
1364
|
+
[key: string]: unknown;
|
|
1343
1365
|
}
|
|
1344
1366
|
/**
|
|
1345
1367
|
* Convert a thread's full `StoredMessage[]` history into `UIMessage[]`, merging consecutive
|
|
@@ -1423,7 +1445,9 @@ interface UseAgentChatOptions<B extends AgentBackend = AgentBackend> {
|
|
|
1423
1445
|
/**
|
|
1424
1446
|
* The model every turn runs on, controlled by you. Omitted → `chat.models.selected` (what
|
|
1425
1447
|
* `chat.models.select(id)` picked), else the thread's pinned model, else the server default. A
|
|
1426
|
-
* single send can still override it with `sendMessage(msg, { body: { model } })`.
|
|
1448
|
+
* single send can still override it with `sendMessage(msg, { body: { model } })`. Sent as the
|
|
1449
|
+
* turn's `model`, which the server applies to that turn only — pinning a model on the thread is
|
|
1450
|
+
* `chat.models.pinToThread(id)`.
|
|
1427
1451
|
*/
|
|
1428
1452
|
model?: string;
|
|
1429
1453
|
/**
|
|
@@ -1497,19 +1521,41 @@ interface ChatBackground {
|
|
|
1497
1521
|
/** Re-read the thread now, instead of waiting for the next poll. */
|
|
1498
1522
|
refresh: () => Promise<void>;
|
|
1499
1523
|
}
|
|
1500
|
-
/**
|
|
1524
|
+
/**
|
|
1525
|
+
* The chat's model picker state. Loaded the first time `list`/`providers`/`defaultModel`/`locked`
|
|
1526
|
+
* is read.
|
|
1527
|
+
*
|
|
1528
|
+
* Two different choices: `select(id)` picks the model this chat's following sends name — each send
|
|
1529
|
+
* carries it as `model`, which the server applies to that turn only and never stores; the pick is
|
|
1530
|
+
* this conversation's, so switching threads drops it. `pinToThread(id)` stores a model on the
|
|
1531
|
+
* thread (`PATCH threads/:id { model }`), which every later turn without a `model` of its own runs
|
|
1532
|
+
* on, across reloads and devices.
|
|
1533
|
+
*/
|
|
1501
1534
|
interface ChatModels {
|
|
1502
1535
|
/** Every model the caller may pick, flattened (`[]` until loaded). */
|
|
1503
1536
|
readonly list: ModelOption[];
|
|
1504
1537
|
/** The same, grouped by provider. */
|
|
1505
1538
|
readonly providers: ModelsState['providers'];
|
|
1506
|
-
/**
|
|
1539
|
+
/**
|
|
1540
|
+
* What the next turn runs on: the lock, the `model` option, the pick, the thread's pin, else the
|
|
1541
|
+
* default.
|
|
1542
|
+
*/
|
|
1507
1543
|
selected: string | null;
|
|
1508
|
-
/**
|
|
1544
|
+
/** The model pinned on the thread (`null` when none, or before the thread is read). */
|
|
1545
|
+
pinned: string | null;
|
|
1546
|
+
/** The catalog's default — what a turn runs on when nothing is picked or pinned (`null` until loaded). */
|
|
1547
|
+
readonly defaultModel: string | null;
|
|
1548
|
+
/**
|
|
1549
|
+
* The agent always runs on one model (`{ model, reason? }`), or `null`. While locked, `select`
|
|
1550
|
+
* does nothing and `selected` is the locked model.
|
|
1551
|
+
*/
|
|
1552
|
+
readonly locked: ModelsState['locked'];
|
|
1553
|
+
/** Run this chat's following sends on `id` — each send's `model`, that turn only. */
|
|
1509
1554
|
select: (id: string) => void;
|
|
1510
1555
|
/**
|
|
1511
1556
|
* Pin `id` on the thread (`null` unpins) — every later turn without its own `model` runs on it,
|
|
1512
|
-
* across reloads.
|
|
1557
|
+
* across reloads. Replaces the pick, so the next send runs on the pin. On a chat with no thread
|
|
1558
|
+
* yet, the pin lands when the first send creates one.
|
|
1513
1559
|
*/
|
|
1514
1560
|
pinToThread: (id: string | null) => Promise<void>;
|
|
1515
1561
|
isLoading: boolean;
|
|
@@ -1594,8 +1640,8 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
|
|
|
1594
1640
|
cancel: () => Promise<void>;
|
|
1595
1641
|
approve: ({ toolCallId, remember, via }: ApproveInput) => Promise<void>;
|
|
1596
1642
|
reject: ({ toolCallId, reason, via }: RejectInput) => Promise<void>;
|
|
1597
|
-
answer: ({ toolCallId, answers }: AnswerInput) => Promise<void>;
|
|
1598
|
-
skip: ({ toolCallId }: SkipInput) => Promise<void>;
|
|
1643
|
+
answer: ({ toolCallId, answers, via }: AnswerInput) => Promise<void>;
|
|
1644
|
+
skip: ({ toolCallId, via }: SkipInput) => Promise<void>;
|
|
1599
1645
|
regenerate: (_input?: Partial<MessageActionInput>) => void;
|
|
1600
1646
|
fork: ({ messageId, threadId, }: MessageActionInput & {
|
|
1601
1647
|
threadId?: string;
|
|
@@ -1622,4 +1668,4 @@ declare class QuotaBlockedError extends Error {
|
|
|
1622
1668
|
constructor(block: QuotaBlock);
|
|
1623
1669
|
}
|
|
1624
1670
|
|
|
1625
|
-
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, ChatStatus, type ChatTranscript, type ClipboardLikeEvent, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type DragLikeEvent, type EditSubmitInput, 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, 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 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, 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 };
|
|
1671
|
+
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, 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, 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 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, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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, a as AttachmentUploadStrategy } from './client-
|
|
4
|
-
export { b as AgentBackendUnsupportedError, c as AgentClient, d as AgentClientOptions, e as AgentConnection, f as AgentHttpError, C as CancelResult,
|
|
5
|
-
import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, QuotaReport, QuotaWindow, QuotaBlock, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
|
|
3
|
+
import { A as AgentBackend, U as UploadAttachmentOptions, H as HttpErrorListener, a as AttachmentUploadStrategy } from './client-D4ZSbZJ8.js';
|
|
4
|
+
export { b as AgentBackendUnsupportedError, c as AgentClient, d as AgentClientOptions, e as AgentConnection, f as AgentHttpError, g as AgentRequestError, C as CancelResult, h as ChatStreamRequest, i as ChatStreamResponse, M as MessageFeedbackInput, R as ResumeStreamRequest, T as ThreadPatch, r as requireBackendMethod } from './client-D4ZSbZJ8.js';
|
|
5
|
+
import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
export { ElicitationInput, ElicitationInputType, 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, M as MessageUsageInfo, w as ToolCatalog, x as AnyToolUIPart, y as TranscriptFile } 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, M as MessageUsageInfo, w as ToolCatalog, x as AnyToolUIPart, y as TranscriptFile } from './generative-ui-BejHxxbR.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-BejHxxbR.js';
|
|
11
11
|
|
|
12
12
|
/** Identity surfaced by the backend's `meta` SSE frame / response headers. */
|
|
13
13
|
interface AgentStreamMeta {
|
|
@@ -329,6 +329,12 @@ interface AgentProviderProps {
|
|
|
329
329
|
credentials?: RequestCredentials;
|
|
330
330
|
/** Injectable for tests / non-browser runtimes. */
|
|
331
331
|
fetch?: typeof fetch;
|
|
332
|
+
/**
|
|
333
|
+
* Every error answer of the built-in client (an `AgentHttpError`, or a `MediaUploadError` from
|
|
334
|
+
* `mediaAttachments()`), right before it is thrown — for app-wide reactions such as "401 → sign
|
|
335
|
+
* in again". Read at call time, so it may change between renders.
|
|
336
|
+
*/
|
|
337
|
+
onHttpError?: HttpErrorListener;
|
|
332
338
|
/** Attachment uploads of the built-in client. */
|
|
333
339
|
attachments?: {
|
|
334
340
|
/** e.g. `mediaAttachments()` from `@dudousxd/nestjs-agent-react/media`. */
|
|
@@ -354,7 +360,7 @@ interface AgentProviderProps {
|
|
|
354
360
|
*
|
|
355
361
|
* Without a provider every hook shares one same-origin client on `/agent`.
|
|
356
362
|
*/
|
|
357
|
-
declare function AgentProvider({ backend, baseUrl, path, headers, getHeaders, credentials, fetch, attachments, genui, children, }: AgentProviderProps): React.JSX.Element;
|
|
363
|
+
declare function AgentProvider({ backend, baseUrl, path, headers, getHeaders, credentials, fetch, onHttpError, attachments, genui, children, }: AgentProviderProps): React.JSX.Element;
|
|
358
364
|
/**
|
|
359
365
|
* The backend a hook talks to: `own` when given, else the enclosing {@link AgentProvider}'s, else a
|
|
360
366
|
* shared same-origin client on `/agent`. For your own hooks over the same connection.
|
|
@@ -421,6 +427,11 @@ interface ModelsState {
|
|
|
421
427
|
models: ModelOption[];
|
|
422
428
|
/** The model a turn runs on when none is picked, or `null` when the provider decides. */
|
|
423
429
|
defaultModel: string | null;
|
|
430
|
+
/**
|
|
431
|
+
* The agent always runs on one model (`{ model, reason? }`), or `null`. A picker shows it
|
|
432
|
+
* read-only: the server runs every turn on it and refuses any other.
|
|
433
|
+
*/
|
|
434
|
+
locked: ModelCatalogLock | null;
|
|
424
435
|
/** The entry for `id`, or `undefined`. */
|
|
425
436
|
find: (id: string | null | undefined) => ModelOption | undefined;
|
|
426
437
|
isLoading: boolean;
|
|
@@ -430,8 +441,8 @@ interface ModelsState {
|
|
|
430
441
|
/**
|
|
431
442
|
* The models this caller may pick (`GET <base>/models?agent=`), with badges and availability — the
|
|
432
443
|
* data behind a model picker. Headless: render the options however you like, then send the pick
|
|
433
|
-
* as `useAgentChat({ model })
|
|
434
|
-
* with `chat.
|
|
444
|
+
* as `useAgentChat({ model })` or `sendMessage(msg, { body: { model } })` (that turn only), or
|
|
445
|
+
* pin it on the thread with `chat.models.pinToThread(id)`.
|
|
435
446
|
*/
|
|
436
447
|
declare function useModels(options?: UseModelsOptions): ModelsState;
|
|
437
448
|
|
|
@@ -452,6 +463,11 @@ interface QuotaState {
|
|
|
452
463
|
month: QuotaWindow | undefined;
|
|
453
464
|
/** The window that blocks sends, or `null` — pass it to `useAgentChat({ blocked })`. */
|
|
454
465
|
blocked: QuotaBlock | null;
|
|
466
|
+
/**
|
|
467
|
+
* The soft limit: the fullest window past its `warnAt` (`{ period, ratio, reason? }`), or `null`.
|
|
468
|
+
* The server's `warning`, else derived from the windows; never set while `blocked`.
|
|
469
|
+
*/
|
|
470
|
+
warning: QuotaWarning | null;
|
|
455
471
|
isLoading: boolean;
|
|
456
472
|
error: Error | null;
|
|
457
473
|
refresh: () => Promise<void>;
|
|
@@ -723,10 +739,14 @@ interface MessageActionInput {
|
|
|
723
739
|
interface AnswerInput {
|
|
724
740
|
toolCallId: string;
|
|
725
741
|
answers?: Record<string, string[]>;
|
|
742
|
+
/** The surface the answer came through; the server records `'web'` when omitted. */
|
|
743
|
+
via?: string;
|
|
726
744
|
}
|
|
727
745
|
/** Declining a parked question set. */
|
|
728
746
|
interface SkipInput {
|
|
729
747
|
toolCallId: string;
|
|
748
|
+
/** The surface the skip came through; the server records `'web'` when omitted. */
|
|
749
|
+
via?: string;
|
|
730
750
|
}
|
|
731
751
|
/** Approving a tool call parked on a human. */
|
|
732
752
|
interface ApproveInput extends ApproveOptions {
|
|
@@ -1340,6 +1360,8 @@ interface AgentMessageMetadata extends Partial<StoredTurnMetadata> {
|
|
|
1340
1360
|
costUsd?: number | null;
|
|
1341
1361
|
/** ISO timestamp: the stored row's `createdAt` (a merged turn: its first row's), or when a live turn started streaming. */
|
|
1342
1362
|
createdAt?: string;
|
|
1363
|
+
/** Host-defined keys: `StoredMessage.metadata` and the stream's `message-metadata` frames. */
|
|
1364
|
+
[key: string]: unknown;
|
|
1343
1365
|
}
|
|
1344
1366
|
/**
|
|
1345
1367
|
* Convert a thread's full `StoredMessage[]` history into `UIMessage[]`, merging consecutive
|
|
@@ -1423,7 +1445,9 @@ interface UseAgentChatOptions<B extends AgentBackend = AgentBackend> {
|
|
|
1423
1445
|
/**
|
|
1424
1446
|
* The model every turn runs on, controlled by you. Omitted → `chat.models.selected` (what
|
|
1425
1447
|
* `chat.models.select(id)` picked), else the thread's pinned model, else the server default. A
|
|
1426
|
-
* single send can still override it with `sendMessage(msg, { body: { model } })`.
|
|
1448
|
+
* single send can still override it with `sendMessage(msg, { body: { model } })`. Sent as the
|
|
1449
|
+
* turn's `model`, which the server applies to that turn only — pinning a model on the thread is
|
|
1450
|
+
* `chat.models.pinToThread(id)`.
|
|
1427
1451
|
*/
|
|
1428
1452
|
model?: string;
|
|
1429
1453
|
/**
|
|
@@ -1497,19 +1521,41 @@ interface ChatBackground {
|
|
|
1497
1521
|
/** Re-read the thread now, instead of waiting for the next poll. */
|
|
1498
1522
|
refresh: () => Promise<void>;
|
|
1499
1523
|
}
|
|
1500
|
-
/**
|
|
1524
|
+
/**
|
|
1525
|
+
* The chat's model picker state. Loaded the first time `list`/`providers`/`defaultModel`/`locked`
|
|
1526
|
+
* is read.
|
|
1527
|
+
*
|
|
1528
|
+
* Two different choices: `select(id)` picks the model this chat's following sends name — each send
|
|
1529
|
+
* carries it as `model`, which the server applies to that turn only and never stores; the pick is
|
|
1530
|
+
* this conversation's, so switching threads drops it. `pinToThread(id)` stores a model on the
|
|
1531
|
+
* thread (`PATCH threads/:id { model }`), which every later turn without a `model` of its own runs
|
|
1532
|
+
* on, across reloads and devices.
|
|
1533
|
+
*/
|
|
1501
1534
|
interface ChatModels {
|
|
1502
1535
|
/** Every model the caller may pick, flattened (`[]` until loaded). */
|
|
1503
1536
|
readonly list: ModelOption[];
|
|
1504
1537
|
/** The same, grouped by provider. */
|
|
1505
1538
|
readonly providers: ModelsState['providers'];
|
|
1506
|
-
/**
|
|
1539
|
+
/**
|
|
1540
|
+
* What the next turn runs on: the lock, the `model` option, the pick, the thread's pin, else the
|
|
1541
|
+
* default.
|
|
1542
|
+
*/
|
|
1507
1543
|
selected: string | null;
|
|
1508
|
-
/**
|
|
1544
|
+
/** The model pinned on the thread (`null` when none, or before the thread is read). */
|
|
1545
|
+
pinned: string | null;
|
|
1546
|
+
/** The catalog's default — what a turn runs on when nothing is picked or pinned (`null` until loaded). */
|
|
1547
|
+
readonly defaultModel: string | null;
|
|
1548
|
+
/**
|
|
1549
|
+
* The agent always runs on one model (`{ model, reason? }`), or `null`. While locked, `select`
|
|
1550
|
+
* does nothing and `selected` is the locked model.
|
|
1551
|
+
*/
|
|
1552
|
+
readonly locked: ModelsState['locked'];
|
|
1553
|
+
/** Run this chat's following sends on `id` — each send's `model`, that turn only. */
|
|
1509
1554
|
select: (id: string) => void;
|
|
1510
1555
|
/**
|
|
1511
1556
|
* Pin `id` on the thread (`null` unpins) — every later turn without its own `model` runs on it,
|
|
1512
|
-
* across reloads.
|
|
1557
|
+
* across reloads. Replaces the pick, so the next send runs on the pin. On a chat with no thread
|
|
1558
|
+
* yet, the pin lands when the first send creates one.
|
|
1513
1559
|
*/
|
|
1514
1560
|
pinToThread: (id: string | null) => Promise<void>;
|
|
1515
1561
|
isLoading: boolean;
|
|
@@ -1594,8 +1640,8 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
|
|
|
1594
1640
|
cancel: () => Promise<void>;
|
|
1595
1641
|
approve: ({ toolCallId, remember, via }: ApproveInput) => Promise<void>;
|
|
1596
1642
|
reject: ({ toolCallId, reason, via }: RejectInput) => Promise<void>;
|
|
1597
|
-
answer: ({ toolCallId, answers }: AnswerInput) => Promise<void>;
|
|
1598
|
-
skip: ({ toolCallId }: SkipInput) => Promise<void>;
|
|
1643
|
+
answer: ({ toolCallId, answers, via }: AnswerInput) => Promise<void>;
|
|
1644
|
+
skip: ({ toolCallId, via }: SkipInput) => Promise<void>;
|
|
1599
1645
|
regenerate: (_input?: Partial<MessageActionInput>) => void;
|
|
1600
1646
|
fork: ({ messageId, threadId, }: MessageActionInput & {
|
|
1601
1647
|
threadId?: string;
|
|
@@ -1622,4 +1668,4 @@ declare class QuotaBlockedError extends Error {
|
|
|
1622
1668
|
constructor(block: QuotaBlock);
|
|
1623
1669
|
}
|
|
1624
1670
|
|
|
1625
|
-
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, ChatStatus, type ChatTranscript, type ClipboardLikeEvent, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type DragLikeEvent, type EditSubmitInput, 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, 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 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, 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 };
|
|
1671
|
+
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, 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, 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 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, 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 };
|