@puckeditor/plugin-ai 0.6.0-canary.b2a309bd → 0.6.0-canary.c5d71c26

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/dist/index.js CHANGED
@@ -274,7 +274,7 @@ var TriangleAlert = createLucideIcon("TriangleAlert", [
274
274
  // src/components/Chat/index.tsx
275
275
  init_react_import();
276
276
 
277
- // ../../node_modules/.pnpm/@ai-sdk+react@2.0.29_react@19.1.1_zod@4.3.5/node_modules/@ai-sdk/react/dist/index.mjs
277
+ // ../../node_modules/.pnpm/@ai-sdk+react@3.0.63_react@19.1.1_zod@4.3.5/node_modules/@ai-sdk/react/dist/index.mjs
278
278
  init_react_import();
279
279
  var import_react4 = require("react");
280
280
  var import_ai = require("ai");
@@ -418,19 +418,59 @@ function useChat({
418
418
  resume = false,
419
419
  ...options
420
420
  } = {}) {
421
+ const callbacksRef = (0, import_react4.useRef)(
422
+ !("chat" in options) ? {
423
+ onToolCall: options.onToolCall,
424
+ onData: options.onData,
425
+ onFinish: options.onFinish,
426
+ onError: options.onError,
427
+ sendAutomaticallyWhen: options.sendAutomaticallyWhen
428
+ } : {}
429
+ );
430
+ if (!("chat" in options)) {
431
+ callbacksRef.current = {
432
+ onToolCall: options.onToolCall,
433
+ onData: options.onData,
434
+ onFinish: options.onFinish,
435
+ onError: options.onError,
436
+ sendAutomaticallyWhen: options.sendAutomaticallyWhen
437
+ };
438
+ }
439
+ const optionsWithCallbacks = {
440
+ ...options,
441
+ onToolCall: (arg) => {
442
+ var _a, _b;
443
+ return (_b = (_a = callbacksRef.current).onToolCall) == null ? void 0 : _b.call(_a, arg);
444
+ },
445
+ onData: (arg) => {
446
+ var _a, _b;
447
+ return (_b = (_a = callbacksRef.current).onData) == null ? void 0 : _b.call(_a, arg);
448
+ },
449
+ onFinish: (arg) => {
450
+ var _a, _b;
451
+ return (_b = (_a = callbacksRef.current).onFinish) == null ? void 0 : _b.call(_a, arg);
452
+ },
453
+ onError: (arg) => {
454
+ var _a, _b;
455
+ return (_b = (_a = callbacksRef.current).onError) == null ? void 0 : _b.call(_a, arg);
456
+ },
457
+ sendAutomaticallyWhen: (arg) => {
458
+ var _a, _b, _c;
459
+ return (_c = (_b = (_a = callbacksRef.current).sendAutomaticallyWhen) == null ? void 0 : _b.call(_a, arg)) != null ? _c : false;
460
+ }
461
+ };
421
462
  const chatRef = (0, import_react4.useRef)(
422
- "chat" in options ? options.chat : new Chat(options)
463
+ "chat" in options ? options.chat : new Chat(optionsWithCallbacks)
423
464
  );
424
465
  const shouldRecreateChat = "chat" in options && options.chat !== chatRef.current || "id" in options && chatRef.current.id !== options.id;
425
466
  if (shouldRecreateChat) {
426
- chatRef.current = "chat" in options ? options.chat : new Chat(options);
467
+ chatRef.current = "chat" in options ? options.chat : new Chat(optionsWithCallbacks);
427
468
  }
428
- const optionsId = "id" in options ? options.id : null;
429
469
  const subscribeToMessages = (0, import_react4.useCallback)(
430
470
  (update) => chatRef.current["~registerMessagesCallback"](update, throttleWaitMs),
431
- // optionsId is required to trigger re-subscription when the chat ID changes
471
+ // `chatRef.current.id` is required to trigger re-subscription when the chat ID changes
432
472
  // eslint-disable-next-line react-hooks/exhaustive-deps
433
- [throttleWaitMs, optionsId]
473
+ [throttleWaitMs, chatRef.current.id]
434
474
  );
435
475
  const messages = (0, import_react4.useSyncExternalStore)(
436
476
  subscribeToMessages,
@@ -472,7 +512,12 @@ function useChat({
472
512
  error,
473
513
  resumeStream: chatRef.current.resumeStream,
474
514
  status,
475
- addToolResult: chatRef.current.addToolResult
515
+ /**
516
+ * @deprecated Use `addToolOutput` instead.
517
+ */
518
+ addToolResult: chatRef.current.addToolOutput,
519
+ addToolOutput: chatRef.current.addToolOutput,
520
+ addToolApprovalResponse: chatRef.current.addToolApprovalResponse
476
521
  };
477
522
  }
478
523
 
package/dist/index.mjs CHANGED
@@ -262,7 +262,7 @@ var TriangleAlert = createLucideIcon("TriangleAlert", [
262
262
  // src/components/Chat/index.tsx
263
263
  init_react_import();
264
264
 
265
- // ../../node_modules/.pnpm/@ai-sdk+react@2.0.29_react@19.1.1_zod@4.3.5/node_modules/@ai-sdk/react/dist/index.mjs
265
+ // ../../node_modules/.pnpm/@ai-sdk+react@3.0.63_react@19.1.1_zod@4.3.5/node_modules/@ai-sdk/react/dist/index.mjs
266
266
  init_react_import();
267
267
  var import_throttleit = __toESM(require_throttleit(), 1);
268
268
  import { useCallback, useEffect, useRef, useSyncExternalStore } from "react";
@@ -271,11 +271,7 @@ import {
271
271
  callCompletionApi
272
272
  } from "ai";
273
273
  import { useCallback as useCallback2, useEffect as useEffect2, useId, useRef as useRef2, useState } from "react";
274
- import {
275
- asSchema,
276
- isDeepEqualData,
277
- parsePartialJson
278
- } from "ai";
274
+ import { asSchema, isDeepEqualData, parsePartialJson } from "ai";
279
275
  import { useCallback as useCallback3, useId as useId2, useRef as useRef3, useState as useState2 } from "react";
280
276
  var __accessCheck = (obj, member, msg) => {
281
277
  if (!member.has(obj))
@@ -412,19 +408,59 @@ function useChat({
412
408
  resume = false,
413
409
  ...options
414
410
  } = {}) {
411
+ const callbacksRef = useRef(
412
+ !("chat" in options) ? {
413
+ onToolCall: options.onToolCall,
414
+ onData: options.onData,
415
+ onFinish: options.onFinish,
416
+ onError: options.onError,
417
+ sendAutomaticallyWhen: options.sendAutomaticallyWhen
418
+ } : {}
419
+ );
420
+ if (!("chat" in options)) {
421
+ callbacksRef.current = {
422
+ onToolCall: options.onToolCall,
423
+ onData: options.onData,
424
+ onFinish: options.onFinish,
425
+ onError: options.onError,
426
+ sendAutomaticallyWhen: options.sendAutomaticallyWhen
427
+ };
428
+ }
429
+ const optionsWithCallbacks = {
430
+ ...options,
431
+ onToolCall: (arg) => {
432
+ var _a, _b;
433
+ return (_b = (_a = callbacksRef.current).onToolCall) == null ? void 0 : _b.call(_a, arg);
434
+ },
435
+ onData: (arg) => {
436
+ var _a, _b;
437
+ return (_b = (_a = callbacksRef.current).onData) == null ? void 0 : _b.call(_a, arg);
438
+ },
439
+ onFinish: (arg) => {
440
+ var _a, _b;
441
+ return (_b = (_a = callbacksRef.current).onFinish) == null ? void 0 : _b.call(_a, arg);
442
+ },
443
+ onError: (arg) => {
444
+ var _a, _b;
445
+ return (_b = (_a = callbacksRef.current).onError) == null ? void 0 : _b.call(_a, arg);
446
+ },
447
+ sendAutomaticallyWhen: (arg) => {
448
+ var _a, _b, _c;
449
+ return (_c = (_b = (_a = callbacksRef.current).sendAutomaticallyWhen) == null ? void 0 : _b.call(_a, arg)) != null ? _c : false;
450
+ }
451
+ };
415
452
  const chatRef = useRef(
416
- "chat" in options ? options.chat : new Chat(options)
453
+ "chat" in options ? options.chat : new Chat(optionsWithCallbacks)
417
454
  );
418
455
  const shouldRecreateChat = "chat" in options && options.chat !== chatRef.current || "id" in options && chatRef.current.id !== options.id;
419
456
  if (shouldRecreateChat) {
420
- chatRef.current = "chat" in options ? options.chat : new Chat(options);
457
+ chatRef.current = "chat" in options ? options.chat : new Chat(optionsWithCallbacks);
421
458
  }
422
- const optionsId = "id" in options ? options.id : null;
423
459
  const subscribeToMessages = useCallback(
424
460
  (update) => chatRef.current["~registerMessagesCallback"](update, throttleWaitMs),
425
- // optionsId is required to trigger re-subscription when the chat ID changes
461
+ // `chatRef.current.id` is required to trigger re-subscription when the chat ID changes
426
462
  // eslint-disable-next-line react-hooks/exhaustive-deps
427
- [throttleWaitMs, optionsId]
463
+ [throttleWaitMs, chatRef.current.id]
428
464
  );
429
465
  const messages = useSyncExternalStore(
430
466
  subscribeToMessages,
@@ -466,7 +502,12 @@ function useChat({
466
502
  error,
467
503
  resumeStream: chatRef.current.resumeStream,
468
504
  status,
469
- addToolResult: chatRef.current.addToolResult
505
+ /**
506
+ * @deprecated Use `addToolOutput` instead.
507
+ */
508
+ addToolResult: chatRef.current.addToolOutput,
509
+ addToolOutput: chatRef.current.addToolOutput,
510
+ addToolApprovalResponse: chatRef.current.addToolApprovalResponse
470
511
  };
471
512
  }
472
513
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puckeditor/plugin-ai",
3
- "version": "0.6.0-canary.b2a309bd",
3
+ "version": "0.6.0-canary.c5d71c26",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "puckeditor/puck",
6
6
  "bugs": "https://github.com/puckeditor/puck/issues",
@@ -27,7 +27,7 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "ai": "^5.0.29",
30
+ "ai": "^6.0.61",
31
31
  "html2canvas-pro": "^1.5.13",
32
32
  "qler": "^0.6.2",
33
33
  "react-markdown": "^10.1.0",
@@ -36,7 +36,7 @@
36
36
  "use-stick-to-bottom": "^1.1.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@ai-sdk/react": "^2.0.29",
39
+ "@ai-sdk/react": "^3.0.63",
40
40
  "@puckeditor/ai-types": "workspace:*",
41
41
  "@puckeditor/core": "0.21.0-canary.de0baf39",
42
42
  "@puckeditor/platform-types": "workspace:*",