@assistant-ui/react 0.11.45 → 0.11.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/augmentations.d.ts.map +1 -1
- package/dist/client/ThreadMessageClient.js +2 -2
- package/dist/client/ThreadMessageClient.js.map +1 -1
- package/dist/client/types/ModelContext.d.ts.map +1 -1
- package/dist/context/react/AssistantApiContext.d.ts.map +1 -1
- package/dist/context/react/AssistantApiContext.js.map +1 -1
- package/dist/context/react/utils/createStateHookForRuntime.d.ts.map +1 -1
- package/dist/context/react/utils/createStateHookForRuntime.js.map +1 -1
- package/dist/context/react/utils/ensureBinding.js.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts +3 -3
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +3 -6
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.js +1 -1
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/MessageRuntimeClient.js +1 -1
- package/dist/legacy-runtime/client/MessageRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/cloud/auiV0.js +1 -1
- package/dist/legacy-runtime/cloud/auiV0.js.map +1 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js +2 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime/AssistantRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime/AssistantRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime/ComposerRuntime.js +2 -2
- package/dist/legacy-runtime/runtime/ComposerRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime/MessageRuntime.js +3 -3
- package/dist/legacy-runtime/runtime/MessageRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime/ThreadListRuntime.js +1 -1
- package/dist/legacy-runtime/runtime/ThreadListRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime/ThreadRuntime.js +2 -2
- package/dist/legacy-runtime/runtime/ThreadRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts +1 -2
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CompositeAttachmentAdapter.js +2 -2
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CompositeAttachmentAdapter.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/feedback/index.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/feedback/index.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/suggestion/index.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/suggestion/index.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +2 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.js +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/index.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/local/index.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/index.js +2 -3
- package/dist/legacy-runtime/runtime-cores/local/index.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js +3 -3
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/types.d.ts +6 -0
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/types.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js +15 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/message/MessageError.js +1 -2
- package/dist/primitives/message/MessageError.js.map +1 -1
- package/dist/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +2 -2
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/package.json +2 -5
- package/src/augmentations.ts +0 -2
- package/src/client/ThreadMessageClient.tsx +2 -2
- package/src/client/types/ModelContext.ts +0 -1
- package/src/context/react/AssistantApiContext.tsx +0 -2
- package/src/context/react/utils/createStateHookForRuntime.ts +0 -1
- package/src/context/react/utils/ensureBinding.ts +1 -1
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +5 -6
- package/src/legacy-runtime/client/MessagePartRuntimeClient.ts +1 -1
- package/src/legacy-runtime/client/MessageRuntimeClient.ts +1 -1
- package/src/legacy-runtime/cloud/auiV0.ts +1 -1
- package/src/legacy-runtime/cloud/useCloudThreadListRuntime.tsx +1 -0
- package/src/legacy-runtime/runtime/AssistantRuntime.ts +3 -1
- package/src/legacy-runtime/runtime/ComposerRuntime.ts +2 -2
- package/src/legacy-runtime/runtime/MessageRuntime.ts +3 -3
- package/src/legacy-runtime/runtime/ThreadListRuntime.ts +1 -1
- package/src/legacy-runtime/runtime/ThreadRuntime.ts +2 -2
- package/src/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.tsx +1 -1
- package/src/legacy-runtime/runtime-cores/adapters/attachment/CompositeAttachmentAdapter.ts +2 -2
- package/src/legacy-runtime/runtime-cores/adapters/feedback/index.ts +1 -1
- package/src/legacy-runtime/runtime-cores/adapters/suggestion/index.ts +1 -1
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.tsx +1 -0
- package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.tsx +1 -1
- package/src/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.tsx +1 -1
- package/src/legacy-runtime/runtime-cores/local/index.ts +1 -1
- package/src/legacy-runtime/runtime-cores/local/useLocalRuntime.tsx +2 -1
- package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +0 -2
- package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +0 -2
- package/src/legacy-runtime/runtime-cores/remote-thread-list/types.tsx +7 -0
- package/src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx +25 -1
- package/src/primitives/actionBar/ActionBarCopy.tsx +3 -1
- package/src/primitives/message/MessageError.tsx +1 -1
- package/src/primitives/message/MessageParts.tsx +0 -1
- package/src/primitives/message/MessagePartsGrouped.tsx +0 -1
- package/src/primitives/messagePart/useMessagePartData.tsx +1 -1
- package/src/types/index.ts +0 -1
- package/src/utils/smooth/useSmooth.tsx +2 -2
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { ChatModelAdapter } from "./ChatModelAdapter";
|
|
2
2
|
import type { LocalRuntimeOptions } from "./LocalRuntimeOptions";
|
|
3
|
-
import { AssistantRuntimeImpl } from "../../../internal";
|
|
4
|
-
export declare const useLocalThreadRuntime: (adapter: ChatModelAdapter, { initialMessages, ...options }: LocalRuntimeOptions) => AssistantRuntimeImpl;
|
|
5
3
|
export declare const useLocalRuntime: (adapter: ChatModelAdapter, { cloud, ...options }?: LocalRuntimeOptions) => import("../../runtime").AssistantRuntime;
|
|
6
4
|
//# sourceMappingURL=useLocalRuntime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/useLocalRuntime.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"useLocalRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/useLocalRuntime.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AA4CjE,eAAO,MAAM,eAAe,GAC1B,SAAS,gBAAgB,EACzB,wBAAuB,mBAAwB,6CAUhD,CAAC"}
|
|
@@ -42,11 +42,11 @@ var useLocalRuntime = (adapter, { cloud, ...options } = {}) => {
|
|
|
42
42
|
runtimeHook: function RuntimeHook() {
|
|
43
43
|
return useLocalThreadRuntime(adapter, options);
|
|
44
44
|
},
|
|
45
|
-
adapter: cloudAdapter
|
|
45
|
+
adapter: cloudAdapter,
|
|
46
|
+
allowNesting: true
|
|
46
47
|
});
|
|
47
48
|
};
|
|
48
49
|
export {
|
|
49
|
-
useLocalRuntime
|
|
50
|
-
useLocalThreadRuntime
|
|
50
|
+
useLocalRuntime
|
|
51
51
|
};
|
|
52
52
|
//# sourceMappingURL=useLocalRuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport type { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport { useRuntimeAdapters } from \"../adapters/RuntimeAdapterProvider\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"../remote-thread-list/adapter/cloud\";\nimport { AssistantRuntimeImpl } from \"../../../internal\";\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport type { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport { useRuntimeAdapters } from \"../adapters/RuntimeAdapterProvider\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"../remote-thread-list/adapter/cloud\";\nimport { AssistantRuntimeImpl } from \"../../../internal\";\n\nconst useLocalThreadRuntime = (\n adapter: ChatModelAdapter,\n { initialMessages, ...options }: LocalRuntimeOptions,\n) => {\n const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};\n const opt = useMemo(\n () => ({\n ...options,\n adapters: {\n ...threadListAdapters,\n ...options.adapters,\n chatModel: adapter,\n },\n }),\n [adapter, options, threadListAdapters],\n );\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));\n\n useEffect(() => {\n return () => {\n runtime.threads.getMainThreadRuntimeCore().detach();\n };\n }, [runtime]);\n\n useEffect(() => {\n runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);\n runtime.threads.getMainThreadRuntimeCore().__internal_load();\n }, [runtime, opt]);\n\n useEffect(() => {\n if (!modelContext) return undefined;\n return runtime.registerModelContextProvider(modelContext);\n }, [modelContext, runtime]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const useLocalRuntime = (\n adapter: ChatModelAdapter,\n { cloud, ...options }: LocalRuntimeOptions = {},\n) => {\n const cloudAdapter = useCloudThreadListAdapter({ cloud });\n return useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n return useLocalThreadRuntime(adapter, options);\n },\n adapter: cloudAdapter,\n allowNesting: true,\n });\n};\n"],"mappings":";;;AAEA,SAAS,WAAW,SAAS,gBAAgB;AAE7C,SAAS,wBAAwB;AAEjC,SAAS,0BAA0B;AACnC,SAAS,kCAAkC;AAC3C,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AAErC,IAAM,wBAAwB,CAC5B,SACA,EAAE,iBAAiB,GAAG,QAAQ,MAC3B;AACH,QAAM,EAAE,cAAc,GAAG,mBAAmB,IAAI,mBAAmB,KAAK,CAAC;AACzE,QAAM,MAAM;AAAA,IACV,OAAO;AAAA,MACL,GAAG;AAAA,MACH,UAAU;AAAA,QACR,GAAG;AAAA,QACH,GAAG,QAAQ;AAAA,QACX,WAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA,CAAC,SAAS,SAAS,kBAAkB;AAAA,EACvC;AAEA,QAAM,CAAC,OAAO,IAAI,SAAS,MAAM,IAAI,iBAAiB,KAAK,eAAe,CAAC;AAE3E,YAAU,MAAM;AACd,WAAO,MAAM;AACX,cAAQ,QAAQ,yBAAyB,EAAE,OAAO;AAAA,IACpD;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AAEZ,YAAU,MAAM;AACd,YAAQ,QAAQ,yBAAyB,EAAE,sBAAsB,GAAG;AACpE,YAAQ,QAAQ,yBAAyB,EAAE,gBAAgB;AAAA,EAC7D,GAAG,CAAC,SAAS,GAAG,CAAC;AAEjB,YAAU,MAAM;AACd,QAAI,CAAC,aAAc,QAAO;AAC1B,WAAO,QAAQ,6BAA6B,YAAY;AAAA,EAC1D,GAAG,CAAC,cAAc,OAAO,CAAC;AAE1B,SAAO,QAAQ,MAAM,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;AAEO,IAAM,kBAAkB,CAC7B,SACA,EAAE,OAAO,GAAG,QAAQ,IAAyB,CAAC,MAC3C;AACH,QAAM,eAAe,0BAA0B,EAAE,MAAM,CAAC;AACxD,SAAO,2BAA2B;AAAA,IAChC,aAAa,SAAS,cAAc;AAClC,aAAO,sBAAsB,SAAS,OAAO;AAAA,IAC/C;AAAA,IACA,SAAS;AAAA,IACT,cAAc;AAAA,EAChB,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteThreadListHookInstanceManager.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RemoteThreadListHookInstanceManager.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,EAAE,EAKF,iBAAiB,EACjB,aAAa,EACd,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,oBAAoB,GAAG,MAAM,gBAAgB,CAAC;AAKnD,qBAAa,mCAAoC,SAAQ,gBAAgB;IACvE,OAAO,CAAC,cAAc,CAEpB;IACF,OAAO,CAAC,SAAS,CAAmD;IACpE,OAAO,CAAC,0BAA0B,CAAsB;gBAE5C,WAAW,EAAE,oBAAoB;IAKtC,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwBnC,oBAAoB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAMrC,iBAAiB,CAAC,QAAQ,EAAE,MAAM;IAKlC,cAAc,CAAC,cAAc,EAAE,oBAAoB;IAO1D,OAAO,CAAC,0BAA0B,CAgDhC;IAEF,OAAO,CAAC,0BAA0B,CAa/B;IAEI,+BAA+B,EAAE,EAAE,CAAC;QACzC,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;KAC5C,CAAC,CAUA;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n FC,\n useCallback,\n useRef,\n useEffect,\n memo,\n PropsWithChildren,\n ComponentType,\n} from \"react\";\nimport { UseBoundStore, StoreApi, create } from \"zustand\";\nimport { useAssistantApi, ThreadListItemByIdProvider } from \"../../../context\";\nimport { ThreadRuntimeCore, ThreadRuntimeImpl } from \"../../../internal\";\nimport { BaseSubscribable } from \"./BaseSubscribable\";\nimport { AssistantRuntime } from \"../../runtime\";\n\ntype RemoteThreadListHook = () => AssistantRuntime;\n\ntype RemoteThreadListHookInstance = {\n runtime?: ThreadRuntimeCore;\n};\nexport class RemoteThreadListHookInstanceManager extends BaseSubscribable {\n private useRuntimeHook: UseBoundStore<\n StoreApi<{ useRuntime: RemoteThreadListHook }>\n >;\n private instances = new Map<string, RemoteThreadListHookInstance>();\n private useAliveThreadsKeysChanged = create(() => ({}));\n\n constructor(runtimeHook: RemoteThreadListHook) {\n super();\n this.useRuntimeHook = create(() => ({ useRuntime: runtimeHook }));\n }\n\n public startThreadRuntime(threadId: string) {\n if (!this.instances.has(threadId)) {\n this.instances.set(threadId, {});\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n return new Promise<ThreadRuntimeCore>((resolve, reject) => {\n const callback = () => {\n const instance = this.instances.get(threadId);\n if (!instance) {\n dispose();\n reject(new Error(\"Thread was deleted before runtime was started\"));\n } else if (!instance.runtime) {\n return; // misc update\n } else {\n dispose();\n resolve(instance.runtime);\n }\n };\n const dispose = this.subscribe(callback);\n callback();\n });\n }\n\n public getThreadRuntimeCore(threadId: string) {\n const instance = this.instances.get(threadId);\n if (!instance) return undefined;\n return instance.runtime;\n }\n\n public stopThreadRuntime(threadId: string) {\n this.instances.delete(threadId);\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n public setRuntimeHook(newRuntimeHook: RemoteThreadListHook) {\n const prevRuntimeHook = this.useRuntimeHook.getState().useRuntime;\n if (prevRuntimeHook !== newRuntimeHook) {\n this.useRuntimeHook.setState({ useRuntime: newRuntimeHook }, true);\n }\n }\n\n private _InnerActiveThreadProvider: FC<{\n threadId: string;\n }> = ({ threadId }) => {\n const { useRuntime } = this.useRuntimeHook();\n const runtime = useRuntime();\n\n const threadBinding = (runtime.thread as ThreadRuntimeImpl)\n .__internal_threadBinding;\n\n const updateRuntime = useCallback(() => {\n const aliveThread = this.instances.get(threadId);\n if (!aliveThread)\n throw new Error(\"Thread not found. This is a bug in assistant-ui.\");\n\n aliveThread.runtime = threadBinding.getState();\n this._notifySubscribers();\n }, [threadId, threadBinding]);\n\n const isMounted = useRef(false);\n if (!isMounted.current) {\n updateRuntime();\n }\n\n useEffect(() => {\n isMounted.current = true;\n updateRuntime();\n return threadBinding.outerSubscribe(updateRuntime);\n }, [threadBinding, updateRuntime]);\n\n // auto initialize thread\n const api = useAssistantApi();\n useEffect(() => {\n return runtime.threads.main.unstable_on(\"initialize\", () => {\n const state = api.threadListItem().getState();\n if (state.status === \"new\") {\n api.threadListItem().initialize();\n\n // auto generate a title after first run\n const dispose = runtime.thread.unstable_on(\"run-end\", () => {\n dispose();\n\n api.threadListItem().generateTitle();\n });\n }\n });\n }, [runtime, api]);\n\n return null;\n };\n\n private _OuterActiveThreadProvider: FC<{\n threadId: string;\n provider: ComponentType<PropsWithChildren>;\n }> = memo(({ threadId, provider: Provider }) => {\n // Runtime is provided by ThreadListItemByIdProvider\n\n return (\n <ThreadListItemByIdProvider id={threadId}>\n <Provider>\n <this._InnerActiveThreadProvider threadId={threadId} />\n </Provider>\n </ThreadListItemByIdProvider>\n );\n });\n\n public __internal_RenderThreadRuntimes: FC<{\n provider: ComponentType<PropsWithChildren>;\n }> = ({ provider }) => {\n this.useAliveThreadsKeysChanged(); // trigger re-render on alive threads change\n\n return Array.from(this.instances.keys()).map((threadId) => (\n <this._OuterActiveThreadProvider\n key={threadId}\n threadId={threadId}\n provider={provider}\n />\n ));\n };\n}\n"],"mappings":";;;AAEA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAkC,cAAc;AAChD,SAAS,iBAAiB,kCAAkC;AAE5D,SAAS,wBAAwB;AAyHvB;AAjHH,IAAM,sCAAN,cAAkD,iBAAiB;AAAA,EAChE;AAAA,EAGA,YAAY,oBAAI,IAA0C;AAAA,EAC1D,6BAA6B,OAAO,OAAO,CAAC,E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ACA;AAAA;AAAA,MAFK;AAAA,IAGP,CACD;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteThreadListThreadListRuntimeCore.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EACL,8BAA8B,EAC9B,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,EAAE,EAA8B,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,KAAK,gBAAgB,GACjB;IACE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACjE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACjE,QAAQ,CAAC,QAAQ,EAAE,M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GAAU,UAAU,MAAM,mBA8B5C;IAEK,MAAM,CAAC,kBAAkB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YA4B5D,sBAAsB;IASvB,OAAO,CAAC,kBAAkB,EAAE,MAAM;IAkBxC,SAAS,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB9C,MAAM,CAAC,kBAAkB,EAAE,MAAM;IAkBjC,MAAM,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9D,OAAO,CAAC,WAAW,CAA8B;IAE1C,0BAA0B,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"RemoteThreadListThreadListRuntimeCore.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EACL,8BAA8B,EAC9B,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,EAAE,EAA8B,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,KAAK,gBAAgB,GACjB;IACE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACjE,QAAQ,CAAC,Q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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAMxB,oBAAoB,CAAC,kBAAkB,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAS/C,WAAW,CAAC,kBAAkB,EAAE,MAAM;IAIhC,cAAc,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkEzD,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAwCxC,UAAU,GAAU,UAAU,MAAM,6CAmDzC;IAEK,aAAa,GAAU,UAAU,MAAM,mBA8B5C;IAEK,MAAM,CAAC,kBAAkB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YA4B5D,sBAAsB;IASvB,OAAO,CAAC,kBAAkB,EAAE,MAAM;IAkBxC,SAAS,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB9C,MAAM,CAAC,kBAAkB,EAAE,MAAM;IAkBjC,MAAM,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9D,OAAO,CAAC,WAAW,CAA8B;IAE1C,0BAA0B,EAAE,EAAE,CA0BnC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx"],"sourcesContent":["\"use client\";\n\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { generateId } from \"../../../internal\";\nimport {\n RemoteThreadInitializeResponse,\n RemoteThreadListOptions,\n} from \"./types\";\nimport { RemoteThreadListHookInstanceManager } from \"./RemoteThreadListHookInstanceManager\";\nimport { BaseSubscribable } from \"./BaseSubscribable\";\nimport { EMPTY_THREAD_CORE } from \"./EMPTY_THREAD_CORE\";\nimport { OptimisticState } from \"./OptimisticState\";\nimport { FC, Fragment, useEffect, useId } from \"react\";\nimport { create } from \"zustand\";\nimport { AssistantMessageStream } from \"assistant-stream\";\nimport { ModelContextProvider } from \"../../../model-context\";\nimport { RuntimeAdapterProvider } from \"../adapters/RuntimeAdapterProvider\";\n\ntype RemoteThreadData =\n | {\n readonly id: string;\n readonly remoteId: undefined;\n readonly externalId: undefined;\n readonly status: \"new\";\n readonly title: undefined;\n }\n | {\n readonly id: string;\n readonly initializeTask: Promise<RemoteThreadInitializeResponse>;\n readonly remoteId: undefined;\n readonly externalId: undefined;\n readonly status: \"regular\" | \"archived\";\n readonly title?: string | undefined;\n }\n | {\n readonly id: string;\n readonly initializeTask: Promise<RemoteThreadInitializeResponse>;\n readonly remoteId: string;\n readonly externalId: string | undefined;\n readonly status: \"regular\" | \"archived\";\n readonly title?: string | undefined;\n };\n\ntype THREAD_MAPPING_ID = string & { __brand: \"THREAD_MAPPING_ID\" };\nfunction createThreadMappingId(id: string): THREAD_MAPPING_ID {\n return id as THREAD_MAPPING_ID;\n}\n\ntype RemoteThreadState = {\n readonly isLoading: boolean;\n readonly newThreadId: string | undefined;\n readonly threadIds: readonly string[];\n readonly archivedThreadIds: readonly string[];\n readonly threadIdMap: Readonly<Record<string, THREAD_MAPPING_ID>>;\n readonly threadData: Readonly<Record<THREAD_MAPPING_ID, RemoteThreadData>>;\n};\n\nconst getThreadData = (\n state: RemoteThreadState,\n threadIdOrRemoteId: string,\n) => {\n const idx = state.threadIdMap[threadIdOrRemoteId];\n if (idx === undefined) return undefined;\n return state.threadData[idx];\n};\n\nconst updateStatusReducer = (\n state: RemoteThreadState,\n threadIdOrRemoteId: string,\n newStatus: \"regular\" | \"archived\" | \"deleted\",\n) => {\n const data = getThreadData(state, threadIdOrRemoteId);\n if (!data) return state;\n\n const { id, remoteId, status: lastStatus } = data;\n if (lastStatus === newStatus) return state;\n\n const newState = { ...state };\n\n // lastStatus\n switch (lastStatus) {\n case \"new\":\n newState.newThreadId = undefined;\n break;\n case \"regular\":\n newState.threadIds = newState.threadIds.filter((t) => t !== id);\n break;\n case \"archived\":\n newState.archivedThreadIds = newState.archivedThreadIds.filter(\n (t) => t !== id,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastStatus;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newStatus\n switch (newStatus) {\n case \"regular\":\n newState.threadIds = [id, ...newState.threadIds];\n break;\n\n case \"archived\":\n newState.archivedThreadIds = [id, ...newState.archivedThreadIds];\n break;\n\n case \"deleted\":\n newState.threadData = Object.fromEntries(\n Object.entries(newState.threadData).filter(([key]) => key !== id),\n );\n newState.threadIdMap = Object.fromEntries(\n Object.entries(newState.threadIdMap).filter(\n ([key]) => key !== id && key !== remoteId,\n ),\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = newStatus;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newStatus !== \"deleted\") {\n newState.threadData = {\n ...newState.threadData,\n [id]: {\n ...data,\n status: newStatus,\n },\n };\n }\n\n return newState;\n};\n\nexport class RemoteThreadListThreadListRuntimeCore\n extends BaseSubscribable\n implements ThreadListRuntimeCore\n{\n private _options!: RemoteThreadListOptions;\n private readonly _hookManager: RemoteThreadListHookInstanceManager;\n\n private _loadThreadsPromise: Promise<void> | undefined;\n\n private _mainThreadId!: string;\n private readonly _state = new OptimisticState<RemoteThreadState>({\n isLoading: false,\n newThreadId: undefined,\n threadIds: [],\n archivedThreadIds: [],\n threadIdMap: {},\n threadData: {},\n });\n\n public get threadData() {\n return this._state.value.threadData;\n }\n\n public getLoadThreadsPromise() {\n // TODO this needs to be cached in case this promise is loaded during suspense\n if (!this._loadThreadsPromise) {\n this._loadThreadsPromise = this._state\n .optimisticUpdate({\n execute: () => this._options.adapter.list(),\n loading: (state) => {\n return {\n ...state,\n isLoading: true,\n };\n },\n then: (state, l) => {\n const newThreadIds = [];\n const newArchivedThreadIds = [];\n const newThreadIdMap = {} as Record<string, THREAD_MAPPING_ID>;\n const newThreadData = {} as Record<\n THREAD_MAPPING_ID,\n RemoteThreadData\n >;\n\n for (const thread of l.threads) {\n switch (thread.status) {\n case \"regular\":\n newThreadIds.push(thread.remoteId);\n break;\n case \"archived\":\n newArchivedThreadIds.push(thread.remoteId);\n break;\n default: {\n const _exhaustiveCheck: never = thread.status;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n const mappingId = createThreadMappingId(thread.remoteId);\n newThreadIdMap[thread.remoteId] = mappingId;\n newThreadData[mappingId] = {\n id: thread.remoteId,\n remoteId: thread.remoteId,\n externalId: thread.externalId,\n status: thread.status,\n title: thread.title,\n initializeTask: Promise.resolve({\n remoteId: thread.remoteId,\n externalId: thread.externalId,\n }),\n };\n }\n\n return {\n ...state,\n threadIds: newThreadIds,\n archivedThreadIds: newArchivedThreadIds,\n threadIdMap: {\n ...state.threadIdMap,\n ...newThreadIdMap,\n },\n threadData: {\n ...state.threadData,\n ...newThreadData,\n },\n };\n },\n })\n .then(() => {});\n }\n\n return this._loadThreadsPromise;\n }\n\n constructor(\n options: RemoteThreadListOptions,\n private readonly contextProvider: ModelContextProvider,\n ) {\n super();\n\n this._state.subscribe(() => this._notifySubscribers());\n this._hookManager = new RemoteThreadListHookInstanceManager(\n options.runtimeHook,\n );\n this.useProvider = create(() => ({\n Provider: options.adapter.unstable_Provider ?? Fragment,\n }));\n this.__internal_setOptions(options);\n\n this.switchToNewThread();\n }\n\n private useProvider;\n\n public __internal_setOptions(options: RemoteThreadListOptions) {\n if (this._options === options) return;\n\n this._options = options;\n\n const Provider = options.adapter.unstable_Provider ?? Fragment;\n if (Provider !== this.useProvider.getState().Provider) {\n this.useProvider.setState({ Provider }, true);\n }\n\n this._hookManager.setRuntimeHook(options.runtimeHook);\n }\n\n public __internal_load() {\n this.getLoadThreadsPromise(); // begin loading on initial bind\n }\n\n public get isLoading() {\n return this._state.value.isLoading;\n }\n\n public get threadIds() {\n return this._state.value.threadIds;\n }\n\n public get archivedThreadIds() {\n return this._state.value.archivedThreadIds;\n }\n\n public get newThreadId() {\n return this._state.value.newThreadId;\n }\n\n public get mainThreadId(): string {\n return this._mainThreadId;\n }\n\n public getMainThreadRuntimeCore() {\n const result = this._hookManager.getThreadRuntimeCore(this._mainThreadId);\n if (!result) return EMPTY_THREAD_CORE;\n return result;\n }\n\n public getThreadRuntimeCore(threadIdOrRemoteId: string) {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n\n const result = this._hookManager.getThreadRuntimeCore(data.id);\n if (!result) throw new Error(\"Thread not found\");\n return result;\n }\n\n public getItemById(threadIdOrRemoteId: string) {\n return getThreadData(this._state.value, threadIdOrRemoteId);\n }\n\n public async switchToThread(threadIdOrRemoteId: string): Promise<void> {\n let data = this.getItemById(threadIdOrRemoteId);\n\n if (!data) {\n const remoteMetadata =\n await this._options.adapter.fetch(threadIdOrRemoteId);\n const state = this._state.value;\n const mappingId = createThreadMappingId(remoteMetadata.remoteId);\n\n const newThreadData = {\n ...state.threadData,\n [mappingId]: {\n id: mappingId,\n initializeTask: Promise.resolve({\n remoteId: remoteMetadata.remoteId,\n externalId: remoteMetadata.externalId,\n }),\n remoteId: remoteMetadata.remoteId,\n externalId: remoteMetadata.externalId,\n status: remoteMetadata.status,\n title: remoteMetadata.title,\n } as RemoteThreadData,\n };\n\n const newThreadIdMap = {\n ...state.threadIdMap,\n [remoteMetadata.remoteId]: mappingId,\n };\n\n const newThreadIds =\n remoteMetadata.status === \"regular\"\n ? [...state.threadIds, remoteMetadata.remoteId]\n : state.threadIds;\n\n const newArchivedThreadIds =\n remoteMetadata.status === \"archived\"\n ? [...state.archivedThreadIds, remoteMetadata.remoteId]\n : state.archivedThreadIds;\n\n this._state.update({\n ...state,\n threadIds: newThreadIds,\n archivedThreadIds: newArchivedThreadIds,\n threadIdMap: newThreadIdMap,\n threadData: newThreadData,\n });\n\n data = this.getItemById(threadIdOrRemoteId);\n }\n\n if (!data) throw new Error(\"Thread not found\");\n if (this._mainThreadId === data.id) return;\n\n const task = this._hookManager.startThreadRuntime(data.id);\n if (this.mainThreadId !== undefined) {\n await task;\n } else {\n task.then(() => this._notifySubscribers());\n }\n\n if (data.status === \"archived\") await this.unarchive(data.id);\n this._mainThreadId = data.id;\n\n this._notifySubscribers();\n }\n\n public async switchToNewThread(): Promise<void> {\n // an initialization transaction is in progress, wait for it to settle\n while (\n this._state.baseValue.newThreadId !== undefined &&\n this._state.value.newThreadId === undefined\n ) {\n await this._state.waitForUpdate();\n }\n\n const state = this._state.value;\n let id: string | undefined = this._state.value.newThreadId;\n if (id === undefined) {\n do {\n id = `__LOCALID_${generateId()}`;\n } while (state.threadIdMap[id]);\n\n const mappingId = createThreadMappingId(id);\n this._state.update({\n ...state,\n newThreadId: id,\n threadIdMap: {\n ...state.threadIdMap,\n [id]: mappingId,\n },\n threadData: {\n ...state.threadData,\n [mappingId]: {\n status: \"new\",\n id,\n remoteId: undefined,\n externalId: undefined,\n title: undefined,\n } satisfies RemoteThreadData,\n },\n });\n }\n\n return this.switchToThread(id);\n }\n\n public initialize = async (threadId: string) => {\n if (this._state.value.newThreadId !== threadId) {\n const data = this.getItemById(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status === \"new\") throw new Error(\"Unexpected new state\");\n return data.initializeTask;\n }\n\n return this._state.optimisticUpdate({\n execute: () => {\n return this._options.adapter.initialize(threadId);\n },\n optimistic: (state) => {\n return updateStatusReducer(state, threadId, \"regular\");\n },\n loading: (state, task) => {\n const mappingId = createThreadMappingId(threadId);\n return {\n ...state,\n threadData: {\n ...state.threadData,\n [mappingId]: {\n ...state.threadData[mappingId],\n initializeTask: task,\n },\n },\n };\n },\n then: (state, { remoteId, externalId }) => {\n const data = getThreadData(state, threadId);\n if (!data) return state;\n\n const mappingId = createThreadMappingId(threadId);\n return {\n ...state,\n threadIdMap: {\n ...state.threadIdMap,\n [remoteId]: mappingId,\n },\n threadData: {\n ...state.threadData,\n [mappingId]: {\n ...data,\n initializeTask: Promise.resolve({ remoteId, externalId }),\n remoteId,\n externalId,\n },\n },\n };\n },\n });\n };\n\n public generateTitle = async (threadId: string) => {\n const data = this.getItemById(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status === \"new\") throw new Error(\"Thread is not yet initialized\");\n\n const { remoteId } = await data.initializeTask;\n\n const runtimeCore = this._hookManager.getThreadRuntimeCore(data.id);\n if (!runtimeCore) return; // thread is no longer running\n\n const messages = runtimeCore.messages;\n const stream = await this._options.adapter.generateTitle(\n remoteId,\n messages,\n );\n const messageStream = AssistantMessageStream.fromAssistantStream(stream);\n for await (const result of messageStream) {\n const newTitle = result.parts.filter((c) => c.type === \"text\")[0]?.text;\n const state = this._state.baseValue;\n this._state.update({\n ...state,\n threadData: {\n ...state.threadData,\n [data.id]: {\n ...data,\n title: newTitle,\n },\n },\n });\n }\n };\n\n public rename(threadIdOrRemoteId: string, newTitle: string): Promise<void> {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status === \"new\") throw new Error(\"Thread is not yet initialized\");\n\n return this._state.optimisticUpdate({\n execute: async () => {\n const { remoteId } = await data.initializeTask;\n return this._options.adapter.rename(remoteId, newTitle);\n },\n optimistic: (state) => {\n const data = getThreadData(state, threadIdOrRemoteId);\n if (!data) return state;\n\n return {\n ...state,\n threadData: {\n ...state.threadData,\n [data.id]: {\n ...data,\n title: newTitle,\n },\n },\n };\n },\n });\n }\n\n private async _ensureThreadIsNotMain(threadId: string) {\n if (threadId === this.newThreadId)\n throw new Error(\"Cannot ensure new thread is not main\");\n\n if (threadId === this._mainThreadId) {\n await this.switchToNewThread();\n }\n }\n\n public async archive(threadIdOrRemoteId: string) {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\")\n throw new Error(\"Thread is not yet initialized or already archived\");\n\n return this._state.optimisticUpdate({\n execute: async () => {\n await this._ensureThreadIsNotMain(data.id);\n const { remoteId } = await data.initializeTask;\n return this._options.adapter.archive(remoteId);\n },\n optimistic: (state) => {\n return updateStatusReducer(state, data.id, \"archived\");\n },\n });\n }\n\n public unarchive(threadIdOrRemoteId: string): Promise<void> {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"archived\") throw new Error(\"Thread is not archived\");\n\n return this._state.optimisticUpdate({\n execute: async () => {\n try {\n const { remoteId } = await data.initializeTask;\n return await this._options.adapter.unarchive(remoteId);\n } catch (error) {\n await this._ensureThreadIsNotMain(data.id);\n throw error;\n }\n },\n optimistic: (state) => {\n return updateStatusReducer(state, data.id, \"regular\");\n },\n });\n }\n\n public async delete(threadIdOrRemoteId: string) {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\" && data.status !== \"archived\")\n throw new Error(\"Thread is not yet initialized\");\n\n return this._state.optimisticUpdate({\n execute: async () => {\n await this._ensureThreadIsNotMain(data.id);\n const { remoteId } = await data.initializeTask;\n return await this._options.adapter.delete(remoteId);\n },\n optimistic: (state) => {\n return updateStatusReducer(state, data.id, \"deleted\");\n },\n });\n }\n\n public async detach(threadIdOrRemoteId: string): Promise<void> {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\" && data.status !== \"archived\")\n throw new Error(\"Thread is not yet initialized\");\n\n await this._ensureThreadIsNotMain(data.id);\n this._hookManager.stopThreadRuntime(data.id);\n }\n\n private useBoundIds = create<string[]>(() => []);\n\n public __internal_RenderComponent: FC = () => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const id = useId();\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n this.useBoundIds.setState((s) => [...s, id], true);\n return () => {\n this.useBoundIds.setState((s) => s.filter((i) => i !== id), true);\n };\n }, [id]);\n\n const boundIds = this.useBoundIds();\n const { Provider } = this.useProvider();\n\n const adapters = {\n modelContext: this.contextProvider,\n };\n\n return (\n (boundIds.length === 0 || boundIds[0] === id) && (\n // only render if the component is the first one mounted\n <RuntimeAdapterProvider adapters={adapters}>\n <this._hookManager.__internal_RenderThreadRuntimes\n provider={Provider}\n />\n </RuntimeAdapterProvider>\n )\n );\n };\n}\n"],"mappings":";;;AAGA,SAAS,kBAAkB;AAK3B,SAAS,2CAA2C;AACpD,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAa,UAAU,WAAW,aAAa;AAC/C,SAAS,cAAc;AACvB,SAAS,8BAA8B;AAEvC,SAAS,8BAA8B;AAomB7B;AAxkBV,SAAS,sBAAsB,IAA+B;AAC5D,SAAO;AACT;AAWA,IAAM,gBAAgB,CACpB,OACA,uBACG;AACH,QAAM,MAAM,MAAM,YAAY,kBAAkB;AAChD,MAAI,QAAQ,OAAW,QAAO;AAC9B,SAAO,MAAM,WAAW,GAAG;AAC7B;AAEA,IAAM,sBAAsB,CAC1B,OACA,oBACA,cACG;AACH,QAAM,OAAO,cAAc,OAAO,kBAAkB;AACpD,MAAI,CAAC,KAAM,QAAO;AAElB,QAAM,EAAE,IAAI,UAAU,QAAQ,WAAW,IAAI;AAC7C,MAAI,eAAe,UAAW,QAAO;AAErC,QAAM,WAAW,EAAE,GAAG,MAAM;AAG5B,UAAQ,YAAY;AAAA,IAClB,KAAK;AACH,eAAS,cAAc;AACvB;AAAA,IACF,KAAK;AACH,eAAS,YAAY,SAAS,UAAU,OAAO,CAAC,MAAM,MAAM,EAAE;AAC9D;AAAA,IACF,KAAK;AACH,eAAS,oBAAoB,SAAS,kBAAkB;AAAA,QACtD,CAAC,MAAM,MAAM;AAAA,MACf;AACA;AAAA,IAEF,SAAS;AACP,YAAM,mBAA0B;AAChC,YAAM,IAAI,MAAM,sBAAsB,gBAAgB,EAAE;AAAA,IAC1D;AAAA,EACF;AAGA,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,eAAS,YAAY,CAAC,IAAI,GAAG,SAAS,SAAS;AAC/C;AAAA,IAEF,KAAK;AACH,e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AAA,QACC,UAAU;AAAA;AAAA,IACZ,GACF;AAAA,EAGN;AACF;","names":["data"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx"],"sourcesContent":["\"use client\";\n\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { generateId } from \"../../../internal\";\nimport {\n RemoteThreadInitializeResponse,\n RemoteThreadListOptions,\n} from \"./types\";\nimport { RemoteThreadListHookInstanceManager } from \"./RemoteThreadListHookInstanceManager\";\nimport { BaseSubscribable } from \"./BaseSubscribable\";\nimport { EMPTY_THREAD_CORE } from \"./EMPTY_THREAD_CORE\";\nimport { OptimisticState } from \"./OptimisticState\";\nimport { FC, Fragment, useEffect, useId } from \"react\";\nimport { create } from \"zustand\";\nimport { AssistantMessageStream } from \"assistant-stream\";\nimport { ModelContextProvider } from \"../../../model-context\";\nimport { RuntimeAdapterProvider } from \"../adapters/RuntimeAdapterProvider\";\n\ntype RemoteThreadData =\n | {\n readonly id: string;\n readonly remoteId: undefined;\n readonly externalId: undefined;\n readonly status: \"new\";\n readonly title: undefined;\n }\n | {\n readonly id: string;\n readonly initializeTask: Promise<RemoteThreadInitializeResponse>;\n readonly remoteId: undefined;\n readonly externalId: undefined;\n readonly status: \"regular\" | \"archived\";\n readonly title?: string | undefined;\n }\n | {\n readonly id: string;\n readonly initializeTask: Promise<RemoteThreadInitializeResponse>;\n readonly remoteId: string;\n readonly externalId: string | undefined;\n readonly status: \"regular\" | \"archived\";\n readonly title?: string | undefined;\n };\n\ntype THREAD_MAPPING_ID = string & { __brand: \"THREAD_MAPPING_ID\" };\nfunction createThreadMappingId(id: string): THREAD_MAPPING_ID {\n return id as THREAD_MAPPING_ID;\n}\n\ntype RemoteThreadState = {\n readonly isLoading: boolean;\n readonly newThreadId: string | undefined;\n readonly threadIds: readonly string[];\n readonly archivedThreadIds: readonly string[];\n readonly threadIdMap: Readonly<Record<string, THREAD_MAPPING_ID>>;\n readonly threadData: Readonly<Record<THREAD_MAPPING_ID, RemoteThreadData>>;\n};\n\nconst getThreadData = (\n state: RemoteThreadState,\n threadIdOrRemoteId: string,\n) => {\n const idx = state.threadIdMap[threadIdOrRemoteId];\n if (idx === undefined) return undefined;\n return state.threadData[idx];\n};\n\nconst updateStatusReducer = (\n state: RemoteThreadState,\n threadIdOrRemoteId: string,\n newStatus: \"regular\" | \"archived\" | \"deleted\",\n) => {\n const data = getThreadData(state, threadIdOrRemoteId);\n if (!data) return state;\n\n const { id, remoteId, status: lastStatus } = data;\n if (lastStatus === newStatus) return state;\n\n const newState = { ...state };\n\n // lastStatus\n switch (lastStatus) {\n case \"new\":\n newState.newThreadId = undefined;\n break;\n case \"regular\":\n newState.threadIds = newState.threadIds.filter((t) => t !== id);\n break;\n case \"archived\":\n newState.archivedThreadIds = newState.archivedThreadIds.filter(\n (t) => t !== id,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastStatus;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newStatus\n switch (newStatus) {\n case \"regular\":\n newState.threadIds = [id, ...newState.threadIds];\n break;\n\n case \"archived\":\n newState.archivedThreadIds = [id, ...newState.archivedThreadIds];\n break;\n\n case \"deleted\":\n newState.threadData = Object.fromEntries(\n Object.entries(newState.threadData).filter(([key]) => key !== id),\n );\n newState.threadIdMap = Object.fromEntries(\n Object.entries(newState.threadIdMap).filter(\n ([key]) => key !== id && key !== remoteId,\n ),\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = newStatus;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newStatus !== \"deleted\") {\n newState.threadData = {\n ...newState.threadData,\n [id]: {\n ...data,\n status: newStatus,\n },\n };\n }\n\n return newState;\n};\n\nexport class RemoteThreadListThreadListRuntimeCore\n extends BaseSubscribable\n implements ThreadListRuntimeCore\n{\n private _options!: RemoteThreadListOptions;\n private readonly _hookManager: RemoteThreadListHookInstanceManager;\n\n private _loadThreadsPromise: Promise<void> | undefined;\n\n private _mainThreadId!: string;\n private readonly _state = new OptimisticState<RemoteThreadState>({\n isLoading: false,\n newThreadId: undefined,\n threadIds: [],\n archivedThreadIds: [],\n threadIdMap: {},\n threadData: {},\n });\n\n public get threadData() {\n return this._state.value.threadData;\n }\n\n public getLoadThreadsPromise() {\n // TODO this needs to be cached in case this promise is loaded during suspense\n if (!this._loadThreadsPromise) {\n this._loadThreadsPromise = this._state\n .optimisticUpdate({\n execute: () => this._options.adapter.list(),\n loading: (state) => {\n return {\n ...state,\n isLoading: true,\n };\n },\n then: (state, l) => {\n const newThreadIds = [];\n const newArchivedThreadIds = [];\n const newThreadIdMap = {} as Record<string, THREAD_MAPPING_ID>;\n const newThreadData = {} as Record<\n THREAD_MAPPING_ID,\n RemoteThreadData\n >;\n\n for (const thread of l.threads) {\n switch (thread.status) {\n case \"regular\":\n newThreadIds.push(thread.remoteId);\n break;\n case \"archived\":\n newArchivedThreadIds.push(thread.remoteId);\n break;\n default: {\n const _exhaustiveCheck: never = thread.status;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n const mappingId = createThreadMappingId(thread.remoteId);\n newThreadIdMap[thread.remoteId] = mappingId;\n newThreadData[mappingId] = {\n id: thread.remoteId,\n remoteId: thread.remoteId,\n externalId: thread.externalId,\n status: thread.status,\n title: thread.title,\n initializeTask: Promise.resolve({\n remoteId: thread.remoteId,\n externalId: thread.externalId,\n }),\n };\n }\n\n return {\n ...state,\n threadIds: newThreadIds,\n archivedThreadIds: newArchivedThreadIds,\n threadIdMap: {\n ...state.threadIdMap,\n ...newThreadIdMap,\n },\n threadData: {\n ...state.threadData,\n ...newThreadData,\n },\n };\n },\n })\n .then(() => {});\n }\n\n return this._loadThreadsPromise;\n }\n\n constructor(\n options: RemoteThreadListOptions,\n private readonly contextProvider: ModelContextProvider,\n ) {\n super();\n\n this._state.subscribe(() => this._notifySubscribers());\n this._hookManager = new RemoteThreadListHookInstanceManager(\n options.runtimeHook,\n );\n this.useProvider = create(() => ({\n Provider: options.adapter.unstable_Provider ?? Fragment,\n }));\n this.__internal_setOptions(options);\n\n this.switchToNewThread();\n }\n\n private useProvider;\n\n public __internal_setOptions(options: RemoteThreadListOptions) {\n if (this._options === options) return;\n\n this._options = options;\n\n const Provider = options.adapter.unstable_Provider ?? Fragment;\n if (Provider !== this.useProvider.getState().Provider) {\n this.useProvider.setState({ Provider }, true);\n }\n\n this._hookManager.setRuntimeHook(options.runtimeHook);\n }\n\n public __internal_load() {\n this.getLoadThreadsPromise(); // begin loading on initial bind\n }\n\n public get isLoading() {\n return this._state.value.isLoading;\n }\n\n public get threadIds() {\n return this._state.value.threadIds;\n }\n\n public get archivedThreadIds() {\n return this._state.value.archivedThreadIds;\n }\n\n public get newThreadId() {\n return this._state.value.newThreadId;\n }\n\n public get mainThreadId(): string {\n return this._mainThreadId;\n }\n\n public getMainThreadRuntimeCore() {\n const result = this._hookManager.getThreadRuntimeCore(this._mainThreadId);\n if (!result) return EMPTY_THREAD_CORE;\n return result;\n }\n\n public getThreadRuntimeCore(threadIdOrRemoteId: string) {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n\n const result = this._hookManager.getThreadRuntimeCore(data.id);\n if (!result) throw new Error(\"Thread not found\");\n return result;\n }\n\n public getItemById(threadIdOrRemoteId: string) {\n return getThreadData(this._state.value, threadIdOrRemoteId);\n }\n\n public async switchToThread(threadIdOrRemoteId: string): Promise<void> {\n let data = this.getItemById(threadIdOrRemoteId);\n\n if (!data) {\n const remoteMetadata =\n await this._options.adapter.fetch(threadIdOrRemoteId);\n const state = this._state.value;\n const mappingId = createThreadMappingId(remoteMetadata.remoteId);\n\n const newThreadData = {\n ...state.threadData,\n [mappingId]: {\n id: mappingId,\n initializeTask: Promise.resolve({\n remoteId: remoteMetadata.remoteId,\n externalId: remoteMetadata.externalId,\n }),\n remoteId: remoteMetadata.remoteId,\n externalId: remoteMetadata.externalId,\n status: remoteMetadata.status,\n title: remoteMetadata.title,\n } as RemoteThreadData,\n };\n\n const newThreadIdMap = {\n ...state.threadIdMap,\n [remoteMetadata.remoteId]: mappingId,\n };\n\n const newThreadIds =\n remoteMetadata.status === \"regular\"\n ? [...state.threadIds, remoteMetadata.remoteId]\n : state.threadIds;\n\n const newArchivedThreadIds =\n remoteMetadata.status === \"archived\"\n ? [...state.archivedThreadIds, remoteMetadata.remoteId]\n : state.archivedThreadIds;\n\n this._state.update({\n ...state,\n threadIds: newThreadIds,\n archivedThreadIds: newArchivedThreadIds,\n threadIdMap: newThreadIdMap,\n threadData: newThreadData,\n });\n\n data = this.getItemById(threadIdOrRemoteId);\n }\n\n if (!data) throw new Error(\"Thread not found\");\n if (this._mainThreadId === data.id) return;\n\n const task = this._hookManager.startThreadRuntime(data.id);\n if (this.mainThreadId !== undefined) {\n await task;\n } else {\n task.then(() => this._notifySubscribers());\n }\n\n if (data.status === \"archived\") await this.unarchive(data.id);\n this._mainThreadId = data.id;\n\n this._notifySubscribers();\n }\n\n public async switchToNewThread(): Promise<void> {\n // an initialization transaction is in progress, wait for it to settle\n while (\n this._state.baseValue.newThreadId !== undefined &&\n this._state.value.newThreadId === undefined\n ) {\n await this._state.waitForUpdate();\n }\n\n const state = this._state.value;\n let id: string | undefined = this._state.value.newThreadId;\n if (id === undefined) {\n do {\n id = `__LOCALID_${generateId()}`;\n } while (state.threadIdMap[id]);\n\n const mappingId = createThreadMappingId(id);\n this._state.update({\n ...state,\n newThreadId: id,\n threadIdMap: {\n ...state.threadIdMap,\n [id]: mappingId,\n },\n threadData: {\n ...state.threadData,\n [mappingId]: {\n status: \"new\",\n id,\n remoteId: undefined,\n externalId: undefined,\n title: undefined,\n } satisfies RemoteThreadData,\n },\n });\n }\n\n return this.switchToThread(id);\n }\n\n public initialize = async (threadId: string) => {\n if (this._state.value.newThreadId !== threadId) {\n const data = this.getItemById(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status === \"new\") throw new Error(\"Unexpected new state\");\n return data.initializeTask;\n }\n\n return this._state.optimisticUpdate({\n execute: () => {\n return this._options.adapter.initialize(threadId);\n },\n optimistic: (state) => {\n return updateStatusReducer(state, threadId, \"regular\");\n },\n loading: (state, task) => {\n const mappingId = createThreadMappingId(threadId);\n return {\n ...state,\n threadData: {\n ...state.threadData,\n [mappingId]: {\n ...state.threadData[mappingId],\n initializeTask: task,\n },\n },\n };\n },\n then: (state, { remoteId, externalId }) => {\n const data = getThreadData(state, threadId);\n if (!data) return state;\n\n const mappingId = createThreadMappingId(threadId);\n return {\n ...state,\n threadIdMap: {\n ...state.threadIdMap,\n [remoteId]: mappingId,\n },\n threadData: {\n ...state.threadData,\n [mappingId]: {\n ...data,\n initializeTask: Promise.resolve({ remoteId, externalId }),\n remoteId,\n externalId,\n },\n },\n };\n },\n });\n };\n\n public generateTitle = async (threadId: string) => {\n const data = this.getItemById(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status === \"new\") throw new Error(\"Thread is not yet initialized\");\n\n const { remoteId } = await data.initializeTask;\n\n const runtimeCore = this._hookManager.getThreadRuntimeCore(data.id);\n if (!runtimeCore) return; // thread is no longer running\n\n const messages = runtimeCore.messages;\n const stream = await this._options.adapter.generateTitle(\n remoteId,\n messages,\n );\n const messageStream = AssistantMessageStream.fromAssistantStream(stream);\n for await (const result of messageStream) {\n const newTitle = result.parts.filter((c) => c.type === \"text\")[0]?.text;\n const state = this._state.baseValue;\n this._state.update({\n ...state,\n threadData: {\n ...state.threadData,\n [data.id]: {\n ...data,\n title: newTitle,\n },\n },\n });\n }\n };\n\n public rename(threadIdOrRemoteId: string, newTitle: string): Promise<void> {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status === \"new\") throw new Error(\"Thread is not yet initialized\");\n\n return this._state.optimisticUpdate({\n execute: async () => {\n const { remoteId } = await data.initializeTask;\n return this._options.adapter.rename(remoteId, newTitle);\n },\n optimistic: (state) => {\n const data = getThreadData(state, threadIdOrRemoteId);\n if (!data) return state;\n\n return {\n ...state,\n threadData: {\n ...state.threadData,\n [data.id]: {\n ...data,\n title: newTitle,\n },\n },\n };\n },\n });\n }\n\n private async _ensureThreadIsNotMain(threadId: string) {\n if (threadId === this.newThreadId)\n throw new Error(\"Cannot ensure new thread is not main\");\n\n if (threadId === this._mainThreadId) {\n await this.switchToNewThread();\n }\n }\n\n public async archive(threadIdOrRemoteId: string) {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\")\n throw new Error(\"Thread is not yet initialized or already archived\");\n\n return this._state.optimisticUpdate({\n execute: async () => {\n await this._ensureThreadIsNotMain(data.id);\n const { remoteId } = await data.initializeTask;\n return this._options.adapter.archive(remoteId);\n },\n optimistic: (state) => {\n return updateStatusReducer(state, data.id, \"archived\");\n },\n });\n }\n\n public unarchive(threadIdOrRemoteId: string): Promise<void> {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"archived\") throw new Error(\"Thread is not archived\");\n\n return this._state.optimisticUpdate({\n execute: async () => {\n try {\n const { remoteId } = await data.initializeTask;\n return await this._options.adapter.unarchive(remoteId);\n } catch (error) {\n await this._ensureThreadIsNotMain(data.id);\n throw error;\n }\n },\n optimistic: (state) => {\n return updateStatusReducer(state, data.id, \"regular\");\n },\n });\n }\n\n public async delete(threadIdOrRemoteId: string) {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\" && data.status !== \"archived\")\n throw new Error(\"Thread is not yet initialized\");\n\n return this._state.optimisticUpdate({\n execute: async () => {\n await this._ensureThreadIsNotMain(data.id);\n const { remoteId } = await data.initializeTask;\n return await this._options.adapter.delete(remoteId);\n },\n optimistic: (state) => {\n return updateStatusReducer(state, data.id, \"deleted\");\n },\n });\n }\n\n public async detach(threadIdOrRemoteId: string): Promise<void> {\n const data = this.getItemById(threadIdOrRemoteId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\" && data.status !== \"archived\")\n throw new Error(\"Thread is not yet initialized\");\n\n await this._ensureThreadIsNotMain(data.id);\n this._hookManager.stopThreadRuntime(data.id);\n }\n\n private useBoundIds = create<string[]>(() => []);\n\n public __internal_RenderComponent: FC = () => {\n const id = useId();\n useEffect(() => {\n this.useBoundIds.setState((s) => [...s, id], true);\n return () => {\n this.useBoundIds.setState((s) => s.filter((i) => i !== id), true);\n };\n }, [id]);\n\n const boundIds = this.useBoundIds();\n const { Provider } = this.useProvider();\n\n const adapters = {\n modelContext: this.contextProvider,\n };\n\n return (\n (boundIds.length === 0 || boundIds[0] === id) && (\n // only render if the component is the first one mounted\n <RuntimeAdapterProvider adapters={adapters}>\n <this._hookManager.__internal_RenderThreadRuntimes\n provider={Provider}\n />\n </RuntimeAdapterProvider>\n )\n );\n };\n}\n"],"mappings":";;;AAGA,SAAS,kBAAkB;AAK3B,SAAS,2CAA2C;AACpD,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAa,UAAU,WAAW,aAAa;AAC/C,SAAS,cAAc;AACvB,SAAS,8BAA8B;AAEvC,SAAS,8BAA8B;AAkmB7B;AAtkBV,SAAS,sBAAsB,IAA+B;AAC5D,SAAO;AACT;AAWA,IAAM,gBAAgB,CACpB,OACA,uBACG;AACH,QAAM,MAAM,MAAM,YAAY,kBAAkB;AAChD,MAAI,QAAQ,OAAW,QAAO;AAC9B,SAAO,MAAM,WAAW,GAAG;AAC7B;AAEA,IAAM,sBAAsB,CAC1B,OACA,oBACA,cACG;AACH,QAAM,OAAO,cAAc,OAAO,kBAAkB;AACpD,MAAI,CAAC,KAAM,QAAO;AAElB,QAAM,EAAE,IAAI,UAAU,QAAQ,WAAW,IAAI;AAC7C,MAAI,eAAe,UAAW,QAAO;AAErC,QAAM,WAAW,EAAE,GAAG,MAAM;AAG5B,UAAQ,YAAY;AAA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AC,MAAM,CAAC,GAAG,GAAG,EAAE,GAAG,IAAI;AACjD,aAAO,MAAM;AACX,aAAK,YAAY,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,GAAG,IAAI;AAAA,MAClE;AAAA,IACF,GAAG,CAAC,EAAE,CAAC;AAEP,UAAM,WAAW,KAAK,YAAY;AAClC,UAAM,EAAE,SAAS,IAAI,KAAK,YAAY;AAEtC,UAAM,WAAW;AAAA,MACf,cAAc,KAAK;AAAA,IACrB;AAEA,YACG,SAAS,WAAW,KAAK,SAAS,CAAC,MAAM;AAAA,IAExC,oBAAC,0BAAuB,UACtB;AAAA,MAAC,KAAK,aAAa;AAAA,MAAlB;AAAA,QACC,UAAU;AAAA;AAAA,IACZ,GACF;AAAA,EAGN;AACF;","names":["data"]}
|
|
@@ -29,5 +29,11 @@ export type RemoteThreadListAdapter = {
|
|
|
29
29
|
export type RemoteThreadListOptions = {
|
|
30
30
|
runtimeHook: () => AssistantRuntime;
|
|
31
31
|
adapter: RemoteThreadListAdapter;
|
|
32
|
+
/**
|
|
33
|
+
* When true, if this runtime is used inside another RemoteThreadListRuntime,
|
|
34
|
+
* it becomes a no-op and simply calls the runtimeHook directly.
|
|
35
|
+
* This allows wrapping runtimes that internally use RemoteThreadListRuntime.
|
|
36
|
+
*/
|
|
37
|
+
allowNesting?: boolean | undefined;
|
|
32
38
|
};
|
|
33
39
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/types.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAA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AAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACtE,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,SAAS,aAAa,EAAE,GAC1C,OAAO,CAAC,eAAe,CAAC,CAAC;IAC5B,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEvD,iBAAiB,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,WAAW,EAAE,MAAM,gBAAgB,CAAC;IACpC,OAAO,EAAE,uBAAuB,CAAC;IAEjC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC,CAAC"}
|
package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRemoteThreadListRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"useRemoteThreadListRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAiClE,eAAO,MAAM,0BAA0B,GACrC,SAAS,uBAAuB,KAC/B,gBAmBF,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { useState, useEffect, useMemo } from "react";
|
|
|
5
5
|
import { BaseAssistantRuntimeCore } from "../core/BaseAssistantRuntimeCore.js";
|
|
6
6
|
import { RemoteThreadListThreadListRuntimeCore } from "./RemoteThreadListThreadListRuntimeCore.js";
|
|
7
7
|
import { AssistantRuntimeImpl } from "../../../internal.js";
|
|
8
|
+
import { useAssistantApiImpl } from "../../../context/react/AssistantApiContext.js";
|
|
8
9
|
var RemoteThreadListRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
9
10
|
threads;
|
|
10
11
|
constructor(options) {
|
|
@@ -18,7 +19,7 @@ var RemoteThreadListRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
|
18
19
|
return this.threads.__internal_RenderComponent;
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
|
-
var
|
|
22
|
+
var useRemoteThreadListRuntimeImpl = (options) => {
|
|
22
23
|
const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));
|
|
23
24
|
useEffect(() => {
|
|
24
25
|
runtime.threads.__internal_setOptions(options);
|
|
@@ -26,6 +27,19 @@ var useRemoteThreadListRuntime = (options) => {
|
|
|
26
27
|
}, [runtime, options]);
|
|
27
28
|
return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
|
|
28
29
|
};
|
|
30
|
+
var useRemoteThreadListRuntime = (options) => {
|
|
31
|
+
const api = useAssistantApiImpl();
|
|
32
|
+
const isNested = api.threadListItem.source !== null;
|
|
33
|
+
if (isNested) {
|
|
34
|
+
if (!options.allowNesting) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
"useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op)."
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return options.runtimeHook();
|
|
40
|
+
}
|
|
41
|
+
return useRemoteThreadListRuntimeImpl(options);
|
|
42
|
+
};
|
|
29
43
|
export {
|
|
30
44
|
useRemoteThreadListRuntime
|
|
31
45
|
};
|
package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, useEffect, useMemo } from \"react\";\nimport { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { RemoteThreadListThreadListRuntimeCore } from \"./RemoteThreadListThreadListRuntimeCore\";\nimport { RemoteThreadListOptions } from \"./types\";\nimport { AssistantRuntimeImpl } from \"../../../internal\";\nimport { AssistantRuntimeCore } from \"../core/AssistantRuntimeCore\";\nimport { AssistantRuntime } from \"../../runtime/AssistantRuntime\";\n\nclass RemoteThreadListRuntimeCore\n extends BaseAssistantRuntimeCore\n implements AssistantRuntimeCore\n{\n public readonly threads;\n\n constructor(options: RemoteThreadListOptions) {\n super();\n this.threads = new RemoteThreadListThreadListRuntimeCore(\n options,\n this._contextProvider,\n );\n }\n\n public get RenderComponent() {\n return this.threads.__internal_RenderComponent;\n }\n}\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, useEffect, useMemo } from \"react\";\nimport { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { RemoteThreadListThreadListRuntimeCore } from \"./RemoteThreadListThreadListRuntimeCore\";\nimport { RemoteThreadListOptions } from \"./types\";\nimport { AssistantRuntimeImpl } from \"../../../internal\";\nimport { AssistantRuntimeCore } from \"../core/AssistantRuntimeCore\";\nimport { AssistantRuntime } from \"../../runtime/AssistantRuntime\";\nimport { useAssistantApiImpl } from \"../../../context/react/AssistantApiContext\";\n\nclass RemoteThreadListRuntimeCore\n extends BaseAssistantRuntimeCore\n implements AssistantRuntimeCore\n{\n public readonly threads;\n\n constructor(options: RemoteThreadListOptions) {\n super();\n this.threads = new RemoteThreadListThreadListRuntimeCore(\n options,\n this._contextProvider,\n );\n }\n\n public get RenderComponent() {\n return this.threads.__internal_RenderComponent;\n }\n}\n\nconst useRemoteThreadListRuntimeImpl = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));\n useEffect(() => {\n runtime.threads.__internal_setOptions(options);\n runtime.threads.__internal_load();\n }, [runtime, options]);\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const useRemoteThreadListRuntime = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const api = useAssistantApiImpl();\n const isNested = api.threadListItem.source !== null;\n\n if (isNested) {\n if (!options.allowNesting) {\n throw new Error(\n \"useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. \" +\n \"Set allowNesting: true to allow nesting (the inner runtime will become a no-op).\",\n );\n }\n\n // If allowNesting is true and already inside a thread list context,\n // just call the runtimeHook directly (no-op behavior)\n return options.runtimeHook();\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useRemoteThreadListRuntimeImpl(options);\n};\n"],"mappings":";;;AAEA,SAAS,UAAU,WAAW,eAAe;AAC7C,SAAS,gCAAgC;AACzC,SAAS,6CAA6C;AAEtD,SAAS,4BAA4B;AAGrC,SAAS,2BAA2B;AAEpC,IAAM,8BAAN,cACU,yBAEV;AAAA,EACkB;AAAA,EAEhB,YAAY,SAAkC;AAC5C,UAAM;AACN,SAAK,UAAU,IAAI;AAAA,MACjB;AAAA,MACA,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEA,IAAW,kBAAkB;AAC3B,WAAO,KAAK,QAAQ;AAAA,EACtB;AACF;AAEA,IAAM,iCAAiC,CACrC,YACqB;AACrB,QAAM,CAAC,OAAO,IAAI,SAAS,MAAM,IAAI,4BAA4B,OAAO,CAAC;AACzE,YAAU,MAAM;AACd,YAAQ,QAAQ,sBAAsB,OAAO;AAC7C,YAAQ,QAAQ,gBAAgB;AAAA,EAClC,GAAG,CAAC,SAAS,OAAO,CAAC;AACrB,SAAO,QAAQ,MAAM,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;AAEO,IAAM,6BAA6B,CACxC,YACqB;AACrB,QAAM,MAAM,oBAAoB;AAChC,QAAM,WAAW,IAAI,eAAe,WAAW;AAE/C,MAAI,UAAU;AACZ,QAAI,CAAC,QAAQ,cAAc;AACzB,YAAM,IAAI;AAAA,QACR;AAAA,MAEF;AAAA,IACF;AAIA,WAAO,QAAQ,YAAY;AAAA,EAC7B;AAGA,SAAO,+BAA+B,OAAO;AAC/C;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarCopy.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAMnE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,yBAAyB,GAAI,sBAEhC;
|
|
1
|
+
{"version":3,"file":"ActionBarCopy.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAMnE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,yBAAyB,GAAI,sBAEhC;IACD,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,wBAyBL,CAAC;AAEF,yBAAiB,sBAAsB,CAAC;IACtC,KAAY,OAAO,GAAG,iBAAiB,CAAC;IACxC;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,yBAAyB,CAAC,CAAC;CACzE;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB;;;qBAnDhB,MAAM,GAAG,SAAS;qDAqEnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useCallback } from \"react\";\nimport { useAssistantState, useAssistantApi } from \"../../context\";\n\n/**\n * Hook that provides copy functionality for action bar buttons.\n *\n * This hook returns a callback function that copies message content to the clipboard,\n * or null if copying is not available. It handles both regular message content and\n * composer text when in editing mode.\n *\n * @param options Configuration options\n * @param options.copiedDuration Duration in milliseconds to show the copied state\n * @returns A copy callback function, or null if copying is disabled\n *\n * @example\n * ```tsx\n * function CustomCopyButton() {\n * const copy = useActionBarPrimitiveCopy({ copiedDuration: 2000 });\n *\n * return (\n * <button onClick={copy} disabled={!copy}>\n * {copy ? \"Copy\" : \"Cannot Copy\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useActionBarPrimitiveCopy = ({\n copiedDuration = 3000,\n}: {
|
|
1
|
+
{"version":3,"sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useCallback } from \"react\";\nimport { useAssistantState, useAssistantApi } from \"../../context\";\n\n/**\n * Hook that provides copy functionality for action bar buttons.\n *\n * This hook returns a callback function that copies message content to the clipboard,\n * or null if copying is not available. It handles both regular message content and\n * composer text when in editing mode.\n *\n * @param options Configuration options\n * @param options.copiedDuration Duration in milliseconds to show the copied state\n * @returns A copy callback function, or null if copying is disabled\n *\n * @example\n * ```tsx\n * function CustomCopyButton() {\n * const copy = useActionBarPrimitiveCopy({ copiedDuration: 2000 });\n *\n * return (\n * <button onClick={copy} disabled={!copy}>\n * {copy ? \"Copy\" : \"Cannot Copy\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useActionBarPrimitiveCopy = ({\n copiedDuration = 3000,\n}: {\n copiedDuration?: number | undefined;\n} = {}) => {\n const api = useAssistantApi();\n const hasCopyableContent = useAssistantState(({ message }) => {\n return (\n (message.role !== \"assistant\" || message.status?.type !== \"running\") &&\n message.parts.some((c) => c.type === \"text\" && c.text.length > 0)\n );\n });\n\n const isEditing = useAssistantState(({ composer }) => composer.isEditing);\n const composerValue = useAssistantState(({ composer }) => composer.text);\n\n const callback = useCallback(() => {\n const valueToCopy = isEditing ? composerValue : api.message().getCopyText();\n\n if (!valueToCopy) return;\n\n navigator.clipboard.writeText(valueToCopy).then(() => {\n api.message().setIsCopied(true);\n setTimeout(() => api.message().setIsCopied(false), copiedDuration);\n });\n }, [api, isEditing, composerValue, copiedDuration]);\n\n if (!hasCopyableContent) return null;\n return callback;\n};\n\nexport namespace ActionBarPrimitiveCopy {\n export type Element = HTMLButtonElement;\n /**\n * Props for the ActionBarPrimitive.Copy component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useActionBarPrimitiveCopy>;\n}\n\n/**\n * A button component that copies message content to the clipboard.\n *\n * This component automatically handles copying message text to the clipboard\n * and provides visual feedback through the data-copied attribute. It's disabled\n * when there's no copyable content available.\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Copy copiedDuration={2000}>\n * Copy Message\n * </ActionBarPrimitive.Copy>\n * ```\n */\nexport const ActionBarPrimitiveCopy = forwardRef<\n ActionBarPrimitiveCopy.Element,\n ActionBarPrimitiveCopy.Props\n>(({ copiedDuration, onClick, disabled, ...props }, forwardedRef) => {\n const isCopied = useAssistantState(({ message }) => message.isCopied);\n const callback = useActionBarPrimitiveCopy({ copiedDuration });\n return (\n <Primitive.button\n type=\"button\"\n {...(isCopied ? { \"data-copied\": \"true\" } : {})}\n {...props}\n ref={forwardedRef}\n disabled={disabled || !callback}\n onClick={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AAe,CAAC;AAC7D,SACE;AAAA,IAAC,UAAU;AAAA,IAAV;AAAA,MACC,MAAK;AAAA,MACJ,GAAI,WAAW,EAAE,eAAe,OAAO,IAAI,CAAC;AAAA,MAC5C,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,UAAU,YAAY,CAAC;AAAA,MACvB,SAAS,qBAAqB,SAAS,MAAM;AAC3C,mBAAW;AAAA,MACb,CAAC;AAAA;AAAA,EACH;AAEJ,CAAC;AAED,uBAAuB,cAAc;","names":[]}
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
// src/primitives/message/MessageError.tsx
|
|
4
4
|
import { useAssistantState } from "../../context/index.js";
|
|
5
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
6
5
|
var MessagePrimitiveError = ({ children }) => {
|
|
7
6
|
const hasError = useAssistantState(
|
|
8
7
|
({ message }) => message.status?.type === "incomplete" && message.status.reason === "error"
|
|
9
8
|
);
|
|
10
|
-
return hasError ?
|
|
9
|
+
return hasError ? children : null;
|
|
11
10
|
};
|
|
12
11
|
MessagePrimitiveError.displayName = "MessagePrimitive.Error";
|
|
13
12
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/message/MessageError.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, PropsWithChildren } from \"react\";\nimport { useAssistantState } from \"../../context\";\n\nexport const MessagePrimitiveError: FC<PropsWithChildren> = ({ children }) => {\n const hasError = useAssistantState(\n ({ message }) =>\n message.status?.type === \"incomplete\" &&\n message.status.reason === \"error\",\n );\n return hasError ?
|
|
1
|
+
{"version":3,"sources":["../../../src/primitives/message/MessageError.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, PropsWithChildren } from \"react\";\nimport { useAssistantState } from \"../../context\";\n\nexport const MessagePrimitiveError: FC<PropsWithChildren> = ({ children }) => {\n const hasError = useAssistantState(\n ({ message }) =>\n message.status?.type === \"incomplete\" &&\n message.status.reason === \"error\",\n );\n return hasError ? children : null;\n};\n\nMessagePrimitiveError.displayName = \"MessagePrimitive.Error\";\n"],"mappings":";;;AAGA,SAAS,yBAAyB;AAE3B,IAAM,wBAA+C,CAAC,EAAE,SAAS,MAAM;AAC5E,QAAM,WAAW;AAAA,IACf,CAAC,EAAE,QAAQ,MACT,QAAQ,QAAQ,SAAS,gBACzB,QAAQ,OAAO,WAAW;AAAA,EAC9B;AACA,SAAO,WAAW,WAAW;AAC/B;AAEA,sBAAsB,cAAc;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageParts.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageParts.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,EAAE,EAEP,iBAAiB,EAElB,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AA6F/C,yBAAiB,qBAAqB,CAAC;IACrC,KAAY,KAAK,GAAG;QAClB;;;;;WAKG;QACH,UAAU,CAAC,EACP;YACE,6CAA6C;YAC7C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,2CAA2C;YAC3C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,mEAAmE;YACnE,SAAS,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;YACtD,6CAA6C;YAC7C,MAAM,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;YAChD,4CAA4C;YAC5C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,2CAA2C;YAC3C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,2DAA2D;YAC3D,cAAc,CAAC,EAAE,kCAAkC,GAAG,SAAS,CAAC;YAChE,4CAA4C;YAC5C,KAAK,CAAC,EACF;gBACE,qDAAqD;gBACrD,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,4BAA4B,GAAG,SAAS,CAAC,GACxD,SAAS,CAAC;gBACd,gDAAgD;gBAChD,QAAQ,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,GAAG,SAAS,CAAC;aAChE,GACD;gBACE,qDAAqD;gBACrD,QAAQ,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;aACnD,GACD,SAAS,CAAC;YAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA+CG;YACH,SAAS,CAAC,EAAE,aAAa,CACvB,iBAAiB,CAAC;gBAAE,UAAU,EAAE,MAAM,CAAC;gBAAC,QAAQ,EAAE,MAAM,CAAA;aAAE,CAAC,CAC5D,CAAC;YAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4BG;YACH,cAAc,CAAC,EAAE,uBAAuB,CAAC;SAC1C,GACD,SAAS,CAAC;KACf,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"MessageParts.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageParts.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,EAAE,EAEP,iBAAiB,EAElB,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AA6F/C,yBAAiB,qBAAqB,CAAC;IACrC,KAAY,KAAK,GAAG;QAClB;;;;;WAKG;QACH,UAAU,CAAC,EACP;YACE,6CAA6C;YAC7C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,2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;;;;;;;;GAgBG;AACH,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAAC,2BAA2B,CAAC,KAAK,CAoB3E,CAAC;AAyCJ;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAsEjE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/message/MessageParts.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n memo,\n PropsWithChildren,\n useMemo,\n} from \"react\";\nimport {\n useAssistantState,\n useAssistantApi,\n PartByIndexProvider,\n TextMessagePartProvider,\n} from \"../../context\";\nimport { MessagePartPrimitiveText } from \"../messagePart/MessagePartText\";\nimport { MessagePartPrimitiveImage } from \"../messagePart/MessagePartImage\";\nimport type {\n Unstable_AudioMessagePartComponent,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n ReasoningGroupComponent,\n} from \"../../types/MessagePartComponentTypes\";\nimport { MessagePartPrimitiveInProgress } from \"../messagePart/MessagePartInProgress\";\nimport { MessagePartStatus } from \"../../types/AssistantTypes\";\nimport { useShallow } from \"zustand/shallow\";\n\ntype MessagePartRange =\n | { type: \"single\"; index: number }\n | { type: \"toolGroup\"; startIndex: number; endIndex: number }\n | { type: \"reasoningGroup\"; startIndex: number; endIndex: number };\n\n/**\n * Creates a group state manager for a specific part type.\n * Returns functions to start, end, and finalize groups.\n */\nconst createGroupState = <T extends \"toolGroup\" | \"reasoningGroup\">(\n groupType: T,\n) => {\n let start = -1;\n\n return {\n startGroup: (index: number) => {\n if (start === -1) {\n start = index;\n }\n },\n endGroup: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n start = -1;\n }\n },\n finalize: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n }\n },\n };\n};\n\n/**\n * Groups consecutive tool-call and reasoning message parts into ranges.\n * Always groups tool calls and reasoning parts, even if there's only one.\n */\nconst groupMessageParts = (\n messageTypes: readonly string[],\n): MessagePartRange[] => {\n const ranges: MessagePartRange[] = [];\n const toolGroup = createGroupState(\"toolGroup\");\n const reasoningGroup = createGroupState(\"reasoningGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\") {\n reasoningGroup.endGroup(i - 1, ranges);\n toolGroup.startGroup(i);\n } else if (type === \"reasoning\") {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.startGroup(i);\n } else {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n toolGroup.finalize(messageTypes.length - 1, ranges);\n reasoningGroup.finalize(messageTypes.length - 1, ranges);\n\n return ranges;\n};\n\nconst useMessagePartsGroups = (): MessagePartRange[] => {\n const messageTypes = useAssistantState(\n useShallow((s) => s.message.parts.map((c: any) => c.type)),\n );\n\n return useMemo(() => {\n if (messageTypes.length === 0) {\n return [];\n }\n return groupMessageParts(messageTypes);\n }, [messageTypes]);\n};\n\nexport namespace MessagePrimitiveParts {\n export type Props = {\n /**\n * Component configuration for rendering different types of message content.\n *\n * You can provide custom components for each content type (text, image, file, etc.)\n * and configure tool rendering behavior. If not provided, default components will be used.\n */\n components?:\n | {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /** Component for rendering audio content (experimental) */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for tool call rendering */\n tools?:\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n }\n | undefined;\n\n /**\n * Component for rendering grouped consecutive tool calls.\n *\n * When provided, this component will automatically wrap consecutive tool-call\n * message parts, allowing you to create collapsible sections, custom styling,\n * or other grouped presentations for multiple tool calls.\n *\n * The component receives:\n * - `startIndex`: The index of the first tool call in the group\n * - `endIndex`: The index of the last tool call in the group\n * - `children`: The rendered tool call components\n *\n * @example\n * ```tsx\n * // Collapsible tool group\n * ToolGroup: ({ startIndex, endIndex, children }) => (\n * <details className=\"tool-group\">\n * <summary>\n * {endIndex - startIndex + 1} tool calls\n * </summary>\n * <div className=\"tool-group-content\">\n * {children}\n * </div>\n * </details>\n * )\n * ```\n *\n * @example\n * ```tsx\n * // Custom styled tool group with header\n * ToolGroup: ({ startIndex, endIndex, children }) => (\n * <div className=\"border rounded-lg p-4 my-2\">\n * <div className=\"text-sm text-gray-600 mb-2\">\n * Tool execution #{startIndex + 1}-{endIndex + 1}\n * </div>\n * <div className=\"space-y-2\">\n * {children}\n * </div>\n * </div>\n * )\n * ```\n *\n * @param startIndex - Index of the first tool call in the group\n * @param endIndex - Index of the last tool call in the group\n * @param children - Rendered tool call components to display within the group\n *\n * @deprecated This feature is still experimental and subject to change.\n */\n ToolGroup?: ComponentType<\n PropsWithChildren<{ startIndex: number; endIndex: number }>\n >;\n\n /**\n * Component for rendering grouped reasoning parts.\n *\n * When provided, this component will automatically wrap reasoning message parts\n * (one or more consecutive) in a group container. Each reasoning part inside\n * renders its own text independently - no text merging occurs.\n *\n * The component receives:\n * - `startIndex`: The index of the first reasoning part in the group\n * - `endIndex`: The index of the last reasoning part in the group\n * - `children`: The rendered Reasoning components (one per part)\n *\n * @example\n * ```tsx\n * // Collapsible reasoning group\n * ReasoningGroup: ({ children }) => (\n * <details className=\"reasoning-group\">\n * <summary>Reasoning</summary>\n * <div className=\"reasoning-content\">\n * {children}\n * </div>\n * </details>\n * )\n * ```\n *\n * @param startIndex - Index of the first reasoning part in the group\n * @param endIndex - Index of the last reasoning part in the group\n * @param children - Rendered reasoning part components\n */\n ReasoningGroup?: ReasoningGroupComponent;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAssistantState(({ tools }) => {\n const Render = tools.tools[props.toolName] ?? Fallback;\n if (Array.isArray(Render)) return Render[0] ?? Fallback;\n return Render;\n });\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <MessagePartPrimitiveText />\n <MessagePartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </MessagePartPrimitiveInProgress>\n </p>\n ),\n Reasoning: () => null,\n Source: () => null,\n Image: () => <MessagePartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n ToolGroup: ({ children }) => children,\n ReasoningGroup: ({ children }) => children,\n} satisfies MessagePrimitiveParts.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveParts.Props[\"components\"];\n};\n\nconst MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n } = {},\n}) => {\n const api = useAssistantApi();\n const part = useAssistantState(({ part }) => part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = api.part().addToolResult;\n const resume = api.part().resumeToolCall;\n if (\"Override\" in tools)\n return <tools.Override {...part} addResult={addResult} resume={resume} />;\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n // eslint-disable-next-line jsx-a11y/alt-text\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\":\n return null;\n\n default:\n const unhandledType: never = type;\n throw new Error(`Unknown message part type: ${unhandledType}`);\n }\n};\n\nexport namespace MessagePrimitivePartByIndex {\n export type Props = {\n index: number;\n components: MessagePrimitiveParts.Props[\"components\"];\n };\n}\n\n/**\n * Renders a single message part at the specified index.\n *\n * This component provides direct access to render a specific message part\n * within the current message context, using the provided component configuration.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.PartByIndex\n * index={0}\n * components={{\n * Text: MyTextComponent,\n * Image: MyImageComponent\n * }}\n * />\n * ```\n */\nexport const MessagePrimitivePartByIndex: FC<MessagePrimitivePartByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <PartByIndexProvider index={index}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.ToolGroup === next.components?.ToolGroup &&\n prev.components?.ReasoningGroup === next.components?.ReasoningGroup,\n );\n\nMessagePrimitivePartByIndex.displayName = \"MessagePrimitive.PartByIndex\";\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAssistantState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\n/**\n * Renders the parts of a message with support for multiple content types.\n *\n * This component automatically handles different types of message content including\n * text, images, files, tool calls, and more. It provides a flexible component\n * system for customizing how each content type is rendered.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Parts\n * components={{\n * Text: ({ text }) => <p className=\"message-text\">{text}</p>,\n * Image: ({ image }) => <img src={image} alt=\"Message image\" />,\n * tools: {\n * by_name: {\n * calculator: CalculatorTool,\n * weather: WeatherTool,\n * },\n * Fallback: DefaultToolComponent\n * }\n * }}\n * />\n * ```\n */\nexport const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({\n components,\n}) => {\n const contentLength = useAssistantState(\n ({ message }) => message.parts.length,\n );\n const messageRanges = useMessagePartsGroups();\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n return messageRanges.map((range) => {\n if (range.type === \"single\") {\n return (\n <MessagePrimitivePartByIndex\n key={range.index}\n index={range.index}\n components={components}\n />\n );\n } else if (range.type === \"toolGroup\") {\n const ToolGroupComponent =\n components!.ToolGroup ?? defaultComponents.ToolGroup;\n return (\n <ToolGroupComponent\n key={`tool-${range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => (\n <MessagePrimitivePartByIndex\n key={i}\n index={range.startIndex + i}\n components={components}\n />\n ),\n )}\n </ToolGroupComponent>\n );\n } else {\n // reasoningGroup\n const ReasoningGroupComponent =\n components!.ReasoningGroup ?? defaultComponents.ReasoningGroup;\n return (\n <ReasoningGroupComponent\n key={`reasoning-${range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => (\n <MessagePrimitivePartByIndex\n key={i}\n index={range.startIndex + i}\n components={components}\n />\n ),\n )}\n </ReasoningGroupComponent>\n );\n }\n });\n }, [messageRanges, components, contentLength]);\n\n return <>{partsElements}</>;\n};\n\nMessagePrimitiveParts.displayName = \"MessagePrimitive.Parts\";\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,iCAAiC;AAa1C,SAAS,sCAAsC;AAE/C,SAAS,kBAAkB;AAqOlB,SA0QA,UA1QA,KAKL,YALK;AA1NT,IAAM,mBAAmB,CACvB,cACG;AACH,MAAI,QAAQ;AAEZ,SAAO;AAAA,IACL,YAAY,CAAC,UAAkB;AAC7B,UAAI,UAAU,IAAI;AAChB,gBAAQ;AAAA,MACV;AAAA,IACF;AAAA,IACA,UAAU,CAAC,UAAkB,WAA+B;AAC1D,UAAI,UAAU,IAAI;AAChB,eAAO,KAAK;AAAA,UACV,MAAM;AAAA,UACN,YAAY;AAAA,UACZ;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M,SAAS,aAAa;AACrC,cAAM,qBACJ,WAAY,aAAa,kBAAkB;AAC7C,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,YAAY,MAAM;AAAA,YAClB,UAAU,MAAM;AAAA,YAEf,gBAAM;AAAA,cACL,EAAE,QAAQ,MAAM,WAAW,MAAM,aAAa,EAAE;AAAA,cAChD,CAAC,GAAG,MACF;AAAA,gBAAC;AAAA;AAAA,kBAEC,OAAO,MAAM,aAAa;AAAA,kBAC1B;AAAA;AAAA,gBAFK;AAAA,cAGP;AAAA,YAEJ;AAAA;AAAA,UAbK,QAAQ,MAAM,UAAU;AAAA,QAc/B;AAAA,MAEJ,OAAO;AAEL,cAAM,0BACJ,WAAY,kBAAkB,kBAAkB;AAClD,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,YAAY,MAAM;AAAA,YAClB,UAAU,MAAM;AAAA,YAEf,gBAAM;AAAA,cACL,EAAE,QAAQ,MAAM,WAAW,MAAM,aAAa,EAAE;AAAA,cAChD,CAAC,GAAG,MACF;AAAA,gBAAC;AAAA;AAAA,kBAEC,OAAO,MAAM,aAAa;AAAA,kBAC1B;AAAA;AAAA,gBAFK;AAAA,cAGP;AAAA,YAEJ;AAAA;AAAA,UAbK,aAAa,MAAM,UAAU;AAAA,QAcpC;AAAA,MAEJ;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,eAAe,YAAY,aAAa,CAAC;AAE7C,SAAO,gCAAG,yBAAc;AAC1B;AAEA,sBAAsB,cAAc;","names":["Render","part"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/primitives/message/MessageParts.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n memo,\n PropsWithChildren,\n useMemo,\n} from \"react\";\nimport {\n useAssistantState,\n useAssistantApi,\n PartByIndexProvider,\n TextMessagePartProvider,\n} from \"../../context\";\nimport { MessagePartPrimitiveText } from \"../messagePart/MessagePartText\";\nimport { MessagePartPrimitiveImage } from \"../messagePart/MessagePartImage\";\nimport type {\n Unstable_AudioMessagePartComponent,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n ReasoningGroupComponent,\n} from \"../../types/MessagePartComponentTypes\";\nimport { MessagePartPrimitiveInProgress } from \"../messagePart/MessagePartInProgress\";\nimport { MessagePartStatus } from \"../../types/AssistantTypes\";\nimport { useShallow } from \"zustand/shallow\";\n\ntype MessagePartRange =\n | { type: \"single\"; index: number }\n | { type: \"toolGroup\"; startIndex: number; endIndex: number }\n | { type: \"reasoningGroup\"; startIndex: number; endIndex: number };\n\n/**\n * Creates a group state manager for a specific part type.\n * Returns functions to start, end, and finalize groups.\n */\nconst createGroupState = <T extends \"toolGroup\" | \"reasoningGroup\">(\n groupType: T,\n) => {\n let start = -1;\n\n return {\n startGroup: (index: number) => {\n if (start === -1) {\n start = index;\n }\n },\n endGroup: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n start = -1;\n }\n },\n finalize: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n }\n },\n };\n};\n\n/**\n * Groups consecutive tool-call and reasoning message parts into ranges.\n * Always groups tool calls and reasoning parts, even if there's only one.\n */\nconst groupMessageParts = (\n messageTypes: readonly string[],\n): MessagePartRange[] => {\n const ranges: MessagePartRange[] = [];\n const toolGroup = createGroupState(\"toolGroup\");\n const reasoningGroup = createGroupState(\"reasoningGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\") {\n reasoningGroup.endGroup(i - 1, ranges);\n toolGroup.startGroup(i);\n } else if (type === \"reasoning\") {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.startGroup(i);\n } else {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n toolGroup.finalize(messageTypes.length - 1, ranges);\n reasoningGroup.finalize(messageTypes.length - 1, ranges);\n\n return ranges;\n};\n\nconst useMessagePartsGroups = (): MessagePartRange[] => {\n const messageTypes = useAssistantState(\n useShallow((s) => s.message.parts.map((c: any) => c.type)),\n );\n\n return useMemo(() => {\n if (messageTypes.length === 0) {\n return [];\n }\n return groupMessageParts(messageTypes);\n }, [messageTypes]);\n};\n\nexport namespace MessagePrimitiveParts {\n export type Props = {\n /**\n * Component configuration for rendering different types of message content.\n *\n * You can provide custom components for each content type (text, image, file, etc.)\n * and configure tool rendering behavior. If not provided, default components will be used.\n */\n components?:\n | {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /** Component for rendering audio content (experimental) */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for tool call rendering */\n tools?:\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n }\n | undefined;\n\n /**\n * Component for rendering grouped consecutive tool calls.\n *\n * When provided, this component will automatically wrap consecutive tool-call\n * message parts, allowing you to create collapsible sections, custom styling,\n * or other grouped presentations for multiple tool calls.\n *\n * The component receives:\n * - `startIndex`: The index of the first tool call in the group\n * - `endIndex`: The index of the last tool call in the group\n * - `children`: The rendered tool call components\n *\n * @example\n * ```tsx\n * // Collapsible tool group\n * ToolGroup: ({ startIndex, endIndex, children }) => (\n * <details className=\"tool-group\">\n * <summary>\n * {endIndex - startIndex + 1} tool calls\n * </summary>\n * <div className=\"tool-group-content\">\n * {children}\n * </div>\n * </details>\n * )\n * ```\n *\n * @example\n * ```tsx\n * // Custom styled tool group with header\n * ToolGroup: ({ startIndex, endIndex, children }) => (\n * <div className=\"border rounded-lg p-4 my-2\">\n * <div className=\"text-sm text-gray-600 mb-2\">\n * Tool execution #{startIndex + 1}-{endIndex + 1}\n * </div>\n * <div className=\"space-y-2\">\n * {children}\n * </div>\n * </div>\n * )\n * ```\n *\n * @param startIndex - Index of the first tool call in the group\n * @param endIndex - Index of the last tool call in the group\n * @param children - Rendered tool call components to display within the group\n *\n * @deprecated This feature is still experimental and subject to change.\n */\n ToolGroup?: ComponentType<\n PropsWithChildren<{ startIndex: number; endIndex: number }>\n >;\n\n /**\n * Component for rendering grouped reasoning parts.\n *\n * When provided, this component will automatically wrap reasoning message parts\n * (one or more consecutive) in a group container. Each reasoning part inside\n * renders its own text independently - no text merging occurs.\n *\n * The component receives:\n * - `startIndex`: The index of the first reasoning part in the group\n * - `endIndex`: The index of the last reasoning part in the group\n * - `children`: The rendered Reasoning components (one per part)\n *\n * @example\n * ```tsx\n * // Collapsible reasoning group\n * ReasoningGroup: ({ children }) => (\n * <details className=\"reasoning-group\">\n * <summary>Reasoning</summary>\n * <div className=\"reasoning-content\">\n * {children}\n * </div>\n * </details>\n * )\n * ```\n *\n * @param startIndex - Index of the first reasoning part in the group\n * @param endIndex - Index of the last reasoning part in the group\n * @param children - Rendered reasoning part components\n */\n ReasoningGroup?: ReasoningGroupComponent;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAssistantState(({ tools }) => {\n const Render = tools.tools[props.toolName] ?? Fallback;\n if (Array.isArray(Render)) return Render[0] ?? Fallback;\n return Render;\n });\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <MessagePartPrimitiveText />\n <MessagePartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </MessagePartPrimitiveInProgress>\n </p>\n ),\n Reasoning: () => null,\n Source: () => null,\n Image: () => <MessagePartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n ToolGroup: ({ children }) => children,\n ReasoningGroup: ({ children }) => children,\n} satisfies MessagePrimitiveParts.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveParts.Props[\"components\"];\n};\n\nconst MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n } = {},\n}) => {\n const api = useAssistantApi();\n const part = useAssistantState(({ part }) => part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = api.part().addToolResult;\n const resume = api.part().resumeToolCall;\n if (\"Override\" in tools)\n return <tools.Override {...part} addResult={addResult} resume={resume} />;\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\":\n return null;\n\n default:\n const unhandledType: never = type;\n throw new Error(`Unknown message part type: ${unhandledType}`);\n }\n};\n\nexport namespace MessagePrimitivePartByIndex {\n export type Props = {\n index: number;\n components: MessagePrimitiveParts.Props[\"components\"];\n };\n}\n\n/**\n * Renders a single message part at the specified index.\n *\n * This component provides direct access to render a specific message part\n * within the current message context, using the provided component configuration.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.PartByIndex\n * index={0}\n * components={{\n * Text: MyTextComponent,\n * Image: MyImageComponent\n * }}\n * />\n * ```\n */\nexport const MessagePrimitivePartByIndex: FC<MessagePrimitivePartByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <PartByIndexProvider index={index}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.ToolGroup === next.components?.ToolGroup &&\n prev.components?.ReasoningGroup === next.components?.ReasoningGroup,\n );\n\nMessagePrimitivePartByIndex.displayName = \"MessagePrimitive.PartByIndex\";\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAssistantState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\n/**\n * Renders the parts of a message with support for multiple content types.\n *\n * This component automatically handles different types of message content including\n * text, images, files, tool calls, and more. It provides a flexible component\n * system for customizing how each content type is rendered.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Parts\n * components={{\n * Text: ({ text }) => <p className=\"message-text\">{text}</p>,\n * Image: ({ image }) => <img src={image} alt=\"Message image\" />,\n * tools: {\n * by_name: {\n * calculator: CalculatorTool,\n * weather: WeatherTool,\n * },\n * Fallback: DefaultToolComponent\n * }\n * }}\n * />\n * ```\n */\nexport const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({\n components,\n}) => {\n const contentLength = useAssistantState(\n ({ message }) => message.parts.length,\n );\n const messageRanges = useMessagePartsGroups();\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n return messageRanges.map((range) => {\n if (range.type === \"single\") {\n return (\n <MessagePrimitivePartByIndex\n key={range.index}\n index={range.index}\n components={components}\n />\n );\n } else if (range.type === \"toolGroup\") {\n const ToolGroupComponent =\n components!.ToolGroup ?? defaultComponents.ToolGroup;\n return (\n <ToolGroupComponent\n key={`tool-${range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => (\n <MessagePrimitivePartByIndex\n key={i}\n index={range.startIndex + i}\n components={components}\n />\n ),\n )}\n </ToolGroupComponent>\n );\n } else {\n // reasoningGroup\n const ReasoningGroupComponent =\n components!.ReasoningGroup ?? defaultComponents.ReasoningGroup;\n return (\n <ReasoningGroupComponent\n key={`reasoning-${range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => (\n <MessagePrimitivePartByIndex\n key={i}\n index={range.startIndex + i}\n components={components}\n />\n ),\n )}\n </ReasoningGroupComponent>\n );\n }\n });\n }, [messageRanges, components, contentLength]);\n\n return <>{partsElements}</>;\n};\n\nMessagePrimitiveParts.displayName = \"MessagePrimitive.Parts\";\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,iCAAiC;AAa1C,SAAS,sCAAsC;AAE/C,SAAS,kBAAkB;AAqOlB,SAyQA,UAzQA,KAKL,YALK;AA1NT,IAAM,mBAAmB,CACvB,cACG;AACH,MAAI,QAAQ;AAEZ,SAAO;AAAA,IACL,YAAY,CAAC,UAAkB;AAC7B,UAAI,UAAU,IAAI;AAChB,gBAAQ;AAAA,MACV;AAAA,IACF;AAAA,IACA,UAAU,CAAC,UAAkB,WAA+B;AAC1D,UAAI,UAAU,IAAI;AAChB,eAAO,KAAK;AAAA,UACV,MAAM;AAAA,UACN,YAAY;AAAA,UACZ;AAAA,QACF,CAAqB;AACrB,gBAAQ;AAAA,MACV;AAAA,IACF;AAAA,IACA,UAAU,CAAC,UAAkB,WAA+B;AAC1D,UAAI,UAAU,IAAI;AAChB,eAAO,KAAK;AAAA,UACV,MAAM;AAAA,UACN,YAAY;AAAA,UACZ;AAAA,QACF,CAAqB;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AACF;AAMA,IAAM,oBAAoB,CACxB,iBACuB;AACvB,QAAM,SAA6B,CAAC;AACpC,QAAM,YAAY,iBAAiB,WAAW;AAC9C,QAAM,iBAAiB,iBAAiB,gBAAgB;AAExD,WAAS,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;AAC5C,UAAM,OAAO,aAAa,CAAC;AAE3B,QAAI,SAAS,aAAa;AACxB,qBAAe,SAAS,IAAI,GAAG,MAAM;AACrC,gBAAU,WAAW,CAAC;AAAA,IACxB,WAAW,SAAS,a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,EAAE,QAAQ,MAAM,WAAW,MAAM,aAAa,EAAE;AAAA,cAChD,CAAC,GAAG,MACF;AAAA,gBAAC;AAAA;AAAA,kBAEC,OAAO,MAAM,aAAa;AAAA,kBAC1B;AAAA;AAAA,gBAFK;AAAA,cAGP;AAAA,YAEJ;AAAA;AAAA,UAbK,aAAa,MAAM,UAAU;AAAA,QAcpC;AAAA,MAEJ;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,eAAe,YAAY,aAAa,CAAC;AAE7C,SAAO,gCAAG,yBAAc;AAC1B;AAEA,sBAAsB,cAAc;","names":["Render","part"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagePartsGrouped.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessagePartsGrouped.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,EAAE,EAEP,iBAAiB,EAElB,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC9B,MAAM,uCAAuC,CAAC;AAI/C,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,KAAK,gBAAgB,EAAE,CAAC;AAmD7E,yBAAiB,qCAAqC,CAAC;IACrD,KAAY,KAAK,GAAG;QAClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA0CG;QACH,gBAAgB,EAAE,gBAAgB,CAAC;QAEnC;;;;;WAKG;QACH,UAAU,EACN;YACE,6CAA6C;YAC7C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,2CAA2C;YAC3C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,mEAAmE;YACnE,SAAS,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;YACtD,6CAA6C;YAC7C,MAAM,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;YAChD,4CAA4C;YAC5C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,2CAA2C;YAC3C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,2DAA2D;YAC3D,cAAc,CAAC,EAAE,kCAAkC,GAAG,SAAS,CAAC;YAChE,4CAA4C;YAC5C,KAAK,CAAC,EACF;gBACE,qDAAqD;gBACrD,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,4BAA4B,GAAG,SAAS,CAAC,GACxD,SAAS,CAAC;gBACd,gDAAgD;gBAChD,QAAQ,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,GAAG,SAAS,CAAC;aAChE,GACD;gBACE,qDAAqD;gBACrD,QAAQ,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;aACnD,GACD,SAAS,CAAC;YAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAgCG;YACH,KAAK,CAAC,EAAE,aAAa,CACnB,iBAAiB,CAAC;gBAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;gBAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;aACnB,CAAC,CACH,CAAC;SACH,GACD,SAAS,CAAC;KACf,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"MessagePartsGrouped.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessagePartsGrouped.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,EAAE,EAEP,iBAAiB,EAElB,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,wBAAwB,EACxB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