@springbrand/chat-client 0.1.3-alpha.3 → 0.1.3-alpha.5
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.5",
|
|
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.1.3-alpha.
|
|
28
|
+
"@springbrand/agent-runtime": "0.1.3-alpha.6"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
@@ -8,6 +8,7 @@ import { useAgent, useAgentToolEvents } from "agents/react";
|
|
|
8
8
|
import {
|
|
9
9
|
type MessageDelivery,
|
|
10
10
|
type MessageDispatchReceipt,
|
|
11
|
+
type RequestedCapability,
|
|
11
12
|
type RuntimeAssemblyView,
|
|
12
13
|
type RuntimeConfigUpdateResult,
|
|
13
14
|
type RuntimeQueuedSubmission,
|
|
@@ -17,6 +18,7 @@ import { createSafeUIMessageAgentConnection } from "./ui-message-stream-guard";
|
|
|
17
18
|
import { CURRENT_INBOX_AGENT_PATH } from "./chat-sessions";
|
|
18
19
|
|
|
19
20
|
type ChatMessageMetadata = Record<string, unknown> & {
|
|
21
|
+
requestedCapabilities?: readonly RequestedCapability[];
|
|
20
22
|
turnStatus?: string;
|
|
21
23
|
};
|
|
22
24
|
type ChatMessage = UIMessage<ChatMessageMetadata>;
|
|
@@ -85,9 +87,21 @@ export interface ChatRuntime {
|
|
|
85
87
|
runtimeLoad: ChatRuntimeLoadState | undefined;
|
|
86
88
|
isStreaming: boolean;
|
|
87
89
|
error: string | Error | undefined;
|
|
88
|
-
sendText: (
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
sendText: (
|
|
91
|
+
text: string,
|
|
92
|
+
files?: readonly FileUIPart[],
|
|
93
|
+
capabilities?: readonly RequestedCapability[],
|
|
94
|
+
) => Promise<boolean>;
|
|
95
|
+
steerText: (
|
|
96
|
+
text: string,
|
|
97
|
+
files?: readonly FileUIPart[],
|
|
98
|
+
capabilities?: readonly RequestedCapability[],
|
|
99
|
+
) => Promise<boolean>;
|
|
100
|
+
enqueueText: (
|
|
101
|
+
text: string,
|
|
102
|
+
files?: readonly FileUIPart[],
|
|
103
|
+
capabilities?: readonly RequestedCapability[],
|
|
104
|
+
) => Promise<boolean>;
|
|
91
105
|
steerQueued: (submissionId: string) => Promise<boolean>;
|
|
92
106
|
cancelQueued: (submissionId: string) => Promise<boolean>;
|
|
93
107
|
stop: () => Promise<void>;
|
|
@@ -195,10 +209,18 @@ function markChatTurnPhase(
|
|
|
195
209
|
function createChatMessage(
|
|
196
210
|
text: string,
|
|
197
211
|
files?: readonly FileUIPart[],
|
|
212
|
+
capabilities: readonly RequestedCapability[] = [],
|
|
198
213
|
): ChatMessage | null {
|
|
199
214
|
const normalizedText = text.trim();
|
|
200
215
|
if (!normalizedText && !files?.length) return null;
|
|
201
216
|
const createdAt = Date.now();
|
|
217
|
+
const seen = new Set<string>();
|
|
218
|
+
const requestedCapabilities = capabilities.filter((capability) => {
|
|
219
|
+
const key = `${capability.kind}:${capability.name}`;
|
|
220
|
+
if (seen.has(key)) return false;
|
|
221
|
+
seen.add(key);
|
|
222
|
+
return true;
|
|
223
|
+
});
|
|
202
224
|
return {
|
|
203
225
|
id: nanoid(),
|
|
204
226
|
role: "user",
|
|
@@ -212,6 +234,7 @@ function createChatMessage(
|
|
|
212
234
|
createdAt,
|
|
213
235
|
authorDisplayName: "You",
|
|
214
236
|
messageSource: "Web",
|
|
237
|
+
...(requestedCapabilities.length > 0 ? { requestedCapabilities } : {}),
|
|
215
238
|
},
|
|
216
239
|
};
|
|
217
240
|
}
|
|
@@ -572,8 +595,9 @@ export function useUniversalAgentChat(
|
|
|
572
595
|
const sendText = useCallback(async (
|
|
573
596
|
text: string,
|
|
574
597
|
files?: readonly FileUIPart[],
|
|
598
|
+
capabilities?: readonly RequestedCapability[],
|
|
575
599
|
): Promise<boolean> => {
|
|
576
|
-
const message = createChatMessage(text, files);
|
|
600
|
+
const message = createChatMessage(text, files, capabilities);
|
|
577
601
|
return message
|
|
578
602
|
? submitMessage(message, "enqueue", "message")
|
|
579
603
|
: false;
|
|
@@ -582,21 +606,28 @@ export function useUniversalAgentChat(
|
|
|
582
606
|
const dispatchText = useCallback(async (
|
|
583
607
|
text: string,
|
|
584
608
|
files: readonly FileUIPart[] | undefined,
|
|
609
|
+
capabilities: readonly RequestedCapability[] | undefined,
|
|
585
610
|
delivery: MessageDelivery,
|
|
586
611
|
projection: "message" | "queue",
|
|
587
612
|
): Promise<boolean> => {
|
|
588
|
-
const message = createChatMessage(text, files);
|
|
613
|
+
const message = createChatMessage(text, files, capabilities);
|
|
589
614
|
return message ? submitMessage(message, delivery, projection) : false;
|
|
590
615
|
}, [submitMessage]);
|
|
591
616
|
|
|
592
617
|
const steerText = useCallback(
|
|
593
|
-
(
|
|
594
|
-
|
|
618
|
+
(
|
|
619
|
+
text: string,
|
|
620
|
+
files?: readonly FileUIPart[],
|
|
621
|
+
capabilities?: readonly RequestedCapability[],
|
|
622
|
+
) => dispatchText(text, files, capabilities, "steer", "message"),
|
|
595
623
|
[dispatchText],
|
|
596
624
|
);
|
|
597
625
|
const enqueueText = useCallback(
|
|
598
|
-
(
|
|
599
|
-
|
|
626
|
+
(
|
|
627
|
+
text: string,
|
|
628
|
+
files?: readonly FileUIPart[],
|
|
629
|
+
capabilities?: readonly RequestedCapability[],
|
|
630
|
+
) => dispatchText(text, files, capabilities, "enqueue", "queue"),
|
|
600
631
|
[dispatchText],
|
|
601
632
|
);
|
|
602
633
|
const steerQueued = useCallback(async (submissionId: string) => {
|