@assistant-ui/react 0.11.4 → 0.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/AssistantClient.d.ts +2 -2
- package/dist/client/AssistantClient.d.ts.map +1 -1
- package/dist/client/AssistantClient.js +1 -2
- package/dist/client/AssistantClient.js.map +1 -1
- package/dist/client/ToolUIClient.d.ts +3 -2
- package/dist/client/ToolUIClient.d.ts.map +1 -1
- package/dist/client/ToolUIClient.js +1 -5
- package/dist/client/ToolUIClient.js.map +1 -1
- package/dist/client/types/ThreadList.d.ts +1 -1
- package/dist/client/types/ThreadList.d.ts.map +1 -1
- package/dist/context/providers/AttachmentProvider.js +3 -3
- package/dist/context/providers/AttachmentProvider.js.map +1 -1
- package/dist/context/providers/MessageProvider.d.ts.map +1 -1
- package/dist/context/providers/MessageProvider.js +2 -2
- package/dist/context/providers/MessageProvider.js.map +1 -1
- package/dist/context/providers/PartProvider.js +2 -2
- package/dist/context/providers/PartProvider.js.map +1 -1
- package/dist/context/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/context/providers/TextMessagePartProvider.js +6 -7
- package/dist/context/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/context/providers/ThreadListItemProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadListItemProvider.js +5 -4
- package/dist/context/providers/ThreadListItemProvider.js.map +1 -1
- package/dist/context/react/AssistantApiContext.d.ts +3 -3
- package/dist/context/react/AssistantApiContext.d.ts.map +1 -1
- package/dist/context/react/AssistantApiContext.js +4 -3
- package/dist/context/react/AssistantApiContext.js.map +1 -1
- package/dist/context/react/hooks/useAssistantEvent.d.ts +2 -2
- package/dist/context/react/hooks/useAssistantEvent.d.ts.map +1 -1
- package/dist/context/react/hooks/useAssistantEvent.js.map +1 -1
- package/dist/context/react/index.d.ts +1 -0
- package/dist/context/react/index.d.ts.map +1 -1
- package/dist/context/react/index.js +2 -0
- package/dist/context/react/index.js.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +1 -5
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/client/AttachmentRuntimeClient.d.ts +2 -4
- package/dist/legacy-runtime/client/AttachmentRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/AttachmentRuntimeClient.js +10 -10
- package/dist/legacy-runtime/client/AttachmentRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/ComposerRuntimeClient.d.ts +3 -2
- package/dist/legacy-runtime/client/ComposerRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ComposerRuntimeClient.js +1 -5
- package/dist/legacy-runtime/client/ComposerRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/EventManagerRuntimeClient.d.ts +6 -7
- package/dist/legacy-runtime/client/EventManagerRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/EventManagerRuntimeClient.js +11 -3
- package/dist/legacy-runtime/client/EventManagerRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.d.ts +1 -1
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.js +10 -10
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/MessageRuntimeClient.d.ts +3 -3
- package/dist/legacy-runtime/client/MessageRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/MessageRuntimeClient.js +31 -31
- package/dist/legacy-runtime/client/MessageRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/ThreadListItemRuntimeClient.d.ts +2 -2
- package/dist/legacy-runtime/client/ThreadListItemRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ThreadListItemRuntimeClient.js +17 -17
- package/dist/legacy-runtime/client/ThreadListItemRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/ThreadListRuntimeClient.d.ts +3 -2
- package/dist/legacy-runtime/client/ThreadListRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ThreadListRuntimeClient.js +2 -6
- package/dist/legacy-runtime/client/ThreadListRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/ThreadRuntimeClient.d.ts +3 -2
- package/dist/legacy-runtime/client/ThreadRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ThreadRuntimeClient.js +1 -5
- package/dist/legacy-runtime/client/ThreadRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js +0 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/types/EventTypes.d.ts +15 -7
- package/dist/types/EventTypes.d.ts.map +1 -1
- package/dist/types/EventTypes.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/tap-store/tap-api.d.ts +9 -1
- package/dist/utils/tap-store/tap-api.d.ts.map +1 -1
- package/dist/utils/tap-store/tap-api.js +12 -2
- package/dist/utils/tap-store/tap-api.js.map +1 -1
- package/package.json +1 -1
- package/src/client/AssistantClient.ts +7 -13
- package/src/client/ToolUIClient.ts +1 -6
- package/src/client/types/ThreadList.ts +1 -1
- package/src/context/providers/AttachmentProvider.tsx +3 -3
- package/src/context/providers/MessageProvider.tsx +3 -8
- package/src/context/providers/PartProvider.tsx +2 -2
- package/src/context/providers/TextMessagePartProvider.tsx +5 -7
- package/src/context/providers/ThreadListItemProvider.tsx +9 -16
- package/src/context/react/AssistantApiContext.tsx +11 -5
- package/src/context/react/hooks/useAssistantEvent.ts +4 -3
- package/src/context/react/index.ts +2 -0
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +1 -15
- package/src/legacy-runtime/client/AttachmentRuntimeClient.ts +10 -11
- package/src/legacy-runtime/client/ComposerRuntimeClient.ts +1 -6
- package/src/legacy-runtime/client/EventManagerRuntimeClient.ts +41 -18
- package/src/legacy-runtime/client/MessagePartRuntimeClient.ts +13 -14
- package/src/legacy-runtime/client/MessageRuntimeClient.ts +35 -36
- package/src/legacy-runtime/client/ThreadListItemRuntimeClient.ts +17 -18
- package/src/legacy-runtime/client/ThreadListRuntimeClient.ts +2 -7
- package/src/legacy-runtime/client/ThreadRuntimeClient.ts +1 -6
- package/src/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.tsx +0 -1
- package/src/types/EventTypes.ts +23 -12
- package/src/types/index.ts +3 -1
- package/src/utils/tap-store/tap-api.ts +19 -2
@@ -2,9 +2,8 @@
|
|
2
2
|
|
3
3
|
// src/legacy-runtime/AssistantRuntimeProvider.tsx
|
4
4
|
import { memo } from "react";
|
5
|
-
import {
|
5
|
+
import { AssistantProvider } from "../context/react/AssistantApiContext.js";
|
6
6
|
import { useAssistantClient } from "../client/AssistantClient.js";
|
7
|
-
import { ThreadViewportProvider } from "../context/providers/ThreadViewportProvider.js";
|
8
7
|
import { ThreadListClient } from "./client/ThreadListRuntimeClient.js";
|
9
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
10
9
|
var getRenderComponent = (runtime) => {
|
@@ -28,9 +27,6 @@ var AssistantRuntimeProviderImpl = ({
|
|
28
27
|
] });
|
29
28
|
};
|
30
29
|
var AssistantRuntimeProvider = memo(AssistantRuntimeProviderImpl);
|
31
|
-
var AssistantProvider = ({ children, api }) => {
|
32
|
-
return /* @__PURE__ */ jsx(AssistantApiProvider, { api, children: /* @__PURE__ */ jsx(ThreadViewportProvider, { children }) });
|
33
|
-
};
|
34
30
|
export {
|
35
31
|
AssistantRuntimeProvider,
|
36
32
|
AssistantRuntimeProviderImpl
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/legacy-runtime/AssistantRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, memo, PropsWithChildren } from \"react\";\nimport {
|
1
|
+
{"version":3,"sources":["../../src/legacy-runtime/AssistantRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, memo, PropsWithChildren } from \"react\";\nimport { AssistantProvider } from \"../context/react/AssistantApiContext\";\nimport { AssistantRuntime } from \"./runtime/AssistantRuntime\";\nimport { AssistantRuntimeCore } from \"./runtime-cores/core/AssistantRuntimeCore\";\nimport { useAssistantClient } from \"../client/AssistantClient\";\nimport { ThreadListClient } from \"./client/ThreadListRuntimeClient\";\n\nexport namespace AssistantProvider {\n export type Props = PropsWithChildren<{\n /**\n * The runtime to provide to the rest of your app.\n */\n runtime: AssistantRuntime;\n }>;\n}\n\nconst getRenderComponent = (runtime: AssistantRuntime) => {\n return (runtime as { _core?: AssistantRuntimeCore })._core?.RenderComponent;\n};\n\nexport const AssistantRuntimeProviderImpl: FC<AssistantProvider.Props> = ({\n children,\n runtime,\n}) => {\n const api = useAssistantClient({\n threads: ThreadListClient({\n runtime: runtime.threads,\n }),\n registerModelContextProvider: runtime.registerModelContextProvider,\n __internal_runtime: runtime,\n });\n\n const RenderComponent = getRenderComponent(runtime);\n\n return (\n <AssistantProvider api={api}>\n {RenderComponent && <RenderComponent />}\n\n {children}\n </AssistantProvider>\n );\n};\n\nexport const AssistantRuntimeProvider = memo(AssistantRuntimeProviderImpl);\n"],"mappings":";;;AAEA,SAAa,YAA+B;AAC5C,SAAS,yBAAyB;AAGlC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AA8B7B,SACsB,KADtB;AAnBJ,IAAM,qBAAqB,CAAC,YAA8B;AACxD,SAAQ,QAA6C,OAAO;AAC9D;AAEO,IAAM,+BAA4D,CAAC;AAAA,EACxE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,MAAM,mBAAmB;AAAA,IAC7B,SAAS,iBAAiB;AAAA,MACxB,SAAS,QAAQ;AAAA,IACnB,CAAC;AAAA,IACD,8BAA8B,QAAQ;AAAA,IACtC,oBAAoB;AAAA,EACtB,CAAC;AAED,QAAM,kBAAkB,mBAAmB,OAAO;AAElD,SACE,qBAAC,qBAAkB,KAChB;AAAA,uBAAmB,oBAAC,mBAAgB;AAAA,IAEpC;AAAA,KACH;AAEJ;AAEO,IAAM,2BAA2B,KAAK,4BAA4B;","names":[]}
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import { AttachmentClientApi } from "../../client/types/Attachment";
|
2
2
|
import { AttachmentRuntime } from "../runtime";
|
3
3
|
export declare const AttachmentRuntimeClient: import("@assistant-ui/tap").ResourceElementConstructor<{
|
4
|
-
|
5
|
-
|
6
|
-
};
|
4
|
+
key: string | undefined;
|
5
|
+
state: any;
|
7
6
|
api: AttachmentClientApi;
|
8
|
-
key: string;
|
9
7
|
}, {
|
10
8
|
runtime: AttachmentRuntime;
|
11
9
|
}>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AttachmentRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/AttachmentRuntimeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,eAAO,MAAM,uBAAuB
|
1
|
+
{"version":3,"file":"AttachmentRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/AttachmentRuntimeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,eAAO,MAAM,uBAAuB;;;;;aACT,iBAAiB;EAa3C,CAAC"}
|
@@ -5,16 +5,16 @@ import { tapSubscribable } from "../util-hooks/tapSubscribable.js";
|
|
5
5
|
var AttachmentRuntimeClient = resource(
|
6
6
|
({ runtime }) => {
|
7
7
|
const state = tapSubscribable(runtime);
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
return tapApi(
|
9
|
+
{
|
10
|
+
getState: () => state,
|
11
|
+
remove: runtime.remove,
|
12
|
+
__internal_getRuntime: () => runtime
|
13
|
+
},
|
14
|
+
{
|
15
|
+
key: state.id
|
16
|
+
}
|
17
|
+
);
|
18
18
|
}
|
19
19
|
);
|
20
20
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/legacy-runtime/client/AttachmentRuntimeClient.ts"],"sourcesContent":["import { resource } from \"../../../../tap/dist/core/resource\";\nimport { AttachmentClientApi } from \"../../client/types/Attachment\";\nimport { tapApi } from \"../../utils/tap-store\";\nimport { AttachmentRuntime } from \"../runtime\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\n\nexport const AttachmentRuntimeClient = resource(\n ({ runtime }: { runtime: AttachmentRuntime }) => {\n const state = tapSubscribable(runtime);\n
|
1
|
+
{"version":3,"sources":["../../../src/legacy-runtime/client/AttachmentRuntimeClient.ts"],"sourcesContent":["import { resource } from \"../../../../tap/dist/core/resource\";\nimport { AttachmentClientApi } from \"../../client/types/Attachment\";\nimport { tapApi } from \"../../utils/tap-store\";\nimport { AttachmentRuntime } from \"../runtime\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\n\nexport const AttachmentRuntimeClient = resource(\n ({ runtime }: { runtime: AttachmentRuntime }) => {\n const state = tapSubscribable(runtime);\n return tapApi<AttachmentClientApi>(\n {\n getState: () => state,\n remove: runtime.remove,\n __internal_getRuntime: () => runtime,\n },\n {\n key: state.id,\n },\n );\n },\n);\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,cAAc;AAEvB,SAAS,uBAAuB;AAEzB,IAAM,0BAA0B;AAAA,EACrC,CAAC,EAAE,QAAQ,MAAsC;AAC/C,UAAM,QAAQ,gBAAgB,OAAO;AACrC,WAAO;AAAA,MACL;AAAA,QACE,UAAU,MAAM;AAAA,QAChB,QAAQ,QAAQ;AAAA,QAChB,uBAAuB,MAAM;AAAA,MAC/B;AAAA,MACA;AAAA,QACE,KAAK,MAAM;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { RefObject } from "@assistant-ui/tap";
|
2
2
|
import { ComposerRuntime } from "../runtime/ComposerRuntime";
|
3
|
-
import {
|
3
|
+
import { ComposerClientApi } from "../../client/types/Composer";
|
4
4
|
export declare const ComposerClient: import("@assistant-ui/tap").ResourceElementConstructor<{
|
5
|
-
|
5
|
+
key: string | undefined;
|
6
|
+
state: any;
|
6
7
|
api: ComposerClientApi;
|
7
8
|
}, {
|
8
9
|
threadIdRef: RefObject<string>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ComposerRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/ComposerRuntimeClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAEV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAMpC,OAAO,
|
1
|
+
{"version":3,"file":"ComposerRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/ComposerRuntimeClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAEV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAMpC,OAAO,EAEL,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAoBrC,eAAO,MAAM,cAAc;;;;;iBAMV,SAAS,CAAC,MAAM,CAAC;mBACf,SAAS,CAAC,MAAM,CAAC;aACvB,eAAe;EAkF3B,CAAC"}
|
@@ -71,7 +71,7 @@ var ComposerClient = resource(
|
|
71
71
|
type: runtimeState.type ?? "thread"
|
72
72
|
};
|
73
73
|
}, [runtimeState, attachments.state]);
|
74
|
-
|
74
|
+
return tapApi({
|
75
75
|
getState: () => state,
|
76
76
|
setText: runtime.setText,
|
77
77
|
setRole: runtime.setRole,
|
@@ -93,10 +93,6 @@ var ComposerClient = resource(
|
|
93
93
|
},
|
94
94
|
__internal_getRuntime: () => runtime
|
95
95
|
});
|
96
|
-
return {
|
97
|
-
state,
|
98
|
-
api
|
99
|
-
};
|
100
96
|
}
|
101
97
|
);
|
102
98
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/legacy-runtime/client/ComposerRuntimeClient.ts"],"sourcesContent":["import {\n resource,\n tapMemo,\n tapEffect,\n RefObject,\n tapInlineResource,\n} from \"@assistant-ui/tap\";\nimport {\n ComposerRuntime,\n EditComposerRuntime,\n} from \"../runtime/ComposerRuntime\";\nimport { Unsubscribe } from \"../../types\";\n\nimport { tapApi } from \"../../utils/tap-store\";\nimport { ComposerRuntimeEventType } from \"../runtime-cores/core/ComposerRuntimeCore\";\nimport { tapEvents } from \"../../client/EventContext\";\nimport {\n ComposerClientState,\n ComposerClientApi,\n} from \"../../client/types/Composer\";\nimport { tapLookupResources } from \"../../client/util-hooks/tapLookupResources\";\nimport { AttachmentRuntimeClient } from \"./AttachmentRuntimeClient\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\n\nconst ComposerAttachmentClientByIndex = resource(\n ({ runtime, index }: { runtime: ComposerRuntime; index: number }) => {\n const attachmentRuntime = tapMemo(\n () => runtime.getAttachmentByIndex(index),\n [runtime, index],\n );\n\n return tapInlineResource(\n AttachmentRuntimeClient({\n runtime: attachmentRuntime,\n }),\n );\n },\n);\n\nexport const ComposerClient = resource(\n ({\n threadIdRef,\n messageIdRef,\n runtime,\n }: {\n threadIdRef: RefObject<string>;\n messageIdRef?: RefObject<string>;\n runtime: ComposerRuntime;\n }) => {\n const runtimeState = tapSubscribable(runtime);\n const events = tapEvents();\n\n // Bind composer events to event manager\n tapEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n // Subscribe to composer events\n const composerEvents: ComposerRuntimeEventType[] = [\n \"send\",\n \"attachment-add\",\n ];\n\n for (const event of composerEvents) {\n const unsubscribe = runtime.unstable_on(event, () => {\n events.emit(`composer.${event}`, {\n threadId: threadIdRef.current,\n ...(messageIdRef && { messageId: messageIdRef.current }),\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, events, threadIdRef, messageIdRef]);\n\n const attachments = tapLookupResources(\n runtimeState.attachments.map((_, idx) =>\n ComposerAttachmentClientByIndex(\n { runtime: runtime, index: idx },\n { key: idx },\n ),\n ),\n );\n\n const state = tapMemo<ComposerClientState>(() => {\n return {\n text: runtimeState.text,\n role: runtimeState.role,\n attachments: attachments.state,\n runConfig: runtimeState.runConfig,\n isEditing: runtimeState.isEditing,\n canCancel: runtimeState.canCancel,\n attachmentAccept: runtimeState.attachmentAccept,\n isEmpty: runtimeState.isEmpty,\n type: runtimeState.type ?? \"thread\",\n };\n }, [runtimeState, attachments.state]);\n\n
|
1
|
+
{"version":3,"sources":["../../../src/legacy-runtime/client/ComposerRuntimeClient.ts"],"sourcesContent":["import {\n resource,\n tapMemo,\n tapEffect,\n RefObject,\n tapInlineResource,\n} from \"@assistant-ui/tap\";\nimport {\n ComposerRuntime,\n EditComposerRuntime,\n} from \"../runtime/ComposerRuntime\";\nimport { Unsubscribe } from \"../../types\";\n\nimport { tapApi } from \"../../utils/tap-store\";\nimport { ComposerRuntimeEventType } from \"../runtime-cores/core/ComposerRuntimeCore\";\nimport { tapEvents } from \"../../client/EventContext\";\nimport {\n ComposerClientState,\n ComposerClientApi,\n} from \"../../client/types/Composer\";\nimport { tapLookupResources } from \"../../client/util-hooks/tapLookupResources\";\nimport { AttachmentRuntimeClient } from \"./AttachmentRuntimeClient\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\n\nconst ComposerAttachmentClientByIndex = resource(\n ({ runtime, index }: { runtime: ComposerRuntime; index: number }) => {\n const attachmentRuntime = tapMemo(\n () => runtime.getAttachmentByIndex(index),\n [runtime, index],\n );\n\n return tapInlineResource(\n AttachmentRuntimeClient({\n runtime: attachmentRuntime,\n }),\n );\n },\n);\n\nexport const ComposerClient = resource(\n ({\n threadIdRef,\n messageIdRef,\n runtime,\n }: {\n threadIdRef: RefObject<string>;\n messageIdRef?: RefObject<string>;\n runtime: ComposerRuntime;\n }) => {\n const runtimeState = tapSubscribable(runtime);\n const events = tapEvents();\n\n // Bind composer events to event manager\n tapEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n // Subscribe to composer events\n const composerEvents: ComposerRuntimeEventType[] = [\n \"send\",\n \"attachment-add\",\n ];\n\n for (const event of composerEvents) {\n const unsubscribe = runtime.unstable_on(event, () => {\n events.emit(`composer.${event}`, {\n threadId: threadIdRef.current,\n ...(messageIdRef && { messageId: messageIdRef.current }),\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, events, threadIdRef, messageIdRef]);\n\n const attachments = tapLookupResources(\n runtimeState.attachments.map((_, idx) =>\n ComposerAttachmentClientByIndex(\n { runtime: runtime, index: idx },\n { key: idx },\n ),\n ),\n );\n\n const state = tapMemo<ComposerClientState>(() => {\n return {\n text: runtimeState.text,\n role: runtimeState.role,\n attachments: attachments.state,\n runConfig: runtimeState.runConfig,\n isEditing: runtimeState.isEditing,\n canCancel: runtimeState.canCancel,\n attachmentAccept: runtimeState.attachmentAccept,\n isEmpty: runtimeState.isEmpty,\n type: runtimeState.type ?? \"thread\",\n };\n }, [runtimeState, attachments.state]);\n\n return tapApi<ComposerClientApi>({\n getState: () => state,\n\n setText: runtime.setText,\n setRole: runtime.setRole,\n setRunConfig: runtime.setRunConfig,\n addAttachment: runtime.addAttachment,\n reset: runtime.reset,\n\n clearAttachments: runtime.clearAttachments,\n send: runtime.send,\n cancel: runtime.cancel,\n beginEdit:\n (runtime as EditComposerRuntime).beginEdit ??\n (() => {\n throw new Error(\"beginEdit is not supported in this runtime\");\n }),\n\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.api({ key: selector.id });\n } else {\n return attachments.api(selector);\n }\n },\n\n __internal_getRuntime: () => runtime,\n });\n },\n);\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAOP,SAAS,cAAc;AAEvB,SAAS,iBAAiB;AAK1B,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;AAEhC,IAAM,kCAAkC;AAAA,EACtC,CAAC,EAAE,SAAS,MAAM,MAAmD;AACnE,UAAM,oBAAoB;AAAA,MACxB,MAAM,QAAQ,qBAAqB,KAAK;AAAA,MACxC,CAAC,SAAS,KAAK;AAAA,IACjB;AAEA,WAAO;AAAA,MACL,wBAAwB;AAAA,QACtB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,IAAM,iBAAiB;AAAA,EAC5B,CAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,MAIM;AACJ,UAAM,eAAe,gBAAgB,OAAO;AAC5C,UAAM,SAAS,UAAU;AAGzB,cAAU,MAAM;AACd,YAAM,gBAA+B,CAAC;AAGtC,YAAM,iBAA6C;AAAA,QACjD;AAAA,QACA;AAAA,MACF;AAEA,iBAAW,SAAS,gBAAgB;AAClC,cAAM,cAAc,QAAQ,YAAY,OAAO,MAAM;AACnD,iBAAO,KAAK,YAAY,KAAK,IAAI;AAAA,YAC/B,UAAU,YAAY;AAAA,YACtB,GAAI,gBAAgB,EAAE,WAAW,aAAa,QAAQ;AAAA,UACxD,CAAC;AAAA,QACH,CAAC;AACD,sBAAc,KAAK,WAAW;AAAA,MAChC;AAEA,aAAO,MAAM;AACX,mBAAW,SAAS,cAAe,OAAM;AAAA,MAC3C;AAAA,IACF,GAAG,CAAC,SAAS,QAAQ,aAAa,YAAY,CAAC;AAE/C,UAAM,cAAc;AAAA,MAClB,aAAa,YAAY;AAAA,QAAI,CAAC,GAAG,QAC/B;AAAA,UACE,EAAE,SAAkB,OAAO,IAAI;AAAA,UAC/B,EAAE,KAAK,IAAI;AAAA,QACb;AAAA,MACF;AAAA,IACF;AAEA,UAAM,QAAQ,QAA6B,MAAM;AAC/C,aAAO;AAAA,QACL,MAAM,aAAa;AAAA,QACnB,MAAM,aAAa;AAAA,QACnB,aAAa,YAAY;AAAA,QACzB,WAAW,aAAa;AAAA,QACxB,WAAW,aAAa;AAAA,QACxB,WAAW,aAAa;AAAA,QACxB,kBAAkB,aAAa;AAAA,QAC/B,SAAS,aAAa;AAAA,QACtB,MAAM,aAAa,QAAQ;AAAA,MAC7B;AAAA,IACF,GAAG,CAAC,cAAc,YAAY,KAAK,CAAC;AAEpC,WAAO,OAA0B;AAAA,MAC/B,UAAU,MAAM;AAAA,MAEhB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,MACjB,cAAc,QAAQ;AAAA,MACtB,eAAe,QAAQ;AAAA,MACvB,OAAO,QAAQ;AAAA,MAEf,kBAAkB,QAAQ;AAAA,MAC1B,MAAM,QAAQ;AAAA,MACd,QAAQ,QAAQ;AAAA,MAChB,WACG,QAAgC,cAChC,MAAM;AACL,cAAM,IAAI,MAAM,4CAA4C;AAAA,MAC9D;AAAA,MAEF,YAAY,CAAC,aAAa;AACxB,YAAI,QAAQ,UAAU;AACpB,iBAAO,YAAY,IAAI,EAAE,KAAK,SAAS,GAAG,CAAC;AAAA,QAC7C,OAAO;AACL,iBAAO,YAAY,IAAI,QAAQ;AAAA,QACjC;AAAA,MACF;AAAA,MAEA,uBAAuB,MAAM;AAAA,IAC/B,CAAC;AAAA,EACH;AACF;","names":[]}
|
@@ -1,12 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
|
1
|
+
import { Unsubscribe } from "../../types/Unsubscribe";
|
2
|
+
import { AssistantEventMap, AssistantEvent, AssistantEventCallback } from "../../types/EventTypes";
|
3
3
|
export type EventManager = {
|
4
|
-
on<TEvent extends
|
5
|
-
emit<TEvent extends
|
4
|
+
on<TEvent extends AssistantEvent>(event: TEvent, callback: AssistantEventCallback<TEvent>): Unsubscribe;
|
5
|
+
emit<TEvent extends Exclude<AssistantEvent, "*">>(event: TEvent, payload: AssistantEventMap[TEvent]): void;
|
6
6
|
};
|
7
7
|
export declare const EventManager: import("@assistant-ui/tap").ResourceElementConstructor<{
|
8
|
-
on: <TEvent extends
|
9
|
-
emit: (event:
|
8
|
+
on: <TEvent extends AssistantEvent>(event: TEvent, callback: AssistantEventCallback<TEvent>) => () => void;
|
9
|
+
emit: <TEvent extends Exclude<AssistantEvent, "*">>(event: TEvent, payload: AssistantEventMap[TEvent]) => void;
|
10
10
|
}, undefined>;
|
11
|
-
export {};
|
12
11
|
//# sourceMappingURL=EventManagerRuntimeClient.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EventManagerRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/EventManagerRuntimeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"EventManagerRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/EventManagerRuntimeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,CAAC,MAAM,SAAS,cAAc,EAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,sBAAsB,CAAC,MAAM,CAAC,GACvC,WAAW,CAAC;IACf,IAAI,CAAC,MAAM,SAAS,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,EAC9C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC,GACjC,IAAI,CAAC;CACT,CAAC;AAeF,eAAO,MAAM,YAAY;SAvBpB,MAAM,SAAS,cAAc;WAI3B,MAAM,SAAS,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC;aAmEhD,CAAC"}
|
@@ -19,10 +19,18 @@ var EventManager = resource(() => {
|
|
19
19
|
},
|
20
20
|
emit: (event, payload) => {
|
21
21
|
const eventListeners = listeners.get(event);
|
22
|
-
|
22
|
+
const wildcardListeners = listeners.get("*");
|
23
|
+
if (!eventListeners && !wildcardListeners) return;
|
23
24
|
queueMicrotask(() => {
|
24
|
-
|
25
|
-
callback
|
25
|
+
if (eventListeners) {
|
26
|
+
for (const callback of eventListeners) {
|
27
|
+
callback(payload);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
if (wildcardListeners) {
|
31
|
+
for (const callback of wildcardListeners) {
|
32
|
+
callback({ event, payload });
|
33
|
+
}
|
26
34
|
}
|
27
35
|
});
|
28
36
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/legacy-runtime/client/EventManagerRuntimeClient.ts"],"sourcesContent":["import { resource, tapMemo } from \"@assistant-ui/tap\";\nimport {
|
1
|
+
{"version":3,"sources":["../../../src/legacy-runtime/client/EventManagerRuntimeClient.ts"],"sourcesContent":["import { resource, tapMemo } from \"@assistant-ui/tap\";\nimport { Unsubscribe } from \"../../types/Unsubscribe\";\nimport {\n AssistantEventMap,\n AssistantEvent,\n AssistantEventCallback,\n} from \"../../types/EventTypes\";\n\nexport type EventManager = {\n on<TEvent extends AssistantEvent>(\n event: TEvent,\n callback: AssistantEventCallback<TEvent>,\n ): Unsubscribe;\n emit<TEvent extends Exclude<AssistantEvent, \"*\">>(\n event: TEvent,\n payload: AssistantEventMap[TEvent],\n ): void;\n};\n\ntype ListenerMap = Omit<\n Map<AssistantEvent, Set<AssistantEventCallback<AssistantEvent>>>,\n \"get\" | \"set\"\n> & {\n get<TEvent extends AssistantEvent>(\n event: TEvent,\n ): Set<AssistantEventCallback<TEvent>> | undefined;\n set<TEvent extends AssistantEvent>(\n event: TEvent,\n value: Set<AssistantEventCallback<TEvent>>,\n ): void;\n};\n\nexport const EventManager = resource(() => {\n const events = tapMemo(() => {\n const listeners: ListenerMap = new Map();\n\n return {\n on: (event, callback) => {\n if (!listeners.has(event)) {\n listeners.set(event, new Set());\n }\n\n const eventListeners = listeners.get(event)!;\n eventListeners.add(callback);\n\n return () => {\n eventListeners.delete(callback);\n if (eventListeners.size === 0) {\n listeners.delete(event);\n }\n };\n },\n\n emit: (event, payload) => {\n const eventListeners = listeners.get(event);\n const wildcardListeners = listeners.get(\"*\");\n\n if (!eventListeners && !wildcardListeners) return;\n\n // make sure state updates flush\n queueMicrotask(() => {\n // Emit to specific event listeners\n if (eventListeners) {\n for (const callback of eventListeners) {\n callback(payload);\n }\n }\n\n // Emit to wildcard listeners\n if (wildcardListeners) {\n for (const callback of wildcardListeners) {\n callback({ event, payload });\n }\n }\n });\n },\n } satisfies EventManager;\n }, []);\n\n return events;\n});\n"],"mappings":";AAAA,SAAS,UAAU,eAAe;AAgC3B,IAAM,eAAe,SAAS,MAAM;AACzC,QAAM,SAAS,QAAQ,MAAM;AAC3B,UAAM,YAAyB,oBAAI,IAAI;AAEvC,WAAO;AAAA,MACL,IAAI,CAAC,OAAO,aAAa;AACvB,YAAI,CAAC,UAAU,IAAI,KAAK,GAAG;AACzB,oBAAU,IAAI,OAAO,oBAAI,IAAI,CAAC;AAAA,QAChC;AAEA,cAAM,iBAAiB,UAAU,IAAI,KAAK;AAC1C,uBAAe,IAAI,QAAQ;AAE3B,eAAO,MAAM;AACX,yBAAe,OAAO,QAAQ;AAC9B,cAAI,eAAe,SAAS,GAAG;AAC7B,sBAAU,OAAO,KAAK;AAAA,UACxB;AAAA,QACF;AAAA,MACF;AAAA,MAEA,MAAM,CAAC,OAAO,YAAY;AACxB,cAAM,iBAAiB,UAAU,IAAI,KAAK;AAC1C,cAAM,oBAAoB,UAAU,IAAI,GAAG;AAE3C,YAAI,CAAC,kBAAkB,CAAC,kBAAmB;AAG3C,uBAAe,MAAM;AAEnB,cAAI,gBAAgB;AAClB,uBAAW,YAAY,gBAAgB;AACrC,uBAAS,OAAO;AAAA,YAClB;AAAA,UACF;AAGA,cAAI,mBAAmB;AACrB,uBAAW,YAAY,mBAAmB;AACxC,uBAAS,EAAE,OAAO,QAAQ,CAAC;AAAA,YAC7B;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT,CAAC;","names":[]}
|
@@ -2,7 +2,7 @@ import { MessagePartRuntime } from "../runtime/MessagePartRuntime";
|
|
2
2
|
import { MessagePartClientApi } from "../../client/types/Part";
|
3
3
|
export declare const MessagePartClient: import("@assistant-ui/tap").ResourceElementConstructor<{
|
4
4
|
key: string | undefined;
|
5
|
-
state:
|
5
|
+
state: any;
|
6
6
|
api: MessagePartClientApi;
|
7
7
|
}, {
|
8
8
|
runtime: MessagePartRuntime;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MessagePartRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/MessagePartRuntimeClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,eAAO,MAAM,iBAAiB;;;;;aACH,kBAAkB;
|
1
|
+
{"version":3,"file":"MessagePartRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/MessagePartRuntimeClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,eAAO,MAAM,iBAAiB;;;;;aACH,kBAAkB;EAmB5C,CAAC"}
|
@@ -5,16 +5,16 @@ import { tapSubscribable } from "../util-hooks/tapSubscribable.js";
|
|
5
5
|
var MessagePartClient = resource(
|
6
6
|
({ runtime }) => {
|
7
7
|
const runtimeState = tapSubscribable(runtime);
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
return tapApi(
|
9
|
+
{
|
10
|
+
getState: () => runtimeState,
|
11
|
+
addToolResult: (result) => runtime.addToolResult(result),
|
12
|
+
__internal_getRuntime: () => runtime
|
13
|
+
},
|
14
|
+
{
|
15
|
+
key: runtimeState.type === "tool-call" ? "toolCallId-" + runtimeState.toolCallId : void 0
|
16
|
+
}
|
17
|
+
);
|
18
18
|
}
|
19
19
|
);
|
20
20
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/legacy-runtime/client/MessagePartRuntimeClient.ts"],"sourcesContent":["import { resource } from \"@assistant-ui/tap\";\nimport { tapApi } from \"../../utils/tap-store\";\nimport { MessagePartRuntime } from \"../runtime/MessagePartRuntime\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\nimport { MessagePartClientApi } from \"../../client/types/Part\";\nexport const MessagePartClient = resource(\n ({ runtime }: { runtime: MessagePartRuntime }) => {\n const runtimeState = tapSubscribable(runtime);\n\n
|
1
|
+
{"version":3,"sources":["../../../src/legacy-runtime/client/MessagePartRuntimeClient.ts"],"sourcesContent":["import { resource } from \"@assistant-ui/tap\";\nimport { tapApi } from \"../../utils/tap-store\";\nimport { MessagePartRuntime } from \"../runtime/MessagePartRuntime\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\nimport { MessagePartClientApi } from \"../../client/types/Part\";\nexport const MessagePartClient = resource(\n ({ runtime }: { runtime: MessagePartRuntime }) => {\n const runtimeState = tapSubscribable(runtime);\n\n return tapApi<MessagePartClientApi>(\n {\n getState: () => runtimeState,\n\n addToolResult: (result) => runtime.addToolResult(result),\n\n __internal_getRuntime: () => runtime,\n },\n {\n key:\n runtimeState.type === \"tool-call\"\n ? \"toolCallId-\" + runtimeState.toolCallId\n : undefined,\n },\n );\n },\n);\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAEvB,SAAS,uBAAuB;AAEzB,IAAM,oBAAoB;AAAA,EAC/B,CAAC,EAAE,QAAQ,MAAuC;AAChD,UAAM,eAAe,gBAAgB,OAAO;AAE5C,WAAO;AAAA,MACL;AAAA,QACE,UAAU,MAAM;AAAA,QAEhB,eAAe,CAAC,WAAW,QAAQ,cAAc,MAAM;AAAA,QAEvD,uBAAuB,MAAM;AAAA,MAC/B;AAAA,MACA;AAAA,QACE,KACE,aAAa,SAAS,cAClB,gBAAgB,aAAa,aAC7B;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { MessageRuntime } from "../runtime/MessageRuntime";
|
2
2
|
import { RefObject } from "react";
|
3
|
-
import {
|
3
|
+
import { MessageClientApi } from "../../client/types/Message";
|
4
4
|
export declare const MessageClient: import("@assistant-ui/tap").ResourceElementConstructor<{
|
5
|
-
key: string;
|
6
|
-
state:
|
5
|
+
key: string | undefined;
|
6
|
+
state: any;
|
7
7
|
api: MessageClientApi;
|
8
8
|
}, {
|
9
9
|
runtime: MessageRuntime;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MessageRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/MessageRuntimeClient.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAK3D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,
|
1
|
+
{"version":3,"file":"MessageRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/MessageRuntimeClient.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAK3D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAEL,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAyBpC,eAAO,MAAM,aAAa;;;;;aAKb,cAAc;iBACV,SAAS,CAAC,MAAM,CAAC;EA6FjC,CAAC"}
|
@@ -79,38 +79,38 @@ var MessageClient = resource(
|
|
79
79
|
isCopiedState,
|
80
80
|
isHoveringState
|
81
81
|
]);
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
82
|
+
return tapApi(
|
83
|
+
{
|
84
|
+
getState: () => state,
|
85
|
+
composer: composer.api,
|
86
|
+
reload: (config) => runtime.reload(config),
|
87
|
+
speak: () => runtime.speak(),
|
88
|
+
stopSpeaking: () => runtime.stopSpeaking(),
|
89
|
+
submitFeedback: (feedback) => runtime.submitFeedback(feedback),
|
90
|
+
switchToBranch: (options) => runtime.switchToBranch(options),
|
91
|
+
getCopyText: () => runtime.unstable_getCopyText(),
|
92
|
+
part: (selector) => {
|
93
|
+
if ("index" in selector) {
|
94
|
+
return parts.api({ index: selector.index });
|
95
|
+
} else {
|
96
|
+
return parts.api({ key: "toolCallId-" + selector.toolCallId });
|
97
|
+
}
|
98
|
+
},
|
99
|
+
attachment: (selector) => {
|
100
|
+
if ("id" in selector) {
|
101
|
+
return attachments.api({ key: selector.id });
|
102
|
+
} else {
|
103
|
+
return attachments.api(selector);
|
104
|
+
}
|
105
|
+
},
|
106
|
+
setIsCopied,
|
107
|
+
setIsHovering,
|
108
|
+
__internal_getRuntime: () => runtime
|
104
109
|
},
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
return {
|
110
|
-
key: runtimeState.id,
|
111
|
-
state,
|
112
|
-
api
|
113
|
-
};
|
110
|
+
{
|
111
|
+
key: runtimeState.id
|
112
|
+
}
|
113
|
+
);
|
114
114
|
}
|
115
115
|
);
|
116
116
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/legacy-runtime/client/MessageRuntimeClient.ts"],"sourcesContent":["import {\n resource,\n tapInlineResource,\n tapMemo,\n tapState,\n} from \"@assistant-ui/tap\";\nimport { tapApi } from \"../../utils/tap-store\";\nimport { MessageRuntime } from \"../runtime/MessageRuntime\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\nimport { ComposerClient } from \"./ComposerRuntimeClient\";\nimport { MessagePartClient } from \"./MessagePartRuntimeClient\";\nimport { tapLookupResources } from \"../../client/util-hooks/tapLookupResources\";\nimport { RefObject } from \"react\";\nimport {\n MessageClientState,\n MessageClientApi,\n} from \"../../client/types/Message\";\nimport { AttachmentRuntimeClient } from \"./AttachmentRuntimeClient\";\n\nconst MessageAttachmentClientByIndex = resource(\n ({ runtime, index }: { runtime: MessageRuntime; index: number }) => {\n const attachmentRuntime = tapMemo(\n () => runtime.getAttachmentByIndex(index),\n [runtime, index],\n );\n return tapInlineResource(\n AttachmentRuntimeClient({ runtime: attachmentRuntime }),\n );\n },\n);\n\nconst MessagePartByIndex = resource(\n ({ runtime, index }: { runtime: MessageRuntime; index: number }) => {\n const partRuntime = tapMemo(\n () => runtime.getMessagePartByIndex(index),\n [runtime, index],\n );\n return tapInlineResource(MessagePartClient({ runtime: partRuntime }));\n },\n);\n\nexport const MessageClient = resource(\n ({\n runtime,\n threadIdRef,\n }: {\n runtime: MessageRuntime;\n threadIdRef: RefObject<string>;\n }) => {\n const runtimeState = tapSubscribable(runtime);\n\n const [isCopiedState, setIsCopied] = tapState(false);\n const [isHoveringState, setIsHovering] = tapState(false);\n\n const messageIdRef = tapMemo(\n () => ({\n get current() {\n return runtime.getState().id;\n },\n }),\n [runtime],\n );\n\n const composer = tapInlineResource(\n ComposerClient({\n runtime: runtime.composer,\n threadIdRef,\n messageIdRef,\n }),\n );\n\n const parts = tapLookupResources(\n runtimeState.content.map((_, idx) =>\n MessagePartByIndex({ runtime, index: idx }, { key: idx }),\n ),\n );\n\n const attachments = tapLookupResources(\n runtimeState.attachments?.map((_, idx) =>\n MessageAttachmentClientByIndex({ runtime, index: idx }, { key: idx }),\n ) ?? [],\n );\n\n const state = tapMemo<MessageClientState>(() => {\n return {\n ...(runtimeState as MessageClientState),\n\n parts: parts.state,\n composer: composer.state,\n\n isCopied: isCopiedState,\n isHovering: isHoveringState,\n };\n }, [\n runtimeState,\n parts.state,\n composer.state,\n isCopiedState,\n isHoveringState,\n ]);\n\n
|
1
|
+
{"version":3,"sources":["../../../src/legacy-runtime/client/MessageRuntimeClient.ts"],"sourcesContent":["import {\n resource,\n tapInlineResource,\n tapMemo,\n tapState,\n} from \"@assistant-ui/tap\";\nimport { tapApi } from \"../../utils/tap-store\";\nimport { MessageRuntime } from \"../runtime/MessageRuntime\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\nimport { ComposerClient } from \"./ComposerRuntimeClient\";\nimport { MessagePartClient } from \"./MessagePartRuntimeClient\";\nimport { tapLookupResources } from \"../../client/util-hooks/tapLookupResources\";\nimport { RefObject } from \"react\";\nimport {\n MessageClientState,\n MessageClientApi,\n} from \"../../client/types/Message\";\nimport { AttachmentRuntimeClient } from \"./AttachmentRuntimeClient\";\n\nconst MessageAttachmentClientByIndex = resource(\n ({ runtime, index }: { runtime: MessageRuntime; index: number }) => {\n const attachmentRuntime = tapMemo(\n () => runtime.getAttachmentByIndex(index),\n [runtime, index],\n );\n return tapInlineResource(\n AttachmentRuntimeClient({ runtime: attachmentRuntime }),\n );\n },\n);\n\nconst MessagePartByIndex = resource(\n ({ runtime, index }: { runtime: MessageRuntime; index: number }) => {\n const partRuntime = tapMemo(\n () => runtime.getMessagePartByIndex(index),\n [runtime, index],\n );\n return tapInlineResource(MessagePartClient({ runtime: partRuntime }));\n },\n);\n\nexport const MessageClient = resource(\n ({\n runtime,\n threadIdRef,\n }: {\n runtime: MessageRuntime;\n threadIdRef: RefObject<string>;\n }) => {\n const runtimeState = tapSubscribable(runtime);\n\n const [isCopiedState, setIsCopied] = tapState(false);\n const [isHoveringState, setIsHovering] = tapState(false);\n\n const messageIdRef = tapMemo(\n () => ({\n get current() {\n return runtime.getState().id;\n },\n }),\n [runtime],\n );\n\n const composer = tapInlineResource(\n ComposerClient({\n runtime: runtime.composer,\n threadIdRef,\n messageIdRef,\n }),\n );\n\n const parts = tapLookupResources(\n runtimeState.content.map((_, idx) =>\n MessagePartByIndex({ runtime, index: idx }, { key: idx }),\n ),\n );\n\n const attachments = tapLookupResources(\n runtimeState.attachments?.map((_, idx) =>\n MessageAttachmentClientByIndex({ runtime, index: idx }, { key: idx }),\n ) ?? [],\n );\n\n const state = tapMemo<MessageClientState>(() => {\n return {\n ...(runtimeState as MessageClientState),\n\n parts: parts.state,\n composer: composer.state,\n\n isCopied: isCopiedState,\n isHovering: isHoveringState,\n };\n }, [\n runtimeState,\n parts.state,\n composer.state,\n isCopiedState,\n isHoveringState,\n ]);\n\n return tapApi<MessageClientApi>(\n {\n getState: () => state,\n\n composer: composer.api,\n\n reload: (config) => runtime.reload(config),\n speak: () => runtime.speak(),\n stopSpeaking: () => runtime.stopSpeaking(),\n submitFeedback: (feedback) => runtime.submitFeedback(feedback),\n switchToBranch: (options) => runtime.switchToBranch(options),\n getCopyText: () => runtime.unstable_getCopyText(),\n\n part: (selector) => {\n if (\"index\" in selector) {\n return parts.api({ index: selector.index });\n } else {\n return parts.api({ key: \"toolCallId-\" + selector.toolCallId });\n }\n },\n\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.api({ key: selector.id });\n } else {\n return attachments.api(selector);\n }\n },\n\n setIsCopied,\n setIsHovering,\n\n __internal_getRuntime: () => runtime,\n },\n {\n key: runtimeState.id,\n },\n );\n },\n);\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AAEvB,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AAMnC,SAAS,+BAA+B;AAExC,IAAM,iCAAiC;AAAA,EACrC,CAAC,EAAE,SAAS,MAAM,MAAkD;AAClE,UAAM,oBAAoB;AAAA,MACxB,MAAM,QAAQ,qBAAqB,KAAK;AAAA,MACxC,CAAC,SAAS,KAAK;AAAA,IACjB;AACA,WAAO;AAAA,MACL,wBAAwB,EAAE,SAAS,kBAAkB,CAAC;AAAA,IACxD;AAAA,EACF;AACF;AAEA,IAAM,qBAAqB;AAAA,EACzB,CAAC,EAAE,SAAS,MAAM,MAAkD;AAClE,UAAM,cAAc;AAAA,MAClB,MAAM,QAAQ,sBAAsB,KAAK;AAAA,MACzC,CAAC,SAAS,KAAK;AAAA,IACjB;AACA,WAAO,kBAAkB,kBAAkB,EAAE,SAAS,YAAY,CAAC,CAAC;AAAA,EACtE;AACF;AAEO,IAAM,gBAAgB;AAAA,EAC3B,CAAC;AAAA,IACC;AAAA,IACA;AAAA,EACF,MAGM;AACJ,UAAM,eAAe,gBAAgB,OAAO;AAE5C,UAAM,CAAC,eAAe,WAAW,IAAI,SAAS,KAAK;AACnD,UAAM,CAAC,iBAAiB,aAAa,IAAI,SAAS,KAAK;AAEvD,UAAM,eAAe;AAAA,MACnB,OAAO;AAAA,QACL,IAAI,UAAU;AACZ,iBAAO,QAAQ,SAAS,EAAE;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,CAAC,OAAO;AAAA,IACV;AAEA,UAAM,WAAW;AAAA,MACf,eAAe;AAAA,QACb,SAAS,QAAQ;AAAA,QACjB;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,UAAM,QAAQ;AAAA,MACZ,aAAa,QAAQ;AAAA,QAAI,CAAC,GAAG,QAC3B,mBAAmB,EAAE,SAAS,OAAO,IAAI,GAAG,EAAE,KAAK,IAAI,CAAC;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,cAAc;AAAA,MAClB,aAAa,aAAa;AAAA,QAAI,CAAC,GAAG,QAChC,+BAA+B,EAAE,SAAS,OAAO,IAAI,GAAG,EAAE,KAAK,IAAI,CAAC;AAAA,MACtE,KAAK,CAAC;AAAA,IACR;AAEA,UAAM,QAAQ,QAA4B,MAAM;AAC9C,aAAO;AAAA,QACL,GAAI;AAAA,QAEJ,OAAO,MAAM;AAAA,QACb,UAAU,SAAS;AAAA,QAEnB,UAAU;AAAA,QACV,YAAY;AAAA,MACd;AAAA,IACF,GAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MACN,SAAS;AAAA,MACT;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO;AAAA,MACL;AAAA,QACE,UAAU,MAAM;AAAA,QAEhB,UAAU,SAAS;AAAA,QAEnB,QAAQ,CAAC,WAAW,QAAQ,OAAO,MAAM;AAAA,QACzC,OAAO,MAAM,QAAQ,MAAM;AAAA,QAC3B,cAAc,MAAM,QAAQ,aAAa;AAAA,QACzC,gBAAgB,CAAC,aAAa,QAAQ,eAAe,QAAQ;AAAA,QAC7D,gBAAgB,CAAC,YAAY,QAAQ,eAAe,OAAO;AAAA,QAC3D,aAAa,MAAM,QAAQ,qBAAqB;AAAA,QAEhD,MAAM,CAAC,aAAa;AAClB,cAAI,WAAW,UAAU;AACvB,mBAAO,MAAM,IAAI,EAAE,OAAO,SAAS,MAAM,CAAC;AAAA,UAC5C,OAAO;AACL,mBAAO,MAAM,IAAI,EAAE,KAAK,gBAAgB,SAAS,WAAW,CAAC;AAAA,UAC/D;AAAA,QACF;AAAA,QAEA,YAAY,CAAC,aAAa;AACxB,cAAI,QAAQ,UAAU;AACpB,mBAAO,YAAY,IAAI,EAAE,KAAK,SAAS,GAAG,CAAC;AAAA,UAC7C,OAAO;AACL,mBAAO,YAAY,IAAI,QAAQ;AAAA,UACjC;AAAA,QACF;AAAA,QAEA;AAAA,QACA;AAAA,QAEA,uBAAuB,MAAM;AAAA,MAC/B;AAAA,MACA;AAAA,QACE,KAAK,aAAa;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { ThreadListItemRuntime } from "../runtime/ThreadListItemRuntime";
|
2
2
|
import { ThreadListItemClientApi } from "../../client/types/ThreadListItem";
|
3
3
|
export declare const ThreadListItemClient: import("@assistant-ui/tap").ResourceElementConstructor<{
|
4
|
-
|
4
|
+
key: string | undefined;
|
5
|
+
state: any;
|
5
6
|
api: ThreadListItemClientApi;
|
6
|
-
key: string;
|
7
7
|
}, {
|
8
8
|
runtime: ThreadListItemRuntime;
|
9
9
|
}>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ThreadListItemRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/ThreadListItemRuntimeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,eAAO,MAAM,oBAAoB;;;;;aACN,qBAAqB;
|
1
|
+
{"version":3,"file":"ThreadListItemRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/ThreadListItemRuntimeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,eAAO,MAAM,oBAAoB;;;;;aACN,qBAAqB;EA8C/C,CAAC"}
|
@@ -25,23 +25,23 @@ var ThreadListItemClient = resource(
|
|
25
25
|
for (const unsub of unsubscribers) unsub();
|
26
26
|
};
|
27
27
|
}, [runtime, events]);
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
return tapApi(
|
29
|
+
{
|
30
|
+
getState: () => runtimeState,
|
31
|
+
switchTo: runtime.switchTo,
|
32
|
+
rename: runtime.rename,
|
33
|
+
archive: runtime.archive,
|
34
|
+
unarchive: runtime.unarchive,
|
35
|
+
delete: runtime.delete,
|
36
|
+
generateTitle: runtime.generateTitle,
|
37
|
+
initialize: runtime.initialize,
|
38
|
+
detach: runtime.detach,
|
39
|
+
__internal_getRuntime: () => runtime
|
40
|
+
},
|
41
|
+
{
|
42
|
+
key: runtimeState.id
|
43
|
+
}
|
44
|
+
);
|
45
45
|
}
|
46
46
|
);
|
47
47
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/legacy-runtime/client/ThreadListItemRuntimeClient.ts"],"sourcesContent":["import { resource, tapEffect } from \"@assistant-ui/tap\";\nimport {\n ThreadListItemEventType,\n ThreadListItemRuntime,\n} from \"../runtime/ThreadListItemRuntime\";\nimport { Unsubscribe } from \"../../types\";\nimport { tapApi } from \"../../utils/tap-store\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\nimport { tapEvents } from \"../../client/EventContext\";\nimport { ThreadListItemClientApi } from \"../../client/types/ThreadListItem\";\n\nexport const ThreadListItemClient = resource(\n ({ runtime }: { runtime: ThreadListItemRuntime }) => {\n const runtimeState = tapSubscribable(runtime);\n const events = tapEvents();\n\n // Bind thread list item events to event manager\n tapEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n // Subscribe to thread list item events\n const threadListItemEvents: ThreadListItemEventType[] = [\n \"switched-to\",\n \"switched-away\",\n ];\n\n for (const event of threadListItemEvents) {\n const unsubscribe = runtime.unstable_on(event, () => {\n events.emit(`thread-list-item.${event}`, {\n threadId: runtime.getState()!.id,\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, events]);\n\n
|
1
|
+
{"version":3,"sources":["../../../src/legacy-runtime/client/ThreadListItemRuntimeClient.ts"],"sourcesContent":["import { resource, tapEffect } from \"@assistant-ui/tap\";\nimport {\n ThreadListItemEventType,\n ThreadListItemRuntime,\n} from \"../runtime/ThreadListItemRuntime\";\nimport { Unsubscribe } from \"../../types\";\nimport { tapApi } from \"../../utils/tap-store\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\nimport { tapEvents } from \"../../client/EventContext\";\nimport { ThreadListItemClientApi } from \"../../client/types/ThreadListItem\";\n\nexport const ThreadListItemClient = resource(\n ({ runtime }: { runtime: ThreadListItemRuntime }) => {\n const runtimeState = tapSubscribable(runtime);\n const events = tapEvents();\n\n // Bind thread list item events to event manager\n tapEffect(() => {\n const unsubscribers: Unsubscribe[] = [];\n\n // Subscribe to thread list item events\n const threadListItemEvents: ThreadListItemEventType[] = [\n \"switched-to\",\n \"switched-away\",\n ];\n\n for (const event of threadListItemEvents) {\n const unsubscribe = runtime.unstable_on(event, () => {\n events.emit(`thread-list-item.${event}`, {\n threadId: runtime.getState()!.id,\n });\n });\n unsubscribers.push(unsubscribe);\n }\n\n return () => {\n for (const unsub of unsubscribers) unsub();\n };\n }, [runtime, events]);\n\n return tapApi<ThreadListItemClientApi>(\n {\n getState: () => runtimeState,\n switchTo: runtime.switchTo,\n rename: runtime.rename,\n archive: runtime.archive,\n unarchive: runtime.unarchive,\n delete: runtime.delete,\n generateTitle: runtime.generateTitle,\n initialize: runtime.initialize,\n detach: runtime.detach,\n __internal_getRuntime: () => runtime,\n },\n {\n key: runtimeState.id,\n },\n );\n },\n);\n"],"mappings":";AAAA,SAAS,UAAU,iBAAiB;AAMpC,SAAS,cAAc;AACvB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAGnB,IAAM,uBAAuB;AAAA,EAClC,CAAC,EAAE,QAAQ,MAA0C;AACnD,UAAM,eAAe,gBAAgB,OAAO;AAC5C,UAAM,SAAS,UAAU;AAGzB,cAAU,MAAM;AACd,YAAM,gBAA+B,CAAC;AAGtC,YAAM,uBAAkD;AAAA,QACtD;AAAA,QACA;AAAA,MACF;AAEA,iBAAW,SAAS,sBAAsB;AACxC,cAAM,cAAc,QAAQ,YAAY,OAAO,MAAM;AACnD,iBAAO,KAAK,oBAAoB,KAAK,IAAI;AAAA,YACvC,UAAU,QAAQ,SAAS,EAAG;AAAA,UAChC,CAAC;AAAA,QACH,CAAC;AACD,sBAAc,KAAK,WAAW;AAAA,MAChC;AAEA,aAAO,MAAM;AACX,mBAAW,SAAS,cAAe,OAAM;AAAA,MAC3C;AAAA,IACF,GAAG,CAAC,SAAS,MAAM,CAAC;AAEpB,WAAO;AAAA,MACL;AAAA,QACE,UAAU,MAAM;AAAA,QAChB,UAAU,QAAQ;AAAA,QAClB,QAAQ,QAAQ;AAAA,QAChB,SAAS,QAAQ;AAAA,QACjB,WAAW,QAAQ;AAAA,QACnB,QAAQ,QAAQ;AAAA,QAChB,eAAe,QAAQ;AAAA,QACvB,YAAY,QAAQ;AAAA,QACpB,QAAQ,QAAQ;AAAA,QAChB,uBAAuB,MAAM;AAAA,MAC/B;AAAA,MACA;AAAA,QACE,KAAK,aAAa;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { ThreadListRuntime } from "../runtime/ThreadListRuntime";
|
2
|
-
import {
|
2
|
+
import { ThreadListClientApi } from "../../client/types/ThreadList";
|
3
3
|
export declare const ThreadListClient: import("@assistant-ui/tap").ResourceElementConstructor<{
|
4
|
-
|
4
|
+
key: string | undefined;
|
5
|
+
state: any;
|
5
6
|
api: ThreadListClientApi;
|
6
7
|
}, {
|
7
8
|
runtime: ThreadListRuntime;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ThreadListRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/ThreadListRuntimeClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKjE,OAAO,
|
1
|
+
{"version":3,"file":"ThreadListRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/ThreadListRuntimeClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKjE,OAAO,EAEL,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AAgBvC,eAAO,MAAM,gBAAgB;;;;;aACF,iBAAiB;EAyD3C,CAAC"}
|
@@ -34,7 +34,7 @@ var ThreadListClient = resource(
|
|
34
34
|
const state = tapMemo(() => {
|
35
35
|
return {
|
36
36
|
mainThreadId: runtimeState.mainThreadId,
|
37
|
-
newThreadId: runtimeState.newThread,
|
37
|
+
newThreadId: runtimeState.newThread ?? null,
|
38
38
|
isLoading: runtimeState.isLoading,
|
39
39
|
threadIds: runtimeState.threads,
|
40
40
|
archivedThreadIds: runtimeState.archivedThreads,
|
@@ -42,7 +42,7 @@ var ThreadListClient = resource(
|
|
42
42
|
main: main.state
|
43
43
|
};
|
44
44
|
}, [runtimeState, threadItems.state, main.state]);
|
45
|
-
|
45
|
+
return tapApi({
|
46
46
|
getState: () => state,
|
47
47
|
thread: () => main.api,
|
48
48
|
item: (threadIdOrOptions) => {
|
@@ -63,10 +63,6 @@ var ThreadListClient = resource(
|
|
63
63
|
runtime.switchToNewThread();
|
64
64
|
}
|
65
65
|
});
|
66
|
-
return {
|
67
|
-
state,
|
68
|
-
api
|
69
|
-
};
|
70
66
|
}
|
71
67
|
);
|
72
68
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/legacy-runtime/client/ThreadListRuntimeClient.ts"],"sourcesContent":["import { tapApi } from \"../../utils/tap-store\";\nimport { resource, tapInlineResource, tapMemo } from \"@assistant-ui/tap\";\nimport { ThreadListRuntime } from \"../runtime/ThreadListRuntime\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\nimport { ThreadListItemClient } from \"./ThreadListItemRuntimeClient\";\nimport { ThreadClient } from \"./ThreadRuntimeClient\";\nimport { tapLookupResources } from \"../../client/util-hooks/tapLookupResources\";\nimport {\n ThreadListClientState,\n ThreadListClientApi,\n} from \"../../client/types/ThreadList\";\n\nconst ThreadListItemClientById = resource(\n ({ runtime, id }: { runtime: ThreadListRuntime; id: string }) => {\n const threadListItemRuntime = tapMemo(\n () => runtime.getItemById(id),\n [runtime, id],\n );\n return tapInlineResource(\n ThreadListItemClient({\n runtime: threadListItemRuntime,\n }),\n );\n },\n);\n\nexport const ThreadListClient = resource(\n ({ runtime }: { runtime: ThreadListRuntime }) => {\n const runtimeState = tapSubscribable(runtime);\n\n const main = tapInlineResource(\n ThreadClient({\n runtime: runtime.main,\n }),\n );\n\n const threadItems = tapLookupResources(\n Object.keys(runtimeState.threadItems).map((id) =>\n ThreadListItemClientById({ runtime, id }, { key: id }),\n ),\n );\n\n const state = tapMemo<ThreadListClientState>(() => {\n return {\n mainThreadId: runtimeState.mainThreadId,\n newThreadId: runtimeState.newThread,\n isLoading: runtimeState.isLoading,\n threadIds: runtimeState.threads,\n archivedThreadIds: runtimeState.archivedThreads,\n threadItems: threadItems.state,\n\n main: main.state,\n };\n }, [runtimeState, threadItems.state, main.state]);\n\n
|
1
|
+
{"version":3,"sources":["../../../src/legacy-runtime/client/ThreadListRuntimeClient.ts"],"sourcesContent":["import { tapApi } from \"../../utils/tap-store\";\nimport { resource, tapInlineResource, tapMemo } from \"@assistant-ui/tap\";\nimport { ThreadListRuntime } from \"../runtime/ThreadListRuntime\";\nimport { tapSubscribable } from \"../util-hooks/tapSubscribable\";\nimport { ThreadListItemClient } from \"./ThreadListItemRuntimeClient\";\nimport { ThreadClient } from \"./ThreadRuntimeClient\";\nimport { tapLookupResources } from \"../../client/util-hooks/tapLookupResources\";\nimport {\n ThreadListClientState,\n ThreadListClientApi,\n} from \"../../client/types/ThreadList\";\n\nconst ThreadListItemClientById = resource(\n ({ runtime, id }: { runtime: ThreadListRuntime; id: string }) => {\n const threadListItemRuntime = tapMemo(\n () => runtime.getItemById(id),\n [runtime, id],\n );\n return tapInlineResource(\n ThreadListItemClient({\n runtime: threadListItemRuntime,\n }),\n );\n },\n);\n\nexport const ThreadListClient = resource(\n ({ runtime }: { runtime: ThreadListRuntime }) => {\n const runtimeState = tapSubscribable(runtime);\n\n const main = tapInlineResource(\n ThreadClient({\n runtime: runtime.main,\n }),\n );\n\n const threadItems = tapLookupResources(\n Object.keys(runtimeState.threadItems).map((id) =>\n ThreadListItemClientById({ runtime, id }, { key: id }),\n ),\n );\n\n const state = tapMemo<ThreadListClientState>(() => {\n return {\n mainThreadId: runtimeState.mainThreadId,\n newThreadId: runtimeState.newThread ?? null,\n isLoading: runtimeState.isLoading,\n threadIds: runtimeState.threads,\n archivedThreadIds: runtimeState.archivedThreads,\n threadItems: threadItems.state,\n\n main: main.state,\n };\n }, [runtimeState, threadItems.state, main.state]);\n\n return tapApi<ThreadListClientApi>({\n getState: () => state,\n\n thread: () => main.api,\n\n item: (threadIdOrOptions) => {\n if (threadIdOrOptions === \"main\") {\n return threadItems.api({ key: state.mainThreadId });\n }\n\n if (\"id\" in threadIdOrOptions) {\n return threadItems.api({ key: threadIdOrOptions.id });\n }\n\n const { index, archived = false } = threadIdOrOptions;\n const id = archived\n ? state.archivedThreadIds[index]!\n : state.threadIds[index]!;\n return threadItems.api({ key: id });\n },\n\n switchToThread: (threadId) => {\n runtime.switchToThread(threadId);\n },\n switchToNewThread: () => {\n runtime.switchToNewThread();\n },\n });\n },\n);\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,UAAU,mBAAmB,eAAe;AAErD,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AAMnC,IAAM,2BAA2B;AAAA,EAC/B,CAAC,EAAE,SAAS,GAAG,MAAkD;AAC/D,UAAM,wBAAwB;AAAA,MAC5B,MAAM,QAAQ,YAAY,EAAE;AAAA,MAC5B,CAAC,SAAS,EAAE;AAAA,IACd;AACA,WAAO;AAAA,MACL,qBAAqB;AAAA,QACnB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,IAAM,mBAAmB;AAAA,EAC9B,CAAC,EAAE,QAAQ,MAAsC;AAC/C,UAAM,eAAe,gBAAgB,OAAO;AAE5C,UAAM,OAAO;AAAA,MACX,aAAa;AAAA,QACX,SAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAEA,UAAM,cAAc;AAAA,MAClB,OAAO,KAAK,aAAa,WAAW,EAAE;AAAA,QAAI,CAAC,OACzC,yBAAyB,EAAE,SAAS,GAAG,GAAG,EAAE,KAAK,GAAG,CAAC;AAAA,MACvD;AAAA,IACF;AAEA,UAAM,QAAQ,QAA+B,MAAM;AACjD,aAAO;AAAA,QACL,cAAc,aAAa;AAAA,QAC3B,aAAa,aAAa,aAAa;AAAA,QACvC,WAAW,aAAa;AAAA,QACxB,WAAW,aAAa;AAAA,QACxB,mBAAmB,aAAa;AAAA,QAChC,aAAa,YAAY;AAAA,QAEzB,MAAM,KAAK;AAAA,MACb;AAAA,IACF,GAAG,CAAC,cAAc,YAAY,OAAO,KAAK,KAAK,CAAC;AAEhD,WAAO,OAA4B;AAAA,MACjC,UAAU,MAAM;AAAA,MAEhB,QAAQ,MAAM,KAAK;AAAA,MAEnB,MAAM,CAAC,sBAAsB;AAC3B,YAAI,sBAAsB,QAAQ;AAChC,iBAAO,YAAY,IAAI,EAAE,KAAK,MAAM,aAAa,CAAC;AAAA,QACpD;AAEA,YAAI,QAAQ,mBAAmB;AAC7B,iBAAO,YAAY,IAAI,EAAE,KAAK,kBAAkB,GAAG,CAAC;AAAA,QACtD;AAEA,cAAM,EAAE,OAAO,WAAW,MAAM,IAAI;AACpC,cAAM,KAAK,WACP,MAAM,kBAAkB,KAAK,IAC7B,MAAM,UAAU,KAAK;AACzB,eAAO,YAAY,IAAI,EAAE,KAAK,GAAG,CAAC;AAAA,MACpC;AAAA,MAEA,gBAAgB,CAAC,aAAa;AAC5B,gBAAQ,eAAe,QAAQ;AAAA,MACjC;AAAA,MACA,mBAAmB,MAAM;AACvB,gBAAQ,kBAAkB;AAAA,MAC5B;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { ThreadRuntime } from "../runtime/ThreadRuntime";
|
2
|
-
import {
|
2
|
+
import { ThreadClientApi } from "../../client/types/Thread";
|
3
3
|
export declare const ThreadClient: import("@assistant-ui/tap").ResourceElementConstructor<{
|
4
|
-
|
4
|
+
key: string | undefined;
|
5
|
+
state: any;
|
5
6
|
api: ThreadClientApi;
|
6
7
|
}, {
|
7
8
|
runtime: ThreadRuntime;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ThreadRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/ThreadRuntimeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAezD,OAAO,
|
1
|
+
{"version":3,"file":"ThreadRuntimeClient.d.ts","sourceRoot":"","sources":["../../../src/legacy-runtime/client/ThreadRuntimeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAezD,OAAO,EAAqB,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAuB/E,eAAO,MAAM,YAAY;;;;;aACE,aAAa;EAmGvC,CAAC"}
|