@springbrand/chat-client 0.1.3-alpha.44 → 0.1.3-alpha.45

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.44",
3
+ "version": "0.1.3-alpha.45",
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.60"
30
+ "@springbrand/agent-runtime": "0.2.0-alpha.61"
31
31
  },
32
32
  "scripts": {
33
33
  "typecheck": "tsc --noEmit"
@@ -118,10 +118,12 @@ export interface ChatRuntime {
118
118
  runtimeLoad: ChatRuntimeLoadState | undefined;
119
119
  isStreaming: boolean;
120
120
  error: string | Error | undefined;
121
+ /** Reusing messageId makes delivery idempotent across caller retries. */
121
122
  sendText: (
122
123
  text: string,
123
124
  files?: readonly FileUIPart[],
124
125
  capabilities?: readonly RequestedCapability[],
126
+ messageId?: string,
125
127
  ) => Promise<boolean>;
126
128
  steerText: (
127
129
  text: string,
@@ -339,6 +341,7 @@ function createChatMessage(
339
341
  text: string,
340
342
  files?: readonly FileUIPart[],
341
343
  capabilities: readonly RequestedCapability[] = [],
344
+ messageId?: string,
342
345
  ): ChatMessage | null {
343
346
  const normalizedText = text.trim();
344
347
  if (!normalizedText && !files?.length) return null;
@@ -351,7 +354,7 @@ function createChatMessage(
351
354
  return true;
352
355
  });
353
356
  return {
354
- id: nanoid(),
357
+ id: messageId ?? nanoid(),
355
358
  role: "user",
356
359
  parts: [
357
360
  ...(files ?? []),
@@ -869,8 +872,9 @@ export function useUniversalAgentChat(): ChatRuntime {
869
872
  text: string,
870
873
  files?: readonly FileUIPart[],
871
874
  capabilities?: readonly RequestedCapability[],
875
+ messageId?: string,
872
876
  ): Promise<boolean> => {
873
- const message = createChatMessage(text, files, capabilities);
877
+ const message = createChatMessage(text, files, capabilities, messageId);
874
878
  return message
875
879
  ? submitMessage(message, "enqueue", "message")
876
880
  : false;