@assistant-ui/core 0.2.11 → 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
|
@@ -23,6 +23,7 @@ type RemoteThreadData = {
|
|
|
23
23
|
readonly externalId: string | undefined;
|
|
24
24
|
readonly status: "regular" | "archived";
|
|
25
25
|
readonly title?: string | undefined;
|
|
26
|
+
readonly lastMessageAt?: Date | undefined;
|
|
26
27
|
readonly custom?: Record<string, unknown> | undefined;
|
|
27
28
|
};
|
|
28
29
|
type THREAD_MAPPING_ID = string & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-thread-state.d.ts","names":[],"sources":["../../../src/runtimes/remote-thread-list/remote-thread-state.ts"],"mappings":";;;KAKY,gBAAA;EAAA,SAEG,EAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,EAAA;EAAA,SACA,cAAA,EAAgB,OAAA,CAAQ,8BAAA;EAAA,SACxB,QAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,EAAA;EAAA,SACA,cAAA,EAAgB,OAAA,CAAQ,8BAAA;EAAA,SACxB,QAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA,GAAS,MAAA;AAAA;AAAA,KAGZ,iBAAA;EAA+B,OAAO;AAAA;AAAA,iBAElC,qBAAA,CAAsB,EAAA,WAAa,iBAAiB;AAAA,cAIvD,eAAA,GAAmB,CAAqB;AAAA,KAGhD,mBAAA;EACH,SAAA;EACA,iBAAA;EACA,WAAA,EAAa,MAAA,SAAe,iBAAA;EAC5B,UAAA,EAAY,MAAA,CAAO,iBAAA,EAAmB,gBAAA;AAAA;AAAA,cAG3B,eAAA,GACX,OAAA,WAAkB,oBAAA,IAClB,GAAA,EAAK,mBAAA,KACJ,mBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"remote-thread-state.d.ts","names":[],"sources":["../../../src/runtimes/remote-thread-list/remote-thread-state.ts"],"mappings":";;;KAKY,gBAAA;EAAA,SAEG,EAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,EAAA;EAAA,SACA,cAAA,EAAgB,OAAA,CAAQ,8BAAA;EAAA,SACxB,QAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,EAAA;EAAA,SACA,cAAA,EAAgB,OAAA,CAAQ,8BAAA;EAAA,SACxB,QAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;EAAA,SACA,aAAA,GAAgB,IAAA;EAAA,SAChB,MAAA,GAAS,MAAA;AAAA;AAAA,KAGZ,iBAAA;EAA+B,OAAO;AAAA;AAAA,iBAElC,qBAAA,CAAsB,EAAA,WAAa,iBAAiB;AAAA,cAIvD,eAAA,GAAmB,CAAqB;AAAA,KAGhD,mBAAA;EACH,SAAA;EACA,iBAAA;EACA,WAAA,EAAa,MAAA,SAAe,iBAAA;EAC5B,UAAA,EAAY,MAAA,CAAO,iBAAA,EAAmB,gBAAA;AAAA;AAAA,cAG3B,eAAA,GACX,OAAA,WAAkB,oBAAA,IAClB,GAAA,EAAK,mBAAA,KACJ,mBAAA;AAAA,KAoCS,iBAAA;EAAA,SACD,SAAA;EAAA,SACA,aAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA;EAAA,SACA,iBAAA;EAAA,SACA,WAAA,EAAa,QAAA,CAAS,MAAA,SAAe,iBAAA;EAAA,SACrC,UAAA,EAAY,QAAA,CAAS,MAAA,CAAO,iBAAA,EAAmB,gBAAA;AAAA;AAAA,cAG7C,aAAA,GACX,KAAA,EAAO,iBAAA,EACP,kBAAA,aAA0B,gBAAA;AAAA,cAOf,mBAAA,GACX,KAAA,EAAO,iBAAA,EACP,kBAAA,UACA,SAAA,yCAA6C,iBAoE9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-thread-state.js","names":["_exhaustiveCheck"],"sources":["../../../src/runtimes/remote-thread-list/remote-thread-state.ts"],"sourcesContent":["import type {\n RemoteThreadInitializeResponse,\n RemoteThreadMetadata,\n} from \"./types\";\n\nexport type RemoteThreadData =\n | {\n readonly id: string;\n readonly remoteId: undefined;\n readonly externalId: undefined;\n readonly status: \"new\";\n readonly title: undefined;\n readonly custom: undefined;\n }\n | {\n readonly id: string;\n readonly initializeTask: Promise<RemoteThreadInitializeResponse>;\n readonly remoteId: undefined;\n readonly externalId: undefined;\n readonly status: \"regular\" | \"archived\";\n readonly title?: string | undefined;\n readonly custom: undefined;\n }\n | {\n readonly id: string;\n readonly initializeTask: Promise<RemoteThreadInitializeResponse>;\n readonly remoteId: string;\n readonly externalId: string | undefined;\n readonly status: \"regular\" | \"archived\";\n readonly title?: string | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n };\n\nexport type THREAD_MAPPING_ID = string & { __brand: \"THREAD_MAPPING_ID\" };\n\nexport function createThreadMappingId(id: string): THREAD_MAPPING_ID {\n return id as THREAD_MAPPING_ID;\n}\n\nexport const normalizeCursor = (c: string | undefined): string | undefined =>\n c || undefined;\n\ntype ClassifyAccumulator = {\n threadIds: string[];\n archivedThreadIds: string[];\n threadIdMap: Record<string, THREAD_MAPPING_ID>;\n threadData: Record<THREAD_MAPPING_ID, RemoteThreadData>;\n};\n\nexport const classifyThreads = (\n threads: readonly RemoteThreadMetadata[],\n acc: ClassifyAccumulator,\n): ClassifyAccumulator => {\n for (const thread of threads) {\n if (acc.threadIdMap[thread.remoteId] !== undefined) continue;\n\n switch (thread.status) {\n case \"regular\":\n acc.threadIds.push(thread.remoteId);\n break;\n case \"archived\":\n acc.archivedThreadIds.push(thread.remoteId);\n break;\n default: {\n const _exhaustiveCheck: never = thread.status;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n const mappingId = createThreadMappingId(thread.remoteId);\n acc.threadIdMap[thread.remoteId] = mappingId;\n acc.threadData[mappingId] = {\n id: thread.remoteId,\n remoteId: thread.remoteId,\n externalId: thread.externalId,\n status: thread.status,\n title: thread.title,\n custom: thread.custom,\n initializeTask: Promise.resolve({\n remoteId: thread.remoteId,\n externalId: thread.externalId,\n }),\n };\n }\n return acc;\n};\n\nexport type RemoteThreadState = {\n readonly isLoading: boolean;\n readonly isLoadingMore: boolean;\n readonly cursor: string | undefined;\n readonly newThreadId: string | undefined;\n readonly threadIds: readonly string[];\n readonly archivedThreadIds: readonly string[];\n readonly threadIdMap: Readonly<Record<string, THREAD_MAPPING_ID>>;\n readonly threadData: Readonly<Record<THREAD_MAPPING_ID, RemoteThreadData>>;\n};\n\nexport const getThreadData = (\n state: RemoteThreadState,\n threadIdOrRemoteId: string,\n) => {\n const idx = state.threadIdMap[threadIdOrRemoteId];\n if (idx === undefined) return undefined;\n return state.threadData[idx];\n};\n\nexport const updateStatusReducer = (\n state: RemoteThreadState,\n threadIdOrRemoteId: string,\n newStatus: \"regular\" | \"archived\" | \"deleted\",\n) => {\n const data = getThreadData(state, threadIdOrRemoteId);\n if (!data) return state;\n\n const { id, remoteId, status: lastStatus } = data;\n if (lastStatus === newStatus) return state;\n\n const newState = { ...state };\n\n // lastStatus\n switch (lastStatus) {\n case \"new\":\n newState.newThreadId = undefined;\n break;\n case \"regular\":\n newState.threadIds = newState.threadIds.filter((t) => t !== id);\n break;\n case \"archived\":\n newState.archivedThreadIds = newState.archivedThreadIds.filter(\n (t) => t !== id,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastStatus;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newStatus\n switch (newStatus) {\n case \"regular\":\n newState.threadIds = [id, ...newState.threadIds];\n break;\n\n case \"archived\":\n newState.archivedThreadIds = [id, ...newState.archivedThreadIds];\n break;\n\n case \"deleted\":\n newState.threadData = Object.fromEntries(\n Object.entries(newState.threadData).filter(([key]) => key !== id),\n );\n newState.threadIdMap = Object.fromEntries(\n Object.entries(newState.threadIdMap).filter(\n ([key]) => key !== id && key !== remoteId,\n ),\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = newStatus;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newStatus !== \"deleted\") {\n newState.threadData = {\n ...newState.threadData,\n [id]: {\n ...data,\n status: newStatus,\n },\n };\n }\n\n return newState;\n};\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"remote-thread-state.js","names":["_exhaustiveCheck"],"sources":["../../../src/runtimes/remote-thread-list/remote-thread-state.ts"],"sourcesContent":["import type {\n RemoteThreadInitializeResponse,\n RemoteThreadMetadata,\n} from \"./types\";\n\nexport type RemoteThreadData =\n | {\n readonly id: string;\n readonly remoteId: undefined;\n readonly externalId: undefined;\n readonly status: \"new\";\n readonly title: undefined;\n readonly custom: undefined;\n }\n | {\n readonly id: string;\n readonly initializeTask: Promise<RemoteThreadInitializeResponse>;\n readonly remoteId: undefined;\n readonly externalId: undefined;\n readonly status: \"regular\" | \"archived\";\n readonly title?: string | undefined;\n readonly custom: undefined;\n }\n | {\n readonly id: string;\n readonly initializeTask: Promise<RemoteThreadInitializeResponse>;\n readonly remoteId: string;\n readonly externalId: string | undefined;\n readonly status: \"regular\" | \"archived\";\n readonly title?: string | undefined;\n readonly lastMessageAt?: Date | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n };\n\nexport type THREAD_MAPPING_ID = string & { __brand: \"THREAD_MAPPING_ID\" };\n\nexport function createThreadMappingId(id: string): THREAD_MAPPING_ID {\n return id as THREAD_MAPPING_ID;\n}\n\nexport const normalizeCursor = (c: string | undefined): string | undefined =>\n c || undefined;\n\ntype ClassifyAccumulator = {\n threadIds: string[];\n archivedThreadIds: string[];\n threadIdMap: Record<string, THREAD_MAPPING_ID>;\n threadData: Record<THREAD_MAPPING_ID, RemoteThreadData>;\n};\n\nexport const classifyThreads = (\n threads: readonly RemoteThreadMetadata[],\n acc: ClassifyAccumulator,\n): ClassifyAccumulator => {\n for (const thread of threads) {\n if (acc.threadIdMap[thread.remoteId] !== undefined) continue;\n\n switch (thread.status) {\n case \"regular\":\n acc.threadIds.push(thread.remoteId);\n break;\n case \"archived\":\n acc.archivedThreadIds.push(thread.remoteId);\n break;\n default: {\n const _exhaustiveCheck: never = thread.status;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n const mappingId = createThreadMappingId(thread.remoteId);\n acc.threadIdMap[thread.remoteId] = mappingId;\n acc.threadData[mappingId] = {\n id: thread.remoteId,\n remoteId: thread.remoteId,\n externalId: thread.externalId,\n status: thread.status,\n title: thread.title,\n lastMessageAt: thread.lastMessageAt,\n custom: thread.custom,\n initializeTask: Promise.resolve({\n remoteId: thread.remoteId,\n externalId: thread.externalId,\n }),\n };\n }\n return acc;\n};\n\nexport type RemoteThreadState = {\n readonly isLoading: boolean;\n readonly isLoadingMore: boolean;\n readonly cursor: string | undefined;\n readonly newThreadId: string | undefined;\n readonly threadIds: readonly string[];\n readonly archivedThreadIds: readonly string[];\n readonly threadIdMap: Readonly<Record<string, THREAD_MAPPING_ID>>;\n readonly threadData: Readonly<Record<THREAD_MAPPING_ID, RemoteThreadData>>;\n};\n\nexport const getThreadData = (\n state: RemoteThreadState,\n threadIdOrRemoteId: string,\n) => {\n const idx = state.threadIdMap[threadIdOrRemoteId];\n if (idx === undefined) return undefined;\n return state.threadData[idx];\n};\n\nexport const updateStatusReducer = (\n state: RemoteThreadState,\n threadIdOrRemoteId: string,\n newStatus: \"regular\" | \"archived\" | \"deleted\",\n) => {\n const data = getThreadData(state, threadIdOrRemoteId);\n if (!data) return state;\n\n const { id, remoteId, status: lastStatus } = data;\n if (lastStatus === newStatus) return state;\n\n const newState = { ...state };\n\n // lastStatus\n switch (lastStatus) {\n case \"new\":\n newState.newThreadId = undefined;\n break;\n case \"regular\":\n newState.threadIds = newState.threadIds.filter((t) => t !== id);\n break;\n case \"archived\":\n newState.archivedThreadIds = newState.archivedThreadIds.filter(\n (t) => t !== id,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastStatus;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newStatus\n switch (newStatus) {\n case \"regular\":\n newState.threadIds = [id, ...newState.threadIds];\n break;\n\n case \"archived\":\n newState.archivedThreadIds = [id, ...newState.archivedThreadIds];\n break;\n\n case \"deleted\":\n newState.threadData = Object.fromEntries(\n Object.entries(newState.threadData).filter(([key]) => key !== id),\n );\n newState.threadIdMap = Object.fromEntries(\n Object.entries(newState.threadIdMap).filter(\n ([key]) => key !== id && key !== remoteId,\n ),\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = newStatus;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newStatus !== \"deleted\") {\n newState.threadData = {\n ...newState.threadData,\n [id]: {\n ...data,\n status: newStatus,\n },\n };\n }\n\n return newState;\n};\n"],"mappings":";AAoCA,SAAgB,sBAAsB,IAA+B;CACnE,OAAO;AACT;AAEA,MAAa,mBAAmB,MAC9B,KAAK,KAAA;AASP,MAAa,mBACX,SACA,QACwB;CACxB,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,IAAI,YAAY,OAAO,cAAc,KAAA,GAAW;EAEpD,QAAQ,OAAO,QAAf;GACE,KAAK;IACH,IAAI,UAAU,KAAK,OAAO,QAAQ;IAClC;GACF,KAAK;IACH,IAAI,kBAAkB,KAAK,OAAO,QAAQ;IAC1C;GACF,SAAS;IACP,MAAM,mBAA0B,OAAO;IACvC,MAAM,IAAI,MAAM,sBAAsB,kBAAkB;GAC1D;EACF;EAEA,MAAM,YAAY,sBAAsB,OAAO,QAAQ;EACvD,IAAI,YAAY,OAAO,YAAY;EACnC,IAAI,WAAW,aAAa;GAC1B,IAAI,OAAO;GACX,UAAU,OAAO;GACjB,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,OAAO,OAAO;GACd,eAAe,OAAO;GACtB,QAAQ,OAAO;GACf,gBAAgB,QAAQ,QAAQ;IAC9B,UAAU,OAAO;IACjB,YAAY,OAAO;GACrB,CAAC;EACH;CACF;CACA,OAAO;AACT;AAaA,MAAa,iBACX,OACA,uBACG;CACH,MAAM,MAAM,MAAM,YAAY;CAC9B,IAAI,QAAQ,KAAA,GAAW,OAAO,KAAA;CAC9B,OAAO,MAAM,WAAW;AAC1B;AAEA,MAAa,uBACX,OACA,oBACA,cACG;CACH,MAAM,OAAO,cAAc,OAAO,kBAAkB;CACpD,IAAI,CAAC,MAAM,OAAO;CAElB,MAAM,EAAE,IAAI,UAAU,QAAQ,eAAe;CAC7C,IAAI,eAAe,WAAW,OAAO;CAErC,MAAM,WAAW,EAAE,GAAG,MAAM;CAG5B,QAAQ,YAAR;EACE,KAAK;GACH,SAAS,cAAc,KAAA;GACvB;EACF,KAAK;GACH,SAAS,YAAY,SAAS,UAAU,QAAQ,MAAM,MAAM,EAAE;GAC9D;EACF,KAAK;GACH,SAAS,oBAAoB,SAAS,kBAAkB,QACrD,MAAM,MAAM,EACf;GACA;EAEF,SAEE,MAAM,IAAI,MAAM,sBAAsBA,YAAkB;CAE5D;CAGA,QAAQ,WAAR;EACE,KAAK;GACH,SAAS,YAAY,CAAC,IAAI,GAAG,SAAS,SAAS;GAC/C;EAEF,KAAK;GACH,SAAS,oBAAoB,CAAC,IAAI,GAAG,SAAS,iBAAiB;GAC/D;EAEF,KAAK;GACH,SAAS,aAAa,OAAO,YAC3B,OAAO,QAAQ,SAAS,UAAU,CAAC,CAAC,QAAQ,CAAC,SAAS,QAAQ,EAAE,CAClE;GACA,SAAS,cAAc,OAAO,YAC5B,OAAO,QAAQ,SAAS,WAAW,CAAC,CAAC,QAClC,CAAC,SAAS,QAAQ,MAAM,QAAQ,QACnC,CACF;GACA;EAEF,SAEE,MAAM,IAAI,MAAM,sBAAsBA,WAAkB;CAE5D;CAEA,IAAI,cAAc,WAChB,SAAS,aAAa;EACpB,GAAG,SAAS;GACX,KAAK;GACJ,GAAG;GACH,QAAQ;EACV;CACF;CAGF,OAAO;AACT"}
|
|
@@ -13,6 +13,7 @@ type RemoteThreadMetadata = {
|
|
|
13
13
|
readonly remoteId: string;
|
|
14
14
|
readonly externalId?: string | undefined;
|
|
15
15
|
readonly title?: string | undefined;
|
|
16
|
+
readonly lastMessageAt?: Date | undefined;
|
|
16
17
|
readonly custom?: Record<string, unknown> | undefined;
|
|
17
18
|
};
|
|
18
19
|
type RemoteThreadListResponse = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/runtimes/remote-thread-list/types.ts"],"mappings":";;;;;;KAKY,8BAAA;EACV,QAAA;EACA,UAAU;AAAA;AAAA,KAGA,oBAAA;EAAA,SACD,MAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA,GAAS,MAAM;AAAA;AAAA,KAGd,wBAAA;EACV,OAAA,EAAS,oBAAoB;EAC7B,UAAA;AAAA;AAAA,KAGU,2BAAA;EACV,KAAK;AAAA;AAAA,KAGK,uBAAA;EACV,IAAA,CAAK,MAAA,GAAS,2BAAA,GAA8B,OAAA,CAAQ,wBAAA;EAEpD,MAAA,CAAO,QAAA,UAAkB,QAAA,WAAmB,OAAA;EAC5C,YAAA,EACE,QAAA,UACA,MAAA,EAAQ,MAAA,gCACP,OAAA;EACH,OAAA,CAAQ,QAAA,WAAmB,OAAA;EAC3B,SAAA,CAAU,QAAA,WAAmB,OAAA;EAC7B,MAAA,CAAO,QAAA,WAAmB,OAAA;EAC1B,UAAA,CAAW,QAAA,WAAmB,OAAA,CAAQ,8BAAA;EACtC,aAAA,CACE,QAAA,UACA,iBAAA,WAA4B,aAAA,KAC3B,OAAA,CAAQ,eAAA;EACX,KAAA,CAAM,QAAA,WAAmB,OAAA,CAAQ,oBAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/runtimes/remote-thread-list/types.ts"],"mappings":";;;;;;KAKY,8BAAA;EACV,QAAA;EACA,UAAU;AAAA;AAAA,KAGA,oBAAA;EAAA,SACD,MAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SACA,KAAA;EAAA,SACA,aAAA,GAAgB,IAAA;EAAA,SAChB,MAAA,GAAS,MAAM;AAAA;AAAA,KAGd,wBAAA;EACV,OAAA,EAAS,oBAAoB;EAC7B,UAAA;AAAA;AAAA,KAGU,2BAAA;EACV,KAAK;AAAA;AAAA,KAGK,uBAAA;EACV,IAAA,CAAK,MAAA,GAAS,2BAAA,GAA8B,OAAA,CAAQ,wBAAA;EAEpD,MAAA,CAAO,QAAA,UAAkB,QAAA,WAAmB,OAAA;EAC5C,YAAA,EACE,QAAA,UACA,MAAA,EAAQ,MAAA,gCACP,OAAA;EACH,OAAA,CAAQ,QAAA,WAAmB,OAAA;EAC3B,SAAA,CAAU,QAAA,WAAmB,OAAA;EAC7B,MAAA,CAAO,QAAA,WAAmB,OAAA;EAC1B,UAAA,CAAW,QAAA,WAAmB,OAAA,CAAQ,8BAAA;EACtC,aAAA,CACE,QAAA,UACA,iBAAA,WAA4B,aAAA,KAC3B,OAAA,CAAQ,eAAA;EACX,KAAA,CAAM,QAAA,WAAmB,OAAA,CAAQ,oBAAA;EAvBvB;AAGZ;;;;AACO;AAGP;;;;EA4BE,iBAAA,GAAoB,aAAA,CAAc,iBAAA;AAAA;AAAA,KAGxB,uBAAA;EACV,WAAA,QAAmB,gBAAA;EACnB,OAAA,EAAS,uBAAuB;EAzBL;;;;;;;EAkC3B,eAAA;EA1BiC;;;;;EAiCjC,QAAA;EAhDA;;;;;EAuDA,YAAA;AAAA"}
|
|
@@ -3,17 +3,12 @@ import { ChainOfThoughtPart } from "../scopes/chain-of-thought.js";
|
|
|
3
3
|
import { ClientOutput } from "@assistant-ui/store";
|
|
4
4
|
|
|
5
5
|
//#region src/store/clients/chain-of-thought-client.d.ts
|
|
6
|
-
declare const ChainOfThoughtClient: (
|
|
6
|
+
declare const ChainOfThoughtClient: import("@assistant-ui/tap").Resource<ClientOutput<"chainOfThought">, [{
|
|
7
7
|
parts: readonly ChainOfThoughtPart[];
|
|
8
8
|
getMessagePart: (selector: {
|
|
9
9
|
index: number;
|
|
10
10
|
}) => PartMethods;
|
|
11
|
-
}
|
|
12
|
-
parts: readonly ChainOfThoughtPart[];
|
|
13
|
-
getMessagePart: (selector: {
|
|
14
|
-
index: number;
|
|
15
|
-
}) => PartMethods;
|
|
16
|
-
}>;
|
|
11
|
+
}]>;
|
|
17
12
|
//#endregion
|
|
18
13
|
export { ChainOfThoughtClient };
|
|
19
14
|
//# sourceMappingURL=chain-of-thought-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-of-thought-client.d.ts","names":[],"sources":["../../../src/store/clients/chain-of-thought-client.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"chain-of-thought-client.d.ts","names":[],"sources":["../../../src/store/clients/chain-of-thought-client.ts"],"mappings":";;;;;cAwCa,oBAAA,8BAAoB,QAAA,CAAA,YAAA;kBAtBf,kBAAA;mBACC,QAAA;IAAY,KAAA;EAAA,MAAoB,WAAA;AAAA"}
|
|
@@ -2,7 +2,7 @@ import { useMemo, useState } from "@assistant-ui/tap/react-shim";
|
|
|
2
2
|
import { resource } from "@assistant-ui/tap";
|
|
3
3
|
//#region src/store/clients/chain-of-thought-client.ts
|
|
4
4
|
const COMPLETE_STATUS = Object.freeze({ type: "complete" });
|
|
5
|
-
const
|
|
5
|
+
const useChainOfThoughtClient = ({ parts, getMessagePart }) => {
|
|
6
6
|
const [collapsed, setCollapsed] = useState(true);
|
|
7
7
|
const status = useMemo(() => {
|
|
8
8
|
return parts[parts.length - 1]?.status ?? COMPLETE_STATUS;
|
|
@@ -21,7 +21,8 @@ const ChainOfThoughtClient = resource(function ChainOfThoughtClient({ parts, get
|
|
|
21
21
|
setCollapsed,
|
|
22
22
|
part: getMessagePart
|
|
23
23
|
};
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
|
+
const ChainOfThoughtClient = resource(useChainOfThoughtClient);
|
|
25
26
|
//#endregion
|
|
26
27
|
export { ChainOfThoughtClient };
|
|
27
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-of-thought-client.js","names":[],"sources":["../../../src/store/clients/chain-of-thought-client.ts"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport type {\n ChainOfThoughtState,\n ChainOfThoughtPart,\n} from \"../scopes/chain-of-thought\";\nimport type { MessagePartStatus } from \"../../types/message\";\nimport type { PartMethods } from \"../scopes/part\";\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\
|
|
1
|
+
{"version":3,"file":"chain-of-thought-client.js","names":[],"sources":["../../../src/store/clients/chain-of-thought-client.ts"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport type {\n ChainOfThoughtState,\n ChainOfThoughtPart,\n} from \"../scopes/chain-of-thought\";\nimport type { MessagePartStatus } from \"../../types/message\";\nimport type { PartMethods } from \"../scopes/part\";\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst useChainOfThoughtClient = ({\n parts,\n getMessagePart,\n}: {\n parts: readonly ChainOfThoughtPart[];\n getMessagePart: (selector: { index: number }) => PartMethods;\n}): ClientOutput<\"chainOfThought\"> => {\n const [collapsed, setCollapsed] = useState(true);\n\n const status = useMemo(() => {\n const lastPart = parts[parts.length - 1];\n return lastPart?.status ?? COMPLETE_STATUS;\n }, [parts]);\n\n const state = useMemo<ChainOfThoughtState>(\n () => ({ parts, collapsed, status }),\n [parts, collapsed, status],\n );\n\n return {\n getState: () => state,\n setCollapsed,\n part: getMessagePart,\n };\n};\n\nexport const ChainOfThoughtClient = resource(useChainOfThoughtClient);\n"],"mappings":";;;AAUA,MAAM,kBAAqC,OAAO,OAAO,EACvD,MAAM,WACR,CAAC;AAED,MAAM,2BAA2B,EAC/B,OACA,qBAIoC;CACpC,MAAM,CAAC,WAAW,gBAAgB,SAAS,IAAI;CAE/C,MAAM,SAAS,cAAc;EAE3B,OADiB,MAAM,MAAM,SAAS,EACvB,EAAE,UAAU;CAC7B,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,QAAQ,eACL;EAAE;EAAO;EAAW;CAAO,IAClC;EAAC;EAAO;EAAW;CAAM,CAC3B;CAEA,OAAO;EACL,gBAAgB;EAChB;EACA,MAAM;CACR;AACF;AAEA,MAAa,uBAAuB,SAAS,uBAAuB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientOutput } from "@assistant-ui/store";
|
|
2
2
|
|
|
3
3
|
//#region src/store/clients/model-context-client.d.ts
|
|
4
|
-
declare const ModelContext:
|
|
4
|
+
declare const ModelContext: import("@assistant-ui/tap").Resource<ClientOutput<"modelContext">, []>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { ModelContext };
|
|
7
7
|
//# sourceMappingURL=model-context-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-context-client.d.ts","names":[],"sources":["../../../src/store/clients/model-context-client.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"model-context-client.d.ts","names":[],"sources":["../../../src/store/clients/model-context-client.ts"],"mappings":";;;cAoDa,YAAA,8BAAY,QAAA,CAAA,YAAA"}
|
|
@@ -19,7 +19,7 @@ const deriveState = (composite, prev) => {
|
|
|
19
19
|
toolNames
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
const
|
|
22
|
+
const useModelContext = () => {
|
|
23
23
|
const composite = useMemo(() => new CompositeContextProvider(), []);
|
|
24
24
|
const [state, setState] = useState(() => deriveState(composite, INITIAL_STATE));
|
|
25
25
|
useEffect(() => {
|
|
@@ -34,7 +34,8 @@ const ModelContext = resource(function ModelContext() {
|
|
|
34
34
|
subscribe: (callback) => composite.subscribe(callback),
|
|
35
35
|
register: (provider) => composite.registerModelContextProvider(provider)
|
|
36
36
|
};
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
|
+
const ModelContext = resource(useModelContext);
|
|
38
39
|
//#endregion
|
|
39
40
|
export { ModelContext };
|
|
40
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-context-client.js","names":[],"sources":["../../../src/store/clients/model-context-client.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { CompositeContextProvider } from \"../../utils/composite-context-provider\";\nimport type { ModelContextState } from \"../scopes/model-context\";\n\nconst EMPTY_TOOL_NAMES: readonly string[] = [];\n\nconst INITIAL_STATE: ModelContextState = {\n modelName: undefined,\n toolNames: EMPTY_TOOL_NAMES,\n};\n\nconst toolNamesEqual = (a: readonly string[], b: readonly string[]): boolean =>\n a === b || (a.length === b.length && a.every((v, i) => v === b[i]));\n\nconst deriveState = (\n composite: CompositeContextProvider,\n prev: ModelContextState,\n): ModelContextState => {\n const ctx = composite.getModelContext();\n const modelName = ctx.config?.modelName;\n const keys = ctx.tools ? Object.keys(ctx.tools).sort() : EMPTY_TOOL_NAMES;\n const toolNames = keys.length ? keys : EMPTY_TOOL_NAMES;\n\n if (modelName === prev.modelName && toolNamesEqual(toolNames, prev.toolNames))\n return prev;\n\n return { modelName, toolNames };\n};\n\
|
|
1
|
+
{"version":3,"file":"model-context-client.js","names":[],"sources":["../../../src/store/clients/model-context-client.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { CompositeContextProvider } from \"../../utils/composite-context-provider\";\nimport type { ModelContextState } from \"../scopes/model-context\";\n\nconst EMPTY_TOOL_NAMES: readonly string[] = [];\n\nconst INITIAL_STATE: ModelContextState = {\n modelName: undefined,\n toolNames: EMPTY_TOOL_NAMES,\n};\n\nconst toolNamesEqual = (a: readonly string[], b: readonly string[]): boolean =>\n a === b || (a.length === b.length && a.every((v, i) => v === b[i]));\n\nconst deriveState = (\n composite: CompositeContextProvider,\n prev: ModelContextState,\n): ModelContextState => {\n const ctx = composite.getModelContext();\n const modelName = ctx.config?.modelName;\n const keys = ctx.tools ? Object.keys(ctx.tools).sort() : EMPTY_TOOL_NAMES;\n const toolNames = keys.length ? keys : EMPTY_TOOL_NAMES;\n\n if (modelName === prev.modelName && toolNamesEqual(toolNames, prev.toolNames))\n return prev;\n\n return { modelName, toolNames };\n};\n\nconst useModelContext = (): ClientOutput<\"modelContext\"> => {\n const composite = useMemo(() => new CompositeContextProvider(), []);\n const [state, setState] = useState<ModelContextState>(() =>\n deriveState(composite, INITIAL_STATE),\n );\n\n useEffect(() => {\n setState((prev) => deriveState(composite, prev));\n return composite.subscribe(() => {\n setState((prev) => deriveState(composite, prev));\n });\n }, [composite]);\n\n return {\n getState: () => deriveState(composite, state),\n getModelContext: () => composite.getModelContext(),\n subscribe: (callback) => composite.subscribe(callback),\n register: (provider) => composite.registerModelContextProvider(provider),\n };\n};\n\nexport const ModelContext = resource(useModelContext);\n"],"mappings":";;;;AAMA,MAAM,mBAAsC,CAAC;AAE7C,MAAM,gBAAmC;CACvC,WAAW,KAAA;CACX,WAAW;AACb;AAEA,MAAM,kBAAkB,GAAsB,MAC5C,MAAM,KAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,MAAM,EAAE,EAAE;AAEnE,MAAM,eACJ,WACA,SACsB;CACtB,MAAM,MAAM,UAAU,gBAAgB;CACtC,MAAM,YAAY,IAAI,QAAQ;CAC9B,MAAM,OAAO,IAAI,QAAQ,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,KAAK,IAAI;CACzD,MAAM,YAAY,KAAK,SAAS,OAAO;CAEvC,IAAI,cAAc,KAAK,aAAa,eAAe,WAAW,KAAK,SAAS,GAC1E,OAAO;CAET,OAAO;EAAE;EAAW;CAAU;AAChC;AAEA,MAAM,wBAAsD;CAC1D,MAAM,YAAY,cAAc,IAAI,yBAAyB,GAAG,CAAC,CAAC;CAClE,MAAM,CAAC,OAAO,YAAY,eACxB,YAAY,WAAW,aAAa,CACtC;CAEA,gBAAgB;EACd,UAAU,SAAS,YAAY,WAAW,IAAI,CAAC;EAC/C,OAAO,UAAU,gBAAgB;GAC/B,UAAU,SAAS,YAAY,WAAW,IAAI,CAAC;EACjD,CAAC;CACH,GAAG,CAAC,SAAS,CAAC;CAEd,OAAO;EACL,gBAAgB,YAAY,WAAW,KAAK;EAC5C,uBAAuB,UAAU,gBAAgB;EACjD,YAAY,aAAa,UAAU,UAAU,QAAQ;EACrD,WAAW,aAAa,UAAU,6BAA6B,QAAQ;CACzE;AACF;AAEA,MAAa,eAAe,SAAS,eAAe"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ClientOutput } from "@assistant-ui/store";
|
|
2
2
|
|
|
3
3
|
//#region src/store/clients/no-op-composer-client.d.ts
|
|
4
|
-
declare const NoOpComposerClient: (
|
|
4
|
+
declare const NoOpComposerClient: import("@assistant-ui/tap").Resource<ClientOutput<"composer">, [{
|
|
5
5
|
type: "edit" | "thread";
|
|
6
|
-
}
|
|
7
|
-
type: "edit" | "thread";
|
|
8
|
-
}>;
|
|
6
|
+
}]>;
|
|
9
7
|
//#endregion
|
|
10
8
|
export { NoOpComposerClient };
|
|
11
9
|
//# sourceMappingURL=no-op-composer-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-op-composer-client.d.ts","names":[],"sources":["../../../src/store/clients/no-op-composer-client.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"no-op-composer-client.d.ts","names":[],"sources":["../../../src/store/clients/no-op-composer-client.ts"],"mappings":";;;cA2Ea,kBAAA,8BAAkB,QAAA,CAAA,YAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from "@assistant-ui/tap/react-shim";
|
|
2
2
|
import { resource } from "@assistant-ui/tap";
|
|
3
3
|
//#region src/store/clients/no-op-composer-client.ts
|
|
4
|
-
const
|
|
4
|
+
const useNoOpComposerClient = ({ type }) => {
|
|
5
5
|
const state = useMemo(() => {
|
|
6
6
|
return {
|
|
7
7
|
isEditing: false,
|
|
@@ -64,7 +64,8 @@ const NoOpComposerClient = resource(function NoOpComposerClient({ type }) {
|
|
|
64
64
|
throw new Error("Not supported");
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
|
+
const NoOpComposerClient = resource(useNoOpComposerClient);
|
|
68
69
|
//#endregion
|
|
69
70
|
export { NoOpComposerClient };
|
|
70
71
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-op-composer-client.js","names":[],"sources":["../../../src/store/clients/no-op-composer-client.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport type { ComposerState } from \"../scopes/composer\";\n\
|
|
1
|
+
{"version":3,"file":"no-op-composer-client.js","names":[],"sources":["../../../src/store/clients/no-op-composer-client.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport type { ComposerState } from \"../scopes/composer\";\n\nconst useNoOpComposerClient = ({\n type,\n}: {\n type: \"edit\" | \"thread\";\n}): ClientOutput<\"composer\"> => {\n const state = useMemo<ComposerState>(() => {\n return {\n isEditing: false,\n isEmpty: true,\n text: \"\",\n attachmentAccept: \"*\",\n attachments: [],\n role: \"user\",\n runConfig: {},\n canCancel: false,\n canSend: false,\n type: type,\n dictation: undefined,\n quote: undefined,\n queue: [],\n };\n }, [type]);\n\n return {\n getState: () => state,\n setText: () => {\n throw new Error(\"Not supported\");\n },\n setRole: () => {\n throw new Error(\"Not supported\");\n },\n setRunConfig: () => {\n throw new Error(\"Not supported\");\n },\n addAttachment: () => {\n throw new Error(\"Not supported\");\n },\n clearAttachments: () => {\n throw new Error(\"Not supported\");\n },\n attachment: () => {\n throw new Error(\"Not supported\");\n },\n reset: () => {\n throw new Error(\"Not supported\");\n },\n send: () => {\n throw new Error(\"Not supported\");\n },\n cancel: () => {\n throw new Error(\"Not supported\");\n },\n startDictation: () => {\n throw new Error(\"Not supported\");\n },\n stopDictation: () => {\n throw new Error(\"Not supported\");\n },\n beginEdit: () => {\n throw new Error(\"Not supported\");\n },\n setQuote: () => {\n throw new Error(\"Not supported\");\n },\n queueItem: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nexport const NoOpComposerClient = resource(useNoOpComposerClient);\n"],"mappings":";;;AAKA,MAAM,yBAAyB,EAC7B,WAG8B;CAC9B,MAAM,QAAQ,cAA6B;EACzC,OAAO;GACL,WAAW;GACX,SAAS;GACT,MAAM;GACN,kBAAkB;GAClB,aAAa,CAAC;GACd,MAAM;GACN,WAAW,CAAC;GACZ,WAAW;GACX,SAAS;GACH;GACN,WAAW,KAAA;GACX,OAAO,KAAA;GACP,OAAO,CAAC;EACV;CACF,GAAG,CAAC,IAAI,CAAC;CAET,OAAO;EACL,gBAAgB;EAChB,eAAe;GACb,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,eAAe;GACb,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,oBAAoB;GAClB,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,qBAAqB;GACnB,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,wBAAwB;GACtB,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,kBAAkB;GAChB,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,aAAa;GACX,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,YAAY;GACV,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,cAAc;GACZ,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,sBAAsB;GACpB,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,qBAAqB;GACnB,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,iBAAiB;GACf,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,gBAAgB;GACd,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,iBAAiB;GACf,MAAM,IAAI,MAAM,eAAe;EACjC;CACF;AACF;AAEA,MAAa,qBAAqB,SAAS,qBAAqB"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { AssistantRuntime } from "../../runtime/api/assistant-runtime.js";
|
|
2
1
|
import { AssistantClient, ScopesConfig } from "@assistant-ui/store";
|
|
3
2
|
|
|
4
3
|
//#region src/store/clients/runtime-adapter.d.ts
|
|
5
|
-
declare const RuntimeAdapterResource: (props: AssistantRuntime) => import("@assistant-ui/tap").ResourceElement<import("@assistant-ui/store").ClientOutput<"threads">, AssistantRuntime>;
|
|
6
4
|
declare const baseRuntimeAdapterTransformScopes: (scopes: ScopesConfig, parent: AssistantClient) => void;
|
|
7
5
|
//#endregion
|
|
8
|
-
export {
|
|
6
|
+
export { baseRuntimeAdapterTransformScopes };
|
|
9
7
|
//# sourceMappingURL=runtime-adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-adapter.d.ts","names":[],"sources":["../../../src/store/clients/runtime-adapter.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-adapter.d.ts","names":[],"sources":["../../../src/store/clients/runtime-adapter.ts"],"mappings":";;;cAQa,iCAAA,GACX,MAAA,EAAQ,YAAA,EACR,MAAA,EAAQ,eAAe"}
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import { ThreadListClient } from "../runtime-clients/thread-list-runtime-client.js";
|
|
2
1
|
import { ModelContext } from "./model-context-client.js";
|
|
3
2
|
import { Suggestions } from "./suggestions.js";
|
|
4
|
-
import {
|
|
5
|
-
import { Derived, useAssistantClientRef } from "@assistant-ui/store";
|
|
6
|
-
import { resource, useResource } from "@assistant-ui/tap";
|
|
3
|
+
import { Derived } from "@assistant-ui/store";
|
|
7
4
|
//#region src/store/clients/runtime-adapter.ts
|
|
8
|
-
const RuntimeAdapterResource = resource(function RuntimeAdapterResource(runtime) {
|
|
9
|
-
const clientRef = useAssistantClientRef();
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
return runtime.registerModelContextProvider(clientRef.current.modelContext());
|
|
12
|
-
}, [runtime, clientRef]);
|
|
13
|
-
return useResource(ThreadListClient({
|
|
14
|
-
runtime: runtime.threads,
|
|
15
|
-
__internal_assistantRuntime: runtime
|
|
16
|
-
}));
|
|
17
|
-
});
|
|
18
5
|
const baseRuntimeAdapterTransformScopes = (scopes, parent) => {
|
|
19
6
|
scopes.thread ??= Derived({
|
|
20
7
|
source: "threads",
|
|
@@ -35,6 +22,6 @@ const baseRuntimeAdapterTransformScopes = (scopes, parent) => {
|
|
|
35
22
|
if (!scopes.suggestions && parent.suggestions.source === null) scopes.suggestions = Suggestions();
|
|
36
23
|
};
|
|
37
24
|
//#endregion
|
|
38
|
-
export {
|
|
25
|
+
export { baseRuntimeAdapterTransformScopes };
|
|
39
26
|
|
|
40
27
|
//# sourceMappingURL=runtime-adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-adapter.js","names":[],"sources":["../../../src/store/clients/runtime-adapter.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"runtime-adapter.js","names":[],"sources":["../../../src/store/clients/runtime-adapter.ts"],"sourcesContent":["import {\n Derived,\n type ScopesConfig,\n type AssistantClient,\n} from \"@assistant-ui/store\";\nimport { ModelContext } from \"./model-context-client\";\nimport { Suggestions } from \"./suggestions\";\n\nexport const baseRuntimeAdapterTransformScopes = (\n scopes: ScopesConfig,\n parent: AssistantClient,\n): void => {\n scopes.thread ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().thread(\"main\"),\n });\n scopes.threadListItem ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().item(\"main\"),\n });\n scopes.composer ??= Derived({\n source: \"thread\",\n query: {},\n get: (aui) => aui.threads().thread(\"main\").composer(),\n });\n\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n if (!scopes.suggestions && parent.suggestions.source === null) {\n scopes.suggestions = Suggestions();\n }\n};\n"],"mappings":";;;;AAQA,MAAa,qCACX,QACA,WACS;CACT,OAAO,WAAW,QAAQ;EACxB,QAAQ;EACR,OAAO,EAAE,MAAM,OAAO;EACtB,MAAM,QAAQ,IAAI,QAAQ,CAAC,CAAC,OAAO,MAAM;CAC3C,CAAC;CACD,OAAO,mBAAmB,QAAQ;EAChC,QAAQ;EACR,OAAO,EAAE,MAAM,OAAO;EACtB,MAAM,QAAQ,IAAI,QAAQ,CAAC,CAAC,KAAK,MAAM;CACzC,CAAC;CACD,OAAO,aAAa,QAAQ;EAC1B,QAAQ;EACR,OAAO,CAAC;EACR,MAAM,QAAQ,IAAI,QAAQ,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS;CACtD,CAAC;CAED,IAAI,CAAC,OAAO,gBAAgB,OAAO,aAAa,WAAW,MACzD,OAAO,eAAe,aAAa;CAErC,IAAI,CAAC,OAAO,eAAe,OAAO,YAAY,WAAW,MACvD,OAAO,cAAc,YAAY;AAErC"}
|
|
@@ -6,10 +6,7 @@ type SuggestionConfig = string | {
|
|
|
6
6
|
label: string;
|
|
7
7
|
prompt: string;
|
|
8
8
|
};
|
|
9
|
-
declare const Suggestions:
|
|
10
|
-
(): import("@assistant-ui/tap").ResourceElement<ClientOutput<"suggestions">, undefined>;
|
|
11
|
-
(suggestions: SuggestionConfig[]): import("@assistant-ui/tap").ResourceElement<ClientOutput<"suggestions">, SuggestionConfig[]>;
|
|
12
|
-
};
|
|
9
|
+
declare const Suggestions: import("@assistant-ui/tap").Resource<ClientOutput<"suggestions">, [suggestions?: SuggestionConfig[] | undefined]>;
|
|
13
10
|
//#endregion
|
|
14
11
|
export { SuggestionConfig, Suggestions };
|
|
15
12
|
//# sourceMappingURL=suggestions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestions.d.ts","names":[],"sources":["../../../src/store/clients/suggestions.ts"],"mappings":";;;KAOY,gBAAA;EAEN,KAAA;EAAe,KAAA;EAAe,MAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"suggestions.d.ts","names":[],"sources":["../../../src/store/clients/suggestions.ts"],"mappings":";;;KAOY,gBAAA;EAEN,KAAA;EAAe,KAAA;EAAe,MAAA;AAAA;AAAA,cAoDvB,WAAA,8BAAW,QAAA,CAAA,YAAA,kBAAA,WAAA,GAAA,gBAAA"}
|
|
@@ -2,10 +2,11 @@ import { useState } from "@assistant-ui/tap/react-shim";
|
|
|
2
2
|
import { useClientLookup } from "@assistant-ui/store";
|
|
3
3
|
import { resource, withKey } from "@assistant-ui/tap";
|
|
4
4
|
//#region src/store/clients/suggestions.ts
|
|
5
|
-
const
|
|
5
|
+
const useSuggestionClient = (state) => {
|
|
6
6
|
return { getState: () => state };
|
|
7
|
-
}
|
|
8
|
-
const
|
|
7
|
+
};
|
|
8
|
+
const SuggestionClient = resource(useSuggestionClient);
|
|
9
|
+
const useSuggestionsResource = (suggestions) => {
|
|
9
10
|
const [state] = useState(() => {
|
|
10
11
|
return { suggestions: (suggestions ?? []).map((s) => {
|
|
11
12
|
if (typeof s === "string") return {
|
|
@@ -27,7 +28,8 @@ const Suggestions = resource(function SuggestionsResource(suggestions) {
|
|
|
27
28
|
return suggestionClients.get({ index });
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
|
-
}
|
|
31
|
+
};
|
|
32
|
+
const Suggestions = resource(useSuggestionsResource);
|
|
31
33
|
//#endregion
|
|
32
34
|
export { Suggestions };
|
|
33
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestions.js","names":[],"sources":["../../../src/store/clients/suggestions.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store\";\nimport type { SuggestionsState } from \"../scopes/suggestions\";\nimport type { SuggestionState } from \"../scopes/suggestion\";\n\nexport type SuggestionConfig =\n | string\n | { title: string; label: string; prompt: string };\n\nconst
|
|
1
|
+
{"version":3,"file":"suggestions.js","names":[],"sources":["../../../src/store/clients/suggestions.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store\";\nimport type { SuggestionsState } from \"../scopes/suggestions\";\nimport type { SuggestionState } from \"../scopes/suggestion\";\n\nexport type SuggestionConfig =\n | string\n | { title: string; label: string; prompt: string };\n\nconst useSuggestionClient = (\n state: SuggestionState,\n): ClientOutput<\"suggestion\"> => {\n return {\n getState: () => state,\n };\n};\n\nconst SuggestionClient = resource(useSuggestionClient);\n\nconst useSuggestionsResource = (\n suggestions?: SuggestionConfig[],\n): ClientOutput<\"suggestions\"> => {\n const [state] = useState<SuggestionsState>(() => {\n const normalizedSuggestions = (suggestions ?? []).map((s) => {\n if (typeof s === \"string\") {\n return {\n title: s,\n label: \"\",\n prompt: s,\n };\n }\n return {\n title: s.title,\n label: s.label,\n prompt: s.prompt,\n };\n });\n\n return {\n suggestions: normalizedSuggestions,\n };\n });\n\n const suggestionClients = useClientLookup(\n () =>\n state.suggestions.map((suggestion, index) =>\n withKey(index, SuggestionClient(suggestion)),\n ),\n [state.suggestions],\n );\n\n return {\n getState: () => state,\n suggestion: ({ index }: { index: number }) => {\n return suggestionClients.get({ index });\n },\n };\n};\n\nexport const Suggestions = resource(useSuggestionsResource);\n"],"mappings":";;;;AAWA,MAAM,uBACJ,UAC+B;CAC/B,OAAO,EACL,gBAAgB,MAClB;AACF;AAEA,MAAM,mBAAmB,SAAS,mBAAmB;AAErD,MAAM,0BACJ,gBACgC;CAChC,MAAM,CAAC,SAAS,eAAiC;EAgB/C,OAAO,EACL,cAhB6B,eAAe,CAAC,EAAA,CAAG,KAAK,MAAM;GAC3D,IAAI,OAAO,MAAM,UACf,OAAO;IACL,OAAO;IACP,OAAO;IACP,QAAQ;GACV;GAEF,OAAO;IACL,OAAO,EAAE;IACT,OAAO,EAAE;IACT,QAAQ,EAAE;GACZ;EACF,CAGmC,EACnC;CACF,CAAC;CAED,MAAM,oBAAoB,sBAEtB,MAAM,YAAY,KAAK,YAAY,UACjC,QAAQ,OAAO,iBAAiB,UAAU,CAAC,CAC7C,GACF,CAAC,MAAM,WAAW,CACpB;CAEA,OAAO;EACL,gBAAgB;EAChB,aAAa,EAAE,YAA+B;GAC5C,OAAO,kBAAkB,IAAI,EAAE,MAAM,CAAC;EACxC;CACF;AACF;AAEA,MAAa,cAAc,SAAS,sBAAsB"}
|
|
@@ -9,7 +9,7 @@ type ThreadMessageClientProps = {
|
|
|
9
9
|
branchNumber?: number;
|
|
10
10
|
branchCount?: number;
|
|
11
11
|
};
|
|
12
|
-
declare const ThreadMessageClient:
|
|
12
|
+
declare const ThreadMessageClient: import("@assistant-ui/tap").Resource<ClientOutput<"message">, [ThreadMessageClientProps]>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { ThreadMessageClient, ThreadMessageClientProps };
|
|
15
15
|
//# sourceMappingURL=thread-message-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-message-client.d.ts","names":[],"sources":["../../../src/store/clients/thread-message-client.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"thread-message-client.d.ts","names":[],"sources":["../../../src/store/clients/thread-message-client.ts"],"mappings":";;;;KA2DY,wBAAA;EACV,OAAA,EAAS,aAAa;EACtB,KAAA;EACA,MAAA;EACA,YAAA;EACA,WAAA;AAAA;AAAA,cA0GW,mBAAA,8BAAmB,QAAA,CAAA,YAAA,cAAA,wBAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { getThreadMessageText } from "../../utils/text.js";
|
|
1
2
|
import { NoOpComposerClient } from "./no-op-composer-client.js";
|
|
2
3
|
import { useMemo, useState } from "@assistant-ui/tap/react-shim";
|
|
3
4
|
import { useClientLookup } from "@assistant-ui/store";
|
|
4
5
|
import { resource, useResource, withKey } from "@assistant-ui/tap";
|
|
5
6
|
//#region src/store/clients/thread-message-client.ts
|
|
6
|
-
const
|
|
7
|
+
const useThreadMessagePartClient = ({ part }) => {
|
|
7
8
|
const state = useMemo(() => {
|
|
8
9
|
return {
|
|
9
10
|
...part,
|
|
@@ -22,16 +23,18 @@ const ThreadMessagePartClient = resource(function ThreadMessagePartClient({ part
|
|
|
22
23
|
throw new Error("Not supported");
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
|
-
}
|
|
26
|
-
const
|
|
26
|
+
};
|
|
27
|
+
const ThreadMessagePartClient = resource(useThreadMessagePartClient);
|
|
28
|
+
const useThreadMessageAttachmentClient = ({ attachment }) => {
|
|
27
29
|
return {
|
|
28
30
|
getState: () => attachment,
|
|
29
31
|
remove: () => {
|
|
30
32
|
throw new Error("Not supported");
|
|
31
33
|
}
|
|
32
34
|
};
|
|
33
|
-
}
|
|
34
|
-
const
|
|
35
|
+
};
|
|
36
|
+
const ThreadMessageAttachmentClient = resource(useThreadMessageAttachmentClient);
|
|
37
|
+
const useThreadMessageClient = ({ message, index, isLast = true, branchNumber = 1, branchCount = 1 }) => {
|
|
35
38
|
const [isCopiedState, setIsCopied] = useState(false);
|
|
36
39
|
const [isHoveringState, setIsHovering] = useState(false);
|
|
37
40
|
const parts = useClientLookup(() => message.content.map((part, idx) => withKey("toolCallId" in part && part.toolCallId != null ? `toolCallId-${part.toolCallId}` : `index-${idx}`, ThreadMessagePartClient({ part }))), [message.content]);
|
|
@@ -74,6 +77,9 @@ const ThreadMessageClient = resource(function ThreadMessageClient({ message, ind
|
|
|
74
77
|
if ("id" in selector) return attachments.get({ key: selector.id });
|
|
75
78
|
else return attachments.get(selector);
|
|
76
79
|
},
|
|
80
|
+
delete: () => {
|
|
81
|
+
throw new Error("Not supported in ThreadMessageProvider");
|
|
82
|
+
},
|
|
77
83
|
reload: () => {
|
|
78
84
|
throw new Error("Not supported in ThreadMessageProvider");
|
|
79
85
|
},
|
|
@@ -90,15 +96,13 @@ const ThreadMessageClient = resource(function ThreadMessageClient({ message, ind
|
|
|
90
96
|
throw new Error("Not supported in ThreadMessageProvider");
|
|
91
97
|
},
|
|
92
98
|
getCopyText: () => {
|
|
93
|
-
return message
|
|
94
|
-
if ("text" in part && typeof part.text === "string") return part.text;
|
|
95
|
-
return "";
|
|
96
|
-
}).join("\n");
|
|
99
|
+
return getThreadMessageText(message);
|
|
97
100
|
},
|
|
98
101
|
setIsCopied,
|
|
99
102
|
setIsHovering
|
|
100
103
|
};
|
|
101
|
-
}
|
|
104
|
+
};
|
|
105
|
+
const ThreadMessageClient = resource(useThreadMessageClient);
|
|
102
106
|
//#endregion
|
|
103
107
|
export { ThreadMessageClient };
|
|
104
108
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-message-client.js","names":[],"sources":["../../../src/store/clients/thread-message-client.ts"],"sourcesContent":["import type {\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Attachment } from \"../../types/attachment\";\nimport { useMemo, useState } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store\";\nimport type { MessageState } from \"../scopes/message\";\nimport type { PartState } from \"../scopes/part\";\nimport { NoOpComposerClient } from \"./no-op-composer-client\";\n\nconst
|
|
1
|
+
{"version":3,"file":"thread-message-client.js","names":[],"sources":["../../../src/store/clients/thread-message-client.ts"],"sourcesContent":["import type {\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Attachment } from \"../../types/attachment\";\nimport { useMemo, useState } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store\";\nimport type { MessageState } from \"../scopes/message\";\nimport type { PartState } from \"../scopes/part\";\nimport { NoOpComposerClient } from \"./no-op-composer-client\";\nimport { getThreadMessageText } from \"../../utils/text\";\n\nconst useThreadMessagePartClient = ({\n part,\n}: {\n part: ThreadAssistantMessagePart | ThreadUserMessagePart;\n}): ClientOutput<\"part\"> => {\n const state = useMemo<PartState>(() => {\n return {\n ...part,\n status: { type: \"complete\" },\n };\n }, [part]);\n\n return {\n getState: () => state,\n addToolResult: () => {\n throw new Error(\"Not supported\");\n },\n resumeToolCall: () => {\n throw new Error(\"Not supported\");\n },\n respondToToolApproval: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessagePartClient = resource(useThreadMessagePartClient);\n\nconst useThreadMessageAttachmentClient = ({\n attachment,\n}: {\n attachment: Attachment;\n}): ClientOutput<\"attachment\"> => {\n return {\n getState: () => attachment,\n remove: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessageAttachmentClient = resource(\n useThreadMessageAttachmentClient,\n);\nexport type ThreadMessageClientProps = {\n message: ThreadMessage;\n index: number;\n isLast?: boolean;\n branchNumber?: number;\n branchCount?: number;\n};\n\nconst useThreadMessageClient = ({\n message,\n index,\n isLast = true,\n branchNumber = 1,\n branchCount = 1,\n}: ThreadMessageClientProps): ClientOutput<\"message\"> => {\n const [isCopiedState, setIsCopied] = useState(false);\n const [isHoveringState, setIsHovering] = useState(false);\n\n const parts = useClientLookup(\n () =>\n message.content.map((part, idx) =>\n withKey(\n \"toolCallId\" in part && part.toolCallId != null\n ? `toolCallId-${part.toolCallId}`\n : `index-${idx}`,\n ThreadMessagePartClient({ part }),\n ),\n ),\n [message.content],\n );\n\n const attachments = useClientLookup(\n () =>\n (message.attachments ?? []).map((attachment) =>\n withKey(attachment.id, ThreadMessageAttachmentClient({ attachment })),\n ),\n [message.attachments],\n );\n\n const composer = useResource(NoOpComposerClient({ type: \"edit\" }));\n const composerState = composer.getState();\n\n const state = useMemo<MessageState>(() => {\n return {\n ...message,\n parts: parts.state,\n composer: composerState,\n parentId: null,\n index,\n isLast,\n branchNumber,\n branchCount,\n speech: undefined,\n isCopied: isCopiedState,\n isHovering: isHoveringState,\n };\n }, [\n message,\n index,\n isCopiedState,\n isHoveringState,\n isLast,\n parts.state,\n composerState,\n branchNumber,\n branchCount,\n ]);\n\n return {\n getState: () => state,\n composer: () => composer,\n part: (selector) => {\n if (\"index\" in selector) {\n return parts.get({ index: selector.index });\n } else {\n return parts.get({ key: `toolCallId-${selector.toolCallId}` });\n }\n },\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.get({ key: selector.id });\n } else {\n return attachments.get(selector);\n }\n },\n delete: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n reload: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n speak: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n stopSpeaking: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n submitFeedback: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n switchToBranch: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n getCopyText: () => {\n return getThreadMessageText(message);\n },\n setIsCopied,\n setIsHovering,\n };\n};\n\nexport const ThreadMessageClient = resource(useThreadMessageClient);\n"],"mappings":";;;;;;AAeA,MAAM,8BAA8B,EAClC,WAG0B;CAC1B,MAAM,QAAQ,cAAyB;EACrC,OAAO;GACL,GAAG;GACH,QAAQ,EAAE,MAAM,WAAW;EAC7B;CACF,GAAG,CAAC,IAAI,CAAC;CAET,OAAO;EACL,gBAAgB;EAChB,qBAAqB;GACnB,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,sBAAsB;GACpB,MAAM,IAAI,MAAM,eAAe;EACjC;EACA,6BAA6B;GAC3B,MAAM,IAAI,MAAM,eAAe;EACjC;CACF;AACF;AAEA,MAAM,0BAA0B,SAAS,0BAA0B;AAEnE,MAAM,oCAAoC,EACxC,iBAGgC;CAChC,OAAO;EACL,gBAAgB;EAChB,cAAc;GACZ,MAAM,IAAI,MAAM,eAAe;EACjC;CACF;AACF;AAEA,MAAM,gCAAgC,SACpC,gCACF;AASA,MAAM,0BAA0B,EAC9B,SACA,OACA,SAAS,MACT,eAAe,GACf,cAAc,QACyC;CACvD,MAAM,CAAC,eAAe,eAAe,SAAS,KAAK;CACnD,MAAM,CAAC,iBAAiB,iBAAiB,SAAS,KAAK;CAEvD,MAAM,QAAQ,sBAEV,QAAQ,QAAQ,KAAK,MAAM,QACzB,QACE,gBAAgB,QAAQ,KAAK,cAAc,OACvC,cAAc,KAAK,eACnB,SAAS,OACb,wBAAwB,EAAE,KAAK,CAAC,CAClC,CACF,GACF,CAAC,QAAQ,OAAO,CAClB;CAEA,MAAM,cAAc,uBAEf,QAAQ,eAAe,CAAC,EAAA,CAAG,KAAK,eAC/B,QAAQ,WAAW,IAAI,8BAA8B,EAAE,WAAW,CAAC,CAAC,CACtE,GACF,CAAC,QAAQ,WAAW,CACtB;CAEA,MAAM,WAAW,YAAY,mBAAmB,EAAE,MAAM,OAAO,CAAC,CAAC;CACjE,MAAM,gBAAgB,SAAS,SAAS;CAExC,MAAM,QAAQ,cAA4B;EACxC,OAAO;GACL,GAAG;GACH,OAAO,MAAM;GACb,UAAU;GACV,UAAU;GACV;GACA;GACA;GACA;GACA,QAAQ,KAAA;GACR,UAAU;GACV,YAAY;EACd;CACF,GAAG;EACD;EACA;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA;CACF,CAAC;CAED,OAAO;EACL,gBAAgB;EAChB,gBAAgB;EAChB,OAAO,aAAa;GAClB,IAAI,WAAW,UACb,OAAO,MAAM,IAAI,EAAE,OAAO,SAAS,MAAM,CAAC;QAE1C,OAAO,MAAM,IAAI,EAAE,KAAK,cAAc,SAAS,aAAa,CAAC;EAEjE;EACA,aAAa,aAAa;GACxB,IAAI,QAAQ,UACV,OAAO,YAAY,IAAI,EAAE,KAAK,SAAS,GAAG,CAAC;QAE3C,OAAO,YAAY,IAAI,QAAQ;EAEnC;EACA,cAAc;GACZ,MAAM,IAAI,MAAM,wCAAwC;EAC1D;EACA,cAAc;GACZ,MAAM,IAAI,MAAM,wCAAwC;EAC1D;EACA,aAAa;GACX,MAAM,IAAI,MAAM,wCAAwC;EAC1D;EACA,oBAAoB;GAClB,MAAM,IAAI,MAAM,wCAAwC;EAC1D;EACA,sBAAsB;GACpB,MAAM,IAAI,MAAM,wCAAwC;EAC1D;EACA,sBAAsB;GACpB,MAAM,IAAI,MAAM,wCAAwC;EAC1D;EACA,mBAAmB;GACjB,OAAO,qBAAqB,OAAO;EACrC;EACA;EACA;CACF;AACF;AAEA,MAAa,sBAAsB,SAAS,sBAAsB"}
|
package/dist/store/internal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { baseRuntimeAdapterTransformScopes } from "./clients/runtime-adapter.js";
|
|
2
2
|
import { AttachmentRuntimeClient } from "./runtime-clients/attachment-runtime-client.js";
|
|
3
3
|
import { MessagePartClient } from "./runtime-clients/message-part-runtime-client.js";
|
|
4
4
|
import { ComposerClient } from "./runtime-clients/composer-runtime-client.js";
|
|
@@ -6,4 +6,4 @@ import { MessageClient } from "./runtime-clients/message-runtime-client.js";
|
|
|
6
6
|
import { ThreadClient } from "./runtime-clients/thread-runtime-client.js";
|
|
7
7
|
import { ThreadListItemClient } from "./runtime-clients/thread-list-item-runtime-client.js";
|
|
8
8
|
import { ThreadListClient } from "./runtime-clients/thread-list-runtime-client.js";
|
|
9
|
-
export { AttachmentRuntimeClient, ComposerClient, MessageClient, MessagePartClient,
|
|
9
|
+
export { AttachmentRuntimeClient, ComposerClient, MessageClient, MessagePartClient, ThreadClient, ThreadListClient, ThreadListItemClient, baseRuntimeAdapterTransformScopes };
|
package/dist/store/internal.js
CHANGED
|
@@ -5,5 +5,5 @@ import { MessageClient } from "./runtime-clients/message-runtime-client.js";
|
|
|
5
5
|
import { ThreadClient } from "./runtime-clients/thread-runtime-client.js";
|
|
6
6
|
import { ThreadListItemClient } from "./runtime-clients/thread-list-item-runtime-client.js";
|
|
7
7
|
import { ThreadListClient } from "./runtime-clients/thread-list-runtime-client.js";
|
|
8
|
-
import {
|
|
9
|
-
export { AttachmentRuntimeClient, ComposerClient, MessageClient, MessagePartClient,
|
|
8
|
+
import { baseRuntimeAdapterTransformScopes } from "./clients/runtime-adapter.js";
|
|
9
|
+
export { AttachmentRuntimeClient, ComposerClient, MessageClient, MessagePartClient, ThreadClient, ThreadListClient, ThreadListItemClient, baseRuntimeAdapterTransformScopes };
|
|
@@ -2,11 +2,9 @@ import { AttachmentRuntime } from "../../runtime/api/attachment-runtime.js";
|
|
|
2
2
|
import { ClientOutput } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
//#region src/store/runtime-clients/attachment-runtime-client.d.ts
|
|
5
|
-
declare const AttachmentRuntimeClient: (
|
|
5
|
+
declare const AttachmentRuntimeClient: import("@assistant-ui/tap").Resource<ClientOutput<"attachment">, [{
|
|
6
6
|
runtime: AttachmentRuntime;
|
|
7
|
-
}
|
|
8
|
-
runtime: AttachmentRuntime;
|
|
9
|
-
}>;
|
|
7
|
+
}]>;
|
|
10
8
|
//#endregion
|
|
11
9
|
export { AttachmentRuntimeClient };
|
|
12
10
|
//# sourceMappingURL=attachment-runtime-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/attachment-runtime-client.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"attachment-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/attachment-runtime-client.ts"],"mappings":";;;;cAmBa,uBAAA,8BAAuB,QAAA,CAAA,YAAA;WAXzB,iBAAiB;AAAA"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { useSubscribable } from "./useSubscribable.js";
|
|
2
2
|
import { resource } from "@assistant-ui/tap";
|
|
3
3
|
//#region src/store/runtime-clients/attachment-runtime-client.ts
|
|
4
|
-
const
|
|
4
|
+
const useAttachmentRuntimeClient = ({ runtime }) => {
|
|
5
5
|
const state = useSubscribable(runtime);
|
|
6
6
|
return {
|
|
7
7
|
getState: () => state,
|
|
8
8
|
remove: runtime.remove,
|
|
9
9
|
__internal_getRuntime: () => runtime
|
|
10
10
|
};
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
|
+
const AttachmentRuntimeClient = resource(useAttachmentRuntimeClient);
|
|
12
13
|
//#endregion
|
|
13
14
|
export { AttachmentRuntimeClient };
|
|
14
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/attachment-runtime-client.ts"],"sourcesContent":["import { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport type { AttachmentRuntime } from \"../../runtime/api/attachment-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\n\
|
|
1
|
+
{"version":3,"file":"attachment-runtime-client.js","names":[],"sources":["../../../src/store/runtime-clients/attachment-runtime-client.ts"],"sourcesContent":["import { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport type { AttachmentRuntime } from \"../../runtime/api/attachment-runtime\";\nimport { useSubscribable } from \"./useSubscribable\";\n\nconst useAttachmentRuntimeClient = ({\n runtime,\n}: {\n runtime: AttachmentRuntime;\n}): ClientOutput<\"attachment\"> => {\n const state = useSubscribable(runtime);\n\n return {\n getState: () => state,\n remove: runtime.remove,\n __internal_getRuntime: () => runtime,\n };\n};\n\nexport const AttachmentRuntimeClient = resource(useAttachmentRuntimeClient);\n"],"mappings":";;;AAKA,MAAM,8BAA8B,EAClC,cAGgC;CAChC,MAAM,QAAQ,gBAAgB,OAAO;CAErC,OAAO;EACL,gBAAgB;EAChB,QAAQ,QAAQ;EAChB,6BAA6B;CAC/B;AACF;AAEA,MAAa,0BAA0B,SAAS,0BAA0B"}
|
|
@@ -2,7 +2,7 @@ import { ComposerRuntime } from "../../runtime/api/composer-runtime.js";
|
|
|
2
2
|
import { ClientOutput } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
//#region src/store/runtime-clients/composer-runtime-client.d.ts
|
|
5
|
-
declare const ComposerClient: (
|
|
5
|
+
declare const ComposerClient: import("@assistant-ui/tap").Resource<ClientOutput<"composer">, [{
|
|
6
6
|
threadIdRef: {
|
|
7
7
|
current: string;
|
|
8
8
|
};
|
|
@@ -10,15 +10,7 @@ declare const ComposerClient: (props: {
|
|
|
10
10
|
current: string;
|
|
11
11
|
};
|
|
12
12
|
runtime: ComposerRuntime;
|
|
13
|
-
}
|
|
14
|
-
threadIdRef: {
|
|
15
|
-
current: string;
|
|
16
|
-
};
|
|
17
|
-
messageIdRef?: {
|
|
18
|
-
current: string;
|
|
19
|
-
};
|
|
20
|
-
runtime: ComposerRuntime;
|
|
21
|
-
}>;
|
|
13
|
+
}]>;
|
|
22
14
|
//#endregion
|
|
23
15
|
export { ComposerClient };
|
|
24
16
|
//# sourceMappingURL=composer-runtime-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composer-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/composer-runtime-client.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"composer-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/composer-runtime-client.ts"],"mappings":";;;;cAqLa,cAAA,8BAAc,QAAA,CAAA,YAAA;;IAtHV,OAAA;EAAA;;IACE,OAAA;EAAA;WACR,eAAe;AAAA"}
|