@assistant-ui/react 0.7.39 → 0.7.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +4 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +4 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +3 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/index.d.ts +2 -0
- package/dist/runtimes/remote-thread-list/index.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/index.js +9 -0
- package/dist/runtimes/remote-thread-list/index.js.map +1 -1
- package/dist/runtimes/remote-thread-list/index.mjs +4 -0
- package/dist/runtimes/remote-thread-list/index.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +1 -2
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.js.map +1 -1
- package/package.json +3 -3
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +5 -1
- package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +10 -10
- package/src/runtimes/remote-thread-list/index.ts +5 -1
- package/src/runtimes/remote-thread-list/types.tsx +1 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseComposer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S;IAOxC,OAAO,CAAC,wBAAwB;YAMlB,mBAAmB;IAOpB,KAAK;IAkBL,gBAAgB;IAOhB,IAAI;IAyBV,MAAM;IAIb,SAAS,CAAC,QAAQ,CAAC,UAAU,CAC3B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,UAAU,CAAC,GACpD,IAAI;IACP,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI;IAEjC,aAAa,CAAC,IAAI,EAAE,IAAI;IAWxB,gBAAgB,CAAC,YAAY,EAAE,MAAM;IAkB3C,OAAO,CAAC,iBAAiB,CAGrB;IAEJ,SAAS,CAAC,uBAAuB,CAAC,KAAK,EAAE,wBAAwB;IAO1D,WAAW,CAAC,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,IAAI;CAczE"}
|
|
@@ -131,7 +131,10 @@ var BaseComposerRuntimeCore = class extends import_BaseSubscribable.BaseSubscrib
|
|
|
131
131
|
if (index === -1) throw new Error("Attachment not found");
|
|
132
132
|
const attachment = this._attachments[index];
|
|
133
133
|
await adapter.remove(attachment);
|
|
134
|
-
this._attachments =
|
|
134
|
+
this._attachments = [
|
|
135
|
+
...this._attachments.slice(0, index),
|
|
136
|
+
...this._attachments.slice(index + 1)
|
|
137
|
+
];
|
|
135
138
|
this._notifySubscribers();
|
|
136
139
|
}
|
|
137
140
|
_eventSubscribers = /* @__PURE__ */ new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/composer/BaseComposerRuntimeCore.tsx"],"sourcesContent":["import {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n} from \"../../types/AttachmentTypes\";\nimport { AppendMessage } from \"../../types\";\nimport { AttachmentAdapter } from \"../attachment\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n} from \"../core/ComposerRuntimeCore\";\nimport { MessageRole, RunConfig } from \"../../types/AssistantTypes\";\nimport { BaseSubscribable } from \"../remote-thread-list/BaseSubscribable\";\n\nconst isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>\n a.status.type === \"complete\";\n\nexport abstract class BaseComposerRuntimeCore\n extends BaseSubscribable\n implements ComposerRuntimeCore\n{\n public readonly isEditing = true;\n\n protected abstract getAttachmentAdapter(): AttachmentAdapter | undefined;\n\n public getAttachmentAccept(): string {\n return this.getAttachmentAdapter()?.accept ?? \"*\";\n }\n\n private _attachments: readonly Attachment[] = [];\n public get attachments() {\n return this._attachments;\n }\n\n protected setAttachments(value: readonly Attachment[]) {\n this._attachments = value;\n this._notifySubscribers();\n }\n\n public abstract get canCancel(): boolean;\n\n public get isEmpty() {\n return !this.text.trim() && !this.attachments.length;\n }\n\n private _text = \"\";\n\n get text() {\n return this._text;\n }\n\n private _role: MessageRole = \"user\";\n\n get role() {\n return this._role;\n }\n\n private _runConfig: RunConfig = {};\n\n get runConfig() {\n return this._runConfig;\n }\n\n public setText(value: string) {\n if (this._text === value) return;\n\n this._text = value;\n this._notifySubscribers();\n }\n\n public setRole(role: MessageRole) {\n if (this._role === role) return;\n\n this._role = role;\n this._notifySubscribers();\n }\n\n public setRunConfig(runConfig: RunConfig) {\n if (this._runConfig === runConfig) return;\n\n this._runConfig = runConfig;\n this._notifySubscribers();\n }\n\n private _emptyTextAndAttachments() {\n this._attachments = [];\n this._text = \"\";\n this._notifySubscribers();\n }\n\n private async _onClearAttachments() {\n const adapter = this.getAttachmentAdapter();\n if (adapter) {\n await Promise.all(this._attachments.map((a) => adapter.remove(a)));\n }\n }\n\n public async reset() {\n if (\n this._attachments.length === 0 &&\n this._text === \"\" &&\n this._role === \"user\" &&\n Object.keys(this._runConfig).length === 0\n ) {\n return;\n }\n\n this._role = \"user\";\n this._runConfig = {};\n\n const task = this._onClearAttachments();\n this._emptyTextAndAttachments();\n await task;\n }\n\n public async clearAttachments() {\n const task = this._onClearAttachments();\n this.setAttachments([]);\n\n await task;\n }\n\n public async send() {\n const adapter = this.getAttachmentAdapter();\n const attachments =\n adapter && this.attachments.length > 0\n ? await Promise.all(\n this.attachments.map(async (a) => {\n if (isAttachmentComplete(a)) return a;\n const result = await adapter.send(a);\n return result as CompleteAttachment;\n }),\n )\n : [];\n\n const message: Omit<AppendMessage, \"parentId\" | \"sourceId\"> = {\n role: this.role,\n content: this.text ? [{ type: \"text\", text: this.text }] : [],\n attachments,\n runConfig: this.runConfig,\n };\n this._emptyTextAndAttachments();\n\n this.handleSend(message);\n this._notifyEventSubscribers(\"send\");\n }\n\n public cancel() {\n this.handleCancel();\n }\n\n protected abstract handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n ): void;\n protected abstract handleCancel(): void;\n\n async addAttachment(file: File) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const attachment = await adapter.add({ file });\n\n this._attachments = [...this._attachments, attachment as PendingAttachment];\n this._notifyEventSubscribers(\"attachment_add\");\n this._notifySubscribers();\n }\n\n async removeAttachment(attachmentId: string) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const index = this._attachments.findIndex((a) => a.id === attachmentId);\n if (index === -1) throw new Error(\"Attachment not found\");\n const attachment = this._attachments[index]!;\n\n await adapter.remove(attachment);\n\n this._attachments = this._attachments.
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/composer/BaseComposerRuntimeCore.tsx"],"sourcesContent":["import {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n} from \"../../types/AttachmentTypes\";\nimport { AppendMessage } from \"../../types\";\nimport { AttachmentAdapter } from \"../attachment\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n} from \"../core/ComposerRuntimeCore\";\nimport { MessageRole, RunConfig } from \"../../types/AssistantTypes\";\nimport { BaseSubscribable } from \"../remote-thread-list/BaseSubscribable\";\n\nconst isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>\n a.status.type === \"complete\";\n\nexport abstract class BaseComposerRuntimeCore\n extends BaseSubscribable\n implements ComposerRuntimeCore\n{\n public readonly isEditing = true;\n\n protected abstract getAttachmentAdapter(): AttachmentAdapter | undefined;\n\n public getAttachmentAccept(): string {\n return this.getAttachmentAdapter()?.accept ?? \"*\";\n }\n\n private _attachments: readonly Attachment[] = [];\n public get attachments() {\n return this._attachments;\n }\n\n protected setAttachments(value: readonly Attachment[]) {\n this._attachments = value;\n this._notifySubscribers();\n }\n\n public abstract get canCancel(): boolean;\n\n public get isEmpty() {\n return !this.text.trim() && !this.attachments.length;\n }\n\n private _text = \"\";\n\n get text() {\n return this._text;\n }\n\n private _role: MessageRole = \"user\";\n\n get role() {\n return this._role;\n }\n\n private _runConfig: RunConfig = {};\n\n get runConfig() {\n return this._runConfig;\n }\n\n public setText(value: string) {\n if (this._text === value) return;\n\n this._text = value;\n this._notifySubscribers();\n }\n\n public setRole(role: MessageRole) {\n if (this._role === role) return;\n\n this._role = role;\n this._notifySubscribers();\n }\n\n public setRunConfig(runConfig: RunConfig) {\n if (this._runConfig === runConfig) return;\n\n this._runConfig = runConfig;\n this._notifySubscribers();\n }\n\n private _emptyTextAndAttachments() {\n this._attachments = [];\n this._text = \"\";\n this._notifySubscribers();\n }\n\n private async _onClearAttachments() {\n const adapter = this.getAttachmentAdapter();\n if (adapter) {\n await Promise.all(this._attachments.map((a) => adapter.remove(a)));\n }\n }\n\n public async reset() {\n if (\n this._attachments.length === 0 &&\n this._text === \"\" &&\n this._role === \"user\" &&\n Object.keys(this._runConfig).length === 0\n ) {\n return;\n }\n\n this._role = \"user\";\n this._runConfig = {};\n\n const task = this._onClearAttachments();\n this._emptyTextAndAttachments();\n await task;\n }\n\n public async clearAttachments() {\n const task = this._onClearAttachments();\n this.setAttachments([]);\n\n await task;\n }\n\n public async send() {\n const adapter = this.getAttachmentAdapter();\n const attachments =\n adapter && this.attachments.length > 0\n ? await Promise.all(\n this.attachments.map(async (a) => {\n if (isAttachmentComplete(a)) return a;\n const result = await adapter.send(a);\n return result as CompleteAttachment;\n }),\n )\n : [];\n\n const message: Omit<AppendMessage, \"parentId\" | \"sourceId\"> = {\n role: this.role,\n content: this.text ? [{ type: \"text\", text: this.text }] : [],\n attachments,\n runConfig: this.runConfig,\n };\n this._emptyTextAndAttachments();\n\n this.handleSend(message);\n this._notifyEventSubscribers(\"send\");\n }\n\n public cancel() {\n this.handleCancel();\n }\n\n protected abstract handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n ): void;\n protected abstract handleCancel(): void;\n\n async addAttachment(file: File) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const attachment = await adapter.add({ file });\n\n this._attachments = [...this._attachments, attachment as PendingAttachment];\n this._notifyEventSubscribers(\"attachment_add\");\n this._notifySubscribers();\n }\n\n async removeAttachment(attachmentId: string) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const index = this._attachments.findIndex((a) => a.id === attachmentId);\n if (index === -1) throw new Error(\"Attachment not found\");\n const attachment = this._attachments[index]!;\n\n await adapter.remove(attachment);\n\n // this._attachments.toSpliced(index, 1); - not yet widely supported\n this._attachments = [\n ...this._attachments.slice(0, index),\n ...this._attachments.slice(index + 1),\n ];\n this._notifySubscribers();\n }\n\n private _eventSubscribers = new Map<\n ComposerRuntimeEventType,\n Set<() => void>\n >();\n\n protected _notifyEventSubscribers(event: ComposerRuntimeEventType) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n for (const callback of subscribers) callback();\n }\n\n public unstable_on(event: ComposerRuntimeEventType, callback: () => void) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) {\n this._eventSubscribers.set(event, new Set([callback]));\n } else {\n subscribers.add(callback);\n }\n\n return () => {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n subscribers.delete(callback);\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,8BAAiC;AAEj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cAAc,UAA+B;AAC1E,SAAK,wBAAwB,gBAAgB;AAC7C,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEA,MAAM,iBAAiB,cAAsB;AAC3C,UAAM,UAAU,KAAK,qBAAqB;AAC1C,QAAI,CAAC,QAAS,OAAM,IAAI,MAAM,+BAA+B;AAE7D,UAAM,QAAQ,KAAK,aAAa,UAAU,CAAC,MAAM,EAAE,OAAO,YAAY;AACtE,QAAI,UAAU,GAAI,OAAM,IAAI,MAAM,sBAAsB;AACxD,UAAM,aAAa,KAAK,aAAa,KAAK;AAE1C,UAAM,QAAQ,OAAO,UAAU;AAG/B,SAAK,eAAe;AAAA,MAClB,GAAG,KAAK,aAAa,MAAM,GAAG,KAAK;AAAA,MACnC,GAAG,KAAK,aAAa,MAAM,QAAQ,CAAC;AAAA,IACtC;AACA,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEQ,oBAAoB,oBAAI,IAG9B;AAAA,EAEQ,wBAAwB,OAAiC;AACjE,UAAM,cAAc,KAAK,kBAAkB,IAAI,KAAK;AACpD,QAAI,CAAC,YAAa;AAElB,eAAW,YAAY,YAAa,UAAS;AAAA,EAC/C;AAAA,EAEO,YAAY,OAAiC,UAAsB;AACxE,UAAM,cAAc,KAAK,kBAAkB,IAAI,KAAK;AACpD,QAAI,CAAC,aAAa;AAChB,WAAK,kBAAkB,IAAI,OAAO,oBAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;AAAA,IACvD,OAAO;AACL,kBAAY,IAAI,QAAQ;AAAA,IAC1B;AAEA,WAAO,MAAM;AACX,YAAMA,eAAc,KAAK,kBAAkB,IAAI,KAAK;AACpD,UAAI,CAACA,aAAa;AAClB,MAAAA,aAAY,OAAO,QAAQ;AAAA,IAC7B;AAAA,EACF;AACF;","names":["subscribers"]}
|
|
@@ -107,7 +107,10 @@ var BaseComposerRuntimeCore = class extends BaseSubscribable {
|
|
|
107
107
|
if (index === -1) throw new Error("Attachment not found");
|
|
108
108
|
const attachment = this._attachments[index];
|
|
109
109
|
await adapter.remove(attachment);
|
|
110
|
-
this._attachments =
|
|
110
|
+
this._attachments = [
|
|
111
|
+
...this._attachments.slice(0, index),
|
|
112
|
+
...this._attachments.slice(index + 1)
|
|
113
|
+
];
|
|
111
114
|
this._notifySubscribers();
|
|
112
115
|
}
|
|
113
116
|
_eventSubscribers = /* @__PURE__ */ new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/composer/BaseComposerRuntimeCore.tsx"],"sourcesContent":["import {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n} from \"../../types/AttachmentTypes\";\nimport { AppendMessage } from \"../../types\";\nimport { AttachmentAdapter } from \"../attachment\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n} from \"../core/ComposerRuntimeCore\";\nimport { MessageRole, RunConfig } from \"../../types/AssistantTypes\";\nimport { BaseSubscribable } from \"../remote-thread-list/BaseSubscribable\";\n\nconst isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>\n a.status.type === \"complete\";\n\nexport abstract class BaseComposerRuntimeCore\n extends BaseSubscribable\n implements ComposerRuntimeCore\n{\n public readonly isEditing = true;\n\n protected abstract getAttachmentAdapter(): AttachmentAdapter | undefined;\n\n public getAttachmentAccept(): string {\n return this.getAttachmentAdapter()?.accept ?? \"*\";\n }\n\n private _attachments: readonly Attachment[] = [];\n public get attachments() {\n return this._attachments;\n }\n\n protected setAttachments(value: readonly Attachment[]) {\n this._attachments = value;\n this._notifySubscribers();\n }\n\n public abstract get canCancel(): boolean;\n\n public get isEmpty() {\n return !this.text.trim() && !this.attachments.length;\n }\n\n private _text = \"\";\n\n get text() {\n return this._text;\n }\n\n private _role: MessageRole = \"user\";\n\n get role() {\n return this._role;\n }\n\n private _runConfig: RunConfig = {};\n\n get runConfig() {\n return this._runConfig;\n }\n\n public setText(value: string) {\n if (this._text === value) return;\n\n this._text = value;\n this._notifySubscribers();\n }\n\n public setRole(role: MessageRole) {\n if (this._role === role) return;\n\n this._role = role;\n this._notifySubscribers();\n }\n\n public setRunConfig(runConfig: RunConfig) {\n if (this._runConfig === runConfig) return;\n\n this._runConfig = runConfig;\n this._notifySubscribers();\n }\n\n private _emptyTextAndAttachments() {\n this._attachments = [];\n this._text = \"\";\n this._notifySubscribers();\n }\n\n private async _onClearAttachments() {\n const adapter = this.getAttachmentAdapter();\n if (adapter) {\n await Promise.all(this._attachments.map((a) => adapter.remove(a)));\n }\n }\n\n public async reset() {\n if (\n this._attachments.length === 0 &&\n this._text === \"\" &&\n this._role === \"user\" &&\n Object.keys(this._runConfig).length === 0\n ) {\n return;\n }\n\n this._role = \"user\";\n this._runConfig = {};\n\n const task = this._onClearAttachments();\n this._emptyTextAndAttachments();\n await task;\n }\n\n public async clearAttachments() {\n const task = this._onClearAttachments();\n this.setAttachments([]);\n\n await task;\n }\n\n public async send() {\n const adapter = this.getAttachmentAdapter();\n const attachments =\n adapter && this.attachments.length > 0\n ? await Promise.all(\n this.attachments.map(async (a) => {\n if (isAttachmentComplete(a)) return a;\n const result = await adapter.send(a);\n return result as CompleteAttachment;\n }),\n )\n : [];\n\n const message: Omit<AppendMessage, \"parentId\" | \"sourceId\"> = {\n role: this.role,\n content: this.text ? [{ type: \"text\", text: this.text }] : [],\n attachments,\n runConfig: this.runConfig,\n };\n this._emptyTextAndAttachments();\n\n this.handleSend(message);\n this._notifyEventSubscribers(\"send\");\n }\n\n public cancel() {\n this.handleCancel();\n }\n\n protected abstract handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n ): void;\n protected abstract handleCancel(): void;\n\n async addAttachment(file: File) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const attachment = await adapter.add({ file });\n\n this._attachments = [...this._attachments, attachment as PendingAttachment];\n this._notifyEventSubscribers(\"attachment_add\");\n this._notifySubscribers();\n }\n\n async removeAttachment(attachmentId: string) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const index = this._attachments.findIndex((a) => a.id === attachmentId);\n if (index === -1) throw new Error(\"Attachment not found\");\n const attachment = this._attachments[index]!;\n\n await adapter.remove(attachment);\n\n this._attachments = this._attachments.
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/composer/BaseComposerRuntimeCore.tsx"],"sourcesContent":["import {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n} from \"../../types/AttachmentTypes\";\nimport { AppendMessage } from \"../../types\";\nimport { AttachmentAdapter } from \"../attachment\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n} from \"../core/ComposerRuntimeCore\";\nimport { MessageRole, RunConfig } from \"../../types/AssistantTypes\";\nimport { BaseSubscribable } from \"../remote-thread-list/BaseSubscribable\";\n\nconst isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>\n a.status.type === \"complete\";\n\nexport abstract class BaseComposerRuntimeCore\n extends BaseSubscribable\n implements ComposerRuntimeCore\n{\n public readonly isEditing = true;\n\n protected abstract getAttachmentAdapter(): AttachmentAdapter | undefined;\n\n public getAttachmentAccept(): string {\n return this.getAttachmentAdapter()?.accept ?? \"*\";\n }\n\n private _attachments: readonly Attachment[] = [];\n public get attachments() {\n return this._attachments;\n }\n\n protected setAttachments(value: readonly Attachment[]) {\n this._attachments = value;\n this._notifySubscribers();\n }\n\n public abstract get canCancel(): boolean;\n\n public get isEmpty() {\n return !this.text.trim() && !this.attachments.length;\n }\n\n private _text = \"\";\n\n get text() {\n return this._text;\n }\n\n private _role: MessageRole = \"user\";\n\n get role() {\n return this._role;\n }\n\n private _runConfig: RunConfig = {};\n\n get runConfig() {\n return this._runConfig;\n }\n\n public setText(value: string) {\n if (this._text === value) return;\n\n this._text = value;\n this._notifySubscribers();\n }\n\n public setRole(role: MessageRole) {\n if (this._role === role) return;\n\n this._role = role;\n this._notifySubscribers();\n }\n\n public setRunConfig(runConfig: RunConfig) {\n if (this._runConfig === runConfig) return;\n\n this._runConfig = runConfig;\n this._notifySubscribers();\n }\n\n private _emptyTextAndAttachments() {\n this._attachments = [];\n this._text = \"\";\n this._notifySubscribers();\n }\n\n private async _onClearAttachments() {\n const adapter = this.getAttachmentAdapter();\n if (adapter) {\n await Promise.all(this._attachments.map((a) => adapter.remove(a)));\n }\n }\n\n public async reset() {\n if (\n this._attachments.length === 0 &&\n this._text === \"\" &&\n this._role === \"user\" &&\n Object.keys(this._runConfig).length === 0\n ) {\n return;\n }\n\n this._role = \"user\";\n this._runConfig = {};\n\n const task = this._onClearAttachments();\n this._emptyTextAndAttachments();\n await task;\n }\n\n public async clearAttachments() {\n const task = this._onClearAttachments();\n this.setAttachments([]);\n\n await task;\n }\n\n public async send() {\n const adapter = this.getAttachmentAdapter();\n const attachments =\n adapter && this.attachments.length > 0\n ? await Promise.all(\n this.attachments.map(async (a) => {\n if (isAttachmentComplete(a)) return a;\n const result = await adapter.send(a);\n return result as CompleteAttachment;\n }),\n )\n : [];\n\n const message: Omit<AppendMessage, \"parentId\" | \"sourceId\"> = {\n role: this.role,\n content: this.text ? [{ type: \"text\", text: this.text }] : [],\n attachments,\n runConfig: this.runConfig,\n };\n this._emptyTextAndAttachments();\n\n this.handleSend(message);\n this._notifyEventSubscribers(\"send\");\n }\n\n public cancel() {\n this.handleCancel();\n }\n\n protected abstract handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n ): void;\n protected abstract handleCancel(): void;\n\n async addAttachment(file: File) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const attachment = await adapter.add({ file });\n\n this._attachments = [...this._attachments, attachment as PendingAttachment];\n this._notifyEventSubscribers(\"attachment_add\");\n this._notifySubscribers();\n }\n\n async removeAttachment(attachmentId: string) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const index = this._attachments.findIndex((a) => a.id === attachmentId);\n if (index === -1) throw new Error(\"Attachment not found\");\n const attachment = this._attachments[index]!;\n\n await adapter.remove(attachment);\n\n // this._attachments.toSpliced(index, 1); - not yet widely supported\n this._attachments = [\n ...this._attachments.slice(0, index),\n ...this._attachments.slice(index + 1),\n ];\n this._notifySubscribers();\n }\n\n private _eventSubscribers = new Map<\n ComposerRuntimeEventType,\n Set<() => void>\n >();\n\n protected _notifyEventSubscribers(event: ComposerRuntimeEventType) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n for (const callback of subscribers) callback();\n }\n\n public unstable_on(event: ComposerRuntimeEventType, callback: () => void) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) {\n this._eventSubscribers.set(event, new Set([callback]));\n } else {\n subscribers.add(callback);\n }\n\n return () => {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n subscribers.delete(callback);\n };\n }\n}\n"],"mappings":";AAYA,SAAS,wBAAwB;AAEjC,IAAM,uBAAuB,CAAC,MAC5B,EAAE,OAAO,SAAS;AAEb,IAAe,0BAAf,cACG,iBAEV;AAAA,EACkB,YAAY;AAAA,EAIrB,sBAA8B;AACnC,WAAO,KAAK,qBAAqB,GAAG,UAAU;AAAA,EAChD;AAAA,EAEQ,eAAsC,CAAC;AAAA,EAC/C,IAAW,cAAc;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEU,eAAe,OAA8B;AACrD,SAAK,eAAe;AACpB,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAIA,IAAW,UAAU;AACnB,WAAO,CAAC,KAAK,KAAK,KAAK,KAAK,CAAC,KAAK,YAAY;AAAA,EAChD;AAAA,EAEQ,QAAQ;AAAA,EAEhB,IAAI,OAAO;AACT,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ,QAAqB;AAAA,EAE7B,IAAI,OAAO;AACT,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ,aAAwB,CAAC;AAAA,EAEjC,IAAI,YAAY;AACd,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,QAAQ,OAAe;AAC5B,QAAI,K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W,YAAY,YAAa,UAAS;AAAA,EAC/C;AAAA,EAEO,YAAY,OAAiC,UAAsB;AACxE,UAAM,cAAc,KAAK,kBAAkB,IAAI,KAAK;AACpD,QAAI,CAAC,aAAa;AAChB,WAAK,kBAAkB,IAAI,OAAO,oBAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;AAAA,IACvD,OAAO;AACL,kBAAY,IAAI,QAAQ;AAAA,IAC1B;AAEA,WAAO,MAAM;AACX,YAAMA,eAAc,KAAK,kBAAkB,IAAI,KAAK;AACpD,UAAI,CAACA,aAAa;AAClB,MAAAA,aAAY,OAAO,QAAQ;AAAA,IAC7B;AAAA,EACF;AACF;","names":["subscribers"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FC, PropsWithChildren, ComponentType } from "react";
|
|
2
2
|
import { BaseSubscribable } from "./BaseSubscribable";
|
|
3
|
-
import {
|
|
3
|
+
import { AssistantRuntime } from "../../api";
|
|
4
|
+
type RemoteThreadListHook = () => AssistantRuntime;
|
|
4
5
|
export declare class RemoteThreadListHookInstanceManager extends BaseSubscribable {
|
|
5
6
|
private useRuntimeHook;
|
|
6
7
|
private instances;
|
|
@@ -74,4 +75,5 @@ export declare class RemoteThreadListHookInstanceManager extends BaseSubscribabl
|
|
|
74
75
|
provider: ComponentType<PropsWithChildren>;
|
|
75
76
|
}>;
|
|
76
77
|
}
|
|
78
|
+
export {};
|
|
77
79
|
//# sourceMappingURL=RemoteThreadListHookInstanceManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteThreadListHookInstanceManager.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,EAAE,EAMF,iBAAiB,EACjB,aAAa,EACd,MAAM,OAAO,CAAC;AAMf,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"RemoteThreadListHookInstanceManager.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,EAAE,EAMF,iBAAiB,EACjB,aAAa,EACd,MAAM,OAAO,CAAC;AAMf,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,KAAK,oBAAoB,GAAG,MAAM,gBAAgB,CAAC;AAKnD,qBAAa,mCAAoC,SAAQ,gBAAgB;IACvE,OAAO,CAAC,cAAc,CAEpB;IACF,OAAO,CAAC,SAAS,CAAmD;IACpE,OAAO,CAAC,0BAA0B,CAAsB;gBAE5C,WAAW,EAAE,oBAAoB;IAKtC,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwBnC,oBAAoB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IASrC,iBAAiB,CAAC,QAAQ,EAAE,MAAM;IAKlC,cAAc,CAAC,cAAc,EAAE,oBAAoB;IAO1D,OAAO,CAAC,0BAA0B,CAiChC;IAEF,OAAO,CAAC,0BAA0B,CAiB/B;IAEI,+BAA+B,EAAE,EAAE,CAAC;QACzC,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;KAC5C,CAAC,CAUA;CACH"}
|
|
@@ -114,7 +114,7 @@ var RemoteThreadListHookInstanceManager = class extends import_BaseSubscribable.
|
|
|
114
114
|
});
|
|
115
115
|
__internal_RenderThreadRuntimes = ({ provider }) => {
|
|
116
116
|
this.useAliveThreadsKeysChanged();
|
|
117
|
-
return this.instances.keys().map((threadId) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
117
|
+
return Array.from(this.instances.keys()).map((threadId) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
118
|
this._OuterActiveThreadProvider,
|
|
119
119
|
{
|
|
120
120
|
threadId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n FC,\n useCallback,\n useRef,\n useEffect,\n memo,\n useMemo,\n PropsWithChildren,\n ComponentType,\n} from \"react\";\nimport { UseBoundStore, StoreApi, create } from \"zustand\";\nimport { useAssistantRuntime } from \"../../context\";\nimport { ThreadListItemRuntimeProvider } from \"../../context/providers/ThreadListItemRuntimeProvider\";\nimport { useThreadListItem } from \"../../context/react/ThreadListItemContext\";\nimport { ThreadRuntimeCore, ThreadRuntimeImpl } from \"../../internal\";\nimport { BaseSubscribable } from \"./BaseSubscribable\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n FC,\n useCallback,\n useRef,\n useEffect,\n memo,\n useMemo,\n PropsWithChildren,\n ComponentType,\n} from \"react\";\nimport { UseBoundStore, StoreApi, create } from \"zustand\";\nimport { useAssistantRuntime } from \"../../context\";\nimport { ThreadListItemRuntimeProvider } from \"../../context/providers/ThreadListItemRuntimeProvider\";\nimport { useThreadListItem } from \"../../context/react/ThreadListItemContext\";\nimport { ThreadRuntimeCore, ThreadRuntimeImpl } from \"../../internal\";\nimport { BaseSubscribable } from \"./BaseSubscribable\";\nimport { AssistantRuntime } from \"../../api\";\n\ntype RemoteThreadListHook = () => AssistantRuntime;\n\ntype RemoteThreadListHookInstance = {\n runtime?: ThreadRuntimeCore;\n};\nexport class RemoteThreadListHookInstanceManager extends BaseSubscribable {\n private useRuntimeHook: UseBoundStore<\n StoreApi<{ useRuntime: RemoteThreadListHook }>\n >;\n private instances = new Map<string, RemoteThreadListHookInstance>();\n private useAliveThreadsKeysChanged = create(() => ({}));\n\n constructor(runtimeHook: RemoteThreadListHook) {\n super();\n this.useRuntimeHook = create(() => ({ useRuntime: runtimeHook }));\n }\n\n public startThreadRuntime(threadId: string) {\n if (!this.instances.has(threadId)) {\n this.instances.set(threadId, {});\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n return new Promise<ThreadRuntimeCore>((resolve, reject) => {\n const callback = () => {\n const instance = this.instances.get(threadId);\n if (!instance) {\n dispose();\n reject(new Error(\"Thread was deleted before runtime was started\"));\n } else if (!instance.runtime) {\n return; // misc update\n } else {\n dispose();\n resolve(instance.runtime);\n }\n };\n const dispose = this.subscribe(callback);\n callback();\n });\n }\n\n public getThreadRuntimeCore(threadId: string) {\n const instance = this.instances.get(threadId);\n if (!instance)\n throw new Error(\n \"getThreadRuntimeCore not found. This is a bug in assistant-ui.\",\n );\n return instance.runtime;\n }\n\n public stopThreadRuntime(threadId: string) {\n this.instances.delete(threadId);\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n public setRuntimeHook(newRuntimeHook: RemoteThreadListHook) {\n const prevRuntimeHook = this.useRuntimeHook.getState().useRuntime;\n if (prevRuntimeHook !== newRuntimeHook) {\n this.useRuntimeHook.setState({ useRuntime: newRuntimeHook }, true);\n }\n }\n\n private _InnerActiveThreadProvider: FC = () => {\n const { id } = useThreadListItem();\n\n const { useRuntime } = this.useRuntimeHook();\n const runtime = useRuntime();\n\n const threadBinding = (runtime.thread as ThreadRuntimeImpl)\n .__internal_threadBinding;\n\n const updateRuntime = useCallback(() => {\n const aliveThread = this.instances.get(id);\n if (!aliveThread)\n throw new Error(\"Thread not found. This is a bug in assistant-ui.\");\n\n aliveThread.runtime = threadBinding.getState();\n\n if (isMounted) {\n this._notifySubscribers();\n }\n }, [id, threadBinding]);\n\n const isMounted = useRef(false);\n if (!isMounted.current) {\n updateRuntime();\n }\n\n useEffect(() => {\n isMounted.current = true;\n updateRuntime();\n return threadBinding.outerSubscribe(updateRuntime);\n }, [threadBinding]);\n\n return null;\n };\n\n private _OuterActiveThreadProvider: FC<{\n threadId: string;\n provider: ComponentType<PropsWithChildren>;\n }> = memo(({ threadId, provider: Provider }) => {\n const assistantRuntime = useAssistantRuntime();\n const threadListItemRuntime = useMemo(\n () => assistantRuntime.threadList.getItemById(threadId),\n [assistantRuntime, threadId],\n );\n\n return (\n <ThreadListItemRuntimeProvider runtime={threadListItemRuntime}>\n <Provider>\n <this._InnerActiveThreadProvider />\n </Provider>\n </ThreadListItemRuntimeProvider>\n );\n });\n\n public __internal_RenderThreadRuntimes: FC<{\n provider: ComponentType<PropsWithChildren>;\n }> = ({ provider }) => {\n this.useAliveThreadsKeysChanged(); // trigger re-render on alive threads change\n\n return Array.from(this.instances.keys()).map((threadId) => (\n <this._OuterActiveThreadProvider\n key={threadId}\n threadId={threadId}\n provider={provider}\n />\n ));\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBASO;AACP,qBAAgD;AAChD,qBAAoC;AACpC,2CAA8C;AAC9C,mCAAkC;AAElC,8BAAiC;AAiHvB;AAzGH,IAAM,sCAAN,cAAkD,yCAAiB;AAAA,EAChE;AAAA,EAGA,YAAY,oBAAI,IAA0C;AAAA,EAC1D,iCAA6B,uBAAO,OAAO,CAAC,EAAE;AAAA,EAEtD,YAAY,aAAmC;AAC7C,UAAM;AACN,SAAK,qBAAiB,uBAAO,OAAO,EAAE,YAAY,YAAY,EAAE;AAAA,EAClE;AAAA,EAEO,mBAAmB,UAAkB;AAC1C,QAAI,CAAC,KAAK,UAAU,IAAI,QAAQ,GAAG;AACjC,WAAK,UAAU,IAAI,UAAU,CAAC,CAAC;AAC/B,WAAK,2BAA2B,SAAS,CAAC,GAAG,IAAI;AAAA,IACnD;AAEA,WAAO,IAAI,QAA2B,CAAC,SAAS,WAAW;AACzD,YAAM,WAAW,MAAM;AACrB,cAAM,WAAW,KAAK,UAAU,IAAI,QAAQ;AAC5C,YAAI,CAAC,UAAU;AACb,kBAAQ;AACR,iBAAO,IAAI,MAAM,+CAA+C,CAAC;AAAA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,aAAa;AAAA,IACnD,GAAG,CAAC,aAAa,CAAC;AAElB,WAAO;AAAA,EACT;AAAA,EAEQ,iCAGH,mBAAK,CAAC,EAAE,UAAU,UAAU,SAAS,MAAM;AAC9C,UAAM,uBAAmB,oCAAoB;AAC7C,UAAM,4BAAwB;AAAA,MAC5B,MAAM,iBAAiB,WAAW,YAAY,QAAQ;AAAA,MACtD,CAAC,kBAAkB,QAAQ;AAAA,IAC7B;AAEA,WACE,4CAAC,sEAA8B,SAAS,uBACtC,sDAAC,YACC,sDAAC,KAAK,4BAAL,EAAgC,GACnC,GACF;AAAA,EAEJ,CAAC;AAAA,EAEM,kCAEF,CAAC,EAAE,SAAS,MAAM;AACrB,SAAK,2BAA2B;AAEhC,WAAO,MAAM,KAAK,KAAK,UAAU,KAAK,CAAC,EAAE,IAAI,CAAC,aAC5C;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QAEC;AAAA,QACA;AAAA;AAAA,MAFK;AAAA,IAGP,CACD;AAAA,EACH;AACF;","names":[]}
|
|
@@ -97,7 +97,7 @@ var RemoteThreadListHookInstanceManager = class extends BaseSubscribable {
|
|
|
97
97
|
});
|
|
98
98
|
__internal_RenderThreadRuntimes = ({ provider }) => {
|
|
99
99
|
this.useAliveThreadsKeysChanged();
|
|
100
|
-
return this.instances.keys().map((threadId) => /* @__PURE__ */ jsx(
|
|
100
|
+
return Array.from(this.instances.keys()).map((threadId) => /* @__PURE__ */ jsx(
|
|
101
101
|
this._OuterActiveThreadProvider,
|
|
102
102
|
{
|
|
103
103
|
threadId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n FC,\n useCallback,\n useRef,\n useEffect,\n memo,\n useMemo,\n PropsWithChildren,\n ComponentType,\n} from \"react\";\nimport { UseBoundStore, StoreApi, create } from \"zustand\";\nimport { useAssistantRuntime } from \"../../context\";\nimport { ThreadListItemRuntimeProvider } from \"../../context/providers/ThreadListItemRuntimeProvider\";\nimport { useThreadListItem } from \"../../context/react/ThreadListItemContext\";\nimport { ThreadRuntimeCore, ThreadRuntimeImpl } from \"../../internal\";\nimport { BaseSubscribable } from \"./BaseSubscribable\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n FC,\n useCallback,\n useRef,\n useEffect,\n memo,\n useMemo,\n PropsWithChildren,\n ComponentType,\n} from \"react\";\nimport { UseBoundStore, StoreApi, create } from \"zustand\";\nimport { useAssistantRuntime } from \"../../context\";\nimport { ThreadListItemRuntimeProvider } from \"../../context/providers/ThreadListItemRuntimeProvider\";\nimport { useThreadListItem } from \"../../context/react/ThreadListItemContext\";\nimport { ThreadRuntimeCore, ThreadRuntimeImpl } from \"../../internal\";\nimport { BaseSubscribable } from \"./BaseSubscribable\";\nimport { AssistantRuntime } from \"../../api\";\n\ntype RemoteThreadListHook = () => AssistantRuntime;\n\ntype RemoteThreadListHookInstance = {\n runtime?: ThreadRuntimeCore;\n};\nexport class RemoteThreadListHookInstanceManager extends BaseSubscribable {\n private useRuntimeHook: UseBoundStore<\n StoreApi<{ useRuntime: RemoteThreadListHook }>\n >;\n private instances = new Map<string, RemoteThreadListHookInstance>();\n private useAliveThreadsKeysChanged = create(() => ({}));\n\n constructor(runtimeHook: RemoteThreadListHook) {\n super();\n this.useRuntimeHook = create(() => ({ useRuntime: runtimeHook }));\n }\n\n public startThreadRuntime(threadId: string) {\n if (!this.instances.has(threadId)) {\n this.instances.set(threadId, {});\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n return new Promise<ThreadRuntimeCore>((resolve, reject) => {\n const callback = () => {\n const instance = this.instances.get(threadId);\n if (!instance) {\n dispose();\n reject(new Error(\"Thread was deleted before runtime was started\"));\n } else if (!instance.runtime) {\n return; // misc update\n } else {\n dispose();\n resolve(instance.runtime);\n }\n };\n const dispose = this.subscribe(callback);\n callback();\n });\n }\n\n public getThreadRuntimeCore(threadId: string) {\n const instance = this.instances.get(threadId);\n if (!instance)\n throw new Error(\n \"getThreadRuntimeCore not found. This is a bug in assistant-ui.\",\n );\n return instance.runtime;\n }\n\n public stopThreadRuntime(threadId: string) {\n this.instances.delete(threadId);\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n public setRuntimeHook(newRuntimeHook: RemoteThreadListHook) {\n const prevRuntimeHook = this.useRuntimeHook.getState().useRuntime;\n if (prevRuntimeHook !== newRuntimeHook) {\n this.useRuntimeHook.setState({ useRuntime: newRuntimeHook }, true);\n }\n }\n\n private _InnerActiveThreadProvider: FC = () => {\n const { id } = useThreadListItem();\n\n const { useRuntime } = this.useRuntimeHook();\n const runtime = useRuntime();\n\n const threadBinding = (runtime.thread as ThreadRuntimeImpl)\n .__internal_threadBinding;\n\n const updateRuntime = useCallback(() => {\n const aliveThread = this.instances.get(id);\n if (!aliveThread)\n throw new Error(\"Thread not found. This is a bug in assistant-ui.\");\n\n aliveThread.runtime = threadBinding.getState();\n\n if (isMounted) {\n this._notifySubscribers();\n }\n }, [id, threadBinding]);\n\n const isMounted = useRef(false);\n if (!isMounted.current) {\n updateRuntime();\n }\n\n useEffect(() => {\n isMounted.current = true;\n updateRuntime();\n return threadBinding.outerSubscribe(updateRuntime);\n }, [threadBinding]);\n\n return null;\n };\n\n private _OuterActiveThreadProvider: FC<{\n threadId: string;\n provider: ComponentType<PropsWithChildren>;\n }> = memo(({ threadId, provider: Provider }) => {\n const assistantRuntime = useAssistantRuntime();\n const threadListItemRuntime = useMemo(\n () => assistantRuntime.threadList.getItemById(threadId),\n [assistantRuntime, threadId],\n );\n\n return (\n <ThreadListItemRuntimeProvider runtime={threadListItemRuntime}>\n <Provider>\n <this._InnerActiveThreadProvider />\n </Provider>\n </ThreadListItemRuntimeProvider>\n );\n });\n\n public __internal_RenderThreadRuntimes: FC<{\n provider: ComponentType<PropsWithChildren>;\n }> = ({ provider }) => {\n this.useAliveThreadsKeysChanged(); // trigger re-render on alive threads change\n\n return Array.from(this.instances.keys()).map((threadId) => (\n <this._OuterActiveThreadProvider\n key={threadId}\n threadId={threadId}\n provider={provider}\n />\n ));\n };\n}\n"],"mappings":";;;AAEA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAkC,cAAc;AAChD,SAAS,2BAA2B;AACpC,SAAS,qCAAqC;AAC9C,SAAS,yBAAyB;AAElC,SAAS,wBAAwB;AAiHvB;AAzGH,IAAM,sCAAN,cAAkD,iBAAiB;AAAA,EAChE;AAAA,EAGA,YAAY,oBAAI,IAA0C;AAAA,EAC1D,6BAA6B,OAAO,OAAO,CAAC,EAAE;AAAA,EAEtD,YAAY,aAAmC;AAC7C,UAAM;AACN,SAAK,iBAAiB,OAAO,OAAO,EAAE,YAAY,YAAY,EAAE;AAAA,EAClE;AAAA,EAEO,mBAAmB,UAAkB;AAC1C,QAAI,CAAC,KAAK,UAAU,IAAI,QAAQ,GAAG;AACjC,WAAK,UAAU,IAAI,UAAU,CAAC,CAAC;AAC/B,WAAK,2BAA2B,SAAS,CAAC,GAAG,IAAI;AAAA,IACnD;AAEA,WAAO,IAAI,QAA2B,CAAC,SAAS,WAAW;AACzD,YAAM,WAAW,MAAM;AACrB,cAAM,WAAW,KAAK,UAAU,IAAI,QAAQ;AAC5C,YAAI,CAAC,UAAU;AACb,kBAAQ;AACR,iBAAO,IAAI,MAAM,+CAA+C,CAAC;AAAA,QACnE,WAAW,CAAC,SAAS,SAAS;AAC5B;AAAA,QACF,OAAO;AACL,kBAAQ;AACR,kBAAQ,SAAS,OAAO;AAAA,QAC1B;AAAA,MACF;AACA,YAAM,UAAU,KAAK,UAAU,QAAQ;AACvC,eAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAEO,qBAAqB,UAAkB;AAC5C,UAAM,WAAW,KAAK,UAAU,IAAI,QAAQ;AAC5C,Q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,WACE,oBAAC,iCAA8B,SAAS,uBACtC,8BAAC,YACC,8BAAC,KAAK,4BAAL,EAAgC,GACnC,GACF;AAAA,EAEJ,CAAC;AAAA,EAEM,kCAEF,CAAC,EAAE,SAAS,MAAM;AACrB,SAAK,2BAA2B;AAEhC,WAAO,MAAM,KAAK,KAAK,UAAU,KAAK,CAAC,EAAE,IAAI,CAAC,aAC5C;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QAEC;AAAA,QACA;AAAA;AAAA,MAFK;AAAA,IAGP,CACD;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { useRemoteThreadListRuntime as unstable_useRemoteThreadListRuntime } from "./useRemoteThreadListRuntime";
|
|
2
|
+
export type { RemoteThreadListAdapter as unstable_RemoteThreadListAdapter, RemoteThreadListSubscriber as unstable_RemoteThreadListSubscriber, } from "./types";
|
|
1
3
|
export * from "./cloud";
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,IAAI,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AACjH,YAAY,EACV,uBAAuB,IAAI,gCAAgC,EAC3D,0BAA0B,IAAI,mCAAmC,GAClE,MAAM,SAAS,CAAC;AACjB,cAAc,SAAS,CAAC"}
|
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -16,10 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
20
|
|
|
17
21
|
// src/runtimes/remote-thread-list/index.ts
|
|
18
22
|
var remote_thread_list_exports = {};
|
|
23
|
+
__export(remote_thread_list_exports, {
|
|
24
|
+
unstable_useRemoteThreadListRuntime: () => import_useRemoteThreadListRuntime.useRemoteThreadListRuntime
|
|
25
|
+
});
|
|
19
26
|
module.exports = __toCommonJS(remote_thread_list_exports);
|
|
27
|
+
var import_useRemoteThreadListRuntime = require("./useRemoteThreadListRuntime.js");
|
|
20
28
|
__reExport(remote_thread_list_exports, require("./cloud/index.js"), module.exports);
|
|
21
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
30
|
0 && (module.exports = {
|
|
31
|
+
unstable_useRemoteThreadListRuntime,
|
|
23
32
|
...require("./cloud/index.js")
|
|
24
33
|
});
|
|
25
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/index.ts"],"sourcesContent":["export { useRemoteThreadListRuntime as unstable_useRemoteThreadListRuntime } from \"./useRemoteThreadListRuntime\";\nexport type {\n RemoteThreadListAdapter as unstable_RemoteThreadListAdapter,\n RemoteThreadListSubscriber as unstable_RemoteThreadListSubscriber,\n} from \"./types\";\nexport * from \"./cloud\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAAkF;AAKlF,uCAAc,6BALd;","names":[]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
// src/runtimes/remote-thread-list/index.ts
|
|
2
|
+
import { useRemoteThreadListRuntime } from "./useRemoteThreadListRuntime.mjs";
|
|
2
3
|
export * from "./cloud/index.mjs";
|
|
4
|
+
export {
|
|
5
|
+
useRemoteThreadListRuntime as unstable_useRemoteThreadListRuntime
|
|
6
|
+
};
|
|
3
7
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/index.ts"],"sourcesContent":["export { useRemoteThreadListRuntime as unstable_useRemoteThreadListRuntime } from \"./useRemoteThreadListRuntime\";\nexport type {\n RemoteThreadListAdapter as unstable_RemoteThreadListAdapter,\n RemoteThreadListSubscriber as unstable_RemoteThreadListSubscriber,\n} from \"./types\";\nexport * from \"./cloud\";\n"],"mappings":";AAAA,SAAuC,kCAA2C;AAKlF,cAAc;","names":[]}
|
|
@@ -15,13 +15,12 @@ export type RemoteThreadMetadata = {
|
|
|
15
15
|
export type RemoteThreadListResponse = {
|
|
16
16
|
threads: RemoteThreadMetadata[];
|
|
17
17
|
};
|
|
18
|
-
export type RemoteThreadListHook = () => AssistantRuntime;
|
|
19
18
|
export type RemoteThreadListSubscriber = {
|
|
20
19
|
onInitialize: (threadId: string, begin: () => Promise<RemoteThreadInitializeResponse>) => void;
|
|
21
20
|
onGenerateTitle: (threadId: string, begin: () => Promise<AssistantStream>) => void;
|
|
22
21
|
};
|
|
23
22
|
export type RemoteThreadListAdapter = {
|
|
24
|
-
runtimeHook:
|
|
23
|
+
runtimeHook: () => AssistantRuntime;
|
|
25
24
|
list(): Promise<RemoteThreadListResponse>;
|
|
26
25
|
rename(remoteId: string, newTitle: string): Promise<void>;
|
|
27
26
|
archive(remoteId: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/types.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,oBAAoB,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/types.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,MAA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PropsWithChildren } from \"react\";\nimport { AssistantRuntime } from \"../../api\";\nimport { Unsubscribe } from \"../../types\";\nimport { AssistantStream } from \"assistant-stream\";\n\nexport type RemoteThreadInitializeResponse = {\n remoteId: string;\n externalId: string | undefined;\n};\n\nexport type RemoteThreadMetadata = {\n readonly status: \"regular\" | \"archived\";\n readonly remoteId: string;\n readonly externalId?: string | undefined;\n readonly title?: string | undefined;\n};\n\nexport type RemoteThreadListResponse = {\n threads: RemoteThreadMetadata[];\n};\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/types.tsx"],"sourcesContent":["import { ComponentType, PropsWithChildren } from \"react\";\nimport { AssistantRuntime } from \"../../api\";\nimport { Unsubscribe } from \"../../types\";\nimport { AssistantStream } from \"assistant-stream\";\n\nexport type RemoteThreadInitializeResponse = {\n remoteId: string;\n externalId: string | undefined;\n};\n\nexport type RemoteThreadMetadata = {\n readonly status: \"regular\" | \"archived\";\n readonly remoteId: string;\n readonly externalId?: string | undefined;\n readonly title?: string | undefined;\n};\n\nexport type RemoteThreadListResponse = {\n threads: RemoteThreadMetadata[];\n};\n\nexport type RemoteThreadListSubscriber = {\n onInitialize: (\n threadId: string,\n begin: () => Promise<RemoteThreadInitializeResponse>,\n ) => void;\n onGenerateTitle: (\n threadId: string,\n begin: () => Promise<AssistantStream>,\n ) => void;\n};\n\nexport type RemoteThreadListAdapter = {\n runtimeHook: () => AssistantRuntime;\n\n list(): Promise<RemoteThreadListResponse>;\n\n rename(remoteId: string, newTitle: string): Promise<void>;\n archive(remoteId: string): Promise<void>;\n unarchive(remoteId: string): Promise<void>;\n delete(remoteId: string): Promise<void>;\n\n subscribe(subscriber: RemoteThreadListSubscriber): Unsubscribe;\n\n unstable_Provider?: ComponentType<PropsWithChildren>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"conversational-ui",
|
|
30
30
|
"conversational-ai"
|
|
31
31
|
],
|
|
32
|
-
"version": "0.7.
|
|
32
|
+
"version": "0.7.41",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"exports": {
|
|
35
35
|
".": {
|
|
@@ -117,9 +117,9 @@
|
|
|
117
117
|
"tailwindcss": "^3.4.17",
|
|
118
118
|
"tailwindcss-animate": "^1.0.7",
|
|
119
119
|
"tsx": "^4.19.2",
|
|
120
|
-
"@assistant-ui/tailwindcss-transformer": "0.1.0",
|
|
121
120
|
"@assistant-ui/tsbuildutils": "^0.0.1",
|
|
122
|
-
"@assistant-ui/tsconfig": "0.0.0"
|
|
121
|
+
"@assistant-ui/tsconfig": "0.0.0",
|
|
122
|
+
"@assistant-ui/tailwindcss-transformer": "0.1.0"
|
|
123
123
|
},
|
|
124
124
|
"publishConfig": {
|
|
125
125
|
"access": "public",
|
|
@@ -175,7 +175,11 @@ export abstract class BaseComposerRuntimeCore
|
|
|
175
175
|
|
|
176
176
|
await adapter.remove(attachment);
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
// this._attachments.toSpliced(index, 1); - not yet widely supported
|
|
179
|
+
this._attachments = [
|
|
180
|
+
...this._attachments.slice(0, index),
|
|
181
|
+
...this._attachments.slice(index + 1),
|
|
182
|
+
];
|
|
179
183
|
this._notifySubscribers();
|
|
180
184
|
}
|
|
181
185
|
|
|
@@ -16,7 +16,9 @@ import { ThreadListItemRuntimeProvider } from "../../context/providers/ThreadLis
|
|
|
16
16
|
import { useThreadListItem } from "../../context/react/ThreadListItemContext";
|
|
17
17
|
import { ThreadRuntimeCore, ThreadRuntimeImpl } from "../../internal";
|
|
18
18
|
import { BaseSubscribable } from "./BaseSubscribable";
|
|
19
|
-
import {
|
|
19
|
+
import { AssistantRuntime } from "../../api";
|
|
20
|
+
|
|
21
|
+
type RemoteThreadListHook = () => AssistantRuntime;
|
|
20
22
|
|
|
21
23
|
type RemoteThreadListHookInstance = {
|
|
22
24
|
runtime?: ThreadRuntimeCore;
|
|
@@ -137,14 +139,12 @@ export class RemoteThreadListHookInstanceManager extends BaseSubscribable {
|
|
|
137
139
|
}> = ({ provider }) => {
|
|
138
140
|
this.useAliveThreadsKeysChanged(); // trigger re-render on alive threads change
|
|
139
141
|
|
|
140
|
-
return this.instances
|
|
141
|
-
.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
/>
|
|
148
|
-
));
|
|
142
|
+
return Array.from(this.instances.keys()).map((threadId) => (
|
|
143
|
+
<this._OuterActiveThreadProvider
|
|
144
|
+
key={threadId}
|
|
145
|
+
threadId={threadId}
|
|
146
|
+
provider={provider}
|
|
147
|
+
/>
|
|
148
|
+
));
|
|
149
149
|
};
|
|
150
150
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
export { useRemoteThreadListRuntime as unstable_useRemoteThreadListRuntime } from "./useRemoteThreadListRuntime";
|
|
2
|
+
export type {
|
|
3
|
+
RemoteThreadListAdapter as unstable_RemoteThreadListAdapter,
|
|
4
|
+
RemoteThreadListSubscriber as unstable_RemoteThreadListSubscriber,
|
|
5
|
+
} from "./types";
|
|
2
6
|
export * from "./cloud";
|
|
@@ -19,8 +19,6 @@ export type RemoteThreadListResponse = {
|
|
|
19
19
|
threads: RemoteThreadMetadata[];
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type RemoteThreadListHook = () => AssistantRuntime;
|
|
23
|
-
|
|
24
22
|
export type RemoteThreadListSubscriber = {
|
|
25
23
|
onInitialize: (
|
|
26
24
|
threadId: string,
|
|
@@ -33,7 +31,7 @@ export type RemoteThreadListSubscriber = {
|
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
export type RemoteThreadListAdapter = {
|
|
36
|
-
runtimeHook:
|
|
34
|
+
runtimeHook: () => AssistantRuntime;
|
|
37
35
|
|
|
38
36
|
list(): Promise<RemoteThreadListResponse>;
|
|
39
37
|
|