@assistant-ui/core 0.2.12 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/thread-history.d.ts +3 -1
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js.map +1 -1
- package/dist/react/AssistantProvider.js +6 -1
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +1 -1
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.js +16 -6
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +1 -8
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.js +3 -2
- package/dist/react/client/DataRenderers.js.map +1 -1
- package/dist/react/client/Interactables.d.ts +1 -1
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +4 -3
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/Tools.d.ts +2 -13
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +4 -3
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +3 -2
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +4 -4
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +28 -1
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +43 -9
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +3 -2
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +2 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +1 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +6 -0
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +2 -0
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
- package/dist/react/utils/groupParts.d.ts +13 -1
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/groupParts.js +17 -5
- package/dist/react/utils/groupParts.js.map +1 -1
- package/dist/runtime/api/bindings.d.ts +1 -0
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +2 -0
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +5 -0
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js +1 -0
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +3 -0
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +4 -0
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +1 -0
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts +30 -0
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -0
- package/dist/runtime/branch/external-thread-branch-adapter.js +0 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +2 -0
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +1 -0
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +1 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +13 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +8 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +63 -5
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.js +4 -2
- package/dist/runtimes/local/should-continue.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +2 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +4 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +4 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +1 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +1 -0
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts +2 -7
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/chain-of-thought-client.js +3 -2
- package/dist/store/clients/chain-of-thought-client.js.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +1 -1
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/model-context-client.js +3 -2
- package/dist/store/clients/model-context-client.js.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +2 -4
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.js +3 -2
- package/dist/store/clients/no-op-composer-client.js.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +1 -3
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.js +2 -15
- package/dist/store/clients/runtime-adapter.js.map +1 -1
- package/dist/store/clients/suggestions.d.ts +1 -4
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/suggestions.js +6 -4
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +1 -1
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +14 -10
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/internal.d.ts +2 -2
- package/dist/store/internal.js +2 -2
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.js +3 -2
- package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +2 -10
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +9 -6
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.js +3 -2
- package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +2 -7
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +10 -6
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +3 -2
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +2 -5
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +6 -4
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +7 -4
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/scopes/message.d.ts +1 -0
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +1 -0
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +1 -0
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/adapters/thread-history.ts +2 -0
- package/src/index.ts +1 -0
- package/src/react/AssistantProvider.tsx +3 -1
- package/src/react/RuntimeAdapter.ts +25 -8
- package/src/react/client/DataRenderers.ts +42 -45
- package/src/react/client/Interactables.ts +261 -261
- package/src/react/client/Tools.ts +6 -4
- package/src/react/primitives/message/MessageGroupedParts.tsx +19 -7
- package/src/react/primitives/message/MessageParts.tsx +64 -13
- package/src/react/providers/TextMessagePartProvider.tsx +5 -3
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +1 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +11 -0
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +6 -0
- package/src/react/utils/groupParts.ts +27 -0
- package/src/runtime/api/bindings.ts +1 -0
- package/src/runtime/api/message-runtime.ts +7 -0
- package/src/runtime/api/thread-list-runtime.ts +1 -0
- package/src/runtime/api/thread-runtime.ts +7 -0
- package/src/runtime/base/base-thread-runtime-core.ts +1 -0
- package/src/runtime/branch/external-thread-branch-adapter.ts +26 -0
- package/src/runtime/interfaces/thread-list-runtime-core.ts +1 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +2 -0
- package/src/runtimes/external-store/external-store-adapter.ts +1 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +24 -0
- package/src/runtimes/local/local-runtime-options.ts +1 -1
- package/src/runtimes/local/local-thread-runtime-core.test.ts +311 -0
- package/src/runtimes/local/local-thread-runtime-core.ts +104 -7
- package/src/runtimes/local/should-continue.ts +23 -13
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +5 -0
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +5 -0
- package/src/runtimes/remote-thread-list/remote-thread-state.ts +2 -0
- package/src/runtimes/remote-thread-list/types.ts +1 -0
- package/src/store/clients/chain-of-thought-client.ts +5 -3
- package/src/store/clients/model-context-client.test.ts +5 -4
- package/src/store/clients/model-context-client.ts +21 -21
- package/src/store/clients/no-op-composer-client.ts +5 -3
- package/src/store/clients/runtime-adapter.ts +0 -24
- package/src/store/clients/suggestions.ts +9 -18
- package/src/store/clients/thread-message-client.ts +29 -26
- package/src/store/internal.ts +1 -4
- package/src/store/runtime-clients/attachment-runtime-client.ts +14 -14
- package/src/store/runtime-clients/composer-runtime-client.ts +30 -24
- package/src/store/runtime-clients/message-part-runtime-client.ts +5 -3
- package/src/store/runtime-clients/message-runtime-client.ts +26 -19
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +5 -3
- package/src/store/runtime-clients/thread-list-runtime-client.ts +10 -6
- package/src/store/runtime-clients/thread-runtime-client.ts +11 -6
- package/src/store/scopes/message.ts +1 -0
- package/src/store/scopes/thread-list-item.ts +1 -0
- package/src/store/scopes/thread.ts +1 -0
- package/src/tests/external-store-thread-runtime-core.test.ts +57 -0
- package/src/tests/groupMessageParts.test.ts +84 -0
- package/src/tests/groupParts.test.ts +55 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantCloudThreadHistoryAdapter.d.ts","names":[],"sources":["../../../../src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"AssistantCloudThreadHistoryAdapter.d.ts","names":[],"sources":["../../../../src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts"],"mappings":";;;;;iBAmxBgB,qCAAA,CACd,QAAA,EAAU,SAAA,CAAU,cAAA,IACnB,oBAAA"}
|
|
@@ -29,6 +29,9 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
|
29
29
|
if (!remoteId) return;
|
|
30
30
|
await formatted.update?.(remoteId, item, localMessageId);
|
|
31
31
|
},
|
|
32
|
+
async delete() {
|
|
33
|
+
throw new Error("Assistant Cloud does not support deleting thread messages yet.");
|
|
34
|
+
},
|
|
32
35
|
reportTelemetry(items, options) {
|
|
33
36
|
const encodedRunMessages = items.map((item) => formatAdapter.encode(item));
|
|
34
37
|
adapter._reportRunTelemetry(formatAdapter.format, encodedRunMessages, options);
|
|
@@ -46,6 +49,9 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
|
46
49
|
await this._persistence.append(remoteId, message.id, parentId, "aui/v0", encoded);
|
|
47
50
|
if (this.cloudRef.current.telemetry.enabled) this._maybeReportRun(remoteId, "aui/v0", encoded);
|
|
48
51
|
}
|
|
52
|
+
async delete() {
|
|
53
|
+
throw new Error("Assistant Cloud does not support deleting thread messages yet.");
|
|
54
|
+
}
|
|
49
55
|
async load() {
|
|
50
56
|
const remoteId = this.aui.threadListItem().getState().remoteId;
|
|
51
57
|
if (!remoteId) return { messages: [] };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantCloudThreadHistoryAdapter.js","names":[],"sources":["../../../../src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts"],"sourcesContent":["import { type RefObject, useState } from \"react\";\nimport type {\n GenericThreadHistoryAdapter,\n ThreadHistoryAdapter,\n MessageFormatAdapter,\n MessageFormatItem,\n MessageFormatRepository,\n} from \"../../../adapters/thread-history\";\nimport type { ExportedMessageRepositoryItem } from \"../../../runtime/utils/message-repository\";\nimport {\n type AssistantCloud,\n CloudMessagePersistence,\n createFormattedPersistence,\n} from \"assistant-cloud\";\nimport { auiV0Decode, auiV0Encode } from \"./auiV0\";\nimport { type AssistantClient, useAui } from \"@assistant-ui/store\";\nimport type { ThreadListItemMethods } from \"../../../store/scopes/thread-list-item\";\n\nconst globalPersistence = new WeakMap<\n ThreadListItemMethods,\n CloudMessagePersistence\n>();\n\nclass AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {\n constructor(\n private cloudRef: RefObject<AssistantCloud>,\n private aui: AssistantClient,\n ) {}\n\n private get _persistence(): CloudMessagePersistence {\n const key = this.aui.threadListItem();\n if (!globalPersistence.has(key)) {\n globalPersistence.set(\n key,\n new CloudMessagePersistence(this.cloudRef.current),\n );\n }\n return globalPersistence.get(key)!;\n }\n\n withFormat<TMessage, TStorageFormat extends Record<string, unknown>>(\n formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>,\n ): GenericThreadHistoryAdapter<TMessage> {\n const adapter = this;\n const formatted = createFormattedPersistence(\n this._persistence,\n formatAdapter,\n );\n return {\n // Note: callers must also call reportTelemetry() for run tracking\n async append(item: MessageFormatItem<TMessage>) {\n const { remoteId } = await adapter.aui.threadListItem().initialize();\n await formatted.append(remoteId, item);\n },\n async update(item: MessageFormatItem<TMessage>, localMessageId: string) {\n const remoteId = adapter.aui.threadListItem().getState().remoteId;\n if (!remoteId) return;\n await formatted.update?.(remoteId, item, localMessageId);\n },\n reportTelemetry(\n items: MessageFormatItem<TMessage>[],\n options?: {\n durationMs?: number;\n stepTimestamps?: StepTimestamp[];\n },\n ) {\n const encodedRunMessages = items.map((item) =>\n formatAdapter.encode(item),\n );\n adapter._reportRunTelemetry(\n formatAdapter.format,\n encodedRunMessages,\n options,\n );\n },\n async load(): Promise<MessageFormatRepository<TMessage>> {\n const remoteId = adapter.aui.threadListItem().getState().remoteId;\n if (!remoteId) return { messages: [] };\n return formatted.load(remoteId);\n },\n };\n }\n\n async append({ parentId, message }: ExportedMessageRepositoryItem) {\n const { remoteId } = await this.aui.threadListItem().initialize();\n const encoded = auiV0Encode(message);\n await this._persistence.append(\n remoteId,\n message.id,\n parentId,\n \"aui/v0\",\n encoded,\n );\n\n if (this.cloudRef.current.telemetry.enabled) {\n this._maybeReportRun(remoteId, \"aui/v0\", encoded);\n }\n }\n\n async load() {\n const remoteId = this.aui.threadListItem().getState().remoteId;\n if (!remoteId) return { messages: [] };\n const messages = await this._persistence.load(remoteId, \"aui/v0\");\n return {\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 }\n\n private _reportRunTelemetry<T>(\n format: string,\n runMessages: T[],\n options?: {\n durationMs?: number;\n stepTimestamps?: StepTimestamp[];\n },\n ) {\n if (!this.cloudRef.current.telemetry.enabled) return;\n\n const remoteId = this.aui.threadListItem().getState().remoteId;\n if (!remoteId) return;\n\n const extracted = extractRunTelemetry(format, runMessages);\n if (!extracted) return;\n\n this._sendReport(\n remoteId,\n extracted,\n options?.durationMs,\n options?.stepTimestamps,\n );\n }\n\n private _maybeReportRun<T>(remoteId: string, format: string, content: T) {\n const extracted = extractTelemetry(format, content);\n if (!extracted) return;\n\n this._sendReport(remoteId, extracted);\n }\n\n private _sendReport(\n remoteId: string,\n data: TelemetryData,\n durationMs?: number,\n stepTimestamps?: StepTimestamp[],\n ) {\n const mergedSteps = mergeStepTimestamps(data.steps, stepTimestamps);\n // Keep in sync with assistant-cloud createRunSchema\n // (apps/aui-cloud-api/src/endpoints/runs/create.ts).\n const initial: Parameters<typeof this.cloudRef.current.runs.report>[0] = {\n thread_id: remoteId,\n status: data.status,\n ...(data.totalSteps != null\n ? { total_steps: data.totalSteps }\n : undefined),\n ...(data.toolCalls ? { tool_calls: data.toolCalls } : undefined),\n ...(mergedSteps ? { steps: mergedSteps } : undefined),\n ...(data.inputTokens != null\n ? { input_tokens: data.inputTokens }\n : undefined),\n ...(data.outputTokens != null\n ? { output_tokens: data.outputTokens }\n : undefined),\n ...(data.reasoningTokens != null\n ? { reasoning_tokens: data.reasoningTokens }\n : undefined),\n ...(data.cachedInputTokens != null\n ? { cached_input_tokens: data.cachedInputTokens }\n : undefined),\n ...(durationMs != null ? { duration_ms: durationMs } : undefined),\n ...(data.outputText != null\n ? { output_text: data.outputText }\n : undefined),\n ...(data.metadata ? { metadata: data.metadata } : undefined),\n ...(data.modelId ? { model_id: data.modelId } : undefined),\n };\n\n const { beforeReport } = this.cloudRef.current.telemetry;\n const report = beforeReport ? beforeReport(initial) : initial;\n if (!report) return;\n\n this.cloudRef.current.runs.report(report).catch(() => {});\n }\n}\n\nconst MAX_SPAN_CONTENT = 50_000;\n\nfunction truncateStr(value: string): string {\n if (value.length <= MAX_SPAN_CONTENT) return value;\n return value.slice(0, MAX_SPAN_CONTENT);\n}\n\nfunction safeStringify(value: unknown): string | undefined {\n if (value == null) return undefined;\n try {\n return truncateStr(JSON.stringify(value));\n } catch {\n return undefined;\n }\n}\n\ntype TelemetryToolCall = {\n tool_name: string;\n tool_call_id: string;\n tool_args?: string;\n tool_result?: string;\n tool_source?: \"mcp\" | \"frontend\" | \"backend\";\n};\n\nconst BASE64_PATTERN = /^[A-Za-z0-9+/]{100,}={0,2}$/;\n\nfunction summarizeMcpResult(value: unknown): string | undefined {\n if (value == null) return undefined;\n try {\n const parsed = typeof value === \"string\" ? JSON.parse(value) : value;\n if (Array.isArray(parsed)) {\n const summarized = parsed.map((item) => {\n if (item && typeof item === \"object\" && item.type) {\n if (\n (item.type === \"image\" || item.type === \"audio\") &&\n typeof item.data === \"string\" &&\n BASE64_PATTERN.test(item.data.slice(0, 200))\n ) {\n const sizeKB = ((item.data.length * 3) / 4 / 1024).toFixed(1);\n return { ...item, data: `[${item.type}: ${sizeKB}KB]` };\n }\n }\n return item;\n });\n return truncateStr(JSON.stringify(summarized));\n }\n } catch {\n // not JSON array, fall through\n }\n return safeStringify(value);\n}\n\nfunction buildToolCall(\n toolName: string,\n toolCallId: string,\n args: unknown,\n result: unknown,\n argsText?: string,\n toolSource?: \"mcp\" | \"frontend\" | \"backend\",\n): TelemetryToolCall {\n const call: TelemetryToolCall = {\n tool_name: toolName,\n tool_call_id: toolCallId,\n };\n const toolArgs = argsText ?? safeStringify(args);\n if (toolArgs !== undefined) call.tool_args = toolArgs;\n const toolResult =\n toolSource === \"mcp\" ? summarizeMcpResult(result) : safeStringify(result);\n if (toolResult !== undefined) call.tool_result = toolResult;\n if (toolSource) call.tool_source = toolSource;\n return call;\n}\n\ntype TelemetryStepData = {\n input_tokens?: number;\n output_tokens?: number;\n reasoning_tokens?: number;\n cached_input_tokens?: number;\n tool_calls?: TelemetryToolCall[];\n start_ms?: number;\n end_ms?: number;\n};\n\ntype StepTimestamp = { start_ms: number; end_ms: number };\n\nfunction mergeStepTimestamps(\n steps: TelemetryStepData[] | undefined,\n timestamps: StepTimestamp[] | undefined,\n): TelemetryStepData[] | undefined {\n if (!timestamps) return steps;\n if (!steps) return timestamps.map((t) => ({ ...t }));\n\n const len = Math.min(steps.length, timestamps.length);\n return steps.map((s, i) => ({\n ...s,\n ...(i < len ? timestamps[i] : undefined),\n }));\n}\n\ntype TelemetryData = {\n status: \"completed\" | \"incomplete\" | \"error\";\n toolCalls?: TelemetryToolCall[];\n totalSteps?: number;\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n outputText?: string;\n metadata?: Record<string, unknown>;\n steps?: TelemetryStepData[];\n modelId?: string;\n};\n\nfunction extractTelemetry<T>(format: string, content: T): TelemetryData | null {\n switch (format) {\n case \"aui/v0\":\n return extractAuiV0(content);\n case \"ai-sdk/v6\":\n return extractAiSdkV6(content);\n default:\n return null;\n }\n}\n\nfunction extractRunTelemetry<T>(\n format: string,\n runMessages: T[],\n): TelemetryData | null {\n if (format === \"ai-sdk/v6\") {\n return aggregateAiSdkV6RunSteps(runMessages);\n }\n for (let i = runMessages.length - 1; i >= 0; i--) {\n const result = extractTelemetry(format, runMessages[i]!);\n if (result) return result;\n }\n return null;\n}\n\nconst AUI_STATUS_MAP: Record<string, TelemetryData[\"status\"]> = {\n error: \"error\",\n incomplete: \"incomplete\",\n};\n\nfunction extractAuiV0<T>(content: T): TelemetryData | null {\n const msg = content as {\n role?: string;\n status?: { type: string };\n content?: readonly {\n type: string;\n text?: string;\n toolName?: string;\n toolCallId?: string;\n args?: unknown;\n argsText?: string;\n result?: unknown;\n }[];\n metadata?: {\n modelId?: string;\n steps?: readonly {\n usage?: {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n };\n }[];\n custom?: Record<string, unknown> & { modelId?: string };\n };\n };\n\n if (msg.role !== \"assistant\") return null;\n\n const toolCalls = msg.content\n ?.filter((p) => p.type === \"tool-call\" && p.toolName && p.toolCallId)\n .map((p) =>\n buildToolCall(p.toolName!, p.toolCallId!, p.args, p.result, p.argsText),\n );\n\n const textParts = msg.content?.filter((p) => p.type === \"text\" && p.text);\n const outputText =\n textParts && textParts.length > 0\n ? truncateStr(textParts.map((p) => p.text).join(\"\"))\n : undefined;\n\n const steps = msg.metadata?.steps;\n let inputTokens: number | undefined;\n let outputTokens: number | undefined;\n let reasoningTokens: number | undefined;\n let cachedInputTokens: number | undefined;\n if (steps && steps.length > 0) {\n let totalInput = 0;\n let totalOutput = 0;\n let totalReasoning = 0;\n let totalCachedInput = 0;\n let hasInput = false;\n let hasOutput = false;\n let hasReasoning = false;\n let hasCachedInput = false;\n for (const step of steps) {\n if (step.usage?.inputTokens != null) {\n totalInput += step.usage.inputTokens;\n hasInput = true;\n }\n if (step.usage?.outputTokens != null) {\n totalOutput += step.usage.outputTokens;\n hasOutput = true;\n }\n if (step.usage?.reasoningTokens != null) {\n totalReasoning += step.usage.reasoningTokens;\n hasReasoning = true;\n }\n if (step.usage?.cachedInputTokens != null) {\n totalCachedInput += step.usage.cachedInputTokens;\n hasCachedInput = true;\n }\n }\n inputTokens = hasInput ? totalInput : undefined;\n outputTokens = hasOutput ? totalOutput : undefined;\n reasoningTokens = hasReasoning ? totalReasoning : undefined;\n cachedInputTokens = hasCachedInput ? totalCachedInput : undefined;\n }\n\n const statusType = msg.status?.type;\n const status: TelemetryData[\"status\"] =\n (statusType && AUI_STATUS_MAP[statusType]) || \"completed\";\n\n const metadata = msg.metadata?.custom as Record<string, unknown> | undefined;\n const modelId =\n msg.metadata?.modelId ??\n (typeof msg.metadata?.custom?.modelId === \"string\"\n ? msg.metadata.custom.modelId\n : undefined);\n\n const telemetrySteps: TelemetryStepData[] | undefined =\n steps && steps.length > 1\n ? steps.map((s) => ({\n ...(s.usage?.inputTokens != null\n ? { input_tokens: s.usage.inputTokens }\n : undefined),\n ...(s.usage?.outputTokens != null\n ? { output_tokens: s.usage.outputTokens }\n : undefined),\n ...(s.usage?.reasoningTokens != null\n ? { reasoning_tokens: s.usage.reasoningTokens }\n : undefined),\n ...(s.usage?.cachedInputTokens != null\n ? { cached_input_tokens: s.usage.cachedInputTokens }\n : undefined),\n }))\n : undefined;\n\n return {\n status,\n ...(toolCalls && toolCalls.length > 0 ? { toolCalls } : undefined),\n ...(steps?.length ? { totalSteps: steps.length } : undefined),\n ...(inputTokens != null ? { inputTokens } : undefined),\n ...(outputTokens != null ? { outputTokens } : undefined),\n ...(reasoningTokens != null ? { reasoningTokens } : undefined),\n ...(cachedInputTokens != null ? { cachedInputTokens } : undefined),\n ...(outputText != null ? { outputText } : undefined),\n ...(metadata ? { metadata } : undefined),\n ...(telemetrySteps ? { steps: telemetrySteps } : undefined),\n ...(modelId ? { modelId } : undefined),\n };\n}\n\ntype AiSdkV6Part = {\n type: string;\n text?: string;\n toolName?: string;\n toolCallId?: string;\n args?: unknown;\n result?: unknown;\n input?: unknown;\n output?: unknown;\n};\n\ntype AiSdkV6Message = {\n role?: string;\n parts?: readonly AiSdkV6Part[];\n metadata?: Record<string, unknown>;\n};\n\nfunction isToolCallPart(p: AiSdkV6Part): boolean {\n if (!p.toolCallId) return false;\n if (p.type === \"tool-call\" || p.type === \"dynamic-tool\") return !!p.toolName;\n return p.type.startsWith(\"tool-\") || p.type.startsWith(\"dynamic-tool-\");\n}\n\nfunction isDynamicToolPart(p: AiSdkV6Part): boolean {\n return p.type === \"dynamic-tool\" || p.type.startsWith(\"dynamic-tool-\");\n}\n\nfunction partToToolCall(p: AiSdkV6Part): TelemetryToolCall {\n const toolSource: \"mcp\" | undefined = isDynamicToolPart(p)\n ? \"mcp\"\n : undefined;\n return buildToolCall(\n p.toolName ?? p.type.slice(5),\n p.toolCallId!,\n p.args ?? p.input,\n p.result ?? p.output,\n undefined,\n toolSource,\n );\n}\n\nfunction collectAiSdkV6Parts(parts: readonly AiSdkV6Part[]): {\n textParts: string[];\n toolCalls: TelemetryToolCall[];\n stepsData: { tool_calls: TelemetryToolCall[] }[];\n} {\n const textParts: string[] = [];\n const toolCalls: TelemetryToolCall[] = [];\n const stepsData: { tool_calls: TelemetryToolCall[] }[] = [];\n let currentStepToolCalls: TelemetryToolCall[] | null = null;\n\n for (const p of parts) {\n if (p.type === \"step-start\") {\n if (currentStepToolCalls !== null) {\n stepsData.push({ tool_calls: currentStepToolCalls });\n }\n currentStepToolCalls = [];\n } else if (p.type === \"text\" && p.text) {\n textParts.push(p.text);\n } else if (isToolCallPart(p)) {\n const tc = partToToolCall(p);\n toolCalls.push(tc);\n if (currentStepToolCalls !== null) {\n currentStepToolCalls.push(tc);\n }\n }\n }\n\n if (currentStepToolCalls !== null) {\n stepsData.push({ tool_calls: currentStepToolCalls });\n }\n\n return { textParts, toolCalls, stepsData };\n}\n\nfunction extractModelId(\n metadata?: Record<string, unknown>,\n): string | undefined {\n if (!metadata) return undefined;\n if (typeof metadata.modelId === \"string\") return metadata.modelId;\n const custom = metadata.custom as Record<string, unknown> | undefined;\n if (typeof custom?.modelId === \"string\") return custom.modelId;\n return undefined;\n}\n\nfunction buildAiSdkV6Result(\n textParts: string[],\n toolCalls: TelemetryToolCall[],\n totalSteps: number,\n metadata?: Record<string, unknown>,\n stepsData?: { tool_calls: TelemetryToolCall[] }[],\n usage?: {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n },\n): TelemetryData {\n const hasText = textParts.length > 0;\n const outputText = hasText ? truncateStr(textParts.join(\"\")) : undefined;\n const modelId = extractModelId(metadata);\n\n const steps: TelemetryStepData[] | undefined =\n stepsData && stepsData.length > 1\n ? stepsData.map((s) => ({\n ...(s.tool_calls.length > 0\n ? { tool_calls: s.tool_calls }\n : undefined),\n }))\n : undefined;\n\n return {\n status: hasText ? \"completed\" : \"incomplete\",\n ...(toolCalls.length > 0 ? { toolCalls } : undefined),\n ...(totalSteps > 0 ? { totalSteps } : undefined),\n ...(usage?.inputTokens != null\n ? { inputTokens: usage.inputTokens }\n : undefined),\n ...(usage?.outputTokens != null\n ? { outputTokens: usage.outputTokens }\n : undefined),\n ...(usage?.reasoningTokens != null\n ? { reasoningTokens: usage.reasoningTokens }\n : undefined),\n ...(usage?.cachedInputTokens != null\n ? { cachedInputTokens: usage.cachedInputTokens }\n : undefined),\n ...(outputText != null ? { outputText } : undefined),\n ...(metadata ? { metadata } : undefined),\n ...(steps ? { steps } : undefined),\n ...(modelId ? { modelId } : undefined),\n };\n}\n\ntype UsageFields = {\n inputTokens?: number;\n outputTokens?: number;\n promptTokens?: number;\n completionTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n};\n\nfunction normalizeUsage(u: UsageFields):\n | {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n }\n | undefined {\n const input = u.inputTokens ?? u.promptTokens;\n const output = u.outputTokens ?? u.completionTokens;\n if (\n input == null &&\n output == null &&\n u.reasoningTokens == null &&\n u.cachedInputTokens == null\n ) {\n return undefined;\n }\n\n return {\n ...(input != null ? { inputTokens: input } : undefined),\n ...(output != null ? { outputTokens: output } : undefined),\n ...(u.reasoningTokens != null\n ? { reasoningTokens: u.reasoningTokens }\n : undefined),\n ...(u.cachedInputTokens != null\n ? { cachedInputTokens: u.cachedInputTokens }\n : undefined),\n };\n}\n\nfunction extractAiSdkV6Usage(metadata?: Record<string, unknown>):\n | {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n }\n | undefined {\n // Try top-level metadata.usage\n const usage = metadata?.usage as UsageFields | undefined;\n if (usage) {\n const normalized = normalizeUsage(usage);\n if (normalized) return normalized;\n }\n\n // Try aggregating from metadata.steps[].usage\n const steps = metadata?.steps as\n | readonly { usage?: UsageFields }[]\n | undefined;\n if (steps && steps.length > 0) {\n let inputTokens = 0;\n let outputTokens = 0;\n let reasoningTokens = 0;\n let cachedInputTokens = 0;\n let hasInput = false;\n let hasOutput = false;\n let hasReasoning = false;\n let hasCachedInput = false;\n let hasAny = false;\n for (const s of steps) {\n if (!s.usage) continue;\n const n = normalizeUsage(s.usage);\n if (n) {\n if (n.inputTokens != null) {\n inputTokens += n.inputTokens;\n hasInput = true;\n }\n if (n.outputTokens != null) {\n outputTokens += n.outputTokens;\n hasOutput = true;\n }\n if (n.reasoningTokens != null) {\n reasoningTokens += n.reasoningTokens;\n hasReasoning = true;\n }\n if (n.cachedInputTokens != null) {\n cachedInputTokens += n.cachedInputTokens;\n hasCachedInput = true;\n }\n hasAny = true;\n }\n }\n if (hasAny) {\n return {\n ...(hasInput ? { inputTokens } : undefined),\n ...(hasOutput ? { outputTokens } : undefined),\n ...(hasReasoning ? { reasoningTokens } : undefined),\n ...(hasCachedInput ? { cachedInputTokens } : undefined),\n };\n }\n }\n\n return undefined;\n}\n\nfunction extractAiSdkV6<T>(content: T): TelemetryData | null {\n const msg = content as AiSdkV6Message;\n if (msg.role !== \"assistant\") return null;\n\n const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(\n msg.parts ?? [],\n );\n return buildAiSdkV6Result(\n textParts,\n toolCalls,\n stepsData.length,\n msg.metadata,\n stepsData,\n extractAiSdkV6Usage(msg.metadata),\n );\n}\n\nfunction aggregateAiSdkV6RunSteps<T>(stepMessages: T[]): TelemetryData | null {\n const allTextParts: string[] = [];\n const allToolCalls: TelemetryToolCall[] = [];\n const allStepsData: { tool_calls: TelemetryToolCall[] }[] = [];\n let hasAssistant = false;\n let metadata: Record<string, unknown> | undefined;\n let inputTokens = 0;\n let outputTokens = 0;\n let reasoningTokens = 0;\n let cachedInputTokens = 0;\n let hasInput = false;\n let hasOutput = false;\n let hasReasoning = false;\n let hasCachedInput = false;\n\n for (const content of stepMessages) {\n const msg = content as AiSdkV6Message;\n if (msg.role !== \"assistant\") continue;\n hasAssistant = true;\n\n const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(\n msg.parts ?? [],\n );\n allTextParts.push(...textParts);\n allToolCalls.push(...toolCalls);\n allStepsData.push(...stepsData);\n if (msg.metadata) metadata = msg.metadata;\n\n const usage = extractAiSdkV6Usage(msg.metadata);\n if (usage) {\n if (usage.inputTokens != null) {\n inputTokens += usage.inputTokens;\n hasInput = true;\n }\n if (usage.outputTokens != null) {\n outputTokens += usage.outputTokens;\n hasOutput = true;\n }\n if (usage.reasoningTokens != null) {\n reasoningTokens += usage.reasoningTokens;\n hasReasoning = true;\n }\n if (usage.cachedInputTokens != null) {\n cachedInputTokens += usage.cachedInputTokens;\n hasCachedInput = true;\n }\n }\n }\n\n if (!hasAssistant) return null;\n return buildAiSdkV6Result(\n allTextParts,\n allToolCalls,\n allStepsData.length,\n metadata,\n allStepsData,\n {\n ...(hasInput ? { inputTokens } : undefined),\n ...(hasOutput ? { outputTokens } : undefined),\n ...(hasReasoning ? { reasoningTokens } : undefined),\n ...(hasCachedInput ? { cachedInputTokens } : undefined),\n },\n );\n}\n\nexport function useAssistantCloudThreadHistoryAdapter(\n cloudRef: RefObject<AssistantCloud>,\n): ThreadHistoryAdapter {\n const aui = useAui();\n const [adapter] = useState(\n () => new AssistantCloudThreadHistoryAdapter(cloudRef, aui),\n );\n return adapter;\n}\n"],"mappings":";;;;;AAkBA,MAAM,oCAAoB,IAAI,QAG5B;AAEF,IAAM,qCAAN,MAAyE;CAE7D;CACA;CAFV,YACE,UACA,KACA;EAFQ,KAAA,WAAA;EACA,KAAA,MAAA;CACP;CAEH,IAAY,eAAwC;EAClD,MAAM,MAAM,KAAK,IAAI,eAAe;EACpC,IAAI,CAAC,kBAAkB,IAAI,GAAG,GAC5B,kBAAkB,IAChB,KACA,IAAI,wBAAwB,KAAK,SAAS,OAAO,CACnD;EAEF,OAAO,kBAAkB,IAAI,GAAG;CAClC;CAEA,WACE,eACuC;EACvC,MAAM,UAAU;EAChB,MAAM,YAAY,2BAChB,KAAK,cACL,aACF;EACA,OAAO;GAEL,MAAM,OAAO,MAAmC;IAC9C,MAAM,EAAE,aAAa,MAAM,QAAQ,IAAI,eAAe,CAAC,CAAC,WAAW;IACnE,MAAM,UAAU,OAAO,UAAU,IAAI;GACvC;GACA,MAAM,OAAO,MAAmC,gBAAwB;IACtE,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K,MAAM,WAAW,cAAc;EAClC,MAAM,MAAM;EACZ,IAAI,IAAI,SAAS,aAAa;EAC9B,eAAe;EAEf,MAAM,EAAE,WAAW,WAAW,cAAc,oBAC1C,IAAI,SAAS,CAAC,CAChB;EACA,aAAa,KAAK,GAAG,SAAS;EAC9B,aAAa,KAAK,GAAG,SAAS;EAC9B,aAAa,KAAK,GAAG,SAAS;EAC9B,IAAI,IAAI,UAAU,WAAW,IAAI;EAEjC,MAAM,QAAQ,oBAAoB,IAAI,QAAQ;EAC9C,IAAI,OAAO;GACT,IAAI,MAAM,eAAe,MAAM;IAC7B,eAAe,MAAM;IACrB,WAAW;GACb;GACA,IAAI,MAAM,gBAAgB,MAAM;IAC9B,gBAAgB,MAAM;IACtB,YAAY;GACd;GACA,IAAI,MAAM,mBAAmB,MAAM;IACjC,mBAAmB,MAAM;IACzB,eAAe;GACjB;GACA,IAAI,MAAM,qBAAqB,MAAM;IACnC,qBAAqB,MAAM;IAC3B,iBAAiB;GACnB;EACF;CACF;CAEA,IAAI,CAAC,cAAc,OAAO;CAC1B,OAAO,mBACL,cACA,cACA,aAAa,QACb,UACA,cACA;EACE,GAAI,WAAW,EAAE,YAAY,IAAI,KAAA;EACjC,GAAI,YAAY,EAAE,aAAa,IAAI,KAAA;EACnC,GAAI,eAAe,EAAE,gBAAgB,IAAI,KAAA;EACzC,GAAI,iBAAiB,EAAE,kBAAkB,IAAI,KAAA;CAC/C,CACF;AACF;AAEA,SAAgB,sCACd,UACsB;CACtB,MAAM,MAAM,OAAO;CACnB,MAAM,CAAC,WAAW,eACV,IAAI,mCAAmC,UAAU,GAAG,CAC5D;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"AssistantCloudThreadHistoryAdapter.js","names":[],"sources":["../../../../src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts"],"sourcesContent":["import { type RefObject, useState } from \"react\";\nimport type {\n GenericThreadHistoryAdapter,\n ThreadHistoryAdapter,\n MessageFormatAdapter,\n MessageFormatItem,\n MessageFormatRepository,\n} from \"../../../adapters/thread-history\";\nimport type { ExportedMessageRepositoryItem } from \"../../../runtime/utils/message-repository\";\nimport {\n type AssistantCloud,\n CloudMessagePersistence,\n createFormattedPersistence,\n} from \"assistant-cloud\";\nimport { auiV0Decode, auiV0Encode } from \"./auiV0\";\nimport { type AssistantClient, useAui } from \"@assistant-ui/store\";\nimport type { ThreadListItemMethods } from \"../../../store/scopes/thread-list-item\";\n\nconst globalPersistence = new WeakMap<\n ThreadListItemMethods,\n CloudMessagePersistence\n>();\n\nclass AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {\n constructor(\n private cloudRef: RefObject<AssistantCloud>,\n private aui: AssistantClient,\n ) {}\n\n private get _persistence(): CloudMessagePersistence {\n const key = this.aui.threadListItem();\n if (!globalPersistence.has(key)) {\n globalPersistence.set(\n key,\n new CloudMessagePersistence(this.cloudRef.current),\n );\n }\n return globalPersistence.get(key)!;\n }\n\n withFormat<TMessage, TStorageFormat extends Record<string, unknown>>(\n formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>,\n ): GenericThreadHistoryAdapter<TMessage> {\n const adapter = this;\n const formatted = createFormattedPersistence(\n this._persistence,\n formatAdapter,\n );\n return {\n // Note: callers must also call reportTelemetry() for run tracking\n async append(item: MessageFormatItem<TMessage>) {\n const { remoteId } = await adapter.aui.threadListItem().initialize();\n await formatted.append(remoteId, item);\n },\n async update(item: MessageFormatItem<TMessage>, localMessageId: string) {\n const remoteId = adapter.aui.threadListItem().getState().remoteId;\n if (!remoteId) return;\n await formatted.update?.(remoteId, item, localMessageId);\n },\n async delete() {\n throw new Error(\n \"Assistant Cloud does not support deleting thread messages yet.\",\n );\n },\n reportTelemetry(\n items: MessageFormatItem<TMessage>[],\n options?: {\n durationMs?: number;\n stepTimestamps?: StepTimestamp[];\n },\n ) {\n const encodedRunMessages = items.map((item) =>\n formatAdapter.encode(item),\n );\n adapter._reportRunTelemetry(\n formatAdapter.format,\n encodedRunMessages,\n options,\n );\n },\n async load(): Promise<MessageFormatRepository<TMessage>> {\n const remoteId = adapter.aui.threadListItem().getState().remoteId;\n if (!remoteId) return { messages: [] };\n return formatted.load(remoteId);\n },\n };\n }\n\n async append({ parentId, message }: ExportedMessageRepositoryItem) {\n const { remoteId } = await this.aui.threadListItem().initialize();\n const encoded = auiV0Encode(message);\n await this._persistence.append(\n remoteId,\n message.id,\n parentId,\n \"aui/v0\",\n encoded,\n );\n\n if (this.cloudRef.current.telemetry.enabled) {\n this._maybeReportRun(remoteId, \"aui/v0\", encoded);\n }\n }\n\n async delete() {\n throw new Error(\n \"Assistant Cloud does not support deleting thread messages yet.\",\n );\n }\n\n async load() {\n const remoteId = this.aui.threadListItem().getState().remoteId;\n if (!remoteId) return { messages: [] };\n const messages = await this._persistence.load(remoteId, \"aui/v0\");\n return {\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 }\n\n private _reportRunTelemetry<T>(\n format: string,\n runMessages: T[],\n options?: {\n durationMs?: number;\n stepTimestamps?: StepTimestamp[];\n },\n ) {\n if (!this.cloudRef.current.telemetry.enabled) return;\n\n const remoteId = this.aui.threadListItem().getState().remoteId;\n if (!remoteId) return;\n\n const extracted = extractRunTelemetry(format, runMessages);\n if (!extracted) return;\n\n this._sendReport(\n remoteId,\n extracted,\n options?.durationMs,\n options?.stepTimestamps,\n );\n }\n\n private _maybeReportRun<T>(remoteId: string, format: string, content: T) {\n const extracted = extractTelemetry(format, content);\n if (!extracted) return;\n\n this._sendReport(remoteId, extracted);\n }\n\n private _sendReport(\n remoteId: string,\n data: TelemetryData,\n durationMs?: number,\n stepTimestamps?: StepTimestamp[],\n ) {\n const mergedSteps = mergeStepTimestamps(data.steps, stepTimestamps);\n // Keep in sync with assistant-cloud createRunSchema\n // (apps/aui-cloud-api/src/endpoints/runs/create.ts).\n const initial: Parameters<typeof this.cloudRef.current.runs.report>[0] = {\n thread_id: remoteId,\n status: data.status,\n ...(data.totalSteps != null\n ? { total_steps: data.totalSteps }\n : undefined),\n ...(data.toolCalls ? { tool_calls: data.toolCalls } : undefined),\n ...(mergedSteps ? { steps: mergedSteps } : undefined),\n ...(data.inputTokens != null\n ? { input_tokens: data.inputTokens }\n : undefined),\n ...(data.outputTokens != null\n ? { output_tokens: data.outputTokens }\n : undefined),\n ...(data.reasoningTokens != null\n ? { reasoning_tokens: data.reasoningTokens }\n : undefined),\n ...(data.cachedInputTokens != null\n ? { cached_input_tokens: data.cachedInputTokens }\n : undefined),\n ...(durationMs != null ? { duration_ms: durationMs } : undefined),\n ...(data.outputText != null\n ? { output_text: data.outputText }\n : undefined),\n ...(data.metadata ? { metadata: data.metadata } : undefined),\n ...(data.modelId ? { model_id: data.modelId } : undefined),\n };\n\n const { beforeReport } = this.cloudRef.current.telemetry;\n const report = beforeReport ? beforeReport(initial) : initial;\n if (!report) return;\n\n this.cloudRef.current.runs.report(report).catch(() => {});\n }\n}\n\nconst MAX_SPAN_CONTENT = 50_000;\n\nfunction truncateStr(value: string): string {\n if (value.length <= MAX_SPAN_CONTENT) return value;\n return value.slice(0, MAX_SPAN_CONTENT);\n}\n\nfunction safeStringify(value: unknown): string | undefined {\n if (value == null) return undefined;\n try {\n return truncateStr(JSON.stringify(value));\n } catch {\n return undefined;\n }\n}\n\ntype TelemetryToolCall = {\n tool_name: string;\n tool_call_id: string;\n tool_args?: string;\n tool_result?: string;\n tool_source?: \"mcp\" | \"frontend\" | \"backend\";\n};\n\nconst BASE64_PATTERN = /^[A-Za-z0-9+/]{100,}={0,2}$/;\n\nfunction summarizeMcpResult(value: unknown): string | undefined {\n if (value == null) return undefined;\n try {\n const parsed = typeof value === \"string\" ? JSON.parse(value) : value;\n if (Array.isArray(parsed)) {\n const summarized = parsed.map((item) => {\n if (item && typeof item === \"object\" && item.type) {\n if (\n (item.type === \"image\" || item.type === \"audio\") &&\n typeof item.data === \"string\" &&\n BASE64_PATTERN.test(item.data.slice(0, 200))\n ) {\n const sizeKB = ((item.data.length * 3) / 4 / 1024).toFixed(1);\n return { ...item, data: `[${item.type}: ${sizeKB}KB]` };\n }\n }\n return item;\n });\n return truncateStr(JSON.stringify(summarized));\n }\n } catch {\n // not JSON array, fall through\n }\n return safeStringify(value);\n}\n\nfunction buildToolCall(\n toolName: string,\n toolCallId: string,\n args: unknown,\n result: unknown,\n argsText?: string,\n toolSource?: \"mcp\" | \"frontend\" | \"backend\",\n): TelemetryToolCall {\n const call: TelemetryToolCall = {\n tool_name: toolName,\n tool_call_id: toolCallId,\n };\n const toolArgs = argsText ?? safeStringify(args);\n if (toolArgs !== undefined) call.tool_args = toolArgs;\n const toolResult =\n toolSource === \"mcp\" ? summarizeMcpResult(result) : safeStringify(result);\n if (toolResult !== undefined) call.tool_result = toolResult;\n if (toolSource) call.tool_source = toolSource;\n return call;\n}\n\ntype TelemetryStepData = {\n input_tokens?: number;\n output_tokens?: number;\n reasoning_tokens?: number;\n cached_input_tokens?: number;\n tool_calls?: TelemetryToolCall[];\n start_ms?: number;\n end_ms?: number;\n};\n\ntype StepTimestamp = { start_ms: number; end_ms: number };\n\nfunction mergeStepTimestamps(\n steps: TelemetryStepData[] | undefined,\n timestamps: StepTimestamp[] | undefined,\n): TelemetryStepData[] | undefined {\n if (!timestamps) return steps;\n if (!steps) return timestamps.map((t) => ({ ...t }));\n\n const len = Math.min(steps.length, timestamps.length);\n return steps.map((s, i) => ({\n ...s,\n ...(i < len ? timestamps[i] : undefined),\n }));\n}\n\ntype TelemetryData = {\n status: \"completed\" | \"incomplete\" | \"error\";\n toolCalls?: TelemetryToolCall[];\n totalSteps?: number;\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n outputText?: string;\n metadata?: Record<string, unknown>;\n steps?: TelemetryStepData[];\n modelId?: string;\n};\n\nfunction extractTelemetry<T>(format: string, content: T): TelemetryData | null {\n switch (format) {\n case \"aui/v0\":\n return extractAuiV0(content);\n case \"ai-sdk/v6\":\n return extractAiSdkV6(content);\n default:\n return null;\n }\n}\n\nfunction extractRunTelemetry<T>(\n format: string,\n runMessages: T[],\n): TelemetryData | null {\n if (format === \"ai-sdk/v6\") {\n return aggregateAiSdkV6RunSteps(runMessages);\n }\n for (let i = runMessages.length - 1; i >= 0; i--) {\n const result = extractTelemetry(format, runMessages[i]!);\n if (result) return result;\n }\n return null;\n}\n\nconst AUI_STATUS_MAP: Record<string, TelemetryData[\"status\"]> = {\n error: \"error\",\n incomplete: \"incomplete\",\n};\n\nfunction extractAuiV0<T>(content: T): TelemetryData | null {\n const msg = content as {\n role?: string;\n status?: { type: string };\n content?: readonly {\n type: string;\n text?: string;\n toolName?: string;\n toolCallId?: string;\n args?: unknown;\n argsText?: string;\n result?: unknown;\n }[];\n metadata?: {\n modelId?: string;\n steps?: readonly {\n usage?: {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n };\n }[];\n custom?: Record<string, unknown> & { modelId?: string };\n };\n };\n\n if (msg.role !== \"assistant\") return null;\n\n const toolCalls = msg.content\n ?.filter((p) => p.type === \"tool-call\" && p.toolName && p.toolCallId)\n .map((p) =>\n buildToolCall(p.toolName!, p.toolCallId!, p.args, p.result, p.argsText),\n );\n\n const textParts = msg.content?.filter((p) => p.type === \"text\" && p.text);\n const outputText =\n textParts && textParts.length > 0\n ? truncateStr(textParts.map((p) => p.text).join(\"\"))\n : undefined;\n\n const steps = msg.metadata?.steps;\n let inputTokens: number | undefined;\n let outputTokens: number | undefined;\n let reasoningTokens: number | undefined;\n let cachedInputTokens: number | undefined;\n if (steps && steps.length > 0) {\n let totalInput = 0;\n let totalOutput = 0;\n let totalReasoning = 0;\n let totalCachedInput = 0;\n let hasInput = false;\n let hasOutput = false;\n let hasReasoning = false;\n let hasCachedInput = false;\n for (const step of steps) {\n if (step.usage?.inputTokens != null) {\n totalInput += step.usage.inputTokens;\n hasInput = true;\n }\n if (step.usage?.outputTokens != null) {\n totalOutput += step.usage.outputTokens;\n hasOutput = true;\n }\n if (step.usage?.reasoningTokens != null) {\n totalReasoning += step.usage.reasoningTokens;\n hasReasoning = true;\n }\n if (step.usage?.cachedInputTokens != null) {\n totalCachedInput += step.usage.cachedInputTokens;\n hasCachedInput = true;\n }\n }\n inputTokens = hasInput ? totalInput : undefined;\n outputTokens = hasOutput ? totalOutput : undefined;\n reasoningTokens = hasReasoning ? totalReasoning : undefined;\n cachedInputTokens = hasCachedInput ? totalCachedInput : undefined;\n }\n\n const statusType = msg.status?.type;\n const status: TelemetryData[\"status\"] =\n (statusType && AUI_STATUS_MAP[statusType]) || \"completed\";\n\n const metadata = msg.metadata?.custom as Record<string, unknown> | undefined;\n const modelId =\n msg.metadata?.modelId ??\n (typeof msg.metadata?.custom?.modelId === \"string\"\n ? msg.metadata.custom.modelId\n : undefined);\n\n const telemetrySteps: TelemetryStepData[] | undefined =\n steps && steps.length > 1\n ? steps.map((s) => ({\n ...(s.usage?.inputTokens != null\n ? { input_tokens: s.usage.inputTokens }\n : undefined),\n ...(s.usage?.outputTokens != null\n ? { output_tokens: s.usage.outputTokens }\n : undefined),\n ...(s.usage?.reasoningTokens != null\n ? { reasoning_tokens: s.usage.reasoningTokens }\n : undefined),\n ...(s.usage?.cachedInputTokens != null\n ? { cached_input_tokens: s.usage.cachedInputTokens }\n : undefined),\n }))\n : undefined;\n\n return {\n status,\n ...(toolCalls && toolCalls.length > 0 ? { toolCalls } : undefined),\n ...(steps?.length ? { totalSteps: steps.length } : undefined),\n ...(inputTokens != null ? { inputTokens } : undefined),\n ...(outputTokens != null ? { outputTokens } : undefined),\n ...(reasoningTokens != null ? { reasoningTokens } : undefined),\n ...(cachedInputTokens != null ? { cachedInputTokens } : undefined),\n ...(outputText != null ? { outputText } : undefined),\n ...(metadata ? { metadata } : undefined),\n ...(telemetrySteps ? { steps: telemetrySteps } : undefined),\n ...(modelId ? { modelId } : undefined),\n };\n}\n\ntype AiSdkV6Part = {\n type: string;\n text?: string;\n toolName?: string;\n toolCallId?: string;\n args?: unknown;\n result?: unknown;\n input?: unknown;\n output?: unknown;\n};\n\ntype AiSdkV6Message = {\n role?: string;\n parts?: readonly AiSdkV6Part[];\n metadata?: Record<string, unknown>;\n};\n\nfunction isToolCallPart(p: AiSdkV6Part): boolean {\n if (!p.toolCallId) return false;\n if (p.type === \"tool-call\" || p.type === \"dynamic-tool\") return !!p.toolName;\n return p.type.startsWith(\"tool-\") || p.type.startsWith(\"dynamic-tool-\");\n}\n\nfunction isDynamicToolPart(p: AiSdkV6Part): boolean {\n return p.type === \"dynamic-tool\" || p.type.startsWith(\"dynamic-tool-\");\n}\n\nfunction partToToolCall(p: AiSdkV6Part): TelemetryToolCall {\n const toolSource: \"mcp\" | undefined = isDynamicToolPart(p)\n ? \"mcp\"\n : undefined;\n return buildToolCall(\n p.toolName ?? p.type.slice(5),\n p.toolCallId!,\n p.args ?? p.input,\n p.result ?? p.output,\n undefined,\n toolSource,\n );\n}\n\nfunction collectAiSdkV6Parts(parts: readonly AiSdkV6Part[]): {\n textParts: string[];\n toolCalls: TelemetryToolCall[];\n stepsData: { tool_calls: TelemetryToolCall[] }[];\n} {\n const textParts: string[] = [];\n const toolCalls: TelemetryToolCall[] = [];\n const stepsData: { tool_calls: TelemetryToolCall[] }[] = [];\n let currentStepToolCalls: TelemetryToolCall[] | null = null;\n\n for (const p of parts) {\n if (p.type === \"step-start\") {\n if (currentStepToolCalls !== null) {\n stepsData.push({ tool_calls: currentStepToolCalls });\n }\n currentStepToolCalls = [];\n } else if (p.type === \"text\" && p.text) {\n textParts.push(p.text);\n } else if (isToolCallPart(p)) {\n const tc = partToToolCall(p);\n toolCalls.push(tc);\n if (currentStepToolCalls !== null) {\n currentStepToolCalls.push(tc);\n }\n }\n }\n\n if (currentStepToolCalls !== null) {\n stepsData.push({ tool_calls: currentStepToolCalls });\n }\n\n return { textParts, toolCalls, stepsData };\n}\n\nfunction extractModelId(\n metadata?: Record<string, unknown>,\n): string | undefined {\n if (!metadata) return undefined;\n if (typeof metadata.modelId === \"string\") return metadata.modelId;\n const custom = metadata.custom as Record<string, unknown> | undefined;\n if (typeof custom?.modelId === \"string\") return custom.modelId;\n return undefined;\n}\n\nfunction buildAiSdkV6Result(\n textParts: string[],\n toolCalls: TelemetryToolCall[],\n totalSteps: number,\n metadata?: Record<string, unknown>,\n stepsData?: { tool_calls: TelemetryToolCall[] }[],\n usage?: {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n },\n): TelemetryData {\n const hasText = textParts.length > 0;\n const outputText = hasText ? truncateStr(textParts.join(\"\")) : undefined;\n const modelId = extractModelId(metadata);\n\n const steps: TelemetryStepData[] | undefined =\n stepsData && stepsData.length > 1\n ? stepsData.map((s) => ({\n ...(s.tool_calls.length > 0\n ? { tool_calls: s.tool_calls }\n : undefined),\n }))\n : undefined;\n\n return {\n status: hasText ? \"completed\" : \"incomplete\",\n ...(toolCalls.length > 0 ? { toolCalls } : undefined),\n ...(totalSteps > 0 ? { totalSteps } : undefined),\n ...(usage?.inputTokens != null\n ? { inputTokens: usage.inputTokens }\n : undefined),\n ...(usage?.outputTokens != null\n ? { outputTokens: usage.outputTokens }\n : undefined),\n ...(usage?.reasoningTokens != null\n ? { reasoningTokens: usage.reasoningTokens }\n : undefined),\n ...(usage?.cachedInputTokens != null\n ? { cachedInputTokens: usage.cachedInputTokens }\n : undefined),\n ...(outputText != null ? { outputText } : undefined),\n ...(metadata ? { metadata } : undefined),\n ...(steps ? { steps } : undefined),\n ...(modelId ? { modelId } : undefined),\n };\n}\n\ntype UsageFields = {\n inputTokens?: number;\n outputTokens?: number;\n promptTokens?: number;\n completionTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n};\n\nfunction normalizeUsage(u: UsageFields):\n | {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n }\n | undefined {\n const input = u.inputTokens ?? u.promptTokens;\n const output = u.outputTokens ?? u.completionTokens;\n if (\n input == null &&\n output == null &&\n u.reasoningTokens == null &&\n u.cachedInputTokens == null\n ) {\n return undefined;\n }\n\n return {\n ...(input != null ? { inputTokens: input } : undefined),\n ...(output != null ? { outputTokens: output } : undefined),\n ...(u.reasoningTokens != null\n ? { reasoningTokens: u.reasoningTokens }\n : undefined),\n ...(u.cachedInputTokens != null\n ? { cachedInputTokens: u.cachedInputTokens }\n : undefined),\n };\n}\n\nfunction extractAiSdkV6Usage(metadata?: Record<string, unknown>):\n | {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n }\n | undefined {\n // Try top-level metadata.usage\n const usage = metadata?.usage as UsageFields | undefined;\n if (usage) {\n const normalized = normalizeUsage(usage);\n if (normalized) return normalized;\n }\n\n // Try aggregating from metadata.steps[].usage\n const steps = metadata?.steps as\n | readonly { usage?: UsageFields }[]\n | undefined;\n if (steps && steps.length > 0) {\n let inputTokens = 0;\n let outputTokens = 0;\n let reasoningTokens = 0;\n let cachedInputTokens = 0;\n let hasInput = false;\n let hasOutput = false;\n let hasReasoning = false;\n let hasCachedInput = false;\n let hasAny = false;\n for (const s of steps) {\n if (!s.usage) continue;\n const n = normalizeUsage(s.usage);\n if (n) {\n if (n.inputTokens != null) {\n inputTokens += n.inputTokens;\n hasInput = true;\n }\n if (n.outputTokens != null) {\n outputTokens += n.outputTokens;\n hasOutput = true;\n }\n if (n.reasoningTokens != null) {\n reasoningTokens += n.reasoningTokens;\n hasReasoning = true;\n }\n if (n.cachedInputTokens != null) {\n cachedInputTokens += n.cachedInputTokens;\n hasCachedInput = true;\n }\n hasAny = true;\n }\n }\n if (hasAny) {\n return {\n ...(hasInput ? { inputTokens } : undefined),\n ...(hasOutput ? { outputTokens } : undefined),\n ...(hasReasoning ? { reasoningTokens } : undefined),\n ...(hasCachedInput ? { cachedInputTokens } : undefined),\n };\n }\n }\n\n return undefined;\n}\n\nfunction extractAiSdkV6<T>(content: T): TelemetryData | null {\n const msg = content as AiSdkV6Message;\n if (msg.role !== \"assistant\") return null;\n\n const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(\n msg.parts ?? [],\n );\n return buildAiSdkV6Result(\n textParts,\n toolCalls,\n stepsData.length,\n msg.metadata,\n stepsData,\n extractAiSdkV6Usage(msg.metadata),\n );\n}\n\nfunction aggregateAiSdkV6RunSteps<T>(stepMessages: T[]): TelemetryData | null {\n const allTextParts: string[] = [];\n const allToolCalls: TelemetryToolCall[] = [];\n const allStepsData: { tool_calls: TelemetryToolCall[] }[] = [];\n let hasAssistant = false;\n let metadata: Record<string, unknown> | undefined;\n let inputTokens = 0;\n let outputTokens = 0;\n let reasoningTokens = 0;\n let cachedInputTokens = 0;\n let hasInput = false;\n let hasOutput = false;\n let hasReasoning = false;\n let hasCachedInput = false;\n\n for (const content of stepMessages) {\n const msg = content as AiSdkV6Message;\n if (msg.role !== \"assistant\") continue;\n hasAssistant = true;\n\n const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(\n msg.parts ?? [],\n );\n allTextParts.push(...textParts);\n allToolCalls.push(...toolCalls);\n allStepsData.push(...stepsData);\n if (msg.metadata) metadata = msg.metadata;\n\n const usage = extractAiSdkV6Usage(msg.metadata);\n if (usage) {\n if (usage.inputTokens != null) {\n inputTokens += usage.inputTokens;\n hasInput = true;\n }\n if (usage.outputTokens != null) {\n outputTokens += usage.outputTokens;\n hasOutput = true;\n }\n if (usage.reasoningTokens != null) {\n reasoningTokens += usage.reasoningTokens;\n hasReasoning = true;\n }\n if (usage.cachedInputTokens != null) {\n cachedInputTokens += usage.cachedInputTokens;\n hasCachedInput = true;\n }\n }\n }\n\n if (!hasAssistant) return null;\n return buildAiSdkV6Result(\n allTextParts,\n allToolCalls,\n allStepsData.length,\n metadata,\n allStepsData,\n {\n ...(hasInput ? { inputTokens } : undefined),\n ...(hasOutput ? { outputTokens } : undefined),\n ...(hasReasoning ? { reasoningTokens } : undefined),\n ...(hasCachedInput ? { cachedInputTokens } : undefined),\n },\n );\n}\n\nexport function useAssistantCloudThreadHistoryAdapter(\n cloudRef: RefObject<AssistantCloud>,\n): ThreadHistoryAdapter {\n const aui = useAui();\n const [adapter] = useState(\n () => new AssistantCloudThreadHistoryAdapter(cloudRef, aui),\n );\n return adapter;\n}\n"],"mappings":";;;;;AAkBA,MAAM,oCAAoB,IAAI,QAG5B;AAEF,IAAM,qCAAN,MAAyE;CAE7D;CACA;CAFV,YACE,UACA,KACA;EAFQ,KAAA,WAAA;EACA,KAAA,MAAA;CACP;CAEH,IAAY,eAAwC;EAClD,MAAM,MAAM,KAAK,IAAI,eAAe;EACpC,IAAI,CAAC,kBAAkB,IAAI,GAAG,GAC5B,kBAAkB,IAChB,KACA,IAAI,wBAAwB,KAAK,SAAS,OAAO,CACnD;EAEF,OAAO,kBAAkB,IAAI,GAAG;CAClC;CAEA,WACE,eACuC;EACvC,MAAM,UAAU;EAChB,MAAM,YAAY,2BAChB,KAAK,cACL,aACF;EACA,OAAO;GAEL,MAAM,OAAO,MAAmC;IAC9C,MAAM,EAAE,aAAa,MAAM,QAAQ,IAAI,eAAe,CAAC,CAAC,WAAW;IACnE,MAAM,UAAU,OAAO,UAAU,IAAI;GACvC;GACA,MAAM,OAAO,MAAmC,gBAAwB;IACtE,MAAM,WAAW,QAAQ,IAAI,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,UAAU;IACf,MAAM,UAAU,SAAS,UAAU,MAAM,cAAc;GACzD;GACA,MAAM,SAAS;IACb,MAAM,IAAI,MACR,gEACF;GACF;GACA,gBACE,OACA,SAIA;IACA,MAAM,qBAAqB,MAAM,KAAK,SACpC,cAAc,OAAO,IAAI,CAC3B;IACA,QAAQ,oBACN,cAAc,QACd,oBACA,OACF;GACF;GACA,MAAM,OAAmD;IACvD,MAAM,WAAW,QAAQ,IAAI,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,UAAU,OAAO,EAAE,UAAU,CAAC,EAAE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I,MAAM,eAAe,MAAM;IAC7B,eAAe,MAAM;IACrB,WAAW;GACb;GACA,IAAI,MAAM,gBAAgB,MAAM;IAC9B,gBAAgB,MAAM;IACtB,YAAY;GACd;GACA,IAAI,MAAM,mBAAmB,MAAM;IACjC,mBAAmB,MAAM;IACzB,eAAe;GACjB;GACA,IAAI,MAAM,qBAAqB,MAAM;IACnC,qBAAqB,MAAM;IAC3B,iBAAiB;GACnB;EACF;CACF;CAEA,IAAI,CAAC,cAAc,OAAO;CAC1B,OAAO,mBACL,cACA,cACA,aAAa,QACb,UACA,cACA;EACE,GAAI,WAAW,EAAE,YAAY,IAAI,KAAA;EACjC,GAAI,YAAY,EAAE,aAAa,IAAI,KAAA;EACnC,GAAI,eAAe,EAAE,gBAAgB,IAAI,KAAA;EACzC,GAAI,iBAAiB,EAAE,kBAAkB,IAAI,KAAA;CAC/C,CACF;AACF;AAEA,SAAgB,sCACd,UACsB;CACtB,MAAM,MAAM,OAAO;CACnB,MAAM,CAAC,WAAW,eACV,IAAI,mCAAmC,UAAU,GAAG,CAC5D;CACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloudThreadListAdapter.d.ts","names":[],"sources":["../../../../src/react/runtimes/cloud/useCloudThreadListAdapter.tsx"],"mappings":";;;;KAkBK,UAAA;EACH,UAAU;AAAA;AAAA,KAGP,6BAAA;EACH,KAAA,GAAQ,cAAA;EAER,MAAA,UAAgB,OAAA,CAAQ,UAAA;EACxB,MAAA,KAAW,QAAA,aAAqB,OAAA;AAAA;AAAA,cAarB,yBAAA,GACX,OAAA,EAAS,6BAAA,KACR,
|
|
1
|
+
{"version":3,"file":"useCloudThreadListAdapter.d.ts","names":[],"sources":["../../../../src/react/runtimes/cloud/useCloudThreadListAdapter.tsx"],"mappings":";;;;KAkBK,UAAA;EACH,UAAU;AAAA;AAAA,KAGP,6BAAA;EACH,KAAA,GAAQ,cAAA;EAER,MAAA,UAAgB,OAAA,CAAQ,UAAA;EACxB,MAAA,KAAW,QAAA,aAAqB,OAAA;AAAA;AAAA,cAarB,yBAAA,GACX,OAAA,EAAS,6BAAA,KACR,uBA+HF"}
|
|
@@ -51,6 +51,7 @@ const useCloudThreadListAdapter = (adapter) => {
|
|
|
51
51
|
status: t.is_archived ? "archived" : "regular",
|
|
52
52
|
remoteId: t.id,
|
|
53
53
|
title: t.title,
|
|
54
|
+
lastMessageAt: t.last_message_at ? new Date(t.last_message_at) : void 0,
|
|
54
55
|
externalId: t.external_id ?? void 0,
|
|
55
56
|
custom: toCustom(t.metadata)
|
|
56
57
|
})) };
|
|
@@ -100,6 +101,7 @@ const useCloudThreadListAdapter = (adapter) => {
|
|
|
100
101
|
status: thread.is_archived ? "archived" : "regular",
|
|
101
102
|
remoteId: thread.id,
|
|
102
103
|
title: thread.title,
|
|
104
|
+
lastMessageAt: thread.last_message_at ? new Date(thread.last_message_at) : void 0,
|
|
103
105
|
externalId: thread.external_id ?? void 0,
|
|
104
106
|
custom: toCustom(thread.metadata)
|
|
105
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloudThreadListAdapter.js","names":[],"sources":["../../../../src/react/runtimes/cloud/useCloudThreadListAdapter.tsx"],"sourcesContent":["declare const process: { env: Record<string, string | undefined> };\n\nimport {\n type FC,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport type { RemoteThreadListAdapter } from \"../../../runtimes/remote-thread-list/types\";\nimport { InMemoryThreadListAdapter } from \"../../../runtimes/remote-thread-list/adapter/in-memory\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"./AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../RuntimeAdapterProvider\";\nimport { CloudFileAttachmentAdapter } from \"./CloudFileAttachmentAdapter\";\nimport { isRecord } from \"../../../utils/json/is-json\";\n\ntype ThreadData = {\n externalId: string | undefined;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?: (() => Promise<ThreadData>) | undefined;\n delete?: ((threadId: string) => Promise<void>) | undefined;\n};\n\nconst toCustom = (value: unknown): Record<string, unknown> | undefined =>\n isRecord(value) ? value : undefined;\n\nconst baseUrl =\n typeof process !== \"undefined\" &&\n process?.env?.NEXT_PUBLIC_ASSISTANT_BASE_URL;\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n function Provider({ children }) {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const cloudInstance = adapterRef.current.cloud ?? autoCloud!;\n const attachments = useMemo(\n () => new CloudFileAttachmentAdapter(cloudInstance),\n [cloudInstance],\n );\n\n const adapters = useMemo(\n () => ({\n history,\n attachments,\n }),\n [history, attachments],\n );\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n if (!cloud) {\n const ref = adapterRef;\n const inMemory = new InMemoryThreadListAdapter();\n inMemory.initialize = async (threadId: string) => {\n const result = await ref.current.create?.();\n return { remoteId: threadId, externalId: result?.externalId };\n };\n return inMemory;\n }\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n externalId: t.external_id ?? undefined,\n custom: toCustom(t.metadata),\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapter.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n updateCustom: async (threadId, custom) => {\n return cloud.threads.update(threadId, { metadata: custom ?? null });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapter.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n // Filter messages to only include content types the title generator understands\n // (reasoning, source, etc. are not needed for title generation)\n // TODO serialize these to a more efficient format\n const filteredMessages = messages.map((msg) => ({\n ...msg,\n content: msg.content.filter(\n (part) => part.type === \"text\" || part.type === \"tool-call\",\n ),\n }));\n\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: filteredMessages,\n });\n },\n\n fetch: async (threadId: string) => {\n const thread = await cloud.threads.get(threadId);\n return {\n status: thread.is_archived ? \"archived\" : \"regular\",\n remoteId: thread.id,\n title: thread.title,\n externalId: thread.external_id ?? undefined,\n custom: toCustom(thread.metadata),\n };\n },\n\n unstable_Provider,\n };\n};\n"],"mappings":";;;;;;;;;AA6BA,MAAM,YAAY,UAChB,SAAS,KAAK,IAAI,QAAQ,KAAA;AAE5B,MAAM,UACJ,OAAO,YAAY,eACnB,SAAS,KAAK;AAChB,MAAM,YAAY,UACd,IAAI,eAAe;CAAE;CAAS,WAAW;AAAK,CAAC,IAC/C,KAAA;AAEJ,MAAa,6BACX,YAC4B;CAC5B,MAAM,aAAa,OAAO,OAAO;CACjC,gBAAgB;EACd,WAAW,UAAU;CACvB,GAAG,CAAC,OAAO,CAAC;CAEZ,MAAM,oBAAoB,YACxB,SAAS,SAAS,EAAE,YAAY;EAC9B,MAAM,UAAU,sCAAsC,EACpD,IAAI,UAAU;GACZ,OAAO,WAAW,QA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CAAC;EACpE;EACA,SAAS,OAAO,aAAa;GAC3B,OAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,KAAK,CAAC;EAC7D;EACA,WAAW,OAAO,aAAa;GAC7B,OAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,MAAM,CAAC;EAC9D;EACA,QAAQ,OAAO,aAAa;GAC1B,MAAM,QAAQ,SAAS,QAAQ;GAC/B,OAAO,MAAM,QAAQ,OAAO,QAAQ;EACtC;EAEA,eAAe,OAAO,UAAU,aAAa;GAI3C,MAAM,mBAAmB,SAAS,KAAK,SAAS;IAC9C,GAAG;IACH,SAAS,IAAI,QAAQ,QAClB,SAAS,KAAK,SAAS,UAAU,KAAK,SAAS,WAClD;GACF,EAAE;GAEF,OAAO,MAAM,KAAK,OAAO;IACvB,WAAW;IACX,cAAc;IACd,UAAU;GACZ,CAAC;EACH;EAEA,OAAO,OAAO,aAAqB;GACjC,MAAM,SAAS,MAAM,MAAM,QAAQ,IAAI,QAAQ;GAC/C,OAAO;IACL,QAAQ,OAAO,cAAc,aAAa;IAC1C,UAAU,OAAO;IACjB,OAAO,OAAO;IACd,YAAY,OAAO,eAAe,KAAA;IAClC,QAAQ,SAAS,OAAO,QAAQ;GAClC;EACF;EAEA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useCloudThreadListAdapter.js","names":[],"sources":["../../../../src/react/runtimes/cloud/useCloudThreadListAdapter.tsx"],"sourcesContent":["declare const process: { env: Record<string, string | undefined> };\n\nimport {\n type FC,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport type { RemoteThreadListAdapter } from \"../../../runtimes/remote-thread-list/types\";\nimport { InMemoryThreadListAdapter } from \"../../../runtimes/remote-thread-list/adapter/in-memory\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"./AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../RuntimeAdapterProvider\";\nimport { CloudFileAttachmentAdapter } from \"./CloudFileAttachmentAdapter\";\nimport { isRecord } from \"../../../utils/json/is-json\";\n\ntype ThreadData = {\n externalId: string | undefined;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?: (() => Promise<ThreadData>) | undefined;\n delete?: ((threadId: string) => Promise<void>) | undefined;\n};\n\nconst toCustom = (value: unknown): Record<string, unknown> | undefined =>\n isRecord(value) ? value : undefined;\n\nconst baseUrl =\n typeof process !== \"undefined\" &&\n process?.env?.NEXT_PUBLIC_ASSISTANT_BASE_URL;\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n function Provider({ children }) {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const cloudInstance = adapterRef.current.cloud ?? autoCloud!;\n const attachments = useMemo(\n () => new CloudFileAttachmentAdapter(cloudInstance),\n [cloudInstance],\n );\n\n const adapters = useMemo(\n () => ({\n history,\n attachments,\n }),\n [history, attachments],\n );\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n if (!cloud) {\n const ref = adapterRef;\n const inMemory = new InMemoryThreadListAdapter();\n inMemory.initialize = async (threadId: string) => {\n const result = await ref.current.create?.();\n return { remoteId: threadId, externalId: result?.externalId };\n };\n return inMemory;\n }\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n lastMessageAt: t.last_message_at\n ? new Date(t.last_message_at)\n : undefined,\n externalId: t.external_id ?? undefined,\n custom: toCustom(t.metadata),\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapter.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n updateCustom: async (threadId, custom) => {\n return cloud.threads.update(threadId, { metadata: custom ?? null });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapter.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n // Filter messages to only include content types the title generator understands\n // (reasoning, source, etc. are not needed for title generation)\n // TODO serialize these to a more efficient format\n const filteredMessages = messages.map((msg) => ({\n ...msg,\n content: msg.content.filter(\n (part) => part.type === \"text\" || part.type === \"tool-call\",\n ),\n }));\n\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: filteredMessages,\n });\n },\n\n fetch: async (threadId: string) => {\n const thread = await cloud.threads.get(threadId);\n return {\n status: thread.is_archived ? \"archived\" : \"regular\",\n remoteId: thread.id,\n title: thread.title,\n lastMessageAt: thread.last_message_at\n ? new Date(thread.last_message_at)\n : undefined,\n externalId: thread.external_id ?? undefined,\n custom: toCustom(thread.metadata),\n };\n },\n\n unstable_Provider,\n };\n};\n"],"mappings":";;;;;;;;;AA6BA,MAAM,YAAY,UAChB,SAAS,KAAK,IAAI,QAAQ,KAAA;AAE5B,MAAM,UACJ,OAAO,YAAY,eACnB,SAAS,KAAK;AAChB,MAAM,YAAY,UACd,IAAI,eAAe;CAAE;CAAS,WAAW;AAAK,CAAC,IAC/C,KAAA;AAEJ,MAA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ling-index path, e.g. `"0.1.0"`. */
|
|
81
81
|
readonly nodeKey: string;
|
|
82
|
+
/**
|
|
83
|
+
* Identity key (`"id:<partId>"`) from the group's first part; undefined
|
|
84
|
+
* when absent or already claimed by an earlier sibling.
|
|
85
|
+
*/
|
|
86
|
+
readonly idKey: string | undefined;
|
|
82
87
|
/** Indices of parts in this subtree, in order. */
|
|
83
88
|
readonly indices: readonly number[];
|
|
84
89
|
readonly children: readonly GroupNode[];
|
|
@@ -89,13 +94,20 @@ interface GroupNodePart {
|
|
|
89
94
|
readonly index: number;
|
|
90
95
|
/** Structural React key: sibling-index path within parent. */
|
|
91
96
|
readonly nodeKey: string;
|
|
97
|
+
/**
|
|
98
|
+
* Identity key (`"id:<partId>"`); undefined when absent or already
|
|
99
|
+
* claimed by an earlier sibling.
|
|
100
|
+
*/
|
|
101
|
+
readonly idKey: string | undefined;
|
|
92
102
|
}
|
|
93
103
|
/**
|
|
94
104
|
* Build the group tree from an array of normalized group paths.
|
|
95
105
|
* `paths[i]` is the path for part `i`. The output tree contains one
|
|
96
106
|
* `part` node per part and one `group` node per coalesced run.
|
|
107
|
+
* `partIds[i]` optionally carries a stable identity for part `i` (e.g. a
|
|
108
|
+
* tool call id), from which nodes derive an `idKey`.
|
|
97
109
|
*/
|
|
98
|
-
declare const buildGroupTree: (paths: readonly (readonly string[])[]) => readonly GroupNode[];
|
|
110
|
+
declare const buildGroupTree: (paths: readonly (readonly string[])[], partIds?: readonly (string | undefined)[]) => readonly GroupNode[];
|
|
99
111
|
//#endregion
|
|
100
112
|
export { GROUPBY_MEMO_KEY, GroupByContext, GroupNode, GroupNodeGroup, GroupNodePart, buildGroupTree, groupPartByType };
|
|
101
113
|
//# sourceMappingURL=groupParts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupParts.d.ts","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"mappings":";;;;;;AAUA;;;;KAAY,cAAA;EAwBC,gFAtBF,OAAA,GAAU,UAAU;AAAA;;AAwB9B;AAAC;;;;AAgB4B;AA4B9B;;;;;;;;;;;cA9Ca,gBAAA;;;;;;;;;;;;;;;KAkBR,aAAA,GAAgB,SAAS;AA6D9B;;;;AAAsD;AAEtD
|
|
1
|
+
{"version":3,"file":"groupParts.d.ts","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"mappings":";;;;;;AAUA;;;;KAAY,cAAA;EAwBC,gFAtBF,OAAA,GAAU,UAAU;AAAA;;AAwB9B;AAAC;;;;AAgB4B;AA4B9B;;;;;;;;;;;cA9Ca,gBAAA;;;;;;;;;;;;;;;KAkBR,aAAA,GAAgB,SAAS;AA6D9B;;;;AAAsD;AAEtD;;;;;;;;;;;;AAauC;AAGvC;;;;;;;;AAlBA,cAjCa,eAAA,mCACX,GAAA,EAAK,OAAA,CAAQ,QAAA,CAAS,MAAA,CAAO,aAAA,WAAwB,IAAA,YAClD,IAAA,EAAM,SAAA,EAAW,OAAA,GAAU,cAAA,cAA4B,IAAA;AAAA,KA+BhD,SAAA,GAAY,cAAA,GAAiB,aAAa;AAAA,UAErC,cAAA;EAAA,SACN,IAAA;;WAEA,GAAA;EAyDT;EAAA,SAvDS,OAAA;EAyDC;;AAAS;;EAAT,SApDD,KAAA;;WAEA,OAAA;EAAA,SACA,QAAA,WAAmB,SAAS;AAAA;AAAA,UAGtB,aAAA;EAAA,SACN,IAAA;;WAEA,KAAA;;WAEA,OAAA;;;;;WAKA,KAAA;AAAA;;;;;;;;cAiCE,cAAA,GACX,KAAA,kCACA,OAAA,gDACU,SAAS"}
|
|
@@ -63,26 +63,36 @@ const makeChildNodeKey = (parent) => {
|
|
|
63
63
|
const idx = parent.nextChildIdx++;
|
|
64
64
|
return parent.nodeKey === "" ? String(idx) : `${parent.nodeKey}.${idx}`;
|
|
65
65
|
};
|
|
66
|
+
const claimIdKey = (frame, id) => {
|
|
67
|
+
if (id === void 0 || frame.claimed.has(id)) return void 0;
|
|
68
|
+
frame.claimed.add(id);
|
|
69
|
+
return `id:${id}`;
|
|
70
|
+
};
|
|
66
71
|
/**
|
|
67
72
|
* Build the group tree from an array of normalized group paths.
|
|
68
73
|
* `paths[i]` is the path for part `i`. The output tree contains one
|
|
69
74
|
* `part` node per part and one `group` node per coalesced run.
|
|
75
|
+
* `partIds[i]` optionally carries a stable identity for part `i` (e.g. a
|
|
76
|
+
* tool call id), from which nodes derive an `idKey`.
|
|
70
77
|
*/
|
|
71
|
-
const buildGroupTree = (paths) => {
|
|
78
|
+
const buildGroupTree = (paths, partIds) => {
|
|
72
79
|
const root = {
|
|
73
80
|
key: "",
|
|
74
81
|
nodeKey: "",
|
|
75
82
|
indices: [],
|
|
76
83
|
children: [],
|
|
77
|
-
nextChildIdx: 0
|
|
84
|
+
nextChildIdx: 0,
|
|
85
|
+
claimed: /* @__PURE__ */ new Set()
|
|
78
86
|
};
|
|
79
87
|
const stack = [root];
|
|
80
88
|
const closeTop = () => {
|
|
81
89
|
const closing = stack.pop();
|
|
82
|
-
stack[stack.length - 1]
|
|
90
|
+
const parent = stack[stack.length - 1];
|
|
91
|
+
parent.children.push({
|
|
83
92
|
type: "group",
|
|
84
93
|
key: closing.key,
|
|
85
94
|
nodeKey: closing.nodeKey,
|
|
95
|
+
idKey: claimIdKey(parent, partIds?.[closing.indices[0]]),
|
|
86
96
|
indices: closing.indices,
|
|
87
97
|
children: closing.children
|
|
88
98
|
});
|
|
@@ -99,14 +109,16 @@ const buildGroupTree = (paths) => {
|
|
|
99
109
|
nodeKey: makeChildNodeKey(parent),
|
|
100
110
|
indices: [],
|
|
101
111
|
children: [],
|
|
102
|
-
nextChildIdx: 0
|
|
112
|
+
nextChildIdx: 0,
|
|
113
|
+
claimed: /* @__PURE__ */ new Set()
|
|
103
114
|
});
|
|
104
115
|
}
|
|
105
116
|
const top = stack[stack.length - 1];
|
|
106
117
|
top.children.push({
|
|
107
118
|
type: "part",
|
|
108
119
|
index: i,
|
|
109
|
-
nodeKey: makeChildNodeKey(top)
|
|
120
|
+
nodeKey: makeChildNodeKey(top),
|
|
121
|
+
idKey: claimIdKey(top, partIds?.[i])
|
|
110
122
|
});
|
|
111
123
|
for (let s = 1; s < stack.length; s++) stack[s].indices.push(i);
|
|
112
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupParts.js","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"sourcesContent":["import { isMcpAppUri } from \"../../types/message\";\nimport type { PartState } from \"../../store/scopes/part\";\nimport type { ToolsState } from \"../types/scopes/tools\";\n\n/**\n * Registry context passed to a `groupBy` function as its second argument by\n * `<MessagePrimitive.GroupedParts>`. Carries the live tool-UI registry so a\n * `groupBy` can resolve registry-driven grouping (e.g. standalone tool calls)\n * without the part itself having to carry that information.\n */\nexport type GroupByContext = {\n /** Tool UIs registered in the tool-UI registry, keyed by tool name. */\n readonly toolUIs?: ToolsState[\"toolUIs\"];\n};\n\n/**\n * Hierarchical adjacent-coalescing grouping for message parts.\n *\n * Given a group path per part (from `groupBy`), builds a tree of group\n * nodes wrapping individual parts. Adjacent parts sharing a path prefix\n * coalesce into the same group; ungrouped parts are direct children of\n * the root.\n *\n * Each node gets a structural `nodeKey` built from sibling indices\n * (`\"0.1.0\"`), stable under append-only streaming.\n */\n\n/**\n * Symbol attached to memoizable `groupBy` functions (e.g. those returned\n * by {@link groupPartByType}). Carries a string fingerprint of the config\n * so `MessagePrimitive.GroupedParts` can memo the tree on\n * `[parts, memoKey]` across renders — even when the helper call site\n * reconstructs the function each render.\n */\nexport const GROUPBY_MEMO_KEY: unique symbol = Symbol.for(\n \"@assistant-ui/groupBy.memoKey\",\n);\n\n/**\n * Synthetic part-type keys recognized by {@link groupPartByType}, in\n * addition to real {@link PartState} types:\n *\n * - `\"standalone-tool-call\"` — a tool-call whose UI should be presented on its\n * own, outside the chain-of-thought grouping. Matches MCP-app tool calls plus\n * any tool-call whose registered UI opts into standalone display (human\n * tools, the built-in generative-UI tool, and tools that set\n * `display: \"standalone\"`). Resolving the registry-driven cases reads the\n * {@link GroupByContext} passed to the `groupBy` function. Takes precedence\n * over the `\"tool-call\"` entry.\n * - `\"mcp-app\"` — **deprecated**, kept for back-compat. Matches only MCP-app\n * tool calls. Prefer `\"standalone-tool-call\"`, which is a superset.\n */\ntype GroupPartType = PartState[\"type\"] | \"standalone-tool-call\" | \"mcp-app\";\n\n/**\n * Build a `groupBy` from a `part.type → group-key path` lookup.\n * Parts whose type isn't in the map are left ungrouped. The returned\n * function carries a stable {@link GROUPBY_MEMO_KEY} fingerprint so\n * `<MessagePrimitive.GroupedParts>` can memoize its tree across renders.\n *\n * The synthetic `\"standalone-tool-call\"` key matches tool calls that should\n * render outside the chain-of-thought grouping. MCP-app calls are detected from\n * the part alone; the registry-driven cases (human tools, the generative-UI\n * tool, `display: \"standalone\"` opt-ins) are resolved from the\n * {@link GroupByContext} that `<MessagePrimitive.GroupedParts>` passes to the\n * `groupBy` function — the helper needs nothing threaded into it.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * \"standalone-tool-call\": [],\n * })}\n * >\n * {({ part, children }) => { ... }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const groupPartByType = <TKey extends `group-${string}`>(\n map: Partial<Readonly<Record<GroupPartType, readonly TKey[]>>>,\n): ((part: PartState, context?: GroupByContext) => readonly TKey[]) => {\n const lookup = map as Readonly<Record<string, readonly TKey[] | undefined>>;\n const fn = ((part, context) => {\n if (part.type === \"tool-call\") {\n const isMcpApp = isMcpAppUri(part.mcp?.app?.resourceUri);\n // Read the first registration's flag — the same one `resolveToolRender`\n // renders — so grouping and rendering never disagree for a tool name.\n const isStandalone =\n isMcpApp ||\n (context?.toolUIs?.[part.toolName]?.[0]?.standalone ?? false);\n if (isStandalone && lookup[\"standalone-tool-call\"] !== undefined) {\n return lookup[\"standalone-tool-call\"]!;\n }\n // TODO(v0.15): drop the deprecated \"mcp-app\" key (superseded by \"standalone-tool-call\").\n if (isMcpApp && lookup[\"mcp-app\"] !== undefined) {\n return lookup[\"mcp-app\"]!;\n }\n }\n return lookup[part.type] ?? [];\n }) as ((part: PartState, context?: GroupByContext) => readonly TKey[]) & {\n [GROUPBY_MEMO_KEY]?: string;\n };\n // Sort keys so the fingerprint is insensitive to map insertion order —\n // two maps with the same key/value pairs but different declaration order\n // would otherwise hash differently and invalidate the memo unnecessarily.\n const sortedKeys = Object.keys(map).sort();\n const sortedEntries = sortedKeys.map((k) => [k, map[k as keyof typeof map]]);\n fn[GROUPBY_MEMO_KEY] = `groupPartByType:${JSON.stringify(sortedEntries)}`;\n return fn;\n};\n\nexport type GroupNode = GroupNodeGroup | GroupNodePart;\n\nexport interface GroupNodeGroup {\n readonly type: \"group\";\n /** Current-level group key (last segment of the path). */\n readonly key: string;\n /** Structural React key: sibling-index path, e.g. `\"0.1.0\"`. */\n readonly nodeKey: string;\n /** Indices of parts in this subtree, in order. */\n readonly indices: readonly number[];\n readonly children: readonly GroupNode[];\n}\n\nexport interface GroupNodePart {\n readonly type: \"part\";\n /** Index of the part in the message. */\n readonly index: number;\n /** Structural React key: sibling-index path within parent. */\n readonly nodeKey: string;\n}\n\ninterface BuildFrame {\n key: string;\n nodeKey: string;\n indices: number[];\n children: GroupNode[];\n nextChildIdx: number;\n}\n\nconst makeChildNodeKey = (parent: BuildFrame): string => {\n const idx = parent.nextChildIdx++;\n return parent.nodeKey === \"\" ? String(idx) : `${parent.nodeKey}.${idx}`;\n};\n\n/**\n * Build the group tree from an array of normalized group paths.\n * `paths[i]` is the path for part `i`. The output tree contains one\n * `part` node per part and one `group` node per coalesced run.\n */\nexport const buildGroupTree = (\n paths: readonly (readonly string[])[],\n): readonly GroupNode[] => {\n const root: BuildFrame = {\n key: \"\",\n nodeKey: \"\",\n indices: [],\n children: [],\n nextChildIdx: 0,\n };\n const stack: BuildFrame[] = [root];\n\n const closeTop = (): void => {\n const closing = stack.pop()!;\n const parent = stack[stack.length - 1]!;\n parent.children.push({\n type: \"group\",\n key: closing.key,\n nodeKey: closing.nodeKey,\n indices: closing.indices,\n children: closing.children,\n });\n };\n\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i]!;\n\n // Find the longest prefix shared between currently-open groups\n // (excluding root) and this part's path.\n let common = 0;\n while (\n common < stack.length - 1 &&\n common < path.length &&\n stack[common + 1]!.key === path[common]\n ) {\n common++;\n }\n\n // Close groups not on this path.\n while (stack.length - 1 > common) {\n closeTop();\n }\n\n // Open new groups down to the part's depth.\n while (stack.length - 1 < path.length) {\n const parent = stack[stack.length - 1]!;\n stack.push({\n key: path[stack.length - 1]!,\n nodeKey: makeChildNodeKey(parent),\n indices: [],\n children: [],\n nextChildIdx: 0,\n });\n }\n\n // Push this part as a leaf in the deepest open group (or root).\n const top = stack[stack.length - 1]!;\n top.children.push({\n type: \"part\",\n index: i,\n nodeKey: makeChildNodeKey(top),\n });\n\n // Record the part index in every open ancestor group.\n for (let s = 1; s < stack.length; s++) {\n stack[s]!.indices.push(i);\n }\n }\n\n // Close any still-open groups.\n while (stack.length > 1) {\n closeTop();\n }\n\n return root.children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,mBAAkC,OAAO,IACpD,+BACF;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,mBACX,QACqE;CACrE,MAAM,SAAS;CACf,MAAM,OAAO,MAAM,YAAY;EAC7B,IAAI,KAAK,SAAS,aAAa;GAC7B,MAAM,WAAW,YAAY,KAAK,KAAK,KAAK,WAAW;GAMvD,KAFE,aACC,SAAS,UAAU,KAAK,SAAS,GAAG,EAAE,EAAE,cAAc,WACrC,OAAO,4BAA4B,KAAA,GACrD,OAAO,OAAO;GAGhB,IAAI,YAAY,OAAO,eAAe,KAAA,GACpC,OAAO,OAAO;EAElB;EACA,OAAO,OAAO,KAAK,SAAS,CAAC;CAC/B;CAOA,MAAM,gBADa,OAAO,KAAK,G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AG,IAAI,MAAM,QAAQ,KAChC,MAAM,EAAE,CAAE,QAAQ,KAAK,CAAC;CAE5B;CAGA,OAAO,MAAM,SAAS,GACpB,SAAS;CAGX,OAAO,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"groupParts.js","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"sourcesContent":["import { isMcpAppUri } from \"../../types/message\";\nimport type { PartState } from \"../../store/scopes/part\";\nimport type { ToolsState } from \"../types/scopes/tools\";\n\n/**\n * Registry context passed to a `groupBy` function as its second argument by\n * `<MessagePrimitive.GroupedParts>`. Carries the live tool-UI registry so a\n * `groupBy` can resolve registry-driven grouping (e.g. standalone tool calls)\n * without the part itself having to carry that information.\n */\nexport type GroupByContext = {\n /** Tool UIs registered in the tool-UI registry, keyed by tool name. */\n readonly toolUIs?: ToolsState[\"toolUIs\"];\n};\n\n/**\n * Hierarchical adjacent-coalescing grouping for message parts.\n *\n * Given a group path per part (from `groupBy`), builds a tree of group\n * nodes wrapping individual parts. Adjacent parts sharing a path prefix\n * coalesce into the same group; ungrouped parts are direct children of\n * the root.\n *\n * Each node gets a structural `nodeKey` built from sibling indices\n * (`\"0.1.0\"`), stable under append-only streaming.\n */\n\n/**\n * Symbol attached to memoizable `groupBy` functions (e.g. those returned\n * by {@link groupPartByType}). Carries a string fingerprint of the config\n * so `MessagePrimitive.GroupedParts` can memo the tree on\n * `[parts, memoKey]` across renders — even when the helper call site\n * reconstructs the function each render.\n */\nexport const GROUPBY_MEMO_KEY: unique symbol = Symbol.for(\n \"@assistant-ui/groupBy.memoKey\",\n);\n\n/**\n * Synthetic part-type keys recognized by {@link groupPartByType}, in\n * addition to real {@link PartState} types:\n *\n * - `\"standalone-tool-call\"` — a tool-call whose UI should be presented on its\n * own, outside the chain-of-thought grouping. Matches MCP-app tool calls plus\n * any tool-call whose registered UI opts into standalone display (human\n * tools, the built-in generative-UI tool, and tools that set\n * `display: \"standalone\"`). Resolving the registry-driven cases reads the\n * {@link GroupByContext} passed to the `groupBy` function. Takes precedence\n * over the `\"tool-call\"` entry.\n * - `\"mcp-app\"` — **deprecated**, kept for back-compat. Matches only MCP-app\n * tool calls. Prefer `\"standalone-tool-call\"`, which is a superset.\n */\ntype GroupPartType = PartState[\"type\"] | \"standalone-tool-call\" | \"mcp-app\";\n\n/**\n * Build a `groupBy` from a `part.type → group-key path` lookup.\n * Parts whose type isn't in the map are left ungrouped. The returned\n * function carries a stable {@link GROUPBY_MEMO_KEY} fingerprint so\n * `<MessagePrimitive.GroupedParts>` can memoize its tree across renders.\n *\n * The synthetic `\"standalone-tool-call\"` key matches tool calls that should\n * render outside the chain-of-thought grouping. MCP-app calls are detected from\n * the part alone; the registry-driven cases (human tools, the generative-UI\n * tool, `display: \"standalone\"` opt-ins) are resolved from the\n * {@link GroupByContext} that `<MessagePrimitive.GroupedParts>` passes to the\n * `groupBy` function — the helper needs nothing threaded into it.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * \"standalone-tool-call\": [],\n * })}\n * >\n * {({ part, children }) => { ... }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const groupPartByType = <TKey extends `group-${string}`>(\n map: Partial<Readonly<Record<GroupPartType, readonly TKey[]>>>,\n): ((part: PartState, context?: GroupByContext) => readonly TKey[]) => {\n const lookup = map as Readonly<Record<string, readonly TKey[] | undefined>>;\n const fn = ((part, context) => {\n if (part.type === \"tool-call\") {\n const isMcpApp = isMcpAppUri(part.mcp?.app?.resourceUri);\n // Read the first registration's flag — the same one `resolveToolRender`\n // renders — so grouping and rendering never disagree for a tool name.\n const isStandalone =\n isMcpApp ||\n (context?.toolUIs?.[part.toolName]?.[0]?.standalone ?? false);\n if (isStandalone && lookup[\"standalone-tool-call\"] !== undefined) {\n return lookup[\"standalone-tool-call\"]!;\n }\n // TODO(v0.15): drop the deprecated \"mcp-app\" key (superseded by \"standalone-tool-call\").\n if (isMcpApp && lookup[\"mcp-app\"] !== undefined) {\n return lookup[\"mcp-app\"]!;\n }\n }\n return lookup[part.type] ?? [];\n }) as ((part: PartState, context?: GroupByContext) => readonly TKey[]) & {\n [GROUPBY_MEMO_KEY]?: string;\n };\n // Sort keys so the fingerprint is insensitive to map insertion order —\n // two maps with the same key/value pairs but different declaration order\n // would otherwise hash differently and invalidate the memo unnecessarily.\n const sortedKeys = Object.keys(map).sort();\n const sortedEntries = sortedKeys.map((k) => [k, map[k as keyof typeof map]]);\n fn[GROUPBY_MEMO_KEY] = `groupPartByType:${JSON.stringify(sortedEntries)}`;\n return fn;\n};\n\nexport type GroupNode = GroupNodeGroup | GroupNodePart;\n\nexport interface GroupNodeGroup {\n readonly type: \"group\";\n /** Current-level group key (last segment of the path). */\n readonly key: string;\n /** Structural React key: sibling-index path, e.g. `\"0.1.0\"`. */\n readonly nodeKey: string;\n /**\n * Identity key (`\"id:<partId>\"`) from the group's first part; undefined\n * when absent or already claimed by an earlier sibling.\n */\n readonly idKey: string | undefined;\n /** Indices of parts in this subtree, in order. */\n readonly indices: readonly number[];\n readonly children: readonly GroupNode[];\n}\n\nexport interface GroupNodePart {\n readonly type: \"part\";\n /** Index of the part in the message. */\n readonly index: number;\n /** Structural React key: sibling-index path within parent. */\n readonly nodeKey: string;\n /**\n * Identity key (`\"id:<partId>\"`); undefined when absent or already\n * claimed by an earlier sibling.\n */\n readonly idKey: string | undefined;\n}\n\ninterface BuildFrame {\n key: string;\n nodeKey: string;\n indices: number[];\n children: GroupNode[];\n nextChildIdx: number;\n claimed: Set<string>;\n}\n\nconst makeChildNodeKey = (parent: BuildFrame): string => {\n const idx = parent.nextChildIdx++;\n return parent.nodeKey === \"\" ? String(idx) : `${parent.nodeKey}.${idx}`;\n};\n\nconst claimIdKey = (\n frame: BuildFrame,\n id: string | undefined,\n): string | undefined => {\n if (id === undefined || frame.claimed.has(id)) return undefined;\n frame.claimed.add(id);\n return `id:${id}`;\n};\n\n/**\n * Build the group tree from an array of normalized group paths.\n * `paths[i]` is the path for part `i`. The output tree contains one\n * `part` node per part and one `group` node per coalesced run.\n * `partIds[i]` optionally carries a stable identity for part `i` (e.g. a\n * tool call id), from which nodes derive an `idKey`.\n */\nexport const buildGroupTree = (\n paths: readonly (readonly string[])[],\n partIds?: readonly (string | undefined)[],\n): readonly GroupNode[] => {\n const root: BuildFrame = {\n key: \"\",\n nodeKey: \"\",\n indices: [],\n children: [],\n nextChildIdx: 0,\n claimed: new Set(),\n };\n const stack: BuildFrame[] = [root];\n\n const closeTop = (): void => {\n const closing = stack.pop()!;\n const parent = stack[stack.length - 1]!;\n parent.children.push({\n type: \"group\",\n key: closing.key,\n nodeKey: closing.nodeKey,\n idKey: claimIdKey(parent, partIds?.[closing.indices[0]!]),\n indices: closing.indices,\n children: closing.children,\n });\n };\n\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i]!;\n\n // Find the longest prefix shared between currently-open groups\n // (excluding root) and this part's path.\n let common = 0;\n while (\n common < stack.length - 1 &&\n common < path.length &&\n stack[common + 1]!.key === path[common]\n ) {\n common++;\n }\n\n // Close groups not on this path.\n while (stack.length - 1 > common) {\n closeTop();\n }\n\n // Open new groups down to the part's depth.\n while (stack.length - 1 < path.length) {\n const parent = stack[stack.length - 1]!;\n stack.push({\n key: path[stack.length - 1]!,\n nodeKey: makeChildNodeKey(parent),\n indices: [],\n children: [],\n nextChildIdx: 0,\n claimed: new Set(),\n });\n }\n\n // Push this part as a leaf in the deepest open group (or root).\n const top = stack[stack.length - 1]!;\n top.children.push({\n type: \"part\",\n index: i,\n nodeKey: makeChildNodeKey(top),\n idKey: claimIdKey(top, partIds?.[i]),\n });\n\n // Record the part index in every open ancestor group.\n for (let s = 1; s < stack.length; s++) {\n stack[s]!.indices.push(i);\n }\n }\n\n // Close any still-open groups.\n while (stack.length > 1) {\n closeTop();\n }\n\n return root.children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA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QAAQ;GACjB,OAAO,WAAW,QAAQ,UAAU,QAAQ,QAAQ,GAAI;GACxD,SAAS,QAAQ;GACjB,UAAU,QAAQ;EACpB,CAAC;CACH;CAEA,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM;EAInB,IAAI,SAAS;EACb,OACE,SAAS,MAAM,SAAS,KACxB,SAAS,KAAK,UACd,MAAM,SAAS,EAAE,CAAE,QAAQ,KAAK,SAEhC;EAIF,OAAO,MAAM,SAAS,IAAI,QACxB,SAAS;EAIX,OAAO,MAAM,SAAS,IAAI,KAAK,QAAQ;GACrC,MAAM,SAAS,MAAM,MAAM,SAAS;GACpC,MAAM,KAAK;IACT,KAAK,KAAK,MAAM,SAAS;IACzB,SAAS,iBAAiB,MAAM;IAChC,SAAS,CAAC;IACV,UAAU,CAAC;IACX,cAAc;IACd,yBAAS,IAAI,IAAI;GACnB,CAAC;EACH;EAGA,MAAM,MAAM,MAAM,MAAM,SAAS;EACjC,IAAI,SAAS,KAAK;GAChB,MAAM;GACN,OAAO;GACP,SAAS,iBAAiB,GAAG;GAC7B,OAAO,WAAW,KAAK,UAAU,EAAE;EACrC,CAAC;EAGD,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,MAAM,EAAE,CAAE,QAAQ,KAAK,CAAC;CAE5B;CAGA,OAAO,MAAM,SAAS,GACpB,SAAS;CAGX,OAAO,KAAK;AACd"}
|
|
@@ -28,6 +28,7 @@ type ThreadListItemState = {
|
|
|
28
28
|
readonly externalId: string | undefined;
|
|
29
29
|
readonly status: ThreadListItemStatus;
|
|
30
30
|
readonly title?: string | undefined;
|
|
31
|
+
readonly lastMessageAt?: Date | undefined;
|
|
31
32
|
readonly custom?: Record<string, unknown> | undefined;
|
|
32
33
|
};
|
|
33
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.d.ts","names":[],"sources":["../../../src/runtime/api/bindings.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GAAS,MAAA;AAAA"}
|
|
@@ -28,6 +28,7 @@ type MessageRuntime = {
|
|
|
28
28
|
readonly path: MessageRuntimePath;
|
|
29
29
|
readonly composer: EditComposerRuntime;
|
|
30
30
|
getState(): MessageState;
|
|
31
|
+
delete(): void | Promise<void>;
|
|
31
32
|
reload(config?: ReloadConfig): void;
|
|
32
33
|
/**
|
|
33
34
|
* @deprecated This API is still under active development and might change without notice.
|
|
@@ -73,6 +74,7 @@ declare class MessageRuntimeImpl implements MessageRuntime {
|
|
|
73
74
|
readonly branchCount: number;
|
|
74
75
|
readonly speech: SpeechState | undefined;
|
|
75
76
|
};
|
|
77
|
+
delete(): void | Promise<void>;
|
|
76
78
|
reload(reloadConfig?: ReloadConfig): void;
|
|
77
79
|
speak(): void;
|
|
78
80
|
stopSpeaking(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/message-runtime.ts"],"mappings":";;;;;;;;;;;cAsCa,mBAAA,GACX,OAAA,EAAS,aAAA,EACT,SAAA,UACA,IAAA,EAAM,qBAAA,GAAwB,0BAAA,KAC7B,yBAAA;AAAA,KAkCS,YAAA,GAAe,aAAA;EAAA,SAChB,QAAA;WAEA,KAAA;EAAA,SACA,MAAA;EAAA,SAEA,YAAA;EAAA,SACA,WAAA;EA3BV;;;EAAA,SAgCU,MAAA,EAAQ,WAAW;AAAA;AAAA,KAKzB,YAAA;EACH,SAAA,GAAY,SAAS;AAAA;AAAA,KAGX,cAAA;EAAA,SACD,IAAA,EAAM,kBAAA;EAAA,SAEN,QAAA,EAAU,mBAAA;EAEnB,QAAA,IAAY,YAAA;EACZ,MAAA,CAAO,MAAA,GAAS,YAAA;
|
|
1
|
+
{"version":3,"file":"message-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/message-runtime.ts"],"mappings":";;;;;;;;;;;cAsCa,mBAAA,GACX,OAAA,EAAS,aAAA,EACT,SAAA,UACA,IAAA,EAAM,qB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A;EAIA,SAAA,CAAU,QAAA,eAAoB,WAAA;EAI9B,qBAAA,CAAsB,GAAA,WAAW,sBAAA;EAmBjC,0BAAA,CAA2B,UAAA,WAAkB,sBAAA;EA0B7C,oBAAA,CAAqB,GAAA,WAAW,4BAAA;AAAA"}
|
|
@@ -46,6 +46,7 @@ var MessageRuntimeImpl = class {
|
|
|
46
46
|
}
|
|
47
47
|
__internal_bindMethods() {
|
|
48
48
|
this.reload = this.reload.bind(this);
|
|
49
|
+
this.delete = this.delete.bind(this);
|
|
49
50
|
this.getState = this.getState.bind(this);
|
|
50
51
|
this.subscribe = this.subscribe.bind(this);
|
|
51
52
|
this.getMessagePartByIndex = this.getMessagePartByIndex.bind(this);
|
|
@@ -64,6 +65,10 @@ var MessageRuntimeImpl = class {
|
|
|
64
65
|
getState() {
|
|
65
66
|
return this._core.getState();
|
|
66
67
|
}
|
|
68
|
+
delete() {
|
|
69
|
+
const state = this._core.getState();
|
|
70
|
+
return this._threadBinding.getState().deleteMessage(state.id);
|
|
71
|
+
}
|
|
67
72
|
reload(reloadConfig = {}) {
|
|
68
73
|
const editComposerRuntimeCore = this._getEditComposerRuntimeCore();
|
|
69
74
|
const composerRuntimeCore = editComposerRuntimeCore ?? this._threadBinding.getState().composer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-runtime.js","names":[],"sources":["../../../src/runtime/api/message-runtime.ts"],"sourcesContent":["import type { SpeechState } from \"../interfaces/thread-runtime-core\";\nimport { symbolInnerMessage } from \"../utils/external-store-message\";\nimport type {\n ToolCallMessagePartStatus,\n ThreadMessage,\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n} from \"../../types/message\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { MessagePartStatus, RunConfig } from \"../../types/message\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { NestedSubscriptionSubject } from \"../../subscribable/subscribable\";\nimport {\n SKIP_UPDATE,\n ShallowMemoizeSubject,\n} from \"../../subscribable/subscribable\";\nimport {\n type AttachmentRuntime,\n type AttachmentState,\n MessageAttachmentRuntimeImpl,\n} from \"./attachment-runtime\";\nimport {\n type EditComposerRuntime,\n EditComposerRuntimeImpl,\n} from \"./composer-runtime\";\nimport {\n type MessagePartRuntime,\n MessagePartRuntimeImpl,\n type MessagePartState,\n} from \"./message-part-runtime\";\nimport type { MessageRuntimePath } from \"./paths\";\nimport type { ThreadRuntimeCoreBinding } from \"./thread-runtime\";\nimport type { MessageStateBinding } from \"./bindings\";\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nexport const toMessagePartStatus = (\n message: ThreadMessage,\n partIndex: number,\n part: ThreadUserMessagePart | ThreadAssistantMessagePart,\n): ToolCallMessagePartStatus => {\n if (message.role !== \"assistant\") return COMPLETE_STATUS;\n\n if (part.type === \"tool-call\") {\n if (!part.result) {\n return message.status as ToolCallMessagePartStatus;\n } else {\n return COMPLETE_STATUS;\n }\n }\n\n const isLastPart = partIndex === Math.max(0, message.content.length - 1);\n if (message.status.type === \"requires-action\") return COMPLETE_STATUS;\n return isLastPart ? (message.status as MessagePartStatus) : COMPLETE_STATUS;\n};\n\nconst getMessagePartState = (\n message: MessageState,\n partIndex: number,\n): MessagePartState | SKIP_UPDATE => {\n const part = message.content[partIndex];\n if (!part) {\n return SKIP_UPDATE;\n }\n\n // if the message part is the same, don't update\n const status = toMessagePartStatus(message, partIndex, part);\n return Object.freeze({\n ...part,\n ...{ [symbolInnerMessage]: (part as any)[symbolInnerMessage] },\n status,\n });\n};\n\nexport type MessageState = ThreadMessage & {\n readonly parentId: string | null;\n /** The position of this message in the thread (0 for first message) */\n readonly index: number;\n readonly isLast: boolean;\n\n readonly branchNumber: number;\n readonly branchCount: number;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n readonly speech: SpeechState | undefined;\n};\n\nexport type { MessageStateBinding } from \"./bindings\";\n\ntype ReloadConfig = {\n runConfig?: RunConfig;\n};\n\nexport type MessageRuntime = {\n readonly path: MessageRuntimePath;\n\n readonly composer: EditComposerRuntime;\n\n getState(): MessageState;\n reload(config?: ReloadConfig): void;\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n speak(): void;\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n stopSpeaking(): void;\n submitFeedback({ type }: { type: \"positive\" | \"negative\" }): void;\n switchToBranch({\n position,\n branchId,\n }: {\n position?: \"previous\" | \"next\" | undefined;\n branchId?: string | undefined;\n }): void;\n unstable_getCopyText(): string;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getMessagePartByIndex(idx: number): MessagePartRuntime;\n getMessagePartByToolCallId(toolCallId: string): MessagePartRuntime;\n\n getAttachmentByIndex(idx: number): AttachmentRuntime & { source: \"message\" };\n};\n\nexport class MessageRuntimeImpl implements MessageRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: MessageStateBinding,\n private _threadBinding: ThreadRuntimeCoreBinding,\n ) {\n this.composer = new EditComposerRuntimeImpl(\n new NestedSubscriptionSubject({\n path: {\n ...this.path,\n ref: `${this.path.ref}${this.path.ref}.composer`,\n composerSource: \"edit\",\n },\n getState: this._getEditComposerRuntimeCore,\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n () => this._threadBinding.getState().beginEdit(this._core.getState().id),\n );\n\n this.__internal_bindMethods();\n }\n\n protected __internal_bindMethods() {\n this.reload = this.reload.bind(this);\n this.getState = this.getState.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.getMessagePartByIndex = this.getMessagePartByIndex.bind(this);\n this.getMessagePartByToolCallId =\n this.getMessagePartByToolCallId.bind(this);\n this.getAttachmentByIndex = this.getAttachmentByIndex.bind(this);\n this.unstable_getCopyText = this.unstable_getCopyText.bind(this);\n this.speak = this.speak.bind(this);\n this.stopSpeaking = this.stopSpeaking.bind(this);\n this.submitFeedback = this.submitFeedback.bind(this);\n this.switchToBranch = this.switchToBranch.bind(this);\n }\n\n public readonly composer;\n\n private _getEditComposerRuntimeCore = () => {\n return this._threadBinding\n .getState()\n .getEditComposer(this._core.getState().id);\n };\n\n public getState() {\n return this._core.getState();\n }\n\n public reload(reloadConfig: ReloadConfig = {}) {\n const editComposerRuntimeCore = this._getEditComposerRuntimeCore();\n const composerRuntimeCore =\n editComposerRuntimeCore ?? this._threadBinding.getState().composer;\n const composer = editComposerRuntimeCore ?? composerRuntimeCore;\n\n const { runConfig = composer.runConfig } = reloadConfig;\n const state = this._core.getState();\n if (state.role !== \"assistant\")\n throw new Error(\"Can only reload assistant messages\");\n\n this._threadBinding.getState().startRun({\n parentId: state.parentId,\n sourceId: state.id,\n runConfig,\n });\n }\n\n public speak() {\n const state = this._core.getState();\n return this._threadBinding.getState().speak(state.id);\n }\n\n public stopSpeaking() {\n const state = this._core.getState();\n const thread = this._threadBinding.getState();\n if (thread.speech?.messageId === state.id) {\n this._threadBinding.getState().stopSpeaking();\n } else {\n throw new Error(\"Message is not being spoken\");\n }\n }\n\n public submitFeedback({ type }: { type: \"positive\" | \"negative\" }) {\n const state = this._core.getState();\n this._threadBinding.getState().submitFeedback({\n messageId: state.id,\n type,\n });\n }\n\n public switchToBranch({\n position,\n branchId,\n }: {\n position?: \"previous\" | \"next\" | undefined;\n branchId?: string | undefined;\n }) {\n const state = this._core.getState();\n if (branchId && position) {\n throw new Error(\"May not specify both branchId and position\");\n } else if (!branchId && !position) {\n throw new Error(\"Must specify either branchId or position\");\n }\n\n const thread = this._threadBinding.getState();\n const branches = thread.getBranches(state.id);\n let targetBranch = branchId;\n if (position === \"previous\") {\n targetBranch = branches[state.branchNumber - 2];\n } else if (position === \"next\") {\n targetBranch = branches[state.branchNumber];\n }\n if (!targetBranch) throw new Error(\"Branch not found\");\n\n this._threadBinding.getState().switchToBranch(targetBranch);\n }\n\n public unstable_getCopyText() {\n return getThreadMessageText(this.getState());\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public getMessagePartByIndex(idx: number) {\n if (idx < 0) throw new Error(\"Message part index must be >= 0\");\n return new MessagePartRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref: `${this.path.ref}${this.path.ref}.content[${idx}]`,\n messagePartSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getMessagePartState(this.getState(), idx);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n this._threadBinding,\n );\n }\n\n public getMessagePartByToolCallId(toolCallId: string) {\n return new MessagePartRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref:\n this.path.ref +\n `${this.path.ref}.content[toolCallId=${JSON.stringify(toolCallId)}]`,\n messagePartSelector: { type: \"toolCallId\", toolCallId },\n },\n getState: () => {\n const state = this._core.getState();\n const idx = state.content.findIndex(\n (part) =>\n part.type === \"tool-call\" && part.toolCallId === toolCallId,\n );\n if (idx === -1) return SKIP_UPDATE;\n return getMessagePartState(state, idx);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n this._threadBinding,\n );\n }\n\n public getAttachmentByIndex(idx: number) {\n return new MessageAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref: `${this.path.ref}${this.path.ref}.attachments[${idx}]`,\n attachmentSource: \"message\",\n attachmentSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments?.[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"message\",\n } satisfies AttachmentState & { source: \"message\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n );\n }\n}\n"],"mappings":";;;;;;;AAkCA,MAAM,kBAAqC,OAAO,OAAO,EACvD,MAAM,WACR,CAAC;AAED,MAAa,uBACX,SACA,WACA,SAC8B;CAC9B,IAAI,QAAQ,SAAS,aAAa,OAAO;CAEzC,IAAI,KAAK,SAAS,aAChB,IAAI,CAAC,KAAK,QACR,OAAO,QAAQ;MAEf,OAAO;CAIX,MAAM,aAAa,cAAc,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OAAO;IACvB,OAAO,oBAAoB,OAAO,GAAG;GACvC;GACA,YAAY,aAAa,KAAK,MAAM,UAAU,QAAQ;EACxD,CAAC,GACD,KAAK,OACL,KAAK,cACP;CACF;CAEA,qBAA4B,KAAa;EACvC,OAAO,IAAI,6BACT,IAAI,sBAAsB;GACxB,MAAM;IACJ,GAAG,KAAK;IACR,KAAK,GAAG,KAAK,KAAK,MAAM,KAAK,KAAK,IAAI,eAAe,IAAI;IACzD,kBAAkB;IAClB,oBAAoB;KAAE,MAAM;KAAS,OAAO;IAAI;GAClD;GACA,gBAAgB;IAEd,MAAM,aADc,KAAK,SAAS,CAAC,CAAC,cACH;IACjC,IAAI,CAAC,YAAY,OAAO;IAExB,OAAO;KACL,GAAG;KACH,QAAQ;IACV;GACF;GACA,YAAY,aAAa,KAAK,MAAM,UAAU,QAAQ;EACxD,CAAC,CACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"message-runtime.js","names":[],"sources":["../../../src/runtime/api/message-runtime.ts"],"sourcesContent":["import type { SpeechState } from \"../interfaces/thread-runtime-core\";\nimport { symbolInnerMessage } from \"../utils/external-store-message\";\nimport type {\n ToolCallMessagePartStatus,\n ThreadMessage,\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n} from \"../../types/message\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { MessagePartStatus, RunConfig } from \"../../types/message\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { NestedSubscriptionSubject } from \"../../subscribable/subscribable\";\nimport {\n SKIP_UPDATE,\n ShallowMemoizeSubject,\n} from \"../../subscribable/subscribable\";\nimport {\n type AttachmentRuntime,\n type AttachmentState,\n MessageAttachmentRuntimeImpl,\n} from \"./attachment-runtime\";\nimport {\n type EditComposerRuntime,\n EditComposerRuntimeImpl,\n} from \"./composer-runtime\";\nimport {\n type MessagePartRuntime,\n MessagePartRuntimeImpl,\n type MessagePartState,\n} from \"./message-part-runtime\";\nimport type { MessageRuntimePath } from \"./paths\";\nimport type { ThreadRuntimeCoreBinding } from \"./thread-runtime\";\nimport type { MessageStateBinding } from \"./bindings\";\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nexport const toMessagePartStatus = (\n message: ThreadMessage,\n partIndex: number,\n part: ThreadUserMessagePart | ThreadAssistantMessagePart,\n): ToolCallMessagePartStatus => {\n if (message.role !== \"assistant\") return COMPLETE_STATUS;\n\n if (part.type === \"tool-call\") {\n if (!part.result) {\n return message.status as ToolCallMessagePartStatus;\n } else {\n return COMPLETE_STATUS;\n }\n }\n\n const isLastPart = partIndex === Math.max(0, message.content.length - 1);\n if (message.status.type === \"requires-action\") return COMPLETE_STATUS;\n return isLastPart ? (message.status as MessagePartStatus) : COMPLETE_STATUS;\n};\n\nconst getMessagePartState = (\n message: MessageState,\n partIndex: number,\n): MessagePartState | SKIP_UPDATE => {\n const part = message.content[partIndex];\n if (!part) {\n return SKIP_UPDATE;\n }\n\n // if the message part is the same, don't update\n const status = toMessagePartStatus(message, partIndex, part);\n return Object.freeze({\n ...part,\n ...{ [symbolInnerMessage]: (part as any)[symbolInnerMessage] },\n status,\n });\n};\n\nexport type MessageState = ThreadMessage & {\n readonly parentId: string | null;\n /** The position of this message in the thread (0 for first message) */\n readonly index: number;\n readonly isLast: boolean;\n\n readonly branchNumber: number;\n readonly branchCount: number;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n readonly speech: SpeechState | undefined;\n};\n\nexport type { MessageStateBinding } from \"./bindings\";\n\ntype ReloadConfig = {\n runConfig?: RunConfig;\n};\n\nexport type MessageRuntime = {\n readonly path: MessageRuntimePath;\n\n readonly composer: EditComposerRuntime;\n\n getState(): MessageState;\n delete(): void | Promise<void>;\n reload(config?: ReloadConfig): void;\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n speak(): void;\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n stopSpeaking(): void;\n submitFeedback({ type }: { type: \"positive\" | \"negative\" }): void;\n switchToBranch({\n position,\n branchId,\n }: {\n position?: \"previous\" | \"next\" | undefined;\n branchId?: string | undefined;\n }): void;\n unstable_getCopyText(): string;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getMessagePartByIndex(idx: number): MessagePartRuntime;\n getMessagePartByToolCallId(toolCallId: string): MessagePartRuntime;\n\n getAttachmentByIndex(idx: number): AttachmentRuntime & { source: \"message\" };\n};\n\nexport class MessageRuntimeImpl implements MessageRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: MessageStateBinding,\n private _threadBinding: ThreadRuntimeCoreBinding,\n ) {\n this.composer = new EditComposerRuntimeImpl(\n new NestedSubscriptionSubject({\n path: {\n ...this.path,\n ref: `${this.path.ref}${this.path.ref}.composer`,\n composerSource: \"edit\",\n },\n getState: this._getEditComposerRuntimeCore,\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n () => this._threadBinding.getState().beginEdit(this._core.getState().id),\n );\n\n this.__internal_bindMethods();\n }\n\n protected __internal_bindMethods() {\n this.reload = this.reload.bind(this);\n this.delete = this.delete.bind(this);\n this.getState = this.getState.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.getMessagePartByIndex = this.getMessagePartByIndex.bind(this);\n this.getMessagePartByToolCallId =\n this.getMessagePartByToolCallId.bind(this);\n this.getAttachmentByIndex = this.getAttachmentByIndex.bind(this);\n this.unstable_getCopyText = this.unstable_getCopyText.bind(this);\n this.speak = this.speak.bind(this);\n this.stopSpeaking = this.stopSpeaking.bind(this);\n this.submitFeedback = this.submitFeedback.bind(this);\n this.switchToBranch = this.switchToBranch.bind(this);\n }\n\n public readonly composer;\n\n private _getEditComposerRuntimeCore = () => {\n return this._threadBinding\n .getState()\n .getEditComposer(this._core.getState().id);\n };\n\n public getState() {\n return this._core.getState();\n }\n\n public delete() {\n const state = this._core.getState();\n return this._threadBinding.getState().deleteMessage(state.id);\n }\n\n public reload(reloadConfig: ReloadConfig = {}) {\n const editComposerRuntimeCore = this._getEditComposerRuntimeCore();\n const composerRuntimeCore =\n editComposerRuntimeCore ?? this._threadBinding.getState().composer;\n const composer = editComposerRuntimeCore ?? composerRuntimeCore;\n\n const { runConfig = composer.runConfig } = reloadConfig;\n const state = this._core.getState();\n if (state.role !== \"assistant\")\n throw new Error(\"Can only reload assistant messages\");\n\n this._threadBinding.getState().startRun({\n parentId: state.parentId,\n sourceId: state.id,\n runConfig,\n });\n }\n\n public speak() {\n const state = this._core.getState();\n return this._threadBinding.getState().speak(state.id);\n }\n\n public stopSpeaking() {\n const state = this._core.getState();\n const thread = this._threadBinding.getState();\n if (thread.speech?.messageId === state.id) {\n this._threadBinding.getState().stopSpeaking();\n } else {\n throw new Error(\"Message is not being spoken\");\n }\n }\n\n public submitFeedback({ type }: { type: \"positive\" | \"negative\" }) {\n const state = this._core.getState();\n this._threadBinding.getState().submitFeedback({\n messageId: state.id,\n type,\n });\n }\n\n public switchToBranch({\n position,\n branchId,\n }: {\n position?: \"previous\" | \"next\" | undefined;\n branchId?: string | undefined;\n }) {\n const state = this._core.getState();\n if (branchId && position) {\n throw new Error(\"May not specify both branchId and position\");\n } else if (!branchId && !position) {\n throw new Error(\"Must specify either branchId or position\");\n }\n\n const thread = this._threadBinding.getState();\n const branches = thread.getBranches(state.id);\n let targetBranch = branchId;\n if (position === \"previous\") {\n targetBranch = branches[state.branchNumber - 2];\n } else if (position === \"next\") {\n targetBranch = branches[state.branchNumber];\n }\n if (!targetBranch) throw new Error(\"Branch not found\");\n\n this._threadBinding.getState().switchToBranch(targetBranch);\n }\n\n public unstable_getCopyText() {\n return getThreadMessageText(this.getState());\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public getMessagePartByIndex(idx: number) {\n if (idx < 0) throw new Error(\"Message part index must be >= 0\");\n return new MessagePartRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref: `${this.path.ref}${this.path.ref}.content[${idx}]`,\n messagePartSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getMessagePartState(this.getState(), idx);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n this._threadBinding,\n );\n }\n\n public getMessagePartByToolCallId(toolCallId: string) {\n return new MessagePartRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref:\n this.path.ref +\n `${this.path.ref}.content[toolCallId=${JSON.stringify(toolCallId)}]`,\n messagePartSelector: { type: \"toolCallId\", toolCallId },\n },\n getState: () => {\n const state = this._core.getState();\n const idx = state.content.findIndex(\n (part) =>\n part.type === \"tool-call\" && part.toolCallId === toolCallId,\n );\n if (idx === -1) return SKIP_UPDATE;\n return getMessagePartState(state, idx);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n this._threadBinding,\n );\n }\n\n public getAttachmentByIndex(idx: number) {\n return new MessageAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref: `${this.path.ref}${this.path.ref}.attachments[${idx}]`,\n attachmentSource: \"message\",\n attachmentSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments?.[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"message\",\n } satisfies AttachmentState & { source: \"message\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n );\n }\n}\n"],"mappings":";;;;;;;AAkCA,MAAM,kBAAqC,OAAO,OAAO,EACvD,MAAM,WACR,CAAC;AAED,MAAa,uBACX,SACA,WACA,SAC8B;CAC9B,IAAI,QAAQ,SAAS,aAAa,OAAO;CAEzC,IAAI,KAAK,SAAS,aAChB,IAAI,CAAC,KAAK,QACR,OAAO,QAAQ;MAEf,OAAO;CAIX,MAAM,aAAa,cAAc,KAAK,IAAI,GAAG,QAAQ,QAAQ,SAAS,CAAC;CACvE,IAAI,QAAQ,OAAO,SAAS,mBAAmB,OAAO;CACtD,OAAO,aAAc,QAAQ,SAA+B;AAC9D;AAEA,MAAM,uBACJ,S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,IAAI,OAAO;IACvB,OAAO,oBAAoB,OAAO,GAAG;GACvC;GACA,YAAY,aAAa,KAAK,MAAM,UAAU,QAAQ;EACxD,CAAC,GACD,KAAK,OACL,KAAK,cACP;CACF;CAEA,qBAA4B,KAAa;EACvC,OAAO,IAAI,6BACT,IAAI,sBAAsB;GACxB,MAAM;IACJ,GAAG,KAAK;IACR,KAAK,GAAG,KAAK,KAAK,MAAM,KAAK,KAAK,IAAI,eAAe,IAAI;IACzD,kBAAkB;IAClB,oBAAoB;KAAE,MAAM;KAAS,OAAO;IAAI;GAClD;GACA,gBAAgB;IAEd,MAAM,aADc,KAAK,SAAS,CAAC,CAAC,cACH;IACjC,IAAI,CAAC,YAAY,OAAO;IAExB,OAAO;KACL,GAAG;KACH,QAAQ;IACV;GACF;GACA,YAAY,aAAa,KAAK,MAAM,UAAU,QAAQ;EACxD,CAAC,CACH;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-list-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/thread-list-runtime.ts"],"mappings":";;;;;;;KAwBY,eAAA;EAAA,SACD,YAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA;EAAA,SACA,iBAAA;EAAA,SACA,SAAA;EAAA,SACA,aAAA;EAAA,SACA,OAAA;EAAA,SACA,WAAA,EAAa,QAAA,CACpB,MAAA,SAAe,IAAA,CAAK,mBAAA;AAAA;AAAA,KAIZ,iBAAA;EACV,QAAA,IAAY,eAAA;EAEZ,SAAA,CAAU,QAAA,eAAuB,WAAA;EAAA,SAExB,IAAA,EAAM,aAAA;EACf,OAAA,CAAQ,QAAA,WAAmB,aAAA;EAAA,SAElB,QAAA,EAAU,qBAAA;EACnB,WAAA,CAAY,QAAA,WAAmB,qBAAA;EAC/B,cAAA,CAAe,GAAA,WAAc,qBAAA;EAC7B,sBAAA,CAAuB,GAAA,WAAc,qBAAA;EAErC,cAAA,CACE,QAAA,UACA,OAAA;IAAY,SAAA;EAAA,IACX,OAAA;EACH,iBAAA,IAAqB,OAAA;EAErB,qBAAA,IAAyB,OAAA;EACzB,MAAA,IAAU,OAAA;EACV,QAAA,IAAY,OAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"thread-list-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/thread-list-runtime.ts"],"mappings":";;;;;;;KAwBY,eAAA;EAAA,SACD,YAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA;EAAA,SACA,iBAAA;EAAA,SACA,SAAA;EAAA,SACA,aAAA;EAAA,SACA,OAAA;EAAA,SACA,WAAA,EAAa,QAAA,CACpB,MAAA,SAAe,IAAA,CAAK,mBAAA;AAAA;AAAA,KAIZ,iBAAA;EACV,QAAA,IAAY,eAAA;EAEZ,SAAA,CAAU,QAAA,eAAuB,WAAA;EAAA,SAExB,IAAA,EAAM,aAAA;EACf,OAAA,CAAQ,QAAA,WAAmB,aAAA;EAAA,SAElB,QAAA,EAAU,qBAAA;EACnB,WAAA,CAAY,QAAA,WAAmB,qBAAA;EAC/B,cAAA,CAAe,GAAA,WAAc,qBAAA;EAC7B,sBAAA,CAAuB,GAAA,WAAc,qBAAA;EAErC,cAAA,CACE,QAAA,UACA,OAAA;IAAY,SAAA;EAAA,IACX,OAAA;EACH,iBAAA,IAAqB,OAAA;EAErB,qBAAA,IAAyB,OAAA;EACzB,MAAA,IAAU,OAAA;EACV,QAAA,IAAY,OAAA;AAAA;AAAA,KAsCF,4BAAA,GAA+B,qBAAqB;AAAA,cAEnD,qBAAA,YAAiC,iBAAA;EAAA,QAGlC,KAAA;EAAA,QACA,eAAA;EAAA,QAHF,SAAA;cAEE,KAAA,EAAO,4BAAA,EACP,eAAA,QACN,OAAA,EAAS,wBAAA,EACT,qBAAA,EAAuB,4BAAA,KACpB,aAAA;EAAA,UAuCG,sBAAA;EAcH,cAAA,CACL,QAAA,UACA,OAAA;IAAY,SAAA;EAAA,IACX,OAAA;EAII,iBAAA,IAAqB,OAAA;EAIrB,qBAAA,IAAyB,OAAA;EAIzB,MAAA,IAAU,OAAA;EAIV,QAAA,IAAY,OAAA;EAIZ,QAAA,IAAY,eAAA;EAIZ,SAAA,CAAU,QAAA,eAAuB,WAAA;EAAA,QAIhC,0BAAA;EAAA,SAEQ,IAAA,EAAM,aAAA;EAAA,IAEX,QAAA,IAAQ,yBAAA;EAIZ,OAAA,CAAQ,QAAA,WAAgB,aAAA;EAcxB,cAAA,CAAe,GAAA,WAAW,yBAAA;EAgB1B,sBAAA,CAAuB,GAAA,WAAW,yBAAA;EAmBlC,WAAA,CAAY,QAAA,WAAgB,yBAAA;AAAA"}
|
|
@@ -25,6 +25,7 @@ const getThreadListItemState = (threadList, threadId) => {
|
|
|
25
25
|
externalId: threadData.externalId,
|
|
26
26
|
title: threadData.title,
|
|
27
27
|
status: threadData.status,
|
|
28
|
+
lastMessageAt: threadData.lastMessageAt,
|
|
28
29
|
custom: threadData.custom,
|
|
29
30
|
isMain: threadData.id === threadList.mainThreadId
|
|
30
31
|
};
|