@assistant-ui/react 0.7.86 → 0.7.87
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/AssistantRuntime.d.ts +10 -3
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js +8 -6
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs +8 -8
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/cloud/useCloudThreadListRuntime.d.ts +1 -1
- package/dist/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/model-context/ModelContextTypes.d.ts +1 -1
- package/dist/model-context/ModelContextTypes.d.ts.map +1 -1
- package/dist/model-context/ModelContextTypes.js +2 -1
- package/dist/model-context/ModelContextTypes.js.map +1 -1
- package/dist/model-context/ModelContextTypes.mjs +2 -1
- package/dist/model-context/ModelContextTypes.mjs.map +1 -1
- package/dist/model-context/index.d.ts +2 -0
- package/dist/model-context/index.d.ts.map +1 -1
- package/dist/model-context/index.js +6 -0
- package/dist/model-context/index.js.map +1 -1
- package/dist/model-context/index.mjs +4 -0
- package/dist/model-context/index.mjs.map +1 -1
- package/dist/model-context/makeAssistantReadable.d.ts +6 -0
- package/dist/model-context/makeAssistantReadable.d.ts.map +1 -0
- package/dist/model-context/makeAssistantReadable.js +86 -0
- package/dist/model-context/makeAssistantReadable.js.map +1 -0
- package/dist/model-context/makeAssistantReadable.mjs +69 -0
- package/dist/model-context/makeAssistantReadable.mjs.map +1 -0
- package/dist/model-context/tool.d.ts +12 -0
- package/dist/model-context/tool.d.ts.map +1 -0
- package/dist/model-context/tool.js +33 -0
- package/dist/model-context/tool.js.map +1 -0
- package/dist/model-context/tool.mjs +8 -0
- package/dist/model-context/tool.mjs.map +1 -0
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.js +2 -0
- package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.mjs +2 -0
- package/dist/runtimes/core/BaseThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.d.ts +1 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.d.ts.map +1 -1
- package/dist/runtimes/edge/useEdgeRuntime.d.ts +1 -1
- package/dist/runtimes/edge/useEdgeRuntime.d.ts.map +1 -1
- package/dist/runtimes/external-store/useExternalStoreRuntime.d.ts +2 -1
- package/dist/runtimes/external-store/useExternalStoreRuntime.d.ts.map +1 -1
- package/dist/runtimes/external-store/useExternalStoreRuntime.js +1 -5
- package/dist/runtimes/external-store/useExternalStoreRuntime.js.map +1 -1
- package/dist/runtimes/external-store/useExternalStoreRuntime.mjs +1 -5
- package/dist/runtimes/external-store/useExternalStoreRuntime.mjs.map +1 -1
- package/dist/runtimes/index.d.ts +1 -0
- package/dist/runtimes/index.d.ts.map +1 -1
- package/dist/runtimes/index.js +9 -0
- package/dist/runtimes/index.js.map +1 -1
- package/dist/runtimes/index.mjs +4 -0
- package/dist/runtimes/index.mjs.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts +0 -4
- package/dist/runtimes/local/LocalRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.js +2 -23
- package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.mjs +2 -23
- package/dist/runtimes/local/LocalRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.d.ts +2 -6
- package/dist/runtimes/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.js +2 -19
- package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.mjs +2 -21
- package/dist/runtimes/local/useLocalRuntime.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +4 -4
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +4 -4
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts +2 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs.map +1 -1
- package/dist/runtimes/utils/MessageRepository.d.ts +7 -2
- package/dist/runtimes/utils/MessageRepository.d.ts.map +1 -1
- package/dist/runtimes/utils/MessageRepository.js +26 -0
- package/dist/runtimes/utils/MessageRepository.js.map +1 -1
- package/dist/runtimes/utils/MessageRepository.mjs +26 -1
- package/dist/runtimes/utils/MessageRepository.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/AssistantRuntime.ts +15 -22
- package/src/model-context/ModelContextTypes.ts +4 -2
- package/src/model-context/index.ts +3 -0
- package/src/model-context/makeAssistantReadable.tsx +81 -0
- package/src/model-context/tool.ts +26 -0
- package/src/runtimes/core/BaseThreadRuntimeCore.tsx +2 -1
- package/src/runtimes/external-store/useExternalStoreRuntime.tsx +1 -5
- package/src/runtimes/index.ts +2 -0
- package/src/runtimes/local/LocalRuntimeCore.tsx +1 -33
- package/src/runtimes/local/useLocalRuntime.tsx +2 -29
- package/src/runtimes/remote-thread-list/useRemoteThreadListRuntime.tsx +1 -1
- package/src/runtimes/utils/MessageRepository.tsx +33 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BaseThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/core/BaseThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAA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D,eAAe;IAItB,OAAO,CAAC,cAAc,CAAqD;IACpE,eAAe,CAAC,SAAS,EAAE,MAAM;IAGjC,SAAS,CAAC,SAAS,EAAE,MAAM;IAe3B,cAAc,CAAC,SAAS,EAAE,MAAM;;;;IAIhC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAIxC,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK7C,SAAS,CAAC,kBAAkB;IAIrB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB;IAOrD,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;IAKnD,OAAO,CAAC,kBAAkB,CAAyC;IAE5D,oBAAoB,CAAC,SAAS,EAAE,MAAM;IAItC,cAAc,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,qBAAqB;IAWhE,OAAO,CAAC,aAAa,CAA0B;IACxC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IAEhC,KAAK,CAAC,SAAS,EAAE,MAAM;IA8BvB,YAAY;IAMnB,SAAS,CAAC,iBAAiB;IAQpB,MAAM;IAIN,MAAM,CAAC,IAAI,EAAE,yBAAyB;IAO7C,OAAO,CAAC,iBAAiB,CAGrB;IAEG,WAAW,CAAC,KAAK,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,IAAI;CAiBvE"}
|
@@ -129,11 +129,13 @@ var BaseThreadRuntimeCore = class {
|
|
129
129
|
this._notifyEventSubscribers("initialize");
|
130
130
|
}
|
131
131
|
}
|
132
|
+
// TODO import()/export() on external store doesn't make much sense
|
132
133
|
export() {
|
133
134
|
return this.repository.export();
|
134
135
|
}
|
135
136
|
import(data) {
|
136
137
|
this.ensureInitialized();
|
138
|
+
this.repository.clear();
|
137
139
|
this.repository.import(data);
|
138
140
|
this._notifySubscribers();
|
139
141
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/core/BaseThreadRuntimeCore.tsx"],"sourcesContent":["import type { AppendMessage, Unsubscribe } from \"../../types\";\nimport {\n ExportedMessageRepository,\n MessageRepository,\n} from \"../utils/MessageRepository\";\nimport { DefaultThreadComposerRuntimeCore } from \"../composer/DefaultThreadComposerRuntimeCore\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n SubmitFeedbackOptions,\n ThreadRuntimeCore,\n SpeechState,\n RuntimeCapabilities,\n SubmittedFeedback,\n ThreadRuntimeEventType,\n StartRunConfig,\n} from \"../core/ThreadRuntimeCore\";\nimport { DefaultEditComposerRuntimeCore } from \"../composer/DefaultEditComposerRuntimeCore\";\nimport { SpeechSynthesisAdapter } from \"../adapters/speech/SpeechAdapterTypes\";\nimport { FeedbackAdapter } from \"../adapters/feedback/FeedbackAdapter\";\nimport { AttachmentAdapter } from \"../adapters/attachment\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport { ModelContextProvider } from \"../../model-context\";\n\ntype BaseThreadAdapters = {\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n};\n\nexport abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {\n private _subscriptions = new Set<() => void>();\n private _isInitialized = false;\n\n protected readonly repository = new MessageRepository();\n public abstract get adapters(): BaseThreadAdapters | undefined;\n public abstract get isDisabled(): boolean;\n public abstract get suggestions(): readonly ThreadSuggestion[];\n public abstract get extras(): unknown;\n\n public abstract get capabilities(): RuntimeCapabilities;\n public abstract append(message: AppendMessage): void;\n public abstract startRun(config: StartRunConfig): void;\n public abstract addToolResult(options: AddToolResultOptions): void;\n public abstract cancelRun(): void;\n\n public get messages() {\n return this.repository.getMessages();\n }\n\n public readonly composer = new DefaultThreadComposerRuntimeCore(this);\n\n constructor(private readonly _contextProvider: ModelContextProvider) {}\n\n public getModelContext() {\n return this._contextProvider.getModelContext();\n }\n\n private _editComposers = new Map<string, DefaultEditComposerRuntimeCore>();\n public getEditComposer(messageId: string) {\n return this._editComposers.get(messageId);\n }\n public beginEdit(messageId: string) {\n if (this._editComposers.has(messageId))\n throw new Error(\"Edit already in progress\");\n\n this._editComposers.set(\n messageId,\n new DefaultEditComposerRuntimeCore(\n this,\n () => this._editComposers.delete(messageId),\n this.repository.getMessage(messageId),\n ),\n );\n this._notifySubscribers();\n }\n\n public getMessageById(messageId: string) {\n return this.repository.getMessage(messageId);\n }\n\n public getBranches(messageId: string): string[] {\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this._notifySubscribers();\n }\n\n protected _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n\n public _notifyEventSubscribers(event: ThreadRuntimeEventType) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n for (const callback of subscribers) callback();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _submittedFeedback: Record<string, SubmittedFeedback> = {};\n\n public getSubmittedFeedback(messageId: string) {\n return this._submittedFeedback[messageId];\n }\n\n public submitFeedback({ messageId, type }: SubmitFeedbackOptions) {\n const adapter = this.adapters?.feedback;\n if (!adapter) throw new Error(\"Feedback adapter not configured\");\n\n const { message } = this.repository.getMessage(messageId);\n adapter.submit({ message, type });\n\n this._submittedFeedback[messageId] = { type };\n this._notifySubscribers();\n }\n\n private _stopSpeaking: Unsubscribe | undefined;\n public speech: SpeechState | undefined;\n\n public speak(messageId: string) {\n const adapter = this.adapters?.speech;\n if (!adapter) throw new Error(\"Speech adapter not configured\");\n\n const { message } = this.repository.getMessage(messageId);\n\n this._stopSpeaking?.();\n\n const utterance = adapter.speak(getThreadMessageText(message));\n const unsub = utterance.subscribe(() => {\n if (utterance.status.type === \"ended\") {\n this._stopSpeaking = undefined;\n this.speech = undefined;\n } else {\n this.speech = { messageId, status: utterance.status };\n }\n this._notifySubscribers();\n });\n\n this.speech = { messageId, status: utterance.status };\n this._notifySubscribers();\n\n this._stopSpeaking = () => {\n utterance.cancel();\n unsub();\n this.speech = undefined;\n this._stopSpeaking = undefined;\n };\n }\n\n public stopSpeaking() {\n if (!this._stopSpeaking) throw new Error(\"No message is being spoken\");\n this._stopSpeaking();\n this._notifySubscribers();\n }\n\n protected ensureInitialized() {\n if (!this._isInitialized) {\n this._isInitialized = true;\n this._notifyEventSubscribers(\"initialize\");\n }\n }\n\n public export() {\n return this.repository.export();\n }\n\n public import(data: ExportedMessageRepository) {\n this.ensureInitialized();\n
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/core/BaseThreadRuntimeCore.tsx"],"sourcesContent":["import type { AppendMessage, Unsubscribe } from \"../../types\";\nimport {\n ExportedMessageRepository,\n MessageRepository,\n} from \"../utils/MessageRepository\";\nimport { DefaultThreadComposerRuntimeCore } from \"../composer/DefaultThreadComposerRuntimeCore\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n SubmitFeedbackOptions,\n ThreadRuntimeCore,\n SpeechState,\n RuntimeCapabilities,\n SubmittedFeedback,\n ThreadRuntimeEventType,\n StartRunConfig,\n} from \"../core/ThreadRuntimeCore\";\nimport { DefaultEditComposerRuntimeCore } from \"../composer/DefaultEditComposerRuntimeCore\";\nimport { SpeechSynthesisAdapter } from \"../adapters/speech/SpeechAdapterTypes\";\nimport { FeedbackAdapter } from \"../adapters/feedback/FeedbackAdapter\";\nimport { AttachmentAdapter } from \"../adapters/attachment\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport { ModelContextProvider } from \"../../model-context\";\n\ntype BaseThreadAdapters = {\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n};\n\nexport abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {\n private _subscriptions = new Set<() => void>();\n private _isInitialized = false;\n\n protected readonly repository = new MessageRepository();\n public abstract get adapters(): BaseThreadAdapters | undefined;\n public abstract get isDisabled(): boolean;\n public abstract get suggestions(): readonly ThreadSuggestion[];\n public abstract get extras(): unknown;\n\n public abstract get capabilities(): RuntimeCapabilities;\n public abstract append(message: AppendMessage): void;\n public abstract startRun(config: StartRunConfig): void;\n public abstract addToolResult(options: AddToolResultOptions): void;\n public abstract cancelRun(): void;\n\n public get messages() {\n return this.repository.getMessages();\n }\n\n public readonly composer = new DefaultThreadComposerRuntimeCore(this);\n\n constructor(private readonly _contextProvider: ModelContextProvider) {}\n\n public getModelContext() {\n return this._contextProvider.getModelContext();\n }\n\n private _editComposers = new Map<string, DefaultEditComposerRuntimeCore>();\n public getEditComposer(messageId: string) {\n return this._editComposers.get(messageId);\n }\n public beginEdit(messageId: string) {\n if (this._editComposers.has(messageId))\n throw new Error(\"Edit already in progress\");\n\n this._editComposers.set(\n messageId,\n new DefaultEditComposerRuntimeCore(\n this,\n () => this._editComposers.delete(messageId),\n this.repository.getMessage(messageId),\n ),\n );\n this._notifySubscribers();\n }\n\n public getMessageById(messageId: string) {\n return this.repository.getMessage(messageId);\n }\n\n public getBranches(messageId: string): string[] {\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this._notifySubscribers();\n }\n\n protected _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n\n public _notifyEventSubscribers(event: ThreadRuntimeEventType) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n for (const callback of subscribers) callback();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _submittedFeedback: Record<string, SubmittedFeedback> = {};\n\n public getSubmittedFeedback(messageId: string) {\n return this._submittedFeedback[messageId];\n }\n\n public submitFeedback({ messageId, type }: SubmitFeedbackOptions) {\n const adapter = this.adapters?.feedback;\n if (!adapter) throw new Error(\"Feedback adapter not configured\");\n\n const { message } = this.repository.getMessage(messageId);\n adapter.submit({ message, type });\n\n this._submittedFeedback[messageId] = { type };\n this._notifySubscribers();\n }\n\n private _stopSpeaking: Unsubscribe | undefined;\n public speech: SpeechState | undefined;\n\n public speak(messageId: string) {\n const adapter = this.adapters?.speech;\n if (!adapter) throw new Error(\"Speech adapter not configured\");\n\n const { message } = this.repository.getMessage(messageId);\n\n this._stopSpeaking?.();\n\n const utterance = adapter.speak(getThreadMessageText(message));\n const unsub = utterance.subscribe(() => {\n if (utterance.status.type === \"ended\") {\n this._stopSpeaking = undefined;\n this.speech = undefined;\n } else {\n this.speech = { messageId, status: utterance.status };\n }\n this._notifySubscribers();\n });\n\n this.speech = { messageId, status: utterance.status };\n this._notifySubscribers();\n\n this._stopSpeaking = () => {\n utterance.cancel();\n unsub();\n this.speech = undefined;\n this._stopSpeaking = undefined;\n };\n }\n\n public stopSpeaking() {\n if (!this._stopSpeaking) throw new Error(\"No message is being spoken\");\n this._stopSpeaking();\n this._notifySubscribers();\n }\n\n protected ensureInitialized() {\n if (!this._isInitialized) {\n this._isInitialized = true;\n this._notifyEventSubscribers(\"initialize\");\n }\n }\n\n // TODO import()/export() on external store doesn't make much sense\n public export() {\n return this.repository.export();\n }\n\n public import(data: ExportedMessageRepository) {\n this.ensureInitialized();\n this.repository.clear();\n this.repository.import(data);\n this._notifySubscribers();\n }\n\n private _eventSubscribers = new Map<\n ThreadRuntimeEventType,\n Set<() => void>\n >();\n\n public unstable_on(event: ThreadRuntimeEventType, callback: () => void) {\n if (event === \"model-context-update\") {\n return this._contextProvider.subscribe?.(callback) ?? (() => {});\n }\n\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 subscribers.delete(callback);\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,+BAGO;AACP,8CAAiD;AAYjD,4CAA+C;AAI/C,kCAAqC;AAS9B,IAAe,wBAAf,MAAkE;AAAA,EA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AAmB;AAAA,EAC1B;AAAA,EAEU,oBAAoB;AAC5B,QAAI,CAAC,KAAK,gBAAgB;AACxB,WAAK,iBAAiB;AACtB,WAAK,wBAAwB,YAAY;AAAA,IAC3C;AAAA,EACF;AAAA;AAAA,EAGO,SAAS;AACd,WAAO,KAAK,WAAW,OAAO;AAAA,EAChC;AAAA,EAEO,OAAO,MAAiC;AAC7C,SAAK,kBAAkB;AACvB,SAAK,WAAW,MAAM;AACtB,SAAK,WAAW,OAAO,IAAI;AAC3B,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEQ,oBAAoB,oBAAI,IAG9B;AAAA,EAEK,YAAY,OAA+B,UAAsB;AACtE,QAAI,UAAU,wBAAwB;AACpC,aAAO,KAAK,iBAAiB,YAAY,QAAQ,MAAM,MAAM;AAAA,MAAC;AAAA,IAChE;AAEA,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,MAAAA,aAAY,OAAO,QAAQ;AAAA,IAC7B;AAAA,EACF;AACF;","names":["subscribers"]}
|
@@ -107,11 +107,13 @@ var BaseThreadRuntimeCore = class {
|
|
107
107
|
this._notifyEventSubscribers("initialize");
|
108
108
|
}
|
109
109
|
}
|
110
|
+
// TODO import()/export() on external store doesn't make much sense
|
110
111
|
export() {
|
111
112
|
return this.repository.export();
|
112
113
|
}
|
113
114
|
import(data) {
|
114
115
|
this.ensureInitialized();
|
116
|
+
this.repository.clear();
|
115
117
|
this.repository.import(data);
|
116
118
|
this._notifySubscribers();
|
117
119
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/core/BaseThreadRuntimeCore.tsx"],"sourcesContent":["import type { AppendMessage, Unsubscribe } from \"../../types\";\nimport {\n ExportedMessageRepository,\n MessageRepository,\n} from \"../utils/MessageRepository\";\nimport { DefaultThreadComposerRuntimeCore } from \"../composer/DefaultThreadComposerRuntimeCore\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n SubmitFeedbackOptions,\n ThreadRuntimeCore,\n SpeechState,\n RuntimeCapabilities,\n SubmittedFeedback,\n ThreadRuntimeEventType,\n StartRunConfig,\n} from \"../core/ThreadRuntimeCore\";\nimport { DefaultEditComposerRuntimeCore } from \"../composer/DefaultEditComposerRuntimeCore\";\nimport { SpeechSynthesisAdapter } from \"../adapters/speech/SpeechAdapterTypes\";\nimport { FeedbackAdapter } from \"../adapters/feedback/FeedbackAdapter\";\nimport { AttachmentAdapter } from \"../adapters/attachment\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport { ModelContextProvider } from \"../../model-context\";\n\ntype BaseThreadAdapters = {\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n};\n\nexport abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {\n private _subscriptions = new Set<() => void>();\n private _isInitialized = false;\n\n protected readonly repository = new MessageRepository();\n public abstract get adapters(): BaseThreadAdapters | undefined;\n public abstract get isDisabled(): boolean;\n public abstract get suggestions(): readonly ThreadSuggestion[];\n public abstract get extras(): unknown;\n\n public abstract get capabilities(): RuntimeCapabilities;\n public abstract append(message: AppendMessage): void;\n public abstract startRun(config: StartRunConfig): void;\n public abstract addToolResult(options: AddToolResultOptions): void;\n public abstract cancelRun(): void;\n\n public get messages() {\n return this.repository.getMessages();\n }\n\n public readonly composer = new DefaultThreadComposerRuntimeCore(this);\n\n constructor(private readonly _contextProvider: ModelContextProvider) {}\n\n public getModelContext() {\n return this._contextProvider.getModelContext();\n }\n\n private _editComposers = new Map<string, DefaultEditComposerRuntimeCore>();\n public getEditComposer(messageId: string) {\n return this._editComposers.get(messageId);\n }\n public beginEdit(messageId: string) {\n if (this._editComposers.has(messageId))\n throw new Error(\"Edit already in progress\");\n\n this._editComposers.set(\n messageId,\n new DefaultEditComposerRuntimeCore(\n this,\n () => this._editComposers.delete(messageId),\n this.repository.getMessage(messageId),\n ),\n );\n this._notifySubscribers();\n }\n\n public getMessageById(messageId: string) {\n return this.repository.getMessage(messageId);\n }\n\n public getBranches(messageId: string): string[] {\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this._notifySubscribers();\n }\n\n protected _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n\n public _notifyEventSubscribers(event: ThreadRuntimeEventType) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n for (const callback of subscribers) callback();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _submittedFeedback: Record<string, SubmittedFeedback> = {};\n\n public getSubmittedFeedback(messageId: string) {\n return this._submittedFeedback[messageId];\n }\n\n public submitFeedback({ messageId, type }: SubmitFeedbackOptions) {\n const adapter = this.adapters?.feedback;\n if (!adapter) throw new Error(\"Feedback adapter not configured\");\n\n const { message } = this.repository.getMessage(messageId);\n adapter.submit({ message, type });\n\n this._submittedFeedback[messageId] = { type };\n this._notifySubscribers();\n }\n\n private _stopSpeaking: Unsubscribe | undefined;\n public speech: SpeechState | undefined;\n\n public speak(messageId: string) {\n const adapter = this.adapters?.speech;\n if (!adapter) throw new Error(\"Speech adapter not configured\");\n\n const { message } = this.repository.getMessage(messageId);\n\n this._stopSpeaking?.();\n\n const utterance = adapter.speak(getThreadMessageText(message));\n const unsub = utterance.subscribe(() => {\n if (utterance.status.type === \"ended\") {\n this._stopSpeaking = undefined;\n this.speech = undefined;\n } else {\n this.speech = { messageId, status: utterance.status };\n }\n this._notifySubscribers();\n });\n\n this.speech = { messageId, status: utterance.status };\n this._notifySubscribers();\n\n this._stopSpeaking = () => {\n utterance.cancel();\n unsub();\n this.speech = undefined;\n this._stopSpeaking = undefined;\n };\n }\n\n public stopSpeaking() {\n if (!this._stopSpeaking) throw new Error(\"No message is being spoken\");\n this._stopSpeaking();\n this._notifySubscribers();\n }\n\n protected ensureInitialized() {\n if (!this._isInitialized) {\n this._isInitialized = true;\n this._notifyEventSubscribers(\"initialize\");\n }\n }\n\n public export() {\n return this.repository.export();\n }\n\n public import(data: ExportedMessageRepository) {\n this.ensureInitialized();\n
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/core/BaseThreadRuntimeCore.tsx"],"sourcesContent":["import type { AppendMessage, Unsubscribe } from \"../../types\";\nimport {\n ExportedMessageRepository,\n MessageRepository,\n} from \"../utils/MessageRepository\";\nimport { DefaultThreadComposerRuntimeCore } from \"../composer/DefaultThreadComposerRuntimeCore\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n SubmitFeedbackOptions,\n ThreadRuntimeCore,\n SpeechState,\n RuntimeCapabilities,\n SubmittedFeedback,\n ThreadRuntimeEventType,\n StartRunConfig,\n} from \"../core/ThreadRuntimeCore\";\nimport { DefaultEditComposerRuntimeCore } from \"../composer/DefaultEditComposerRuntimeCore\";\nimport { SpeechSynthesisAdapter } from \"../adapters/speech/SpeechAdapterTypes\";\nimport { FeedbackAdapter } from \"../adapters/feedback/FeedbackAdapter\";\nimport { AttachmentAdapter } from \"../adapters/attachment\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport { ModelContextProvider } from \"../../model-context\";\n\ntype BaseThreadAdapters = {\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n};\n\nexport abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {\n private _subscriptions = new Set<() => void>();\n private _isInitialized = false;\n\n protected readonly repository = new MessageRepository();\n public abstract get adapters(): BaseThreadAdapters | undefined;\n public abstract get isDisabled(): boolean;\n public abstract get suggestions(): readonly ThreadSuggestion[];\n public abstract get extras(): unknown;\n\n public abstract get capabilities(): RuntimeCapabilities;\n public abstract append(message: AppendMessage): void;\n public abstract startRun(config: StartRunConfig): void;\n public abstract addToolResult(options: AddToolResultOptions): void;\n public abstract cancelRun(): void;\n\n public get messages() {\n return this.repository.getMessages();\n }\n\n public readonly composer = new DefaultThreadComposerRuntimeCore(this);\n\n constructor(private readonly _contextProvider: ModelContextProvider) {}\n\n public getModelContext() {\n return this._contextProvider.getModelContext();\n }\n\n private _editComposers = new Map<string, DefaultEditComposerRuntimeCore>();\n public getEditComposer(messageId: string) {\n return this._editComposers.get(messageId);\n }\n public beginEdit(messageId: string) {\n if (this._editComposers.has(messageId))\n throw new Error(\"Edit already in progress\");\n\n this._editComposers.set(\n messageId,\n new DefaultEditComposerRuntimeCore(\n this,\n () => this._editComposers.delete(messageId),\n this.repository.getMessage(messageId),\n ),\n );\n this._notifySubscribers();\n }\n\n public getMessageById(messageId: string) {\n return this.repository.getMessage(messageId);\n }\n\n public getBranches(messageId: string): string[] {\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this._notifySubscribers();\n }\n\n protected _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n\n public _notifyEventSubscribers(event: ThreadRuntimeEventType) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n for (const callback of subscribers) callback();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _submittedFeedback: Record<string, SubmittedFeedback> = {};\n\n public getSubmittedFeedback(messageId: string) {\n return this._submittedFeedback[messageId];\n }\n\n public submitFeedback({ messageId, type }: SubmitFeedbackOptions) {\n const adapter = this.adapters?.feedback;\n if (!adapter) throw new Error(\"Feedback adapter not configured\");\n\n const { message } = this.repository.getMessage(messageId);\n adapter.submit({ message, type });\n\n this._submittedFeedback[messageId] = { type };\n this._notifySubscribers();\n }\n\n private _stopSpeaking: Unsubscribe | undefined;\n public speech: SpeechState | undefined;\n\n public speak(messageId: string) {\n const adapter = this.adapters?.speech;\n if (!adapter) throw new Error(\"Speech adapter not configured\");\n\n const { message } = this.repository.getMessage(messageId);\n\n this._stopSpeaking?.();\n\n const utterance = adapter.speak(getThreadMessageText(message));\n const unsub = utterance.subscribe(() => {\n if (utterance.status.type === \"ended\") {\n this._stopSpeaking = undefined;\n this.speech = undefined;\n } else {\n this.speech = { messageId, status: utterance.status };\n }\n this._notifySubscribers();\n });\n\n this.speech = { messageId, status: utterance.status };\n this._notifySubscribers();\n\n this._stopSpeaking = () => {\n utterance.cancel();\n unsub();\n this.speech = undefined;\n this._stopSpeaking = undefined;\n };\n }\n\n public stopSpeaking() {\n if (!this._stopSpeaking) throw new Error(\"No message is being spoken\");\n this._stopSpeaking();\n this._notifySubscribers();\n }\n\n protected ensureInitialized() {\n if (!this._isInitialized) {\n this._isInitialized = true;\n this._notifyEventSubscribers(\"initialize\");\n }\n }\n\n // TODO import()/export() on external store doesn't make much sense\n public export() {\n return this.repository.export();\n }\n\n public import(data: ExportedMessageRepository) {\n this.ensureInitialized();\n this.repository.clear();\n this.repository.import(data);\n this._notifySubscribers();\n }\n\n private _eventSubscribers = new Map<\n ThreadRuntimeEventType,\n Set<() => void>\n >();\n\n public unstable_on(event: ThreadRuntimeEventType, callback: () => void) {\n if (event === \"model-context-update\") {\n return this._contextProvider.subscribe?.(callback) ?? (() => {});\n }\n\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 subscribers.delete(callback);\n };\n }\n}\n"],"mappings":";AACA;AAAA,EAEE;AAAA,OACK;AACP,SAAS,wCAAwC;AAYjD,SAAS,sCAAsC;AAI/C,SAAS,4BAA4B;AAS9B,IAAe,wBAAf,MAAkE;AAAA,EAsBvE,YAA6B,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AC1B;AAAA,EAEU,oBAAoB;AAC5B,QAAI,CAAC,KAAK,gBAAgB;AACxB,WAAK,iBAAiB;AACtB,WAAK,wBAAwB,YAAY;AAAA,IAC3C;AAAA,EACF;AAAA;AAAA,EAGO,SAAS;AACd,WAAO,KAAK,WAAW,OAAO;AAAA,EAChC;AAAA,EAEO,OAAO,MAAiC;AAC7C,SAAK,kBAAkB;AACvB,SAAK,WAAW,MAAM;AACtB,SAAK,WAAW,OAAO,IAAI;AAC3B,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEQ,oBAAoB,oBAAI,IAG9B;AAAA,EAEK,YAAY,OAA+B,UAAsB;AACtE,QAAI,UAAU,wBAAwB;AACpC,aAAO,KAAK,iBAAiB,YAAY,QAAQ,MAAM,MAAM;AAAA,MAAC;AAAA,IAChE;AAEA,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,MAAAA,aAAY,OAAO,QAAQ;AAAA,IAC7B;AAAA,EACF;AACF;","names":["subscribers"]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { LocalRuntimeOptions } from "..";
|
2
2
|
import { DangerousInBrowserAdapterOptions } from "./DangerousInBrowserAdapter";
|
3
3
|
export type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
|
4
|
-
export declare const useDangerousInBrowserRuntime: (options: DangerousInBrowserRuntimeOptions) => import("
|
4
|
+
export declare const useDangerousInBrowserRuntime: (options: DangerousInBrowserRuntimeOptions) => import("../../internal").AssistantRuntimeImpl;
|
5
5
|
//# sourceMappingURL=useDangerousInBrowserRuntime.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDangerousInBrowserRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,IAAI,CAAC;AAE1D,OAAO,EAEL,gCAAgC,EACjC,MAAM,6BAA6B,CAAC;AAGrC,MAAM,MAAM,gCAAgC,GAC1C,gCAAgC,GAAG,mBAAmB,CAAC;AAEzD,eAAO,MAAM,4BAA4B,YAC9B,gCAAgC,
|
1
|
+
{"version":3,"file":"useDangerousInBrowserRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,IAAI,CAAC;AAE1D,OAAO,EAEL,gCAAgC,EACjC,MAAM,6BAA6B,CAAC;AAGrC,MAAM,MAAM,gCAAgC,GAC1C,gCAAgC,GAAG,mBAAmB,CAAC;AAEzD,eAAO,MAAM,4BAA4B,YAC9B,gCAAgC,kDAM1C,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { LocalRuntimeOptions } from "..";
|
2
2
|
import { EdgeChatAdapterOptions } from "./EdgeChatAdapter";
|
3
3
|
export type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions;
|
4
|
-
export declare const useEdgeRuntime: (options: EdgeRuntimeOptions) => import("
|
4
|
+
export declare const useEdgeRuntime: (options: EdgeRuntimeOptions) => import("../../internal").AssistantRuntimeImpl;
|
5
5
|
//# sourceMappingURL=useEdgeRuntime.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useEdgeRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/edge/useEdgeRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAmB,MAAM,mBAAmB,CAAC;AAG5E,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG,mBAAmB,CAAC;AAE9E,eAAO,MAAM,cAAc,YAAa,kBAAkB,
|
1
|
+
{"version":3,"file":"useEdgeRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/edge/useEdgeRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAmB,MAAM,mBAAmB,CAAC;AAG5E,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG,mBAAmB,CAAC;AAE9E,eAAO,MAAM,cAAc,YAAa,kBAAkB,kDAQzD,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
1
|
import { ExternalStoreAdapter } from "./ExternalStoreAdapter";
|
2
|
-
|
2
|
+
import { AssistantRuntimeImpl } from "../../api/AssistantRuntime";
|
3
|
+
export declare const useExternalStoreRuntime: <T>(store: ExternalStoreAdapter<T>) => AssistantRuntimeImpl;
|
3
4
|
//# sourceMappingURL=useExternalStoreRuntime.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useExternalStoreRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/useExternalStoreRuntime.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
1
|
+
{"version":3,"file":"useExternalStoreRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/useExternalStoreRuntime.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAU,oBAAoB,CAAC,CAAC,CAAC,yBAezE,CAAC"}
|
@@ -27,7 +27,6 @@ module.exports = __toCommonJS(useExternalStoreRuntime_exports);
|
|
27
27
|
var import_react = require("react");
|
28
28
|
var import_ExternalStoreRuntimeCore = require("./ExternalStoreRuntimeCore.js");
|
29
29
|
var import_AssistantRuntime = require("../../api/AssistantRuntime.js");
|
30
|
-
var import_ThreadRuntime = require("../../api/ThreadRuntime.js");
|
31
30
|
var import_RuntimeAdapterProvider = require("../adapters/RuntimeAdapterProvider.js");
|
32
31
|
var useExternalStoreRuntime = (store) => {
|
33
32
|
const [runtime] = (0, import_react.useState)(() => new import_ExternalStoreRuntimeCore.ExternalStoreRuntimeCore(store));
|
@@ -39,10 +38,7 @@ var useExternalStoreRuntime = (store) => {
|
|
39
38
|
if (!modelContext) return void 0;
|
40
39
|
return runtime.registerModelContextProvider(modelContext);
|
41
40
|
}, [modelContext, runtime]);
|
42
|
-
return (0, import_react.useMemo)(
|
43
|
-
() => import_AssistantRuntime.AssistantRuntimeImpl.create(runtime, import_ThreadRuntime.ThreadRuntimeImpl),
|
44
|
-
[runtime]
|
45
|
-
);
|
41
|
+
return (0, import_react.useMemo)(() => new import_AssistantRuntime.AssistantRuntimeImpl(runtime), [runtime]);
|
46
42
|
};
|
47
43
|
// Annotate the CommonJS export names for ESM import in node:
|
48
44
|
0 && (module.exports = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/useExternalStoreRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { ExternalStoreRuntimeCore } from \"./ExternalStoreRuntimeCore\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { AssistantRuntimeImpl } from \"../../api/AssistantRuntime\";\nimport {
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/useExternalStoreRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { ExternalStoreRuntimeCore } from \"./ExternalStoreRuntimeCore\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { AssistantRuntimeImpl } from \"../../api/AssistantRuntime\";\nimport { useRuntimeAdapters } from \"../adapters/RuntimeAdapterProvider\";\n\nexport const useExternalStoreRuntime = <T,>(store: ExternalStoreAdapter<T>) => {\n const [runtime] = useState(() => new ExternalStoreRuntimeCore(store));\n\n useEffect(() => {\n runtime.setAdapter(store);\n });\n\n const { modelContext } = useRuntimeAdapters() ?? {};\n\n useEffect(() => {\n if (!modelContext) return undefined;\n return runtime.registerModelContextProvider(modelContext);\n }, [modelContext, runtime]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA6C;AAC7C,sCAAyC;AAEzC,8BAAqC;AACrC,oCAAmC;AAE5B,IAAM,0BAA0B,CAAK,UAAmC;AAC7E,QAAM,CAAC,OAAO,QAAI,uBAAS,MAAM,IAAI,yDAAyB,KAAK,CAAC;AAEpE,8BAAU,MAAM;AACd,YAAQ,WAAW,KAAK;AAAA,EAC1B,CAAC;AAED,QAAM,EAAE,aAAa,QAAI,kDAAmB,KAAK,CAAC;AAElD,8BAAU,MAAM;AACd,QAAI,CAAC,aAAc,QAAO;AAC1B,WAAO,QAAQ,6BAA6B,YAAY;AAAA,EAC1D,GAAG,CAAC,cAAc,OAAO,CAAC;AAE1B,aAAO,sBAAQ,MAAM,IAAI,6CAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;","names":[]}
|
@@ -4,7 +4,6 @@
|
|
4
4
|
import { useEffect, useMemo, useState } from "react";
|
5
5
|
import { ExternalStoreRuntimeCore } from "./ExternalStoreRuntimeCore.mjs";
|
6
6
|
import { AssistantRuntimeImpl } from "../../api/AssistantRuntime.mjs";
|
7
|
-
import { ThreadRuntimeImpl } from "../../api/ThreadRuntime.mjs";
|
8
7
|
import { useRuntimeAdapters } from "../adapters/RuntimeAdapterProvider.mjs";
|
9
8
|
var useExternalStoreRuntime = (store) => {
|
10
9
|
const [runtime] = useState(() => new ExternalStoreRuntimeCore(store));
|
@@ -16,10 +15,7 @@ var useExternalStoreRuntime = (store) => {
|
|
16
15
|
if (!modelContext) return void 0;
|
17
16
|
return runtime.registerModelContextProvider(modelContext);
|
18
17
|
}, [modelContext, runtime]);
|
19
|
-
return useMemo(
|
20
|
-
() => AssistantRuntimeImpl.create(runtime, ThreadRuntimeImpl),
|
21
|
-
[runtime]
|
22
|
-
);
|
18
|
+
return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
|
23
19
|
};
|
24
20
|
export {
|
25
21
|
useExternalStoreRuntime
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/useExternalStoreRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { ExternalStoreRuntimeCore } from \"./ExternalStoreRuntimeCore\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { AssistantRuntimeImpl } from \"../../api/AssistantRuntime\";\nimport {
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/useExternalStoreRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { ExternalStoreRuntimeCore } from \"./ExternalStoreRuntimeCore\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { AssistantRuntimeImpl } from \"../../api/AssistantRuntime\";\nimport { useRuntimeAdapters } from \"../adapters/RuntimeAdapterProvider\";\n\nexport const useExternalStoreRuntime = <T,>(store: ExternalStoreAdapter<T>) => {\n const [runtime] = useState(() => new ExternalStoreRuntimeCore(store));\n\n useEffect(() => {\n runtime.setAdapter(store);\n });\n\n const { modelContext } = useRuntimeAdapters() ?? {};\n\n useEffect(() => {\n if (!modelContext) return undefined;\n return runtime.registerModelContextProvider(modelContext);\n }, [modelContext, runtime]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n"],"mappings":";;;AAEA,SAAS,WAAW,SAAS,gBAAgB;AAC7C,SAAS,gCAAgC;AAEzC,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AAE5B,IAAM,0BAA0B,CAAK,UAAmC;AAC7E,QAAM,CAAC,OAAO,IAAI,SAAS,MAAM,IAAI,yBAAyB,KAAK,CAAC;AAEpE,YAAU,MAAM;AACd,YAAQ,WAAW,KAAK;AAAA,EAC1B,CAAC;AAED,QAAM,EAAE,aAAa,IAAI,mBAAmB,KAAK,CAAC;AAElD,YAAU,MAAM;AACd,QAAI,CAAC,aAAc,QAAO;AAC1B,WAAO,QAAQ,6BAA6B,YAAY;AAAA,EAC1D,GAAG,CAAC,cAAc,OAAO,CAAC;AAE1B,SAAO,QAAQ,MAAM,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;","names":[]}
|
package/dist/runtimes/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtimes/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtimes/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AAErC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/runtimes/index.js
CHANGED
@@ -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,6 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
16
20
|
|
17
21
|
// src/runtimes/index.ts
|
18
22
|
var runtimes_exports = {};
|
23
|
+
__export(runtimes_exports, {
|
24
|
+
ExportedMessageRepository: () => import_MessageRepository.ExportedMessageRepository
|
25
|
+
});
|
19
26
|
module.exports = __toCommonJS(runtimes_exports);
|
20
27
|
__reExport(runtimes_exports, require("./adapters/index.js"), module.exports);
|
21
28
|
__reExport(runtimes_exports, require("./core/index.js"), module.exports);
|
@@ -24,8 +31,10 @@ __reExport(runtimes_exports, require("./edge/index.js"), module.exports);
|
|
24
31
|
__reExport(runtimes_exports, require("./external-store/index.js"), module.exports);
|
25
32
|
__reExport(runtimes_exports, require("./local/index.js"), module.exports);
|
26
33
|
__reExport(runtimes_exports, require("./remote-thread-list/index.js"), module.exports);
|
34
|
+
var import_MessageRepository = require("./utils/MessageRepository.js");
|
27
35
|
// Annotate the CommonJS export names for ESM import in node:
|
28
36
|
0 && (module.exports = {
|
37
|
+
ExportedMessageRepository,
|
29
38
|
...require("./adapters/index.js"),
|
30
39
|
...require("./core/index.js"),
|
31
40
|
...require("./dangerous-in-browser/index.js"),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/runtimes/index.ts"],"sourcesContent":["export * from \"./adapters\";\nexport * from \"./core\";\nexport * from \"./dangerous-in-browser\";\nexport * from \"./edge\";\nexport * from \"./external-store\";\nexport * from \"./local\";\nexport * from \"./remote-thread-list\";\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../src/runtimes/index.ts"],"sourcesContent":["export * from \"./adapters\";\nexport * from \"./core\";\nexport * from \"./dangerous-in-browser\";\nexport * from \"./edge\";\nexport * from \"./external-store\";\nexport * from \"./local\";\nexport * from \"./remote-thread-list\";\n\nexport { ExportedMessageRepository } from \"./utils/MessageRepository\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAc,gCAAd;AACA,6BAAc,4BADd;AAEA,6BAAc,4CAFd;AAGA,6BAAc,4BAHd;AAIA,6BAAc,sCAJd;AAKA,6BAAc,6BALd;AAMA,6BAAc,0CANd;AAQA,+BAA0C;","names":[]}
|
package/dist/runtimes/index.mjs
CHANGED
@@ -6,4 +6,8 @@ export * from "./edge/index.mjs";
|
|
6
6
|
export * from "./external-store/index.mjs";
|
7
7
|
export * from "./local/index.mjs";
|
8
8
|
export * from "./remote-thread-list/index.mjs";
|
9
|
+
import { ExportedMessageRepository } from "./utils/MessageRepository.mjs";
|
10
|
+
export {
|
11
|
+
ExportedMessageRepository
|
12
|
+
};
|
9
13
|
//# sourceMappingURL=index.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/runtimes/index.ts"],"sourcesContent":["export * from \"./adapters\";\nexport * from \"./core\";\nexport * from \"./dangerous-in-browser\";\nexport * from \"./edge\";\nexport * from \"./external-store\";\nexport * from \"./local\";\nexport * from \"./remote-thread-list\";\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
1
|
+
{"version":3,"sources":["../../src/runtimes/index.ts"],"sourcesContent":["export * from \"./adapters\";\nexport * from \"./core\";\nexport * from \"./dangerous-in-browser\";\nexport * from \"./edge\";\nexport * from \"./external-store\";\nexport * from \"./local\";\nexport * from \"./remote-thread-list\";\n\nexport { ExportedMessageRepository } from \"./utils/MessageRepository\";\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,iCAAiC;","names":[]}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type { CoreMessage } from "../../types/AssistantTypes";
|
2
1
|
import { BaseAssistantRuntimeCore } from "../core/BaseAssistantRuntimeCore";
|
3
2
|
import { LocalRuntimeOptionsBase } from "./LocalRuntimeOptions";
|
4
3
|
import { LocalThreadListRuntimeCore } from "./LocalThreadListRuntimeCore";
|
@@ -8,8 +7,5 @@ export declare class LocalRuntimeCore extends BaseAssistantRuntimeCore {
|
|
8
7
|
readonly Provider: undefined;
|
9
8
|
private _options;
|
10
9
|
constructor(options: LocalRuntimeOptionsBase, initialMessages: readonly ThreadMessageLike[] | undefined);
|
11
|
-
reset({ initialMessages, }?: {
|
12
|
-
initialMessages?: readonly CoreMessage[] | undefined;
|
13
|
-
}): void;
|
14
10
|
}
|
15
11
|
//# sourceMappingURL=LocalRuntimeCore.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LocalRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"LocalRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,qBAAa,gBAAiB,SAAQ,wBAAwB;IAC5D,SAAgB,OAAO,6BAAC;IACxB,SAAgB,QAAQ,YAAa;IAErC,OAAO,CAAC,QAAQ,CAA0B;gBAGxC,OAAO,EAAE,uBAAuB,EAChC,eAAe,EAAE,SAAS,iBAAiB,EAAE,GAAG,SAAS;CAgB5D"}
|
@@ -26,21 +26,7 @@ module.exports = __toCommonJS(LocalRuntimeCore_exports);
|
|
26
26
|
var import_BaseAssistantRuntimeCore = require("../core/BaseAssistantRuntimeCore.js");
|
27
27
|
var import_LocalThreadRuntimeCore = require("./LocalThreadRuntimeCore.js");
|
28
28
|
var import_LocalThreadListRuntimeCore = require("./LocalThreadListRuntimeCore.js");
|
29
|
-
var
|
30
|
-
var import_internal = require("../../internal.js");
|
31
|
-
var import_auto_status = require("../external-store/auto-status.js");
|
32
|
-
var getExportFromInitialMessages = (initialMessages) => {
|
33
|
-
const messages = initialMessages.map((i, idx) => {
|
34
|
-
const isLast = idx === initialMessages.length - 1;
|
35
|
-
return (0, import_ThreadMessageLike.fromThreadMessageLike)(i, (0, import_internal.generateId)(), (0, import_auto_status.getAutoStatus)(isLast, false));
|
36
|
-
});
|
37
|
-
return {
|
38
|
-
messages: messages.map((m, idx) => ({
|
39
|
-
parentId: messages[idx - 1]?.id ?? null,
|
40
|
-
message: m
|
41
|
-
}))
|
42
|
-
};
|
43
|
-
};
|
29
|
+
var import_MessageRepository = require("../utils/MessageRepository.js");
|
44
30
|
var LocalRuntimeCore = class extends import_BaseAssistantRuntimeCore.BaseAssistantRuntimeCore {
|
45
31
|
threads;
|
46
32
|
Provider = void 0;
|
@@ -52,16 +38,9 @@ var LocalRuntimeCore = class extends import_BaseAssistantRuntimeCore.BaseAssista
|
|
52
38
|
return new import_LocalThreadRuntimeCore.LocalThreadRuntimeCore(this._contextProvider, this._options);
|
53
39
|
});
|
54
40
|
if (initialMessages) {
|
55
|
-
this.threads.getMainThreadRuntimeCore().import(
|
41
|
+
this.threads.getMainThreadRuntimeCore().import(import_MessageRepository.ExportedMessageRepository.fromArray(initialMessages));
|
56
42
|
}
|
57
43
|
}
|
58
|
-
reset({
|
59
|
-
initialMessages
|
60
|
-
} = {}) {
|
61
|
-
this.threads.switchToNewThread();
|
62
|
-
if (!initialMessages) return;
|
63
|
-
this.threads.getMainThreadRuntimeCore().import(getExportFromInitialMessages(initialMessages));
|
64
|
-
}
|
65
44
|
};
|
66
45
|
// Annotate the CommonJS export names for ESM import in node:
|
67
46
|
0 && (module.exports = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"sourcesContent":["import
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"sourcesContent":["import { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport { LocalThreadListRuntimeCore } from \"./LocalThreadListRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\nimport { ThreadMessageLike } from \"../external-store\";\n\nexport class LocalRuntimeCore extends BaseAssistantRuntimeCore {\n public readonly threads;\n public readonly Provider = undefined;\n\n private _options: LocalRuntimeOptionsBase;\n\n constructor(\n options: LocalRuntimeOptionsBase,\n initialMessages: readonly ThreadMessageLike[] | undefined,\n ) {\n super();\n\n this._options = options;\n\n this.threads = new LocalThreadListRuntimeCore(() => {\n return new LocalThreadRuntimeCore(this._contextProvider, this._options);\n });\n\n if (initialMessages) {\n this.threads\n .getMainThreadRuntimeCore()\n .import(ExportedMessageRepository.fromArray(initialMessages));\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAyC;AACzC,oCAAuC;AAEvC,wCAA2C;AAC3C,+BAA0C;AAGnC,IAAM,mBAAN,cAA+B,yDAAyB;AAAA,EAC7C;AAAA,EACA,WAAW;AAAA,EAEnB;AAAA,EAER,YACE,SACA,iBACA;AACA,UAAM;AAEN,SAAK,WAAW;AAEhB,SAAK,UAAU,IAAI,6DAA2B,MAAM;AAClD,aAAO,IAAI,qDAAuB,KAAK,kBAAkB,KAAK,QAAQ;AAAA,IACxE,CAAC;AAED,QAAI,iBAAiB;AACnB,WAAK,QACF,yBAAyB,EACzB,OAAO,mDAA0B,UAAU,eAAe,CAAC;AAAA,IAChE;AAAA,EACF;AACF;","names":[]}
|
@@ -2,21 +2,7 @@
|
|
2
2
|
import { BaseAssistantRuntimeCore } from "../core/BaseAssistantRuntimeCore.mjs";
|
3
3
|
import { LocalThreadRuntimeCore } from "./LocalThreadRuntimeCore.mjs";
|
4
4
|
import { LocalThreadListRuntimeCore } from "./LocalThreadListRuntimeCore.mjs";
|
5
|
-
import {
|
6
|
-
import { generateId } from "../../internal.mjs";
|
7
|
-
import { getAutoStatus } from "../external-store/auto-status.mjs";
|
8
|
-
var getExportFromInitialMessages = (initialMessages) => {
|
9
|
-
const messages = initialMessages.map((i, idx) => {
|
10
|
-
const isLast = idx === initialMessages.length - 1;
|
11
|
-
return fromThreadMessageLike(i, generateId(), getAutoStatus(isLast, false));
|
12
|
-
});
|
13
|
-
return {
|
14
|
-
messages: messages.map((m, idx) => ({
|
15
|
-
parentId: messages[idx - 1]?.id ?? null,
|
16
|
-
message: m
|
17
|
-
}))
|
18
|
-
};
|
19
|
-
};
|
5
|
+
import { ExportedMessageRepository } from "../utils/MessageRepository.mjs";
|
20
6
|
var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
21
7
|
threads;
|
22
8
|
Provider = void 0;
|
@@ -28,16 +14,9 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
28
14
|
return new LocalThreadRuntimeCore(this._contextProvider, this._options);
|
29
15
|
});
|
30
16
|
if (initialMessages) {
|
31
|
-
this.threads.getMainThreadRuntimeCore().import(
|
17
|
+
this.threads.getMainThreadRuntimeCore().import(ExportedMessageRepository.fromArray(initialMessages));
|
32
18
|
}
|
33
19
|
}
|
34
|
-
reset({
|
35
|
-
initialMessages
|
36
|
-
} = {}) {
|
37
|
-
this.threads.switchToNewThread();
|
38
|
-
if (!initialMessages) return;
|
39
|
-
this.threads.getMainThreadRuntimeCore().import(getExportFromInitialMessages(initialMessages));
|
40
|
-
}
|
41
20
|
};
|
42
21
|
export {
|
43
22
|
LocalRuntimeCore
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"sourcesContent":["import
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"sourcesContent":["import { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport { LocalThreadListRuntimeCore } from \"./LocalThreadListRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\nimport { ThreadMessageLike } from \"../external-store\";\n\nexport class LocalRuntimeCore extends BaseAssistantRuntimeCore {\n public readonly threads;\n public readonly Provider = undefined;\n\n private _options: LocalRuntimeOptionsBase;\n\n constructor(\n options: LocalRuntimeOptionsBase,\n initialMessages: readonly ThreadMessageLike[] | undefined,\n ) {\n super();\n\n this._options = options;\n\n this.threads = new LocalThreadListRuntimeCore(() => {\n return new LocalThreadRuntimeCore(this._contextProvider, this._options);\n });\n\n if (initialMessages) {\n this.threads\n .getMainThreadRuntimeCore()\n .import(ExportedMessageRepository.fromArray(initialMessages));\n }\n }\n}\n"],"mappings":";AAAA,SAAS,gCAAgC;AACzC,SAAS,8BAA8B;AAEvC,SAAS,kCAAkC;AAC3C,SAAS,iCAAiC;AAGnC,IAAM,mBAAN,cAA+B,yBAAyB;AAAA,EAC7C;AAAA,EACA,WAAW;AAAA,EAEnB;AAAA,EAER,YACE,SACA,iBACA;AACA,UAAM;AAEN,SAAK,WAAW;AAEhB,SAAK,UAAU,IAAI,2BAA2B,MAAM;AAClD,aAAO,IAAI,uBAAuB,KAAK,kBAAkB,KAAK,QAAQ;AAAA,IACxE,CAAC;AAED,QAAI,iBAAiB;AACnB,WAAK,QACF,yBAAyB,EACzB,OAAO,0BAA0B,UAAU,eAAe,CAAC;AAAA,IAChE;AAAA,EACF;AACF;","names":[]}
|
@@ -1,9 +1,5 @@
|
|
1
1
|
import type { ChatModelAdapter } from "./ChatModelAdapter";
|
2
|
-
import { LocalRuntimeCore } from "./LocalRuntimeCore";
|
3
2
|
import { LocalRuntimeOptions } from "./LocalRuntimeOptions";
|
4
|
-
import {
|
5
|
-
export
|
6
|
-
reset: (options?: Parameters<LocalRuntimeCore["reset"]>[0]) => void;
|
7
|
-
};
|
8
|
-
export declare const useLocalRuntime: (adapter: ChatModelAdapter, { cloud, ...options }?: LocalRuntimeOptions) => AssistantRuntime;
|
3
|
+
import { AssistantRuntimeImpl } from "../../internal";
|
4
|
+
export declare const useLocalRuntime: (adapter: ChatModelAdapter, { cloud, ...options }?: LocalRuntimeOptions) => AssistantRuntimeImpl;
|
9
5
|
//# sourceMappingURL=useLocalRuntime.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useLocalRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
1
|
+
{"version":3,"file":"useLocalRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAkCtD,eAAO,MAAM,eAAe,YACjB,gBAAgB,0BACF,mBAAmB,yBAO3C,CAAC"}
|
@@ -26,27 +26,10 @@ __export(useLocalRuntime_exports, {
|
|
26
26
|
module.exports = __toCommonJS(useLocalRuntime_exports);
|
27
27
|
var import_react = require("react");
|
28
28
|
var import_LocalRuntimeCore = require("./LocalRuntimeCore.js");
|
29
|
-
var import_AssistantRuntime = require("../../api/AssistantRuntime.js");
|
30
|
-
var import_internal = require("../../internal.js");
|
31
29
|
var import_RuntimeAdapterProvider = require("../adapters/RuntimeAdapterProvider.js");
|
32
30
|
var import_useRemoteThreadListRuntime = require("../remote-thread-list/useRemoteThreadListRuntime.js");
|
33
31
|
var import_cloud = require("../remote-thread-list/adapter/cloud.js");
|
34
|
-
var
|
35
|
-
constructor(core) {
|
36
|
-
super(core, import_internal.ThreadRuntimeImpl);
|
37
|
-
this.core = core;
|
38
|
-
}
|
39
|
-
__internal_bindMethods() {
|
40
|
-
super.__internal_bindMethods();
|
41
|
-
this.reset = this.reset.bind(this);
|
42
|
-
}
|
43
|
-
reset(options) {
|
44
|
-
this.core.reset(options);
|
45
|
-
}
|
46
|
-
static create(_core) {
|
47
|
-
return new _LocalRuntimeImpl(_core);
|
48
|
-
}
|
49
|
-
};
|
32
|
+
var import_internal = require("../../internal.js");
|
50
33
|
var useLocalThreadRuntime = (adapter, { initialMessages, ...options }) => {
|
51
34
|
const { modelContext, ...threadListAdapters } = (0, import_RuntimeAdapterProvider.useRuntimeAdapters)() ?? {};
|
52
35
|
const opt = (0, import_react.useMemo)(
|
@@ -69,7 +52,7 @@ var useLocalThreadRuntime = (adapter, { initialMessages, ...options }) => {
|
|
69
52
|
if (!modelContext) return void 0;
|
70
53
|
return runtime.registerModelContextProvider(modelContext);
|
71
54
|
}, [modelContext, runtime]);
|
72
|
-
return (0, import_react.useMemo)(() =>
|
55
|
+
return (0, import_react.useMemo)(() => new import_internal.AssistantRuntimeImpl(runtime), [runtime]);
|
73
56
|
};
|
74
57
|
var useLocalRuntime = (adapter, { cloud, ...options } = {}) => {
|
75
58
|
const cloudAdapter = (0, import_cloud.useCloudThreadListAdapter)({ cloud });
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport {
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport { useRuntimeAdapters } from \"../adapters/RuntimeAdapterProvider\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"../remote-thread-list/adapter/cloud\";\nimport { AssistantRuntimeImpl } from \"../../internal\";\n\nconst useLocalThreadRuntime = (\n adapter: ChatModelAdapter,\n { initialMessages, ...options }: LocalRuntimeOptions,\n) => {\n const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};\n const opt = useMemo(\n () => ({\n ...options,\n adapters: {\n ...threadListAdapters,\n ...options.adapters,\n chatModel: adapter,\n },\n }),\n [adapter, options, threadListAdapters],\n );\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));\n\n useEffect(() => {\n runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);\n runtime.threads.getMainThreadRuntimeCore().__internal_load();\n }, [runtime, opt]);\n\n useEffect(() => {\n if (!modelContext) return undefined;\n return runtime.registerModelContextProvider(modelContext);\n }, [modelContext, runtime]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const useLocalRuntime = (\n adapter: ChatModelAdapter,\n { cloud, ...options }: LocalRuntimeOptions = {},\n) => {\n const cloudAdapter = useCloudThreadListAdapter({ cloud });\n return useRemoteThreadListRuntime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3,10 @@
|
|
3
3
|
// src/runtimes/local/useLocalRuntime.tsx
|
4
4
|
import { useEffect, useMemo, useState } from "react";
|
5
5
|
import { LocalRuntimeCore } from "./LocalRuntimeCore.mjs";
|
6
|
-
import {
|
7
|
-
AssistantRuntimeImpl
|
8
|
-
} from "../../api/AssistantRuntime.mjs";
|
9
|
-
import { ThreadRuntimeImpl } from "../../internal.mjs";
|
10
6
|
import { useRuntimeAdapters } from "../adapters/RuntimeAdapterProvider.mjs";
|
11
7
|
import { useRemoteThreadListRuntime } from "../remote-thread-list/useRemoteThreadListRuntime.mjs";
|
12
8
|
import { useCloudThreadListAdapter } from "../remote-thread-list/adapter/cloud.mjs";
|
13
|
-
|
14
|
-
constructor(core) {
|
15
|
-
super(core, ThreadRuntimeImpl);
|
16
|
-
this.core = core;
|
17
|
-
}
|
18
|
-
__internal_bindMethods() {
|
19
|
-
super.__internal_bindMethods();
|
20
|
-
this.reset = this.reset.bind(this);
|
21
|
-
}
|
22
|
-
reset(options) {
|
23
|
-
this.core.reset(options);
|
24
|
-
}
|
25
|
-
static create(_core) {
|
26
|
-
return new _LocalRuntimeImpl(_core);
|
27
|
-
}
|
28
|
-
};
|
9
|
+
import { AssistantRuntimeImpl } from "../../internal.mjs";
|
29
10
|
var useLocalThreadRuntime = (adapter, { initialMessages, ...options }) => {
|
30
11
|
const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};
|
31
12
|
const opt = useMemo(
|
@@ -48,7 +29,7 @@ var useLocalThreadRuntime = (adapter, { initialMessages, ...options }) => {
|
|
48
29
|
if (!modelContext) return void 0;
|
49
30
|
return runtime.registerModelContextProvider(modelContext);
|
50
31
|
}, [modelContext, runtime]);
|
51
|
-
return useMemo(() =>
|
32
|
+
return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
|
52
33
|
};
|
53
34
|
var useLocalRuntime = (adapter, { cloud, ...options } = {}) => {
|
54
35
|
const cloudAdapter = useCloudThreadListAdapter({ cloud });
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport {
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport { useRuntimeAdapters } from \"../adapters/RuntimeAdapterProvider\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"../remote-thread-list/adapter/cloud\";\nimport { AssistantRuntimeImpl } from \"../../internal\";\n\nconst useLocalThreadRuntime = (\n adapter: ChatModelAdapter,\n { initialMessages, ...options }: LocalRuntimeOptions,\n) => {\n const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};\n const opt = useMemo(\n () => ({\n ...options,\n adapters: {\n ...threadListAdapters,\n ...options.adapters,\n chatModel: adapter,\n },\n }),\n [adapter, options, threadListAdapters],\n );\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));\n\n useEffect(() => {\n runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);\n runtime.threads.getMainThreadRuntimeCore().__internal_load();\n }, [runtime, opt]);\n\n useEffect(() => {\n if (!modelContext) return undefined;\n return runtime.registerModelContextProvider(modelContext);\n }, [modelContext, runtime]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const useLocalRuntime = (\n adapter: ChatModelAdapter,\n { cloud, ...options }: LocalRuntimeOptions = {},\n) => {\n const cloudAdapter = useCloudThreadListAdapter({ cloud });\n return useRemoteThreadListRuntime({\n runtimeHook: () => useLocalThreadRuntime(adapter, options),\n adapter: cloudAdapter,\n });\n};\n"],"mappings":";;;AAEA,SAAS,WAAW,SAAS,gBAAgB;AAE7C,SAAS,wBAAwB;AAEjC,SAAS,0BAA0B;AACnC,SAAS,kCAAkC;AAC3C,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AAErC,IAAM,wBAAwB,CAC5B,SACA,EAAE,iBAAiB,GAAG,QAAQ,MAC3B;AACH,QAAM,EAAE,cAAc,GAAG,mBAAmB,IAAI,mBAAmB,KAAK,CAAC;AACzE,QAAM,MAAM;AAAA,IACV,OAAO;AAAA,MACL,GAAG;AAAA,MACH,UAAU;AAAA,QACR,GAAG;AAAA,QACH,GAAG,QAAQ;AAAA,QACX,WAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA,CAAC,SAAS,SAAS,kBAAkB;AAAA,EACvC;AAEA,QAAM,CAAC,OAAO,IAAI,SAAS,MAAM,IAAI,iBAAiB,KAAK,eAAe,CAAC;AAE3E,YAAU,MAAM;AACd,YAAQ,QAAQ,yBAAyB,EAAE,sBAAsB,GAAG;AACpE,YAAQ,QAAQ,yBAAyB,EAAE,gBAAgB;AAAA,EAC7D,GAAG,CAAC,SAAS,GAAG,CAAC;AAEjB,YAAU,MAAM;AACd,QAAI,CAAC,aAAc,QAAO;AAC1B,WAAO,QAAQ,6BAA6B,YAAY;AAAA,EAC1D,GAAG,CAAC,cAAc,OAAO,CAAC;AAE1B,SAAO,QAAQ,MAAM,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;AAEO,IAAM,kBAAkB,CAC7B,SACA,EAAE,OAAO,GAAG,QAAQ,IAAyB,CAAC,MAC3C;AACH,QAAM,eAAe,0BAA0B,EAAE,MAAM,CAAC;AACxD,SAAO,2BAA2B;AAAA,IAChC,aAAa,MAAM,sBAAsB,SAAS,OAAO;AAAA,IACzD,SAAS;AAAA,EACX,CAAC;AACH;","names":[]}
|