@assistant-ui/react 0.5.66 → 0.5.67
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/{edge-D7ch2oPK.d.mts → edge-BDAlTCC1.d.mts} +2 -2
- package/dist/{edge-D7ch2oPK.d.ts → edge-BDAlTCC1.d.ts} +2 -2
- package/dist/index.d.mts +388 -646
- package/dist/index.d.ts +388 -646
- package/dist/index.js +991 -890
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +924 -823
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17;
|
2
2
|
|
3
3
|
|
4
4
|
|
@@ -144,7 +144,9 @@ var { useThread, useThreadStore } = createContextStoreHook(
|
|
144
144
|
useThreadContext,
|
145
145
|
"useThread"
|
146
146
|
);
|
147
|
-
var
|
147
|
+
var messages = createContextStoreHook(useThreadContext, "useThreadMessages");
|
148
|
+
var useThreadMessages = messages.useThreadMessages;
|
149
|
+
var useThreadMessagesStore = messages.useThreadMessagesStore;
|
148
150
|
var {
|
149
151
|
useComposer: useThreadComposer,
|
150
152
|
useComposerStore: useThreadComposerStore
|
@@ -154,56 +156,6 @@ var {
|
|
154
156
|
useViewportStore: useThreadViewportStore
|
155
157
|
} = createContextStoreHook(useThreadContext, "useViewport");
|
156
158
|
|
157
|
-
// src/context/stores/ThreadComposer.ts
|
158
|
-
|
159
|
-
var makeThreadComposerStore = (runtime) => {
|
160
|
-
const focusListeners = /* @__PURE__ */ new Set();
|
161
|
-
return _zustand.create.call(void 0, )((_, get) => {
|
162
|
-
return {
|
163
|
-
type: "thread",
|
164
|
-
get value() {
|
165
|
-
return get().text;
|
166
|
-
},
|
167
|
-
setValue(value) {
|
168
|
-
get().setText(value);
|
169
|
-
},
|
170
|
-
...runtime.getState(),
|
171
|
-
canCancel: false,
|
172
|
-
// "TODO",
|
173
|
-
isEditing: true,
|
174
|
-
addAttachment: (file) => {
|
175
|
-
runtime.addAttachment(file);
|
176
|
-
},
|
177
|
-
removeAttachment: (attachmentId) => {
|
178
|
-
runtime.removeAttachment(attachmentId);
|
179
|
-
},
|
180
|
-
reset: () => {
|
181
|
-
runtime.reset();
|
182
|
-
},
|
183
|
-
setText: (text) => {
|
184
|
-
runtime.setText(text);
|
185
|
-
},
|
186
|
-
send: () => {
|
187
|
-
runtime.send();
|
188
|
-
},
|
189
|
-
cancel: () => {
|
190
|
-
runtime.cancel();
|
191
|
-
},
|
192
|
-
focus: () => {
|
193
|
-
for (const listener of focusListeners) {
|
194
|
-
listener();
|
195
|
-
}
|
196
|
-
},
|
197
|
-
onFocus: (listener) => {
|
198
|
-
focusListeners.add(listener);
|
199
|
-
return () => {
|
200
|
-
focusListeners.delete(listener);
|
201
|
-
};
|
202
|
-
}
|
203
|
-
};
|
204
|
-
});
|
205
|
-
};
|
206
|
-
|
207
159
|
// src/context/stores/ThreadViewport.tsx
|
208
160
|
|
209
161
|
var makeThreadViewportStore = () => {
|
@@ -258,9 +210,9 @@ var useThreadMessagesStore2 = (runtime) => {
|
|
258
210
|
return store;
|
259
211
|
};
|
260
212
|
var useThreadComposerStore2 = (runtime) => {
|
261
|
-
const [store] = _react.useState.call(void 0, () =>
|
213
|
+
const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime.getState()));
|
262
214
|
_react.useEffect.call(void 0, () => {
|
263
|
-
const updateState = () => writableStore(store).setState(runtime.getState());
|
215
|
+
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
264
216
|
updateState();
|
265
217
|
return runtime.subscribe(updateState);
|
266
218
|
}, [runtime, store]);
|
@@ -331,11 +283,47 @@ var useContentPartContext = createContextHook(
|
|
331
283
|
ContentPartContext,
|
332
284
|
"a component passed to <MessagePrimitive.Content components={...}>"
|
333
285
|
);
|
286
|
+
function useContentPartRuntime(options) {
|
287
|
+
const context = useContentPartContext(options);
|
288
|
+
if (!context) return null;
|
289
|
+
return context.useContentPartRuntime();
|
290
|
+
}
|
334
291
|
var { useContentPart, useContentPartStore } = createContextStoreHook(
|
335
292
|
useContentPartContext,
|
336
293
|
"useContentPart"
|
337
294
|
);
|
338
295
|
|
296
|
+
// src/api/ContentPartRuntime.ts
|
297
|
+
var ContentPartRuntime = class {
|
298
|
+
constructor(contentBinding, messageApi, threadApi) {
|
299
|
+
this.contentBinding = contentBinding;
|
300
|
+
this.messageApi = messageApi;
|
301
|
+
this.threadApi = threadApi;
|
302
|
+
}
|
303
|
+
getState() {
|
304
|
+
return this.contentBinding.getState();
|
305
|
+
}
|
306
|
+
addToolResult(result) {
|
307
|
+
const message = this.messageApi.getState();
|
308
|
+
if (!message) throw new Error("Message is not available");
|
309
|
+
const state = this.contentBinding.getState();
|
310
|
+
if (!state) throw new Error("Content part is not available");
|
311
|
+
if (state.type !== "tool-call")
|
312
|
+
throw new Error("Tried to add tool result to non-tool content part");
|
313
|
+
const toolName = state.toolName;
|
314
|
+
const toolCallId = state.toolCallId;
|
315
|
+
this.threadApi.getState().addToolResult({
|
316
|
+
messageId: message.id,
|
317
|
+
toolName,
|
318
|
+
toolCallId,
|
319
|
+
result
|
320
|
+
});
|
321
|
+
}
|
322
|
+
subscribe(callback) {
|
323
|
+
return this.contentBinding.subscribe(callback);
|
324
|
+
}
|
325
|
+
};
|
326
|
+
|
339
327
|
// src/context/providers/TextContentPartProvider.tsx
|
340
328
|
|
341
329
|
var COMPLETE_STATUS = {
|
@@ -346,18 +334,22 @@ var RUNNING_STATUS = {
|
|
346
334
|
};
|
347
335
|
var TextContentPartProvider = ({ children, text, isRunning }) => {
|
348
336
|
const [context] = _react.useState.call(void 0, () => {
|
337
|
+
const useContentPartRuntime2 = _zustand.create.call(void 0,
|
338
|
+
// TODO
|
339
|
+
() => new ContentPartRuntime(null, null, null)
|
340
|
+
);
|
349
341
|
const useContentPart2 = _zustand.create.call(void 0, () => ({
|
350
342
|
status: isRunning ? RUNNING_STATUS : COMPLETE_STATUS,
|
351
|
-
part: { type: "text", text }
|
343
|
+
part: { type: "text", text },
|
344
|
+
type: "text",
|
345
|
+
text
|
352
346
|
}));
|
353
|
-
return {
|
354
|
-
useContentPart: useContentPart2
|
355
|
-
};
|
347
|
+
return { useContentPartRuntime: useContentPartRuntime2, useContentPart: useContentPart2 };
|
356
348
|
});
|
357
349
|
_react.useEffect.call(void 0, () => {
|
358
350
|
const state = context.useContentPart.getState();
|
359
|
-
const textUpdated = state.
|
360
|
-
const targetTextPart = textUpdated ? { type: "text", text } : state
|
351
|
+
const textUpdated = state.text !== text;
|
352
|
+
const targetTextPart = textUpdated ? { type: "text", text } : state;
|
361
353
|
const targetStatus = isRunning ? RUNNING_STATUS : COMPLETE_STATUS;
|
362
354
|
const statusUpdated = state.status !== targetStatus;
|
363
355
|
if (!textUpdated && !statusUpdated) return;
|
@@ -400,20 +392,25 @@ var { useEditComposer, useEditComposerStore } = createContextStoreHook(
|
|
400
392
|
// src/context/react/ComposerContext.ts
|
401
393
|
|
402
394
|
var useComposerContext = () => {
|
403
|
-
const { useComposer:
|
395
|
+
const { useComposer: useThreadComposer2 } = useThreadContext();
|
404
396
|
const { useEditComposer: useEditComposer2 } = _nullishCoalesce(useMessageContext({ optional: true }), () => ( {}));
|
405
397
|
return _react.useMemo.call(void 0,
|
406
398
|
() => ({
|
407
|
-
useComposer: _nullishCoalesce(useEditComposer2, () => (
|
399
|
+
useComposer: _nullishCoalesce(useEditComposer2, () => ( useThreadComposer2)),
|
408
400
|
type: useEditComposer2 ? "edit" : "new"
|
409
401
|
}),
|
410
|
-
[useEditComposer2,
|
402
|
+
[useEditComposer2, useThreadComposer2]
|
411
403
|
);
|
412
404
|
};
|
413
405
|
var { useComposer, useComposerStore } = createContextStoreHook(
|
414
406
|
useComposerContext,
|
415
407
|
"useComposer"
|
416
408
|
);
|
409
|
+
function useComposerRuntime(options) {
|
410
|
+
const messageRuntime = useMessageRuntime({ optional: true });
|
411
|
+
const threadRuntime = useThreadRuntime(options);
|
412
|
+
return messageRuntime ? messageRuntime.composer : _nullishCoalesce(_optionalChain([threadRuntime, 'optionalAccess', _5 => _5.composer]), () => ( null));
|
413
|
+
}
|
417
414
|
|
418
415
|
// src/hooks/useAppendMessage.tsx
|
419
416
|
|
@@ -462,7 +459,7 @@ var useAssistantTool = (tool) => {
|
|
462
459
|
const unsub2 = render ? toolUIsStore.getState().setToolUI(toolName, render) : void 0;
|
463
460
|
return () => {
|
464
461
|
unsub1();
|
465
|
-
_optionalChain([unsub2, 'optionalCall',
|
462
|
+
_optionalChain([unsub2, 'optionalCall', _6 => _6()]);
|
466
463
|
};
|
467
464
|
}, [assistantRuntime, toolUIsStore, tool]);
|
468
465
|
};
|
@@ -579,12 +576,11 @@ var useActionBarCopy = ({
|
|
579
576
|
// src/primitive-hooks/actionBar/useActionBarEdit.tsx
|
580
577
|
|
581
578
|
var useActionBarEdit = () => {
|
582
|
-
const
|
583
|
-
const disabled =
|
579
|
+
const composerRuntime = useComposerRuntime();
|
580
|
+
const disabled = useComposer((c) => c.isEditing);
|
584
581
|
const callback = _react.useCallback.call(void 0, () => {
|
585
|
-
|
586
|
-
|
587
|
-
}, [editComposerStore]);
|
582
|
+
composerRuntime.beginEdit();
|
583
|
+
}, [composerRuntime]);
|
588
584
|
if (disabled) return null;
|
589
585
|
return callback;
|
590
586
|
};
|
@@ -594,7 +590,7 @@ var useActionBarEdit = () => {
|
|
594
590
|
var useActionBarReload = () => {
|
595
591
|
const messageStore = useMessageStore();
|
596
592
|
const threadStore = useThreadStore();
|
597
|
-
const
|
593
|
+
const messageRuntime = useMessageRuntime();
|
598
594
|
const threadComposerStore = useThreadComposerStore();
|
599
595
|
const threadViewportStore = useThreadViewportStore();
|
600
596
|
const disabled = useCombinedStore(
|
@@ -602,11 +598,10 @@ var useActionBarReload = () => {
|
|
602
598
|
(t, m) => t.isRunning || t.isDisabled || m.role !== "assistant"
|
603
599
|
);
|
604
600
|
const callback = _react.useCallback.call(void 0, () => {
|
605
|
-
|
606
|
-
threadRuntime.startRun(parentId);
|
601
|
+
messageRuntime.reload();
|
607
602
|
threadViewportStore.getState().scrollToBottom();
|
608
603
|
threadComposerStore.getState().focus();
|
609
|
-
}, [
|
604
|
+
}, [messageRuntime, threadComposerStore, threadViewportStore]);
|
610
605
|
if (disabled) return null;
|
611
606
|
return callback;
|
612
607
|
};
|
@@ -616,19 +611,18 @@ var useActionBarReload = () => {
|
|
616
611
|
var useActionBarSpeak = () => {
|
617
612
|
const messageStore = useMessageStore();
|
618
613
|
const editComposerStore = useEditComposerStore();
|
619
|
-
const
|
614
|
+
const messageRunime = useMessageRuntime();
|
620
615
|
const messageUtilsStore = useMessageUtilsStore();
|
621
616
|
const hasSpeakableContent = useCombinedStore(
|
622
617
|
[messageStore, editComposerStore],
|
623
|
-
(
|
618
|
+
(message, c) => {
|
624
619
|
return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
|
625
620
|
}
|
626
621
|
);
|
627
622
|
const callback = _react.useCallback.call(void 0, async () => {
|
628
|
-
const
|
629
|
-
const utt = threadRuntime.speak(message.id);
|
623
|
+
const utt = messageRunime.speak();
|
630
624
|
messageUtilsStore.getState().addUtterance(utt);
|
631
|
-
}, [
|
625
|
+
}, [messageRunime, messageUtilsStore]);
|
632
626
|
if (!hasSpeakableContent) return null;
|
633
627
|
return callback;
|
634
628
|
};
|
@@ -648,32 +642,28 @@ var useActionBarStopSpeaking = () => {
|
|
648
642
|
// src/primitive-hooks/actionBar/useActionBarFeedbackPositive.tsx
|
649
643
|
|
650
644
|
var useActionBarFeedbackPositive = () => {
|
651
|
-
const
|
652
|
-
const messageStore = useMessageStore();
|
645
|
+
const messageRuntime = useMessageRuntime();
|
653
646
|
const messageUtilsStore = useMessageUtilsStore();
|
654
647
|
const callback = _react.useCallback.call(void 0, () => {
|
655
|
-
|
656
|
-
messageId: messageStore.getState().id,
|
648
|
+
messageRuntime.submitFeedback({
|
657
649
|
type: "positive"
|
658
650
|
});
|
659
651
|
messageUtilsStore.getState().setSubmittedFeedback("positive");
|
660
|
-
}, [
|
652
|
+
}, [messageUtilsStore, messageRuntime]);
|
661
653
|
return callback;
|
662
654
|
};
|
663
655
|
|
664
656
|
// src/primitive-hooks/actionBar/useActionBarFeedbackNegative.tsx
|
665
657
|
|
666
658
|
var useActionBarFeedbackNegative = () => {
|
667
|
-
const
|
668
|
-
const messageStore = useMessageStore();
|
659
|
+
const messageRuntime = useMessageRuntime();
|
669
660
|
const messageUtilsStore = useMessageUtilsStore();
|
670
661
|
const callback = _react.useCallback.call(void 0, () => {
|
671
|
-
|
672
|
-
messageId: messageStore.getState().id,
|
662
|
+
messageRuntime.submitFeedback({
|
673
663
|
type: "negative"
|
674
664
|
});
|
675
665
|
messageUtilsStore.getState().setSubmittedFeedback("negative");
|
676
|
-
}, [
|
666
|
+
}, [messageUtilsStore, messageRuntime]);
|
677
667
|
return callback;
|
678
668
|
};
|
679
669
|
|
@@ -782,7 +772,7 @@ var useComposerAddAttachment = () => {
|
|
782
772
|
input.accept = attachmentAccept;
|
783
773
|
}
|
784
774
|
input.onchange = (e) => {
|
785
|
-
const file = _optionalChain([e, 'access',
|
775
|
+
const file = _optionalChain([e, 'access', _7 => _7.target, 'access', _8 => _8.files, 'optionalAccess', _9 => _9[0]]);
|
786
776
|
if (!file) return;
|
787
777
|
addAttachment(file);
|
788
778
|
};
|
@@ -795,7 +785,7 @@ var useComposerAddAttachment = () => {
|
|
795
785
|
// src/primitive-hooks/contentPart/useContentPartDisplay.tsx
|
796
786
|
var useContentPartDisplay = () => {
|
797
787
|
const display = useContentPart((c) => {
|
798
|
-
if (c.
|
788
|
+
if (c.type !== "ui")
|
799
789
|
throw new Error(
|
800
790
|
"This component can only be used inside ui content parts."
|
801
791
|
);
|
@@ -807,7 +797,7 @@ var useContentPartDisplay = () => {
|
|
807
797
|
// src/primitive-hooks/contentPart/useContentPartImage.tsx
|
808
798
|
var useContentPartImage = () => {
|
809
799
|
const image = useContentPart((c) => {
|
810
|
-
if (c.
|
800
|
+
if (c.type !== "image")
|
811
801
|
throw new Error(
|
812
802
|
"ContentPartImage can only be used inside image content parts."
|
813
803
|
);
|
@@ -819,7 +809,7 @@ var useContentPartImage = () => {
|
|
819
809
|
// src/primitive-hooks/contentPart/useContentPartText.tsx
|
820
810
|
var useContentPartText = () => {
|
821
811
|
const text = useContentPart((c) => {
|
822
|
-
if (c.
|
812
|
+
if (c.type !== "text")
|
823
813
|
throw new Error(
|
824
814
|
"ContentPartText can only be used inside text content parts."
|
825
815
|
);
|
@@ -857,20 +847,15 @@ var useMessageIf = (props) => {
|
|
857
847
|
|
858
848
|
// src/primitive-hooks/thread/useThreadIf.tsx
|
859
849
|
var useThreadIf = (props) => {
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
(thread
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
if (props.disabled === true && thread.isDisabled) return false;
|
870
|
-
if (props.disabled === false && thread.isDisabled) return false;
|
871
|
-
return true;
|
872
|
-
}
|
873
|
-
);
|
850
|
+
return useThread((thread) => {
|
851
|
+
if (props.empty === true && thread.messages.length !== 0) return false;
|
852
|
+
if (props.empty === false && thread.messages.length === 0) return false;
|
853
|
+
if (props.running === true && !thread.isRunning) return false;
|
854
|
+
if (props.running === false && thread.isRunning) return false;
|
855
|
+
if (props.disabled === true && thread.isDisabled) return false;
|
856
|
+
if (props.disabled === false && thread.isDisabled) return false;
|
857
|
+
return true;
|
858
|
+
});
|
874
859
|
};
|
875
860
|
|
876
861
|
// src/primitive-hooks/thread/useThreadEmpty.tsx
|
@@ -993,7 +978,7 @@ var ActionBarPrimitiveCopy = _react.forwardRef.call(void 0, ({ copiedDuration, o
|
|
993
978
|
ref: forwardedRef,
|
994
979
|
disabled: disabled || !callback,
|
995
980
|
onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
|
996
|
-
_optionalChain([callback, 'optionalCall',
|
981
|
+
_optionalChain([callback, 'optionalCall', _10 => _10()]);
|
997
982
|
})
|
998
983
|
}
|
999
984
|
);
|
@@ -1025,7 +1010,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
|
1025
1010
|
ref: forwardedRef,
|
1026
1011
|
disabled: primitiveProps.disabled || !callback,
|
1027
1012
|
onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
|
1028
|
-
_optionalChain([callback, 'optionalCall',
|
1013
|
+
_optionalChain([callback, 'optionalCall', _11 => _11()]);
|
1029
1014
|
})
|
1030
1015
|
}
|
1031
1016
|
);
|
@@ -1074,7 +1059,7 @@ var ActionBarPrimitiveStopSpeaking = _react.forwardRef.call(void 0, (props, ref)
|
|
1074
1059
|
...props,
|
1075
1060
|
ref,
|
1076
1061
|
onClick: _primitive.composeEventHandlers.call(void 0, props.onClick, () => {
|
1077
|
-
_optionalChain([callback, 'optionalCall',
|
1062
|
+
_optionalChain([callback, 'optionalCall', _12 => _12()]);
|
1078
1063
|
})
|
1079
1064
|
}
|
1080
1065
|
);
|
@@ -1100,7 +1085,7 @@ var ActionBarPrimitiveFeedbackPositive = _react.forwardRef.call(void 0, ({ onCli
|
|
1100
1085
|
ref: forwardedRef,
|
1101
1086
|
disabled: disabled || !callback,
|
1102
1087
|
onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
|
1103
|
-
_optionalChain([callback, 'optionalCall',
|
1088
|
+
_optionalChain([callback, 'optionalCall', _13 => _13()]);
|
1104
1089
|
})
|
1105
1090
|
}
|
1106
1091
|
);
|
@@ -1126,7 +1111,7 @@ var ActionBarPrimitiveFeedbackNegative = _react.forwardRef.call(void 0, ({ onCli
|
|
1126
1111
|
ref: forwardedRef,
|
1127
1112
|
disabled: disabled || !callback,
|
1128
1113
|
onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
|
1129
|
-
_optionalChain([callback, 'optionalCall',
|
1114
|
+
_optionalChain([callback, 'optionalCall', _14 => _14()]);
|
1130
1115
|
})
|
1131
1116
|
}
|
1132
1117
|
);
|
@@ -1381,74 +1366,35 @@ MessagePrimitiveIf.displayName = "MessagePrimitive.If";
|
|
1381
1366
|
// src/primitives/message/MessageContent.tsx
|
1382
1367
|
|
1383
1368
|
|
1384
|
-
// src/context/providers/
|
1369
|
+
// src/context/providers/ContentPartRuntimeProvider.tsx
|
1385
1370
|
|
1386
1371
|
|
1387
1372
|
|
1388
|
-
var
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
if (part.type !== "tool-call") {
|
1395
|
-
if ("reason" in message.status && message.status.reason === "tool-calls" && isLastPart)
|
1396
|
-
throw new Error(
|
1397
|
-
"Encountered unexpected requires-action status. This is likely an internal bug in assistant-ui."
|
1398
|
-
);
|
1399
|
-
return isLastPart ? message.status : COMPLETE_STATUS2;
|
1400
|
-
}
|
1401
|
-
if (!!part.result) {
|
1402
|
-
return COMPLETE_STATUS2;
|
1403
|
-
}
|
1404
|
-
return message.status;
|
1405
|
-
};
|
1406
|
-
var EMPTY_CONTENT = Object.freeze({ type: "text", text: "" });
|
1407
|
-
var getContentPartState = ({ message }, useContentPart2, partIndex) => {
|
1408
|
-
let part = message.content[partIndex];
|
1409
|
-
if (!part) {
|
1410
|
-
if (message.content.length === 0 && partIndex === 0) {
|
1411
|
-
part = EMPTY_CONTENT;
|
1412
|
-
} else {
|
1413
|
-
return null;
|
1414
|
-
}
|
1415
|
-
} else if (message.content.length === 1 && part.type === "text" && part.text.length === 0) {
|
1416
|
-
part = EMPTY_CONTENT;
|
1417
|
-
}
|
1418
|
-
const status = toContentPartStatus(message, partIndex, part);
|
1419
|
-
const currentState = _optionalChain([useContentPart2, 'optionalAccess', _14 => _14.getState, 'call', _15 => _15()]);
|
1420
|
-
if (currentState && currentState.part === part && currentState.status === status)
|
1421
|
-
return null;
|
1422
|
-
return Object.freeze({ part, status });
|
1373
|
+
var useContentPartRuntimeStore = (runtime) => {
|
1374
|
+
const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime));
|
1375
|
+
_react.useEffect.call(void 0, () => {
|
1376
|
+
writableStore(store).setState(runtime, true);
|
1377
|
+
}, [runtime, store]);
|
1378
|
+
return store;
|
1423
1379
|
};
|
1424
|
-
var
|
1425
|
-
const
|
1426
|
-
const [context] = _react.useState.call(void 0, () => {
|
1427
|
-
const useContentPart2 = _zustand.create.call(void 0,
|
1428
|
-
() => getContentPartState(messageStore.getState(), void 0, partIndex)
|
1429
|
-
);
|
1430
|
-
return { useContentPart: useContentPart2 };
|
1431
|
-
});
|
1380
|
+
var useContentPartStore2 = (runtime) => {
|
1381
|
+
const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime.getState()));
|
1432
1382
|
_react.useEffect.call(void 0, () => {
|
1433
|
-
const
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
);
|
1439
|
-
if (!newState) return;
|
1440
|
-
writableStore(context.useContentPart).setState(newState, true);
|
1441
|
-
};
|
1442
|
-
syncContentPart(messageStore.getState());
|
1443
|
-
return messageStore.subscribe(syncContentPart);
|
1444
|
-
}, [context, messageStore, partIndex]);
|
1445
|
-
return context;
|
1383
|
+
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
1384
|
+
updateState();
|
1385
|
+
return runtime.subscribe(updateState);
|
1386
|
+
}, [runtime, store]);
|
1387
|
+
return store;
|
1446
1388
|
};
|
1447
|
-
var
|
1448
|
-
|
1389
|
+
var ContentPartRuntimeProvider = ({
|
1390
|
+
runtime,
|
1449
1391
|
children
|
1450
1392
|
}) => {
|
1451
|
-
const
|
1393
|
+
const useContentPartRuntime2 = useContentPartRuntimeStore(runtime);
|
1394
|
+
const useContentPart2 = useContentPartStore2(runtime);
|
1395
|
+
const [context] = _react.useState.call(void 0, () => {
|
1396
|
+
return { useContentPartRuntime: useContentPartRuntime2, useContentPart: useContentPart2 };
|
1397
|
+
});
|
1452
1398
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartContext.Provider, { value: context, children });
|
1453
1399
|
};
|
1454
1400
|
|
@@ -1493,7 +1439,7 @@ var withSmoothContextProvider = (Component) => {
|
|
1493
1439
|
};
|
1494
1440
|
function useSmoothContext(options) {
|
1495
1441
|
const context = _react.useContext.call(void 0, SmoothContext);
|
1496
|
-
if (!_optionalChain([options, 'optionalAccess',
|
1442
|
+
if (!_optionalChain([options, 'optionalAccess', _15 => _15.optional]) && !context)
|
1497
1443
|
throw new Error(
|
1498
1444
|
"This component must be used within a SmoothContextProvider."
|
1499
1445
|
);
|
@@ -1553,9 +1499,7 @@ var SMOOTH_STATUS = Object.freeze({
|
|
1553
1499
|
type: "running"
|
1554
1500
|
});
|
1555
1501
|
var useSmooth = (state, smooth = false) => {
|
1556
|
-
const {
|
1557
|
-
part: { text }
|
1558
|
-
} = state;
|
1502
|
+
const { text } = state;
|
1559
1503
|
const id = useMessage({
|
1560
1504
|
optional: true,
|
1561
1505
|
selector: (m) => m.id
|
@@ -1567,17 +1511,17 @@ var useSmooth = (state, smooth = false) => {
|
|
1567
1511
|
setDisplayedText(text2);
|
1568
1512
|
if (smoothStatusStore) {
|
1569
1513
|
writableStore(smoothStatusStore).setState(
|
1570
|
-
text2 !== state.
|
1514
|
+
text2 !== state.text ? SMOOTH_STATUS : state.status
|
1571
1515
|
);
|
1572
1516
|
}
|
1573
1517
|
});
|
1574
1518
|
_react.useEffect.call(void 0, () => {
|
1575
1519
|
if (smoothStatusStore) {
|
1576
1520
|
writableStore(smoothStatusStore).setState(
|
1577
|
-
text !== state.
|
1521
|
+
text !== state.text ? SMOOTH_STATUS : state.status
|
1578
1522
|
);
|
1579
1523
|
}
|
1580
|
-
}, [smoothStatusStore, text, displayedText, state.status, state.
|
1524
|
+
}, [smoothStatusStore, text, displayedText, state.status, state.text]);
|
1581
1525
|
const [animatorRef] = _react.useState.call(void 0,
|
1582
1526
|
new TextStreamAnimator(text, setText)
|
1583
1527
|
);
|
@@ -1604,6 +1548,8 @@ var useSmooth = (state, smooth = false) => {
|
|
1604
1548
|
}, [animatorRef]);
|
1605
1549
|
return _react.useMemo.call(void 0,
|
1606
1550
|
() => smooth ? {
|
1551
|
+
type: "text",
|
1552
|
+
text: displayedText,
|
1607
1553
|
part: { type: "text", text: displayedText },
|
1608
1554
|
status: text === displayedText ? state.status : SMOOTH_STATUS
|
1609
1555
|
} : state,
|
@@ -1614,10 +1560,7 @@ var useSmooth = (state, smooth = false) => {
|
|
1614
1560
|
// src/primitives/contentPart/ContentPartText.tsx
|
1615
1561
|
|
1616
1562
|
var ContentPartPrimitiveText = _react.forwardRef.call(void 0, ({ smooth = true, component: Component = "span", ...rest }, forwardedRef) => {
|
1617
|
-
const {
|
1618
|
-
part: { text },
|
1619
|
-
status
|
1620
|
-
} = useSmooth(useContentPartText(), smooth);
|
1563
|
+
const { text, status } = useSmooth(useContentPartText(), smooth);
|
1621
1564
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { "data-status": status.type, ...rest, ref: forwardedRef, children: text });
|
1622
1565
|
});
|
1623
1566
|
ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
|
@@ -1627,18 +1570,14 @@ ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
|
|
1627
1570
|
|
1628
1571
|
|
1629
1572
|
var ContentPartPrimitiveImage = _react.forwardRef.call(void 0, (props, forwardedRef) => {
|
1630
|
-
const {
|
1631
|
-
part: { image }
|
1632
|
-
} = useContentPartImage();
|
1573
|
+
const { image } = useContentPartImage();
|
1633
1574
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.img, { src: image, ...props, ref: forwardedRef });
|
1634
1575
|
});
|
1635
1576
|
ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
|
1636
1577
|
|
1637
1578
|
// src/primitives/contentPart/ContentPartDisplay.tsx
|
1638
1579
|
var ContentPartPrimitiveDisplay = () => {
|
1639
|
-
const {
|
1640
|
-
part: { display }
|
1641
|
-
} = useContentPartDisplay();
|
1580
|
+
const { display } = useContentPartDisplay();
|
1642
1581
|
return _nullishCoalesce(display, () => ( null));
|
1643
1582
|
};
|
1644
1583
|
ContentPartPrimitiveDisplay.displayName = "ContentPartPrimitive.Display";
|
@@ -1650,143 +1589,511 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
|
|
1650
1589
|
};
|
1651
1590
|
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
1652
1591
|
|
1653
|
-
// src/
|
1654
|
-
|
1655
|
-
|
1656
|
-
UI,
|
1657
|
-
...props
|
1658
|
-
}) => {
|
1659
|
-
const Render = _nullishCoalesce(useToolUIs((s) => s.getToolUI(props.part.toolName)), () => ( UI));
|
1660
|
-
if (!Render) return null;
|
1661
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Render, { ...props });
|
1592
|
+
// src/api/ComposerRuntime.ts
|
1593
|
+
var METHOD_NOT_SUPPORTED = () => {
|
1594
|
+
throw new Error("Composer is not available");
|
1662
1595
|
};
|
1663
|
-
var
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1596
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
1597
|
+
var getThreadComposerState = (type, runtime, beginEdit, focus, onFocus) => {
|
1598
|
+
return Object.freeze({
|
1599
|
+
type,
|
1600
|
+
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _16 => _16.isEditing]), () => ( false)),
|
1601
|
+
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _17 => _17.canCancel]), () => ( false)),
|
1602
|
+
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _18 => _18.isEmpty]), () => ( true)),
|
1603
|
+
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _19 => _19.text]), () => ( "")),
|
1604
|
+
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _20 => _20.attachments]), () => ( EMPTY_ARRAY)),
|
1605
|
+
attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _21 => _21.attachmentAccept]), () => ( "*")),
|
1606
|
+
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _22 => _22.text]), () => ( "")),
|
1607
|
+
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _23 => _23.setText, 'access', _24 => _24.bind, 'call', _25 => _25(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1608
|
+
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _26 => _26.setText, 'access', _27 => _27.bind, 'call', _28 => _28(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1609
|
+
edit: beginEdit,
|
1610
|
+
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _29 => _29.send, 'access', _30 => _30.bind, 'call', _31 => _31(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1611
|
+
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _32 => _32.cancel, 'access', _33 => _33.bind, 'call', _34 => _34(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1612
|
+
focus: _nullishCoalesce(focus, () => ( METHOD_NOT_SUPPORTED)),
|
1613
|
+
onFocus: _nullishCoalesce(onFocus, () => ( METHOD_NOT_SUPPORTED)),
|
1614
|
+
reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _35 => _35.reset, 'access', _36 => _36.bind, 'call', _37 => _37(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1615
|
+
addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _38 => _38.addAttachment, 'access', _39 => _39.bind, 'call', _40 => _40(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1616
|
+
removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _41 => _41.removeAttachment, 'access', _42 => _42.bind, 'call', _43 => _43(runtime)]), () => ( METHOD_NOT_SUPPORTED))
|
1617
|
+
});
|
1670
1618
|
};
|
1671
|
-
var
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
Image: Image2 = defaultComponents.Image,
|
1676
|
-
UI = defaultComponents.UI,
|
1677
|
-
tools: { by_name = {}, Fallback: Fallback2 = void 0 } = {}
|
1678
|
-
} = {}
|
1679
|
-
}) => {
|
1680
|
-
const messageStore = useMessageStore();
|
1681
|
-
const threadRuntime = useThreadRuntime();
|
1682
|
-
const { part, status } = useContentPart();
|
1683
|
-
const type = part.type;
|
1684
|
-
switch (type) {
|
1685
|
-
case "text":
|
1686
|
-
if (status.type === "requires-action")
|
1687
|
-
throw new Error("Encountered unexpected requires-action status");
|
1688
|
-
if (part === EMPTY_CONTENT && !!Empty) {
|
1689
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Empty, { status });
|
1690
|
-
}
|
1691
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text2, { part, status });
|
1692
|
-
case "image":
|
1693
|
-
if (status.type === "requires-action")
|
1694
|
-
throw new Error("Encountered unexpected requires-action status");
|
1695
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Image2, { part, status });
|
1696
|
-
case "ui":
|
1697
|
-
if (status.type === "requires-action")
|
1698
|
-
throw new Error("Encountered unexpected requires-action status");
|
1699
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UI, { part, status });
|
1700
|
-
case "tool-call": {
|
1701
|
-
const Tool = by_name[part.toolName] || Fallback2;
|
1702
|
-
const addResult = (result) => threadRuntime.addToolResult({
|
1703
|
-
messageId: messageStore.getState().id,
|
1704
|
-
toolName: part.toolName,
|
1705
|
-
toolCallId: part.toolCallId,
|
1706
|
-
result
|
1707
|
-
});
|
1708
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
1709
|
-
ToolUIDisplay,
|
1710
|
-
{
|
1711
|
-
UI: Tool,
|
1712
|
-
part,
|
1713
|
-
status,
|
1714
|
-
addResult
|
1715
|
-
}
|
1716
|
-
);
|
1717
|
-
}
|
1718
|
-
default:
|
1719
|
-
const unhandledType = type;
|
1720
|
-
throw new Error(`Unknown content part type: ${unhandledType}`);
|
1619
|
+
var ComposerRuntime = (_class2 = class {
|
1620
|
+
constructor(_core, _beginEdit) {;_class2.prototype.__init5.call(this);
|
1621
|
+
this._core = _core;
|
1622
|
+
this._beginEdit = _beginEdit;
|
1721
1623
|
}
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
)
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
);
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
);
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1624
|
+
get type() {
|
1625
|
+
return this._beginEdit ? "edit" : "thread";
|
1626
|
+
}
|
1627
|
+
/**
|
1628
|
+
* @deprecated Use `getState().isEditing` instead. This will be removed in 0.6.0.
|
1629
|
+
*/
|
1630
|
+
get isEditing() {
|
1631
|
+
return this.getState().isEditing;
|
1632
|
+
}
|
1633
|
+
/**
|
1634
|
+
* @deprecated Use `getState().isEmpty` instead. This will be removed in 0.6.0.
|
1635
|
+
*/
|
1636
|
+
get isEmpty() {
|
1637
|
+
return this.getState().isEmpty;
|
1638
|
+
}
|
1639
|
+
/**
|
1640
|
+
* @deprecated Use `getState().canCancel` instead. This will be removed in 0.6.0.
|
1641
|
+
*/
|
1642
|
+
get canCancel() {
|
1643
|
+
return this.getState().canCancel;
|
1644
|
+
}
|
1645
|
+
/**
|
1646
|
+
* @deprecated Use `getState().text` instead. This will be removed in 0.6.0.
|
1647
|
+
*/
|
1648
|
+
get text() {
|
1649
|
+
return this.getState().text;
|
1650
|
+
}
|
1651
|
+
/**
|
1652
|
+
* @deprecated Use `getState().attachmentAccept` instead. This will be removed in 0.6.0.
|
1653
|
+
*/
|
1654
|
+
get attachmentAccept() {
|
1655
|
+
return this.getState().attachmentAccept;
|
1656
|
+
}
|
1657
|
+
// TODO should this instead return getAttachmentByIndex([idx]) instead?
|
1658
|
+
/**
|
1659
|
+
* @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
|
1660
|
+
*/
|
1661
|
+
get attachments() {
|
1662
|
+
return this.getState().attachments;
|
1663
|
+
}
|
1664
|
+
/**
|
1665
|
+
* @deprecated Use `getState().text` instead. This will be removed in 0.6.0.
|
1666
|
+
*/
|
1667
|
+
get value() {
|
1668
|
+
return this.text;
|
1669
|
+
}
|
1670
|
+
getState() {
|
1671
|
+
return getThreadComposerState(
|
1672
|
+
this.type,
|
1673
|
+
this._core.getState(),
|
1674
|
+
_nullishCoalesce(_optionalChain([this, 'access', _44 => _44._beginEdit, 'optionalAccess', _45 => _45.bind, 'call', _46 => _46(this)]), () => ( METHOD_NOT_SUPPORTED)),
|
1675
|
+
this.focus.bind(this),
|
1676
|
+
this.onFocus.bind(this)
|
1677
|
+
);
|
1678
|
+
}
|
1679
|
+
setText(text) {
|
1680
|
+
const core = this._core.getState();
|
1681
|
+
if (!core) throw new Error("Composer is not available");
|
1682
|
+
core.setText(text);
|
1683
|
+
}
|
1684
|
+
setValue(text) {
|
1685
|
+
this.setText(text);
|
1686
|
+
}
|
1687
|
+
addAttachment(file) {
|
1688
|
+
const core = this._core.getState();
|
1689
|
+
if (!core) throw new Error("Composer is not available");
|
1690
|
+
return core.addAttachment(file);
|
1691
|
+
}
|
1692
|
+
// /**
|
1693
|
+
// * @deprecated Use `getAttachmentById(id).removeAttachment` instead. This will be removed in 0.6.0.
|
1694
|
+
// */
|
1695
|
+
removeAttachment(attachmentId) {
|
1696
|
+
const core = this._core.getState();
|
1697
|
+
if (!core) throw new Error("Composer is not available");
|
1698
|
+
return core.removeAttachment(attachmentId);
|
1699
|
+
}
|
1700
|
+
/**
|
1701
|
+
* @deprecated This method will be removed in 0.6.0. Submit feedback if you need this functionality.
|
1702
|
+
*/
|
1703
|
+
reset() {
|
1704
|
+
const core = this._core.getState();
|
1705
|
+
if (!core) throw new Error("Composer is not available");
|
1706
|
+
core.reset();
|
1707
|
+
}
|
1708
|
+
send() {
|
1709
|
+
const core = this._core.getState();
|
1710
|
+
if (!core) throw new Error("Composer is not available");
|
1711
|
+
core.send();
|
1712
|
+
}
|
1713
|
+
cancel() {
|
1714
|
+
const core = this._core.getState();
|
1715
|
+
if (!core) throw new Error("Composer is not available");
|
1716
|
+
core.cancel();
|
1717
|
+
}
|
1718
|
+
beginEdit() {
|
1719
|
+
_optionalChain([this, 'access', _47 => _47._beginEdit, 'optionalCall', _48 => _48()]);
|
1720
|
+
}
|
1721
|
+
/**
|
1722
|
+
* @deprecated Use `beginEdit()` instead. This will be removed in 0.6.0.
|
1723
|
+
*/
|
1724
|
+
edit() {
|
1725
|
+
this.beginEdit();
|
1726
|
+
}
|
1727
|
+
subscribe(callback) {
|
1728
|
+
return this._core.subscribe(callback);
|
1729
|
+
}
|
1730
|
+
__init5() {this._focusListeners = /* @__PURE__ */ new Set()}
|
1731
|
+
focus() {
|
1732
|
+
this._focusListeners.forEach((callback) => callback());
|
1733
|
+
}
|
1734
|
+
onFocus(callback) {
|
1735
|
+
this._focusListeners.add(callback);
|
1736
|
+
return () => this._focusListeners.delete(callback);
|
1737
|
+
}
|
1738
|
+
}, _class2);
|
1739
|
+
|
1740
|
+
// src/api/subscribable/BaseSubject.ts
|
1741
|
+
var BaseSubject = (_class3 = class {constructor() { _class3.prototype.__init6.call(this); }
|
1742
|
+
__init6() {this._subscriptions = /* @__PURE__ */ new Set()}
|
1743
|
+
|
1744
|
+
get isConnected() {
|
1745
|
+
return !!this._connection;
|
1746
|
+
}
|
1747
|
+
notifySubscribers() {
|
1748
|
+
for (const callback of this._subscriptions) callback();
|
1749
|
+
}
|
1750
|
+
_updateConnection() {
|
1751
|
+
if (this._subscriptions.size > 0) {
|
1752
|
+
if (this._connection) return;
|
1753
|
+
this._connection = this._connect();
|
1754
|
+
} else {
|
1755
|
+
_optionalChain([this, 'access', _49 => _49._connection, 'optionalCall', _50 => _50()]);
|
1756
|
+
this._connection = void 0;
|
1757
|
+
}
|
1758
|
+
}
|
1759
|
+
subscribe(callback) {
|
1760
|
+
this._subscriptions.add(callback);
|
1761
|
+
this._updateConnection();
|
1762
|
+
return () => {
|
1763
|
+
this._subscriptions.delete(callback);
|
1764
|
+
this._updateConnection();
|
1765
|
+
};
|
1766
|
+
}
|
1767
|
+
}, _class3);
|
1768
|
+
|
1769
|
+
// src/api/subscribable/NestedSubscriptionSubject.ts
|
1770
|
+
var NestedSubscriptionSubject = class extends BaseSubject {
|
1771
|
+
constructor(binding) {
|
1772
|
+
super();
|
1773
|
+
this.binding = binding;
|
1774
|
+
}
|
1775
|
+
getState() {
|
1776
|
+
return this.binding.getState();
|
1777
|
+
}
|
1778
|
+
_connect() {
|
1779
|
+
const callback = () => {
|
1780
|
+
this.notifySubscribers();
|
1781
|
+
};
|
1782
|
+
let lastState = this.binding.getState();
|
1783
|
+
let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess', _51 => _51.subscribe, 'call', _52 => _52(callback)]);
|
1784
|
+
const onRuntimeUpdate = () => {
|
1785
|
+
const newState = this.binding.getState();
|
1786
|
+
if (newState === lastState) return;
|
1787
|
+
lastState = newState;
|
1788
|
+
_optionalChain([innerUnsubscribe, 'optionalCall', _53 => _53()]);
|
1789
|
+
innerUnsubscribe = _optionalChain([this, 'access', _54 => _54.binding, 'access', _55 => _55.getState, 'call', _56 => _56(), 'optionalAccess', _57 => _57.subscribe, 'call', _58 => _58(callback)]);
|
1790
|
+
callback();
|
1791
|
+
};
|
1792
|
+
const outerUnsubscribe = this.binding.subscribe(onRuntimeUpdate);
|
1793
|
+
return () => {
|
1794
|
+
_optionalChain([outerUnsubscribe, 'optionalCall', _59 => _59()]);
|
1795
|
+
_optionalChain([innerUnsubscribe, 'optionalCall', _60 => _60()]);
|
1796
|
+
};
|
1797
|
+
}
|
1798
|
+
};
|
1799
|
+
|
1800
|
+
// src/api/subscribable/shallowEqual.ts
|
1801
|
+
function shallowEqual(objA, objB) {
|
1802
|
+
if (objA === void 0 && objB === void 0) return true;
|
1803
|
+
if (objA === void 0) return false;
|
1804
|
+
if (objB === void 0) return false;
|
1805
|
+
for (const key of Object.keys(objA)) {
|
1806
|
+
const valueA = objA[key];
|
1807
|
+
const valueB = objB[key];
|
1808
|
+
if (!Object.is(valueA, valueB)) return false;
|
1809
|
+
}
|
1810
|
+
return true;
|
1811
|
+
}
|
1812
|
+
|
1813
|
+
// src/api/subscribable/ShallowMemoizeSubject.ts
|
1814
|
+
var ShallowMemoizeSubject = (_class4 = class extends BaseSubject {
|
1815
|
+
constructor(binding) {
|
1816
|
+
super();_class4.prototype.__init7.call(this);;
|
1817
|
+
this.binding = binding;
|
1818
|
+
const state = binding.getState();
|
1819
|
+
if (state === void 0)
|
1820
|
+
throw new Error("Entry not available in the store");
|
1821
|
+
this._previousState = state;
|
1822
|
+
}
|
1823
|
+
|
1824
|
+
__init7() {this.getState = () => {
|
1825
|
+
if (!this.isConnected) this._syncState();
|
1826
|
+
return this._previousState;
|
1827
|
+
}}
|
1828
|
+
_syncState() {
|
1829
|
+
const state = this.binding.getState();
|
1830
|
+
if (state === void 0) return false;
|
1831
|
+
if (shallowEqual(state, this._previousState)) return false;
|
1832
|
+
this._previousState = state;
|
1833
|
+
return true;
|
1834
|
+
}
|
1835
|
+
_connect() {
|
1836
|
+
const callback = () => {
|
1837
|
+
if (this._syncState()) {
|
1838
|
+
this.notifySubscribers();
|
1839
|
+
}
|
1840
|
+
};
|
1841
|
+
return this.binding.subscribe(callback);
|
1842
|
+
}
|
1843
|
+
}, _class4);
|
1844
|
+
|
1845
|
+
// src/api/MessageRuntime.ts
|
1846
|
+
var COMPLETE_STATUS2 = {
|
1847
|
+
type: "complete"
|
1848
|
+
};
|
1849
|
+
var toContentPartStatus = (message, partIndex, part) => {
|
1850
|
+
if (message.role !== "assistant") return COMPLETE_STATUS2;
|
1851
|
+
const isLastPart = partIndex === Math.max(0, message.content.length - 1);
|
1852
|
+
if (part.type !== "tool-call") {
|
1853
|
+
if ("reason" in message.status && message.status.reason === "tool-calls" && isLastPart)
|
1854
|
+
throw new Error(
|
1855
|
+
"Encountered unexpected requires-action status. This is likely an internal bug in assistant-ui."
|
1856
|
+
);
|
1857
|
+
return isLastPart ? message.status : COMPLETE_STATUS2;
|
1858
|
+
}
|
1859
|
+
if (!!part.result) {
|
1860
|
+
return COMPLETE_STATUS2;
|
1861
|
+
}
|
1862
|
+
return message.status;
|
1863
|
+
};
|
1864
|
+
var EMPTY_CONTENT = Object.freeze({ type: "text", text: "" });
|
1865
|
+
var getContentPartState = (message, partIndex) => {
|
1866
|
+
let part = message.content[partIndex];
|
1867
|
+
if (!part) {
|
1868
|
+
if (message.content.length === 0 && partIndex === 0) {
|
1869
|
+
part = EMPTY_CONTENT;
|
1870
|
+
} else {
|
1871
|
+
return void 0;
|
1872
|
+
}
|
1873
|
+
} else if (message.content.length === 1 && part.type === "text" && part.text.length === 0) {
|
1874
|
+
part = EMPTY_CONTENT;
|
1875
|
+
}
|
1876
|
+
const status = toContentPartStatus(message, partIndex, part);
|
1877
|
+
return Object.freeze({ ...part, part, status });
|
1878
|
+
};
|
1879
|
+
var MessageRuntime = (_class5 = class {
|
1880
|
+
constructor(_core, _threadBinding) {;_class5.prototype.__init8.call(this);
|
1881
|
+
this._core = _core;
|
1882
|
+
this._threadBinding = _threadBinding;
|
1883
|
+
}
|
1884
|
+
__init8() {this.composer = new ComposerRuntime(
|
1885
|
+
new NestedSubscriptionSubject({
|
1886
|
+
getState: () => this._threadBinding.getState().getEditComposer(this._core.getState().id),
|
1887
|
+
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
1888
|
+
}),
|
1889
|
+
() => this._threadBinding.getState().beginEdit(this._core.getState().id)
|
1890
|
+
)}
|
1891
|
+
getState() {
|
1892
|
+
return this._core.getState();
|
1893
|
+
}
|
1894
|
+
// TODO improve type
|
1895
|
+
unstable_edit(message) {
|
1896
|
+
const state = this._core.getState();
|
1897
|
+
if (!state) throw new Error("Message is not available");
|
1898
|
+
this._threadBinding.getState().append({
|
1899
|
+
...message,
|
1900
|
+
parentId: state.parentId
|
1901
|
+
});
|
1902
|
+
}
|
1903
|
+
reload() {
|
1904
|
+
const state = this._core.getState();
|
1905
|
+
if (!state) throw new Error("Message is not available");
|
1906
|
+
if (state.role !== "assistant")
|
1907
|
+
throw new Error("Can only reload assistant messages");
|
1908
|
+
this._threadBinding.getState().startRun(state.parentId);
|
1909
|
+
}
|
1910
|
+
speak() {
|
1911
|
+
const state = this._core.getState();
|
1912
|
+
if (!state) throw new Error("Message is not available");
|
1913
|
+
return this._threadBinding.getState().speak(state.id);
|
1914
|
+
}
|
1915
|
+
submitFeedback({ type }) {
|
1916
|
+
const state = this._core.getState();
|
1917
|
+
if (!state) throw new Error("Message is not available");
|
1918
|
+
this._threadBinding.getState().submitFeedback({
|
1919
|
+
messageId: state.id,
|
1920
|
+
type
|
1921
|
+
});
|
1922
|
+
}
|
1923
|
+
switchToBranch({
|
1924
|
+
position,
|
1925
|
+
branchId
|
1926
|
+
}) {
|
1927
|
+
const state = this._core.getState();
|
1928
|
+
if (!state) throw new Error("Message is not available");
|
1929
|
+
if (branchId && position) {
|
1930
|
+
throw new Error("May not specify both branchId and position");
|
1931
|
+
} else if (!branchId && !position) {
|
1932
|
+
throw new Error("Must specify either branchId or position");
|
1933
|
+
}
|
1934
|
+
const thread = this._threadBinding.getState();
|
1935
|
+
const branches = thread.getBranches(state.id);
|
1936
|
+
let targetBranch = branchId;
|
1937
|
+
if (position === "previous") {
|
1938
|
+
targetBranch = branches[state.branchNumber - 2];
|
1939
|
+
} else if (position === "next") {
|
1940
|
+
targetBranch = branches[state.branchNumber];
|
1941
|
+
}
|
1942
|
+
if (!targetBranch) throw new Error("Branch not found");
|
1943
|
+
this._threadBinding.getState().switchToBranch(targetBranch);
|
1944
|
+
}
|
1945
|
+
subscribe(callback) {
|
1946
|
+
return this._core.subscribe(callback);
|
1947
|
+
}
|
1948
|
+
unstable_getContentPartByIndex(idx) {
|
1949
|
+
if (idx < 0) throw new Error("Message index must be >= 0");
|
1950
|
+
return new ContentPartRuntime(
|
1951
|
+
new ShallowMemoizeSubject({
|
1952
|
+
getState: () => {
|
1953
|
+
return getContentPartState(this.getState(), idx);
|
1954
|
+
},
|
1955
|
+
subscribe: (callback) => this._core.subscribe(callback)
|
1956
|
+
}),
|
1957
|
+
this._core,
|
1958
|
+
this._threadBinding
|
1959
|
+
);
|
1960
|
+
}
|
1961
|
+
}, _class5);
|
1962
|
+
|
1963
|
+
// src/primitives/message/MessageContent.tsx
|
1964
|
+
|
1965
|
+
var ToolUIDisplay = ({
|
1966
|
+
UI,
|
1967
|
+
...props
|
1968
|
+
}) => {
|
1969
|
+
const Render = _nullishCoalesce(useToolUIs((s) => s.getToolUI(props.toolName)), () => ( UI));
|
1970
|
+
if (!Render) return null;
|
1971
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Render, { ...props });
|
1972
|
+
};
|
1973
|
+
var defaultComponents = {
|
1974
|
+
Text: () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { style: { whiteSpace: "pre-line" }, children: [
|
1975
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveText, {}),
|
1976
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
|
1977
|
+
] }),
|
1978
|
+
Image: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveImage, {}),
|
1979
|
+
UI: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveDisplay, {})
|
1980
|
+
};
|
1981
|
+
var MessageContentPartComponent = ({
|
1982
|
+
components: {
|
1983
|
+
Text: Text2 = defaultComponents.Text,
|
1984
|
+
Empty,
|
1985
|
+
Image: Image2 = defaultComponents.Image,
|
1986
|
+
UI = defaultComponents.UI,
|
1987
|
+
tools: { by_name = {}, Fallback: Fallback2 = void 0 } = {}
|
1988
|
+
} = {}
|
1989
|
+
}) => {
|
1990
|
+
const messageStore = useMessageStore();
|
1991
|
+
const threadRuntime = useThreadRuntime();
|
1992
|
+
const part = useContentPart();
|
1993
|
+
const type = part.type;
|
1994
|
+
switch (type) {
|
1995
|
+
case "text":
|
1996
|
+
if (part.status.type === "requires-action")
|
1997
|
+
throw new Error("Encountered unexpected requires-action status");
|
1998
|
+
if (part.part === EMPTY_CONTENT && !!Empty) {
|
1999
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Empty, { status: part.status });
|
2000
|
+
}
|
2001
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text2, { ...part, part });
|
2002
|
+
case "image":
|
2003
|
+
if (part.status.type === "requires-action")
|
2004
|
+
throw new Error("Encountered unexpected requires-action status");
|
2005
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Image2, { ...part, part });
|
2006
|
+
case "ui":
|
2007
|
+
if (part.status.type === "requires-action")
|
2008
|
+
throw new Error("Encountered unexpected requires-action status");
|
2009
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UI, { ...part, part });
|
2010
|
+
case "tool-call": {
|
2011
|
+
const Tool = by_name[part.toolName] || Fallback2;
|
2012
|
+
const addResult = (result) => threadRuntime.addToolResult({
|
2013
|
+
messageId: messageStore.getState().id,
|
2014
|
+
toolName: part.toolName,
|
2015
|
+
toolCallId: part.toolCallId,
|
2016
|
+
result
|
2017
|
+
});
|
2018
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ToolUIDisplay, { ...part, part, UI: Tool, addResult });
|
2019
|
+
}
|
2020
|
+
default:
|
2021
|
+
const unhandledType = type;
|
2022
|
+
throw new Error(`Unknown content part type: ${unhandledType}`);
|
2023
|
+
}
|
2024
|
+
};
|
2025
|
+
var MessageContentPartImpl = ({
|
2026
|
+
partIndex,
|
2027
|
+
components
|
2028
|
+
}) => {
|
2029
|
+
const messageRuntime = useMessageRuntime();
|
2030
|
+
const runtime = _react.useMemo.call(void 0,
|
2031
|
+
() => messageRuntime.unstable_getContentPartByIndex(partIndex),
|
2032
|
+
[messageRuntime, partIndex]
|
2033
|
+
);
|
2034
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContentPartComponent, { components }) });
|
2035
|
+
};
|
2036
|
+
var MessageContentPart = _react.memo.call(void 0,
|
2037
|
+
MessageContentPartImpl,
|
2038
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _61 => _61.components, 'optionalAccess', _62 => _62.Text]) === _optionalChain([next, 'access', _63 => _63.components, 'optionalAccess', _64 => _64.Text]) && _optionalChain([prev, 'access', _65 => _65.components, 'optionalAccess', _66 => _66.Image]) === _optionalChain([next, 'access', _67 => _67.components, 'optionalAccess', _68 => _68.Image]) && _optionalChain([prev, 'access', _69 => _69.components, 'optionalAccess', _70 => _70.UI]) === _optionalChain([next, 'access', _71 => _71.components, 'optionalAccess', _72 => _72.UI]) && _optionalChain([prev, 'access', _73 => _73.components, 'optionalAccess', _74 => _74.tools]) === _optionalChain([next, 'access', _75 => _75.components, 'optionalAccess', _76 => _76.tools])
|
2039
|
+
);
|
2040
|
+
var MessagePrimitiveContent = ({
|
2041
|
+
components
|
2042
|
+
}) => {
|
2043
|
+
const contentLength = useMessage((s) => s.content.length) || 1;
|
2044
|
+
return Array.from({ length: contentLength }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContentPart, { partIndex: index, components }, index));
|
2045
|
+
};
|
2046
|
+
MessagePrimitiveContent.displayName = "MessagePrimitive.Content";
|
2047
|
+
|
2048
|
+
// src/primitives/message/MessageInProgress.tsx
|
2049
|
+
var MessagePrimitiveInProgress = () => {
|
2050
|
+
return null;
|
2051
|
+
};
|
2052
|
+
MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
|
2053
|
+
|
2054
|
+
// src/primitives/message/MessageAttachments.tsx
|
2055
|
+
|
2056
|
+
|
2057
|
+
// src/context/react/AttachmentContext.ts
|
2058
|
+
|
2059
|
+
var AttachmentContext = _react.createContext.call(void 0,
|
2060
|
+
null
|
2061
|
+
);
|
2062
|
+
function useAttachmentContext(options) {
|
2063
|
+
const context = _react.useContext.call(void 0, AttachmentContext);
|
2064
|
+
if (!_optionalChain([options, 'optionalAccess', _77 => _77.optional]) && !context)
|
2065
|
+
throw new Error(
|
2066
|
+
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
2067
|
+
);
|
2068
|
+
return context;
|
2069
|
+
}
|
2070
|
+
function useComposerAttachmentContext(options) {
|
2071
|
+
const context = useAttachmentContext(options);
|
2072
|
+
if (!context) return null;
|
2073
|
+
if (context.type !== "composer")
|
2074
|
+
throw new Error(
|
2075
|
+
"This component must be used within a ComposerPrimitive.Attachments component."
|
2076
|
+
);
|
2077
|
+
return context;
|
2078
|
+
}
|
2079
|
+
function useMessageAttachmentContext(options) {
|
2080
|
+
const context = useAttachmentContext(options);
|
2081
|
+
if (!context) return null;
|
2082
|
+
if (context.type !== "message")
|
2083
|
+
throw new Error(
|
2084
|
+
"This component must be used within a MessagePrimitive.Attachments component."
|
2085
|
+
);
|
2086
|
+
return context;
|
2087
|
+
}
|
2088
|
+
var { useAttachment, useAttachmentStore } = createContextStoreHook(
|
2089
|
+
useAttachmentContext,
|
2090
|
+
"useAttachment"
|
2091
|
+
);
|
2092
|
+
var {
|
2093
|
+
useAttachment: useComposerAttachment,
|
2094
|
+
useAttachmentStore: useComposerAttachmentStore
|
2095
|
+
} = createContextStoreHook(useComposerAttachmentContext, "useAttachment");
|
2096
|
+
var {
|
1790
2097
|
useAttachment: useMessageAttachment,
|
1791
2098
|
useAttachmentStore: useMessageAttachmentStore
|
1792
2099
|
} = createContextStoreHook(useMessageAttachmentContext, "useAttachment");
|
@@ -1800,7 +2107,7 @@ var getAttachment = (message, useAttachment2, partIndex) => {
|
|
1800
2107
|
const attachments = message.attachments;
|
1801
2108
|
const attachment = attachments[partIndex];
|
1802
2109
|
if (!attachment) return null;
|
1803
|
-
const currentState = _optionalChain([useAttachment2, 'optionalAccess',
|
2110
|
+
const currentState = _optionalChain([useAttachment2, 'optionalAccess', _78 => _78.getState, 'call', _79 => _79()]);
|
1804
2111
|
if (currentState && currentState.attachment === attachment) return null;
|
1805
2112
|
return Object.freeze({ attachment });
|
1806
2113
|
};
|
@@ -1843,11 +2150,11 @@ var getComponent = (components, attachment) => {
|
|
1843
2150
|
const type = attachment.type;
|
1844
2151
|
switch (type) {
|
1845
2152
|
case "image":
|
1846
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2153
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _80 => _80.Image]), () => ( _optionalChain([components, 'optionalAccess', _81 => _81.Attachment])));
|
1847
2154
|
case "document":
|
1848
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2155
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _82 => _82.Document]), () => ( _optionalChain([components, 'optionalAccess', _83 => _83.Attachment])));
|
1849
2156
|
case "file":
|
1850
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2157
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _84 => _84.File]), () => ( _optionalChain([components, 'optionalAccess', _85 => _85.Attachment])));
|
1851
2158
|
default:
|
1852
2159
|
const _exhaustiveCheck = type;
|
1853
2160
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
@@ -1865,7 +2172,7 @@ var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
1865
2172
|
};
|
1866
2173
|
var MessageAttachment = _react.memo.call(void 0,
|
1867
2174
|
MessageAttachmentImpl,
|
1868
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2175
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _86 => _86.components, 'optionalAccess', _87 => _87.Image]) === _optionalChain([next, 'access', _88 => _88.components, 'optionalAccess', _89 => _89.Image]) && _optionalChain([prev, 'access', _90 => _90.components, 'optionalAccess', _91 => _91.Document]) === _optionalChain([next, 'access', _92 => _92.components, 'optionalAccess', _93 => _93.Document]) && _optionalChain([prev, 'access', _94 => _94.components, 'optionalAccess', _95 => _95.File]) === _optionalChain([next, 'access', _96 => _96.components, 'optionalAccess', _97 => _97.File]) && _optionalChain([prev, 'access', _98 => _98.components, 'optionalAccess', _99 => _99.Attachment]) === _optionalChain([next, 'access', _100 => _100.components, 'optionalAccess', _101 => _101.Attachment])
|
1869
2176
|
);
|
1870
2177
|
var MessagePrimitiveAttachments = ({ components }) => {
|
1871
2178
|
const attachmentsCount = useMessage(({ message }) => {
|
@@ -1976,7 +2283,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
1976
2283
|
const { isRunning } = threadStore.getState();
|
1977
2284
|
if (!isRunning) {
|
1978
2285
|
e.preventDefault();
|
1979
|
-
_optionalChain([textareaRef, 'access',
|
2286
|
+
_optionalChain([textareaRef, 'access', _102 => _102.current, 'optionalAccess', _103 => _103.closest, 'call', _104 => _104("form"), 'optionalAccess', _105 => _105.requestSubmit, 'call', _106 => _106()]);
|
1980
2287
|
}
|
1981
2288
|
}
|
1982
2289
|
};
|
@@ -2044,7 +2351,7 @@ var ComposerPrimitiveAddAttachment = createActionButton(
|
|
2044
2351
|
var getAttachment2 = ({ attachments }, useAttachment2, partIndex) => {
|
2045
2352
|
const attachment = attachments[partIndex];
|
2046
2353
|
if (!attachment) return null;
|
2047
|
-
const currentState = _optionalChain([useAttachment2, 'optionalAccess',
|
2354
|
+
const currentState = _optionalChain([useAttachment2, 'optionalAccess', _107 => _107.getState, 'call', _108 => _108()]);
|
2048
2355
|
if (currentState && currentState.attachment === attachment) return null;
|
2049
2356
|
return Object.freeze({ attachment });
|
2050
2357
|
};
|
@@ -2084,11 +2391,11 @@ var getComponent2 = (components, attachment) => {
|
|
2084
2391
|
const type = attachment.type;
|
2085
2392
|
switch (type) {
|
2086
2393
|
case "image":
|
2087
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2394
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _109 => _109.Image]), () => ( _optionalChain([components, 'optionalAccess', _110 => _110.Attachment])));
|
2088
2395
|
case "document":
|
2089
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2396
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _111 => _111.Document]), () => ( _optionalChain([components, 'optionalAccess', _112 => _112.Attachment])));
|
2090
2397
|
case "file":
|
2091
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2398
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _113 => _113.File]), () => ( _optionalChain([components, 'optionalAccess', _114 => _114.Attachment])));
|
2092
2399
|
default:
|
2093
2400
|
const _exhaustiveCheck = type;
|
2094
2401
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
@@ -2106,7 +2413,7 @@ var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
2106
2413
|
};
|
2107
2414
|
var ComposerAttachment = _react.memo.call(void 0,
|
2108
2415
|
ComposerAttachmentImpl,
|
2109
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2416
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _115 => _115.components, 'optionalAccess', _116 => _116.Image]) === _optionalChain([next, 'access', _117 => _117.components, 'optionalAccess', _118 => _118.Image]) && _optionalChain([prev, 'access', _119 => _119.components, 'optionalAccess', _120 => _120.Document]) === _optionalChain([next, 'access', _121 => _121.components, 'optionalAccess', _122 => _122.Document]) && _optionalChain([prev, 'access', _123 => _123.components, 'optionalAccess', _124 => _124.File]) === _optionalChain([next, 'access', _125 => _125.components, 'optionalAccess', _126 => _126.File]) && _optionalChain([prev, 'access', _127 => _127.components, 'optionalAccess', _128 => _128.Attachment]) === _optionalChain([next, 'access', _129 => _129.components, 'optionalAccess', _130 => _130.Attachment])
|
2110
2417
|
);
|
2111
2418
|
var ComposerPrimitiveAttachments = ({ components }) => {
|
2112
2419
|
const attachmentsCount = useThreadComposer((s) => s.attachments.length);
|
@@ -2311,45 +2618,6 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
|
2311
2618
|
|
2312
2619
|
|
2313
2620
|
|
2314
|
-
// src/context/stores/EditComposer.ts
|
2315
|
-
|
2316
|
-
var makeEditComposerStore = ({
|
2317
|
-
onEdit,
|
2318
|
-
onSend
|
2319
|
-
}) => _zustand.create.call(void 0, )((set, get) => ({
|
2320
|
-
type: "edit",
|
2321
|
-
get value() {
|
2322
|
-
return get().text;
|
2323
|
-
},
|
2324
|
-
setValue(value) {
|
2325
|
-
get().setText(value);
|
2326
|
-
},
|
2327
|
-
text: "",
|
2328
|
-
setText: (text) => {
|
2329
|
-
set({ text, isEmpty: text.trim().length === 0 });
|
2330
|
-
},
|
2331
|
-
canCancel: false,
|
2332
|
-
isEditing: false,
|
2333
|
-
isEmpty: true,
|
2334
|
-
edit: () => {
|
2335
|
-
const text = onEdit();
|
2336
|
-
set({
|
2337
|
-
isEditing: true,
|
2338
|
-
canCancel: true,
|
2339
|
-
isEmpty: text.trim().length === 0,
|
2340
|
-
text
|
2341
|
-
});
|
2342
|
-
},
|
2343
|
-
send: () => {
|
2344
|
-
const text = get().text;
|
2345
|
-
set({ isEditing: false, canCancel: false });
|
2346
|
-
onSend(text);
|
2347
|
-
},
|
2348
|
-
cancel: () => {
|
2349
|
-
set({ isEditing: false, canCancel: false });
|
2350
|
-
}
|
2351
|
-
}));
|
2352
|
-
|
2353
2621
|
// src/context/stores/MessageUtils.ts
|
2354
2622
|
|
2355
2623
|
var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
|
@@ -2365,7 +2633,7 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
|
|
2365
2633
|
},
|
2366
2634
|
isSpeaking: false,
|
2367
2635
|
stopSpeaking: () => {
|
2368
|
-
_optionalChain([utterance, 'optionalAccess',
|
2636
|
+
_optionalChain([utterance, 'optionalAccess', _131 => _131.cancel, 'call', _132 => _132()]);
|
2369
2637
|
},
|
2370
2638
|
addUtterance: (utt) => {
|
2371
2639
|
utterance = utt;
|
@@ -2404,29 +2672,13 @@ var useMessageUtilsStore2 = () => {
|
|
2404
2672
|
return store;
|
2405
2673
|
};
|
2406
2674
|
var useEditComposerStore2 = (useMessageRuntime2) => {
|
2407
|
-
const
|
2408
|
-
|
2409
|
-
|
2410
|
-
|
2411
|
-
|
2412
|
-
|
2413
|
-
|
2414
|
-
},
|
2415
|
-
onSend: (text) => {
|
2416
|
-
const message = useMessageRuntime2.getState().getState();
|
2417
|
-
const previousText = getThreadMessageText(message);
|
2418
|
-
if (previousText === text) return;
|
2419
|
-
const nonTextParts = message.content.filter(
|
2420
|
-
(part) => part.type !== "text" && part.type !== "ui"
|
2421
|
-
);
|
2422
|
-
useMessageRuntime2.getState().edit({
|
2423
|
-
role: message.role,
|
2424
|
-
content: [{ type: "text", text }, ...nonTextParts],
|
2425
|
-
attachments: _nullishCoalesce(message.attachments, () => ( []))
|
2426
|
-
});
|
2427
|
-
}
|
2428
|
-
})
|
2429
|
-
);
|
2675
|
+
const runtime = useMessageRuntime2.getState().composer;
|
2676
|
+
const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime.getState()));
|
2677
|
+
_react.useEffect.call(void 0, () => {
|
2678
|
+
const updateState = () => writableStore(store).setState(runtime.getState());
|
2679
|
+
updateState();
|
2680
|
+
return runtime.subscribe(updateState);
|
2681
|
+
}, [runtime, store]);
|
2430
2682
|
return store;
|
2431
2683
|
};
|
2432
2684
|
var MessageRuntimeProvider = ({
|
@@ -2500,7 +2752,7 @@ var ThreadMessage = _react.memo.call(void 0,
|
|
2500
2752
|
var ThreadPrimitiveMessagesImpl = ({
|
2501
2753
|
components
|
2502
2754
|
}) => {
|
2503
|
-
const messagesLength =
|
2755
|
+
const messagesLength = useThread((t) => t.messages.length);
|
2504
2756
|
if (messagesLength === 0) return null;
|
2505
2757
|
return Array.from({ length: messagesLength }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessage, { messageIndex: index, components }, index));
|
2506
2758
|
};
|
@@ -2528,7 +2780,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2528
2780
|
let first = true;
|
2529
2781
|
let cleanup;
|
2530
2782
|
const inner = () => {
|
2531
|
-
_optionalChain([cleanup, 'optionalCall',
|
2783
|
+
_optionalChain([cleanup, 'optionalCall', _133 => _133()]);
|
2532
2784
|
cleanup = runtime.thread.subscribe(callback);
|
2533
2785
|
if (!first) {
|
2534
2786
|
callback();
|
@@ -2539,7 +2791,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2539
2791
|
inner();
|
2540
2792
|
return () => {
|
2541
2793
|
unsubscribe();
|
2542
|
-
_optionalChain([cleanup, 'optionalCall',
|
2794
|
+
_optionalChain([cleanup, 'optionalCall', _134 => _134()]);
|
2543
2795
|
};
|
2544
2796
|
};
|
2545
2797
|
|
@@ -2547,8 +2799,8 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2547
2799
|
|
2548
2800
|
|
2549
2801
|
// src/runtimes/core/BaseAssistantRuntimeCore.tsx
|
2550
|
-
var BaseAssistantRuntimeCore = (
|
2551
|
-
constructor(_thread) {;
|
2802
|
+
var BaseAssistantRuntimeCore = (_class6 = class {
|
2803
|
+
constructor(_thread) {;_class6.prototype.__init9.call(this);_class6.prototype.__init10.call(this);
|
2552
2804
|
this._thread = _thread;
|
2553
2805
|
this._thread = _thread;
|
2554
2806
|
}
|
@@ -2559,22 +2811,22 @@ var BaseAssistantRuntimeCore = (_class2 = class {
|
|
2559
2811
|
this._thread = thread;
|
2560
2812
|
this.subscriptionHandler();
|
2561
2813
|
}
|
2562
|
-
|
2814
|
+
__init9() {this._subscriptions = /* @__PURE__ */ new Set()}
|
2563
2815
|
subscribe(callback) {
|
2564
2816
|
this._subscriptions.add(callback);
|
2565
2817
|
return () => this._subscriptions.delete(callback);
|
2566
2818
|
}
|
2567
|
-
|
2819
|
+
__init10() {this.subscriptionHandler = () => {
|
2568
2820
|
for (const callback of this._subscriptions) callback();
|
2569
2821
|
}}
|
2570
|
-
},
|
2822
|
+
}, _class6);
|
2571
2823
|
|
2572
2824
|
// src/internal.ts
|
2573
2825
|
var internal_exports = {};
|
2574
2826
|
_chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
|
2575
2827
|
AssistantRuntime: () => AssistantRuntime,
|
2576
2828
|
BaseAssistantRuntimeCore: () => BaseAssistantRuntimeCore,
|
2577
|
-
|
2829
|
+
DefaultThreadComposerRuntimeCore: () => DefaultThreadComposerRuntimeCore,
|
2578
2830
|
MessageRepository: () => MessageRepository,
|
2579
2831
|
ProxyConfigProvider: () => ProxyConfigProvider,
|
2580
2832
|
ThreadRuntime: () => ThreadRuntime,
|
@@ -2585,41 +2837,56 @@ _chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
|
|
2585
2837
|
withSmoothContextProvider: () => withSmoothContextProvider
|
2586
2838
|
});
|
2587
2839
|
|
2588
|
-
// src/runtimes/
|
2589
|
-
var
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2840
|
+
// src/runtimes/composer/BaseComposerRuntimeCore.tsx
|
2841
|
+
var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototype.__init11.call(this);_class7.prototype.__init12.call(this);_class7.prototype.__init13.call(this);_class7.prototype.__init14.call(this);_class7.prototype.__init15.call(this); }
|
2842
|
+
__init11() {this.isEditing = true}
|
2843
|
+
__init12() {this.attachmentAccept = "*"}
|
2844
|
+
__init13() {this._attachments = []}
|
2845
|
+
set attachments(value) {
|
2846
|
+
this._attachments = value;
|
2847
|
+
this.notifySubscribers();
|
2848
|
+
}
|
2849
|
+
get attachments() {
|
2850
|
+
return this._attachments;
|
2593
2851
|
}
|
2594
|
-
|
2595
|
-
__init7() {this.attachmentAccept = "*"}
|
2596
2852
|
get isEmpty() {
|
2597
2853
|
return !this.text.trim() && !this.attachments.length;
|
2598
2854
|
}
|
2599
|
-
|
2600
|
-
get
|
2601
|
-
return this.
|
2855
|
+
__init14() {this._text = ""}
|
2856
|
+
get text() {
|
2857
|
+
return this._text;
|
2602
2858
|
}
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2606
|
-
|
2607
|
-
|
2608
|
-
|
2609
|
-
|
2859
|
+
setText(value) {
|
2860
|
+
this._text = value;
|
2861
|
+
this.notifySubscribers();
|
2862
|
+
}
|
2863
|
+
reset() {
|
2864
|
+
this._text = "";
|
2865
|
+
this._attachments = [];
|
2866
|
+
this.notifySubscribers();
|
2867
|
+
}
|
2868
|
+
async send() {
|
2869
|
+
const attachments = this._attachmentAdapter ? await Promise.all(
|
2870
|
+
this.attachments.map(
|
2871
|
+
async (a) => await this._attachmentAdapter.send(a)
|
2872
|
+
)
|
2873
|
+
) : [];
|
2874
|
+
const message = {
|
2875
|
+
role: "user",
|
2876
|
+
content: this.text ? [{ type: "text", text: this.text }] : [],
|
2877
|
+
attachments
|
2878
|
+
};
|
2879
|
+
this.reset();
|
2880
|
+
this.handleSend(message);
|
2610
2881
|
}
|
2882
|
+
|
2611
2883
|
setAttachmentAdapter(adapter) {
|
2612
2884
|
this._attachmentAdapter = adapter;
|
2613
|
-
const accept = _nullishCoalesce(_optionalChain([adapter, 'optionalAccess',
|
2885
|
+
const accept = _nullishCoalesce(_optionalChain([adapter, 'optionalAccess', _135 => _135.accept]), () => ( "*"));
|
2614
2886
|
if (this.attachmentAccept !== accept) {
|
2615
2887
|
this.attachmentAccept = accept;
|
2616
|
-
|
2888
|
+
this.notifySubscribers();
|
2617
2889
|
}
|
2618
|
-
return false;
|
2619
|
-
}
|
2620
|
-
__init9() {this._attachments = []}
|
2621
|
-
get attachments() {
|
2622
|
-
return this._attachments;
|
2623
2890
|
}
|
2624
2891
|
async addAttachment(file) {
|
2625
2892
|
if (!this._attachmentAdapter)
|
@@ -2638,49 +2905,49 @@ var BaseThreadComposerRuntimeCore = (_class3 = class {
|
|
2638
2905
|
this._attachments = this._attachments.toSpliced(index, 1);
|
2639
2906
|
this.notifySubscribers();
|
2640
2907
|
}
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2908
|
+
__init15() {this._subscriptions = /* @__PURE__ */ new Set()}
|
2909
|
+
notifySubscribers() {
|
2910
|
+
for (const callback of this._subscriptions) callback();
|
2644
2911
|
}
|
2645
|
-
|
2646
|
-
this.
|
2647
|
-
this.
|
2912
|
+
subscribe(callback) {
|
2913
|
+
this._subscriptions.add(callback);
|
2914
|
+
return () => this._subscriptions.delete(callback);
|
2648
2915
|
}
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
|
2916
|
+
}, _class7);
|
2917
|
+
|
2918
|
+
// src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx
|
2919
|
+
var DefaultThreadComposerRuntimeCore = (_class8 = class extends BaseComposerRuntimeCore {
|
2920
|
+
constructor(runtime) {
|
2921
|
+
super();_class8.prototype.__init16.call(this);;
|
2922
|
+
this.runtime = runtime;
|
2923
|
+
this.connect();
|
2653
2924
|
}
|
2654
|
-
|
2655
|
-
|
2656
|
-
|
2657
|
-
|
2658
|
-
|
2659
|
-
)
|
2925
|
+
__init16() {this._canCancel = false}
|
2926
|
+
get canCancel() {
|
2927
|
+
return this._canCancel;
|
2928
|
+
}
|
2929
|
+
connect() {
|
2930
|
+
return this.runtime.subscribe(() => {
|
2931
|
+
if (this.canCancel !== this.runtime.capabilities.cancel) {
|
2932
|
+
this._canCancel = this.runtime.capabilities.cancel;
|
2933
|
+
this.notifySubscribers();
|
2934
|
+
}
|
2935
|
+
});
|
2936
|
+
}
|
2937
|
+
async handleSend(message) {
|
2660
2938
|
this.runtime.append({
|
2661
|
-
|
2662
|
-
|
2663
|
-
content: this.text ? [{ type: "text", text: this.text }] : [],
|
2664
|
-
attachments
|
2939
|
+
...message,
|
2940
|
+
parentId: _nullishCoalesce(_optionalChain([this, 'access', _136 => _136.runtime, 'access', _137 => _137.messages, 'access', _138 => _138.at, 'call', _139 => _139(-1), 'optionalAccess', _140 => _140.id]), () => ( null))
|
2665
2941
|
});
|
2666
|
-
this.reset();
|
2667
2942
|
}
|
2668
2943
|
async cancel() {
|
2669
2944
|
this.runtime.cancelRun();
|
2670
2945
|
}
|
2671
|
-
|
2672
|
-
notifySubscribers() {
|
2673
|
-
for (const callback of this._subscriptions) callback();
|
2674
|
-
}
|
2675
|
-
subscribe(callback) {
|
2676
|
-
this._subscriptions.add(callback);
|
2677
|
-
return () => this._subscriptions.delete(callback);
|
2678
|
-
}
|
2679
|
-
}, _class3);
|
2946
|
+
}, _class8);
|
2680
2947
|
|
2681
2948
|
// src/utils/ProxyConfigProvider.ts
|
2682
|
-
var ProxyConfigProvider = (
|
2683
|
-
|
2949
|
+
var ProxyConfigProvider = (_class9 = class {constructor() { _class9.prototype.__init17.call(this); }
|
2950
|
+
__init17() {this._providers = /* @__PURE__ */ new Set()}
|
2684
2951
|
getModelConfig() {
|
2685
2952
|
return _chunk5KIEXJRKjs.mergeModelConfigs.call(void 0, this._providers);
|
2686
2953
|
}
|
@@ -2690,7 +2957,7 @@ var ProxyConfigProvider = (_class4 = class {constructor() { _class4.prototype.__
|
|
2690
2957
|
this._providers.delete(provider);
|
2691
2958
|
};
|
2692
2959
|
}
|
2693
|
-
},
|
2960
|
+
}, _class9);
|
2694
2961
|
|
2695
2962
|
// src/utils/idUtils.tsx
|
2696
2963
|
var _nonsecure = require('nanoid/non-secure');
|
@@ -2757,11 +3024,11 @@ var findHead = (message) => {
|
|
2757
3024
|
if ("current" in message) return message;
|
2758
3025
|
return null;
|
2759
3026
|
};
|
2760
|
-
var MessageRepository = (
|
2761
|
-
|
3027
|
+
var MessageRepository = (_class10 = class {constructor() { _class10.prototype.__init18.call(this);_class10.prototype.__init19.call(this);_class10.prototype.__init20.call(this); }
|
3028
|
+
__init18() {this.messages = /* @__PURE__ */ new Map()}
|
2762
3029
|
// message_id -> item
|
2763
|
-
|
2764
|
-
|
3030
|
+
__init19() {this.head = null}
|
3031
|
+
__init20() {this.root = {
|
2765
3032
|
children: [],
|
2766
3033
|
next: null
|
2767
3034
|
}}
|
@@ -2803,11 +3070,11 @@ var MessageRepository = (_class5 = class {constructor() { _class5.prototype.__in
|
|
2803
3070
|
}
|
2804
3071
|
}
|
2805
3072
|
getMessages() {
|
2806
|
-
const
|
3073
|
+
const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access', _141 => _141.head, 'optionalAccess', _142 => _142.level]), () => ( 0)));
|
2807
3074
|
for (let current = this.head; current; current = current.prev) {
|
2808
|
-
|
3075
|
+
messages2[current.level] = current.current;
|
2809
3076
|
}
|
2810
|
-
return
|
3077
|
+
return messages2;
|
2811
3078
|
}
|
2812
3079
|
addOrUpdateMessage(parentId, message) {
|
2813
3080
|
const existingItem = this.messages.get(message.id);
|
@@ -2841,7 +3108,7 @@ var MessageRepository = (_class5 = class {constructor() { _class5.prototype.__in
|
|
2841
3108
|
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
2842
3109
|
);
|
2843
3110
|
return {
|
2844
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3111
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _143 => _143.prev, 'optionalAccess', _144 => _144.current, 'access', _145 => _145.id]), () => ( null)),
|
2845
3112
|
message: message.current
|
2846
3113
|
};
|
2847
3114
|
}
|
@@ -2925,21 +3192,21 @@ var MessageRepository = (_class5 = class {constructor() { _class5.prototype.__in
|
|
2925
3192
|
for (const [, message] of this.messages) {
|
2926
3193
|
exportItems.push({
|
2927
3194
|
message: message.current,
|
2928
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3195
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _146 => _146.prev, 'optionalAccess', _147 => _147.current, 'access', _148 => _148.id]), () => ( null))
|
2929
3196
|
});
|
2930
3197
|
}
|
2931
3198
|
return {
|
2932
|
-
headId: _nullishCoalesce(_optionalChain([this, 'access',
|
3199
|
+
headId: _nullishCoalesce(_optionalChain([this, 'access', _149 => _149.head, 'optionalAccess', _150 => _150.current, 'access', _151 => _151.id]), () => ( null)),
|
2933
3200
|
messages: exportItems
|
2934
3201
|
};
|
2935
3202
|
}
|
2936
|
-
import({ headId, messages }) {
|
2937
|
-
for (const { message, parentId } of
|
3203
|
+
import({ headId, messages: messages2 }) {
|
3204
|
+
for (const { message, parentId } of messages2) {
|
2938
3205
|
this.addOrUpdateMessage(parentId, message);
|
2939
3206
|
}
|
2940
|
-
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([
|
3207
|
+
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access', _152 => _152.at, 'call', _153 => _153(-1), 'optionalAccess', _154 => _154.message, 'access', _155 => _155.id]))), () => ( null)));
|
2941
3208
|
}
|
2942
|
-
},
|
3209
|
+
}, _class10);
|
2943
3210
|
|
2944
3211
|
// src/ui/base/tooltip-icon-button.tsx
|
2945
3212
|
|
@@ -3017,85 +3284,25 @@ var Button = _react.forwardRef.call(void 0,
|
|
3017
3284
|
{
|
3018
3285
|
className: buttonVariants({ variant, size, className }),
|
3019
3286
|
...props,
|
3020
|
-
ref
|
3021
|
-
}
|
3022
|
-
);
|
3023
|
-
}
|
3024
|
-
);
|
3025
|
-
Button.displayName = "Button";
|
3026
|
-
|
3027
|
-
// src/ui/base/tooltip-icon-button.tsx
|
3028
|
-
|
3029
|
-
var TooltipIconButton = _react.forwardRef.call(void 0, ({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
3030
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Tooltip, { children: [
|
3031
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
|
3032
|
-
children,
|
3033
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-sr-only", children: tooltip })
|
3034
|
-
] }) }),
|
3035
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipContent, { side, children: tooltip })
|
3036
|
-
] });
|
3037
|
-
});
|
3038
|
-
TooltipIconButton.displayName = "TooltipIconButton";
|
3039
|
-
|
3040
|
-
// src/api/subscribable/BaseSubject.ts
|
3041
|
-
var BaseSubject = (_class6 = class {constructor() { _class6.prototype.__init16.call(this); }
|
3042
|
-
__init16() {this._subscriptions = /* @__PURE__ */ new Set()}
|
3043
|
-
|
3044
|
-
get isConnected() {
|
3045
|
-
return !!this._connection;
|
3046
|
-
}
|
3047
|
-
notifySubscribers() {
|
3048
|
-
for (const callback of this._subscriptions) callback();
|
3049
|
-
}
|
3050
|
-
_updateConnection() {
|
3051
|
-
if (this._subscriptions.size > 0) {
|
3052
|
-
if (this._connection) return;
|
3053
|
-
this._connection = this._connect();
|
3054
|
-
} else {
|
3055
|
-
_optionalChain([this, 'access', _112 => _112._connection, 'optionalCall', _113 => _113()]);
|
3056
|
-
this._connection = void 0;
|
3057
|
-
}
|
3058
|
-
}
|
3059
|
-
subscribe(callback) {
|
3060
|
-
this._subscriptions.add(callback);
|
3061
|
-
this._updateConnection();
|
3062
|
-
return () => {
|
3063
|
-
this._subscriptions.delete(callback);
|
3064
|
-
this._updateConnection();
|
3065
|
-
};
|
3066
|
-
}
|
3067
|
-
}, _class6);
|
3068
|
-
|
3069
|
-
// src/api/subscribable/NestedSubscriptionSubject.ts
|
3070
|
-
var NestedSubscriptionSubject = class extends BaseSubject {
|
3071
|
-
constructor(binding) {
|
3072
|
-
super();
|
3073
|
-
this.binding = binding;
|
3074
|
-
}
|
3075
|
-
getState() {
|
3076
|
-
return this.binding.getState();
|
3077
|
-
}
|
3078
|
-
_connect() {
|
3079
|
-
const callback = () => {
|
3080
|
-
this.notifySubscribers();
|
3081
|
-
};
|
3082
|
-
let lastState = this.binding.getState();
|
3083
|
-
let innerUnsubscribe = lastState.subscribe(callback);
|
3084
|
-
const onRuntimeUpdate = () => {
|
3085
|
-
const newState = this.binding.getState();
|
3086
|
-
if (newState === lastState) return;
|
3087
|
-
lastState = newState;
|
3088
|
-
_optionalChain([innerUnsubscribe, 'optionalCall', _114 => _114()]);
|
3089
|
-
innerUnsubscribe = this.binding.getState().subscribe(callback);
|
3090
|
-
callback();
|
3091
|
-
};
|
3092
|
-
const outerUnsubscribe = this.binding.subscribe(onRuntimeUpdate);
|
3093
|
-
return () => {
|
3094
|
-
_optionalChain([outerUnsubscribe, 'optionalCall', _115 => _115()]);
|
3095
|
-
innerUnsubscribe();
|
3096
|
-
};
|
3287
|
+
ref
|
3288
|
+
}
|
3289
|
+
);
|
3097
3290
|
}
|
3098
|
-
|
3291
|
+
);
|
3292
|
+
Button.displayName = "Button";
|
3293
|
+
|
3294
|
+
// src/ui/base/tooltip-icon-button.tsx
|
3295
|
+
|
3296
|
+
var TooltipIconButton = _react.forwardRef.call(void 0, ({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
3297
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Tooltip, { children: [
|
3298
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
|
3299
|
+
children,
|
3300
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-sr-only", children: tooltip })
|
3301
|
+
] }) }),
|
3302
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipContent, { side, children: tooltip })
|
3303
|
+
] });
|
3304
|
+
});
|
3305
|
+
TooltipIconButton.displayName = "TooltipIconButton";
|
3099
3306
|
|
3100
3307
|
// src/api/AssistantRuntime.ts
|
3101
3308
|
var AssistantRuntime = class {
|
@@ -3127,245 +3334,42 @@ var AssistantRuntime = class {
|
|
3127
3334
|
}
|
3128
3335
|
};
|
3129
3336
|
|
3130
|
-
// src/api/
|
3131
|
-
var
|
3132
|
-
constructor(contentBinding, messageApi, threadApi) {
|
3133
|
-
this.contentBinding = contentBinding;
|
3134
|
-
this.messageApi = messageApi;
|
3135
|
-
this.threadApi = threadApi;
|
3136
|
-
}
|
3137
|
-
getState() {
|
3138
|
-
return this.contentBinding.getState();
|
3139
|
-
}
|
3140
|
-
addToolResult(result) {
|
3141
|
-
const message = this.messageApi.getState();
|
3142
|
-
if (!message) throw new Error("Message is not available");
|
3143
|
-
const state = this.contentBinding.getState();
|
3144
|
-
if (!state) throw new Error("Content part is not available");
|
3145
|
-
if (state.part.type !== "tool-call")
|
3146
|
-
throw new Error("Tried to add tool result to non-tool content part");
|
3147
|
-
const toolName = state.part.toolName;
|
3148
|
-
const toolCallId = state.part.toolCallId;
|
3149
|
-
this.threadApi.getState().addToolResult({
|
3150
|
-
messageId: message.id,
|
3151
|
-
toolName,
|
3152
|
-
toolCallId,
|
3153
|
-
result
|
3154
|
-
});
|
3155
|
-
}
|
3156
|
-
};
|
3157
|
-
|
3158
|
-
// src/api/subscribable/shallowEqual.ts
|
3159
|
-
function shallowEqual(objA, objB) {
|
3160
|
-
if (objA === void 0 && objB === void 0) return true;
|
3161
|
-
if (objA === void 0) return false;
|
3162
|
-
if (objB === void 0) return false;
|
3163
|
-
for (const key of Object.keys(objA)) {
|
3164
|
-
const valueA = objA[key];
|
3165
|
-
const valueB = objB[key];
|
3166
|
-
if (!Object.is(valueA, valueB)) return false;
|
3167
|
-
}
|
3168
|
-
return true;
|
3169
|
-
}
|
3170
|
-
|
3171
|
-
// src/api/subscribable/ShallowMemoizeSubject.ts
|
3172
|
-
var ShallowMemoizeSubject = (_class7 = class extends BaseSubject {
|
3337
|
+
// src/api/subscribable/LazyMemoizeSubject.ts
|
3338
|
+
var LazyMemoizeSubject = (_class11 = class extends BaseSubject {
|
3173
3339
|
constructor(binding) {
|
3174
|
-
super();
|
3340
|
+
super();_class11.prototype.__init21.call(this);_class11.prototype.__init22.call(this);;
|
3175
3341
|
this.binding = binding;
|
3176
3342
|
const state = binding.getState();
|
3177
3343
|
if (state === void 0)
|
3178
3344
|
throw new Error("Entry not available in the store");
|
3179
3345
|
this._previousState = state;
|
3180
3346
|
}
|
3347
|
+
__init21() {this._previousStateDirty = true}
|
3181
3348
|
|
3182
|
-
|
3183
|
-
if (!this.isConnected
|
3349
|
+
__init22() {this.getState = () => {
|
3350
|
+
if (!this.isConnected || this._previousStateDirty) {
|
3351
|
+
const newState = this.binding.getState();
|
3352
|
+
if (newState !== void 0) {
|
3353
|
+
this._previousState = newState;
|
3354
|
+
}
|
3355
|
+
this._previousStateDirty = false;
|
3356
|
+
}
|
3184
3357
|
return this._previousState;
|
3185
3358
|
}}
|
3186
|
-
_syncState() {
|
3187
|
-
const state = this.binding.getState();
|
3188
|
-
if (state === void 0) return false;
|
3189
|
-
if (shallowEqual(state, this._previousState)) return false;
|
3190
|
-
this._previousState = state;
|
3191
|
-
return true;
|
3192
|
-
}
|
3193
3359
|
_connect() {
|
3194
3360
|
const callback = () => {
|
3195
|
-
|
3196
|
-
|
3197
|
-
}
|
3361
|
+
this._previousStateDirty = true;
|
3362
|
+
this.notifySubscribers();
|
3198
3363
|
};
|
3199
3364
|
return this.binding.subscribe(callback);
|
3200
3365
|
}
|
3201
|
-
},
|
3202
|
-
|
3203
|
-
// src/api/MessageRuntime.ts
|
3204
|
-
var MessageRuntime = class {
|
3205
|
-
constructor(_core, _threadBinding) {
|
3206
|
-
this._core = _core;
|
3207
|
-
this._threadBinding = _threadBinding;
|
3208
|
-
}
|
3209
|
-
getState() {
|
3210
|
-
return this._core.getState();
|
3211
|
-
}
|
3212
|
-
// TODO improve type
|
3213
|
-
edit(message) {
|
3214
|
-
const state = this._core.getState();
|
3215
|
-
if (!state) throw new Error("Message is not available");
|
3216
|
-
this._threadBinding.getState().append({
|
3217
|
-
...message,
|
3218
|
-
parentId: state.parentId
|
3219
|
-
});
|
3220
|
-
}
|
3221
|
-
reload() {
|
3222
|
-
const state = this._core.getState();
|
3223
|
-
if (!state) throw new Error("Message is not available");
|
3224
|
-
this._threadBinding.getState().startRun(state.parentId);
|
3225
|
-
}
|
3226
|
-
speak() {
|
3227
|
-
const state = this._core.getState();
|
3228
|
-
if (!state) throw new Error("Message is not available");
|
3229
|
-
this._threadBinding.getState().speak(state.id);
|
3230
|
-
}
|
3231
|
-
submitFeedback({ type }) {
|
3232
|
-
const state = this._core.getState();
|
3233
|
-
if (!state) throw new Error("Message is not available");
|
3234
|
-
this._threadBinding.getState().submitFeedback({
|
3235
|
-
messageId: state.id,
|
3236
|
-
type
|
3237
|
-
});
|
3238
|
-
}
|
3239
|
-
switchToBranch({
|
3240
|
-
position,
|
3241
|
-
branchId
|
3242
|
-
}) {
|
3243
|
-
const state = this._core.getState();
|
3244
|
-
if (!state) throw new Error("Message is not available");
|
3245
|
-
if (branchId && position) {
|
3246
|
-
throw new Error("May not specify both branchId and position");
|
3247
|
-
} else if (!branchId && !position) {
|
3248
|
-
throw new Error("Must specify either branchId or position");
|
3249
|
-
}
|
3250
|
-
const thread = this._threadBinding.getState();
|
3251
|
-
const branches = thread.getBranches(state.id);
|
3252
|
-
let targetBranch = branchId;
|
3253
|
-
if (position === "previous") {
|
3254
|
-
targetBranch = branches[state.branchNumber - 2];
|
3255
|
-
} else if (position === "next") {
|
3256
|
-
targetBranch = branches[state.branchNumber];
|
3257
|
-
}
|
3258
|
-
if (!targetBranch) throw new Error("Branch not found");
|
3259
|
-
this._threadBinding.getState().switchToBranch(targetBranch);
|
3260
|
-
}
|
3261
|
-
subscribe(callback) {
|
3262
|
-
return this._core.subscribe(callback);
|
3263
|
-
}
|
3264
|
-
getContentPartByIdx(idx) {
|
3265
|
-
if (idx < 0) throw new Error("Message index must be >= 0");
|
3266
|
-
return new ContentPartRuntime(
|
3267
|
-
new ShallowMemoizeSubject({
|
3268
|
-
getState: () => {
|
3269
|
-
const state = this.getState();
|
3270
|
-
if (!state) return void 0;
|
3271
|
-
const message = state.message;
|
3272
|
-
const part = message.content[idx];
|
3273
|
-
if (!part) return void 0;
|
3274
|
-
return {
|
3275
|
-
part,
|
3276
|
-
status: toContentPartStatus(message, idx, part)
|
3277
|
-
};
|
3278
|
-
},
|
3279
|
-
subscribe: (callback) => this._core.subscribe(callback)
|
3280
|
-
}),
|
3281
|
-
this._core,
|
3282
|
-
this._threadBinding
|
3283
|
-
);
|
3284
|
-
}
|
3285
|
-
};
|
3286
|
-
|
3287
|
-
// src/api/ThreadComposerRuntime.ts
|
3288
|
-
var getThreadComposerState = (runtime) => {
|
3289
|
-
return Object.freeze({
|
3290
|
-
canCancel: runtime.canCancel,
|
3291
|
-
isEmpty: runtime.isEmpty,
|
3292
|
-
text: runtime.text,
|
3293
|
-
attachments: runtime.attachments,
|
3294
|
-
attachmentAccept: runtime.attachmentAccept
|
3295
|
-
});
|
3296
|
-
};
|
3297
|
-
var ThreadComposerRuntime = class {
|
3298
|
-
constructor(_core) {
|
3299
|
-
this._core = _core;
|
3300
|
-
}
|
3301
|
-
/**
|
3302
|
-
* @deprecated Use `getState().isEmpty` instead. This will be removed in 0.6.0.
|
3303
|
-
*/
|
3304
|
-
get isEmpty() {
|
3305
|
-
return this._core.getState().isEmpty;
|
3306
|
-
}
|
3307
|
-
/**
|
3308
|
-
* @deprecated Use `getState().canCancel` instead. This will be removed in 0.6.0.
|
3309
|
-
*/
|
3310
|
-
get canCancel() {
|
3311
|
-
return this._core.getState().canCancel;
|
3312
|
-
}
|
3313
|
-
/**
|
3314
|
-
* @deprecated Use `getState().text` instead. This will be removed in 0.6.0.
|
3315
|
-
*/
|
3316
|
-
get text() {
|
3317
|
-
return this._core.getState().text;
|
3318
|
-
}
|
3319
|
-
/**
|
3320
|
-
* @deprecated Use `getState().attachmentAccept` instead. This will be removed in 0.6.0.
|
3321
|
-
*/
|
3322
|
-
get attachmentAccept() {
|
3323
|
-
return this._core.getState().attachmentAccept;
|
3324
|
-
}
|
3325
|
-
// TODO should this instead return getAttachmentByIndex([idx]) instead?
|
3326
|
-
/**
|
3327
|
-
* @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
|
3328
|
-
*/
|
3329
|
-
get attachments() {
|
3330
|
-
return this._core.getState().attachments;
|
3331
|
-
}
|
3332
|
-
getState() {
|
3333
|
-
return getThreadComposerState(this._core.getState());
|
3334
|
-
}
|
3335
|
-
setText(text) {
|
3336
|
-
this._core.getState().setText(text);
|
3337
|
-
}
|
3338
|
-
addAttachment(file) {
|
3339
|
-
return this._core.getState().addAttachment(file);
|
3340
|
-
}
|
3341
|
-
// /**
|
3342
|
-
// * @deprecated Use `getAttachmentById(id).removeAttachment` instead. This will be removed in 0.6.0.
|
3343
|
-
// */
|
3344
|
-
removeAttachment(attachmentId) {
|
3345
|
-
return this._core.getState().removeAttachment(attachmentId);
|
3346
|
-
}
|
3347
|
-
/**
|
3348
|
-
* @deprecated This method will be removed in 0.6.0. Submit feedback if you need this functionality.
|
3349
|
-
*/
|
3350
|
-
reset() {
|
3351
|
-
this._core.getState().reset();
|
3352
|
-
}
|
3353
|
-
send() {
|
3354
|
-
this._core.getState().send();
|
3355
|
-
}
|
3356
|
-
cancel() {
|
3357
|
-
this._core.getState().cancel();
|
3358
|
-
}
|
3359
|
-
subscribe(callback) {
|
3360
|
-
return this._core.subscribe(callback);
|
3361
|
-
}
|
3362
|
-
};
|
3366
|
+
}, _class11);
|
3363
3367
|
|
3364
3368
|
// src/api/ThreadRuntime.ts
|
3365
|
-
var toAppendMessage = (
|
3369
|
+
var toAppendMessage = (messages2, message) => {
|
3366
3370
|
if (typeof message === "string") {
|
3367
3371
|
return {
|
3368
|
-
parentId: _nullishCoalesce(_optionalChain([
|
3372
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _156 => _156.at, 'call', _157 => _157(-1), 'optionalAccess', _158 => _158.id]), () => ( null)),
|
3369
3373
|
role: "user",
|
3370
3374
|
content: [{ type: "text", text: message }],
|
3371
3375
|
attachments: []
|
@@ -3375,7 +3379,7 @@ var toAppendMessage = (messages, message) => {
|
|
3375
3379
|
return message;
|
3376
3380
|
}
|
3377
3381
|
return {
|
3378
|
-
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([
|
3382
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access', _159 => _159.at, 'call', _160 => _160(-1), 'optionalAccess', _161 => _161.id]))), () => ( null)),
|
3379
3383
|
role: _nullishCoalesce(message.role, () => ( "user")),
|
3380
3384
|
content: message.content,
|
3381
3385
|
attachments: _nullishCoalesce(message.attachments, () => ( []))
|
@@ -3387,14 +3391,12 @@ var getThreadState = (runtime) => {
|
|
3387
3391
|
threadId: runtime.threadId,
|
3388
3392
|
capabilities: runtime.capabilities,
|
3389
3393
|
isDisabled: runtime.isDisabled,
|
3390
|
-
isRunning: _optionalChain([lastMessage, 'optionalAccess',
|
3394
|
+
isRunning: _optionalChain([lastMessage, 'optionalAccess', _162 => _162.role]) !== "assistant" ? false : lastMessage.status.type === "running",
|
3395
|
+
messages: runtime.messages,
|
3391
3396
|
unstable_synchronizer: runtime.unstable_synchronizer
|
3392
3397
|
});
|
3393
3398
|
};
|
3394
|
-
var ThreadRuntime = (
|
3395
|
-
constructor(_threadBinding) {;_class8.prototype.__init18.call(this);
|
3396
|
-
this._threadBinding = _threadBinding;
|
3397
|
-
}
|
3399
|
+
var ThreadRuntime = (_class12 = class {
|
3398
3400
|
// public path = "assistant.threads[main]"; // TODO
|
3399
3401
|
/**
|
3400
3402
|
* @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
|
@@ -3420,21 +3422,35 @@ var ThreadRuntime = (_class8 = class {
|
|
3420
3422
|
get capabilities() {
|
3421
3423
|
return this.getState().capabilities;
|
3422
3424
|
}
|
3423
|
-
|
3425
|
+
/**
|
3426
|
+
* @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
|
3427
|
+
*/
|
3424
3428
|
get messages() {
|
3425
3429
|
return this._threadBinding.getState().messages;
|
3426
3430
|
}
|
3427
3431
|
unstable_getCore() {
|
3428
3432
|
return this._threadBinding.getState();
|
3429
3433
|
}
|
3430
|
-
|
3434
|
+
|
3435
|
+
constructor(threadBinding) {;_class12.prototype.__init23.call(this);
|
3436
|
+
const stateBinding = new LazyMemoizeSubject({
|
3437
|
+
getState: () => getThreadState(threadBinding.getState()),
|
3438
|
+
subscribe: (callback) => threadBinding.subscribe(callback)
|
3439
|
+
});
|
3440
|
+
this._threadBinding = {
|
3441
|
+
getState: () => threadBinding.getState(),
|
3442
|
+
getStateState: () => stateBinding.getState(),
|
3443
|
+
subscribe: (callback) => threadBinding.subscribe(callback)
|
3444
|
+
};
|
3445
|
+
}
|
3446
|
+
__init23() {this.composer = new ComposerRuntime(
|
3431
3447
|
new NestedSubscriptionSubject({
|
3432
3448
|
getState: () => this._threadBinding.getState().composer,
|
3433
3449
|
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
3434
3450
|
})
|
3435
3451
|
)}
|
3436
3452
|
getState() {
|
3437
|
-
return
|
3453
|
+
return this._threadBinding.getStateState();
|
3438
3454
|
}
|
3439
3455
|
append(message) {
|
3440
3456
|
this._threadBinding.getState().append(
|
@@ -3483,6 +3499,18 @@ var ThreadRuntime = (_class8 = class {
|
|
3483
3499
|
submitFeedback(options) {
|
3484
3500
|
return this._threadBinding.getState().submitFeedback(options);
|
3485
3501
|
}
|
3502
|
+
/**
|
3503
|
+
* @deprecated This is a temporary API. This will be removed in 0.6.0.
|
3504
|
+
*/
|
3505
|
+
getEditComposer(messageId) {
|
3506
|
+
return this._threadBinding.getState().getEditComposer(messageId);
|
3507
|
+
}
|
3508
|
+
/**
|
3509
|
+
* @deprecated This is a temporary API. This will be removed in 0.6.0.
|
3510
|
+
*/
|
3511
|
+
beginEdit(messageId) {
|
3512
|
+
return this._threadBinding.getState().beginEdit(messageId);
|
3513
|
+
}
|
3486
3514
|
export() {
|
3487
3515
|
return this._threadBinding.getState().export();
|
3488
3516
|
}
|
@@ -3494,15 +3522,15 @@ var ThreadRuntime = (_class8 = class {
|
|
3494
3522
|
return new MessageRuntime(
|
3495
3523
|
new ShallowMemoizeSubject({
|
3496
3524
|
getState: () => {
|
3497
|
-
const
|
3498
|
-
const message =
|
3525
|
+
const messages2 = this.messages;
|
3526
|
+
const message = messages2[idx];
|
3499
3527
|
if (!message) return void 0;
|
3500
3528
|
const branches = this._threadBinding.getState().getBranches(message.id);
|
3501
3529
|
return {
|
3502
3530
|
...message,
|
3503
3531
|
message,
|
3504
|
-
isLast: idx ===
|
3505
|
-
parentId: _nullishCoalesce(_optionalChain([
|
3532
|
+
isLast: idx === messages2.length - 1,
|
3533
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _163 => _163[idx - 1], 'optionalAccess', _164 => _164.id]), () => ( null)),
|
3506
3534
|
branches,
|
3507
3535
|
branchNumber: branches.indexOf(message.id) + 1,
|
3508
3536
|
branchCount: branches.length
|
@@ -3513,16 +3541,16 @@ var ThreadRuntime = (_class8 = class {
|
|
3513
3541
|
this._threadBinding
|
3514
3542
|
);
|
3515
3543
|
}
|
3516
|
-
},
|
3544
|
+
}, _class12);
|
3517
3545
|
|
3518
3546
|
// src/runtimes/edge/converters/fromLanguageModelMessages.ts
|
3519
3547
|
var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
3520
|
-
const
|
3548
|
+
const messages2 = [];
|
3521
3549
|
for (const lmMessage of lm) {
|
3522
3550
|
const role = lmMessage.role;
|
3523
3551
|
switch (role) {
|
3524
3552
|
case "system": {
|
3525
|
-
|
3553
|
+
messages2.push({
|
3526
3554
|
role: "system",
|
3527
3555
|
content: [
|
3528
3556
|
{
|
@@ -3534,7 +3562,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
3534
3562
|
break;
|
3535
3563
|
}
|
3536
3564
|
case "user": {
|
3537
|
-
|
3565
|
+
messages2.push({
|
3538
3566
|
role: "user",
|
3539
3567
|
content: lmMessage.content.map((part) => {
|
3540
3568
|
const type = part.type;
|
@@ -3577,21 +3605,21 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
3577
3605
|
return part;
|
3578
3606
|
});
|
3579
3607
|
if (mergeRoundtrips) {
|
3580
|
-
const previousMessage =
|
3581
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
3608
|
+
const previousMessage = messages2[messages2.length - 1];
|
3609
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _165 => _165.role]) === "assistant") {
|
3582
3610
|
previousMessage.content.push(...newContent);
|
3583
3611
|
break;
|
3584
3612
|
}
|
3585
3613
|
}
|
3586
|
-
|
3614
|
+
messages2.push({
|
3587
3615
|
role: "assistant",
|
3588
3616
|
content: newContent
|
3589
3617
|
});
|
3590
3618
|
break;
|
3591
3619
|
}
|
3592
3620
|
case "tool": {
|
3593
|
-
const previousMessage =
|
3594
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
3621
|
+
const previousMessage = messages2[messages2.length - 1];
|
3622
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _166 => _166.role]) !== "assistant")
|
3595
3623
|
throw new Error(
|
3596
3624
|
"A tool message must be preceded by an assistant message."
|
3597
3625
|
);
|
@@ -3616,7 +3644,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
3616
3644
|
}
|
3617
3645
|
}
|
3618
3646
|
}
|
3619
|
-
return
|
3647
|
+
return messages2;
|
3620
3648
|
};
|
3621
3649
|
|
3622
3650
|
// src/runtimes/edge/converters/fromLanguageModelTools.ts
|
@@ -3774,7 +3802,7 @@ var EdgeChatAdapter = class {
|
|
3774
3802
|
constructor(options) {
|
3775
3803
|
this.options = options;
|
3776
3804
|
}
|
3777
|
-
async *run({ messages, abortSignal, config }) {
|
3805
|
+
async *run({ messages: messages2, abortSignal, config }) {
|
3778
3806
|
const headers = new Headers(this.options.headers);
|
3779
3807
|
headers.set("Content-Type", "application/json");
|
3780
3808
|
const result = await fetch(this.options.api, {
|
@@ -3783,7 +3811,7 @@ var EdgeChatAdapter = class {
|
|
3783
3811
|
credentials: _nullishCoalesce(this.options.credentials, () => ( "same-origin")),
|
3784
3812
|
body: JSON.stringify({
|
3785
3813
|
system: config.system,
|
3786
|
-
messages: _chunk5KIEXJRKjs.toCoreMessages.call(void 0,
|
3814
|
+
messages: _chunk5KIEXJRKjs.toCoreMessages.call(void 0, messages2),
|
3787
3815
|
tools: config.tools ? _chunk5KIEXJRKjs.toLanguageModelTools.call(void 0, config.tools) : [],
|
3788
3816
|
...config.callSettings,
|
3789
3817
|
...config.config,
|
@@ -3820,28 +3848,65 @@ var useEdgeRuntime = ({
|
|
3820
3848
|
};
|
3821
3849
|
|
3822
3850
|
// src/runtimes/local/shouldContinue.tsx
|
3823
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
3851
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _167 => _167.status, 'optionalAccess', _168 => _168.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
3852
|
+
|
3853
|
+
// src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
|
3854
|
+
var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
3855
|
+
constructor(runtime, endEditCallback, { parentId, message }) {
|
3856
|
+
super();
|
3857
|
+
this.runtime = runtime;
|
3858
|
+
this.endEditCallback = endEditCallback;
|
3859
|
+
this._parentId = parentId;
|
3860
|
+
this._previousText = getThreadMessageText(message);
|
3861
|
+
this.setText(this._previousText);
|
3862
|
+
this._nonTextParts = message.content.filter(
|
3863
|
+
(part) => part.type !== "text" && part.type !== "ui"
|
3864
|
+
);
|
3865
|
+
}
|
3866
|
+
get canCancel() {
|
3867
|
+
return true;
|
3868
|
+
}
|
3869
|
+
|
3870
|
+
|
3871
|
+
|
3872
|
+
async handleSend(message) {
|
3873
|
+
const text = getThreadMessageText(message);
|
3874
|
+
if (text !== this._previousText) {
|
3875
|
+
this.runtime.append({
|
3876
|
+
...message,
|
3877
|
+
content: [...message.content, ...this._nonTextParts],
|
3878
|
+
parentId: this._parentId
|
3879
|
+
});
|
3880
|
+
}
|
3881
|
+
this.endEditCallback();
|
3882
|
+
this.notifySubscribers();
|
3883
|
+
}
|
3884
|
+
async cancel() {
|
3885
|
+
this.endEditCallback();
|
3886
|
+
this.notifySubscribers();
|
3887
|
+
}
|
3888
|
+
};
|
3824
3889
|
|
3825
3890
|
// src/runtimes/local/LocalThreadRuntimeCore.tsx
|
3826
|
-
var LocalThreadRuntimeCore = (
|
3827
|
-
constructor(configProvider, adapter, { initialMessages, ...options }) {;
|
3891
|
+
var LocalThreadRuntimeCore = (_class13 = class {
|
3892
|
+
constructor(configProvider, adapter, { initialMessages, ...options }) {;_class13.prototype.__init24.call(this);_class13.prototype.__init25.call(this);_class13.prototype.__init26.call(this);_class13.prototype.__init27.call(this);_class13.prototype.__init28.call(this);_class13.prototype.__init29.call(this);_class13.prototype.__init30.call(this);
|
3828
3893
|
this.configProvider = configProvider;
|
3829
3894
|
this.adapter = adapter;
|
3830
3895
|
this.threadId = generateId();
|
3831
3896
|
this.options = options;
|
3832
3897
|
if (initialMessages) {
|
3833
3898
|
let parentId = null;
|
3834
|
-
const
|
3835
|
-
for (const message of
|
3899
|
+
const messages2 = fromCoreMessages(initialMessages);
|
3900
|
+
for (const message of messages2) {
|
3836
3901
|
this.repository.addOrUpdateMessage(parentId, message);
|
3837
3902
|
parentId = message.id;
|
3838
3903
|
}
|
3839
3904
|
}
|
3840
3905
|
}
|
3841
|
-
|
3842
|
-
|
3843
|
-
|
3844
|
-
|
3906
|
+
__init24() {this._subscriptions = /* @__PURE__ */ new Set()}
|
3907
|
+
__init25() {this.abortController = null}
|
3908
|
+
__init26() {this.repository = new MessageRepository()}
|
3909
|
+
__init27() {this.capabilities = {
|
3845
3910
|
switchToBranch: true,
|
3846
3911
|
edit: true,
|
3847
3912
|
reload: true,
|
@@ -3852,11 +3917,11 @@ var LocalThreadRuntimeCore = (_class9 = class {
|
|
3852
3917
|
feedback: false
|
3853
3918
|
}}
|
3854
3919
|
|
3855
|
-
|
3920
|
+
__init28() {this.isDisabled = false}
|
3856
3921
|
get messages() {
|
3857
3922
|
return this.repository.getMessages();
|
3858
3923
|
}
|
3859
|
-
|
3924
|
+
__init29() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
3860
3925
|
getModelConfig() {
|
3861
3926
|
return this.configProvider.getModelConfig();
|
3862
3927
|
}
|
@@ -3867,24 +3932,41 @@ var LocalThreadRuntimeCore = (_class9 = class {
|
|
3867
3932
|
set options({ initialMessages, ...options }) {
|
3868
3933
|
this._options = options;
|
3869
3934
|
let hasUpdates = false;
|
3870
|
-
const canSpeak = _optionalChain([options, 'access',
|
3935
|
+
const canSpeak = _optionalChain([options, 'access', _169 => _169.adapters, 'optionalAccess', _170 => _170.speech]) !== void 0;
|
3871
3936
|
if (this.capabilities.speak !== canSpeak) {
|
3872
3937
|
this.capabilities.speak = canSpeak;
|
3873
3938
|
hasUpdates = true;
|
3874
3939
|
}
|
3875
|
-
this.composer.setAttachmentAdapter(_optionalChain([options, 'access',
|
3876
|
-
const canAttach = _optionalChain([options, 'access',
|
3940
|
+
this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _171 => _171.adapters, 'optionalAccess', _172 => _172.attachments]));
|
3941
|
+
const canAttach = _optionalChain([options, 'access', _173 => _173.adapters, 'optionalAccess', _174 => _174.attachments]) !== void 0;
|
3877
3942
|
if (this.capabilities.attachments !== canAttach) {
|
3878
3943
|
this.capabilities.attachments = canAttach;
|
3879
3944
|
hasUpdates = true;
|
3880
3945
|
}
|
3881
|
-
const canFeedback = _optionalChain([options, 'access',
|
3946
|
+
const canFeedback = _optionalChain([options, 'access', _175 => _175.adapters, 'optionalAccess', _176 => _176.feedback]) !== void 0;
|
3882
3947
|
if (this.capabilities.feedback !== canFeedback) {
|
3883
3948
|
this.capabilities.feedback = canFeedback;
|
3884
3949
|
hasUpdates = true;
|
3885
3950
|
}
|
3886
3951
|
if (hasUpdates) this.notifySubscribers();
|
3887
3952
|
}
|
3953
|
+
__init30() {this._editComposers = /* @__PURE__ */ new Map()}
|
3954
|
+
getEditComposer(messageId) {
|
3955
|
+
return this._editComposers.get(messageId);
|
3956
|
+
}
|
3957
|
+
beginEdit(messageId) {
|
3958
|
+
if (this._editComposers.has(messageId))
|
3959
|
+
throw new Error("Edit already in progress");
|
3960
|
+
this._editComposers.set(
|
3961
|
+
messageId,
|
3962
|
+
new DefaultEditComposerRuntimeCore(
|
3963
|
+
this,
|
3964
|
+
() => this._editComposers.delete(messageId),
|
3965
|
+
this.repository.getMessage(messageId)
|
3966
|
+
)
|
3967
|
+
);
|
3968
|
+
this.notifySubscribers();
|
3969
|
+
}
|
3888
3970
|
getBranches(messageId) {
|
3889
3971
|
return this.repository.getBranches(messageId);
|
3890
3972
|
}
|
@@ -3919,19 +4001,19 @@ var LocalThreadRuntimeCore = (_class9 = class {
|
|
3919
4001
|
} while (shouldContinue(message));
|
3920
4002
|
}
|
3921
4003
|
async performRoundtrip(parentId, message) {
|
3922
|
-
const
|
3923
|
-
_optionalChain([this, 'access',
|
4004
|
+
const messages2 = this.repository.getMessages();
|
4005
|
+
_optionalChain([this, 'access', _177 => _177.abortController, 'optionalAccess', _178 => _178.abort, 'call', _179 => _179()]);
|
3924
4006
|
this.abortController = new AbortController();
|
3925
4007
|
const initialContent = message.content;
|
3926
|
-
const initialRoundtrips = _optionalChain([message, 'access',
|
3927
|
-
const initalCustom = _optionalChain([message, 'access',
|
4008
|
+
const initialRoundtrips = _optionalChain([message, 'access', _180 => _180.metadata, 'optionalAccess', _181 => _181.roundtrips]);
|
4009
|
+
const initalCustom = _optionalChain([message, 'access', _182 => _182.metadata, 'optionalAccess', _183 => _183.custom]);
|
3928
4010
|
const updateMessage = (m) => {
|
3929
4011
|
message = {
|
3930
4012
|
...message,
|
3931
4013
|
...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
|
3932
4014
|
status: _nullishCoalesce(m.status, () => ( message.status)),
|
3933
4015
|
// TODO deprecated, remove in v0.6
|
3934
|
-
..._optionalChain([m, 'access',
|
4016
|
+
..._optionalChain([m, 'access', _184 => _184.metadata, 'optionalAccess', _185 => _185.roundtrips]) ? {
|
3935
4017
|
roundtrips: [
|
3936
4018
|
..._nullishCoalesce(initialRoundtrips, () => ( [])),
|
3937
4019
|
...m.metadata.roundtrips
|
@@ -3946,7 +4028,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
|
|
3946
4028
|
...m.metadata.roundtrips
|
3947
4029
|
]
|
3948
4030
|
} : void 0,
|
3949
|
-
..._optionalChain([m, 'access',
|
4031
|
+
..._optionalChain([m, 'access', _186 => _186.metadata, 'optionalAccess', _187 => _187.custom]) ? {
|
3950
4032
|
custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
|
3951
4033
|
} : void 0
|
3952
4034
|
}
|
@@ -3956,7 +4038,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
|
|
3956
4038
|
this.notifySubscribers();
|
3957
4039
|
};
|
3958
4040
|
const maxToolRoundtrips = _nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1));
|
3959
|
-
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access',
|
4041
|
+
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _188 => _188.metadata, 'optionalAccess', _189 => _189.roundtrips, 'optionalAccess', _190 => _190.length]), () => ( 0));
|
3960
4042
|
if (toolRoundtrips > maxToolRoundtrips) {
|
3961
4043
|
updateMessage({
|
3962
4044
|
status: {
|
@@ -3974,7 +4056,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
|
|
3974
4056
|
}
|
3975
4057
|
try {
|
3976
4058
|
const promiseOrGenerator = this.adapter.run({
|
3977
|
-
messages,
|
4059
|
+
messages: messages2,
|
3978
4060
|
abortSignal: this.abortController.signal,
|
3979
4061
|
config: this.configProvider.getModelConfig(),
|
3980
4062
|
onUpdate: updateMessage
|
@@ -4055,7 +4137,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
|
|
4055
4137
|
// TODO lift utterance state to thread runtime
|
4056
4138
|
|
4057
4139
|
speak(messageId) {
|
4058
|
-
const adapter = _optionalChain([this, 'access',
|
4140
|
+
const adapter = _optionalChain([this, 'access', _191 => _191.options, 'access', _192 => _192.adapters, 'optionalAccess', _193 => _193.speech]);
|
4059
4141
|
if (!adapter) throw new Error("Speech adapter not configured");
|
4060
4142
|
const { message } = this.repository.getMessage(messageId);
|
4061
4143
|
if (this._utterance) {
|
@@ -4072,7 +4154,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
|
|
4072
4154
|
return this._utterance;
|
4073
4155
|
}
|
4074
4156
|
submitFeedback({ messageId, type }) {
|
4075
|
-
const adapter = _optionalChain([this, 'access',
|
4157
|
+
const adapter = _optionalChain([this, 'access', _194 => _194.options, 'access', _195 => _195.adapters, 'optionalAccess', _196 => _196.feedback]);
|
4076
4158
|
if (!adapter) throw new Error("Feedback adapter not configured");
|
4077
4159
|
const { message } = this.repository.getMessage(messageId);
|
4078
4160
|
adapter.submit({ message, type });
|
@@ -4084,7 +4166,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
|
|
4084
4166
|
this.repository.import(data);
|
4085
4167
|
this.notifySubscribers();
|
4086
4168
|
}
|
4087
|
-
},
|
4169
|
+
}, _class13);
|
4088
4170
|
|
4089
4171
|
// src/runtimes/local/LocalRuntimeCore.tsx
|
4090
4172
|
var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
@@ -4116,10 +4198,10 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4116
4198
|
} = {}) {
|
4117
4199
|
this.switchToThread(null);
|
4118
4200
|
if (!initialMessages) return;
|
4119
|
-
const
|
4201
|
+
const messages2 = fromCoreMessages(initialMessages);
|
4120
4202
|
this.thread.import({
|
4121
|
-
messages:
|
4122
|
-
parentId: _nullishCoalesce(_optionalChain([
|
4203
|
+
messages: messages2.map((m, idx) => ({
|
4204
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _197 => _197[idx - 1], 'optionalAccess', _198 => _198.id]), () => ( null)),
|
4123
4205
|
message: m
|
4124
4206
|
}))
|
4125
4207
|
});
|
@@ -4155,17 +4237,17 @@ var getExternalStoreMessage = (message) => {
|
|
4155
4237
|
};
|
4156
4238
|
|
4157
4239
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
4158
|
-
var ThreadMessageConverter = (
|
4159
|
-
|
4160
|
-
convertMessages(
|
4161
|
-
return
|
4240
|
+
var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.__init31.call(this); }
|
4241
|
+
__init31() {this.cache = /* @__PURE__ */ new WeakMap()}
|
4242
|
+
convertMessages(messages2, converter) {
|
4243
|
+
return messages2.map((m, idx) => {
|
4162
4244
|
const cached = this.cache.get(m);
|
4163
4245
|
const newMessage = converter(cached, m, idx);
|
4164
4246
|
this.cache.set(m, newMessage);
|
4165
4247
|
return newMessage;
|
4166
4248
|
});
|
4167
4249
|
}
|
4168
|
-
},
|
4250
|
+
}, _class14);
|
4169
4251
|
|
4170
4252
|
// src/runtimes/external-store/auto-status.tsx
|
4171
4253
|
var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
|
@@ -4251,18 +4333,18 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
4251
4333
|
};
|
4252
4334
|
|
4253
4335
|
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
4254
|
-
var hasUpcomingMessage = (isRunning,
|
4255
|
-
return isRunning && _optionalChain([
|
4336
|
+
var hasUpcomingMessage = (isRunning, messages2) => {
|
4337
|
+
return isRunning && _optionalChain([messages2, 'access', _199 => _199[messages2.length - 1], 'optionalAccess', _200 => _200.role]) !== "assistant";
|
4256
4338
|
};
|
4257
|
-
var ExternalStoreThreadRuntimeCore = (
|
4258
|
-
constructor(configProvider, store) {;
|
4339
|
+
var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
4340
|
+
constructor(configProvider, store) {;_class15.prototype.__init32.call(this);_class15.prototype.__init33.call(this);_class15.prototype.__init34.call(this);_class15.prototype.__init35.call(this);_class15.prototype.__init36.call(this);_class15.prototype.__init37.call(this);_class15.prototype.__init38.call(this);_class15.prototype.__init39.call(this);
|
4259
4341
|
this.configProvider = configProvider;
|
4260
4342
|
this.store = store;
|
4261
4343
|
}
|
4262
|
-
|
4263
|
-
|
4264
|
-
|
4265
|
-
|
4344
|
+
__init32() {this._subscriptions = /* @__PURE__ */ new Set()}
|
4345
|
+
__init33() {this.repository = new MessageRepository()}
|
4346
|
+
__init34() {this.assistantOptimisticId = null}
|
4347
|
+
__init35() {this._capabilities = {
|
4266
4348
|
switchToBranch: false,
|
4267
4349
|
edit: false,
|
4268
4350
|
reload: false,
|
@@ -4278,9 +4360,26 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4278
4360
|
|
4279
4361
|
|
4280
4362
|
|
4281
|
-
|
4363
|
+
__init36() {this.converter = new ThreadMessageConverter()}
|
4282
4364
|
|
4283
|
-
|
4365
|
+
__init37() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
4366
|
+
__init38() {this._editComposers = /* @__PURE__ */ new Map()}
|
4367
|
+
getEditComposer(messageId) {
|
4368
|
+
return this._editComposers.get(messageId);
|
4369
|
+
}
|
4370
|
+
beginEdit(messageId) {
|
4371
|
+
if (this._editComposers.has(messageId))
|
4372
|
+
throw new Error("Edit already in progress");
|
4373
|
+
this._editComposers.set(
|
4374
|
+
messageId,
|
4375
|
+
new DefaultEditComposerRuntimeCore(
|
4376
|
+
this,
|
4377
|
+
() => this._editComposers.delete(messageId),
|
4378
|
+
this.repository.getMessage(messageId)
|
4379
|
+
)
|
4380
|
+
);
|
4381
|
+
this.notifySubscribers();
|
4382
|
+
}
|
4284
4383
|
get store() {
|
4285
4384
|
return this._store;
|
4286
4385
|
}
|
@@ -4297,12 +4396,12 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4297
4396
|
reload: this._store.onReload !== void 0,
|
4298
4397
|
cancel: this._store.onCancel !== void 0,
|
4299
4398
|
speak: this._store.onSpeak !== void 0,
|
4300
|
-
unstable_copy: _optionalChain([this, 'access',
|
4399
|
+
unstable_copy: _optionalChain([this, 'access', _204 => _204._store, 'access', _205 => _205.unstable_capabilities, 'optionalAccess', _206 => _206.copy]) !== false,
|
4301
4400
|
// default true
|
4302
|
-
attachments: !!_optionalChain([this, 'access',
|
4303
|
-
feedback: !!_optionalChain([this, 'access',
|
4401
|
+
attachments: !!_optionalChain([this, 'access', _207 => _207.store, 'access', _208 => _208.adapters, 'optionalAccess', _209 => _209.attachments]),
|
4402
|
+
feedback: !!_optionalChain([this, 'access', _210 => _210.store, 'access', _211 => _211.adapters, 'optionalAccess', _212 => _212.feedback])
|
4304
4403
|
};
|
4305
|
-
this.composer.setAttachmentAdapter(_optionalChain([this, 'access',
|
4404
|
+
this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _213 => _213._store, 'access', _214 => _214.adapters, 'optionalAccess', _215 => _215.attachments]));
|
4306
4405
|
if (oldStore) {
|
4307
4406
|
if (oldStore.convertMessage !== store.convertMessage) {
|
4308
4407
|
this.converter = new ThreadMessageConverter();
|
@@ -4311,7 +4410,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4311
4410
|
return;
|
4312
4411
|
}
|
4313
4412
|
}
|
4314
|
-
const
|
4413
|
+
const messages2 = !store.convertMessage ? store.messages : this.converter.convertMessages(store.messages, (cache, m, idx) => {
|
4315
4414
|
if (!store.convertMessage) return m;
|
4316
4415
|
const isLast = idx === store.messages.length - 1;
|
4317
4416
|
const autoStatus = getAutoStatus(isLast, isRunning);
|
@@ -4325,18 +4424,18 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4325
4424
|
newMessage[symbolInnerMessage] = m;
|
4326
4425
|
return newMessage;
|
4327
4426
|
});
|
4328
|
-
for (let i = 0; i <
|
4329
|
-
const message =
|
4330
|
-
const parent =
|
4331
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
4427
|
+
for (let i = 0; i < messages2.length; i++) {
|
4428
|
+
const message = messages2[i];
|
4429
|
+
const parent = messages2[i - 1];
|
4430
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _216 => _216.id]), () => ( null)), message);
|
4332
4431
|
}
|
4333
4432
|
if (this.assistantOptimisticId) {
|
4334
4433
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
4335
4434
|
this.assistantOptimisticId = null;
|
4336
4435
|
}
|
4337
|
-
if (hasUpcomingMessage(isRunning,
|
4436
|
+
if (hasUpcomingMessage(isRunning, messages2)) {
|
4338
4437
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
4339
|
-
_nullishCoalesce(_optionalChain([
|
4438
|
+
_nullishCoalesce(_optionalChain([messages2, 'access', _217 => _217.at, 'call', _218 => _218(-1), 'optionalAccess', _219 => _219.id]), () => ( null)),
|
4340
4439
|
{
|
4341
4440
|
role: "assistant",
|
4342
4441
|
content: []
|
@@ -4344,7 +4443,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4344
4443
|
);
|
4345
4444
|
}
|
4346
4445
|
this.repository.resetHead(
|
4347
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([
|
4446
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _220 => _220.at, 'call', _221 => _221(-1), 'optionalAccess', _222 => _222.id]))), () => ( null))
|
4348
4447
|
);
|
4349
4448
|
this.messages = this.repository.getMessages();
|
4350
4449
|
this.notifySubscribers();
|
@@ -4365,7 +4464,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4365
4464
|
this.updateMessages(this.repository.getMessages());
|
4366
4465
|
}
|
4367
4466
|
async append(message) {
|
4368
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
4467
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _223 => _223.messages, 'access', _224 => _224.at, 'call', _225 => _225(-1), 'optionalAccess', _226 => _226.id]), () => ( null)))) {
|
4369
4468
|
if (!this._store.onEdit)
|
4370
4469
|
throw new Error("Runtime does not support editing messages.");
|
4371
4470
|
await this._store.onEdit(message);
|
@@ -4386,19 +4485,19 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4386
4485
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
4387
4486
|
this.assistantOptimisticId = null;
|
4388
4487
|
}
|
4389
|
-
let
|
4390
|
-
const previousMessage =
|
4391
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
4488
|
+
let messages2 = this.repository.getMessages();
|
4489
|
+
const previousMessage = messages2[messages2.length - 1];
|
4490
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _227 => _227.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _228 => _228.at, 'call', _229 => _229(-1), 'optionalAccess', _230 => _230.id])) {
|
4392
4491
|
this.repository.deleteMessage(previousMessage.id);
|
4393
4492
|
if (!this.composer.text.trim()) {
|
4394
4493
|
this.composer.setText(getThreadMessageText(previousMessage));
|
4395
4494
|
}
|
4396
|
-
|
4495
|
+
messages2 = this.repository.getMessages();
|
4397
4496
|
} else {
|
4398
4497
|
this.notifySubscribers();
|
4399
4498
|
}
|
4400
4499
|
setTimeout(() => {
|
4401
|
-
this.updateMessages(
|
4500
|
+
this.updateMessages(messages2);
|
4402
4501
|
}, 0);
|
4403
4502
|
}
|
4404
4503
|
addToolResult(options) {
|
@@ -4413,7 +4512,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4413
4512
|
return this._store.onSpeak(message);
|
4414
4513
|
}
|
4415
4514
|
submitFeedback({ messageId, type }) {
|
4416
|
-
const adapter = _optionalChain([this, 'access',
|
4515
|
+
const adapter = _optionalChain([this, 'access', _231 => _231._store, 'access', _232 => _232.adapters, 'optionalAccess', _233 => _233.feedback]);
|
4417
4516
|
if (!adapter) throw new Error("Feedback adapter not configured");
|
4418
4517
|
const { message } = this.repository.getMessage(messageId);
|
4419
4518
|
adapter.submit({ message, type });
|
@@ -4422,9 +4521,9 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4422
4521
|
this._subscriptions.add(callback);
|
4423
4522
|
return () => this._subscriptions.delete(callback);
|
4424
4523
|
}
|
4425
|
-
|
4426
|
-
_optionalChain([this, 'access',
|
4427
|
-
|
4524
|
+
__init39() {this.updateMessages = (messages2) => {
|
4525
|
+
_optionalChain([this, 'access', _234 => _234._store, 'access', _235 => _235.setMessages, 'optionalCall', _236 => _236(
|
4526
|
+
messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
4428
4527
|
)]);
|
4429
4528
|
}}
|
4430
4529
|
import(repository) {
|
@@ -4433,7 +4532,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
|
|
4433
4532
|
export() {
|
4434
4533
|
return this.repository.export();
|
4435
4534
|
}
|
4436
|
-
},
|
4535
|
+
}, _class15);
|
4437
4536
|
|
4438
4537
|
// src/runtimes/external-store/ExternalStoreRuntimeCore.tsx
|
4439
4538
|
var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
@@ -4491,12 +4590,12 @@ var useExternalStoreRuntime = (store) => {
|
|
4491
4590
|
|
4492
4591
|
// src/runtimes/external-store/external-message-converter.tsx
|
4493
4592
|
|
4494
|
-
var joinExternalMessages = (
|
4593
|
+
var joinExternalMessages = (messages2) => {
|
4495
4594
|
const assistantMessage = {
|
4496
4595
|
role: "assistant",
|
4497
4596
|
content: []
|
4498
4597
|
};
|
4499
|
-
for (const output of
|
4598
|
+
for (const output of messages2) {
|
4500
4599
|
if (output.role === "tool") {
|
4501
4600
|
const toolCallIdx = assistantMessage.content.findIndex(
|
4502
4601
|
(c) => c.type === "tool-call" && c.toolCallId === output.toolCallId
|
@@ -4573,7 +4672,7 @@ var chunkExternalMessages = (callbackResults) => {
|
|
4573
4672
|
};
|
4574
4673
|
var useExternalMessageConverter = ({
|
4575
4674
|
callback,
|
4576
|
-
messages,
|
4675
|
+
messages: messages2,
|
4577
4676
|
isRunning
|
4578
4677
|
}) => {
|
4579
4678
|
const state = _react.useMemo.call(void 0,
|
@@ -4587,7 +4686,7 @@ var useExternalMessageConverter = ({
|
|
4587
4686
|
);
|
4588
4687
|
return _react.useMemo.call(void 0, () => {
|
4589
4688
|
const callbackResults = [];
|
4590
|
-
for (const message of
|
4689
|
+
for (const message of messages2) {
|
4591
4690
|
let result = state.callbackCache.get(message);
|
4592
4691
|
if (!result) {
|
4593
4692
|
const output = state.callback(message);
|
@@ -4625,7 +4724,7 @@ var useExternalMessageConverter = ({
|
|
4625
4724
|
return newMessage;
|
4626
4725
|
}
|
4627
4726
|
);
|
4628
|
-
}, [state,
|
4727
|
+
}, [state, messages2, isRunning]);
|
4629
4728
|
};
|
4630
4729
|
var shallowArrayEqual = (a, b) => {
|
4631
4730
|
if (a.length !== b.length) return false;
|
@@ -4643,13 +4742,13 @@ var DangerousInBrowserAdapter = class {
|
|
4643
4742
|
constructor(options) {
|
4644
4743
|
this.options = options;
|
4645
4744
|
}
|
4646
|
-
async *run({ messages, abortSignal, config }) {
|
4745
|
+
async *run({ messages: messages2, abortSignal, config }) {
|
4647
4746
|
const res = await _chunk5KIEXJRKjs.getEdgeRuntimeStream.call(void 0, {
|
4648
4747
|
options: this.options,
|
4649
4748
|
abortSignal,
|
4650
4749
|
requestData: {
|
4651
4750
|
system: config.system,
|
4652
|
-
messages: _chunk5KIEXJRKjs.toCoreMessages.call(void 0,
|
4751
|
+
messages: _chunk5KIEXJRKjs.toCoreMessages.call(void 0, messages2),
|
4653
4752
|
tools: config.tools ? _chunk5KIEXJRKjs.toLanguageModelTools.call(void 0, config.tools) : [],
|
4654
4753
|
...config.callSettings,
|
4655
4754
|
...config.config
|
@@ -4713,8 +4812,8 @@ var WebSpeechSynthesisAdapter = class {
|
|
4713
4812
|
};
|
4714
4813
|
|
4715
4814
|
// src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
|
4716
|
-
var SimpleImageAttachmentAdapter = (
|
4717
|
-
|
4815
|
+
var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.__init40.call(this); }
|
4816
|
+
__init40() {this.accept = "image/*"}
|
4718
4817
|
async add(state) {
|
4719
4818
|
return {
|
4720
4819
|
id: state.file.name,
|
@@ -4736,7 +4835,7 @@ var SimpleImageAttachmentAdapter = (_class12 = class {constructor() { _class12.p
|
|
4736
4835
|
}
|
4737
4836
|
async remove() {
|
4738
4837
|
}
|
4739
|
-
},
|
4838
|
+
}, _class16);
|
4740
4839
|
var getFileDataURL = (file) => new Promise((resolve, reject) => {
|
4741
4840
|
const reader = new FileReader();
|
4742
4841
|
reader.onload = () => resolve(reader.result);
|
@@ -4745,8 +4844,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
|
|
4745
4844
|
});
|
4746
4845
|
|
4747
4846
|
// src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
|
4748
|
-
var SimpleTextAttachmentAdapter = (
|
4749
|
-
|
4847
|
+
var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init41.call(this); }
|
4848
|
+
__init41() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
|
4750
4849
|
async add(state) {
|
4751
4850
|
return {
|
4752
4851
|
id: state.file.name,
|
@@ -4770,7 +4869,7 @@ ${await getFileText(attachment.file)}
|
|
4770
4869
|
}
|
4771
4870
|
async remove() {
|
4772
4871
|
}
|
4773
|
-
},
|
4872
|
+
}, _class17);
|
4774
4873
|
var getFileText = (file) => new Promise((resolve, reject) => {
|
4775
4874
|
const reader = new FileReader();
|
4776
4875
|
reader.onload = () => resolve(reader.result);
|
@@ -4864,7 +4963,7 @@ var ThreadConfigProvider = ({
|
|
4864
4963
|
}) => {
|
4865
4964
|
const hasAssistant = !!useAssistantRuntime({ optional: true });
|
4866
4965
|
const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
|
4867
|
-
if (!_optionalChain([config, 'optionalAccess',
|
4966
|
+
if (!_optionalChain([config, 'optionalAccess', _237 => _237.runtime])) return configProvider;
|
4868
4967
|
if (hasAssistant) {
|
4869
4968
|
throw new Error(
|
4870
4969
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -5192,7 +5291,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
5192
5291
|
{
|
5193
5292
|
components: {
|
5194
5293
|
...componentsProp,
|
5195
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
5294
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _238 => _238.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
|
5196
5295
|
tools: toolsComponents
|
5197
5296
|
}
|
5198
5297
|
}
|
@@ -5335,7 +5434,7 @@ var ComposerAttachments = ({ components }) => {
|
|
5335
5434
|
{
|
5336
5435
|
components: {
|
5337
5436
|
...components,
|
5338
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5437
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _239 => _239.Attachment]), () => ( composer_attachment_default))
|
5339
5438
|
}
|
5340
5439
|
}
|
5341
5440
|
) });
|
@@ -5467,7 +5566,7 @@ var ThreadWelcomeSuggestion = ({
|
|
5467
5566
|
};
|
5468
5567
|
var ThreadWelcomeSuggestions = () => {
|
5469
5568
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
5470
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess',
|
5569
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _240 => _240.map, 'call', _241 => _241((suggestion, idx) => {
|
5471
5570
|
const key = `${suggestion.prompt}-${idx}`;
|
5472
5571
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
5473
5572
|
})]) });
|
@@ -5566,7 +5665,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
|
|
5566
5665
|
{
|
5567
5666
|
components: {
|
5568
5667
|
...components,
|
5569
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5668
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _242 => _242.Text]), () => ( content_part_default.Text))
|
5570
5669
|
}
|
5571
5670
|
}
|
5572
5671
|
) });
|
@@ -5584,7 +5683,7 @@ var UserMessageAttachments = ({
|
|
5584
5683
|
{
|
5585
5684
|
components: {
|
5586
5685
|
...components,
|
5587
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5686
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _243 => _243.Attachment]), () => ( user_message_attachment_default))
|
5588
5687
|
}
|
5589
5688
|
}
|
5590
5689
|
) }) });
|
@@ -5685,10 +5784,10 @@ var ThreadMessages = ({ components, ...rest }) => {
|
|
5685
5784
|
thread_exports.Messages,
|
5686
5785
|
{
|
5687
5786
|
components: {
|
5688
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5689
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5690
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5691
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5787
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _244 => _244.UserMessage]), () => ( user_message_default)),
|
5788
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _245 => _245.EditComposer]), () => ( edit_composer_default)),
|
5789
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _246 => _246.AssistantMessage]), () => ( assistant_message_default)),
|
5790
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _247 => _247.SystemMessage]), () => ( SystemMessage))
|
5692
5791
|
},
|
5693
5792
|
...rest
|
5694
5793
|
}
|
@@ -5908,5 +6007,7 @@ var assistant_modal_default = Object.assign(AssistantModal, exports13);
|
|
5908
6007
|
|
5909
6008
|
|
5910
6009
|
|
5911
|
-
|
6010
|
+
|
6011
|
+
|
6012
|
+
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunk5KIEXJRKjs.toCoreMessage; exports.toCoreMessages = _chunk5KIEXJRKjs.toCoreMessages; exports.toLanguageModelMessages = _chunk5KIEXJRKjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunk5KIEXJRKjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarFeedbackNegative = useActionBarFeedbackNegative; exports.useActionBarFeedbackPositive = useActionBarFeedbackPositive; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantActions = useAssistantActions; exports.useAssistantActionsStore = useAssistantActionsStore; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantRuntime = useAssistantRuntime; exports.useAssistantRuntimeStore = useAssistantRuntimeStore; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposer = useComposer; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerRuntime = useComposerRuntime; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartRuntime = useContentPartRuntime; exports.useContentPartStore = useContentPartStore; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useEditComposer = useEditComposer; exports.useEditComposerStore = useEditComposerStore; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessage = useMessage; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useMessageRuntime = useMessageRuntime; exports.useMessageStore = useMessageStore; exports.useMessageUtils = useMessageUtils; exports.useMessageUtilsStore = useMessageUtilsStore; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThread = useThread; exports.useThreadActions = useThreadActions; exports.useThreadActionsStore = useThreadActionsStore; exports.useThreadComposer = useThreadComposer; exports.useThreadComposerStore = useThreadComposerStore; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadRuntime = useThreadRuntime; exports.useThreadRuntimeStore = useThreadRuntimeStore; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadStore = useThreadStore; exports.useThreadSuggestion = useThreadSuggestion; exports.useThreadViewport = useThreadViewport; exports.useThreadViewportStore = useThreadViewportStore; exports.useToolUIs = useToolUIs; exports.useToolUIsStore = useToolUIsStore;
|
5912
6013
|
//# sourceMappingURL=index.js.map
|