@dudousxd/nestjs-agent-react 0.31.5 → 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/{client-BuobfZtx.d.cts → client-C7eu9WMJ.d.cts} +3 -1
- package/dist/{client-BuobfZtx.d.ts → client-C7eu9WMJ.d.ts} +3 -1
- package/dist/index.cjs +25 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -5
- package/dist/index.d.ts +31 -5
- package/dist/index.js +106 -83
- package/dist/index.js.map +1 -1
- package/dist/media.d.cts +1 -1
- package/dist/media.d.ts +1 -1
- package/package.json +2 -2
|
@@ -37,10 +37,12 @@ interface ThreadPatch {
|
|
|
37
37
|
defaultAgent?: string | null;
|
|
38
38
|
/** Pin a catalog model on the thread; `null` unpins it. */
|
|
39
39
|
model?: string | null;
|
|
40
|
+
/** Pin one of the agent's personas on the thread; `null` clears it (the agent's default applies). */
|
|
41
|
+
persona?: string | null;
|
|
40
42
|
}
|
|
41
43
|
/** Starting a turn: the body `POST <base>/chat` takes (see docs/stream-protocol.md). */
|
|
42
44
|
interface ChatStreamRequest {
|
|
43
|
-
/** `{ message, threadId?, agent?, model?, attachments?, pageContext?, regenerate?, … }`. */
|
|
45
|
+
/** `{ message, threadId?, agent?, persona?, model?, attachments?, pageContext?, regenerate?, … }`. */
|
|
44
46
|
body: Record<string, unknown>;
|
|
45
47
|
/** Per-request headers the AI SDK was handed for this send. */
|
|
46
48
|
headers?: Record<string, string>;
|
|
@@ -37,10 +37,12 @@ interface ThreadPatch {
|
|
|
37
37
|
defaultAgent?: string | null;
|
|
38
38
|
/** Pin a catalog model on the thread; `null` unpins it. */
|
|
39
39
|
model?: string | null;
|
|
40
|
+
/** Pin one of the agent's personas on the thread; `null` clears it (the agent's default applies). */
|
|
41
|
+
persona?: string | null;
|
|
40
42
|
}
|
|
41
43
|
/** Starting a turn: the body `POST <base>/chat` takes (see docs/stream-protocol.md). */
|
|
42
44
|
interface ChatStreamRequest {
|
|
43
|
-
/** `{ message, threadId?, agent?, model?, attachments?, pageContext?, regenerate?, … }`. */
|
|
45
|
+
/** `{ message, threadId?, agent?, persona?, model?, attachments?, pageContext?, regenerate?, … }`. */
|
|
44
46
|
body: Record<string, unknown>;
|
|
45
47
|
/** Per-request headers the AI SDK was handed for this send. */
|
|
46
48
|
headers?: Record<string, string>;
|
package/dist/index.cjs
CHANGED
|
@@ -639,6 +639,7 @@ var AgentChatTransport = class {
|
|
|
639
639
|
const message = lastMessage ? extractText(lastMessage) : "";
|
|
640
640
|
const body = {
|
|
641
641
|
...this.options.agent !== void 0 ? { agent: this.options.agent } : {},
|
|
642
|
+
...this.options.persona !== void 0 ? { persona: this.options.persona } : {},
|
|
642
643
|
...this.options.getBody?.() ?? {},
|
|
643
644
|
...options.body ?? {},
|
|
644
645
|
message
|
|
@@ -2303,16 +2304,24 @@ function useAgents(options = {}) {
|
|
|
2303
2304
|
"",
|
|
2304
2305
|
enabled
|
|
2305
2306
|
);
|
|
2307
|
+
const find = (0, import_react9.useCallback)(
|
|
2308
|
+
(name) => (data ?? []).find(
|
|
2309
|
+
(agent) => name === void 0 ? agent.isDefault === true : agent.name === name
|
|
2310
|
+
),
|
|
2311
|
+
[data]
|
|
2312
|
+
);
|
|
2306
2313
|
return (0, import_react9.useMemo)(() => {
|
|
2307
2314
|
const agents = data ?? [];
|
|
2308
2315
|
return {
|
|
2309
2316
|
agents,
|
|
2310
2317
|
defaultAgent: agents.find((agent) => agent.isDefault === true)?.name ?? null,
|
|
2318
|
+
personasOf: (agent) => find(agent)?.personas ?? [],
|
|
2319
|
+
defaultPersonaOf: (agent) => find(agent)?.defaultPersona ?? null,
|
|
2311
2320
|
isLoading,
|
|
2312
2321
|
error,
|
|
2313
2322
|
refresh
|
|
2314
2323
|
};
|
|
2315
|
-
}, [data, isLoading, error, refresh]);
|
|
2324
|
+
}, [data, find, isLoading, error, refresh]);
|
|
2316
2325
|
}
|
|
2317
2326
|
|
|
2318
2327
|
// src/catalog/use-models.ts
|
|
@@ -5156,6 +5165,8 @@ function storedMessageToUiMessage(message) {
|
|
|
5156
5165
|
...message.metadata,
|
|
5157
5166
|
...message.feedback !== void 0 ? { feedback: message.feedback } : {},
|
|
5158
5167
|
...message.createdAt ? { createdAt: message.createdAt } : {},
|
|
5168
|
+
...message.agentName !== void 0 ? { agentName: message.agentName } : {},
|
|
5169
|
+
...message.persona !== void 0 ? { persona: message.persona } : {},
|
|
5159
5170
|
...message.usage !== void 0 ? {
|
|
5160
5171
|
usage: {
|
|
5161
5172
|
inputTokens: message.usage.inputTokens,
|
|
@@ -5206,7 +5217,9 @@ function mergeTurn(rows) {
|
|
|
5206
5217
|
...Object.assign({}, ...rows.map((row) => row.metadata ?? {})),
|
|
5207
5218
|
...usage !== void 0 ? { usage } : {},
|
|
5208
5219
|
...feedback !== void 0 ? { feedback } : {},
|
|
5209
|
-
...createdAt ? { createdAt } : {}
|
|
5220
|
+
...createdAt ? { createdAt } : {},
|
|
5221
|
+
...lastRow.agentName !== void 0 ? { agentName: lastRow.agentName } : {},
|
|
5222
|
+
...lastRow.persona !== void 0 ? { persona: lastRow.persona } : {}
|
|
5210
5223
|
};
|
|
5211
5224
|
return {
|
|
5212
5225
|
id: lastRow.id,
|
|
@@ -5313,6 +5326,7 @@ function useAgentChat(options = {}) {
|
|
|
5313
5326
|
const [historyError, setHistoryError] = (0, import_react23.useState)(null);
|
|
5314
5327
|
const [runError, setRunError] = (0, import_react23.useState)(null);
|
|
5315
5328
|
const [threadModel, setThreadModel] = (0, import_react23.useState)(null);
|
|
5329
|
+
const [threadPersona, setThreadPersona] = (0, import_react23.useState)(null);
|
|
5316
5330
|
const [pickedModel, setPickedModel] = (0, import_react23.useState)(void 0);
|
|
5317
5331
|
const pickedModelRef = (0, import_react23.useRef)(pickedModel);
|
|
5318
5332
|
pickedModelRef.current = pickedModel;
|
|
@@ -5336,6 +5350,7 @@ function useAgentChat(options = {}) {
|
|
|
5336
5350
|
const threadWaiters = (0, import_react23.useRef)([]);
|
|
5337
5351
|
const turnBody = (0, import_react23.useCallback)(() => {
|
|
5338
5352
|
const current = latest.current;
|
|
5353
|
+
if (current.persona !== void 0) setThreadPersona(current.persona);
|
|
5339
5354
|
const pageContext = current.getPageContext?.() ?? null;
|
|
5340
5355
|
const threadId = currentThreadId();
|
|
5341
5356
|
const model = current.model ?? (lockedRef.current ? void 0 : pickedModelRef.current);
|
|
@@ -5343,6 +5358,7 @@ function useAgentChat(options = {}) {
|
|
|
5343
5358
|
// Read per send: a host that switches agents before the first message (a picker on a new
|
|
5344
5359
|
// chat) sends the one picked now, not the one this chat mounted with.
|
|
5345
5360
|
...current.agent !== void 0 ? { agent: current.agent } : {},
|
|
5361
|
+
...current.persona !== void 0 ? { persona: current.persona } : {},
|
|
5346
5362
|
...threadId !== void 0 ? { threadId } : {},
|
|
5347
5363
|
...model !== void 0 ? { model } : {},
|
|
5348
5364
|
...pageContext ? { pageContext } : {}
|
|
@@ -5511,6 +5527,7 @@ function useAgentChat(options = {}) {
|
|
|
5511
5527
|
setRunId(void 0);
|
|
5512
5528
|
setActiveRunId(null);
|
|
5513
5529
|
setThreadModel(null);
|
|
5530
|
+
setThreadPersona(null);
|
|
5514
5531
|
setPickedModel(void 0);
|
|
5515
5532
|
setBackgroundRuns([]);
|
|
5516
5533
|
setHistoryError(null);
|
|
@@ -5539,6 +5556,7 @@ function useAgentChat(options = {}) {
|
|
|
5539
5556
|
const stored = Array.isArray(thread.messages) ? thread.messages : [];
|
|
5540
5557
|
setActiveRunId(active);
|
|
5541
5558
|
setThreadModel(thread.model ?? null);
|
|
5559
|
+
setThreadPersona(thread.persona ?? null);
|
|
5542
5560
|
setHistoryError(null);
|
|
5543
5561
|
const queue2 = thread.queue ?? EMPTY_QUEUE;
|
|
5544
5562
|
applyQueue(queue2);
|
|
@@ -6150,6 +6168,11 @@ function useAgentChat(options = {}) {
|
|
|
6150
6168
|
queue,
|
|
6151
6169
|
/** The model picker: `list`, `selected`, `select(id)`, `pinToThread(id)`. */
|
|
6152
6170
|
models,
|
|
6171
|
+
/**
|
|
6172
|
+
* The persona pinned on this thread (`ThreadSummary.persona`), or `null` when none is — what a
|
|
6173
|
+
* persona picker on a reopened thread starts from (`?? agent.defaultPersona`).
|
|
6174
|
+
*/
|
|
6175
|
+
threadPersona,
|
|
6153
6176
|
/** The caller's budget (`GET <base>/quota`); `quota.blocked` gates sends. */
|
|
6154
6177
|
quota,
|
|
6155
6178
|
/** The window blocking sends right now (the `blocked` option, else the quota report's). */
|