@assistant-ui/vue 0.0.0 → 0.0.1
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/LICENSE +21 -0
- package/README.md +90 -2
- package/dist/AuiIf.d.ts +27 -0
- package/dist/AuiIf.d.ts.map +1 -0
- package/dist/AuiIf.js +30 -0
- package/dist/AuiIf.js.map +1 -0
- package/dist/AuiProvider.d.ts +41 -0
- package/dist/AuiProvider.d.ts.map +1 -0
- package/dist/AuiProvider.js +61 -0
- package/dist/AuiProvider.js.map +1 -0
- package/dist/context.d.ts +10 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +17 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/primitives/AttachmentByIndexProvider.d.ts +30 -0
- package/dist/primitives/AttachmentByIndexProvider.d.ts.map +1 -0
- package/dist/primitives/AttachmentByIndexProvider.js +63 -0
- package/dist/primitives/AttachmentByIndexProvider.js.map +1 -0
- package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.d.ts +11 -0
- package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.d.ts.map +1 -0
- package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.js +31 -0
- package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.js.map +1 -0
- package/dist/primitives/ChainOfThoughtPrimitiveParts.d.ts +19 -0
- package/dist/primitives/ChainOfThoughtPrimitiveParts.d.ts.map +1 -0
- package/dist/primitives/ChainOfThoughtPrimitiveParts.js +85 -0
- package/dist/primitives/ChainOfThoughtPrimitiveParts.js.map +1 -0
- package/dist/primitives/ComposerPrimitiveCancel.d.ts +12 -0
- package/dist/primitives/ComposerPrimitiveCancel.d.ts.map +1 -0
- package/dist/primitives/ComposerPrimitiveCancel.js +33 -0
- package/dist/primitives/ComposerPrimitiveCancel.js.map +1 -0
- package/dist/primitives/ComposerPrimitiveInput.d.ts +26 -0
- package/dist/primitives/ComposerPrimitiveInput.d.ts.map +1 -0
- package/dist/primitives/ComposerPrimitiveInput.js +57 -0
- package/dist/primitives/ComposerPrimitiveInput.js.map +1 -0
- package/dist/primitives/ComposerPrimitiveSend.d.ts +13 -0
- package/dist/primitives/ComposerPrimitiveSend.d.ts.map +1 -0
- package/dist/primitives/ComposerPrimitiveSend.js +31 -0
- package/dist/primitives/ComposerPrimitiveSend.js.map +1 -0
- package/dist/primitives/MessageByIdProvider.d.ts +23 -0
- package/dist/primitives/MessageByIdProvider.d.ts.map +1 -0
- package/dist/primitives/MessageByIdProvider.js +70 -0
- package/dist/primitives/MessageByIdProvider.js.map +1 -0
- package/dist/primitives/MessagePrimitiveParts.d.ts +50 -0
- package/dist/primitives/MessagePrimitiveParts.d.ts.map +1 -0
- package/dist/primitives/MessagePrimitiveParts.js +93 -0
- package/dist/primitives/MessagePrimitiveParts.js.map +1 -0
- package/dist/primitives/PartByIndexProvider.d.ts +21 -0
- package/dist/primitives/PartByIndexProvider.d.ts.map +1 -0
- package/dist/primitives/PartByIndexProvider.js +50 -0
- package/dist/primitives/PartByIndexProvider.js.map +1 -0
- package/dist/primitives/ThreadListItemPrimitiveRoot.d.ts +7 -0
- package/dist/primitives/ThreadListItemPrimitiveRoot.d.ts.map +1 -0
- package/dist/primitives/ThreadListItemPrimitiveRoot.js +36 -0
- package/dist/primitives/ThreadListItemPrimitiveRoot.js.map +1 -0
- package/dist/primitives/ThreadListItemPrimitiveTrigger.d.ts +14 -0
- package/dist/primitives/ThreadListItemPrimitiveTrigger.d.ts.map +1 -0
- package/dist/primitives/ThreadListItemPrimitiveTrigger.js +58 -0
- package/dist/primitives/ThreadListItemPrimitiveTrigger.js.map +1 -0
- package/dist/primitives/ThreadListPrimitiveRoot.d.ts +7 -0
- package/dist/primitives/ThreadListPrimitiveRoot.d.ts.map +1 -0
- package/dist/primitives/ThreadListPrimitiveRoot.js +16 -0
- package/dist/primitives/ThreadListPrimitiveRoot.js.map +1 -0
- package/dist/primitives/ThreadPrimitiveMessages.d.ts +23 -0
- package/dist/primitives/ThreadPrimitiveMessages.d.ts.map +1 -0
- package/dist/primitives/ThreadPrimitiveMessages.js +37 -0
- package/dist/primitives/ThreadPrimitiveMessages.js.map +1 -0
- package/dist/primitives/ThreadPrimitiveScrollToBottom.d.ts +25 -0
- package/dist/primitives/ThreadPrimitiveScrollToBottom.d.ts.map +1 -0
- package/dist/primitives/ThreadPrimitiveScrollToBottom.js +43 -0
- package/dist/primitives/ThreadPrimitiveScrollToBottom.js.map +1 -0
- package/dist/primitives/ThreadPrimitiveViewport.d.ts +57 -0
- package/dist/primitives/ThreadPrimitiveViewport.d.ts.map +1 -0
- package/dist/primitives/ThreadPrimitiveViewport.js +174 -0
- package/dist/primitives/ThreadPrimitiveViewport.js.map +1 -0
- package/dist/primitives/ThreadPrimitiveViewportFooter.d.ts +13 -0
- package/dist/primitives/ThreadPrimitiveViewportFooter.d.ts.map +1 -0
- package/dist/primitives/ThreadPrimitiveViewportFooter.js +46 -0
- package/dist/primitives/ThreadPrimitiveViewportFooter.js.map +1 -0
- package/dist/primitives/actionBar.d.ts +41 -0
- package/dist/primitives/actionBar.d.ts.map +1 -0
- package/dist/primitives/actionBar.js +110 -0
- package/dist/primitives/actionBar.js.map +1 -0
- package/dist/primitives/attachment.d.ts +27 -0
- package/dist/primitives/attachment.d.ts.map +1 -0
- package/dist/primitives/attachment.js +63 -0
- package/dist/primitives/attachment.js.map +1 -0
- package/dist/primitives/attrDisabled.d.ts +2 -0
- package/dist/primitives/attrDisabled.d.ts.map +1 -0
- package/dist/primitives/attrDisabled.js +6 -0
- package/dist/primitives/attrDisabled.js.map +1 -0
- package/dist/primitives/branchPicker.d.ts +18 -0
- package/dist/primitives/branchPicker.d.ts.map +1 -0
- package/dist/primitives/branchPicker.js +48 -0
- package/dist/primitives/branchPicker.js.map +1 -0
- package/dist/primitives/composerAttachments.d.ts +57 -0
- package/dist/primitives/composerAttachments.d.ts.map +1 -0
- package/dist/primitives/composerAttachments.js +132 -0
- package/dist/primitives/composerAttachments.js.map +1 -0
- package/dist/primitives/error.d.ts +15 -0
- package/dist/primitives/error.d.ts.map +1 -0
- package/dist/primitives/error.js +29 -0
- package/dist/primitives/error.js.map +1 -0
- package/dist/primitives/lastValidCache.d.ts +6 -0
- package/dist/primitives/lastValidCache.d.ts.map +1 -0
- package/dist/primitives/lastValidCache.js +9 -0
- package/dist/primitives/lastValidCache.js.map +1 -0
- package/dist/primitives/message.d.ts +12 -0
- package/dist/primitives/message.d.ts.map +1 -0
- package/dist/primitives/message.js +44 -0
- package/dist/primitives/message.js.map +1 -0
- package/dist/primitives/messageAttachments.d.ts +12 -0
- package/dist/primitives/messageAttachments.d.ts.map +1 -0
- package/dist/primitives/messageAttachments.js +27 -0
- package/dist/primitives/messageAttachments.js.map +1 -0
- package/dist/primitives/stableKeys.d.ts +5 -0
- package/dist/primitives/stableKeys.d.ts.map +1 -0
- package/dist/primitives/stableKeys.js +14 -0
- package/dist/primitives/stableKeys.js.map +1 -0
- package/dist/primitives/suggestions.d.ts +66 -0
- package/dist/primitives/suggestions.d.ts.map +1 -0
- package/dist/primitives/suggestions.js +137 -0
- package/dist/primitives/suggestions.js.map +1 -0
- package/dist/primitives/thread.d.ts +11 -0
- package/dist/primitives/thread.d.ts.map +1 -0
- package/dist/primitives/thread.js +37 -0
- package/dist/primitives/thread.js.map +1 -0
- package/dist/primitives/threadList.d.ts +82 -0
- package/dist/primitives/threadList.d.ts.map +1 -0
- package/dist/primitives/threadList.js +128 -0
- package/dist/primitives/threadList.js.map +1 -0
- package/dist/primitives/threadListFocusGroup.d.ts +14 -0
- package/dist/primitives/threadListFocusGroup.d.ts.map +1 -0
- package/dist/primitives/threadListFocusGroup.js +32 -0
- package/dist/primitives/threadListFocusGroup.js.map +1 -0
- package/dist/primitives/threadListStructural.d.ts +29 -0
- package/dist/primitives/threadListStructural.d.ts.map +1 -0
- package/dist/primitives/threadListStructural.js +55 -0
- package/dist/primitives/threadListStructural.js.map +1 -0
- package/dist/primitives/useComposerSendState.d.ts +6 -0
- package/dist/primitives/useComposerSendState.d.ts.map +1 -0
- package/dist/primitives/useComposerSendState.js +15 -0
- package/dist/primitives/useComposerSendState.js.map +1 -0
- package/dist/primitives/viewportContext.d.ts +12 -0
- package/dist/primitives/viewportContext.d.ts.map +1 -0
- package/dist/primitives/viewportContext.js +6 -0
- package/dist/primitives/viewportContext.js.map +1 -0
- package/dist/useAui.d.ts +15 -0
- package/dist/useAui.d.ts.map +1 -0
- package/dist/useAui.js +21 -0
- package/dist/useAui.js.map +1 -0
- package/dist/useAuiEvent.d.ts +17 -0
- package/dist/useAuiEvent.d.ts.map +1 -0
- package/dist/useAuiEvent.js +52 -0
- package/dist/useAuiEvent.js.map +1 -0
- package/dist/useAuiState.d.ts +23 -0
- package/dist/useAuiState.d.ts.map +1 -0
- package/dist/useAuiState.js +42 -0
- package/dist/useAuiState.js.map +1 -0
- package/dist/useScrollLock.d.ts +3 -0
- package/dist/useScrollLock.d.ts.map +1 -0
- package/dist/useScrollLock.js +53 -0
- package/dist/useScrollLock.js.map +1 -0
- package/package.json +57 -6
- package/src/AuiIf.ts +34 -0
- package/src/AuiProvider.ts +90 -0
- package/src/__tests__/AuiIf.test.ts +54 -0
- package/src/__tests__/AuiProvider.test.ts +266 -0
- package/src/__tests__/byindex-shrink-race.test.ts +411 -0
- package/src/__tests__/dist-graph.test.ts +49 -0
- package/src/__tests__/fixtures.ts +51 -0
- package/src/__tests__/primitives-actionbar.test.ts +469 -0
- package/src/__tests__/primitives-attachment.test.ts +493 -0
- package/src/__tests__/primitives-content.test.ts +749 -0
- package/src/__tests__/primitives-keyed-items.test.ts +270 -0
- package/src/__tests__/primitives-keyed-messages.test.ts +264 -0
- package/src/__tests__/primitives-structural.test.ts +573 -0
- package/src/__tests__/primitives-suggestions.test.ts +374 -0
- package/src/__tests__/primitives-threadlist.test.ts +443 -0
- package/src/__tests__/primitives-tool-ui.test.ts +579 -0
- package/src/__tests__/primitives.test.ts +361 -0
- package/src/__tests__/useAuiEvent.test.ts +159 -0
- package/src/__tests__/useAuiState.test.ts +124 -0
- package/src/context.ts +31 -0
- package/src/index.ts +87 -0
- package/src/primitives/AttachmentByIndexProvider.ts +88 -0
- package/src/primitives/ChainOfThoughtPrimitiveAccordionTrigger.test.ts +105 -0
- package/src/primitives/ChainOfThoughtPrimitiveAccordionTrigger.ts +38 -0
- package/src/primitives/ChainOfThoughtPrimitiveParts.test.ts +254 -0
- package/src/primitives/ChainOfThoughtPrimitiveParts.ts +112 -0
- package/src/primitives/ComposerPrimitiveCancel.ts +41 -0
- package/src/primitives/ComposerPrimitiveInput.ts +64 -0
- package/src/primitives/ComposerPrimitiveSend.ts +39 -0
- package/src/primitives/MessageByIdProvider.ts +89 -0
- package/src/primitives/MessagePrimitiveParts.tool-interaction.test.ts +88 -0
- package/src/primitives/MessagePrimitiveParts.ts +166 -0
- package/src/primitives/PartByIndexProvider.ts +62 -0
- package/src/primitives/ThreadListItemPrimitiveRoot.ts +57 -0
- package/src/primitives/ThreadListItemPrimitiveTrigger.ts +74 -0
- package/src/primitives/ThreadListKeyboardNav.test.ts +298 -0
- package/src/primitives/ThreadListPrimitiveRoot.ts +18 -0
- package/src/primitives/ThreadPrimitiveMessages.ts +40 -0
- package/src/primitives/ThreadPrimitiveScrollToBottom.ts +65 -0
- package/src/primitives/ThreadPrimitiveViewport.ts +233 -0
- package/src/primitives/ThreadPrimitiveViewportFooter.test.ts +305 -0
- package/src/primitives/ThreadPrimitiveViewportFooter.ts +60 -0
- package/src/primitives/actionBar.ts +159 -0
- package/src/primitives/attachment.ts +76 -0
- package/src/primitives/attrDisabled.ts +6 -0
- package/src/primitives/branchPicker.ts +77 -0
- package/src/primitives/composerAttachments.ts +181 -0
- package/src/primitives/error.ts +36 -0
- package/src/primitives/lastValidCache.ts +12 -0
- package/src/primitives/message.ts +54 -0
- package/src/primitives/messageAttachments.ts +32 -0
- package/src/primitives/stableKeys.test.ts +19 -0
- package/src/primitives/stableKeys.ts +21 -0
- package/src/primitives/suggestions.ts +179 -0
- package/src/primitives/thread.ts +46 -0
- package/src/primitives/threadList.ts +163 -0
- package/src/primitives/threadListFocusGroup.ts +56 -0
- package/src/primitives/threadListStructural.ts +86 -0
- package/src/primitives/useComposerSendState.ts +13 -0
- package/src/primitives/viewportContext.ts +16 -0
- package/src/useAui.ts +18 -0
- package/src/useAuiEvent.ts +64 -0
- package/src/useAuiState.ts +55 -0
- package/src/useScrollLock.test.ts +207 -0
- package/src/useScrollLock.ts +79 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useAuiState } from "../useAuiState.js";
|
|
2
|
+
import { AuiProvider } from "../AuiProvider.js";
|
|
3
|
+
import { useAui } from "../useAui.js";
|
|
4
|
+
import { createLastValidCache as createLastValidCache$1, createStaleReporter } from "./lastValidCache.js";
|
|
5
|
+
import { useStableKeys } from "./stableKeys.js";
|
|
6
|
+
import { computed, defineComponent, h, onScopeDispose } from "vue";
|
|
7
|
+
import { AuiConfig, Derived } from "@assistant-ui/store/client";
|
|
8
|
+
import { getMessagePartKeys } from "@assistant-ui/core/internal";
|
|
9
|
+
//#region src/primitives/ChainOfThoughtPrimitiveParts.ts
|
|
10
|
+
const ChainOfThoughtPartByIndexProvider = defineComponent({
|
|
11
|
+
name: "ChainOfThoughtPartByIndexProvider",
|
|
12
|
+
props: { index: {
|
|
13
|
+
type: Number,
|
|
14
|
+
required: true
|
|
15
|
+
} },
|
|
16
|
+
slots: Object,
|
|
17
|
+
setup(props, { slots }) {
|
|
18
|
+
const aui = useAui();
|
|
19
|
+
let disposed = false;
|
|
20
|
+
onScopeDispose(() => {
|
|
21
|
+
disposed = true;
|
|
22
|
+
});
|
|
23
|
+
const config = computed(() => {
|
|
24
|
+
const index = props.index;
|
|
25
|
+
const cache = createLastValidCache$1(createStaleReporter({
|
|
26
|
+
name: "ChainOfThoughtPartByIndexProvider",
|
|
27
|
+
index,
|
|
28
|
+
isCurrent: () => !disposed && index === props.index,
|
|
29
|
+
isValid: () => index < aui.chainOfThought.getState().parts.length
|
|
30
|
+
}));
|
|
31
|
+
return AuiConfig({ part: Derived({
|
|
32
|
+
source: "chainOfThought",
|
|
33
|
+
query: {
|
|
34
|
+
type: "index",
|
|
35
|
+
index
|
|
36
|
+
},
|
|
37
|
+
get: (aui) => {
|
|
38
|
+
const valid = index < aui.chainOfThought.getState().parts.length;
|
|
39
|
+
try {
|
|
40
|
+
return cache.resolve(valid, () => aui.chainOfThought.part({ index }));
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return cache.resolve(false, () => {
|
|
43
|
+
throw error;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}) });
|
|
48
|
+
});
|
|
49
|
+
return () => h(AuiProvider, {
|
|
50
|
+
config: config.value,
|
|
51
|
+
extends: aui
|
|
52
|
+
}, { default: () => slots.default?.() });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const ChainOfThoughtPartView = defineComponent({
|
|
56
|
+
name: "ChainOfThoughtPartView",
|
|
57
|
+
slots: Object,
|
|
58
|
+
setup(_, { slots }) {
|
|
59
|
+
const part = useAuiState((s) => s.part);
|
|
60
|
+
return () => slots.default?.({ part: part.value });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Renders the parts within a chain of thought through the default slot, one
|
|
65
|
+
* invocation per entry of `s.chainOfThought.parts`.
|
|
66
|
+
*
|
|
67
|
+
* Rendering is not gated on `s.chainOfThought.collapsed`; gate visibility in
|
|
68
|
+
* the caller (for example with `AuiIf`), matching the React primitive.
|
|
69
|
+
*/
|
|
70
|
+
const ChainOfThoughtPrimitiveParts = defineComponent({
|
|
71
|
+
name: "ChainOfThoughtPrimitiveParts",
|
|
72
|
+
slots: Object,
|
|
73
|
+
setup(_, { slots }) {
|
|
74
|
+
const parts = useAuiState((s) => s.chainOfThought.parts);
|
|
75
|
+
const partKeys = useStableKeys(() => getMessagePartKeys(parts.value));
|
|
76
|
+
return () => partKeys.value.map((key, index) => h(ChainOfThoughtPartByIndexProvider, {
|
|
77
|
+
index,
|
|
78
|
+
key
|
|
79
|
+
}, { default: () => h(ChainOfThoughtPartView, null, { default: slots.default }) }));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
//#endregion
|
|
83
|
+
export { ChainOfThoughtPrimitiveParts };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=ChainOfThoughtPrimitiveParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtPrimitiveParts.js","names":["createLastValidCache"],"sources":["../../src/primitives/ChainOfThoughtPrimitiveParts.ts"],"sourcesContent":["import {\n computed,\n defineComponent,\n h,\n onScopeDispose,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport type { PartMethods, PartState } from \"@assistant-ui/core/store\";\nimport { getMessagePartKeys } from \"@assistant-ui/core/internal\";\nimport { AuiConfig, Derived } from \"@assistant-ui/store/client\";\nimport { AuiProvider } from \"../AuiProvider\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\nimport { createLastValidCache, createStaleReporter } from \"./lastValidCache\";\nimport { useStableKeys } from \"./stableKeys\";\n\ntype ChainOfThoughtPartsSlots = {\n default?: (props: { part: PartState }) => VNodeChild[];\n};\n\nconst ChainOfThoughtPartByIndexProvider = defineComponent({\n name: \"ChainOfThoughtPartByIndexProvider\",\n props: {\n index: {\n type: Number,\n required: true,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { slots }) {\n const aui = useAui();\n let disposed = false;\n onScopeDispose(() => {\n disposed = true;\n });\n const config = computed(() => {\n const index = props.index;\n const cache = createLastValidCache<PartMethods>(\n createStaleReporter({\n name: \"ChainOfThoughtPartByIndexProvider\",\n index,\n isCurrent: () => !disposed && index === props.index,\n isValid: () => index < aui.chainOfThought.getState().parts.length,\n }),\n );\n return AuiConfig({\n part: Derived({\n source: \"chainOfThought\",\n query: { type: \"index\", index },\n // chainOfThought.part() delegates to a userland getMessagePart, so\n // validity is not decided by parts.length alone; a lookup throw is\n // absorbed into the stale cache like an invalid index.\n get: (aui) => {\n const valid = index < aui.chainOfThought.getState().parts.length;\n try {\n return cache.resolve(valid, () =>\n aui.chainOfThought.part({ index }),\n );\n } catch (error) {\n return cache.resolve(false, () => {\n throw error;\n });\n }\n },\n }),\n });\n });\n return () =>\n h(\n AuiProvider,\n { config: config.value, extends: aui },\n { default: () => slots.default?.() },\n );\n },\n});\n\nconst ChainOfThoughtPartView = defineComponent({\n name: \"ChainOfThoughtPartView\",\n slots: Object as SlotsType<ChainOfThoughtPartsSlots>,\n setup(_, { slots }) {\n const part = useAuiState((s) => s.part);\n return () => slots.default?.({ part: part.value });\n },\n});\n\n/**\n * Renders the parts within a chain of thought through the default slot, one\n * invocation per entry of `s.chainOfThought.parts`.\n *\n * Rendering is not gated on `s.chainOfThought.collapsed`; gate visibility in\n * the caller (for example with `AuiIf`), matching the React primitive.\n */\nexport const ChainOfThoughtPrimitiveParts = defineComponent({\n name: \"ChainOfThoughtPrimitiveParts\",\n slots: Object as SlotsType<ChainOfThoughtPartsSlots>,\n setup(_, { slots }) {\n const parts = useAuiState((s) => s.chainOfThought.parts);\n const partKeys = useStableKeys(() => getMessagePartKeys(parts.value));\n return () =>\n partKeys.value.map((key, index) =>\n h(\n ChainOfThoughtPartByIndexProvider,\n { index, key },\n {\n default: () =>\n h(ChainOfThoughtPartView, null, { default: slots.default }),\n },\n ),\n );\n },\n});\n"],"mappings":";;;;;;;;;AAqBA,MAAM,oCAAoC,gBAAgB;CACxD,MAAM;CACN,OAAO,EACL,OAAO;EACL,MAAM;EACN,UAAU;CACZ,EACF;CACA,OAAO;CACP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,MAAM,OAAO;EACnB,IAAI,WAAW;EACf,qBAAqB;GACnB,WAAW;EACb,CAAC;EACD,MAAM,SAAS,eAAe;GAC5B,MAAM,QAAQ,MAAM;GACpB,MAAM,QAAQA,uBACZ,oBAAoB;IAClB,MAAM;IACN;IACA,iBAAiB,CAAC,YAAY,UAAU,MAAM;IAC9C,eAAe,QAAQ,IAAI,eAAe,SAAS,CAAC,CAAC,MAAM;GAC7D,CAAC,CACH;GACA,OAAO,UAAU,EACf,MAAM,QAAQ;IACZ,QAAQ;IACR,OAAO;KAAE,MAAM;KAAS;IAAM;IAI9B,MAAM,QAAQ;KACZ,MAAM,QAAQ,QAAQ,IAAI,eAAe,SAAS,CAAC,CAAC,MAAM;KAC1D,IAAI;MACF,OAAO,MAAM,QAAQ,aACnB,IAAI,eAAe,KAAK,EAAE,MAAM,CAAC,CACnC;KACF,SAAS,OAAO;MACd,OAAO,MAAM,QAAQ,aAAa;OAChC,MAAM;MACR,CAAC;KACH;IACF;GACF,CAAC,EACH,CAAC;EACH,CAAC;EACD,aACE,EACE,aACA;GAAE,QAAQ,OAAO;GAAO,SAAS;EAAI,GACrC,EAAE,eAAe,MAAM,UAAU,EAAE,CACrC;CACJ;AACF,CAAC;AAED,MAAM,yBAAyB,gBAAgB;CAC7C,MAAM;CACN,OAAO;CACP,MAAM,GAAG,EAAE,SAAS;EAClB,MAAM,OAAO,aAAa,MAAM,EAAE,IAAI;EACtC,aAAa,MAAM,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CACnD;AACF,CAAC;;;;;;;;AASD,MAAa,+BAA+B,gBAAgB;CAC1D,MAAM;CACN,OAAO;CACP,MAAM,GAAG,EAAE,SAAS;EAClB,MAAM,QAAQ,aAAa,MAAM,EAAE,eAAe,KAAK;EACvD,MAAM,WAAW,oBAAoB,mBAAmB,MAAM,KAAK,CAAC;EACpE,aACE,SAAS,MAAM,KAAK,KAAK,UACvB,EACE,mCACA;GAAE;GAAO;EAAI,GACb,EACE,eACE,EAAE,wBAAwB,MAAM,EAAE,SAAS,MAAM,QAAQ,CAAC,EAC9D,CACF,CACF;CACJ;AACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type SlotsType, type VNodeChild } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* A button that cancels the current run. Disabled while nothing can be
|
|
4
|
+
* cancelled. A fallthrough click listener runs first and can veto the cancel
|
|
5
|
+
* with `preventDefault`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ComposerPrimitiveCancel: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
|
|
10
|
+
default?: () => VNodeChild[];
|
|
11
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
12
|
+
//# sourceMappingURL=ComposerPrimitiveCancel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposerPrimitiveCancel.d.ts","sourceRoot":"","sources":["../../src/primitives/ComposerPrimitiveCancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAMb;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;cAGK,MAAM,UAAU,EAAE;yEAoBzD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useAuiState } from "../useAuiState.js";
|
|
2
|
+
import { useAui } from "../useAui.js";
|
|
3
|
+
import { isAttrDisabled } from "./attrDisabled.js";
|
|
4
|
+
import { defineComponent, h, mergeProps } from "vue";
|
|
5
|
+
import { composerCancelDisabled } from "@assistant-ui/core/store/internal";
|
|
6
|
+
//#region src/primitives/ComposerPrimitiveCancel.ts
|
|
7
|
+
/**
|
|
8
|
+
* A button that cancels the current run. Disabled while nothing can be
|
|
9
|
+
* cancelled. A fallthrough click listener runs first and can veto the cancel
|
|
10
|
+
* with `preventDefault`.
|
|
11
|
+
*/
|
|
12
|
+
const ComposerPrimitiveCancel = defineComponent({
|
|
13
|
+
name: "ComposerPrimitiveCancel",
|
|
14
|
+
inheritAttrs: false,
|
|
15
|
+
slots: Object,
|
|
16
|
+
setup(_, { attrs, slots }) {
|
|
17
|
+
const aui = useAui();
|
|
18
|
+
const disabled = useAuiState(composerCancelDisabled);
|
|
19
|
+
const onClick = (event) => {
|
|
20
|
+
if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs)) return;
|
|
21
|
+
aui.composer.cancel();
|
|
22
|
+
};
|
|
23
|
+
return () => h("button", mergeProps(attrs, {
|
|
24
|
+
type: "button",
|
|
25
|
+
disabled: disabled.value || isAttrDisabled(attrs),
|
|
26
|
+
onClick
|
|
27
|
+
}), slots.default?.());
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ComposerPrimitiveCancel };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=ComposerPrimitiveCancel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposerPrimitiveCancel.js","names":[],"sources":["../../src/primitives/ComposerPrimitiveCancel.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { composerCancelDisabled } from \"@assistant-ui/core/store/internal\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\n\n/**\n * A button that cancels the current run. Disabled while nothing can be\n * cancelled. A fallthrough click listener runs first and can veto the cancel\n * with `preventDefault`.\n */\nexport const ComposerPrimitiveCancel = defineComponent({\n name: \"ComposerPrimitiveCancel\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const aui = useAui();\n const disabled = useAuiState(composerCancelDisabled);\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs))\n return;\n aui.composer.cancel();\n };\n return () =>\n h(\n \"button\",\n mergeProps(attrs, {\n type: \"button\",\n disabled: disabled.value || isAttrDisabled(attrs),\n onClick,\n }),\n slots.default?.(),\n );\n },\n});\n"],"mappings":";;;;;;;;;;;AAiBA,MAAa,0BAA0B,gBAAgB;CACrD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,MAAM,OAAO;EACnB,MAAM,WAAW,YAAY,sBAAsB;EACnD,MAAM,WAAW,UAAsB;GACrC,IAAI,MAAM,oBAAoB,SAAS,SAAS,eAAe,KAAK,GAClE;GACF,IAAI,SAAS,OAAO;EACtB;EACA,aACE,EACE,UACA,WAAW,OAAO;GAChB,MAAM;GACN,UAAU,SAAS,SAAS,eAAe,KAAK;GAChD;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type SlotsType } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* A textarea bound to the composer text, disabled while the thread is
|
|
4
|
+
* disabled. Enter submits (Shift+Enter inserts a newline, IME composition is
|
|
5
|
+
* ignored) unless `submitOnEnter` is false; an Enter that cannot send falls
|
|
6
|
+
* through to a newline, and a fallthrough keydown listener can veto the
|
|
7
|
+
* submit with `preventDefault`. While the composer is not editing (an edit
|
|
8
|
+
* composer before `beginEdit`), the value stays controlled to the empty
|
|
9
|
+
* composer text.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ComposerPrimitiveInput: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
12
|
+
submitOnEnter: {
|
|
13
|
+
type: BooleanConstructor;
|
|
14
|
+
default: boolean;
|
|
15
|
+
};
|
|
16
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
|
+
submitOnEnter: {
|
|
20
|
+
type: BooleanConstructor;
|
|
21
|
+
default: boolean;
|
|
22
|
+
};
|
|
23
|
+
}>> & Readonly<{}>, {
|
|
24
|
+
submitOnEnter: boolean;
|
|
25
|
+
}, SlotsType<Record<string, never>>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
|
+
//# sourceMappingURL=ComposerPrimitiveInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposerPrimitiveInput.d.ts","sourceRoot":"","sources":["../../src/primitives/ComposerPrimitiveInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAQrE;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;0GA8CjC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useAuiState } from "../useAuiState.js";
|
|
2
|
+
import { useAui } from "../useAui.js";
|
|
3
|
+
import { isAttrDisabled } from "./attrDisabled.js";
|
|
4
|
+
import { useComposerSendState } from "./useComposerSendState.js";
|
|
5
|
+
import { defineComponent, h, mergeProps } from "vue";
|
|
6
|
+
import { composerInputDisabled } from "@assistant-ui/core/store/internal";
|
|
7
|
+
import { flushTapSync } from "@assistant-ui/tap";
|
|
8
|
+
//#region src/primitives/ComposerPrimitiveInput.ts
|
|
9
|
+
/**
|
|
10
|
+
* A textarea bound to the composer text, disabled while the thread is
|
|
11
|
+
* disabled. Enter submits (Shift+Enter inserts a newline, IME composition is
|
|
12
|
+
* ignored) unless `submitOnEnter` is false; an Enter that cannot send falls
|
|
13
|
+
* through to a newline, and a fallthrough keydown listener can veto the
|
|
14
|
+
* submit with `preventDefault`. While the composer is not editing (an edit
|
|
15
|
+
* composer before `beginEdit`), the value stays controlled to the empty
|
|
16
|
+
* composer text.
|
|
17
|
+
*/
|
|
18
|
+
const ComposerPrimitiveInput = defineComponent({
|
|
19
|
+
name: "ComposerPrimitiveInput",
|
|
20
|
+
inheritAttrs: false,
|
|
21
|
+
props: { submitOnEnter: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: true
|
|
24
|
+
} },
|
|
25
|
+
slots: Object,
|
|
26
|
+
setup(props, { attrs }) {
|
|
27
|
+
const aui = useAui();
|
|
28
|
+
const text = useAuiState((s) => s.composer.isEditing ? s.composer.text : "");
|
|
29
|
+
const threadDisabled = useAuiState(composerInputDisabled);
|
|
30
|
+
const { disabled, send } = useComposerSendState();
|
|
31
|
+
const onInput = (event) => {
|
|
32
|
+
const target = event.target;
|
|
33
|
+
if (!aui.composer.getState().isEditing) {
|
|
34
|
+
target.value = text.value;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
flushTapSync(() => aui.composer.setText(target.value));
|
|
38
|
+
};
|
|
39
|
+
const onKeydown = (event) => {
|
|
40
|
+
if (event.defaultPrevented || !props.submitOnEnter) return;
|
|
41
|
+
if (event.key !== "Enter" || event.shiftKey || event.isComposing) return;
|
|
42
|
+
if (disabled.value || threadDisabled.value || isAttrDisabled(attrs)) return;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
send();
|
|
45
|
+
};
|
|
46
|
+
return () => h("textarea", mergeProps({ name: "input" }, attrs, {
|
|
47
|
+
value: text.value,
|
|
48
|
+
disabled: threadDisabled.value || isAttrDisabled(attrs),
|
|
49
|
+
onInput,
|
|
50
|
+
onKeydown
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ComposerPrimitiveInput };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=ComposerPrimitiveInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposerPrimitiveInput.js","names":[],"sources":["../../src/primitives/ComposerPrimitiveInput.ts"],"sourcesContent":["import { defineComponent, h, mergeProps, type SlotsType } from \"vue\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\nimport { composerInputDisabled } from \"@assistant-ui/core/store/internal\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\nimport { useComposerSendState } from \"./useComposerSendState\";\n\n/**\n * A textarea bound to the composer text, disabled while the thread is\n * disabled. Enter submits (Shift+Enter inserts a newline, IME composition is\n * ignored) unless `submitOnEnter` is false; an Enter that cannot send falls\n * through to a newline, and a fallthrough keydown listener can veto the\n * submit with `preventDefault`. While the composer is not editing (an edit\n * composer before `beginEdit`), the value stays controlled to the empty\n * composer text.\n */\nexport const ComposerPrimitiveInput = defineComponent({\n name: \"ComposerPrimitiveInput\",\n inheritAttrs: false,\n props: {\n submitOnEnter: {\n type: Boolean,\n default: true,\n },\n },\n slots: Object as SlotsType<Record<string, never>>,\n setup(props, { attrs }) {\n const aui = useAui();\n const text = useAuiState((s) =>\n s.composer.isEditing ? s.composer.text : \"\",\n );\n const threadDisabled = useAuiState(composerInputDisabled);\n const { disabled, send } = useComposerSendState();\n\n const onInput = (event: Event) => {\n const target = event.target as HTMLTextAreaElement;\n if (!aui.composer.getState().isEditing) {\n target.value = text.value;\n return;\n }\n flushTapSync(() => aui.composer.setText(target.value));\n };\n const onKeydown = (event: KeyboardEvent) => {\n if (event.defaultPrevented || !props.submitOnEnter) return;\n if (event.key !== \"Enter\" || event.shiftKey || event.isComposing) return;\n if (disabled.value || threadDisabled.value || isAttrDisabled(attrs))\n return;\n event.preventDefault();\n send();\n };\n\n return () =>\n h(\n \"textarea\",\n mergeProps({ name: \"input\" }, attrs, {\n value: text.value,\n disabled: threadDisabled.value || isAttrDisabled(attrs),\n onInput,\n onKeydown,\n }),\n );\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,yBAAyB,gBAAgB;CACpD,MAAM;CACN,cAAc;CACd,OAAO,EACL,eAAe;EACb,MAAM;EACN,SAAS;CACX,EACF;CACA,OAAO;CACP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,MAAM,OAAO;EACnB,MAAM,OAAO,aAAa,MACxB,EAAE,SAAS,YAAY,EAAE,SAAS,OAAO,EAC3C;EACA,MAAM,iBAAiB,YAAY,qBAAqB;EACxD,MAAM,EAAE,UAAU,SAAS,qBAAqB;EAEhD,MAAM,WAAW,UAAiB;GAChC,MAAM,SAAS,MAAM;GACrB,IAAI,CAAC,IAAI,SAAS,SAAS,CAAC,CAAC,WAAW;IACtC,OAAO,QAAQ,KAAK;IACpB;GACF;GACA,mBAAmB,IAAI,SAAS,QAAQ,OAAO,KAAK,CAAC;EACvD;EACA,MAAM,aAAa,UAAyB;GAC1C,IAAI,MAAM,oBAAoB,CAAC,MAAM,eAAe;GACpD,IAAI,MAAM,QAAQ,WAAW,MAAM,YAAY,MAAM,aAAa;GAClE,IAAI,SAAS,SAAS,eAAe,SAAS,eAAe,KAAK,GAChE;GACF,MAAM,eAAe;GACrB,KAAK;EACP;EAEA,aACE,EACE,YACA,WAAW,EAAE,MAAM,QAAQ,GAAG,OAAO;GACnC,OAAO,KAAK;GACZ,UAAU,eAAe,SAAS,eAAe,KAAK;GACtD;GACA;EACF,CAAC,CACH;CACJ;AACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type SlotsType, type VNodeChild } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* A button that sends the composer. Disabled while the composer cannot send,
|
|
4
|
+
* or while a run is in flight and the runtime does not queue sends. A
|
|
5
|
+
* fallthrough click listener runs first and can veto the send with
|
|
6
|
+
* `preventDefault`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ComposerPrimitiveSend: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
|
|
11
|
+
default?: () => VNodeChild[];
|
|
12
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
13
|
+
//# sourceMappingURL=ComposerPrimitiveSend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposerPrimitiveSend.d.ts","sourceRoot":"","sources":["../../src/primitives/ComposerPrimitiveSend.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAIb;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;cAGO,MAAM,UAAU,EAAE;yEAmBzD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isAttrDisabled } from "./attrDisabled.js";
|
|
2
|
+
import { useComposerSendState } from "./useComposerSendState.js";
|
|
3
|
+
import { defineComponent, h, mergeProps } from "vue";
|
|
4
|
+
//#region src/primitives/ComposerPrimitiveSend.ts
|
|
5
|
+
/**
|
|
6
|
+
* A button that sends the composer. Disabled while the composer cannot send,
|
|
7
|
+
* or while a run is in flight and the runtime does not queue sends. A
|
|
8
|
+
* fallthrough click listener runs first and can veto the send with
|
|
9
|
+
* `preventDefault`.
|
|
10
|
+
*/
|
|
11
|
+
const ComposerPrimitiveSend = defineComponent({
|
|
12
|
+
name: "ComposerPrimitiveSend",
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
slots: Object,
|
|
15
|
+
setup(_, { attrs, slots }) {
|
|
16
|
+
const { disabled, send } = useComposerSendState();
|
|
17
|
+
const onClick = (event) => {
|
|
18
|
+
if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs)) return;
|
|
19
|
+
send();
|
|
20
|
+
};
|
|
21
|
+
return () => h("button", mergeProps(attrs, {
|
|
22
|
+
type: "button",
|
|
23
|
+
disabled: disabled.value || isAttrDisabled(attrs),
|
|
24
|
+
onClick
|
|
25
|
+
}), slots.default?.());
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ComposerPrimitiveSend };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=ComposerPrimitiveSend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposerPrimitiveSend.js","names":[],"sources":["../../src/primitives/ComposerPrimitiveSend.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { useComposerSendState } from \"./useComposerSendState\";\n\n/**\n * A button that sends the composer. Disabled while the composer cannot send,\n * or while a run is in flight and the runtime does not queue sends. A\n * fallthrough click listener runs first and can veto the send with\n * `preventDefault`.\n */\nexport const ComposerPrimitiveSend = defineComponent({\n name: \"ComposerPrimitiveSend\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const { disabled, send } = useComposerSendState();\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs))\n return;\n send();\n };\n return () =>\n h(\n \"button\",\n mergeProps(attrs, {\n type: \"button\",\n disabled: disabled.value || isAttrDisabled(attrs),\n onClick,\n }),\n slots.default?.(),\n );\n },\n});\n"],"mappings":";;;;;;;;;;AAgBA,MAAa,wBAAwB,gBAAgB;CACnD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,EAAE,UAAU,SAAS,qBAAqB;EAChD,MAAM,WAAW,UAAsB;GACrC,IAAI,MAAM,oBAAoB,SAAS,SAAS,eAAe,KAAK,GAClE;GACF,KAAK;EACP;EACA,aACE,EACE,UACA,WAAW,OAAO;GAChB,MAAM;GACN,UAAU,SAAS,SAAS,eAAe,KAAK;GAChD;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SlotsType, type VNodeChild } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* Scopes the subtree to the thread message with `id`: descendants read the
|
|
4
|
+
* message through `s.message` and its edit composer through `s.composer`.
|
|
5
|
+
* The scope follows the message's identity rather than a positional slot, so
|
|
6
|
+
* it pairs with id-keyed iteration.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MessageByIdProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
9
|
+
id: {
|
|
10
|
+
type: StringConstructor;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
16
|
+
id: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
required: true;
|
|
19
|
+
};
|
|
20
|
+
}>> & Readonly<{}>, {}, SlotsType<{
|
|
21
|
+
default?: () => VNodeChild[];
|
|
22
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
23
|
+
//# sourceMappingURL=MessageByIdProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageByIdProvider.d.ts","sourceRoot":"","sources":["../../src/primitives/MessageByIdProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAuBb;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;cAQS,MAAM,UAAU,EAAE;yEA4CzD,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AuiProvider } from "../AuiProvider.js";
|
|
2
|
+
import { useAui } from "../useAui.js";
|
|
3
|
+
import { createLastValidCache as createLastValidCache$1, createStaleReporter } from "./lastValidCache.js";
|
|
4
|
+
import { computed, defineComponent, h, onScopeDispose } from "vue";
|
|
5
|
+
import { AuiConfig, Derived } from "@assistant-ui/store/client";
|
|
6
|
+
//#region src/primitives/MessageByIdProvider.ts
|
|
7
|
+
const idSets = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
const hasMessage = (aui, id) => {
|
|
9
|
+
const messages = aui.thread.getState().messages;
|
|
10
|
+
let set = idSets.get(messages);
|
|
11
|
+
if (!set) {
|
|
12
|
+
set = new Set(messages.map((message) => message.id));
|
|
13
|
+
idSets.set(messages, set);
|
|
14
|
+
}
|
|
15
|
+
return set.has(id);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Scopes the subtree to the thread message with `id`: descendants read the
|
|
19
|
+
* message through `s.message` and its edit composer through `s.composer`.
|
|
20
|
+
* The scope follows the message's identity rather than a positional slot, so
|
|
21
|
+
* it pairs with id-keyed iteration.
|
|
22
|
+
*/
|
|
23
|
+
const MessageByIdProvider = defineComponent({
|
|
24
|
+
name: "MessageByIdProvider",
|
|
25
|
+
props: { id: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true
|
|
28
|
+
} },
|
|
29
|
+
slots: Object,
|
|
30
|
+
setup(props, { slots }) {
|
|
31
|
+
const aui = useAui();
|
|
32
|
+
let disposed = false;
|
|
33
|
+
onScopeDispose(() => {
|
|
34
|
+
disposed = true;
|
|
35
|
+
});
|
|
36
|
+
const config = computed(() => {
|
|
37
|
+
const id = props.id;
|
|
38
|
+
const messageCache = createLastValidCache$1(createStaleReporter({
|
|
39
|
+
name: "MessageByIdProvider",
|
|
40
|
+
index: id,
|
|
41
|
+
isCurrent: () => !disposed && id === props.id,
|
|
42
|
+
isValid: () => hasMessage(aui, id)
|
|
43
|
+
}));
|
|
44
|
+
const composerCache = createLastValidCache$1(null);
|
|
45
|
+
return AuiConfig({
|
|
46
|
+
message: Derived({
|
|
47
|
+
source: "thread",
|
|
48
|
+
query: {
|
|
49
|
+
type: "id",
|
|
50
|
+
id
|
|
51
|
+
},
|
|
52
|
+
get: (aui) => messageCache.resolve(hasMessage(aui, id), () => aui.thread.message({ id }))
|
|
53
|
+
}),
|
|
54
|
+
composer: Derived({
|
|
55
|
+
source: "message",
|
|
56
|
+
query: {},
|
|
57
|
+
get: (aui) => composerCache.resolve(hasMessage(aui, id), () => aui.thread.message({ id }).composer())
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
return () => h(AuiProvider, {
|
|
62
|
+
config: config.value,
|
|
63
|
+
extends: aui
|
|
64
|
+
}, { default: () => slots.default?.() });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
//#endregion
|
|
68
|
+
export { MessageByIdProvider };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=MessageByIdProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageByIdProvider.js","names":["createLastValidCache"],"sources":["../../src/primitives/MessageByIdProvider.ts"],"sourcesContent":["import {\n computed,\n defineComponent,\n h,\n onScopeDispose,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport {\n AuiConfig,\n Derived,\n type AssistantClient,\n} from \"@assistant-ui/store/client\";\nimport type { ComposerMethods, MessageMethods } from \"@assistant-ui/core/store\";\nimport { AuiProvider } from \"../AuiProvider\";\nimport { useAui } from \"../useAui\";\nimport { createLastValidCache, createStaleReporter } from \"./lastValidCache\";\n\nconst idSets = new WeakMap<readonly { id: string }[], Set<string>>();\n\nconst hasMessage = (aui: AssistantClient, id: string) => {\n const messages = aui.thread.getState().messages;\n let set = idSets.get(messages);\n if (!set) {\n set = new Set(messages.map((message) => message.id));\n idSets.set(messages, set);\n }\n return set.has(id);\n};\n\n/**\n * Scopes the subtree to the thread message with `id`: descendants read the\n * message through `s.message` and its edit composer through `s.composer`.\n * The scope follows the message's identity rather than a positional slot, so\n * it pairs with id-keyed iteration.\n */\nexport const MessageByIdProvider = defineComponent({\n name: \"MessageByIdProvider\",\n props: {\n id: {\n type: String,\n required: true,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { slots }) {\n const aui = useAui();\n let disposed = false;\n onScopeDispose(() => {\n disposed = true;\n });\n const config = computed(() => {\n const id = props.id;\n const messageCache = createLastValidCache<MessageMethods>(\n createStaleReporter({\n name: \"MessageByIdProvider\",\n index: id,\n isCurrent: () => !disposed && id === props.id,\n isValid: () => hasMessage(aui, id),\n }),\n );\n const composerCache = createLastValidCache<ComposerMethods>(null);\n return AuiConfig({\n message: Derived({\n source: \"thread\",\n query: { type: \"id\", id },\n get: (aui) =>\n messageCache.resolve(hasMessage(aui, id), () =>\n aui.thread.message({ id }),\n ),\n }),\n composer: Derived({\n source: \"message\",\n query: {},\n get: (aui) =>\n composerCache.resolve(hasMessage(aui, id), () =>\n aui.thread.message({ id }).composer(),\n ),\n }),\n });\n });\n return () =>\n h(\n AuiProvider,\n { config: config.value, extends: aui },\n { default: () => slots.default?.() },\n );\n },\n});\n"],"mappings":";;;;;;AAkBA,MAAM,yBAAS,IAAI,QAAgD;AAEnE,MAAM,cAAc,KAAsB,OAAe;CACvD,MAAM,WAAW,IAAI,OAAO,SAAS,CAAC,CAAC;CACvC,IAAI,MAAM,OAAO,IAAI,QAAQ;CAC7B,IAAI,CAAC,KAAK;EACR,MAAM,IAAI,IAAI,SAAS,KAAK,YAAY,QAAQ,EAAE,CAAC;EACnD,OAAO,IAAI,UAAU,GAAG;CAC1B;CACA,OAAO,IAAI,IAAI,EAAE;AACnB;;;;;;;AAQA,MAAa,sBAAsB,gBAAgB;CACjD,MAAM;CACN,OAAO,EACL,IAAI;EACF,MAAM;EACN,UAAU;CACZ,EACF;CACA,OAAO;CACP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,MAAM,OAAO;EACnB,IAAI,WAAW;EACf,qBAAqB;GACnB,WAAW;EACb,CAAC;EACD,MAAM,SAAS,eAAe;GAC5B,MAAM,KAAK,MAAM;GACjB,MAAM,eAAeA,uBACnB,oBAAoB;IAClB,MAAM;IACN,OAAO;IACP,iBAAiB,CAAC,YAAY,OAAO,MAAM;IAC3C,eAAe,WAAW,KAAK,EAAE;GACnC,CAAC,CACH;GACA,MAAM,gBAAgBA,uBAAsC,IAAI;GAChE,OAAO,UAAU;IACf,SAAS,QAAQ;KACf,QAAQ;KACR,OAAO;MAAE,MAAM;MAAM;KAAG;KACxB,MAAM,QACJ,aAAa,QAAQ,WAAW,KAAK,EAAE,SACrC,IAAI,OAAO,QAAQ,EAAE,GAAG,CAAC,CAC3B;IACJ,CAAC;IACD,UAAU,QAAQ;KAChB,QAAQ;KACR,OAAO,CAAC;KACR,MAAM,QACJ,cAAc,QAAQ,WAAW,KAAK,EAAE,SACtC,IAAI,OAAO,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CACtC;IACJ,CAAC;GACH,CAAC;EACH,CAAC;EACD,aACE,EACE,aACA;GAAE,QAAQ,OAAO;GAAO,SAAS;EAAI,GACrC,EAAE,eAAe,MAAM,UAAU,EAAE,CACrC;CACJ;AACF,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type SlotsType, type VNodeChild } from "vue";
|
|
2
|
+
import { type PartMethods } from "@assistant-ui/core/store";
|
|
3
|
+
import type { AssistantState } from "@assistant-ui/store/client";
|
|
4
|
+
export declare const clearPartWarningsForTesting: () => void;
|
|
5
|
+
/**
|
|
6
|
+
* The value of the single `tool` prop passed to a tool UI registered in the
|
|
7
|
+
* `tools` scope. React spreads the part state as individual props; in Vue any
|
|
8
|
+
* prop the component does not declare falls through to `$attrs` and gets
|
|
9
|
+
* stringified onto its root element, so the Vue face passes one `tool` object
|
|
10
|
+
* instead, which a component always declares in full. The tools scope
|
|
11
|
+
* declares renderers as React's `ToolCallMessagePartComponent`, so the Vue
|
|
12
|
+
* face bridges the seam with casts at registration and render; a genuine
|
|
13
|
+
* React renderer arriving through a shared toolkit type-checks at `setToolUI`
|
|
14
|
+
* and then fails when invoked as a Vue component. This type is the Vue-facing
|
|
15
|
+
* contract for custom components. Toolkit `renderText` descriptors resolve
|
|
16
|
+
* through the neutral resolver and render string or number results directly;
|
|
17
|
+
* a react-element-valued descriptor is react-only and renders nothing here.
|
|
18
|
+
*/
|
|
19
|
+
export type ToolUIProps = {
|
|
20
|
+
part: Extract<AssistantState["part"], {
|
|
21
|
+
type: "tool-call";
|
|
22
|
+
}>;
|
|
23
|
+
addResult: PartMethods["addToolResult"];
|
|
24
|
+
resume: PartMethods["resumeToolCall"];
|
|
25
|
+
respondToApproval: PartMethods["respondToToolApproval"];
|
|
26
|
+
unstable_recordInteraction?: PartMethods["unstable_recordInteraction"];
|
|
27
|
+
};
|
|
28
|
+
/** The value of the single `data` prop passed to a Vue data renderer. */
|
|
29
|
+
export type DataUIProps<T = unknown> = {
|
|
30
|
+
part: Omit<Extract<AssistantState["part"], {
|
|
31
|
+
type: "data";
|
|
32
|
+
}>, "data"> & {
|
|
33
|
+
data: T;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Renders the current message's content parts in order, each scoped through
|
|
38
|
+
* {@link PartByIndexProvider}. A `tool-call` part first resolves a renderer
|
|
39
|
+
* registered in the `tools` scope by tool name (`aui.tools.setToolUI`, or a
|
|
40
|
+
* `Tools({ toolkit })` config entry) and renders it with a single `tool` prop
|
|
41
|
+
* of type {@link ToolUIProps}.
|
|
42
|
+
* Otherwise a slot named after the part type (`text`, `reasoning`,
|
|
43
|
+
* `tool-call`, ...) renders that part; the `default` slot is the fallback for
|
|
44
|
+
* types without a named slot, except text, which always renders its text
|
|
45
|
+
* unless a `text` slot overrides it.
|
|
46
|
+
*/
|
|
47
|
+
export declare const MessagePrimitiveParts: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
}>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<Record<string, (() => VNodeChild[]) | undefined>>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
50
|
+
//# sourceMappingURL=MessagePrimitiveParts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessagePrimitiveParts.d.ts","sourceRoot":"","sources":["../../src/primitives/MessagePrimitiveParts.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAGb,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAQjE,eAAO,MAAM,2BAA2B,YAA4B,CAAC;AAErE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAC7D,SAAS,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IACxC,MAAM,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;IACtC,iBAAiB,EAAE,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACxD,0BAA0B,CAAC,EAAE,WAAW,CAAC,4BAA4B,CAAC,CAAC;CACxE,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI;IACrC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,MAAM,CAAC,GAAG;QACtE,IAAI,EAAE,CAAC,CAAC;KACT,CAAC;CACH,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB;;oMAEiB,UAAU,EAAE,sFAmG7D,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useAuiState } from "../useAuiState.js";
|
|
2
|
+
import { useAui } from "../useAui.js";
|
|
3
|
+
import { PartByIndexProvider } from "./PartByIndexProvider.js";
|
|
4
|
+
import { useStableKeys } from "./stableKeys.js";
|
|
5
|
+
import { defineComponent, h } from "vue";
|
|
6
|
+
import { isDevelopment } from "@assistant-ui/core/store/internal";
|
|
7
|
+
import { isMcpAppUri } from "@assistant-ui/core";
|
|
8
|
+
import { getMessagePartKeys } from "@assistant-ui/core/internal";
|
|
9
|
+
import { resolveToolCallText } from "@assistant-ui/core/store";
|
|
10
|
+
//#region src/primitives/MessagePrimitiveParts.ts
|
|
11
|
+
const warnedTypes = /* @__PURE__ */ new Set();
|
|
12
|
+
const clearPartWarningsForTesting = () => warnedTypes.clear();
|
|
13
|
+
/**
|
|
14
|
+
* Renders the current message's content parts in order, each scoped through
|
|
15
|
+
* {@link PartByIndexProvider}. A `tool-call` part first resolves a renderer
|
|
16
|
+
* registered in the `tools` scope by tool name (`aui.tools.setToolUI`, or a
|
|
17
|
+
* `Tools({ toolkit })` config entry) and renders it with a single `tool` prop
|
|
18
|
+
* of type {@link ToolUIProps}.
|
|
19
|
+
* Otherwise a slot named after the part type (`text`, `reasoning`,
|
|
20
|
+
* `tool-call`, ...) renders that part; the `default` slot is the fallback for
|
|
21
|
+
* types without a named slot, except text, which always renders its text
|
|
22
|
+
* unless a `text` slot overrides it.
|
|
23
|
+
*/
|
|
24
|
+
const MessagePrimitiveParts = defineComponent({
|
|
25
|
+
name: "MessagePrimitiveParts",
|
|
26
|
+
slots: Object,
|
|
27
|
+
setup(_, { slots }) {
|
|
28
|
+
const parts = useAuiState((s) => s.message.parts);
|
|
29
|
+
const partKeys = useStableKeys(() => getMessagePartKeys(parts.value));
|
|
30
|
+
const PartView = defineComponent({
|
|
31
|
+
name: "MessagePartView",
|
|
32
|
+
setup() {
|
|
33
|
+
const aui = useAui();
|
|
34
|
+
const type = useAuiState((s) => s.part.type);
|
|
35
|
+
const text = useAuiState((s) => s.part.type === "text" ? s.part.text : "");
|
|
36
|
+
const toolUI = useAuiState((s) => {
|
|
37
|
+
if (s.part.type !== "tool-call") return null;
|
|
38
|
+
return s.optional.tools?.toolUIs[s.part.toolName]?.[0] ?? null;
|
|
39
|
+
});
|
|
40
|
+
const mcpAppRender = useAuiState((s) => s.part.type === "tool-call" && isMcpAppUri(s.part.mcp?.app?.resourceUri) ? s.optional.tools?.mcpApp?.render ?? null : null);
|
|
41
|
+
const toolPart = useAuiState((s) => s.part.type === "tool-call" ? s.part : null);
|
|
42
|
+
const dataRenderer = useAuiState((s) => {
|
|
43
|
+
if (s.part.type !== "data") return null;
|
|
44
|
+
return s.optional.dataRenderers?.renderers[s.part.name]?.[0] ?? null ?? s.optional.dataRenderers?.fallbacks[0] ?? null;
|
|
45
|
+
});
|
|
46
|
+
const dataPart = useAuiState((s) => s.part.type === "data" ? s.part : null);
|
|
47
|
+
return () => {
|
|
48
|
+
if (type.value === "tool-call") {
|
|
49
|
+
const registration = toolUI.value;
|
|
50
|
+
const part = toolPart.value;
|
|
51
|
+
if (registration?.renderText && part) {
|
|
52
|
+
const resolved = resolveToolCallText(registration.renderText, part);
|
|
53
|
+
if (typeof resolved === "string" || typeof resolved === "number") return resolved;
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const Render = registration?.render ?? mcpAppRender.value;
|
|
57
|
+
if (Render && part) return h(Render, { tool: {
|
|
58
|
+
part,
|
|
59
|
+
addResult: aui.part.addToolResult,
|
|
60
|
+
resume: aui.part.resumeToolCall,
|
|
61
|
+
respondToApproval: aui.part.respondToToolApproval,
|
|
62
|
+
...aui.part.unstable_recordInteraction && { unstable_recordInteraction: aui.part.unstable_recordInteraction }
|
|
63
|
+
} });
|
|
64
|
+
}
|
|
65
|
+
if (type.value === "data") {
|
|
66
|
+
const Render = dataRenderer.value;
|
|
67
|
+
const part = dataPart.value;
|
|
68
|
+
if (Render && part) return h(Render, { data: { part } });
|
|
69
|
+
}
|
|
70
|
+
if (type.value === "text") {
|
|
71
|
+
const slot = slots.text;
|
|
72
|
+
return slot ? slot() : h("p", { style: { whiteSpace: "pre-line" } }, text.value);
|
|
73
|
+
}
|
|
74
|
+
const slot = slots[type.value] ?? slots.default;
|
|
75
|
+
if (slot) return slot();
|
|
76
|
+
if (isDevelopment && !warnedTypes.has(type.value)) {
|
|
77
|
+
warnedTypes.add(type.value);
|
|
78
|
+
console.warn(`MessagePrimitiveParts: no slot for part type "${type.value}"; the part renders nothing. Add a #${type.value} or #default slot.`);
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return () => partKeys.value.map((key, index) => h(PartByIndexProvider, {
|
|
85
|
+
index,
|
|
86
|
+
key
|
|
87
|
+
}, { default: () => h(PartView) }));
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
//#endregion
|
|
91
|
+
export { MessagePrimitiveParts, clearPartWarningsForTesting };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=MessagePrimitiveParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessagePrimitiveParts.js","names":[],"sources":["../../src/primitives/MessagePrimitiveParts.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n type Component,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { isMcpAppUri } from \"@assistant-ui/core\";\nimport { getMessagePartKeys } from \"@assistant-ui/core/internal\";\nimport {\n resolveToolCallText,\n type PartMethods,\n} from \"@assistant-ui/core/store\";\nimport { isDevelopment } from \"@assistant-ui/core/store/internal\";\nimport type { AssistantState } from \"@assistant-ui/store/client\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\nimport { PartByIndexProvider } from \"./PartByIndexProvider\";\nimport { useStableKeys } from \"./stableKeys\";\n\nconst warnedTypes = new Set<string>();\n\nexport const clearPartWarningsForTesting = () => warnedTypes.clear();\n\n/**\n * The value of the single `tool` prop passed to a tool UI registered in the\n * `tools` scope. React spreads the part state as individual props; in Vue any\n * prop the component does not declare falls through to `$attrs` and gets\n * stringified onto its root element, so the Vue face passes one `tool` object\n * instead, which a component always declares in full. The tools scope\n * declares renderers as React's `ToolCallMessagePartComponent`, so the Vue\n * face bridges the seam with casts at registration and render; a genuine\n * React renderer arriving through a shared toolkit type-checks at `setToolUI`\n * and then fails when invoked as a Vue component. This type is the Vue-facing\n * contract for custom components. Toolkit `renderText` descriptors resolve\n * through the neutral resolver and render string or number results directly;\n * a react-element-valued descriptor is react-only and renders nothing here.\n */\nexport type ToolUIProps = {\n part: Extract<AssistantState[\"part\"], { type: \"tool-call\" }>;\n addResult: PartMethods[\"addToolResult\"];\n resume: PartMethods[\"resumeToolCall\"];\n respondToApproval: PartMethods[\"respondToToolApproval\"];\n unstable_recordInteraction?: PartMethods[\"unstable_recordInteraction\"];\n};\n\n/** The value of the single `data` prop passed to a Vue data renderer. */\nexport type DataUIProps<T = unknown> = {\n part: Omit<Extract<AssistantState[\"part\"], { type: \"data\" }>, \"data\"> & {\n data: T;\n };\n};\n\n/**\n * Renders the current message's content parts in order, each scoped through\n * {@link PartByIndexProvider}. A `tool-call` part first resolves a renderer\n * registered in the `tools` scope by tool name (`aui.tools.setToolUI`, or a\n * `Tools({ toolkit })` config entry) and renders it with a single `tool` prop\n * of type {@link ToolUIProps}.\n * Otherwise a slot named after the part type (`text`, `reasoning`,\n * `tool-call`, ...) renders that part; the `default` slot is the fallback for\n * types without a named slot, except text, which always renders its text\n * unless a `text` slot overrides it.\n */\nexport const MessagePrimitiveParts = defineComponent({\n name: \"MessagePrimitiveParts\",\n slots: Object as SlotsType<Record<string, (() => VNodeChild[]) | undefined>>,\n setup(_, { slots }) {\n const parts = useAuiState((s) => s.message.parts);\n const partKeys = useStableKeys(() => getMessagePartKeys(parts.value));\n const PartView = defineComponent({\n name: \"MessagePartView\",\n setup() {\n const aui = useAui();\n const type = useAuiState((s) => s.part.type);\n const text = useAuiState((s) =>\n s.part.type === \"text\" ? s.part.text : \"\",\n );\n const toolUI = useAuiState((s) => {\n if (s.part.type !== \"tool-call\") return null;\n return s.optional.tools?.toolUIs[s.part.toolName]?.[0] ?? null;\n });\n const mcpAppRender = useAuiState((s) =>\n s.part.type === \"tool-call\" &&\n isMcpAppUri(s.part.mcp?.app?.resourceUri)\n ? (s.optional.tools?.mcpApp?.render ?? null)\n : null,\n );\n const toolPart = useAuiState((s) =>\n s.part.type === \"tool-call\" ? s.part : null,\n );\n const dataRenderer = useAuiState((s) => {\n if (s.part.type !== \"data\") return null;\n const named =\n s.optional.dataRenderers?.renderers[s.part.name]?.[0] ?? null;\n return named ?? s.optional.dataRenderers?.fallbacks[0] ?? null;\n });\n const dataPart = useAuiState((s) =>\n s.part.type === \"data\" ? s.part : null,\n );\n return () => {\n if (type.value === \"tool-call\") {\n const registration = toolUI.value;\n const part = toolPart.value;\n if (registration?.renderText && part) {\n const resolved = resolveToolCallText(\n registration.renderText,\n part,\n );\n if (\n typeof resolved === \"string\" ||\n typeof resolved === \"number\"\n ) {\n return resolved;\n }\n return null;\n }\n const Render = registration?.render ?? mcpAppRender.value;\n if (Render && part) {\n return h(Render as unknown as Component, {\n tool: {\n part,\n addResult: aui.part.addToolResult,\n resume: aui.part.resumeToolCall,\n respondToApproval: aui.part.respondToToolApproval,\n ...(aui.part.unstable_recordInteraction && {\n unstable_recordInteraction:\n aui.part.unstable_recordInteraction,\n }),\n } satisfies ToolUIProps,\n });\n }\n }\n if (type.value === \"data\") {\n const Render = dataRenderer.value;\n const part = dataPart.value;\n if (Render && part) {\n return h(Render as unknown as Component, {\n data: { part } satisfies DataUIProps,\n });\n }\n }\n if (type.value === \"text\") {\n const slot = slots.text;\n return slot\n ? slot()\n : h(\"p\", { style: { whiteSpace: \"pre-line\" } }, text.value);\n }\n const slot = slots[type.value] ?? slots.default;\n if (slot) return slot();\n if (isDevelopment && !warnedTypes.has(type.value)) {\n warnedTypes.add(type.value);\n console.warn(\n `MessagePrimitiveParts: no slot for part type \"${type.value}\"; the part renders nothing. Add a #${type.value} or #default slot.`,\n );\n }\n return null;\n };\n },\n });\n return () =>\n partKeys.value.map((key, index) =>\n h(PartByIndexProvider, { index, key }, { default: () => h(PartView) }),\n );\n },\n});\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,8BAAc,IAAI,IAAY;AAEpC,MAAa,oCAAoC,YAAY,MAAM;;;;;;;;;;;;AA0CnE,MAAa,wBAAwB,gBAAgB;CACnD,MAAM;CACN,OAAO;CACP,MAAM,GAAG,EAAE,SAAS;EAClB,MAAM,QAAQ,aAAa,MAAM,EAAE,QAAQ,KAAK;EAChD,MAAM,WAAW,oBAAoB,mBAAmB,MAAM,KAAK,CAAC;EACpE,MAAM,WAAW,gBAAgB;GAC/B,MAAM;GACN,QAAQ;IACN,MAAM,MAAM,OAAO;IACnB,MAAM,OAAO,aAAa,MAAM,EAAE,KAAK,IAAI;IAC3C,MAAM,OAAO,aAAa,MACxB,EAAE,KAAK,SAAS,SAAS,EAAE,KAAK,OAAO,EACzC;IACA,MAAM,SAAS,aAAa,MAAM;KAChC,IAAI,EAAE,KAAK,SAAS,aAAa,OAAO;KACxC,OAAO,EAAE,SAAS,OAAO,QAAQ,EAAE,KAAK,SAAS,GAAG,MAAM;IAC5D,CAAC;IACD,MAAM,eAAe,aAAa,MAChC,EAAE,KAAK,SAAS,eAChB,YAAY,EAAE,KAAK,KAAK,KAAK,WAAW,IACnC,EAAE,SAAS,OAAO,QAAQ,UAAU,OACrC,IACN;IACA,MAAM,WAAW,aAAa,MAC5B,EAAE,KAAK,SAAS,cAAc,EAAE,OAAO,IACzC;IACA,MAAM,eAAe,aAAa,MAAM;KACtC,IAAI,EAAE,KAAK,SAAS,QAAQ,OAAO;KAGnC,OADE,EAAE,SAAS,eAAe,UAAU,EAAE,KAAK,KAAK,GAAG,MAAM,QAC3C,EAAE,SAAS,eAAe,UAAU,MAAM;IAC5D,CAAC;IACD,MAAM,WAAW,aAAa,MAC5B,EAAE,KAAK,SAAS,SAAS,EAAE,OAAO,IACpC;IACA,aAAa;KACX,IAAI,KAAK,UAAU,aAAa;MAC9B,MAAM,eAAe,OAAO;MAC5B,MAAM,OAAO,SAAS;MACtB,IAAI,cAAc,cAAc,MAAM;OACpC,MAAM,WAAW,oBACf,aAAa,YACb,IACF;OACA,IACE,OAAO,aAAa,YACpB,OAAO,aAAa,UAEpB,OAAO;OAET,OAAO;MACT;MACA,MAAM,SAAS,cAAc,UAAU,aAAa;MACpD,IAAI,UAAU,MACZ,OAAO,EAAE,QAAgC,EACvC,MAAM;OACJ;OACA,WAAW,IAAI,KAAK;OACpB,QAAQ,IAAI,KAAK;OACjB,mBAAmB,IAAI,KAAK;OAC5B,GAAI,IAAI,KAAK,8BAA8B,EACzC,4BACE,IAAI,KAAK,2BACb;MACF,EACF,CAAC;KAEL;KACA,IAAI,KAAK,UAAU,QAAQ;MACzB,MAAM,SAAS,aAAa;MAC5B,MAAM,OAAO,SAAS;MACtB,IAAI,UAAU,MACZ,OAAO,EAAE,QAAgC,EACvC,MAAM,EAAE,KAAK,EACf,CAAC;KAEL;KACA,IAAI,KAAK,UAAU,QAAQ;MACzB,MAAM,OAAO,MAAM;MACnB,OAAO,OACH,KAAK,IACL,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,WAAW,EAAE,GAAG,KAAK,KAAK;KAC9D;KACA,MAAM,OAAO,MAAM,KAAK,UAAU,MAAM;KACxC,IAAI,MAAM,OAAO,KAAK;KACtB,IAAI,iBAAiB,CAAC,YAAY,IAAI,KAAK,KAAK,GAAG;MACjD,YAAY,IAAI,KAAK,KAAK;MAC1B,QAAQ,KACN,iDAAiD,KAAK,MAAM,sCAAsC,KAAK,MAAM,mBAC/G;KACF;KACA,OAAO;IACT;GACF;EACF,CAAC;EACD,aACE,SAAS,MAAM,KAAK,KAAK,UACvB,EAAE,qBAAqB;GAAE;GAAO;EAAI,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CACvE;CACJ;AACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type SlotsType, type VNodeChild } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* Scopes the subtree to the message part at `index`: descendants read the
|
|
4
|
+
* part through `s.part`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PartByIndexProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
7
|
+
index: {
|
|
8
|
+
type: NumberConstructor;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
14
|
+
index: {
|
|
15
|
+
type: NumberConstructor;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
18
|
+
}>> & Readonly<{}>, {}, SlotsType<{
|
|
19
|
+
default?: () => VNodeChild[];
|
|
20
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
21
|
+
//# sourceMappingURL=PartByIndexProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PartByIndexProvider.d.ts","sourceRoot":"","sources":["../../src/primitives/PartByIndexProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAOb;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;cAQS,MAAM,UAAU,EAAE;yEAmCzD,CAAC"}
|