@dudousxd/nestjs-agent-react 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -6
- package/dist/index.cjs +20 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +17 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } fro
|
|
|
3
3
|
import { A as AgentBackend, U as UploadAttachmentOptions, H as HttpErrorListener, a as AttachmentUploadStrategy } from './client-D4ZSbZJ8.cjs';
|
|
4
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
5
|
import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
|
|
6
|
-
export { ElicitationInput, ElicitationInputType, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
|
|
6
|
+
export { ALL_AGENTS, 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
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';
|
|
@@ -761,6 +761,16 @@ interface RejectInput {
|
|
|
761
761
|
via?: string;
|
|
762
762
|
}
|
|
763
763
|
interface TranscriptItemOptions {
|
|
764
|
+
/**
|
|
765
|
+
* A transcript nobody acts on (an audit view, a shared or archived conversation): no approve /
|
|
766
|
+
* reject, answer / skip, edit, fork, regenerate or stop — whatever handlers or backend are in
|
|
767
|
+
* scope. Parked approvals and question sets still render, with their actions unavailable.
|
|
768
|
+
*
|
|
769
|
+
* Without it the decision handlers DEFAULT to the in-scope backend (`<AgentProvider>`'s), so a
|
|
770
|
+
* parked call is actionable with no wiring; a read-only surface would otherwise have to pass
|
|
771
|
+
* `onApprove: null`, `onReject: null`, `onAnswer: null` and `onSkip: null` one by one.
|
|
772
|
+
*/
|
|
773
|
+
readOnly?: boolean;
|
|
764
774
|
/** User messages get an inline edit-and-resubmit machine. */
|
|
765
775
|
editable?: boolean;
|
|
766
776
|
onEditSubmit?: (input: EditSubmitInput) => void | Promise<void>;
|
|
@@ -987,6 +997,11 @@ interface MessageListProps {
|
|
|
987
997
|
reasoningLabel?: React__default.ReactNode;
|
|
988
998
|
/** Extra content for one message's action row — e.g. a badge naming which agent answered. */
|
|
989
999
|
getMeta?: (message: UIMessage) => React__default.ReactNode;
|
|
1000
|
+
/**
|
|
1001
|
+
* Nobody acts on this list (an audit or shared view): parked approvals and question sets render
|
|
1002
|
+
* without their actions, and no fork / edit / regenerate — see `useChatTranscript({ readOnly })`.
|
|
1003
|
+
*/
|
|
1004
|
+
readOnly?: boolean;
|
|
990
1005
|
/** When set, every message gets a "Fork" affordance calling back with its id. */
|
|
991
1006
|
onFork?: (input: MessageActionInput) => void | Promise<void>;
|
|
992
1007
|
/** User messages get an inline edit-and-resubmit affordance. */
|
|
@@ -1019,7 +1034,7 @@ interface MessageListProps {
|
|
|
1019
1034
|
* Every decision here comes from `useChatTranscript`; the file below it is markup. A host that
|
|
1020
1035
|
* wants a different layout drives that hook directly and never imports this component.
|
|
1021
1036
|
*/
|
|
1022
|
-
declare function MessageList({ messages, status, renderToolPart, renderToolGroup, renderText, renderReasoning, renderFiles, renderUi, reasoningLabel, getMeta, onFork, editable, onEditSubmit, regeneratable, onRegenerate, getUsage, getCreatedAt, emptyState, typingIndicator, followUps, onFollowUpClick, error, onRetry, classNames, }: MessageListProps): React__default.JSX.Element;
|
|
1037
|
+
declare function MessageList({ messages, status, renderToolPart, renderToolGroup, renderText, renderReasoning, renderFiles, renderUi, reasoningLabel, getMeta, readOnly, onFork, editable, onEditSubmit, regeneratable, onRegenerate, getUsage, getCreatedAt, emptyState, typingIndicator, followUps, onFollowUpClick, error, onRetry, classNames, }: MessageListProps): React__default.JSX.Element;
|
|
1023
1038
|
|
|
1024
1039
|
/**
|
|
1025
1040
|
* Languages the dictation mic offers. The Web Speech API expects a
|
|
@@ -1256,7 +1271,11 @@ interface UseToolCatalogOptions {
|
|
|
1256
1271
|
* (the shared copy is keyed by it): a backend constructed inline refetches every render.
|
|
1257
1272
|
*/
|
|
1258
1273
|
backend?: ToolsBackend;
|
|
1259
|
-
/**
|
|
1274
|
+
/**
|
|
1275
|
+
* The agent whose tools to list. Omitted → the server's default agent. {@link ALL_AGENTS} (`'*'`)
|
|
1276
|
+
* → every tool the actor reaches through any agent, each once — for an app with several agents
|
|
1277
|
+
* whose conversations one surface shows.
|
|
1278
|
+
*/
|
|
1260
1279
|
agent?: string;
|
|
1261
1280
|
/** `false` holds the request (e.g. until the user is signed in). Default `true`. */
|
|
1262
1281
|
enabled?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } fro
|
|
|
3
3
|
import { A as AgentBackend, U as UploadAttachmentOptions, H as HttpErrorListener, a as AttachmentUploadStrategy } from './client-D4ZSbZJ8.js';
|
|
4
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
5
|
import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
|
|
6
|
-
export { ElicitationInput, ElicitationInputType, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
|
|
6
|
+
export { ALL_AGENTS, 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
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';
|
|
@@ -761,6 +761,16 @@ interface RejectInput {
|
|
|
761
761
|
via?: string;
|
|
762
762
|
}
|
|
763
763
|
interface TranscriptItemOptions {
|
|
764
|
+
/**
|
|
765
|
+
* A transcript nobody acts on (an audit view, a shared or archived conversation): no approve /
|
|
766
|
+
* reject, answer / skip, edit, fork, regenerate or stop — whatever handlers or backend are in
|
|
767
|
+
* scope. Parked approvals and question sets still render, with their actions unavailable.
|
|
768
|
+
*
|
|
769
|
+
* Without it the decision handlers DEFAULT to the in-scope backend (`<AgentProvider>`'s), so a
|
|
770
|
+
* parked call is actionable with no wiring; a read-only surface would otherwise have to pass
|
|
771
|
+
* `onApprove: null`, `onReject: null`, `onAnswer: null` and `onSkip: null` one by one.
|
|
772
|
+
*/
|
|
773
|
+
readOnly?: boolean;
|
|
764
774
|
/** User messages get an inline edit-and-resubmit machine. */
|
|
765
775
|
editable?: boolean;
|
|
766
776
|
onEditSubmit?: (input: EditSubmitInput) => void | Promise<void>;
|
|
@@ -987,6 +997,11 @@ interface MessageListProps {
|
|
|
987
997
|
reasoningLabel?: React__default.ReactNode;
|
|
988
998
|
/** Extra content for one message's action row — e.g. a badge naming which agent answered. */
|
|
989
999
|
getMeta?: (message: UIMessage) => React__default.ReactNode;
|
|
1000
|
+
/**
|
|
1001
|
+
* Nobody acts on this list (an audit or shared view): parked approvals and question sets render
|
|
1002
|
+
* without their actions, and no fork / edit / regenerate — see `useChatTranscript({ readOnly })`.
|
|
1003
|
+
*/
|
|
1004
|
+
readOnly?: boolean;
|
|
990
1005
|
/** When set, every message gets a "Fork" affordance calling back with its id. */
|
|
991
1006
|
onFork?: (input: MessageActionInput) => void | Promise<void>;
|
|
992
1007
|
/** User messages get an inline edit-and-resubmit affordance. */
|
|
@@ -1019,7 +1034,7 @@ interface MessageListProps {
|
|
|
1019
1034
|
* Every decision here comes from `useChatTranscript`; the file below it is markup. A host that
|
|
1020
1035
|
* wants a different layout drives that hook directly and never imports this component.
|
|
1021
1036
|
*/
|
|
1022
|
-
declare function MessageList({ messages, status, renderToolPart, renderToolGroup, renderText, renderReasoning, renderFiles, renderUi, reasoningLabel, getMeta, onFork, editable, onEditSubmit, regeneratable, onRegenerate, getUsage, getCreatedAt, emptyState, typingIndicator, followUps, onFollowUpClick, error, onRetry, classNames, }: MessageListProps): React__default.JSX.Element;
|
|
1037
|
+
declare function MessageList({ messages, status, renderToolPart, renderToolGroup, renderText, renderReasoning, renderFiles, renderUi, reasoningLabel, getMeta, readOnly, onFork, editable, onEditSubmit, regeneratable, onRegenerate, getUsage, getCreatedAt, emptyState, typingIndicator, followUps, onFollowUpClick, error, onRetry, classNames, }: MessageListProps): React__default.JSX.Element;
|
|
1023
1038
|
|
|
1024
1039
|
/**
|
|
1025
1040
|
* Languages the dictation mic offers. The Web Speech API expects a
|
|
@@ -1256,7 +1271,11 @@ interface UseToolCatalogOptions {
|
|
|
1256
1271
|
* (the shared copy is keyed by it): a backend constructed inline refetches every render.
|
|
1257
1272
|
*/
|
|
1258
1273
|
backend?: ToolsBackend;
|
|
1259
|
-
/**
|
|
1274
|
+
/**
|
|
1275
|
+
* The agent whose tools to list. Omitted → the server's default agent. {@link ALL_AGENTS} (`'*'`)
|
|
1276
|
+
* → every tool the actor reaches through any agent, each once — for an app with several agents
|
|
1277
|
+
* whose conversations one surface shows.
|
|
1278
|
+
*/
|
|
1260
1279
|
agent?: string;
|
|
1261
1280
|
/** `false` holds the request (e.g. until the user is signed in). Default `true`. */
|
|
1262
1281
|
enabled?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -3785,7 +3785,7 @@ function useChatTranscript(options) {
|
|
|
3785
3785
|
},
|
|
3786
3786
|
scroll,
|
|
3787
3787
|
stop: {
|
|
3788
|
-
available: isBusy && options.onStop !== void 0,
|
|
3788
|
+
available: isBusy && options.readOnly !== true && options.onStop !== void 0,
|
|
3789
3789
|
isStopping: stopRequested,
|
|
3790
3790
|
stop
|
|
3791
3791
|
}
|
|
@@ -4055,11 +4055,12 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
4055
4055
|
...options.toolCatalog !== void 0 ? {
|
|
4056
4056
|
toolCatalog: options.toolCatalog
|
|
4057
4057
|
} : {},
|
|
4058
|
-
|
|
4058
|
+
// Read-only still lifts question sets into their block, so the outcome shows.
|
|
4059
|
+
...handlers.onAnswer !== void 0 || options.readOnly === true && options.onAnswer !== null ? {
|
|
4059
4060
|
elicitation: {
|
|
4060
4061
|
picked: /* @__PURE__ */ __name((toolCallId, questionId) => picks.get(pickKey(toolCallId, questionId)), "picked"),
|
|
4061
4062
|
pick,
|
|
4062
|
-
canAnswer:
|
|
4063
|
+
canAnswer: handlers.onAnswer !== void 0,
|
|
4063
4064
|
canSkip: handlers.onSkip !== void 0,
|
|
4064
4065
|
answer,
|
|
4065
4066
|
skip,
|
|
@@ -4087,7 +4088,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
4087
4088
|
copy: callbacks.copy
|
|
4088
4089
|
},
|
|
4089
4090
|
edit: {
|
|
4090
|
-
available: isUser && options.editable === true && options.onEditSubmit !== void 0,
|
|
4091
|
+
available: isUser && options.readOnly !== true && options.editable === true && options.onEditSubmit !== void 0,
|
|
4091
4092
|
isEditing,
|
|
4092
4093
|
draft: draft ?? text,
|
|
4093
4094
|
canSave: (draft ?? "").trim().length > 0,
|
|
@@ -4103,11 +4104,11 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
4103
4104
|
}), "getTextareaProps")
|
|
4104
4105
|
},
|
|
4105
4106
|
fork: {
|
|
4106
|
-
available: options.onFork !== void 0,
|
|
4107
|
+
available: options.readOnly !== true && options.onFork !== void 0,
|
|
4107
4108
|
run: callbacks.fork
|
|
4108
4109
|
},
|
|
4109
4110
|
regenerate: {
|
|
4110
|
-
available: isLastAssistant && options.regeneratable === true && options.onRegenerate !== void 0,
|
|
4111
|
+
available: isLastAssistant && options.readOnly !== true && options.regeneratable === true && options.onRegenerate !== void 0,
|
|
4111
4112
|
run: callbacks.regenerate
|
|
4112
4113
|
}
|
|
4113
4114
|
});
|
|
@@ -4116,7 +4117,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
4116
4117
|
}
|
|
4117
4118
|
__name(useTranscriptItems, "useTranscriptItems");
|
|
4118
4119
|
function settleHandlers(options, backend) {
|
|
4119
|
-
const pick = /* @__PURE__ */ __name((own, fallback2) => own === null ? void 0 : own ?? fallback2, "pick");
|
|
4120
|
+
const pick = /* @__PURE__ */ __name((own, fallback2) => options.readOnly === true || own === null ? void 0 : own ?? fallback2, "pick");
|
|
4120
4121
|
return {
|
|
4121
4122
|
onAnswer: pick(options.onAnswer, backend.answerToolCall ? async (input) => {
|
|
4122
4123
|
await backend.answerToolCall?.(input);
|
|
@@ -4409,10 +4410,13 @@ function joinClasses(...entries) {
|
|
|
4409
4410
|
__name(joinClasses, "joinClasses");
|
|
4410
4411
|
|
|
4411
4412
|
// src/components/message-list.tsx
|
|
4412
|
-
function MessageList({ messages, status, renderToolPart, renderToolGroup, renderText, renderReasoning, renderFiles, renderUi, reasoningLabel, getMeta, onFork, editable, onEditSubmit, regeneratable, onRegenerate, getUsage, getCreatedAt, emptyState, typingIndicator, followUps, onFollowUpClick, error, onRetry, classNames }) {
|
|
4413
|
+
function MessageList({ messages, status, renderToolPart, renderToolGroup, renderText, renderReasoning, renderFiles, renderUi, reasoningLabel, getMeta, readOnly, onFork, editable, onEditSubmit, regeneratable, onRegenerate, getUsage, getCreatedAt, emptyState, typingIndicator, followUps, onFollowUpClick, error, onRetry, classNames }) {
|
|
4413
4414
|
const transcript = useChatTranscript({
|
|
4414
4415
|
messages,
|
|
4415
4416
|
status,
|
|
4417
|
+
...readOnly !== void 0 ? {
|
|
4418
|
+
readOnly
|
|
4419
|
+
} : {},
|
|
4416
4420
|
...onFork ? {
|
|
4417
4421
|
onFork
|
|
4418
4422
|
} : {},
|
|
@@ -4877,6 +4881,7 @@ function isPromise(value) {
|
|
|
4877
4881
|
__name(isPromise, "isPromise");
|
|
4878
4882
|
|
|
4879
4883
|
// src/presentation/use-tool-catalog.ts
|
|
4884
|
+
import { ALL_AGENTS } from "@dudousxd/nestjs-agent-core";
|
|
4880
4885
|
import { useCallback as useCallback10, useEffect as useEffect13, useMemo as useMemo10, useState as useState13 } from "react";
|
|
4881
4886
|
var shared2 = /* @__PURE__ */ new WeakMap();
|
|
4882
4887
|
function load2(client, agent) {
|
|
@@ -5279,7 +5284,7 @@ function useAgentChat(options = {}) {
|
|
|
5279
5284
|
const settlingRunIdRef = useRef12(void 0);
|
|
5280
5285
|
const autoResumeRunIdRef = useRef12(void 0);
|
|
5281
5286
|
const [activeRunId, setActiveRunId] = useState15(null);
|
|
5282
|
-
const [
|
|
5287
|
+
const [historyFor, setHistoryFor] = useState15(void 0);
|
|
5283
5288
|
const [historyError, setHistoryError] = useState15(null);
|
|
5284
5289
|
const [threadModel, setThreadModel] = useState15(null);
|
|
5285
5290
|
const [pickedModel, setPickedModel] = useState15(void 0);
|
|
@@ -5444,7 +5449,6 @@ function useAgentChat(options = {}) {
|
|
|
5444
5449
|
const wantResume = current.resume !== false && current.resumeRunId === void 0;
|
|
5445
5450
|
if (!wantHistory && !wantResume) return;
|
|
5446
5451
|
let cancelled = false;
|
|
5447
|
-
if (wantHistory) setIsLoadingHistory(true);
|
|
5448
5452
|
client.getThread(threadId).then((thread) => {
|
|
5449
5453
|
if (cancelled || thread == null) return;
|
|
5450
5454
|
const active = thread.activeRunId ?? null;
|
|
@@ -5465,17 +5469,17 @@ function useAgentChat(options = {}) {
|
|
|
5465
5469
|
if (cancelled) return;
|
|
5466
5470
|
setHistoryError(error instanceof Error ? error : new Error(String(error)));
|
|
5467
5471
|
}).finally(() => {
|
|
5468
|
-
if (!cancelled)
|
|
5472
|
+
if (!cancelled) setHistoryFor(threadId);
|
|
5469
5473
|
});
|
|
5470
5474
|
return () => {
|
|
5471
5475
|
cancelled = true;
|
|
5472
|
-
setIsLoadingHistory(false);
|
|
5473
5476
|
};
|
|
5474
5477
|
}, [
|
|
5475
5478
|
client,
|
|
5476
5479
|
chatId,
|
|
5477
5480
|
options.threadId
|
|
5478
5481
|
]);
|
|
5482
|
+
const isLoadingHistory = options.threadId !== void 0 && options.threadId !== createdThreadId.current && options.history !== false && options.initialMessages === void 0 && historyFor !== options.threadId;
|
|
5479
5483
|
const turnInFlight = useRef12(false);
|
|
5480
5484
|
const isTurnInFlight = useCallback11(() => turnInFlight.current || transport.isAttemptLive, [
|
|
5481
5485
|
transport
|
|
@@ -5885,6 +5889,7 @@ var QuotaBlockedError = class extends Error {
|
|
|
5885
5889
|
}
|
|
5886
5890
|
};
|
|
5887
5891
|
export {
|
|
5892
|
+
ALL_AGENTS,
|
|
5888
5893
|
AgentBackendUnsupportedError,
|
|
5889
5894
|
AgentChatTransport,
|
|
5890
5895
|
AgentClient,
|