@assistant-ui/core 0.2.12 → 0.2.14

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 (212) hide show
  1. package/dist/adapters/thread-history.d.ts +3 -1
  2. package/dist/adapters/thread-history.d.ts.map +1 -1
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/react/AssistantProvider.js +6 -1
  6. package/dist/react/AssistantProvider.js.map +1 -1
  7. package/dist/react/RuntimeAdapter.d.ts +1 -1
  8. package/dist/react/RuntimeAdapter.d.ts.map +1 -1
  9. package/dist/react/RuntimeAdapter.js +16 -6
  10. package/dist/react/RuntimeAdapter.js.map +1 -1
  11. package/dist/react/client/DataRenderers.d.ts +1 -8
  12. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  13. package/dist/react/client/DataRenderers.js +3 -2
  14. package/dist/react/client/DataRenderers.js.map +1 -1
  15. package/dist/react/client/Interactables.d.ts +1 -1
  16. package/dist/react/client/Interactables.d.ts.map +1 -1
  17. package/dist/react/client/Interactables.js +4 -3
  18. package/dist/react/client/Interactables.js.map +1 -1
  19. package/dist/react/client/Tools.d.ts +2 -13
  20. package/dist/react/client/Tools.d.ts.map +1 -1
  21. package/dist/react/client/Tools.js +4 -3
  22. package/dist/react/client/Tools.js.map +1 -1
  23. package/dist/react/primitives/message/MessageGroupedParts.d.ts +3 -2
  24. package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
  25. package/dist/react/primitives/message/MessageGroupedParts.js +4 -4
  26. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  27. package/dist/react/primitives/message/MessageParts.d.ts +28 -1
  28. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  29. package/dist/react/primitives/message/MessageParts.js +43 -9
  30. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  31. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  32. package/dist/react/providers/TextMessagePartProvider.js +3 -2
  33. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  34. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -0
  35. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  36. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +2 -0
  37. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  38. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +1 -0
  39. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  40. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  41. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +6 -0
  42. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  43. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  44. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +2 -0
  45. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
  46. package/dist/react/utils/groupParts.d.ts +13 -1
  47. package/dist/react/utils/groupParts.d.ts.map +1 -1
  48. package/dist/react/utils/groupParts.js +17 -5
  49. package/dist/react/utils/groupParts.js.map +1 -1
  50. package/dist/runtime/api/bindings.d.ts +1 -0
  51. package/dist/runtime/api/bindings.d.ts.map +1 -1
  52. package/dist/runtime/api/message-runtime.d.ts +2 -0
  53. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  54. package/dist/runtime/api/message-runtime.js +5 -0
  55. package/dist/runtime/api/message-runtime.js.map +1 -1
  56. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  57. package/dist/runtime/api/thread-list-runtime.js +1 -0
  58. package/dist/runtime/api/thread-list-runtime.js.map +1 -1
  59. package/dist/runtime/api/thread-runtime.d.ts +3 -0
  60. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  61. package/dist/runtime/api/thread-runtime.js +4 -0
  62. package/dist/runtime/api/thread-runtime.js.map +1 -1
  63. package/dist/runtime/base/base-thread-runtime-core.d.ts +1 -0
  64. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  65. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  66. package/dist/runtime/branch/external-thread-branch-adapter.d.ts +30 -0
  67. package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -0
  68. package/dist/runtime/branch/external-thread-branch-adapter.js +0 -0
  69. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -0
  70. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  71. package/dist/runtime/interfaces/thread-runtime-core.d.ts +2 -0
  72. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  73. package/dist/runtimes/external-store/external-store-adapter.d.ts +1 -0
  74. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  75. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +1 -0
  76. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  77. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +13 -0
  78. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  79. package/dist/runtimes/local/local-runtime-options.d.ts +1 -1
  80. package/dist/runtimes/local/local-thread-runtime-core.d.ts +8 -1
  81. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  82. package/dist/runtimes/local/local-thread-runtime-core.js +63 -5
  83. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  84. package/dist/runtimes/local/should-continue.js +4 -2
  85. package/dist/runtimes/local/should-continue.js.map +1 -1
  86. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +2 -0
  87. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  88. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +4 -0
  89. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  90. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  91. package/dist/runtimes/remote-thread-list/empty-thread-core.js +4 -0
  92. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  93. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +1 -0
  94. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  95. package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -0
  96. package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
  97. package/dist/runtimes/remote-thread-list/types.d.ts +1 -0
  98. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  99. package/dist/store/clients/chain-of-thought-client.d.ts +2 -7
  100. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  101. package/dist/store/clients/chain-of-thought-client.js +3 -2
  102. package/dist/store/clients/chain-of-thought-client.js.map +1 -1
  103. package/dist/store/clients/model-context-client.d.ts +1 -1
  104. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  105. package/dist/store/clients/model-context-client.js +3 -2
  106. package/dist/store/clients/model-context-client.js.map +1 -1
  107. package/dist/store/clients/no-op-composer-client.d.ts +2 -4
  108. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  109. package/dist/store/clients/no-op-composer-client.js +3 -2
  110. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  111. package/dist/store/clients/runtime-adapter.d.ts +1 -3
  112. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  113. package/dist/store/clients/runtime-adapter.js +2 -15
  114. package/dist/store/clients/runtime-adapter.js.map +1 -1
  115. package/dist/store/clients/suggestions.d.ts +1 -4
  116. package/dist/store/clients/suggestions.d.ts.map +1 -1
  117. package/dist/store/clients/suggestions.js +6 -4
  118. package/dist/store/clients/suggestions.js.map +1 -1
  119. package/dist/store/clients/thread-message-client.d.ts +1 -1
  120. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  121. package/dist/store/clients/thread-message-client.js +14 -10
  122. package/dist/store/clients/thread-message-client.js.map +1 -1
  123. package/dist/store/internal.d.ts +2 -2
  124. package/dist/store/internal.js +2 -2
  125. package/dist/store/runtime-clients/attachment-runtime-client.d.ts +2 -4
  126. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  127. package/dist/store/runtime-clients/attachment-runtime-client.js +3 -2
  128. package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
  129. package/dist/store/runtime-clients/composer-runtime-client.d.ts +2 -10
  130. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  131. package/dist/store/runtime-clients/composer-runtime-client.js +9 -6
  132. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  133. package/dist/store/runtime-clients/message-part-runtime-client.d.ts +2 -4
  134. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  135. package/dist/store/runtime-clients/message-part-runtime-client.js +3 -2
  136. package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
  137. package/dist/store/runtime-clients/message-runtime-client.d.ts +2 -7
  138. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  139. package/dist/store/runtime-clients/message-runtime-client.js +10 -6
  140. package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
  141. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +2 -4
  142. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  143. package/dist/store/runtime-clients/thread-list-item-runtime-client.js +3 -2
  144. package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
  145. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +2 -5
  146. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  147. package/dist/store/runtime-clients/thread-list-runtime-client.js +6 -4
  148. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  149. package/dist/store/runtime-clients/thread-runtime-client.d.ts +2 -4
  150. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  151. package/dist/store/runtime-clients/thread-runtime-client.js +7 -4
  152. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  153. package/dist/store/scopes/message.d.ts +1 -0
  154. package/dist/store/scopes/message.d.ts.map +1 -1
  155. package/dist/store/scopes/thread-list-item.d.ts +1 -0
  156. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  157. package/dist/store/scopes/thread.d.ts +1 -0
  158. package/dist/store/scopes/thread.d.ts.map +1 -1
  159. package/package.json +4 -4
  160. package/src/adapters/thread-history.ts +2 -0
  161. package/src/index.ts +1 -0
  162. package/src/react/AssistantProvider.tsx +3 -1
  163. package/src/react/RuntimeAdapter.ts +25 -8
  164. package/src/react/client/DataRenderers.ts +42 -45
  165. package/src/react/client/Interactables.ts +261 -261
  166. package/src/react/client/Tools.ts +6 -4
  167. package/src/react/primitives/message/MessageGroupedParts.tsx +19 -7
  168. package/src/react/primitives/message/MessageParts.tsx +64 -13
  169. package/src/react/providers/TextMessagePartProvider.tsx +5 -3
  170. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +1 -0
  171. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +11 -0
  172. package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +6 -0
  173. package/src/react/utils/groupParts.ts +27 -0
  174. package/src/runtime/api/bindings.ts +1 -0
  175. package/src/runtime/api/message-runtime.ts +7 -0
  176. package/src/runtime/api/thread-list-runtime.ts +1 -0
  177. package/src/runtime/api/thread-runtime.ts +7 -0
  178. package/src/runtime/base/base-thread-runtime-core.ts +1 -0
  179. package/src/runtime/branch/external-thread-branch-adapter.ts +26 -0
  180. package/src/runtime/interfaces/thread-list-runtime-core.ts +1 -0
  181. package/src/runtime/interfaces/thread-runtime-core.ts +2 -0
  182. package/src/runtimes/external-store/external-store-adapter.ts +1 -0
  183. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +24 -0
  184. package/src/runtimes/local/local-runtime-options.ts +1 -1
  185. package/src/runtimes/local/local-thread-runtime-core.test.ts +311 -0
  186. package/src/runtimes/local/local-thread-runtime-core.ts +104 -7
  187. package/src/runtimes/local/should-continue.ts +23 -13
  188. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +5 -0
  189. package/src/runtimes/remote-thread-list/empty-thread-core.ts +5 -0
  190. package/src/runtimes/remote-thread-list/remote-thread-state.ts +2 -0
  191. package/src/runtimes/remote-thread-list/types.ts +1 -0
  192. package/src/store/clients/chain-of-thought-client.ts +5 -3
  193. package/src/store/clients/model-context-client.test.ts +5 -4
  194. package/src/store/clients/model-context-client.ts +21 -21
  195. package/src/store/clients/no-op-composer-client.ts +5 -3
  196. package/src/store/clients/runtime-adapter.ts +0 -24
  197. package/src/store/clients/suggestions.ts +9 -18
  198. package/src/store/clients/thread-message-client.ts +29 -26
  199. package/src/store/internal.ts +1 -4
  200. package/src/store/runtime-clients/attachment-runtime-client.ts +14 -14
  201. package/src/store/runtime-clients/composer-runtime-client.ts +30 -24
  202. package/src/store/runtime-clients/message-part-runtime-client.ts +5 -3
  203. package/src/store/runtime-clients/message-runtime-client.ts +26 -19
  204. package/src/store/runtime-clients/thread-list-item-runtime-client.ts +5 -3
  205. package/src/store/runtime-clients/thread-list-runtime-client.ts +10 -6
  206. package/src/store/runtime-clients/thread-runtime-client.ts +11 -6
  207. package/src/store/scopes/message.ts +1 -0
  208. package/src/store/scopes/thread-list-item.ts +1 -0
  209. package/src/store/scopes/thread.ts +1 -0
  210. package/src/tests/external-store-thread-runtime-core.test.ts +57 -0
  211. package/src/tests/groupMessageParts.test.ts +84 -0
  212. package/src/tests/groupParts.test.ts +55 -0
@@ -4,17 +4,19 @@ import { useEffect, useMemo } from "@assistant-ui/tap/react-shim";
4
4
  import { useAssistantEmit, useClientLookup } from "@assistant-ui/store";
5
5
  import { resource, useResource, withKey } from "@assistant-ui/tap";
6
6
  //#region src/store/runtime-clients/composer-runtime-client.ts
7
- const ComposerAttachmentClientByIndex = resource(function ComposerAttachmentClientByIndex({ runtime, index }) {
7
+ const useComposerAttachmentClientByIndex = ({ runtime, index }) => {
8
8
  return useResource(AttachmentRuntimeClient({ runtime: useMemo(() => runtime.getAttachmentByIndex(index), [runtime, index]) }));
9
- });
10
- const QueueItemClient = resource(function QueueItemClient({ item, onSteer, onRemove }) {
9
+ };
10
+ const ComposerAttachmentClientByIndex = resource(useComposerAttachmentClientByIndex);
11
+ const useQueueItemClient = ({ item, onSteer, onRemove }) => {
11
12
  return {
12
13
  getState: () => item,
13
14
  steer: onSteer,
14
15
  remove: onRemove
15
16
  };
16
- });
17
- const ComposerClient = resource(function ComposerClient({ threadIdRef, messageIdRef, runtime }) {
17
+ };
18
+ const QueueItemClient = resource(useQueueItemClient);
19
+ const useComposerClient = ({ threadIdRef, messageIdRef, runtime }) => {
18
20
  const runtimeState = useSubscribable(runtime);
19
21
  const emit = useAssistantEmit();
20
22
  useEffect(() => {
@@ -100,7 +102,8 @@ const ComposerClient = resource(function ComposerClient({ threadIdRef, messageId
100
102
  queueItem: (selector) => queueItems.get(selector),
101
103
  __internal_getRuntime: () => runtime
102
104
  };
103
- });
105
+ };
106
+ const ComposerClient = resource(useComposerClient);
104
107
  //#endregion
105
108
  export { ComposerClient };
106
109
 
@@ -1 +1 @@
1
- {"version":3,"file":"composer-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/composer-runtime-client.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport { useMemo, useEffect } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n useAssistantEmit,\n useClientLookup,\n} from \"@assistant-ui/store\";\nimport type {\n ComposerRuntime,\n EditComposerRuntime,\n} from \"../../runtime/api/composer-runtime\";\nimport type { ComposerState } from \"../scopes/composer\";\nimport type { QueueItemState } from \"../scopes/queue-item\";\nimport { AttachmentRuntimeClient } from \"./attachment-runtime-client\";\nimport { useSubscribable } from \"./useSubscribable\";\n\nconst ComposerAttachmentClientByIndex = resource(\n function ComposerAttachmentClientByIndex({\n runtime,\n index,\n }: {\n runtime: ComposerRuntime;\n index: number;\n }) {\n const attachmentRuntime = useMemo(\n () => runtime.getAttachmentByIndex(index),\n [runtime, index],\n );\n\n return useResource(\n AttachmentRuntimeClient({\n runtime: attachmentRuntime,\n }),\n );\n },\n);\n\nconst QueueItemClient = resource(function QueueItemClient({\n item,\n onSteer,\n onRemove,\n}: {\n item: QueueItemState;\n onSteer: () => void;\n onRemove: () => void;\n}): ClientOutput<\"queueItem\"> {\n return {\n getState: () => item,\n steer: onSteer,\n remove: onRemove,\n };\n});\n\nexport const ComposerClient = resource(function ComposerClient({\n threadIdRef,\n messageIdRef,\n runtime,\n}: {\n threadIdRef: { current: string };\n messageIdRef?: { current: string };\n runtime: ComposerRuntime;\n}): ClientOutput<\"composer\"> {\n const runtimeState = useSubscribable(runtime);\n const emit = useAssistantEmit();\n\n // Bind composer events to event manager\n useEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n // Subscribe to composer events\n for (const event of [\"send\", \"attachmentAdd\"] as const) {\n const unsubscribe = runtime.unstable_on(event, () => {\n emit(`composer.${event}`, {\n threadId: threadIdRef.current,\n ...(messageIdRef && { messageId: messageIdRef.current }),\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n unsubscribers.push(\n runtime.unstable_on(\"attachmentAddError\", (payload) => {\n // payload.error omitted: raw Error is not store-serializable; use runtime.unstable_on for it.\n emit(\"composer.attachmentAddError\", {\n threadId: threadIdRef.current,\n ...(messageIdRef && { messageId: messageIdRef.current }),\n ...(payload.attachmentId && { attachmentId: payload.attachmentId }),\n reason: payload.reason,\n message: payload.message,\n });\n }),\n );\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, emit, threadIdRef, messageIdRef]);\n\n const attachments = useClientLookup(\n () =>\n runtimeState.attachments.map((attachment, idx) =>\n withKey(\n attachment.id,\n ComposerAttachmentClientByIndex({\n runtime,\n index: idx,\n }),\n ),\n ),\n [runtimeState.attachments, runtime],\n );\n\n const queue = runtimeState.queue;\n const queueItems = useClientLookup(\n () =>\n queue.map((item) =>\n withKey(\n item.id,\n QueueItemClient({\n item,\n onSteer: () => runtime.steerQueueItem(item.id),\n onRemove: () => runtime.removeQueueItem(item.id),\n }),\n ),\n ),\n [queue, runtime],\n );\n\n const state = useMemo<ComposerState>(() => {\n return {\n text: runtimeState.text,\n role: runtimeState.role,\n attachments: attachments.state,\n runConfig: runtimeState.runConfig,\n isEditing: runtimeState.isEditing,\n canCancel: runtimeState.canCancel,\n canSend: runtimeState.canSend,\n attachmentAccept: runtimeState.attachmentAccept,\n isEmpty: runtimeState.isEmpty,\n type: runtimeState.type ?? \"thread\",\n dictation: runtimeState.dictation,\n quote: runtimeState.quote,\n queue,\n };\n }, [runtimeState, attachments.state, queue]);\n\n return {\n getState: () => state,\n setText: runtime.setText,\n setRole: runtime.setRole,\n setRunConfig: runtime.setRunConfig,\n addAttachment: runtime.addAttachment,\n reset: runtime.reset,\n clearAttachments: runtime.clearAttachments,\n send: runtime.send,\n cancel: runtime.cancel,\n beginEdit:\n (runtime as EditComposerRuntime).beginEdit ??\n (() => {\n throw new Error(\"beginEdit is not supported in this runtime\");\n }),\n startDictation: runtime.startDictation,\n stopDictation: runtime.stopDictation,\n setQuote: runtime.setQuote,\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.get({ key: selector.id });\n } else {\n return attachments.get(selector);\n }\n },\n queueItem: (selector) => queueItems.get(selector),\n __internal_getRuntime: () => runtime,\n };\n});\n"],"mappings":";;;;;;AAiBA,MAAM,kCAAkC,SACtC,SAAS,gCAAgC,EACvC,SACA,SAIC;CAMD,OAAO,YACL,wBAAwB,EACtB,SAPsB,cAClB,QAAQ,qBAAqB,KAAK,GACxC,CAAC,SAAS,KAAK,CAKY,EAC3B,CAAC,CACH;AACF,CACF;AAEA,MAAM,kBAAkB,SAAS,SAAS,gBAAgB,EACxD,MACA,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zC,OAAO;GACL,MAAM,aAAa;GACnB,MAAM,aAAa;GACnB,aAAa,YAAY;GACzB,WAAW,aAAa;GACxB,WAAW,aAAa;GACxB,WAAW,aAAa;GACxB,SAAS,aAAa;GACtB,kBAAkB,aAAa;GAC/B,SAAS,aAAa;GACtB,MAAM,aAAa,QAAQ;GAC3B,WAAW,aAAa;GACxB,OAAO,aAAa;GACpB;EACF;CACF,GAAG;EAAC;EAAc,YAAY;EAAO;CAAK,CAAC;CAE3C,OAAO;EACL,gBAAgB;EAChB,SAAS,QAAQ;EACjB,SAAS,QAAQ;EACjB,cAAc,QAAQ;EACtB,eAAe,QAAQ;EACvB,OAAO,QAAQ;EACf,kBAAkB,QAAQ;EAC1B,MAAM,QAAQ;EACd,QAAQ,QAAQ;EAChB,WACG,QAAgC,oBAC1B;GACL,MAAM,IAAI,MAAM,4CAA4C;EAC9D;EACF,gBAAgB,QAAQ;EACxB,eAAe,QAAQ;EACvB,UAAU,QAAQ;EAClB,aAAa,aAAa;GACxB,IAAI,QAAQ,UACV,OAAO,YAAY,IAAI,EAAE,KAAK,SAAS,GAAG,CAAC;QAE3C,OAAO,YAAY,IAAI,QAAQ;EAEnC;EACA,YAAY,aAAa,WAAW,IAAI,QAAQ;EAChD,6BAA6B;CAC/B;AACF,CAAC"}
1
+ {"version":3,"file":"composer-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/composer-runtime-client.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport { useMemo, useEffect } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n useAssistantEmit,\n useClientLookup,\n} from \"@assistant-ui/store\";\nimport type {\n ComposerRuntime,\n EditComposerRuntime,\n} from \"../../runtime/api/composer-runtime\";\nimport type { ComposerState } from \"../scopes/composer\";\nimport type { QueueItemState } from \"../scopes/queue-item\";\nimport { AttachmentRuntimeClient } from \"./attachment-runtime-client\";\nimport { useSubscribable } from \"./useSubscribable\";\n\nconst useComposerAttachmentClientByIndex = ({\n runtime,\n index,\n}: {\n runtime: ComposerRuntime;\n index: number;\n}) => {\n const attachmentRuntime = useMemo(\n () => runtime.getAttachmentByIndex(index),\n [runtime, index],\n );\n\n return useResource(\n AttachmentRuntimeClient({\n runtime: attachmentRuntime,\n }),\n );\n};\n\nconst ComposerAttachmentClientByIndex = resource(\n useComposerAttachmentClientByIndex,\n);\n\nconst useQueueItemClient = ({\n item,\n onSteer,\n onRemove,\n}: {\n item: QueueItemState;\n onSteer: () => void;\n onRemove: () => void;\n}): ClientOutput<\"queueItem\"> => {\n return {\n getState: () => item,\n steer: onSteer,\n remove: onRemove,\n };\n};\n\nconst QueueItemClient = resource(useQueueItemClient);\n\nconst useComposerClient = ({\n threadIdRef,\n messageIdRef,\n runtime,\n}: {\n threadIdRef: { current: string };\n messageIdRef?: { current: string };\n runtime: ComposerRuntime;\n}): ClientOutput<\"composer\"> => {\n const runtimeState = useSubscribable(runtime);\n const emit = useAssistantEmit();\n\n // Bind composer events to event manager\n useEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n // Subscribe to composer events\n for (const event of [\"send\", \"attachmentAdd\"] as const) {\n const unsubscribe = runtime.unstable_on(event, () => {\n emit(`composer.${event}`, {\n threadId: threadIdRef.current,\n ...(messageIdRef && { messageId: messageIdRef.current }),\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n unsubscribers.push(\n runtime.unstable_on(\"attachmentAddError\", (payload) => {\n // payload.error omitted: raw Error is not store-serializable; use runtime.unstable_on for it.\n emit(\"composer.attachmentAddError\", {\n threadId: threadIdRef.current,\n ...(messageIdRef && { messageId: messageIdRef.current }),\n ...(payload.attachmentId && { attachmentId: payload.attachmentId }),\n reason: payload.reason,\n message: payload.message,\n });\n }),\n );\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, emit, threadIdRef, messageIdRef]);\n\n const attachments = useClientLookup(\n () =>\n runtimeState.attachments.map((attachment, idx) =>\n withKey(\n attachment.id,\n ComposerAttachmentClientByIndex({\n runtime,\n index: idx,\n }),\n ),\n ),\n [runtimeState.attachments, runtime],\n );\n\n const queue = runtimeState.queue;\n const queueItems = useClientLookup(\n () =>\n queue.map((item) =>\n withKey(\n item.id,\n QueueItemClient({\n item,\n onSteer: () => runtime.steerQueueItem(item.id),\n onRemove: () => runtime.removeQueueItem(item.id),\n }),\n ),\n ),\n [queue, runtime],\n );\n\n const state = useMemo<ComposerState>(() => {\n return {\n text: runtimeState.text,\n role: runtimeState.role,\n attachments: attachments.state,\n runConfig: runtimeState.runConfig,\n isEditing: runtimeState.isEditing,\n canCancel: runtimeState.canCancel,\n canSend: runtimeState.canSend,\n attachmentAccept: runtimeState.attachmentAccept,\n isEmpty: runtimeState.isEmpty,\n type: runtimeState.type ?? \"thread\",\n dictation: runtimeState.dictation,\n quote: runtimeState.quote,\n queue,\n };\n }, [runtimeState, attachments.state, queue]);\n\n return {\n getState: () => state,\n setText: runtime.setText,\n setRole: runtime.setRole,\n setRunConfig: runtime.setRunConfig,\n addAttachment: runtime.addAttachment,\n reset: runtime.reset,\n clearAttachments: runtime.clearAttachments,\n send: runtime.send,\n cancel: runtime.cancel,\n beginEdit:\n (runtime as EditComposerRuntime).beginEdit ??\n (() => {\n throw new Error(\"beginEdit is not supported in this runtime\");\n }),\n startDictation: runtime.startDictation,\n stopDictation: runtime.stopDictation,\n setQuote: runtime.setQuote,\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.get({ key: selector.id });\n } else {\n return attachments.get(selector);\n }\n },\n queueItem: (selector) => queueItems.get(selector),\n __internal_getRuntime: () => runtime,\n };\n};\n\nexport const ComposerClient = resource(useComposerClient);\n"],"mappings":";;;;;;AAiBA,MAAM,sCAAsC,EAC1C,SACA,YAII;CAMJ,OAAO,YACL,wBAAwB,EACtB,SAPsB,cAClB,QAAQ,qBAAqB,KAAK,GACxC,CAAC,SAAS,KAAK,CAKY,EAC3B,CAAC,CACH;AACF;AAEA,MAAM,kCA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ACF,GACF,CAAC,OAAO,OAAO,CACjB;CAEA,MAAM,QAAQ,cAA6B;EACzC,OAAO;GACL,MAAM,aAAa;GACnB,MAAM,aAAa;GACnB,aAAa,YAAY;GACzB,WAAW,aAAa;GACxB,WAAW,aAAa;GACxB,WAAW,aAAa;GACxB,SAAS,aAAa;GACtB,kBAAkB,aAAa;GAC/B,SAAS,aAAa;GACtB,MAAM,aAAa,QAAQ;GAC3B,WAAW,aAAa;GACxB,OAAO,aAAa;GACpB;EACF;CACF,GAAG;EAAC;EAAc,YAAY;EAAO;CAAK,CAAC;CAE3C,OAAO;EACL,gBAAgB;EAChB,SAAS,QAAQ;EACjB,SAAS,QAAQ;EACjB,cAAc,QAAQ;EACtB,eAAe,QAAQ;EACvB,OAAO,QAAQ;EACf,kBAAkB,QAAQ;EAC1B,MAAM,QAAQ;EACd,QAAQ,QAAQ;EAChB,WACG,QAAgC,oBAC1B;GACL,MAAM,IAAI,MAAM,4CAA4C;EAC9D;EACF,gBAAgB,QAAQ;EACxB,eAAe,QAAQ;EACvB,UAAU,QAAQ;EAClB,aAAa,aAAa;GACxB,IAAI,QAAQ,UACV,OAAO,YAAY,IAAI,EAAE,KAAK,SAAS,GAAG,CAAC;QAE3C,OAAO,YAAY,IAAI,QAAQ;EAEnC;EACA,YAAY,aAAa,WAAW,IAAI,QAAQ;EAChD,6BAA6B;CAC/B;AACF;AAEA,MAAa,iBAAiB,SAAS,iBAAiB"}
@@ -2,11 +2,9 @@ import { MessagePartRuntime } from "../../runtime/api/message-part-runtime.js";
2
2
  import { ClientOutput } from "@assistant-ui/store";
3
3
 
4
4
  //#region src/store/runtime-clients/message-part-runtime-client.d.ts
5
- declare const MessagePartClient: (props: {
5
+ declare const MessagePartClient: import("@assistant-ui/tap").Resource<ClientOutput<"part">, [{
6
6
  runtime: MessagePartRuntime;
7
- }) => import("@assistant-ui/tap").ResourceElement<ClientOutput<"part">, {
8
- runtime: MessagePartRuntime;
9
- }>;
7
+ }]>;
10
8
  //#endregion
11
9
  export { MessagePartClient };
12
10
  //# sourceMappingURL=message-part-runtime-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-part-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/message-part-runtime-client.ts"],"mappings":";;;;cAKa,iBAAA,GAAiB,KAAA;WAGnB,kBAAA;AAAA;WAAA,kBAAA;AAAA"}
1
+ {"version":3,"file":"message-part-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/message-part-runtime-client.ts"],"mappings":";;;;cAsBa,iBAAA,8BAAiB,QAAA,CAAA,YAAA;WAdnB,kBAAkB;AAAA"}
@@ -1,7 +1,7 @@
1
1
  import { useSubscribable } from "./useSubscribable.js";
2
2
  import { resource } from "@assistant-ui/tap";
3
3
  //#region src/store/runtime-clients/message-part-runtime-client.ts
4
- const MessagePartClient = resource(function MessagePartClient({ runtime }) {
4
+ const useMessagePartClient = ({ runtime }) => {
5
5
  const state = useSubscribable(runtime);
6
6
  return {
7
7
  getState: () => state,
@@ -10,7 +10,8 @@ const MessagePartClient = resource(function MessagePartClient({ runtime }) {
10
10
  respondToToolApproval: (response) => runtime.respondToToolApproval(response),
11
11
  __internal_getRuntime: () => runtime
12
12
  };
13
- });
13
+ };
14
+ const MessagePartClient = resource(useMessagePartClient);
14
15
  //#endregion
15
16
  export { MessagePartClient };
16
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"message-part-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/message-part-runtime-client.ts"],"sourcesContent":["import { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport type { MessagePartRuntime } from \"../../runtime/api/message-part-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\n\nexport const MessagePartClient = resource(function MessagePartClient({\n runtime,\n}: {\n runtime: MessagePartRuntime;\n}): ClientOutput<\"part\"> {\n const state = useSubscribable(runtime);\n\n return {\n getState: () => state,\n addToolResult: (result) => runtime.addToolResult(result),\n resumeToolCall: (payload) => runtime.resumeToolCall(payload),\n respondToToolApproval: (response) =>\n runtime.respondToToolApproval(response),\n __internal_getRuntime: () => runtime,\n };\n});\n"],"mappings":";;;AAKA,MAAa,oBAAoB,SAAS,SAAS,kBAAkB,EACnE,WAGuB;CACvB,MAAM,QAAQ,gBAAgB,OAAO;CAErC,OAAO;EACL,gBAAgB;EAChB,gBAAgB,WAAW,QAAQ,cAAc,MAAM;EACvD,iBAAiB,YAAY,QAAQ,eAAe,OAAO;EAC3D,wBAAwB,aACtB,QAAQ,sBAAsB,QAAQ;EACxC,6BAA6B;CAC/B;AACF,CAAC"}
1
+ {"version":3,"file":"message-part-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/message-part-runtime-client.ts"],"sourcesContent":["import { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport type { MessagePartRuntime } from \"../../runtime/api/message-part-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\n\nconst useMessagePartClient = ({\n runtime,\n}: {\n runtime: MessagePartRuntime;\n}): ClientOutput<\"part\"> => {\n const state = useSubscribable(runtime);\n\n return {\n getState: () => state,\n addToolResult: (result) => runtime.addToolResult(result),\n resumeToolCall: (payload) => runtime.resumeToolCall(payload),\n respondToToolApproval: (response) =>\n runtime.respondToToolApproval(response),\n __internal_getRuntime: () => runtime,\n };\n};\n\nexport const MessagePartClient = resource(useMessagePartClient);\n"],"mappings":";;;AAKA,MAAM,wBAAwB,EAC5B,cAG0B;CAC1B,MAAM,QAAQ,gBAAgB,OAAO;CAErC,OAAO;EACL,gBAAgB;EAChB,gBAAgB,WAAW,QAAQ,cAAc,MAAM;EACvD,iBAAiB,YAAY,QAAQ,eAAe,OAAO;EAC3D,wBAAwB,aACtB,QAAQ,sBAAsB,QAAQ;EACxC,6BAA6B;CAC/B;AACF;AAEA,MAAa,oBAAoB,SAAS,oBAAoB"}
@@ -2,17 +2,12 @@ import { MessageRuntime } from "../../runtime/api/message-runtime.js";
2
2
  import { ClientOutput } from "@assistant-ui/store";
3
3
 
4
4
  //#region src/store/runtime-clients/message-runtime-client.d.ts
5
- declare const MessageClient: (props: {
5
+ declare const MessageClient: import("@assistant-ui/tap").Resource<ClientOutput<"message">, [{
6
6
  runtime: MessageRuntime;
7
7
  threadIdRef: {
8
8
  current: string;
9
9
  };
10
- }) => import("@assistant-ui/tap").ResourceElement<ClientOutput<"message">, {
11
- runtime: MessageRuntime;
12
- threadIdRef: {
13
- current: string;
14
- };
15
- }>;
10
+ }]>;
16
11
  //#endregion
17
12
  export { MessageClient };
18
13
  //# sourceMappingURL=message-runtime-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/message-runtime-client.ts"],"mappings":";;;;cA4Ca,aAAA,GAAa,KAAA;WAIf,cAAA;;IACM,OAAA;EAAA;AAAA;WADN,cAAA;;IACM,OAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"message-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/message-runtime-client.ts"],"mappings":";;;;cAyJa,aAAA,8BAAa,QAAA,CAAA,YAAA;WArGf,cAAc;;IACR,OAAA;EAAA;AAAA"}
@@ -6,13 +6,15 @@ import { useMemo, useState } from "@assistant-ui/tap/react-shim";
6
6
  import { useClientLookup, useClientResource } from "@assistant-ui/store";
7
7
  import { resource, useResource, withKey } from "@assistant-ui/tap";
8
8
  //#region src/store/runtime-clients/message-runtime-client.ts
9
- const MessageAttachmentClientByIndex = resource(function MessageAttachmentClientByIndex({ runtime, index }) {
9
+ const useMessageAttachmentClientByIndex = ({ runtime, index }) => {
10
10
  return useResource(AttachmentRuntimeClient({ runtime: useMemo(() => runtime.getAttachmentByIndex(index), [runtime, index]) }));
11
- });
12
- const MessagePartByIndex = resource(function MessagePartByIndex({ runtime, index }) {
11
+ };
12
+ const MessageAttachmentClientByIndex = resource(useMessageAttachmentClientByIndex);
13
+ const useMessagePartByIndex = ({ runtime, index }) => {
13
14
  return useResource(MessagePartClient({ runtime: useMemo(() => runtime.getMessagePartByIndex(index), [runtime, index]) }));
14
- });
15
- const MessageClient = resource(function MessageClient({ runtime, threadIdRef }) {
15
+ };
16
+ const MessagePartByIndex = resource(useMessagePartByIndex);
17
+ const useMessageClient = ({ runtime, threadIdRef }) => {
16
18
  const runtimeState = useSubscribable(runtime);
17
19
  const [isCopiedState, setIsCopied] = useState(false);
18
20
  const [isHoveringState, setIsHovering] = useState(false);
@@ -50,6 +52,7 @@ const MessageClient = resource(function MessageClient({ runtime, threadIdRef })
50
52
  return {
51
53
  getState: () => state,
52
54
  composer: () => composer.methods,
55
+ delete: () => runtime.delete(),
53
56
  reload: (config) => runtime.reload(config),
54
57
  speak: () => runtime.speak(),
55
58
  stopSpeaking: () => runtime.stopSpeaking(),
@@ -68,7 +71,8 @@ const MessageClient = resource(function MessageClient({ runtime, threadIdRef })
68
71
  setIsHovering,
69
72
  __internal_getRuntime: () => runtime
70
73
  };
71
- });
74
+ };
75
+ const MessageClient = resource(useMessageClient);
72
76
  //#endregion
73
77
  export { MessageClient };
74
78
 
@@ -1 +1 @@
1
- {"version":3,"file":"message-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/message-runtime-client.ts"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { useResource, withKey, resource } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n useClientLookup,\n useClientResource,\n} from \"@assistant-ui/store\";\nimport type { MessageRuntime } from \"../../runtime/api/message-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\nimport { ComposerClient } from \"./composer-runtime-client\";\nimport { MessagePartClient } from \"./message-part-runtime-client\";\nimport type { MessageState } from \"../scopes/message\";\nimport { AttachmentRuntimeClient } from \"./attachment-runtime-client\";\n\nconst MessageAttachmentClientByIndex = resource(\n function MessageAttachmentClientByIndex({\n runtime,\n index,\n }: {\n runtime: MessageRuntime;\n index: number;\n }) {\n const attachmentRuntime = useMemo(\n () => runtime.getAttachmentByIndex(index),\n [runtime, index],\n );\n return useResource(AttachmentRuntimeClient({ runtime: attachmentRuntime }));\n },\n);\n\nconst MessagePartByIndex = resource(function MessagePartByIndex({\n runtime,\n index,\n}: {\n runtime: MessageRuntime;\n index: number;\n}) {\n const partRuntime = useMemo(\n () => runtime.getMessagePartByIndex(index),\n [runtime, index],\n );\n return useResource(MessagePartClient({ runtime: partRuntime }));\n});\n\nexport const MessageClient = resource(function MessageClient({\n runtime,\n threadIdRef,\n}: {\n runtime: MessageRuntime;\n threadIdRef: { current: string };\n}): ClientOutput<\"message\"> {\n const runtimeState = useSubscribable(runtime);\n\n const [isCopiedState, setIsCopied] = useState(false);\n const [isHoveringState, setIsHovering] = useState(false);\n\n const messageIdRef = useMemo(\n () => ({\n get current() {\n return runtime.getState().id;\n },\n }),\n [runtime],\n );\n\n const composer = useClientResource(\n ComposerClient({\n runtime: runtime.composer,\n threadIdRef,\n messageIdRef,\n }),\n );\n const parts = useClientLookup(\n () =>\n runtimeState.content.map((part, idx) =>\n withKey(\n \"toolCallId\" in part && part.toolCallId != null\n ? `toolCallId-${part.toolCallId}`\n : `index-${idx}`,\n MessagePartByIndex({ runtime, index: idx }),\n ),\n ),\n [runtimeState.content, runtime],\n );\n\n const attachments = useClientLookup(\n () =>\n (runtimeState.attachments ?? []).map((attachment, idx) =>\n withKey(\n attachment.id,\n MessageAttachmentClientByIndex({ runtime, index: idx }),\n ),\n ),\n [runtimeState.attachments, runtime],\n );\n\n const state = useMemo<MessageState>(() => {\n return {\n ...(runtimeState as MessageState),\n\n parts: parts.state,\n composer: composer.state,\n\n isCopied: isCopiedState,\n isHovering: isHoveringState,\n };\n }, [\n runtimeState,\n parts.state,\n composer.state,\n isCopiedState,\n isHoveringState,\n ]);\n\n return {\n getState: () => state,\n\n composer: () => composer.methods,\n\n reload: (config) => runtime.reload(config),\n speak: () => runtime.speak(),\n stopSpeaking: () => runtime.stopSpeaking(),\n submitFeedback: (feedback) => runtime.submitFeedback(feedback),\n switchToBranch: (options) => runtime.switchToBranch(options),\n getCopyText: () => runtime.unstable_getCopyText(),\n part: (selector) => {\n if (\"index\" in selector) {\n return parts.get({ index: selector.index });\n } else {\n return parts.get({ key: `toolCallId-${selector.toolCallId}` });\n }\n },\n\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.get({ key: selector.id });\n } else {\n return attachments.get(selector);\n }\n },\n\n setIsCopied,\n setIsHovering,\n\n __internal_getRuntime: () => runtime,\n };\n});\n"],"mappings":";;;;;;;;AAcA,MAAM,iCAAiC,SACrC,SAAS,+BAA+B,EACtC,SACA,SAIC;CAKD,OAAO,YAAY,wBAAwB,EAAE,SAJnB,cAClB,QAAQ,qBAAqB,KAAK,GACxC,CAAC,SAAS,KAAK,CAEqD,EAAE,CAAC,CAAC;AAC5E,CACF;AAEA,MAAM,qBAAqB,SAAS,SAAS,mBAAmB,EAC9D,SACA,SAIC;CAKD,OAAO,YAAY,kBAAkB,EAAE,SAJnB,cACZ,QAAQ,sBAAsB,KAAK,GACzC,CAAC,SAAS,KAAK,CAEyC,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,MAAa,gBAAgB,SAAS,SAAS,cAAc,EAC3D,SACA,eAI0B;CAC1B,MAAM,eAAe,gBAAgB,OAAO;CAE5C,MAAM,CAAC,eAAe,eAAe,SAAS,KAAK;CACnD,MAAM,CAAC,iBAAiB,iBAAiB,SAAS,KAAK;CAEvD,MAAM,eAAe,eACZ,EACL,IAAI,UAAU;EACZ,OAAO,QAAQ,SAAS,CAAC,CAAC;CAC5B,EACF,IACA,CAAC,OAAO,CACV;CAEA,MAAM,WAAW,kBACf,eAAe;EACb,SAAS,QAAQ;EACjB;EACA;CACF,CAAC,CACH;CACA,MAAM,QAAQ,sBAEV,aAAa,QAAQ,KAAK,MAAM,QAC9B,QACE,gBAAgB,QAAQ,KAAK,cAAc,OACvC,cAAc,KAAK,eACnB,SAAS,OACb,mBAAmB;EAAE;EAAS,OAAO;CAAI,CAAC,CAC5C,CACF,GACF,CAAC,aAAa,SAAS,OAAO,CAChC;CAEA,MAAM,cAAc,uBAEf,aAAa,eAAe,CAAC,EAAA,CAAG,KAAK,YAAY,QAChD,QACE,WAAW,IACX,+BAA+B;EAAE;EAAS,OAAO;CAAI,CAAC,CACxD,CACF,GACF,CAAC,aAAa,aAAa,OAAO,CACpC;CAEA,MAAM,QAAQ,cAA4B;EACxC,OAAO;GACL,GAAI;GAEJ,OAAO,MAAM;GACb,UAAU,SAAS;GAEnB,UAAU;GACV,YAAY;EACd;CACF,GAAG;EACD;EACA,MAAM;EACN,SAAS;EACT;EACA;CACF,CAAC;CAED,OAAO;EACL,gBAAgB;EAEhB,gBAAgB,SAAS;EAEzB,SAAS,WAAW,QAAQ,OAAO,MAAM;EACzC,aAAa,QAAQ,MAAM;EAC3B,oBAAoB,QAAQ,aAAa;EACzC,iBAAiB,aAAa,QAAQ,eAAe,QAAQ;EAC7D,iBAAiB,YAAY,QAAQ,eAAe,OAAO;EAC3D,mBAAmB,QAAQ,qBAAqB;EAChD,OAAO,aAAa;GAClB,IAAI,WAAW,UACb,OAAO,MAAM,IAAI,EAAE,OAAO,SAAS,MAAM,CAAC;QAE1C,OAAO,MAAM,IAAI,EAAE,KAAK,cAAc,SAAS,aAAa,CAAC;EAEjE;EAEA,aAAa,aAAa;GACxB,IAAI,QAAQ,UACV,OAAO,YAAY,IAAI,EAAE,KAAK,SAAS,GAAG,CAAC;QAE3C,OAAO,YAAY,IAAI,QAAQ;EAEnC;EAEA;EACA;EAEA,6BAA6B;CAC/B;AACF,CAAC"}
1
+ {"version":3,"file":"message-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/message-runtime-client.ts"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { useResource, withKey, resource } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n useClientLookup,\n useClientResource,\n} from \"@assistant-ui/store\";\nimport type { MessageRuntime } from \"../../runtime/api/message-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\nimport { ComposerClient } from \"./composer-runtime-client\";\nimport { MessagePartClient } from \"./message-part-runtime-client\";\nimport type { MessageState } from \"../scopes/message\";\nimport { AttachmentRuntimeClient } from \"./attachment-runtime-client\";\n\nconst useMessageAttachmentClientByIndex = ({\n runtime,\n index,\n}: {\n runtime: MessageRuntime;\n index: number;\n}) => {\n const attachmentRuntime = useMemo(\n () => runtime.getAttachmentByIndex(index),\n [runtime, index],\n );\n return useResource(AttachmentRuntimeClient({ runtime: attachmentRuntime }));\n};\n\nconst MessageAttachmentClientByIndex = resource(\n useMessageAttachmentClientByIndex,\n);\n\nconst useMessagePartByIndex = ({\n runtime,\n index,\n}: {\n runtime: MessageRuntime;\n index: number;\n}) => {\n const partRuntime = useMemo(\n () => runtime.getMessagePartByIndex(index),\n [runtime, index],\n );\n return useResource(MessagePartClient({ runtime: partRuntime }));\n};\n\nconst MessagePartByIndex = resource(useMessagePartByIndex);\n\nconst useMessageClient = ({\n runtime,\n threadIdRef,\n}: {\n runtime: MessageRuntime;\n threadIdRef: { current: string };\n}): ClientOutput<\"message\"> => {\n const runtimeState = useSubscribable(runtime);\n\n const [isCopiedState, setIsCopied] = useState(false);\n const [isHoveringState, setIsHovering] = useState(false);\n\n const messageIdRef = useMemo(\n () => ({\n get current() {\n return runtime.getState().id;\n },\n }),\n [runtime],\n );\n\n const composer = useClientResource(\n ComposerClient({\n runtime: runtime.composer,\n threadIdRef,\n messageIdRef,\n }),\n );\n const parts = useClientLookup(\n () =>\n runtimeState.content.map((part, idx) =>\n withKey(\n \"toolCallId\" in part && part.toolCallId != null\n ? `toolCallId-${part.toolCallId}`\n : `index-${idx}`,\n MessagePartByIndex({ runtime, index: idx }),\n ),\n ),\n [runtimeState.content, runtime],\n );\n\n const attachments = useClientLookup(\n () =>\n (runtimeState.attachments ?? []).map((attachment, idx) =>\n withKey(\n attachment.id,\n MessageAttachmentClientByIndex({ runtime, index: idx }),\n ),\n ),\n [runtimeState.attachments, runtime],\n );\n\n const state = useMemo<MessageState>(() => {\n return {\n ...(runtimeState as MessageState),\n\n parts: parts.state,\n composer: composer.state,\n\n isCopied: isCopiedState,\n isHovering: isHoveringState,\n };\n }, [\n runtimeState,\n parts.state,\n composer.state,\n isCopiedState,\n isHoveringState,\n ]);\n\n return {\n getState: () => state,\n\n composer: () => composer.methods,\n\n delete: () => runtime.delete(),\n reload: (config) => runtime.reload(config),\n speak: () => runtime.speak(),\n stopSpeaking: () => runtime.stopSpeaking(),\n submitFeedback: (feedback) => runtime.submitFeedback(feedback),\n switchToBranch: (options) => runtime.switchToBranch(options),\n getCopyText: () => runtime.unstable_getCopyText(),\n part: (selector) => {\n if (\"index\" in selector) {\n return parts.get({ index: selector.index });\n } else {\n return parts.get({ key: `toolCallId-${selector.toolCallId}` });\n }\n },\n\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.get({ key: selector.id });\n } else {\n return attachments.get(selector);\n }\n },\n\n setIsCopied,\n setIsHovering,\n\n __internal_getRuntime: () => runtime,\n };\n};\n\nexport const MessageClient = resource(useMessageClient);\n"],"mappings":";;;;;;;;AAcA,MAAM,qCAAqC,EACzC,SACA,YAII;CAKJ,OAAO,YAAY,wBAAwB,EAAE,SAJnB,cAClB,QAAQ,qBAAqB,KAAK,GACxC,CAAC,SAAS,KAAK,CAEqD,EAAE,CAAC,CAAC;AAC5E;AAEA,MAAM,iCAAiC,SACrC,iCACF;AAEA,MAAM,yBAAyB,EAC7B,SACA,YAII;CAKJ,OAAO,YAAY,kBAAkB,EAAE,SAJnB,cACZ,QAAQ,sBAAsB,KAAK,GACzC,CAAC,SAAS,KAAK,CAEyC,EAAE,CAAC,CAAC;AAChE;AAEA,MAAM,qBAAqB,SAAS,qBAAqB;AAEzD,MAAM,oBAAoB,EACxB,SACA,kBAI6B;CAC7B,MAAM,eAAe,gBAAgB,OAAO;CAE5C,MAAM,CAAC,eAAe,eAAe,SAAS,KAAK;CACnD,MAAM,CAAC,iBAAiB,iBAAiB,SAAS,KAAK;CAEvD,MAAM,eAAe,e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AAS,GAAG,CAAC;QAE3C,OAAO,YAAY,IAAI,QAAQ;EAEnC;EAEA;EACA;EAEA,6BAA6B;CAC/B;AACF;AAEA,MAAa,gBAAgB,SAAS,gBAAgB"}
@@ -2,11 +2,9 @@ import { ThreadListItemRuntime } from "../../runtime/api/thread-list-item-runtim
2
2
  import { ClientOutput } from "@assistant-ui/store";
3
3
 
4
4
  //#region src/store/runtime-clients/thread-list-item-runtime-client.d.ts
5
- declare const ThreadListItemClient: (props: {
5
+ declare const ThreadListItemClient: import("@assistant-ui/tap").Resource<ClientOutput<"threadListItem">, [{
6
6
  runtime: ThreadListItemRuntime;
7
- }) => import("@assistant-ui/tap").ResourceElement<ClientOutput<"threadListItem">, {
8
- runtime: ThreadListItemRuntime;
9
- }>;
7
+ }]>;
10
8
  //#endregion
11
9
  export { ThreadListItemClient };
12
10
  //# sourceMappingURL=thread-list-item-runtime-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-list-item-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/thread-list-item-runtime-client.ts"],"mappings":";;;;cAUa,oBAAA,GAAoB,KAAA;WAGtB,qBAAA;AAAA;WAAA,qBAAA;AAAA"}
1
+ {"version":3,"file":"thread-list-item-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/thread-list-item-runtime-client.ts"],"mappings":";;;;cAyDa,oBAAA,8BAAoB,QAAA,CAAA,YAAA;WA5CtB,qBAAqB;AAAA"}
@@ -3,7 +3,7 @@ import { useEffect } from "@assistant-ui/tap/react-shim";
3
3
  import { useAssistantEmit } from "@assistant-ui/store";
4
4
  import { resource } from "@assistant-ui/tap";
5
5
  //#region src/store/runtime-clients/thread-list-item-runtime-client.ts
6
- const ThreadListItemClient = resource(function ThreadListItemClient({ runtime }) {
6
+ const useThreadListItemClient = ({ runtime }) => {
7
7
  const state = useSubscribable(runtime);
8
8
  const emit = useAssistantEmit();
9
9
  useEffect(() => {
@@ -31,7 +31,8 @@ const ThreadListItemClient = resource(function ThreadListItemClient({ runtime })
31
31
  detach: runtime.detach,
32
32
  __internal_getRuntime: () => runtime
33
33
  };
34
- });
34
+ };
35
+ const ThreadListItemClient = resource(useThreadListItemClient);
35
36
  //#endregion
36
37
  export { ThreadListItemClient };
37
38
 
@@ -1 +1 @@
1
- {"version":3,"file":"thread-list-item-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/thread-list-item-runtime-client.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport { useEffect } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport { type ClientOutput, useAssistantEmit } from \"@assistant-ui/store\";\nimport type {\n ThreadListItemEventType,\n ThreadListItemRuntime,\n} from \"../../runtime/api/thread-list-item-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\n\nexport const ThreadListItemClient = resource(function ThreadListItemClient({\n runtime,\n}: {\n runtime: ThreadListItemRuntime;\n}): ClientOutput<\"threadListItem\"> {\n const state = useSubscribable(runtime);\n const emit = useAssistantEmit();\n\n // Bind thread list item events to event manager\n useEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n // Subscribe to thread list item events\n const threadListItemEvents: ThreadListItemEventType[] = [\n \"switchedTo\",\n \"switchedAway\",\n ];\n\n for (const event of threadListItemEvents) {\n const unsubscribe = runtime.unstable_on(event, () => {\n emit(`threadListItem.${event}`, {\n threadId: runtime.getState()!.id,\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, emit]);\n\n return {\n getState: () => state,\n switchTo: runtime.switchTo,\n rename: runtime.rename,\n updateCustom: runtime.updateCustom,\n archive: runtime.archive,\n unarchive: runtime.unarchive,\n delete: runtime.delete,\n generateTitle: runtime.generateTitle,\n initialize: runtime.initialize,\n detach: runtime.detach,\n __internal_getRuntime: () => runtime,\n };\n});\n"],"mappings":";;;;;AAUA,MAAa,uBAAuB,SAAS,SAAS,qBAAqB,EACzE,WAGiC;CACjC,MAAM,QAAQ,gBAAgB,OAAO;CACrC,MAAM,OAAO,iBAAiB;CAG9B,gBAAgB;EACd,MAAM,gBAA+B,CAAC;EAQtC,KAAK,MAAM,SAAS,CAJlB,cACA,cAGqC,GAAG;GACxC,MAAM,cAAc,QAAQ,YAAY,aAAa;IACnD,KAAK,kBAAkB,SAAS,EAC9B,UAAU,QAAQ,SAAS,CAAC,CAAE,GAChC,CAAC;GACH,CAAC;GACD,cAAc,KAAK,WAAW;EAChC;EAEA,aAAa;GACX,KAAK,MAAM,SAAS,eAAe,MAAM;EAC3C;CACF,GAAG,CAAC,SAAS,IAAI,CAAC;CAElB,OAAO;EACL,gBAAgB;EAChB,UAAU,QAAQ;EAClB,QAAQ,QAAQ;EAChB,cAAc,QAAQ;EACtB,SAAS,QAAQ;EACjB,WAAW,QAAQ;EACnB,QAAQ,QAAQ;EAChB,eAAe,QAAQ;EACvB,YAAY,QAAQ;EACpB,QAAQ,QAAQ;EAChB,6BAA6B;CAC/B;AACF,CAAC"}
1
+ {"version":3,"file":"thread-list-item-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/thread-list-item-runtime-client.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport { useEffect } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport { type ClientOutput, useAssistantEmit } from \"@assistant-ui/store\";\nimport type {\n ThreadListItemEventType,\n ThreadListItemRuntime,\n} from \"../../runtime/api/thread-list-item-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\n\nconst useThreadListItemClient = ({\n runtime,\n}: {\n runtime: ThreadListItemRuntime;\n}): ClientOutput<\"threadListItem\"> => {\n const state = useSubscribable(runtime);\n const emit = useAssistantEmit();\n\n // Bind thread list item events to event manager\n useEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n // Subscribe to thread list item events\n const threadListItemEvents: ThreadListItemEventType[] = [\n \"switchedTo\",\n \"switchedAway\",\n ];\n\n for (const event of threadListItemEvents) {\n const unsubscribe = runtime.unstable_on(event, () => {\n emit(`threadListItem.${event}`, {\n threadId: runtime.getState()!.id,\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, emit]);\n\n return {\n getState: () => state,\n switchTo: runtime.switchTo,\n rename: runtime.rename,\n updateCustom: runtime.updateCustom,\n archive: runtime.archive,\n unarchive: runtime.unarchive,\n delete: runtime.delete,\n generateTitle: runtime.generateTitle,\n initialize: runtime.initialize,\n detach: runtime.detach,\n __internal_getRuntime: () => runtime,\n };\n};\n\nexport const ThreadListItemClient = resource(useThreadListItemClient);\n"],"mappings":";;;;;AAUA,MAAM,2BAA2B,EAC/B,cAGoC;CACpC,MAAM,QAAQ,gBAAgB,OAAO;CACrC,MAAM,OAAO,iBAAiB;CAG9B,gBAAgB;EACd,MAAM,gBAA+B,CAAC;EAQtC,KAAK,MAAM,SAAS,CAJlB,cACA,cAGqC,GAAG;GACxC,MAAM,cAAc,QAAQ,YAAY,aAAa;IACnD,KAAK,kBAAkB,SAAS,EAC9B,UAAU,QAAQ,SAAS,CAAC,CAAE,GAChC,CAAC;GACH,CAAC;GACD,cAAc,KAAK,WAAW;EAChC;EAEA,aAAa;GACX,KAAK,MAAM,SAAS,eAAe,MAAM;EAC3C;CACF,GAAG,CAAC,SAAS,IAAI,CAAC;CAElB,OAAO;EACL,gBAAgB;EAChB,UAAU,QAAQ;EAClB,QAAQ,QAAQ;EAChB,cAAc,QAAQ;EACtB,SAAS,QAAQ;EACjB,WAAW,QAAQ;EACnB,QAAQ,QAAQ;EAChB,eAAe,QAAQ;EACvB,YAAY,QAAQ;EACpB,QAAQ,QAAQ;EAChB,6BAA6B;CAC/B;AACF;AAEA,MAAa,uBAAuB,SAAS,uBAAuB"}
@@ -3,13 +3,10 @@ import { AssistantRuntime } from "../../runtime/api/assistant-runtime.js";
3
3
  import { ClientOutput } from "@assistant-ui/store";
4
4
 
5
5
  //#region src/store/runtime-clients/thread-list-runtime-client.d.ts
6
- declare const ThreadListClient: (props: {
6
+ declare const ThreadListClient: import("@assistant-ui/tap").Resource<ClientOutput<"threads">, [{
7
7
  runtime: ThreadListRuntime;
8
8
  __internal_assistantRuntime: AssistantRuntime;
9
- }) => import("@assistant-ui/tap").ResourceElement<ClientOutput<"threads">, {
10
- runtime: ThreadListRuntime;
11
- __internal_assistantRuntime: AssistantRuntime;
12
- }>;
9
+ }]>;
13
10
  //#endregion
14
11
  export { ThreadListClient };
15
12
  //# sourceMappingURL=thread-list-runtime-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-list-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/thread-list-runtime-client.ts"],"mappings":";;;;;cAgCa,gBAAA,GAAgB,KAAA;WAIlB,iBAAA;+BACoB,gBAAA;AAAA;WADpB,iBAAA;+BACoB,gBAAA;AAAA"}
1
+ {"version":3,"file":"thread-list-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/thread-list-runtime-client.ts"],"mappings":";;;;;cAsGa,gBAAA,8BAAgB,QAAA,CAAA,YAAA;WAhElB,iBAAA;+BACoB,gBAAA;AAAA"}
@@ -5,10 +5,11 @@ import { useMemo } from "@assistant-ui/tap/react-shim";
5
5
  import { useClientLookup, useClientResource } from "@assistant-ui/store";
6
6
  import { resource, useResource, withKey } from "@assistant-ui/tap";
7
7
  //#region src/store/runtime-clients/thread-list-runtime-client.ts
8
- const ThreadListItemClientById = resource(function ThreadListItemClientById({ runtime, id }) {
8
+ const useThreadListItemClientById = ({ runtime, id }) => {
9
9
  return useResource(ThreadListItemClient({ runtime: useMemo(() => runtime.getItemById(id), [runtime, id]) }));
10
- });
11
- const ThreadListClient = resource(function ThreadListClient({ runtime, __internal_assistantRuntime }) {
10
+ };
11
+ const ThreadListItemClientById = resource(useThreadListItemClientById);
12
+ const useThreadListClient = ({ runtime, __internal_assistantRuntime }) => {
12
13
  const runtimeState = useSubscribable(runtime);
13
14
  const main = useClientResource(ThreadClient({ runtime: runtime.main }));
14
15
  const threadItems = useClientLookup(() => Object.keys(runtimeState.threadItems).map((id) => withKey(id, ThreadListItemClientById({
@@ -53,7 +54,8 @@ const ThreadListClient = resource(function ThreadListClient({ runtime, __interna
53
54
  loadMore: () => runtime.loadMore(),
54
55
  __internal_getAssistantRuntime: () => __internal_assistantRuntime
55
56
  };
56
- });
57
+ };
58
+ const ThreadListClient = resource(useThreadListClient);
57
59
  //#endregion
58
60
  export { ThreadListClient };
59
61
 
@@ -1 +1 @@
1
- {"version":3,"file":"thread-list-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/thread-list-runtime-client.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useResource, withKey, resource } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n useClientLookup,\n useClientResource,\n} from \"@assistant-ui/store\";\nimport type { ThreadListRuntime } from \"../../runtime/api/thread-list-runtime\";\nimport type { AssistantRuntime } from \"../../runtime/api/assistant-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\nimport { ThreadListItemClient } from \"./thread-list-item-runtime-client\";\nimport { ThreadClient } from \"./thread-runtime-client\";\nimport type { ThreadsState } from \"../scopes/threads\";\n\nconst ThreadListItemClientById = resource(function ThreadListItemClientById({\n runtime,\n id,\n}: {\n runtime: ThreadListRuntime;\n id: string;\n}) {\n const threadListItemRuntime = useMemo(\n () => runtime.getItemById(id),\n [runtime, id],\n );\n return useResource(\n ThreadListItemClient({\n runtime: threadListItemRuntime,\n }),\n );\n});\n\nexport const ThreadListClient = resource(function ThreadListClient({\n runtime,\n __internal_assistantRuntime,\n}: {\n runtime: ThreadListRuntime;\n __internal_assistantRuntime: AssistantRuntime;\n}): ClientOutput<\"threads\"> {\n const runtimeState = useSubscribable(runtime);\n\n const main = useClientResource(\n ThreadClient({\n runtime: runtime.main,\n }),\n );\n const threadItems = useClientLookup(\n () =>\n Object.keys(runtimeState.threadItems).map((id) =>\n withKey(id, ThreadListItemClientById({ runtime, id })),\n ),\n [runtimeState.threadItems, runtime],\n );\n\n const state = useMemo<ThreadsState>(() => {\n return {\n mainThreadId: runtimeState.mainThreadId,\n newThreadId: runtimeState.newThreadId ?? null,\n isLoading: runtimeState.isLoading,\n isLoadingMore: runtimeState.isLoadingMore,\n hasMore: runtimeState.hasMore,\n threadIds: runtimeState.threadIds,\n archivedThreadIds: runtimeState.archivedThreadIds,\n threadItems: threadItems.state,\n\n main: main.state,\n };\n }, [runtimeState, threadItems.state, main.state]);\n\n return {\n getState: () => state,\n thread: () => main.methods,\n item: (threadIdOrOptions) => {\n if (threadIdOrOptions === \"main\") {\n return threadItems.get({ key: state.mainThreadId });\n }\n\n if (\"id\" in threadIdOrOptions) {\n return threadItems.get({ key: threadIdOrOptions.id });\n }\n\n const { index, archived = false } = threadIdOrOptions;\n const id = archived\n ? state.archivedThreadIds[index]!\n : state.threadIds[index]!;\n return threadItems.get({ key: id });\n },\n switchToThread: async (threadId, options) => {\n await runtime.switchToThread(threadId, options);\n },\n switchToNewThread: async () => {\n await runtime.switchToNewThread();\n },\n getLoadThreadsPromise: () => runtime.getLoadThreadsPromise(),\n reload: () => runtime.reload(),\n loadMore: () => runtime.loadMore(),\n __internal_getAssistantRuntime: () => __internal_assistantRuntime,\n };\n});\n"],"mappings":";;;;;;;AAcA,MAAM,2BAA2B,SAAS,SAAS,yBAAyB,EAC1E,SACA,MAIC;CAKD,OAAO,YACL,qBAAqB,EACnB,SAN0B,cACtB,QAAQ,YAAY,EAAE,GAC5B,CAAC,SAAS,EAAE,CAImB,EAC/B,CAAC,CACH;AACF,CAAC;AAED,MAAa,mBAAmB,SAAS,SAAS,iBAAiB,EACjE,SACA,+BAI0B;CAC1B,MAAM,eAAe,gBAAgB,OAAO;CAE5C,MAAM,OAAO,kBACX,aAAa,EACX,SAAS,QAAQ,KACnB,CAAC,CACH;CACA,MAAM,cAAc,sBAEhB,OAAO,KAAK,aAAa,WAAW,CAAC,CAAC,KAAK,OACzC,QAAQ,IAAI,yBAAyB;EAAE;EAAS;CAAG,CAAC,CAAC,CACvD,GACF,CAAC,aAAa,aAAa,OAAO,CACpC;CAEA,MAAM,QAAQ,cAA4B;EACxC,OAAO;GACL,cAAc,aAAa;GAC3B,aAAa,aAAa,eAAe;GACzC,WAAW,aAAa;GACxB,eAAe,aAAa;GAC5B,SAAS,aAAa;GACtB,WAAW,aAAa;GACxB,mBAAmB,aAAa;GAChC,aAAa,YAAY;GAEzB,MAAM,KAAK;EACb;CACF,GAAG;EAAC;EAAc,YAAY;EAAO,KAAK;CAAK,CAAC;CAEhD,OAAO;EACL,gBAAgB;EAChB,cAAc,KAAK;EACnB,OAAO,sBAAsB;GAC3B,IAAI,sBAAsB,QACxB,OAAO,YAAY,IAAI,EAAE,KAAK,MAAM,aAAa,CAAC;GAGpD,IAAI,QAAQ,mBACV,OAAO,YAAY,IAAI,EAAE,KAAK,kBAAkB,GAAG,CAAC;GAGtD,MAAM,EAAE,OAAO,WAAW,UAAU;GACpC,MAAM,KAAK,WACP,MAAM,kBAAkB,SACxB,MAAM,UAAU;GACpB,OAAO,YAAY,IAAI,EAAE,KAAK,GAAG,CAAC;EACpC;EACA,gBAAgB,OAAO,UAAU,YAAY;GAC3C,MAAM,QAAQ,eAAe,UAAU,OAAO;EAChD;EACA,mBAAmB,YAAY;GAC7B,MAAM,QAAQ,kBAAkB;EAClC;EACA,6BAA6B,QAAQ,sBAAsB;EAC3D,cAAc,QAAQ,OAAO;EAC7B,gBAAgB,QAAQ,SAAS;EACjC,sCAAsC;CACxC;AACF,CAAC"}
1
+ {"version":3,"file":"thread-list-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/thread-list-runtime-client.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useResource, withKey, resource } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n useClientLookup,\n useClientResource,\n} from \"@assistant-ui/store\";\nimport type { ThreadListRuntime } from \"../../runtime/api/thread-list-runtime\";\nimport type { AssistantRuntime } from \"../../runtime/api/assistant-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\nimport { ThreadListItemClient } from \"./thread-list-item-runtime-client\";\nimport { ThreadClient } from \"./thread-runtime-client\";\nimport type { ThreadsState } from \"../scopes/threads\";\n\nconst useThreadListItemClientById = ({\n runtime,\n id,\n}: {\n runtime: ThreadListRuntime;\n id: string;\n}) => {\n const threadListItemRuntime = useMemo(\n () => runtime.getItemById(id),\n [runtime, id],\n );\n return useResource(\n ThreadListItemClient({\n runtime: threadListItemRuntime,\n }),\n );\n};\n\nconst ThreadListItemClientById = resource(useThreadListItemClientById);\n\nconst useThreadListClient = ({\n runtime,\n __internal_assistantRuntime,\n}: {\n runtime: ThreadListRuntime;\n __internal_assistantRuntime: AssistantRuntime;\n}): ClientOutput<\"threads\"> => {\n const runtimeState = useSubscribable(runtime);\n\n const main = useClientResource(\n ThreadClient({\n runtime: runtime.main,\n }),\n );\n const threadItems = useClientLookup(\n () =>\n Object.keys(runtimeState.threadItems).map((id) =>\n withKey(id, ThreadListItemClientById({ runtime, id })),\n ),\n [runtimeState.threadItems, runtime],\n );\n\n const state = useMemo<ThreadsState>(() => {\n return {\n mainThreadId: runtimeState.mainThreadId,\n newThreadId: runtimeState.newThreadId ?? null,\n isLoading: runtimeState.isLoading,\n isLoadingMore: runtimeState.isLoadingMore,\n hasMore: runtimeState.hasMore,\n threadIds: runtimeState.threadIds,\n archivedThreadIds: runtimeState.archivedThreadIds,\n threadItems: threadItems.state,\n\n main: main.state,\n };\n }, [runtimeState, threadItems.state, main.state]);\n\n return {\n getState: () => state,\n thread: () => main.methods,\n item: (threadIdOrOptions) => {\n if (threadIdOrOptions === \"main\") {\n return threadItems.get({ key: state.mainThreadId });\n }\n\n if (\"id\" in threadIdOrOptions) {\n return threadItems.get({ key: threadIdOrOptions.id });\n }\n\n const { index, archived = false } = threadIdOrOptions;\n const id = archived\n ? state.archivedThreadIds[index]!\n : state.threadIds[index]!;\n return threadItems.get({ key: id });\n },\n switchToThread: async (threadId, options) => {\n await runtime.switchToThread(threadId, options);\n },\n switchToNewThread: async () => {\n await runtime.switchToNewThread();\n },\n getLoadThreadsPromise: () => runtime.getLoadThreadsPromise(),\n reload: () => runtime.reload(),\n loadMore: () => runtime.loadMore(),\n __internal_getAssistantRuntime: () => __internal_assistantRuntime,\n };\n};\n\nexport const ThreadListClient = resource(useThreadListClient);\n"],"mappings":";;;;;;;AAcA,MAAM,+BAA+B,EACnC,SACA,SAII;CAKJ,OAAO,YACL,qBAAqB,EACnB,SAN0B,cACtB,QAAQ,YAAY,EAAE,GAC5B,CAAC,SAAS,EAAE,CAImB,EAC/B,CAAC,CACH;AACF;AAEA,MAAM,2BAA2B,SAAS,2BAA2B;AAErE,MAAM,uBAAuB,EAC3B,SACA,kCAI6B;CAC7B,MAAM,eAAe,gBAAgB,OAAO;CAE5C,MAAM,OAAO,kBACX,aAAa,EACX,SAAS,QAAQ,KACnB,CAAC,CACH;CACA,MAAM,cAAc,sBAEhB,OAAO,KAAK,aAAa,WAAW,CAAC,CAAC,KAAK,OACzC,QAAQ,IAAI,yBAAyB;EAAE;EAAS;CAAG,CAAC,CAAC,CACvD,GACF,CAAC,aAAa,aAAa,OAAO,CACpC;CAEA,MAAM,QAAQ,cAA4B;EACxC,OAAO;GACL,cAAc,aAAa;GAC3B,aAAa,aAAa,eAAe;GACzC,WAAW,aAAa;GACxB,eAAe,aAAa;GAC5B,SAAS,aAAa;GACtB,WAAW,aAAa;GACxB,mBAAmB,aAAa;GAChC,aAAa,YAAY;GAEzB,MAAM,KAAK;EACb;CACF,GAAG;EAAC;EAAc,YAAY;EAAO,KAAK;CAAK,CAAC;CAEhD,OAAO;EACL,gBAAgB;EAChB,cAAc,KAAK;EACnB,OAAO,sBAAsB;GAC3B,IAAI,sBAAsB,QACxB,OAAO,YAAY,IAAI,EAAE,KAAK,MAAM,aAAa,CAAC;GAGpD,IAAI,QAAQ,mBACV,OAAO,YAAY,IAAI,EAAE,KAAK,kBAAkB,GAAG,CAAC;GAGtD,MAAM,EAAE,OAAO,WAAW,UAAU;GACpC,MAAM,KAAK,WACP,MAAM,kBAAkB,SACxB,MAAM,UAAU;GACpB,OAAO,YAAY,IAAI,EAAE,KAAK,GAAG,CAAC;EACpC;EACA,gBAAgB,OAAO,UAAU,YAAY;GAC3C,MAAM,QAAQ,eAAe,UAAU,OAAO;EAChD;EACA,mBAAmB,YAAY;GAC7B,MAAM,QAAQ,kBAAkB;EAClC;EACA,6BAA6B,QAAQ,sBAAsB;EAC3D,cAAc,QAAQ,OAAO;EAC7B,gBAAgB,QAAQ,SAAS;EACjC,sCAAsC;CACxC;AACF;AAEA,MAAa,mBAAmB,SAAS,mBAAmB"}
@@ -2,11 +2,9 @@ import { ThreadRuntime } from "../../runtime/api/thread-runtime.js";
2
2
  import { ClientOutput } from "@assistant-ui/store";
3
3
 
4
4
  //#region src/store/runtime-clients/thread-runtime-client.d.ts
5
- declare const ThreadClient: (props: {
5
+ declare const ThreadClient: import("@assistant-ui/tap").Resource<ClientOutput<"thread">, [{
6
6
  runtime: ThreadRuntime;
7
- }) => import("@assistant-ui/tap").ResourceElement<ClientOutput<"thread">, {
8
- runtime: ThreadRuntime;
9
- }>;
7
+ }]>;
10
8
  //#endregion
11
9
  export { ThreadClient };
12
10
  //# sourceMappingURL=thread-runtime-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/thread-runtime-client.ts"],"mappings":";;;;cAiCa,YAAA,GAAY,KAAA;WAGd,aAAA;AAAA;WAAA,aAAA;AAAA"}
1
+ {"version":3,"file":"thread-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/thread-runtime-client.ts"],"mappings":";;;;cA2Ia,YAAA,8BAAY,QAAA,CAAA,YAAA;WArGd,aAAa;AAAA"}
@@ -5,13 +5,14 @@ import { useEffect, useMemo } from "@assistant-ui/tap/react-shim";
5
5
  import { useAssistantEmit, useClientLookup, useClientResource } from "@assistant-ui/store";
6
6
  import { resource, useResource, withKey } from "@assistant-ui/tap";
7
7
  //#region src/store/runtime-clients/thread-runtime-client.ts
8
- const MessageClientById = resource(function MessageClientById({ runtime, id, threadIdRef }) {
8
+ const useMessageClientById = ({ runtime, id, threadIdRef }) => {
9
9
  return useResource(MessageClient({
10
10
  runtime: useMemo(() => runtime.getMessageById(id), [runtime, id]),
11
11
  threadIdRef
12
12
  }));
13
- });
14
- const ThreadClient = resource(function ThreadClient({ runtime }) {
13
+ };
14
+ const MessageClientById = resource(useMessageClientById);
15
+ const useThreadClient = ({ runtime }) => {
15
16
  const runtimeState = useSubscribable(runtime);
16
17
  const emit = useAssistantEmit();
17
18
  useEffect(() => {
@@ -72,6 +73,7 @@ const ThreadClient = resource(function ThreadClient({ runtime }) {
72
73
  getState: () => state,
73
74
  composer: () => composer.methods,
74
75
  append: runtime.append,
76
+ deleteMessage: runtime.deleteMessage,
75
77
  startRun: runtime.startRun,
76
78
  resumeRun: runtime.resumeRun,
77
79
  cancelRun: runtime.cancelRun,
@@ -92,7 +94,8 @@ const ThreadClient = resource(function ThreadClient({ runtime }) {
92
94
  },
93
95
  __internal_getRuntime: () => runtime
94
96
  };
95
- });
97
+ };
98
+ const ThreadClient = resource(useThreadClient);
96
99
  //#endregion
97
100
  export { ThreadClient };
98
101
 
@@ -1 +1 @@
1
- {"version":3,"file":"thread-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/thread-runtime-client.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ThreadRuntimeEventType } from \"../../runtime/interfaces/thread-runtime-core\";\nimport type { ThreadRuntime } from \"../../runtime/api/thread-runtime\";\nimport { useMemo, useEffect, RefObject } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n useAssistantEmit,\n useClientLookup,\n useClientResource,\n} from \"@assistant-ui/store\";\nimport { ComposerClient } from \"./composer-runtime-client\";\nimport { MessageClient } from \"./message-runtime-client\";\nimport { useSubscribable } from \"./useSubscribable\";\nimport type { ThreadState } from \"../scopes/thread\";\n\nconst MessageClientById = resource(function MessageClientById({\n runtime,\n id,\n threadIdRef,\n}: {\n runtime: ThreadRuntime;\n id: string;\n threadIdRef: RefObject<string>;\n}) {\n const messageRuntime = useMemo(\n () => runtime.getMessageById(id),\n [runtime, id],\n );\n\n return useResource(MessageClient({ runtime: messageRuntime, threadIdRef }));\n});\n\nexport const ThreadClient = resource(function ThreadClient({\n runtime,\n}: {\n runtime: ThreadRuntime;\n}): ClientOutput<\"thread\"> {\n const runtimeState = useSubscribable(runtime);\n const emit = useAssistantEmit();\n\n useEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n const threadEvents: ThreadRuntimeEventType[] = [\n \"runStart\",\n \"runEnd\",\n \"initialize\",\n \"modelContextUpdate\",\n ];\n\n for (const event of threadEvents) {\n const unsubscribe = runtime.unstable_on(event, () => {\n const threadId = runtime.getState()?.threadId || \"unknown\";\n emit(`thread.${event}`, {\n threadId,\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, emit]);\n\n const threadIdRef = useMemo(\n () => ({\n get current() {\n return runtime.getState()!.threadId;\n },\n }),\n [runtime],\n );\n\n const composer = useClientResource(\n ComposerClient({\n runtime: runtime.composer,\n threadIdRef,\n }),\n );\n const messages = useClientLookup(\n () =>\n runtimeState.messages.map((m) =>\n withKey(m.id, MessageClientById({ runtime, id: m.id, threadIdRef })),\n ),\n [runtimeState.messages, runtime, threadIdRef],\n );\n\n const state = useMemo<ThreadState>(() => {\n return {\n isEmpty: messages.state.length === 0 && !runtimeState.isLoading,\n isDisabled: runtimeState.isDisabled,\n isLoading: runtimeState.isLoading,\n isRunning: runtimeState.isRunning,\n capabilities: runtimeState.capabilities,\n state: runtimeState.state,\n suggestions: runtimeState.suggestions,\n extras: runtimeState.extras,\n speech: runtimeState.speech,\n voice: runtimeState.voice,\n\n composer: composer.state,\n messages: messages.state,\n };\n }, [runtimeState, messages, composer.state]);\n\n return {\n getState: () => state,\n composer: () => composer.methods,\n append: runtime.append,\n startRun: runtime.startRun,\n resumeRun: runtime.resumeRun,\n cancelRun: runtime.cancelRun,\n getModelContext: runtime.getModelContext,\n export: runtime.export,\n import: runtime.import,\n reset: runtime.reset,\n stopSpeaking: runtime.stopSpeaking,\n connectVoice: runtime.connectVoice,\n disconnectVoice: runtime.disconnectVoice,\n getVoiceVolume: runtime.getVoiceVolume,\n subscribeVoiceVolume: runtime.subscribeVoiceVolume,\n muteVoice: runtime.muteVoice,\n unmuteVoice: runtime.unmuteVoice,\n message: (selector) => {\n if (\"id\" in selector) {\n return messages.get({ key: selector.id });\n } else {\n return messages.get(selector);\n }\n },\n __internal_getRuntime: () => runtime,\n };\n});\n"],"mappings":";;;;;;;AAgBA,MAAM,oBAAoB,SAAS,SAAS,kBAAkB,EAC5D,SACA,IACA,eAKC;CAMD,OAAO,YAAY,cAAc;EAAE,SALZ,cACf,QAAQ,eAAe,EAAE,GAC/B,CAAC,SAAS,EAAE,CAG2C;EAAG;CAAY,CAAC,CAAC;AAC5E,CAAC;AAED,MAAa,eAAe,SAAS,SAAS,aAAa,EACzD,WAGyB;CACzB,MAAM,eAAe,gBAAgB,OAAO;CAC5C,MAAM,OAAO,iBAAiB;CAE9B,gBAAgB;EACd,MAAM,gBAA+B,CAAC;EAStC,KAAK,MAAM,SAAS;GANlB;GACA;GACA;GACA;EAG6B,GAAG;GAChC,MAAM,cAAc,QAAQ,YAAY,aAAa;IACnD,MAAM,WAAW,QAAQ,SAAS,CAAC,EAAE,YAAY;IACjD,KAAK,UAAU,SAAS,EACtB,SACF,CAAC;GACH,CAAC;GACD,cAAc,KAAK,WAAW;EAChC;EAEA,aAAa;GACX,KAAK,MAAM,SAAS,eAAe,MAAM;EAC3C;CACF,GAAG,CAAC,SAAS,IAAI,CAAC;CAElB,MAAM,cAAc,eACX,EACL,IAAI,UAAU;EACZ,OAAO,QAAQ,SAAS,CAAC,CAAE;CAC7B,EACF,IACA,CAAC,OAAO,CACV;CAEA,MAAM,WAAW,kBACf,eAAe;EACb,SAAS,QAAQ;EACjB;CACF,CAAC,CACH;CACA,MAAM,WAAW,sBAEb,aAAa,SAAS,KAAK,MACzB,QAAQ,EAAE,IAAI,kBAAkB;EAAE;EAAS,IAAI,EAAE;EAAI;CAAY,CAAC,CAAC,CACrE,GACF;EAAC,aAAa;EAAU;EAAS;CAAW,CAC9C;CAEA,MAAM,QAAQ,cAA2B;EACvC,OAAO;GACL,SAAS,SAAS,MAAM,WAAW,KAAK,CAAC,aAAa;GACtD,YAAY,aAAa;GACzB,WAAW,aAAa;GACxB,WAAW,aAAa;GACxB,cAAc,aAAa;GAC3B,OAAO,aAAa;GACpB,aAAa,aAAa;GAC1B,QAAQ,aAAa;GACrB,QAAQ,aAAa;GACrB,OAAO,aAAa;GAEpB,UAAU,SAAS;GACnB,UAAU,SAAS;EACrB;CACF,GAAG;EAAC;EAAc;EAAU,SAAS;CAAK,CAAC;CAE3C,OAAO;EACL,gBAAgB;EAChB,gBAAgB,SAAS;EACzB,QAAQ,QAAQ;EAChB,UAAU,QAAQ;EAClB,WAAW,QAAQ;EACnB,WAAW,QAAQ;EACnB,iBAAiB,QAAQ;EACzB,QAAQ,QAAQ;EAChB,QAAQ,QAAQ;EAChB,OAAO,QAAQ;EACf,cAAc,QAAQ;EACtB,cAAc,QAAQ;EACtB,iBAAiB,QAAQ;EACzB,gBAAgB,QAAQ;EACxB,sBAAsB,QAAQ;EAC9B,WAAW,QAAQ;EACnB,aAAa,QAAQ;EACrB,UAAU,aAAa;GACrB,IAAI,QAAQ,UACV,OAAO,SAAS,IAAI,EAAE,KAAK,SAAS,GAAG,CAAC;QAExC,OAAO,SAAS,IAAI,QAAQ;EAEhC;EACA,6BAA6B;CAC/B;AACF,CAAC"}
1
+ {"version":3,"file":"thread-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/thread-runtime-client.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ThreadRuntimeEventType } from \"../../runtime/interfaces/thread-runtime-core\";\nimport type { ThreadRuntime } from \"../../runtime/api/thread-runtime\";\nimport { useMemo, useEffect, RefObject } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n useAssistantEmit,\n useClientLookup,\n useClientResource,\n} from \"@assistant-ui/store\";\nimport { ComposerClient } from \"./composer-runtime-client\";\nimport { MessageClient } from \"./message-runtime-client\";\nimport { useSubscribable } from \"./useSubscribable\";\nimport type { ThreadState } from \"../scopes/thread\";\n\nconst useMessageClientById = ({\n runtime,\n id,\n threadIdRef,\n}: {\n runtime: ThreadRuntime;\n id: string;\n threadIdRef: RefObject<string>;\n}) => {\n const messageRuntime = useMemo(\n () => runtime.getMessageById(id),\n [runtime, id],\n );\n\n return useResource(MessageClient({ runtime: messageRuntime, threadIdRef }));\n};\n\nconst MessageClientById = resource(useMessageClientById);\n\nconst useThreadClient = ({\n runtime,\n}: {\n runtime: ThreadRuntime;\n}): ClientOutput<\"thread\"> => {\n const runtimeState = useSubscribable(runtime);\n const emit = useAssistantEmit();\n\n useEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n const threadEvents: ThreadRuntimeEventType[] = [\n \"runStart\",\n \"runEnd\",\n \"initialize\",\n \"modelContextUpdate\",\n ];\n\n for (const event of threadEvents) {\n const unsubscribe = runtime.unstable_on(event, () => {\n const threadId = runtime.getState()?.threadId || \"unknown\";\n emit(`thread.${event}`, {\n threadId,\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, emit]);\n\n const threadIdRef = useMemo(\n () => ({\n get current() {\n return runtime.getState()!.threadId;\n },\n }),\n [runtime],\n );\n\n const composer = useClientResource(\n ComposerClient({\n runtime: runtime.composer,\n threadIdRef,\n }),\n );\n const messages = useClientLookup(\n () =>\n runtimeState.messages.map((m) =>\n withKey(m.id, MessageClientById({ runtime, id: m.id, threadIdRef })),\n ),\n [runtimeState.messages, runtime, threadIdRef],\n );\n\n const state = useMemo<ThreadState>(() => {\n return {\n isEmpty: messages.state.length === 0 && !runtimeState.isLoading,\n isDisabled: runtimeState.isDisabled,\n isLoading: runtimeState.isLoading,\n isRunning: runtimeState.isRunning,\n capabilities: runtimeState.capabilities,\n state: runtimeState.state,\n suggestions: runtimeState.suggestions,\n extras: runtimeState.extras,\n speech: runtimeState.speech,\n voice: runtimeState.voice,\n\n composer: composer.state,\n messages: messages.state,\n };\n }, [runtimeState, messages, composer.state]);\n\n return {\n getState: () => state,\n composer: () => composer.methods,\n append: runtime.append,\n deleteMessage: runtime.deleteMessage,\n startRun: runtime.startRun,\n resumeRun: runtime.resumeRun,\n cancelRun: runtime.cancelRun,\n getModelContext: runtime.getModelContext,\n export: runtime.export,\n import: runtime.import,\n reset: runtime.reset,\n stopSpeaking: runtime.stopSpeaking,\n connectVoice: runtime.connectVoice,\n disconnectVoice: runtime.disconnectVoice,\n getVoiceVolume: runtime.getVoiceVolume,\n subscribeVoiceVolume: runtime.subscribeVoiceVolume,\n muteVoice: runtime.muteVoice,\n unmuteVoice: runtime.unmuteVoice,\n message: (selector) => {\n if (\"id\" in selector) {\n return messages.get({ key: selector.id });\n } else {\n return messages.get(selector);\n }\n },\n __internal_getRuntime: () => runtime,\n };\n};\n\nexport const ThreadClient = resource(useThreadClient);\n"],"mappings":";;;;;;;AAgBA,MAAM,wBAAwB,EAC5B,SACA,IACA,kBAKI;CAMJ,OAAO,YAAY,cAAc;EAAE,SALZ,cACf,QAAQ,eAAe,EAAE,GAC/B,CAAC,SAAS,EAAE,CAG2C;EAAG;CAAY,CAAC,CAAC;AAC5E;AAEA,MAAM,oBAAoB,SAAS,oBAAoB;AAEvD,MAAM,mBAAmB,EACvB,cAG4B;CAC5B,MAAM,eAAe,gBAAgB,OAAO;CAC5C,MAAM,OAAO,iBAAiB;CAE9B,gBAAgB;EACd,MAAM,gBAA+B,CAAC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AQ;EACf,cAAc,QAAQ;EACtB,cAAc,QAAQ;EACtB,iBAAiB,QAAQ;EACzB,gBAAgB,QAAQ;EACxB,sBAAsB,QAAQ;EAC9B,WAAW,QAAQ;EACnB,aAAa,QAAQ;EACrB,UAAU,aAAa;GACrB,IAAI,QAAQ,UACV,OAAO,SAAS,IAAI,EAAE,KAAK,SAAS,GAAG,CAAC;QAExC,OAAO,SAAS,IAAI,QAAQ;EAEhC;EACA,6BAA6B;CAC/B;AACF;AAEA,MAAa,eAAe,SAAS,eAAe"}
@@ -40,6 +40,7 @@ type MessageMethods = {
40
40
  */
41
41
  getState(): MessageState;
42
42
  composer(): ComposerMethods;
43
+ delete(): void | Promise<void>;
43
44
  reload(config?: {
44
45
  runConfig?: RunConfig;
45
46
  }): void; /** @deprecated This API is still under active development and might change without notice. */
@@ -1 +1 @@
1
- {"version":3,"file":"message.d.ts","names":[],"sources":["../../../src/store/scopes/message.ts"],"mappings":";;;;;;;;KAQY,YAAA,GAAe,aAAA;EAAA,SAChB,QAAA;EAAA,SACA,MAAA;EAAA,SACA,YAAA;EAAA,SACA,WAAA;EAiBQ;;;;;;;;;;;;;;;;EAAA,SAAR,MAAA,EAAQ,WAAA;EAAA,SACR,QAAA,EAAU,aAAA;EAAA,SACV,KAAA,WAAgB,SAAA;EAAA,SAChB,QAAA;EAAA,SACA,UAAA,WAKC;EAAA,SAHD,KAAA;AAAA;AAAA,KAGC,cAAA;EAKE;;;EADZ,QAAA,IAAY,YAAA;EACZ,QAAA,IAAY,eAAA;EACZ,MAAA,CAAO,MAAA;IAAW,SAAA,GAAY,SAAA;EAAA,UAFlB;EAIZ,KAAA,UAHY;EAKZ,YAAA;EACA,cAAA,CAAe,QAAA;IAAY,IAAA;EAAA;EAC3B,cAAA,CAAe,OAAA;IACb,QAAA;IACA,QAAA;EAAA;EAEF,WAAA;EACA,IAAA,CAAK,QAAA;IAAY,KAAA;EAAA;IAAoB,UAAA;EAAA,IAAuB,WAAA;EAC5D,UAAA,C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ACA,KAAA;IAAS,IAAA;IAAY,EAAA;EAAA;IAAiB,IAAA;IAAe,KAAA;EAAA;AAAA;AAAA,KAG3C,mBAAA;EACV,OAAA,EAAS,cAAA;EACT,IAAA,EAAM,WAAW;AAAA"}
@@ -7,6 +7,7 @@ type ThreadListItemState = {
7
7
  readonly remoteId: string | undefined;
8
8
  readonly externalId: string | undefined;
9
9
  readonly title?: string | undefined;
10
+ readonly lastMessageAt?: Date | undefined;
10
11
  readonly status: ThreadListItemStatus;
11
12
  readonly custom?: Record<string, unknown> | undefined;
12
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"thread-list-item.d.ts","names":[],"sources":["../../../src/store/scopes/thread-list-item.ts"],"mappings":";;;;KAGY,mBAAA;EAAA,SACD,EAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA,EAAQ,oBAAA;EAAA,SACR,MAAA,GAAS,MAAM;AAAA;AAAA,KAGd,qBAAA;EACV,QAAA,IAAY,mBAAA;EACZ,QAAA,CAAS,OAAA;IAAY,SAAA;EAAA;EACrB,MAAA,CAAO,QAAA;EACP,YAAA,CAAa,MAAA,EAAQ,MAAA;EACrB,OAAA;EACA,SAAA;EACA,MAAA;EACA,aAAA;EACA,UAAA,IAAc,OAAA;IAAU,QAAA;IAAkB,UAAA;EAAA;EAC1C,MAAA;EACA,qBAAA,KAA0B,qBAAA;AAAA;AAAA,KAGhB,kBAAA;EACV,MAAA;EACA,KAAA;IACM,IAAA;EAAA;IACA,IAAA;IAAY,EAAA;EAAA;IACZ,IAAA;IAAe,KAAA;IAAe,QAAA;EAAA;AAAA;AAAA,KAG1B,oBAAA;EAbI;;;;;EAmBd,2BAAA;IAA+B,QAAA;EAAA;EAdrB;;;;;EAoBV,6BAAA;IAAiC,QAAA;EAAA;AAAA;AAAA,KAGvB,0BAAA;EACV,OAAA,EAAS,qBAAA;EACT,IAAA,EAAM,kBAAA;EACN,MAAA,EAAQ,oBAAA;AAAA"}
1
+ {"version":3,"file":"thread-list-item.d.ts","names":[],"sources":["../../../src/store/scopes/thread-list-item.ts"],"mappings":";;;;KAGY,mBAAA;EAAA,SACD,EAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SACA,KAAA;EAAA,SACA,aAAA,GAAgB,IAAA;EAAA,SAChB,MAAA,EAAQ,oBAAA;EAAA,SACR,MAAA,GAAS,MAAA;AAAA;AAAA,KAGR,qBAAA;EACV,QAAA,IAAY,mBAAA;EACZ,QAAA,CAAS,OAAA;IAAY,SAAA;EAAA;EACrB,MAAA,CAAO,QAAA;EACP,YAAA,CAAa,MAAA,EAAQ,MAAA;EACrB,OAAA;EACA,SAAA;EACA,MAAA;EACA,aAAA;EACA,UAAA,IAAc,OAAA;IAAU,QAAA;IAAkB,UAAA;EAAA;EAC1C,MAAA;EACA,qBAAA,KAA0B,qBAAA;AAAA;AAAA,KAGhB,kBAAA;EACV,MAAA;EACA,KAAA;IACM,IAAA;EAAA;IACA,IAAA;IAAY,EAAA;EAAA;IACZ,IAAA;IAAe,KAAA;IAAe,QAAA;EAAA;AAAA;AAAA,KAG1B,oBAAA;EAjBV;;;;;EAuBA,2BAAA;IAA+B,QAAA;EAAA;EAlB/B;;;;AAC+C;EAuB/C,6BAAA;IAAiC,QAAA;EAAA;AAAA;AAAA,KAGvB,0BAAA;EACV,OAAA,EAAS,qBAAA;EACT,IAAA,EAAM,kBAAA;EACN,MAAA,EAAQ,oBAAA;AAAA"}
@@ -77,6 +77,7 @@ type ThreadMethods = {
77
77
  * ```
78
78
  */
79
79
  append(message: CreateAppendMessage): void;
80
+ deleteMessage(messageId: string): void | Promise<void>;
80
81
  /**
81
82
  * Start a new run with the given configuration.
82
83
  * @param config The configuration for starting the run
@@ -1 +1 @@
1
- {"version":3,"file":"thread.d.ts","names":[],"sources":["../../../src/store/scopes/thread.ts"],"mappings":";;;;;;;;;;;KAoBY,WAAA;;AAAZ;;WAIW,OAAA;EAgBc;;;EAAA,SAZd,UAA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AAA;EACA,qBAAA,KAA0B,aAAA;AAAA;AAAA,KAGhB,UAAA;EACV,MAAA;EACA,KAAA;IAAS,IAAA;EAAA;AAAA;AAAA,KAGC,YAAA;EAKV;;;;EAAA,iBAAA;IAAqB,QAAA;EAAA;EAgBU;;AAAQ;AAGzC;EAdE,eAAA;IAAmB,QAAA;EAAA;EAgBb;;;;;EAVN,mBAAA;IAAuB,QAAA;EAAA;EAWvB;;;AAAoB;EANpB,2BAAA;IAA+B,QAAA;EAAA;AAAA;AAAA,KAGrB,kBAAA;EACV,OAAA,EAAS,aAAA;EACT,IAAA,EAAM,UAAA;EACN,MAAA,EAAQ,YAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/core",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "description": "Framework-agnostic core runtime for assistant-ui",
5
5
  "keywords": [
6
6
  "assistant",
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@assistant-ui/store": "^0.2.13",
70
- "@assistant-ui/tap": "^0.6.1",
70
+ "@assistant-ui/tap": "^0.7.0",
71
71
  "@types/react": "*",
72
72
  "react": "^18 || ^19",
73
73
  "assistant-cloud": "^0.1.31",
@@ -92,8 +92,8 @@
92
92
  "react": "^19.2.7",
93
93
  "vitest": "^4.1.8",
94
94
  "zustand": "^5.0.14",
95
- "@assistant-ui/store": "0.2.14",
96
- "@assistant-ui/tap": "0.6.1",
95
+ "@assistant-ui/store": "0.2.16",
96
+ "@assistant-ui/tap": "0.7.1",
97
97
  "@assistant-ui/vite": "0.0.4",
98
98
  "@assistant-ui/x-buildutils": "0.0.12",
99
99
  "assistant-cloud": "0.1.32"
@@ -43,6 +43,7 @@ export type GenericThreadHistoryAdapter<TMessage> = {
43
43
  item: MessageFormatItem<TMessage>,
44
44
  localMessageId: string,
45
45
  ): Promise<void>;
46
+ delete?(items: MessageFormatItem<TMessage>[]): Promise<void>;
46
47
  reportTelemetry?(
47
48
  items: MessageFormatItem<TMessage>[],
48
49
  options?: {
@@ -58,6 +59,7 @@ export type ThreadHistoryAdapter = {
58
59
  options: ChatModelRunOptions,
59
60
  ): AsyncGenerator<ChatModelRunResult, void, unknown>;
60
61
  append(item: ExportedMessageRepositoryItem): Promise<void>;
62
+ delete?(items: ExportedMessageRepositoryItem[]): Promise<void>;
61
63
  /** Required when used with `useAISDKRuntime` / `useChatRuntime`. */
62
64
  withFormat?<TMessage, TStorageFormat extends Record<string, unknown>>(
63
65
  formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>,
package/src/index.ts CHANGED
@@ -287,6 +287,7 @@ export { pickExternalStoreSharedOptions } from "./runtimes/external-store/extern
287
287
 
288
288
  // Message queue
289
289
  export type { ExternalThreadQueueAdapter } from "./runtime/queue/external-thread-queue-adapter";
290
+ export type { ExternalThreadBranchAdapter } from "./runtime/branch/external-thread-branch-adapter";
290
291
  export {
291
292
  createMessageQueue,
292
293
  type MessageQueueDriver,
@@ -23,11 +23,13 @@ export const AssistantProviderBase: FC<AssistantProviderBaseProps> = memo(
23
23
  ({ runtime, aui: parent = null, children }) => {
24
24
  const aui = useAui({ threads: RuntimeAdapter(runtime) }, { parent });
25
25
  const RenderComponent = getRenderComponent(runtime);
26
- return (
26
+ const inner = (
27
27
  <AuiProvider value={aui}>
28
28
  {RenderComponent && <RenderComponent />}
29
29
  {children}
30
30
  </AuiProvider>
31
31
  );
32
+ if (!parent) return inner;
33
+ return <AuiProvider value={parent}>{inner}</AuiProvider>;
32
34
  },
33
35
  );