@assistant-ui/react 0.10.28 → 0.10.30
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/api/AttachmentRuntime.d.ts +1 -1
- package/dist/api/AttachmentRuntime.d.ts.map +1 -1
- package/dist/api/AttachmentRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.d.ts +3 -10
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/MessagePartRuntime.d.ts +1 -1
- package/dist/api/MessagePartRuntime.d.ts.map +1 -1
- package/dist/api/MessagePartRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.d.ts +10 -4
- package/dist/api/MessageRuntime.d.ts.map +1 -1
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/RuntimeBindings.d.ts +38 -0
- package/dist/api/RuntimeBindings.d.ts.map +1 -0
- package/dist/api/RuntimeBindings.js +1 -0
- package/dist/api/RuntimeBindings.js.map +1 -0
- package/dist/api/ThreadListItemRuntime.d.ts +2 -12
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +1 -1
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/context/react/AttachmentContext.d.ts +48 -48
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +2 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/types/AssistantTypes.d.ts +4 -50
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AttachmentTypes.d.ts +1 -1
- package/dist/types/AttachmentTypes.d.ts.map +1 -1
- package/dist/types/MessagePartTypes.d.ts +49 -0
- package/dist/types/MessagePartTypes.d.ts.map +1 -0
- package/dist/types/MessagePartTypes.js +1 -0
- package/dist/types/MessagePartTypes.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/AttachmentRuntime.ts +1 -1
- package/src/api/ComposerRuntime.ts +12 -16
- package/src/api/MessagePartRuntime.ts +1 -1
- package/src/api/MessageRuntime.ts +2 -5
- package/src/api/RuntimeBindings.ts +70 -0
- package/src/api/ThreadListItemRuntime.ts +5 -14
- package/src/api/ThreadRuntime.ts +1 -1
- package/src/runtimes/core/ThreadListRuntimeCore.tsx +2 -1
- package/src/runtimes/external-store/ExternalStoreRuntimeCore.tsx +1 -1
- package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +1 -0
- package/src/types/AssistantTypes.ts +27 -70
- package/src/types/AttachmentTypes.ts +1 -1
- package/src/types/MessagePartTypes.ts +69 -0
- package/src/types/index.ts +3 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/api/ThreadRuntime.ts"],"sourcesContent":["import {\n ThreadSuggestion,\n RuntimeCapabilities,\n ThreadRuntimeCore,\n SpeechState,\n ThreadRuntimeEventType,\n StartRunConfig,\n ResumeRunConfig,\n} from \"../runtimes/core/ThreadRuntimeCore\";\nimport { ExportedMessageRepository } from \"../runtimes/utils/MessageRepository\";\nimport { AppendMessage, ThreadMessage, Unsubscribe } from \"../types\";\nimport { ThreadMessageLike } from \"../runtimes/external-store\";\nimport {\n MessageRuntime,\n MessageRuntimeImpl,\n MessageState,\n} from \"./MessageRuntime\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport {\n ThreadComposerRuntime,\n ThreadComposerRuntimeImpl,\n} from \"./ComposerRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport {\n MessageRuntimePath,\n ThreadListItemRuntimePath,\n ThreadRuntimePath,\n} from \"./RuntimePathTypes\";\nimport { ThreadListItemState } from \"./ThreadListItemRuntime\";\nimport { RunConfig } from \"../types/AssistantTypes\";\nimport { EventSubscriptionSubject } from \"./subscribable/EventSubscriptionSubject\";\nimport { symbolInnerMessage } from \"../runtimes/external-store/getExternalStoreMessage\";\nimport { ModelContext } from \"../model-context\";\nimport { ChatModelRunOptions, ChatModelRunResult } from \"../runtimes\";\nimport { ReadonlyJSONValue } from \"assistant-stream/utils\";\n\nexport type CreateStartRunConfig = {\n parentId: string | null;\n sourceId?: string | null | undefined;\n runConfig?: RunConfig | undefined;\n};\n\nexport type CreateResumeRunConfig = CreateStartRunConfig & {\n stream: (\n options: ChatModelRunOptions,\n ) => AsyncGenerator<ChatModelRunResult, void, unknown>;\n};\n\nconst toResumeRunConfig = (message: CreateResumeRunConfig): ResumeRunConfig => {\n return {\n parentId: message.parentId ?? null,\n sourceId: message.sourceId ?? null,\n runConfig: message.runConfig ?? {},\n stream: message.stream,\n };\n};\n\nconst toStartRunConfig = (message: CreateStartRunConfig): StartRunConfig => {\n return {\n parentId: message.parentId ?? null,\n sourceId: message.sourceId ?? null,\n runConfig: message.runConfig ?? {},\n };\n};\n\nexport type CreateAppendMessage =\n | string\n | {\n parentId?: string | null | undefined;\n sourceId?: string | null | undefined;\n role?: AppendMessage[\"role\"] | undefined;\n content: AppendMessage[\"content\"];\n attachments?: AppendMessage[\"attachments\"] | undefined;\n metadata?: AppendMessage[\"metadata\"] | undefined;\n createdAt?: Date | undefined;\n runConfig?: AppendMessage[\"runConfig\"] | 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 createdAt: new Date(),\n parentId: messages.at(-1)?.id ?? null,\n sourceId: null,\n runConfig: {},\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n attachments: [],\n metadata: { custom: {} },\n };\n }\n\n return {\n createdAt: message.createdAt ?? new Date(),\n parentId: message.parentId ?? messages.at(-1)?.id ?? null,\n sourceId: message.sourceId ?? null,\n role: message.role ?? \"user\",\n content: message.content,\n attachments: message.attachments ?? [],\n metadata: message.metadata ?? { custom: {} },\n runConfig: message.runConfig ?? {},\n startRun: message.startRun,\n } as AppendMessage;\n};\n\nexport type ThreadRuntimeCoreBinding = SubscribableWithState<\n ThreadRuntimeCore,\n ThreadRuntimePath\n> & {\n outerSubscribe(callback: () => void): Unsubscribe;\n};\n\nexport type ThreadListItemRuntimeBinding = SubscribableWithState<\n ThreadListItemState,\n ThreadListItemRuntimePath\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 `useThreadListItem().id` instead.\n */\n readonly threadId: string;\n\n /**\n * The thread metadata.\n *\n * @deprecated Use `useThreadListItem()` instead. This field is deprecated and will be removed in 0.8.0.\n */\n readonly metadata: ThreadListItemState;\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 loading its history.\n */\n readonly isLoading: 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 * The thread state.\n *\n * @deprecated This feature is experimental\n */\n readonly state: ReadonlyJSONValue;\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 = (\n runtime: ThreadRuntimeCore,\n threadListItemState: ThreadListItemState,\n): ThreadState => {\n const lastMessage = runtime.messages.at(-1);\n return Object.freeze({\n threadId: threadListItemState.id,\n metadata: threadListItemState,\n capabilities: runtime.capabilities,\n isDisabled: runtime.isDisabled,\n isLoading: runtime.isLoading,\n isRunning:\n lastMessage?.role !== \"assistant\"\n ? false\n : lastMessage.status.type === \"running\",\n messages: runtime.messages,\n state: runtime.state,\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 * @deprecated pass an object with `parentId` instead. This will be removed in 0.8.0.\n */\n startRun(parentId: string | null): void;\n /**\n * Start a new run with the given configuration.\n * @param config The configuration for starting the run\n */\n startRun(config: CreateStartRunConfig): void;\n\n /**\n * Resume a run with the given configuration.\n * @param config The configuration for resuming the run\n **/\n unstable_resumeRun(config: CreateResumeRunConfig): void;\n\n subscribe(callback: () => void): Unsubscribe;\n cancelRun(): void;\n getModelContext(): ModelContext;\n\n /**\n * @deprecated This method was renamed to `getModelContext`.\n */\n getModelConfig(): ModelContext;\n\n export(): ExportedMessageRepository;\n import(repository: ExportedMessageRepository): void;\n\n /**\n * Reset the thread with optional initial messages.\n *\n * @param initialMessages - Optional array of initial messages to populate the thread\n */\n reset(initialMessages?: readonly ThreadMessageLike[]): void;\n\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 get __internal_threadBinding() {\n return this._threadBinding;\n }\n\n private readonly _threadBinding: ThreadRuntimeCoreBinding & {\n getStateState(): ThreadState;\n };\n\n constructor(\n threadBinding: ThreadRuntimeCoreBinding,\n threadListItemBinding: ThreadListItemRuntimeBinding,\n ) {\n const stateBinding = new ShallowMemoizeSubject({\n path: threadBinding.path,\n getState: () =>\n getThreadState(\n threadBinding.getState(),\n threadListItemBinding.getState(),\n ),\n subscribe: (callback) => {\n const sub1 = threadBinding.subscribe(callback);\n const sub2 = threadListItemBinding.subscribe(callback);\n return () => {\n sub1();\n sub2();\n };\n },\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 protected __internal_bindMethods() {\n this.append = this.append.bind(this);\n this.unstable_resumeRun = this.unstable_resumeRun.bind(this);\n this.startRun = this.startRun.bind(this);\n this.cancelRun = this.cancelRun.bind(this);\n this.stopSpeaking = this.stopSpeaking.bind(this);\n this.export = this.export.bind(this);\n this.import = this.import.bind(this);\n this.reset = this.reset.bind(this);\n this.getMesssageByIndex = this.getMesssageByIndex.bind(this);\n this.getMesssageById = this.getMesssageById.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.unstable_on = this.unstable_on.bind(this);\n this.getModelContext = this.getModelContext.bind(this);\n this.getModelConfig = this.getModelConfig.bind(this);\n this.getState = this.getState.bind(this);\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 getModelContext() {\n return this._threadBinding.getState().getModelContext();\n }\n\n public getModelConfig() {\n return this.getModelContext();\n }\n\n public startRun(configOrParentId: string | null | CreateStartRunConfig) {\n const config =\n configOrParentId === null || typeof configOrParentId === \"string\"\n ? { parentId: configOrParentId }\n : configOrParentId;\n return this._threadBinding.getState().startRun(toStartRunConfig(config));\n }\n\n public unstable_resumeRun(config: CreateResumeRunConfig) {\n return this._threadBinding.getState().resumeRun(toResumeRunConfig(config));\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 export() {\n return this._threadBinding.getState().export();\n }\n\n public import(data: ExportedMessageRepository) {\n this._threadBinding.getState().import(data);\n }\n\n public reset(initialMessages?: readonly ThreadMessageLike[]) {\n this._threadBinding.getState().reset(initialMessages);\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 ...{ [symbolInnerMessage]: (message as any)[symbolInnerMessage] },\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 _eventSubscriptionSubjects = new Map<\n string,\n EventSubscriptionSubject<ThreadRuntimeEventType>\n >();\n\n public unstable_on(\n event: ThreadRuntimeEventType,\n callback: () => void,\n ): Unsubscribe {\n let subject = this._eventSubscriptionSubjects.get(event);\n if (!subject) {\n subject = new EventSubscriptionSubject({\n event: event,\n binding: this._threadBinding,\n });\n this._eventSubscriptionSubjects.set(event, subject);\n }\n return subject.subscribe(callback);\n }\n}\n"],"mappings":";AAYA;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AAEtC;AAAA,EAEE;AAAA,O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ACa;AACb,QAAI,UAAU,KAAK,2BAA2B,IAAI,KAAK;AACvD,QAAI,CAAC,SAAS;AACZ,gBAAU,IAAI,yBAAyB;AAAA,QACrC;AAAA,QACA,SAAS,KAAK;AAAA,MAChB,CAAC;AACD,WAAK,2BAA2B,IAAI,OAAO,OAAO;AAAA,IACpD;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 StartRunConfig,\n ResumeRunConfig,\n} from \"../runtimes/core/ThreadRuntimeCore\";\nimport { ExportedMessageRepository } from \"../runtimes/utils/MessageRepository\";\nimport { AppendMessage, ThreadMessage, Unsubscribe } from \"../types\";\nimport { ThreadMessageLike } from \"../runtimes/external-store\";\nimport {\n MessageRuntime,\n MessageRuntimeImpl,\n MessageState,\n} from \"./MessageRuntime\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport {\n ThreadComposerRuntime,\n ThreadComposerRuntimeImpl,\n} from \"./ComposerRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport {\n MessageRuntimePath,\n ThreadListItemRuntimePath,\n ThreadRuntimePath,\n} from \"./RuntimePathTypes\";\nimport type { ThreadListItemState } from \"./RuntimeBindings\";\nimport { RunConfig } from \"../types/AssistantTypes\";\nimport { EventSubscriptionSubject } from \"./subscribable/EventSubscriptionSubject\";\nimport { symbolInnerMessage } from \"../runtimes/external-store/getExternalStoreMessage\";\nimport { ModelContext } from \"../model-context\";\nimport { ChatModelRunOptions, ChatModelRunResult } from \"../runtimes\";\nimport { ReadonlyJSONValue } from \"assistant-stream/utils\";\n\nexport type CreateStartRunConfig = {\n parentId: string | null;\n sourceId?: string | null | undefined;\n runConfig?: RunConfig | undefined;\n};\n\nexport type CreateResumeRunConfig = CreateStartRunConfig & {\n stream: (\n options: ChatModelRunOptions,\n ) => AsyncGenerator<ChatModelRunResult, void, unknown>;\n};\n\nconst toResumeRunConfig = (message: CreateResumeRunConfig): ResumeRunConfig => {\n return {\n parentId: message.parentId ?? null,\n sourceId: message.sourceId ?? null,\n runConfig: message.runConfig ?? {},\n stream: message.stream,\n };\n};\n\nconst toStartRunConfig = (message: CreateStartRunConfig): StartRunConfig => {\n return {\n parentId: message.parentId ?? null,\n sourceId: message.sourceId ?? null,\n runConfig: message.runConfig ?? {},\n };\n};\n\nexport type CreateAppendMessage =\n | string\n | {\n parentId?: string | null | undefined;\n sourceId?: string | null | undefined;\n role?: AppendMessage[\"role\"] | undefined;\n content: AppendMessage[\"content\"];\n attachments?: AppendMessage[\"attachments\"] | undefined;\n metadata?: AppendMessage[\"metadata\"] | undefined;\n createdAt?: Date | undefined;\n runConfig?: AppendMessage[\"runConfig\"] | 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 createdAt: new Date(),\n parentId: messages.at(-1)?.id ?? null,\n sourceId: null,\n runConfig: {},\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n attachments: [],\n metadata: { custom: {} },\n };\n }\n\n return {\n createdAt: message.createdAt ?? new Date(),\n parentId: message.parentId ?? messages.at(-1)?.id ?? null,\n sourceId: message.sourceId ?? null,\n role: message.role ?? \"user\",\n content: message.content,\n attachments: message.attachments ?? [],\n metadata: message.metadata ?? { custom: {} },\n runConfig: message.runConfig ?? {},\n startRun: message.startRun,\n } as AppendMessage;\n};\n\nexport type ThreadRuntimeCoreBinding = SubscribableWithState<\n ThreadRuntimeCore,\n ThreadRuntimePath\n> & {\n outerSubscribe(callback: () => void): Unsubscribe;\n};\n\nexport type ThreadListItemRuntimeBinding = SubscribableWithState<\n ThreadListItemState,\n ThreadListItemRuntimePath\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 `useThreadListItem().id` instead.\n */\n readonly threadId: string;\n\n /**\n * The thread metadata.\n *\n * @deprecated Use `useThreadListItem()` instead. This field is deprecated and will be removed in 0.8.0.\n */\n readonly metadata: ThreadListItemState;\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 loading its history.\n */\n readonly isLoading: 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 * The thread state.\n *\n * @deprecated This feature is experimental\n */\n readonly state: ReadonlyJSONValue;\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 = (\n runtime: ThreadRuntimeCore,\n threadListItemState: ThreadListItemState,\n): ThreadState => {\n const lastMessage = runtime.messages.at(-1);\n return Object.freeze({\n threadId: threadListItemState.id,\n metadata: threadListItemState,\n capabilities: runtime.capabilities,\n isDisabled: runtime.isDisabled,\n isLoading: runtime.isLoading,\n isRunning:\n lastMessage?.role !== \"assistant\"\n ? false\n : lastMessage.status.type === \"running\",\n messages: runtime.messages,\n state: runtime.state,\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 * @deprecated pass an object with `parentId` instead. This will be removed in 0.8.0.\n */\n startRun(parentId: string | null): void;\n /**\n * Start a new run with the given configuration.\n * @param config The configuration for starting the run\n */\n startRun(config: CreateStartRunConfig): void;\n\n /**\n * Resume a run with the given configuration.\n * @param config The configuration for resuming the run\n **/\n unstable_resumeRun(config: CreateResumeRunConfig): void;\n\n subscribe(callback: () => void): Unsubscribe;\n cancelRun(): void;\n getModelContext(): ModelContext;\n\n /**\n * @deprecated This method was renamed to `getModelContext`.\n */\n getModelConfig(): ModelContext;\n\n export(): ExportedMessageRepository;\n import(repository: ExportedMessageRepository): void;\n\n /**\n * Reset the thread with optional initial messages.\n *\n * @param initialMessages - Optional array of initial messages to populate the thread\n */\n reset(initialMessages?: readonly ThreadMessageLike[]): void;\n\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 get __internal_threadBinding() {\n return this._threadBinding;\n }\n\n private readonly _threadBinding: ThreadRuntimeCoreBinding & {\n getStateState(): ThreadState;\n };\n\n constructor(\n threadBinding: ThreadRuntimeCoreBinding,\n threadListItemBinding: ThreadListItemRuntimeBinding,\n ) {\n const stateBinding = new ShallowMemoizeSubject({\n path: threadBinding.path,\n getState: () =>\n getThreadState(\n threadBinding.getState(),\n threadListItemBinding.getState(),\n ),\n subscribe: (callback) => {\n const sub1 = threadBinding.subscribe(callback);\n const sub2 = threadListItemBinding.subscribe(callback);\n return () => {\n sub1();\n sub2();\n };\n },\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 protected __internal_bindMethods() {\n this.append = this.append.bind(this);\n this.unstable_resumeRun = this.unstable_resumeRun.bind(this);\n this.startRun = this.startRun.bind(this);\n this.cancelRun = this.cancelRun.bind(this);\n this.stopSpeaking = this.stopSpeaking.bind(this);\n this.export = this.export.bind(this);\n this.import = this.import.bind(this);\n this.reset = this.reset.bind(this);\n this.getMesssageByIndex = this.getMesssageByIndex.bind(this);\n this.getMesssageById = this.getMesssageById.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.unstable_on = this.unstable_on.bind(this);\n this.getModelContext = this.getModelContext.bind(this);\n this.getModelConfig = this.getModelConfig.bind(this);\n this.getState = this.getState.bind(this);\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 getModelContext() {\n return this._threadBinding.getState().getModelContext();\n }\n\n public getModelConfig() {\n return this.getModelContext();\n }\n\n public startRun(configOrParentId: string | null | CreateStartRunConfig) {\n const config =\n configOrParentId === null || typeof configOrParentId === \"string\"\n ? { parentId: configOrParentId }\n : configOrParentId;\n return this._threadBinding.getState().startRun(toStartRunConfig(config));\n }\n\n public unstable_resumeRun(config: CreateResumeRunConfig) {\n return this._threadBinding.getState().resumeRun(toResumeRunConfig(config));\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 export() {\n return this._threadBinding.getState().export();\n }\n\n public import(data: ExportedMessageRepository) {\n this._threadBinding.getState().import(data);\n }\n\n public reset(initialMessages?: readonly ThreadMessageLike[]) {\n this._threadBinding.getState().reset(initialMessages);\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 ...{ [symbolInnerMessage]: (message as any)[symbolInnerMessage] },\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 _eventSubscriptionSubjects = new Map<\n string,\n EventSubscriptionSubject<ThreadRuntimeEventType>\n >();\n\n public unstable_on(\n event: ThreadRuntimeEventType,\n callback: () => void,\n ): Unsubscribe {\n let subject = this._eventSubscriptionSubjects.get(event);\n if (!subject) {\n subject = new EventSubscriptionSubject({\n event: event,\n binding: this._threadBinding,\n });\n this._eventSubscriptionSubjects.set(event, subject);\n }\n return subject.subscribe(callback);\n }\n}\n"],"mappings":";AAYA;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AAEtC;AAAA,EAEE;AAAA,OACK;AACP,SAAS,mBAAmB;AAQ5B,SAAS,gCAAgC;AACzC,SAAS,0BAA0B;AAiBnC,IAAM,oBAAoB,CAAC,YAAoD;AAC7E,SAAO;AAAA,IACL,UAAU,QAAQ,YAAY;AAAA,IAC9B,UAAU,QAAQ,YAAY;AAAA,IAC9B,WAAW,QAAQ,aAAa,CAAC;AAAA,IACjC,QAAQ,QAAQ;AAAA,EAClB;AACF;AAEA,IAAM,mBAAmB,CAAC,YAAkD;AAC1E,SAAO;AAAA,IACL,UAAU,QAAQ,YAAY;AAAA,IAC9B,UAAU,QAAQ,YAAY;AAAA,IAC9B,WAAW,QAAQ,aAAa,CAAC;AAAA,EACnC;AACF;AAgBA,IAAM,kBAAkB,CACtB,UACA,YACkB;AAClB,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,MACL,WAAW,oBAAI,KAAK;AAAA,MACpB,UAAU,SAAS,GAAG,EAAE,GAAG,MAAM;AAAA,MACjC,UAAU;AAAA,MAC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AAM,SAAS,KAAK,eAAe,SAAS;AAE5C,gBAAM,WAAW,OAAO,YAAY,QAAQ,EAAE;AAC9C,gBAAM,oBAAoB,OAAO,qBAAqB,QAAQ,EAAE;AAEhE,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,GAAG,EAAE,CAAC,kBAAkB,GAAI,QAAgB,kBAAkB,EAAE;AAAA,YAEhE,QAAQ,SAAS,GAAG,EAAE,GAAG,OAAO,QAAQ;AAAA,YACxC;AAAA,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,6BAA6B,oBAAI,IAGvC;AAAA,EAEK,YACL,OACA,UACa;AACb,QAAI,UAAU,KAAK,2BAA2B,IAAI,KAAK;AACvD,QAAI,CAAC,SAAS;AACZ,gBAAU,IAAI,yBAAyB;AAAA,QACrC;AAAA,QACA,SAAS,KAAK;AAAA,MAChB,CAAC;AACD,WAAK,2BAA2B,IAAI,OAAO,OAAO;AAAA,IACpD;AACA,WAAO,QAAQ,UAAU,QAAQ;AAAA,EACnC;AACF;","names":["callback"]}
|
@@ -284,8 +284,8 @@ export declare const useEditComposerAttachment: {
|
|
284
284
|
file?: File;
|
285
285
|
content?: import("../..").ThreadUserMessagePart[];
|
286
286
|
} & {
|
287
|
-
status: import("../../types/AttachmentTypes").
|
288
|
-
|
287
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
288
|
+
file: File;
|
289
289
|
} & {
|
290
290
|
readonly source: "edit-composer";
|
291
291
|
} & {
|
@@ -298,8 +298,8 @@ export declare const useEditComposerAttachment: {
|
|
298
298
|
file?: File;
|
299
299
|
content?: import("../..").ThreadUserMessagePart[];
|
300
300
|
} & {
|
301
|
-
status: import("../../types/AttachmentTypes").
|
302
|
-
|
301
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
302
|
+
content: import("../..").ThreadUserMessagePart[];
|
303
303
|
} & {
|
304
304
|
readonly source: "edit-composer";
|
305
305
|
} & {
|
@@ -313,8 +313,8 @@ export declare const useEditComposerAttachment: {
|
|
313
313
|
file?: File;
|
314
314
|
content?: import("../..").ThreadUserMessagePart[];
|
315
315
|
} & {
|
316
|
-
status: import("../../types/AttachmentTypes").
|
317
|
-
|
316
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
317
|
+
file: File;
|
318
318
|
} & {
|
319
319
|
readonly source: "edit-composer";
|
320
320
|
} & {
|
@@ -327,8 +327,8 @@ export declare const useEditComposerAttachment: {
|
|
327
327
|
file?: File;
|
328
328
|
content?: import("../..").ThreadUserMessagePart[];
|
329
329
|
} & {
|
330
|
-
status: import("../../types/AttachmentTypes").
|
331
|
-
|
330
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
331
|
+
content: import("../..").ThreadUserMessagePart[];
|
332
332
|
} & {
|
333
333
|
readonly source: "edit-composer";
|
334
334
|
} & {
|
@@ -342,8 +342,8 @@ export declare const useEditComposerAttachment: {
|
|
342
342
|
file?: File;
|
343
343
|
content?: import("../..").ThreadUserMessagePart[];
|
344
344
|
} & {
|
345
|
-
status: import("../../types/AttachmentTypes").
|
346
|
-
|
345
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
346
|
+
file: File;
|
347
347
|
} & {
|
348
348
|
readonly source: "edit-composer";
|
349
349
|
} & {
|
@@ -356,8 +356,8 @@ export declare const useEditComposerAttachment: {
|
|
356
356
|
file?: File;
|
357
357
|
content?: import("../..").ThreadUserMessagePart[];
|
358
358
|
} & {
|
359
|
-
status: import("../../types/AttachmentTypes").
|
360
|
-
|
359
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
360
|
+
content: import("../..").ThreadUserMessagePart[];
|
361
361
|
} & {
|
362
362
|
readonly source: "edit-composer";
|
363
363
|
} & {
|
@@ -370,8 +370,8 @@ export declare const useEditComposerAttachment: {
|
|
370
370
|
file?: File;
|
371
371
|
content?: import("../..").ThreadUserMessagePart[];
|
372
372
|
} & {
|
373
|
-
status: import("../../types/AttachmentTypes").
|
374
|
-
|
373
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
374
|
+
file: File;
|
375
375
|
} & {
|
376
376
|
readonly source: "edit-composer";
|
377
377
|
} & {
|
@@ -384,8 +384,8 @@ export declare const useEditComposerAttachment: {
|
|
384
384
|
file?: File;
|
385
385
|
content?: import("../..").ThreadUserMessagePart[];
|
386
386
|
} & {
|
387
|
-
status: import("../../types/AttachmentTypes").
|
388
|
-
|
387
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
388
|
+
content: import("../..").ThreadUserMessagePart[];
|
389
389
|
} & {
|
390
390
|
readonly source: "edit-composer";
|
391
391
|
} & {
|
@@ -401,8 +401,8 @@ export declare const useEditComposerAttachment: {
|
|
401
401
|
file?: File;
|
402
402
|
content?: import("../..").ThreadUserMessagePart[];
|
403
403
|
} & {
|
404
|
-
status: import("../../types/AttachmentTypes").
|
405
|
-
|
404
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
405
|
+
file: File;
|
406
406
|
} & {
|
407
407
|
readonly source: "edit-composer";
|
408
408
|
} & {
|
@@ -415,8 +415,8 @@ export declare const useEditComposerAttachment: {
|
|
415
415
|
file?: File;
|
416
416
|
content?: import("../..").ThreadUserMessagePart[];
|
417
417
|
} & {
|
418
|
-
status: import("../../types/AttachmentTypes").
|
419
|
-
|
418
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
419
|
+
content: import("../..").ThreadUserMessagePart[];
|
420
420
|
} & {
|
421
421
|
readonly source: "edit-composer";
|
422
422
|
} & {
|
@@ -432,8 +432,8 @@ export declare const useEditComposerAttachment: {
|
|
432
432
|
file?: File;
|
433
433
|
content?: import("../..").ThreadUserMessagePart[];
|
434
434
|
} & {
|
435
|
-
status: import("../../types/AttachmentTypes").
|
436
|
-
|
435
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
436
|
+
file: File;
|
437
437
|
} & {
|
438
438
|
readonly source: "edit-composer";
|
439
439
|
} & {
|
@@ -446,8 +446,8 @@ export declare const useEditComposerAttachment: {
|
|
446
446
|
file?: File;
|
447
447
|
content?: import("../..").ThreadUserMessagePart[];
|
448
448
|
} & {
|
449
|
-
status: import("../../types/AttachmentTypes").
|
450
|
-
|
449
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
450
|
+
content: import("../..").ThreadUserMessagePart[];
|
451
451
|
} & {
|
452
452
|
readonly source: "edit-composer";
|
453
453
|
} & {
|
@@ -463,8 +463,8 @@ export declare const useEditComposerAttachment: {
|
|
463
463
|
file?: File;
|
464
464
|
content?: import("../..").ThreadUserMessagePart[];
|
465
465
|
} & {
|
466
|
-
status: import("../../types/AttachmentTypes").
|
467
|
-
|
466
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
467
|
+
file: File;
|
468
468
|
} & {
|
469
469
|
readonly source: "edit-composer";
|
470
470
|
} & {
|
@@ -477,8 +477,8 @@ export declare const useEditComposerAttachment: {
|
|
477
477
|
file?: File;
|
478
478
|
content?: import("../..").ThreadUserMessagePart[];
|
479
479
|
} & {
|
480
|
-
status: import("../../types/AttachmentTypes").
|
481
|
-
|
480
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
481
|
+
content: import("../..").ThreadUserMessagePart[];
|
482
482
|
} & {
|
483
483
|
readonly source: "edit-composer";
|
484
484
|
} & {
|
@@ -495,8 +495,8 @@ export declare const useEditComposerAttachment: {
|
|
495
495
|
file?: File;
|
496
496
|
content?: import("../..").ThreadUserMessagePart[];
|
497
497
|
} & {
|
498
|
-
status: import("../../types/AttachmentTypes").
|
499
|
-
|
498
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
499
|
+
file: File;
|
500
500
|
} & {
|
501
501
|
readonly source: "edit-composer";
|
502
502
|
} & {
|
@@ -509,8 +509,8 @@ export declare const useEditComposerAttachment: {
|
|
509
509
|
file?: File;
|
510
510
|
content?: import("../..").ThreadUserMessagePart[];
|
511
511
|
} & {
|
512
|
-
status: import("../../types/AttachmentTypes").
|
513
|
-
|
512
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
513
|
+
content: import("../..").ThreadUserMessagePart[];
|
514
514
|
} & {
|
515
515
|
readonly source: "edit-composer";
|
516
516
|
} & {
|
@@ -524,8 +524,8 @@ export declare const useEditComposerAttachment: {
|
|
524
524
|
file?: File;
|
525
525
|
content?: import("../..").ThreadUserMessagePart[];
|
526
526
|
} & {
|
527
|
-
status: import("../../types/AttachmentTypes").
|
528
|
-
|
527
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
528
|
+
file: File;
|
529
529
|
} & {
|
530
530
|
readonly source: "edit-composer";
|
531
531
|
} & {
|
@@ -538,8 +538,8 @@ export declare const useEditComposerAttachment: {
|
|
538
538
|
file?: File;
|
539
539
|
content?: import("../..").ThreadUserMessagePart[];
|
540
540
|
} & {
|
541
|
-
status: import("../../types/AttachmentTypes").
|
542
|
-
|
541
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
542
|
+
content: import("../..").ThreadUserMessagePart[];
|
543
543
|
} & {
|
544
544
|
readonly source: "edit-composer";
|
545
545
|
} & {
|
@@ -555,8 +555,8 @@ export declare const useEditComposerAttachment: {
|
|
555
555
|
file?: File;
|
556
556
|
content?: import("../..").ThreadUserMessagePart[];
|
557
557
|
} & {
|
558
|
-
status: import("../../types/AttachmentTypes").
|
559
|
-
|
558
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
559
|
+
file: File;
|
560
560
|
} & {
|
561
561
|
readonly source: "edit-composer";
|
562
562
|
} & {
|
@@ -569,8 +569,8 @@ export declare const useEditComposerAttachment: {
|
|
569
569
|
file?: File;
|
570
570
|
content?: import("../..").ThreadUserMessagePart[];
|
571
571
|
} & {
|
572
|
-
status: import("../../types/AttachmentTypes").
|
573
|
-
|
572
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
573
|
+
content: import("../..").ThreadUserMessagePart[];
|
574
574
|
} & {
|
575
575
|
readonly source: "edit-composer";
|
576
576
|
} & {
|
@@ -587,8 +587,8 @@ export declare const useEditComposerAttachment: {
|
|
587
587
|
file?: File;
|
588
588
|
content?: import("../..").ThreadUserMessagePart[];
|
589
589
|
} & {
|
590
|
-
status: import("../../types/AttachmentTypes").
|
591
|
-
|
590
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
591
|
+
file: File;
|
592
592
|
} & {
|
593
593
|
readonly source: "edit-composer";
|
594
594
|
} & {
|
@@ -601,8 +601,8 @@ export declare const useEditComposerAttachment: {
|
|
601
601
|
file?: File;
|
602
602
|
content?: import("../..").ThreadUserMessagePart[];
|
603
603
|
} & {
|
604
|
-
status: import("../../types/AttachmentTypes").
|
605
|
-
|
604
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
605
|
+
content: import("../..").ThreadUserMessagePart[];
|
606
606
|
} & {
|
607
607
|
readonly source: "edit-composer";
|
608
608
|
} & {
|
@@ -616,8 +616,8 @@ export declare const useEditComposerAttachment: {
|
|
616
616
|
file?: File;
|
617
617
|
content?: import("../..").ThreadUserMessagePart[];
|
618
618
|
} & {
|
619
|
-
status: import("../../types/AttachmentTypes").
|
620
|
-
|
619
|
+
status: import("../../types/AttachmentTypes").PendingAttachmentStatus;
|
620
|
+
file: File;
|
621
621
|
} & {
|
622
622
|
readonly source: "edit-composer";
|
623
623
|
} & {
|
@@ -630,8 +630,8 @@ export declare const useEditComposerAttachment: {
|
|
630
630
|
file?: File;
|
631
631
|
content?: import("../..").ThreadUserMessagePart[];
|
632
632
|
} & {
|
633
|
-
status: import("../../types/AttachmentTypes").
|
634
|
-
|
633
|
+
status: import("../../types/AttachmentTypes").CompleteAttachmentStatus;
|
634
|
+
content: import("../..").ThreadUserMessagePart[];
|
635
635
|
} & {
|
636
636
|
readonly source: "edit-composer";
|
637
637
|
} & {
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { Unsubscribe } from "../../types";
|
2
2
|
import { ThreadRuntimeCore } from "./ThreadRuntimeCore";
|
3
|
+
import type { ThreadListItemStatus } from "../../api/RuntimeBindings";
|
3
4
|
type ThreadListItemCoreState = {
|
4
5
|
readonly threadId: string;
|
5
6
|
readonly remoteId?: string | undefined;
|
6
7
|
readonly externalId?: string | undefined;
|
7
|
-
readonly status:
|
8
|
+
readonly status: ThreadListItemStatus;
|
8
9
|
readonly title?: string | undefined;
|
9
10
|
readonly runtime?: ThreadRuntimeCore | undefined;
|
10
11
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ThreadListRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/core/ThreadListRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
1
|
+
{"version":3,"file":"ThreadListRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/core/ThreadListRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,G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;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC,CAAC;IACjE,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;CAC9C,CAAC"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BaseAssistantRuntimeCore } from "
|
1
|
+
import { BaseAssistantRuntimeCore } from "../core/BaseAssistantRuntimeCore";
|
2
2
|
import { ExternalStoreThreadListRuntimeCore } from "./ExternalStoreThreadListRuntimeCore";
|
3
3
|
import { ExternalStoreAdapter } from "./ExternalStoreAdapter";
|
4
4
|
export declare class ExternalStoreRuntimeCore extends BaseAssistantRuntimeCore {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ExternalStoreRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"ExternalStoreRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAO9D,qBAAa,wBAAyB,SAAQ,wBAAwB;IACpE,SAAgB,OAAO,qCAAC;gBAEZ,OAAO,EAAE,oBAAoB,CAAC,GAAG,CAAC;IAQvC,UAAU,CAAC,OAAO,EAAE,oBAAoB,CAAC,GAAG,CAAC;CAKrD"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
// src/runtimes/external-store/ExternalStoreRuntimeCore.tsx
|
2
|
-
import { BaseAssistantRuntimeCore } from "
|
2
|
+
import { BaseAssistantRuntimeCore } from "../core/BaseAssistantRuntimeCore.js";
|
3
3
|
import { ExternalStoreThreadListRuntimeCore } from "./ExternalStoreThreadListRuntimeCore.js";
|
4
4
|
import { ExternalStoreThreadRuntimeCore } from "./ExternalStoreThreadRuntimeCore.js";
|
5
5
|
var getThreadListAdapter = (store) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreRuntimeCore.tsx"],"sourcesContent":["import { BaseAssistantRuntimeCore } from \"
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreRuntimeCore.tsx"],"sourcesContent":["import { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { ExternalStoreThreadListRuntimeCore } from \"./ExternalStoreThreadListRuntimeCore\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\n\nconst getThreadListAdapter = (store: ExternalStoreAdapter<any>) => {\n return store.adapters?.threadList ?? {};\n};\n\nexport class ExternalStoreRuntimeCore extends BaseAssistantRuntimeCore {\n public readonly threads;\n\n constructor(adapter: ExternalStoreAdapter<any>) {\n super();\n this.threads = new ExternalStoreThreadListRuntimeCore(\n getThreadListAdapter(adapter),\n () => new ExternalStoreThreadRuntimeCore(this._contextProvider, adapter),\n );\n }\n\n public setAdapter(adapter: ExternalStoreAdapter<any>) {\n // Update the thread list adapter and propagate store changes to the main thread\n this.threads.__internal_setAdapter(getThreadListAdapter(adapter));\n this.threads.getMainThreadRuntimeCore().__internal_setAdapter(adapter);\n }\n}\n"],"mappings":";AAAA,SAAS,gCAAgC;AACzC,SAAS,0CAA0C;AAEnD,SAAS,sCAAsC;AAE/C,IAAM,uBAAuB,CAAC,UAAqC;AACjE,SAAO,MAAM,UAAU,cAAc,CAAC;AACxC;AAEO,IAAM,2BAAN,cAAuC,yBAAyB;AAAA,EACrD;AAAA,EAEhB,YAAY,SAAoC;AAC9C,UAAM;AACN,SAAK,UAAU,IAAI;AAAA,MACjB,qBAAqB,OAAO;AAAA,MAC5B,MAAM,IAAI,+BAA+B,KAAK,kBAAkB,OAAO;AAAA,IACzE;AAAA,EACF;AAAA,EAEO,WAAW,SAAoC;AAEpD,SAAK,QAAQ,sBAAsB,qBAAqB,OAAO,CAAC;AAChE,SAAK,QAAQ,yBAAyB,EAAE,sBAAsB,OAAO;AAAA,EACvE;AACF;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ExternalStoreThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAS9D,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAI3D,eAAO,MAAM,kBAAkB,GAC7B,WAAW,OAAO,EAClB,UAAU,SAAS,aAAa,EAAE,YAGnC,CAAC;AAEF,qBAAa,8BACX,SAAQ,qBACR,YAAW,iBAAiB;IAE5B,OAAO,CAAC,qBAAqB,CAAuB;IAEpD,OAAO,CAAC,aAAa,CASnB;IAEF,IAAW,YAAY,wBAEtB;IAED,OAAO,CAAC,SAAS,CAA4B;IACtC,UAAU,EAAG,OAAO,CAAC;IAC5B,IAAW,SAAS,YAEnB;IAED,IAAoB,QAAQ,6BAE3B;IAED,IAAW,QAAQ;;;;;kBAElB;IAEM,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAM;IAC9C,MAAM,EAAE,OAAO,CAAa;IAEnC,OAAO,CAAC,UAAU,CAAgC;IAElD,OAAO,CAAC,MAAM,CAA6B;IAE3B,SAAS,CAAC,SAAS,EAAE,MAAM;gBAQzC,eAAe,EAAE,oBAAoB,EACrC,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC;IAM3B,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC;
|
1
|
+
{"version":3,"file":"ExternalStoreThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAS9D,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAI3D,eAAO,MAAM,kBAAkB,GAC7B,WAAW,OAAO,EAClB,UAAU,SAAS,aAAa,EAAE,YAGnC,CAAC;AAEF,qBAAa,8BACX,SAAQ,qBACR,YAAW,iBAAiB;IAE5B,OAAO,CAAC,qBAAqB,CAAuB;IAEpD,OAAO,CAAC,aAAa,CASnB;IAEF,IAAW,YAAY,wBAEtB;IAED,OAAO,CAAC,SAAS,CAA4B;IACtC,UAAU,EAAG,OAAO,CAAC;IAC5B,IAAW,SAAS,YAEnB;IAED,IAAoB,QAAQ,6BAE3B;IAED,IAAW,QAAQ;;;;;kBAElB;IAEM,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAM;IAC9C,MAAM,EAAE,OAAO,CAAa;IAEnC,OAAO,CAAC,UAAU,CAAgC;IAElD,OAAO,CAAC,MAAM,CAA6B;IAE3B,SAAS,CAAC,SAAS,EAAE,MAAM;gBAQzC,eAAe,EAAE,oBAAoB,EACrC,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC;IAM3B,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC;IAgI7C,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQzC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7C,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC,SAAS,IAAI,IAAI;IAiCjB,aAAa,CAAC,OAAO,EAAE,oBAAoB;IAMlD,OAAO,CAAC,cAAc,CAUpB;CACH"}
|
@@ -77,6 +77,7 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
77
77
|
return;
|
78
78
|
}
|
79
79
|
this.repository.clear();
|
80
|
+
this.assistantOptimisticId = null;
|
80
81
|
this.repository.import(store.messageRepository);
|
81
82
|
messages = this.repository.getMessages();
|
82
83
|
} else if (store.messages) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"sourcesContent":["import {\n AddToolResultOptions,\n StartRunConfig,\n ThreadSuggestion,\n} from \"../core/ThreadRuntimeCore\";\n\nimport { AppendMessage, ThreadMessage } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport {\n RuntimeCapabilities,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { ModelContextProvider } from \"../../model-context\";\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: readonly ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n private assistantOptimisticId: string | null = null;\n\n private _capabilities: RuntimeCapabilities = {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n public get capabilities() {\n return this._capabilities;\n }\n\n private _messages!: readonly ThreadMessage[];\n public isDisabled!: boolean;\n public get isLoading() {\n return this._store.isLoading ?? false;\n }\n\n public override get messages() {\n return this._messages;\n }\n\n public get adapters() {\n return this._store.adapters;\n }\n\n public suggestions: readonly ThreadSuggestion[] = [];\n public extras: unknown = undefined;\n\n private _converter = new ThreadMessageConverter();\n\n private _store!: ExternalStoreAdapter<any>;\n\n public override beginEdit(messageId: string) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing.\");\n\n super.beginEdit(messageId);\n }\n\n constructor(\n contextProvider: ModelContextProvider,\n store: ExternalStoreAdapter<any>,\n ) {\n super(contextProvider);\n this.__internal_setAdapter(store);\n }\n\n public __internal_setAdapter(store: ExternalStoreAdapter<any>) {\n if (this._store === store) return;\n\n const isRunning = store.isRunning ?? false;\n this.isDisabled = store.isDisabled ?? false;\n\n const oldStore = this._store as ExternalStoreAdapter<any> | undefined;\n this._store = store;\n this.extras = store.extras;\n this.suggestions = store.suggestions ?? EMPTY_ARRAY;\n this._capabilities = {\n switchToBranch: this._store.setMessages !== undefined,\n edit: this._store.onEdit !== undefined,\n reload: this._store.onReload !== undefined,\n cancel: this._store.onCancel !== undefined,\n speech: this._store.adapters?.speech !== undefined,\n unstable_copy: this._store.unstable_capabilities?.copy !== false, // default true\n attachments: !!this._store.adapters?.attachments,\n feedback: !!this._store.adapters?.feedback,\n };\n\n let messages: readonly ThreadMessage[];\n\n if (store.messageRepository) {\n // Handle messageRepository\n if (\n oldStore &&\n oldStore.isRunning === store.isRunning &&\n oldStore.messageRepository === store.messageRepository\n ) {\n this._notifySubscribers();\n return;\n }\n\n // Clear and import the message repository\n this.repository.clear();\n this.repository.import(store.messageRepository);\n\n messages = this.repository.getMessages();\n } else if (store.messages) {\n // Handle messages array\n\n if (oldStore) {\n // flush the converter cache when the convertMessage prop changes\n if (oldStore.convertMessage !== store.convertMessage) {\n this._converter = new ThreadMessageConverter();\n } else if (\n oldStore.isRunning === store.isRunning &&\n oldStore.messages === store.messages\n ) {\n this._notifySubscribers();\n // no conversion update\n return;\n }\n }\n\n messages = !store.convertMessage\n ? store.messages\n : this._converter.convertMessages(store.messages, (cache, m, idx) => {\n if (!store.convertMessage) return m;\n\n const isLast = idx === store.messages!.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n )\n return cache;\n\n const messageLike = store.convertMessage(m, idx);\n const newMessage = fromThreadMessageLike(\n messageLike,\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n });\n\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i]!;\n const parent = messages[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n } else {\n throw new Error(\n \"ExternalStoreAdapter must provide either 'messages' or 'messageRepository'\",\n );\n }\n\n // Common logic for both paths\n if (messages.length > 0) this.ensureInitialized();\n\n if (oldStore?.isRunning ?? false !== store.isRunning ?? false) {\n if (store.isRunning) {\n this._notifyEventSubscribers(\"run-start\");\n } else {\n this._notifyEventSubscribers(\"run-end\");\n }\n }\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, messages)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n messages.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? messages.at(-1)?.id ?? null,\n );\n\n this._messages = this.repository.getMessages();\n this._notifySubscribers();\n }\n\n public override switchToBranch(branchId: string): void {\n if (!this._store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this._store.onEdit(message);\n } else {\n await this._store.onNew(message);\n }\n }\n\n public async startRun(config: StartRunConfig): Promise<void> {\n if (!this._store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this._store.onReload(config.parentId, config);\n }\n\n public async resumeRun(): Promise<void> {\n throw new Error(\"Runtime does not support resuming runs.\");\n }\n\n public cancelRun(): void {\n if (!this._store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this._store.onCancel();\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n const previousMessage = messages[messages.length - 1];\n if (\n previousMessage?.role === \"user\" &&\n previousMessage.id === messages.at(-1)?.id // ensure the previous message is a leaf node\n ) {\n this.repository.deleteMessage(previousMessage.id);\n if (!this.composer.text.trim()) {\n this.composer.setText(getThreadMessageText(previousMessage));\n }\n\n messages = this.repository.getMessages();\n } else {\n this._notifySubscribers();\n }\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public addToolResult(options: AddToolResultOptions) {\n if (!this._store.onAddToolResult && !this._store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this._store.onAddToolResult?.(options);\n }\n\n private updateMessages = (messages: readonly ThreadMessage[]) => {\n const hasConverter = this._store.convertMessage !== undefined;\n if (hasConverter) {\n this._store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n } else {\n // TODO mark this as readonly in v0.8.0\n this._store.setMessages?.(messages as ThreadMessage[]);\n }\n };\n}\n"],"mappings":";AAQA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,eAAe,oBAAoB;AAC5C,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AAKrC,SAAS,6BAA6B;AAGtC,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAE7B,IAAM,qBAAqB,CAChC,WACA,aACG;AACH,SAAO,aAAa,SAAS,SAAS,SAAS,CAAC,GAAG,SAAS;AAC9D;AAEO,IAAM,iCAAN,cACG,sBAEV;AAAA,EACU,wBAAuC;AAAA,EAEvC,gBAAqC;AAAA,IAC3C,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EACD;AAAA,EACP,IAAW,YAAY;AACrB,WAAO,KAAK,OAAO,aAAa;AAAA,EAClC;AAAA,EAEA,IAAoB,WAAW;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,WAAW;AACpB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEO,cAA2C,CAAC;AAAA,EAC5C,SAAkB;AAAA,EAEjB,aAAa,IAAI,uBAAuB;AAAA,EAExC;AAAA,EAEQ,UAAU,W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,GAAG,IACxC;AACA,WAAK,WAAW,cAAc,gBAAgB,EAAE;AAChD,UAAI,CAAC,KAAK,SAAS,KAAK,KAAK,GAAG;AAC9B,aAAK,SAAS,QAAQ,qBAAqB,eAAe,CAAC;AAAA,MAC7D;AAEA,iBAAW,KAAK,WAAW,YAAY;AAAA,IACzC,OAAO;AACL,WAAK,mBAAmB;AAAA,IAC1B;AAGA,eAAW,MAAM;AACf,WAAK,eAAe,QAAQ;AAAA,IAC9B,GAAG,CAAC;AAAA,EACN;AAAA,EAEO,cAAc,SAA+B;AAClD,QAAI,CAAC,KAAK,OAAO,mBAAmB,CAAC,KAAK,OAAO;AAC/C,YAAM,IAAI,MAAM,wCAAwC;AAC1D,SAAK,OAAO,kBAAkB,OAAO;AAAA,EACvC;AAAA,EAEQ,iBAAiB,CAAC,aAAuC;AAC/D,UAAM,eAAe,KAAK,OAAO,mBAAmB;AACpD,QAAI,cAAc;AAChB,WAAK,OAAO;AAAA,QACV,SAAS,QAAQ,uBAAuB,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI;AAAA,MACnE;AAAA,IACF,OAAO;AAEL,WAAK,OAAO,cAAc,QAA2B;AAAA,IACvD;AAAA,EACF;AACF;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"sourcesContent":["import {\n AddToolResultOptions,\n StartRunConfig,\n ThreadSuggestion,\n} from \"../core/ThreadRuntimeCore\";\n\nimport { AppendMessage, ThreadMessage } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport {\n RuntimeCapabilities,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { ModelContextProvider } from \"../../model-context\";\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: readonly ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n private assistantOptimisticId: string | null = null;\n\n private _capabilities: RuntimeCapabilities = {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n public get capabilities() {\n return this._capabilities;\n }\n\n private _messages!: readonly ThreadMessage[];\n public isDisabled!: boolean;\n public get isLoading() {\n return this._store.isLoading ?? false;\n }\n\n public override get messages() {\n return this._messages;\n }\n\n public get adapters() {\n return this._store.adapters;\n }\n\n public suggestions: readonly ThreadSuggestion[] = [];\n public extras: unknown = undefined;\n\n private _converter = new ThreadMessageConverter();\n\n private _store!: ExternalStoreAdapter<any>;\n\n public override beginEdit(messageId: string) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing.\");\n\n super.beginEdit(messageId);\n }\n\n constructor(\n contextProvider: ModelContextProvider,\n store: ExternalStoreAdapter<any>,\n ) {\n super(contextProvider);\n this.__internal_setAdapter(store);\n }\n\n public __internal_setAdapter(store: ExternalStoreAdapter<any>) {\n if (this._store === store) return;\n\n const isRunning = store.isRunning ?? false;\n this.isDisabled = store.isDisabled ?? false;\n\n const oldStore = this._store as ExternalStoreAdapter<any> | undefined;\n this._store = store;\n this.extras = store.extras;\n this.suggestions = store.suggestions ?? EMPTY_ARRAY;\n this._capabilities = {\n switchToBranch: this._store.setMessages !== undefined,\n edit: this._store.onEdit !== undefined,\n reload: this._store.onReload !== undefined,\n cancel: this._store.onCancel !== undefined,\n speech: this._store.adapters?.speech !== undefined,\n unstable_copy: this._store.unstable_capabilities?.copy !== false, // default true\n attachments: !!this._store.adapters?.attachments,\n feedback: !!this._store.adapters?.feedback,\n };\n\n let messages: readonly ThreadMessage[];\n\n if (store.messageRepository) {\n // Handle messageRepository\n if (\n oldStore &&\n oldStore.isRunning === store.isRunning &&\n oldStore.messageRepository === store.messageRepository\n ) {\n this._notifySubscribers();\n return;\n }\n\n // Clear and import the message repository\n this.repository.clear();\n this.assistantOptimisticId = null;\n this.repository.import(store.messageRepository);\n\n messages = this.repository.getMessages();\n } else if (store.messages) {\n // Handle messages array\n\n if (oldStore) {\n // flush the converter cache when the convertMessage prop changes\n if (oldStore.convertMessage !== store.convertMessage) {\n this._converter = new ThreadMessageConverter();\n } else if (\n oldStore.isRunning === store.isRunning &&\n oldStore.messages === store.messages\n ) {\n this._notifySubscribers();\n // no conversion update\n return;\n }\n }\n\n messages = !store.convertMessage\n ? store.messages\n : this._converter.convertMessages(store.messages, (cache, m, idx) => {\n if (!store.convertMessage) return m;\n\n const isLast = idx === store.messages!.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n )\n return cache;\n\n const messageLike = store.convertMessage(m, idx);\n const newMessage = fromThreadMessageLike(\n messageLike,\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n });\n\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i]!;\n const parent = messages[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n } else {\n throw new Error(\n \"ExternalStoreAdapter must provide either 'messages' or 'messageRepository'\",\n );\n }\n\n // Common logic for both paths\n if (messages.length > 0) this.ensureInitialized();\n\n if (oldStore?.isRunning ?? false !== store.isRunning ?? false) {\n if (store.isRunning) {\n this._notifyEventSubscribers(\"run-start\");\n } else {\n this._notifyEventSubscribers(\"run-end\");\n }\n }\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, messages)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n messages.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? messages.at(-1)?.id ?? null,\n );\n\n this._messages = this.repository.getMessages();\n this._notifySubscribers();\n }\n\n public override switchToBranch(branchId: string): void {\n if (!this._store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this._store.onEdit(message);\n } else {\n await this._store.onNew(message);\n }\n }\n\n public async startRun(config: StartRunConfig): Promise<void> {\n if (!this._store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this._store.onReload(config.parentId, config);\n }\n\n public async resumeRun(): Promise<void> {\n throw new Error(\"Runtime does not support resuming runs.\");\n }\n\n public cancelRun(): void {\n if (!this._store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this._store.onCancel();\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n const previousMessage = messages[messages.length - 1];\n if (\n previousMessage?.role === \"user\" &&\n previousMessage.id === messages.at(-1)?.id // ensure the previous message is a leaf node\n ) {\n this.repository.deleteMessage(previousMessage.id);\n if (!this.composer.text.trim()) {\n this.composer.setText(getThreadMessageText(previousMessage));\n }\n\n messages = this.repository.getMessages();\n } else {\n this._notifySubscribers();\n }\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public addToolResult(options: AddToolResultOptions) {\n if (!this._store.onAddToolResult && !this._store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this._store.onAddToolResult?.(options);\n }\n\n private updateMessages = (messages: readonly ThreadMessage[]) => {\n const hasConverter = this._store.convertMessage !== undefined;\n if (hasConverter) {\n this._store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n } else {\n // TODO mark this as readonly in v0.8.0\n this._store.setMessages?.(messages as ThreadMessage[]);\n }\n };\n}\n"],"mappings":";AAQA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,eAAe,oBAAoB;AAC5C,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AAKrC,SAAS,6BAA6B;AAGtC,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAE7B,IAAM,qBAAqB,CAChC,WACA,aACG;AACH,SAAO,aAAa,SAAS,SAAS,SAAS,CAAC,GAAG,SAAS;AAC9D;AAEO,IAAM,iCAAN,cACG,sBAEV;AAAA,EACU,wBAAuC;AAAA,EAEvC,gBAAqC;AAAA,IAC3C,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EACD;AAAA,EACP,IAAW,YAAY;AACrB,WAAO,KAAK,OAAO,aAAa;AAAA,EAClC;AAAA,EAEA,IAAoB,WAAW;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,WAAW;AACpB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEO,cAA2C,CAAC;AAAA,EAC5C,SAAkB;AAAA,EAEjB,aAAa,IAAI,uBAAuB;AAAA,EAExC;AAAA,EAEQ,UAAU,WAAmB;AAC3C,QAAI,CAAC,KAAK,OA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;AACA,WAAK,WAAW,cAAc,gBAAgB,EAAE;AAChD,UAAI,CAAC,KAAK,SAAS,KAAK,KAAK,GAAG;AAC9B,aAAK,SAAS,QAAQ,qBAAqB,eAAe,CAAC;AAAA,MAC7D;AAEA,iBAAW,KAAK,WAAW,YAAY;AAAA,IACzC,OAAO;AACL,WAAK,mBAAmB;AAAA,IAC1B;AAGA,eAAW,MAAM;AACf,WAAK,eAAe,QAAQ;AAAA,IAC9B,GAAG,CAAC;AAAA,EACN;AAAA,EAEO,cAAc,SAA+B;AAClD,QAAI,CAAC,KAAK,OAAO,mBAAmB,CAAC,KAAK,OAAO;AAC/C,YAAM,IAAI,MAAM,wCAAwC;AAC1D,SAAK,OAAO,kBAAkB,OAAO;AAAA,EACvC;AAAA,EAEQ,iBAAiB,CAAC,aAAuC;AAC/D,UAAM,eAAe,KAAK,OAAO,mBAAmB;AACpD,QAAI,cAAc;AAChB,WAAK,OAAO;AAAA,QACV,SAAS,QAAQ,uBAAuB,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI;AAAA,MACnE;AAAA,IACF,OAAO;AAEL,WAAK,OAAO,cAAc,QAA2B;AAAA,IACvD;AAAA,EACF;AACF;","names":[]}
|
@@ -1,53 +1,8 @@
|
|
1
|
-
import { CompleteAttachment } from "./AttachmentTypes";
|
2
|
-
import {
|
1
|
+
import type { CompleteAttachment } from "./AttachmentTypes";
|
2
|
+
import type { ReadonlyJSONValue } from "assistant-stream/utils";
|
3
|
+
import type { TextMessagePart, ReasoningMessagePart, SourceMessagePart, ImageMessagePart, FileMessagePart, Unstable_AudioMessagePart, ToolCallMessagePart, ThreadUserMessagePart, ThreadAssistantMessagePart } from "./MessagePartTypes";
|
4
|
+
export type { TextMessagePart, ReasoningMessagePart, SourceMessagePart, ImageMessagePart, FileMessagePart, Unstable_AudioMessagePart, ToolCallMessagePart, ThreadUserMessagePart, ThreadAssistantMessagePart, };
|
3
5
|
export type MessageRole = ThreadMessage["role"];
|
4
|
-
export type TextMessagePart = {
|
5
|
-
readonly type: "text";
|
6
|
-
readonly text: string;
|
7
|
-
readonly parentId?: string;
|
8
|
-
};
|
9
|
-
export type ReasoningMessagePart = {
|
10
|
-
readonly type: "reasoning";
|
11
|
-
readonly text: string;
|
12
|
-
readonly parentId?: string;
|
13
|
-
};
|
14
|
-
export type SourceMessagePart = {
|
15
|
-
readonly type: "source";
|
16
|
-
readonly sourceType: "url";
|
17
|
-
readonly id: string;
|
18
|
-
readonly url: string;
|
19
|
-
readonly title?: string;
|
20
|
-
readonly parentId?: string;
|
21
|
-
};
|
22
|
-
export type ImageMessagePart = {
|
23
|
-
readonly type: "image";
|
24
|
-
readonly image: string;
|
25
|
-
};
|
26
|
-
export type FileMessagePart = {
|
27
|
-
readonly type: "file";
|
28
|
-
readonly data: string;
|
29
|
-
readonly mimeType: string;
|
30
|
-
};
|
31
|
-
export type Unstable_AudioMessagePart = {
|
32
|
-
readonly type: "audio";
|
33
|
-
readonly audio: {
|
34
|
-
readonly data: string;
|
35
|
-
readonly format: "mp3" | "wav";
|
36
|
-
};
|
37
|
-
};
|
38
|
-
export type ToolCallMessagePart<TArgs = ReadonlyJSONObject, TResult = unknown> = {
|
39
|
-
readonly type: "tool-call";
|
40
|
-
readonly toolCallId: string;
|
41
|
-
readonly toolName: string;
|
42
|
-
readonly args: TArgs;
|
43
|
-
readonly result?: TResult | undefined;
|
44
|
-
readonly isError?: boolean | undefined;
|
45
|
-
readonly argsText: string;
|
46
|
-
readonly artifact?: unknown;
|
47
|
-
readonly parentId?: string;
|
48
|
-
};
|
49
|
-
export type ThreadUserMessagePart = TextMessagePart | ImageMessagePart | FileMessagePart | Unstable_AudioMessagePart;
|
50
|
-
export type ThreadAssistantMessagePart = TextMessagePart | ReasoningMessagePart | ToolCallMessagePart | SourceMessagePart | FileMessagePart;
|
51
6
|
type MessageCommonProps = {
|
52
7
|
readonly id: string;
|
53
8
|
readonly createdAt: Date;
|
@@ -134,5 +89,4 @@ type BaseThreadMessage = {
|
|
134
89
|
readonly attachments?: ThreadUserMessage["attachments"];
|
135
90
|
};
|
136
91
|
export type ThreadMessage = BaseThreadMessage & (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);
|
137
|
-
export {};
|
138
92
|
//# sourceMappingURL=AssistantTypes.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AssistantTypes.d.ts","sourceRoot":"","sources":["../../src/types/AssistantTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;
|
1
|
+
{"version":3,"file":"AssistantTypes.d.ts","sourceRoot":"","sources":["../../src/types/AssistantTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,GAC3B,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAEhD,KAAK,kBAAkB,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EACX;QACE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,gBAAg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1D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,cAAc,CAAC,EAAE,iBAAiB,CAAC;QAC5C,QAAQ,CAAC,oBAAoB,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;QAC7D,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;QACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;QACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC1C,CAAC;IACF,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,CAAC,mBAAmB,GAAG,iBAAiB,GAAG,sBAAsB,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AttachmentTypes.d.ts","sourceRoot":"","sources":["../../src/types/AttachmentTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"AttachmentTypes.d.ts","sourceRoot":"","sources":["../../src/types/AttachmentTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,MAAM,uBAAuB,GAC/B;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,eAAe,CAAC;CACzB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,OAAO,GAAG,eAAe,CAAC;CACnC,CAAC;AAEN,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB,uBAAuB,GACvB,wBAAwB,CAAC;AAE7B,KAAK,cAAc,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAC/C,MAAM,EAAE,uBAAuB,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG;IAChD,MAAM,EAAE,wBAAwB,CAAC;IACjC,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,CAAC"}
|