@dudousxd/nestjs-agent-react 0.17.0 → 0.19.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 +70 -29
- package/dist/generative-ui-BhXFni8j.d.ts +167 -0
- package/dist/generative-ui-C53b3FoA.d.cts +167 -0
- package/dist/genui-json-render.cjs +521 -4
- package/dist/genui-json-render.cjs.map +1 -1
- package/dist/genui-json-render.d.cts +15 -2
- package/dist/genui-json-render.d.ts +15 -2
- package/dist/genui-json-render.js +518 -2
- package/dist/genui-json-render.js.map +1 -1
- package/dist/genui.cjs +120 -23
- package/dist/genui.cjs.map +1 -1
- package/dist/genui.d.cts +5 -52
- package/dist/genui.d.ts +5 -52
- package/dist/genui.js +106 -11
- package/dist/genui.js.map +1 -1
- package/dist/index.cjs +584 -214
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -7
- package/dist/index.d.ts +157 -7
- package/dist/index.js +538 -176
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
- package/dist/types-DFD-soWU.d.cts +0 -86
- package/dist/types-DFD-soWU.d.ts +0 -86
package/dist/index.d.cts
CHANGED
|
@@ -3,8 +3,8 @@ import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } fro
|
|
|
3
3
|
import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
|
|
4
4
|
import { ThreadSummary, ThreadDetail, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaView, QuotaReport, ModelCatalogView, AgentCatalogEntry, MessageFeedbackValue, MessageFeedback, ModelCatalogEntry, QuotaWindow, QuotaBlock, StoredMessage } from '@dudousxd/nestjs-agent-core';
|
|
5
5
|
export { ElicitationInput, ElicitationInputType, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
|
|
6
|
-
import React__default from 'react';
|
|
7
|
-
import { a as TranscriptBlock, U as UsageSummary, b as TimestampInfo, C as ChatStatus, M as MessageUsageInfo, c as ToolCatalog, A as ApproveOptions, d as AnyToolUIPart, e as TranscriptFile
|
|
6
|
+
import React__default, { ReactNode, Context } from 'react';
|
|
7
|
+
import { T as TranscriptUiBlock, a as TranscriptBlock, U as UsageSummary, b as TimestampInfo, C as ChatStatus, M as MessageUsageInfo, c as ToolCatalog, A as ApproveOptions, d as AnyToolUIPart, e as TranscriptFile } from './model-gHqjNjLJ.cjs';
|
|
8
8
|
export { f as ApprovalBlockOptions, B as BuildBlocksOptions, g as CoercibleQuestion, D as DescribeToolCallOptions, E as ElicitationBlockOptions, G as GroupToolActivityOptions, R as RawAnswer, h as ResolvedReading, i as ResolvedResultView, j as RetrievedPassage, S as SettleAction, k as ToolActivityGroup, l as ToolCallDescription, m as ToolCallState, n as ToolCallStatus, o as TranscriptApproval, p as TranscriptApprovalStatus, q as TranscriptElicitationBlock, r as TranscriptElicitationOutcome, s as TranscriptFilesBlock, t as TranscriptQuestion, u as TranscriptQuestionOption, v as TranscriptReasoningBlock, w as TranscriptSettleState, x as TranscriptSource, y as TranscriptSourcesBlock, z as TranscriptTextBlock, F as TranscriptToolBlock, H as TranscriptToolCall, I as buildTranscriptBlocks, J as coerceAnswer, K as correctedCallIds, L as describeTimestamp, N as describeToolCall, O as describeUsage, P as extractMessageText, Q as fillTemplate, V as formatRelativeTime, W as groupToolActivity, X as inferResultView, Y as isActionCall, Z as phraseFor, _ as readPath, $ as resolveResultView, a0 as toolCallState, a1 as toolCatalogFrom } from './model-gHqjNjLJ.cjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -294,6 +294,138 @@ declare class AgentChatTransport implements ChatTransport<UIMessage> {
|
|
|
294
294
|
private toChunkStream;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
/** How a renderer is likely to show a file. */
|
|
298
|
+
type MessageFileKind = 'image' | 'pdf' | 'text' | 'audio' | 'video' | 'other';
|
|
299
|
+
/** One file on a message, live or replayed, with what a renderer needs to decide how to show it. */
|
|
300
|
+
interface MessageFile {
|
|
301
|
+
url: string;
|
|
302
|
+
mediaType: string;
|
|
303
|
+
/** The original name, or `null` when the part carried none. */
|
|
304
|
+
filename: string | null;
|
|
305
|
+
kind: MessageFileKind;
|
|
306
|
+
/** Lower-case extension from the name (`'pdf'`), or `null`. */
|
|
307
|
+
extension: string | null;
|
|
308
|
+
/** The stored media id — present on files replayed from history (`StoredMessage.attachments`). */
|
|
309
|
+
mediaId: string | null;
|
|
310
|
+
}
|
|
311
|
+
/** The {@link MessageFileKind} of a MIME type. */
|
|
312
|
+
declare function fileKind(mediaType: string): MessageFileKind;
|
|
313
|
+
/**
|
|
314
|
+
* The files on a message — the user's attachments (live, or replayed from `StoredMessage.attachments`
|
|
315
|
+
* by `storedMessageToUiMessage`) and any the model produced — in part order. Data only: pair it with
|
|
316
|
+
* your own thumbnails/links.
|
|
317
|
+
*/
|
|
318
|
+
declare function messageFiles(message: Pick<UIMessage, 'parts'>): MessageFile[];
|
|
319
|
+
/**
|
|
320
|
+
* Whether `file` matches an `accept` list in the `<input accept>` grammar: MIME types
|
|
321
|
+
* (`application/pdf`), wildcards (`image/*`) and extensions (`.csv`). An empty list accepts all.
|
|
322
|
+
*/
|
|
323
|
+
declare function acceptsFile(accept: string | readonly string[] | undefined, file: Pick<File, 'name' | 'type'>): boolean;
|
|
324
|
+
/** Files carried by a paste — screenshots and copied files. Text-only pastes give `[]`. */
|
|
325
|
+
declare function filesFromClipboard(data: DataTransfer | null | undefined): File[];
|
|
326
|
+
/** Whether a drag carries files (as opposed to text or a link) — gate your drop highlight on it. */
|
|
327
|
+
declare function dragHasFiles(data: DataTransfer | null | undefined): boolean;
|
|
328
|
+
|
|
329
|
+
/** Where one staged file stands. `rejected` never uploaded (validation); `error` can be retried. */
|
|
330
|
+
type StagedAttachmentStatus = 'uploading' | 'ready' | 'error' | 'rejected';
|
|
331
|
+
interface StagedAttachment {
|
|
332
|
+
/** Local id, stable for the item's life — use it as the React key and for `remove`/`retry`. */
|
|
333
|
+
id: string;
|
|
334
|
+
file: File;
|
|
335
|
+
name: string;
|
|
336
|
+
size: number;
|
|
337
|
+
type: string;
|
|
338
|
+
status: StagedAttachmentStatus;
|
|
339
|
+
/** 0..1 while uploading (0 until the backend reports progress), 1 once ready. */
|
|
340
|
+
progress: number;
|
|
341
|
+
/** Why it was rejected or failed. */
|
|
342
|
+
error?: string;
|
|
343
|
+
/** What the server returned — present once `ready`. */
|
|
344
|
+
attachment?: MessageAttachment;
|
|
345
|
+
/** An object URL for image previews (revoked on remove/unmount), when the runtime has one. */
|
|
346
|
+
previewUrl?: string;
|
|
347
|
+
}
|
|
348
|
+
/** Why a file was turned away before any upload. */
|
|
349
|
+
type AttachmentRejection = 'type' | 'size' | 'count';
|
|
350
|
+
interface UseAttachmentsOptions {
|
|
351
|
+
/**
|
|
352
|
+
* Upload one file — defaults to `backend.uploadAttachment`. Resolve with what the server
|
|
353
|
+
* answered; honour `signal` so `remove` can cancel; call `onProgress(0..1)` if you can.
|
|
354
|
+
*/
|
|
355
|
+
upload?: (file: File, options: UploadAttachmentOptions) => Promise<MessageAttachment>;
|
|
356
|
+
/** Used for the default `upload`. One of `upload` / `backend` is required. */
|
|
357
|
+
backend?: AgentBackend;
|
|
358
|
+
/** `<input accept>` grammar: `'image/*,.pdf'` or `['image/*', 'application/pdf']`. */
|
|
359
|
+
accept?: string | readonly string[];
|
|
360
|
+
/** Per-file ceiling, in bytes. */
|
|
361
|
+
maxBytes?: number;
|
|
362
|
+
/** How many files may be staged at once (rejected ones do not count). */
|
|
363
|
+
maxFiles?: number;
|
|
364
|
+
/** Words for a rejection; default English. */
|
|
365
|
+
describeRejection?: (reason: AttachmentRejection, file: File) => string;
|
|
366
|
+
}
|
|
367
|
+
interface AttachmentsState {
|
|
368
|
+
items: StagedAttachment[];
|
|
369
|
+
/** Stage files: validate, then upload each that passes. */
|
|
370
|
+
add: (files: Iterable<File> | ArrayLike<File> | null | undefined) => void;
|
|
371
|
+
/** Drop an item, cancelling its upload. */
|
|
372
|
+
remove: (id: string) => void;
|
|
373
|
+
/** Upload a failed item again. */
|
|
374
|
+
retry: (id: string) => void;
|
|
375
|
+
/** Drop everything — call after a send. */
|
|
376
|
+
clear: () => void;
|
|
377
|
+
/** An upload is still running — hold the send button. */
|
|
378
|
+
isUploading: boolean;
|
|
379
|
+
/** What to send: the ready uploads, in order. */
|
|
380
|
+
attachments: MessageAttachment[];
|
|
381
|
+
/** The same, as the `{ mediaId }` refs `POST <base>/chat` takes. */
|
|
382
|
+
refs: Array<{
|
|
383
|
+
mediaId: string;
|
|
384
|
+
}>;
|
|
385
|
+
/** Props for a hidden `<input type="file">`: `accept`, `multiple`, `onChange`. */
|
|
386
|
+
inputProps: {
|
|
387
|
+
type: 'file';
|
|
388
|
+
accept: string | undefined;
|
|
389
|
+
multiple: boolean;
|
|
390
|
+
onChange: (event: {
|
|
391
|
+
currentTarget: HTMLInputElement;
|
|
392
|
+
}) => void;
|
|
393
|
+
};
|
|
394
|
+
/** Handlers for any element that should take dropped files. */
|
|
395
|
+
dropZoneProps: {
|
|
396
|
+
onDragEnter: (event: DragLikeEvent) => void;
|
|
397
|
+
onDragOver: (event: DragLikeEvent) => void;
|
|
398
|
+
onDragLeave: (event: DragLikeEvent) => void;
|
|
399
|
+
onDrop: (event: DragLikeEvent) => void;
|
|
400
|
+
};
|
|
401
|
+
/** Files are being dragged over the drop zone — for a highlight. */
|
|
402
|
+
isDragging: boolean;
|
|
403
|
+
/** Paste handler for the composer: stages pasted files (screenshots), leaves text alone. */
|
|
404
|
+
onPaste: (event: ClipboardLikeEvent) => void;
|
|
405
|
+
}
|
|
406
|
+
/** The slice of a React/DOM drag event these handlers read. */
|
|
407
|
+
interface DragLikeEvent {
|
|
408
|
+
dataTransfer: DataTransfer | null;
|
|
409
|
+
preventDefault: () => void;
|
|
410
|
+
}
|
|
411
|
+
/** The slice of a React/DOM clipboard event `onPaste` reads. */
|
|
412
|
+
interface ClipboardLikeEvent {
|
|
413
|
+
clipboardData: DataTransfer | null;
|
|
414
|
+
preventDefault: () => void;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Staged attachments for a composer, headless: validation (`accept`, `maxBytes`, `maxFiles`),
|
|
418
|
+
* one upload per file with progress and cancel, retry, previews, and the event handlers for a file
|
|
419
|
+
* input, a drop zone and paste — no markup, no styles. Send `attachments` (or `refs`) with the
|
|
420
|
+
* message, then `clear()`:
|
|
421
|
+
*
|
|
422
|
+
* ```ts
|
|
423
|
+
* await chat.sendMessage({ text }, { body: { attachments: files.refs } });
|
|
424
|
+
* files.clear();
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
declare function useAttachments(options: UseAttachmentsOptions): AttachmentsState;
|
|
428
|
+
|
|
297
429
|
interface UseAgentsOptions {
|
|
298
430
|
/** `useAgentChat(...).backend`, or your own. Must implement `listAgents`. */
|
|
299
431
|
backend: AgentBackend;
|
|
@@ -570,6 +702,7 @@ declare class AgentClient implements AgentBackend {
|
|
|
570
702
|
* what a caller then rides on `sendMessage({ text }, { body: { attachments: [...] } })`.
|
|
571
703
|
*/
|
|
572
704
|
uploadAttachment(file: File, options?: UploadAttachmentOptions): Promise<MessageAttachment>;
|
|
705
|
+
private uploadWithProgress;
|
|
573
706
|
promoteThread(id: string): Promise<OkResult>;
|
|
574
707
|
truncateFromMessage(threadId: string, messageId: string): Promise<OkResult>;
|
|
575
708
|
/** `GET /agent/models?agent=` — the models this caller may pick, grouped by provider. */
|
|
@@ -620,6 +753,20 @@ declare class AgentClient implements AgentBackend {
|
|
|
620
753
|
private handleResponse;
|
|
621
754
|
}
|
|
622
755
|
|
|
756
|
+
/** Draws a server-pushed component block. */
|
|
757
|
+
type AmbientRenderUi = (block: TranscriptUiBlock) => ReactNode;
|
|
758
|
+
/**
|
|
759
|
+
* How pushed components are drawn when no `renderUi` is passed — set by `<GenuiProvider>` (the
|
|
760
|
+
* `/genui` subpath) and read by `MessageItem`.
|
|
761
|
+
*/
|
|
762
|
+
declare const AmbientRenderUiContext: Context<AmbientRenderUi | null>;
|
|
763
|
+
/**
|
|
764
|
+
* The renderer `<GenuiProvider>` installed for pushed components, or `null` outside one. For a
|
|
765
|
+
* custom transcript built on `useTranscriptItem`: draw a `ui` block with it and you get what
|
|
766
|
+
* `MessageItem` draws.
|
|
767
|
+
*/
|
|
768
|
+
declare function useAmbientRenderUi(): AmbientRenderUi | null;
|
|
769
|
+
|
|
623
770
|
interface ChatInputProps {
|
|
624
771
|
onSubmit: (text: string) => void;
|
|
625
772
|
disabled?: boolean;
|
|
@@ -858,8 +1005,8 @@ type RenderTextFn = (text: string, ctx: {
|
|
|
858
1005
|
type RenderFilesFn = (files: TranscriptFile[]) => React__default.ReactNode;
|
|
859
1006
|
/**
|
|
860
1007
|
* Render a component the server pushed into the message — look `block.component` up in your own
|
|
861
|
-
* registry. Omitted →
|
|
862
|
-
* own component).
|
|
1008
|
+
* registry. Omitted → drawn by the enclosing `<GenuiProvider>` (`/genui`) if there is one, else not
|
|
1009
|
+
* drawn (there is no sensible default for an app's own component).
|
|
863
1010
|
*/
|
|
864
1011
|
type RenderUiFn = (block: TranscriptUiBlock) => React__default.ReactNode;
|
|
865
1012
|
/** Render the body of a reasoning run; the disclosure toggle around it stays this component's. */
|
|
@@ -894,7 +1041,10 @@ interface MessageRenderSlots {
|
|
|
894
1041
|
renderReasoning?: RenderReasoningFn;
|
|
895
1042
|
/** Draw files yourself — a gallery, a viewer. Omitted → images inline, everything else a link. */
|
|
896
1043
|
renderFiles?: RenderFilesFn;
|
|
897
|
-
/**
|
|
1044
|
+
/**
|
|
1045
|
+
* Draw a server-pushed component (a `ui` stream frame). Omitted → the enclosing `<GenuiProvider>`
|
|
1046
|
+
* draws it; without one, not drawn.
|
|
1047
|
+
*/
|
|
898
1048
|
renderUi?: RenderUiFn;
|
|
899
1049
|
/**
|
|
900
1050
|
* Extra content for the action row, after the built-in affordances and before usage — a badge
|
|
@@ -937,7 +1087,7 @@ interface MessageItemViewProps extends MessageRenderSlots {
|
|
|
937
1087
|
*/
|
|
938
1088
|
declare function MessageItem({ message, isStreaming, editable, onEditSubmit, regeneratable, onRegenerate, onFork, usage, createdAt, ...slots }: MessageItemProps): React__default.JSX.Element;
|
|
939
1089
|
/** The default markup for one modelled message — what `MessageItem` renders once it has an item. */
|
|
940
|
-
declare function MessageItemView({ item, ...
|
|
1090
|
+
declare function MessageItemView({ item, ...given }: MessageItemViewProps): React__default.JSX.Element;
|
|
941
1091
|
|
|
942
1092
|
interface MessageListClassNames {
|
|
943
1093
|
root?: string;
|
|
@@ -1607,4 +1757,4 @@ declare class QuotaBlockedError extends Error {
|
|
|
1607
1757
|
constructor(block: QuotaBlock);
|
|
1608
1758
|
}
|
|
1609
1759
|
|
|
1610
|
-
export { type AgentBackend, AgentBackendUnsupportedError, AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentMessageMetadata, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, AnyToolUIPart, type ApprovalCountdown, ApproveOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, ChatStatus, type ChatStreamRequest, type ChatStreamResponse, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type MessageFeedbackInput, type MessageFeedbackState, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type ModelOption, type ModelsState, QuotaBlockedError, type QuotaState, type QuotaToday, type ReconnectOptions, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type ResumeStreamRequest, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadPatch, 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, type UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseAgentsOptions, type UseApprovalCountdownOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseModelsOptions, type UseQuotaOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, approvalCountdown, backgroundRunsFromThread, createSkillsSource, filterAutocompleteItems, findActiveTrigger, formatElapsed, loadStoredSpeechLang, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, requireBackendMethod, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useAgents, useApprovalCountdown, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|
|
1760
|
+
export { type AgentBackend, AgentBackendUnsupportedError, AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentMessageMetadata, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, type AmbientRenderUi, AmbientRenderUiContext, AnyToolUIPart, type ApprovalCountdown, ApproveOptions, type AttachmentRejection, type AttachmentsState, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, ChatStatus, type ChatStreamRequest, type ChatStreamResponse, type ChatTranscript, type ClipboardLikeEvent, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type DragLikeEvent, type MessageFeedbackInput, 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 QuotaToday, type ReconnectOptions, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type ResumeStreamRequest, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StagedAttachment, type StagedAttachmentStatus, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadPatch, 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, type UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, 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, requireBackendMethod, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useAgents, useAmbientRenderUi, useApprovalCountdown, useAttachments, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } fro
|
|
|
3
3
|
import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
|
|
4
4
|
import { ThreadSummary, ThreadDetail, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaView, QuotaReport, ModelCatalogView, AgentCatalogEntry, MessageFeedbackValue, MessageFeedback, ModelCatalogEntry, QuotaWindow, QuotaBlock, StoredMessage } from '@dudousxd/nestjs-agent-core';
|
|
5
5
|
export { ElicitationInput, ElicitationInputType, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
|
|
6
|
-
import React__default from 'react';
|
|
7
|
-
import { a as TranscriptBlock, U as UsageSummary, b as TimestampInfo, C as ChatStatus, M as MessageUsageInfo, c as ToolCatalog, A as ApproveOptions, d as AnyToolUIPart, e as TranscriptFile
|
|
6
|
+
import React__default, { ReactNode, Context } from 'react';
|
|
7
|
+
import { T as TranscriptUiBlock, a as TranscriptBlock, U as UsageSummary, b as TimestampInfo, C as ChatStatus, M as MessageUsageInfo, c as ToolCatalog, A as ApproveOptions, d as AnyToolUIPart, e as TranscriptFile } from './model-gHqjNjLJ.js';
|
|
8
8
|
export { f as ApprovalBlockOptions, B as BuildBlocksOptions, g as CoercibleQuestion, D as DescribeToolCallOptions, E as ElicitationBlockOptions, G as GroupToolActivityOptions, R as RawAnswer, h as ResolvedReading, i as ResolvedResultView, j as RetrievedPassage, S as SettleAction, k as ToolActivityGroup, l as ToolCallDescription, m as ToolCallState, n as ToolCallStatus, o as TranscriptApproval, p as TranscriptApprovalStatus, q as TranscriptElicitationBlock, r as TranscriptElicitationOutcome, s as TranscriptFilesBlock, t as TranscriptQuestion, u as TranscriptQuestionOption, v as TranscriptReasoningBlock, w as TranscriptSettleState, x as TranscriptSource, y as TranscriptSourcesBlock, z as TranscriptTextBlock, F as TranscriptToolBlock, H as TranscriptToolCall, I as buildTranscriptBlocks, J as coerceAnswer, K as correctedCallIds, L as describeTimestamp, N as describeToolCall, O as describeUsage, P as extractMessageText, Q as fillTemplate, V as formatRelativeTime, W as groupToolActivity, X as inferResultView, Y as isActionCall, Z as phraseFor, _ as readPath, $ as resolveResultView, a0 as toolCallState, a1 as toolCatalogFrom } from './model-gHqjNjLJ.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -294,6 +294,138 @@ declare class AgentChatTransport implements ChatTransport<UIMessage> {
|
|
|
294
294
|
private toChunkStream;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
/** How a renderer is likely to show a file. */
|
|
298
|
+
type MessageFileKind = 'image' | 'pdf' | 'text' | 'audio' | 'video' | 'other';
|
|
299
|
+
/** One file on a message, live or replayed, with what a renderer needs to decide how to show it. */
|
|
300
|
+
interface MessageFile {
|
|
301
|
+
url: string;
|
|
302
|
+
mediaType: string;
|
|
303
|
+
/** The original name, or `null` when the part carried none. */
|
|
304
|
+
filename: string | null;
|
|
305
|
+
kind: MessageFileKind;
|
|
306
|
+
/** Lower-case extension from the name (`'pdf'`), or `null`. */
|
|
307
|
+
extension: string | null;
|
|
308
|
+
/** The stored media id — present on files replayed from history (`StoredMessage.attachments`). */
|
|
309
|
+
mediaId: string | null;
|
|
310
|
+
}
|
|
311
|
+
/** The {@link MessageFileKind} of a MIME type. */
|
|
312
|
+
declare function fileKind(mediaType: string): MessageFileKind;
|
|
313
|
+
/**
|
|
314
|
+
* The files on a message — the user's attachments (live, or replayed from `StoredMessage.attachments`
|
|
315
|
+
* by `storedMessageToUiMessage`) and any the model produced — in part order. Data only: pair it with
|
|
316
|
+
* your own thumbnails/links.
|
|
317
|
+
*/
|
|
318
|
+
declare function messageFiles(message: Pick<UIMessage, 'parts'>): MessageFile[];
|
|
319
|
+
/**
|
|
320
|
+
* Whether `file` matches an `accept` list in the `<input accept>` grammar: MIME types
|
|
321
|
+
* (`application/pdf`), wildcards (`image/*`) and extensions (`.csv`). An empty list accepts all.
|
|
322
|
+
*/
|
|
323
|
+
declare function acceptsFile(accept: string | readonly string[] | undefined, file: Pick<File, 'name' | 'type'>): boolean;
|
|
324
|
+
/** Files carried by a paste — screenshots and copied files. Text-only pastes give `[]`. */
|
|
325
|
+
declare function filesFromClipboard(data: DataTransfer | null | undefined): File[];
|
|
326
|
+
/** Whether a drag carries files (as opposed to text or a link) — gate your drop highlight on it. */
|
|
327
|
+
declare function dragHasFiles(data: DataTransfer | null | undefined): boolean;
|
|
328
|
+
|
|
329
|
+
/** Where one staged file stands. `rejected` never uploaded (validation); `error` can be retried. */
|
|
330
|
+
type StagedAttachmentStatus = 'uploading' | 'ready' | 'error' | 'rejected';
|
|
331
|
+
interface StagedAttachment {
|
|
332
|
+
/** Local id, stable for the item's life — use it as the React key and for `remove`/`retry`. */
|
|
333
|
+
id: string;
|
|
334
|
+
file: File;
|
|
335
|
+
name: string;
|
|
336
|
+
size: number;
|
|
337
|
+
type: string;
|
|
338
|
+
status: StagedAttachmentStatus;
|
|
339
|
+
/** 0..1 while uploading (0 until the backend reports progress), 1 once ready. */
|
|
340
|
+
progress: number;
|
|
341
|
+
/** Why it was rejected or failed. */
|
|
342
|
+
error?: string;
|
|
343
|
+
/** What the server returned — present once `ready`. */
|
|
344
|
+
attachment?: MessageAttachment;
|
|
345
|
+
/** An object URL for image previews (revoked on remove/unmount), when the runtime has one. */
|
|
346
|
+
previewUrl?: string;
|
|
347
|
+
}
|
|
348
|
+
/** Why a file was turned away before any upload. */
|
|
349
|
+
type AttachmentRejection = 'type' | 'size' | 'count';
|
|
350
|
+
interface UseAttachmentsOptions {
|
|
351
|
+
/**
|
|
352
|
+
* Upload one file — defaults to `backend.uploadAttachment`. Resolve with what the server
|
|
353
|
+
* answered; honour `signal` so `remove` can cancel; call `onProgress(0..1)` if you can.
|
|
354
|
+
*/
|
|
355
|
+
upload?: (file: File, options: UploadAttachmentOptions) => Promise<MessageAttachment>;
|
|
356
|
+
/** Used for the default `upload`. One of `upload` / `backend` is required. */
|
|
357
|
+
backend?: AgentBackend;
|
|
358
|
+
/** `<input accept>` grammar: `'image/*,.pdf'` or `['image/*', 'application/pdf']`. */
|
|
359
|
+
accept?: string | readonly string[];
|
|
360
|
+
/** Per-file ceiling, in bytes. */
|
|
361
|
+
maxBytes?: number;
|
|
362
|
+
/** How many files may be staged at once (rejected ones do not count). */
|
|
363
|
+
maxFiles?: number;
|
|
364
|
+
/** Words for a rejection; default English. */
|
|
365
|
+
describeRejection?: (reason: AttachmentRejection, file: File) => string;
|
|
366
|
+
}
|
|
367
|
+
interface AttachmentsState {
|
|
368
|
+
items: StagedAttachment[];
|
|
369
|
+
/** Stage files: validate, then upload each that passes. */
|
|
370
|
+
add: (files: Iterable<File> | ArrayLike<File> | null | undefined) => void;
|
|
371
|
+
/** Drop an item, cancelling its upload. */
|
|
372
|
+
remove: (id: string) => void;
|
|
373
|
+
/** Upload a failed item again. */
|
|
374
|
+
retry: (id: string) => void;
|
|
375
|
+
/** Drop everything — call after a send. */
|
|
376
|
+
clear: () => void;
|
|
377
|
+
/** An upload is still running — hold the send button. */
|
|
378
|
+
isUploading: boolean;
|
|
379
|
+
/** What to send: the ready uploads, in order. */
|
|
380
|
+
attachments: MessageAttachment[];
|
|
381
|
+
/** The same, as the `{ mediaId }` refs `POST <base>/chat` takes. */
|
|
382
|
+
refs: Array<{
|
|
383
|
+
mediaId: string;
|
|
384
|
+
}>;
|
|
385
|
+
/** Props for a hidden `<input type="file">`: `accept`, `multiple`, `onChange`. */
|
|
386
|
+
inputProps: {
|
|
387
|
+
type: 'file';
|
|
388
|
+
accept: string | undefined;
|
|
389
|
+
multiple: boolean;
|
|
390
|
+
onChange: (event: {
|
|
391
|
+
currentTarget: HTMLInputElement;
|
|
392
|
+
}) => void;
|
|
393
|
+
};
|
|
394
|
+
/** Handlers for any element that should take dropped files. */
|
|
395
|
+
dropZoneProps: {
|
|
396
|
+
onDragEnter: (event: DragLikeEvent) => void;
|
|
397
|
+
onDragOver: (event: DragLikeEvent) => void;
|
|
398
|
+
onDragLeave: (event: DragLikeEvent) => void;
|
|
399
|
+
onDrop: (event: DragLikeEvent) => void;
|
|
400
|
+
};
|
|
401
|
+
/** Files are being dragged over the drop zone — for a highlight. */
|
|
402
|
+
isDragging: boolean;
|
|
403
|
+
/** Paste handler for the composer: stages pasted files (screenshots), leaves text alone. */
|
|
404
|
+
onPaste: (event: ClipboardLikeEvent) => void;
|
|
405
|
+
}
|
|
406
|
+
/** The slice of a React/DOM drag event these handlers read. */
|
|
407
|
+
interface DragLikeEvent {
|
|
408
|
+
dataTransfer: DataTransfer | null;
|
|
409
|
+
preventDefault: () => void;
|
|
410
|
+
}
|
|
411
|
+
/** The slice of a React/DOM clipboard event `onPaste` reads. */
|
|
412
|
+
interface ClipboardLikeEvent {
|
|
413
|
+
clipboardData: DataTransfer | null;
|
|
414
|
+
preventDefault: () => void;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Staged attachments for a composer, headless: validation (`accept`, `maxBytes`, `maxFiles`),
|
|
418
|
+
* one upload per file with progress and cancel, retry, previews, and the event handlers for a file
|
|
419
|
+
* input, a drop zone and paste — no markup, no styles. Send `attachments` (or `refs`) with the
|
|
420
|
+
* message, then `clear()`:
|
|
421
|
+
*
|
|
422
|
+
* ```ts
|
|
423
|
+
* await chat.sendMessage({ text }, { body: { attachments: files.refs } });
|
|
424
|
+
* files.clear();
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
declare function useAttachments(options: UseAttachmentsOptions): AttachmentsState;
|
|
428
|
+
|
|
297
429
|
interface UseAgentsOptions {
|
|
298
430
|
/** `useAgentChat(...).backend`, or your own. Must implement `listAgents`. */
|
|
299
431
|
backend: AgentBackend;
|
|
@@ -570,6 +702,7 @@ declare class AgentClient implements AgentBackend {
|
|
|
570
702
|
* what a caller then rides on `sendMessage({ text }, { body: { attachments: [...] } })`.
|
|
571
703
|
*/
|
|
572
704
|
uploadAttachment(file: File, options?: UploadAttachmentOptions): Promise<MessageAttachment>;
|
|
705
|
+
private uploadWithProgress;
|
|
573
706
|
promoteThread(id: string): Promise<OkResult>;
|
|
574
707
|
truncateFromMessage(threadId: string, messageId: string): Promise<OkResult>;
|
|
575
708
|
/** `GET /agent/models?agent=` — the models this caller may pick, grouped by provider. */
|
|
@@ -620,6 +753,20 @@ declare class AgentClient implements AgentBackend {
|
|
|
620
753
|
private handleResponse;
|
|
621
754
|
}
|
|
622
755
|
|
|
756
|
+
/** Draws a server-pushed component block. */
|
|
757
|
+
type AmbientRenderUi = (block: TranscriptUiBlock) => ReactNode;
|
|
758
|
+
/**
|
|
759
|
+
* How pushed components are drawn when no `renderUi` is passed — set by `<GenuiProvider>` (the
|
|
760
|
+
* `/genui` subpath) and read by `MessageItem`.
|
|
761
|
+
*/
|
|
762
|
+
declare const AmbientRenderUiContext: Context<AmbientRenderUi | null>;
|
|
763
|
+
/**
|
|
764
|
+
* The renderer `<GenuiProvider>` installed for pushed components, or `null` outside one. For a
|
|
765
|
+
* custom transcript built on `useTranscriptItem`: draw a `ui` block with it and you get what
|
|
766
|
+
* `MessageItem` draws.
|
|
767
|
+
*/
|
|
768
|
+
declare function useAmbientRenderUi(): AmbientRenderUi | null;
|
|
769
|
+
|
|
623
770
|
interface ChatInputProps {
|
|
624
771
|
onSubmit: (text: string) => void;
|
|
625
772
|
disabled?: boolean;
|
|
@@ -858,8 +1005,8 @@ type RenderTextFn = (text: string, ctx: {
|
|
|
858
1005
|
type RenderFilesFn = (files: TranscriptFile[]) => React__default.ReactNode;
|
|
859
1006
|
/**
|
|
860
1007
|
* Render a component the server pushed into the message — look `block.component` up in your own
|
|
861
|
-
* registry. Omitted →
|
|
862
|
-
* own component).
|
|
1008
|
+
* registry. Omitted → drawn by the enclosing `<GenuiProvider>` (`/genui`) if there is one, else not
|
|
1009
|
+
* drawn (there is no sensible default for an app's own component).
|
|
863
1010
|
*/
|
|
864
1011
|
type RenderUiFn = (block: TranscriptUiBlock) => React__default.ReactNode;
|
|
865
1012
|
/** Render the body of a reasoning run; the disclosure toggle around it stays this component's. */
|
|
@@ -894,7 +1041,10 @@ interface MessageRenderSlots {
|
|
|
894
1041
|
renderReasoning?: RenderReasoningFn;
|
|
895
1042
|
/** Draw files yourself — a gallery, a viewer. Omitted → images inline, everything else a link. */
|
|
896
1043
|
renderFiles?: RenderFilesFn;
|
|
897
|
-
/**
|
|
1044
|
+
/**
|
|
1045
|
+
* Draw a server-pushed component (a `ui` stream frame). Omitted → the enclosing `<GenuiProvider>`
|
|
1046
|
+
* draws it; without one, not drawn.
|
|
1047
|
+
*/
|
|
898
1048
|
renderUi?: RenderUiFn;
|
|
899
1049
|
/**
|
|
900
1050
|
* Extra content for the action row, after the built-in affordances and before usage — a badge
|
|
@@ -937,7 +1087,7 @@ interface MessageItemViewProps extends MessageRenderSlots {
|
|
|
937
1087
|
*/
|
|
938
1088
|
declare function MessageItem({ message, isStreaming, editable, onEditSubmit, regeneratable, onRegenerate, onFork, usage, createdAt, ...slots }: MessageItemProps): React__default.JSX.Element;
|
|
939
1089
|
/** The default markup for one modelled message — what `MessageItem` renders once it has an item. */
|
|
940
|
-
declare function MessageItemView({ item, ...
|
|
1090
|
+
declare function MessageItemView({ item, ...given }: MessageItemViewProps): React__default.JSX.Element;
|
|
941
1091
|
|
|
942
1092
|
interface MessageListClassNames {
|
|
943
1093
|
root?: string;
|
|
@@ -1607,4 +1757,4 @@ declare class QuotaBlockedError extends Error {
|
|
|
1607
1757
|
constructor(block: QuotaBlock);
|
|
1608
1758
|
}
|
|
1609
1759
|
|
|
1610
|
-
export { type AgentBackend, AgentBackendUnsupportedError, AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentMessageMetadata, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, AnyToolUIPart, type ApprovalCountdown, ApproveOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, ChatStatus, type ChatStreamRequest, type ChatStreamResponse, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type MessageFeedbackInput, type MessageFeedbackState, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type ModelOption, type ModelsState, QuotaBlockedError, type QuotaState, type QuotaToday, type ReconnectOptions, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type ResumeStreamRequest, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadPatch, 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, type UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseAgentsOptions, type UseApprovalCountdownOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseModelsOptions, type UseQuotaOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, approvalCountdown, backgroundRunsFromThread, createSkillsSource, filterAutocompleteItems, findActiveTrigger, formatElapsed, loadStoredSpeechLang, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, requireBackendMethod, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useAgents, useApprovalCountdown, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|
|
1760
|
+
export { type AgentBackend, AgentBackendUnsupportedError, AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentMessageMetadata, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, type AmbientRenderUi, AmbientRenderUiContext, AnyToolUIPart, type ApprovalCountdown, ApproveOptions, type AttachmentRejection, type AttachmentsState, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, ChatStatus, type ChatStreamRequest, type ChatStreamResponse, type ChatTranscript, type ClipboardLikeEvent, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type DragLikeEvent, type MessageFeedbackInput, 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 QuotaToday, type ReconnectOptions, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type ResumeStreamRequest, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StagedAttachment, type StagedAttachmentStatus, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadPatch, 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, type UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, 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, requireBackendMethod, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useAgents, useAmbientRenderUi, useApprovalCountdown, useAttachments, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|