@springbrand/chat-client 0.1.3-alpha.44 → 0.1.3-alpha.46
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.46",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -27,7 +27,7 @@
|
|
|
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.2.0-alpha.
|
|
30
|
+
"@springbrand/agent-runtime": "0.2.0-alpha.62"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"typecheck": "tsc --noEmit"
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
type RuntimeConfigUpdateResult,
|
|
27
27
|
type RuntimeQueuedSubmission,
|
|
28
28
|
type RuntimeState,
|
|
29
|
+
type RuntimeTurnState,
|
|
29
30
|
} from "@springbrand/agent-runtime/contracts";
|
|
30
31
|
import { createSafeUIMessageAgentConnection } from "./ui-message-stream-guard";
|
|
31
32
|
import { CURRENT_INBOX_AGENT_PATH } from "./chat-sessions";
|
|
@@ -90,26 +91,6 @@ type ChatApproval = {
|
|
|
90
91
|
requestId: string;
|
|
91
92
|
};
|
|
92
93
|
|
|
93
|
-
type ChatQueuedSubmission = {
|
|
94
|
-
submissionId: string;
|
|
95
|
-
messageId: string;
|
|
96
|
-
preview: string;
|
|
97
|
-
position: number;
|
|
98
|
-
createdAt: number;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
type ChatTurn = {
|
|
102
|
-
activeSubmissionId?: string;
|
|
103
|
-
activeRequestId?: string;
|
|
104
|
-
activeMessageId?: string;
|
|
105
|
-
recoveryAttempt?: number;
|
|
106
|
-
recoveryMax?: number;
|
|
107
|
-
recoveryReason?: "no_meaningful_model_progress" | "transient_model_error";
|
|
108
|
-
steerable: boolean;
|
|
109
|
-
hasPendingSteer: boolean;
|
|
110
|
-
queued: ChatQueuedSubmission[];
|
|
111
|
-
};
|
|
112
|
-
|
|
113
94
|
export interface ChatRuntime {
|
|
114
95
|
messages: ChatMessage[];
|
|
115
96
|
status: ChatStatus;
|
|
@@ -118,10 +99,12 @@ export interface ChatRuntime {
|
|
|
118
99
|
runtimeLoad: ChatRuntimeLoadState | undefined;
|
|
119
100
|
isStreaming: boolean;
|
|
120
101
|
error: string | Error | undefined;
|
|
102
|
+
/** Reusing messageId makes delivery idempotent across caller retries. */
|
|
121
103
|
sendText: (
|
|
122
104
|
text: string,
|
|
123
105
|
files?: readonly FileUIPart[],
|
|
124
106
|
capabilities?: readonly RequestedCapability[],
|
|
107
|
+
messageId?: string,
|
|
125
108
|
) => Promise<boolean>;
|
|
126
109
|
steerText: (
|
|
127
110
|
text: string,
|
|
@@ -175,7 +158,7 @@ export interface ChatRuntime {
|
|
|
175
158
|
isToolContinuation: boolean;
|
|
176
159
|
approvals: ChatApproval[] | undefined;
|
|
177
160
|
approvalsLoaded: boolean;
|
|
178
|
-
turn:
|
|
161
|
+
turn: RuntimeTurnState | undefined;
|
|
179
162
|
turnActive: boolean;
|
|
180
163
|
canSteer: boolean;
|
|
181
164
|
}
|
|
@@ -339,6 +322,7 @@ function createChatMessage(
|
|
|
339
322
|
text: string,
|
|
340
323
|
files?: readonly FileUIPart[],
|
|
341
324
|
capabilities: readonly RequestedCapability[] = [],
|
|
325
|
+
messageId?: string,
|
|
342
326
|
): ChatMessage | null {
|
|
343
327
|
const normalizedText = text.trim();
|
|
344
328
|
if (!normalizedText && !files?.length) return null;
|
|
@@ -351,7 +335,7 @@ function createChatMessage(
|
|
|
351
335
|
return true;
|
|
352
336
|
});
|
|
353
337
|
return {
|
|
354
|
-
id: nanoid(),
|
|
338
|
+
id: messageId ?? nanoid(),
|
|
355
339
|
role: "user",
|
|
356
340
|
parts: [
|
|
357
341
|
...(files ?? []),
|
|
@@ -869,8 +853,9 @@ export function useUniversalAgentChat(): ChatRuntime {
|
|
|
869
853
|
text: string,
|
|
870
854
|
files?: readonly FileUIPart[],
|
|
871
855
|
capabilities?: readonly RequestedCapability[],
|
|
856
|
+
messageId?: string,
|
|
872
857
|
): Promise<boolean> => {
|
|
873
|
-
const message = createChatMessage(text, files, capabilities);
|
|
858
|
+
const message = createChatMessage(text, files, capabilities, messageId);
|
|
874
859
|
return message
|
|
875
860
|
? submitMessage(message, "enqueue", "message")
|
|
876
861
|
: false;
|