@dudousxd/nestjs-agent-react 0.31.4 → 0.32.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/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as ai from 'ai';
2
2
  import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } from 'ai';
3
- import { A as AgentRequestError, a as AgentBackend, U as UploadAttachmentOptions, C as ChatStreamRequest, b as ChatStreamResponse, H as HttpErrorListener, c as AttachmentUploadStrategy } from './client-BuobfZtx.cjs';
4
- export { d as AgentBackendUnsupportedError, e as AgentClient, f as AgentClientOptions, g as AgentConnection, h as AgentHttpError, i as CancelResult, M as MessageFeedbackInput, Q as QueuedMessageUpdate, j as QueuedSendResult, R as ResumeStreamRequest, T as ThreadPatch, r as requireBackendMethod } from './client-BuobfZtx.cjs';
5
- import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, QueuePause, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
3
+ import { A as AgentRequestError, a as AgentBackend, U as UploadAttachmentOptions, C as ChatStreamRequest, b as ChatStreamResponse, H as HttpErrorListener, c as AttachmentUploadStrategy } from './client-C7eu9WMJ.cjs';
4
+ export { d as AgentBackendUnsupportedError, e as AgentClient, f as AgentClientOptions, g as AgentConnection, h as AgentHttpError, i as CancelResult, M as MessageFeedbackInput, Q as QueuedMessageUpdate, j as QueuedSendResult, R as ResumeStreamRequest, T as ThreadPatch, r as requireBackendMethod } from './client-C7eu9WMJ.cjs';
5
+ import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, PersonaCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, QueuePause, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
6
6
  export { ALL_AGENTS, ChatQueueState, ElicitationInput, ElicitationInputType, QueuePause, QueuePauseReason, QueuedMessageView, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
7
7
  import * as React from 'react';
8
8
  import React__default, { ReactNode, Context } from 'react';
@@ -107,6 +107,8 @@ interface AgentChatTransportOptions {
107
107
  credentials?: RequestCredentials;
108
108
  /** Named agent to run the turn (backend `agent` field). */
109
109
  agent?: string;
110
+ /** One of the agent's personas to answer as (backend `persona` field). */
111
+ persona?: string;
110
112
  /**
111
113
  * Extra body fields evaluated per send — the hook injects `threadId`
112
114
  * and `pageContext` through this. Returned object is spread into the
@@ -542,13 +544,21 @@ interface AgentsState {
542
544
  agents: AgentCatalogEntry[];
543
545
  /** The agent a turn runs as when none is named. */
544
546
  defaultAgent: string | null;
547
+ /**
548
+ * An agent's personas — the data behind a persona picker. `agent` omitted → the default agent's.
549
+ * `[]` for an agent that declares none (or before the list loads).
550
+ */
551
+ personasOf: (agent?: string) => PersonaCatalogEntry[];
552
+ /** The persona `agent` (default: the default agent) runs under when a send names none, or `null`. */
553
+ defaultPersonaOf: (agent?: string) => string | null;
545
554
  isLoading: boolean;
546
555
  error: Error | null;
547
556
  refresh: () => Promise<void>;
548
557
  }
549
558
  /**
550
- * The registered agents (`GET <base>/agents`) — the data behind an agent picker. Send the pick as
551
- * `useAgentChat({ agent })`, or pin it on a thread with `PATCH <base>/threads/:id { defaultAgent }`.
559
+ * The registered agents (`GET <base>/agents`) — the data behind an agent picker, and each agent's
560
+ * personas behind a persona picker. Send the pick as `useAgentChat({ agent, persona })`, or pin it on
561
+ * a thread with `PATCH <base>/threads/:id { defaultAgent, persona }`.
552
562
  */
553
563
  declare function useAgents(options?: UseAgentsOptions): AgentsState;
554
564
 
@@ -1653,6 +1663,10 @@ interface AgentMessageMetadata extends Partial<StoredTurnMetadata> {
1653
1663
  costUsd?: number | null;
1654
1664
  /** ISO timestamp: the stored row's `createdAt` (a merged turn: its first row's), or when a live turn started streaming. */
1655
1665
  createdAt?: string;
1666
+ /** The agent that wrote a replayed message, when the row names one (`StoredMessage.agentName`). */
1667
+ agentName?: string;
1668
+ /** The persona the turn that wrote a replayed message ran under (`StoredMessage.persona`). */
1669
+ persona?: string;
1656
1670
  /** Host-defined keys: `StoredMessage.metadata` and the stream's `message-metadata` frames. */
1657
1671
  [key: string]: unknown;
1658
1672
  }
@@ -1710,6 +1724,13 @@ interface UseAgentChatOptions<B extends AgentBackend = AgentBackend> {
1710
1724
  reconnect?: ReconnectOptions | false;
1711
1725
  /** Named agent to run each turn. */
1712
1726
  agent?: string;
1727
+ /**
1728
+ * One of the agent's personas (`GET <base>/agents` lists them) to answer as. Read per send, so a
1729
+ * picker can switch it between messages; the server pins it on the thread, and `threadPersona`
1730
+ * reports it back. Omitted → the thread's pinned persona, else the agent's default. A single send
1731
+ * can name its own: `sendMessage(message, { body: { persona } })`.
1732
+ */
1733
+ persona?: string;
1713
1734
  /**
1714
1735
  * Thread this chat is bound to. Omitted → the backend creates one on the first send
1715
1736
  * ({@link UseAgentChatOptions.onThreadCreated}). Changing it switches the chat to that thread:
@@ -1971,6 +1992,11 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
1971
1992
  queue: ChatQueue;
1972
1993
  /** The model picker: `list`, `selected`, `select(id)`, `pinToThread(id)`. */
1973
1994
  models: ChatModels;
1995
+ /**
1996
+ * The persona pinned on this thread (`ThreadSummary.persona`), or `null` when none is — what a
1997
+ * persona picker on a reopened thread starts from (`?? agent.defaultPersona`).
1998
+ */
1999
+ threadPersona: string | null;
1974
2000
  /** The caller's budget (`GET <base>/quota`); `quota.blocked` gates sends. */
1975
2001
  quota: QuotaState;
1976
2002
  /** The window blocking sends right now (the `blocked` option, else the quota report's). */
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as ai from 'ai';
2
2
  import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } from 'ai';
3
- import { A as AgentRequestError, a as AgentBackend, U as UploadAttachmentOptions, C as ChatStreamRequest, b as ChatStreamResponse, H as HttpErrorListener, c as AttachmentUploadStrategy } from './client-BuobfZtx.js';
4
- export { d as AgentBackendUnsupportedError, e as AgentClient, f as AgentClientOptions, g as AgentConnection, h as AgentHttpError, i as CancelResult, M as MessageFeedbackInput, Q as QueuedMessageUpdate, j as QueuedSendResult, R as ResumeStreamRequest, T as ThreadPatch, r as requireBackendMethod } from './client-BuobfZtx.js';
5
- import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, QueuePause, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
3
+ import { A as AgentRequestError, a as AgentBackend, U as UploadAttachmentOptions, C as ChatStreamRequest, b as ChatStreamResponse, H as HttpErrorListener, c as AttachmentUploadStrategy } from './client-C7eu9WMJ.js';
4
+ export { d as AgentBackendUnsupportedError, e as AgentClient, f as AgentClientOptions, g as AgentConnection, h as AgentHttpError, i as CancelResult, M as MessageFeedbackInput, Q as QueuedMessageUpdate, j as QueuedSendResult, R as ResumeStreamRequest, T as ThreadPatch, r as requireBackendMethod } from './client-C7eu9WMJ.js';
5
+ import { MessageAttachment, AgentClientConfig, AgentCatalogEntry, PersonaCatalogEntry, ModelCatalogEntry, ModelCatalogView, ModelCatalogLock, QuotaReport, QuotaWindow, QuotaBlock, QuotaWarning, MessageFeedback, MessageFeedbackValue, ThreadSummary, StoredMessage, QueuePause, ToolCatalogEntry } from '@dudousxd/nestjs-agent-core';
6
6
  export { ALL_AGENTS, ChatQueueState, ElicitationInput, ElicitationInputType, QueuePause, QueuePauseReason, QueuedMessageView, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
7
7
  import * as React from 'react';
8
8
  import React__default, { ReactNode, Context } from 'react';
@@ -107,6 +107,8 @@ interface AgentChatTransportOptions {
107
107
  credentials?: RequestCredentials;
108
108
  /** Named agent to run the turn (backend `agent` field). */
109
109
  agent?: string;
110
+ /** One of the agent's personas to answer as (backend `persona` field). */
111
+ persona?: string;
110
112
  /**
111
113
  * Extra body fields evaluated per send — the hook injects `threadId`
112
114
  * and `pageContext` through this. Returned object is spread into the
@@ -542,13 +544,21 @@ interface AgentsState {
542
544
  agents: AgentCatalogEntry[];
543
545
  /** The agent a turn runs as when none is named. */
544
546
  defaultAgent: string | null;
547
+ /**
548
+ * An agent's personas — the data behind a persona picker. `agent` omitted → the default agent's.
549
+ * `[]` for an agent that declares none (or before the list loads).
550
+ */
551
+ personasOf: (agent?: string) => PersonaCatalogEntry[];
552
+ /** The persona `agent` (default: the default agent) runs under when a send names none, or `null`. */
553
+ defaultPersonaOf: (agent?: string) => string | null;
545
554
  isLoading: boolean;
546
555
  error: Error | null;
547
556
  refresh: () => Promise<void>;
548
557
  }
549
558
  /**
550
- * The registered agents (`GET <base>/agents`) — the data behind an agent picker. Send the pick as
551
- * `useAgentChat({ agent })`, or pin it on a thread with `PATCH <base>/threads/:id { defaultAgent }`.
559
+ * The registered agents (`GET <base>/agents`) — the data behind an agent picker, and each agent's
560
+ * personas behind a persona picker. Send the pick as `useAgentChat({ agent, persona })`, or pin it on
561
+ * a thread with `PATCH <base>/threads/:id { defaultAgent, persona }`.
552
562
  */
553
563
  declare function useAgents(options?: UseAgentsOptions): AgentsState;
554
564
 
@@ -1653,6 +1663,10 @@ interface AgentMessageMetadata extends Partial<StoredTurnMetadata> {
1653
1663
  costUsd?: number | null;
1654
1664
  /** ISO timestamp: the stored row's `createdAt` (a merged turn: its first row's), or when a live turn started streaming. */
1655
1665
  createdAt?: string;
1666
+ /** The agent that wrote a replayed message, when the row names one (`StoredMessage.agentName`). */
1667
+ agentName?: string;
1668
+ /** The persona the turn that wrote a replayed message ran under (`StoredMessage.persona`). */
1669
+ persona?: string;
1656
1670
  /** Host-defined keys: `StoredMessage.metadata` and the stream's `message-metadata` frames. */
1657
1671
  [key: string]: unknown;
1658
1672
  }
@@ -1710,6 +1724,13 @@ interface UseAgentChatOptions<B extends AgentBackend = AgentBackend> {
1710
1724
  reconnect?: ReconnectOptions | false;
1711
1725
  /** Named agent to run each turn. */
1712
1726
  agent?: string;
1727
+ /**
1728
+ * One of the agent's personas (`GET <base>/agents` lists them) to answer as. Read per send, so a
1729
+ * picker can switch it between messages; the server pins it on the thread, and `threadPersona`
1730
+ * reports it back. Omitted → the thread's pinned persona, else the agent's default. A single send
1731
+ * can name its own: `sendMessage(message, { body: { persona } })`.
1732
+ */
1733
+ persona?: string;
1713
1734
  /**
1714
1735
  * Thread this chat is bound to. Omitted → the backend creates one on the first send
1715
1736
  * ({@link UseAgentChatOptions.onThreadCreated}). Changing it switches the chat to that thread:
@@ -1971,6 +1992,11 @@ declare function useAgentChat<B extends AgentBackend = AgentBackend>(options?: U
1971
1992
  queue: ChatQueue;
1972
1993
  /** The model picker: `list`, `selected`, `select(id)`, `pinToThread(id)`. */
1973
1994
  models: ChatModels;
1995
+ /**
1996
+ * The persona pinned on this thread (`ThreadSummary.persona`), or `null` when none is — what a
1997
+ * persona picker on a reopened thread starts from (`?? agent.defaultPersona`).
1998
+ */
1999
+ threadPersona: string | null;
1974
2000
  /** The caller's budget (`GET <base>/quota`); `quota.blocked` gates sends. */
1975
2001
  quota: QuotaState;
1976
2002
  /** The window blocking sends right now (the `blocked` option, else the quota report's). */