@assistant-ui/react 0.10.39 → 0.10.41
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AssistantCloudThreadHistoryAdapter.d.ts","sourceRoot":"","sources":["../../src/cloud/AssistantCloudThreadHistoryAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"AssistantCloudThreadHistoryAdapter.d.ts","sourceRoot":"","sources":["../../src/cloud/AssistantCloudThreadHistoryAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA6JjD,eAAO,MAAM,qCAAqC,GAChD,UAAU,SAAS,CAAC,cAAc,CAAC,KAClC,oBAQF,CAAC"}
|
@@ -50,7 +50,12 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
50
50
|
async load() {
|
51
51
|
const remoteId = this.threadListItemRuntime.getState().remoteId;
|
52
52
|
if (!remoteId) return { messages: [] };
|
53
|
-
const { messages } = await this.cloudRef.current.threads.messages.list(
|
53
|
+
const { messages } = await this.cloudRef.current.threads.messages.list(
|
54
|
+
remoteId,
|
55
|
+
{
|
56
|
+
format: "aui/v0"
|
57
|
+
}
|
58
|
+
);
|
54
59
|
const payload = {
|
55
60
|
messages: messages.filter(
|
56
61
|
(m) => m.format === "aui/v0"
|
@@ -76,7 +81,12 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
76
81
|
async _loadWithFormat(format, decoder) {
|
77
82
|
const remoteId = this.threadListItemRuntime.getState().remoteId;
|
78
83
|
if (!remoteId) return { messages: [] };
|
79
|
-
const { messages } = await this.cloudRef.current.threads.messages.list(
|
84
|
+
const { messages } = await this.cloudRef.current.threads.messages.list(
|
85
|
+
remoteId,
|
86
|
+
{
|
87
|
+
format
|
88
|
+
}
|
89
|
+
);
|
80
90
|
return {
|
81
91
|
messages: messages.filter((m) => m.format === format).map(
|
82
92
|
(m) => decoder({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/cloud/AssistantCloudThreadHistoryAdapter.tsx"],"sourcesContent":["import { RefObject, useState } from \"react\";\nimport { useThreadListItemRuntime } from \"../context\";\nimport { ThreadHistoryAdapter } from \"../runtimes/adapters/thread-history/ThreadHistoryAdapter\";\nimport { ExportedMessageRepositoryItem } from \"../runtimes/utils/MessageRepository\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport { auiV0Decode, auiV0Encode } from \"./auiV0\";\nimport { ThreadListItemRuntime } from \"../api\";\nimport {\n MessageFormatAdapter,\n MessageFormatItem,\n MessageFormatRepository,\n MessageStorageEntry,\n} from \"../runtimes/adapters/thread-history/MessageFormatAdapter\";\nimport { GenericThreadHistoryAdapter } from \"../runtimes/adapters/thread-history/ThreadHistoryAdapter\";\nimport { ReadonlyJSONObject } from \"assistant-stream/utils\";\n\nclass FormattedThreadHistoryAdapter<TMessage, TStorageFormat>\n implements GenericThreadHistoryAdapter<TMessage>\n{\n constructor(\n private parent: AssistantCloudThreadHistoryAdapter,\n private formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>,\n ) {}\n\n async append(item: MessageFormatItem<TMessage>) {\n // Encode the message using the format adapter\n const encoded = this.formatAdapter.encode(item);\n const messageId = this.formatAdapter.getId(item.message);\n\n // Delegate to parent's internal append method with the encoded format\n return this.parent._appendWithFormat(\n item.parentId,\n messageId,\n this.formatAdapter.format,\n encoded,\n );\n }\n\n async load(): Promise<MessageFormatRepository<TMessage>> {\n // Delegate to parent's internal load method with format filter\n return this.parent._loadWithFormat(\n this.formatAdapter.format,\n (message: MessageStorageEntry<TStorageFormat>) =>\n this.formatAdapter.decode(message),\n );\n }\n}\n\nclass AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {\n constructor(\n private cloudRef: RefObject<AssistantCloud>,\n private threadListItemRuntime: ThreadListItemRuntime,\n ) {}\n\n private _getIdForLocalId: Record<string, string | Promise<string>> = {};\n\n withFormat<TMessage, TStorageFormat>(\n formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>,\n ): GenericThreadHistoryAdapter<TMessage> {\n return new FormattedThreadHistoryAdapter(this, formatAdapter);\n }\n\n async append({ parentId, message }: ExportedMessageRepositoryItem) {\n const { remoteId } = await this.threadListItemRuntime.initialize();\n const task = this.cloudRef.current.threads.messages\n .create(remoteId, {\n parent_id: parentId\n ? ((await this._getIdForLocalId[parentId]) ?? parentId)\n : null,\n format: \"aui/v0\",\n content: auiV0Encode(message),\n })\n .then(({ message_id }) => {\n this._getIdForLocalId[message.id] = message_id;\n return message_id;\n });\n\n this._getIdForLocalId[message.id] = task;\n\n return task.then(() => {});\n }\n\n async load() {\n const remoteId = this.threadListItemRuntime.getState().remoteId;\n if (!remoteId) return { messages: [] };\n const { messages }
|
1
|
+
{"version":3,"sources":["../../src/cloud/AssistantCloudThreadHistoryAdapter.tsx"],"sourcesContent":["import { RefObject, useState } from \"react\";\nimport { useThreadListItemRuntime } from \"../context\";\nimport { ThreadHistoryAdapter } from \"../runtimes/adapters/thread-history/ThreadHistoryAdapter\";\nimport { ExportedMessageRepositoryItem } from \"../runtimes/utils/MessageRepository\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport { auiV0Decode, auiV0Encode } from \"./auiV0\";\nimport { ThreadListItemRuntime } from \"../api\";\nimport {\n MessageFormatAdapter,\n MessageFormatItem,\n MessageFormatRepository,\n MessageStorageEntry,\n} from \"../runtimes/adapters/thread-history/MessageFormatAdapter\";\nimport { GenericThreadHistoryAdapter } from \"../runtimes/adapters/thread-history/ThreadHistoryAdapter\";\nimport { ReadonlyJSONObject } from \"assistant-stream/utils\";\n\nclass FormattedThreadHistoryAdapter<TMessage, TStorageFormat>\n implements GenericThreadHistoryAdapter<TMessage>\n{\n constructor(\n private parent: AssistantCloudThreadHistoryAdapter,\n private formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>,\n ) {}\n\n async append(item: MessageFormatItem<TMessage>) {\n // Encode the message using the format adapter\n const encoded = this.formatAdapter.encode(item);\n const messageId = this.formatAdapter.getId(item.message);\n\n // Delegate to parent's internal append method with the encoded format\n return this.parent._appendWithFormat(\n item.parentId,\n messageId,\n this.formatAdapter.format,\n encoded,\n );\n }\n\n async load(): Promise<MessageFormatRepository<TMessage>> {\n // Delegate to parent's internal load method with format filter\n return this.parent._loadWithFormat(\n this.formatAdapter.format,\n (message: MessageStorageEntry<TStorageFormat>) =>\n this.formatAdapter.decode(message),\n );\n }\n}\n\nclass AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {\n constructor(\n private cloudRef: RefObject<AssistantCloud>,\n private threadListItemRuntime: ThreadListItemRuntime,\n ) {}\n\n private _getIdForLocalId: Record<string, string | Promise<string>> = {};\n\n withFormat<TMessage, TStorageFormat>(\n formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>,\n ): GenericThreadHistoryAdapter<TMessage> {\n return new FormattedThreadHistoryAdapter(this, formatAdapter);\n }\n\n async append({ parentId, message }: ExportedMessageRepositoryItem) {\n const { remoteId } = await this.threadListItemRuntime.initialize();\n const task = this.cloudRef.current.threads.messages\n .create(remoteId, {\n parent_id: parentId\n ? ((await this._getIdForLocalId[parentId]) ?? parentId)\n : null,\n format: \"aui/v0\",\n content: auiV0Encode(message),\n })\n .then(({ message_id }) => {\n this._getIdForLocalId[message.id] = message_id;\n return message_id;\n });\n\n this._getIdForLocalId[message.id] = task;\n\n return task.then(() => {});\n }\n\n async load() {\n const remoteId = this.threadListItemRuntime.getState().remoteId;\n if (!remoteId) return { messages: [] };\n const { messages } = await this.cloudRef.current.threads.messages.list(\n remoteId,\n {\n format: \"aui/v0\",\n },\n );\n const payload = {\n messages: messages\n .filter(\n (m): m is typeof m & { format: \"aui/v0\" } => m.format === \"aui/v0\",\n )\n .map(auiV0Decode)\n .reverse(),\n };\n return payload;\n }\n\n // Internal methods for FormattedThreadHistoryAdapter\n async _appendWithFormat<T>(\n parentId: string | null,\n messageId: string,\n format: string,\n content: T,\n ) {\n const { remoteId } = await this.threadListItemRuntime.initialize();\n\n const task = this.cloudRef.current.threads.messages\n .create(remoteId, {\n parent_id: parentId\n ? ((await this._getIdForLocalId[parentId]) ?? parentId)\n : null,\n format,\n content: content as ReadonlyJSONObject,\n })\n .then(({ message_id }) => {\n this._getIdForLocalId[messageId] = message_id;\n return message_id;\n });\n\n this._getIdForLocalId[messageId] = task;\n\n return task.then(() => {});\n }\n\n async _loadWithFormat<TMessage, TStorageFormat>(\n format: string,\n decoder: (\n message: MessageStorageEntry<TStorageFormat>,\n ) => MessageFormatItem<TMessage>,\n ): Promise<MessageFormatRepository<TMessage>> {\n const remoteId = this.threadListItemRuntime.getState().remoteId;\n if (!remoteId) return { messages: [] };\n\n const { messages } = await this.cloudRef.current.threads.messages.list(\n remoteId,\n {\n format,\n },\n );\n\n return {\n messages: messages\n .filter((m) => m.format === format)\n .map((m) =>\n decoder({\n id: m.id,\n parent_id: m.parent_id,\n format: m.format,\n content: m.content as TStorageFormat,\n }),\n )\n .reverse(),\n };\n }\n}\n\nexport const useAssistantCloudThreadHistoryAdapter = (\n cloudRef: RefObject<AssistantCloud>,\n): ThreadHistoryAdapter => {\n const threadListItemRuntime = useThreadListItemRuntime();\n const [adapter] = useState(\n () =>\n new AssistantCloudThreadHistoryAdapter(cloudRef, threadListItemRuntime),\n );\n\n return adapter;\n};\n"],"mappings":";AAAA,SAAoB,gBAAgB;AACpC,SAAS,gCAAgC;AAIzC,SAAS,aAAa,mBAAmB;AAWzC,IAAM,gCAAN,MAEA;AAAA,EACE,YACU,QACA,eACR;AAFQ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AAAA,EACF;AACF;AAEO,IAAM,wCAAwC,CACnD,aACyB;AACzB,QAAM,wBAAwB,yBAAyB;AACvD,QAAM,CAAC,OAAO,IAAI;AAAA,IAChB,MACE,IAAI,mCAAmC,UAAU,qBAAqB;AAAA,EAC1E;AAEA,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
"conversational-ui",
|
29
29
|
"conversational-ai"
|
30
30
|
],
|
31
|
-
"version": "0.10.
|
31
|
+
"version": "0.10.41",
|
32
32
|
"license": "MIT",
|
33
33
|
"type": "module",
|
34
34
|
"exports": {
|
@@ -63,7 +63,7 @@
|
|
63
63
|
"react-textarea-autosize": "^8.5.9",
|
64
64
|
"zod": "^4.0.14",
|
65
65
|
"zustand": "^5.0.7",
|
66
|
-
"assistant-cloud": "0.0
|
66
|
+
"assistant-cloud": "0.1.0"
|
67
67
|
},
|
68
68
|
"peerDependencies": {
|
69
69
|
"@types/react": "*",
|
@@ -83,8 +83,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
83
83
|
async load() {
|
84
84
|
const remoteId = this.threadListItemRuntime.getState().remoteId;
|
85
85
|
if (!remoteId) return { messages: [] };
|
86
|
-
const { messages } =
|
87
|
-
|
86
|
+
const { messages } = await this.cloudRef.current.threads.messages.list(
|
87
|
+
remoteId,
|
88
|
+
{
|
89
|
+
format: "aui/v0",
|
90
|
+
},
|
91
|
+
);
|
88
92
|
const payload = {
|
89
93
|
messages: messages
|
90
94
|
.filter(
|
@@ -132,8 +136,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
132
136
|
const remoteId = this.threadListItemRuntime.getState().remoteId;
|
133
137
|
if (!remoteId) return { messages: [] };
|
134
138
|
|
135
|
-
const { messages } =
|
136
|
-
|
139
|
+
const { messages } = await this.cloudRef.current.threads.messages.list(
|
140
|
+
remoteId,
|
141
|
+
{
|
142
|
+
format,
|
143
|
+
},
|
144
|
+
);
|
137
145
|
|
138
146
|
return {
|
139
147
|
messages: messages
|