@assistant-ui/react 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/AssistantRuntime.d.ts +4 -34
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/AttachmentRuntime.d.ts +4 -4
- package/dist/api/AttachmentRuntime.d.ts.map +1 -1
- package/dist/api/AttachmentRuntime.js.map +1 -1
- package/dist/api/AttachmentRuntime.mjs.map +1 -1
- package/dist/api/ComposerRuntime.d.ts +10 -10
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.mjs.map +1 -1
- package/dist/api/ContentPartRuntime.d.ts +2 -2
- package/dist/api/ContentPartRuntime.d.ts.map +1 -1
- package/dist/api/ContentPartRuntime.js.map +1 -1
- package/dist/api/ContentPartRuntime.mjs.map +1 -1
- package/dist/api/MessageRuntime.d.ts +7 -7
- package/dist/api/MessageRuntime.d.ts.map +1 -1
- package/dist/api/MessageRuntime.js +2 -2
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.mjs +2 -2
- package/dist/api/MessageRuntime.mjs.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +33 -33
- package/dist/api/RuntimePathTypes.d.ts.map +1 -1
- package/dist/api/RuntimePathTypes.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.d.ts +4 -4
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
- package/dist/api/ThreadListRuntime.d.ts +9 -9
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.mjs.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +45 -56
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/context/react/AssistantContext.d.ts +10 -48
- package/dist/context/react/AssistantContext.d.ts.map +1 -1
- package/dist/context/react/AttachmentContext.d.ts +16 -16
- package/dist/context/react/MessageContext.d.ts +6 -36
- package/dist/context/react/MessageContext.d.ts.map +1 -1
- package/dist/context/react/ThreadContext.d.ts +10 -138
- package/dist/context/react/ThreadContext.d.ts.map +1 -1
- package/dist/context/stores/AssistantToolUIs.d.ts +9 -6
- package/dist/context/stores/AssistantToolUIs.d.ts.map +1 -1
- package/dist/context/stores/AssistantToolUIs.js.map +1 -1
- package/dist/context/stores/AssistantToolUIs.mjs.map +1 -1
- package/dist/context/stores/MessageUtils.d.ts +7 -12
- package/dist/context/stores/MessageUtils.d.ts.map +1 -1
- package/dist/context/stores/MessageUtils.js.map +1 -1
- package/dist/context/stores/MessageUtils.mjs.map +1 -1
- package/dist/context/stores/ThreadViewport.d.ts +6 -10
- package/dist/context/stores/ThreadViewport.d.ts.map +1 -1
- package/dist/context/stores/ThreadViewport.js +0 -1
- package/dist/context/stores/ThreadViewport.js.map +1 -1
- package/dist/context/stores/ThreadViewport.mjs +0 -2
- package/dist/context/stores/ThreadViewport.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.d.ts +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartImage.d.ts +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartText.d.ts +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +2 -4
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts +22 -22
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +3 -3
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +2 -11
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api/AssistantRuntime.ts +2 -2
- package/src/api/AttachmentRuntime.ts +4 -4
- package/src/api/ComposerRuntime.ts +10 -10
- package/src/api/ContentPartRuntime.ts +2 -2
- package/src/api/MessageRuntime.ts +9 -9
- package/src/api/RuntimePathTypes.ts +26 -26
- package/src/api/ThreadListItemRuntime.ts +4 -4
- package/src/api/ThreadListRuntime.ts +10 -10
- package/src/api/ThreadRuntime.ts +45 -14
- package/src/api/index.ts +4 -0
- package/src/context/stores/AssistantToolUIs.ts +9 -2
- package/src/context/stores/MessageUtils.ts +6 -6
- package/src/context/stores/ThreadViewport.tsx +5 -6
- package/src/runtimes/core/ThreadRuntimeCore.tsx +28 -29
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/api/ThreadRuntime.ts"],"sourcesContent":["import {\n ThreadSuggestion,\n RuntimeCapabilities,\n ThreadRuntimeCore,\n SpeechState,\n ThreadRuntimeEventType,\n ThreadMetadata,\n} from \"../runtimes/core/ThreadRuntimeCore\";\nimport { ExportedMessageRepository } from \"../runtimes/utils/MessageRepository\";\nimport {\n AppendMessage,\n ModelConfig,\n ThreadMessage,\n Unsubscribe,\n} from \"../types\";\nimport {\n MessageRuntime,\n MessageRuntimeImpl,\n MessageState,\n} from \"./MessageRuntime\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport {\n Subscribable,\n SubscribableWithState,\n} from \"./subscribable/Subscribable\";\nimport {\n ThreadComposerRuntime,\n ThreadComposerRuntimeImpl,\n} from \"./ComposerRuntime\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { MessageRuntimePath, ThreadRuntimePath } from \"./RuntimePathTypes\";\n\nexport type CreateAppendMessage =\n | string\n | {\n parentId?: string | null | undefined;\n role?: AppendMessage[\"role\"] | undefined;\n content: AppendMessage[\"content\"];\n attachments?: AppendMessage[\"attachments\"] | undefined;\n startRun?: boolean | undefined;\n };\n\nconst toAppendMessage = (\n messages: readonly ThreadMessage[],\n message: CreateAppendMessage,\n): AppendMessage => {\n if (typeof message === \"string\") {\n return {\n parentId: messages.at(-1)?.id ?? null,\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n attachments: [],\n };\n }\n\n if (message.role && message.parentId && message.attachments) {\n return message as AppendMessage;\n }\n\n return {\n ...message,\n parentId: message.parentId ?? messages.at(-1)?.id ?? null,\n role: message.role ?? \"user\",\n attachments: message.attachments ?? [],\n } as AppendMessage;\n};\n\nexport type ThreadRuntimeCoreBinding = SubscribableWithState<\n ThreadRuntimeCore,\n ThreadRuntimePath\n> & {\n outerSubscribe(callback: () => void): Unsubscribe;\n};\n\nexport type ThreadState = Readonly<{\n /**\n * The thread ID.\n * @deprecated This field is deprecated and will be removed in 0.7.0. Use `metadata.threadId` instead. \n */\n threadId: string;\n\n /**\n * The thread metadata.\n */\n metadata: ThreadMetadata;\n\n /**\n * Whether the thread is disabled. Disabled threads cannot receive new messages.\n */\n isDisabled: boolean;\n\n /**\n * Whether the thread is running. A thread is considered running when there is an active stream connection to the backend.\n */\n isRunning: boolean;\n\n /**\n * The capabilities of the thread, such as whether the thread supports editing, branch switching, etc.\n */\n capabilities: RuntimeCapabilities;\n\n /**\n * The messages in the currently selected branch of the thread.\n */\n messages: readonly ThreadMessage[];\n\n /**\n * Follow up message suggestions to show the user.\n */\n suggestions: readonly ThreadSuggestion[];\n\n /**\n * Custom extra information provided by the runtime.\n */\n extras: unknown;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n speech: SpeechState | undefined;\n}>;\n\nexport const getThreadState = (runtime: ThreadRuntimeCore): ThreadState => {\n const lastMessage = runtime.messages.at(-1);\n return Object.freeze({\n threadId: runtime.metadata.threadId,\n metadata: runtime.metadata,\n capabilities: runtime.capabilities,\n isDisabled: runtime.isDisabled,\n isRunning:\n lastMessage?.role !== \"assistant\"\n ? false\n : lastMessage.status.type === \"running\",\n messages: runtime.messages,\n suggestions: runtime.suggestions,\n extras: runtime.extras,\n speech: runtime.speech,\n });\n};\n\nexport type ThreadRuntime = Readonly<{\n readonly path: ThreadRuntimePath;\n\n readonly composer: ThreadComposerRuntime;\n getState(): ThreadState;\n\n append(message: CreateAppendMessage): void;\n startRun(parentId: string | null): void;\n subscribe(callback: () => void): Unsubscribe;\n cancelRun(): void;\n getModelConfig(): ModelConfig;\n export(): ExportedMessageRepository;\n import(repository: ExportedMessageRepository): void;\n getMesssageByIndex(idx: number): MessageRuntime;\n getMesssageById(messageId: string): MessageRuntime;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n stopSpeaking: () => void;\n\n unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;\n}>;\n\nexport class ThreadRuntimeImpl implements ThreadRuntime {\n public get path() {\n return this._threadBinding.path;\n }\n\n public unstable_getCore() {\n return this._threadBinding.getState();\n }\n\n private _threadBinding: ThreadRuntimeCoreBinding & {\n getStateState(): ThreadState;\n };\n\n constructor(threadBinding: ThreadRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: threadBinding.path,\n getState: () => getThreadState(threadBinding.getState()),\n subscribe: (callback) => threadBinding.subscribe(callback),\n });\n\n this._threadBinding = {\n path: threadBinding.path,\n getState: () => threadBinding.getState(),\n getStateState: () => stateBinding.getState(),\n outerSubscribe: (callback) => threadBinding.outerSubscribe(callback),\n subscribe: (callback) => threadBinding.subscribe(callback),\n };\n\n this.composer = new ThreadComposerRuntimeImpl(\n new NestedSubscriptionSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.composer`,\n composerSource: \"thread\",\n },\n getState: () => this._threadBinding.getState().composer,\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n );\n }\n\n public readonly composer;\n\n public getState() {\n return this._threadBinding.getStateState();\n }\n\n public append(message: CreateAppendMessage) {\n this._threadBinding\n .getState()\n .append(\n toAppendMessage(this._threadBinding.getState().messages, message),\n );\n }\n\n public subscribe(callback: () => void) {\n return this._threadBinding.subscribe(callback);\n }\n\n public getModelConfig() {\n return this._threadBinding.getState().getModelConfig();\n }\n\n public startRun(parentId: string | null) {\n return this._threadBinding.getState().startRun(parentId);\n }\n\n public cancelRun() {\n this._threadBinding.getState().cancelRun();\n }\n\n public stopSpeaking() {\n return this._threadBinding.getState().stopSpeaking();\n }\n\n public getSubmittedFeedback(messageId: string) {\n return this._threadBinding.getState().getSubmittedFeedback(messageId);\n }\n\n public export() {\n return this._threadBinding.getState().export();\n }\n\n public import(data: ExportedMessageRepository) {\n this._threadBinding.getState().import(data);\n }\n\n public getMesssageByIndex(idx: number) {\n if (idx < 0) throw new Error(\"Message index must be >= 0\");\n\n return this._getMessageRuntime(\n {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.messages[${idx}]`,\n messageSelector: { type: \"index\", index: idx },\n },\n () => {\n const messages = this._threadBinding.getState().messages;\n const message = messages[idx];\n if (!message) return undefined;\n return {\n message,\n parentId: messages[idx - 1]?.id ?? null,\n };\n },\n );\n }\n\n public getMesssageById(messageId: string) {\n return this._getMessageRuntime(\n {\n ...this.path,\n ref:\n this.path.ref +\n `${this.path.ref}.messages[messageId=${JSON.stringify(messageId)}]`,\n messageSelector: { type: \"messageId\", messageId: messageId },\n },\n () => this._threadBinding.getState().getMessageById(messageId),\n );\n }\n\n private _getMessageRuntime(\n path: MessageRuntimePath,\n callback: () =>\n | { parentId: string | null; message: ThreadMessage }\n | undefined,\n ) {\n return new MessageRuntimeImpl(\n new ShallowMemoizeSubject({\n path,\n getState: () => {\n const { message, parentId } = callback() ?? {};\n\n const { messages, speech: speechState } =\n this._threadBinding.getState();\n\n if (!message || parentId === undefined) return SKIP_UPDATE;\n\n const thread = this._threadBinding.getState();\n\n const branches = thread.getBranches(message.id);\n const submittedFeedback = thread.getSubmittedFeedback(message.id);\n\n return {\n ...message,\n\n isLast: messages.at(-1)?.id === message.id,\n parentId,\n\n branchNumber: branches.indexOf(message.id) + 1,\n branchCount: branches.length,\n\n speech:\n speechState?.messageId === message.id ? speechState : undefined,\n\n submittedFeedback,\n } satisfies MessageState;\n },\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n this._threadBinding,\n );\n }\n\n private _eventListenerNestedSubscriptions = new Map<\n string,\n NestedSubscriptionSubject<Subscribable, ThreadRuntimePath>\n >();\n\n public unstable_on(\n event: ThreadRuntimeEventType,\n callback: () => void,\n ): Unsubscribe {\n let subject = this._eventListenerNestedSubscriptions.get(event);\n if (!subject) {\n subject = new NestedSubscriptionSubject({\n path: this.path,\n getState: () => ({\n subscribe: (callback) =>\n this._threadBinding.getState().unstable_on(event, callback),\n }),\n subscribe: (callback) => this._threadBinding.outerSubscribe(callback),\n });\n this._eventListenerNestedSubscriptions.set(event, subject);\n }\n return subject.subscribe(callback);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,4BAIO;AACP,uCAA0C;AAC1C,mCAAsC;AAKtC,6BAGO;AACP,gCAAmC;AACnC,yBAA4B;AAa5B,IAAM,kBAAkB,CACtB,UACA,YACkB;AAClB,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,MACL,UAAU,SAAS,GAAG,EAAE,GAAG,MAAM;AAAA,MACjC,MAAM;AAAA,MACN,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,QAAQ,CAAC;AAAA,MACzC,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AAEA,MAAI,Q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AAA,YAEA,cAAc,SAAS,QAAQ,QAAQ,EAAE,IAAI;AAAA,YAC7C,aAAa,SAAS;AAAA,YAEtB,QACE,aAAa,cAAc,QAAQ,KAAK,cAAc;AAAA,YAExD;AAAA,UACF;AAAA,QACF;AAAA,QACA,WAAW,CAACA,cAAa,KAAK,eAAe,UAAUA,SAAQ;AAAA,MACjE,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEQ,oCAAoC,oBAAI,IAG9C;AAAA,EAEK,YACL,OACA,UACa;AACb,QAAI,UAAU,KAAK,kCAAkC,IAAI,KAAK;AAC9D,QAAI,CAAC,SAAS;AACZ,gBAAU,IAAI,2DAA0B;AAAA,QACtC,MAAM,KAAK;AAAA,QACX,UAAU,OAAO;AAAA,UACf,WAAW,CAACA,cACV,KAAK,eAAe,SAAS,EAAE,YAAY,OAAOA,SAAQ;AAAA,QAC9D;AAAA,QACA,WAAW,CAACA,cAAa,KAAK,eAAe,eAAeA,SAAQ;AAAA,MACtE,CAAC;AACD,WAAK,kCAAkC,IAAI,OAAO,OAAO;AAAA,IAC3D;AACA,WAAO,QAAQ,UAAU,QAAQ;AAAA,EACnC;AACF;","names":["callback"]}
|
1
|
+
{"version":3,"sources":["../../src/api/ThreadRuntime.ts"],"sourcesContent":["import {\n ThreadSuggestion,\n RuntimeCapabilities,\n ThreadRuntimeCore,\n SpeechState,\n ThreadRuntimeEventType,\n ThreadMetadata,\n} from \"../runtimes/core/ThreadRuntimeCore\";\nimport { ExportedMessageRepository } from \"../runtimes/utils/MessageRepository\";\nimport {\n AppendMessage,\n ModelConfig,\n ThreadMessage,\n Unsubscribe,\n} from \"../types\";\nimport {\n MessageRuntime,\n MessageRuntimeImpl,\n MessageState,\n} from \"./MessageRuntime\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport {\n Subscribable,\n SubscribableWithState,\n} from \"./subscribable/Subscribable\";\nimport {\n ThreadComposerRuntime,\n ThreadComposerRuntimeImpl,\n} from \"./ComposerRuntime\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { MessageRuntimePath, ThreadRuntimePath } from \"./RuntimePathTypes\";\n\nexport type CreateAppendMessage =\n | string\n | {\n parentId?: string | null | undefined;\n role?: AppendMessage[\"role\"] | undefined;\n content: AppendMessage[\"content\"];\n attachments?: AppendMessage[\"attachments\"] | undefined;\n startRun?: boolean | undefined;\n };\n\nconst toAppendMessage = (\n messages: readonly ThreadMessage[],\n message: CreateAppendMessage,\n): AppendMessage => {\n if (typeof message === \"string\") {\n return {\n parentId: messages.at(-1)?.id ?? null,\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n attachments: [],\n };\n }\n\n if (message.role && message.parentId && message.attachments) {\n return message as AppendMessage;\n }\n\n return {\n ...message,\n parentId: message.parentId ?? messages.at(-1)?.id ?? null,\n role: message.role ?? \"user\",\n attachments: message.attachments ?? [],\n } as AppendMessage;\n};\n\nexport type ThreadRuntimeCoreBinding = SubscribableWithState<\n ThreadRuntimeCore,\n ThreadRuntimePath\n> & {\n outerSubscribe(callback: () => void): Unsubscribe;\n};\n\nexport type ThreadState = {\n /**\n * The thread ID.\n * @deprecated This field is deprecated and will be removed in 0.8.0. Use `metadata.threadId` instead.\n */\n readonly threadId: string;\n\n /**\n * The thread metadata.\n */\n readonly metadata: ThreadMetadata;\n\n /**\n * Whether the thread is disabled. Disabled threads cannot receive new messages.\n */\n readonly isDisabled: boolean;\n\n /**\n * Whether the thread is running. A thread is considered running when there is an active stream connection to the backend.\n */\n readonly isRunning: boolean;\n\n /**\n * The capabilities of the thread, such as whether the thread supports editing, branch switching, etc.\n */\n readonly capabilities: RuntimeCapabilities;\n\n /**\n * The messages in the currently selected branch of the thread.\n */\n readonly messages: readonly ThreadMessage[];\n\n /**\n * Follow up message suggestions to show the user.\n */\n readonly suggestions: readonly ThreadSuggestion[];\n\n /**\n * Custom extra information provided by the runtime.\n */\n readonly extras: unknown;\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 const getThreadState = (runtime: ThreadRuntimeCore): ThreadState => {\n const lastMessage = runtime.messages.at(-1);\n return Object.freeze({\n threadId: runtime.metadata.threadId,\n metadata: runtime.metadata,\n capabilities: runtime.capabilities,\n isDisabled: runtime.isDisabled,\n isRunning:\n lastMessage?.role !== \"assistant\"\n ? false\n : lastMessage.status.type === \"running\",\n messages: runtime.messages,\n suggestions: runtime.suggestions,\n extras: runtime.extras,\n speech: runtime.speech,\n });\n};\n\nexport type ThreadRuntime = {\n /**\n * The selector for the thread runtime.\n */\n readonly path: ThreadRuntimePath;\n\n /**\n * The thread composer runtime.\n */\n readonly composer: ThreadComposerRuntime;\n\n /**\n * Gets a snapshot of the thread state.\n */\n getState(): ThreadState;\n\n /**\n * Append a new message to the thread.\n *\n * @example ```ts\n * // append a new user message with the text \"Hello, world!\"\n * threadRuntime.append(\"Hello, world!\");\n * ```\n *\n * @example ```ts\n * // append a new assistant message with the text \"Hello, world!\"\n * threadRuntime.append({\n * role: \"assistant\",\n * content: [{ type: \"text\", text: \"Hello, world!\" }],\n * });\n * ```\n */\n append(message: CreateAppendMessage): void;\n\n /**\n *\n * @param parentId\n */\n startRun(parentId: string | null): void;\n subscribe(callback: () => void): Unsubscribe;\n cancelRun(): void;\n getModelConfig(): ModelConfig;\n export(): ExportedMessageRepository;\n import(repository: ExportedMessageRepository): void;\n getMesssageByIndex(idx: number): MessageRuntime;\n getMesssageById(messageId: string): MessageRuntime;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n stopSpeaking: () => void;\n\n unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;\n};\n\nexport class ThreadRuntimeImpl implements ThreadRuntime {\n public get path() {\n return this._threadBinding.path;\n }\n\n public unstable_getCore() {\n return this._threadBinding.getState();\n }\n\n private _threadBinding: ThreadRuntimeCoreBinding & {\n getStateState(): ThreadState;\n };\n\n constructor(threadBinding: ThreadRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: threadBinding.path,\n getState: () => getThreadState(threadBinding.getState()),\n subscribe: (callback) => threadBinding.subscribe(callback),\n });\n\n this._threadBinding = {\n path: threadBinding.path,\n getState: () => threadBinding.getState(),\n getStateState: () => stateBinding.getState(),\n outerSubscribe: (callback) => threadBinding.outerSubscribe(callback),\n subscribe: (callback) => threadBinding.subscribe(callback),\n };\n\n this.composer = new ThreadComposerRuntimeImpl(\n new NestedSubscriptionSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.composer`,\n composerSource: \"thread\",\n },\n getState: () => this._threadBinding.getState().composer,\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n );\n }\n\n public readonly composer;\n\n public getState() {\n return this._threadBinding.getStateState();\n }\n\n public append(message: CreateAppendMessage) {\n this._threadBinding\n .getState()\n .append(\n toAppendMessage(this._threadBinding.getState().messages, message),\n );\n }\n\n public subscribe(callback: () => void) {\n return this._threadBinding.subscribe(callback);\n }\n\n public getModelConfig() {\n return this._threadBinding.getState().getModelConfig();\n }\n\n public startRun(parentId: string | null) {\n return this._threadBinding.getState().startRun(parentId);\n }\n\n public cancelRun() {\n this._threadBinding.getState().cancelRun();\n }\n\n public stopSpeaking() {\n return this._threadBinding.getState().stopSpeaking();\n }\n\n public getSubmittedFeedback(messageId: string) {\n return this._threadBinding.getState().getSubmittedFeedback(messageId);\n }\n\n public export() {\n return this._threadBinding.getState().export();\n }\n\n public import(data: ExportedMessageRepository) {\n this._threadBinding.getState().import(data);\n }\n\n public getMesssageByIndex(idx: number) {\n if (idx < 0) throw new Error(\"Message index must be >= 0\");\n\n return this._getMessageRuntime(\n {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.messages[${idx}]`,\n messageSelector: { type: \"index\", index: idx },\n },\n () => {\n const messages = this._threadBinding.getState().messages;\n const message = messages[idx];\n if (!message) return undefined;\n return {\n message,\n parentId: messages[idx - 1]?.id ?? null,\n };\n },\n );\n }\n\n public getMesssageById(messageId: string) {\n return this._getMessageRuntime(\n {\n ...this.path,\n ref:\n this.path.ref +\n `${this.path.ref}.messages[messageId=${JSON.stringify(messageId)}]`,\n messageSelector: { type: \"messageId\", messageId: messageId },\n },\n () => this._threadBinding.getState().getMessageById(messageId),\n );\n }\n\n private _getMessageRuntime(\n path: MessageRuntimePath,\n callback: () =>\n | { parentId: string | null; message: ThreadMessage }\n | undefined,\n ) {\n return new MessageRuntimeImpl(\n new ShallowMemoizeSubject({\n path,\n getState: () => {\n const { message, parentId } = callback() ?? {};\n\n const { messages, speech: speechState } =\n this._threadBinding.getState();\n\n if (!message || parentId === undefined) return SKIP_UPDATE;\n\n const thread = this._threadBinding.getState();\n\n const branches = thread.getBranches(message.id);\n const submittedFeedback = thread.getSubmittedFeedback(message.id);\n\n return {\n ...message,\n\n isLast: messages.at(-1)?.id === message.id,\n parentId,\n\n branchNumber: branches.indexOf(message.id) + 1,\n branchCount: branches.length,\n\n speech:\n speechState?.messageId === message.id ? speechState : undefined,\n\n submittedFeedback,\n } satisfies MessageState;\n },\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n this._threadBinding,\n );\n }\n\n private _eventListenerNestedSubscriptions = new Map<\n string,\n NestedSubscriptionSubject<Subscribable, ThreadRuntimePath>\n >();\n\n public unstable_on(\n event: ThreadRuntimeEventType,\n callback: () => void,\n ): Unsubscribe {\n let subject = this._eventListenerNestedSubscriptions.get(event);\n if (!subject) {\n subject = new NestedSubscriptionSubject({\n path: this.path,\n getState: () => ({\n subscribe: (callback) =>\n this._threadBinding.getState().unstable_on(event, callback),\n }),\n subscribe: (callback) => this._threadBinding.outerSubscribe(callback),\n });\n this._eventListenerNestedSubscriptions.set(event, subject);\n }\n return subject.subscribe(callback);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;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ilities,\n ThreadRuntimeCore,\n SpeechState,\n ThreadRuntimeEventType,\n ThreadMetadata,\n} from \"../runtimes/core/ThreadRuntimeCore\";\nimport { ExportedMessageRepository } from \"../runtimes/utils/MessageRepository\";\nimport {\n AppendMessage,\n ModelConfig,\n ThreadMessage,\n Unsubscribe,\n} from \"../types\";\nimport {\n MessageRuntime,\n MessageRuntimeImpl,\n MessageState,\n} from \"./MessageRuntime\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport {\n Subscribable,\n SubscribableWithState,\n} from \"./subscribable/Subscribable\";\nimport {\n ThreadComposerRuntime,\n ThreadComposerRuntimeImpl,\n} from \"./ComposerRuntime\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { MessageRuntimePath, ThreadRuntimePath } from \"./RuntimePathTypes\";\n\nexport type CreateAppendMessage =\n | string\n | {\n parentId?: string | null | undefined;\n role?: AppendMessage[\"role\"] | undefined;\n content: AppendMessage[\"content\"];\n attachments?: AppendMessage[\"attachments\"] | undefined;\n startRun?: boolean | undefined;\n };\n\nconst toAppendMessage = (\n messages: readonly ThreadMessage[],\n message: CreateAppendMessage,\n): AppendMessage => {\n if (typeof message === \"string\") {\n return {\n parentId: messages.at(-1)?.id ?? null,\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n attachments: [],\n };\n }\n\n if (message.role && message.parentId && message.attachments) {\n return message as AppendMessage;\n }\n\n return {\n ...message,\n parentId: message.parentId ?? messages.at(-1)?.id ?? null,\n role: message.role ?? \"user\",\n attachments: message.attachments ?? [],\n } as AppendMessage;\n};\n\nexport type ThreadRuntimeCoreBinding = SubscribableWithState<\n ThreadRuntimeCore,\n ThreadRuntimePath\n> & {\n outerSubscribe(callback: () => void): Unsubscribe;\n};\n\nexport type ThreadState = Readonly<{\n /**\n * The thread ID.\n * @deprecated This field is deprecated and will be removed in 0.7.0. Use `metadata.threadId` instead. \n */\n threadId: string;\n\n /**\n * The thread metadata.\n */\n metadata: ThreadMetadata;\n\n /**\n * Whether the thread is disabled. Disabled threads cannot receive new messages.\n */\n isDisabled: boolean;\n\n /**\n * Whether the thread is running. A thread is considered running when there is an active stream connection to the backend.\n */\n isRunning: boolean;\n\n /**\n * The capabilities of the thread, such as whether the thread supports editing, branch switching, etc.\n */\n capabilities: RuntimeCapabilities;\n\n /**\n * The messages in the currently selected branch of the thread.\n */\n messages: readonly ThreadMessage[];\n\n /**\n * Follow up message suggestions to show the user.\n */\n suggestions: readonly ThreadSuggestion[];\n\n /**\n * Custom extra information provided by the runtime.\n */\n extras: unknown;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n speech: SpeechState | undefined;\n}>;\n\nexport const getThreadState = (runtime: ThreadRuntimeCore): ThreadState => {\n const lastMessage = runtime.messages.at(-1);\n return Object.freeze({\n threadId: runtime.metadata.threadId,\n metadata: runtime.metadata,\n capabilities: runtime.capabilities,\n isDisabled: runtime.isDisabled,\n isRunning:\n lastMessage?.role !== \"assistant\"\n ? false\n : lastMessage.status.type === \"running\",\n messages: runtime.messages,\n suggestions: runtime.suggestions,\n extras: runtime.extras,\n speech: runtime.speech,\n });\n};\n\nexport type ThreadRuntime = Readonly<{\n readonly path: ThreadRuntimePath;\n\n readonly composer: ThreadComposerRuntime;\n getState(): ThreadState;\n\n append(message: CreateAppendMessage): void;\n startRun(parentId: string | null): void;\n subscribe(callback: () => void): Unsubscribe;\n cancelRun(): void;\n getModelConfig(): ModelConfig;\n export(): ExportedMessageRepository;\n import(repository: ExportedMessageRepository): void;\n getMesssageByIndex(idx: number): MessageRuntime;\n getMesssageById(messageId: string): MessageRuntime;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n stopSpeaking: () => void;\n\n unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;\n}>;\n\nexport class ThreadRuntimeImpl implements ThreadRuntime {\n public get path() {\n return this._threadBinding.path;\n }\n\n public unstable_getCore() {\n return this._threadBinding.getState();\n }\n\n private _threadBinding: ThreadRuntimeCoreBinding & {\n getStateState(): ThreadState;\n };\n\n constructor(threadBinding: ThreadRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: threadBinding.path,\n getState: () => getThreadState(threadBinding.getState()),\n subscribe: (callback) => threadBinding.subscribe(callback),\n });\n\n this._threadBinding = {\n path: threadBinding.path,\n getState: () => threadBinding.getState(),\n getStateState: () => stateBinding.getState(),\n outerSubscribe: (callback) => threadBinding.outerSubscribe(callback),\n subscribe: (callback) => threadBinding.subscribe(callback),\n };\n\n this.composer = new ThreadComposerRuntimeImpl(\n new NestedSubscriptionSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.composer`,\n composerSource: \"thread\",\n },\n getState: () => this._threadBinding.getState().composer,\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n );\n }\n\n public readonly composer;\n\n public getState() {\n return this._threadBinding.getStateState();\n }\n\n public append(message: CreateAppendMessage) {\n this._threadBinding\n .getState()\n .append(\n toAppendMessage(this._threadBinding.getState().messages, message),\n );\n }\n\n public subscribe(callback: () => void) {\n return this._threadBinding.subscribe(callback);\n }\n\n public getModelConfig() {\n return this._threadBinding.getState().getModelConfig();\n }\n\n public startRun(parentId: string | null) {\n return this._threadBinding.getState().startRun(parentId);\n }\n\n public cancelRun() {\n this._threadBinding.getState().cancelRun();\n }\n\n public stopSpeaking() {\n return this._threadBinding.getState().stopSpeaking();\n }\n\n public getSubmittedFeedback(messageId: string) {\n return this._threadBinding.getState().getSubmittedFeedback(messageId);\n }\n\n public export() {\n return this._threadBinding.getState().export();\n }\n\n public import(data: ExportedMessageRepository) {\n this._threadBinding.getState().import(data);\n }\n\n public getMesssageByIndex(idx: number) {\n if (idx < 0) throw new Error(\"Message index must be >= 0\");\n\n return this._getMessageRuntime(\n {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.messages[${idx}]`,\n messageSelector: { type: \"index\", index: idx },\n },\n () => {\n const messages = this._threadBinding.getState().messages;\n const message = messages[idx];\n if (!message) return undefined;\n return {\n message,\n parentId: messages[idx - 1]?.id ?? null,\n };\n },\n );\n }\n\n public getMesssageById(messageId: string) {\n return this._getMessageRuntime(\n {\n ...this.path,\n ref:\n this.path.ref +\n `${this.path.ref}.messages[messageId=${JSON.stringify(messageId)}]`,\n messageSelector: { type: \"messageId\", messageId: messageId },\n },\n () => this._threadBinding.getState().getMessageById(messageId),\n );\n }\n\n private _getMessageRuntime(\n path: MessageRuntimePath,\n callback: () =>\n | { parentId: string | null; message: ThreadMessage }\n | undefined,\n ) {\n return new MessageRuntimeImpl(\n new ShallowMemoizeSubject({\n path,\n getState: () => {\n const { message, parentId } = callback() ?? {};\n\n const { messages, speech: speechState } =\n this._threadBinding.getState();\n\n if (!message || parentId === undefined) return SKIP_UPDATE;\n\n const thread = this._threadBinding.getState();\n\n const branches = thread.getBranches(message.id);\n const submittedFeedback = thread.getSubmittedFeedback(message.id);\n\n return {\n ...message,\n\n isLast: messages.at(-1)?.id === message.id,\n parentId,\n\n branchNumber: branches.indexOf(message.id) + 1,\n branchCount: branches.length,\n\n speech:\n speechState?.messageId === message.id ? speechState : undefined,\n\n submittedFeedback,\n } satisfies MessageState;\n },\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n this._threadBinding,\n );\n }\n\n private _eventListenerNestedSubscriptions = new Map<\n string,\n NestedSubscriptionSubject<Subscribable, ThreadRuntimePath>\n >();\n\n public unstable_on(\n event: ThreadRuntimeEventType,\n callback: () => void,\n ): Unsubscribe {\n let subject = this._eventListenerNestedSubscriptions.get(event);\n if (!subject) {\n subject = new NestedSubscriptionSubject({\n path: this.path,\n getState: () => ({\n subscribe: (callback) =>\n this._threadBinding.getState().unstable_on(event, callback),\n }),\n subscribe: (callback) => this._threadBinding.outerSubscribe(callback),\n });\n this._eventListenerNestedSubscriptions.set(event, subject);\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.ts"],"sourcesContent":["import {\n ThreadSuggestion,\n RuntimeCapabilities,\n ThreadRuntimeCore,\n SpeechState,\n ThreadRuntimeEventType,\n ThreadMetadata,\n} from \"../runtimes/core/ThreadRuntimeCore\";\nimport { ExportedMessageRepository } from \"../runtimes/utils/MessageRepository\";\nimport {\n AppendMessage,\n ModelConfig,\n ThreadMessage,\n Unsubscribe,\n} from \"../types\";\nimport {\n MessageRuntime,\n MessageRuntimeImpl,\n MessageState,\n} from \"./MessageRuntime\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport {\n Subscribable,\n SubscribableWithState,\n} from \"./subscribable/Subscribable\";\nimport {\n ThreadComposerRuntime,\n ThreadComposerRuntimeImpl,\n} from \"./ComposerRuntime\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { MessageRuntimePath, ThreadRuntimePath } from \"./RuntimePathTypes\";\n\nexport type CreateAppendMessage =\n | string\n | {\n parentId?: string | null | undefined;\n role?: AppendMessage[\"role\"] | undefined;\n content: AppendMessage[\"content\"];\n attachments?: AppendMessage[\"attachments\"] | undefined;\n startRun?: boolean | undefined;\n };\n\nconst toAppendMessage = (\n messages: readonly ThreadMessage[],\n message: CreateAppendMessage,\n): AppendMessage => {\n if (typeof message === \"string\") {\n return {\n parentId: messages.at(-1)?.id ?? null,\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n attachments: [],\n };\n }\n\n if (message.role && message.parentId && message.attachments) {\n return message as AppendMessage;\n }\n\n return {\n ...message,\n parentId: message.parentId ?? messages.at(-1)?.id ?? null,\n role: message.role ?? \"user\",\n attachments: message.attachments ?? [],\n } as AppendMessage;\n};\n\nexport type ThreadRuntimeCoreBinding = SubscribableWithState<\n ThreadRuntimeCore,\n ThreadRuntimePath\n> & {\n outerSubscribe(callback: () => void): Unsubscribe;\n};\n\nexport type ThreadState = {\n /**\n * The thread ID.\n * @deprecated This field is deprecated and will be removed in 0.8.0. Use `metadata.threadId` instead.\n */\n readonly threadId: string;\n\n /**\n * The thread metadata.\n */\n readonly metadata: ThreadMetadata;\n\n /**\n * Whether the thread is disabled. Disabled threads cannot receive new messages.\n */\n readonly isDisabled: boolean;\n\n /**\n * Whether the thread is running. A thread is considered running when there is an active stream connection to the backend.\n */\n readonly isRunning: boolean;\n\n /**\n * The capabilities of the thread, such as whether the thread supports editing, branch switching, etc.\n */\n readonly capabilities: RuntimeCapabilities;\n\n /**\n * The messages in the currently selected branch of the thread.\n */\n readonly messages: readonly ThreadMessage[];\n\n /**\n * Follow up message suggestions to show the user.\n */\n readonly suggestions: readonly ThreadSuggestion[];\n\n /**\n * Custom extra information provided by the runtime.\n */\n readonly extras: unknown;\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 const getThreadState = (runtime: ThreadRuntimeCore): ThreadState => {\n const lastMessage = runtime.messages.at(-1);\n return Object.freeze({\n threadId: runtime.metadata.threadId,\n metadata: runtime.metadata,\n capabilities: runtime.capabilities,\n isDisabled: runtime.isDisabled,\n isRunning:\n lastMessage?.role !== \"assistant\"\n ? false\n : lastMessage.status.type === \"running\",\n messages: runtime.messages,\n suggestions: runtime.suggestions,\n extras: runtime.extras,\n speech: runtime.speech,\n });\n};\n\nexport type ThreadRuntime = {\n /**\n * The selector for the thread runtime.\n */\n readonly path: ThreadRuntimePath;\n\n /**\n * The thread composer runtime.\n */\n readonly composer: ThreadComposerRuntime;\n\n /**\n * Gets a snapshot of the thread state.\n */\n getState(): ThreadState;\n\n /**\n * Append a new message to the thread.\n *\n * @example ```ts\n * // append a new user message with the text \"Hello, world!\"\n * threadRuntime.append(\"Hello, world!\");\n * ```\n *\n * @example ```ts\n * // append a new assistant message with the text \"Hello, world!\"\n * threadRuntime.append({\n * role: \"assistant\",\n * content: [{ type: \"text\", text: \"Hello, world!\" }],\n * });\n * ```\n */\n append(message: CreateAppendMessage): void;\n\n /**\n *\n * @param parentId\n */\n startRun(parentId: string | null): void;\n subscribe(callback: () => void): Unsubscribe;\n cancelRun(): void;\n getModelConfig(): ModelConfig;\n export(): ExportedMessageRepository;\n import(repository: ExportedMessageRepository): void;\n getMesssageByIndex(idx: number): MessageRuntime;\n getMesssageById(messageId: string): MessageRuntime;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n stopSpeaking: () => void;\n\n unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;\n};\n\nexport class ThreadRuntimeImpl implements ThreadRuntime {\n public get path() {\n return this._threadBinding.path;\n }\n\n public unstable_getCore() {\n return this._threadBinding.getState();\n }\n\n private _threadBinding: ThreadRuntimeCoreBinding & {\n getStateState(): ThreadState;\n };\n\n constructor(threadBinding: ThreadRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: threadBinding.path,\n getState: () => getThreadState(threadBinding.getState()),\n subscribe: (callback) => threadBinding.subscribe(callback),\n });\n\n this._threadBinding = {\n path: threadBinding.path,\n getState: () => threadBinding.getState(),\n getStateState: () => stateBinding.getState(),\n outerSubscribe: (callback) => threadBinding.outerSubscribe(callback),\n subscribe: (callback) => threadBinding.subscribe(callback),\n };\n\n this.composer = new ThreadComposerRuntimeImpl(\n new NestedSubscriptionSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.composer`,\n composerSource: \"thread\",\n },\n getState: () => this._threadBinding.getState().composer,\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n );\n }\n\n public readonly composer;\n\n public getState() {\n return this._threadBinding.getStateState();\n }\n\n public append(message: CreateAppendMessage) {\n this._threadBinding\n .getState()\n .append(\n toAppendMessage(this._threadBinding.getState().messages, message),\n );\n }\n\n public subscribe(callback: () => void) {\n return this._threadBinding.subscribe(callback);\n }\n\n public getModelConfig() {\n return this._threadBinding.getState().getModelConfig();\n }\n\n public startRun(parentId: string | null) {\n return this._threadBinding.getState().startRun(parentId);\n }\n\n public cancelRun() {\n this._threadBinding.getState().cancelRun();\n }\n\n public stopSpeaking() {\n return this._threadBinding.getState().stopSpeaking();\n }\n\n public getSubmittedFeedback(messageId: string) {\n return this._threadBinding.getState().getSubmittedFeedback(messageId);\n }\n\n public export() {\n return this._threadBinding.getState().export();\n }\n\n public import(data: ExportedMessageRepository) {\n this._threadBinding.getState().import(data);\n }\n\n public getMesssageByIndex(idx: number) {\n if (idx < 0) throw new Error(\"Message index must be >= 0\");\n\n return this._getMessageRuntime(\n {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.messages[${idx}]`,\n messageSelector: { type: \"index\", index: idx },\n },\n () => {\n const messages = this._threadBinding.getState().messages;\n const message = messages[idx];\n if (!message) return undefined;\n return {\n message,\n parentId: messages[idx - 1]?.id ?? null,\n };\n },\n );\n }\n\n public getMesssageById(messageId: string) {\n return this._getMessageRuntime(\n {\n ...this.path,\n ref:\n this.path.ref +\n `${this.path.ref}.messages[messageId=${JSON.stringify(messageId)}]`,\n messageSelector: { type: \"messageId\", messageId: messageId },\n },\n () => this._threadBinding.getState().getMessageById(messageId),\n );\n }\n\n private _getMessageRuntime(\n path: MessageRuntimePath,\n callback: () =>\n | { parentId: string | null; message: ThreadMessage }\n | undefined,\n ) {\n return new MessageRuntimeImpl(\n new ShallowMemoizeSubject({\n path,\n getState: () => {\n const { message, parentId } = callback() ?? {};\n\n const { messages, speech: speechState } =\n this._threadBinding.getState();\n\n if (!message || parentId === undefined) return SKIP_UPDATE;\n\n const thread = this._threadBinding.getState();\n\n const branches = thread.getBranches(message.id);\n const submittedFeedback = thread.getSubmittedFeedback(message.id);\n\n return {\n ...message,\n\n isLast: messages.at(-1)?.id === message.id,\n parentId,\n\n branchNumber: branches.indexOf(message.id) + 1,\n branchCount: branches.length,\n\n speech:\n speechState?.messageId === message.id ? speechState : undefined,\n\n submittedFeedback,\n } satisfies MessageState;\n },\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n this._threadBinding,\n );\n }\n\n private _eventListenerNestedSubscriptions = new Map<\n string,\n NestedSubscriptionSubject<Subscribable, ThreadRuntimePath>\n >();\n\n public unstable_on(\n event: ThreadRuntimeEventType,\n callback: () => void,\n ): Unsubscribe {\n let subject = this._eventListenerNestedSubscriptions.get(event);\n if (!subject) {\n subject = new NestedSubscriptionSubject({\n path: this.path,\n getState: () => ({\n subscribe: (callback) =>\n this._threadBinding.getState().unstable_on(event, callback),\n }),\n subscribe: (callback) => this._threadBinding.outerSubscribe(callback),\n });\n this._eventListenerNestedSubscriptions.set(event, subject);\n }\n return subject.subscribe(callback);\n }\n}\n"],"mappings":";AAeA;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AAKtC;AAAA,EAEE;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAa5B,IAAM,kBAAkB,CACtB,UACA,YACkB;AAClB,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,MACL,UAAU,SAAS,GAAG,EAAE,GAAG,MAAM;AAAA,MACjC,MAAM;AAAA,MACN,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,QAAQ,CAAC;AAAA,MACzC,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AAEA,MAAI,QAAQ,QAAQ,QAAQ,YAAY,QAAQ,aAAa;AAC3D,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,UAAU,QAAQ,YAAY,SAAS,GAAG,EAAE,GAAG,MAAM;AAAA,IACrD,MAAM,QAAQ,QAAQ;AAAA,IACtB,aAAa,QAAQ,eAAe,CAAC;AAAA,EACvC;AACF;AAyDO,IAAM,iBAAiB,CAAC,YAA4C;AACzE,QAAM,cAAc,QAAQ,SAAS,GAAG,EAAE;AAC1C,SAAO,OAAO,OAAO;AAAA,IACnB,UAAU,QAAQ,SAAS;AAAA,IAC3B,UAAU,QAAQ;AAA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,gBAAU,IAAI,0BAA0B;AAAA,QACtC,MAAM,KAAK;AAAA,QACX,UAAU,OAAO;AAAA,UACf,WAAW,CAACA,cACV,KAAK,eAAe,SAAS,EAAE,YAAY,OAAOA,SAAQ;AAAA,QAC9D;AAAA,QACA,WAAW,CAACA,cAAa,KAAK,eAAe,eAAeA,SAAQ;AAAA,MACtE,CAAC;AACD,WAAK,kCAAkC,IAAI,OAAO,OAAO;AAAA,IAC3D;AACA,WAAO,QAAQ,UAAU,QAAQ;AAAA,EACnC;AACF;","names":["callback"]}
|
package/dist/api/index.d.ts
CHANGED
@@ -5,4 +5,5 @@ export type { ContentPartRuntime, ContentPartState, } from "./ContentPartRuntime
|
|
5
5
|
export type { ComposerRuntime, ThreadComposerRuntime, EditComposerRuntime, EditComposerState, ThreadComposerState, ComposerState, } from "./ComposerRuntime";
|
6
6
|
export type { AttachmentRuntime, AttachmentState } from "./AttachmentRuntime";
|
7
7
|
export type { ThreadListRuntime, ThreadListState } from "./ThreadListRuntime";
|
8
|
+
export type { ThreadListItemRuntime, ThreadListItemState, } from "./ThreadListItemRuntime";
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/api/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrE,YAAY,EACV,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrE,YAAY,EACV,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,YAAY,EACV,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC"}
|
package/dist/api/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/api/index.ts"],"sourcesContent":["export type { AssistantRuntime } from \"./AssistantRuntime\";\nexport type { ThreadRuntime, ThreadState } from \"./ThreadRuntime\";\nexport type { MessageRuntime, MessageState } from \"./MessageRuntime\";\nexport type {\n ContentPartRuntime,\n ContentPartState,\n} from \"./ContentPartRuntime\";\nexport type {\n ComposerRuntime,\n ThreadComposerRuntime,\n EditComposerRuntime,\n EditComposerState,\n ThreadComposerState,\n ComposerState,\n} from \"./ComposerRuntime\";\nexport type { AttachmentRuntime, AttachmentState } from \"./AttachmentRuntime\";\nexport type { ThreadListRuntime, ThreadListState } from \"./ThreadListRuntime\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
1
|
+
{"version":3,"sources":["../../src/api/index.ts"],"sourcesContent":["export type { AssistantRuntime } from \"./AssistantRuntime\";\nexport type { ThreadRuntime, ThreadState } from \"./ThreadRuntime\";\nexport type { MessageRuntime, MessageState } from \"./MessageRuntime\";\nexport type {\n ContentPartRuntime,\n ContentPartState,\n} from \"./ContentPartRuntime\";\nexport type {\n ComposerRuntime,\n ThreadComposerRuntime,\n EditComposerRuntime,\n EditComposerState,\n ThreadComposerState,\n ComposerState,\n} from \"./ComposerRuntime\";\nexport type { AttachmentRuntime, AttachmentState } from \"./AttachmentRuntime\";\nexport type { ThreadListRuntime, ThreadListState } from \"./ThreadListRuntime\";\nexport type {\n ThreadListItemRuntime,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
@@ -5,6 +5,6 @@ export declare namespace ThreadListItemRuntimeProvider {
|
|
5
5
|
runtime: ThreadListItemRuntime;
|
6
6
|
}>;
|
7
7
|
}
|
8
|
-
export declare const useThreadListItemStore: (runtime: ThreadListItemRuntime) => import("zustand").UseBoundStore<import("zustand").StoreApi<import("
|
8
|
+
export declare const useThreadListItemStore: (runtime: ThreadListItemRuntime) => import("zustand").UseBoundStore<import("zustand").StoreApi<import("../..").ThreadListItemState>>;
|
9
9
|
export declare const ThreadListItemRuntimeProvider: FC<ThreadListItemRuntimeProvider.Props>;
|
10
10
|
//# sourceMappingURL=ThreadListItemRuntimeProvider.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ThreadListItemRuntimeProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/ThreadListItemRuntimeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAO7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,yBAAiB,6BAA6B,CAAC;IAC7C,KAAY,KAAK,GAAG,iBAAiB,CAAC;QACpC,OAAO,EAAE,qBAAqB,CAAC;KAChC,CAAC,CAAC;CACJ;AAYD,eAAO,MAAM,sBAAsB,YAAa,qBAAqB
|
1
|
+
{"version":3,"file":"ThreadListItemRuntimeProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/ThreadListItemRuntimeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAO7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,yBAAiB,6BAA6B,CAAC;IAC7C,KAAY,KAAK,GAAG,iBAAiB,CAAC;QACpC,OAAO,EAAE,qBAAqB,CAAC;KAChC,CAAC,CAAC;CACJ;AAYD,eAAO,MAAM,sBAAsB,YAAa,qBAAqB,qGAUpE,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,EAAE,CAC5C,6BAA6B,CAAC,KAAK,CAapC,CAAC"}
|
@@ -24,68 +24,30 @@ export declare function useAssistantRuntime(options?: {
|
|
24
24
|
optional?: boolean | undefined;
|
25
25
|
}): AssistantRuntime | null;
|
26
26
|
export declare const useToolUIs: {
|
27
|
-
():
|
28
|
-
|
29
|
-
setToolUI: (toolName: string, render: import("../..").ToolCallContentPartComponent) => import("../..").Unsubscribe;
|
30
|
-
}>;
|
31
|
-
<TSelected>(selector: (state: Readonly<{
|
32
|
-
getToolUI: (toolName: string) => import("../..").ToolCallContentPartComponent | null;
|
33
|
-
setToolUI: (toolName: string, render: import("../..").ToolCallContentPartComponent) => import("../..").Unsubscribe;
|
34
|
-
}>) => TSelected): TSelected;
|
27
|
+
(): AssistantToolUIsState;
|
28
|
+
<TSelected>(selector: (state: AssistantToolUIsState) => TSelected): TSelected;
|
35
29
|
(options: {
|
36
30
|
optional: true;
|
37
|
-
}):
|
38
|
-
getToolUI: (toolName: string) => import("../..").ToolCallContentPartComponent | null;
|
39
|
-
setToolUI: (toolName: string, render: import("../..").ToolCallContentPartComponent) => import("../..").Unsubscribe;
|
40
|
-
}> | null;
|
31
|
+
}): AssistantToolUIsState | null;
|
41
32
|
<TSelected>(options: {
|
42
33
|
optional: true;
|
43
|
-
selector?: (state:
|
44
|
-
getToolUI: (toolName: string) => import("../..").ToolCallContentPartComponent | null;
|
45
|
-
setToolUI: (toolName: string, render: import("../..").ToolCallContentPartComponent) => import("../..").Unsubscribe;
|
46
|
-
}>) => TSelected;
|
34
|
+
selector?: (state: AssistantToolUIsState) => TSelected;
|
47
35
|
}): TSelected | null;
|
48
36
|
}, useToolUIsStore: {
|
49
|
-
(): ReadonlyStore<
|
50
|
-
getToolUI: (toolName: string) => import("../..").ToolCallContentPartComponent | null;
|
51
|
-
setToolUI: (toolName: string, render: import("../..").ToolCallContentPartComponent) => import("../..").Unsubscribe;
|
52
|
-
}>>;
|
37
|
+
(): ReadonlyStore<AssistantToolUIsState>;
|
53
38
|
(options: {
|
54
39
|
optional: true;
|
55
|
-
}): ReadonlyStore<
|
56
|
-
getToolUI: (toolName: string) => import("../..").ToolCallContentPartComponent | null;
|
57
|
-
setToolUI: (toolName: string, render: import("../..").ToolCallContentPartComponent) => import("../..").Unsubscribe;
|
58
|
-
}>> | null;
|
40
|
+
}): ReadonlyStore<AssistantToolUIsState> | null;
|
59
41
|
};
|
60
42
|
export declare const useThreadList: {
|
61
|
-
():
|
62
|
-
|
63
|
-
newThread: string | undefined;
|
64
|
-
threads: readonly string[];
|
65
|
-
archivedThreads: readonly string[];
|
66
|
-
}>;
|
67
|
-
<TSelected>(selector: (state: Readonly<{
|
68
|
-
mainThreadId: string;
|
69
|
-
newThread: string | undefined;
|
70
|
-
threads: readonly string[];
|
71
|
-
archivedThreads: readonly string[];
|
72
|
-
}>) => TSelected): TSelected;
|
43
|
+
(): ThreadListState;
|
44
|
+
<TSelected>(selector: (state: ThreadListState) => TSelected): TSelected;
|
73
45
|
(options: {
|
74
46
|
optional: true;
|
75
|
-
}):
|
76
|
-
mainThreadId: string;
|
77
|
-
newThread: string | undefined;
|
78
|
-
threads: readonly string[];
|
79
|
-
archivedThreads: readonly string[];
|
80
|
-
}> | null;
|
47
|
+
}): ThreadListState | null;
|
81
48
|
<TSelected>(options: {
|
82
49
|
optional: true;
|
83
|
-
selector?: (state:
|
84
|
-
mainThreadId: string;
|
85
|
-
newThread: string | undefined;
|
86
|
-
threads: readonly string[];
|
87
|
-
archivedThreads: readonly string[];
|
88
|
-
}>) => TSelected;
|
50
|
+
selector?: (state: ThreadListState) => TSelected;
|
89
51
|
}): TSelected | null;
|
90
52
|
};
|
91
53
|
//# sourceMappingURL=AssistantContext.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AssistantContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/AssistantContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,aAAa,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAChE,mBAAmB,EAAE,aAAa,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACpE,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;CAC9D,CAAC;AAEF,eAAO,MAAM,gBAAgB,uDAE5B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;CAG/B,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;C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Aa;;;;;;;;;;CAG3B,CAAC"}
|
@@ -60,7 +60,7 @@ export declare const useThreadComposerAttachment: {
|
|
60
60
|
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
61
61
|
file: File;
|
62
62
|
} & {
|
63
|
-
source: "thread-composer";
|
63
|
+
readonly source: "thread-composer";
|
64
64
|
} & {
|
65
65
|
source: "thread-composer";
|
66
66
|
};
|
@@ -75,7 +75,7 @@ export declare const useThreadComposerAttachment: {
|
|
75
75
|
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
76
76
|
file: File;
|
77
77
|
} & {
|
78
|
-
source: "thread-composer";
|
78
|
+
readonly source: "thread-composer";
|
79
79
|
} & {
|
80
80
|
source: "thread-composer";
|
81
81
|
}) => TSelected): TSelected;
|
@@ -92,7 +92,7 @@ export declare const useThreadComposerAttachment: {
|
|
92
92
|
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
93
93
|
file: File;
|
94
94
|
} & {
|
95
|
-
source: "thread-composer";
|
95
|
+
readonly source: "thread-composer";
|
96
96
|
} & {
|
97
97
|
source: "thread-composer";
|
98
98
|
}) | null;
|
@@ -109,7 +109,7 @@ export declare const useThreadComposerAttachment: {
|
|
109
109
|
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
110
110
|
file: File;
|
111
111
|
} & {
|
112
|
-
source: "thread-composer";
|
112
|
+
readonly source: "thread-composer";
|
113
113
|
} & {
|
114
114
|
source: "thread-composer";
|
115
115
|
}) => TSelected;
|
@@ -127,7 +127,7 @@ export declare const useEditComposerAttachment: {
|
|
127
127
|
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
128
128
|
file: File;
|
129
129
|
} & {
|
130
|
-
source: "edit-composer";
|
130
|
+
readonly source: "edit-composer";
|
131
131
|
} & {
|
132
132
|
source: "edit-composer";
|
133
133
|
}) | ({
|
@@ -141,7 +141,7 @@ export declare const useEditComposerAttachment: {
|
|
141
141
|
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
142
142
|
content: import("../..").CoreUserContentPart[];
|
143
143
|
} & {
|
144
|
-
source: "edit-composer";
|
144
|
+
readonly source: "edit-composer";
|
145
145
|
} & {
|
146
146
|
source: "edit-composer";
|
147
147
|
});
|
@@ -156,7 +156,7 @@ export declare const useEditComposerAttachment: {
|
|
156
156
|
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
157
157
|
file: File;
|
158
158
|
} & {
|
159
|
-
source: "edit-composer";
|
159
|
+
readonly source: "edit-composer";
|
160
160
|
} & {
|
161
161
|
source: "edit-composer";
|
162
162
|
}) | ({
|
@@ -170,7 +170,7 @@ export declare const useEditComposerAttachment: {
|
|
170
170
|
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
171
171
|
content: import("../..").CoreUserContentPart[];
|
172
172
|
} & {
|
173
|
-
source: "edit-composer";
|
173
|
+
readonly source: "edit-composer";
|
174
174
|
} & {
|
175
175
|
source: "edit-composer";
|
176
176
|
})) => TSelected): TSelected;
|
@@ -187,7 +187,7 @@ export declare const useEditComposerAttachment: {
|
|
187
187
|
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
188
188
|
file: File;
|
189
189
|
} & {
|
190
|
-
source: "edit-composer";
|
190
|
+
readonly source: "edit-composer";
|
191
191
|
} & {
|
192
192
|
source: "edit-composer";
|
193
193
|
}) | ({
|
@@ -201,7 +201,7 @@ export declare const useEditComposerAttachment: {
|
|
201
201
|
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
202
202
|
content: import("../..").CoreUserContentPart[];
|
203
203
|
} & {
|
204
|
-
source: "edit-composer";
|
204
|
+
readonly source: "edit-composer";
|
205
205
|
} & {
|
206
206
|
source: "edit-composer";
|
207
207
|
}) | null;
|
@@ -218,7 +218,7 @@ export declare const useEditComposerAttachment: {
|
|
218
218
|
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
219
219
|
file: File;
|
220
220
|
} & {
|
221
|
-
source: "edit-composer";
|
221
|
+
readonly source: "edit-composer";
|
222
222
|
} & {
|
223
223
|
source: "edit-composer";
|
224
224
|
}) | ({
|
@@ -232,7 +232,7 @@ export declare const useEditComposerAttachment: {
|
|
232
232
|
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
233
233
|
content: import("../..").CoreUserContentPart[];
|
234
234
|
} & {
|
235
|
-
source: "edit-composer";
|
235
|
+
readonly source: "edit-composer";
|
236
236
|
} & {
|
237
237
|
source: "edit-composer";
|
238
238
|
})) => TSelected;
|
@@ -250,7 +250,7 @@ export declare const useMessageAttachment: {
|
|
250
250
|
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
251
251
|
content: import("../..").CoreUserContentPart[];
|
252
252
|
} & {
|
253
|
-
source: "message";
|
253
|
+
readonly source: "message";
|
254
254
|
} & {
|
255
255
|
source: "message";
|
256
256
|
};
|
@@ -265,7 +265,7 @@ export declare const useMessageAttachment: {
|
|
265
265
|
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
266
266
|
content: import("../..").CoreUserContentPart[];
|
267
267
|
} & {
|
268
|
-
source: "message";
|
268
|
+
readonly source: "message";
|
269
269
|
} & {
|
270
270
|
source: "message";
|
271
271
|
}) => TSelected): TSelected;
|
@@ -282,7 +282,7 @@ export declare const useMessageAttachment: {
|
|
282
282
|
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
283
283
|
content: import("../..").CoreUserContentPart[];
|
284
284
|
} & {
|
285
|
-
source: "message";
|
285
|
+
readonly source: "message";
|
286
286
|
} & {
|
287
287
|
source: "message";
|
288
288
|
}) | null;
|
@@ -299,7 +299,7 @@ export declare const useMessageAttachment: {
|
|
299
299
|
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
300
300
|
content: import("../..").CoreUserContentPart[];
|
301
301
|
} & {
|
302
|
-
source: "message";
|
302
|
+
readonly source: "message";
|
303
303
|
} & {
|
304
304
|
source: "message";
|
305
305
|
}) => TSelected;
|
@@ -37,50 +37,20 @@ export declare const useMessage: {
|
|
37
37
|
}): TSelected | null;
|
38
38
|
};
|
39
39
|
export declare const useMessageUtils: {
|
40
|
-
():
|
41
|
-
|
42
|
-
setIsCopied: (value: boolean) => void;
|
43
|
-
isHovering: boolean;
|
44
|
-
setIsHovering: (value: boolean) => void;
|
45
|
-
}>;
|
46
|
-
<TSelected>(selector: (state: Readonly<{
|
47
|
-
isCopied: boolean;
|
48
|
-
setIsCopied: (value: boolean) => void;
|
49
|
-
isHovering: boolean;
|
50
|
-
setIsHovering: (value: boolean) => void;
|
51
|
-
}>) => TSelected): TSelected;
|
40
|
+
(): MessageUtilsState;
|
41
|
+
<TSelected>(selector: (state: MessageUtilsState) => TSelected): TSelected;
|
52
42
|
(options: {
|
53
43
|
optional: true;
|
54
|
-
}):
|
55
|
-
isCopied: boolean;
|
56
|
-
setIsCopied: (value: boolean) => void;
|
57
|
-
isHovering: boolean;
|
58
|
-
setIsHovering: (value: boolean) => void;
|
59
|
-
}> | null;
|
44
|
+
}): MessageUtilsState | null;
|
60
45
|
<TSelected>(options: {
|
61
46
|
optional: true;
|
62
|
-
selector?: (state:
|
63
|
-
isCopied: boolean;
|
64
|
-
setIsCopied: (value: boolean) => void;
|
65
|
-
isHovering: boolean;
|
66
|
-
setIsHovering: (value: boolean) => void;
|
67
|
-
}>) => TSelected;
|
47
|
+
selector?: (state: MessageUtilsState) => TSelected;
|
68
48
|
}): TSelected | null;
|
69
49
|
}, useMessageUtilsStore: {
|
70
|
-
(): ReadonlyStore<
|
71
|
-
isCopied: boolean;
|
72
|
-
setIsCopied: (value: boolean) => void;
|
73
|
-
isHovering: boolean;
|
74
|
-
setIsHovering: (value: boolean) => void;
|
75
|
-
}>>;
|
50
|
+
(): ReadonlyStore<MessageUtilsState>;
|
76
51
|
(options: {
|
77
52
|
optional: true;
|
78
|
-
}): ReadonlyStore<
|
79
|
-
isCopied: boolean;
|
80
|
-
setIsCopied: (value: boolean) => void;
|
81
|
-
isHovering: boolean;
|
82
|
-
setIsHovering: (value: boolean) => void;
|
83
|
-
}>> | null;
|
53
|
+
}): ReadonlyStore<MessageUtilsState> | null;
|
84
54
|
};
|
85
55
|
export declare const useEditComposer: {
|
86
56
|
(): EditComposerState;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MessageContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/MessageContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAAG;IAChC,iBAAiB,EAAE,aAAa,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC;IAChE,UAAU,EAAE,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;IACvD,eAAe,EAAE,aAAa,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACjE,eAAe,EAAE,aAAa,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC;CAClE,CAAC;AAEF,eAAO,MAAM,cAAc,qDAAkD,CAAC;AAE9E,eAAO,MAAM,iBAAiB;;;;;;;CAG7B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE;IAC1C,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC9B,GAAG,cAAc,CAAC;AACnB,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE;IAC1C,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,cAAc,GAAG,IAAI,CAAC;AAS1B,eAAO,MAAQ,UAAU;;;;;;;;;;C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