@dudousxd/nestjs-agent-react 0.23.0 → 0.24.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.cjs +47 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +47 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -967,6 +967,13 @@ var AgentChatTransport = class {
|
|
|
967
967
|
}
|
|
968
968
|
});
|
|
969
969
|
break;
|
|
970
|
+
case "message-metadata":
|
|
971
|
+
ensureStarted();
|
|
972
|
+
controller.enqueue({
|
|
973
|
+
type: "message-metadata",
|
|
974
|
+
messageMetadata: event.metadata
|
|
975
|
+
});
|
|
976
|
+
break;
|
|
970
977
|
case "title":
|
|
971
978
|
case "cancelled":
|
|
972
979
|
forwardAsData(event, true);
|
|
@@ -5121,13 +5128,19 @@ function storedMessageToUiMessage(message) {
|
|
|
5121
5128
|
for (const call of message.toolCalls ?? []) {
|
|
5122
5129
|
const result = message.toolResults?.find((candidate) => candidate.id === call.id);
|
|
5123
5130
|
const toolKind2 = call.kind;
|
|
5131
|
+
const toolMetadata = {
|
|
5132
|
+
...toolKind2 !== void 0 ? {
|
|
5133
|
+
toolKind: toolKind2
|
|
5134
|
+
} : {},
|
|
5135
|
+
...call.parentId !== void 0 ? {
|
|
5136
|
+
parentId: call.parentId
|
|
5137
|
+
} : {}
|
|
5138
|
+
};
|
|
5124
5139
|
parts.push({
|
|
5125
5140
|
type: `tool-${call.name}`,
|
|
5126
5141
|
toolCallId: call.id,
|
|
5127
|
-
...
|
|
5128
|
-
toolMetadata
|
|
5129
|
-
toolKind: toolKind2
|
|
5130
|
-
}
|
|
5142
|
+
...Object.keys(toolMetadata).length > 0 ? {
|
|
5143
|
+
toolMetadata
|
|
5131
5144
|
} : {},
|
|
5132
5145
|
...result !== void 0 ? isRefusal(result) ? {
|
|
5133
5146
|
// A declined action is NOT an available output. Reloading a thread used to bring one
|
|
@@ -5155,6 +5168,8 @@ function storedMessageToUiMessage(message) {
|
|
|
5155
5168
|
parts.push(...pushedByCall.get(call.id) ?? []);
|
|
5156
5169
|
}
|
|
5157
5170
|
const metadata = {
|
|
5171
|
+
// The host's own facts first: the library's keys win on a clash.
|
|
5172
|
+
...message.metadata,
|
|
5158
5173
|
...message.feedback !== void 0 ? {
|
|
5159
5174
|
feedback: message.feedback
|
|
5160
5175
|
} : {},
|
|
@@ -5214,6 +5229,8 @@ function mergeTurn(rows) {
|
|
|
5214
5229
|
const feedback = lastRow.feedback;
|
|
5215
5230
|
const createdAt = rows[0]?.createdAt;
|
|
5216
5231
|
const metadata = {
|
|
5232
|
+
// Host facts of every row, a later row's winning (the turn's final state), under the library's.
|
|
5233
|
+
...Object.assign({}, ...rows.map((row) => row.metadata ?? {})),
|
|
5217
5234
|
...usage !== void 0 ? {
|
|
5218
5235
|
usage
|
|
5219
5236
|
} : {},
|
|
@@ -5335,6 +5352,11 @@ function useAgentChat(options = {}) {
|
|
|
5335
5352
|
const threadId = currentThreadId();
|
|
5336
5353
|
const model = current.model ?? pickedModelRef.current;
|
|
5337
5354
|
return {
|
|
5355
|
+
// Read per send: a host that switches agents before the first message (a picker on a
|
|
5356
|
+
// new chat) sends the one picked now, not the one this chat mounted with.
|
|
5357
|
+
...current.agent !== void 0 ? {
|
|
5358
|
+
agent: current.agent
|
|
5359
|
+
} : {},
|
|
5338
5360
|
...threadId !== void 0 ? {
|
|
5339
5361
|
threadId
|
|
5340
5362
|
} : {},
|
|
@@ -5708,6 +5730,10 @@ function useAgentChat(options = {}) {
|
|
|
5708
5730
|
return catalog.providers;
|
|
5709
5731
|
},
|
|
5710
5732
|
selected: options.model ?? pickedModel ?? threadModel ?? catalog.defaultModel ?? null,
|
|
5733
|
+
get defaultModel() {
|
|
5734
|
+
wantModels();
|
|
5735
|
+
return catalog.defaultModel;
|
|
5736
|
+
},
|
|
5711
5737
|
select: selectModel,
|
|
5712
5738
|
pinToThread,
|
|
5713
5739
|
isLoading: modelsWanted && catalog.isLoading,
|
|
@@ -5735,10 +5761,26 @@ function useAgentChat(options = {}) {
|
|
|
5735
5761
|
const current = composerRef.current;
|
|
5736
5762
|
if (current.blockedBy !== null) return;
|
|
5737
5763
|
const refs = current.files.refs;
|
|
5764
|
+
const files2 = current.files.items.flatMap((item) => item.status === "ready" && item.attachment !== void 0 ? [
|
|
5765
|
+
{
|
|
5766
|
+
type: "file",
|
|
5767
|
+
mediaType: item.attachment.contentType,
|
|
5768
|
+
filename: item.attachment.name,
|
|
5769
|
+
url: item.attachment.url,
|
|
5770
|
+
providerMetadata: {
|
|
5771
|
+
agent: {
|
|
5772
|
+
mediaId: item.attachment.mediaId
|
|
5773
|
+
}
|
|
5774
|
+
}
|
|
5775
|
+
}
|
|
5776
|
+
] : []);
|
|
5738
5777
|
const draft = current.text.trim();
|
|
5739
5778
|
setText("");
|
|
5740
5779
|
current.files.clear();
|
|
5741
|
-
await sendMessage({
|
|
5780
|
+
await sendMessage(files2.length > 0 ? {
|
|
5781
|
+
text: draft,
|
|
5782
|
+
files: files2
|
|
5783
|
+
} : {
|
|
5742
5784
|
text: draft
|
|
5743
5785
|
}, refs.length > 0 ? {
|
|
5744
5786
|
body: {
|