@ai-sdk/vue 4.0.114 → 4.0.116

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @ai-sdk/vue
2
2
 
3
+ ## 4.0.116
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [af9597b]
8
+ - Updated dependencies [bc49f78]
9
+ - ai@7.0.116
10
+ - @ai-sdk/provider-utils@5.0.49
11
+
12
+ ## 4.0.115
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [be877ff]
17
+ - Updated dependencies [be877ff]
18
+ - @ai-sdk/provider-utils@5.0.48
19
+ - ai@7.0.115
20
+
3
21
  ## 4.0.114
4
22
 
5
23
  ### Patch Changes
package/dist/index.js CHANGED
@@ -25,7 +25,6 @@ function useObject({
25
25
  headers,
26
26
  credentials
27
27
  }) {
28
- var _a;
29
28
  const completionId = id || `completion-${uniqueId++}`;
30
29
  const key = `${api}|${completionId}`;
31
30
  const { data, mutate: originalMutate } = useSWRV(key, () => key in store ? store[key] : initialValue);
@@ -33,8 +32,8 @@ function useObject({
33
32
  `${completionId}-loading`,
34
33
  null
35
34
  );
36
- (_a = isLoading.value) != null ? _a : isLoading.value = false;
37
- data.value || (data.value = initialValue);
35
+ isLoading.value ??= false;
36
+ data.value ||= initialValue;
38
37
  const mutateObject = (value) => {
39
38
  store[key] = value;
40
39
  return originalMutate();
@@ -45,7 +44,7 @@ function useObject({
45
44
  if (abortController) {
46
45
  try {
47
46
  abortController.abort();
48
- } catch (e) {
47
+ } catch {
49
48
  } finally {
50
49
  abortController = null;
51
50
  }
@@ -67,14 +66,14 @@ function useObject({
67
66
  await clearObject();
68
67
  await mutateLoading(() => true);
69
68
  abortController = new AbortController();
70
- const actualFetch = fetch2 != null ? fetch2 : getOriginalFetch();
69
+ const actualFetch = fetch2 ?? getOriginalFetch();
71
70
  const response = await actualFetch(api, {
72
71
  method: "POST",
73
72
  headers: {
74
73
  "Content-Type": "application/json",
75
74
  ...headers
76
75
  },
77
- credentials: credentials != null ? credentials : "same-origin",
76
+ credentials: credentials ?? "same-origin",
78
77
  signal: abortController.signal,
79
78
  body: JSON.stringify(input)
80
79
  });
@@ -158,22 +157,18 @@ function useCompletion({
158
157
  onError,
159
158
  fetch: fetch2
160
159
  } = {}) {
161
- var _a, _b;
162
160
  const completionId = id || `completion-${uniqueId2++}`;
163
161
  const key = `${api}|${completionId}`;
164
162
  const { data, mutate: originalMutate } = useSWRV2(
165
163
  key,
166
- () => {
167
- var _a2;
168
- return (_a2 = store2[key]) != null ? _a2 : initialCompletion;
169
- }
164
+ () => store2[key] ?? initialCompletion
170
165
  );
171
166
  const { data: isLoading, mutate: mutateLoading } = useSWRV2(
172
167
  `${completionId}-loading`,
173
168
  null
174
169
  );
175
- (_a = isLoading.value) != null ? _a : isLoading.value = false;
176
- (_b = data.value) != null ? _b : data.value = initialCompletion;
170
+ isLoading.value ??= false;
171
+ data.value ??= initialCompletion;
177
172
  const mutate = (data2) => {
178
173
  store2[key] = data2;
179
174
  return originalMutate();
@@ -188,11 +183,11 @@ function useCompletion({
188
183
  credentials,
189
184
  headers: {
190
185
  ...headers,
191
- ...options == null ? void 0 : options.headers
186
+ ...options?.headers
192
187
  },
193
188
  body: {
194
189
  ...unref(body),
195
- ...options == null ? void 0 : options.body
190
+ ...options?.body
196
191
  },
197
192
  streamProtocol,
198
193
  setCompletion: mutate,
@@ -222,8 +217,7 @@ function useCompletion({
222
217
  };
223
218
  const input = ref2(initialInput);
224
219
  const handleSubmit = (event) => {
225
- var _a2;
226
- (_a2 = event == null ? void 0 : event.preventDefault) == null ? void 0 : _a2.call(event);
220
+ event?.preventDefault?.();
227
221
  const inputValue = input.value;
228
222
  return inputValue ? complete(inputValue) : void 0;
229
223
  };
@@ -258,7 +252,7 @@ var VueChatState = class {
258
252
  this.messagesRef.value[index] = { ...message };
259
253
  };
260
254
  this.snapshot = (value) => value;
261
- this.messagesRef = ref3(messages != null ? messages : []);
255
+ this.messagesRef = ref3(messages ?? []);
262
256
  }
263
257
  get messages() {
264
258
  return this.messagesRef.value;
@@ -495,11 +489,10 @@ function useChat(init) {
495
489
  watch(
496
490
  () => toValue(init),
497
491
  (opts) => {
498
- var _a;
499
- chatState == null ? void 0 : chatState.dispose();
500
- const { throttle, ...chatInit } = opts != null ? opts : {};
492
+ chatState?.dispose();
493
+ const { throttle, ...chatInit } = opts ?? {};
501
494
  const nextChatState = new VueChatState2({
502
- initialMessages: (_a = chatInit.messages) != null ? _a : [],
495
+ initialMessages: chatInit.messages ?? [],
503
496
  messagesRef: messages,
504
497
  statusRef: status,
505
498
  errorRef: error,
@@ -516,7 +509,7 @@ function useChat(init) {
516
509
  );
517
510
  if (getCurrentScope() != null) {
518
511
  onScopeDispose(() => {
519
- chatState == null ? void 0 : chatState.dispose();
512
+ chatState?.dispose();
520
513
  });
521
514
  }
522
515
  return {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-object.ts","../src/use-completion.ts","../src/chat.vue.ts","../src/use-chat.ts","../src/index.ts"],"sourcesContent":["import {\n isAbortError,\n safeValidateTypes,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport {\n asSchema,\n isDeepEqualData,\n parsePartialJson,\n type DeepPartial,\n type FlexibleSchema,\n type InferSchema,\n} from 'ai';\nimport type * as SwrvModule from 'swrv';\nimport swrv from 'swrv';\nimport { ref, type Ref } from 'vue';\n// use function to allow for mocking in tests\nconst getOriginalFetch = () => fetch;\n\nexport type UseObjectOptions<SCHEMA extends FlexibleSchema, RESULT> = {\n /** API endpoint that streams JSON chunks matching the schema */\n api: string;\n\n /** Schema that defines the final object shape */\n schema: SCHEMA;\n\n /** Shared state key. If omitted a random one is generated */\n id?: string;\n\n /** Initial partial value */\n initialValue?: DeepPartial<RESULT>;\n\n /** Optional custom fetch implementation */\n fetch?: FetchFunction;\n\n /** Called when stream ends */\n onFinish?: (event: {\n object: RESULT | undefined;\n error: Error | undefined;\n }) => Promise<void> | void;\n\n /** Called on error */\n onError?: (error: Error) => void;\n\n /** Extra request headers */\n headers?: Record<string, string> | Headers;\n\n /** Request credentials mode. Defaults to 'same-origin' if omitted */\n credentials?: RequestCredentials;\n};\n\nexport type UseObjectHelpers<RESULT, INPUT> = {\n /** POST the input and start streaming */\n submit: (input: INPUT) => void;\n\n /** Current partial object, updated as chunks arrive */\n object: Ref<DeepPartial<RESULT> | undefined>;\n\n /** Latest error if any */\n error: Ref<Error | undefined>;\n\n /** Loading flag for the in-flight request */\n isLoading: Ref<boolean | undefined>;\n\n /** Abort the current request. Keeps current partial object. */\n stop: () => void;\n\n /** Abort and clear all state */\n clear: () => void;\n};\n\nlet uniqueId = 0;\n\n// @ts-expect-error - some issues with the default export of useSWRV\nconst useSWRV = (swrv.default as (typeof SwrvModule)['default']) || swrv;\nconst store: Record<string, any> = {};\n\nexport function useObject<\n SCHEMA extends FlexibleSchema,\n RESULT = InferSchema<SCHEMA>,\n INPUT = any,\n>({\n api,\n id,\n schema,\n initialValue,\n fetch,\n onError,\n onFinish,\n headers,\n credentials,\n}: UseObjectOptions<SCHEMA, RESULT>): UseObjectHelpers<RESULT, INPUT> {\n // Generate an unique id for the object if not provided.\n const completionId = id || `completion-${uniqueId++}`;\n\n const key = `${api}|${completionId}`;\n const { data, mutate: originalMutate } = useSWRV<\n DeepPartial<RESULT> | undefined\n >(key, () => (key in store ? store[key] : initialValue));\n\n const { data: isLoading, mutate: mutateLoading } = useSWRV<boolean>(\n `${completionId}-loading`,\n null,\n );\n\n isLoading.value ??= false;\n data.value ||= initialValue as DeepPartial<RESULT> | undefined;\n\n const mutateObject = (value: DeepPartial<RESULT> | undefined) => {\n store[key] = value;\n return originalMutate();\n };\n\n const error = ref<Error | undefined>(undefined);\n let abortController: AbortController | null = null;\n\n const stop = async () => {\n if (abortController) {\n try {\n abortController.abort();\n } catch {\n // ignore\n } finally {\n abortController = null;\n }\n }\n await mutateLoading(() => false);\n };\n\n const clearObject = async () => {\n error.value = undefined;\n await mutateLoading(() => false);\n await mutateObject(undefined);\n // Need to explicitly set the value to undefined to trigger a re-render\n data.value = undefined;\n };\n\n const clear = async () => {\n await stop();\n await clearObject();\n };\n\n const submit = async (input: INPUT) => {\n try {\n await clearObject();\n await mutateLoading(() => true);\n\n abortController = new AbortController();\n\n const actualFetch = fetch ?? getOriginalFetch();\n const response = await actualFetch(api, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(headers as any),\n },\n credentials: credentials ?? 'same-origin',\n signal: abortController.signal,\n body: JSON.stringify(input),\n });\n\n if (!response.ok) {\n throw new Error(\n (await response.text()) || 'Failed to fetch the response.',\n );\n }\n\n if (!response.body) {\n throw new Error('The response body is empty.');\n }\n\n let accumulatedText = '';\n let latestObject: DeepPartial<RESULT> | undefined = undefined;\n\n await response.body.pipeThrough(new TextDecoderStream()).pipeTo(\n new WritableStream<string>({\n async write(chunk) {\n accumulatedText += chunk;\n const { value } = await parsePartialJson(accumulatedText);\n const currentObject = value as DeepPartial<RESULT>;\n if (!isDeepEqualData(latestObject, currentObject)) {\n latestObject = currentObject;\n await mutateObject(currentObject);\n }\n },\n async close() {\n await mutateLoading(() => false);\n abortController = null;\n\n if (onFinish) {\n const validationResult = await safeValidateTypes({\n value: latestObject,\n schema: asSchema(schema),\n });\n\n onFinish(\n validationResult.success\n ? {\n object: validationResult.value as RESULT,\n error: undefined,\n }\n : { object: undefined, error: validationResult.error },\n );\n }\n },\n }),\n );\n } catch (err: unknown) {\n if (isAbortError(err)) return;\n\n if (onError && err instanceof Error) onError(err);\n\n await mutateLoading(() => false);\n error.value = err instanceof Error ? err : new Error(String(err));\n }\n };\n\n return {\n submit,\n object: data,\n error,\n isLoading,\n stop,\n clear,\n };\n}\n","import {\n callCompletionApi,\n type CompletionRequestOptions,\n type UseCompletionOptions,\n} from 'ai';\nimport type * as SwrvModule from 'swrv';\nimport swrv from 'swrv';\nimport { ref, unref, type Ref } from 'vue';\nexport type { UseCompletionOptions };\n\nexport type UseCompletionHelpers<BODY extends object = object> = {\n /** The current completion result */\n completion: Ref<string>;\n /** The error object of the API request */\n error: Ref<undefined | Error>;\n /**\n * Send a new prompt to the API endpoint and update the completion state.\n */\n complete: (\n prompt: string,\n options?: CompletionRequestOptions<BODY>,\n ) => Promise<string | null | undefined>;\n /**\n * Abort the current API request but keep the generated tokens.\n */\n stop: () => void;\n /**\n * Update the `completion` state locally.\n */\n setCompletion: (completion: string) => void;\n /** The current value of the input */\n input: Ref<string>;\n /**\n * Form submission handler to automatically reset input and append a user message\n * @example\n * ```jsx\n * <form @submit=\"handleSubmit\">\n * <input @change=\"handleInputChange\" v-model=\"input\" />\n * </form>\n * ```\n */\n handleSubmit: (event?: { preventDefault?: () => void }) => void;\n /** Whether the API request is in progress */\n isLoading: Ref<boolean | undefined>;\n};\n\nlet uniqueId = 0;\n\n// @ts-expect-error - some issues with the default export of useSWRV\nconst useSWRV = (swrv.default as (typeof SwrvModule)['default']) || swrv;\nconst store: Record<string, any> = {};\n\nexport function useCompletion<BODY extends object = object>({\n api = '/api/completion',\n id,\n initialCompletion = '',\n initialInput = '',\n credentials,\n headers,\n body,\n streamProtocol,\n onFinish,\n onError,\n fetch,\n}: UseCompletionOptions<NoInfer<BODY>> = {}): UseCompletionHelpers<BODY> {\n // Generate an unique id for the completion if not provided.\n const completionId = id || `completion-${uniqueId++}`;\n\n const key = `${api}|${completionId}`;\n const { data, mutate: originalMutate } = useSWRV<string>(\n key,\n () => store[key] ?? initialCompletion,\n );\n\n const { data: isLoading, mutate: mutateLoading } = useSWRV<boolean>(\n `${completionId}-loading`,\n null,\n );\n\n isLoading.value ??= false;\n\n // Force the `data` to be `initialCompletion` if it's `undefined`.\n data.value ??= initialCompletion;\n\n const mutate = (data: string) => {\n store[key] = data;\n return originalMutate();\n };\n\n // Because of the `initialData` option, the `data` will never be `undefined`.\n const completion = data as Ref<string>;\n\n const error = ref<undefined | Error>(undefined);\n\n let abortController: AbortController | null = null;\n\n async function triggerRequest(\n prompt: string,\n options?: CompletionRequestOptions<BODY>,\n ) {\n return callCompletionApi({\n api,\n prompt,\n credentials,\n headers: {\n ...headers,\n ...options?.headers,\n },\n body: {\n ...unref(body),\n ...options?.body,\n },\n streamProtocol,\n setCompletion: mutate,\n setLoading: loading => mutateLoading(() => loading),\n setError: err => {\n error.value = err;\n },\n setAbortController: controller => {\n abortController = controller;\n },\n getAbortController: () => abortController,\n onFinish,\n onError,\n fetch,\n });\n }\n\n const complete: UseCompletionHelpers<BODY>['complete'] = async (\n prompt,\n options,\n ) => {\n return triggerRequest(prompt, options);\n };\n\n const stop = () => {\n if (abortController) {\n abortController.abort();\n }\n };\n\n const setCompletion = (completion: string) => {\n mutate(completion);\n };\n\n const input = ref(initialInput);\n\n const handleSubmit = (event?: { preventDefault?: () => void }) => {\n event?.preventDefault?.();\n const inputValue = input.value;\n return inputValue ? complete(inputValue) : undefined;\n };\n\n return {\n completion,\n complete,\n error,\n stop,\n setCompletion,\n input,\n handleSubmit,\n isLoading,\n };\n}\n","import {\n AbstractChat,\n type ChatInit,\n type ChatState,\n type ChatStatus,\n type UIMessage,\n} from 'ai';\nimport { ref, type Ref } from 'vue';\nclass VueChatState<\n UI_MESSAGE extends UIMessage,\n> implements ChatState<UI_MESSAGE> {\n private messagesRef: Ref<UI_MESSAGE[]>;\n private statusRef = ref<ChatStatus>('ready');\n private errorRef = ref<Error | undefined>(undefined);\n\n constructor(messages?: UI_MESSAGE[]) {\n this.messagesRef = ref(messages ?? []) as Ref<UI_MESSAGE[]>;\n }\n\n get messages(): UI_MESSAGE[] {\n return this.messagesRef.value;\n }\n\n set messages(messages: UI_MESSAGE[]) {\n this.messagesRef.value = messages;\n }\n\n get status(): ChatStatus {\n return this.statusRef.value;\n }\n\n set status(status: ChatStatus) {\n this.statusRef.value = status;\n }\n\n get error(): Error | undefined {\n return this.errorRef.value;\n }\n\n set error(error: Error | undefined) {\n this.errorRef.value = error;\n }\n\n pushMessage = (message: UI_MESSAGE) => {\n this.messagesRef.value = [...this.messagesRef.value, message];\n };\n\n popMessage = () => {\n this.messagesRef.value = this.messagesRef.value.slice(0, -1);\n };\n\n replaceMessage = (index: number, message: UI_MESSAGE) => {\n // message is cloned here because vue's deep reactivity shows unexpected behavior, particularly when updating tool invocation parts\n this.messagesRef.value[index] = { ...message };\n };\n\n snapshot = <T>(value: T): T => value;\n}\n\n/**\n * @deprecated Use the {@link useChat} composable instead. It exposes reactive\n * refs and automatically recreates the chat when its init object changes.\n */\nexport class Chat<\n UI_MESSAGE extends UIMessage,\n> extends AbstractChat<UI_MESSAGE> {\n constructor({ messages, ...init }: ChatInit<UI_MESSAGE>) {\n super({\n ...init,\n state: new VueChatState(messages),\n });\n }\n}\n","import {\n AbstractChat,\n type ChatInit as BaseChatInit,\n type ChatInit,\n type ChatState,\n type ChatStatus,\n type UIMessage,\n} from 'ai';\nimport {\n computed,\n getCurrentScope,\n onScopeDispose,\n shallowRef,\n toValue,\n watch,\n type ComputedRef,\n type MaybeRefOrGetter,\n type ShallowRef,\n} from 'vue';\n\nfunction cloneMetadata<METADATA>(metadata: METADATA): METADATA {\n if (Array.isArray(metadata)) {\n return [...metadata] as METADATA;\n }\n\n if (\n metadata != null &&\n typeof metadata === 'object' &&\n (Object.getPrototypeOf(metadata) === Object.prototype ||\n Object.getPrototypeOf(metadata) === null)\n ) {\n return { ...metadata } as METADATA;\n }\n\n return metadata;\n}\n\nfunction snapshotValue<T>(value: T): T {\n if (\n value == null ||\n typeof value !== 'object' ||\n !('parts' in value) ||\n !Array.isArray(value.parts)\n ) {\n return value;\n }\n\n const message = value as unknown as UIMessage;\n const snapshot = {\n ...message,\n parts: message.parts.map(part => ({ ...part })),\n };\n\n if ('metadata' in message) {\n snapshot.metadata = cloneMetadata(message.metadata);\n }\n\n return snapshot as T;\n}\n\nclass VueChatState<\n UI_MESSAGE extends UIMessage,\n> implements ChatState<UI_MESSAGE> {\n private messagesValue: UI_MESSAGE[];\n private publishedMessages: UI_MESSAGE[] = [];\n private publishedMessageSources: UI_MESSAGE[] = [];\n private readonly dirtyMessageIndices = new Set<number>();\n private statusValue: ChatStatus = 'ready';\n private errorValue: Error | undefined;\n private readonly throttleWaitMs: number | undefined;\n private timeout: ReturnType<typeof setTimeout> | undefined;\n private hasPendingPublication = false;\n private isActive = true;\n\n isPublishing = false;\n\n constructor({\n initialMessages,\n messagesRef,\n statusRef,\n errorRef,\n throttleWaitMs,\n }: {\n initialMessages: UI_MESSAGE[];\n messagesRef: ShallowRef<UI_MESSAGE[]>;\n statusRef: ShallowRef<ChatStatus>;\n errorRef: ShallowRef<Error | undefined>;\n throttleWaitMs?: number;\n }) {\n this.messagesValue = initialMessages;\n this.messagesRef = messagesRef;\n this.statusRef = statusRef;\n this.errorRef = errorRef;\n this.throttleWaitMs =\n throttleWaitMs != null &&\n Number.isFinite(throttleWaitMs) &&\n throttleWaitMs > 0\n ? throttleWaitMs\n : undefined;\n }\n\n private readonly messagesRef: ShallowRef<UI_MESSAGE[]>;\n private readonly statusRef: ShallowRef<ChatStatus>;\n private readonly errorRef: ShallowRef<Error | undefined>;\n\n get messages(): UI_MESSAGE[] {\n return this.messagesValue;\n }\n\n set messages(messages: UI_MESSAGE[]) {\n const previousMessages = this.messagesValue;\n this.messagesValue = messages;\n\n for (let index = 0; index < messages.length; index++) {\n if (messages[index] !== previousMessages[index]) {\n this.dirtyMessageIndices.add(index);\n }\n }\n\n this.schedulePublication();\n }\n\n get status(): ChatStatus {\n return this.statusValue;\n }\n\n set status(status: ChatStatus) {\n this.statusValue = status;\n\n if (!this.isActive) {\n return;\n }\n\n if (status === 'ready' || status === 'error') {\n // Terminal states must never become observable before the final message.\n this.flushPublication();\n }\n\n this.statusRef.value = status;\n }\n\n get error(): Error | undefined {\n return this.errorValue;\n }\n\n set error(error: Error | undefined) {\n this.errorValue = error;\n\n if (this.isActive) {\n this.errorRef.value = error;\n }\n }\n\n pushMessage = (message: UI_MESSAGE) => {\n this.messagesValue.push(message);\n this.dirtyMessageIndices.add(this.messagesValue.length - 1);\n this.schedulePublication();\n };\n\n popMessage = () => {\n this.messagesValue.pop();\n this.schedulePublication();\n };\n\n replaceMessage = (index: number, message: UI_MESSAGE) => {\n this.messagesValue[index] = message;\n this.dirtyMessageIndices.add(index);\n this.schedulePublication();\n };\n\n snapshot = snapshotValue;\n\n publishInitialState() {\n this.publishMessages();\n this.statusRef.value = this.statusValue;\n this.errorRef.value = this.errorValue;\n }\n\n setMessagesFromConsumer(messages: UI_MESSAGE[]) {\n this.messagesValue = messages;\n this.publishedMessages = messages;\n this.publishedMessageSources = messages;\n this.dirtyMessageIndices.clear();\n }\n\n dispose() {\n this.isActive = false;\n this.hasPendingPublication = false;\n this.dirtyMessageIndices.clear();\n this.publishedMessages = [];\n this.publishedMessageSources = [];\n\n if (this.timeout != null) {\n clearTimeout(this.timeout);\n this.timeout = undefined;\n }\n }\n\n private schedulePublication() {\n if (!this.isActive) {\n return;\n }\n\n if (this.throttleWaitMs == null) {\n this.publishMessages();\n return;\n }\n\n if (this.timeout == null) {\n // Publish the leading update immediately, then coalesce updates until\n // the next interval boundary.\n this.publishMessages();\n this.timeout = setTimeout(this.handleIntervalEnd, this.throttleWaitMs);\n } else {\n this.hasPendingPublication = true;\n }\n }\n\n private readonly handleIntervalEnd = () => {\n this.timeout = undefined;\n\n if (!this.isActive || !this.hasPendingPublication) {\n return;\n }\n\n this.hasPendingPublication = false;\n this.publishMessages();\n this.timeout = setTimeout(this.handleIntervalEnd, this.throttleWaitMs);\n };\n\n private flushPublication() {\n if (this.timeout != null) {\n clearTimeout(this.timeout);\n this.timeout = undefined;\n }\n\n this.hasPendingPublication = false;\n this.publishMessages();\n }\n\n private publishMessages() {\n if (!this.isActive) {\n return;\n }\n\n const publishedMessages = this.messagesValue.map((message, index) =>\n this.dirtyMessageIndices.has(index) ||\n this.publishedMessageSources[index] !== message\n ? snapshotValue(message)\n : this.publishedMessages[index],\n );\n\n this.publishedMessages = publishedMessages;\n this.publishedMessageSources = [...this.messagesValue];\n this.dirtyMessageIndices.clear();\n\n this.isPublishing = true;\n try {\n this.messagesRef.value = publishedMessages;\n } finally {\n this.isPublishing = false;\n }\n }\n}\n\n/**\n * @internal\n */\nexport class VueChat<\n UI_MESSAGE extends UIMessage,\n> extends AbstractChat<UI_MESSAGE> {\n constructor({\n state,\n ...init\n }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {\n state: ChatState<UI_MESSAGE>;\n }) {\n super({\n ...init,\n state,\n });\n }\n}\n\n/**\n * Return type of the {@link useChat} composable, which includes the chat\n * instance methods and reactive properties for messages, status, and error.\n */\nexport interface UseChatHelpers<UI_MESSAGE extends UIMessage> extends Pick<\n AbstractChat<UI_MESSAGE>,\n | 'sendMessage'\n | 'regenerate'\n | 'stop'\n | 'resumeStream'\n | 'addToolOutput'\n | 'addToolApprovalResponse'\n | 'clearError'\n> {\n /**\n * The id of the chat.\n */\n id: ComputedRef<string>;\n\n /**\n * The current error state of the chat, if any.\n */\n error: ShallowRef<Error | undefined>;\n\n /**\n * The current status of the chat, which can be 'ready', 'generating', 'streaming', or 'error'.\n */\n status: ShallowRef<ChatStatus>;\n\n /**\n * The list of messages in the chat, which can be updated by the chat instance methods or directly by setting this property.\n */\n messages: ShallowRef<UI_MESSAGE[]>;\n}\n\nexport type UseChatOptions<UI_MESSAGE extends UIMessage> =\n BaseChatInit<UI_MESSAGE> & {\n /**\n * Custom throttle wait time in milliseconds for reactive message updates.\n * Positive values enable throttling. Defaults to undefined, which disables\n * throttling.\n */\n throttle?: number;\n };\n\n/**\n * Composable to access messages, status, and other chat properties and\n * methods. Accepts an optional reactive initial configuration object\n *\n * @example\n *\n * ```ts\n * // passing a getter if any reactive properties are used within\n * // the init object\n * const { messages, sendMessage } = useChat(() => ({\n * // ...\n * })\n * ```\n *\n * @see BaseChatInit\n */\nexport function useChat<UI_MESSAGE extends UIMessage = UIMessage>(\n init?: MaybeRefOrGetter<UseChatOptions<UI_MESSAGE>>,\n): UseChatHelpers<UI_MESSAGE> {\n const messages = shallowRef<UI_MESSAGE[]>([]);\n const status = shallowRef<ChatStatus>('ready');\n const error = shallowRef<Error | undefined>();\n\n // the instance is created right away thanks to immediate: true. We do it this\n // way instead of a computed to ensure all changes to reactive state happen\n // in the same tick\n const chatInstance = shallowRef<VueChat<UI_MESSAGE>>() as ShallowRef<\n VueChat<UI_MESSAGE>\n >;\n let chatState: VueChatState<UI_MESSAGE> | undefined;\n\n watch(\n messages,\n messageList => {\n if (chatState != null && !chatState.isPublishing) {\n chatState.setMessagesFromConsumer(messageList);\n }\n },\n { flush: 'sync' },\n );\n\n watch(\n () => toValue(init),\n opts => {\n chatState?.dispose();\n\n const { throttle, ...chatInit } = opts ?? {};\n const nextChatState = new VueChatState<UI_MESSAGE>({\n initialMessages: chatInit.messages ?? [],\n messagesRef: messages,\n statusRef: status,\n errorRef: error,\n throttleWaitMs: throttle,\n });\n\n chatState = nextChatState;\n nextChatState.publishInitialState();\n\n chatInstance.value = new VueChat<UI_MESSAGE>({\n ...chatInit,\n state: nextChatState,\n });\n },\n { immediate: true },\n );\n\n if (getCurrentScope() != null) {\n onScopeDispose(() => {\n chatState?.dispose();\n });\n }\n\n return {\n id: computed(() => chatInstance.value.id),\n status,\n messages,\n error,\n addToolApprovalResponse: opts =>\n chatInstance.value.addToolApprovalResponse(opts),\n addToolOutput: opts => chatInstance.value.addToolOutput(opts),\n clearError: () => chatInstance.value.clearError(),\n regenerate: opts => chatInstance.value.regenerate(opts),\n sendMessage: (...args) => chatInstance.value.sendMessage(...args),\n stop: () => chatInstance.value.stop(),\n resumeStream: opts => chatInstance.value.resumeStream(opts),\n };\n}\n","import type { FlexibleSchema } from '@ai-sdk/provider-utils';\nimport {\n useObject,\n type UseObjectHelpers,\n type UseObjectOptions,\n} from './use-object';\n\nexport * from './use-completion';\nexport { Chat } from './chat.vue';\nexport { useChat, type UseChatHelpers, type UseChatOptions } from './use-chat';\nexport * from './use-object';\n\n// deprecated aliases\n// note: declared here (instead of export aliases) so that the `@deprecated`\n// tags are preserved in the bundled type declarations\n\n/**\n * @deprecated Use `useObject` instead.\n */\nexport const experimental_useObject = useObject;\n\n/**\n * @deprecated Use `UseObjectOptions` instead.\n */\nexport type Experimental_UseObjectOptions<\n SCHEMA extends FlexibleSchema,\n RESULT,\n> = UseObjectOptions<SCHEMA, RESULT>;\n\n/**\n * @deprecated Use `UseObjectHelpers` instead.\n */\nexport type Experimental_UseObjectHelpers<RESULT, INPUT> = UseObjectHelpers<\n RESULT,\n INPUT\n>;\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP,OAAO,UAAU;AACjB,SAAS,WAAqB;AAE9B,IAAM,mBAAmB,MAAM;AAsD/B,IAAI,WAAW;AAGf,IAAM,UAAW,KAAK,WAA8C;AACpE,IAAM,QAA6B,CAAC;AAE7B,SAAS,UAId;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsE;AA3FtE;AA6FE,QAAM,eAAe,MAAM,cAAc,UAAU;AAEnD,QAAM,MAAM,GAAG,GAAG,IAAI,YAAY;AAClC,QAAM,EAAE,MAAM,QAAQ,eAAe,IAAI,QAEvC,KAAK,MAAO,OAAO,QAAQ,MAAM,GAAG,IAAI,YAAa;AAEvD,QAAM,EAAE,MAAM,WAAW,QAAQ,cAAc,IAAI;AAAA,IACjD,GAAG,YAAY;AAAA,IACf;AAAA,EACF;AAEA,kBAAU,UAAV,sBAAU,QAAU;AACpB,OAAK,UAAL,KAAK,QAAU;AAEf,QAAM,eAAe,CAAC,UAA2C;AAC/D,UAAM,GAAG,IAAI;AACb,WAAO,eAAe;AAAA,EACxB;AAEA,QAAM,QAAQ,IAAuB,MAAS;AAC9C,MAAI,kBAA0C;AAE9C,QAAM,OAAO,YAAY;AAC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AAAA,QACb,WAAW;AAAA,QACX,UAAU;AAAA,QACV,gBAAgB;AAAA,MAClB,CAAC;AAED,kBAAY;AACZ,oBAAc,oBAAoB;AAElC,mBAAa,QAAQ,IAAI,QAAoB;AAAA,QAC3C,GAAG;AAAA,QACH,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EACpB;AAEA,MAAI,gBAAgB,KAAK,MAAM;AAC7B,mBAAe,MAAM;AACnB,6CAAW;AAAA,IACb,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,IAAI,SAAS,MAAM,aAAa,MAAM,EAAE;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA,yBAAyB,UACvB,aAAa,MAAM,wBAAwB,IAAI;AAAA,IACjD,eAAe,UAAQ,aAAa,MAAM,cAAc,IAAI;AAAA,IAC5D,YAAY,MAAM,aAAa,MAAM,WAAW;AAAA,IAChD,YAAY,UAAQ,aAAa,MAAM,WAAW,IAAI;AAAA,IACtD,aAAa,IAAI,SAAS,aAAa,MAAM,YAAY,GAAG,IAAI;AAAA,IAChE,MAAM,MAAM,aAAa,MAAM,KAAK;AAAA,IACpC,cAAc,UAAQ,aAAa,MAAM,aAAa,IAAI;AAAA,EAC5D;AACF;;;AC5YO,IAAM,yBAAyB;","names":["fetch","swrv","ref","uniqueId","useSWRV","store","fetch","_a","data","completion","ref","AbstractChat","VueChatState"]}
1
+ {"version":3,"sources":["../src/use-object.ts","../src/use-completion.ts","../src/chat.vue.ts","../src/use-chat.ts","../src/index.ts"],"sourcesContent":["import {\n isAbortError,\n safeValidateTypes,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport {\n asSchema,\n isDeepEqualData,\n parsePartialJson,\n type DeepPartial,\n type FlexibleSchema,\n type InferSchema,\n} from 'ai';\nimport type * as SwrvModule from 'swrv';\nimport swrv from 'swrv';\nimport { ref, type Ref } from 'vue';\n// use function to allow for mocking in tests\nconst getOriginalFetch = () => fetch;\n\nexport type UseObjectOptions<SCHEMA extends FlexibleSchema, RESULT> = {\n /** API endpoint that streams JSON chunks matching the schema */\n api: string;\n\n /** Schema that defines the final object shape */\n schema: SCHEMA;\n\n /** Shared state key. If omitted a random one is generated */\n id?: string;\n\n /** Initial partial value */\n initialValue?: DeepPartial<RESULT>;\n\n /** Optional custom fetch implementation */\n fetch?: FetchFunction;\n\n /** Called when stream ends */\n onFinish?: (event: {\n object: RESULT | undefined;\n error: Error | undefined;\n }) => Promise<void> | void;\n\n /** Called on error */\n onError?: (error: Error) => void;\n\n /** Extra request headers */\n headers?: Record<string, string> | Headers;\n\n /** Request credentials mode. Defaults to 'same-origin' if omitted */\n credentials?: RequestCredentials;\n};\n\nexport type UseObjectHelpers<RESULT, INPUT> = {\n /** POST the input and start streaming */\n submit: (input: INPUT) => void;\n\n /** Current partial object, updated as chunks arrive */\n object: Ref<DeepPartial<RESULT> | undefined>;\n\n /** Latest error if any */\n error: Ref<Error | undefined>;\n\n /** Loading flag for the in-flight request */\n isLoading: Ref<boolean | undefined>;\n\n /** Abort the current request. Keeps current partial object. */\n stop: () => void;\n\n /** Abort and clear all state */\n clear: () => void;\n};\n\nlet uniqueId = 0;\n\n// @ts-expect-error - some issues with the default export of useSWRV\nconst useSWRV = (swrv.default as (typeof SwrvModule)['default']) || swrv;\nconst store: Record<string, any> = {};\n\nexport function useObject<\n SCHEMA extends FlexibleSchema,\n RESULT = InferSchema<SCHEMA>,\n INPUT = any,\n>({\n api,\n id,\n schema,\n initialValue,\n fetch,\n onError,\n onFinish,\n headers,\n credentials,\n}: UseObjectOptions<SCHEMA, RESULT>): UseObjectHelpers<RESULT, INPUT> {\n // Generate an unique id for the object if not provided.\n const completionId = id || `completion-${uniqueId++}`;\n\n const key = `${api}|${completionId}`;\n const { data, mutate: originalMutate } = useSWRV<\n DeepPartial<RESULT> | undefined\n >(key, () => (key in store ? store[key] : initialValue));\n\n const { data: isLoading, mutate: mutateLoading } = useSWRV<boolean>(\n `${completionId}-loading`,\n null,\n );\n\n isLoading.value ??= false;\n data.value ||= initialValue as DeepPartial<RESULT> | undefined;\n\n const mutateObject = (value: DeepPartial<RESULT> | undefined) => {\n store[key] = value;\n return originalMutate();\n };\n\n const error = ref<Error | undefined>(undefined);\n let abortController: AbortController | null = null;\n\n const stop = async () => {\n if (abortController) {\n try {\n abortController.abort();\n } catch {\n // ignore\n } finally {\n abortController = null;\n }\n }\n await mutateLoading(() => false);\n };\n\n const clearObject = async () => {\n error.value = undefined;\n await mutateLoading(() => false);\n await mutateObject(undefined);\n // Need to explicitly set the value to undefined to trigger a re-render\n data.value = undefined;\n };\n\n const clear = async () => {\n await stop();\n await clearObject();\n };\n\n const submit = async (input: INPUT) => {\n try {\n await clearObject();\n await mutateLoading(() => true);\n\n abortController = new AbortController();\n\n const actualFetch = fetch ?? getOriginalFetch();\n const response = await actualFetch(api, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(headers as any),\n },\n credentials: credentials ?? 'same-origin',\n signal: abortController.signal,\n body: JSON.stringify(input),\n });\n\n if (!response.ok) {\n throw new Error(\n (await response.text()) || 'Failed to fetch the response.',\n );\n }\n\n if (!response.body) {\n throw new Error('The response body is empty.');\n }\n\n let accumulatedText = '';\n let latestObject: DeepPartial<RESULT> | undefined = undefined;\n\n await response.body.pipeThrough(new TextDecoderStream()).pipeTo(\n new WritableStream<string>({\n async write(chunk) {\n accumulatedText += chunk;\n const { value } = await parsePartialJson(accumulatedText);\n const currentObject = value as DeepPartial<RESULT>;\n if (!isDeepEqualData(latestObject, currentObject)) {\n latestObject = currentObject;\n await mutateObject(currentObject);\n }\n },\n async close() {\n await mutateLoading(() => false);\n abortController = null;\n\n if (onFinish) {\n const validationResult = await safeValidateTypes({\n value: latestObject,\n schema: asSchema(schema),\n });\n\n onFinish(\n validationResult.success\n ? {\n object: validationResult.value as RESULT,\n error: undefined,\n }\n : { object: undefined, error: validationResult.error },\n );\n }\n },\n }),\n );\n } catch (err: unknown) {\n if (isAbortError(err)) return;\n\n if (onError && err instanceof Error) onError(err);\n\n await mutateLoading(() => false);\n error.value = err instanceof Error ? err : new Error(String(err));\n }\n };\n\n return {\n submit,\n object: data,\n error,\n isLoading,\n stop,\n clear,\n };\n}\n","import {\n callCompletionApi,\n type CompletionRequestOptions,\n type UseCompletionOptions,\n} from 'ai';\nimport type * as SwrvModule from 'swrv';\nimport swrv from 'swrv';\nimport { ref, unref, type Ref } from 'vue';\nexport type { UseCompletionOptions };\n\nexport type UseCompletionHelpers<BODY extends object = object> = {\n /** The current completion result */\n completion: Ref<string>;\n /** The error object of the API request */\n error: Ref<undefined | Error>;\n /**\n * Send a new prompt to the API endpoint and update the completion state.\n */\n complete: (\n prompt: string,\n options?: CompletionRequestOptions<BODY>,\n ) => Promise<string | null | undefined>;\n /**\n * Abort the current API request but keep the generated tokens.\n */\n stop: () => void;\n /**\n * Update the `completion` state locally.\n */\n setCompletion: (completion: string) => void;\n /** The current value of the input */\n input: Ref<string>;\n /**\n * Form submission handler to automatically reset input and append a user message\n * @example\n * ```jsx\n * <form @submit=\"handleSubmit\">\n * <input @change=\"handleInputChange\" v-model=\"input\" />\n * </form>\n * ```\n */\n handleSubmit: (event?: { preventDefault?: () => void }) => void;\n /** Whether the API request is in progress */\n isLoading: Ref<boolean | undefined>;\n};\n\nlet uniqueId = 0;\n\n// @ts-expect-error - some issues with the default export of useSWRV\nconst useSWRV = (swrv.default as (typeof SwrvModule)['default']) || swrv;\nconst store: Record<string, any> = {};\n\nexport function useCompletion<BODY extends object = object>({\n api = '/api/completion',\n id,\n initialCompletion = '',\n initialInput = '',\n credentials,\n headers,\n body,\n streamProtocol,\n onFinish,\n onError,\n fetch,\n}: UseCompletionOptions<NoInfer<BODY>> = {}): UseCompletionHelpers<BODY> {\n // Generate an unique id for the completion if not provided.\n const completionId = id || `completion-${uniqueId++}`;\n\n const key = `${api}|${completionId}`;\n const { data, mutate: originalMutate } = useSWRV<string>(\n key,\n () => store[key] ?? initialCompletion,\n );\n\n const { data: isLoading, mutate: mutateLoading } = useSWRV<boolean>(\n `${completionId}-loading`,\n null,\n );\n\n isLoading.value ??= false;\n\n // Force the `data` to be `initialCompletion` if it's `undefined`.\n data.value ??= initialCompletion;\n\n const mutate = (data: string) => {\n store[key] = data;\n return originalMutate();\n };\n\n // Because of the `initialData` option, the `data` will never be `undefined`.\n const completion = data as Ref<string>;\n\n const error = ref<undefined | Error>(undefined);\n\n let abortController: AbortController | null = null;\n\n async function triggerRequest(\n prompt: string,\n options?: CompletionRequestOptions<BODY>,\n ) {\n return callCompletionApi({\n api,\n prompt,\n credentials,\n headers: {\n ...headers,\n ...options?.headers,\n },\n body: {\n ...unref(body),\n ...options?.body,\n },\n streamProtocol,\n setCompletion: mutate,\n setLoading: loading => mutateLoading(() => loading),\n setError: err => {\n error.value = err;\n },\n setAbortController: controller => {\n abortController = controller;\n },\n getAbortController: () => abortController,\n onFinish,\n onError,\n fetch,\n });\n }\n\n const complete: UseCompletionHelpers<BODY>['complete'] = async (\n prompt,\n options,\n ) => {\n return triggerRequest(prompt, options);\n };\n\n const stop = () => {\n if (abortController) {\n abortController.abort();\n }\n };\n\n const setCompletion = (completion: string) => {\n mutate(completion);\n };\n\n const input = ref(initialInput);\n\n const handleSubmit = (event?: { preventDefault?: () => void }) => {\n event?.preventDefault?.();\n const inputValue = input.value;\n return inputValue ? complete(inputValue) : undefined;\n };\n\n return {\n completion,\n complete,\n error,\n stop,\n setCompletion,\n input,\n handleSubmit,\n isLoading,\n };\n}\n","import {\n AbstractChat,\n type ChatInit,\n type ChatState,\n type ChatStatus,\n type UIMessage,\n} from 'ai';\nimport { ref, type Ref } from 'vue';\nclass VueChatState<\n UI_MESSAGE extends UIMessage,\n> implements ChatState<UI_MESSAGE> {\n private messagesRef: Ref<UI_MESSAGE[]>;\n private statusRef = ref<ChatStatus>('ready');\n private errorRef = ref<Error | undefined>(undefined);\n\n constructor(messages?: UI_MESSAGE[]) {\n this.messagesRef = ref(messages ?? []) as Ref<UI_MESSAGE[]>;\n }\n\n get messages(): UI_MESSAGE[] {\n return this.messagesRef.value;\n }\n\n set messages(messages: UI_MESSAGE[]) {\n this.messagesRef.value = messages;\n }\n\n get status(): ChatStatus {\n return this.statusRef.value;\n }\n\n set status(status: ChatStatus) {\n this.statusRef.value = status;\n }\n\n get error(): Error | undefined {\n return this.errorRef.value;\n }\n\n set error(error: Error | undefined) {\n this.errorRef.value = error;\n }\n\n pushMessage = (message: UI_MESSAGE) => {\n this.messagesRef.value = [...this.messagesRef.value, message];\n };\n\n popMessage = () => {\n this.messagesRef.value = this.messagesRef.value.slice(0, -1);\n };\n\n replaceMessage = (index: number, message: UI_MESSAGE) => {\n // message is cloned here because vue's deep reactivity shows unexpected behavior, particularly when updating tool invocation parts\n this.messagesRef.value[index] = { ...message };\n };\n\n snapshot = <T>(value: T): T => value;\n}\n\n/**\n * @deprecated Use the {@link useChat} composable instead. It exposes reactive\n * refs and automatically recreates the chat when its init object changes.\n */\nexport class Chat<\n UI_MESSAGE extends UIMessage,\n> extends AbstractChat<UI_MESSAGE> {\n constructor({ messages, ...init }: ChatInit<UI_MESSAGE>) {\n super({\n ...init,\n state: new VueChatState(messages),\n });\n }\n}\n","import {\n AbstractChat,\n type ChatInit as BaseChatInit,\n type ChatInit,\n type ChatState,\n type ChatStatus,\n type UIMessage,\n} from 'ai';\nimport {\n computed,\n getCurrentScope,\n onScopeDispose,\n shallowRef,\n toValue,\n watch,\n type ComputedRef,\n type MaybeRefOrGetter,\n type ShallowRef,\n} from 'vue';\n\nfunction cloneMetadata<METADATA>(metadata: METADATA): METADATA {\n if (Array.isArray(metadata)) {\n return [...metadata] as METADATA;\n }\n\n if (\n metadata != null &&\n typeof metadata === 'object' &&\n (Object.getPrototypeOf(metadata) === Object.prototype ||\n Object.getPrototypeOf(metadata) === null)\n ) {\n return { ...metadata } as METADATA;\n }\n\n return metadata;\n}\n\nfunction snapshotValue<T>(value: T): T {\n if (\n value == null ||\n typeof value !== 'object' ||\n !('parts' in value) ||\n !Array.isArray(value.parts)\n ) {\n return value;\n }\n\n const message = value as unknown as UIMessage;\n const snapshot = {\n ...message,\n parts: message.parts.map(part => ({ ...part })),\n };\n\n if ('metadata' in message) {\n snapshot.metadata = cloneMetadata(message.metadata);\n }\n\n return snapshot as T;\n}\n\nclass VueChatState<\n UI_MESSAGE extends UIMessage,\n> implements ChatState<UI_MESSAGE> {\n private messagesValue: UI_MESSAGE[];\n private publishedMessages: UI_MESSAGE[] = [];\n private publishedMessageSources: UI_MESSAGE[] = [];\n private readonly dirtyMessageIndices = new Set<number>();\n private statusValue: ChatStatus = 'ready';\n private errorValue: Error | undefined;\n private readonly throttleWaitMs: number | undefined;\n private timeout: ReturnType<typeof setTimeout> | undefined;\n private hasPendingPublication = false;\n private isActive = true;\n\n isPublishing = false;\n\n constructor({\n initialMessages,\n messagesRef,\n statusRef,\n errorRef,\n throttleWaitMs,\n }: {\n initialMessages: UI_MESSAGE[];\n messagesRef: ShallowRef<UI_MESSAGE[]>;\n statusRef: ShallowRef<ChatStatus>;\n errorRef: ShallowRef<Error | undefined>;\n throttleWaitMs?: number;\n }) {\n this.messagesValue = initialMessages;\n this.messagesRef = messagesRef;\n this.statusRef = statusRef;\n this.errorRef = errorRef;\n this.throttleWaitMs =\n throttleWaitMs != null &&\n Number.isFinite(throttleWaitMs) &&\n throttleWaitMs > 0\n ? throttleWaitMs\n : undefined;\n }\n\n private readonly messagesRef: ShallowRef<UI_MESSAGE[]>;\n private readonly statusRef: ShallowRef<ChatStatus>;\n private readonly errorRef: ShallowRef<Error | undefined>;\n\n get messages(): UI_MESSAGE[] {\n return this.messagesValue;\n }\n\n set messages(messages: UI_MESSAGE[]) {\n const previousMessages = this.messagesValue;\n this.messagesValue = messages;\n\n for (let index = 0; index < messages.length; index++) {\n if (messages[index] !== previousMessages[index]) {\n this.dirtyMessageIndices.add(index);\n }\n }\n\n this.schedulePublication();\n }\n\n get status(): ChatStatus {\n return this.statusValue;\n }\n\n set status(status: ChatStatus) {\n this.statusValue = status;\n\n if (!this.isActive) {\n return;\n }\n\n if (status === 'ready' || status === 'error') {\n // Terminal states must never become observable before the final message.\n this.flushPublication();\n }\n\n this.statusRef.value = status;\n }\n\n get error(): Error | undefined {\n return this.errorValue;\n }\n\n set error(error: Error | undefined) {\n this.errorValue = error;\n\n if (this.isActive) {\n this.errorRef.value = error;\n }\n }\n\n pushMessage = (message: UI_MESSAGE) => {\n this.messagesValue.push(message);\n this.dirtyMessageIndices.add(this.messagesValue.length - 1);\n this.schedulePublication();\n };\n\n popMessage = () => {\n this.messagesValue.pop();\n this.schedulePublication();\n };\n\n replaceMessage = (index: number, message: UI_MESSAGE) => {\n this.messagesValue[index] = message;\n this.dirtyMessageIndices.add(index);\n this.schedulePublication();\n };\n\n snapshot = snapshotValue;\n\n publishInitialState() {\n this.publishMessages();\n this.statusRef.value = this.statusValue;\n this.errorRef.value = this.errorValue;\n }\n\n setMessagesFromConsumer(messages: UI_MESSAGE[]) {\n this.messagesValue = messages;\n this.publishedMessages = messages;\n this.publishedMessageSources = messages;\n this.dirtyMessageIndices.clear();\n }\n\n dispose() {\n this.isActive = false;\n this.hasPendingPublication = false;\n this.dirtyMessageIndices.clear();\n this.publishedMessages = [];\n this.publishedMessageSources = [];\n\n if (this.timeout != null) {\n clearTimeout(this.timeout);\n this.timeout = undefined;\n }\n }\n\n private schedulePublication() {\n if (!this.isActive) {\n return;\n }\n\n if (this.throttleWaitMs == null) {\n this.publishMessages();\n return;\n }\n\n if (this.timeout == null) {\n // Publish the leading update immediately, then coalesce updates until\n // the next interval boundary.\n this.publishMessages();\n this.timeout = setTimeout(this.handleIntervalEnd, this.throttleWaitMs);\n } else {\n this.hasPendingPublication = true;\n }\n }\n\n private readonly handleIntervalEnd = () => {\n this.timeout = undefined;\n\n if (!this.isActive || !this.hasPendingPublication) {\n return;\n }\n\n this.hasPendingPublication = false;\n this.publishMessages();\n this.timeout = setTimeout(this.handleIntervalEnd, this.throttleWaitMs);\n };\n\n private flushPublication() {\n if (this.timeout != null) {\n clearTimeout(this.timeout);\n this.timeout = undefined;\n }\n\n this.hasPendingPublication = false;\n this.publishMessages();\n }\n\n private publishMessages() {\n if (!this.isActive) {\n return;\n }\n\n const publishedMessages = this.messagesValue.map((message, index) =>\n this.dirtyMessageIndices.has(index) ||\n this.publishedMessageSources[index] !== message\n ? snapshotValue(message)\n : this.publishedMessages[index],\n );\n\n this.publishedMessages = publishedMessages;\n this.publishedMessageSources = [...this.messagesValue];\n this.dirtyMessageIndices.clear();\n\n this.isPublishing = true;\n try {\n this.messagesRef.value = publishedMessages;\n } finally {\n this.isPublishing = false;\n }\n }\n}\n\n/**\n * @internal\n */\nexport class VueChat<\n UI_MESSAGE extends UIMessage,\n> extends AbstractChat<UI_MESSAGE> {\n constructor({\n state,\n ...init\n }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {\n state: ChatState<UI_MESSAGE>;\n }) {\n super({\n ...init,\n state,\n });\n }\n}\n\n/**\n * Return type of the {@link useChat} composable, which includes the chat\n * instance methods and reactive properties for messages, status, and error.\n */\nexport interface UseChatHelpers<UI_MESSAGE extends UIMessage> extends Pick<\n AbstractChat<UI_MESSAGE>,\n | 'sendMessage'\n | 'regenerate'\n | 'stop'\n | 'resumeStream'\n | 'addToolOutput'\n | 'addToolApprovalResponse'\n | 'clearError'\n> {\n /**\n * The id of the chat.\n */\n id: ComputedRef<string>;\n\n /**\n * The current error state of the chat, if any.\n */\n error: ShallowRef<Error | undefined>;\n\n /**\n * The current status of the chat, which can be 'ready', 'generating', 'streaming', or 'error'.\n */\n status: ShallowRef<ChatStatus>;\n\n /**\n * The list of messages in the chat, which can be updated by the chat instance methods or directly by setting this property.\n */\n messages: ShallowRef<UI_MESSAGE[]>;\n}\n\nexport type UseChatOptions<UI_MESSAGE extends UIMessage> =\n BaseChatInit<UI_MESSAGE> & {\n /**\n * Custom throttle wait time in milliseconds for reactive message updates.\n * Positive values enable throttling. Defaults to undefined, which disables\n * throttling.\n */\n throttle?: number;\n };\n\n/**\n * Composable to access messages, status, and other chat properties and\n * methods. Accepts an optional reactive initial configuration object\n *\n * @example\n *\n * ```ts\n * // passing a getter if any reactive properties are used within\n * // the init object\n * const { messages, sendMessage } = useChat(() => ({\n * // ...\n * })\n * ```\n *\n * @see BaseChatInit\n */\nexport function useChat<UI_MESSAGE extends UIMessage = UIMessage>(\n init?: MaybeRefOrGetter<UseChatOptions<UI_MESSAGE>>,\n): UseChatHelpers<UI_MESSAGE> {\n const messages = shallowRef<UI_MESSAGE[]>([]);\n const status = shallowRef<ChatStatus>('ready');\n const error = shallowRef<Error | undefined>();\n\n // the instance is created right away thanks to immediate: true. We do it this\n // way instead of a computed to ensure all changes to reactive state happen\n // in the same tick\n const chatInstance = shallowRef<VueChat<UI_MESSAGE>>() as ShallowRef<\n VueChat<UI_MESSAGE>\n >;\n let chatState: VueChatState<UI_MESSAGE> | undefined;\n\n watch(\n messages,\n messageList => {\n if (chatState != null && !chatState.isPublishing) {\n chatState.setMessagesFromConsumer(messageList);\n }\n },\n { flush: 'sync' },\n );\n\n watch(\n () => toValue(init),\n opts => {\n chatState?.dispose();\n\n const { throttle, ...chatInit } = opts ?? {};\n const nextChatState = new VueChatState<UI_MESSAGE>({\n initialMessages: chatInit.messages ?? [],\n messagesRef: messages,\n statusRef: status,\n errorRef: error,\n throttleWaitMs: throttle,\n });\n\n chatState = nextChatState;\n nextChatState.publishInitialState();\n\n chatInstance.value = new VueChat<UI_MESSAGE>({\n ...chatInit,\n state: nextChatState,\n });\n },\n { immediate: true },\n );\n\n if (getCurrentScope() != null) {\n onScopeDispose(() => {\n chatState?.dispose();\n });\n }\n\n return {\n id: computed(() => chatInstance.value.id),\n status,\n messages,\n error,\n addToolApprovalResponse: opts =>\n chatInstance.value.addToolApprovalResponse(opts),\n addToolOutput: opts => chatInstance.value.addToolOutput(opts),\n clearError: () => chatInstance.value.clearError(),\n regenerate: opts => chatInstance.value.regenerate(opts),\n sendMessage: (...args) => chatInstance.value.sendMessage(...args),\n stop: () => chatInstance.value.stop(),\n resumeStream: opts => chatInstance.value.resumeStream(opts),\n };\n}\n","import type { FlexibleSchema } from '@ai-sdk/provider-utils';\nimport {\n useObject,\n type UseObjectHelpers,\n type UseObjectOptions,\n} from './use-object';\n\nexport * from './use-completion';\nexport { Chat } from './chat.vue';\nexport { useChat, type UseChatHelpers, type UseChatOptions } from './use-chat';\nexport * from './use-object';\n\n// deprecated aliases\n// note: declared here (instead of export aliases) so that the `@deprecated`\n// tags are preserved in the bundled type declarations\n\n/**\n * @deprecated Use `useObject` instead.\n */\nexport const experimental_useObject = useObject;\n\n/**\n * @deprecated Use `UseObjectOptions` instead.\n */\nexport type Experimental_UseObjectOptions<\n SCHEMA extends FlexibleSchema,\n RESULT,\n> = UseObjectOptions<SCHEMA, RESULT>;\n\n/**\n * @deprecated Use `UseObjectHelpers` instead.\n */\nexport type Experimental_UseObjectHelpers<RESULT, INPUT> = UseObjectHelpers<\n RESULT,\n INPUT\n>;\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP,OAAO,UAAU;AACjB,SAAS,WAAqB;AAE9B,IAAM,mBAAmB,MAAM;AAsD/B,IAAI,WAAW;AAGf,IAAM,UAAW,KAAK,WAA8C;AACpE,IAAM,QAA6B,CAAC;AAE7B,SAAS,UAId;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsE;AAEpE,QAAM,eAAe,MAAM,cAAc,UAAU;AAEnD,QAAM,MAAM,GAAG,GAAG,IAAI,YAAY;AAClC,QAAM,EAAE,MAAM,QAAQ,eAAe,IAAI,QAEvC,KAAK,MAAO,OAAO,QAAQ,MAAM,GAAG,IAAI,YAAa;AAEvD,QAAM,EAAE,MAAM,WAAW,QAAQ,cAAc,IAAI;AAAA,IACjD,GAA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IAAIC,cAAyB;AAAA,QACjD,iBAAiB,SAAS,YAAY,CAAC;AAAA,QACvC,aAAa;AAAA,QACb,WAAW;AAAA,QACX,UAAU;AAAA,QACV,gBAAgB;AAAA,MAClB,CAAC;AAED,kBAAY;AACZ,oBAAc,oBAAoB;AAElC,mBAAa,QAAQ,IAAI,QAAoB;AAAA,QAC3C,GAAG;AAAA,QACH,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EACpB;AAEA,MAAI,gBAAgB,KAAK,MAAM;AAC7B,mBAAe,MAAM;AACnB,iBAAW,QAAQ;AAAA,IACrB,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,IAAI,SAAS,MAAM,aAAa,MAAM,EAAE;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA,yBAAyB,UACvB,aAAa,MAAM,wBAAwB,IAAI;AAAA,IACjD,eAAe,UAAQ,aAAa,MAAM,cAAc,IAAI;AAAA,IAC5D,YAAY,MAAM,aAAa,MAAM,WAAW;AAAA,IAChD,YAAY,UAAQ,aAAa,MAAM,WAAW,IAAI;AAAA,IACtD,aAAa,IAAI,SAAS,aAAa,MAAM,YAAY,GAAG,IAAI;AAAA,IAChE,MAAM,MAAM,aAAa,MAAM,KAAK;AAAA,IACpC,cAAc,UAAQ,aAAa,MAAM,aAAa,IAAI;AAAA,EAC5D;AACF;;;AC5YO,IAAM,yBAAyB;","names":["fetch","swrv","ref","uniqueId","useSWRV","store","fetch","data","completion","ref","AbstractChat","VueChatState"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/vue",
3
- "version": "4.0.114",
3
+ "version": "4.0.116",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -26,12 +26,12 @@
26
26
  "README.md"
27
27
  ],
28
28
  "dependencies": {
29
- "@ai-sdk/provider-utils": "5.0.47",
30
- "ai": "7.0.114",
29
+ "@ai-sdk/provider-utils": "5.0.49",
30
+ "ai": "7.0.116",
31
31
  "swrv": "^1.2.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@ai-sdk/test-server": "2.0.1",
34
+ "@ai-sdk/test-server": "2.0.2",
35
35
  "@testing-library/jest-dom": "^6.9.1",
36
36
  "@testing-library/user-event": "^14.6.1",
37
37
  "@testing-library/vue": "^8.1.0",