@economic/agents-react 1.6.3 → 1.6.4
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.mjs +5 -10
- package/dist/util-CPk3RN3P.mjs +13 -0
- package/dist/v1.mjs +5 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
+
import { n as isPublicChatMessage, t as getTokenArgs } from "./util-CPk3RN3P.mjs";
|
|
1
2
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
3
|
import { useAgent as useAgent$1 } from "agents/react";
|
|
3
4
|
import { getToolApproval, getToolCallId, getToolPartState, useAgentChat } from "@cloudflare/ai-chat/react";
|
|
4
|
-
//#region src/util.ts
|
|
5
|
-
function getTokenArgs(authToken) {
|
|
6
|
-
if (!authToken) return {};
|
|
7
|
-
return {
|
|
8
|
-
headers: { Authorization: `Bearer ${authToken}` },
|
|
9
|
-
protocols: ["bearer", authToken]
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
5
|
//#region src/useAgent.ts
|
|
14
6
|
function getAgentConnectionStatus(state, connectionId) {
|
|
15
7
|
return state.connectionId === connectionId ? state.status : "connecting";
|
|
@@ -253,7 +245,10 @@ function useChat(options) {
|
|
|
253
245
|
return {
|
|
254
246
|
status,
|
|
255
247
|
agent,
|
|
256
|
-
chat
|
|
248
|
+
chat: {
|
|
249
|
+
...chat,
|
|
250
|
+
messages: chat.messages.filter(isPublicChatMessage)
|
|
251
|
+
},
|
|
257
252
|
submitMessageFeedback,
|
|
258
253
|
getMessageFeedback
|
|
259
254
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/util.ts
|
|
2
|
+
function getTokenArgs(authToken) {
|
|
3
|
+
if (!authToken) return {};
|
|
4
|
+
return {
|
|
5
|
+
headers: { Authorization: `Bearer ${authToken}` },
|
|
6
|
+
protocols: ["bearer", authToken]
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function isPublicChatMessage(message) {
|
|
10
|
+
return !message.id.startsWith("compaction_");
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isPublicChatMessage as n, getTokenArgs as t };
|
package/dist/v1.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as isPublicChatMessage } from "./util-CPk3RN3P.mjs";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { useAgent } from "agents/react";
|
|
3
4
|
import { useAgentChat } from "@cloudflare/ai-chat/react";
|
|
@@ -113,7 +114,10 @@ function useAIChatAgent(options) {
|
|
|
113
114
|
]);
|
|
114
115
|
return {
|
|
115
116
|
agent,
|
|
116
|
-
chat
|
|
117
|
+
chat: {
|
|
118
|
+
...chat,
|
|
119
|
+
messages: chat.messages.filter(isPublicChatMessage)
|
|
120
|
+
},
|
|
117
121
|
connectionStatus
|
|
118
122
|
};
|
|
119
123
|
}
|