@springbrand/chat-client 0.3.0-alpha.1 → 0.3.0-alpha.2

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.3.0-alpha.1",
3
+ "version": "0.3.0-alpha.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src",
@@ -13,8 +13,8 @@
13
13
  ".": "./src/index.ts"
14
14
  },
15
15
  "peerDependencies": {
16
- "@cloudflare/ai-chat": "^0.11.0",
17
- "agents": "^0.22.0",
16
+ "@cloudflare/ai-chat": "^0.12.0",
17
+ "agents": "^0.23.0",
18
18
  "ai": "^7.0.0",
19
19
  "react": "^19.0.0"
20
20
  },
@@ -22,12 +22,12 @@
22
22
  "nanoid": "^5.1.16"
23
23
  },
24
24
  "devDependencies": {
25
- "@cloudflare/ai-chat": "0.11.0",
25
+ "@cloudflare/ai-chat": "0.12.0",
26
26
  "@types/react": "^19.2.18",
27
27
  "@types/react-dom": "^19.2.5",
28
28
  "react-dom": "^19.2.8",
29
29
  "typescript": "^7.0.2",
30
- "@springbrand/agent-runtime": "0.3.0-alpha.1"
30
+ "@springbrand/agent-runtime": "0.3.0-alpha.3"
31
31
  },
32
32
  "scripts": {
33
33
  "typecheck": "tsc --noEmit"
@@ -180,8 +180,9 @@ type SharedChatConnectionOptions = {
180
180
  };
181
181
 
182
182
  export type ChatConnectionOptions = SharedChatConnectionOptions & (
183
- | { inboxName: string; basePath?: never }
184
- | { inboxName?: never; basePath?: string }
183
+ | { inboxName: string; basePath?: never; sessionBasePath?: never }
184
+ | { inboxName?: never; basePath?: string; sessionBasePath?: never }
185
+ | { inboxName?: never; basePath?: never; sessionBasePath: string }
185
186
  );
186
187
 
187
188
  type SessionAgentConnection = ReturnType<typeof useAgent<RuntimeState>>;
@@ -206,19 +207,24 @@ export function UniversalAgentChatProvider({
206
207
  children: ReactNode;
207
208
  }) {
208
209
  const inboxAgent = connection.inboxAgent ?? "Inbox";
210
+ const routed = connection.sessionBasePath !== undefined;
209
211
  const agent = useAgent<RuntimeState>({
210
- agent: inboxAgent,
211
- ...(connection.inboxName === undefined
212
- ? { basePath: connection.basePath ?? CURRENT_INBOX_AGENT_PATH }
213
- : { name: connection.inboxName }),
212
+ agent: routed ? connection.sessionAgent ?? "UniversalAgent" : inboxAgent,
213
+ ...(routed
214
+ ? { basePath: connection.sessionBasePath }
215
+ : connection.inboxName === undefined
216
+ ? { basePath: connection.basePath ?? CURRENT_INBOX_AGENT_PATH }
217
+ : { name: connection.inboxName }),
214
218
  ...(connection.host === undefined ? {} : { host: connection.host }),
215
219
  ...(connection.protocols === undefined ? {} : { protocols: connection.protocols }),
216
220
  ...(connection.onMessage === undefined ? {} : { onMessage: connection.onMessage }),
217
221
  connectionTimeout: 6_000,
218
- sub: [{
219
- agent: connection.sessionAgent ?? "UniversalAgent",
220
- name: chatId,
221
- }],
222
+ ...(routed ? {} : {
223
+ sub: [{
224
+ agent: connection.sessionAgent ?? "UniversalAgent",
225
+ name: chatId,
226
+ }],
227
+ }),
222
228
  });
223
229
  const chatAgent = useMemo(
224
230
  () => createSafeUIMessageAgentConnection(agent),