@assistant-ui/react 0.14.12 → 0.14.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/client/InMemoryThreadList.js +13 -3
- package/dist/client/InMemoryThreadList.js.map +1 -1
- package/dist/client/SingleThreadList.d.ts.map +1 -1
- package/dist/client/SingleThreadList.js +5 -2
- package/dist/client/SingleThreadList.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts +14 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts.map +1 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js +101 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js.map +1 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +12 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/unstable/useMentionAdapter.d.ts +2 -2
- package/dist/unstable/useMentionAdapter.js +1 -1
- package/dist/unstable/useMentionAdapter.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.d.ts +2 -2
- package/dist/utils/useToolArgsFieldStatus.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/client/InMemoryThreadList.ts +23 -2
- package/src/client/SingleThreadList.ts +5 -1
- package/src/index.ts +12 -2
- package/src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.test.ts +426 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts +146 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts +16 -1
- package/src/unstable/useMentionAdapter.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryThreadList.d.ts","names":[],"sources":["../../src/client/InMemoryThreadList.ts"],"mappings":";;;;KAgBY,uBAAA;EACV,MAAA,GAAS,QAAA,aAAqB,eAAe,CAAC,YAAA;EAC9C,gBAAA,IAAoB,QAAA;EACpB,mBAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"InMemoryThreadList.d.ts","names":[],"sources":["../../src/client/InMemoryThreadList.ts"],"mappings":";;;;KAgBY,uBAAA;EACV,MAAA,GAAS,QAAA,aAAqB,eAAe,CAAC,YAAA;EAC9C,gBAAA,IAAoB,QAAA;EACpB,mBAAA;AAAA;AAAA,cAwDW,kBAAA,GAAkB,KAAA,EAAA,uBAAA,KAAA,eAAA,CAAA,YAAA,aAAA,uBAAA"}
|
|
@@ -5,22 +5,25 @@ import { resource, tapMemo, tapState, withKey } from "@assistant-ui/tap";
|
|
|
5
5
|
//#region src/client/InMemoryThreadList.ts
|
|
6
6
|
const RESOLVED_PROMISE = Promise.resolve();
|
|
7
7
|
const ThreadListItemClient = resource((props) => {
|
|
8
|
-
const { data, onSwitchTo, onArchive, onUnarchive, onDelete } = props;
|
|
8
|
+
const { data, onSwitchTo, onUpdateCustom, onArchive, onUnarchive, onDelete } = props;
|
|
9
9
|
const state = tapMemo(() => ({
|
|
10
10
|
id: data.id,
|
|
11
11
|
remoteId: void 0,
|
|
12
12
|
externalId: void 0,
|
|
13
13
|
title: data.title,
|
|
14
|
-
status: data.status
|
|
14
|
+
status: data.status,
|
|
15
|
+
custom: data.custom
|
|
15
16
|
}), [
|
|
16
17
|
data.id,
|
|
17
18
|
data.title,
|
|
18
|
-
data.status
|
|
19
|
+
data.status,
|
|
20
|
+
data.custom
|
|
19
21
|
]);
|
|
20
22
|
return {
|
|
21
23
|
getState: () => state,
|
|
22
24
|
switchTo: onSwitchTo,
|
|
23
25
|
rename: () => {},
|
|
26
|
+
updateCustom: onUpdateCustom,
|
|
24
27
|
archive: onArchive,
|
|
25
28
|
unarchive: onUnarchive,
|
|
26
29
|
delete: onDelete,
|
|
@@ -56,6 +59,12 @@ const InMemoryThreadList = resource((props) => {
|
|
|
56
59
|
status: "regular"
|
|
57
60
|
} : t));
|
|
58
61
|
};
|
|
62
|
+
const handleUpdateCustom = (threadId, custom) => {
|
|
63
|
+
setThreads((prev) => prev.map((t) => t.id === threadId ? {
|
|
64
|
+
...t,
|
|
65
|
+
custom
|
|
66
|
+
} : t));
|
|
67
|
+
};
|
|
59
68
|
const handleDelete = (threadId) => {
|
|
60
69
|
setThreads((prev) => prev.filter((t) => t.id !== threadId));
|
|
61
70
|
if (mainThreadId === threadId) setMainThreadId(threads.filter((t) => t.id !== threadId)[0]?.id || "main");
|
|
@@ -73,6 +82,7 @@ const InMemoryThreadList = resource((props) => {
|
|
|
73
82
|
const threadListItems = tapClientLookup(() => threads.map((t) => withKey(t.id, ThreadListItemClient({
|
|
74
83
|
data: t,
|
|
75
84
|
onSwitchTo: () => handleSwitchToThread(t.id),
|
|
85
|
+
onUpdateCustom: (custom) => handleUpdateCustom(t.id, custom),
|
|
76
86
|
onArchive: () => handleArchive(t.id),
|
|
77
87
|
onUnarchive: () => handleUnarchive(t.id),
|
|
78
88
|
onDelete: () => handleDelete(t.id)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryThreadList.js","names":[],"sources":["../../src/client/InMemoryThreadList.ts"],"sourcesContent":["import { resource, tapState, tapMemo } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n tapClientLookup,\n Derived,\n attachTransformScopes,\n tapClientResource,\n} from \"@assistant-ui/store\";\nimport { withKey } from \"@assistant-ui/tap\";\nimport type { ResourceElement } from \"@assistant-ui/tap\";\n\nimport { ModelContext, Suggestions } from \"@assistant-ui/core/store\";\nimport { Tools, DataRenderers } from \"@assistant-ui/core/react\";\n\nconst RESOLVED_PROMISE = Promise.resolve();\n\nexport type InMemoryThreadListProps = {\n thread: (threadId: string) => ResourceElement<ClientOutput<\"thread\">>;\n onSwitchToThread?: (threadId: string) => void;\n onSwitchToNewThread?: () => void;\n};\n\ntype ThreadData = {\n id: string;\n title?: string;\n status: \"regular\" | \"archived\";\n};\n\n// ThreadListItem Client\nconst ThreadListItemClient = resource(\n (props: {\n data: ThreadData;\n onSwitchTo: () => void;\n onArchive: () => void;\n onUnarchive: () => void;\n onDelete: () => void;\n }): ClientOutput<\"threadListItem\"> => {\n const { data, onSwitchTo, onArchive, onUnarchive, onDelete } = props;\n const state = tapMemo(\n () => ({\n id: data.id,\n remoteId: undefined,\n externalId: undefined,\n title: data.title,\n status: data.status,\n }),\n [data.id, data.title, data.status],\n );\n\n return {\n getState: () => state,\n switchTo: onSwitchTo,\n rename: () => {},\n archive: onArchive,\n unarchive: onUnarchive,\n delete: onDelete,\n generateTitle: () => {},\n initialize: async () => ({ remoteId: data.id, externalId: undefined }),\n detach: () => {},\n };\n },\n);\n\n// InMemoryThreadList Client\nexport const InMemoryThreadList = resource(\n (props: InMemoryThreadListProps): ClientOutput<\"threads\"> => {\n const {\n thread: threadFactory,\n onSwitchToThread,\n onSwitchToNewThread,\n } = props;\n\n const [mainThreadId, setMainThreadId] = tapState(\"main\");\n const [threads, setThreads] = tapState<readonly ThreadData[]>(() => [\n { id: \"main\", title: \"Main Thread\", status: \"regular\" },\n ]);\n\n const handleSwitchToThread = (threadId: string) => {\n setMainThreadId(threadId);\n onSwitchToThread?.(threadId);\n };\n\n const handleArchive = (threadId: string) => {\n setThreads((prev) =>\n prev.map((t) =>\n t.id === threadId ? { ...t, status: \"archived\" as const } : t,\n ),\n );\n };\n\n const handleUnarchive = (threadId: string) => {\n setThreads((prev) =>\n prev.map((t) =>\n t.id === threadId ? { ...t, status: \"regular\" as const } : t,\n ),\n );\n };\n\n const handleDelete = (threadId: string) => {\n setThreads((prev) => prev.filter((t) => t.id !== threadId));\n if (mainThreadId === threadId) {\n const remaining = threads.filter((t) => t.id !== threadId);\n setMainThreadId(remaining[0]?.id || \"main\");\n }\n };\n\n const handleSwitchToNewThread = () => {\n const newId = `thread-${Date.now()}`;\n setThreads((prev) => [\n ...prev,\n { id: newId, title: \"New Thread\", status: \"regular\" },\n ]);\n setMainThreadId(newId);\n onSwitchToNewThread?.();\n };\n\n const threadListItems = tapClientLookup(\n () =>\n threads.map((t) =>\n withKey(\n t.id,\n ThreadListItemClient({\n data: t,\n onSwitchTo: () => handleSwitchToThread(t.id),\n onArchive: () => handleArchive(t.id),\n onUnarchive: () => handleUnarchive(t.id),\n onDelete: () => handleDelete(t.id),\n }),\n ),\n ),\n [threads],\n );\n\n // Create the main thread\n const mainThreadClient = tapClientResource(threadFactory(mainThreadId));\n\n const state = tapMemo(() => {\n const regularThreads = threads.filter((t) => t.status === \"regular\");\n const archivedThreads = threads.filter((t) => t.status === \"archived\");\n\n return {\n mainThreadId,\n newThreadId: null,\n isLoading: false,\n isLoadingMore: false,\n hasMore: false,\n threadIds: regularThreads.map((t) => t.id),\n archivedThreadIds: archivedThreads.map((t) => t.id),\n threadItems: threadListItems.state,\n main: mainThreadClient.state,\n };\n }, [mainThreadId, threads, threadListItems.state, mainThreadClient.state]);\n\n return {\n getState: () => state,\n switchToThread: handleSwitchToThread,\n switchToNewThread: handleSwitchToNewThread,\n getLoadThreadsPromise: () => RESOLVED_PROMISE,\n reload: () => RESOLVED_PROMISE,\n loadMore: () => RESOLVED_PROMISE,\n item: (selector) => {\n if (selector === \"main\") {\n const index = threads.findIndex((t) => t.id === mainThreadId);\n return threadListItems.get({ index: index === -1 ? 0 : index });\n }\n if (\"id\" in selector) {\n const index = threads.findIndex((t) => t.id === selector.id);\n return threadListItems.get({ index });\n }\n return threadListItems.get(selector);\n },\n thread: () => mainThreadClient.methods,\n };\n },\n);\n\nattachTransformScopes(InMemoryThreadList, (scopes, parent) => {\n scopes.thread ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().thread(\"main\"),\n });\n scopes.threadListItem ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().item(\"main\"),\n });\n scopes.composer ??= Derived({\n source: \"thread\",\n query: {},\n get: (aui) => aui.threads().thread(\"main\").composer(),\n });\n\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n if (!scopes.tools && parent.tools.source === null) {\n scopes.tools = Tools({});\n }\n if (!scopes.dataRenderers && parent.dataRenderers.source === null) {\n scopes.dataRenderers = DataRenderers();\n }\n if (!scopes.suggestions && parent.suggestions.source === null) {\n scopes.suggestions = Suggestions();\n }\n});\n"],"mappings":";;;;;AAcA,MAAM,mBAAmB,QAAQ,QAAQ;AAezC,MAAM,uBAAuB,UAC1B,UAMqC;CACpC,MAAM,EAAE,MAAM,YAAY,WAAW,aAAa,aAAa;CAC/D,MAAM,QAAQ,eACL;EACL,IAAI,KAAK;EACT,UAAU,KAAA;EACV,YAAY,KAAA;EACZ,OAAO,KAAK;EACZ,QAAQ,KAAK;CACf,IACA;EAAC,KAAK;EAAI,KAAK;EAAO,KAAK;CAAM,CACnC;CAEA,OAAO;EACL,gBAAgB;EAChB,UAAU;EACV,cAAc,CAAC;EACf,SAAS;EACT,WAAW;EACX,QAAQ;EACR,qBAAqB,CAAC;EACtB,YAAY,aAAa;GAAE,UAAU,KAAK;GAAI,YAAY,KAAA;EAAU;EACpE,cAAc,CAAC;CACjB;AACF,CACF;AAGA,MAAa,qBAAqB,UAC/B,UAA4D;CAC3D,MAAM,EACJ,QAAQ,eACR,kBACA,wBACE;CAEJ,MAAM,CAAC,cAAc,mBAAmB,SAAS,MAAM;CACvD,MAAM,CAAC,SAAS,cAAc,eAAsC,CAClE;EAAE,IAAI;EAAQ,OAAO;EAAe,QAAQ;CAAU,CACxD,CAAC;CAED,MAAM,wBAAwB,aAAqB;EACjD,gBAAgB,QAAQ;EACxB,mBAAmB,QAAQ;CAC7B;CAEA,MAAM,iBAAiB,aAAqB;EAC1C,YAAY,SACV,KAAK,KAAK,MACR,EAAE,OAAO,WAAW;GAAE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e,OAAO,YAAY,WAAW,MACvD,OAAO,cAAc,YAAY;AAErC,CAAC"}
|
|
1
|
+
{"version":3,"file":"InMemoryThreadList.js","names":[],"sources":["../../src/client/InMemoryThreadList.ts"],"sourcesContent":["import { resource, tapState, tapMemo } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n tapClientLookup,\n Derived,\n attachTransformScopes,\n tapClientResource,\n} from \"@assistant-ui/store\";\nimport { withKey } from \"@assistant-ui/tap\";\nimport type { ResourceElement } from \"@assistant-ui/tap\";\n\nimport { ModelContext, Suggestions } from \"@assistant-ui/core/store\";\nimport { Tools, DataRenderers } from \"@assistant-ui/core/react\";\n\nconst RESOLVED_PROMISE = Promise.resolve();\n\nexport type InMemoryThreadListProps = {\n thread: (threadId: string) => ResourceElement<ClientOutput<\"thread\">>;\n onSwitchToThread?: (threadId: string) => void;\n onSwitchToNewThread?: () => void;\n};\n\ntype ThreadData = {\n id: string;\n title?: string;\n status: \"regular\" | \"archived\";\n custom?: Record<string, unknown> | undefined;\n};\n\n// ThreadListItem Client\nconst ThreadListItemClient = resource(\n (props: {\n data: ThreadData;\n onSwitchTo: () => void;\n onUpdateCustom: (custom: Record<string, unknown> | undefined) => void;\n onArchive: () => void;\n onUnarchive: () => void;\n onDelete: () => void;\n }): ClientOutput<\"threadListItem\"> => {\n const {\n data,\n onSwitchTo,\n onUpdateCustom,\n onArchive,\n onUnarchive,\n onDelete,\n } = props;\n const state = tapMemo(\n () => ({\n id: data.id,\n remoteId: undefined,\n externalId: undefined,\n title: data.title,\n status: data.status,\n custom: data.custom,\n }),\n [data.id, data.title, data.status, data.custom],\n );\n\n return {\n getState: () => state,\n switchTo: onSwitchTo,\n rename: () => {},\n updateCustom: onUpdateCustom,\n archive: onArchive,\n unarchive: onUnarchive,\n delete: onDelete,\n generateTitle: () => {},\n initialize: async () => ({ remoteId: data.id, externalId: undefined }),\n detach: () => {},\n };\n },\n);\n\n// InMemoryThreadList Client\nexport const InMemoryThreadList = resource(\n (props: InMemoryThreadListProps): ClientOutput<\"threads\"> => {\n const {\n thread: threadFactory,\n onSwitchToThread,\n onSwitchToNewThread,\n } = props;\n\n const [mainThreadId, setMainThreadId] = tapState(\"main\");\n const [threads, setThreads] = tapState<readonly ThreadData[]>(() => [\n { id: \"main\", title: \"Main Thread\", status: \"regular\" },\n ]);\n\n const handleSwitchToThread = (threadId: string) => {\n setMainThreadId(threadId);\n onSwitchToThread?.(threadId);\n };\n\n const handleArchive = (threadId: string) => {\n setThreads((prev) =>\n prev.map((t) =>\n t.id === threadId ? { ...t, status: \"archived\" as const } : t,\n ),\n );\n };\n\n const handleUnarchive = (threadId: string) => {\n setThreads((prev) =>\n prev.map((t) =>\n t.id === threadId ? { ...t, status: \"regular\" as const } : t,\n ),\n );\n };\n\n const handleUpdateCustom = (\n threadId: string,\n custom: Record<string, unknown> | undefined,\n ) => {\n setThreads((prev) =>\n prev.map((t) => (t.id === threadId ? { ...t, custom } : t)),\n );\n };\n\n const handleDelete = (threadId: string) => {\n setThreads((prev) => prev.filter((t) => t.id !== threadId));\n if (mainThreadId === threadId) {\n const remaining = threads.filter((t) => t.id !== threadId);\n setMainThreadId(remaining[0]?.id || \"main\");\n }\n };\n\n const handleSwitchToNewThread = () => {\n const newId = `thread-${Date.now()}`;\n setThreads((prev) => [\n ...prev,\n { id: newId, title: \"New Thread\", status: \"regular\" },\n ]);\n setMainThreadId(newId);\n onSwitchToNewThread?.();\n };\n\n const threadListItems = tapClientLookup(\n () =>\n threads.map((t) =>\n withKey(\n t.id,\n ThreadListItemClient({\n data: t,\n onSwitchTo: () => handleSwitchToThread(t.id),\n onUpdateCustom: (custom) => handleUpdateCustom(t.id, custom),\n onArchive: () => handleArchive(t.id),\n onUnarchive: () => handleUnarchive(t.id),\n onDelete: () => handleDelete(t.id),\n }),\n ),\n ),\n [threads],\n );\n\n // Create the main thread\n const mainThreadClient = tapClientResource(threadFactory(mainThreadId));\n\n const state = tapMemo(() => {\n const regularThreads = threads.filter((t) => t.status === \"regular\");\n const archivedThreads = threads.filter((t) => t.status === \"archived\");\n\n return {\n mainThreadId,\n newThreadId: null,\n isLoading: false,\n isLoadingMore: false,\n hasMore: false,\n threadIds: regularThreads.map((t) => t.id),\n archivedThreadIds: archivedThreads.map((t) => t.id),\n threadItems: threadListItems.state,\n main: mainThreadClient.state,\n };\n }, [mainThreadId, threads, threadListItems.state, mainThreadClient.state]);\n\n return {\n getState: () => state,\n switchToThread: handleSwitchToThread,\n switchToNewThread: handleSwitchToNewThread,\n getLoadThreadsPromise: () => RESOLVED_PROMISE,\n reload: () => RESOLVED_PROMISE,\n loadMore: () => RESOLVED_PROMISE,\n item: (selector) => {\n if (selector === \"main\") {\n const index = threads.findIndex((t) => t.id === mainThreadId);\n return threadListItems.get({ index: index === -1 ? 0 : index });\n }\n if (\"id\" in selector) {\n const index = threads.findIndex((t) => t.id === selector.id);\n return threadListItems.get({ index });\n }\n return threadListItems.get(selector);\n },\n thread: () => mainThreadClient.methods,\n };\n },\n);\n\nattachTransformScopes(InMemoryThreadList, (scopes, parent) => {\n scopes.thread ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().thread(\"main\"),\n });\n scopes.threadListItem ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().item(\"main\"),\n });\n scopes.composer ??= Derived({\n source: \"thread\",\n query: {},\n get: (aui) => aui.threads().thread(\"main\").composer(),\n });\n\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n if (!scopes.tools && parent.tools.source === null) {\n scopes.tools = Tools({});\n }\n if (!scopes.dataRenderers && parent.dataRenderers.source === null) {\n scopes.dataRenderers = DataRenderers();\n }\n if (!scopes.suggestions && parent.suggestions.source === null) {\n scopes.suggestions = Suggestions();\n }\n});\n"],"mappings":";;;;;AAcA,MAAM,mBAAmB,QAAQ,QAAQ;AAgBzC,MAAM,uBAAuB,UAC1B,UAOqC;CACpC,MAAM,EACJ,MACA,Y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AE,OAAO,YAAY;IAC5D,OAAO,gBAAgB,IAAI,EAAE,OAAO,UAAU,KAAK,IAAI,MAAM,CAAC;GAChE;GACA,IAAI,QAAQ,UAAU;IACpB,MAAM,QAAQ,QAAQ,WAAW,MAAM,EAAE,OAAO,SAAS,EAAE;IAC3D,OAAO,gBAAgB,IAAI,EAAE,MAAM,CAAC;GACtC;GACA,OAAO,gBAAgB,IAAI,QAAQ;EACrC;EACA,cAAc,iBAAiB;CACjC;AACF,CACF;AAEA,sBAAsB,qBAAqB,QAAQ,WAAW;CAC5D,OAAO,WAAW,QAAQ;EACxB,QAAQ;EACR,OAAO,EAAE,MAAM,OAAO;EACtB,MAAM,QAAQ,IAAI,QAAQ,EAAE,OAAO,MAAM;CAC3C,CAAC;CACD,OAAO,mBAAmB,QAAQ;EAChC,QAAQ;EACR,OAAO,EAAE,MAAM,OAAO;EACtB,MAAM,QAAQ,IAAI,QAAQ,EAAE,KAAK,MAAM;CACzC,CAAC;CACD,OAAO,aAAa,QAAQ;EAC1B,QAAQ;EACR,OAAO,CAAC;EACR,MAAM,QAAQ,IAAI,QAAQ,EAAE,OAAO,MAAM,EAAE,SAAS;CACtD,CAAC;CAED,IAAI,CAAC,OAAO,gBAAgB,OAAO,aAAa,WAAW,MACzD,OAAO,eAAe,aAAa;CAErC,IAAI,CAAC,OAAO,SAAS,OAAO,MAAM,WAAW,MAC3C,OAAO,QAAQ,MAAM,CAAC,CAAC;CAEzB,IAAI,CAAC,OAAO,iBAAiB,OAAO,cAAc,WAAW,MAC3D,OAAO,gBAAgB,cAAc;CAEvC,IAAI,CAAC,OAAO,eAAe,OAAO,YAAY,WAAW,MACvD,OAAO,cAAc,YAAY;AAErC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleThreadList.d.ts","names":[],"sources":["../../src/client/SingleThreadList.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SingleThreadList.d.ts","names":[],"sources":["../../src/client/SingleThreadList.ts"],"mappings":";;;KAkCK,qBAAA;EACH,MAAA,EAAQ,aAAa;AAAA;;;;AAAA;AAQvB;cAAa,gBAAA,GAAgB,KAAA,EAAA,qBAAA,iCAAA,eAAA,CAAA,YAAA,aAAA,qBAAA"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { tapClientResource } from "@assistant-ui/store";
|
|
2
|
-
import { resource, tapMemo } from "@assistant-ui/tap";
|
|
2
|
+
import { resource, tapMemo, tapState } from "@assistant-ui/tap";
|
|
3
3
|
//#region src/client/SingleThreadList.ts
|
|
4
4
|
const RESOLVED_PROMISE = Promise.resolve();
|
|
5
5
|
const THREAD_ID = "default";
|
|
6
6
|
const SingleThreadListItem = resource(() => {
|
|
7
|
+
const [custom, setCustom] = tapState();
|
|
7
8
|
return {
|
|
8
9
|
getState: () => ({
|
|
9
10
|
id: THREAD_ID,
|
|
10
11
|
remoteId: void 0,
|
|
11
12
|
externalId: void 0,
|
|
12
13
|
title: void 0,
|
|
13
|
-
status: "regular"
|
|
14
|
+
status: "regular",
|
|
15
|
+
custom
|
|
14
16
|
}),
|
|
15
17
|
switchTo: () => {},
|
|
16
18
|
rename: () => {},
|
|
19
|
+
updateCustom: setCustom,
|
|
17
20
|
archive: () => {},
|
|
18
21
|
unarchive: () => {},
|
|
19
22
|
delete: () => {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleThreadList.js","names":[],"sources":["../../src/client/SingleThreadList.ts"],"sourcesContent":["import { resource, tapMemo } from \"@assistant-ui/tap\";\nimport {\n type ClientElement,\n type ClientOutput,\n tapClientResource,\n} from \"@assistant-ui/store\";\n\nconst RESOLVED_PROMISE = Promise.resolve();\nconst THREAD_ID = \"default\";\n\nconst SingleThreadListItem = resource((): ClientOutput<\"threadListItem\"> => {\n return {\n getState: () => ({\n id: THREAD_ID,\n remoteId: undefined,\n externalId: undefined,\n title: undefined,\n status: \"regular\",\n }),\n switchTo: () => {},\n rename: () => {},\n archive: () => {},\n unarchive: () => {},\n delete: () => {},\n generateTitle: () => {},\n initialize: async () => ({ remoteId: THREAD_ID, externalId: undefined }),\n detach: () => {},\n };\n});\n\ntype SingleThreadListProps = {\n thread: ClientElement<\"thread\">;\n};\n\n/**\n * A minimal threads scope that wraps a single thread.\n * Automatically provided by ExternalThread when no threads scope exists.\n * Mounts the provided thread resource element.\n */\nexport const SingleThreadList = resource(\n ({ thread }: SingleThreadListProps): ClientOutput<\"threads\"> => {\n const itemClient = tapClientResource(SingleThreadListItem());\n const threadClient = tapClientResource(thread);\n\n const state = tapMemo(\n () => ({\n mainThreadId: THREAD_ID,\n newThreadId: null,\n isLoading: false,\n isLoadingMore: false,\n hasMore: false,\n threadIds: [THREAD_ID],\n archivedThreadIds: [],\n threadItems: [itemClient.state],\n main: threadClient.state,\n }),\n [itemClient.state, threadClient.state],\n );\n\n return {\n getState: () => state,\n switchToThread: () => {\n throw new Error(\"SingleThreadList does not support switchToThread\");\n },\n switchToNewThread: () => {\n throw new Error(\"SingleThreadList does not support switchToNewThread\");\n },\n getLoadThreadsPromise: () => RESOLVED_PROMISE,\n reload: () => RESOLVED_PROMISE,\n loadMore: () => RESOLVED_PROMISE,\n item: (selector) => {\n if (\n selector !== \"main\" &&\n !(\n typeof selector === \"object\" &&\n \"id\" in selector &&\n selector.id === THREAD_ID\n ) &&\n !(\n typeof selector === \"object\" &&\n \"index\" in selector &&\n selector.index === 0\n )\n ) {\n throw new Error(\n `SingleThreadList: unknown item selector ${JSON.stringify(selector)}`,\n );\n }\n return itemClient.methods;\n },\n thread: (selector) => {\n if (selector !== \"main\" && selector !== THREAD_ID) {\n throw new Error(\n `SingleThreadList: unknown thread selector ${JSON.stringify(selector)}`,\n );\n }\n return threadClient.methods;\n },\n };\n },\n);\n"],"mappings":";;;AAOA,MAAM,mBAAmB,QAAQ,QAAQ;AACzC,MAAM,YAAY;AAElB,MAAM,uBAAuB,eAA+C;CAC1E,OAAO;EACL,iBAAiB;GACf,IAAI;GACJ,UAAU,KAAA;GACV,YAAY,KAAA;GACZ,OAAO,KAAA;GACP,QAAQ;
|
|
1
|
+
{"version":3,"file":"SingleThreadList.js","names":[],"sources":["../../src/client/SingleThreadList.ts"],"sourcesContent":["import { resource, tapMemo, tapState } from \"@assistant-ui/tap\";\nimport {\n type ClientElement,\n type ClientOutput,\n tapClientResource,\n} from \"@assistant-ui/store\";\n\nconst RESOLVED_PROMISE = Promise.resolve();\nconst THREAD_ID = \"default\";\n\nconst SingleThreadListItem = resource((): ClientOutput<\"threadListItem\"> => {\n const [custom, setCustom] = tapState<Record<string, unknown> | undefined>();\n\n return {\n getState: () => ({\n id: THREAD_ID,\n remoteId: undefined,\n externalId: undefined,\n title: undefined,\n status: \"regular\",\n custom,\n }),\n switchTo: () => {},\n rename: () => {},\n updateCustom: setCustom,\n archive: () => {},\n unarchive: () => {},\n delete: () => {},\n generateTitle: () => {},\n initialize: async () => ({ remoteId: THREAD_ID, externalId: undefined }),\n detach: () => {},\n };\n});\n\ntype SingleThreadListProps = {\n thread: ClientElement<\"thread\">;\n};\n\n/**\n * A minimal threads scope that wraps a single thread.\n * Automatically provided by ExternalThread when no threads scope exists.\n * Mounts the provided thread resource element.\n */\nexport const SingleThreadList = resource(\n ({ thread }: SingleThreadListProps): ClientOutput<\"threads\"> => {\n const itemClient = tapClientResource(SingleThreadListItem());\n const threadClient = tapClientResource(thread);\n\n const state = tapMemo(\n () => ({\n mainThreadId: THREAD_ID,\n newThreadId: null,\n isLoading: false,\n isLoadingMore: false,\n hasMore: false,\n threadIds: [THREAD_ID],\n archivedThreadIds: [],\n threadItems: [itemClient.state],\n main: threadClient.state,\n }),\n [itemClient.state, threadClient.state],\n );\n\n return {\n getState: () => state,\n switchToThread: () => {\n throw new Error(\"SingleThreadList does not support switchToThread\");\n },\n switchToNewThread: () => {\n throw new Error(\"SingleThreadList does not support switchToNewThread\");\n },\n getLoadThreadsPromise: () => RESOLVED_PROMISE,\n reload: () => RESOLVED_PROMISE,\n loadMore: () => RESOLVED_PROMISE,\n item: (selector) => {\n if (\n selector !== \"main\" &&\n !(\n typeof selector === \"object\" &&\n \"id\" in selector &&\n selector.id === THREAD_ID\n ) &&\n !(\n typeof selector === \"object\" &&\n \"index\" in selector &&\n selector.index === 0\n )\n ) {\n throw new Error(\n `SingleThreadList: unknown item selector ${JSON.stringify(selector)}`,\n );\n }\n return itemClient.methods;\n },\n thread: (selector) => {\n if (selector !== \"main\" && selector !== THREAD_ID) {\n throw new Error(\n `SingleThreadList: unknown thread selector ${JSON.stringify(selector)}`,\n );\n }\n return threadClient.methods;\n },\n };\n },\n);\n"],"mappings":";;;AAOA,MAAM,mBAAmB,QAAQ,QAAQ;AACzC,MAAM,YAAY;AAElB,MAAM,uBAAuB,eAA+C;CAC1E,MAAM,CAAC,QAAQ,aAAa,SAA8C;CAE1E,OAAO;EACL,iBAAiB;GACf,IAAI;GACJ,UAAU,KAAA;GACV,YAAY,KAAA;GACZ,OAAO,KAAA;GACP,QAAQ;GACR;EACF;EACA,gBAAgB,CAAC;EACjB,cAAc,CAAC;EACf,cAAc;EACd,eAAe,CAAC;EAChB,iBAAiB,CAAC;EAClB,cAAc,CAAC;EACf,qBAAqB,CAAC;EACtB,YAAY,aAAa;GAAE,UAAU;GAAW,YAAY,KAAA;EAAU;EACtE,cAAc,CAAC;CACjB;AACF,CAAC;;;;;;AAWD,MAAa,mBAAmB,UAC7B,EAAE,aAA6D;CAC9D,MAAM,aAAa,kBAAkB,qBAAqB,CAAC;CAC3D,MAAM,eAAe,kBAAkB,MAAM;CAE7C,MAAM,QAAQ,eACL;EACL,cAAc;EACd,aAAa;EACb,WAAW;EACX,eAAe;EACf,SAAS;EACT,WAAW,CAAC,SAAS;EACrB,mBAAmB,CAAC;EACpB,aAAa,CAAC,WAAW,KAAK;EAC9B,MAAM,aAAa;CACrB,IACA,CAAC,WAAW,OAAO,aAAa,KAAK,CACvC;CAEA,OAAO;EACL,gBAAgB;EAChB,sBAAsB;GACpB,MAAM,IAAI,MAAM,kDAAkD;EACpE;EACA,yBAAyB;GACvB,MAAM,IAAI,MAAM,qDAAqD;EACvE;EACA,6BAA6B;EAC7B,cAAc;EACd,gBAAgB;EAChB,OAAO,aAAa;GAClB,IACE,aAAa,UACb,EACE,OAAO,aAAa,YACpB,QAAQ,YACR,SAAS,OAAO,cAElB,EACE,OAAO,aAAa,YACpB,WAAW,YACX,SAAS,UAAU,IAGrB,MAAM,IAAI,MACR,2CAA2C,KAAK,UAAU,QAAQ,GACpE;GAEF,OAAO,WAAW;EACpB;EACA,SAAS,aAAa;GACpB,IAAI,aAAa,UAAU,aAAa,WACtC,MAAM,IAAI,MACR,6CAA6C,KAAK,UAAU,QAAQ,GACtE;GAEF,OAAO,aAAa;EACtB;CACF;AACF,CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -74,9 +74,9 @@ import { McpAppRenderer, McpAppRendererOptions } from "./mcp-apps/McpAppRenderer
|
|
|
74
74
|
import { McpAppsRemoteHost } from "./mcp-apps/McpAppsRemoteHost.js";
|
|
75
75
|
import { getMcpAppFromToolPart } from "./mcp-apps/utils.js";
|
|
76
76
|
import { AssistantClient, AssistantEventCallback, AssistantEventName, AssistantEventPayload, AssistantEventScope, AssistantEventSelector, AssistantState, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
77
|
-
import { AssistantContextConfig, AssistantDataUI, AssistantDataUIProps, AssistantInteractableProps, AssistantTool, AssistantToolProps, AssistantToolUI, AssistantToolUIProps, DataMessagePartComponent, DataMessagePartProps, DataRenderers, EmptyMessagePartComponent, EmptyMessagePartProps, EnrichedPartState, FileMessagePartComponent, FileMessagePartProps, GenerativeUIComponentRegistry, GenerativeUIMessagePartComponent, GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, GenerativeUIRenderProps, GroupByContext, ImageMessagePartComponent, ImageMessagePartProps, Interactables, McpAppResourceOutput, PartState, QuoteMessagePartComponent, QuoteMessagePartProps, ReasoningGroupComponent, ReasoningGroupProps, ReasoningMessagePartComponent, ReasoningMessagePartProps, RuntimeAdapterProvider, RuntimeAdapters, SourceMessagePartComponent, SourceMessagePartProps, TextMessagePartComponent, TextMessagePartProps, ToolArgsStatus, ToolCallMessagePartComponent, ToolCallMessagePartProps, ToolDefinition, Toolkit,
|
|
77
|
+
import { AssistantContextConfig, AssistantDataUI, AssistantDataUIProps, AssistantInteractableProps, AssistantTool, AssistantToolProps, AssistantToolUI, AssistantToolUIProps, DataMessagePartComponent, DataMessagePartProps, DataRenderers, EmptyMessagePartComponent, EmptyMessagePartProps, EnrichedPartState, FileMessagePartComponent, FileMessagePartProps, GenerativeUIComponentRegistry, GenerativeUIMessagePartComponent, GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, GenerativeUIRenderProps, GroupByContext, ImageMessagePartComponent, ImageMessagePartProps, Interactables, McpAppResourceOutput, McpToolkitDefinition, PartState, ProviderToolConfig, QuoteMessagePartComponent, QuoteMessagePartProps, ReasoningGroupComponent, ReasoningGroupProps, ReasoningMessagePartComponent, ReasoningMessagePartProps, RuntimeAdapterProvider, RuntimeAdapters, SourceMessagePartComponent, SourceMessagePartProps, TextMessagePartComponent, TextMessagePartProps, ToolArgsStatus, ToolCallMessagePartComponent, ToolCallMessagePartProps, ToolCallText, ToolDefinition, Toolkit, ToolkitDefinition, ToolkitDefinitionEntry, Tools, Unstable_AudioMessagePartComponent, Unstable_AudioMessagePartProps, defineMcpToolkit, defineToolkit, groupPartByType, hitl, hitlTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
|
|
78
78
|
import { AssistantCloud } from "assistant-cloud";
|
|
79
79
|
import { AddToolResultOptions, AppendMessage, AssistantFrameHost, AssistantFrameProvider, AssistantRuntime, Attachment, AttachmentAdapter, AttachmentRuntime, AttachmentState, AttachmentStatus, ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, ChatModelRunUpdate, CompleteAttachment, ComposerRuntime, ComposerState, CompositeAttachmentAdapter, CreateAppendMessage, CreateAttachment, CreateResumeRunConfig, CreateStartRunConfig, DataMessagePart, DictationAdapter, DictationState, EditComposerRuntime, EditComposerState, ExportedMessageRepository, ExportedMessageRepositoryItem, ExternalStoreAdapter, ExternalStoreMessageConverter, ExternalStoreSharedOptions, ExternalStoreThreadData, ExternalStoreThreadListAdapter, FRAME_MESSAGE_CHANNEL, FeedbackAdapter, FileMessagePart, FrameMessage, FrameMessageType, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, GenericThreadHistoryAdapter, ImageMessagePart, InMemoryThreadListAdapter, LanguageModelConfig, LanguageModelV1CallSettings, LocalRuntimeOptionsBase, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessagePartRuntime, MessagePartState, MessagePartStatus, MessageRuntime, MessageState, MessageStatus, MessageStorageEntry, MessageTiming, ModelContext, ModelContextProvider, ModelContextRegistry, ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle, PendingAttachment, QuoteInfo, RealtimeVoiceAdapter, ReasoningMessagePart, RemoteThreadListAdapter, SerializedModelContext, SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SourceMessagePart, SourceProviderMetadata, SpeechSynthesisAdapter, SubmitFeedbackOptions, SuggestionAdapter, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadComposerRuntime, ThreadComposerState, ThreadHistoryAdapter, ThreadListItemRuntime, ThreadListItemState, ThreadListItemStatus, ThreadListRuntime, ThreadListState, ThreadMessage, ThreadMessageLike, ThreadRuntime, ThreadState, ThreadSuggestion, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolCallMessagePart, ToolCallMessagePartStatus, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_DirectiveFormatter, Unstable_DirectiveSegment, Unstable_TriggerItem, Unsubscribe, VoiceSessionControls, VoiceSessionHelpers, VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, mergeModelContexts, pickExternalStoreSharedOptions, tool, unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
|
|
80
80
|
import { Tool } from "assistant-stream";
|
|
81
81
|
import { ChainOfThoughtClient, ComposerSendOptions, ModelContext as ModelContextClient, QueueItemMethods, QueueItemState, SuggestionConfig, Suggestions } from "@assistant-ui/core/store";
|
|
82
|
-
export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, type GroupByContext, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartState, type PendingAttachment, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, type RemoteThreadListAdapter, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, type
|
|
82
|
+
export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, type GroupByContext, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, type McpToolkitDefinition, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartState, type PendingAttachment, type ProviderToolConfig, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, type RemoteThreadListAdapter, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolCallText, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_IconComponent, type Unstable_Mention, type Unstable_MentionCategory, type Unstable_MentionDirective, type Unstable_ModelContextToolsOptions, type RegisteredTrigger as Unstable_RegisteredTrigger, type Unstable_SlashCommand, type Unstable_SlashCommandAction, type TriggerBehavior as Unstable_TriggerBehavior, type Unstable_TriggerItem, type Unstable_UseMentionAdapterOptions, type Unstable_UseSlashCommandAdapterOptions, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, defineMcpToolkit, defineToolkit, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
|
package/dist/index.js
CHANGED
|
@@ -67,8 +67,8 @@ import { getMcpAppFromToolPart } from "./mcp-apps/utils.js";
|
|
|
67
67
|
import { McpAppRenderer } from "./mcp-apps/McpAppRenderer.js";
|
|
68
68
|
import { McpAppsRemoteHost } from "./mcp-apps/McpAppsRemoteHost.js";
|
|
69
69
|
import { AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
70
|
-
import { DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, RuntimeAdapterProvider, Tools, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
|
|
70
|
+
import { DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, RuntimeAdapterProvider, Tools, defineMcpToolkit, defineToolkit, groupPartByType, hitl, hitlTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
|
|
71
71
|
import { AssistantCloud } from "assistant-cloud";
|
|
72
72
|
import { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, mergeModelContexts, pickExternalStoreSharedOptions, tool, unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
|
|
73
73
|
import { ChainOfThoughtClient, ModelContext as ModelContextClient, Suggestions } from "@assistant-ui/core/store";
|
|
74
|
-
export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
74
|
+
export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, defineMcpToolkit, defineToolkit, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts
|
|
2
|
+
declare const REPLAY_CONTENT_LENGTH_HEADER = "Aui-Replay-Content-Length";
|
|
3
|
+
type ReplayBoundaryStreamOptions = {
|
|
4
|
+
setReplaying: (value: boolean) => void;
|
|
5
|
+
waitForRender: () => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
declare const useReplayRenderWait: () => () => Promise<void>;
|
|
8
|
+
declare const createReplayBoundaryStream: (response: Response, {
|
|
9
|
+
setReplaying,
|
|
10
|
+
waitForRender: waitForReplayRender
|
|
11
|
+
}: ReplayBoundaryStreamOptions) => Promise<ReadableStream<Uint8Array>>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { REPLAY_CONTENT_LENGTH_HEADER, createReplayBoundaryStream, useReplayRenderWait };
|
|
14
|
+
//# sourceMappingURL=replayBoundaryStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replayBoundaryStream.d.ts","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts"],"mappings":";cAIa,4BAAA;AAAA,KAER,2BAAA;EACH,YAAA,GAAe,KAAA;EACf,aAAA,QAAqB,OAAO;AAAA;AAAA,cAGjB,mBAAA,cAAmB,OAAA;AAAA,cA6DnB,0BAAA,GACX,QAAA,EAAU,QAAA;EACV,YAAA;EAAA,aAAA,EAAA;AAAA,GAGG,2BAAA,KACF,OAAA,CAAQ,cAAA,CAAe,UAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
//#region src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts
|
|
4
|
+
const REPLAY_CONTENT_LENGTH_HEADER = "Aui-Replay-Content-Length";
|
|
5
|
+
const useReplayRenderWait = () => {
|
|
6
|
+
const [renderTicket, setRenderTicket] = useState(0);
|
|
7
|
+
const mountedRef = useRef(true);
|
|
8
|
+
const nextTicketRef = useRef(0);
|
|
9
|
+
const waitersRef = useRef([]);
|
|
10
|
+
const resolveWaiters = useCallback((committedTicket) => {
|
|
11
|
+
const pendingWaiters = [];
|
|
12
|
+
for (const waiter of waitersRef.current) if (committedTicket === void 0 || waiter.ticket <= committedTicket) waiter.resolve();
|
|
13
|
+
else pendingWaiters.push(waiter);
|
|
14
|
+
waitersRef.current = pendingWaiters;
|
|
15
|
+
}, []);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
mountedRef.current = true;
|
|
18
|
+
resolveWaiters(renderTicket);
|
|
19
|
+
}, [renderTicket, resolveWaiters]);
|
|
20
|
+
useEffect(() => () => {
|
|
21
|
+
mountedRef.current = false;
|
|
22
|
+
resolveWaiters();
|
|
23
|
+
}, [resolveWaiters]);
|
|
24
|
+
return useCallback(() => new Promise((resolve) => {
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
if (!mountedRef.current) {
|
|
27
|
+
resolve();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const ticket = nextTicketRef.current + 1;
|
|
31
|
+
nextTicketRef.current = ticket;
|
|
32
|
+
waitersRef.current.push({
|
|
33
|
+
ticket,
|
|
34
|
+
resolve
|
|
35
|
+
});
|
|
36
|
+
setRenderTicket(ticket);
|
|
37
|
+
}, 0);
|
|
38
|
+
}), []);
|
|
39
|
+
};
|
|
40
|
+
const parseReplayContentLength = (headers) => {
|
|
41
|
+
const raw = headers.get(REPLAY_CONTENT_LENGTH_HEADER);
|
|
42
|
+
if (raw == null) return 0;
|
|
43
|
+
const boundary = Number(raw);
|
|
44
|
+
return Number.isSafeInteger(boundary) && boundary > 0 ? boundary : 0;
|
|
45
|
+
};
|
|
46
|
+
const createReplayBoundaryStream = async (response, { setReplaying, waitForRender: waitForReplayRender }) => {
|
|
47
|
+
const body = response.body;
|
|
48
|
+
const replayContentLength = parseReplayContentLength(response.headers);
|
|
49
|
+
if (replayContentLength <= 0) return body;
|
|
50
|
+
setReplaying(true);
|
|
51
|
+
await waitForReplayRender();
|
|
52
|
+
const reader = body.getReader();
|
|
53
|
+
let bytesForwarded = 0;
|
|
54
|
+
let replayFinished = false;
|
|
55
|
+
const finishReplay = async () => {
|
|
56
|
+
if (replayFinished) return;
|
|
57
|
+
replayFinished = true;
|
|
58
|
+
await waitForReplayRender();
|
|
59
|
+
setReplaying(false);
|
|
60
|
+
await waitForReplayRender();
|
|
61
|
+
};
|
|
62
|
+
return new ReadableStream({
|
|
63
|
+
async pull(controller) {
|
|
64
|
+
const { done, value } = await reader.read();
|
|
65
|
+
if (done) {
|
|
66
|
+
await finishReplay();
|
|
67
|
+
controller.close();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (replayFinished) {
|
|
71
|
+
controller.enqueue(value);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const nextBytesForwarded = bytesForwarded + value.byteLength;
|
|
75
|
+
if (nextBytesForwarded < replayContentLength) {
|
|
76
|
+
bytesForwarded = nextBytesForwarded;
|
|
77
|
+
controller.enqueue(value);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (nextBytesForwarded === replayContentLength) {
|
|
81
|
+
controller.enqueue(value);
|
|
82
|
+
await finishReplay();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const replayBytesInChunk = replayContentLength - bytesForwarded;
|
|
86
|
+
controller.enqueue(value.subarray(0, replayBytesInChunk));
|
|
87
|
+
await finishReplay();
|
|
88
|
+
controller.enqueue(value.subarray(replayBytesInChunk));
|
|
89
|
+
},
|
|
90
|
+
async cancel(reason) {
|
|
91
|
+
const wasFinished = replayFinished;
|
|
92
|
+
replayFinished = true;
|
|
93
|
+
if (!wasFinished) setReplaying(false);
|
|
94
|
+
await reader.cancel(reason);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
99
|
+
export { REPLAY_CONTENT_LENGTH_HEADER, createReplayBoundaryStream, useReplayRenderWait };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=replayBoundaryStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replayBoundaryStream.js","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport const REPLAY_CONTENT_LENGTH_HEADER = \"Aui-Replay-Content-Length\";\n\ntype ReplayBoundaryStreamOptions = {\n setReplaying: (value: boolean) => void;\n waitForRender: () => Promise<void>;\n};\n\nexport const useReplayRenderWait = () => {\n const [renderTicket, setRenderTicket] = useState(0);\n const mountedRef = useRef(true);\n const nextTicketRef = useRef(0);\n const waitersRef = useRef<Array<{ ticket: number; resolve: () => void }>>([]);\n\n const resolveWaiters = useCallback((committedTicket?: number) => {\n const pendingWaiters = [];\n\n for (const waiter of waitersRef.current) {\n if (committedTicket === undefined || waiter.ticket <= committedTicket) {\n waiter.resolve();\n } else {\n pendingWaiters.push(waiter);\n }\n }\n\n waitersRef.current = pendingWaiters;\n }, []);\n\n useEffect(() => {\n mountedRef.current = true;\n resolveWaiters(renderTicket);\n }, [renderTicket, resolveWaiters]);\n\n useEffect(\n () => () => {\n mountedRef.current = false;\n resolveWaiters();\n },\n [resolveWaiters],\n );\n\n return useCallback(\n () =>\n new Promise<void>((resolve) => {\n setTimeout(() => {\n if (!mountedRef.current) {\n resolve();\n return;\n }\n\n const ticket = nextTicketRef.current + 1;\n nextTicketRef.current = ticket;\n waitersRef.current.push({ ticket, resolve });\n setRenderTicket(ticket);\n }, 0);\n }),\n [],\n );\n};\n\nconst parseReplayContentLength = (headers: Headers): number => {\n const raw = headers.get(REPLAY_CONTENT_LENGTH_HEADER);\n if (raw == null) return 0;\n\n const boundary = Number(raw);\n return Number.isSafeInteger(boundary) && boundary > 0 ? boundary : 0;\n};\n\n// Gates replay bytes until isReplaying:true renders, then releases live bytes after isReplaying:false renders.\nexport const createReplayBoundaryStream = async (\n response: Response,\n {\n setReplaying,\n waitForRender: waitForReplayRender,\n }: ReplayBoundaryStreamOptions,\n): Promise<ReadableStream<Uint8Array>> => {\n const body = response.body as ReadableStream<Uint8Array>;\n const replayContentLength = parseReplayContentLength(response.headers);\n\n if (replayContentLength <= 0) {\n return body;\n }\n\n setReplaying(true);\n await waitForReplayRender();\n\n const reader = body.getReader();\n let bytesForwarded = 0;\n let replayFinished = false;\n\n const finishReplay = async () => {\n if (replayFinished) return;\n replayFinished = true;\n\n // Let replay bytes drain before rendering live mode, then render live mode before releasing live bytes.\n await waitForReplayRender();\n setReplaying(false);\n await waitForReplayRender();\n };\n\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n const { done, value } = await reader.read();\n\n if (done) {\n await finishReplay();\n controller.close();\n return;\n }\n\n if (replayFinished) {\n controller.enqueue(value);\n return;\n }\n\n const nextBytesForwarded = bytesForwarded + value.byteLength;\n\n if (nextBytesForwarded < replayContentLength) {\n bytesForwarded = nextBytesForwarded;\n controller.enqueue(value);\n return;\n }\n\n if (nextBytesForwarded === replayContentLength) {\n controller.enqueue(value);\n await finishReplay();\n return;\n }\n\n const replayBytesInChunk = replayContentLength - bytesForwarded;\n\n controller.enqueue(value.subarray(0, replayBytesInChunk));\n await finishReplay();\n controller.enqueue(value.subarray(replayBytesInChunk));\n },\n async cancel(reason) {\n const wasFinished = replayFinished;\n replayFinished = true;\n if (!wasFinished) setReplaying(false);\n await reader.cancel(reason);\n },\n });\n};\n"],"mappings":";;;AAIA,MAAa,+BAA+B;AAO5C,MAAa,4BAA4B;CACvC,MAAM,CAAC,cAAc,mBAAmB,SAAS,CAAC;CAClD,MAAM,aAAa,OAAO,IAAI;CAC9B,MAAM,gBAAgB,OAAO,CAAC;CAC9B,MAAM,aAAa,OAAuD,CAAC,CAAC;CAE5E,MAAM,iBAAiB,aAAa,oBAA6B;EAC/D,MAAM,iBAAiB,CAAC;EAExB,KAAK,MAAM,UAAU,WAAW,SAC9B,IAAI,oBAA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AE1C,IAAI,MAAM;IACR,MAAM,aAAa;IACnB,WAAW,MAAM;IACjB;GACF;GAEA,IAAI,gBAAgB;IAClB,WAAW,QAAQ,KAAK;IACxB;GACF;GAEA,MAAM,qBAAqB,iBAAiB,MAAM;GAElD,IAAI,qBAAqB,qBAAqB;IAC5C,iBAAiB;IACjB,WAAW,QAAQ,KAAK;IACxB;GACF;GAEA,IAAI,uBAAuB,qBAAqB;IAC9C,WAAW,QAAQ,KAAK;IACxB,MAAM,aAAa;IACnB;GACF;GAEA,MAAM,qBAAqB,sBAAsB;GAEjD,WAAW,QAAQ,MAAM,SAAS,GAAG,kBAAkB,CAAC;GACxD,MAAM,aAAa;GACnB,WAAW,QAAQ,MAAM,SAAS,kBAAkB,CAAC;EACvD;EACA,MAAM,OAAO,QAAQ;GACnB,MAAM,cAAc;GACpB,iBAAiB;GACjB,IAAI,CAAC,aAAa,aAAa,KAAK;GACpC,MAAM,OAAO,OAAO,MAAM;EAC5B;CACF,CAAC;AACH"}
|
package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAssistantTransportRuntime.d.ts","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"useAssistantTransportRuntime.d.ts","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"mappings":";;;;;cA8Fa,gCAAA,SAGH,OAAkC,EAAzB,yBAAyB;AAAA,iBAO5B,0BAAA,IAA8B,iBAAiB;AAAA,iBAC/C,0BAAA,IACd,QAAA,GAAW,KAAA,EAAO,iBAAA,KAAsB,CAAA,GACvC,CAAA;;;;cAmQU,4BAAA,MACX,OAAA,EAAS,yBAAA,CAA0B,CAAA,MAClC,gBAAA"}
|
package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { useRemoteThreadListRuntime } from "../remote-thread-list/useRemoteThreadListRuntime.js";
|
|
3
3
|
import { useExternalStoreRuntime } from "../external-store/useExternalStoreRuntime.js";
|
|
4
4
|
import { useCommandQueue } from "./commandQueue.js";
|
|
5
|
+
import { createReplayBoundaryStream, useReplayRenderWait } from "./replayBoundaryStream.js";
|
|
5
6
|
import { useRunManager } from "./runManager.js";
|
|
6
7
|
import { useConvertedState } from "./useConvertedState.js";
|
|
7
8
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
@@ -51,6 +52,8 @@ const useAssistantTransportThreadRuntime = (options) => {
|
|
|
51
52
|
const agentStateRef = useRef(options.initialState);
|
|
52
53
|
const [, rerender] = useState(0);
|
|
53
54
|
const resumeFlagRef = useRef(false);
|
|
55
|
+
const [isReplaying, setIsReplaying] = useState(false);
|
|
56
|
+
const waitForReplayRender = useReplayRenderWait();
|
|
54
57
|
const parentIdRef = useRef(void 0);
|
|
55
58
|
const commandQueue = useCommandQueue({ onQueue: () => runManager.schedule() });
|
|
56
59
|
const threadId = useAuiState((s) => s.threadListItem.remoteId);
|
|
@@ -58,6 +61,7 @@ const useAssistantTransportThreadRuntime = (options) => {
|
|
|
58
61
|
onRun: async (signal) => {
|
|
59
62
|
const isResume = resumeFlagRef.current;
|
|
60
63
|
resumeFlagRef.current = false;
|
|
64
|
+
setIsReplaying(false);
|
|
61
65
|
const commands = isResume ? [] : commandQueue.flush();
|
|
62
66
|
if (commands.length === 0 && !isResume) throw new Error("No commands to send");
|
|
63
67
|
const headers = await createRequestHeaders(options.headers);
|
|
@@ -86,9 +90,13 @@ const useAssistantTransportThreadRuntime = (options) => {
|
|
|
86
90
|
options.onResponse?.(response);
|
|
87
91
|
if (!response.ok) throw new Error(`Status ${response.status}: ${await response.text()}`);
|
|
88
92
|
if (!response.body) throw new Error("Response body is null");
|
|
93
|
+
const body = await createReplayBoundaryStream(response, {
|
|
94
|
+
setReplaying: setIsReplaying,
|
|
95
|
+
waitForRender: waitForReplayRender
|
|
96
|
+
});
|
|
89
97
|
const decoder = (options.protocol ?? "data-stream") === "assistant-transport" ? new AssistantTransportDecoder() : new DataStreamDecoder();
|
|
90
98
|
let err;
|
|
91
|
-
const stream =
|
|
99
|
+
const stream = body.pipeThrough(decoder).pipeThrough(new AssistantMessageAccumulator({
|
|
92
100
|
initialMessage: unstable_createInitialMessage({ unstable_state: agentStateRef.current ?? null }),
|
|
93
101
|
throttle: isResume,
|
|
94
102
|
onError: (error) => {
|
|
@@ -109,6 +117,7 @@ const useAssistantTransportThreadRuntime = (options) => {
|
|
|
109
117
|
},
|
|
110
118
|
onFinish: options.onFinish,
|
|
111
119
|
onCancel: () => {
|
|
120
|
+
setIsReplaying(false);
|
|
112
121
|
const cmds = [...commandQueue.state.inTransit, ...commandQueue.state.queued];
|
|
113
122
|
commandQueue.reset();
|
|
114
123
|
options.onCancel?.({
|
|
@@ -120,6 +129,7 @@ const useAssistantTransportThreadRuntime = (options) => {
|
|
|
120
129
|
});
|
|
121
130
|
},
|
|
122
131
|
onError: async (error) => {
|
|
132
|
+
setIsReplaying(false);
|
|
123
133
|
const inTransitCmds = [...commandQueue.state.inTransit];
|
|
124
134
|
const queuedCmds = [...commandQueue.state.queued];
|
|
125
135
|
commandQueue.reset();
|
|
@@ -150,6 +160,7 @@ const useAssistantTransportThreadRuntime = (options) => {
|
|
|
150
160
|
messages: converted.messages,
|
|
151
161
|
state: converted.state,
|
|
152
162
|
isRunning: converted.isRunning,
|
|
163
|
+
isLoading: isReplaying,
|
|
153
164
|
adapters: options.adapters,
|
|
154
165
|
unstable_enableToolInvocations: true,
|
|
155
166
|
setToolStatuses,
|
package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAssistantTransportRuntime.js","names":["createInitialMessage"],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"sourcesContent":["\"use client\";\n\nimport type { AppendMessage } from \"@assistant-ui/core\";\nimport {\n type ReadonlyJSONObject,\n type ReadonlyJSONValue,\n asAsyncIterableStream,\n} from \"assistant-stream/utils\";\nimport { useExternalStoreRuntime } from \"../external-store/useExternalStoreRuntime\";\nimport type { AssistantRuntime } from \"../../runtime/AssistantRuntime\";\nimport type { AddToolResultOptions } from \"@assistant-ui/core\";\nimport { useMemo, useRef, useState } from \"react\";\nimport {\n AssistantMessageAccumulator,\n DataStreamDecoder,\n AssistantTransportDecoder,\n unstable_createInitialMessage as createInitialMessage,\n toToolsJSONSchema,\n} from \"assistant-stream\";\nimport type {\n AssistantTransportOptions,\n AddMessageCommand,\n AddToolResultCommand,\n UserMessagePart,\n QueuedCommand,\n AssistantTransportCommand,\n SendCommandsRequestBody,\n} from \"./types\";\nimport { useCommandQueue } from \"./commandQueue\";\nimport { useRunManager } from \"./runManager\";\nimport { useConvertedState } from \"./useConvertedState\";\nimport type { ToolExecutionStatus } from \"@assistant-ui/core\";\nimport { createRequestHeaders } from \"@assistant-ui/core\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { InMemoryThreadListAdapter } from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { UserExternalState } from \"../../../augmentations\";\n\nconst convertAppendMessageToCommand = (\n message: AppendMessage,\n): AddMessageCommand => {\n if (message.role !== \"user\")\n throw new Error(\"Only user messages are supported\");\n\n const parts: UserMessagePart[] = [];\n const content = [\n ...message.content,\n ...(message.attachments?.flatMap((a) => a.content) ?? []),\n ];\n for (const contentPart of content) {\n if (contentPart.type === \"text\") {\n parts.push({ type: \"text\", text: contentPart.text });\n } else if (contentPart.type === \"image\") {\n parts.push({ type: \"image\", image: contentPart.image });\n }\n }\n\n return {\n type: \"add-message\",\n message: {\n role: \"user\",\n parts,\n },\n parentId: message.parentId,\n sourceId: message.sourceId,\n };\n};\n\nconst symbolAssistantTransportExtras = Symbol(\"assistant-transport-extras\");\ntype AssistantTransportExtras = {\n [symbolAssistantTransportExtras]: true;\n sendCommand: (command: AssistantTransportCommand) => void;\n state: UserExternalState;\n};\n\nconst asAssistantTransportExtras = (\n extras: unknown,\n): AssistantTransportExtras => {\n if (\n typeof extras !== \"object\" ||\n extras == null ||\n !(symbolAssistantTransportExtras in extras)\n )\n throw new Error(\n \"This method can only be called when you are using useAssistantTransportRuntime\",\n );\n\n return extras as AssistantTransportExtras;\n};\n\nexport const useAssistantTransportSendCommand = () => {\n const aui = useAui();\n\n return (command: AssistantTransportCommand) => {\n const extras = aui.thread().getState().extras;\n const transportExtras = asAssistantTransportExtras(extras);\n transportExtras.sendCommand(command);\n };\n};\n\nexport function useAssistantTransportState(): UserExternalState;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T,\n): T;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T = (t) => t as T,\n): T | UserExternalState {\n return useAuiState((s) =>\n selector(asAssistantTransportExtras(s.thread.extras).state),\n );\n}\n\nconst useAssistantTransportThreadRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const agentStateRef = useRef(options.initialState);\n const [, rerender] = useState(0);\n const resumeFlagRef = useRef(false);\n const parentIdRef = useRef<string | null | undefined>(undefined);\n const commandQueue = useCommandQueue({\n onQueue: () => runManager.schedule(),\n });\n\n const threadId = useAuiState((s) => s.threadListItem.remoteId);\n\n const runManager = useRunManager({\n onRun: async (signal: AbortSignal) => {\n const isResume = resumeFlagRef.current;\n resumeFlagRef.current = false;\n const commands: QueuedCommand[] = isResume ? [] : commandQueue.flush();\n if (commands.length === 0 && !isResume)\n throw new Error(\"No commands to send\");\n\n const headers = await createRequestHeaders(options.headers);\n const bodyValue =\n typeof options.body === \"function\"\n ? await options.body()\n : options.body;\n const context = runtime.thread.getModelContext();\n\n let requestBody: Record<string, unknown> = {\n commands,\n state: agentStateRef.current,\n system: context.system,\n tools: context.tools ? toToolsJSONSchema(context.tools) : undefined,\n threadId,\n ...(parentIdRef.current !== undefined && {\n parentId: parentIdRef.current,\n }),\n // nested (new format, aligned with AssistantChatTransport)\n callSettings: context.callSettings,\n config: context.config,\n // @deprecated spread at top level — use nested `callSettings`/`config` instead. Will be removed in a future version.\n ...context.callSettings,\n ...context.config,\n ...(bodyValue ?? {}),\n };\n\n if (options.prepareSendCommandsRequest) {\n requestBody = await options.prepareSendCommandsRequest(\n requestBody as SendCommandsRequestBody,\n );\n }\n\n const response = await fetch(\n isResume ? options.resumeApi! : options.api,\n {\n method: \"POST\",\n headers,\n body: JSON.stringify(requestBody),\n signal,\n },\n );\n\n options.onResponse?.(response);\n\n if (!response.ok) {\n throw new Error(`Status ${response.status}: ${await response.text()}`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n // Select decoder based on protocol option\n const protocol = options.protocol ?? \"data-stream\";\n const decoder =\n protocol === \"assistant-transport\"\n ? new AssistantTransportDecoder()\n : new DataStreamDecoder();\n\n let err: string | undefined;\n const stream = response.body.pipeThrough(decoder).pipeThrough(\n new AssistantMessageAccumulator({\n initialMessage: createInitialMessage({\n unstable_state:\n (agentStateRef.current as ReadonlyJSONValue) ?? null,\n }),\n throttle: isResume,\n onError: (error) => {\n err = error;\n },\n }),\n );\n\n let markedDelivered = false;\n\n for await (const chunk of asAsyncIterableStream(stream)) {\n if (chunk.metadata.unstable_state === agentStateRef.current) continue;\n\n if (!markedDelivered) {\n commandQueue.markDelivered();\n markedDelivered = true;\n }\n\n agentStateRef.current = chunk.metadata.unstable_state as T;\n rerender((prev) => prev + 1);\n }\n\n if (err) {\n throw new Error(err);\n }\n },\n onFinish: options.onFinish,\n onCancel: () => {\n const cmds = [\n ...commandQueue.state.inTransit,\n ...commandQueue.state.queued,\n ];\n\n commandQueue.reset();\n\n options.onCancel?.({\n commands: cmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n },\n onError: async (error) => {\n const inTransitCmds = [...commandQueue.state.inTransit];\n const queuedCmds = [...commandQueue.state.queued];\n\n commandQueue.reset();\n\n try {\n await options.onError?.(error as Error, {\n commands: inTransitCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n } finally {\n options.onCancel?.({\n commands: queuedCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n error: error as Error,\n });\n }\n },\n });\n\n // Tool execution status state\n const [toolStatuses, setToolStatuses] = useState<\n Record<string, ToolExecutionStatus>\n >({});\n\n // Reactive conversion of agent state + connection metadata → UI state\n const pendingCommands = useMemo(\n () => [...commandQueue.state.inTransit, ...commandQueue.state.queued],\n [commandQueue.state],\n );\n const converted = useConvertedState(\n options.converter,\n agentStateRef.current,\n pendingCommands,\n runManager.isRunning,\n toolStatuses,\n );\n\n // Create runtime\n const runtime = useExternalStoreRuntime({\n messages: converted.messages,\n state: converted.state,\n isRunning: converted.isRunning,\n adapters: options.adapters,\n unstable_enableToolInvocations: true,\n setToolStatuses,\n extras: {\n [symbolAssistantTransportExtras]: true,\n sendCommand: (command: AssistantTransportCommand) => {\n commandQueue.enqueue(command);\n },\n state: agentStateRef.current as UserExternalState,\n } satisfies AssistantTransportExtras,\n onNew: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n ...(options.capabilities?.edit && {\n onEdit: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n }),\n onCancel: async () => {\n runManager.cancel();\n },\n onResume: async () => {\n if (!options.resumeApi)\n throw new Error(\"Must pass resumeApi to options to resume runs\");\n\n resumeFlagRef.current = true;\n runManager.schedule();\n },\n onAddToolResult: async (\n toolOptions: AddToolResultOptions,\n ): Promise<void> => {\n const command: AddToolResultCommand = {\n type: \"add-tool-result\",\n toolCallId: toolOptions.toolCallId,\n result: toolOptions.result as ReadonlyJSONObject,\n toolName: toolOptions.toolName,\n isError: toolOptions.isError,\n ...(toolOptions.artifact && { artifact: toolOptions.artifact }),\n ...(toolOptions.modelContent !== undefined && {\n modelContent: toolOptions.modelContent,\n }),\n };\n\n commandQueue.enqueue(command);\n },\n onLoadExternalState: async (state) => {\n agentStateRef.current = state as T;\n rerender((prev) => prev + 1);\n },\n });\n\n return runtime;\n};\n\n/**\n * @alpha This is an experimental API that is subject to change.\n */\nexport const useAssistantTransportRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const runtime = useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n return useAssistantTransportThreadRuntime(options);\n },\n adapter: new InMemoryThreadListAdapter(),\n allowNesting: true,\n });\n return runtime;\n};\n"],"mappings":";;;;;;;;;;;;AAsCA,MAAM,iCACJ,YACsB;CACtB,IAAI,QAAQ,SAAS,QACnB,MAAM,IAAI,MAAM,kCAAkC;CAEpD,MAAM,QAA2B,CAAC;CAClC,MAAM,UAAU,CACd,GAAG,QAAQ,SACX,GAAI,QAAQ,aAAa,SAAS,MAAM,EAAE,OAAO,KAAK,CAAC,CACzD;CACA,KAAK,MAAM,eAAe,SACxB,IAAI,YAAY,SAAS,QACvB,MAAM,KAAK;EAAE,MAAM;EAAQ,MAAM,YAAY;CAAK,CAAC;MAC9C,IAAI,YAAY,SAAS,SAC9B,MAAM,KAAK;EAAE,MAAM;EAAS,OAAO,YAAY;CAAM,CAAC;CAI1D,OAAO;EACL,MAAM;EACN,SAAS;GACP,MAAM;GACN;EACF;EACA,UAAU,QAAQ;EAClB,UAAU,QAAQ;CACpB;AACF;AAEA,MAAM,iCAAiC,OAAO,4BAA4B;AAO1E,MAAM,8BACJ,WAC6B;CAC7B,IACE,OAAO,WAAW,YAClB,UAAU,QACV,EAAE,kCAAkC,SAEpC,MAA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AAW,OAAO;EACpB;EACA,UAAU,YAAY;GACpB,IAAI,CAAC,QAAQ,WACX,MAAM,IAAI,MAAM,+CAA+C;GAEjE,cAAc,UAAU;GACxB,WAAW,SAAS;EACtB;EACA,iBAAiB,OACf,gBACkB;GAClB,MAAM,UAAgC;IACpC,MAAM;IACN,YAAY,YAAY;IACxB,QAAQ,YAAY;IACpB,UAAU,YAAY;IACtB,SAAS,YAAY;IACrB,GAAI,YAAY,YAAY,EAAE,UAAU,YAAY,SAAS;IAC7D,GAAI,YAAY,iBAAiB,KAAA,KAAa,EAC5C,cAAc,YAAY,aAC5B;GACF;GAEA,aAAa,QAAQ,OAAO;EAC9B;EACA,qBAAqB,OAAO,UAAU;GACpC,cAAc,UAAU;GACxB,UAAU,SAAS,OAAO,CAAC;EAC7B;CACF,CAAC;CAED,OAAO;AACT;;;;AAKA,MAAa,gCACX,YACqB;CAQrB,OAPgB,2BAA2B;EACzC,aAAa,SAAS,cAAc;GAClC,OAAO,mCAAmC,OAAO;EACnD;EACA,SAAS,IAAI,0BAA0B;EACvC,cAAc;CAChB,CACa;AACf"}
|
|
1
|
+
{"version":3,"file":"useAssistantTransportRuntime.js","names":["createInitialMessage"],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"sourcesContent":["\"use client\";\n\nimport type { AppendMessage } from \"@assistant-ui/core\";\nimport {\n type ReadonlyJSONObject,\n type ReadonlyJSONValue,\n asAsyncIterableStream,\n} from \"assistant-stream/utils\";\nimport { useExternalStoreRuntime } from \"../external-store/useExternalStoreRuntime\";\nimport type { AssistantRuntime } from \"../../runtime/AssistantRuntime\";\nimport type { AddToolResultOptions } from \"@assistant-ui/core\";\nimport { useMemo, useRef, useState } from \"react\";\nimport {\n AssistantMessageAccumulator,\n DataStreamDecoder,\n AssistantTransportDecoder,\n unstable_createInitialMessage as createInitialMessage,\n toToolsJSONSchema,\n} from \"assistant-stream\";\nimport type {\n AssistantTransportOptions,\n AddMessageCommand,\n AddToolResultCommand,\n UserMessagePart,\n QueuedCommand,\n AssistantTransportCommand,\n SendCommandsRequestBody,\n} from \"./types\";\nimport { useCommandQueue } from \"./commandQueue\";\nimport {\n createReplayBoundaryStream,\n useReplayRenderWait,\n} from \"./replayBoundaryStream\";\nimport { useRunManager } from \"./runManager\";\nimport { useConvertedState } from \"./useConvertedState\";\nimport type { ToolExecutionStatus } from \"@assistant-ui/core\";\nimport { createRequestHeaders } from \"@assistant-ui/core\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { InMemoryThreadListAdapter } from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { UserExternalState } from \"../../../augmentations\";\n\nconst convertAppendMessageToCommand = (\n message: AppendMessage,\n): AddMessageCommand => {\n if (message.role !== \"user\")\n throw new Error(\"Only user messages are supported\");\n\n const parts: UserMessagePart[] = [];\n const content = [\n ...message.content,\n ...(message.attachments?.flatMap((a) => a.content) ?? []),\n ];\n for (const contentPart of content) {\n if (contentPart.type === \"text\") {\n parts.push({ type: \"text\", text: contentPart.text });\n } else if (contentPart.type === \"image\") {\n parts.push({ type: \"image\", image: contentPart.image });\n }\n }\n\n return {\n type: \"add-message\",\n message: {\n role: \"user\",\n parts,\n },\n parentId: message.parentId,\n sourceId: message.sourceId,\n };\n};\n\nconst symbolAssistantTransportExtras = Symbol(\"assistant-transport-extras\");\ntype AssistantTransportExtras = {\n [symbolAssistantTransportExtras]: true;\n sendCommand: (command: AssistantTransportCommand) => void;\n state: UserExternalState;\n};\n\nconst asAssistantTransportExtras = (\n extras: unknown,\n): AssistantTransportExtras => {\n if (\n typeof extras !== \"object\" ||\n extras == null ||\n !(symbolAssistantTransportExtras in extras)\n )\n throw new Error(\n \"This method can only be called when you are using useAssistantTransportRuntime\",\n );\n\n return extras as AssistantTransportExtras;\n};\n\nexport const useAssistantTransportSendCommand = () => {\n const aui = useAui();\n\n return (command: AssistantTransportCommand) => {\n const extras = aui.thread().getState().extras;\n const transportExtras = asAssistantTransportExtras(extras);\n transportExtras.sendCommand(command);\n };\n};\n\nexport function useAssistantTransportState(): UserExternalState;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T,\n): T;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T = (t) => t as T,\n): T | UserExternalState {\n return useAuiState((s) =>\n selector(asAssistantTransportExtras(s.thread.extras).state),\n );\n}\n\nconst useAssistantTransportThreadRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const agentStateRef = useRef(options.initialState);\n const [, rerender] = useState(0);\n const resumeFlagRef = useRef(false);\n const [isReplaying, setIsReplaying] = useState(false);\n const waitForReplayRender = useReplayRenderWait();\n const parentIdRef = useRef<string | null | undefined>(undefined);\n const commandQueue = useCommandQueue({\n onQueue: () => runManager.schedule(),\n });\n\n const threadId = useAuiState((s) => s.threadListItem.remoteId);\n\n const runManager = useRunManager({\n onRun: async (signal: AbortSignal) => {\n const isResume = resumeFlagRef.current;\n resumeFlagRef.current = false;\n setIsReplaying(false);\n const commands: QueuedCommand[] = isResume ? [] : commandQueue.flush();\n if (commands.length === 0 && !isResume)\n throw new Error(\"No commands to send\");\n\n const headers = await createRequestHeaders(options.headers);\n const bodyValue =\n typeof options.body === \"function\"\n ? await options.body()\n : options.body;\n const context = runtime.thread.getModelContext();\n\n let requestBody: Record<string, unknown> = {\n commands,\n state: agentStateRef.current,\n system: context.system,\n tools: context.tools ? toToolsJSONSchema(context.tools) : undefined,\n threadId,\n ...(parentIdRef.current !== undefined && {\n parentId: parentIdRef.current,\n }),\n // nested (new format, aligned with AssistantChatTransport)\n callSettings: context.callSettings,\n config: context.config,\n // @deprecated spread at top level — use nested `callSettings`/`config` instead. Will be removed in a future version.\n ...context.callSettings,\n ...context.config,\n ...(bodyValue ?? {}),\n };\n\n if (options.prepareSendCommandsRequest) {\n requestBody = await options.prepareSendCommandsRequest(\n requestBody as SendCommandsRequestBody,\n );\n }\n\n const response = await fetch(\n isResume ? options.resumeApi! : options.api,\n {\n method: \"POST\",\n headers,\n body: JSON.stringify(requestBody),\n signal,\n },\n );\n\n options.onResponse?.(response);\n\n if (!response.ok) {\n throw new Error(`Status ${response.status}: ${await response.text()}`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const body = await createReplayBoundaryStream(response, {\n setReplaying: setIsReplaying,\n waitForRender: waitForReplayRender,\n });\n\n // Select decoder based on protocol option\n const protocol = options.protocol ?? \"data-stream\";\n const decoder =\n protocol === \"assistant-transport\"\n ? new AssistantTransportDecoder()\n : new DataStreamDecoder();\n\n let err: string | undefined;\n const stream = body.pipeThrough(decoder).pipeThrough(\n new AssistantMessageAccumulator({\n initialMessage: createInitialMessage({\n unstable_state:\n (agentStateRef.current as ReadonlyJSONValue) ?? null,\n }),\n throttle: isResume,\n onError: (error) => {\n err = error;\n },\n }),\n );\n\n let markedDelivered = false;\n\n for await (const chunk of asAsyncIterableStream(stream)) {\n if (chunk.metadata.unstable_state === agentStateRef.current) continue;\n\n if (!markedDelivered) {\n commandQueue.markDelivered();\n markedDelivered = true;\n }\n\n agentStateRef.current = chunk.metadata.unstable_state as T;\n rerender((prev) => prev + 1);\n }\n\n if (err) {\n throw new Error(err);\n }\n },\n onFinish: options.onFinish,\n onCancel: () => {\n setIsReplaying(false);\n const cmds = [\n ...commandQueue.state.inTransit,\n ...commandQueue.state.queued,\n ];\n\n commandQueue.reset();\n\n options.onCancel?.({\n commands: cmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n },\n onError: async (error) => {\n setIsReplaying(false);\n const inTransitCmds = [...commandQueue.state.inTransit];\n const queuedCmds = [...commandQueue.state.queued];\n\n commandQueue.reset();\n\n try {\n await options.onError?.(error as Error, {\n commands: inTransitCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n } finally {\n options.onCancel?.({\n commands: queuedCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n error: error as Error,\n });\n }\n },\n });\n\n // Tool execution status state\n const [toolStatuses, setToolStatuses] = useState<\n Record<string, ToolExecutionStatus>\n >({});\n\n // Reactive conversion of agent state + connection metadata → UI state\n const pendingCommands = useMemo(\n () => [...commandQueue.state.inTransit, ...commandQueue.state.queued],\n [commandQueue.state],\n );\n const converted = useConvertedState(\n options.converter,\n agentStateRef.current,\n pendingCommands,\n runManager.isRunning,\n toolStatuses,\n );\n\n // Create runtime\n const runtime = useExternalStoreRuntime({\n messages: converted.messages,\n state: converted.state,\n isRunning: converted.isRunning,\n isLoading: isReplaying,\n adapters: options.adapters,\n unstable_enableToolInvocations: true,\n setToolStatuses,\n extras: {\n [symbolAssistantTransportExtras]: true,\n sendCommand: (command: AssistantTransportCommand) => {\n commandQueue.enqueue(command);\n },\n state: agentStateRef.current as UserExternalState,\n } satisfies AssistantTransportExtras,\n onNew: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n ...(options.capabilities?.edit && {\n onEdit: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n }),\n onCancel: async () => {\n runManager.cancel();\n },\n onResume: async () => {\n if (!options.resumeApi)\n throw new Error(\"Must pass resumeApi to options to resume runs\");\n\n resumeFlagRef.current = true;\n runManager.schedule();\n },\n onAddToolResult: async (\n toolOptions: AddToolResultOptions,\n ): Promise<void> => {\n const command: AddToolResultCommand = {\n type: \"add-tool-result\",\n toolCallId: toolOptions.toolCallId,\n result: toolOptions.result as ReadonlyJSONObject,\n toolName: toolOptions.toolName,\n isError: toolOptions.isError,\n ...(toolOptions.artifact && { artifact: toolOptions.artifact }),\n ...(toolOptions.modelContent !== undefined && {\n modelContent: toolOptions.modelContent,\n }),\n };\n\n commandQueue.enqueue(command);\n },\n onLoadExternalState: async (state) => {\n agentStateRef.current = state as T;\n rerender((prev) => prev + 1);\n },\n });\n\n return runtime;\n};\n\n/**\n * @alpha This is an experimental API that is subject to change.\n */\nexport const useAssistantTransportRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const runtime = useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n return useAssistantTransportThreadRuntime(options);\n },\n adapter: new InMemoryThreadListAdapter(),\n allowNesting: true,\n });\n return runtime;\n};\n"],"mappings":";;;;;;;;;;;;;AA0CA,MAAM,iCACJ,YACsB;CACtB,IAAI,QAAQ,SAAS,QACnB,MAAM,IAAI,MAAM,kCAAkC;CAEpD,MAAM,QAA2B,CAAC;CAClC,MAAM,UAAU,CACd,GAAG,QAAQ,SACX,GAAI,QAAQ,aAAa,SAAS,MAAM,EAAE,OAAO,KAAK,CAAC,CACzD;CACA,KAAK,MAAM,eAAe,SACxB,IAAI,YAAY,SAAS,QACvB,MAAM,KAAK;EAAE,MAAM;EAAQ,MAAM,YAAY;CAAK,CAAC;MAC9C,IAAI,YAAY,SAAS,SAC9B,MAAM,KAAK;EAAE,MAAM;EAAS,OAAO,YAAY;CAAM,CAAC;CAI1D,OAAO;EACL,MAAM;EACN,SAAS;GACP,MAAM;GACN;EACF;EACA,UAAU,QAAQ;EAClB,UAAU,QAAQ;CACpB;AACF;AAEA,MAAM,iCAAiC,OAAO,4BAA4B;AAO1E,MAAM,8BACJ,WAC6B;CAC7B,IACE,OAAO,WAAW,YAClB,UAAU,QACV,EAAE,kCAAkC,SAEpC,MAAM,IAAI,MACR,gFACF;CAEF,OAAO;AACT;AAEA,MAAa,yCAAyC;CACpD,MAAM,MAAM,OAAO;CAEnB,QAAQ,YAAuC;EAC7C,MAAM,SAAS,IAAI,OAAO,EAAE,SAAS,EAAE;EAEvC,2BADmD,MACrC,EAAE,YAAY,OAAO;CACrC;AACF;AAMA,SAAgB,2BACd,Y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EACA,UAAU,YAAY;GACpB,IAAI,CAAC,QAAQ,WACX,MAAM,IAAI,MAAM,+CAA+C;GAEjE,cAAc,UAAU;GACxB,WAAW,SAAS;EACtB;EACA,iBAAiB,OACf,gBACkB;GAClB,MAAM,UAAgC;IACpC,MAAM;IACN,YAAY,YAAY;IACxB,QAAQ,YAAY;IACpB,UAAU,YAAY;IACtB,SAAS,YAAY;IACrB,GAAI,YAAY,YAAY,EAAE,UAAU,YAAY,SAAS;IAC7D,GAAI,YAAY,iBAAiB,KAAA,KAAa,EAC5C,cAAc,YAAY,aAC5B;GACF;GAEA,aAAa,QAAQ,OAAO;EAC9B;EACA,qBAAqB,OAAO,UAAU;GACpC,cAAc,UAAU;GACxB,UAAU,SAAS,OAAO,CAAC;EAC7B;CACF,CAAC;CAED,OAAO;AACT;;;;AAKA,MAAa,gCACX,YACqB;CAQrB,OAPgB,2BAA2B;EACzC,aAAa,SAAS,cAAc;GAClC,OAAO,mCAAmC,OAAO;EACnD;EACA,SAAS,IAAI,0BAA0B;EACvC,cAAc;CAChB,CACa;AACf"}
|
|
@@ -32,7 +32,7 @@ type Unstable_UseMentionAdapterOptions = {
|
|
|
32
32
|
/** Flat mention list. Ignored when `categories` is set. */readonly items?: readonly Unstable_Mention[]; /** Categorized mentions for drill-down navigation. */
|
|
33
33
|
readonly categories?: readonly Unstable_MentionCategory[];
|
|
34
34
|
/**
|
|
35
|
-
* How tools registered
|
|
35
|
+
* How tools registered in model context integrate.
|
|
36
36
|
* - `false`: exclude.
|
|
37
37
|
* - `true`: include (default when no `items`/`categories`; as a category
|
|
38
38
|
* if `categories` is set, flat otherwise).
|
|
@@ -54,7 +54,7 @@ type Unstable_MentionDirective = {
|
|
|
54
54
|
* @deprecated Under active development and might change without notice.
|
|
55
55
|
*
|
|
56
56
|
* Creates a spreadable `{ adapter, directive }` bundle for `@` mentions.
|
|
57
|
-
* Supports tools registered
|
|
57
|
+
* Supports tools registered in model context, explicit items, or both —
|
|
58
58
|
* flat or categorized.
|
|
59
59
|
*
|
|
60
60
|
* @example
|
|
@@ -7,7 +7,7 @@ import { useMemo } from "react";
|
|
|
7
7
|
* @deprecated Under active development and might change without notice.
|
|
8
8
|
*
|
|
9
9
|
* Creates a spreadable `{ adapter, directive }` bundle for `@` mentions.
|
|
10
|
-
* Supports tools registered
|
|
10
|
+
* Supports tools registered in model context, explicit items, or both —
|
|
11
11
|
* flat or categorized.
|
|
12
12
|
*
|
|
13
13
|
* @example
|