@assistant-ui/react 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. package/dist/{ModelConfigTypes-CzmXY3sn.d.mts → Thread-By2aBNAG.d.mts} +14 -2
  2. package/dist/{ModelConfigTypes-CzmXY3sn.d.ts → Thread-By2aBNAG.d.ts} +14 -2
  3. package/dist/{chunk-CY4TTHR7.mjs → chunk-SCWPIDP6.mjs} +8 -1
  4. package/dist/{chunk-CY4TTHR7.mjs.map → chunk-SCWPIDP6.mjs.map} +1 -1
  5. package/dist/experimental.d.mts +2 -3
  6. package/dist/experimental.d.ts +2 -3
  7. package/dist/experimental.mjs +1 -2
  8. package/dist/experimental.mjs.map +1 -1
  9. package/dist/index.d.mts +31 -4
  10. package/dist/index.d.ts +31 -4
  11. package/dist/index.js +9 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +205 -10
  14. package/dist/index.mjs.map +1 -1
  15. package/package.json +5 -15
  16. package/dist/AssistantRuntime-BM_jVV3g.d.mts +0 -23
  17. package/dist/AssistantRuntime-CBMSAJqH.d.mts +0 -23
  18. package/dist/AssistantRuntime-C_BvM7ZT.d.ts +0 -23
  19. package/dist/AssistantRuntime-DELpXWfG.d.ts +0 -23
  20. package/dist/ModelConfigTypes-B9UY4zxv.d.mts +0 -55
  21. package/dist/ModelConfigTypes-B9UY4zxv.d.ts +0 -55
  22. package/dist/ModelConfigTypes-BF5HxVrH.d.mts +0 -55
  23. package/dist/ModelConfigTypes-BF5HxVrH.d.ts +0 -55
  24. package/dist/ModelConfigTypes-Cf3yjaDu.d.mts +0 -55
  25. package/dist/ModelConfigTypes-Cf3yjaDu.d.ts +0 -55
  26. package/dist/Thread-BMASJT4a.d.ts +0 -15
  27. package/dist/Thread-UEVsUmvl.d.mts +0 -15
  28. package/dist/chunk-3XZUKECF.mjs +0 -207
  29. package/dist/chunk-3XZUKECF.mjs.map +0 -1
  30. package/dist/chunk-4DQ2CIAD.mjs +0 -69
  31. package/dist/chunk-4DQ2CIAD.mjs.map +0 -1
  32. package/dist/chunk-5YONSDN4.mjs +0 -200
  33. package/dist/chunk-5YONSDN4.mjs.map +0 -1
  34. package/dist/chunk-DKAWDNW5.mjs +0 -22
  35. package/dist/chunk-DKAWDNW5.mjs.map +0 -1
  36. package/dist/chunk-GQKH2ADD.mjs +0 -165
  37. package/dist/chunk-GQKH2ADD.mjs.map +0 -1
  38. package/dist/chunk-J5LGTIGS.mjs +0 -10
  39. package/dist/chunk-J5LGTIGS.mjs.map +0 -1
  40. package/dist/chunk-NSBOH42A.mjs +0 -200
  41. package/dist/chunk-NSBOH42A.mjs.map +0 -1
  42. package/dist/chunk-X4HBDEFP.mjs +0 -30
  43. package/dist/chunk-X4HBDEFP.mjs.map +0 -1
  44. package/dist/internal-dlLjX30u.d.mts +0 -75
  45. package/dist/internal-dlLjX30u.d.ts +0 -75
  46. package/dist/internal.d.mts +0 -25
  47. package/dist/internal.d.ts +0 -25
  48. package/dist/internal.js +0 -225
  49. package/dist/internal.js.map +0 -1
  50. package/dist/internal.mjs +0 -10
  51. package/dist/internal.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
1
  import { z } from 'zod';
2
+ import { ReactNode } from 'react';
3
3
 
4
4
  type TextContentPart = {
5
5
  type: "text";
@@ -52,4 +52,16 @@ type ModelConfig = {
52
52
  };
53
53
  type ModelConfigProvider = () => ModelConfig;
54
54
 
55
- export type { AssistantContentPart as A, ImageContentPart as I, ModelConfigProvider as M, TextContentPart as T, UIContentPart as U, ToolCallContentPart as a, ThreadMessage as b, ModelConfig as c, AppendMessage as d, AssistantMessage as e, UserMessage as f, UserContentPart as g, AppendContentPart as h };
55
+ type Unsubscribe = () => void;
56
+
57
+ type ThreadState = {
58
+ messages: readonly ThreadMessage[];
59
+ isRunning: boolean;
60
+ getBranches: (messageId: string) => readonly string[];
61
+ switchToBranch: (branchId: string) => void;
62
+ append: (message: AppendMessage) => void;
63
+ startRun: (parentId: string | null) => void;
64
+ cancelRun: () => void;
65
+ };
66
+
67
+ export type { AssistantContentPart as A, ImageContentPart as I, ModelConfigProvider as M, TextContentPart as T, UIContentPart as U, ToolCallContentPart as a, ThreadState as b, Unsubscribe as c, ThreadMessage as d, ModelConfig as e, AppendMessage as f, AssistantMessage as g, UserMessage as h, UserContentPart as i, AppendContentPart as j };
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
1
  import { z } from 'zod';
2
+ import { ReactNode } from 'react';
3
3
 
4
4
  type TextContentPart = {
5
5
  type: "text";
@@ -52,4 +52,16 @@ type ModelConfig = {
52
52
  };
53
53
  type ModelConfigProvider = () => ModelConfig;
54
54
 
55
- export type { AssistantContentPart as A, ImageContentPart as I, ModelConfigProvider as M, TextContentPart as T, UIContentPart as U, ToolCallContentPart as a, ThreadMessage as b, ModelConfig as c, AppendMessage as d, AssistantMessage as e, UserMessage as f, UserContentPart as g, AppendContentPart as h };
55
+ type Unsubscribe = () => void;
56
+
57
+ type ThreadState = {
58
+ messages: readonly ThreadMessage[];
59
+ isRunning: boolean;
60
+ getBranches: (messageId: string) => readonly string[];
61
+ switchToBranch: (branchId: string) => void;
62
+ append: (message: AppendMessage) => void;
63
+ startRun: (parentId: string | null) => void;
64
+ cancelRun: () => void;
65
+ };
66
+
67
+ export type { AssistantContentPart as A, ImageContentPart as I, ModelConfigProvider as M, TextContentPart as T, UIContentPart as U, ToolCallContentPart as a, ThreadState as b, Unsubscribe as c, ThreadMessage as d, ModelConfig as e, AppendMessage as f, AssistantMessage as g, UserMessage as h, UserContentPart as i, AppendContentPart as j };
@@ -1,3 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
1
7
  // src/context/MessageContext.ts
2
8
  import { createContext, useContext } from "react";
3
9
  var MessageContext = createContext(null);
@@ -63,6 +69,7 @@ var useAssistantContext = () => {
63
69
  };
64
70
 
65
71
  export {
72
+ __export,
66
73
  MessageContext,
67
74
  useMessageContext,
68
75
  ThreadContext,
@@ -73,4 +80,4 @@ export {
73
80
  AssistantContext,
74
81
  useAssistantContext
75
82
  };
76
- //# sourceMappingURL=chunk-CY4TTHR7.mjs.map
83
+ //# sourceMappingURL=chunk-SCWPIDP6.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context/MessageContext.ts","../src/context/ThreadContext.ts","../src/context/ComposerContext.ts","../src/context/ContentPartContext.ts","../src/context/AssistantContext.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { MessageState } from \"./stores/Message\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type MessageContextValue = {\n useMessage: UseBoundStore<StoreApi<MessageState>>;\n useComposer: UseBoundStore<StoreApi<EditComposerState>>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nexport const useMessageContext = () => {\n const context = useContext(MessageContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { ThreadState } from \"./stores/Thread\";\nimport type { ThreadViewportState } from \"./stores/ThreadViewport\";\n\nexport type ThreadContextValue = {\n useThread: UseBoundStore<StoreApi<ThreadState>>;\n useComposer: UseBoundStore<StoreApi<ComposerState>>;\n useViewport: UseBoundStore<StoreApi<ThreadViewportState>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nexport const useThreadContext = (): ThreadContextValue => {\n const context = useContext(ThreadContext);\n if (!context)\n throw new Error(\"This component must be used within an AssistantRuntimeProvider.\");\n return context;\n};\n","import { useContext, useMemo } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport { MessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type ComposerContextValue = {\n useComposer: UseBoundStore<StoreApi<EditComposerState | ComposerState>>;\n type: \"edit\" | \"new\";\n};\n\nexport const useComposerContext = (): ComposerContextValue => {\n const { useComposer } = useThreadContext();\n const { useComposer: useEditComposer } = useContext(MessageContext) ?? {};\n return useMemo(\n () => ({\n useComposer: (useEditComposer ?? useComposer) as UseBoundStore<\n StoreApi<EditComposerState | ComposerState>\n >,\n type: useEditComposer ? (\"edit\" as const) : (\"new\" as const),\n }),\n [useEditComposer, useComposer],\n );\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ContentPartState } from \"./stores/ContentPart\";\n\nexport type ContentPartContextValue = {\n useContentPart: UseBoundStore<StoreApi<ContentPartState>>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nexport const useContentPartContext = (): ContentPartContextValue => {\n const context = useContext(ContentPartContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { AssistantModelConfigState } from \"./stores/AssistantModelConfig\";\n\nexport type AssistantContextValue = {\n useModelConfig: UseBoundStore<StoreApi<AssistantModelConfigState>>;\n};\n\nexport const AssistantContext = createContext<AssistantContextValue | null>(\n null,\n);\n\nexport const useAssistantContext = (): AssistantContextValue => {\n const context = useContext(AssistantContext);\n if (!context)\n throw new Error(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n};\n"],"mappings":";AAAA,SAAS,eAAe,kBAAkB;AAUnC,IAAM,iBAAiB,cAA0C,IAAI;AAErE,IAAM,oBAAoB,MAAM;AACrC,QAAM,UAAU,WAAW,cAAc;AACzC,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACnBA,SAAS,iBAAAA,gBAAe,cAAAC,mBAAkB;AAYnC,IAAM,gBAAgBD,eAAyC,IAAI;AAEnE,IAAM,mBAAmB,MAA0B;AACxD,QAAM,UAAUC,YAAW,aAAa;AACxC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,iEAAiE;AACnF,SAAO;AACT;;;ACnBA,SAAS,cAAAC,aAAY,eAAe;AAY7B,IAAM,qBAAqB,MAA4B;AAC5D,QAAM,EAAE,YAAY,IAAI,iBAAiB;AACzC,QAAM,EAAE,aAAa,gBAAgB,IAAIC,YAAW,cAAc,KAAK,CAAC;AACxE,SAAO;AAAA,IACL,OAAO;AAAA,MACL,aAAc,mBAAmB;AAAA,MAGjC,MAAM,kBAAmB,SAAoB;AAAA,IAC/C;AAAA,IACA,CAAC,iBAAiB,WAAW;AAAA,EAC/B;AACF;;;ACxBA,SAAS,iBAAAC,gBAAe,cAAAC,mBAAkB;AAQnC,IAAM,qBAAqBD;AAAA,EAChC;AACF;AAEO,IAAM,wBAAwB,MAA+B;AAClE,QAAM,UAAUC,YAAW,kBAAkB;AAC7C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACnBA,SAAS,iBAAAC,gBAAe,cAAAC,mBAAkB;AAQnC,IAAM,mBAAmBD;AAAA,EAC9B;AACF;AAEO,IAAM,sBAAsB,MAA6B;AAC9D,QAAM,UAAUC,YAAW,gBAAgB;AAC3C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;","names":["createContext","useContext","useContext","useContext","createContext","useContext","createContext","useContext"]}
1
+ {"version":3,"sources":["../src/context/MessageContext.ts","../src/context/ThreadContext.ts","../src/context/ComposerContext.ts","../src/context/ContentPartContext.ts","../src/context/AssistantContext.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { MessageState } from \"./stores/Message\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type MessageContextValue = {\n useMessage: UseBoundStore<StoreApi<MessageState>>;\n useComposer: UseBoundStore<StoreApi<EditComposerState>>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nexport const useMessageContext = () => {\n const context = useContext(MessageContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { ThreadState } from \"./stores/Thread\";\nimport type { ThreadViewportState } from \"./stores/ThreadViewport\";\n\nexport type ThreadContextValue = {\n useThread: UseBoundStore<StoreApi<ThreadState>>;\n useComposer: UseBoundStore<StoreApi<ComposerState>>;\n useViewport: UseBoundStore<StoreApi<ThreadViewportState>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nexport const useThreadContext = (): ThreadContextValue => {\n const context = useContext(ThreadContext);\n if (!context)\n throw new Error(\"This component must be used within an AssistantRuntimeProvider.\");\n return context;\n};\n","import { useContext, useMemo } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport { MessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type ComposerContextValue = {\n useComposer: UseBoundStore<StoreApi<EditComposerState | ComposerState>>;\n type: \"edit\" | \"new\";\n};\n\nexport const useComposerContext = (): ComposerContextValue => {\n const { useComposer } = useThreadContext();\n const { useComposer: useEditComposer } = useContext(MessageContext) ?? {};\n return useMemo(\n () => ({\n useComposer: (useEditComposer ?? useComposer) as UseBoundStore<\n StoreApi<EditComposerState | ComposerState>\n >,\n type: useEditComposer ? (\"edit\" as const) : (\"new\" as const),\n }),\n [useEditComposer, useComposer],\n );\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ContentPartState } from \"./stores/ContentPart\";\n\nexport type ContentPartContextValue = {\n useContentPart: UseBoundStore<StoreApi<ContentPartState>>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nexport const useContentPartContext = (): ContentPartContextValue => {\n const context = useContext(ContentPartContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { AssistantModelConfigState } from \"./stores/AssistantModelConfig\";\n\nexport type AssistantContextValue = {\n useModelConfig: UseBoundStore<StoreApi<AssistantModelConfigState>>;\n};\n\nexport const AssistantContext = createContext<AssistantContextValue | null>(\n null,\n);\n\nexport const useAssistantContext = (): AssistantContextValue => {\n const context = useContext(AssistantContext);\n if (!context)\n throw new Error(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n};\n"],"mappings":";;;;;;;AAAA,SAAS,eAAe,kBAAkB;AAUnC,IAAM,iBAAiB,cAA0C,IAAI;AAErE,IAAM,oBAAoB,MAAM;AACrC,QAAM,UAAU,WAAW,cAAc;AACzC,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACnBA,SAAS,iBAAAA,gBAAe,cAAAC,mBAAkB;AAYnC,IAAM,gBAAgBD,eAAyC,IAAI;AAEnE,IAAM,mBAAmB,MAA0B;AACxD,QAAM,UAAUC,YAAW,aAAa;AACxC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,iEAAiE;AACnF,SAAO;AACT;;;ACnBA,SAAS,cAAAC,aAAY,eAAe;AAY7B,IAAM,qBAAqB,MAA4B;AAC5D,QAAM,EAAE,YAAY,IAAI,iBAAiB;AACzC,QAAM,EAAE,aAAa,gBAAgB,IAAIC,YAAW,cAAc,KAAK,CAAC;AACxE,SAAO;AAAA,IACL,OAAO;AAAA,MACL,aAAc,mBAAmB;AAAA,MAGjC,MAAM,kBAAmB,SAAoB;AAAA,IAC/C;AAAA,IACA,CAAC,iBAAiB,WAAW;AAAA,EAC/B;AACF;;;ACxBA,SAAS,iBAAAC,gBAAe,cAAAC,mBAAkB;AAQnC,IAAM,qBAAqBD;AAAA,EAChC;AACF;AAEO,IAAM,wBAAwB,MAA+B;AAClE,QAAM,UAAUC,YAAW,kBAAkB;AAC7C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACnBA,SAAS,iBAAAC,gBAAe,cAAAC,mBAAkB;AAQnC,IAAM,mBAAmBD;AAAA,EAC9B;AACF;AAEO,IAAM,sBAAsB,MAA6B;AAC9D,QAAM,UAAUC,YAAW,gBAAgB;AAC3C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;","names":["createContext","useContext","useContext","useContext","createContext","useContext","createContext","useContext"]}
@@ -1,7 +1,6 @@
1
- import { M as ModelConfigProvider, b as ThreadMessage } from './ModelConfigTypes-CzmXY3sn.mjs';
2
- export { I as ImageContentPart, a as ToolCallContentPart, U as UIContentPart } from './ModelConfigTypes-CzmXY3sn.mjs';
1
+ import { M as ModelConfigProvider, d as ThreadMessage, c as Unsubscribe, b as ThreadState } from './Thread-By2aBNAG.mjs';
2
+ export { I as ImageContentPart, a as ToolCallContentPart, U as UIContentPart } from './Thread-By2aBNAG.mjs';
3
3
  import { ReactNode } from 'react';
4
- import { U as Unsubscribe, T as ThreadState } from './Thread-UEVsUmvl.mjs';
5
4
  import { UseBoundStore, StoreApi } from 'zustand';
6
5
  import 'zod';
7
6
 
@@ -1,7 +1,6 @@
1
- import { M as ModelConfigProvider, b as ThreadMessage } from './ModelConfigTypes-CzmXY3sn.js';
2
- export { I as ImageContentPart, a as ToolCallContentPart, U as UIContentPart } from './ModelConfigTypes-CzmXY3sn.js';
1
+ import { M as ModelConfigProvider, d as ThreadMessage, c as Unsubscribe, b as ThreadState } from './Thread-By2aBNAG.js';
2
+ export { I as ImageContentPart, a as ToolCallContentPart, U as UIContentPart } from './Thread-By2aBNAG.js';
3
3
  import { ReactNode } from 'react';
4
- import { U as Unsubscribe, T as ThreadState } from './Thread-BMASJT4a.js';
5
4
  import { UseBoundStore, StoreApi } from 'zustand';
6
5
  import 'zod';
7
6
 
@@ -4,8 +4,7 @@ import {
4
4
  useContentPartContext,
5
5
  useMessageContext,
6
6
  useThreadContext
7
- } from "./chunk-CY4TTHR7.mjs";
8
- import "./chunk-J5LGTIGS.mjs";
7
+ } from "./chunk-SCWPIDP6.mjs";
9
8
 
10
9
  // src/model-config/useAssistantInstructions.tsx
11
10
  import { useEffect } from "react";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/model-config/useAssistantInstructions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\n\nexport const useAssistantInstructions = (instruction: string) => {\n const { useModelConfig } = useAssistantContext();\n const addContextProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(\n () =>\n addContextProvider(() => {\n return {\n system: instruction,\n };\n }),\n [addContextProvider, instruction],\n );\n};\n"],"mappings":";;;;;;;;;;AAEA,SAAS,iBAAiB;AAGnB,IAAM,2BAA2B,CAAC,gBAAwB;AAC/D,QAAM,EAAE,eAAe,IAAI,oBAAoB;AAC/C,QAAM,qBAAqB;AAAA,IACzB,CAAC,MAAM,EAAE;AAAA,EACX;AACA;AAAA,IACE,MACE,mBAAmB,MAAM;AACvB,aAAO;AAAA,QACL,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,IACH,CAAC,oBAAoB,WAAW;AAAA,EAClC;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/model-config/useAssistantInstructions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\n\nexport const useAssistantInstructions = (instruction: string) => {\n const { useModelConfig } = useAssistantContext();\n const addContextProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(\n () =>\n addContextProvider(() => {\n return {\n system: instruction,\n };\n }),\n [addContextProvider, instruction],\n );\n};\n"],"mappings":";;;;;;;;;AAEA,SAAS,iBAAiB;AAGnB,IAAM,2BAA2B,CAAC,gBAAwB;AAC/D,QAAM,EAAE,eAAe,IAAI,oBAAoB;AAC/C,QAAM,qBAAqB;AAAA,IACzB,CAAC,MAAM,EAAE;AAAA,EACX;AACA;AAAA,IACE,MACE,mBAAmB,MAAM;AACvB,aAAO;AAAA,QACL,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,IACH,CAAC,oBAAoB,WAAW;AAAA,EAClC;AACF;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,9 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
3
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
- import { T as TextContentPart, I as ImageContentPart, U as UIContentPart, a as ToolCallContentPart, M as ModelConfigProvider, b as ThreadMessage, c as ModelConfig, A as AssistantContentPart, d as AppendMessage } from './ModelConfigTypes-CzmXY3sn.mjs';
5
- export { h as AppendContentPart, e as AssistantMessage, g as UserContentPart, f as UserMessage } from './ModelConfigTypes-CzmXY3sn.mjs';
6
- import { T as ThreadState, U as Unsubscribe } from './Thread-UEVsUmvl.mjs';
4
+ import { T as TextContentPart, I as ImageContentPart, U as UIContentPart, a as ToolCallContentPart, b as ThreadState, c as Unsubscribe, M as ModelConfigProvider, d as ThreadMessage, e as ModelConfig, A as AssistantContentPart, f as AppendMessage } from './Thread-By2aBNAG.mjs';
5
+ export { j as AppendContentPart, g as AssistantMessage, i as UserContentPart, h as UserMessage } from './Thread-By2aBNAG.mjs';
7
6
  import 'zod';
8
7
 
9
8
  declare const useCopyMessage: ({ copiedDuration }: {
@@ -286,4 +285,32 @@ type AssistantRuntimeProviderProps = {
286
285
  };
287
286
  declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
288
287
 
289
- export { index$1 as ActionBarPrimitive, AppendMessage, AssistantContentPart, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, index$4 as ComposerPrimitive, index as ContentPartPrimitive, index$3 as MessagePrimitive, type ReactThreadRuntime, TextContentPart, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useLocalRuntime, useReloadMessage };
288
+ declare class ProxyConfigProvider {
289
+ private _providers;
290
+ getModelConfig(): ModelConfig;
291
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
292
+ }
293
+
294
+ declare class MessageRepository {
295
+ private messages;
296
+ private head;
297
+ private root;
298
+ private performOp;
299
+ getMessages(): ThreadMessage[];
300
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
301
+ appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
302
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
303
+ getBranches(messageId: string): string[];
304
+ switchToBranch(messageId: string): void;
305
+ resetHead(messageId: string | null): void;
306
+ }
307
+
308
+ type internal_MessageRepository = MessageRepository;
309
+ declare const internal_MessageRepository: typeof MessageRepository;
310
+ type internal_ProxyConfigProvider = ProxyConfigProvider;
311
+ declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
312
+ declare namespace internal {
313
+ export { internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
314
+ }
315
+
316
+ export { index$1 as ActionBarPrimitive, AppendMessage, AssistantContentPart, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, index$4 as ComposerPrimitive, index as ContentPartPrimitive, internal as INTERNAL, index$3 as MessagePrimitive, type ReactThreadRuntime, TextContentPart, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useLocalRuntime, useReloadMessage };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
3
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
- import { T as TextContentPart, I as ImageContentPart, U as UIContentPart, a as ToolCallContentPart, M as ModelConfigProvider, b as ThreadMessage, c as ModelConfig, A as AssistantContentPart, d as AppendMessage } from './ModelConfigTypes-CzmXY3sn.js';
5
- export { h as AppendContentPart, e as AssistantMessage, g as UserContentPart, f as UserMessage } from './ModelConfigTypes-CzmXY3sn.js';
6
- import { T as ThreadState, U as Unsubscribe } from './Thread-BMASJT4a.js';
4
+ import { T as TextContentPart, I as ImageContentPart, U as UIContentPart, a as ToolCallContentPart, b as ThreadState, c as Unsubscribe, M as ModelConfigProvider, d as ThreadMessage, e as ModelConfig, A as AssistantContentPart, f as AppendMessage } from './Thread-By2aBNAG.js';
5
+ export { j as AppendContentPart, g as AssistantMessage, i as UserContentPart, h as UserMessage } from './Thread-By2aBNAG.js';
7
6
  import 'zod';
8
7
 
9
8
  declare const useCopyMessage: ({ copiedDuration }: {
@@ -286,4 +285,32 @@ type AssistantRuntimeProviderProps = {
286
285
  };
287
286
  declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
288
287
 
289
- export { index$1 as ActionBarPrimitive, AppendMessage, AssistantContentPart, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, index$4 as ComposerPrimitive, index as ContentPartPrimitive, index$3 as MessagePrimitive, type ReactThreadRuntime, TextContentPart, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useLocalRuntime, useReloadMessage };
288
+ declare class ProxyConfigProvider {
289
+ private _providers;
290
+ getModelConfig(): ModelConfig;
291
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
292
+ }
293
+
294
+ declare class MessageRepository {
295
+ private messages;
296
+ private head;
297
+ private root;
298
+ private performOp;
299
+ getMessages(): ThreadMessage[];
300
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
301
+ appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
302
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
303
+ getBranches(messageId: string): string[];
304
+ switchToBranch(messageId: string): void;
305
+ resetHead(messageId: string | null): void;
306
+ }
307
+
308
+ type internal_MessageRepository = MessageRepository;
309
+ declare const internal_MessageRepository: typeof MessageRepository;
310
+ type internal_ProxyConfigProvider = ProxyConfigProvider;
311
+ declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
312
+ declare namespace internal {
313
+ export { internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
314
+ }
315
+
316
+ export { index$1 as ActionBarPrimitive, AppendMessage, AssistantContentPart, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, index$4 as ComposerPrimitive, index as ContentPartPrimitive, internal as INTERNAL, index$3 as MessagePrimitive, type ReactThreadRuntime, TextContentPart, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useLocalRuntime, useReloadMessage };
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ __export(src_exports, {
35
35
  BranchPickerPrimitive: () => branchPicker_exports,
36
36
  ComposerPrimitive: () => composer_exports,
37
37
  ContentPartPrimitive: () => contentPart_exports,
38
+ INTERNAL: () => internal_exports,
38
39
  MessagePrimitive: () => message_exports,
39
40
  ThreadPrimitive: () => thread_exports,
40
41
  useBeginMessageEdit: () => useBeginMessageEdit,
@@ -1481,6 +1482,13 @@ var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
1481
1482
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AssistantProvider, { runtime, children });
1482
1483
  };
1483
1484
  var AssistantRuntimeProvider = (0, import_react33.memo)(AssistantRuntimeProviderImpl);
1485
+
1486
+ // src/internal.ts
1487
+ var internal_exports = {};
1488
+ __export(internal_exports, {
1489
+ MessageRepository: () => MessageRepository,
1490
+ ProxyConfigProvider: () => ProxyConfigProvider
1491
+ });
1484
1492
  // Annotate the CommonJS export names for ESM import in node:
1485
1493
  0 && (module.exports = {
1486
1494
  ActionBarPrimitive,
@@ -1488,6 +1496,7 @@ var AssistantRuntimeProvider = (0, import_react33.memo)(AssistantRuntimeProvider
1488
1496
  BranchPickerPrimitive,
1489
1497
  ComposerPrimitive,
1490
1498
  ContentPartPrimitive,
1499
+ INTERNAL,
1491
1500
  MessagePrimitive,
1492
1501
  ThreadPrimitive,
1493
1502
  useBeginMessageEdit,