@springbrand/chat-client 0.1.3-alpha.25 → 0.1.3-alpha.28
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@springbrand/chat-client",
|
|
3
|
-
"version": "0.1.3-alpha.
|
|
3
|
+
"version": "0.1.3-alpha.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@types/react-dom": "^19.2.3",
|
|
26
26
|
"react-dom": "^19.2.7",
|
|
27
27
|
"typescript": "^7.0.2",
|
|
28
|
-
"@springbrand/agent-runtime": "0.2.0-alpha.
|
|
28
|
+
"@springbrand/agent-runtime": "0.2.0-alpha.36"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
@@ -194,6 +194,7 @@ type UniversalAgentChatContextValue = {
|
|
|
194
194
|
chatId: string;
|
|
195
195
|
connection: ChatConnectionOptions;
|
|
196
196
|
agent: SessionAgentConnection;
|
|
197
|
+
chatAgent: SessionAgentConnection;
|
|
197
198
|
};
|
|
198
199
|
|
|
199
200
|
const UniversalAgentChatContext = createContext<UniversalAgentChatContextValue | null>(null);
|
|
@@ -224,9 +225,13 @@ export function UniversalAgentChatProvider({
|
|
|
224
225
|
name: chatId,
|
|
225
226
|
}],
|
|
226
227
|
});
|
|
228
|
+
const chatAgent = useMemo(
|
|
229
|
+
() => createSafeUIMessageAgentConnection(agent),
|
|
230
|
+
[agent],
|
|
231
|
+
);
|
|
227
232
|
const value = useMemo(
|
|
228
|
-
() => ({ chatId, connection, agent }),
|
|
229
|
-
[agent, chatId, connection],
|
|
233
|
+
() => ({ chatId, connection, agent, chatAgent }),
|
|
234
|
+
[agent, chatAgent, chatId, connection],
|
|
230
235
|
);
|
|
231
236
|
return createElement(
|
|
232
237
|
UniversalAgentChatContext.Provider,
|
|
@@ -367,7 +372,7 @@ export function useUniversalAgentChat(): ChatRuntime {
|
|
|
367
372
|
if (!context) {
|
|
368
373
|
throw new Error("useUniversalAgentChat must be used within UniversalAgentChatProvider");
|
|
369
374
|
}
|
|
370
|
-
const { chatId, connection, agent } = context;
|
|
375
|
+
const { chatId, connection, agent, chatAgent } = context;
|
|
371
376
|
const [optimisticMessages, setOptimisticMessages] =
|
|
372
377
|
useState<ChatMessage[]>([]);
|
|
373
378
|
const [optimisticQueued, setOptimisticQueued] =
|
|
@@ -376,11 +381,6 @@ export function useUniversalAgentChat(): ChatRuntime {
|
|
|
376
381
|
const [canRetry, setCanRetry] = useState(false);
|
|
377
382
|
const failedDispatchRef = useRef<FailedDispatch | undefined>(undefined);
|
|
378
383
|
const activeSubmissionIdRef = useRef<string | undefined>(undefined);
|
|
379
|
-
const chatAgent = useMemo(
|
|
380
|
-
() => createSafeUIMessageAgentConnection(agent),
|
|
381
|
-
[agent],
|
|
382
|
-
);
|
|
383
|
-
|
|
384
384
|
// 轮询→推送:这条 chat 连接连的是 UniversalAgent facet,`agent.state` 即 facet 的
|
|
385
385
|
// AgentState 广播(useAgent 内部 useState,收到 cf_agent_state 即 re-render)。待批项
|
|
386
386
|
// 随它推来 —— 审批读侧复用这条已开的连接,不另开第二条 WebSocket。三态(原则 VII):
|