@assistant-ui/react 0.14.29 → 0.15.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.
Files changed (142) hide show
  1. package/dist/client/ExternalThread.js +4 -3
  2. package/dist/client/ExternalThread.js.map +1 -1
  3. package/dist/client/InMemoryThreadList.js +3 -3
  4. package/dist/client/InMemoryThreadList.js.map +1 -1
  5. package/dist/context/index.d.ts +1 -8
  6. package/dist/context/index.js +1 -8
  7. package/dist/hooks/useToolCallElapsed.js +24 -29
  8. package/dist/hooks/useToolCallElapsed.js.map +1 -1
  9. package/dist/index.d.ts +1 -8
  10. package/dist/index.js +1 -8
  11. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +3 -3
  12. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
  13. package/dist/mcp-apps/McpAppRenderer.js +1 -1
  14. package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
  15. package/dist/model-context/makeAssistantVisible.js +26 -25
  16. package/dist/model-context/makeAssistantVisible.js.map +1 -1
  17. package/dist/primitives/actionBar/ActionBarExportMarkdown.js +3 -3
  18. package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
  19. package/dist/primitives/attachment/AttachmentRemove.js +3 -3
  20. package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
  21. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +3 -3
  22. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
  23. package/dist/primitives/composer/ComposerAddAttachment.js +3 -3
  24. package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
  25. package/dist/primitives/composer/ComposerAttachmentDropzone.js +1 -1
  26. package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
  27. package/dist/primitives/composer/ComposerInput.js +13 -13
  28. package/dist/primitives/composer/ComposerInput.js.map +1 -1
  29. package/dist/primitives/composer/ComposerQuote.js +1 -1
  30. package/dist/primitives/composer/ComposerQuote.js.map +1 -1
  31. package/dist/primitives/composer/ComposerStopDictation.js +3 -3
  32. package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
  33. package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
  34. package/dist/primitives/composer/trigger/triggerSelectionResource.js +3 -3
  35. package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
  36. package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
  37. package/dist/primitives/message/MessagePartsGrouped.js +67 -89
  38. package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
  39. package/dist/primitives/message/MessageRoot.js +3 -3
  40. package/dist/primitives/message/MessageRoot.js.map +1 -1
  41. package/dist/primitives/queueItem/QueueItemRemove.js +3 -3
  42. package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -1
  43. package/dist/primitives/queueItem/QueueItemSteer.js +3 -3
  44. package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -1
  45. package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +1 -1
  46. package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -1
  47. package/dist/primitives/suggestion/SuggestionTrigger.js +16 -15
  48. package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
  49. package/dist/unstable/useComposerInput.js +2 -2
  50. package/dist/unstable/useComposerInput.js.map +1 -1
  51. package/dist/unstable/useComposerInputHistory.js +6 -6
  52. package/dist/unstable/useComposerInputHistory.js.map +1 -1
  53. package/dist/unstable/useMentionAdapter.js +1 -1
  54. package/dist/unstable/useMentionAdapter.js.map +1 -1
  55. package/dist/utils/smooth/SmoothContext.js +3 -3
  56. package/dist/utils/smooth/SmoothContext.js.map +1 -1
  57. package/dist/utils/smooth/useSmooth.js +1 -1
  58. package/dist/utils/smooth/useSmooth.js.map +1 -1
  59. package/dist/utils/useToolArgsFieldStatus.d.ts +2 -2
  60. package/package.json +5 -5
  61. package/src/client/ExternalThread.ts +5 -3
  62. package/src/client/InMemoryThreadList.ts +3 -3
  63. package/src/context/index.ts +0 -44
  64. package/src/hooks/useToolCallElapsed.ts +9 -12
  65. package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.test.tsx +5 -9
  66. package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts +1 -1
  67. package/src/mcp-apps/McpAppRenderer.tsx +1 -1
  68. package/src/model-context/makeAssistantVisible.test.tsx +1 -1
  69. package/src/model-context/makeAssistantVisible.tsx +1 -1
  70. package/src/primitives/actionBar/ActionBarExportMarkdown.tsx +1 -1
  71. package/src/primitives/attachment/AttachmentRemove.ts +1 -1
  72. package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.ts +1 -1
  73. package/src/primitives/composer/ComposerAddAttachment.test.tsx +2 -2
  74. package/src/primitives/composer/ComposerAddAttachment.ts +1 -1
  75. package/src/primitives/composer/ComposerAttachmentDropzone.test.tsx +2 -2
  76. package/src/primitives/composer/ComposerAttachmentDropzone.tsx +1 -1
  77. package/src/primitives/composer/ComposerInput.test.tsx +7 -7
  78. package/src/primitives/composer/ComposerInput.tsx +13 -13
  79. package/src/primitives/composer/ComposerQuote.tsx +1 -1
  80. package/src/primitives/composer/ComposerStopDictation.ts +1 -1
  81. package/src/primitives/composer/trigger/triggerSelectionResource.ts +7 -9
  82. package/src/primitives/message/MessagePartsGrouped.tsx +6 -8
  83. package/src/primitives/message/MessageRoot.tsx +1 -1
  84. package/src/primitives/queueItem/QueueItemRemove.ts +1 -1
  85. package/src/primitives/queueItem/QueueItemSteer.ts +1 -1
  86. package/src/primitives/selectionToolbar/SelectionToolbarQuote.tsx +1 -1
  87. package/src/primitives/suggestion/SuggestionTrigger.ts +9 -9
  88. package/src/tests/DataRenderers.test.tsx +1 -1
  89. package/src/tests/RemoteThreadListRuntime.deferredProvider.test.tsx +3 -3
  90. package/src/tests/external-thread-attachments.test.tsx +21 -23
  91. package/src/tests/external-thread-branches.test.tsx +10 -10
  92. package/src/tests/external-thread-parity.test.tsx +18 -20
  93. package/src/tests/local-runtime-queue.test.tsx +29 -34
  94. package/src/tests/messagePartSwitchRace.test.tsx +30 -13
  95. package/src/unstable/useComposerInput.test.tsx +2 -2
  96. package/src/unstable/useComposerInput.ts +2 -2
  97. package/src/unstable/useComposerInputHistory.test.tsx +3 -3
  98. package/src/unstable/useComposerInputHistory.ts +6 -6
  99. package/src/unstable/useMentionAdapter.ts +1 -1
  100. package/src/utils/smooth/SmoothContext.tsx +1 -1
  101. package/src/utils/smooth/useSmooth.test.tsx +1 -1
  102. package/src/utils/smooth/useSmooth.ts +1 -1
  103. package/dist/context/react/utils/createStateHookForRuntime.d.ts +0 -34
  104. package/dist/context/react/utils/createStateHookForRuntime.d.ts.map +0 -1
  105. package/dist/context/react/utils/createStateHookForRuntime.js +0 -21
  106. package/dist/context/react/utils/createStateHookForRuntime.js.map +0 -1
  107. package/dist/legacy-runtime/hooks/AssistantContext.d.ts +0 -74
  108. package/dist/legacy-runtime/hooks/AssistantContext.d.ts.map +0 -1
  109. package/dist/legacy-runtime/hooks/AssistantContext.js +0 -29
  110. package/dist/legacy-runtime/hooks/AssistantContext.js.map +0 -1
  111. package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +0 -1007
  112. package/dist/legacy-runtime/hooks/AttachmentContext.d.ts.map +0 -1
  113. package/dist/legacy-runtime/hooks/AttachmentContext.js +0 -47
  114. package/dist/legacy-runtime/hooks/AttachmentContext.js.map +0 -1
  115. package/dist/legacy-runtime/hooks/ComposerContext.d.ts +0 -141
  116. package/dist/legacy-runtime/hooks/ComposerContext.d.ts.map +0 -1
  117. package/dist/legacy-runtime/hooks/ComposerContext.js +0 -65
  118. package/dist/legacy-runtime/hooks/ComposerContext.js.map +0 -1
  119. package/dist/legacy-runtime/hooks/MessageContext.d.ts +0 -155
  120. package/dist/legacy-runtime/hooks/MessageContext.d.ts.map +0 -1
  121. package/dist/legacy-runtime/hooks/MessageContext.js +0 -68
  122. package/dist/legacy-runtime/hooks/MessageContext.js.map +0 -1
  123. package/dist/legacy-runtime/hooks/MessagePartContext.d.ts +0 -44
  124. package/dist/legacy-runtime/hooks/MessagePartContext.d.ts.map +0 -1
  125. package/dist/legacy-runtime/hooks/MessagePartContext.js +0 -26
  126. package/dist/legacy-runtime/hooks/MessagePartContext.js.map +0 -1
  127. package/dist/legacy-runtime/hooks/ThreadContext.d.ts +0 -139
  128. package/dist/legacy-runtime/hooks/ThreadContext.d.ts.map +0 -1
  129. package/dist/legacy-runtime/hooks/ThreadContext.js +0 -84
  130. package/dist/legacy-runtime/hooks/ThreadContext.js.map +0 -1
  131. package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts +0 -44
  132. package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts.map +0 -1
  133. package/dist/legacy-runtime/hooks/ThreadListItemContext.js +0 -26
  134. package/dist/legacy-runtime/hooks/ThreadListItemContext.js.map +0 -1
  135. package/src/context/react/utils/createStateHookForRuntime.ts +0 -82
  136. package/src/legacy-runtime/hooks/AssistantContext.ts +0 -67
  137. package/src/legacy-runtime/hooks/AttachmentContext.ts +0 -99
  138. package/src/legacy-runtime/hooks/ComposerContext.ts +0 -131
  139. package/src/legacy-runtime/hooks/MessageContext.ts +0 -127
  140. package/src/legacy-runtime/hooks/MessagePartContext.ts +0 -32
  141. package/src/legacy-runtime/hooks/ThreadContext.ts +0 -120
  142. package/src/legacy-runtime/hooks/ThreadListItemContext.ts +0 -36
@@ -1 +0,0 @@
1
- {"version":3,"file":"AttachmentContext.d.ts","names":[],"sources":["../../../src/legacy-runtime/hooks/AttachmentContext.ts"],"mappings":";;;;;iBASgB,qBAAqB;EACnC;IACE;iBACY,qBAAqB;EACnC;IACE;iBAgBY,mCAAmC;EACjD;IACE;iBACY,mCAAmC;EACjD;IACE;iBAaY,iCAAiC;EAC/C;IACE;iBACY,iCAAiC;EAC/C;IACE;iBAcY,4BAA4B;EAC1C;IACE;iBACY,4BAA4B;EAC1C;IACE;;;;cAgBS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAGA"}
@@ -1,47 +0,0 @@
1
- "use client";
2
- import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
3
- import { useAui, useAuiState } from "@assistant-ui/store";
4
- import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
5
- //#region src/legacy-runtime/hooks/AttachmentContext.ts
6
- function useAttachmentRuntime(options) {
7
- const $ = c(2);
8
- const aui = useAui();
9
- let t0;
10
- if ($[0] !== aui) {
11
- t0 = () => aui.attachment.source ? aui.attachment().__internal_getRuntime?.() ?? null : null;
12
- $[0] = aui;
13
- $[1] = t0;
14
- } else t0 = $[1];
15
- const runtime = useAuiState(t0);
16
- if (!runtime && !options?.optional) throw new Error("AttachmentRuntime is not available");
17
- return runtime;
18
- }
19
- function useThreadComposerAttachmentRuntime(options) {
20
- const attachmentRuntime = useAttachmentRuntime(options);
21
- if (!attachmentRuntime) return null;
22
- if (attachmentRuntime.source !== "thread-composer") throw new Error("This component must be used within a thread's ComposerPrimitive.Attachments component.");
23
- return attachmentRuntime;
24
- }
25
- function useEditComposerAttachmentRuntime(options) {
26
- const attachmentRuntime = useAttachmentRuntime(options);
27
- if (!attachmentRuntime) return null;
28
- if (attachmentRuntime.source !== "edit-composer") throw new Error("This component must be used within a message's ComposerPrimitive.Attachments component.");
29
- return attachmentRuntime;
30
- }
31
- function useMessageAttachmentRuntime(options) {
32
- const attachmentRuntime = useAttachmentRuntime(options);
33
- if (!attachmentRuntime) return null;
34
- if (attachmentRuntime.source !== "message") throw new Error("This component must be used within a MessagePrimitive.Attachments component.");
35
- return attachmentRuntime;
36
- }
37
- /**
38
- * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.attachment)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
39
- */
40
- const useAttachment = createStateHookForRuntime(useAttachmentRuntime);
41
- const useThreadComposerAttachment = createStateHookForRuntime(useThreadComposerAttachmentRuntime);
42
- const useEditComposerAttachment = createStateHookForRuntime(useEditComposerAttachmentRuntime);
43
- const useMessageAttachment = createStateHookForRuntime(useMessageAttachmentRuntime);
44
- //#endregion
45
- export { useAttachment, useAttachmentRuntime, useEditComposerAttachment, useEditComposerAttachmentRuntime, useMessageAttachment, useMessageAttachmentRuntime, useThreadComposerAttachment, useThreadComposerAttachmentRuntime };
46
-
47
- //# sourceMappingURL=AttachmentContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AttachmentContext.js","names":["c","_c","AttachmentRuntime","createStateHookForRuntime","useAui","useAuiState","useAttachmentRuntime","options","optional","$","aui","t0","attachment","source","__internal_getRuntime","runtime","Error","useThreadComposerAttachmentRuntime","attachmentRuntime","useEditComposerAttachmentRuntime","useMessageAttachmentRuntime","useAttachment","useThreadComposerAttachment","useEditComposerAttachment","useMessageAttachment"],"sources":["../../../src/legacy-runtime/hooks/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { AttachmentRuntime } from \"../runtime/AttachmentRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.attachment()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.attachment.source\n ? (aui.attachment().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"AttachmentRuntime is not available\");\n }\n return runtime;\n}\n\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"thread-composer\">;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"thread-composer\")\n throw new Error(\n \"This component must be used within a thread's ComposerPrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"thread-composer\">;\n}\n\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"edit-composer\">;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"edit-composer\")\n throw new Error(\n \"This component must be used within a message's ComposerPrimitive.Attachments component.\",\n );\n\n return attachmentRuntime as AttachmentRuntime<\"edit-composer\">;\n}\n\nexport function useMessageAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"message\">;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"message\")\n throw new Error(\n \"This component must be used within a MessagePrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"message\">;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.attachment)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useAttachment = createStateHookForRuntime(useAttachmentRuntime);\n\nexport const useThreadComposerAttachment = createStateHookForRuntime(\n useThreadComposerAttachmentRuntime,\n);\nexport const useEditComposerAttachment = createStateHookForRuntime(\n useEditComposerAttachmentRuntime,\n);\nexport const useMessageAttachment = createStateHookForRuntime(\n useMessageAttachmentRuntime,\n);\n"],"mappings":";;;;;AAeA,SAAOM,qBAAAC,SAAA;CAAA,MAAAE,IAAAR,EAAA,CAAA;CAGL,MAAAS,MAAYN,OAAO;CAAE,IAAAO;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,WAAWC,SACTH,IAAGE,WAAY,CAAC,CAAAE,wBAAiC,KAAjD,OADL;EAEQL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHV,MAAAM,UAAgBV,YAAYM,EAI5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,oCAAoC;CACrD,OACMD;AAAO;AAShB,SAAOE,mCAAAV,SAAA;CAGL,MAAAW,oBAA0BZ,qBAAqBC,OAAO;CACtD,IAAI,CAACW,mBAAiB,OAAS;CAC/B,IAAIA,kBAAiBL,WAAY,mBAC/B,MAAM,IAAIG,MACR,wFACF;CAAE,OACGE;AAAyD;AASlE,SAAOC,iCAAAZ,SAAA;CAGL,MAAAW,oBAA0BZ,qBAAqBC,OAAO;CACtD,IAAI,CAACW,mBAAiB,OAAS;CAC/B,IAAIA,kBAAiBL,WAAY,iBAC/B,MAAM,IAAIG,MACR,yFACF;CAAE,OAEGE;AAAuD;AAShE,SAAOE,4BAAAb,SAAA;CAGL,MAAAW,oBAA0BZ,qBAAqBC,OAAO;CACtD,IAAI,CAACW,mBAAiB,OAAS;CAC/B,IAAIA,kBAAiBL,WAAY,WAC/B,MAAM,IAAIG,MACR,8EACF;CAAE,OACGE;AAAiD;;;;AAM1D,MAAaG,gBAAgBlB,0BAA0BG,oBAAoB;AAE3E,MAAagB,8BAA8BnB,0BACzCc,kCACF;AACA,MAAaM,4BAA4BpB,0BACvCgB,gCACF;AACA,MAAaK,uBAAuBrB,0BAClCiB,2BACF"}
@@ -1,141 +0,0 @@
1
- import { ComposerRuntime } from "../runtime/ComposerRuntime.js";
2
- //#region src/legacy-runtime/hooks/ComposerContext.d.ts
3
- /**
4
- * @deprecated Use {@link useAui} with `aui.composer()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
5
- *
6
- * Hook to access the ComposerRuntime from the current context.
7
- *
8
- * The ComposerRuntime provides access to composer state and actions for message
9
- * composition, including text input, attachments, and sending functionality.
10
- * This hook automatically resolves to either the message's edit composer or
11
- * the thread's main composer depending on the context.
12
- *
13
- * @param options Configuration options
14
- * @param options.optional Whether the hook should return null if no context is found
15
- * @returns The ComposerRuntime instance, or null if optional is true and no context exists
16
- *
17
- * @example
18
- * ```tsx
19
- * // Before:
20
- * function ComposerActions() {
21
- * const runtime = useComposerRuntime();
22
- * const handleSend = () => {
23
- * if (runtime.getState().canSend) {
24
- * runtime.send();
25
- * }
26
- * };
27
- * const handleCancel = () => {
28
- * if (runtime.getState().canCancel) {
29
- * runtime.cancel();
30
- * }
31
- * };
32
- * return (
33
- * <div>
34
- * <button onClick={handleSend}>Send</button>
35
- * <button onClick={handleCancel}>Cancel</button>
36
- * </div>
37
- * );
38
- * }
39
- *
40
- * // After:
41
- * function ComposerActions() {
42
- * const aui = useAui();
43
- * const canSend = useAuiState((s) => s.composer.canSend);
44
- * const canCancel = useAuiState((s) => s.composer.canCancel);
45
- * const handleSend = () => {
46
- * if (canSend) {
47
- * aui.composer().send();
48
- * }
49
- * };
50
- * const handleCancel = () => {
51
- * if (canCancel) {
52
- * aui.composer().cancel();
53
- * }
54
- * };
55
- * return (
56
- * <div>
57
- * <button onClick={handleSend}>Send</button>
58
- * <button onClick={handleCancel}>Cancel</button>
59
- * </div>
60
- * );
61
- * }
62
- * ```
63
- */
64
- declare function useComposerRuntime(options?: {
65
- optional?: false | undefined;
66
- }): ComposerRuntime;
67
- declare function useComposerRuntime(options?: {
68
- optional?: boolean | undefined;
69
- }): ComposerRuntime | null;
70
- /**
71
- * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
72
- *
73
- * Hook to access the current composer state.
74
- *
75
- * This hook provides reactive access to the composer's state, including text content,
76
- * attachments, editing status, and send/cancel capabilities.
77
- *
78
- * @param selector Optional selector function to pick specific state properties
79
- * @returns The selected composer state or the entire composer state if no selector provided
80
- *
81
- * @example
82
- * ```tsx
83
- * // Before:
84
- * function ComposerStatus() {
85
- * const text = useComposer((state) => state.text);
86
- * const canSend = useComposer((state) => state.canSend);
87
- * const attachmentCount = useComposer((state) => state.attachments.length);
88
- * return (
89
- * <div>
90
- * Text: {text.length} chars,
91
- * Attachments: {attachmentCount},
92
- * Can send: {canSend}
93
- * </div>
94
- * );
95
- * }
96
- *
97
- * // After:
98
- * function ComposerStatus() {
99
- * const text = useAuiState((s) => s.composer.text);
100
- * const canSend = useAuiState((s) => s.composer.canSend);
101
- * const attachmentCount = useAuiState((s) => s.composer.attachments.length);
102
- * return (
103
- * <div>
104
- * Text: {text.length} chars,
105
- * Attachments: {attachmentCount},
106
- * Can send: {canSend}
107
- * </div>
108
- * );
109
- * }
110
- * ```
111
- */
112
- declare const useComposer: {
113
- (): import("@assistant-ui/core").ComposerState;
114
- <TSelected>(selector: (state: import("@assistant-ui/core").ComposerState) => TSelected): TSelected;
115
- <TSelected>(selector: ((state: import("@assistant-ui/core").ComposerState) => TSelected) | undefined): import("@assistant-ui/core").ComposerState | TSelected;
116
- (options: {
117
- optional?: false | undefined;
118
- }): import("@assistant-ui/core").ComposerState;
119
- (options: {
120
- optional?: boolean | undefined;
121
- }): import("@assistant-ui/core").ComposerState | null;
122
- <TSelected>(options: {
123
- optional?: false | undefined;
124
- selector: (state: import("@assistant-ui/core").ComposerState) => TSelected;
125
- }): TSelected;
126
- <TSelected>(options: {
127
- optional?: false | undefined;
128
- selector: ((state: import("@assistant-ui/core").ComposerState) => TSelected) | undefined;
129
- }): import("@assistant-ui/core").ComposerState | TSelected;
130
- <TSelected>(options: {
131
- optional?: boolean | undefined;
132
- selector: (state: import("@assistant-ui/core").ComposerState) => TSelected;
133
- }): TSelected | null;
134
- <TSelected>(options: {
135
- optional?: boolean | undefined;
136
- selector: ((state: import("@assistant-ui/core").ComposerState) => TSelected) | undefined;
137
- }): import("@assistant-ui/core").ComposerState | TSelected | null;
138
- };
139
- //#endregion
140
- export { useComposer, useComposerRuntime };
141
- //# sourceMappingURL=ComposerContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComposerContext.d.ts","names":[],"sources":["../../../src/legacy-runtime/hooks/ComposerContext.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmEgB,mBAAmB;EACjC;IACE;iBACY,mBAAmB;EACjC;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0DS"}
@@ -1,65 +0,0 @@
1
- "use client";
2
- import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
3
- import { useAui, useAuiState } from "@assistant-ui/store";
4
- import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
5
- //#region src/legacy-runtime/hooks/ComposerContext.ts
6
- function useComposerRuntime(options) {
7
- const $ = c(2);
8
- const aui = useAui();
9
- let t0;
10
- if ($[0] !== aui) {
11
- t0 = () => aui.composer.source ? aui.composer().__internal_getRuntime?.() ?? null : null;
12
- $[0] = aui;
13
- $[1] = t0;
14
- } else t0 = $[1];
15
- const runtime = useAuiState(t0);
16
- if (!runtime && !options?.optional) throw new Error("ComposerRuntime is not available");
17
- return runtime;
18
- }
19
- /**
20
- * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
21
- *
22
- * Hook to access the current composer state.
23
- *
24
- * This hook provides reactive access to the composer's state, including text content,
25
- * attachments, editing status, and send/cancel capabilities.
26
- *
27
- * @param selector Optional selector function to pick specific state properties
28
- * @returns The selected composer state or the entire composer state if no selector provided
29
- *
30
- * @example
31
- * ```tsx
32
- * // Before:
33
- * function ComposerStatus() {
34
- * const text = useComposer((state) => state.text);
35
- * const canSend = useComposer((state) => state.canSend);
36
- * const attachmentCount = useComposer((state) => state.attachments.length);
37
- * return (
38
- * <div>
39
- * Text: {text.length} chars,
40
- * Attachments: {attachmentCount},
41
- * Can send: {canSend}
42
- * </div>
43
- * );
44
- * }
45
- *
46
- * // After:
47
- * function ComposerStatus() {
48
- * const text = useAuiState((s) => s.composer.text);
49
- * const canSend = useAuiState((s) => s.composer.canSend);
50
- * const attachmentCount = useAuiState((s) => s.composer.attachments.length);
51
- * return (
52
- * <div>
53
- * Text: {text.length} chars,
54
- * Attachments: {attachmentCount},
55
- * Can send: {canSend}
56
- * </div>
57
- * );
58
- * }
59
- * ```
60
- */
61
- const useComposer = createStateHookForRuntime(useComposerRuntime);
62
- //#endregion
63
- export { useComposer, useComposerRuntime };
64
-
65
- //# sourceMappingURL=ComposerContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComposerContext.js","names":["c","_c","useAui","useAuiState","ComposerRuntime","createStateHookForRuntime","useComposerRuntime","options","optional","$","aui","t0","composer","source","__internal_getRuntime","runtime","Error","useComposer"],"sources":["../../../src/legacy-runtime/hooks/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { ComposerRuntime } from \"../runtime/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.composer()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the ComposerRuntime from the current context.\n *\n * The ComposerRuntime provides access to composer state and actions for message\n * composition, including text input, attachments, and sending functionality.\n * This hook automatically resolves to either the message's edit composer or\n * the thread's main composer depending on the context.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The ComposerRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerActions() {\n * const runtime = useComposerRuntime();\n * const handleSend = () => {\n * if (runtime.getState().canSend) {\n * runtime.send();\n * }\n * };\n * const handleCancel = () => {\n * if (runtime.getState().canCancel) {\n * runtime.cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerActions() {\n * const aui = useAui();\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const canCancel = useAuiState((s) => s.composer.canCancel);\n * const handleSend = () => {\n * if (canSend) {\n * aui.composer().send();\n * }\n * };\n * const handleCancel = () => {\n * if (canCancel) {\n * aui.composer().cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useComposerRuntime(options?: {\n optional?: false | undefined;\n}): ComposerRuntime;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.composer.source\n ? (aui.composer().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ComposerRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current composer state.\n *\n * This hook provides reactive access to the composer's state, including text content,\n * attachments, editing status, and send/cancel capabilities.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected composer state or the entire composer state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerStatus() {\n * const text = useComposer((state) => state.text);\n * const canSend = useComposer((state) => state.canSend);\n * const attachmentCount = useComposer((state) => state.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerStatus() {\n * const text = useAuiState((s) => s.composer.text);\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const attachmentCount = useAuiState((s) => s.composer.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n * ```\n */\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":";;;;;AAyEA,SAAOM,mBAAAC,SAAA;CAAA,MAAAE,IAAAR,EAAA,CAAA;CAGL,MAAAS,MAAYR,OAAO;CAAE,IAAAS;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,SAASC,SACPH,IAAGE,SAAU,CAAC,CAAAE,wBAAiC,KAA/C,OADL;EAEQL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHV,MAAAM,UAAgBZ,YAAYQ,EAI5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,kCAAkC;CACnD,OACMD;AAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6ChB,MAAaE,cAAcZ,0BAA0BC,kBAAkB"}
@@ -1,155 +0,0 @@
1
- import { MessageRuntime } from "../runtime/MessageRuntime.js";
2
- //#region src/legacy-runtime/hooks/MessageContext.d.ts
3
- /**
4
- * @deprecated Use {@link useAui} with `aui.message()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
5
- *
6
- * Hook to access the MessageRuntime from the current context.
7
- *
8
- * The MessageRuntime provides access to message-level state and actions,
9
- * including message content, status, editing capabilities, and branching.
10
- *
11
- * @param options Configuration options
12
- * @param options.optional Whether the hook should return null if no context is found
13
- * @returns The MessageRuntime instance, or null if optional is true and no context exists
14
- *
15
- * @example
16
- * ```tsx
17
- * // Before:
18
- * function MessageActions() {
19
- * const runtime = useMessageRuntime();
20
- * const handleReload = () => {
21
- * runtime.reload();
22
- * };
23
- * const handleEdit = () => {
24
- * runtime.startEdit();
25
- * };
26
- * return (
27
- * <div>
28
- * <button onClick={handleReload}>Reload</button>
29
- * <button onClick={handleEdit}>Edit</button>
30
- * </div>
31
- * );
32
- * }
33
- *
34
- * // After:
35
- * function MessageActions() {
36
- * const aui = useAui();
37
- * const handleReload = () => {
38
- * aui.message().reload();
39
- * };
40
- * const handleEdit = () => {
41
- * aui.message().startEdit();
42
- * };
43
- * return (
44
- * <div>
45
- * <button onClick={handleReload}>Reload</button>
46
- * <button onClick={handleEdit}>Edit</button>
47
- * </div>
48
- * );
49
- * }
50
- * ```
51
- */
52
- declare function useMessageRuntime(options?: {
53
- optional?: false | undefined;
54
- }): MessageRuntime;
55
- declare function useMessageRuntime(options?: {
56
- optional?: boolean | undefined;
57
- }): MessageRuntime | null;
58
- /**
59
- * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
60
- *
61
- * Hook to access the current message state.
62
- *
63
- * This hook provides reactive access to the message's state, including content,
64
- * role, status, and other message-level properties.
65
- *
66
- * @param selector Optional selector function to pick specific state properties
67
- * @returns The selected message state or the entire message state if no selector provided
68
- *
69
- * @example
70
- * ```tsx
71
- * // Before:
72
- * function MessageContent() {
73
- * const role = useMessage((state) => state.role);
74
- * const content = useMessage((state) => state.content);
75
- * const isLoading = useMessage((state) => state.status.type === "running");
76
- * return (
77
- * <div className={`message-${role}`}>
78
- * {isLoading ? "Loading..." : content.map(part => part.text).join("")}
79
- * </div>
80
- * );
81
- * }
82
- *
83
- * // After:
84
- * function MessageContent() {
85
- * const role = useAuiState((s) => s.message.role);
86
- * const content = useAuiState((s) => s.message.content);
87
- * const isLoading = useAuiState((s) => s.message.status.type === "running");
88
- * return (
89
- * <div className={`message-${role}`}>
90
- * {isLoading ? "Loading..." : content.map(part => part.text).join("")}
91
- * </div>
92
- * );
93
- * }
94
- * ```
95
- */
96
- declare const useMessage: {
97
- (): import("@assistant-ui/core").MessageState;
98
- <TSelected>(selector: (state: import("@assistant-ui/core").MessageState) => TSelected): TSelected;
99
- <TSelected>(selector: ((state: import("@assistant-ui/core").MessageState) => TSelected) | undefined): import("@assistant-ui/core").MessageState | TSelected;
100
- (options: {
101
- optional?: false | undefined;
102
- }): import("@assistant-ui/core").MessageState;
103
- (options: {
104
- optional?: boolean | undefined;
105
- }): import("@assistant-ui/core").MessageState | null;
106
- <TSelected>(options: {
107
- optional?: false | undefined;
108
- selector: (state: import("@assistant-ui/core").MessageState) => TSelected;
109
- }): TSelected;
110
- <TSelected>(options: {
111
- optional?: false | undefined;
112
- selector: ((state: import("@assistant-ui/core").MessageState) => TSelected) | undefined;
113
- }): import("@assistant-ui/core").MessageState | TSelected;
114
- <TSelected>(options: {
115
- optional?: boolean | undefined;
116
- selector: (state: import("@assistant-ui/core").MessageState) => TSelected;
117
- }): TSelected | null;
118
- <TSelected>(options: {
119
- optional?: boolean | undefined;
120
- selector: ((state: import("@assistant-ui/core").MessageState) => TSelected) | undefined;
121
- }): import("@assistant-ui/core").MessageState | TSelected | null;
122
- };
123
- /**
124
- * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
125
- */
126
- declare const useEditComposer: {
127
- (): import("@assistant-ui/core").EditComposerState;
128
- <TSelected>(selector: (state: import("@assistant-ui/core").EditComposerState) => TSelected): TSelected;
129
- <TSelected>(selector: ((state: import("@assistant-ui/core").EditComposerState) => TSelected) | undefined): import("@assistant-ui/core").EditComposerState | TSelected;
130
- (options: {
131
- optional?: false | undefined;
132
- }): import("@assistant-ui/core").EditComposerState;
133
- (options: {
134
- optional?: boolean | undefined;
135
- }): import("@assistant-ui/core").EditComposerState | null;
136
- <TSelected>(options: {
137
- optional?: false | undefined;
138
- selector: (state: import("@assistant-ui/core").EditComposerState) => TSelected;
139
- }): TSelected;
140
- <TSelected>(options: {
141
- optional?: false | undefined;
142
- selector: ((state: import("@assistant-ui/core").EditComposerState) => TSelected) | undefined;
143
- }): import("@assistant-ui/core").EditComposerState | TSelected;
144
- <TSelected>(options: {
145
- optional?: boolean | undefined;
146
- selector: (state: import("@assistant-ui/core").EditComposerState) => TSelected;
147
- }): TSelected | null;
148
- <TSelected>(options: {
149
- optional?: boolean | undefined;
150
- selector: ((state: import("@assistant-ui/core").EditComposerState) => TSelected) | undefined;
151
- }): import("@assistant-ui/core").EditComposerState | TSelected | null;
152
- };
153
- //#endregion
154
- export { useEditComposer, useMessage, useMessageRuntime };
155
- //# sourceMappingURL=MessageContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessageContext.d.ts","names":[],"sources":["../../../src/legacy-runtime/hooks/MessageContext.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwDgB,kBAAkB;EAChC;IACE;iBACY,kBAAkB;EAChC;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsDS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cASA"}
@@ -1,68 +0,0 @@
1
- "use client";
2
- import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
3
- import { useAui, useAuiState } from "@assistant-ui/store";
4
- import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
5
- //#region src/legacy-runtime/hooks/MessageContext.ts
6
- function useMessageRuntime(options) {
7
- const $ = c(2);
8
- const aui = useAui();
9
- let t0;
10
- if ($[0] !== aui) {
11
- t0 = () => aui.message.source ? aui.message().__internal_getRuntime?.() ?? null : null;
12
- $[0] = aui;
13
- $[1] = t0;
14
- } else t0 = $[1];
15
- const runtime = useAuiState(t0);
16
- if (!runtime && !options?.optional) throw new Error("MessageRuntime is not available");
17
- return runtime;
18
- }
19
- /**
20
- * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
21
- *
22
- * Hook to access the current message state.
23
- *
24
- * This hook provides reactive access to the message's state, including content,
25
- * role, status, and other message-level properties.
26
- *
27
- * @param selector Optional selector function to pick specific state properties
28
- * @returns The selected message state or the entire message state if no selector provided
29
- *
30
- * @example
31
- * ```tsx
32
- * // Before:
33
- * function MessageContent() {
34
- * const role = useMessage((state) => state.role);
35
- * const content = useMessage((state) => state.content);
36
- * const isLoading = useMessage((state) => state.status.type === "running");
37
- * return (
38
- * <div className={`message-${role}`}>
39
- * {isLoading ? "Loading..." : content.map(part => part.text).join("")}
40
- * </div>
41
- * );
42
- * }
43
- *
44
- * // After:
45
- * function MessageContent() {
46
- * const role = useAuiState((s) => s.message.role);
47
- * const content = useAuiState((s) => s.message.content);
48
- * const isLoading = useAuiState((s) => s.message.status.type === "running");
49
- * return (
50
- * <div className={`message-${role}`}>
51
- * {isLoading ? "Loading..." : content.map(part => part.text).join("")}
52
- * </div>
53
- * );
54
- * }
55
- * ```
56
- */
57
- const useMessage = createStateHookForRuntime(useMessageRuntime);
58
- const useEditComposerRuntime = (opt) => {
59
- return useMessageRuntime(opt)?.composer ?? null;
60
- };
61
- /**
62
- * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
63
- */
64
- const useEditComposer = createStateHookForRuntime(useEditComposerRuntime);
65
- //#endregion
66
- export { useEditComposer, useMessage, useMessageRuntime };
67
-
68
- //# sourceMappingURL=MessageContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessageContext.js","names":["c","_c","MessageRuntime","useAui","useAuiState","createStateHookForRuntime","EditComposerRuntime","useMessageRuntime","options","optional","$","aui","t0","message","source","__internal_getRuntime","runtime","Error","useMessage","useEditComposerRuntime","opt","composer","useEditComposer"],"sources":["../../../src/legacy-runtime/hooks/MessageContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessageRuntime } from \"../runtime/MessageRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport type { EditComposerRuntime } from \"@assistant-ui/core\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.message()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the MessageRuntime from the current context.\n *\n * The MessageRuntime provides access to message-level state and actions,\n * including message content, status, editing capabilities, and branching.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The MessageRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageActions() {\n * const runtime = useMessageRuntime();\n * const handleReload = () => {\n * runtime.reload();\n * };\n * const handleEdit = () => {\n * runtime.startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageActions() {\n * const aui = useAui();\n * const handleReload = () => {\n * aui.message().reload();\n * };\n * const handleEdit = () => {\n * aui.message().startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useMessageRuntime(options?: {\n optional?: false | undefined;\n}): MessageRuntime;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}): MessageRuntime | null;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.message.source\n ? (aui.message().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessageRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current message state.\n *\n * This hook provides reactive access to the message's state, including content,\n * role, status, and other message-level properties.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected message state or the entire message state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageContent() {\n * const role = useMessage((state) => state.role);\n * const content = useMessage((state) => state.content);\n * const isLoading = useMessage((state) => state.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageContent() {\n * const role = useAuiState((s) => s.message.role);\n * const content = useAuiState((s) => s.message.content);\n * const isLoading = useAuiState((s) => s.message.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n * ```\n */\nexport const useMessage = createStateHookForRuntime(useMessageRuntime);\n\nconst useEditComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): EditComposerRuntime | null => useMessageRuntime(opt)?.composer ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useEditComposer = createStateHookForRuntime(\n useEditComposerRuntime,\n);\n"],"mappings":";;;;;AA8DA,SAAOO,kBAAAC,SAAA;CAAA,MAAAE,IAAAT,EAAA,CAAA;CAGL,MAAAU,MAAYR,OAAO;CAAE,IAAAS;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,QAAQC,SACNH,IAAGE,QAAS,CAAC,CAAAE,wBAAiC,KAA9C,OADL;EAEQL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHV,MAAAM,UAAgBZ,YAAYQ,EAI5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,iCAAiC;CAClD,OACMD;AAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyChB,MAAaE,aAAab,0BAA0BE,iBAAiB;AAErE,MAAMY,0BAAyBC,QAAA;CAAA,OAEGb,kBAAkBa,GAAa,CAAC,EAAAC,YAAhC;AAAwC;;;;AAK1E,MAAaC,kBAAkBjB,0BAC7Bc,sBACF"}
@@ -1,44 +0,0 @@
1
- import { MessagePartRuntime } from "../runtime/MessagePartRuntime.js";
2
- //#region src/legacy-runtime/hooks/MessagePartContext.d.ts
3
- /**
4
- * @deprecated Use {@link useAui} with `aui.part()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
5
- */
6
- declare function useMessagePartRuntime(options?: {
7
- optional?: false | undefined;
8
- }): MessagePartRuntime;
9
- declare function useMessagePartRuntime(options?: {
10
- optional?: boolean | undefined;
11
- }): MessagePartRuntime | null;
12
- /**
13
- * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.part)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
14
- */
15
- declare const useMessagePart: {
16
- (): import("@assistant-ui/core").MessagePartState;
17
- <TSelected>(selector: (state: import("@assistant-ui/core").MessagePartState) => TSelected): TSelected;
18
- <TSelected>(selector: ((state: import("@assistant-ui/core").MessagePartState) => TSelected) | undefined): import("@assistant-ui/core").MessagePartState | TSelected;
19
- (options: {
20
- optional?: false | undefined;
21
- }): import("@assistant-ui/core").MessagePartState;
22
- (options: {
23
- optional?: boolean | undefined;
24
- }): import("@assistant-ui/core").MessagePartState | null;
25
- <TSelected>(options: {
26
- optional?: false | undefined;
27
- selector: (state: import("@assistant-ui/core").MessagePartState) => TSelected;
28
- }): TSelected;
29
- <TSelected>(options: {
30
- optional?: false | undefined;
31
- selector: ((state: import("@assistant-ui/core").MessagePartState) => TSelected) | undefined;
32
- }): import("@assistant-ui/core").MessagePartState | TSelected;
33
- <TSelected>(options: {
34
- optional?: boolean | undefined;
35
- selector: (state: import("@assistant-ui/core").MessagePartState) => TSelected;
36
- }): TSelected | null;
37
- <TSelected>(options: {
38
- optional?: boolean | undefined;
39
- selector: ((state: import("@assistant-ui/core").MessagePartState) => TSelected) | undefined;
40
- }): import("@assistant-ui/core").MessagePartState | TSelected | null;
41
- };
42
- //#endregion
43
- export { useMessagePart, useMessagePartRuntime };
44
- //# sourceMappingURL=MessagePartContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessagePartContext.d.ts","names":[],"sources":["../../../src/legacy-runtime/hooks/MessagePartContext.ts"],"mappings":";;;;;iBASgB,sBAAsB;EACpC;IACE;iBACY,sBAAsB;EACpC;IACE;;;;cAiBS"}
@@ -1,26 +0,0 @@
1
- "use client";
2
- import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
3
- import { useAui, useAuiState } from "@assistant-ui/store";
4
- import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
5
- //#region src/legacy-runtime/hooks/MessagePartContext.ts
6
- function useMessagePartRuntime(options) {
7
- const $ = c(2);
8
- const aui = useAui();
9
- let t0;
10
- if ($[0] !== aui) {
11
- t0 = () => aui.part.source ? aui.part().__internal_getRuntime?.() ?? null : null;
12
- $[0] = aui;
13
- $[1] = t0;
14
- } else t0 = $[1];
15
- const runtime = useAuiState(t0);
16
- if (!runtime && !options?.optional) throw new Error("MessagePartRuntime is not available");
17
- return runtime;
18
- }
19
- /**
20
- * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.part)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
21
- */
22
- const useMessagePart = createStateHookForRuntime(useMessagePartRuntime);
23
- //#endregion
24
- export { useMessagePart, useMessagePartRuntime };
25
-
26
- //# sourceMappingURL=MessagePartContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessagePartContext.js","names":["c","_c","MessagePartRuntime","createStateHookForRuntime","useAui","useAuiState","useMessagePartRuntime","options","optional","$","aui","t0","part","source","__internal_getRuntime","runtime","Error","useMessagePart"],"sources":["../../../src/legacy-runtime/hooks/MessagePartContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessagePartRuntime } from \"../runtime/MessagePartRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.part()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useMessagePartRuntime(options?: {\n optional?: false | undefined;\n}): MessagePartRuntime;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}): MessagePartRuntime | null;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.part.source ? (aui.part().__internal_getRuntime?.() ?? null) : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessagePartRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.part)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useMessagePart = createStateHookForRuntime(useMessagePartRuntime);\n"],"mappings":";;;;;AAeA,SAAOM,sBAAAC,SAAA;CAAA,MAAAE,IAAAR,EAAA,CAAA;CAGL,MAAAS,MAAYN,OAAO;CAAE,IAAAO;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,KAAKC,SAAWH,IAAGE,KAAM,CAAC,CAAAE,wBAAiC,KAA3C,OAAnB;EAAuEL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CADzE,MAAAM,UAAgBV,YAAYM,EAE5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,qCAAqC;CACtD,OACMD;AAAO;;;;AAMhB,MAAaE,iBAAiBd,0BAA0BG,qBAAqB"}