@springbrand/chat-client 0.3.0-alpha.2 → 0.3.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@springbrand/chat-client",
3
- "version": "0.3.0-alpha.2",
3
+ "version": "0.3.0-alpha.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src",
@@ -16,7 +16,8 @@
16
16
  "@cloudflare/ai-chat": "^0.12.0",
17
17
  "agents": "^0.23.0",
18
18
  "ai": "^7.0.0",
19
- "react": "^19.0.0"
19
+ "react": "^19.0.0",
20
+ "@springbrand/agent-runtime": "^0.3.0-alpha.5"
20
21
  },
21
22
  "dependencies": {
22
23
  "nanoid": "^5.1.16"
@@ -27,7 +28,7 @@
27
28
  "@types/react-dom": "^19.2.5",
28
29
  "react-dom": "^19.2.8",
29
30
  "typescript": "^7.0.2",
30
- "@springbrand/agent-runtime": "0.3.0-alpha.3"
31
+ "@springbrand/agent-runtime": "0.3.0-alpha.5"
31
32
  },
32
33
  "scripts": {
33
34
  "typecheck": "tsc --noEmit"
@@ -24,6 +24,7 @@ import {
24
24
  type RequestedCapability,
25
25
  type RuntimeAssemblyView,
26
26
  type RuntimeConfigUpdateResult,
27
+ type RuntimeInputLock,
27
28
  type RuntimeQueuedSubmission,
28
29
  type RuntimeState,
29
30
  type RuntimeTurnState,
@@ -162,6 +163,13 @@ export interface ChatRuntime {
162
163
  turn: RuntimeTurnState | undefined;
163
164
  turnActive: boolean;
164
165
  canSteer: boolean;
166
+ /**
167
+ * 定时 Run 未结束时的输入锁。
168
+ *
169
+ * 与服务端准入共用同一事实:有值时普通消息会被拒绝,宿主应禁用输入框。
170
+ * Run 进入终态后恢复 undefined。
171
+ */
172
+ inputLock: RuntimeInputLock | undefined;
165
173
  }
166
174
 
167
175
  type SharedChatConnectionOptions = {
@@ -211,7 +219,7 @@ export function UniversalAgentChatProvider({
211
219
  const agent = useAgent<RuntimeState>({
212
220
  agent: routed ? connection.sessionAgent ?? "UniversalAgent" : inboxAgent,
213
221
  ...(routed
214
- ? { basePath: connection.sessionBasePath }
222
+ ? { basePath: connection.sessionBasePath, name: chatId }
215
223
  : connection.inboxName === undefined
216
224
  ? { basePath: connection.basePath ?? CURRENT_INBOX_AGENT_PATH }
217
225
  : { name: connection.inboxName }),
@@ -603,6 +611,13 @@ export function useUniversalAgentChat(): ChatRuntime {
603
611
  throw new Error("useUniversalAgentChat must be used within UniversalAgentChatProvider");
604
612
  }
605
613
  const { chatId, connection, agent, chatAgent } = context;
614
+ const routedHistoryUrl = connection.sessionBasePath !== undefined &&
615
+ connection.host !== undefined
616
+ ? new URL(
617
+ `/${connection.sessionBasePath.replace(/^\/+/, "")}`,
618
+ connection.host,
619
+ ).toString()
620
+ : undefined;
606
621
  const [optimisticMessages, setOptimisticMessages] =
607
622
  useState<ChatMessage[]>([]);
608
623
  const [optimisticQueued, setOptimisticQueued] =
@@ -638,7 +653,10 @@ export function useUniversalAgentChat(): ChatRuntime {
638
653
  agent: chatAgent,
639
654
  getInitialMessages: connection.skipInitialMessages
640
655
  ? null
641
- : ({ url }) => loadInitialMessages(url, connection.credentials),
656
+ : ({ url }) => loadInitialMessages(
657
+ routedHistoryUrl ?? url,
658
+ connection.credentials,
659
+ ),
642
660
  ...(connection.credentials === undefined
643
661
  ? {}
644
662
  : { credentials: connection.credentials }),
@@ -1315,6 +1333,7 @@ export function useUniversalAgentChat(): ChatRuntime {
1315
1333
  turn,
1316
1334
  turnActive,
1317
1335
  canSteer,
1336
+ inputLock: facetState?.inputLock,
1318
1337
  };
1319
1338
  }
1320
1339