@assistant-ui/react 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -0
- package/dist/{chunk-7O2URLFI.mjs → chunk-KUACYNLE.mjs} +22 -22
- package/dist/chunk-KUACYNLE.mjs.map +1 -0
- package/dist/experimental.d.mts +1 -1
- package/dist/experimental.d.ts +1 -1
- package/dist/experimental.js +7 -7
- package/dist/experimental.js.map +1 -1
- package/dist/experimental.mjs +1 -1
- package/dist/experimental.mjs.map +1 -1
- package/dist/index.d.mts +75 -40
- package/dist/index.d.ts +75 -40
- package/dist/index.js +469 -377
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +376 -300
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-7O2URLFI.mjs.map +0 -1
package/README.md
CHANGED
@@ -14,6 +14,8 @@ assistant-ui is a set of React components for AI chat.
|
|
14
14
|
|
15
15
|
## Quick Start
|
16
16
|
|
17
|
+
[![assistant-ui starter template](https://raw.githubusercontent.com/Yonom/assistant-ui/main/.github/assets/assistant-ui-starter.gif)](https://youtu.be/k6Dc8URmLjk)
|
18
|
+
|
17
19
|
Step 1: Create a new project with `assistant-ui` pre-configured:
|
18
20
|
|
19
21
|
```sh
|
@@ -4,7 +4,7 @@ var __export = (target, all) => {
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
5
5
|
};
|
6
6
|
|
7
|
-
// src/context/MessageContext.ts
|
7
|
+
// src/context/react/MessageContext.ts
|
8
8
|
import { createContext, useContext } from "react";
|
9
9
|
var MessageContext = createContext(null);
|
10
10
|
var useMessageContext = () => {
|
@@ -16,7 +16,7 @@ var useMessageContext = () => {
|
|
16
16
|
return context;
|
17
17
|
};
|
18
18
|
|
19
|
-
// src/context/ThreadContext.ts
|
19
|
+
// src/context/react/ThreadContext.ts
|
20
20
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
21
21
|
var ThreadContext = createContext2(null);
|
22
22
|
var useThreadContext = () => {
|
@@ -28,27 +28,13 @@ var useThreadContext = () => {
|
|
28
28
|
return context;
|
29
29
|
};
|
30
30
|
|
31
|
-
// src/context/
|
32
|
-
import { useContext as useContext3
|
33
|
-
var useComposerContext = () => {
|
34
|
-
const { useComposer } = useThreadContext();
|
35
|
-
const { useComposer: useEditComposer } = useContext3(MessageContext) ?? {};
|
36
|
-
return useMemo(
|
37
|
-
() => ({
|
38
|
-
useComposer: useEditComposer ?? useComposer,
|
39
|
-
type: useEditComposer ? "edit" : "new"
|
40
|
-
}),
|
41
|
-
[useEditComposer, useComposer]
|
42
|
-
);
|
43
|
-
};
|
44
|
-
|
45
|
-
// src/context/AssistantContext.ts
|
46
|
-
import { createContext as createContext3, useContext as useContext4 } from "react";
|
31
|
+
// src/context/react/AssistantContext.ts
|
32
|
+
import { createContext as createContext3, useContext as useContext3 } from "react";
|
47
33
|
var AssistantContext = createContext3(
|
48
34
|
null
|
49
35
|
);
|
50
36
|
var useAssistantContext = () => {
|
51
|
-
const context =
|
37
|
+
const context = useContext3(AssistantContext);
|
52
38
|
if (!context)
|
53
39
|
throw new Error(
|
54
40
|
"This component must be used within an AssistantRuntimeProvider."
|
@@ -56,7 +42,21 @@ var useAssistantContext = () => {
|
|
56
42
|
return context;
|
57
43
|
};
|
58
44
|
|
59
|
-
// src/context/
|
45
|
+
// src/context/react/ComposerContext.ts
|
46
|
+
import { useContext as useContext4, useMemo } from "react";
|
47
|
+
var useComposerContext = () => {
|
48
|
+
const { useComposer } = useThreadContext();
|
49
|
+
const { useEditComposer } = useContext4(MessageContext) ?? {};
|
50
|
+
return useMemo(
|
51
|
+
() => ({
|
52
|
+
useComposer: useEditComposer ?? useComposer,
|
53
|
+
type: useEditComposer ? "edit" : "new"
|
54
|
+
}),
|
55
|
+
[useEditComposer, useComposer]
|
56
|
+
);
|
57
|
+
};
|
58
|
+
|
59
|
+
// src/context/react/ContentPartContext.ts
|
60
60
|
import { createContext as createContext4, useContext as useContext5 } from "react";
|
61
61
|
var ContentPartContext = createContext4(
|
62
62
|
null
|
@@ -76,10 +76,10 @@ export {
|
|
76
76
|
useMessageContext,
|
77
77
|
ThreadContext,
|
78
78
|
useThreadContext,
|
79
|
-
useComposerContext,
|
80
79
|
AssistantContext,
|
81
80
|
useAssistantContext,
|
81
|
+
useComposerContext,
|
82
82
|
ContentPartContext,
|
83
83
|
useContentPartContext
|
84
84
|
};
|
85
|
-
//# sourceMappingURL=chunk-
|
85
|
+
//# sourceMappingURL=chunk-KUACYNLE.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/context/react/MessageContext.ts","../src/context/react/ThreadContext.ts","../src/context/react/AssistantContext.ts","../src/context/react/ComposerContext.ts","../src/context/react/ContentPartContext.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { MessageState } from \"../stores/Message\";\nimport type { EditComposerState } from \"../stores/EditComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { MessageUtilsState } from \"../stores/MessageUtils\";\n\nexport type MessageContextValue = {\n useMessage: ReadonlyStore<MessageState>;\n useMessageUtils: ReadonlyStore<MessageUtilsState>;\n useEditComposer: ReadonlyStore<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 { ComposerState } from \"../stores/Composer\";\nimport type { ThreadState } from \"../stores/Thread\";\nimport type { ThreadViewportState } from \"../stores/ThreadViewport\";\nimport { ThreadActionsState } from \"../stores/ThreadActions\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ThreadContextValue = {\n useThread: ReadonlyStore<ThreadState>;\n useThreadActions: ReadonlyStore<ThreadActionsState>;\n useComposer: ReadonlyStore<ComposerState>;\n useViewport: ReadonlyStore<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(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { AssistantModelConfigState } from \"../stores/AssistantModelConfig\";\nimport type { AssistantToolUIsState } from \"../stores/AssistantToolUIs\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type AssistantContextValue = {\n useModelConfig: ReadonlyStore<AssistantModelConfigState>;\n useToolUIs: ReadonlyStore<AssistantToolUIsState>;\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","import { useContext, useMemo } from \"react\";\nimport { MessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"../stores/Composer\";\nimport type { EditComposerState } from \"../stores/EditComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ComposerContextValue = {\n useComposer: ReadonlyStore<EditComposerState | ComposerState>;\n type: \"edit\" | \"new\";\n};\n\nexport const useComposerContext = (): ComposerContextValue => {\n const { useComposer } = useThreadContext();\n const { useEditComposer } = useContext(MessageContext) ?? {};\n return useMemo(\n () => ({\n useComposer: (useEditComposer ?? useComposer) as ReadonlyStore<\n 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 { ContentPartState } from \"../stores/ContentPart\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ContentPartContextValue = {\n useContentPart: ReadonlyStore<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"],"mappings":";;;;;;;AAAA,SAAS,eAAe,kBAAkB;AAYnC,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;;;ACrBA,SAAS,iBAAAA,gBAAe,cAAAC,mBAAkB;AAcnC,IAAM,gBAAgBD,eAAyC,IAAI;AAEnE,IAAM,mBAAmB,MAA0B;AACxD,QAAM,UAAUC,YAAW,aAAa;AACxC,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACvBA,SAAS,iBAAAC,gBAAe,cAAAC,mBAAkB;AAUnC,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;;;ACrBA,SAAS,cAAAC,aAAY,eAAe;AAY7B,IAAM,qBAAqB,MAA4B;AAC5D,QAAM,EAAE,YAAY,IAAI,iBAAiB;AACzC,QAAM,EAAE,gBAAgB,IAAIC,YAAW,cAAc,KAAK,CAAC;AAC3D,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;","names":["createContext","useContext","createContext","useContext","useContext","useContext","createContext","useContext"]}
|
package/dist/experimental.d.mts
CHANGED
@@ -84,7 +84,7 @@ type MessageUtilsState = Readonly<{
|
|
84
84
|
type MessageContextValue = {
|
85
85
|
useMessage: ReadonlyStore<MessageState>;
|
86
86
|
useMessageUtils: ReadonlyStore<MessageUtilsState>;
|
87
|
-
|
87
|
+
useEditComposer: ReadonlyStore<EditComposerState>;
|
88
88
|
};
|
89
89
|
declare const useMessageContext: () => MessageContextValue;
|
90
90
|
|
package/dist/experimental.d.ts
CHANGED
@@ -84,7 +84,7 @@ type MessageUtilsState = Readonly<{
|
|
84
84
|
type MessageContextValue = {
|
85
85
|
useMessage: ReadonlyStore<MessageState>;
|
86
86
|
useMessageUtils: ReadonlyStore<MessageUtilsState>;
|
87
|
-
|
87
|
+
useEditComposer: ReadonlyStore<EditComposerState>;
|
88
88
|
};
|
89
89
|
declare const useMessageContext: () => MessageContextValue;
|
90
90
|
|
package/dist/experimental.js
CHANGED
@@ -33,7 +33,7 @@ __export(experimental_exports, {
|
|
33
33
|
});
|
34
34
|
module.exports = __toCommonJS(experimental_exports);
|
35
35
|
|
36
|
-
// src/context/AssistantContext.ts
|
36
|
+
// src/context/react/AssistantContext.ts
|
37
37
|
var import_react = require("react");
|
38
38
|
var AssistantContext = (0, import_react.createContext)(
|
39
39
|
null
|
@@ -47,7 +47,7 @@ var useAssistantContext = () => {
|
|
47
47
|
return context;
|
48
48
|
};
|
49
49
|
|
50
|
-
// src/context/ThreadContext.ts
|
50
|
+
// src/context/react/ThreadContext.ts
|
51
51
|
var import_react2 = require("react");
|
52
52
|
var ThreadContext = (0, import_react2.createContext)(null);
|
53
53
|
var useThreadContext = () => {
|
@@ -59,10 +59,10 @@ var useThreadContext = () => {
|
|
59
59
|
return context;
|
60
60
|
};
|
61
61
|
|
62
|
-
// src/context/ComposerContext.ts
|
62
|
+
// src/context/react/ComposerContext.ts
|
63
63
|
var import_react4 = require("react");
|
64
64
|
|
65
|
-
// src/context/MessageContext.ts
|
65
|
+
// src/context/react/MessageContext.ts
|
66
66
|
var import_react3 = require("react");
|
67
67
|
var MessageContext = (0, import_react3.createContext)(null);
|
68
68
|
var useMessageContext = () => {
|
@@ -74,10 +74,10 @@ var useMessageContext = () => {
|
|
74
74
|
return context;
|
75
75
|
};
|
76
76
|
|
77
|
-
// src/context/ComposerContext.ts
|
77
|
+
// src/context/react/ComposerContext.ts
|
78
78
|
var useComposerContext = () => {
|
79
79
|
const { useComposer } = useThreadContext();
|
80
|
-
const {
|
80
|
+
const { useEditComposer } = (0, import_react4.useContext)(MessageContext) ?? {};
|
81
81
|
return (0, import_react4.useMemo)(
|
82
82
|
() => ({
|
83
83
|
useComposer: useEditComposer ?? useComposer,
|
@@ -87,7 +87,7 @@ var useComposerContext = () => {
|
|
87
87
|
);
|
88
88
|
};
|
89
89
|
|
90
|
-
// src/context/ContentPartContext.ts
|
90
|
+
// src/context/react/ContentPartContext.ts
|
91
91
|
var import_react5 = require("react");
|
92
92
|
var ContentPartContext = (0, import_react5.createContext)(
|
93
93
|
null
|
package/dist/experimental.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/experimental.ts","../src/context/AssistantContext.ts","../src/context/ThreadContext.ts","../src/context/ComposerContext.ts","../src/context/MessageContext.ts","../src/context/ContentPartContext.ts","../src/model-config/useAssistantInstructions.tsx","../src/model-config/useAssistantTool.tsx","../src/model-config/useAssistantToolUI.tsx","../src/model-config/makeAssistantTool.tsx","../src/model-config/makeAssistantToolUI.tsx"],"sourcesContent":["export type {\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n} from \"./utils/AssistantTypes\";\n\nexport type {\n ModelConfigProvider,\n ModelConfig,\n} from \"./utils/ModelConfigTypes\";\n\nexport type {\n TextContentPartProps,\n TextContentPartComponent,\n ImageContentPartProps,\n ImageContentPartComponent,\n UIContentPartProps,\n UIContentPartComponent,\n ToolCallContentPartProps,\n ToolCallContentPartComponent,\n} from \"./primitives/message/ContentPartComponentTypes\";\n\nexport * from \"./context\";\nexport { useAssistantInstructions } from \"./model-config/useAssistantInstructions\";\nexport {\n useAssistantTool,\n type AssistantToolProps,\n} from \"./model-config/useAssistantTool\";\nexport {\n useAssistantToolUI,\n type AssistantToolUIProps,\n} from \"./model-config/useAssistantToolUI\";\nexport { makeAssistantTool } from \"./model-config/makeAssistantTool\";\nexport { makeAssistantToolUI } from \"./model-config/makeAssistantToolUI\";\n","import { createContext, useContext } from \"react\";\nimport type { AssistantModelConfigState } from \"./stores/AssistantModelConfig\";\nimport type { AssistantToolUIsState } from \"./stores/AssistantToolUIs\";\nimport { ReadonlyStore } from \"./ReadonlyStore\";\n\nexport type AssistantContextValue = {\n useModelConfig: ReadonlyStore<AssistantModelConfigState>;\n useToolUIs: ReadonlyStore<AssistantToolUIsState>;\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","import { createContext, useContext } from \"react\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { ThreadState } from \"./stores/Thread\";\nimport type { ThreadViewportState } from \"./stores/ThreadViewport\";\nimport { ThreadActionsState } from \"./stores/ThreadActions\";\nimport { ReadonlyStore } from \"./ReadonlyStore\";\n\nexport type ThreadContextValue = {\n useThread: ReadonlyStore<ThreadState>;\n useThreadActions: ReadonlyStore<ThreadActionsState>;\n useComposer: ReadonlyStore<ComposerState>;\n useViewport: ReadonlyStore<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(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n};\n","import { useContext, useMemo } from \"react\";\nimport { MessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\nimport { ReadonlyStore } from \"./ReadonlyStore\";\n\nexport type ComposerContextValue = {\n useComposer: ReadonlyStore<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 ReadonlyStore<\n 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 { MessageState } from \"./stores/Message\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\nimport { ReadonlyStore } from \"./ReadonlyStore\";\nimport { MessageUtilsState } from \"./stores/MessageUtils\";\n\nexport type MessageContextValue = {\n useMessage: ReadonlyStore<MessageState>;\n useMessageUtils: ReadonlyStore<MessageUtilsState>;\n useComposer: ReadonlyStore<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 { ContentPartState } from \"./stores/ContentPart\";\nimport { ReadonlyStore } from \"./ReadonlyStore\";\n\nexport type ContentPartContextValue = {\n useContentPart: ReadonlyStore<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","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\n\nexport const useAssistantInstructions = (instruction: string) => {\n const { useModelConfig } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(() => {\n const config = {\n system: instruction,\n };\n return registerModelConfigProvider(() => config);\n }, [registerModelConfigProvider, instruction]);\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../primitives/message/ContentPartComponentTypes\";\nimport type { Tool } from \"../utils/ModelConfigTypes\";\n\nexport type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {\n toolName: string;\n render?: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const { useModelConfig, useToolUIs } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n const { toolName, render, ...rest } = tool;\n const config = {\n tools: {\n [tool.toolName]: rest,\n },\n };\n const unsub1 = registerModelConfigProvider(() => config);\n const unsub2 = render ? setToolUI(toolName, render) : undefined;\n return () => {\n unsub1();\n unsub2?.();\n };\n }, [registerModelConfigProvider, setToolUI, tool]);\n};\n","\"use client\";\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../primitives/message/ContentPartComponentTypes\";\n\nexport type AssistantToolUIProps<TArgs, TResult> = {\n toolName: string;\n render: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantToolUI = (\n tool: AssistantToolUIProps<any, any> | null,\n) => {\n const { useToolUIs } = useAssistantContext();\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n if (!tool) return;\n const { toolName, render } = tool;\n return setToolUI(toolName, render);\n }, [setToolUI, tool]);\n};\n","\"use client\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\n\nexport const makeAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const Tool = () => {\n useAssistantTool(tool);\n return null;\n };\n return Tool;\n};\n","\"use client\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\n\nexport const makeAssistantToolUI = <TArgs, TResult>(\n tool: AssistantToolUIProps<TArgs, TResult>,\n) => {\n const ToolUI = () => {\n useAssistantToolUI(tool);\n return null;\n };\n return ToolUI;\n};\n"],"mappings":"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","names":["import_react","import_react","import_react","import_react","import_react","import_react","import_react"]}
|
1
|
+
{"version":3,"sources":["../src/experimental.ts","../src/context/react/AssistantContext.ts","../src/context/react/ThreadContext.ts","../src/context/react/ComposerContext.ts","../src/context/react/MessageContext.ts","../src/context/react/ContentPartContext.ts","../src/model-config/useAssistantInstructions.tsx","../src/model-config/useAssistantTool.tsx","../src/model-config/useAssistantToolUI.tsx","../src/model-config/makeAssistantTool.tsx","../src/model-config/makeAssistantToolUI.tsx"],"sourcesContent":["export type {\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n} from \"./utils/AssistantTypes\";\n\nexport type {\n ModelConfigProvider,\n ModelConfig,\n} from \"./utils/ModelConfigTypes\";\n\nexport type {\n TextContentPartProps,\n TextContentPartComponent,\n ImageContentPartProps,\n ImageContentPartComponent,\n UIContentPartProps,\n UIContentPartComponent,\n ToolCallContentPartProps,\n ToolCallContentPartComponent,\n} from \"./primitives/message/ContentPartComponentTypes\";\n\nexport * from \"./context\";\nexport { useAssistantInstructions } from \"./model-config/useAssistantInstructions\";\nexport {\n useAssistantTool,\n type AssistantToolProps,\n} from \"./model-config/useAssistantTool\";\nexport {\n useAssistantToolUI,\n type AssistantToolUIProps,\n} from \"./model-config/useAssistantToolUI\";\nexport { makeAssistantTool } from \"./model-config/makeAssistantTool\";\nexport { makeAssistantToolUI } from \"./model-config/makeAssistantToolUI\";\n","import { createContext, useContext } from \"react\";\nimport type { AssistantModelConfigState } from \"../stores/AssistantModelConfig\";\nimport type { AssistantToolUIsState } from \"../stores/AssistantToolUIs\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type AssistantContextValue = {\n useModelConfig: ReadonlyStore<AssistantModelConfigState>;\n useToolUIs: ReadonlyStore<AssistantToolUIsState>;\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","import { createContext, useContext } from \"react\";\nimport type { ComposerState } from \"../stores/Composer\";\nimport type { ThreadState } from \"../stores/Thread\";\nimport type { ThreadViewportState } from \"../stores/ThreadViewport\";\nimport { ThreadActionsState } from \"../stores/ThreadActions\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ThreadContextValue = {\n useThread: ReadonlyStore<ThreadState>;\n useThreadActions: ReadonlyStore<ThreadActionsState>;\n useComposer: ReadonlyStore<ComposerState>;\n useViewport: ReadonlyStore<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(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n};\n","import { useContext, useMemo } from \"react\";\nimport { MessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"../stores/Composer\";\nimport type { EditComposerState } from \"../stores/EditComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ComposerContextValue = {\n useComposer: ReadonlyStore<EditComposerState | ComposerState>;\n type: \"edit\" | \"new\";\n};\n\nexport const useComposerContext = (): ComposerContextValue => {\n const { useComposer } = useThreadContext();\n const { useEditComposer } = useContext(MessageContext) ?? {};\n return useMemo(\n () => ({\n useComposer: (useEditComposer ?? useComposer) as ReadonlyStore<\n 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 { MessageState } from \"../stores/Message\";\nimport type { EditComposerState } from \"../stores/EditComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { MessageUtilsState } from \"../stores/MessageUtils\";\n\nexport type MessageContextValue = {\n useMessage: ReadonlyStore<MessageState>;\n useMessageUtils: ReadonlyStore<MessageUtilsState>;\n useEditComposer: ReadonlyStore<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 { ContentPartState } from \"../stores/ContentPart\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ContentPartContextValue = {\n useContentPart: ReadonlyStore<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","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\n\nexport const useAssistantInstructions = (instruction: string) => {\n const { useModelConfig } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(() => {\n const config = {\n system: instruction,\n };\n return registerModelConfigProvider(() => config);\n }, [registerModelConfigProvider, instruction]);\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../primitives/message/ContentPartComponentTypes\";\nimport type { Tool } from \"../utils/ModelConfigTypes\";\n\nexport type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {\n toolName: string;\n render?: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const { useModelConfig, useToolUIs } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n const { toolName, render, ...rest } = tool;\n const config = {\n tools: {\n [tool.toolName]: rest,\n },\n };\n const unsub1 = registerModelConfigProvider(() => config);\n const unsub2 = render ? setToolUI(toolName, render) : undefined;\n return () => {\n unsub1();\n unsub2?.();\n };\n }, [registerModelConfigProvider, setToolUI, tool]);\n};\n","\"use client\";\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../primitives/message/ContentPartComponentTypes\";\n\nexport type AssistantToolUIProps<TArgs, TResult> = {\n toolName: string;\n render: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantToolUI = (\n tool: AssistantToolUIProps<any, any> | null,\n) => {\n const { useToolUIs } = useAssistantContext();\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n if (!tool) return;\n const { toolName, render } = tool;\n return setToolUI(toolName, render);\n }, [setToolUI, tool]);\n};\n","\"use client\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\n\nexport const makeAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const Tool = () => {\n useAssistantTool(tool);\n return null;\n };\n return Tool;\n};\n","\"use client\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\n\nexport const makeAssistantToolUI = <TArgs, TResult>(\n tool: AssistantToolUIProps<TArgs, TResult>,\n) => {\n const ToolUI = () => {\n useAssistantToolUI(tool);\n return null;\n };\n return ToolUI;\n};\n"],"mappings":"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","names":["import_react","import_react","import_react","import_react","import_react","import_react","import_react"]}
|
package/dist/experimental.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/model-config/useAssistantInstructions.tsx","../src/model-config/useAssistantTool.tsx","../src/model-config/useAssistantToolUI.tsx","../src/model-config/makeAssistantTool.tsx","../src/model-config/makeAssistantToolUI.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 registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(() => {\n const config = {\n system: instruction,\n };\n return registerModelConfigProvider(() => config);\n }, [registerModelConfigProvider, instruction]);\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../primitives/message/ContentPartComponentTypes\";\nimport type { Tool } from \"../utils/ModelConfigTypes\";\n\nexport type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {\n toolName: string;\n render?: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const { useModelConfig, useToolUIs } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n const { toolName, render, ...rest } = tool;\n const config = {\n tools: {\n [tool.toolName]: rest,\n },\n };\n const unsub1 = registerModelConfigProvider(() => config);\n const unsub2 = render ? setToolUI(toolName, render) : undefined;\n return () => {\n unsub1();\n unsub2?.();\n };\n }, [registerModelConfigProvider, setToolUI, tool]);\n};\n","\"use client\";\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../primitives/message/ContentPartComponentTypes\";\n\nexport type AssistantToolUIProps<TArgs, TResult> = {\n toolName: string;\n render: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantToolUI = (\n tool: AssistantToolUIProps<any, any> | null,\n) => {\n const { useToolUIs } = useAssistantContext();\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n if (!tool) return;\n const { toolName, render } = tool;\n return setToolUI(toolName, render);\n }, [setToolUI, tool]);\n};\n","\"use client\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\n\nexport const makeAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const Tool = () => {\n useAssistantTool(tool);\n return null;\n };\n return Tool;\n};\n","\"use client\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\n\nexport const makeAssistantToolUI = <TArgs, TResult>(\n tool: AssistantToolUIProps<TArgs, TResult>,\n) => {\n const ToolUI = () => {\n useAssistantToolUI(tool);\n return null;\n };\n return ToolUI;\n};\n"],"mappings":";;;;;;;;;AAEA,SAAS,iBAAiB;AAGnB,IAAM,2BAA2B,CAAC,gBAAwB;AAC/D,QAAM,EAAE,eAAe,IAAI,oBAAoB;AAC/C,QAAM,8BAA8B;AAAA,IAClC,CAAC,MAAM,EAAE;AAAA,EACX;AACA,YAAU,MAAM;AACd,UAAM,SAAS;AAAA,MACb,QAAQ;AAAA,IACV;AACA,WAAO,4BAA4B,MAAM,MAAM;AAAA,EACjD,GAAG,CAAC,6BAA6B,WAAW,CAAC;AAC/C;;;ACdA,SAAS,aAAAA,kBAAiB;AAUnB,IAAM,mBAAmB,CAC9B,SACG;AACH,QAAM,EAAE,gBAAgB,WAAW,IAAI,oBAAoB;AAC3D,QAAM,8BAA8B;AAAA,IAClC,CAAC,MAAM,EAAE;AAAA,EACX;AACA,QAAM,YAAY,WAAW,CAAC,MAAM,EAAE,SAAS;AAC/C,EAAAC,WAAU,MAAM;AACd,UAAM,EAAE,UAAU,QAAQ,GAAG,KAAK,IAAI;AACtC,UAAM,SAAS;AAAA,MACb,OAAO;AAAA,QACL,CAAC,KAAK,QAAQ,GAAG;AAAA,MACnB;AAAA,IACF;AACA,UAAM,SAAS,4BAA4B,MAAM,MAAM;AACvD,UAAM,SAAS,SAAS,UAAU,UAAU,MAAM,IAAI;AACtD,WAAO,MAAM;AACX,aAAO;AACP,eAAS;AAAA,IACX;AAAA,EACF,GAAG,CAAC,6BAA6B,WAAW,IAAI,CAAC;AACnD;;;ACjCA,SAAS,aAAAC,kBAAiB;AASnB,IAAM,qBAAqB,CAChC,SACG;AACH,QAAM,EAAE,WAAW,IAAI,oBAAoB;AAC3C,QAAM,YAAY,WAAW,CAAC,MAAM,EAAE,SAAS;AAC/C,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,UAAM,EAAE,UAAU,OAAO,IAAI;AAC7B,WAAO,UAAU,UAAU,MAAM;AAAA,EACnC,GAAG,CAAC,WAAW,IAAI,CAAC;AACtB;;;ACjBO,IAAM,oBAAoB,CAC/B,SACG;AACH,QAAM,OAAO,MAAM;AACjB,qBAAiB,IAAI;AACrB,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;ACLO,IAAM,sBAAsB,CACjC,SACG;AACH,QAAM,SAAS,MAAM;AACnB,uBAAmB,IAAI;AACvB,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":["useEffect","useEffect","useEffect","useEffect"]}
|
1
|
+
{"version":3,"sources":["../src/model-config/useAssistantInstructions.tsx","../src/model-config/useAssistantTool.tsx","../src/model-config/useAssistantToolUI.tsx","../src/model-config/makeAssistantTool.tsx","../src/model-config/makeAssistantToolUI.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\n\nexport const useAssistantInstructions = (instruction: string) => {\n const { useModelConfig } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(() => {\n const config = {\n system: instruction,\n };\n return registerModelConfigProvider(() => config);\n }, [registerModelConfigProvider, instruction]);\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../primitives/message/ContentPartComponentTypes\";\nimport type { Tool } from \"../utils/ModelConfigTypes\";\n\nexport type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {\n toolName: string;\n render?: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const { useModelConfig, useToolUIs } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n const { toolName, render, ...rest } = tool;\n const config = {\n tools: {\n [tool.toolName]: rest,\n },\n };\n const unsub1 = registerModelConfigProvider(() => config);\n const unsub2 = render ? setToolUI(toolName, render) : undefined;\n return () => {\n unsub1();\n unsub2?.();\n };\n }, [registerModelConfigProvider, setToolUI, tool]);\n};\n","\"use client\";\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../primitives/message/ContentPartComponentTypes\";\n\nexport type AssistantToolUIProps<TArgs, TResult> = {\n toolName: string;\n render: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantToolUI = (\n tool: AssistantToolUIProps<any, any> | null,\n) => {\n const { useToolUIs } = useAssistantContext();\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n if (!tool) return;\n const { toolName, render } = tool;\n return setToolUI(toolName, render);\n }, [setToolUI, tool]);\n};\n","\"use client\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\n\nexport const makeAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const Tool = () => {\n useAssistantTool(tool);\n return null;\n };\n return Tool;\n};\n","\"use client\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\n\nexport const makeAssistantToolUI = <TArgs, TResult>(\n tool: AssistantToolUIProps<TArgs, TResult>,\n) => {\n const ToolUI = () => {\n useAssistantToolUI(tool);\n return null;\n };\n return ToolUI;\n};\n"],"mappings":";;;;;;;;;AAEA,SAAS,iBAAiB;AAGnB,IAAM,2BAA2B,CAAC,gBAAwB;AAC/D,QAAM,EAAE,eAAe,IAAI,oBAAoB;AAC/C,QAAM,8BAA8B;AAAA,IAClC,CAAC,MAAM,EAAE;AAAA,EACX;AACA,YAAU,MAAM;AACd,UAAM,SAAS;AAAA,MACb,QAAQ;AAAA,IACV;AACA,WAAO,4BAA4B,MAAM,MAAM;AAAA,EACjD,GAAG,CAAC,6BAA6B,WAAW,CAAC;AAC/C;;;ACdA,SAAS,aAAAA,kBAAiB;AAUnB,IAAM,mBAAmB,CAC9B,SACG;AACH,QAAM,EAAE,gBAAgB,WAAW,IAAI,oBAAoB;AAC3D,QAAM,8BAA8B;AAAA,IAClC,CAAC,MAAM,EAAE;AAAA,EACX;AACA,QAAM,YAAY,WAAW,CAAC,MAAM,EAAE,SAAS;AAC/C,EAAAC,WAAU,MAAM;AACd,UAAM,EAAE,UAAU,QAAQ,GAAG,KAAK,IAAI;AACtC,UAAM,SAAS;AAAA,MACb,OAAO;AAAA,QACL,CAAC,KAAK,QAAQ,GAAG;AAAA,MACnB;AAAA,IACF;AACA,UAAM,SAAS,4BAA4B,MAAM,MAAM;AACvD,UAAM,SAAS,SAAS,UAAU,UAAU,MAAM,IAAI;AACtD,WAAO,MAAM;AACX,aAAO;AACP,eAAS;AAAA,IACX;AAAA,EACF,GAAG,CAAC,6BAA6B,WAAW,IAAI,CAAC;AACnD;;;ACjCA,SAAS,aAAAC,kBAAiB;AASnB,IAAM,qBAAqB,CAChC,SACG;AACH,QAAM,EAAE,WAAW,IAAI,oBAAoB;AAC3C,QAAM,YAAY,WAAW,CAAC,MAAM,EAAE,SAAS;AAC/C,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,UAAM,EAAE,UAAU,OAAO,IAAI;AAC7B,WAAO,UAAU,UAAU,MAAM;AAAA,EACnC,GAAG,CAAC,WAAW,IAAI,CAAC;AACtB;;;ACjBO,IAAM,oBAAoB,CAC/B,SACG;AACH,QAAM,OAAO,MAAM;AACjB,qBAAiB,IAAI;AACrB,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;ACLO,IAAM,sBAAsB,CACjC,SACG;AACH,QAAM,SAAS,MAAM;AACnB,uBAAmB,IAAI;AACvB,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":["useEffect","useEffect","useEffect","useEffect"]}
|
package/dist/index.d.mts
CHANGED
@@ -6,17 +6,72 @@ export { l as AppendContentPart, i as AssistantMessage, m as TextContentPart, k
|
|
6
6
|
import { Primitive } from '@radix-ui/react-primitive';
|
7
7
|
import 'zod';
|
8
8
|
|
9
|
-
|
10
|
-
copiedDuration?: number
|
11
|
-
}
|
9
|
+
type UseActionBarCopyProps = {
|
10
|
+
copiedDuration?: number;
|
11
|
+
};
|
12
|
+
declare const useActionBarCopy: ({ copiedDuration, }?: UseActionBarCopyProps) => (() => void) | null;
|
13
|
+
|
14
|
+
declare const useActionBarEdit: () => (() => void) | null;
|
15
|
+
|
16
|
+
declare const useActionBarReload: () => (() => void) | null;
|
17
|
+
|
18
|
+
declare const useBranchPickerCount: () => number;
|
19
|
+
|
20
|
+
declare const useBranchPickerNext: () => (() => void) | null;
|
21
|
+
|
22
|
+
declare const useBranchPickerNumber: () => number;
|
23
|
+
|
24
|
+
declare const useBranchPickerPrevious: () => (() => void) | null;
|
25
|
+
|
26
|
+
declare const useComposerCancel: () => (() => void) | null;
|
27
|
+
|
28
|
+
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
29
|
+
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
30
|
+
}[Keys];
|
31
|
+
|
32
|
+
type ComposerIfFilters = {
|
33
|
+
editing: boolean | undefined;
|
34
|
+
};
|
35
|
+
type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;
|
36
|
+
declare const useComposerIf: (props: UseComposerIfProps) => boolean;
|
12
37
|
|
13
|
-
declare const
|
38
|
+
declare const useComposerSend: () => (() => void) | null;
|
14
39
|
|
15
|
-
declare const
|
40
|
+
declare const useContentPartDisplay: () => react.ReactNode;
|
41
|
+
|
42
|
+
declare const useContentPartImage: () => string;
|
43
|
+
|
44
|
+
declare const useContentPartInProgressIndicator: () => react.ReactNode;
|
45
|
+
|
46
|
+
declare const useContentPartText: () => string;
|
47
|
+
|
48
|
+
type MessageIfFilters = {
|
49
|
+
user: boolean | undefined;
|
50
|
+
assistant: boolean | undefined;
|
51
|
+
hasBranches: boolean | undefined;
|
52
|
+
copied: boolean | undefined;
|
53
|
+
lastOrHover: boolean | undefined;
|
54
|
+
};
|
55
|
+
type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;
|
56
|
+
declare const useMessageIf: (props: UseMessageIfProps) => boolean;
|
57
|
+
|
58
|
+
declare const useThreadEmpty: () => boolean;
|
59
|
+
|
60
|
+
type ThreadIfFilters = {
|
61
|
+
empty: boolean | undefined;
|
62
|
+
running: boolean | undefined;
|
63
|
+
};
|
64
|
+
type UseThreadIfProps = RequireAtLeastOne<ThreadIfFilters>;
|
65
|
+
declare const useThreadIf: (props: UseThreadIfProps) => boolean;
|
16
66
|
|
17
|
-
declare const
|
67
|
+
declare const useThreadScrollToBottom: () => (() => void) | null;
|
18
68
|
|
19
|
-
|
69
|
+
type UseApplyThreadSuggestionProps = {
|
70
|
+
prompt: string;
|
71
|
+
method: "replace";
|
72
|
+
autoSend?: boolean;
|
73
|
+
};
|
74
|
+
declare const useThreadSuggestion: ({ prompt, autoSend, }: UseApplyThreadSuggestionProps) => (() => void) | null;
|
20
75
|
|
21
76
|
declare const ThreadRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
22
77
|
ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
|
@@ -29,15 +84,7 @@ type ThreadEmptyProps = {
|
|
29
84
|
};
|
30
85
|
declare const ThreadEmpty: FC<ThreadEmptyProps>;
|
31
86
|
|
32
|
-
type
|
33
|
-
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
34
|
-
}[Keys];
|
35
|
-
|
36
|
-
type ThreadIfFilters = {
|
37
|
-
empty: boolean | undefined;
|
38
|
-
running: boolean | undefined;
|
39
|
-
};
|
40
|
-
type ThreadIfProps = PropsWithChildren<RequireAtLeastOne<ThreadIfFilters>>;
|
87
|
+
type ThreadIfProps = PropsWithChildren<UseThreadIfProps>;
|
41
88
|
declare const ThreadIf: FC<ThreadIfProps>;
|
42
89
|
|
43
90
|
declare const ThreadViewport: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
@@ -105,10 +152,7 @@ declare const ComposerCancel: react.ForwardRefExoticComponent<Omit<Omit<react.De
|
|
105
152
|
asChild?: boolean;
|
106
153
|
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
107
154
|
|
108
|
-
type
|
109
|
-
editing: boolean | undefined;
|
110
|
-
};
|
111
|
-
type ComposerIfProps = PropsWithChildren<RequireAtLeastOne<ComposerIfFilters>>;
|
155
|
+
type ComposerIfProps = PropsWithChildren<UseComposerIfProps>;
|
112
156
|
declare const ComposerIf: FC<ComposerIfProps>;
|
113
157
|
|
114
158
|
declare namespace index$4 {
|
@@ -121,16 +165,7 @@ declare const MessageRoot: react.ForwardRefExoticComponent<Omit<Omit<react.Detai
|
|
121
165
|
asChild?: boolean;
|
122
166
|
}, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
123
167
|
|
124
|
-
type
|
125
|
-
user: boolean | undefined;
|
126
|
-
assistant: boolean | undefined;
|
127
|
-
hasBranches: boolean | undefined;
|
128
|
-
copied: boolean | undefined;
|
129
|
-
lastOrHover: boolean | undefined;
|
130
|
-
};
|
131
|
-
type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
|
132
|
-
children: ReactNode;
|
133
|
-
};
|
168
|
+
type MessageIfProps = PropsWithChildren<UseMessageIfProps>;
|
134
169
|
declare const MessageIf: FC<MessageIfProps>;
|
135
170
|
|
136
171
|
type MessageContentProps = {
|
@@ -184,24 +219,24 @@ declare namespace index$2 {
|
|
184
219
|
export { BranchPickerCount as Count, BranchPickerNext as Next, BranchPickerNumber as Number, BranchPickerPrevious as Previous, BranchPickerRoot as Root };
|
185
220
|
}
|
186
221
|
|
222
|
+
type UseActionBarFloatStatusProps = {
|
223
|
+
hideWhenRunning?: boolean | undefined;
|
224
|
+
autohide?: "always" | "not-last" | "never" | undefined;
|
225
|
+
autohideFloat?: "always" | "single-branch" | "never" | undefined;
|
226
|
+
};
|
187
227
|
declare const ActionBarRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
188
228
|
ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
|
189
229
|
} & {
|
190
230
|
asChild?: boolean;
|
191
|
-
}, "ref"> &
|
192
|
-
hideWhenRunning?: boolean;
|
193
|
-
autohide?: "always" | "not-last" | "never";
|
194
|
-
autohideFloat?: "always" | "single-branch" | "never";
|
195
|
-
} & react.RefAttributes<HTMLDivElement>>;
|
231
|
+
}, "ref"> & UseActionBarFloatStatusProps & react.RefAttributes<HTMLDivElement>>;
|
196
232
|
|
197
|
-
type ActionBarCopyProps = {
|
198
|
-
copiedDuration?: number;
|
199
|
-
};
|
200
233
|
declare const ActionBarCopy: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
201
234
|
ref?: ((instance: HTMLButtonElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLButtonElement> | null | undefined;
|
202
235
|
} & {
|
203
236
|
asChild?: boolean;
|
204
|
-
}, "ref"> &
|
237
|
+
}, "ref"> & {
|
238
|
+
copiedDuration?: number;
|
239
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
205
240
|
|
206
241
|
declare const ActionBarReload: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
207
242
|
ref?: ((instance: HTMLButtonElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLButtonElement> | null | undefined;
|
@@ -317,4 +352,4 @@ declare namespace internal {
|
|
317
352
|
export { internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
|
318
353
|
}
|
319
354
|
|
320
|
-
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, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe,
|
355
|
+
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, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useActionBarCopy, useActionBarEdit, useActionBarReload, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerIf, useComposerSend, useContentPartDisplay, useContentPartImage, useContentPartInProgressIndicator, useContentPartText, useLocalRuntime, useMessageIf, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
|
package/dist/index.d.ts
CHANGED
@@ -6,17 +6,72 @@ export { l as AppendContentPart, i as AssistantMessage, m as TextContentPart, k
|
|
6
6
|
import { Primitive } from '@radix-ui/react-primitive';
|
7
7
|
import 'zod';
|
8
8
|
|
9
|
-
|
10
|
-
copiedDuration?: number
|
11
|
-
}
|
9
|
+
type UseActionBarCopyProps = {
|
10
|
+
copiedDuration?: number;
|
11
|
+
};
|
12
|
+
declare const useActionBarCopy: ({ copiedDuration, }?: UseActionBarCopyProps) => (() => void) | null;
|
13
|
+
|
14
|
+
declare const useActionBarEdit: () => (() => void) | null;
|
15
|
+
|
16
|
+
declare const useActionBarReload: () => (() => void) | null;
|
17
|
+
|
18
|
+
declare const useBranchPickerCount: () => number;
|
19
|
+
|
20
|
+
declare const useBranchPickerNext: () => (() => void) | null;
|
21
|
+
|
22
|
+
declare const useBranchPickerNumber: () => number;
|
23
|
+
|
24
|
+
declare const useBranchPickerPrevious: () => (() => void) | null;
|
25
|
+
|
26
|
+
declare const useComposerCancel: () => (() => void) | null;
|
27
|
+
|
28
|
+
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
29
|
+
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
30
|
+
}[Keys];
|
31
|
+
|
32
|
+
type ComposerIfFilters = {
|
33
|
+
editing: boolean | undefined;
|
34
|
+
};
|
35
|
+
type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;
|
36
|
+
declare const useComposerIf: (props: UseComposerIfProps) => boolean;
|
12
37
|
|
13
|
-
declare const
|
38
|
+
declare const useComposerSend: () => (() => void) | null;
|
14
39
|
|
15
|
-
declare const
|
40
|
+
declare const useContentPartDisplay: () => react.ReactNode;
|
41
|
+
|
42
|
+
declare const useContentPartImage: () => string;
|
43
|
+
|
44
|
+
declare const useContentPartInProgressIndicator: () => react.ReactNode;
|
45
|
+
|
46
|
+
declare const useContentPartText: () => string;
|
47
|
+
|
48
|
+
type MessageIfFilters = {
|
49
|
+
user: boolean | undefined;
|
50
|
+
assistant: boolean | undefined;
|
51
|
+
hasBranches: boolean | undefined;
|
52
|
+
copied: boolean | undefined;
|
53
|
+
lastOrHover: boolean | undefined;
|
54
|
+
};
|
55
|
+
type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;
|
56
|
+
declare const useMessageIf: (props: UseMessageIfProps) => boolean;
|
57
|
+
|
58
|
+
declare const useThreadEmpty: () => boolean;
|
59
|
+
|
60
|
+
type ThreadIfFilters = {
|
61
|
+
empty: boolean | undefined;
|
62
|
+
running: boolean | undefined;
|
63
|
+
};
|
64
|
+
type UseThreadIfProps = RequireAtLeastOne<ThreadIfFilters>;
|
65
|
+
declare const useThreadIf: (props: UseThreadIfProps) => boolean;
|
16
66
|
|
17
|
-
declare const
|
67
|
+
declare const useThreadScrollToBottom: () => (() => void) | null;
|
18
68
|
|
19
|
-
|
69
|
+
type UseApplyThreadSuggestionProps = {
|
70
|
+
prompt: string;
|
71
|
+
method: "replace";
|
72
|
+
autoSend?: boolean;
|
73
|
+
};
|
74
|
+
declare const useThreadSuggestion: ({ prompt, autoSend, }: UseApplyThreadSuggestionProps) => (() => void) | null;
|
20
75
|
|
21
76
|
declare const ThreadRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
22
77
|
ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
|
@@ -29,15 +84,7 @@ type ThreadEmptyProps = {
|
|
29
84
|
};
|
30
85
|
declare const ThreadEmpty: FC<ThreadEmptyProps>;
|
31
86
|
|
32
|
-
type
|
33
|
-
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
34
|
-
}[Keys];
|
35
|
-
|
36
|
-
type ThreadIfFilters = {
|
37
|
-
empty: boolean | undefined;
|
38
|
-
running: boolean | undefined;
|
39
|
-
};
|
40
|
-
type ThreadIfProps = PropsWithChildren<RequireAtLeastOne<ThreadIfFilters>>;
|
87
|
+
type ThreadIfProps = PropsWithChildren<UseThreadIfProps>;
|
41
88
|
declare const ThreadIf: FC<ThreadIfProps>;
|
42
89
|
|
43
90
|
declare const ThreadViewport: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
@@ -105,10 +152,7 @@ declare const ComposerCancel: react.ForwardRefExoticComponent<Omit<Omit<react.De
|
|
105
152
|
asChild?: boolean;
|
106
153
|
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
107
154
|
|
108
|
-
type
|
109
|
-
editing: boolean | undefined;
|
110
|
-
};
|
111
|
-
type ComposerIfProps = PropsWithChildren<RequireAtLeastOne<ComposerIfFilters>>;
|
155
|
+
type ComposerIfProps = PropsWithChildren<UseComposerIfProps>;
|
112
156
|
declare const ComposerIf: FC<ComposerIfProps>;
|
113
157
|
|
114
158
|
declare namespace index$4 {
|
@@ -121,16 +165,7 @@ declare const MessageRoot: react.ForwardRefExoticComponent<Omit<Omit<react.Detai
|
|
121
165
|
asChild?: boolean;
|
122
166
|
}, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
123
167
|
|
124
|
-
type
|
125
|
-
user: boolean | undefined;
|
126
|
-
assistant: boolean | undefined;
|
127
|
-
hasBranches: boolean | undefined;
|
128
|
-
copied: boolean | undefined;
|
129
|
-
lastOrHover: boolean | undefined;
|
130
|
-
};
|
131
|
-
type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
|
132
|
-
children: ReactNode;
|
133
|
-
};
|
168
|
+
type MessageIfProps = PropsWithChildren<UseMessageIfProps>;
|
134
169
|
declare const MessageIf: FC<MessageIfProps>;
|
135
170
|
|
136
171
|
type MessageContentProps = {
|
@@ -184,24 +219,24 @@ declare namespace index$2 {
|
|
184
219
|
export { BranchPickerCount as Count, BranchPickerNext as Next, BranchPickerNumber as Number, BranchPickerPrevious as Previous, BranchPickerRoot as Root };
|
185
220
|
}
|
186
221
|
|
222
|
+
type UseActionBarFloatStatusProps = {
|
223
|
+
hideWhenRunning?: boolean | undefined;
|
224
|
+
autohide?: "always" | "not-last" | "never" | undefined;
|
225
|
+
autohideFloat?: "always" | "single-branch" | "never" | undefined;
|
226
|
+
};
|
187
227
|
declare const ActionBarRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
188
228
|
ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
|
189
229
|
} & {
|
190
230
|
asChild?: boolean;
|
191
|
-
}, "ref"> &
|
192
|
-
hideWhenRunning?: boolean;
|
193
|
-
autohide?: "always" | "not-last" | "never";
|
194
|
-
autohideFloat?: "always" | "single-branch" | "never";
|
195
|
-
} & react.RefAttributes<HTMLDivElement>>;
|
231
|
+
}, "ref"> & UseActionBarFloatStatusProps & react.RefAttributes<HTMLDivElement>>;
|
196
232
|
|
197
|
-
type ActionBarCopyProps = {
|
198
|
-
copiedDuration?: number;
|
199
|
-
};
|
200
233
|
declare const ActionBarCopy: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
201
234
|
ref?: ((instance: HTMLButtonElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLButtonElement> | null | undefined;
|
202
235
|
} & {
|
203
236
|
asChild?: boolean;
|
204
|
-
}, "ref"> &
|
237
|
+
}, "ref"> & {
|
238
|
+
copiedDuration?: number;
|
239
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
205
240
|
|
206
241
|
declare const ActionBarReload: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
207
242
|
ref?: ((instance: HTMLButtonElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLButtonElement> | null | undefined;
|
@@ -317,4 +352,4 @@ declare namespace internal {
|
|
317
352
|
export { internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
|
318
353
|
}
|
319
354
|
|
320
|
-
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, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe,
|
355
|
+
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, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useActionBarCopy, useActionBarEdit, useActionBarReload, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerIf, useComposerSend, useContentPartDisplay, useContentPartImage, useContentPartInProgressIndicator, useContentPartText, useLocalRuntime, useMessageIf, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
|