@assistant-ui/react 0.12.7 → 0.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/ChainOfThoughtClient.d.ts +15 -0
- package/dist/client/ChainOfThoughtClient.d.ts.map +1 -0
- package/dist/client/ChainOfThoughtClient.js +21 -0
- package/dist/client/ChainOfThoughtClient.js.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.d.ts +6 -0
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -0
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.js +21 -0
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.js.map +1 -0
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.d.ts +5 -0
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -0
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.js +14 -0
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts +28 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts.map +1 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +27 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.d.ts +37 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.js +42 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.d.ts +28 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.d.ts.map +1 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js +25 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js.map +1 -0
- package/dist/primitives/chainOfThought/index.d.ts +4 -0
- package/dist/primitives/chainOfThought/index.d.ts.map +1 -0
- package/dist/primitives/chainOfThought/index.js +4 -0
- package/dist/primitives/chainOfThought/index.js.map +1 -0
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +1 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/message/MessageParts.d.ts +29 -0
- package/dist/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/primitives/message/MessageParts.js +48 -23
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/types/scopes/chainOfThought.d.ts +40 -0
- package/dist/types/scopes/chainOfThought.d.ts.map +1 -0
- package/dist/types/scopes/chainOfThought.js +2 -0
- package/dist/types/scopes/chainOfThought.js.map +1 -0
- package/dist/types/scopes/index.d.ts +1 -0
- package/dist/types/scopes/index.d.ts.map +1 -1
- package/dist/types/scopes/part.d.ts +6 -0
- package/dist/types/scopes/part.d.ts.map +1 -1
- package/dist/types/store-augmentation.d.ts +2 -0
- package/dist/types/store-augmentation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/ChainOfThoughtClient.ts +43 -0
- package/src/client/index.ts +1 -0
- package/src/context/providers/ChainOfThoughtByIndicesProvider.tsx +35 -0
- package/src/context/providers/ChainOfThoughtPartByIndexProvider.tsx +20 -0
- package/src/primitives/chainOfThought/CHAIN_OF_THOUGHT.spec.md +68 -0
- package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx +51 -0
- package/src/primitives/chainOfThought/ChainOfThoughtParts.tsx +79 -0
- package/src/primitives/chainOfThought/ChainOfThoughtRoot.tsx +36 -0
- package/src/primitives/chainOfThought/index.ts +14 -0
- package/src/primitives/index.ts +1 -0
- package/src/primitives/message/MessageParts.tsx +90 -26
- package/src/types/scopes/chainOfThought.ts +42 -0
- package/src/types/scopes/index.ts +7 -0
- package/src/types/scopes/part.ts +11 -6
- package/src/types/store-augmentation.ts +2 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ClientOutput } from "@assistant-ui/store";
|
|
2
|
+
import type { ChainOfThoughtPart } from "../types/scopes/chainOfThought.js";
|
|
3
|
+
import type { PartMethods } from "../types/scopes/part.js";
|
|
4
|
+
export declare const ChainOfThoughtClient: (props: {
|
|
5
|
+
parts: readonly ChainOfThoughtPart[];
|
|
6
|
+
getMessagePart: (selector: {
|
|
7
|
+
index: number;
|
|
8
|
+
}) => PartMethods;
|
|
9
|
+
}) => import("@assistant-ui/tap").ResourceElement<ClientOutput<"chainOfThought">, {
|
|
10
|
+
parts: readonly ChainOfThoughtPart[];
|
|
11
|
+
getMessagePart: (selector: {
|
|
12
|
+
index: number;
|
|
13
|
+
}) => PartMethods;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=ChainOfThoughtClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtClient.d.ts","sourceRoot":"","sources":["../../src/client/ChainOfThoughtClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAEV,kBAAkB,EACnB,0CAAuC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,gCAA6B;AAMxD,eAAO,MAAM,oBAAoB;WAKtB,SAAS,kBAAkB,EAAE;oBACpB,CAAC,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,WAAW;;WADrD,SAAS,kBAAkB,EAAE;oBACpB,CAAC,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,WAAW;EAuB/D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { resource, tapMemo, tapState } from "@assistant-ui/tap";
|
|
2
|
+
const COMPLETE_STATUS = Object.freeze({
|
|
3
|
+
type: "complete",
|
|
4
|
+
});
|
|
5
|
+
export const ChainOfThoughtClient = resource(({ parts, getMessagePart, }) => {
|
|
6
|
+
const [collapsed, setCollapsed] = tapState(true);
|
|
7
|
+
const status = tapMemo(() => {
|
|
8
|
+
const lastPart = parts[parts.length - 1];
|
|
9
|
+
return lastPart?.status ?? COMPLETE_STATUS;
|
|
10
|
+
}, [parts]);
|
|
11
|
+
const state = tapMemo(() => ({ parts, collapsed, status }), [parts, collapsed, status]);
|
|
12
|
+
return {
|
|
13
|
+
state,
|
|
14
|
+
methods: {
|
|
15
|
+
getState: () => state,
|
|
16
|
+
setCollapsed,
|
|
17
|
+
part: getMessagePart,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=ChainOfThoughtClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtClient.js","sourceRoot":"","sources":["../../src/client/ChainOfThoughtClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAShE,MAAM,eAAe,GAAsB,MAAM,CAAC,MAAM,CAAC;IACvD,IAAI,EAAE,UAAU;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAC1C,CAAC,EACC,KAAK,EACL,cAAc,GAIf,EAAkC,EAAE;IACnC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEjD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;QAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzC,OAAO,QAAQ,EAAE,MAAM,IAAI,eAAe,CAAC;IAC7C,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EACpC,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAC3B,CAAC;IAEF,OAAO;QACL,KAAK;QACL,OAAO,EAAE;YACP,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;YACrB,YAAY;YACZ,IAAI,EAAE,cAAc;SACrB;KACF,CAAC;AACJ,CAAC,CACF,CAAC"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { Tools } from "./Tools.js";
|
|
|
3
3
|
export { Suggestions, type SuggestionConfig } from "./Suggestions.js";
|
|
4
4
|
export { ExternalThread, type ExternalThreadProps, type ExternalThreadMessage, } from "./ExternalThread.js";
|
|
5
5
|
export { InMemoryThreadList, type InMemoryThreadListProps, } from "./InMemoryThreadList.js";
|
|
6
|
+
export { ChainOfThoughtClient } from "./ChainOfThoughtClient.js";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,gCAA6B;AAC1E,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,yBAAsB;AACnE,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,GAC3B,4BAAyB;AAC1B,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,gCAA6B"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,gCAA6B;AAC1E,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,yBAAsB;AACnE,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,GAC3B,4BAAyB;AAC1B,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,gCAA6B;AAC9B,OAAO,EAAE,oBAAoB,EAAE,kCAA+B"}
|
package/dist/client/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { Tools } from "./Tools.js";
|
|
|
3
3
|
export { Suggestions } from "./Suggestions.js";
|
|
4
4
|
export { ExternalThread, } from "./ExternalThread.js";
|
|
5
5
|
export { InMemoryThreadList, } from "./InMemoryThreadList.js";
|
|
6
|
+
export { ChainOfThoughtClient } from "./ChainOfThoughtClient.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,gCAA6B;AAC1E,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,WAAW,EAAyB,yBAAsB;AACnE,OAAO,EACL,cAAc,GAGf,4BAAyB;AAC1B,OAAO,EACL,kBAAkB,GAEnB,gCAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,gCAA6B;AAC1E,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,WAAW,EAAyB,yBAAsB;AACnE,OAAO,EACL,cAAc,GAGf,4BAAyB;AAC1B,OAAO,EACL,kBAAkB,GAEnB,gCAA6B;AAC9B,OAAO,EAAE,oBAAoB,EAAE,kCAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtByIndicesProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/ChainOfThoughtByIndicesProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKxD,eAAO,MAAM,+BAA+B,EAAE,EAAE,CAC9C,iBAAiB,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAuBH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useAui, useAuiState, AuiProvider } from "@assistant-ui/store";
|
|
4
|
+
import { ChainOfThoughtClient } from "../../client/ChainOfThoughtClient.js";
|
|
5
|
+
export const ChainOfThoughtByIndicesProvider = ({ startIndex, endIndex, children }) => {
|
|
6
|
+
const parts = useAuiState(({ message }) => message.parts.slice(startIndex, endIndex + 1));
|
|
7
|
+
const parentAui = useAui();
|
|
8
|
+
const aui = useAui({
|
|
9
|
+
chainOfThought: ChainOfThoughtClient({
|
|
10
|
+
parts,
|
|
11
|
+
getMessagePart: ({ index }) => {
|
|
12
|
+
if (index < 0 || index >= parts.length) {
|
|
13
|
+
throw new Error(`ChainOfThought part index ${index} is out of bounds (0..${parts.length - 1})`);
|
|
14
|
+
}
|
|
15
|
+
return parentAui.message().part({ index: startIndex + index });
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
return _jsx(AuiProvider, { value: aui, children: children });
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=ChainOfThoughtByIndicesProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtByIndicesProvider.js","sourceRoot":"","sources":["../../../src/context/providers/ChainOfThoughtByIndicesProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,6CAA0C;AAGzE,MAAM,CAAC,MAAM,+BAA+B,GAKxC,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;IACzC,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CACxC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,GAAG,CAAC,CAAC,CACtB,CAAC;IAE1B,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;IAE3B,MAAM,GAAG,GAAG,MAAM,CAAC;QACjB,cAAc,EAAE,oBAAoB,CAAC;YACnC,KAAK;YACL,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;gBAC5B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;oBACvC,MAAM,IAAI,KAAK,CACb,6BAA6B,KAAK,yBAAyB,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,CAC/E,CAAC;gBACJ,CAAC;gBACD,OAAO,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,CAAC,CAAC;YACjE,CAAC;SACF,CAAC;KACH,CAAC,CAAC;IAEH,OAAO,KAAC,WAAW,IAAC,KAAK,EAAE,GAAG,YAAG,QAAQ,GAAe,CAAC;AAC3D,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtPartByIndexProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/ChainOfThoughtPartByIndexProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGxD,eAAO,MAAM,iCAAiC,EAAE,EAAE,CAChD,iBAAiB,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAWH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
4
|
+
export const ChainOfThoughtPartByIndexProvider = ({ index, children }) => {
|
|
5
|
+
const aui = useAui({
|
|
6
|
+
part: Derived({
|
|
7
|
+
source: "chainOfThought",
|
|
8
|
+
query: { type: "index", index },
|
|
9
|
+
get: (aui) => aui.chainOfThought().part({ index }),
|
|
10
|
+
}),
|
|
11
|
+
});
|
|
12
|
+
return _jsx(AuiProvider, { value: aui, children: children });
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=ChainOfThoughtPartByIndexProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtPartByIndexProvider.js","sourceRoot":"","sources":["../../../src/context/providers/ChainOfThoughtPartByIndexProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnE,MAAM,CAAC,MAAM,iCAAiC,GAI1C,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC1B,MAAM,GAAG,GAAG,MAAM,CAAC;QACjB,IAAI,EAAE,OAAO,CAAC;YACZ,MAAM,EAAE,gBAAgB;YACxB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE;YAC/B,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;SACnD,CAAC;KACH,CAAC,CAAC;IAEH,OAAO,KAAC,WAAW,IAAC,KAAK,EAAE,GAAG,YAAG,QAAQ,GAAe,CAAC;AAC3D,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ActionButtonElement, ActionButtonProps } from "../../utils/createActionButton.js";
|
|
2
|
+
declare const useChainOfThoughtAccordionTrigger: () => () => void;
|
|
3
|
+
export declare namespace ChainOfThoughtPrimitiveAccordionTrigger {
|
|
4
|
+
type Element = ActionButtonElement;
|
|
5
|
+
/**
|
|
6
|
+
* Props for the ChainOfThoughtPrimitive.AccordionTrigger component.
|
|
7
|
+
* Inherits all button element props and action button functionality.
|
|
8
|
+
*/
|
|
9
|
+
type Props = ActionButtonProps<typeof useChainOfThoughtAccordionTrigger>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A button component that toggles the collapsed state of the chain of thought accordion.
|
|
13
|
+
*
|
|
14
|
+
* This component automatically handles the toggle functionality, expanding or collapsing
|
|
15
|
+
* the chain of thought parts when clicked.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <ChainOfThoughtPrimitive.AccordionTrigger>
|
|
20
|
+
* Toggle Reasoning
|
|
21
|
+
* </ChainOfThoughtPrimitive.AccordionTrigger>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const ChainOfThoughtPrimitiveAccordionTrigger: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
25
|
+
asChild?: boolean;
|
|
26
|
+
}, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=ChainOfThoughtAccordionTrigger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtAccordionTrigger.d.ts","sourceRoot":"","sources":["../../../src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;AAIxC,QAAA,MAAM,iCAAiC,kBAWtC,CAAC;AAEF,yBAAiB,uCAAuC,CAAC;IACvD,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CACnC,OAAO,iCAAiC,CACzC,CAAC;CACH;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uCAAuC;;6DAGnD,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createActionButton, } from "../../utils/createActionButton.js";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
5
|
+
const useChainOfThoughtAccordionTrigger = () => {
|
|
6
|
+
const aui = useAui();
|
|
7
|
+
const collapsed = useAuiState(({ chainOfThought }) => chainOfThought.collapsed);
|
|
8
|
+
const callback = useCallback(() => {
|
|
9
|
+
aui.chainOfThought().setCollapsed(!collapsed);
|
|
10
|
+
}, [aui, collapsed]);
|
|
11
|
+
return callback;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A button component that toggles the collapsed state of the chain of thought accordion.
|
|
15
|
+
*
|
|
16
|
+
* This component automatically handles the toggle functionality, expanding or collapsing
|
|
17
|
+
* the chain of thought parts when clicked.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <ChainOfThoughtPrimitive.AccordionTrigger>
|
|
22
|
+
* Toggle Reasoning
|
|
23
|
+
* </ChainOfThoughtPrimitive.AccordionTrigger>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export const ChainOfThoughtPrimitiveAccordionTrigger = createActionButton("ChainOfThoughtPrimitive.AccordionTrigger", useChainOfThoughtAccordionTrigger);
|
|
27
|
+
//# sourceMappingURL=ChainOfThoughtAccordionTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtAccordionTrigger.js","sourceRoot":"","sources":["../../../src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,iCAAiC,GAAG,GAAG,EAAE;IAC7C,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,SAAS,CACjD,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;QAChC,GAAG,CAAC,cAAc,EAAE,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;IAErB,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAaF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,kBAAkB,CACvE,0CAA0C,EAC1C,iCAAiC,CAClC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { ReasoningMessagePartComponent, ToolCallMessagePartComponent } from "../../types/MessagePartComponentTypes.js";
|
|
3
|
+
export declare namespace ChainOfThoughtPrimitiveParts {
|
|
4
|
+
type Props = {
|
|
5
|
+
/**
|
|
6
|
+
* Component configuration for rendering chain of thought parts.
|
|
7
|
+
*/
|
|
8
|
+
components?: {
|
|
9
|
+
/** Component for rendering reasoning parts */
|
|
10
|
+
Reasoning?: ReasoningMessagePartComponent | undefined;
|
|
11
|
+
/** Fallback component for tool-call parts */
|
|
12
|
+
tools?: {
|
|
13
|
+
Fallback?: ToolCallMessagePartComponent | undefined;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Renders the parts within a chain of thought, with support for collapsed/expanded states.
|
|
20
|
+
*
|
|
21
|
+
* When collapsed, no parts are shown. When expanded, all parts are rendered
|
|
22
|
+
* using the provided component configuration through the part scope mechanism.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <ChainOfThoughtPrimitive.Parts
|
|
27
|
+
* components={{
|
|
28
|
+
* Reasoning: ({ text }) => <p className="reasoning">{text}</p>,
|
|
29
|
+
* tools: {
|
|
30
|
+
* Fallback: ({ toolName }) => <div>Tool: {toolName}</div>
|
|
31
|
+
* }
|
|
32
|
+
* }}
|
|
33
|
+
* />
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const ChainOfThoughtPrimitiveParts: FC<ChainOfThoughtPrimitiveParts.Props>;
|
|
37
|
+
//# sourceMappingURL=ChainOfThoughtParts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtParts.d.ts","sourceRoot":"","sources":["../../../src/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAW,MAAM,OAAO,CAAC;AAIzC,OAAO,KAAK,EACV,6BAA6B,EAC7B,4BAA4B,EAC7B,iDAA8C;AAE/C,yBAAiB,4BAA4B,CAAC;IAC5C,KAAY,KAAK,GAAG;QAClB;;WAEG;QACH,UAAU,CAAC,EAAE;YACX,8CAA8C;YAC9C,SAAS,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;YACtD,6CAA6C;YAC7C,KAAK,CAAC,EAAE;gBACN,QAAQ,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;aACrD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,4BAA4B,EAAE,EAAE,CAC3C,4BAA4B,CAAC,KAAK,CA8BnC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
5
|
+
import { ChainOfThoughtPartByIndexProvider } from "../../context/providers/ChainOfThoughtPartByIndexProvider.js";
|
|
6
|
+
import { MessagePartComponent } from "../message/MessageParts.js";
|
|
7
|
+
/**
|
|
8
|
+
* Renders the parts within a chain of thought, with support for collapsed/expanded states.
|
|
9
|
+
*
|
|
10
|
+
* When collapsed, no parts are shown. When expanded, all parts are rendered
|
|
11
|
+
* using the provided component configuration through the part scope mechanism.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <ChainOfThoughtPrimitive.Parts
|
|
16
|
+
* components={{
|
|
17
|
+
* Reasoning: ({ text }) => <p className="reasoning">{text}</p>,
|
|
18
|
+
* tools: {
|
|
19
|
+
* Fallback: ({ toolName }) => <div>Tool: {toolName}</div>
|
|
20
|
+
* }
|
|
21
|
+
* }}
|
|
22
|
+
* />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const ChainOfThoughtPrimitiveParts = ({ components }) => {
|
|
26
|
+
const collapsed = useAuiState(({ chainOfThought }) => chainOfThought.collapsed);
|
|
27
|
+
const partsLength = useAuiState(({ chainOfThought }) => chainOfThought.parts.length);
|
|
28
|
+
const messageComponents = useMemo(() => ({
|
|
29
|
+
Reasoning: components?.Reasoning,
|
|
30
|
+
tools: {
|
|
31
|
+
Fallback: components?.tools?.Fallback,
|
|
32
|
+
},
|
|
33
|
+
}), [components?.Reasoning, components?.tools?.Fallback]);
|
|
34
|
+
const elements = useMemo(() => {
|
|
35
|
+
if (collapsed)
|
|
36
|
+
return null;
|
|
37
|
+
return Array.from({ length: partsLength }, (_, index) => (_jsx(ChainOfThoughtPartByIndexProvider, { index: index, children: _jsx(MessagePartComponent, { components: messageComponents }) }, index)));
|
|
38
|
+
}, [collapsed, partsLength, messageComponents]);
|
|
39
|
+
return _jsx(_Fragment, { children: elements });
|
|
40
|
+
};
|
|
41
|
+
ChainOfThoughtPrimitiveParts.displayName = "ChainOfThoughtPrimitive.Parts";
|
|
42
|
+
//# sourceMappingURL=ChainOfThoughtParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtParts.js","sourceRoot":"","sources":["../../../src/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAW,OAAO,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iCAAiC,EAAE,qEAAkE;AAC9G,OAAO,EAAE,oBAAoB,EAAE,mCAAgC;AAsB/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAErC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;IACrB,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,SAAS,CACjD,CAAC;IACF,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CACpD,CAAC;IAEF,MAAM,iBAAiB,GAAG,OAAO,CAC/B,GAAG,EAAE,CAAC,CAAC;QACL,SAAS,EAAE,UAAU,EAAE,SAAS;QAChC,KAAK,EAAE;YACL,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ;SACtC;KACF,CAAC,EACF,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CACrD,CAAC;IAEF,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,IAAI,SAAS;YAAE,OAAO,IAAI,CAAC;QAE3B,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CACvD,KAAC,iCAAiC,IAAa,KAAK,EAAE,KAAK,YACzD,KAAC,oBAAoB,IAAC,UAAU,EAAE,iBAAiB,GAAI,IADjB,KAAK,CAET,CACrC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEhD,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC,CAAC;AAEF,4BAA4B,CAAC,WAAW,GAAG,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
2
|
+
import { type ComponentRef, ComponentPropsWithoutRef } from "react";
|
|
3
|
+
type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
4
|
+
export declare namespace ChainOfThoughtPrimitiveRoot {
|
|
5
|
+
type Element = ComponentRef<typeof Primitive.div>;
|
|
6
|
+
type Props = PrimitiveDivProps;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The root container for chain of thought components.
|
|
10
|
+
*
|
|
11
|
+
* This component provides a wrapper for chain of thought content,
|
|
12
|
+
* including reasoning and tool-call parts that can be collapsed in an accordion.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <ChainOfThoughtPrimitive.Root>
|
|
17
|
+
* <ChainOfThoughtPrimitive.AccordionTrigger>
|
|
18
|
+
* Toggle reasoning
|
|
19
|
+
* </ChainOfThoughtPrimitive.AccordionTrigger>
|
|
20
|
+
* <ChainOfThoughtPrimitive.Parts />
|
|
21
|
+
* </ChainOfThoughtPrimitive.Root>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const ChainOfThoughtPrimitiveRoot: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
25
|
+
asChild?: boolean;
|
|
26
|
+
}, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=ChainOfThoughtRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/chainOfThought/ChainOfThoughtRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,KAAK,YAAY,EAAc,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAEhF,KAAK,iBAAiB,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;AAExE,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD,KAAY,KAAK,GAAG,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,2BAA2B;;0DAKtC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* The root container for chain of thought components.
|
|
7
|
+
*
|
|
8
|
+
* This component provides a wrapper for chain of thought content,
|
|
9
|
+
* including reasoning and tool-call parts that can be collapsed in an accordion.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <ChainOfThoughtPrimitive.Root>
|
|
14
|
+
* <ChainOfThoughtPrimitive.AccordionTrigger>
|
|
15
|
+
* Toggle reasoning
|
|
16
|
+
* </ChainOfThoughtPrimitive.AccordionTrigger>
|
|
17
|
+
* <ChainOfThoughtPrimitive.Parts />
|
|
18
|
+
* </ChainOfThoughtPrimitive.Root>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export const ChainOfThoughtPrimitiveRoot = forwardRef((props, ref) => {
|
|
22
|
+
return _jsx(Primitive.div, { ...props, ref: ref });
|
|
23
|
+
});
|
|
24
|
+
ChainOfThoughtPrimitiveRoot.displayName = "ChainOfThoughtPrimitive.Root";
|
|
25
|
+
//# sourceMappingURL=ChainOfThoughtRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtRoot.js","sourceRoot":"","sources":["../../../src/primitives/chainOfThought/ChainOfThoughtRoot.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAqB,UAAU,EAA4B,MAAM,OAAO,CAAC;AAShF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAGnD,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACf,OAAO,KAAC,SAAS,CAAC,GAAG,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH,2BAA2B,CAAC,WAAW,GAAG,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ChainOfThoughtPrimitiveRoot as Root, type ChainOfThoughtPrimitiveRoot as RootPrimitive, } from "./ChainOfThoughtRoot.js";
|
|
2
|
+
export { ChainOfThoughtPrimitiveAccordionTrigger as AccordionTrigger, type ChainOfThoughtPrimitiveAccordionTrigger as AccordionTriggerPrimitive, } from "./ChainOfThoughtAccordionTrigger.js";
|
|
3
|
+
export { ChainOfThoughtPrimitiveParts as Parts, type ChainOfThoughtPrimitiveParts as PartsPrimitive, } from "./ChainOfThoughtParts.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/chainOfThought/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,IAAI,IAAI,EACnC,KAAK,2BAA2B,IAAI,aAAa,GAClD,gCAA6B;AAE9B,OAAO,EACL,uCAAuC,IAAI,gBAAgB,EAC3D,KAAK,uCAAuC,IAAI,yBAAyB,GAC1E,4CAAyC;AAE1C,OAAO,EACL,4BAA4B,IAAI,KAAK,EACrC,KAAK,4BAA4B,IAAI,cAAc,GACpD,iCAA8B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ChainOfThoughtPrimitiveRoot as Root, } from "./ChainOfThoughtRoot.js";
|
|
2
|
+
export { ChainOfThoughtPrimitiveAccordionTrigger as AccordionTrigger, } from "./ChainOfThoughtAccordionTrigger.js";
|
|
3
|
+
export { ChainOfThoughtPrimitiveParts as Parts, } from "./ChainOfThoughtParts.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/primitives/chainOfThought/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,IAAI,IAAI,GAEpC,gCAA6B;AAE9B,OAAO,EACL,uCAAuC,IAAI,gBAAgB,GAE5D,4CAAyC;AAE1C,OAAO,EACL,4BAA4B,IAAI,KAAK,GAEtC,iCAA8B"}
|
|
@@ -3,6 +3,7 @@ export * as ActionBarMorePrimitive from "./actionBarMore/index.js";
|
|
|
3
3
|
export * as AssistantModalPrimitive from "./assistantModal/index.js";
|
|
4
4
|
export * as AttachmentPrimitive from "./attachment/index.js";
|
|
5
5
|
export * as BranchPickerPrimitive from "./branchPicker/index.js";
|
|
6
|
+
export * as ChainOfThoughtPrimitive from "./chainOfThought/index.js";
|
|
6
7
|
export * as ComposerPrimitive from "./composer/index.js";
|
|
7
8
|
export * as MessagePartPrimitive from "./messagePart/index.js";
|
|
8
9
|
export * as ErrorPrimitive from "./error/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,6BAAoB;AAClD,OAAO,KAAK,sBAAsB,iCAAwB;AAC1D,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,qBAAqB,gCAAuB;AACxD,OAAO,KAAK,iBAAiB,4BAAmB;AAChD,OAAO,KAAK,oBAAoB,+BAAsB;AACtD,OAAO,KAAK,cAAc,yBAAgB;AAC1C,OAAO,KAAK,gBAAgB,2BAAkB;AAC9C,OAAO,KAAK,eAAe,0BAAiB;AAC5C,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,2BAA2B,sCAA6B;AAEpE,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,uBAAuB,EAAE,iDAA8C;AAChF,OAAO,EAAE,oBAAoB,EAAE,8CAA2C;AAC1E,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,mBAAmB,EAAE,6CAA0C;AACxE,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,2BAA2B,EAAE,gDAA6C;AACnF,OAAO,EAAE,aAAa,EAAE,6BAAoB"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,6BAAoB;AAClD,OAAO,KAAK,sBAAsB,iCAAwB;AAC1D,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,qBAAqB,gCAAuB;AACxD,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,iBAAiB,4BAAmB;AAChD,OAAO,KAAK,oBAAoB,+BAAsB;AACtD,OAAO,KAAK,cAAc,yBAAgB;AAC1C,OAAO,KAAK,gBAAgB,2BAAkB;AAC9C,OAAO,KAAK,eAAe,0BAAiB;AAC5C,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,2BAA2B,sCAA6B;AAEpE,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,uBAAuB,EAAE,iDAA8C;AAChF,OAAO,EAAE,oBAAoB,EAAE,8CAA2C;AAC1E,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,mBAAmB,EAAE,6CAA0C;AACxE,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,2BAA2B,EAAE,gDAA6C;AACnF,OAAO,EAAE,aAAa,EAAE,6BAAoB"}
|
package/dist/primitives/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * as ActionBarMorePrimitive from "./actionBarMore/index.js";
|
|
|
3
3
|
export * as AssistantModalPrimitive from "./assistantModal/index.js";
|
|
4
4
|
export * as AttachmentPrimitive from "./attachment/index.js";
|
|
5
5
|
export * as BranchPickerPrimitive from "./branchPicker/index.js";
|
|
6
|
+
export * as ChainOfThoughtPrimitive from "./chainOfThought/index.js";
|
|
6
7
|
export * as ComposerPrimitive from "./composer/index.js";
|
|
7
8
|
export * as MessagePartPrimitive from "./messagePart/index.js";
|
|
8
9
|
export * as ErrorPrimitive from "./error/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,6BAAoB;AAClD,OAAO,KAAK,sBAAsB,iCAAwB;AAC1D,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,qBAAqB,gCAAuB;AACxD,OAAO,KAAK,iBAAiB,4BAAmB;AAChD,OAAO,KAAK,oBAAoB,+BAAsB;AACtD,OAAO,KAAK,cAAc,yBAAgB;AAC1C,OAAO,KAAK,gBAAgB,2BAAkB;AAC9C,OAAO,KAAK,eAAe,0BAAiB;AAC5C,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,2BAA2B,sCAA6B;AAEpE,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,uBAAuB,EAAE,iDAA8C;AAChF,OAAO,EAAE,oBAAoB,EAAE,8CAA2C;AAC1E,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,mBAAmB,EAAE,6CAA0C;AACxE,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,2BAA2B,EAAE,gDAA6C;AACnF,OAAO,EAAE,aAAa,EAAE,6BAAoB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,6BAAoB;AAClD,OAAO,KAAK,sBAAsB,iCAAwB;AAC1D,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,qBAAqB,gCAAuB;AACxD,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,iBAAiB,4BAAmB;AAChD,OAAO,KAAK,oBAAoB,+BAAsB;AACtD,OAAO,KAAK,cAAc,yBAAgB;AAC1C,OAAO,KAAK,gBAAgB,2BAAkB;AAC9C,OAAO,KAAK,eAAe,0BAAiB;AAC5C,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,mBAAmB,8BAAqB;AACpD,OAAO,KAAK,uBAAuB,kCAAyB;AAC5D,OAAO,KAAK,2BAA2B,sCAA6B;AAEpE,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,uBAAuB,EAAE,iDAA8C;AAChF,OAAO,EAAE,oBAAoB,EAAE,8CAA2C;AAC1E,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,mBAAmB,EAAE,6CAA0C;AACxE,OAAO,EAAE,kBAAkB,EAAE,4CAAyC;AACtE,OAAO,EAAE,2BAA2B,EAAE,gDAA6C;AACnF,OAAO,EAAE,aAAa,EAAE,6BAAoB"}
|
|
@@ -115,6 +115,30 @@ export declare namespace MessagePrimitiveParts {
|
|
|
115
115
|
* @param children - Rendered reasoning part components
|
|
116
116
|
*/
|
|
117
117
|
ReasoningGroup?: ReasoningGroupComponent;
|
|
118
|
+
/**
|
|
119
|
+
* Component for rendering chain of thought (reasoning + tool-call) parts.
|
|
120
|
+
*
|
|
121
|
+
* When provided, this component takes control of rendering ALL reasoning and
|
|
122
|
+
* tool-call parts in the message. The Reasoning, tools, ReasoningGroup, and
|
|
123
|
+
* ToolGroup components are completely ignored when ChainOfThought is set.
|
|
124
|
+
*
|
|
125
|
+
* The component is automatically wrapped in a ChainOfThoughtByIndicesProvider
|
|
126
|
+
* that sets up the chainOfThought client scope with the correct parts.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```tsx
|
|
130
|
+
* // Chain of thought with accordion
|
|
131
|
+
* ChainOfThought: () => (
|
|
132
|
+
* <ChainOfThoughtPrimitive.Root>
|
|
133
|
+
* <ChainOfThoughtPrimitive.AccordionTrigger>
|
|
134
|
+
* Toggle reasoning
|
|
135
|
+
* </ChainOfThoughtPrimitive.AccordionTrigger>
|
|
136
|
+
* <ChainOfThoughtPrimitive.Parts />
|
|
137
|
+
* </ChainOfThoughtPrimitive.Root>
|
|
138
|
+
* )
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
ChainOfThought?: ComponentType;
|
|
118
142
|
} | undefined;
|
|
119
143
|
/**
|
|
120
144
|
* When enabled, shows the Empty component if the last part in the message
|
|
@@ -129,6 +153,10 @@ export declare namespace MessagePrimitiveParts {
|
|
|
129
153
|
unstable_showEmptyOnNonTextEnd?: boolean | undefined;
|
|
130
154
|
};
|
|
131
155
|
}
|
|
156
|
+
type MessagePartComponentProps = {
|
|
157
|
+
components: MessagePrimitiveParts.Props["components"];
|
|
158
|
+
};
|
|
159
|
+
export declare const MessagePartComponent: FC<MessagePartComponentProps>;
|
|
132
160
|
export declare namespace MessagePrimitivePartByIndex {
|
|
133
161
|
type Props = {
|
|
134
162
|
index: number;
|
|
@@ -178,4 +206,5 @@ export declare const MessagePrimitivePartByIndex: FC<MessagePrimitivePartByIndex
|
|
|
178
206
|
* ```
|
|
179
207
|
*/
|
|
180
208
|
export declare const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props>;
|
|
209
|
+
export {};
|
|
181
210
|
//# sourceMappingURL=MessageParts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageParts.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageParts.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,EAAE,EAEP,iBAAiB,EAElB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MessageParts.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageParts.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,EAAE,EAEP,iBAAiB,EAElB,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACxB,iDAA8C;AAsH/C,yBAAiB,qBAAqB,CAAC;IACrC,KAAY,KAAK,GAAG;QAClB;;;;;WAKG;QACH,UAAU,CAAC,EACP;YACE,6CAA6C;YAC7C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,2CAA2C;YAC3C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,mEAAmE;YACnE,SAAS,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;YACtD,6CAA6C;YAC7C,MAAM,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;YAChD,4CAA4C;YAC5C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,2CAA2C;YAC3C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,2DAA2D;YAC3D,cAAc,CAAC,EAAE,kCAAkC,GAAG,SAAS,CAAC;YAChE,4CAA4C;YAC5C,KAAK,CAAC,EACF;gBACE,qDAAqD;gBACrD,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,4BAA4B,GAAG,SAAS,CAAC,GACxD,SAAS,CAAC;gBACd,gDAAgD;gBAChD,QAAQ,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,GAAG,SAAS,CAAC;aAChE,GACD;gBACE,qDAAqD;gBACrD,QAAQ,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;aACnD,GACD,SAAS,CAAC;YAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA+CG;YACH,SAAS,CAAC,EAAE,aAAa,CACvB,iBAAiB,CAAC;gBAAE,UAAU,EAAE,MAAM,CAAC;gBAAC,QAAQ,EAAE,MAAM,CAAA;aAAE,CAAC,CAC5D,CAAC;YAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4BG;YACH,cAAc,CAAC,EAAE,uBAAuB,CAAC;YAEzC;;;;;;;;;;;;;;;;;;;;;;eAsBG;YACH,cAAc,CAAC,EAAE,aAAa,CAAC;SAChC,GACD,SAAS,CAAC;QACd;;;;;;;;;WASG;QACH,8BAA8B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KACtD,CAAC;CACH;AAmCD,KAAK,yBAAyB,GAAG;IAC/B,UAAU,EAAE,qBAAqB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;CACvD,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CA4D9D,CAAC;AAEF,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,KAAK,GAAG;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,qBAAqB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;KACvD,CAAC;CACH;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAAC,2BAA2B,CAAC,KAAK,CAoB3E,CAAC;AAiEJ;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,qBAAqB,CAAC,KAAK,CA0FjE,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { memo, useMemo, } from "react";
|
|
4
4
|
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
5
5
|
import { PartByIndexProvider, TextMessagePartProvider, } from "../../context/providers/index.js";
|
|
6
|
+
import { ChainOfThoughtByIndicesProvider } from "../../context/providers/ChainOfThoughtByIndicesProvider.js";
|
|
6
7
|
import { MessagePartPrimitiveText } from "../messagePart/MessagePartText.js";
|
|
7
8
|
import { MessagePartPrimitiveImage } from "../messagePart/MessagePartImage.js";
|
|
8
9
|
import { MessagePartPrimitiveInProgress } from "../messagePart/MessagePartInProgress.js";
|
|
@@ -43,39 +44,56 @@ const createGroupState = (groupType) => {
|
|
|
43
44
|
/**
|
|
44
45
|
* Groups consecutive tool-call and reasoning message parts into ranges.
|
|
45
46
|
* Always groups tool calls and reasoning parts, even if there's only one.
|
|
47
|
+
* When useChainOfThought is true, groups tool-call and reasoning parts together.
|
|
46
48
|
*/
|
|
47
|
-
const groupMessageParts = (messageTypes) => {
|
|
49
|
+
const groupMessageParts = (messageTypes, useChainOfThought) => {
|
|
48
50
|
const ranges = [];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
if (useChainOfThought) {
|
|
52
|
+
const chainOfThoughtGroup = createGroupState("chainOfThoughtGroup");
|
|
53
|
+
for (let i = 0; i < messageTypes.length; i++) {
|
|
54
|
+
const type = messageTypes[i];
|
|
55
|
+
if (type === "tool-call" || type === "reasoning") {
|
|
56
|
+
chainOfThoughtGroup.startGroup(i);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
chainOfThoughtGroup.endGroup(i - 1, ranges);
|
|
60
|
+
ranges.push({ type: "single", index: i });
|
|
61
|
+
}
|
|
60
62
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
chainOfThoughtGroup.finalize(messageTypes.length - 1, ranges);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const toolGroup = createGroupState("toolGroup");
|
|
67
|
+
const reasoningGroup = createGroupState("reasoningGroup");
|
|
68
|
+
for (let i = 0; i < messageTypes.length; i++) {
|
|
69
|
+
const type = messageTypes[i];
|
|
70
|
+
if (type === "tool-call") {
|
|
71
|
+
reasoningGroup.endGroup(i - 1, ranges);
|
|
72
|
+
toolGroup.startGroup(i);
|
|
73
|
+
}
|
|
74
|
+
else if (type === "reasoning") {
|
|
75
|
+
toolGroup.endGroup(i - 1, ranges);
|
|
76
|
+
reasoningGroup.startGroup(i);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
toolGroup.endGroup(i - 1, ranges);
|
|
80
|
+
reasoningGroup.endGroup(i - 1, ranges);
|
|
81
|
+
ranges.push({ type: "single", index: i });
|
|
82
|
+
}
|
|
65
83
|
}
|
|
84
|
+
toolGroup.finalize(messageTypes.length - 1, ranges);
|
|
85
|
+
reasoningGroup.finalize(messageTypes.length - 1, ranges);
|
|
66
86
|
}
|
|
67
|
-
toolGroup.finalize(messageTypes.length - 1, ranges);
|
|
68
|
-
reasoningGroup.finalize(messageTypes.length - 1, ranges);
|
|
69
87
|
return ranges;
|
|
70
88
|
};
|
|
71
|
-
const useMessagePartsGroups = () => {
|
|
89
|
+
const useMessagePartsGroups = (useChainOfThought) => {
|
|
72
90
|
const messageTypes = useAuiState(useShallow((s) => s.message.parts.map((c) => c.type)));
|
|
73
91
|
return useMemo(() => {
|
|
74
92
|
if (messageTypes.length === 0) {
|
|
75
93
|
return [];
|
|
76
94
|
}
|
|
77
|
-
return groupMessageParts(messageTypes);
|
|
78
|
-
}, [messageTypes]);
|
|
95
|
+
return groupMessageParts(messageTypes, useChainOfThought);
|
|
96
|
+
}, [messageTypes, useChainOfThought]);
|
|
79
97
|
};
|
|
80
98
|
const ToolUIDisplay = ({ Fallback, ...props }) => {
|
|
81
99
|
const Render = useAuiState(({ tools }) => {
|
|
@@ -98,7 +116,7 @@ const defaultComponents = {
|
|
|
98
116
|
ToolGroup: ({ children }) => children,
|
|
99
117
|
ReasoningGroup: ({ children }) => children,
|
|
100
118
|
};
|
|
101
|
-
const MessagePartComponent = ({ components: { Text = defaultComponents.Text, Reasoning = defaultComponents.Reasoning, Image = defaultComponents.Image, Source = defaultComponents.Source, File = defaultComponents.File, Unstable_Audio: Audio = defaultComponents.Unstable_Audio, tools = {}, } = {}, }) => {
|
|
119
|
+
export const MessagePartComponent = ({ components: { Text = defaultComponents.Text, Reasoning = defaultComponents.Reasoning, Image = defaultComponents.Image, Source = defaultComponents.Source, File = defaultComponents.File, Unstable_Audio: Audio = defaultComponents.Unstable_Audio, tools = {}, } = {}, }) => {
|
|
102
120
|
const aui = useAui();
|
|
103
121
|
const part = useAuiState(({ part }) => part);
|
|
104
122
|
const type = part.type;
|
|
@@ -218,7 +236,8 @@ const ConditionalEmpty = memo(ConditionalEmptyImpl, (prev, next) => prev.enabled
|
|
|
218
236
|
*/
|
|
219
237
|
export const MessagePrimitiveParts = ({ components, unstable_showEmptyOnNonTextEnd = true, }) => {
|
|
220
238
|
const contentLength = useAuiState(({ message }) => message.parts.length);
|
|
221
|
-
const
|
|
239
|
+
const useChainOfThought = !!components?.ChainOfThought;
|
|
240
|
+
const messageRanges = useMessagePartsGroups(useChainOfThought);
|
|
222
241
|
const partsElements = useMemo(() => {
|
|
223
242
|
if (contentLength === 0) {
|
|
224
243
|
return _jsx(EmptyParts, { components: components });
|
|
@@ -227,6 +246,12 @@ export const MessagePrimitiveParts = ({ components, unstable_showEmptyOnNonTextE
|
|
|
227
246
|
if (range.type === "single") {
|
|
228
247
|
return (_jsx(MessagePrimitivePartByIndex, { index: range.index, components: components }, range.index));
|
|
229
248
|
}
|
|
249
|
+
else if (range.type === "chainOfThoughtGroup") {
|
|
250
|
+
const ChainOfThoughtComponent = components?.ChainOfThought;
|
|
251
|
+
if (!ChainOfThoughtComponent)
|
|
252
|
+
return null;
|
|
253
|
+
return (_jsx(ChainOfThoughtByIndicesProvider, { startIndex: range.startIndex, endIndex: range.endIndex, children: _jsx(ChainOfThoughtComponent, {}) }, `chainOfThought-${range.startIndex}`));
|
|
254
|
+
}
|
|
230
255
|
else if (range.type === "toolGroup") {
|
|
231
256
|
const ToolGroupComponent = components?.ToolGroup ?? defaultComponents.ToolGroup;
|
|
232
257
|
return (_jsx(ToolGroupComponent, { startIndex: range.startIndex, endIndex: range.endIndex, children: Array.from({ length: range.endIndex - range.startIndex + 1 }, (_, i) => (_jsx(MessagePrimitivePartByIndex, { index: range.startIndex + i, components: components }, i))) }, `tool-${range.startIndex}`));
|