@assistant-ui/react 0.7.69 → 0.7.71

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) 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/cloud/auiV0.d.ts +3 -0
  8. package/dist/cloud/auiV0.d.ts.map +1 -1
  9. package/dist/cloud/auiV0.js +6 -0
  10. package/dist/cloud/auiV0.js.map +1 -1
  11. package/dist/cloud/auiV0.mjs +6 -0
  12. package/dist/cloud/auiV0.mjs.map +1 -1
  13. package/dist/context/providers/ThreadRuntimeProvider.d.ts.map +1 -1
  14. package/dist/context/providers/ThreadRuntimeProvider.js +3 -5
  15. package/dist/context/providers/ThreadRuntimeProvider.js.map +1 -1
  16. package/dist/context/providers/ThreadRuntimeProvider.mjs +3 -5
  17. package/dist/context/providers/ThreadRuntimeProvider.mjs.map +1 -1
  18. package/dist/context/providers/ThreadViewportProvider.d.ts +3 -0
  19. package/dist/context/providers/ThreadViewportProvider.d.ts.map +1 -0
  20. package/dist/context/providers/ThreadViewportProvider.js +63 -0
  21. package/dist/context/providers/ThreadViewportProvider.js.map +1 -0
  22. package/dist/context/providers/ThreadViewportProvider.mjs +42 -0
  23. package/dist/context/providers/ThreadViewportProvider.mjs.map +1 -0
  24. package/dist/context/react/ThreadContext.d.ts +0 -18
  25. package/dist/context/react/ThreadContext.d.ts.map +1 -1
  26. package/dist/context/react/ThreadContext.js +2 -11
  27. package/dist/context/react/ThreadContext.js.map +1 -1
  28. package/dist/context/react/ThreadContext.mjs +1 -8
  29. package/dist/context/react/ThreadContext.mjs.map +1 -1
  30. package/dist/context/react/ThreadViewportContext.d.ts +24 -0
  31. package/dist/context/react/ThreadViewportContext.d.ts.map +1 -0
  32. package/dist/context/react/ThreadViewportContext.js +44 -0
  33. package/dist/context/react/ThreadViewportContext.js.map +1 -0
  34. package/dist/context/react/ThreadViewportContext.mjs +18 -0
  35. package/dist/context/react/ThreadViewportContext.mjs.map +1 -0
  36. package/dist/context/react/index.d.ts +2 -1
  37. package/dist/context/react/index.d.ts.map +1 -1
  38. package/dist/context/react/index.js +3 -2
  39. package/dist/context/react/index.js.map +1 -1
  40. package/dist/context/react/index.mjs +4 -2
  41. package/dist/context/react/index.mjs.map +1 -1
  42. package/dist/context/stores/ThreadViewport.d.ts.map +1 -1
  43. package/dist/context/stores/ThreadViewport.js +1 -0
  44. package/dist/context/stores/ThreadViewport.js.map +1 -1
  45. package/dist/context/stores/ThreadViewport.mjs +2 -0
  46. package/dist/context/stores/ThreadViewport.mjs.map +1 -1
  47. package/dist/model-context/ModelContextTypes.d.ts +3 -0
  48. package/dist/model-context/ModelContextTypes.d.ts.map +1 -1
  49. package/dist/model-context/ModelContextTypes.js.map +1 -1
  50. package/dist/model-context/ModelContextTypes.mjs.map +1 -1
  51. package/dist/primitives/contentPart/useContentPartReasoning.d.ts +5 -0
  52. package/dist/primitives/contentPart/useContentPartReasoning.d.ts.map +1 -0
  53. package/dist/primitives/contentPart/useContentPartReasoning.js +42 -0
  54. package/dist/primitives/contentPart/useContentPartReasoning.js.map +1 -0
  55. package/dist/primitives/contentPart/useContentPartReasoning.mjs +18 -0
  56. package/dist/primitives/contentPart/useContentPartReasoning.mjs.map +1 -0
  57. package/dist/primitives/index.d.ts +1 -0
  58. package/dist/primitives/index.d.ts.map +1 -1
  59. package/dist/primitives/index.js +3 -0
  60. package/dist/primitives/index.js.map +1 -1
  61. package/dist/primitives/index.mjs +2 -0
  62. package/dist/primitives/index.mjs.map +1 -1
  63. package/dist/primitives/message/MessageContent.d.ts +2 -1
  64. package/dist/primitives/message/MessageContent.d.ts.map +1 -1
  65. package/dist/primitives/message/MessageContent.js +5 -1
  66. package/dist/primitives/message/MessageContent.js.map +1 -1
  67. package/dist/primitives/message/MessageContent.mjs +5 -1
  68. package/dist/primitives/message/MessageContent.mjs.map +1 -1
  69. package/dist/primitives/thread/ThreadScrollToBottom.d.ts.map +1 -1
  70. package/dist/primitives/thread/ThreadScrollToBottom.js +3 -4
  71. package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
  72. package/dist/primitives/thread/ThreadScrollToBottom.mjs +1 -2
  73. package/dist/primitives/thread/ThreadScrollToBottom.mjs.map +1 -1
  74. package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
  75. package/dist/primitives/thread/ThreadViewport.js +5 -1
  76. package/dist/primitives/thread/ThreadViewport.js.map +1 -1
  77. package/dist/primitives/thread/ThreadViewport.mjs +5 -1
  78. package/dist/primitives/thread/ThreadViewport.mjs.map +1 -1
  79. package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
  80. package/dist/primitives/thread/useThreadViewportAutoScroll.js +2 -1
  81. package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
  82. package/dist/primitives/thread/useThreadViewportAutoScroll.mjs +2 -4
  83. package/dist/primitives/thread/useThreadViewportAutoScroll.mjs.map +1 -1
  84. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts +1 -1
  85. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
  86. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +1 -0
  87. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
  88. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +1 -0
  89. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
  90. package/dist/runtimes/edge/EdgeRuntimeRequestOptions.d.ts +6 -6
  91. package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +1 -1
  92. package/dist/runtimes/edge/converters/toCoreMessages.js +2 -1
  93. package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
  94. package/dist/runtimes/edge/converters/toCoreMessages.mjs +2 -1
  95. package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
  96. package/dist/runtimes/edge/converters/toLanguageModelMessages.d.ts.map +1 -1
  97. package/dist/runtimes/edge/converters/toLanguageModelMessages.js +3 -0
  98. package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
  99. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs +3 -0
  100. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
  101. package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts +2 -2
  102. package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts.map +1 -1
  103. package/dist/runtimes/edge/createEdgeRuntimeAPI.js +10 -1
  104. package/dist/runtimes/edge/createEdgeRuntimeAPI.js.map +1 -1
  105. package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs +10 -1
  106. package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs.map +1 -1
  107. package/dist/runtimes/edge/streams/assistantEncoderStream.d.ts.map +1 -1
  108. package/dist/runtimes/edge/streams/assistantEncoderStream.js +7 -0
  109. package/dist/runtimes/edge/streams/assistantEncoderStream.js.map +1 -1
  110. package/dist/runtimes/edge/streams/assistantEncoderStream.mjs +7 -0
  111. package/dist/runtimes/edge/streams/assistantEncoderStream.mjs.map +1 -1
  112. package/dist/runtimes/edge/streams/runResultStream.d.ts.map +1 -1
  113. package/dist/runtimes/edge/streams/runResultStream.js +19 -0
  114. package/dist/runtimes/edge/streams/runResultStream.js.map +1 -1
  115. package/dist/runtimes/edge/streams/runResultStream.mjs +19 -0
  116. package/dist/runtimes/edge/streams/runResultStream.mjs.map +1 -1
  117. package/dist/runtimes/edge/streams/toolResultStream.d.ts.map +1 -1
  118. package/dist/runtimes/edge/streams/toolResultStream.js +14 -15
  119. package/dist/runtimes/edge/streams/toolResultStream.js.map +1 -1
  120. package/dist/runtimes/edge/streams/toolResultStream.mjs +14 -15
  121. package/dist/runtimes/edge/streams/toolResultStream.mjs.map +1 -1
  122. package/dist/runtimes/external-store/ThreadMessageLike.d.ts +2 -2
  123. package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
  124. package/dist/runtimes/external-store/ThreadMessageLike.js +1 -0
  125. package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
  126. package/dist/runtimes/external-store/ThreadMessageLike.mjs +1 -0
  127. package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
  128. package/dist/runtimes/local/ChatModelAdapter.d.ts +2 -2
  129. package/dist/runtimes/local/ChatModelAdapter.d.ts.map +1 -1
  130. package/dist/runtimes/local/ChatModelAdapter.js.map +1 -1
  131. package/dist/styles/index.css +57 -29
  132. package/dist/styles/index.css.map +1 -1
  133. package/dist/styles/tailwindcss/thread.css +30 -23
  134. package/dist/styles/tailwindcss/thread.css.json +31 -25
  135. package/dist/types/AssistantTypes.d.ts +5 -1
  136. package/dist/types/AssistantTypes.d.ts.map +1 -1
  137. package/dist/types/AssistantTypes.js.map +1 -1
  138. package/dist/types/ContentPartComponentTypes.d.ts +3 -1
  139. package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
  140. package/dist/types/ContentPartComponentTypes.js.map +1 -1
  141. package/dist/types/index.d.ts +2 -2
  142. package/dist/types/index.d.ts.map +1 -1
  143. package/dist/types/index.js.map +1 -1
  144. package/dist/utils/hooks/useOnScrollToBottom.js +2 -2
  145. package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
  146. package/dist/utils/hooks/useOnScrollToBottom.mjs +1 -1
  147. package/dist/utils/hooks/useOnScrollToBottom.mjs.map +1 -1
  148. package/package.json +14 -14
  149. package/src/api/MessageRuntime.ts +14 -5
  150. package/src/cloud/auiV0.ts +11 -0
  151. package/src/context/providers/ThreadRuntimeProvider.tsx +4 -5
  152. package/src/context/providers/ThreadViewportProvider.tsx +49 -0
  153. package/src/context/react/ThreadContext.ts +0 -8
  154. package/src/context/react/ThreadViewportContext.ts +23 -0
  155. package/src/context/react/index.ts +4 -1
  156. package/src/context/stores/ThreadViewport.tsx +2 -0
  157. package/src/model-context/ModelContextTypes.ts +7 -0
  158. package/src/primitives/contentPart/useContentPartReasoning.tsx +18 -0
  159. package/src/primitives/index.ts +1 -0
  160. package/src/primitives/message/MessageContent.tsx +8 -0
  161. package/src/primitives/thread/ThreadScrollToBottom.tsx +1 -2
  162. package/src/primitives/thread/ThreadViewport.tsx +13 -1
  163. package/src/primitives/thread/useThreadViewportAutoScroll.tsx +2 -4
  164. package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +4 -1
  165. package/src/runtimes/edge/converters/toCoreMessages.ts +2 -1
  166. package/src/runtimes/edge/converters/toLanguageModelMessages.ts +4 -0
  167. package/src/runtimes/edge/createEdgeRuntimeAPI.ts +12 -3
  168. package/src/runtimes/edge/streams/assistantEncoderStream.ts +8 -0
  169. package/src/runtimes/edge/streams/runResultStream.ts +24 -0
  170. package/src/runtimes/edge/streams/toolResultStream.ts +21 -18
  171. package/src/runtimes/external-store/ThreadMessageLike.tsx +4 -2
  172. package/src/runtimes/local/ChatModelAdapter.tsx +2 -1
  173. package/src/styles/tailwindcss/thread.css +30 -23
  174. package/src/types/AssistantTypes.ts +7 -0
  175. package/src/types/ContentPartComponentTypes.tsx +4 -0
  176. package/src/types/index.ts +3 -0
  177. package/src/utils/hooks/useOnScrollToBottom.tsx +1 -1
@@ -1,11 +1,9 @@
1
- import type { ThreadViewportState } from "../stores/ThreadViewport";
2
1
  import { ReadonlyStore } from "../ReadonlyStore";
3
2
  import { UseBoundStore } from "zustand";
4
3
  import { ThreadRuntime } from "../../api/ThreadRuntime";
5
4
  import { ModelContext } from "../../model-context";
6
5
  export type ThreadContextValue = {
7
6
  useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;
8
- useViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;
9
7
  };
10
8
  export declare const ThreadContext: import("react").Context<ThreadContextValue | null>;
11
9
  export declare function useThreadRuntime(options?: {
@@ -68,22 +66,6 @@ export declare const useThreadComposer: {
68
66
  selector: ((state: import("../..").ThreadComposerState) => TSelected) | undefined;
69
67
  }): import("../..").ThreadComposerState | TSelected | null;
70
68
  };
71
- export declare const useThreadViewport: {
72
- (): ThreadViewportState;
73
- <TSelected>(selector: (state: ThreadViewportState) => TSelected): TSelected;
74
- (options: {
75
- optional: true;
76
- }): ThreadViewportState | null;
77
- <TSelected>(options: {
78
- optional: true;
79
- selector?: (state: ThreadViewportState) => TSelected;
80
- }): TSelected | null;
81
- }, useThreadViewportStore: {
82
- (): ReadonlyStore<ThreadViewportState>;
83
- (options: {
84
- optional: true;
85
- }): ReadonlyStore<ThreadViewportState> | null;
86
- };
87
69
  export declare function useThreadModelContext(options?: {
88
70
  optional?: false | undefined;
89
71
  }): ModelContext;
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/ThreadContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;IAC9D,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF,eAAO,MAAM,aAAa,oDAAiD,CAAC;AAO5E,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IACzC,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC9B,GAAG,aAAa,CAAC;AAClB,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IACzC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,aAAa,GAAG,IAAI,CAAC;AAOzB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;CAA8C,CAAC;AAKrE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;CAE7B,CAAC;AAEF,eAAO,MACQ,iBAAiB;;;;;;;;;;GACZ,sBAAsB;;;;;CACiB,CAAC;AAE5D,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC9B,GAAG,YAAY,CAAC;AACjB,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,YAAY,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"ThreadContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/ThreadContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,eAAO,MAAM,aAAa,oDAAiD,CAAC;AAO5E,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IACzC,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC9B,GAAG,aAAa,CAAC;AAClB,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IACzC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,aAAa,GAAG,IAAI,CAAC;AAOzB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;CAA8C,CAAC;AAKrE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;CAE7B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC9B,GAAG,YAAY,CAAC;AACjB,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,YAAY,GAAG,IAAI,CAAC"}
@@ -25,14 +25,11 @@ __export(ThreadContext_exports, {
25
25
  useThread: () => useThread,
26
26
  useThreadComposer: () => useThreadComposer,
27
27
  useThreadModelContext: () => useThreadModelContext,
28
- useThreadRuntime: () => useThreadRuntime,
29
- useThreadViewport: () => useThreadViewport,
30
- useThreadViewportStore: () => useThreadViewportStore
28
+ useThreadRuntime: () => useThreadRuntime
31
29
  });
32
30
  module.exports = __toCommonJS(ThreadContext_exports);
33
31
  var import_react = require("react");
34
32
  var import_createContextHook = require("./utils/createContextHook.js");
35
- var import_createContextStoreHook = require("./utils/createContextStoreHook.js");
36
33
  var import_createStateHookForRuntime = require("./utils/createStateHookForRuntime.js");
37
34
  var ThreadContext = (0, import_react.createContext)(null);
38
35
  var useThreadContext = (0, import_createContextHook.createContextHook)(
@@ -49,10 +46,6 @@ var useThreadComposerRuntime = (opt) => useThreadRuntime(opt)?.composer ?? null;
49
46
  var useThreadComposer = (0, import_createStateHookForRuntime.createStateHookForRuntime)(
50
47
  useThreadComposerRuntime
51
48
  );
52
- var {
53
- useViewport: useThreadViewport,
54
- useViewportStore: useThreadViewportStore
55
- } = (0, import_createContextStoreHook.createContextStoreHook)(useThreadContext, "useViewport");
56
49
  function useThreadModelContext(options) {
57
50
  const [, rerender] = (0, import_react.useState)({});
58
51
  const runtime = useThreadRuntime(options);
@@ -68,8 +61,6 @@ function useThreadModelContext(options) {
68
61
  useThread,
69
62
  useThreadComposer,
70
63
  useThreadModelContext,
71
- useThreadRuntime,
72
- useThreadViewport,
73
- useThreadViewportStore
64
+ useThreadRuntime
74
65
  });
75
66
  //# sourceMappingURL=ThreadContext.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/react/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useEffect, useState } from \"react\";\nimport type { ThreadViewportState } from \"../stores/ThreadViewport\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\nimport { ModelContext } from \"../../model-context\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\nimport { ThreadComposerRuntime } from \"../../api\";\n\nexport type ThreadContextValue = {\n useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;\n useViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nconst useThreadContext = createContextHook(\n ThreadContext,\n \"AssistantRuntimeProvider\",\n);\n\nexport function useThreadRuntime(options?: {\n optional?: false | undefined;\n}): ThreadRuntime;\nexport function useThreadRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadRuntime | null;\nexport function useThreadRuntime(options?: { optional?: boolean | undefined }) {\n const context = useThreadContext(options);\n if (!context) return null;\n return context.useThreadRuntime();\n}\n\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\n\nexport const {\n useViewport: useThreadViewport,\n useViewportStore: useThreadViewportStore,\n} = createContextStoreHook(useThreadContext, \"useViewport\");\n\nexport function useThreadModelContext(options?: {\n optional?: false | undefined;\n}): ModelContext;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null {\n const [, rerender] = useState({});\n\n const runtime = useThreadRuntime(options);\n useEffect(() => {\n return runtime?.unstable_on(\"model-context-update\", () => rerender({}));\n }, [runtime]);\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAmD;AAInD,+BAAkC;AAClC,oCAAuC;AAGvC,uCAA0C;AAQnC,IAAM,oBAAgB,4BAAyC,IAAI;AAE1E,IAAM,uBAAmB;AAAA,EACvB;AAAA,EACA;AACF;AAQO,SAAS,iBAAiB,SAA8C;AAC7E,QAAM,UAAU,iBAAiB,OAAO;AACxC,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,iBAAiB;AAClC;AAEO,IAAM,gBAAY,4DAA0B,gBAAgB;AAEnE,IAAM,2BAA2B,CAAC,QAEE,iBAAiB,GAAG,GAAG,YAAY;AAChE,IAAM,wBAAoB;AAAA,EAC/B;AACF;AAEO,IAAM;AAAA,EACX,aAAa;AAAA,EACb,kBAAkB;AACpB,QAAI,sDAAuB,kBAAkB,aAAa;AAQnD,SAAS,sBAAsB,SAEd;AACtB,QAAM,CAAC,EAAE,QAAQ,QAAI,uBAAS,CAAC,CAAC;AAEhC,QAAM,UAAU,iBAAiB,OAAO;AACxC,8BAAU,MAAM;AACd,WAAO,SAAS,YAAY,wBAAwB,MAAM,SAAS,CAAC,CAAC,CAAC;AAAA,EACxE,GAAG,CAAC,OAAO,CAAC;AAEZ,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,SAAS,gBAAgB;AAClC;","names":[]}
1
+ {"version":3,"sources":["../../../src/context/react/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useEffect, useState } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\nimport { ModelContext } from \"../../model-context\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\nimport { ThreadComposerRuntime } from \"../../api\";\n\nexport type ThreadContextValue = {\n useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nconst useThreadContext = createContextHook(\n ThreadContext,\n \"AssistantRuntimeProvider\",\n);\n\nexport function useThreadRuntime(options?: {\n optional?: false | undefined;\n}): ThreadRuntime;\nexport function useThreadRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadRuntime | null;\nexport function useThreadRuntime(options?: { optional?: boolean | undefined }) {\n const context = useThreadContext(options);\n if (!context) return null;\n return context.useThreadRuntime();\n}\n\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\n\nexport function useThreadModelContext(options?: {\n optional?: false | undefined;\n}): ModelContext;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null {\n const [, rerender] = useState({});\n\n const runtime = useThreadRuntime(options);\n useEffect(() => {\n return runtime?.unstable_on(\"model-context-update\", () => rerender({}));\n }, [runtime]);\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAmD;AAGnD,+BAAkC;AAGlC,uCAA0C;AAOnC,IAAM,oBAAgB,4BAAyC,IAAI;AAE1E,IAAM,uBAAmB;AAAA,EACvB;AAAA,EACA;AACF;AAQO,SAAS,iBAAiB,SAA8C;AAC7E,QAAM,UAAU,iBAAiB,OAAO;AACxC,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,iBAAiB;AAClC;AAEO,IAAM,gBAAY,4DAA0B,gBAAgB;AAEnE,IAAM,2BAA2B,CAAC,QAEE,iBAAiB,GAAG,GAAG,YAAY;AAChE,IAAM,wBAAoB;AAAA,EAC/B;AACF;AAQO,SAAS,sBAAsB,SAEd;AACtB,QAAM,CAAC,EAAE,QAAQ,QAAI,uBAAS,CAAC,CAAC;AAEhC,QAAM,UAAU,iBAAiB,OAAO;AACxC,8BAAU,MAAM;AACd,WAAO,SAAS,YAAY,wBAAwB,MAAM,SAAS,CAAC,CAAC,CAAC;AAAA,EACxE,GAAG,CAAC,OAAO,CAAC;AAEZ,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,SAAS,gBAAgB;AAClC;","names":[]}
@@ -3,7 +3,6 @@
3
3
  // src/context/react/ThreadContext.ts
4
4
  import { createContext, useEffect, useState } from "react";
5
5
  import { createContextHook } from "./utils/createContextHook.mjs";
6
- import { createContextStoreHook } from "./utils/createContextStoreHook.mjs";
7
6
  import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.mjs";
8
7
  var ThreadContext = createContext(null);
9
8
  var useThreadContext = createContextHook(
@@ -20,10 +19,6 @@ var useThreadComposerRuntime = (opt) => useThreadRuntime(opt)?.composer ?? null;
20
19
  var useThreadComposer = createStateHookForRuntime(
21
20
  useThreadComposerRuntime
22
21
  );
23
- var {
24
- useViewport: useThreadViewport,
25
- useViewportStore: useThreadViewportStore
26
- } = createContextStoreHook(useThreadContext, "useViewport");
27
22
  function useThreadModelContext(options) {
28
23
  const [, rerender] = useState({});
29
24
  const runtime = useThreadRuntime(options);
@@ -38,8 +33,6 @@ export {
38
33
  useThread,
39
34
  useThreadComposer,
40
35
  useThreadModelContext,
41
- useThreadRuntime,
42
- useThreadViewport,
43
- useThreadViewportStore
36
+ useThreadRuntime
44
37
  };
45
38
  //# sourceMappingURL=ThreadContext.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/react/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useEffect, useState } from \"react\";\nimport type { ThreadViewportState } from \"../stores/ThreadViewport\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\nimport { ModelContext } from \"../../model-context\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\nimport { ThreadComposerRuntime } from \"../../api\";\n\nexport type ThreadContextValue = {\n useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;\n useViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nconst useThreadContext = createContextHook(\n ThreadContext,\n \"AssistantRuntimeProvider\",\n);\n\nexport function useThreadRuntime(options?: {\n optional?: false | undefined;\n}): ThreadRuntime;\nexport function useThreadRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadRuntime | null;\nexport function useThreadRuntime(options?: { optional?: boolean | undefined }) {\n const context = useThreadContext(options);\n if (!context) return null;\n return context.useThreadRuntime();\n}\n\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\n\nexport const {\n useViewport: useThreadViewport,\n useViewportStore: useThreadViewportStore,\n} = createContextStoreHook(useThreadContext, \"useViewport\");\n\nexport function useThreadModelContext(options?: {\n optional?: false | undefined;\n}): ModelContext;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null {\n const [, rerender] = useState({});\n\n const runtime = useThreadRuntime(options);\n useEffect(() => {\n return runtime?.unstable_on(\"model-context-update\", () => rerender({}));\n }, [runtime]);\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":";;;AAEA,SAAS,eAAe,WAAW,gBAAgB;AAInD,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAGvC,SAAS,iCAAiC;AAQnC,IAAM,gBAAgB,cAAyC,IAAI;AAE1E,IAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AACF;AAQO,SAAS,iBAAiB,SAA8C;AAC7E,QAAM,UAAU,iBAAiB,OAAO;AACxC,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,iBAAiB;AAClC;AAEO,IAAM,YAAY,0BAA0B,gBAAgB;AAEnE,IAAM,2BAA2B,CAAC,QAEE,iBAAiB,GAAG,GAAG,YAAY;AAChE,IAAM,oBAAoB;AAAA,EAC/B;AACF;AAEO,IAAM;AAAA,EACX,aAAa;AAAA,EACb,kBAAkB;AACpB,IAAI,uBAAuB,kBAAkB,aAAa;AAQnD,SAAS,sBAAsB,SAEd;AACtB,QAAM,CAAC,EAAE,QAAQ,IAAI,SAAS,CAAC,CAAC;AAEhC,QAAM,UAAU,iBAAiB,OAAO;AACxC,YAAU,MAAM;AACd,WAAO,SAAS,YAAY,wBAAwB,MAAM,SAAS,CAAC,CAAC,CAAC;AAAA,EACxE,GAAG,CAAC,OAAO,CAAC;AAEZ,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,SAAS,gBAAgB;AAClC;","names":[]}
1
+ {"version":3,"sources":["../../../src/context/react/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useEffect, useState } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\nimport { ModelContext } from \"../../model-context\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\nimport { ThreadComposerRuntime } from \"../../api\";\n\nexport type ThreadContextValue = {\n useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nconst useThreadContext = createContextHook(\n ThreadContext,\n \"AssistantRuntimeProvider\",\n);\n\nexport function useThreadRuntime(options?: {\n optional?: false | undefined;\n}): ThreadRuntime;\nexport function useThreadRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadRuntime | null;\nexport function useThreadRuntime(options?: { optional?: boolean | undefined }) {\n const context = useThreadContext(options);\n if (!context) return null;\n return context.useThreadRuntime();\n}\n\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\n\nexport function useThreadModelContext(options?: {\n optional?: false | undefined;\n}): ModelContext;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null {\n const [, rerender] = useState({});\n\n const runtime = useThreadRuntime(options);\n useEffect(() => {\n return runtime?.unstable_on(\"model-context-update\", () => rerender({}));\n }, [runtime]);\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":";;;AAEA,SAAS,eAAe,WAAW,gBAAgB;AAGnD,SAAS,yBAAyB;AAGlC,SAAS,iCAAiC;AAOnC,IAAM,gBAAgB,cAAyC,IAAI;AAE1E,IAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AACF;AAQO,SAAS,iBAAiB,SAA8C;AAC7E,QAAM,UAAU,iBAAiB,OAAO;AACxC,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,iBAAiB;AAClC;AAEO,IAAM,YAAY,0BAA0B,gBAAgB;AAEnE,IAAM,2BAA2B,CAAC,QAEE,iBAAiB,GAAG,GAAG,YAAY;AAChE,IAAM,oBAAoB;AAAA,EAC/B;AACF;AAQO,SAAS,sBAAsB,SAEd;AACtB,QAAM,CAAC,EAAE,QAAQ,IAAI,SAAS,CAAC,CAAC;AAEhC,QAAM,UAAU,iBAAiB,OAAO;AACxC,YAAU,MAAM;AACd,WAAO,SAAS,YAAY,wBAAwB,MAAM,SAAS,CAAC,CAAC,CAAC;AAAA,EACxE,GAAG,CAAC,OAAO,CAAC;AAEZ,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,SAAS,gBAAgB;AAClC;","names":[]}
@@ -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,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;EAIpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,KAAK,mBAAmB,CAAC,KAAK,EAAE,OAAO,IAAI,CACzC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE;IACP,WAAW,EAAE,WAAW,CAAC;CAC1B,KACE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC,MAAM,MAAM,IAAI,CACd,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EACxE,OAAO,GAAG,OAAO,IACf;IACF,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC;IAC7C,OAAO,CAAC,EAAE,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;CAC/C,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
+ {"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,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;EAIpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,KAAK,mBAAmB,CAAC,KAAK,EAAE,OAAO,IAAI,CACzC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE;IACP,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;CAC1B,KACE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC,KAAK,+BAA+B,CAAC,OAAO,IAAI,mBAAmB,CACjE,OAAO,EACP,OAAO,CACR,CAAC;AAEF,MAAM,MAAM,IAAI,CACd,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EACxE,OAAO,GAAG,OAAO,IACf;IACF,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC;IAC7C,OAAO,CAAC,EAAE,mBAAmB,CAAC,KAAK,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,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;AAiCM,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
+ {"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);\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;AAiCM,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
+ {"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":[]}
@@ -0,0 +1,5 @@
1
+ import { ReasoningContentPart } from "../../types";
2
+ export declare const useContentPartReasoning: () => ReasoningContentPart & {
3
+ readonly status: import("../../types/AssistantTypes").ContentPartStatus | import("../../types/AssistantTypes").ToolCallContentPartStatus;
4
+ };
5
+ //# sourceMappingURL=useContentPartReasoning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContentPartReasoning.d.ts","sourceRoot":"","sources":["../../../src/primitives/contentPart/useContentPartReasoning.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,eAAO,MAAM,uBAAuB;;CAWnC,CAAC"}
@@ -0,0 +1,42 @@
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/primitives/contentPart/useContentPartReasoning.tsx
22
+ var useContentPartReasoning_exports = {};
23
+ __export(useContentPartReasoning_exports, {
24
+ useContentPartReasoning: () => useContentPartReasoning
25
+ });
26
+ module.exports = __toCommonJS(useContentPartReasoning_exports);
27
+ var import_ContentPartContext = require("../../context/react/ContentPartContext.js");
28
+ var useContentPartReasoning = () => {
29
+ const text = (0, import_ContentPartContext.useContentPart)((c) => {
30
+ if (c.type !== "reasoning")
31
+ throw new Error(
32
+ "ContentPartReasoning can only be used inside reasoning content parts."
33
+ );
34
+ return c;
35
+ });
36
+ return text;
37
+ };
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ useContentPartReasoning
41
+ });
42
+ //# sourceMappingURL=useContentPartReasoning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/primitives/contentPart/useContentPartReasoning.tsx"],"sourcesContent":["\"use client\";\n\nimport { ContentPartState } from \"../../api/ContentPartRuntime\";\nimport { useContentPart } from \"../../context/react/ContentPartContext\";\nimport { ReasoningContentPart } from \"../../types\";\n\nexport const useContentPartReasoning = () => {\n const text = useContentPart((c) => {\n if (c.type !== \"reasoning\")\n throw new Error(\n \"ContentPartReasoning can only be used inside reasoning content parts.\",\n );\n\n return c as ContentPartState & ReasoningContentPart;\n });\n\n return text;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gCAA+B;AAGxB,IAAM,0BAA0B,MAAM;AAC3C,QAAM,WAAO,0CAAe,CAAC,MAAM;AACjC,QAAI,EAAE,SAAS;AACb,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAEF,WAAO;AAAA,EACT,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+
3
+ // src/primitives/contentPart/useContentPartReasoning.tsx
4
+ import { useContentPart } from "../../context/react/ContentPartContext.mjs";
5
+ var useContentPartReasoning = () => {
6
+ const text = useContentPart((c) => {
7
+ if (c.type !== "reasoning")
8
+ throw new Error(
9
+ "ContentPartReasoning can only be used inside reasoning content parts."
10
+ );
11
+ return c;
12
+ });
13
+ return text;
14
+ };
15
+ export {
16
+ useContentPartReasoning
17
+ };
18
+ //# sourceMappingURL=useContentPartReasoning.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/primitives/contentPart/useContentPartReasoning.tsx"],"sourcesContent":["\"use client\";\n\nimport { ContentPartState } from \"../../api/ContentPartRuntime\";\nimport { useContentPart } from \"../../context/react/ContentPartContext\";\nimport { ReasoningContentPart } from \"../../types\";\n\nexport const useContentPartReasoning = () => {\n const text = useContentPart((c) => {\n if (c.type !== \"reasoning\")\n throw new Error(\n \"ContentPartReasoning can only be used inside reasoning content parts.\",\n );\n\n return c as ContentPartState & ReasoningContentPart;\n });\n\n return text;\n};\n"],"mappings":";;;AAGA,SAAS,sBAAsB;AAGxB,IAAM,0BAA0B,MAAM;AAC3C,QAAM,OAAO,eAAe,CAAC,MAAM;AACjC,QAAI,EAAE,SAAS;AACb,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAEF,WAAO;AAAA,EACT,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -11,5 +11,6 @@ export * as ThreadListItemPrimitive from "./threadListItem";
11
11
  export { useContentPartDisplay } from "./contentPart/useContentPartDisplay";
12
12
  export { useContentPartImage } from "./contentPart/useContentPartImage";
13
13
  export { useContentPartText } from "./contentPart/useContentPartText";
14
+ export { useContentPartReasoning } from "./contentPart/useContentPartReasoning";
14
15
  export { useThreadViewportAutoScroll } from "./thread/useThreadViewportAutoScroll";
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,uBAAuB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,mBAAmB,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,qBAAqB,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,iBAAiB,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,oBAAoB,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,gBAAgB,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,eAAe,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,mBAAmB,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,uBAAuB,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,uBAAuB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,mBAAmB,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,qBAAqB,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,iBAAiB,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,oBAAoB,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,gBAAgB,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,eAAe,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,mBAAmB,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,uBAAuB,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC"}
@@ -42,6 +42,7 @@ __export(primitives_exports, {
42
42
  ThreadPrimitive: () => ThreadPrimitive,
43
43
  useContentPartDisplay: () => import_useContentPartDisplay.useContentPartDisplay,
44
44
  useContentPartImage: () => import_useContentPartImage.useContentPartImage,
45
+ useContentPartReasoning: () => import_useContentPartReasoning.useContentPartReasoning,
45
46
  useContentPartText: () => import_useContentPartText.useContentPartText,
46
47
  useThreadViewportAutoScroll: () => import_useThreadViewportAutoScroll.useThreadViewportAutoScroll
47
48
  });
@@ -59,6 +60,7 @@ var ThreadListItemPrimitive = __toESM(require("./threadListItem/index.js"));
59
60
  var import_useContentPartDisplay = require("./contentPart/useContentPartDisplay.js");
60
61
  var import_useContentPartImage = require("./contentPart/useContentPartImage.js");
61
62
  var import_useContentPartText = require("./contentPart/useContentPartText.js");
63
+ var import_useContentPartReasoning = require("./contentPart/useContentPartReasoning.js");
62
64
  var import_useThreadViewportAutoScroll = require("./thread/useThreadViewportAutoScroll.js");
63
65
  // Annotate the CommonJS export names for ESM import in node:
64
66
  0 && (module.exports = {
@@ -74,6 +76,7 @@ var import_useThreadViewportAutoScroll = require("./thread/useThreadViewportAuto
74
76
  ThreadPrimitive,
75
77
  useContentPartDisplay,
76
78
  useContentPartImage,
79
+ useContentPartReasoning,
77
80
  useContentPartText,
78
81
  useThreadViewportAutoScroll
79
82
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/primitives/index.ts"],"sourcesContent":["export * as ActionBarPrimitive from \"./actionBar\";\nexport * as AssistantModalPrimitive from \"./assistantModal\";\nexport * as AttachmentPrimitive from \"./attachment\";\nexport * as BranchPickerPrimitive from \"./branchPicker\";\nexport * as ComposerPrimitive from \"./composer\";\nexport * as ContentPartPrimitive from \"./contentPart\";\nexport * as MessagePrimitive from \"./message\";\nexport * as ThreadPrimitive from \"./thread\";\nexport * as ThreadListPrimitive from \"./threadList\";\nexport * as ThreadListItemPrimitive from \"./threadListItem\";\n\nexport { useContentPartDisplay } from \"./contentPart/useContentPartDisplay\";\nexport { useContentPartImage } from \"./contentPart/useContentPartImage\";\nexport { useContentPartText } from \"./contentPart/useContentPartText\";\nexport { useThreadViewportAutoScroll } from \"./thread/useThreadViewportAutoScroll\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAoC;AACpC,8BAAyC;AACzC,0BAAqC;AACrC,4BAAuC;AACvC,wBAAmC;AACnC,2BAAsC;AACtC,uBAAkC;AAClC,sBAAiC;AACjC,0BAAqC;AACrC,8BAAyC;AAEzC,mCAAsC;AACtC,iCAAoC;AACpC,gCAAmC;AACnC,yCAA4C;","names":[]}
1
+ {"version":3,"sources":["../../src/primitives/index.ts"],"sourcesContent":["export * as ActionBarPrimitive from \"./actionBar\";\nexport * as AssistantModalPrimitive from \"./assistantModal\";\nexport * as AttachmentPrimitive from \"./attachment\";\nexport * as BranchPickerPrimitive from \"./branchPicker\";\nexport * as ComposerPrimitive from \"./composer\";\nexport * as ContentPartPrimitive from \"./contentPart\";\nexport * as MessagePrimitive from \"./message\";\nexport * as ThreadPrimitive from \"./thread\";\nexport * as ThreadListPrimitive from \"./threadList\";\nexport * as ThreadListItemPrimitive from \"./threadListItem\";\n\nexport { useContentPartDisplay } from \"./contentPart/useContentPartDisplay\";\nexport { useContentPartImage } from \"./contentPart/useContentPartImage\";\nexport { useContentPartText } from \"./contentPart/useContentPartText\";\nexport { useContentPartReasoning } from \"./contentPart/useContentPartReasoning\";\nexport { useThreadViewportAutoScroll } from \"./thread/useThreadViewportAutoScroll\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAoC;AACpC,8BAAyC;AACzC,0BAAqC;AACrC,4BAAuC;AACvC,wBAAmC;AACnC,2BAAsC;AACtC,uBAAkC;AAClC,sBAAiC;AACjC,0BAAqC;AACrC,8BAAyC;AAEzC,mCAAsC;AACtC,iCAAoC;AACpC,gCAAmC;AACnC,qCAAwC;AACxC,yCAA4C;","names":[]}
@@ -12,6 +12,7 @@ import * as ThreadListItemPrimitive from "./threadListItem/index.mjs";
12
12
  import { useContentPartDisplay } from "./contentPart/useContentPartDisplay.mjs";
13
13
  import { useContentPartImage } from "./contentPart/useContentPartImage.mjs";
14
14
  import { useContentPartText } from "./contentPart/useContentPartText.mjs";
15
+ import { useContentPartReasoning } from "./contentPart/useContentPartReasoning.mjs";
15
16
  import { useThreadViewportAutoScroll } from "./thread/useThreadViewportAutoScroll.mjs";
16
17
  export {
17
18
  ActionBarPrimitive,
@@ -26,6 +27,7 @@ export {
26
27
  ThreadPrimitive,
27
28
  useContentPartDisplay,
28
29
  useContentPartImage,
30
+ useContentPartReasoning,
29
31
  useContentPartText,
30
32
  useThreadViewportAutoScroll
31
33
  };