@assistant-ui/react 0.7.69 → 0.7.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. package/dist/api/MessageRuntime.d.ts +2 -1
  2. package/dist/api/MessageRuntime.d.ts.map +1 -1
  3. package/dist/api/MessageRuntime.js +9 -2
  4. package/dist/api/MessageRuntime.js.map +1 -1
  5. package/dist/api/MessageRuntime.mjs +9 -2
  6. package/dist/api/MessageRuntime.mjs.map +1 -1
  7. package/dist/context/providers/ThreadRuntimeProvider.d.ts.map +1 -1
  8. package/dist/context/providers/ThreadRuntimeProvider.js +3 -5
  9. package/dist/context/providers/ThreadRuntimeProvider.js.map +1 -1
  10. package/dist/context/providers/ThreadRuntimeProvider.mjs +3 -5
  11. package/dist/context/providers/ThreadRuntimeProvider.mjs.map +1 -1
  12. package/dist/context/providers/ThreadViewportProvider.d.ts +3 -0
  13. package/dist/context/providers/ThreadViewportProvider.d.ts.map +1 -0
  14. package/dist/context/providers/ThreadViewportProvider.js +63 -0
  15. package/dist/context/providers/ThreadViewportProvider.js.map +1 -0
  16. package/dist/context/providers/ThreadViewportProvider.mjs +42 -0
  17. package/dist/context/providers/ThreadViewportProvider.mjs.map +1 -0
  18. package/dist/context/react/ThreadContext.d.ts +0 -18
  19. package/dist/context/react/ThreadContext.d.ts.map +1 -1
  20. package/dist/context/react/ThreadContext.js +2 -11
  21. package/dist/context/react/ThreadContext.js.map +1 -1
  22. package/dist/context/react/ThreadContext.mjs +1 -8
  23. package/dist/context/react/ThreadContext.mjs.map +1 -1
  24. package/dist/context/react/ThreadViewportContext.d.ts +24 -0
  25. package/dist/context/react/ThreadViewportContext.d.ts.map +1 -0
  26. package/dist/context/react/ThreadViewportContext.js +44 -0
  27. package/dist/context/react/ThreadViewportContext.js.map +1 -0
  28. package/dist/context/react/ThreadViewportContext.mjs +18 -0
  29. package/dist/context/react/ThreadViewportContext.mjs.map +1 -0
  30. package/dist/context/react/index.d.ts +2 -1
  31. package/dist/context/react/index.d.ts.map +1 -1
  32. package/dist/context/react/index.js +3 -2
  33. package/dist/context/react/index.js.map +1 -1
  34. package/dist/context/react/index.mjs +4 -2
  35. package/dist/context/react/index.mjs.map +1 -1
  36. package/dist/context/stores/ThreadViewport.d.ts.map +1 -1
  37. package/dist/context/stores/ThreadViewport.js +1 -0
  38. package/dist/context/stores/ThreadViewport.js.map +1 -1
  39. package/dist/context/stores/ThreadViewport.mjs +2 -0
  40. package/dist/context/stores/ThreadViewport.mjs.map +1 -1
  41. package/dist/model-context/ModelContextTypes.d.ts +3 -0
  42. package/dist/model-context/ModelContextTypes.d.ts.map +1 -1
  43. package/dist/model-context/ModelContextTypes.js.map +1 -1
  44. package/dist/model-context/ModelContextTypes.mjs.map +1 -1
  45. package/dist/primitives/thread/ThreadScrollToBottom.d.ts.map +1 -1
  46. package/dist/primitives/thread/ThreadScrollToBottom.js +3 -4
  47. package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
  48. package/dist/primitives/thread/ThreadScrollToBottom.mjs +1 -2
  49. package/dist/primitives/thread/ThreadScrollToBottom.mjs.map +1 -1
  50. package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
  51. package/dist/primitives/thread/ThreadViewport.js +5 -1
  52. package/dist/primitives/thread/ThreadViewport.js.map +1 -1
  53. package/dist/primitives/thread/ThreadViewport.mjs +5 -1
  54. package/dist/primitives/thread/ThreadViewport.mjs.map +1 -1
  55. package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
  56. package/dist/primitives/thread/useThreadViewportAutoScroll.js +2 -1
  57. package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
  58. package/dist/primitives/thread/useThreadViewportAutoScroll.mjs +2 -4
  59. package/dist/primitives/thread/useThreadViewportAutoScroll.mjs.map +1 -1
  60. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts +1 -1
  61. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
  62. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +1 -0
  63. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
  64. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +1 -0
  65. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
  66. package/dist/runtimes/edge/streams/toolResultStream.d.ts.map +1 -1
  67. package/dist/runtimes/edge/streams/toolResultStream.js +13 -15
  68. package/dist/runtimes/edge/streams/toolResultStream.js.map +1 -1
  69. package/dist/runtimes/edge/streams/toolResultStream.mjs +13 -15
  70. package/dist/runtimes/edge/streams/toolResultStream.mjs.map +1 -1
  71. package/dist/utils/hooks/useOnScrollToBottom.js +2 -2
  72. package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
  73. package/dist/utils/hooks/useOnScrollToBottom.mjs +1 -1
  74. package/dist/utils/hooks/useOnScrollToBottom.mjs.map +1 -1
  75. package/package.json +3 -3
  76. package/src/api/MessageRuntime.ts +14 -5
  77. package/src/context/providers/ThreadRuntimeProvider.tsx +4 -5
  78. package/src/context/providers/ThreadViewportProvider.tsx +49 -0
  79. package/src/context/react/ThreadContext.ts +0 -8
  80. package/src/context/react/ThreadViewportContext.ts +23 -0
  81. package/src/context/react/index.ts +4 -1
  82. package/src/context/stores/ThreadViewport.tsx +2 -0
  83. package/src/model-context/ModelContextTypes.ts +7 -0
  84. package/src/primitives/thread/ThreadScrollToBottom.tsx +1 -2
  85. package/src/primitives/thread/ThreadViewport.tsx +13 -1
  86. package/src/primitives/thread/useThreadViewportAutoScroll.tsx +2 -4
  87. package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +4 -1
  88. package/src/runtimes/edge/streams/toolResultStream.ts +20 -18
  89. package/src/utils/hooks/useOnScrollToBottom.tsx +1 -1
@@ -0,0 +1,24 @@
1
+ import { ReadonlyStore } from "../ReadonlyStore";
2
+ import { UseBoundStore } from "zustand";
3
+ import { ThreadViewportState } from "../stores";
4
+ export type ThreadViewportContextValue = {
5
+ useThreadViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;
6
+ };
7
+ export declare const ThreadViewportContext: import("react").Context<ThreadViewportContextValue | null>;
8
+ export declare const useThreadViewport: {
9
+ (): ThreadViewportState;
10
+ <TSelected>(selector: (state: ThreadViewportState) => TSelected): TSelected;
11
+ (options: {
12
+ optional: true;
13
+ }): ThreadViewportState | null;
14
+ <TSelected>(options: {
15
+ optional: true;
16
+ selector?: (state: ThreadViewportState) => TSelected;
17
+ }): TSelected | null;
18
+ }, useThreadViewportStore: {
19
+ (): ReadonlyStore<ThreadViewportState>;
20
+ (options: {
21
+ optional: true;
22
+ }): ReadonlyStore<ThreadViewportState> | null;
23
+ };
24
+ //# sourceMappingURL=ThreadViewportContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadViewportContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/ThreadViewportContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,MAAM,0BAA0B,GAAG;IACvC,iBAAiB,EAAE,aAAa,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,qBAAqB,4DACsB,CAAC;AAOzD,eAAO,MAAQ,iBAAiB;;;;;;;;;;GAAE,sBAAsB;;;;;CACe,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/context/react/ThreadViewportContext.ts
22
+ var ThreadViewportContext_exports = {};
23
+ __export(ThreadViewportContext_exports, {
24
+ ThreadViewportContext: () => ThreadViewportContext,
25
+ useThreadViewport: () => useThreadViewport,
26
+ useThreadViewportStore: () => useThreadViewportStore
27
+ });
28
+ module.exports = __toCommonJS(ThreadViewportContext_exports);
29
+ var import_react = require("react");
30
+ var import_createContextHook = require("./utils/createContextHook.js");
31
+ var import_createContextStoreHook = require("./utils/createContextStoreHook.js");
32
+ var ThreadViewportContext = (0, import_react.createContext)(null);
33
+ var useThreadViewportContext = (0, import_createContextHook.createContextHook)(
34
+ ThreadViewportContext,
35
+ "ThreadPrimitive.Viewport"
36
+ );
37
+ var { useThreadViewport, useThreadViewportStore } = (0, import_createContextStoreHook.createContextStoreHook)(useThreadViewportContext, "useThreadViewport");
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ ThreadViewportContext,
41
+ useThreadViewport,
42
+ useThreadViewportStore
43
+ });
44
+ //# sourceMappingURL=ThreadViewportContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/react/ThreadViewportContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { ThreadViewportState } from \"../stores\";\n\nexport type ThreadViewportContextValue = {\n useThreadViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;\n};\n\nexport const ThreadViewportContext =\n createContext<ThreadViewportContextValue | null>(null);\n\nconst useThreadViewportContext = createContextHook(\n ThreadViewportContext,\n \"ThreadPrimitive.Viewport\",\n);\n\nexport const { useThreadViewport, useThreadViewportStore } =\n createContextStoreHook(useThreadViewportContext, \"useThreadViewport\");\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA8B;AAG9B,+BAAkC;AAClC,oCAAuC;AAOhC,IAAM,4BACX,4BAAiD,IAAI;AAEvD,IAAM,+BAA2B;AAAA,EAC/B;AAAA,EACA;AACF;AAEO,IAAM,EAAE,mBAAmB,uBAAuB,QACvD,sDAAuB,0BAA0B,mBAAmB;","names":[]}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+
3
+ // src/context/react/ThreadViewportContext.ts
4
+ import { createContext } from "react";
5
+ import { createContextHook } from "./utils/createContextHook.mjs";
6
+ import { createContextStoreHook } from "./utils/createContextStoreHook.mjs";
7
+ var ThreadViewportContext = createContext(null);
8
+ var useThreadViewportContext = createContextHook(
9
+ ThreadViewportContext,
10
+ "ThreadPrimitive.Viewport"
11
+ );
12
+ var { useThreadViewport, useThreadViewportStore } = createContextStoreHook(useThreadViewportContext, "useThreadViewport");
13
+ export {
14
+ ThreadViewportContext,
15
+ useThreadViewport,
16
+ useThreadViewportStore
17
+ };
18
+ //# sourceMappingURL=ThreadViewportContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/react/ThreadViewportContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { ThreadViewportState } from \"../stores\";\n\nexport type ThreadViewportContextValue = {\n useThreadViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;\n};\n\nexport const ThreadViewportContext =\n createContext<ThreadViewportContextValue | null>(null);\n\nconst useThreadViewportContext = createContextHook(\n ThreadViewportContext,\n \"ThreadPrimitive.Viewport\",\n);\n\nexport const { useThreadViewport, useThreadViewportStore } =\n createContextStoreHook(useThreadViewportContext, \"useThreadViewport\");\n"],"mappings":";;;AAEA,SAAS,qBAAqB;AAG9B,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAOhC,IAAM,wBACX,cAAiD,IAAI;AAEvD,IAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AACF;AAEO,IAAM,EAAE,mBAAmB,uBAAuB,IACvD,uBAAuB,0BAA0B,mBAAmB;","names":[]}
@@ -3,7 +3,8 @@ export { useThreadRuntime, useThread, useThreadComposer, useThreadModelContext,
3
3
  /**
4
4
  * @deprecated This method was renamed to `useThreadModelContext`.
5
5
  */
6
- useThreadModelContext as useThreadModelConfig, useThreadViewport, useThreadViewportStore, } from "./ThreadContext";
6
+ useThreadModelContext as useThreadModelConfig, } from "./ThreadContext";
7
+ export { useThreadViewport, useThreadViewportStore, } from "./ThreadViewportContext";
7
8
  export { useThreadListItemRuntime, useThreadListItem, } from "./ThreadListItemContext";
8
9
  export { useMessageRuntime, useMessage, useEditComposer, useMessageUtils, useMessageUtilsStore, } from "./MessageContext";
9
10
  export { useContentPartRuntime, useContentPart } from "./ContentPartContext";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/react/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,qBAAqB;AACrB;;GAEG;AACH,qBAAqB,IAAI,oBAAoB,EAC7C,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EACL,aAAa,EACb,oBAAoB,GASrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/react/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,qBAAqB;AACrB;;GAEG;AACH,qBAAqB,IAAI,oBAAoB,GAC9C,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EACL,aAAa,EACb,oBAAoB,GASrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC"}
@@ -42,14 +42,15 @@ __export(react_exports, {
42
42
  useThreadModelConfig: () => import_ThreadContext.useThreadModelContext,
43
43
  useThreadModelContext: () => import_ThreadContext.useThreadModelContext,
44
44
  useThreadRuntime: () => import_ThreadContext.useThreadRuntime,
45
- useThreadViewport: () => import_ThreadContext.useThreadViewport,
46
- useThreadViewportStore: () => import_ThreadContext.useThreadViewportStore,
45
+ useThreadViewport: () => import_ThreadViewportContext.useThreadViewport,
46
+ useThreadViewportStore: () => import_ThreadViewportContext.useThreadViewportStore,
47
47
  useToolUIs: () => import_AssistantContext.useToolUIs,
48
48
  useToolUIsStore: () => import_AssistantContext.useToolUIsStore
49
49
  });
50
50
  module.exports = __toCommonJS(react_exports);
51
51
  var import_AssistantContext = require("./AssistantContext.js");
52
52
  var import_ThreadContext = require("./ThreadContext.js");
53
+ var import_ThreadViewportContext = require("./ThreadViewportContext.js");
53
54
  var import_ThreadListItemContext = require("./ThreadListItemContext.js");
54
55
  var import_MessageContext = require("./MessageContext.js");
55
56
  var import_ContentPartContext = require("./ContentPartContext.js");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelContext,\n /**\n * @deprecated This method was renamed to `useThreadModelContext`.\n */\n useThreadModelContext as useThreadModelConfig,\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n\nexport { useRuntimeState } from \"./utils/useRuntimeState\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAKO;AAEP,2BAWO;AAEP,mCAGO;AAEP,4BAMO;AACP,gCAAsD;AACtD,6BAAgD;AAEhD,+BAWO;AAEP,6BAAgC;","names":[]}
1
+ {"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelContext,\n /**\n * @deprecated This method was renamed to `useThreadModelContext`.\n */\n useThreadModelContext as useThreadModelConfig,\n} from \"./ThreadContext\";\n\nexport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadViewportContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n\nexport { useRuntimeState } from \"./utils/useRuntimeState\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAKO;AAEP,2BASO;AAEP,mCAGO;AAEP,mCAGO;AAEP,4BAMO;AACP,gCAAsD;AACtD,6BAAgD;AAEhD,+BAWO;AAEP,6BAAgC;","names":[]}
@@ -12,10 +12,12 @@ import {
12
12
  useThread,
13
13
  useThreadComposer,
14
14
  useThreadModelContext,
15
- useThreadModelContext as useThreadModelContext2,
15
+ useThreadModelContext as useThreadModelContext2
16
+ } from "./ThreadContext.mjs";
17
+ import {
16
18
  useThreadViewport,
17
19
  useThreadViewportStore
18
- } from "./ThreadContext.mjs";
20
+ } from "./ThreadViewportContext.mjs";
19
21
  import {
20
22
  useThreadListItemRuntime,
21
23
  useThreadListItem
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelContext,\n /**\n * @deprecated This method was renamed to `useThreadModelContext`.\n */\n useThreadModelContext as useThreadModelConfig,\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n\nexport { useRuntimeState } from \"./utils/useRuntimeState\";\n"],"mappings":";;;AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIyB,yBAAzBA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB,sBAAsB;AACtD,SAAS,oBAAoB,mBAAmB;AAEhD;AAAA,EACE;AAAA,EACA;AAAA,OASK;AAEP,SAAS,uBAAuB;","names":["useThreadModelContext"]}
1
+ {"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelContext,\n /**\n * @deprecated This method was renamed to `useThreadModelContext`.\n */\n useThreadModelContext as useThreadModelConfig,\n} from \"./ThreadContext\";\n\nexport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadViewportContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n\nexport { useRuntimeState } from \"./utils/useRuntimeState\";\n"],"mappings":";;;AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIyB,yBAAzBA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB,sBAAsB;AACtD,SAAS,oBAAoB,mBAAmB;AAEhD;AAAA,EACE;AAAA,EACA;AAAA,OASK;AAEP,SAAS,uBAAuB;","names":["useThreadModelContext"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadViewport.d.ts","sourceRoot":"","sources":["../../../src/context/stores/ThreadViewport.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC;IACpC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,WAAW,CAAC;CAClE,CAAC;AAEF,eAAO,MAAM,uBAAuB,wFAiBnC,CAAC"}
1
+ {"version":3,"file":"ThreadViewport.d.ts","sourceRoot":"","sources":["../../../src/context/stores/ThreadViewport.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC;IACpC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,WAAW,CAAC;CAClE,CAAC;AAEF,eAAO,MAAM,uBAAuB,wFAiBnC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/stores/ThreadViewport.tsx"],"sourcesContent":["import { create } from \"zustand\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\n\nexport type ThreadViewportState = {\n readonly isAtBottom: boolean;\n readonly scrollToBottom: () => void;\n readonly onScrollToBottom: (callback: () => void) => Unsubscribe;\n};\n\nexport const makeThreadViewportStore = () => {\n const scrollToBottomListeners = new Set<() => void>();\n\n return create<ThreadViewportState>(() => ({\n isAtBottom: true,\n scrollToBottom: () => {\n for (const listener of scrollToBottomListeners) {\n listener();\n }\n },\n onScrollToBottom: (callback) => {\n scrollToBottomListeners.add(callback);\n return () => {\n scrollToBottomListeners.delete(callback);\n };\n },\n }));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAuB;AAShB,IAAM,0BAA0B,MAAM;AAC3C,QAAM,0BAA0B,oBAAI,IAAgB;AAEpD,aAAO,uBAA4B,OAAO;AAAA,IACxC,YAAY;AAAA,IACZ,gBAAgB,MAAM;AACpB,iBAAW,YAAY,yBAAyB;AAC9C,iBAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,kBAAkB,CAAC,aAAa;AAC9B,8BAAwB,IAAI,QAAQ;AACpC,aAAO,MAAM;AACX,gCAAwB,OAAO,QAAQ;AAAA,MACzC;AAAA,IACF;AAAA,EACF,EAAE;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/context/stores/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { create } from \"zustand\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\n\nexport type ThreadViewportState = {\n readonly isAtBottom: boolean;\n readonly scrollToBottom: () => void;\n readonly onScrollToBottom: (callback: () => void) => Unsubscribe;\n};\n\nexport const makeThreadViewportStore = () => {\n const scrollToBottomListeners = new Set<() => void>();\n\n return create<ThreadViewportState>(() => ({\n isAtBottom: true,\n scrollToBottom: () => {\n for (const listener of scrollToBottomListeners) {\n listener();\n }\n },\n onScrollToBottom: (callback) => {\n scrollToBottomListeners.add(callback);\n return () => {\n scrollToBottomListeners.delete(callback);\n };\n },\n }));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBAAuB;AAShB,IAAM,0BAA0B,MAAM;AAC3C,QAAM,0BAA0B,oBAAI,IAAgB;AAEpD,aAAO,uBAA4B,OAAO;AAAA,IACxC,YAAY;AAAA,IACZ,gBAAgB,MAAM;AACpB,iBAAW,YAAY,yBAAyB;AAC9C,iBAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,kBAAkB,CAAC,aAAa;AAC9B,8BAAwB,IAAI,QAAQ;AACpC,aAAO,MAAM;AACX,gCAAwB,OAAO,QAAQ;AAAA,MACzC;AAAA,IACF;AAAA,EACF,EAAE;AACJ;","names":[]}
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  // src/context/stores/ThreadViewport.tsx
2
4
  import { create } from "zustand";
3
5
  var makeThreadViewportStore = () => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/stores/ThreadViewport.tsx"],"sourcesContent":["import { create } from \"zustand\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\n\nexport type ThreadViewportState = {\n readonly isAtBottom: boolean;\n readonly scrollToBottom: () => void;\n readonly onScrollToBottom: (callback: () => void) => Unsubscribe;\n};\n\nexport const makeThreadViewportStore = () => {\n const scrollToBottomListeners = new Set<() => void>();\n\n return create<ThreadViewportState>(() => ({\n isAtBottom: true,\n scrollToBottom: () => {\n for (const listener of scrollToBottomListeners) {\n listener();\n }\n },\n onScrollToBottom: (callback) => {\n scrollToBottomListeners.add(callback);\n return () => {\n scrollToBottomListeners.delete(callback);\n };\n },\n }));\n};\n"],"mappings":";AAAA,SAAS,cAAc;AAShB,IAAM,0BAA0B,MAAM;AAC3C,QAAM,0BAA0B,oBAAI,IAAgB;AAEpD,SAAO,OAA4B,OAAO;AAAA,IACxC,YAAY;AAAA,IACZ,gBAAgB,MAAM;AACpB,iBAAW,YAAY,yBAAyB;AAC9C,iBAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,kBAAkB,CAAC,aAAa;AAC9B,8BAAwB,IAAI,QAAQ;AACpC,aAAO,MAAM;AACX,gCAAwB,OAAO,QAAQ;AAAA,MACzC;AAAA,IACF;AAAA,EACF,EAAE;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/context/stores/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { create } from \"zustand\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\n\nexport type ThreadViewportState = {\n readonly isAtBottom: boolean;\n readonly scrollToBottom: () => void;\n readonly onScrollToBottom: (callback: () => void) => Unsubscribe;\n};\n\nexport const makeThreadViewportStore = () => {\n const scrollToBottomListeners = new Set<() => void>();\n\n return create<ThreadViewportState>(() => ({\n isAtBottom: true,\n scrollToBottom: () => {\n for (const listener of scrollToBottomListeners) {\n listener();\n }\n },\n onScrollToBottom: (callback) => {\n scrollToBottomListeners.add(callback);\n return () => {\n scrollToBottomListeners.delete(callback);\n };\n },\n }));\n};\n"],"mappings":";;;AAEA,SAAS,cAAc;AAShB,IAAM,0BAA0B,MAAM;AAC3C,QAAM,0BAA0B,oBAAI,IAAgB;AAEpD,SAAO,OAA4B,OAAO;AAAA,IACxC,YAAY;AAAA,IACZ,gBAAgB,MAAM;AACpB,iBAAW,YAAY,yBAAyB;AAC9C,iBAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,kBAAkB,CAAC,aAAa;AAC9B,8BAAwB,IAAI,QAAQ;AACpC,aAAO,MAAM;AACX,gCAAwB,OAAO,QAAQ;AAAA,MACzC;AAAA,IACF;AAAA,EACF,EAAE;AACJ;","names":[]}
@@ -42,12 +42,15 @@ export declare const LanguageModelConfigSchema: z.ZodObject<{
42
42
  }>;
43
43
  export type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;
44
44
  type ToolExecuteFunction<TArgs, TResult> = (args: TArgs, context: {
45
+ toolCallId: string;
45
46
  abortSignal: AbortSignal;
46
47
  }) => TResult | Promise<TResult>;
48
+ type OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<unknown, TResult>;
47
49
  export type Tool<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
48
50
  description?: string | undefined;
49
51
  parameters: z.ZodSchema<TArgs> | JSONSchema7;
50
52
  execute?: ToolExecuteFunction<TArgs, TResult>;
53
+ experimental_onSchemaValidationError?: OnSchemaValidationErrorFunction<TResult>;
51
54
  };
52
55
  export type ModelContext = {
53
56
  priority?: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"ModelContextTypes.d.ts","sourceRoot":"","sources":["../../src/model-context/ModelContextTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;EAQ5C,CAAC;AAEH,MAAM,MAAM,2BA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AAK,EAAE,OAAO,CAAC,CAAC;IAC9C,oCAAoC,CAAC,EAAE,+BAA+B,CAAC,OAAO,CAAC,CAAC;CACjF,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC;IACnD,YAAY,CAAC,EAAE,2BAA2B,GAAG,SAAS,CAAC;IACvD,MAAM,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,MAAM,YAAY,CAAC;IACpC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,WAAW,CAAC;CACnD,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAClB,GAAG,CAAC,oBAAoB,CAAC,KACnC,YAuCF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model-context/ModelContextTypes.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"../types/Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\nexport type Tool<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n description?: string | undefined;\n parameters: z.ZodSchema<TArgs> | JSONSchema7;\n execute?: ToolExecuteFunction<TArgs, TResult>;\n};\n\nexport type ModelContext = {\n priority?: number | undefined;\n system?: string | undefined;\n tools?: Record<string, Tool<any, any>> | undefined;\n callSettings?: LanguageModelV1CallSettings | undefined;\n config?: LanguageModelConfig | undefined;\n};\n\nexport type ModelContextProvider = {\n getModelContext: () => ModelContext;\n subscribe?: (callback: () => void) => Unsubscribe;\n};\n\nexport const mergeModelContexts = (\n configSet: Set<ModelContextProvider>,\n): ModelContext => {\n const configs = Array.from(configSet)\n .map((c) => c.getModelContext())\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n for (const [name, tool] of Object.entries(config.tools)) {\n if (acc.tools?.[name]) {\n throw new Error(\n `You tried to define a tool with the name ${name}, but it already exists.`,\n );\n }\n if (!acc.tools) acc.tools = {};\n acc.tools[name] = tool;\n }\n }\n if (config.config) {\n acc.config = {\n ...acc.config,\n ...config.config,\n };\n }\n if (config.callSettings) {\n acc.callSettings = {\n ...acc.callSettings,\n ...config.callSettings,\n };\n }\n return acc;\n }, {} as ModelContext);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAIX,IAAM,oCAAoC,aAAE,OAAO;AAAA,EACxD,WAAW,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAAA,EAChD,aAAa,aAAE,OAAO,EAAE,SAAS;AAAA,EACjC,MAAM,aAAE,OAA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cAAc;AACvB,UAAI,eAAe;AAAA,QACjB,GAAG,IAAI;AAAA,QACP,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAiB;AACvB;","names":[]}
1
+ {"version":3,"sources":["../../src/model-context/ModelContextTypes.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"../types/Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n toolCallId: string;\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\ntype OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<\n unknown,\n TResult\n>;\n\nexport type Tool<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n description?: string | undefined;\n parameters: z.ZodSchema<TArgs> | JSONSchema7;\n execute?: ToolExecuteFunction<TArgs, TResult>;\n experimental_onSchemaValidationError?: OnSchemaValidationErrorFunction<TResult>;\n};\n\nexport type ModelContext = {\n priority?: number | undefined;\n system?: string | undefined;\n tools?: Record<string, Tool<any, any>> | undefined;\n callSettings?: LanguageModelV1CallSettings | undefined;\n config?: LanguageModelConfig | undefined;\n};\n\nexport type ModelContextProvider = {\n getModelContext: () => ModelContext;\n subscribe?: (callback: () => void) => Unsubscribe;\n};\n\nexport const mergeModelContexts = (\n configSet: Set<ModelContextProvider>,\n): ModelContext => {\n const configs = Array.from(configSet)\n .map((c) => c.getModelContext())\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n for (const [name, tool] of Object.entries(config.tools)) {\n if (acc.tools?.[name]) {\n throw new Error(\n `You tried to define a tool with the name ${name}, but it already exists.`,\n );\n }\n if (!acc.tools) acc.tools = {};\n acc.tools[name] = tool;\n }\n }\n if (config.config) {\n acc.config = {\n ...acc.config,\n ...config.config,\n };\n }\n if (config.callSettings) {\n acc.callSettings = {\n ...acc.callSettings,\n ...config.callSettings,\n };\n }\n return acc;\n }, {} as ModelContext);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAIX,IAAM,oCAAoC,aAAE,OAAO;AAAA,EACxD,WAAW,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAAA,EAChD,aAAa,aAAE,OAAO,EAAE,SAAS;AAAA,EACjC,MAAM,aAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,iBAAiB,aAAE,OAAO,EAAE,SAAS;AAAA,EACrC,kBAAkB,aAAE,OAAO,EAAE,SAAS;AAAA,EACtC,MAAM,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAChC,SAAS,aAAE,OAAO,aAAE,OAAO,EAAE,SAAS,CAAC,EAAE,SAAS;AACpD,CAAC;AAMM,IAAM,4BAA4B,aAAE,OAAO;AAAA,EAChD,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,SAAS,aAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,WAAW,aAAE,OAAO,EAAE,SAAS;AACjC,CAAC;AAwCM,IAAM,qBAAqB,CAChC,cACiB;AACjB,QAAM,UAAU,MAAM,KAAK,SAAS,EACjC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC9B,KAAK,CAAC,GAAG,OAAO,EAAE,YAAY,MAAM,EAAE,YAAY,EAAE;AAEvD,SAAO,QAAQ,OAAO,CAAC,KAAK,WAAW;AACrC,QAAI,OAAO,QAAQ;AACjB,UAAI,IAAI,QAAQ;AAEd,YAAI,UAAU;AAAA;AAAA,EAAO,OAAO,MAAM;AAAA,MACpC,OAAO;AACL,YAAI,SAAS,OAAO;AAAA,MACtB;AAAA,IACF;AACA,QAAI,OAAO,OAAO;AAChB,iBAAW,CAAC,MAAM,IAAI,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACvD,YAAI,IAAI,QAAQ,IAAI,GAAG;AACrB,gBAAM,IAAI;AAAA,YACR,4CAA4C,IAAI;AAAA,UAClD;AAAA,QACF;AACA,YAAI,CAAC,IAAI,MAAO,KAAI,QAAQ,CAAC;AAC7B,YAAI,MAAM,IAAI,IAAI;AAAA,MACpB;AAAA,IACF;AACA,QAAI,OAAO,QAAQ;AACjB,UAAI,SAAS;AAAA,QACX,GAAG,IAAI;AAAA,QACP,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,QAAI,OAAO,cAAc;AACvB,UAAI,eAAe;AAAA,QACjB,GAAG,IAAI;AAAA,QACP,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAiB;AACvB;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model-context/ModelContextTypes.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"../types/Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\nexport type Tool<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n description?: string | undefined;\n parameters: z.ZodSchema<TArgs> | JSONSchema7;\n execute?: ToolExecuteFunction<TArgs, TResult>;\n};\n\nexport type ModelContext = {\n priority?: number | undefined;\n system?: string | undefined;\n tools?: Record<string, Tool<any, any>> | undefined;\n callSettings?: LanguageModelV1CallSettings | undefined;\n config?: LanguageModelConfig | undefined;\n};\n\nexport type ModelContextProvider = {\n getModelContext: () => ModelContext;\n subscribe?: (callback: () => void) => Unsubscribe;\n};\n\nexport const mergeModelContexts = (\n configSet: Set<ModelContextProvider>,\n): ModelContext => {\n const configs = Array.from(configSet)\n .map((c) => c.getModelContext())\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n for (const [name, tool] of Object.entries(config.tools)) {\n if (acc.tools?.[name]) {\n throw new Error(\n `You tried to define a tool with the name ${name}, but it already exists.`,\n );\n }\n if (!acc.tools) acc.tools = {};\n acc.tools[name] = tool;\n }\n }\n if (config.config) {\n acc.config = {\n ...acc.config,\n ...config.config,\n };\n }\n if (config.callSettings) {\n acc.callSettings = {\n ...acc.callSettings,\n ...config.callSettings,\n };\n }\n return acc;\n }, {} as ModelContext);\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KAAI,QAAQ,CAAC;AAC7B,YAAI,MAAM,IAAI,IAAI;AAAA,MACpB;AAAA,IACF;AACA,QAAI,OAAO,QAAQ;AACjB,UAAI,SAAS;AAAA,QACX,GAAG,IAAI;AAAA,QACP,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,QAAI,OAAO,cAAc;AACvB,UAAI,eAAe;AAAA,QACjB,GAAG,IAAI;AAAA,QACP,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAiB;AACvB;","names":[]}
1
+ {"version":3,"sources":["../../src/model-context/ModelContextTypes.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"../types/Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n toolCallId: string;\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\ntype OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<\n unknown,\n TResult\n>;\n\nexport type Tool<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n description?: string | undefined;\n parameters: z.ZodSchema<TArgs> | JSONSchema7;\n execute?: ToolExecuteFunction<TArgs, TResult>;\n experimental_onSchemaValidationError?: OnSchemaValidationErrorFunction<TResult>;\n};\n\nexport type ModelContext = {\n priority?: number | undefined;\n system?: string | undefined;\n tools?: Record<string, Tool<any, any>> | undefined;\n callSettings?: LanguageModelV1CallSettings | undefined;\n config?: LanguageModelConfig | undefined;\n};\n\nexport type ModelContextProvider = {\n getModelContext: () => ModelContext;\n subscribe?: (callback: () => void) => Unsubscribe;\n};\n\nexport const mergeModelContexts = (\n configSet: Set<ModelContextProvider>,\n): ModelContext => {\n const configs = Array.from(configSet)\n .map((c) => c.getModelContext())\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n for (const [name, tool] of Object.entries(config.tools)) {\n if (acc.tools?.[name]) {\n throw new Error(\n `You tried to define a tool with the name ${name}, but it already exists.`,\n );\n }\n if (!acc.tools) acc.tools = {};\n acc.tools[name] = tool;\n }\n }\n if (config.config) {\n acc.config = {\n ...acc.config,\n ...config.config,\n };\n }\n if (config.callSettings) {\n acc.callSettings = {\n ...acc.callSettings,\n ...config.callSettings,\n };\n }\n return acc;\n }, {} as ModelContext);\n};\n"],"mappings":";AAAA,SAAS,SAAS;AAIX,IAAM,oCAAoC,EAAE,OAAO;AAAA,EACxD,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAAA,EAChD,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,kBAAkB,EAAE,OAAO,EAAE,SAAS;AAAA,EACtC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAChC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,SAAS;AACpD,CAAC;AAMM,IAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,WAAW,EAAE,OAAO,EAAE,SAAS;AACjC,CAAC;AAwCM,IAAM,qBAAqB,CAChC,cACiB;AACjB,QAAM,UAAU,MAAM,KAAK,SAAS,EACjC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC9B,KAAK,CAAC,GAAG,OAAO,EAAE,YAAY,MAAM,EAAE,YAAY,EAAE;AAEvD,SAAO,QAAQ,OAAO,CAAC,KAAK,WAAW;AACrC,QAAI,OAAO,QAAQ;AACjB,UAAI,IAAI,QAAQ;AAEd,YAAI,UAAU;AAAA;AAAA,EAAO,OAAO,MAAM;AAAA,MACpC,OAAO;AACL,YAAI,SAAS,OAAO;AAAA,MACtB;AAAA,IACF;AACA,QAAI,OAAO,OAAO;AAChB,iBAAW,CAAC,MAAM,IAAI,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACvD,YAAI,IAAI,QAAQ,IAAI,GAAG;AACrB,gBAAM,IAAI;AAAA,YACR,4CAA4C,IAAI;AAAA,UAClD;AAAA,QACF;AACA,YAAI,CAAC,IAAI,MAAO,KAAI,QAAQ,CAAC;AAC7B,YAAI,MAAM,IAAI,IAAI;AAAA,MACpB;AAAA,IACF;AACA,QAAI,OAAO,QAAQ;AACjB,UAAI,SAAS;AAAA,QACX,GAAG,IAAI;AAAA,QACP,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,QAAI,OAAO,cAAc;AACvB,UAAI,eAAe;AAAA,QACjB,GAAG,IAAI;AAAA,QACP,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAiB;AACvB;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadScrollToBottom.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAKxC,QAAA,MAAM,uBAAuB,2BAW5B,CAAC;AAEF,yBAAiB,6BAA6B,CAAC;IAC7C,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,uBAAuB,CAAC,CAAC;CACvE;AAED,eAAO,MAAM,6BAA6B;;6DAGzC,CAAC"}
1
+ {"version":3,"file":"ThreadScrollToBottom.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAIxC,QAAA,MAAM,uBAAuB,2BAW5B,CAAC;AAEF,yBAAiB,6BAA6B,CAAC;IAC7C,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,uBAAuB,CAAC,CAAC;CACvE;AAED,eAAO,MAAM,6BAA6B;;6DAGzC,CAAC"}
@@ -26,11 +26,10 @@ __export(ThreadScrollToBottom_exports, {
26
26
  module.exports = __toCommonJS(ThreadScrollToBottom_exports);
27
27
  var import_createActionButton = require("../../utils/createActionButton.js");
28
28
  var import_react = require("react");
29
- var import_context = require("../../context/index.js");
30
- var import_ThreadContext = require("../../context/react/ThreadContext.js");
29
+ var import_ThreadViewportContext = require("../../context/react/ThreadViewportContext.js");
31
30
  var useThreadScrollToBottom = () => {
32
- const isAtBottom = (0, import_context.useThreadViewport)((s) => s.isAtBottom);
33
- const threadViewportStore = (0, import_ThreadContext.useThreadViewportStore)();
31
+ const isAtBottom = (0, import_ThreadViewportContext.useThreadViewport)((s) => s.isAtBottom);
32
+ const threadViewportStore = (0, import_ThreadViewportContext.useThreadViewportStore)();
34
33
  const handleScrollToBottom = (0, import_react.useCallback)(() => {
35
34
  threadViewportStore.getState().scrollToBottom();
36
35
  }, [threadViewportStore]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useThreadViewport } from \"../../context\";\nimport { useThreadViewportStore } from \"../../context/react/ThreadContext\";\n\nconst useThreadScrollToBottom = () => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom();\n }, [threadViewportStore]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAIO;AACP,mBAA4B;AAC5B,qBAAkC;AAClC,2BAAuC;AAEvC,IAAM,0BAA0B,MAAM;AACpC,QAAM,iBAAa,kCAAkB,CAAC,MAAM,EAAE,UAAU;AAExD,QAAM,0BAAsB,6CAAuB;AAEnD,QAAM,2BAAuB,0BAAY,MAAM;AAC7C,wBAAoB,SAAS,EAAE,eAAe;AAAA,EAChD,GAAG,CAAC,mBAAmB,CAAC;AAExB,MAAI,WAAY,QAAO;AACvB,SAAO;AACT;AAOO,IAAM,oCAAgC;AAAA,EAC3C;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useThreadViewport, useThreadViewportStore } from \"../../context/react/ThreadViewportContext\";\n\nconst useThreadScrollToBottom = () => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom();\n }, [threadViewportStore]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAIO;AACP,mBAA4B;AAC5B,mCAA0D;AAE1D,IAAM,0BAA0B,MAAM;AACpC,QAAM,iBAAa,gDAAkB,CAAC,MAAM,EAAE,UAAU;AAExD,QAAM,0BAAsB,qDAAuB;AAEnD,QAAM,2BAAuB,0BAAY,MAAM;AAC7C,wBAAoB,SAAS,EAAE,eAAe;AAAA,EAChD,GAAG,CAAC,mBAAmB,CAAC;AAExB,MAAI,WAAY,QAAO;AACvB,SAAO;AACT;AAOO,IAAM,oCAAgC;AAAA,EAC3C;AAAA,EACA;AACF;","names":[]}
@@ -5,8 +5,7 @@ import {
5
5
  createActionButton
6
6
  } from "../../utils/createActionButton.mjs";
7
7
  import { useCallback } from "react";
8
- import { useThreadViewport } from "../../context/index.mjs";
9
- import { useThreadViewportStore } from "../../context/react/ThreadContext.mjs";
8
+ import { useThreadViewport, useThreadViewportStore } from "../../context/react/ThreadViewportContext.mjs";
10
9
  var useThreadScrollToBottom = () => {
11
10
  const isAtBottom = useThreadViewport((s) => s.isAtBottom);
12
11
  const threadViewportStore = useThreadViewportStore();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useThreadViewport } from \"../../context\";\nimport { useThreadViewportStore } from \"../../context/react/ThreadContext\";\n\nconst useThreadScrollToBottom = () => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom();\n }, [threadViewportStore]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n);\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAEvC,IAAM,0BAA0B,MAAM;AACpC,QAAM,aAAa,kBAAkB,CAAC,MAAM,EAAE,UAAU;AAExD,QAAM,sBAAsB,uBAAuB;AAEnD,QAAM,uBAAuB,YAAY,MAAM;AAC7C,wBAAoB,SAAS,EAAE,eAAe;AAAA,EAChD,GAAG,CAAC,mBAAmB,CAAC;AAExB,MAAI,WAAY,QAAO;AACvB,SAAO;AACT;AAOO,IAAM,gCAAgC;AAAA,EAC3C;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useThreadViewport, useThreadViewportStore } from \"../../context/react/ThreadViewportContext\";\n\nconst useThreadScrollToBottom = () => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom();\n }, [threadViewportStore]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n);\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,8BAA8B;AAE1D,IAAM,0BAA0B,MAAM;AACpC,QAAM,aAAa,kBAAkB,CAAC,MAAM,EAAE,UAAU;AAExD,QAAM,sBAAsB,uBAAuB;AAEnD,QAAM,uBAAuB,YAAY,MAAM;AAC7C,wBAAoB,SAAS,EAAE,eAAe;AAAA,EAChD,GAAG,CAAC,mBAAmB,CAAC;AAExB,MAAI,WAAY,QAAO;AACvB,SAAO;AACT;AAOO,IAAM,gCAAgC;AAAA,EAC3C;AAAA,EACA;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadViewport.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,KAAK,YAAY,EAAc,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAGhF,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD,KAAY,KAAK,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG;QACnE,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAClC,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB;;;iBAJnB,OAAO,GAAG,SAAS;kDAmBlC,CAAC"}
1
+ {"version":3,"file":"ThreadViewport.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,KAAK,YAAY,EAAc,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAIhF,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD,KAAY,KAAK,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG;QACnE,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAClC,CAAC;CACH;AAmBD,eAAO,MAAM,uBAAuB;;;iBArBnB,OAAO,GAAG,SAAS;kDA8BlC,CAAC"}
@@ -28,14 +28,18 @@ var import_react_compose_refs = require("@radix-ui/react-compose-refs");
28
28
  var import_react_primitive = require("@radix-ui/react-primitive");
29
29
  var import_react = require("react");
30
30
  var import_useThreadViewportAutoScroll = require("./useThreadViewportAutoScroll.js");
31
+ var import_ThreadViewportProvider = require("../../context/providers/ThreadViewportProvider.js");
31
32
  var import_jsx_runtime = require("react/jsx-runtime");
32
- var ThreadPrimitiveViewport = (0, import_react.forwardRef)(({ autoScroll, children, ...rest }, forwardedRef) => {
33
+ var ThreadPrimitiveViewportScrollable = (0, import_react.forwardRef)(({ autoScroll, children, ...rest }, forwardedRef) => {
33
34
  const autoScrollRef = (0, import_useThreadViewportAutoScroll.useThreadViewportAutoScroll)({
34
35
  autoScroll
35
36
  });
36
37
  const ref = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, autoScrollRef);
37
38
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...rest, ref, children });
38
39
  });
40
+ var ThreadPrimitiveViewport = (0, import_react.forwardRef)((props, ref) => {
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThreadViewportProvider.ThreadViewportProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadPrimitiveViewportScrollable, { ...props, ref }) });
42
+ });
39
43
  ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
40
44
  // Annotate the CommonJS export names for ESM import in node:
41
45
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n autoScroll?: boolean | undefined;\n };\n}\n\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ autoScroll, children, ...rest }, forwardedRef) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n });\n\n const ref = useComposedRefs(forwardedRef, autoScrollRef);\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAAgC;AAChC,6BAA0B;AAC1B,mBAAwE;AACxE,yCAA4C;AAoBxC;AAXG,IAAM,8BAA0B,yBAGrC,CAAC,EAAE,YAAY,UAAU,GAAG,KAAK,GAAG,iBAAiB;AACrD,QAAM,oBAAgB,gEAA4C;AAAA,IAChE;AAAA,EACF,CAAC;AAED,QAAM,UAAM,2CAAgB,cAAc,aAAa;AAEvD,SACE,4CAAC,iCAAU,KAAV,EAAe,GAAG,MAAM,KACtB,UACH;AAEJ,CAAC;AAED,wBAAwB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\nimport { ThreadViewportProvider } from \"../../context/providers/ThreadViewportProvider\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n autoScroll?: boolean | undefined;\n };\n}\n\nconst ThreadPrimitiveViewportScrollable = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ autoScroll, children, ...rest }, forwardedRef) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n });\n\n const ref = useComposedRefs(forwardedRef, autoScrollRef);\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n});\n\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>((props, ref) => {\n return (\n <ThreadViewportProvider>\n <ThreadPrimitiveViewportScrollable {...props} ref={ref} />\n </ThreadViewportProvider>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAAgC;AAChC,6BAA0B;AAC1B,mBAAwE;AACxE,yCAA4C;AAC5C,oCAAuC;AAoBnC;AAXJ,IAAM,wCAAoC,yBAGxC,CAAC,EAAE,YAAY,UAAU,GAAG,KAAK,GAAG,iBAAiB;AACrD,QAAM,oBAAgB,gEAA4C;AAAA,IAChE;AAAA,EACF,CAAC;AAED,QAAM,UAAM,2CAAgB,cAAc,aAAa;AAEvD,SACE,4CAAC,iCAAU,KAAV,EAAe,GAAG,MAAM,KACtB,UACH;AAEJ,CAAC;AAEM,IAAM,8BAA0B,yBAGrC,CAAC,OAAO,QAAQ;AAChB,SACE,4CAAC,wDACC,sDAAC,qCAAmC,GAAG,OAAO,KAAU,GAC1D;AAEJ,CAAC;AAED,wBAAwB,cAAc;","names":[]}
@@ -5,14 +5,18 @@ import { useComposedRefs } from "@radix-ui/react-compose-refs";
5
5
  import { Primitive } from "@radix-ui/react-primitive";
6
6
  import { forwardRef } from "react";
7
7
  import { useThreadViewportAutoScroll } from "./useThreadViewportAutoScroll.mjs";
8
+ import { ThreadViewportProvider } from "../../context/providers/ThreadViewportProvider.mjs";
8
9
  import { jsx } from "react/jsx-runtime";
9
- var ThreadPrimitiveViewport = forwardRef(({ autoScroll, children, ...rest }, forwardedRef) => {
10
+ var ThreadPrimitiveViewportScrollable = forwardRef(({ autoScroll, children, ...rest }, forwardedRef) => {
10
11
  const autoScrollRef = useThreadViewportAutoScroll({
11
12
  autoScroll
12
13
  });
13
14
  const ref = useComposedRefs(forwardedRef, autoScrollRef);
14
15
  return /* @__PURE__ */ jsx(Primitive.div, { ...rest, ref, children });
15
16
  });
17
+ var ThreadPrimitiveViewport = forwardRef((props, ref) => {
18
+ return /* @__PURE__ */ jsx(ThreadViewportProvider, { children: /* @__PURE__ */ jsx(ThreadPrimitiveViewportScrollable, { ...props, ref }) });
19
+ });
16
20
  ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
17
21
  export {
18
22
  ThreadPrimitiveViewport
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n autoScroll?: boolean | undefined;\n };\n}\n\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ autoScroll, children, ...rest }, forwardedRef) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n });\n\n const ref = useComposedRefs(forwardedRef, autoScrollRef);\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n"],"mappings":";;;AAEA,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAA4B,kBAA4C;AACxE,SAAS,mCAAmC;AAoBxC;AAXG,IAAM,0BAA0B,WAGrC,CAAC,EAAE,YAAY,UAAU,GAAG,KAAK,GAAG,iBAAiB;AACrD,QAAM,gBAAgB,4BAA4C;AAAA,IAChE;AAAA,EACF,CAAC;AAED,QAAM,MAAM,gBAAgB,cAAc,aAAa;AAEvD,SACE,oBAAC,UAAU,KAAV,EAAe,GAAG,MAAM,KACtB,UACH;AAEJ,CAAC;AAED,wBAAwB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\nimport { ThreadViewportProvider } from \"../../context/providers/ThreadViewportProvider\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n autoScroll?: boolean | undefined;\n };\n}\n\nconst ThreadPrimitiveViewportScrollable = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ autoScroll, children, ...rest }, forwardedRef) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n });\n\n const ref = useComposedRefs(forwardedRef, autoScrollRef);\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n});\n\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>((props, ref) => {\n return (\n <ThreadViewportProvider>\n <ThreadPrimitiveViewportScrollable {...props} ref={ref} />\n </ThreadViewportProvider>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n"],"mappings":";;;AAEA,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAA4B,kBAA4C;AACxE,SAAS,mCAAmC;AAC5C,SAAS,8BAA8B;AAoBnC;AAXJ,IAAM,oCAAoC,WAGxC,CAAC,EAAE,YAAY,UAAU,GAAG,KAAK,GAAG,iBAAiB;AACrD,QAAM,gBAAgB,4BAA4C;AAAA,IAChE;AAAA,EACF,CAAC;AAED,QAAM,MAAM,gBAAgB,cAAc,aAAa;AAEvD,SACE,oBAAC,UAAU,KAAV,EAAe,GAAG,MAAM,KACtB,UACH;AAEJ,CAAC;AAEM,IAAM,0BAA0B,WAGrC,CAAC,OAAO,QAAQ;AAChB,SACE,oBAAC,0BACC,8BAAC,qCAAmC,GAAG,OAAO,KAAU,GAC1D;AAEJ,CAAC;AAED,wBAAwB,cAAc;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useThreadViewportAutoScroll.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAqB,MAAM,OAAO,CAAC;AAUvD,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,OAAO,GAAG;QACpB,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAClC,CAAC;CACH;AAED,eAAO,MAAM,2BAA2B,GAAI,QAAQ,SAAS,WAAW,mBAErE,2BAA2B,CAAC,OAAO,KAAG,WAAW,CAAC,QAAQ,CA0E5D,CAAC"}
1
+ {"version":3,"file":"useThreadViewportAutoScroll.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAqB,MAAM,OAAO,CAAC;AAQvD,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,OAAO,GAAG;QACpB,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAClC,CAAC;CACH;AAED,eAAO,MAAM,2BAA2B,GAAI,QAAQ,SAAS,WAAW,mBAErE,2BAA2B,CAAC,OAAO,KAAG,WAAW,CAAC,QAAQ,CA0E5D,CAAC"}
@@ -31,11 +31,12 @@ var import_useOnResizeContent = require("../../utils/hooks/useOnResizeContent.js
31
31
  var import_useOnScrollToBottom = require("../../utils/hooks/useOnScrollToBottom.js");
32
32
  var import_useManagedRef = require("../../utils/hooks/useManagedRef.js");
33
33
  var import_ReadonlyStore = require("../../context/ReadonlyStore.js");
34
+ var import_ThreadViewportContext = require("../../context/react/ThreadViewportContext.js");
34
35
  var useThreadViewportAutoScroll = ({
35
36
  autoScroll = true
36
37
  }) => {
37
38
  const divRef = (0, import_react.useRef)(null);
38
- const threadViewportStore = (0, import_ThreadContext.useThreadViewportStore)();
39
+ const threadViewportStore = (0, import_ThreadViewportContext.useThreadViewportStore)();
39
40
  const lastScrollTop = (0, import_react.useRef)(0);
40
41
  const isScrollingToBottomRef = (0, import_react.useRef)(false);
41
42
  const scrollToBottom = (behavior) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { RefCallback, useEffect, useRef } from \"react\";\nimport {\n useThreadRuntime,\n useThreadViewportStore,\n} from \"../../context/react/ThreadContext\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { writableStore } from \"../../context/ReadonlyStore\";\n\nexport namespace useThreadViewportAutoScroll {\n export type Options = {\n autoScroll?: boolean | undefined;\n };\n}\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll = true,\n}: useThreadViewportAutoScroll.Options): RefCallback<TElement> => {\n const divRef = useRef<TElement>(null);\n\n const threadViewportStore = useThreadViewportStore();\n\n const lastScrollTop = useRef<number>(0);\n\n // bug: when ScrollToBottom's button changes its disabled state, the scroll stops\n // fix: delay the state change until the scroll is done\n const isScrollingToBottomRef = useRef(false);\n\n const scrollToBottom = (behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div || !autoScroll) return;\n\n isScrollingToBottomRef.current = true;\n div.scrollTo({ top: div.scrollHeight, behavior });\n };\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = threadViewportStore.getState().isAtBottom;\n const newIsAtBottom =\n div.scrollHeight - div.scrollTop <= div.clientHeight + 1; // TODO figure out why +1 is needed\n\n if (!newIsAtBottom && lastScrollTop.current < div.scrollTop) {\n // ignore scroll down\n } else {\n if (newIsAtBottom) {\n isScrollingToBottomRef.current = false;\n }\n\n if (newIsAtBottom !== isAtBottom) {\n writableStore(threadViewportStore).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n };\n\n const resizeRef = useOnResizeContent(() => {\n if (\n isScrollingToBottomRef.current ||\n threadViewportStore.getState().isAtBottom\n ) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n el.addEventListener(\"scroll\", handleScroll);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n };\n });\n\n useOnScrollToBottom(() => {\n scrollToBottom(\"auto\");\n });\n\n // autoscroll on run start\n const threadRuntime = useThreadRuntime();\n useEffect(() => {\n return threadRuntime.unstable_on(\"run-start\", () => scrollToBottom(\"auto\"));\n }, []);\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n return autoScrollRef;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAAgC;AAChC,mBAA+C;AAC/C,2BAGO;AACP,gCAAmC;AACnC,iCAAoC;AACpC,2BAA8B;AAC9B,2BAA8B;AAQvB,IAAM,8BAA8B,CAA+B;AAAA,EACxE,aAAa;AACf,MAAkE;AAChE,QAAM,aAAS,qBAAiB,IAAI;AAEpC,QAAM,0BAAsB,6CAAuB;AAEnD,QAAM,oBAAgB,qBAAe,CAAC;AAItC,QAAM,6BAAyB,qBAAO,KAAK;AAE3C,QAAM,iBAAiB,CAAC,aAA6B;AACnD,UAAM,MAAM,OAAO;AACnB,QAAI,CAAC,OAAO,CAAC,WAAY;AAEzB,2BAAuB,UAAU;AACjC,QAAI,SAAS,EAAE,KAAK,IAAI,cAAc,SAAS,CAAC;AAAA,EAClD;AAEA,QAAM,eAAe,MAAM;AACzB,UAAM,MAAM,OAAO;AACnB,QAAI,CAAC,IAAK;AAEV,UAAM,aAAa,oBAAoB,SAAS,EAAE;AAClD,UAAM,gBACJ,IAAI,eAAe,IAAI,aAAa,IAAI,eAAe;AAEzD,QAAI,CAAC,iBAAiB,cAAc,UAAU,IAAI,WAAW;AAAA,IAE7D,OAAO;AACL,UAAI,eAAe;AACjB,+BAAuB,UAAU;AAAA,MACnC;AAEA,UAAI,kBAAkB,YAAY;AAChC,gDAAc,mBAAmB,EAAE,SAAS;AAAA,UAC1C,YAAY;AAAA,QACd,CAAC;AAAA,MACH;AAAA,IACF;AAEA,kBAAc,UAAU,IAAI;AAAA,EAC9B;AAEA,QAAM,gBAAY,8CAAmB,MAAM;AACzC,QACE,uBAAuB,WACvB,oBAAoB,SAAS,EAAE,YAC/B;AACA,qBAAe,SAAS;AAAA,IAC1B;AAEA,iBAAa;AAAA,EACf,CAAC;AAED,QAAM,gBAAY,oCAA2B,CAAC,OAAO;AACnD,OAAG,iBAAiB,UAAU,YAAY;AAC1C,WAAO,MAAM;AACX,SAAG,oBAAoB,UAAU,YAAY;AAAA,IAC/C;AAAA,EACF,CAAC;AAED,sDAAoB,MAAM;AACxB,mBAAe,MAAM;AAAA,EACvB,CAAC;AAGD,QAAM,oBAAgB,uCAAiB;AACvC,8BAAU,MAAM;AACd,WAAO,cAAc,YAAY,aAAa,MAAM,eAAe,MAAM,CAAC;AAAA,EAC5E,GAAG,CAAC,CAAC;AAEL,QAAM,oBAAgB,2CAA0B,WAAW,WAAW,MAAM;AAC5E,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { RefCallback, useEffect, useRef } from \"react\";\nimport { useThreadRuntime } from \"../../context/react/ThreadContext\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { writableStore } from \"../../context/ReadonlyStore\";\nimport { useThreadViewportStore } from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadViewportAutoScroll {\n export type Options = {\n autoScroll?: boolean | undefined;\n };\n}\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll = true,\n}: useThreadViewportAutoScroll.Options): RefCallback<TElement> => {\n const divRef = useRef<TElement>(null);\n\n const threadViewportStore = useThreadViewportStore();\n\n const lastScrollTop = useRef<number>(0);\n\n // bug: when ScrollToBottom's button changes its disabled state, the scroll stops\n // fix: delay the state change until the scroll is done\n const isScrollingToBottomRef = useRef(false);\n\n const scrollToBottom = (behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div || !autoScroll) return;\n\n isScrollingToBottomRef.current = true;\n div.scrollTo({ top: div.scrollHeight, behavior });\n };\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = threadViewportStore.getState().isAtBottom;\n const newIsAtBottom =\n div.scrollHeight - div.scrollTop <= div.clientHeight + 1; // TODO figure out why +1 is needed\n\n if (!newIsAtBottom && lastScrollTop.current < div.scrollTop) {\n // ignore scroll down\n } else {\n if (newIsAtBottom) {\n isScrollingToBottomRef.current = false;\n }\n\n if (newIsAtBottom !== isAtBottom) {\n writableStore(threadViewportStore).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n };\n\n const resizeRef = useOnResizeContent(() => {\n if (\n isScrollingToBottomRef.current ||\n threadViewportStore.getState().isAtBottom\n ) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n el.addEventListener(\"scroll\", handleScroll);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n };\n });\n\n useOnScrollToBottom(() => {\n scrollToBottom(\"auto\");\n });\n\n // autoscroll on run start\n const threadRuntime = useThreadRuntime();\n useEffect(() => {\n return threadRuntime.unstable_on(\"run-start\", () => scrollToBottom(\"auto\"));\n }, []);\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n return autoScrollRef;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAAgC;AAChC,mBAA+C;AAC/C,2BAAiC;AACjC,gCAAmC;AACnC,iCAAoC;AACpC,2BAA8B;AAC9B,2BAA8B;AAC9B,mCAAuC;AAQhC,IAAM,8BAA8B,CAA+B;AAAA,EACxE,aAAa;AACf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5E,GAAG,CAAC,CAAC;AAEL,QAAM,oBAAgB,2CAA0B,WAAW,WAAW,MAAM;AAC5E,SAAO;AACT;","names":[]}
@@ -3,14 +3,12 @@
3
3
  // src/primitives/thread/useThreadViewportAutoScroll.tsx
4
4
  import { useComposedRefs } from "@radix-ui/react-compose-refs";
5
5
  import { useEffect, useRef } from "react";
6
- import {
7
- useThreadRuntime,
8
- useThreadViewportStore
9
- } from "../../context/react/ThreadContext.mjs";
6
+ import { useThreadRuntime } from "../../context/react/ThreadContext.mjs";
10
7
  import { useOnResizeContent } from "../../utils/hooks/useOnResizeContent.mjs";
11
8
  import { useOnScrollToBottom } from "../../utils/hooks/useOnScrollToBottom.mjs";
12
9
  import { useManagedRef } from "../../utils/hooks/useManagedRef.mjs";
13
10
  import { writableStore } from "../../context/ReadonlyStore.mjs";
11
+ import { useThreadViewportStore } from "../../context/react/ThreadViewportContext.mjs";
14
12
  var useThreadViewportAutoScroll = ({
15
13
  autoScroll = true
16
14
  }) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { RefCallback, useEffect, useRef } from \"react\";\nimport {\n useThreadRuntime,\n useThreadViewportStore,\n} from \"../../context/react/ThreadContext\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { writableStore } from \"../../context/ReadonlyStore\";\n\nexport namespace useThreadViewportAutoScroll {\n export type Options = {\n autoScroll?: boolean | undefined;\n };\n}\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll = true,\n}: useThreadViewportAutoScroll.Options): RefCallback<TElement> => {\n const divRef = useRef<TElement>(null);\n\n const threadViewportStore = useThreadViewportStore();\n\n const lastScrollTop = useRef<number>(0);\n\n // bug: when ScrollToBottom's button changes its disabled state, the scroll stops\n // fix: delay the state change until the scroll is done\n const isScrollingToBottomRef = useRef(false);\n\n const scrollToBottom = (behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div || !autoScroll) return;\n\n isScrollingToBottomRef.current = true;\n div.scrollTo({ top: div.scrollHeight, behavior });\n };\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = threadViewportStore.getState().isAtBottom;\n const newIsAtBottom =\n div.scrollHeight - div.scrollTop <= div.clientHeight + 1; // TODO figure out why +1 is needed\n\n if (!newIsAtBottom && lastScrollTop.current < div.scrollTop) {\n // ignore scroll down\n } else {\n if (newIsAtBottom) {\n isScrollingToBottomRef.current = false;\n }\n\n if (newIsAtBottom !== isAtBottom) {\n writableStore(threadViewportStore).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n };\n\n const resizeRef = useOnResizeContent(() => {\n if (\n isScrollingToBottomRef.current ||\n threadViewportStore.getState().isAtBottom\n ) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n el.addEventListener(\"scroll\", handleScroll);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n };\n });\n\n useOnScrollToBottom(() => {\n scrollToBottom(\"auto\");\n });\n\n // autoscroll on run start\n const threadRuntime = useThreadRuntime();\n useEffect(() => {\n return threadRuntime.unstable_on(\"run-start\", () => scrollToBottom(\"auto\"));\n }, []);\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n return autoScrollRef;\n};\n"],"mappings":";;;AAEA,SAAS,uBAAuB;AAChC,SAAsB,WAAW,cAAc;AAC/C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAQvB,IAAM,8BAA8B,CAA+B;AAA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AAAA,EAC5E,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,gBAA0B,WAAW,WAAW,MAAM;AAC5E,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { RefCallback, useEffect, useRef } from \"react\";\nimport { useThreadRuntime } from \"../../context/react/ThreadContext\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { writableStore } from \"../../context/ReadonlyStore\";\nimport { useThreadViewportStore } from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadViewportAutoScroll {\n export type Options = {\n autoScroll?: boolean | undefined;\n };\n}\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll = true,\n}: useThreadViewportAutoScroll.Options): RefCallback<TElement> => {\n const divRef = useRef<TElement>(null);\n\n const threadViewportStore = useThreadViewportStore();\n\n const lastScrollTop = useRef<number>(0);\n\n // bug: when ScrollToBottom's button changes its disabled state, the scroll stops\n // fix: delay the state change until the scroll is done\n const isScrollingToBottomRef = useRef(false);\n\n const scrollToBottom = (behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div || !autoScroll) return;\n\n isScrollingToBottomRef.current = true;\n div.scrollTo({ top: div.scrollHeight, behavior });\n };\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = threadViewportStore.getState().isAtBottom;\n const newIsAtBottom =\n div.scrollHeight - div.scrollTop <= div.clientHeight + 1; // TODO figure out why +1 is needed\n\n if (!newIsAtBottom && lastScrollTop.current < div.scrollTop) {\n // ignore scroll down\n } else {\n if (newIsAtBottom) {\n isScrollingToBottomRef.current = false;\n }\n\n if (newIsAtBottom !== isAtBottom) {\n writableStore(threadViewportStore).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n };\n\n const resizeRef = useOnResizeContent(() => {\n if (\n isScrollingToBottomRef.current ||\n threadViewportStore.getState().isAtBottom\n ) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n el.addEventListener(\"scroll\", handleScroll);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n };\n });\n\n useOnScrollToBottom(() => {\n scrollToBottom(\"auto\");\n });\n\n // autoscroll on run start\n const threadRuntime = useThreadRuntime();\n useEffect(() => {\n return threadRuntime.unstable_on(\"run-start\", () => scrollToBottom(\"auto\"));\n }, []);\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n return autoScrollRef;\n};\n"],"mappings":";;;AAEA,SAAS,uBAAuB;AAChC,SAAsB,WAAW,cAAc;AAC/C,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,8BAA8B;AAQhC,IAAM,8BAA8B,CAA+B;AAAA,EACxE,aAAa;AACf,MAAkE;AAChE,QAAM,SAAS,OAAiB,IAAI;AAEpC,QAAM,sBAAsB,uBAAuB;AAEnD,QAAM,gBAAgB,OAAe,CAAC;AAItC,QAAM,yBAAyB,OAAO,KAAK;AAE3C,QAAM,iBAAiB,CAAC,aAA6B;AACnD,UAAM,MAAM,OAAO;AACnB,QAAI,CAAC,OAAO,CAAC,WAAY;AAEzB,2BAAuB,UAAU;AACjC,QAAI,SAAS,EAAE,KAAK,IAAI,cAAc,SAAS,CAAC;AAAA,EAClD;AAEA,QAAM,eAAe,MAAM;AACzB,UAAM,MAAM,OAAO;AACnB,QAAI,CAAC,IAAK;AAEV,UAAM,aAAa,oBAAoB,SAAS,EAAE;AAClD,UAAM,gBACJ,IAAI,eAAe,IAAI,aAAa,IAAI,eAAe;AAEzD,QAAI,CAAC,iBAAiB,cAAc,UAAU,IAAI,WAAW;AAAA,IAE7D,OAAO;AACL,UAAI,eAAe;AACjB,+BAAuB,UAAU;AAAA,MACnC;AAEA,UAAI,kBAAkB,YAAY;AAChC,sBAAc,mBAAmB,EAAE,SAAS;AAAA,UAC1C,YAAY;AAAA,QACd,CAAC;AAAA,MACH;AAAA,IACF;AAEA,kBAAc,UAAU,IAAI;AAAA,EAC9B;AAEA,QAAM,YAAY,mBAAmB,MAAM;AACzC,QACE,uBAAuB,WACvB,oBAAoB,SAAS,EAAE,YAC/B;AACA,qBAAe,SAAS;AAAA,IAC1B;AAEA,iBAAa;AAAA,EACf,CAAC;AAED,QAAM,YAAY,cAA2B,CAAC,OAAO;AACnD,OAAG,iBAAiB,UAAU,YAAY;AAC1C,WAAO,MAAM;AACX,SAAG,oBAAoB,UAAU,YAAY;AAAA,IAC/C;AAAA,EACF,CAAC;AAED,sBAAoB,MAAM;AACxB,mBAAe,MAAM;AAAA,EACvB,CAAC;AAGD,QAAM,gBAAgB,iBAAiB;AACvC,YAAU,MAAM;AACd,WAAO,cAAc,YAAY,aAAa,MAAM,eAAe,MAAM,CAAC;AAAA,EAC5E,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,gBAA0B,WAAW,WAAW,MAAM;AAC5E,SAAO;AACT;","names":[]}
@@ -11,7 +11,7 @@ export declare class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeC
11
11
  private _previousText;
12
12
  private _parentId;
13
13
  private _sourceId;
14
- constructor(runtime: Omit<ThreadRuntimeCore, "composer"> & {
14
+ constructor(runtime: ThreadRuntimeCore & {
15
15
  adapters?: {
16
16
  attachments?: AttachmentAdapter | undefined;
17
17
  } | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultEditComposerRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE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AA+B,SAAQ,uBAAuB;IAcvE,OAAO,CAAC,OAAO;IAGf,OAAO,CAAC,eAAe;IAhBzB,IAAW,SAAS,YAEnB;IAED,SAAS,CAAC,oBAAoB;IAI9B,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAAC;gBAER,OAAO,EAAE,iBAAiB,GAAG;QACnC,QAAQ,CAAC,EAAE;YAAE,WAAW,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAA;SAAE,GAAG,SAAS,CAAC;KACxE,EACO,eAAe,EAAE,MAAM,IAAI,EACnC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,aAAa,CAAA;KAAE;IAmB/D,UAAU,CACrB,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,UAAU,CAAC;IAehD,YAAY;CAIpB"}
@@ -39,6 +39,7 @@ var DefaultEditComposerRuntimeCore = class extends import_BaseComposerRuntimeCor
39
39
  this._nonTextParts = message.content.filter(
40
40
  (part) => part.type !== "text" && part.type !== "ui"
41
41
  );
42
+ this.setRunConfig({ ...runtime.composer.runConfig });
42
43
  }
43
44
  get canCancel() {
44
45
  return true;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx"],"sourcesContent":["import { AppendMessage, ThreadMessage } from \"../../types\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport { AttachmentAdapter } from \"../adapters/attachment\";\nimport { ThreadRuntimeCore } from \"../core/ThreadRuntimeCore\";\nimport { BaseComposerRuntimeCore } from \"./BaseComposerRuntimeCore\";\n\nexport class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {\n public get canCancel() {\n return true;\n }\n\n protected getAttachmentAdapter() {\n return this.runtime.adapters?.attachments;\n }\n\n private _nonTextParts;\n private _previousText;\n private _parentId;\n private _sourceId;\n constructor(\n private runtime: Omit<ThreadRuntimeCore, \"composer\"> & {\n adapters?: { attachments?: AttachmentAdapter | undefined } | undefined;\n },\n private endEditCallback: () => void,\n { parentId, message }: { parentId: string | null; message: ThreadMessage },\n ) {\n super();\n this._parentId = parentId;\n this._sourceId = message.id;\n this._previousText = getThreadMessageText(message);\n this.setText(this._previousText);\n\n this.setRole(message.role);\n this.setAttachments(message.attachments ?? []);\n\n this._nonTextParts = message.content.filter(\n (part) => part.type !== \"text\" && part.type !== \"ui\",\n );\n }\n\n public async handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n ) {\n const text = getThreadMessageText(message as AppendMessage);\n if (text !== this._previousText) {\n this.runtime.append({\n ...message,\n content: [...message.content, ...this._nonTextParts] as any,\n parentId: this._parentId,\n sourceId: this._sourceId,\n });\n }\n\n this.handleCancel();\n }\n\n public handleCancel() {\n this.endEditCallback();\n this._notifySubscribers();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kCAAqC;AAGrC,qCAAwC;AAEjC,IAAM,iCAAN,cAA6C,uDAAwB;AAAA,EAa1E,YACU,SAGA,iBACR,EAAE,UAAU,QAAQ,GACpB;AACA,UAAM;AANE;AAGA;AAIR,SAAK,YAAY;AACjB,SAAK,YAAY,QAAQ;AACzB,SAAK,oBAAgB,kDAAqB,OAAO;AACjD,SAAK,QAAQ,KAAK,aAAa;AAE/B,SAAK,QAAQ,QAAQ,IAAI;AACzB,SAAK,eAAe,QAAQ,eAAe,CAAC,CAAC;AAE7C,SAAK,gBAAgB,QAAQ,QAAQ;AAAA,MACnC,CAAC,SAAS,KAAK,SAAS,UAAU,KAAK,SAAS;AAAA,IAClD;AAAA,EACF;AAAA,EA/BA,IAAW,YAAY;AACrB,WAAO;AAAA,EACT;AAAA,EAEU,uBAAuB;AAC/B,WAAO,KAAK,QAAQ,UAAU;AAAA,EAChC;AAAA,EAEQ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAsBR,MAAa,WACX,SACA;AACA,UAAM,WAAO,kDAAqB,OAAwB;AAC1D,QAAI,SAAS,KAAK,eAAe;AAC/B,WAAK,QAAQ,OAAO;AAAA,QAClB,GAAG;AAAA,QACH,SAAS,CAAC,GAAG,QAAQ,SAAS,GAAG,KAAK,aAAa;AAAA,QACnD,UAAU,KAAK;AAAA,QACf,UAAU,KAAK;AAAA,MACjB,CAAC;AAAA,IACH;AAEA,SAAK,aAAa;AAAA,EACpB;AAAA,EAEO,eAAe;AACpB,SAAK,gBAAgB;AACrB,SAAK,mBAAmB;AAAA,EAC1B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx"],"sourcesContent":["import { AppendMessage, ThreadMessage } from \"../../types\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport { AttachmentAdapter } from \"../adapters/attachment\";\nimport { ThreadRuntimeCore } from \"../core/ThreadRuntimeCore\";\nimport { BaseComposerRuntimeCore } from \"./BaseComposerRuntimeCore\";\n\nexport class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {\n public get canCancel() {\n return true;\n }\n\n protected getAttachmentAdapter() {\n return this.runtime.adapters?.attachments;\n }\n\n private _nonTextParts;\n private _previousText;\n private _parentId;\n private _sourceId;\n constructor(\n private runtime: ThreadRuntimeCore & {\n adapters?: { attachments?: AttachmentAdapter | undefined } | undefined;\n },\n private endEditCallback: () => void,\n { parentId, message }: { parentId: string | null; message: ThreadMessage },\n ) {\n super();\n this._parentId = parentId;\n this._sourceId = message.id;\n this._previousText = getThreadMessageText(message);\n this.setText(this._previousText);\n\n this.setRole(message.role);\n this.setAttachments(message.attachments ?? []);\n\n this._nonTextParts = message.content.filter(\n (part) => part.type !== \"text\" && part.type !== \"ui\",\n );\n\n // Use the runConfig from the regular (non-edit) composer as the initial runConfig for the edit composer\n this.setRunConfig({ ...runtime.composer.runConfig });\n }\n\n public async handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n ) {\n const text = getThreadMessageText(message as AppendMessage);\n if (text !== this._previousText) {\n this.runtime.append({\n ...message,\n content: [...message.content, ...this._nonTextParts] as any,\n parentId: this._parentId,\n sourceId: this._sourceId,\n });\n }\n\n this.handleCancel();\n }\n\n public handleCancel() {\n this.endEditCallback();\n this._notifySubscribers();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kCAAqC;AAGrC,qCAAwC;AAEjC,IAAM,iCAAN,cAA6C,uDAAwB;AAAA,EAa1E,YACU,SAGA,iBACR,EAAE,UAAU,QAAQ,GACpB;AACA,UAAM;AANE;AAGA;AAIR,SAAK,YAAY;AACjB,SAAK,YAAY,QAAQ;AACzB,SAAK,oBAAgB,kDAAqB,OAAO;AACjD,SAAK,QAAQ,KAAK,aAAa;AAE/B,SAAK,QAAQ,QAAQ,IAAI;AACzB,SAAK,eAAe,QAAQ,eAAe,CAAC,CAAC;AAE7C,SAAK,gBAAgB,QAAQ,QAAQ;AAAA,MACnC,CAAC,SAAS,KAAK,SAAS,UAAU,KAAK,SAAS;AAAA,IAClD;AAGA,SAAK,aAAa,EAAE,GAAG,QAAQ,SAAS,UAAU,CAAC;AAAA,EACrD;AAAA,EAlCA,IAAW,YAAY;AACrB,WAAO;AAAA,EACT;AAAA,EAEU,uBAAuB;AAC/B,WAAO,KAAK,QAAQ,UAAU;AAAA,EAChC;AAAA,EAEQ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAyBR,MAAa,WACX,SACA;AACA,UAAM,WAAO,kDAAqB,OAAwB;AAC1D,QAAI,SAAS,KAAK,eAAe;AAC/B,WAAK,QAAQ,OAAO;AAAA,QAClB,GAAG;AAAA,QACH,SAAS,CAAC,GAAG,QAAQ,SAAS,GAAG,KAAK,aAAa;AAAA,QACnD,UAAU,KAAK;AAAA,QACf,UAAU,KAAK;AAAA,MACjB,CAAC;AAAA,IACH;AAEA,SAAK,aAAa;AAAA,EACpB;AAAA,EAEO,eAAe;AACpB,SAAK,gBAAgB;AACrB,SAAK,mBAAmB;AAAA,EAC1B;AACF;","names":[]}
@@ -15,6 +15,7 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
15
15
  this._nonTextParts = message.content.filter(
16
16
  (part) => part.type !== "text" && part.type !== "ui"
17
17
  );
18
+ this.setRunConfig({ ...runtime.composer.runConfig });
18
19
  }
19
20
  get canCancel() {
20
21
  return true;