@assistant-ui/react 0.5.81 → 0.5.83
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-CYIFAX4U.js → chunk-C6UZOY5A.js} +1 -1
- package/dist/chunk-C6UZOY5A.js.map +1 -0
- package/dist/{chunk-RHM73CQE.mjs → chunk-TWIMAOZR.mjs} +1 -1
- package/dist/chunk-TWIMAOZR.mjs.map +1 -0
- package/dist/{edge-rTP-G718.d.mts → edge-B3YIacNl.d.mts} +4 -1
- package/dist/{edge-rTP-G718.d.ts → edge-B3YIacNl.d.ts} +4 -1
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +1869 -711
- package/dist/index.d.ts +1869 -711
- package/dist/index.js +769 -387
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +680 -298
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-CYIFAX4U.js.map +0 -1
- package/dist/chunk-RHM73CQE.mjs.map +0 -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; var _class14; var _class15; var _class16; var _class17;
|
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; var _class18;
|
2
2
|
|
3
3
|
|
4
4
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
|
12
|
-
var
|
12
|
+
var _chunkC6UZOY5Ajs = require('./chunk-C6UZOY5A.js');
|
13
13
|
|
14
14
|
|
15
15
|
var _chunkPZ5AY32Cjs = require('./chunk-PZ5AY32C.js');
|
@@ -85,6 +85,10 @@ var { useToolUIs, useToolUIsStore } = createContextStoreHook(
|
|
85
85
|
useAssistantContext,
|
86
86
|
"useToolUIs"
|
87
87
|
);
|
88
|
+
var { useThreadManager } = createContextStoreHook(
|
89
|
+
useAssistantContext,
|
90
|
+
"useThreadManager"
|
91
|
+
);
|
88
92
|
|
89
93
|
// src/context/stores/AssistantToolUIs.ts
|
90
94
|
var _zustand = require('zustand');
|
@@ -155,6 +159,15 @@ var {
|
|
155
159
|
useViewport: useThreadViewport,
|
156
160
|
useViewportStore: useThreadViewportStore
|
157
161
|
} = createContextStoreHook(useThreadContext, "useViewport");
|
162
|
+
function useThreadModelConfig(options) {
|
163
|
+
const [, rerender] = _react.useState.call(void 0, {});
|
164
|
+
const runtime = useThreadRuntime(options);
|
165
|
+
_react.useEffect.call(void 0, () => {
|
166
|
+
return _optionalChain([runtime, 'optionalAccess', _5 => _5.unstable_on, 'call', _6 => _6("model-config-update", () => rerender({}))]);
|
167
|
+
}, [runtime]);
|
168
|
+
if (!runtime) return null;
|
169
|
+
return _optionalChain([runtime, 'optionalAccess', _7 => _7.getModelConfig, 'call', _8 => _8()]);
|
170
|
+
}
|
158
171
|
|
159
172
|
// src/context/stores/ThreadViewport.tsx
|
160
173
|
|
@@ -250,16 +263,29 @@ var useAssistantRuntimeStore2 = (runtime) => {
|
|
250
263
|
var useAssistantToolUIsStore = () => {
|
251
264
|
return _react.useMemo.call(void 0, () => makeAssistantToolUIsStore(), []);
|
252
265
|
};
|
266
|
+
var useThreadManagerStore = (runtime) => {
|
267
|
+
const [store] = _react.useState.call(void 0,
|
268
|
+
() => _zustand.create.call(void 0, () => runtime.threadManager.getState())
|
269
|
+
);
|
270
|
+
_react.useEffect.call(void 0, () => {
|
271
|
+
const updateState = () => writableStore(store).setState(runtime.threadManager.getState(), true);
|
272
|
+
updateState();
|
273
|
+
return runtime.threadManager.subscribe(updateState);
|
274
|
+
}, [runtime, store]);
|
275
|
+
return store;
|
276
|
+
};
|
253
277
|
var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
|
254
278
|
const useAssistantRuntime2 = useAssistantRuntimeStore2(runtime);
|
255
279
|
const useToolUIs2 = useAssistantToolUIsStore();
|
280
|
+
const useThreadManager2 = useThreadManagerStore(runtime);
|
256
281
|
const context = _react.useMemo.call(void 0, () => {
|
257
282
|
return {
|
258
283
|
useToolUIs: useToolUIs2,
|
259
284
|
useAssistantRuntime: useAssistantRuntime2,
|
260
|
-
useAssistantActions: useAssistantRuntime2
|
285
|
+
useAssistantActions: useAssistantRuntime2,
|
286
|
+
useThreadManager: useThreadManager2
|
261
287
|
};
|
262
|
-
}, [useAssistantRuntime2, useToolUIs2]);
|
288
|
+
}, [useAssistantRuntime2, useToolUIs2, useThreadManager2]);
|
263
289
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantContext.Provider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRuntimeProvider, { runtime: runtime.thread, children }) });
|
264
290
|
};
|
265
291
|
var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProviderImpl);
|
@@ -294,6 +320,9 @@ var ContentPartRuntimeImpl = class {
|
|
294
320
|
this.messageApi = messageApi;
|
295
321
|
this.threadApi = threadApi;
|
296
322
|
}
|
323
|
+
get path() {
|
324
|
+
return this.contentBinding.path;
|
325
|
+
}
|
297
326
|
getState() {
|
298
327
|
return this.contentBinding.getState();
|
299
328
|
}
|
@@ -404,7 +433,7 @@ var { useComposer, useComposerStore } = createContextStoreHook(
|
|
404
433
|
function useComposerRuntime(options) {
|
405
434
|
const messageRuntime = useMessageRuntime({ optional: true });
|
406
435
|
const threadRuntime = useThreadRuntime(options);
|
407
|
-
return messageRuntime ? messageRuntime.composer : _nullishCoalesce(_optionalChain([threadRuntime, 'optionalAccess',
|
436
|
+
return messageRuntime ? messageRuntime.composer : _nullishCoalesce(_optionalChain([threadRuntime, 'optionalAccess', _9 => _9.composer]), () => ( null));
|
408
437
|
}
|
409
438
|
|
410
439
|
// src/hooks/useAppendMessage.tsx
|
@@ -448,7 +477,7 @@ var useAssistantTool = (tool) => {
|
|
448
477
|
const unsub2 = render ? toolUIsStore.getState().setToolUI(toolName, render) : void 0;
|
449
478
|
return () => {
|
450
479
|
unsub1();
|
451
|
-
_optionalChain([unsub2, 'optionalCall',
|
480
|
+
_optionalChain([unsub2, 'optionalCall', _10 => _10()]);
|
452
481
|
};
|
453
482
|
}, [assistantRuntime, toolUIsStore, tool]);
|
454
483
|
};
|
@@ -500,64 +529,23 @@ var useAssistantInstructions = (instruction) => {
|
|
500
529
|
|
501
530
|
// src/primitive-hooks/actionBar/useActionBarCopy.tsx
|
502
531
|
|
503
|
-
|
504
|
-
// src/utils/combined/useCombinedStore.ts
|
505
|
-
|
506
|
-
|
507
|
-
// src/utils/combined/createCombinedStore.ts
|
508
|
-
|
509
|
-
var createCombinedStore = (stores) => {
|
510
|
-
const subscribe = (callback) => {
|
511
|
-
const unsubscribes = stores.map((store) => store.subscribe(callback));
|
512
|
-
return () => {
|
513
|
-
for (const unsub of unsubscribes) {
|
514
|
-
unsub();
|
515
|
-
}
|
516
|
-
};
|
517
|
-
};
|
518
|
-
return (selector) => {
|
519
|
-
const getSnapshot = () => selector(...stores.map((store) => store.getState()));
|
520
|
-
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getSnapshot);
|
521
|
-
};
|
522
|
-
};
|
523
|
-
|
524
|
-
// src/utils/combined/useCombinedStore.ts
|
525
|
-
var useCombinedStore = (stores, selector) => {
|
526
|
-
const useCombined = _react.useMemo.call(void 0, () => createCombinedStore(stores), stores);
|
527
|
-
return useCombined(selector);
|
528
|
-
};
|
529
|
-
|
530
|
-
// src/utils/getThreadMessageText.tsx
|
531
|
-
var getThreadMessageText = (message) => {
|
532
|
-
const textParts = message.content.filter(
|
533
|
-
(part) => part.type === "text"
|
534
|
-
);
|
535
|
-
return textParts.map((part) => part.text).join("\n\n");
|
536
|
-
};
|
537
|
-
|
538
|
-
// src/primitive-hooks/actionBar/useActionBarCopy.tsx
|
539
532
|
var useActionBarCopy = ({
|
540
533
|
copiedDuration = 3e3
|
541
534
|
} = {}) => {
|
542
535
|
const messageRuntime = useMessageRuntime();
|
543
536
|
const composerRuntime = useComposerRuntime();
|
544
|
-
const
|
545
|
-
const hasCopyableContent =
|
546
|
-
|
547
|
-
|
548
|
-
return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
|
549
|
-
}
|
550
|
-
);
|
537
|
+
const setIsCopied = useMessageUtils((s) => s.setIsCopied);
|
538
|
+
const hasCopyableContent = useMessage((message) => {
|
539
|
+
return (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c) => c.type === "text" && c.text.length > 0);
|
540
|
+
});
|
551
541
|
const callback = _react.useCallback.call(void 0, () => {
|
552
|
-
const message = messageRuntime.getState();
|
553
|
-
const { setIsCopied } = messageUtilsStore.getState();
|
554
542
|
const { isEditing, text: composerValue } = composerRuntime.getState();
|
555
|
-
const valueToCopy = isEditing ? composerValue :
|
543
|
+
const valueToCopy = isEditing ? composerValue : messageRuntime.unstable_getCopyText();
|
556
544
|
navigator.clipboard.writeText(valueToCopy).then(() => {
|
557
545
|
setIsCopied(true);
|
558
546
|
setTimeout(() => setIsCopied(false), copiedDuration);
|
559
547
|
});
|
560
|
-
}, [messageRuntime,
|
548
|
+
}, [messageRuntime, setIsCopied, composerRuntime, copiedDuration]);
|
561
549
|
if (!hasCopyableContent) return null;
|
562
550
|
return callback;
|
563
551
|
};
|
@@ -576,6 +564,34 @@ var useActionBarEdit = () => {
|
|
576
564
|
|
577
565
|
// src/primitive-hooks/actionBar/useActionBarReload.tsx
|
578
566
|
|
567
|
+
|
568
|
+
// src/utils/combined/useCombinedStore.ts
|
569
|
+
|
570
|
+
|
571
|
+
// src/utils/combined/createCombinedStore.ts
|
572
|
+
|
573
|
+
var createCombinedStore = (stores) => {
|
574
|
+
const subscribe = (callback) => {
|
575
|
+
const unsubscribes = stores.map((store) => store.subscribe(callback));
|
576
|
+
return () => {
|
577
|
+
for (const unsub of unsubscribes) {
|
578
|
+
unsub();
|
579
|
+
}
|
580
|
+
};
|
581
|
+
};
|
582
|
+
return (selector) => {
|
583
|
+
const getSnapshot = () => selector(...stores.map((store) => store.getState()));
|
584
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getSnapshot);
|
585
|
+
};
|
586
|
+
};
|
587
|
+
|
588
|
+
// src/utils/combined/useCombinedStore.ts
|
589
|
+
var useCombinedStore = (stores, selector) => {
|
590
|
+
const useCombined = _react.useMemo.call(void 0, () => createCombinedStore(stores), stores);
|
591
|
+
return useCombined(selector);
|
592
|
+
};
|
593
|
+
|
594
|
+
// src/primitive-hooks/actionBar/useActionBarReload.tsx
|
579
595
|
var useActionBarReload = () => {
|
580
596
|
const messageRuntime = useMessageRuntime();
|
581
597
|
const threadRuntime = useThreadRuntime();
|
@@ -723,7 +739,7 @@ var useComposerAddAttachment = () => {
|
|
723
739
|
input.accept = attachmentAccept;
|
724
740
|
}
|
725
741
|
input.onchange = (e) => {
|
726
|
-
const file = _optionalChain([e, 'access',
|
742
|
+
const file = _optionalChain([e, 'access', _11 => _11.target, 'access', _12 => _12.files, 'optionalAccess', _13 => _13[0]]);
|
727
743
|
if (!file) return;
|
728
744
|
composerRuntime.addAttachment(file);
|
729
745
|
};
|
@@ -799,7 +815,7 @@ var useMessageIf = (props) => {
|
|
799
815
|
return false;
|
800
816
|
if (props.hasContent === true && content.length === 0) return false;
|
801
817
|
if (props.hasContent === false && content.length > 0) return false;
|
802
|
-
if (props.submittedFeedback !== void 0 && (_nullishCoalesce(_optionalChain([submittedFeedback, 'optionalAccess',
|
818
|
+
if (props.submittedFeedback !== void 0 && (_nullishCoalesce(_optionalChain([submittedFeedback, 'optionalAccess', _14 => _14.type]), () => ( null))) !== props.submittedFeedback)
|
803
819
|
return false;
|
804
820
|
return true;
|
805
821
|
}
|
@@ -933,7 +949,7 @@ var ActionBarPrimitiveCopy = _react.forwardRef.call(void 0, ({ copiedDuration, o
|
|
933
949
|
ref: forwardedRef,
|
934
950
|
disabled: disabled || !callback,
|
935
951
|
onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
|
936
|
-
_optionalChain([callback, 'optionalCall',
|
952
|
+
_optionalChain([callback, 'optionalCall', _15 => _15()]);
|
937
953
|
})
|
938
954
|
}
|
939
955
|
);
|
@@ -965,7 +981,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
|
965
981
|
ref: forwardedRef,
|
966
982
|
disabled: primitiveProps.disabled || !callback,
|
967
983
|
onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
|
968
|
-
_optionalChain([callback, 'optionalCall',
|
984
|
+
_optionalChain([callback, 'optionalCall', _16 => _16()]);
|
969
985
|
})
|
970
986
|
}
|
971
987
|
);
|
@@ -1014,7 +1030,7 @@ var ActionBarPrimitiveStopSpeaking = _react.forwardRef.call(void 0, (props, ref)
|
|
1014
1030
|
...props,
|
1015
1031
|
ref,
|
1016
1032
|
onClick: _primitive.composeEventHandlers.call(void 0, props.onClick, () => {
|
1017
|
-
_optionalChain([callback, 'optionalCall',
|
1033
|
+
_optionalChain([callback, 'optionalCall', _17 => _17()]);
|
1018
1034
|
})
|
1019
1035
|
}
|
1020
1036
|
);
|
@@ -1028,7 +1044,7 @@ ActionBarPrimitiveStopSpeaking.displayName = "ActionBarPrimitive.StopSpeaking";
|
|
1028
1044
|
|
1029
1045
|
var ActionBarPrimitiveFeedbackPositive = _react.forwardRef.call(void 0, ({ onClick, disabled, ...props }, forwardedRef) => {
|
1030
1046
|
const isSubmitted = useMessage(
|
1031
|
-
(u) => _optionalChain([u, 'access',
|
1047
|
+
(u) => _optionalChain([u, 'access', _18 => _18.submittedFeedback, 'optionalAccess', _19 => _19.type]) === "positive"
|
1032
1048
|
);
|
1033
1049
|
const callback = useActionBarFeedbackPositive();
|
1034
1050
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
@@ -1040,7 +1056,7 @@ var ActionBarPrimitiveFeedbackPositive = _react.forwardRef.call(void 0, ({ onCli
|
|
1040
1056
|
ref: forwardedRef,
|
1041
1057
|
disabled: disabled || !callback,
|
1042
1058
|
onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
|
1043
|
-
_optionalChain([callback, 'optionalCall',
|
1059
|
+
_optionalChain([callback, 'optionalCall', _20 => _20()]);
|
1044
1060
|
})
|
1045
1061
|
}
|
1046
1062
|
);
|
@@ -1054,7 +1070,7 @@ ActionBarPrimitiveFeedbackPositive.displayName = "ActionBarPrimitive.FeedbackPos
|
|
1054
1070
|
|
1055
1071
|
var ActionBarPrimitiveFeedbackNegative = _react.forwardRef.call(void 0, ({ onClick, disabled, ...props }, forwardedRef) => {
|
1056
1072
|
const isSubmitted = useMessage(
|
1057
|
-
(u) => _optionalChain([u, 'access',
|
1073
|
+
(u) => _optionalChain([u, 'access', _21 => _21.submittedFeedback, 'optionalAccess', _22 => _22.type]) === "negative"
|
1058
1074
|
);
|
1059
1075
|
const callback = useActionBarFeedbackNegative();
|
1060
1076
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
@@ -1066,7 +1082,7 @@ var ActionBarPrimitiveFeedbackNegative = _react.forwardRef.call(void 0, ({ onCli
|
|
1066
1082
|
ref: forwardedRef,
|
1067
1083
|
disabled: disabled || !callback,
|
1068
1084
|
onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
|
1069
|
-
_optionalChain([callback, 'optionalCall',
|
1085
|
+
_optionalChain([callback, 'optionalCall', _23 => _23()]);
|
1070
1086
|
})
|
1071
1087
|
}
|
1072
1088
|
);
|
@@ -1224,7 +1240,7 @@ var AttachmentContext = _react.createContext.call(void 0,
|
|
1224
1240
|
);
|
1225
1241
|
function useAttachmentContext(options) {
|
1226
1242
|
const context = _react.useContext.call(void 0, AttachmentContext);
|
1227
|
-
if (!_optionalChain([options, 'optionalAccess',
|
1243
|
+
if (!_optionalChain([options, 'optionalAccess', _24 => _24.optional]) && !context)
|
1228
1244
|
throw new Error(
|
1229
1245
|
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
1230
1246
|
);
|
@@ -1505,7 +1521,7 @@ var withSmoothContextProvider = (Component) => {
|
|
1505
1521
|
};
|
1506
1522
|
function useSmoothContext(options) {
|
1507
1523
|
const context = _react.useContext.call(void 0, SmoothContext);
|
1508
|
-
if (!_optionalChain([options, 'optionalAccess',
|
1524
|
+
if (!_optionalChain([options, 'optionalAccess', _25 => _25.optional]) && !context)
|
1509
1525
|
throw new Error(
|
1510
1526
|
"This component must be used within a SmoothContextProvider."
|
1511
1527
|
);
|
@@ -1655,11 +1671,22 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
|
|
1655
1671
|
};
|
1656
1672
|
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
1657
1673
|
|
1674
|
+
// src/utils/getThreadMessageText.tsx
|
1675
|
+
var getThreadMessageText = (message) => {
|
1676
|
+
const textParts = message.content.filter(
|
1677
|
+
(part) => part.type === "text"
|
1678
|
+
);
|
1679
|
+
return textParts.map((part) => part.text).join("\n\n");
|
1680
|
+
};
|
1681
|
+
|
1658
1682
|
// src/api/AttachmentRuntime.ts
|
1659
1683
|
var AttachmentRuntimeImpl = class {
|
1660
1684
|
constructor(_core) {
|
1661
1685
|
this._core = _core;
|
1662
1686
|
}
|
1687
|
+
get path() {
|
1688
|
+
return this._core.path;
|
1689
|
+
}
|
1663
1690
|
getState() {
|
1664
1691
|
return this._core.getState();
|
1665
1692
|
}
|
@@ -1715,7 +1742,7 @@ var BaseSubject = (_class2 = class {constructor() { _class2.prototype.__init5.ca
|
|
1715
1742
|
if (this._connection) return;
|
1716
1743
|
this._connection = this._connect();
|
1717
1744
|
} else {
|
1718
|
-
_optionalChain([this, 'access',
|
1745
|
+
_optionalChain([this, 'access', _26 => _26._connection, 'optionalCall', _27 => _27()]);
|
1719
1746
|
this._connection = void 0;
|
1720
1747
|
}
|
1721
1748
|
}
|
@@ -1738,6 +1765,9 @@ var LazyMemoizeSubject = (_class3 = class extends BaseSubject {
|
|
1738
1765
|
super();_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);;
|
1739
1766
|
this.binding = binding;
|
1740
1767
|
}
|
1768
|
+
get path() {
|
1769
|
+
return this.binding.path;
|
1770
|
+
}
|
1741
1771
|
__init6() {this._previousStateDirty = true}
|
1742
1772
|
|
1743
1773
|
__init7() {this.getState = () => {
|
@@ -1784,6 +1814,9 @@ var ShallowMemoizeSubject = (_class4 = class extends BaseSubject {
|
|
1784
1814
|
throw new Error("Entry not available in the store");
|
1785
1815
|
this._previousState = state;
|
1786
1816
|
}
|
1817
|
+
get path() {
|
1818
|
+
return this.binding.path;
|
1819
|
+
}
|
1787
1820
|
|
1788
1821
|
__init8() {this.getState = () => {
|
1789
1822
|
if (!this.isConnected) this._syncState();
|
@@ -1814,42 +1847,45 @@ var EMPTY_ARRAY = Object.freeze([]);
|
|
1814
1847
|
var getThreadComposerState = (runtime) => {
|
1815
1848
|
return Object.freeze({
|
1816
1849
|
type: "thread",
|
1817
|
-
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1818
|
-
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1819
|
-
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1820
|
-
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1821
|
-
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1822
|
-
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1823
|
-
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1824
|
-
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1850
|
+
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _28 => _28.isEditing]), () => ( false)),
|
1851
|
+
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _29 => _29.canCancel]), () => ( false)),
|
1852
|
+
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _30 => _30.isEmpty]), () => ( true)),
|
1853
|
+
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _31 => _31.text]), () => ( "")),
|
1854
|
+
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _32 => _32.attachments]), () => ( EMPTY_ARRAY)),
|
1855
|
+
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _33 => _33.text]), () => ( "")),
|
1856
|
+
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _34 => _34.setText, 'access', _35 => _35.bind, 'call', _36 => _36(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1857
|
+
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _37 => _37.setText, 'access', _38 => _38.bind, 'call', _39 => _39(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1825
1858
|
// edit: beginEdit,
|
1826
|
-
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1827
|
-
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1828
|
-
reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1829
|
-
addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1830
|
-
removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1859
|
+
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _40 => _40.send, 'access', _41 => _41.bind, 'call', _42 => _42(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1860
|
+
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _43 => _43.cancel, 'access', _44 => _44.bind, 'call', _45 => _45(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1861
|
+
reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _46 => _46.reset, 'access', _47 => _47.bind, 'call', _48 => _48(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1862
|
+
addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _49 => _49.addAttachment, 'access', _50 => _50.bind, 'call', _51 => _51(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1863
|
+
removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _52 => _52.removeAttachment, 'access', _53 => _53.bind, 'call', _54 => _54(runtime)]), () => ( METHOD_NOT_SUPPORTED))
|
1831
1864
|
});
|
1832
1865
|
};
|
1833
1866
|
var getEditComposerState = (runtime, beginEdit) => {
|
1834
1867
|
return Object.freeze({
|
1835
1868
|
type: "edit",
|
1836
|
-
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1837
|
-
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1838
|
-
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1839
|
-
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1840
|
-
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1841
|
-
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1842
|
-
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1843
|
-
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1869
|
+
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _55 => _55.isEditing]), () => ( false)),
|
1870
|
+
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _56 => _56.canCancel]), () => ( false)),
|
1871
|
+
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _57 => _57.isEmpty]), () => ( true)),
|
1872
|
+
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _58 => _58.text]), () => ( "")),
|
1873
|
+
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _59 => _59.attachments]), () => ( EMPTY_ARRAY)),
|
1874
|
+
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _60 => _60.text]), () => ( "")),
|
1875
|
+
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _61 => _61.setText, 'access', _62 => _62.bind, 'call', _63 => _63(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1876
|
+
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _64 => _64.setText, 'access', _65 => _65.bind, 'call', _66 => _66(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1844
1877
|
edit: beginEdit,
|
1845
|
-
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1846
|
-
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1878
|
+
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _67 => _67.send, 'access', _68 => _68.bind, 'call', _69 => _69(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1879
|
+
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _70 => _70.cancel, 'access', _71 => _71.bind, 'call', _72 => _72(runtime)]), () => ( METHOD_NOT_SUPPORTED))
|
1847
1880
|
});
|
1848
1881
|
};
|
1849
1882
|
var ComposerRuntimeImpl = class {
|
1850
1883
|
constructor(_core) {
|
1851
1884
|
this._core = _core;
|
1852
1885
|
}
|
1886
|
+
get path() {
|
1887
|
+
return this._core.path;
|
1888
|
+
}
|
1853
1889
|
/**
|
1854
1890
|
* @deprecated Use `getState().isEditing` instead. This will be removed in 0.6.0.
|
1855
1891
|
*/
|
@@ -1935,23 +1971,28 @@ var ComposerRuntimeImpl = class {
|
|
1935
1971
|
}
|
1936
1972
|
};
|
1937
1973
|
var ThreadComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
1974
|
+
get path() {
|
1975
|
+
return this._core.path;
|
1976
|
+
}
|
1938
1977
|
get type() {
|
1939
1978
|
return "thread";
|
1940
1979
|
}
|
1941
1980
|
|
1942
1981
|
constructor(core) {
|
1943
1982
|
const stateBinding = new LazyMemoizeSubject({
|
1983
|
+
path: core.path,
|
1944
1984
|
getState: () => getThreadComposerState(core.getState()),
|
1945
1985
|
subscribe: (callback) => core.subscribe(callback)
|
1946
1986
|
});
|
1947
1987
|
super({
|
1988
|
+
path: core.path,
|
1948
1989
|
getState: () => core.getState(),
|
1949
1990
|
subscribe: (callback) => stateBinding.subscribe(callback)
|
1950
1991
|
});
|
1951
1992
|
this._getState = stateBinding.getState.bind(stateBinding);
|
1952
1993
|
}
|
1953
1994
|
get attachments() {
|
1954
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
1995
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _73 => _73.getState, 'call', _74 => _74(), 'optionalAccess', _75 => _75.attachments]), () => ( EMPTY_ARRAY));
|
1955
1996
|
}
|
1956
1997
|
getState() {
|
1957
1998
|
return this._getState();
|
@@ -1959,6 +2000,12 @@ var ThreadComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
|
1959
2000
|
getAttachmentByIndex(idx) {
|
1960
2001
|
return new ThreadComposerAttachmentRuntimeImpl(
|
1961
2002
|
new ShallowMemoizeSubject({
|
2003
|
+
path: {
|
2004
|
+
...this.path,
|
2005
|
+
attachmentSource: "thread-composer",
|
2006
|
+
attachmentSelector: { type: "index", index: idx },
|
2007
|
+
ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`
|
2008
|
+
},
|
1962
2009
|
getState: () => {
|
1963
2010
|
const attachments = this.getState().attachments;
|
1964
2011
|
const attachment = attachments[idx];
|
@@ -1978,16 +2025,21 @@ var ThreadComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
|
1978
2025
|
var EditComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
1979
2026
|
constructor(core, _beginEdit) {
|
1980
2027
|
const stateBinding = new LazyMemoizeSubject({
|
2028
|
+
path: core.path,
|
1981
2029
|
getState: () => getEditComposerState(core.getState(), this._beginEdit),
|
1982
2030
|
subscribe: (callback) => core.subscribe(callback)
|
1983
2031
|
});
|
1984
2032
|
super({
|
2033
|
+
path: core.path,
|
1985
2034
|
getState: () => core.getState(),
|
1986
2035
|
subscribe: (callback) => stateBinding.subscribe(callback)
|
1987
2036
|
});
|
1988
2037
|
this._beginEdit = _beginEdit;
|
1989
2038
|
this._getState = stateBinding.getState.bind(stateBinding);
|
1990
2039
|
}
|
2040
|
+
get path() {
|
2041
|
+
return this._core.path;
|
2042
|
+
}
|
1991
2043
|
get type() {
|
1992
2044
|
return "edit";
|
1993
2045
|
}
|
@@ -2007,6 +2059,12 @@ var EditComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
|
2007
2059
|
getAttachmentByIndex(idx) {
|
2008
2060
|
return new EditComposerAttachmentRuntimeImpl(
|
2009
2061
|
new ShallowMemoizeSubject({
|
2062
|
+
path: {
|
2063
|
+
...this.path,
|
2064
|
+
attachmentSource: "edit-composer",
|
2065
|
+
attachmentSelector: { type: "index", index: idx },
|
2066
|
+
ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`
|
2067
|
+
},
|
2010
2068
|
getState: () => {
|
2011
2069
|
const attachments = this.getState().attachments;
|
2012
2070
|
const attachment = attachments[idx];
|
@@ -2030,6 +2088,9 @@ var NestedSubscriptionSubject = class extends BaseSubject {
|
|
2030
2088
|
super();
|
2031
2089
|
this.binding = binding;
|
2032
2090
|
}
|
2091
|
+
get path() {
|
2092
|
+
return this.binding.path;
|
2093
|
+
}
|
2033
2094
|
getState() {
|
2034
2095
|
return this.binding.getState();
|
2035
2096
|
}
|
@@ -2041,19 +2102,19 @@ var NestedSubscriptionSubject = class extends BaseSubject {
|
|
2041
2102
|
this.notifySubscribers();
|
2042
2103
|
};
|
2043
2104
|
let lastState = this.binding.getState();
|
2044
|
-
let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess',
|
2105
|
+
let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess', _76 => _76.subscribe, 'call', _77 => _77(callback)]);
|
2045
2106
|
const onRuntimeUpdate = () => {
|
2046
2107
|
const newState = this.binding.getState();
|
2047
2108
|
if (newState === lastState) return;
|
2048
2109
|
lastState = newState;
|
2049
|
-
_optionalChain([innerUnsubscribe, 'optionalCall',
|
2050
|
-
innerUnsubscribe = _optionalChain([this, 'access',
|
2110
|
+
_optionalChain([innerUnsubscribe, 'optionalCall', _78 => _78()]);
|
2111
|
+
innerUnsubscribe = _optionalChain([this, 'access', _79 => _79.binding, 'access', _80 => _80.getState, 'call', _81 => _81(), 'optionalAccess', _82 => _82.subscribe, 'call', _83 => _83(callback)]);
|
2051
2112
|
callback();
|
2052
2113
|
};
|
2053
2114
|
const outerUnsubscribe = this.outerSubscribe(onRuntimeUpdate);
|
2054
2115
|
return () => {
|
2055
|
-
_optionalChain([outerUnsubscribe, 'optionalCall',
|
2056
|
-
_optionalChain([innerUnsubscribe, 'optionalCall',
|
2116
|
+
_optionalChain([outerUnsubscribe, 'optionalCall', _84 => _84()]);
|
2117
|
+
_optionalChain([innerUnsubscribe, 'optionalCall', _85 => _85()]);
|
2057
2118
|
};
|
2058
2119
|
}
|
2059
2120
|
};
|
@@ -2092,18 +2153,27 @@ var getContentPartState = (message, partIndex) => {
|
|
2092
2153
|
const status = toContentPartStatus(message, partIndex, part);
|
2093
2154
|
return Object.freeze({ ...part, part, status });
|
2094
2155
|
};
|
2095
|
-
var MessageRuntimeImpl =
|
2096
|
-
constructor(_core, _threadBinding) {
|
2156
|
+
var MessageRuntimeImpl = class {
|
2157
|
+
constructor(_core, _threadBinding) {
|
2097
2158
|
this._core = _core;
|
2098
2159
|
this._threadBinding = _threadBinding;
|
2160
|
+
this.composer = new EditComposerRuntimeImpl(
|
2161
|
+
new NestedSubscriptionSubject({
|
2162
|
+
path: {
|
2163
|
+
...this.path,
|
2164
|
+
ref: this.path.ref + `${this.path.ref}.composer`,
|
2165
|
+
composerSource: "edit"
|
2166
|
+
},
|
2167
|
+
getState: () => this._threadBinding.getState().getEditComposer(this._core.getState().id),
|
2168
|
+
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
2169
|
+
}),
|
2170
|
+
() => this._threadBinding.getState().beginEdit(this._core.getState().id)
|
2171
|
+
);
|
2099
2172
|
}
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
}),
|
2105
|
-
() => this._threadBinding.getState().beginEdit(this._core.getState().id)
|
2106
|
-
)}
|
2173
|
+
get path() {
|
2174
|
+
return this._core.path;
|
2175
|
+
}
|
2176
|
+
|
2107
2177
|
getState() {
|
2108
2178
|
return this._core.getState();
|
2109
2179
|
}
|
@@ -2123,7 +2193,7 @@ var MessageRuntimeImpl = (_class5 = class {
|
|
2123
2193
|
const state = this._core.getState();
|
2124
2194
|
if (!state) throw new Error("Message is not available");
|
2125
2195
|
const thread = this._threadBinding.getState();
|
2126
|
-
if (_optionalChain([thread, 'access',
|
2196
|
+
if (_optionalChain([thread, 'access', _86 => _86.speech, 'optionalAccess', _87 => _87.messageId]) === state.id) {
|
2127
2197
|
this._threadBinding.getState().stopSpeaking();
|
2128
2198
|
} else {
|
2129
2199
|
throw new Error("Message is not being spoken");
|
@@ -2159,13 +2229,21 @@ var MessageRuntimeImpl = (_class5 = class {
|
|
2159
2229
|
if (!targetBranch) throw new Error("Branch not found");
|
2160
2230
|
this._threadBinding.getState().switchToBranch(targetBranch);
|
2161
2231
|
}
|
2232
|
+
unstable_getCopyText() {
|
2233
|
+
return getThreadMessageText(this.getState());
|
2234
|
+
}
|
2162
2235
|
subscribe(callback) {
|
2163
2236
|
return this._core.subscribe(callback);
|
2164
2237
|
}
|
2165
2238
|
getContentPartByIndex(idx) {
|
2166
|
-
if (idx < 0) throw new Error("
|
2239
|
+
if (idx < 0) throw new Error("Content part index must be >= 0");
|
2167
2240
|
return new ContentPartRuntimeImpl(
|
2168
2241
|
new ShallowMemoizeSubject({
|
2242
|
+
path: {
|
2243
|
+
...this.path,
|
2244
|
+
ref: this.path.ref + `${this.path.ref}.content[${idx}]`,
|
2245
|
+
contentPartSelector: { type: "index", index: idx }
|
2246
|
+
},
|
2169
2247
|
getState: () => {
|
2170
2248
|
return getContentPartState(this.getState(), idx);
|
2171
2249
|
},
|
@@ -2175,12 +2253,40 @@ var MessageRuntimeImpl = (_class5 = class {
|
|
2175
2253
|
this._threadBinding
|
2176
2254
|
);
|
2177
2255
|
}
|
2256
|
+
getContentPartByToolCallId(toolCallId) {
|
2257
|
+
return new ContentPartRuntimeImpl(
|
2258
|
+
new ShallowMemoizeSubject({
|
2259
|
+
path: {
|
2260
|
+
...this.path,
|
2261
|
+
ref: this.path.ref + `${this.path.ref}.content[toolCallId=${JSON.stringify(toolCallId)}]`,
|
2262
|
+
contentPartSelector: { type: "toolCallId", toolCallId }
|
2263
|
+
},
|
2264
|
+
getState: () => {
|
2265
|
+
const state = this._core.getState();
|
2266
|
+
const idx = state.content.findIndex(
|
2267
|
+
(part) => part.type === "tool-call" && part.toolCallId === toolCallId
|
2268
|
+
);
|
2269
|
+
if (idx === -1) return SKIP_UPDATE;
|
2270
|
+
return getContentPartState(state, idx);
|
2271
|
+
},
|
2272
|
+
subscribe: (callback) => this._core.subscribe(callback)
|
2273
|
+
}),
|
2274
|
+
this._core,
|
2275
|
+
this._threadBinding
|
2276
|
+
);
|
2277
|
+
}
|
2178
2278
|
getAttachmentByIndex(idx) {
|
2179
2279
|
return new MessageAttachmentRuntimeImpl(
|
2180
2280
|
new ShallowMemoizeSubject({
|
2281
|
+
path: {
|
2282
|
+
...this.path,
|
2283
|
+
ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,
|
2284
|
+
attachmentSource: "message",
|
2285
|
+
attachmentSelector: { type: "index", index: idx }
|
2286
|
+
},
|
2181
2287
|
getState: () => {
|
2182
2288
|
const attachments = this.getState().attachments;
|
2183
|
-
const attachment = _optionalChain([attachments, 'optionalAccess',
|
2289
|
+
const attachment = _optionalChain([attachments, 'optionalAccess', _88 => _88[idx]]);
|
2184
2290
|
if (!attachment) return SKIP_UPDATE;
|
2185
2291
|
return {
|
2186
2292
|
...attachment,
|
@@ -2192,7 +2298,7 @@ var MessageRuntimeImpl = (_class5 = class {
|
|
2192
2298
|
})
|
2193
2299
|
);
|
2194
2300
|
}
|
2195
|
-
}
|
2301
|
+
};
|
2196
2302
|
|
2197
2303
|
// src/primitives/message/MessageContent.tsx
|
2198
2304
|
|
@@ -2263,7 +2369,7 @@ var MessageContentPartImpl = ({
|
|
2263
2369
|
};
|
2264
2370
|
var MessageContentPart = _react.memo.call(void 0,
|
2265
2371
|
MessageContentPartImpl,
|
2266
|
-
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access',
|
2372
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _89 => _89.components, 'optionalAccess', _90 => _90.Text]) === _optionalChain([next, 'access', _91 => _91.components, 'optionalAccess', _92 => _92.Text]) && _optionalChain([prev, 'access', _93 => _93.components, 'optionalAccess', _94 => _94.Image]) === _optionalChain([next, 'access', _95 => _95.components, 'optionalAccess', _96 => _96.Image]) && _optionalChain([prev, 'access', _97 => _97.components, 'optionalAccess', _98 => _98.UI]) === _optionalChain([next, 'access', _99 => _99.components, 'optionalAccess', _100 => _100.UI]) && _optionalChain([prev, 'access', _101 => _101.components, 'optionalAccess', _102 => _102.tools]) === _optionalChain([next, 'access', _103 => _103.components, 'optionalAccess', _104 => _104.tools])
|
2267
2373
|
);
|
2268
2374
|
var MessagePrimitiveContent = ({
|
2269
2375
|
components
|
@@ -2329,11 +2435,11 @@ var getComponent = (components, attachment) => {
|
|
2329
2435
|
const type = attachment.type;
|
2330
2436
|
switch (type) {
|
2331
2437
|
case "image":
|
2332
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2438
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _105 => _105.Image]), () => ( _optionalChain([components, 'optionalAccess', _106 => _106.Attachment])));
|
2333
2439
|
case "document":
|
2334
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2440
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _107 => _107.Document]), () => ( _optionalChain([components, 'optionalAccess', _108 => _108.Attachment])));
|
2335
2441
|
case "file":
|
2336
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2442
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _109 => _109.File]), () => ( _optionalChain([components, 'optionalAccess', _110 => _110.Attachment])));
|
2337
2443
|
default:
|
2338
2444
|
const _exhaustiveCheck = type;
|
2339
2445
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
@@ -2356,7 +2462,7 @@ var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
2356
2462
|
};
|
2357
2463
|
var MessageAttachment = _react.memo.call(void 0,
|
2358
2464
|
MessageAttachmentImpl,
|
2359
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2465
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _111 => _111.components, 'optionalAccess', _112 => _112.Image]) === _optionalChain([next, 'access', _113 => _113.components, 'optionalAccess', _114 => _114.Image]) && _optionalChain([prev, 'access', _115 => _115.components, 'optionalAccess', _116 => _116.Document]) === _optionalChain([next, 'access', _117 => _117.components, 'optionalAccess', _118 => _118.Document]) && _optionalChain([prev, 'access', _119 => _119.components, 'optionalAccess', _120 => _120.File]) === _optionalChain([next, 'access', _121 => _121.components, 'optionalAccess', _122 => _122.File]) && _optionalChain([prev, 'access', _123 => _123.components, 'optionalAccess', _124 => _124.Attachment]) === _optionalChain([next, 'access', _125 => _125.components, 'optionalAccess', _126 => _126.Attachment])
|
2360
2466
|
);
|
2361
2467
|
var MessagePrimitiveAttachments = ({ components }) => {
|
2362
2468
|
const attachmentsCount = useMessage(({ message }) => {
|
@@ -2482,7 +2588,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
2482
2588
|
const { isRunning } = threadRuntime.getState();
|
2483
2589
|
if (!isRunning) {
|
2484
2590
|
e.preventDefault();
|
2485
|
-
_optionalChain([textareaRef, 'access',
|
2591
|
+
_optionalChain([textareaRef, 'access', _127 => _127.current, 'optionalAccess', _128 => _128.closest, 'call', _129 => _129("form"), 'optionalAccess', _130 => _130.requestSubmit, 'call', _131 => _131()]);
|
2486
2592
|
}
|
2487
2593
|
}
|
2488
2594
|
};
|
@@ -2556,11 +2662,11 @@ var getComponent2 = (components, attachment) => {
|
|
2556
2662
|
const type = attachment.type;
|
2557
2663
|
switch (type) {
|
2558
2664
|
case "image":
|
2559
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2665
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _132 => _132.Image]), () => ( _optionalChain([components, 'optionalAccess', _133 => _133.Attachment])));
|
2560
2666
|
case "document":
|
2561
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2667
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _134 => _134.Document]), () => ( _optionalChain([components, 'optionalAccess', _135 => _135.Attachment])));
|
2562
2668
|
case "file":
|
2563
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2669
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _136 => _136.File]), () => ( _optionalChain([components, 'optionalAccess', _137 => _137.Attachment])));
|
2564
2670
|
default:
|
2565
2671
|
const _exhaustiveCheck = type;
|
2566
2672
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
@@ -2583,7 +2689,7 @@ var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
2583
2689
|
};
|
2584
2690
|
var ComposerAttachment = _react.memo.call(void 0,
|
2585
2691
|
ComposerAttachmentImpl,
|
2586
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2692
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _138 => _138.components, 'optionalAccess', _139 => _139.Image]) === _optionalChain([next, 'access', _140 => _140.components, 'optionalAccess', _141 => _141.Image]) && _optionalChain([prev, 'access', _142 => _142.components, 'optionalAccess', _143 => _143.Document]) === _optionalChain([next, 'access', _144 => _144.components, 'optionalAccess', _145 => _145.Document]) && _optionalChain([prev, 'access', _146 => _146.components, 'optionalAccess', _147 => _147.File]) === _optionalChain([next, 'access', _148 => _148.components, 'optionalAccess', _149 => _149.File]) && _optionalChain([prev, 'access', _150 => _150.components, 'optionalAccess', _151 => _151.Attachment]) === _optionalChain([next, 'access', _152 => _152.components, 'optionalAccess', _153 => _153.Attachment])
|
2587
2693
|
);
|
2588
2694
|
var ComposerPrimitiveAttachments = ({ components }) => {
|
2589
2695
|
const attachmentsCount = useComposer((s) => s.attachments.length);
|
@@ -2927,45 +3033,60 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2927
3033
|
let first = true;
|
2928
3034
|
let cleanup;
|
2929
3035
|
const inner = () => {
|
2930
|
-
_optionalChain([cleanup, 'optionalCall',
|
2931
|
-
cleanup = runtime.
|
3036
|
+
_optionalChain([cleanup, 'optionalCall', _154 => _154()]);
|
3037
|
+
cleanup = runtime.threadManager.mainThread.subscribe(callback);
|
2932
3038
|
if (!first) {
|
2933
3039
|
callback();
|
2934
3040
|
}
|
2935
3041
|
first = false;
|
2936
3042
|
};
|
2937
|
-
const unsubscribe = runtime.subscribe(inner);
|
3043
|
+
const unsubscribe = runtime.threadManager.mainThread.subscribe(inner);
|
2938
3044
|
inner();
|
2939
3045
|
return () => {
|
2940
3046
|
unsubscribe();
|
2941
|
-
_optionalChain([cleanup, 'optionalCall',
|
3047
|
+
_optionalChain([cleanup, 'optionalCall', _155 => _155()]);
|
2942
3048
|
};
|
2943
3049
|
};
|
2944
3050
|
|
2945
3051
|
// src/runtimes/local/useLocalRuntime.tsx
|
2946
3052
|
|
2947
3053
|
|
2948
|
-
// src/
|
2949
|
-
var
|
2950
|
-
|
2951
|
-
|
2952
|
-
|
3054
|
+
// src/utils/ProxyConfigProvider.ts
|
3055
|
+
var ProxyConfigProvider = (_class5 = class {constructor() { _class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this); }
|
3056
|
+
__init9() {this._providers = /* @__PURE__ */ new Set()}
|
3057
|
+
getModelConfig() {
|
3058
|
+
return _chunkC6UZOY5Ajs.mergeModelConfigs.call(void 0, this._providers);
|
2953
3059
|
}
|
2954
|
-
|
2955
|
-
|
3060
|
+
registerModelConfigProvider(provider) {
|
3061
|
+
this._providers.add(provider);
|
3062
|
+
const unsubscribe = _optionalChain([provider, 'access', _156 => _156.subscribe, 'optionalCall', _157 => _157(() => {
|
3063
|
+
this.notifySubscribers();
|
3064
|
+
})]);
|
3065
|
+
this.notifySubscribers();
|
3066
|
+
return () => {
|
3067
|
+
this._providers.delete(provider);
|
3068
|
+
_optionalChain([unsubscribe, 'optionalCall', _158 => _158()]);
|
3069
|
+
this.notifySubscribers();
|
3070
|
+
};
|
2956
3071
|
}
|
2957
|
-
|
2958
|
-
|
2959
|
-
this.
|
3072
|
+
__init10() {this._subscribers = /* @__PURE__ */ new Set()}
|
3073
|
+
notifySubscribers() {
|
3074
|
+
for (const callback of this._subscribers) callback();
|
2960
3075
|
}
|
2961
|
-
__init10() {this._subscriptions = /* @__PURE__ */ new Set()}
|
2962
3076
|
subscribe(callback) {
|
2963
|
-
this.
|
2964
|
-
return () => this.
|
3077
|
+
this._subscribers.add(callback);
|
3078
|
+
return () => this._subscribers.delete(callback);
|
3079
|
+
}
|
3080
|
+
}, _class5);
|
3081
|
+
|
3082
|
+
// src/runtimes/core/BaseAssistantRuntimeCore.tsx
|
3083
|
+
var BaseAssistantRuntimeCore = (_class6 = class {
|
3084
|
+
__init11() {this._proxyConfigProvider = new ProxyConfigProvider()}
|
3085
|
+
constructor() {;_class6.prototype.__init11.call(this);
|
3086
|
+
}
|
3087
|
+
registerModelConfigProvider(provider) {
|
3088
|
+
return this._proxyConfigProvider.registerModelConfigProvider(provider);
|
2965
3089
|
}
|
2966
|
-
__init11() {this.subscriptionHandler = () => {
|
2967
|
-
for (const callback of this._subscriptions) callback();
|
2968
|
-
}}
|
2969
3090
|
}, _class6);
|
2970
3091
|
|
2971
3092
|
// src/internal.ts
|
@@ -2989,7 +3110,7 @@ var isAttachmentComplete = (a) => a.status.type === "complete";
|
|
2989
3110
|
var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototype.__init12.call(this);_class7.prototype.__init13.call(this);_class7.prototype.__init14.call(this);_class7.prototype.__init15.call(this); }
|
2990
3111
|
__init12() {this.isEditing = true}
|
2991
3112
|
getAttachmentAccept() {
|
2992
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
3113
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _159 => _159.getAttachmentAdapter, 'call', _160 => _160(), 'optionalAccess', _161 => _161.accept]), () => ( "*"));
|
2993
3114
|
}
|
2994
3115
|
__init13() {this._attachments = []}
|
2995
3116
|
set attachments(value) {
|
@@ -3021,7 +3142,7 @@ var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototyp
|
|
3021
3142
|
this.attachments.map(async (a) => {
|
3022
3143
|
if (isAttachmentComplete(a)) return a;
|
3023
3144
|
const result = await adapter.send(a);
|
3024
|
-
if (_optionalChain([result, 'access',
|
3145
|
+
if (_optionalChain([result, 'access', _162 => _162.status, 'optionalAccess', _163 => _163.type]) !== "complete") {
|
3025
3146
|
result.status = { type: "complete" };
|
3026
3147
|
}
|
3027
3148
|
return result;
|
@@ -3080,7 +3201,7 @@ var DefaultThreadComposerRuntimeCore = (_class8 = class extends BaseComposerRunt
|
|
3080
3201
|
return super.attachments;
|
3081
3202
|
}
|
3082
3203
|
getAttachmentAdapter() {
|
3083
|
-
return _optionalChain([this, 'access',
|
3204
|
+
return _optionalChain([this, 'access', _164 => _164.runtime, 'access', _165 => _165.adapters, 'optionalAccess', _166 => _166.attachments]);
|
3084
3205
|
}
|
3085
3206
|
connect() {
|
3086
3207
|
return this.runtime.subscribe(() => {
|
@@ -3093,7 +3214,7 @@ var DefaultThreadComposerRuntimeCore = (_class8 = class extends BaseComposerRunt
|
|
3093
3214
|
async handleSend(message) {
|
3094
3215
|
this.runtime.append({
|
3095
3216
|
...message,
|
3096
|
-
parentId: _nullishCoalesce(_optionalChain([this, 'access',
|
3217
|
+
parentId: _nullishCoalesce(_optionalChain([this, 'access', _167 => _167.runtime, 'access', _168 => _168.messages, 'access', _169 => _169.at, 'call', _170 => _170(-1), 'optionalAccess', _171 => _171.id]), () => ( null))
|
3097
3218
|
});
|
3098
3219
|
}
|
3099
3220
|
async cancel() {
|
@@ -3101,20 +3222,6 @@ var DefaultThreadComposerRuntimeCore = (_class8 = class extends BaseComposerRunt
|
|
3101
3222
|
}
|
3102
3223
|
}, _class8);
|
3103
3224
|
|
3104
|
-
// src/utils/ProxyConfigProvider.ts
|
3105
|
-
var ProxyConfigProvider = (_class9 = class {constructor() { _class9.prototype.__init17.call(this); }
|
3106
|
-
__init17() {this._providers = /* @__PURE__ */ new Set()}
|
3107
|
-
getModelConfig() {
|
3108
|
-
return _chunkCYIFAX4Ujs.mergeModelConfigs.call(void 0, this._providers);
|
3109
|
-
}
|
3110
|
-
registerModelConfigProvider(provider) {
|
3111
|
-
this._providers.add(provider);
|
3112
|
-
return () => {
|
3113
|
-
this._providers.delete(provider);
|
3114
|
-
};
|
3115
|
-
}
|
3116
|
-
}, _class9);
|
3117
|
-
|
3118
3225
|
// src/utils/idUtils.tsx
|
3119
3226
|
var _nonsecure = require('nanoid/non-secure');
|
3120
3227
|
var generateId = _nonsecure.customAlphabet.call(void 0,
|
@@ -3180,11 +3287,11 @@ var findHead = (message) => {
|
|
3180
3287
|
if ("current" in message) return message;
|
3181
3288
|
return null;
|
3182
3289
|
};
|
3183
|
-
var MessageRepository = (
|
3184
|
-
|
3290
|
+
var MessageRepository = (_class9 = class {constructor() { _class9.prototype.__init17.call(this);_class9.prototype.__init18.call(this);_class9.prototype.__init19.call(this); }
|
3291
|
+
__init17() {this.messages = /* @__PURE__ */ new Map()}
|
3185
3292
|
// message_id -> item
|
3186
|
-
|
3187
|
-
|
3293
|
+
__init18() {this.head = null}
|
3294
|
+
__init19() {this.root = {
|
3188
3295
|
children: [],
|
3189
3296
|
next: null
|
3190
3297
|
}}
|
@@ -3226,7 +3333,7 @@ var MessageRepository = (_class10 = class {constructor() { _class10.prototype.__
|
|
3226
3333
|
}
|
3227
3334
|
}
|
3228
3335
|
getMessages() {
|
3229
|
-
const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access',
|
3336
|
+
const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access', _172 => _172.head, 'optionalAccess', _173 => _173.level]), () => ( 0)));
|
3230
3337
|
for (let current = this.head; current; current = current.prev) {
|
3231
3338
|
messages2[current.level] = current.current;
|
3232
3339
|
}
|
@@ -3264,7 +3371,7 @@ var MessageRepository = (_class10 = class {constructor() { _class10.prototype.__
|
|
3264
3371
|
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
3265
3372
|
);
|
3266
3373
|
return {
|
3267
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3374
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _174 => _174.prev, 'optionalAccess', _175 => _175.current, 'access', _176 => _176.id]), () => ( null)),
|
3268
3375
|
message: message.current
|
3269
3376
|
};
|
3270
3377
|
}
|
@@ -3348,11 +3455,11 @@ var MessageRepository = (_class10 = class {constructor() { _class10.prototype.__
|
|
3348
3455
|
for (const [, message] of this.messages) {
|
3349
3456
|
exportItems.push({
|
3350
3457
|
message: message.current,
|
3351
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3458
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _177 => _177.prev, 'optionalAccess', _178 => _178.current, 'access', _179 => _179.id]), () => ( null))
|
3352
3459
|
});
|
3353
3460
|
}
|
3354
3461
|
return {
|
3355
|
-
headId: _nullishCoalesce(_optionalChain([this, 'access',
|
3462
|
+
headId: _nullishCoalesce(_optionalChain([this, 'access', _180 => _180.head, 'optionalAccess', _181 => _181.current, 'access', _182 => _182.id]), () => ( null)),
|
3356
3463
|
messages: exportItems
|
3357
3464
|
};
|
3358
3465
|
}
|
@@ -3360,9 +3467,9 @@ var MessageRepository = (_class10 = class {constructor() { _class10.prototype.__
|
|
3360
3467
|
for (const { message, parentId } of messages2) {
|
3361
3468
|
this.addOrUpdateMessage(parentId, message);
|
3362
3469
|
}
|
3363
|
-
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access',
|
3470
|
+
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access', _183 => _183.at, 'call', _184 => _184(-1), 'optionalAccess', _185 => _185.message, 'access', _186 => _186.id]))), () => ( null)));
|
3364
3471
|
}
|
3365
|
-
},
|
3472
|
+
}, _class9);
|
3366
3473
|
|
3367
3474
|
// src/ui/base/tooltip-icon-button.tsx
|
3368
3475
|
|
@@ -3464,7 +3571,7 @@ TooltipIconButton.displayName = "TooltipIconButton";
|
|
3464
3571
|
var toAppendMessage = (messages2, message) => {
|
3465
3572
|
if (typeof message === "string") {
|
3466
3573
|
return {
|
3467
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
3574
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _187 => _187.at, 'call', _188 => _188(-1), 'optionalAccess', _189 => _189.id]), () => ( null)),
|
3468
3575
|
role: "user",
|
3469
3576
|
content: [{ type: "text", text: message }],
|
3470
3577
|
attachments: []
|
@@ -3474,7 +3581,7 @@ var toAppendMessage = (messages2, message) => {
|
|
3474
3581
|
return message;
|
3475
3582
|
}
|
3476
3583
|
return {
|
3477
|
-
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access',
|
3584
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access', _190 => _190.at, 'call', _191 => _191(-1), 'optionalAccess', _192 => _192.id]))), () => ( null)),
|
3478
3585
|
role: _nullishCoalesce(message.role, () => ( "user")),
|
3479
3586
|
content: message.content,
|
3480
3587
|
attachments: _nullishCoalesce(message.attachments, () => ( []))
|
@@ -3486,15 +3593,17 @@ var getThreadState = (runtime) => {
|
|
3486
3593
|
threadId: runtime.threadId,
|
3487
3594
|
capabilities: runtime.capabilities,
|
3488
3595
|
isDisabled: runtime.isDisabled,
|
3489
|
-
isRunning: _optionalChain([lastMessage, 'optionalAccess',
|
3596
|
+
isRunning: _optionalChain([lastMessage, 'optionalAccess', _193 => _193.role]) !== "assistant" ? false : lastMessage.status.type === "running",
|
3490
3597
|
messages: runtime.messages,
|
3491
3598
|
suggestions: runtime.suggestions,
|
3492
3599
|
extras: runtime.extras,
|
3493
3600
|
speech: runtime.speech
|
3494
3601
|
});
|
3495
3602
|
};
|
3496
|
-
var ThreadRuntimeImpl = (
|
3497
|
-
|
3603
|
+
var ThreadRuntimeImpl = (_class10 = class {
|
3604
|
+
get path() {
|
3605
|
+
return this._threadBinding.path;
|
3606
|
+
}
|
3498
3607
|
/**
|
3499
3608
|
* @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
|
3500
3609
|
*/
|
@@ -3547,24 +3656,32 @@ var ThreadRuntimeImpl = (_class11 = class {
|
|
3547
3656
|
return this._threadBinding.getState();
|
3548
3657
|
}
|
3549
3658
|
|
3550
|
-
constructor(threadBinding) {;
|
3659
|
+
constructor(threadBinding) {;_class10.prototype.__init20.call(this);
|
3551
3660
|
const stateBinding = new LazyMemoizeSubject({
|
3661
|
+
path: threadBinding.path,
|
3552
3662
|
getState: () => getThreadState(threadBinding.getState()),
|
3553
3663
|
subscribe: (callback) => threadBinding.subscribe(callback)
|
3554
3664
|
});
|
3555
3665
|
this._threadBinding = {
|
3666
|
+
path: threadBinding.path,
|
3556
3667
|
getState: () => threadBinding.getState(),
|
3557
3668
|
getStateState: () => stateBinding.getState(),
|
3558
3669
|
outerSubscribe: (callback) => threadBinding.outerSubscribe(callback),
|
3559
3670
|
subscribe: (callback) => threadBinding.subscribe(callback)
|
3560
3671
|
};
|
3672
|
+
this.composer = new ThreadComposerRuntimeImpl(
|
3673
|
+
new NestedSubscriptionSubject({
|
3674
|
+
path: {
|
3675
|
+
...this.path,
|
3676
|
+
ref: this.path.ref + `${this.path.ref}.composer`,
|
3677
|
+
composerSource: "thread"
|
3678
|
+
},
|
3679
|
+
getState: () => this._threadBinding.getState().composer,
|
3680
|
+
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
3681
|
+
})
|
3682
|
+
);
|
3561
3683
|
}
|
3562
|
-
|
3563
|
-
new NestedSubscriptionSubject({
|
3564
|
-
getState: () => this._threadBinding.getState().composer,
|
3565
|
-
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
3566
|
-
})
|
3567
|
-
)}
|
3684
|
+
|
3568
3685
|
getState() {
|
3569
3686
|
return this._threadBinding.getStateState();
|
3570
3687
|
}
|
@@ -3642,37 +3759,67 @@ var ThreadRuntimeImpl = (_class11 = class {
|
|
3642
3759
|
}
|
3643
3760
|
getMesssageByIndex(idx) {
|
3644
3761
|
if (idx < 0) throw new Error("Message index must be >= 0");
|
3762
|
+
return this._getMessageRuntime(
|
3763
|
+
{
|
3764
|
+
...this.path,
|
3765
|
+
ref: this.path.ref + `${this.path.ref}.messages[${idx}]`,
|
3766
|
+
messageSelector: { type: "index", index: idx }
|
3767
|
+
},
|
3768
|
+
() => {
|
3769
|
+
const messages2 = this._threadBinding.getState().messages;
|
3770
|
+
const message = messages2[idx];
|
3771
|
+
if (!message) return void 0;
|
3772
|
+
return {
|
3773
|
+
message,
|
3774
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _194 => _194[idx - 1], 'optionalAccess', _195 => _195.id]), () => ( null))
|
3775
|
+
};
|
3776
|
+
}
|
3777
|
+
);
|
3778
|
+
}
|
3779
|
+
getMesssageById(messageId) {
|
3780
|
+
return this._getMessageRuntime(
|
3781
|
+
{
|
3782
|
+
...this.path,
|
3783
|
+
ref: this.path.ref + `${this.path.ref}.messages[messageId=${JSON.stringify(messageId)}]`,
|
3784
|
+
messageSelector: { type: "messageId", messageId }
|
3785
|
+
},
|
3786
|
+
() => this._threadBinding.getState().getMessageById(messageId)
|
3787
|
+
);
|
3788
|
+
}
|
3789
|
+
_getMessageRuntime(path, callback) {
|
3645
3790
|
return new MessageRuntimeImpl(
|
3646
3791
|
new ShallowMemoizeSubject({
|
3792
|
+
path,
|
3647
3793
|
getState: () => {
|
3648
|
-
const {
|
3649
|
-
const
|
3650
|
-
if (!message) return SKIP_UPDATE;
|
3794
|
+
const { message, parentId } = _nullishCoalesce(callback(), () => ( {}));
|
3795
|
+
const { messages: messages2, speech: speechState } = this._threadBinding.getState();
|
3796
|
+
if (!message || parentId === void 0) return SKIP_UPDATE;
|
3651
3797
|
const thread = this._threadBinding.getState();
|
3652
3798
|
const branches = thread.getBranches(message.id);
|
3653
3799
|
const submittedFeedback = thread.getSubmittedFeedback(message.id);
|
3654
3800
|
return {
|
3655
3801
|
...message,
|
3656
3802
|
message,
|
3657
|
-
isLast:
|
3658
|
-
parentId
|
3803
|
+
isLast: _optionalChain([messages2, 'access', _196 => _196.at, 'call', _197 => _197(-1), 'optionalAccess', _198 => _198.id]) === message.id,
|
3804
|
+
parentId,
|
3659
3805
|
branches,
|
3660
3806
|
branchNumber: branches.indexOf(message.id) + 1,
|
3661
3807
|
branchCount: branches.length,
|
3662
|
-
speech: _optionalChain([speechState, 'optionalAccess',
|
3808
|
+
speech: _optionalChain([speechState, 'optionalAccess', _199 => _199.messageId]) === message.id ? speechState : void 0,
|
3663
3809
|
submittedFeedback
|
3664
3810
|
};
|
3665
3811
|
},
|
3666
|
-
subscribe: (
|
3812
|
+
subscribe: (callback2) => this._threadBinding.subscribe(callback2)
|
3667
3813
|
}),
|
3668
3814
|
this._threadBinding
|
3669
3815
|
);
|
3670
3816
|
}
|
3671
|
-
|
3817
|
+
__init20() {this._eventListenerNestedSubscriptions = /* @__PURE__ */ new Map()}
|
3672
3818
|
unstable_on(event, callback) {
|
3673
3819
|
let subject = this._eventListenerNestedSubscriptions.get(event);
|
3674
3820
|
if (!subject) {
|
3675
3821
|
subject = new NestedSubscriptionSubject({
|
3822
|
+
path: this.path,
|
3676
3823
|
getState: () => ({
|
3677
3824
|
subscribe: (callback2) => this._threadBinding.getState().unstable_on(event, callback2)
|
3678
3825
|
}),
|
@@ -3682,45 +3829,96 @@ var ThreadRuntimeImpl = (_class11 = class {
|
|
3682
3829
|
}
|
3683
3830
|
return subject.subscribe(callback);
|
3684
3831
|
}
|
3685
|
-
},
|
3832
|
+
}, _class10);
|
3833
|
+
|
3834
|
+
// src/api/ThreadManagerRuntime.ts
|
3835
|
+
var getThreadManagerState = (threadManager) => {
|
3836
|
+
return {
|
3837
|
+
threads: threadManager.threads,
|
3838
|
+
archivedThreads: threadManager.archivedThreads
|
3839
|
+
};
|
3840
|
+
};
|
3841
|
+
var THREAD_MANAGER_PATH = {
|
3842
|
+
ref: "threadManager"
|
3843
|
+
};
|
3844
|
+
var ThreadManagerRuntimeImpl = class {
|
3845
|
+
constructor(_core) {
|
3846
|
+
this._core = _core;
|
3847
|
+
const stateBinding = new LazyMemoizeSubject({
|
3848
|
+
path: THREAD_MANAGER_PATH,
|
3849
|
+
getState: () => getThreadManagerState(_core),
|
3850
|
+
subscribe: (callback) => _core.subscribe(callback)
|
3851
|
+
});
|
3852
|
+
this._getState = stateBinding.getState.bind(stateBinding);
|
3853
|
+
}
|
3854
|
+
get path() {
|
3855
|
+
return THREAD_MANAGER_PATH;
|
3856
|
+
}
|
3857
|
+
|
3858
|
+
getState() {
|
3859
|
+
return this._getState();
|
3860
|
+
}
|
3861
|
+
rename(threadId, newTitle) {
|
3862
|
+
return this._core.rename(threadId, newTitle);
|
3863
|
+
}
|
3864
|
+
archive(threadId) {
|
3865
|
+
return this._core.archive(threadId);
|
3866
|
+
}
|
3867
|
+
unarchive(threadId) {
|
3868
|
+
return this._core.unarchive(threadId);
|
3869
|
+
}
|
3870
|
+
delete(threadId) {
|
3871
|
+
return this._core.delete(threadId);
|
3872
|
+
}
|
3873
|
+
subscribe(callback) {
|
3874
|
+
return this._core.subscribe(callback);
|
3875
|
+
}
|
3876
|
+
};
|
3686
3877
|
|
3687
3878
|
// src/api/AssistantRuntime.ts
|
3688
3879
|
var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
|
3689
3880
|
constructor(_core, _thread) {
|
3690
3881
|
this._core = _core;
|
3691
3882
|
this._thread = _thread;
|
3883
|
+
this.threadManager = new ThreadManagerRuntimeImpl(_core.threadManager);
|
3692
3884
|
}
|
3885
|
+
|
3693
3886
|
get thread() {
|
3694
3887
|
return this._thread;
|
3695
3888
|
}
|
3696
3889
|
switchToNewThread() {
|
3697
|
-
return this._core.switchToNewThread();
|
3890
|
+
return this._core.threadManager.switchToNewThread();
|
3698
3891
|
}
|
3699
3892
|
switchToThread(threadId) {
|
3700
|
-
return this.
|
3893
|
+
if (threadId === null) return this.switchToNewThread();
|
3894
|
+
return this._core.threadManager.switchToThread(threadId);
|
3701
3895
|
}
|
3702
3896
|
registerModelConfigProvider(provider) {
|
3703
3897
|
return this._core.registerModelConfigProvider(provider);
|
3704
3898
|
}
|
3705
|
-
// TODO events for thread switching
|
3706
3899
|
/**
|
3707
3900
|
* @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
|
3708
3901
|
*/
|
3709
|
-
subscribe(
|
3710
|
-
return
|
3902
|
+
subscribe() {
|
3903
|
+
return () => {
|
3904
|
+
};
|
3711
3905
|
}
|
3712
|
-
static
|
3906
|
+
static createMainThreadRuntime(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
|
3713
3907
|
return new CustomThreadRuntime(
|
3714
3908
|
new NestedSubscriptionSubject({
|
3715
|
-
|
3716
|
-
|
3909
|
+
path: {
|
3910
|
+
ref: "threads.main",
|
3911
|
+
threadSelector: { type: "main" }
|
3912
|
+
},
|
3913
|
+
getState: () => _core.threadManager.mainThread,
|
3914
|
+
subscribe: (callback) => _core.threadManager.subscribe(callback)
|
3717
3915
|
})
|
3718
3916
|
);
|
3719
3917
|
}
|
3720
3918
|
static create(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
|
3721
3919
|
return new _AssistantRuntimeImpl(
|
3722
3920
|
_core,
|
3723
|
-
_AssistantRuntimeImpl.
|
3921
|
+
_AssistantRuntimeImpl.createMainThreadRuntime(_core, CustomThreadRuntime)
|
3724
3922
|
);
|
3725
3923
|
}
|
3726
3924
|
};
|
@@ -3791,7 +3989,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
|
3791
3989
|
});
|
3792
3990
|
if (mergeSteps) {
|
3793
3991
|
const previousMessage = messages2[messages2.length - 1];
|
3794
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
3992
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _200 => _200.role]) === "assistant") {
|
3795
3993
|
previousMessage.content.push(...newContent);
|
3796
3994
|
break;
|
3797
3995
|
}
|
@@ -3804,7 +4002,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
|
3804
4002
|
}
|
3805
4003
|
case "tool": {
|
3806
4004
|
const previousMessage = messages2[messages2.length - 1];
|
3807
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
4005
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _201 => _201.role]) !== "assistant")
|
3808
4006
|
throw new Error(
|
3809
4007
|
"A tool message must be preceded by an assistant message."
|
3810
4008
|
);
|
@@ -3880,14 +4078,14 @@ function streamPartDecoderStream() {
|
|
3880
4078
|
controller.enqueue(decodeStreamPart(chunk));
|
3881
4079
|
}
|
3882
4080
|
});
|
3883
|
-
return new (0,
|
4081
|
+
return new (0, _chunkC6UZOY5Ajs.PipeableTransformStream)((readable) => {
|
3884
4082
|
return readable.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(decodeStream);
|
3885
4083
|
});
|
3886
4084
|
}
|
3887
4085
|
|
3888
4086
|
// src/runtimes/edge/streams/utils/index.ts
|
3889
4087
|
var streamUtils = {
|
3890
|
-
streamPartEncoderStream:
|
4088
|
+
streamPartEncoderStream: _chunkC6UZOY5Ajs.streamPartEncoderStream,
|
3891
4089
|
streamPartDecoderStream
|
3892
4090
|
};
|
3893
4091
|
|
@@ -3934,7 +4132,7 @@ function assistantDecoderStream() {
|
|
3934
4132
|
case "c" /* ToolCallDelta */: {
|
3935
4133
|
const { toolCallId, argsTextDelta } = value;
|
3936
4134
|
const toolName = toolCallNames.get(toolCallId);
|
3937
|
-
if (_optionalChain([currentToolCall, 'optionalAccess',
|
4135
|
+
if (_optionalChain([currentToolCall, 'optionalAccess', _202 => _202.id]) === toolCallId) {
|
3938
4136
|
currentToolCall.argsText += argsTextDelta;
|
3939
4137
|
}
|
3940
4138
|
controller.enqueue({
|
@@ -4035,8 +4233,8 @@ var EdgeChatAdapter = class {
|
|
4035
4233
|
credentials: _nullishCoalesce(this.options.credentials, () => ( "same-origin")),
|
4036
4234
|
body: JSON.stringify({
|
4037
4235
|
system: config.system,
|
4038
|
-
messages:
|
4039
|
-
tools: config.tools ?
|
4236
|
+
messages: _chunkC6UZOY5Ajs.toCoreMessages.call(void 0, messages2),
|
4237
|
+
tools: config.tools ? _chunkC6UZOY5Ajs.toLanguageModelTools.call(void 0, config.tools) : [],
|
4040
4238
|
...config.callSettings,
|
4041
4239
|
...config.config,
|
4042
4240
|
...this.options.body
|
@@ -4046,7 +4244,7 @@ var EdgeChatAdapter = class {
|
|
4046
4244
|
if (!result.ok) {
|
4047
4245
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
4048
4246
|
}
|
4049
|
-
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(
|
4247
|
+
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkC6UZOY5Ajs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkC6UZOY5Ajs.runResultStream.call(void 0, ));
|
4050
4248
|
let update;
|
4051
4249
|
for await (update of asAsyncIterable(stream)) {
|
4052
4250
|
yield update;
|
@@ -4078,7 +4276,7 @@ var useEdgeRuntime = (options) => {
|
|
4078
4276
|
};
|
4079
4277
|
|
4080
4278
|
// src/runtimes/local/shouldContinue.tsx
|
4081
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
4279
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _203 => _203.status, 'optionalAccess', _204 => _204.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
4082
4280
|
|
4083
4281
|
// src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
|
4084
4282
|
var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
@@ -4098,7 +4296,7 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
4098
4296
|
return true;
|
4099
4297
|
}
|
4100
4298
|
getAttachmentAdapter() {
|
4101
|
-
return _optionalChain([this, 'access',
|
4299
|
+
return _optionalChain([this, 'access', _205 => _205.runtime, 'access', _206 => _206.adapters, 'optionalAccess', _207 => _207.attachments]);
|
4102
4300
|
}
|
4103
4301
|
|
4104
4302
|
|
@@ -4122,20 +4320,20 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
4122
4320
|
};
|
4123
4321
|
|
4124
4322
|
// src/runtimes/core/BaseThreadRuntimeCore.tsx
|
4125
|
-
var BaseThreadRuntimeCore = (
|
4126
|
-
constructor(configProvider) {;
|
4323
|
+
var BaseThreadRuntimeCore = (_class11 = class {
|
4324
|
+
constructor(configProvider) {;_class11.prototype.__init21.call(this);_class11.prototype.__init22.call(this);_class11.prototype.__init23.call(this);_class11.prototype.__init24.call(this);_class11.prototype.__init25.call(this);_class11.prototype.__init26.call(this);
|
4127
4325
|
this.configProvider = configProvider;
|
4128
4326
|
}
|
4129
|
-
|
4130
|
-
|
4327
|
+
__init21() {this._subscriptions = /* @__PURE__ */ new Set()}
|
4328
|
+
__init22() {this.repository = new MessageRepository()}
|
4131
4329
|
get messages() {
|
4132
4330
|
return this.repository.getMessages();
|
4133
4331
|
}
|
4134
|
-
|
4332
|
+
__init23() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
4135
4333
|
getModelConfig() {
|
4136
4334
|
return this.configProvider.getModelConfig();
|
4137
4335
|
}
|
4138
|
-
|
4336
|
+
__init24() {this._editComposers = /* @__PURE__ */ new Map()}
|
4139
4337
|
getEditComposer(messageId) {
|
4140
4338
|
return this._editComposers.get(messageId);
|
4141
4339
|
}
|
@@ -4152,6 +4350,9 @@ var BaseThreadRuntimeCore = (_class12 = class {
|
|
4152
4350
|
);
|
4153
4351
|
this._notifySubscribers();
|
4154
4352
|
}
|
4353
|
+
getMessageById(messageId) {
|
4354
|
+
return this.repository.getMessage(messageId);
|
4355
|
+
}
|
4155
4356
|
getBranches(messageId) {
|
4156
4357
|
return this.repository.getBranches(messageId);
|
4157
4358
|
}
|
@@ -4171,12 +4372,12 @@ var BaseThreadRuntimeCore = (_class12 = class {
|
|
4171
4372
|
this._subscriptions.add(callback);
|
4172
4373
|
return () => this._subscriptions.delete(callback);
|
4173
4374
|
}
|
4174
|
-
|
4375
|
+
__init25() {this._submittedFeedback = {}}
|
4175
4376
|
getSubmittedFeedback(messageId) {
|
4176
4377
|
return this._submittedFeedback[messageId];
|
4177
4378
|
}
|
4178
4379
|
submitFeedback({ messageId, type }) {
|
4179
|
-
const adapter = _optionalChain([this, 'access',
|
4380
|
+
const adapter = _optionalChain([this, 'access', _208 => _208.adapters, 'optionalAccess', _209 => _209.feedback]);
|
4180
4381
|
if (!adapter) throw new Error("Feedback adapter not configured");
|
4181
4382
|
const { message } = this.repository.getMessage(messageId);
|
4182
4383
|
adapter.submit({ message, type });
|
@@ -4186,11 +4387,11 @@ var BaseThreadRuntimeCore = (_class12 = class {
|
|
4186
4387
|
|
4187
4388
|
|
4188
4389
|
speak(messageId) {
|
4189
|
-
const adapter = _optionalChain([this, 'access',
|
4390
|
+
const adapter = _optionalChain([this, 'access', _210 => _210.adapters, 'optionalAccess', _211 => _211.speech]);
|
4190
4391
|
if (!adapter) throw new Error("Speech adapter not configured");
|
4191
4392
|
const { message } = this.repository.getMessage(messageId);
|
4192
|
-
_optionalChain([this, 'access',
|
4193
|
-
const utterance = adapter.speak(message);
|
4393
|
+
_optionalChain([this, 'access', _212 => _212._stopSpeaking, 'optionalCall', _213 => _213()]);
|
4394
|
+
const utterance = adapter.speak(getThreadMessageText(message));
|
4194
4395
|
const unsub = utterance.subscribe(() => {
|
4195
4396
|
if (utterance.status.type === "ended") {
|
4196
4397
|
this._stopSpeaking = void 0;
|
@@ -4221,8 +4422,12 @@ var BaseThreadRuntimeCore = (_class12 = class {
|
|
4221
4422
|
this.repository.import(data);
|
4222
4423
|
this._notifySubscribers();
|
4223
4424
|
}
|
4224
|
-
|
4425
|
+
__init26() {this._eventSubscribers = /* @__PURE__ */ new Map()}
|
4225
4426
|
unstable_on(event, callback) {
|
4427
|
+
if (event === "model-config-update") {
|
4428
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _214 => _214.configProvider, 'access', _215 => _215.subscribe, 'optionalCall', _216 => _216(callback)]), () => ( (() => {
|
4429
|
+
})));
|
4430
|
+
}
|
4226
4431
|
const subscribers = this._eventSubscribers.get(event);
|
4227
4432
|
if (!subscribers) {
|
4228
4433
|
this._eventSubscribers.set(event, /* @__PURE__ */ new Set([callback]));
|
@@ -4234,25 +4439,16 @@ var BaseThreadRuntimeCore = (_class12 = class {
|
|
4234
4439
|
subscribers2.delete(callback);
|
4235
4440
|
};
|
4236
4441
|
}
|
4237
|
-
},
|
4442
|
+
}, _class11);
|
4238
4443
|
|
4239
4444
|
// src/runtimes/local/LocalThreadRuntimeCore.tsx
|
4240
|
-
var LocalThreadRuntimeCore = (
|
4241
|
-
constructor(configProvider,
|
4242
|
-
super(configProvider);
|
4243
|
-
this.
|
4244
|
-
this.
|
4245
|
-
this.options = options;
|
4246
|
-
if (initialMessages) {
|
4247
|
-
let parentId = null;
|
4248
|
-
const messages2 = fromCoreMessages(initialMessages);
|
4249
|
-
for (const message of messages2) {
|
4250
|
-
this.repository.addOrUpdateMessage(parentId, message);
|
4251
|
-
parentId = message.id;
|
4252
|
-
}
|
4253
|
-
}
|
4445
|
+
var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
|
4446
|
+
constructor(configProvider, threadId, options) {
|
4447
|
+
super(configProvider);_class12.prototype.__init27.call(this);_class12.prototype.__init28.call(this);_class12.prototype.__init29.call(this);_class12.prototype.__init30.call(this);;
|
4448
|
+
this.threadId = threadId;
|
4449
|
+
this._options = options;
|
4254
4450
|
}
|
4255
|
-
|
4451
|
+
__init27() {this.capabilities = {
|
4256
4452
|
switchToBranch: true,
|
4257
4453
|
edit: true,
|
4258
4454
|
reload: true,
|
@@ -4262,34 +4458,31 @@ var LocalThreadRuntimeCore = (_class13 = class extends BaseThreadRuntimeCore {
|
|
4262
4458
|
attachments: false,
|
4263
4459
|
feedback: false
|
4264
4460
|
}}
|
4265
|
-
|
4266
|
-
|
4267
|
-
|
4268
|
-
__init32() {this.suggestions = []}
|
4461
|
+
__init28() {this.abortController = null}
|
4462
|
+
__init29() {this.isDisabled = false}
|
4463
|
+
__init30() {this.suggestions = []}
|
4269
4464
|
get adapters() {
|
4270
|
-
return this.
|
4465
|
+
return this._options.adapters;
|
4271
4466
|
}
|
4272
4467
|
|
4273
|
-
get options() {
|
4274
|
-
return this._options;
|
4275
|
-
}
|
4276
4468
|
get extras() {
|
4277
4469
|
return void 0;
|
4278
4470
|
}
|
4279
|
-
|
4471
|
+
setOptions(options) {
|
4472
|
+
if (this._options === options) return;
|
4280
4473
|
this._options = options;
|
4281
4474
|
let hasUpdates = false;
|
4282
|
-
const canSpeak = _optionalChain([options, 'access',
|
4475
|
+
const canSpeak = _optionalChain([options, 'access', _217 => _217.adapters, 'optionalAccess', _218 => _218.speech]) !== void 0;
|
4283
4476
|
if (this.capabilities.speech !== canSpeak) {
|
4284
4477
|
this.capabilities.speech = canSpeak;
|
4285
4478
|
hasUpdates = true;
|
4286
4479
|
}
|
4287
|
-
const canAttach = _optionalChain([options, 'access',
|
4480
|
+
const canAttach = _optionalChain([options, 'access', _219 => _219.adapters, 'optionalAccess', _220 => _220.attachments]) !== void 0;
|
4288
4481
|
if (this.capabilities.attachments !== canAttach) {
|
4289
4482
|
this.capabilities.attachments = canAttach;
|
4290
4483
|
hasUpdates = true;
|
4291
4484
|
}
|
4292
|
-
const canFeedback = _optionalChain([options, 'access',
|
4485
|
+
const canFeedback = _optionalChain([options, 'access', _221 => _221.adapters, 'optionalAccess', _222 => _222.feedback]) !== void 0;
|
4293
4486
|
if (this.capabilities.feedback !== canFeedback) {
|
4294
4487
|
this.capabilities.feedback = canFeedback;
|
4295
4488
|
hasUpdates = true;
|
@@ -4325,13 +4518,13 @@ var LocalThreadRuntimeCore = (_class13 = class extends BaseThreadRuntimeCore {
|
|
4325
4518
|
}
|
4326
4519
|
async performRoundtrip(parentId, message) {
|
4327
4520
|
const messages2 = this.repository.getMessages();
|
4328
|
-
_optionalChain([this, 'access',
|
4521
|
+
_optionalChain([this, 'access', _223 => _223.abortController, 'optionalAccess', _224 => _224.abort, 'call', _225 => _225()]);
|
4329
4522
|
this.abortController = new AbortController();
|
4330
4523
|
const initialContent = message.content;
|
4331
|
-
const initialSteps = _optionalChain([message, 'access',
|
4332
|
-
const initalCustom = _optionalChain([message, 'access',
|
4524
|
+
const initialSteps = _optionalChain([message, 'access', _226 => _226.metadata, 'optionalAccess', _227 => _227.steps]);
|
4525
|
+
const initalCustom = _optionalChain([message, 'access', _228 => _228.metadata, 'optionalAccess', _229 => _229.custom]);
|
4333
4526
|
const updateMessage = (m) => {
|
4334
|
-
const newSteps = _optionalChain([m, 'access',
|
4527
|
+
const newSteps = _optionalChain([m, 'access', _230 => _230.metadata, 'optionalAccess', _231 => _231.steps]) || _optionalChain([m, 'access', _232 => _232.metadata, 'optionalAccess', _233 => _233.roundtrips]);
|
4335
4528
|
const steps2 = newSteps ? [..._nullishCoalesce(initialSteps, () => ( [])), ...newSteps] : void 0;
|
4336
4529
|
message = {
|
4337
4530
|
...message,
|
@@ -4343,7 +4536,7 @@ var LocalThreadRuntimeCore = (_class13 = class extends BaseThreadRuntimeCore {
|
|
4343
4536
|
metadata: {
|
4344
4537
|
...message.metadata,
|
4345
4538
|
...steps2 ? { roundtrips: steps2, steps: steps2 } : void 0,
|
4346
|
-
..._optionalChain([m, 'access',
|
4539
|
+
..._optionalChain([m, 'access', _234 => _234.metadata, 'optionalAccess', _235 => _235.custom]) ? {
|
4347
4540
|
custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
|
4348
4541
|
} : void 0
|
4349
4542
|
}
|
@@ -4352,8 +4545,8 @@ var LocalThreadRuntimeCore = (_class13 = class extends BaseThreadRuntimeCore {
|
|
4352
4545
|
this.repository.addOrUpdateMessage(parentId, message);
|
4353
4546
|
this._notifySubscribers();
|
4354
4547
|
};
|
4355
|
-
const maxSteps = this.
|
4356
|
-
const steps = _nullishCoalesce(_optionalChain([message, 'access',
|
4548
|
+
const maxSteps = this._options.maxSteps ? this._options.maxSteps : (_nullishCoalesce(this._options.maxToolRoundtrips, () => ( 1))) + 1;
|
4549
|
+
const steps = _nullishCoalesce(_optionalChain([message, 'access', _236 => _236.metadata, 'optionalAccess', _237 => _237.steps, 'optionalAccess', _238 => _238.length]), () => ( 0));
|
4357
4550
|
if (steps >= maxSteps) {
|
4358
4551
|
updateMessage({
|
4359
4552
|
status: {
|
@@ -4370,7 +4563,7 @@ var LocalThreadRuntimeCore = (_class13 = class extends BaseThreadRuntimeCore {
|
|
4370
4563
|
});
|
4371
4564
|
}
|
4372
4565
|
try {
|
4373
|
-
const promiseOrGenerator = this.
|
4566
|
+
const promiseOrGenerator = this.adapters.chatModel.run({
|
4374
4567
|
messages: messages2,
|
4375
4568
|
abortSignal: this.abortController.signal,
|
4376
4569
|
config: this.getModelConfig(),
|
@@ -4405,7 +4598,7 @@ var LocalThreadRuntimeCore = (_class13 = class extends BaseThreadRuntimeCore {
|
|
4405
4598
|
return message;
|
4406
4599
|
}
|
4407
4600
|
cancelRun() {
|
4408
|
-
_optionalChain([this, 'access',
|
4601
|
+
_optionalChain([this, 'access', _239 => _239.abortController, 'optionalAccess', _240 => _240.abort, 'call', _241 => _241()]);
|
4409
4602
|
this.abortController = null;
|
4410
4603
|
}
|
4411
4604
|
addToolResult({
|
@@ -4441,46 +4634,156 @@ var LocalThreadRuntimeCore = (_class13 = class extends BaseThreadRuntimeCore {
|
|
4441
4634
|
this.performRoundtrip(parentId, message);
|
4442
4635
|
}
|
4443
4636
|
}
|
4444
|
-
},
|
4637
|
+
}, _class12);
|
4445
4638
|
|
4446
|
-
// src/runtimes/local/
|
4447
|
-
var
|
4639
|
+
// src/runtimes/local/LocalThreadManagerRuntimeCore.tsx
|
4640
|
+
var LocalThreadManagerRuntimeCore = (_class13 = class {
|
4641
|
+
constructor(_threadFactory) {;_class13.prototype.__init31.call(this);_class13.prototype.__init32.call(this);_class13.prototype.__init33.call(this);_class13.prototype.__init34.call(this);
|
4642
|
+
this._threadFactory = _threadFactory;
|
4643
|
+
this._mainThread = this._threadFactory(generateId(), { messages: [] });
|
4644
|
+
}
|
4645
|
+
__init31() {this._threadData = /* @__PURE__ */ new Map()}
|
4646
|
+
__init32() {this._threads = []}
|
4647
|
+
__init33() {this._archivedThreads = []}
|
4648
|
+
get threads() {
|
4649
|
+
return this._threads;
|
4650
|
+
}
|
4651
|
+
get archivedThreads() {
|
4652
|
+
return this._archivedThreads;
|
4653
|
+
}
|
4448
4654
|
|
4449
|
-
|
4450
|
-
|
4451
|
-
super(new LocalThreadRuntimeCore(proxyConfigProvider, adapter, options));
|
4452
|
-
this._proxyConfigProvider = proxyConfigProvider;
|
4655
|
+
get mainThread() {
|
4656
|
+
return this._mainThread;
|
4453
4657
|
}
|
4454
|
-
|
4455
|
-
|
4658
|
+
switchToThread(threadId) {
|
4659
|
+
if (this._mainThread.threadId === threadId) return;
|
4660
|
+
const data = this._threadData.get(threadId);
|
4661
|
+
if (!data) throw new Error("Thread not found");
|
4662
|
+
const thread = this._threadFactory(threadId, data.data);
|
4663
|
+
this._performThreadSwitch(thread);
|
4456
4664
|
}
|
4457
4665
|
switchToNewThread() {
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4462
|
-
|
4463
|
-
)
|
4464
|
-
|
4666
|
+
if (!this._mainThread) return;
|
4667
|
+
const thread = this._threadFactory(generateId(), { messages: [] });
|
4668
|
+
this._performThreadSwitch(thread);
|
4669
|
+
}
|
4670
|
+
_performThreadSwitch(newThreadCore) {
|
4671
|
+
if (this._mainThread) {
|
4672
|
+
const data = this._threadData.get(this._mainThread.threadId);
|
4673
|
+
if (!data) throw new Error("Thread not found");
|
4674
|
+
const exprt = this._mainThread.export();
|
4675
|
+
data.data = exprt;
|
4676
|
+
}
|
4677
|
+
this._mainThread._notifyEventSubscribers("switched-away");
|
4678
|
+
this._mainThread = newThreadCore;
|
4679
|
+
newThreadCore._notifyEventSubscribers("switched-to");
|
4680
|
+
this._notifySubscribers();
|
4465
4681
|
}
|
4466
|
-
|
4467
|
-
|
4468
|
-
|
4682
|
+
_performMoveOp(threadId, operation) {
|
4683
|
+
const data = this._threadData.get(threadId);
|
4684
|
+
if (!data) throw new Error("Thread not found");
|
4685
|
+
if (operation === "archive" && data.isArchived) return;
|
4686
|
+
if (operation === "unarchive" && !data.isArchived) return;
|
4687
|
+
if (operation === "archive") {
|
4688
|
+
data.isArchived = true;
|
4689
|
+
this._archivedThreads = [...this._archivedThreads, data.metadata];
|
4690
|
+
}
|
4691
|
+
if (operation === "unarchive") {
|
4692
|
+
data.isArchived = false;
|
4693
|
+
this._threads = [...this._threads, data.metadata];
|
4694
|
+
}
|
4695
|
+
if (operation === "delete") {
|
4696
|
+
this._threadData.delete(threadId);
|
4697
|
+
}
|
4698
|
+
if (operation === "archive" || operation === "delete" && data.isArchived) {
|
4699
|
+
this._archivedThreads = this._archivedThreads.filter(
|
4700
|
+
(t) => t.threadId !== threadId
|
4701
|
+
);
|
4702
|
+
}
|
4703
|
+
if (operation === "unarchive" || operation === "delete" && !data.isArchived) {
|
4704
|
+
this._threads = this._threads.filter((t) => t.threadId !== threadId);
|
4469
4705
|
}
|
4470
|
-
this.
|
4706
|
+
this._notifySubscribers();
|
4707
|
+
}
|
4708
|
+
async rename(threadId, newTitle) {
|
4709
|
+
const data = this._threadData.get(threadId);
|
4710
|
+
if (!data) throw new Error("Thread not found");
|
4711
|
+
data.metadata = {
|
4712
|
+
...data.metadata,
|
4713
|
+
title: newTitle
|
4714
|
+
};
|
4715
|
+
const threadList = data.isArchived ? this.archivedThreads : this.threads;
|
4716
|
+
const idx = threadList.findIndex((t) => t.threadId === threadId);
|
4717
|
+
const updatedThreadList = threadList.toSpliced(idx, 1, data.metadata);
|
4718
|
+
if (data.isArchived) {
|
4719
|
+
this._archivedThreads = updatedThreadList;
|
4720
|
+
} else {
|
4721
|
+
this._threads = updatedThreadList;
|
4722
|
+
}
|
4723
|
+
this._notifySubscribers();
|
4724
|
+
}
|
4725
|
+
async archive(threadId) {
|
4726
|
+
this._performMoveOp(threadId, "archive");
|
4727
|
+
}
|
4728
|
+
async unarchive(threadId) {
|
4729
|
+
this._performMoveOp(threadId, "unarchive");
|
4730
|
+
}
|
4731
|
+
async delete(threadId) {
|
4732
|
+
this._performMoveOp(threadId, "delete");
|
4733
|
+
}
|
4734
|
+
__init34() {this._subscriptions = /* @__PURE__ */ new Set()}
|
4735
|
+
subscribe(callback) {
|
4736
|
+
this._subscriptions.add(callback);
|
4737
|
+
return () => this._subscriptions.delete(callback);
|
4738
|
+
}
|
4739
|
+
_notifySubscribers() {
|
4740
|
+
for (const callback of this._subscriptions) callback();
|
4741
|
+
}
|
4742
|
+
}, _class13);
|
4743
|
+
|
4744
|
+
// src/runtimes/local/LocalRuntimeCore.tsx
|
4745
|
+
var getExportFromInitialMessages = (initialMessages) => {
|
4746
|
+
const messages2 = fromCoreMessages(initialMessages);
|
4747
|
+
return {
|
4748
|
+
messages: messages2.map((m, idx) => ({
|
4749
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _242 => _242[idx - 1], 'optionalAccess', _243 => _243.id]), () => ( null)),
|
4750
|
+
message: m
|
4751
|
+
}))
|
4752
|
+
};
|
4753
|
+
};
|
4754
|
+
var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
4755
|
+
|
4756
|
+
|
4757
|
+
constructor(options, initialMessages) {
|
4758
|
+
super();
|
4759
|
+
this._options = options;
|
4760
|
+
this.threadManager = new LocalThreadManagerRuntimeCore((threadId, data) => {
|
4761
|
+
const thread = new LocalThreadRuntimeCore(
|
4762
|
+
this._proxyConfigProvider,
|
4763
|
+
threadId,
|
4764
|
+
this._options
|
4765
|
+
);
|
4766
|
+
thread.import(data);
|
4767
|
+
return thread;
|
4768
|
+
});
|
4769
|
+
if (initialMessages) {
|
4770
|
+
this.threadManager.mainThread.import(
|
4771
|
+
getExportFromInitialMessages(initialMessages)
|
4772
|
+
);
|
4773
|
+
}
|
4774
|
+
}
|
4775
|
+
setOptions(options) {
|
4776
|
+
this._options = options;
|
4777
|
+
this.threadManager.mainThread.setOptions(options);
|
4471
4778
|
}
|
4472
4779
|
reset({
|
4473
4780
|
initialMessages
|
4474
4781
|
} = {}) {
|
4475
|
-
this.
|
4782
|
+
this.threadManager.switchToNewThread();
|
4476
4783
|
if (!initialMessages) return;
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _229 => _229[idx - 1], 'optionalAccess', _230 => _230.id]), () => ( null)),
|
4481
|
-
message: m
|
4482
|
-
}))
|
4483
|
-
});
|
4784
|
+
this.threadManager.mainThread.import(
|
4785
|
+
getExportFromInitialMessages(initialMessages)
|
4786
|
+
);
|
4484
4787
|
}
|
4485
4788
|
};
|
4486
4789
|
|
@@ -4496,15 +4799,21 @@ var LocalRuntimeImpl = class _LocalRuntimeImpl extends AssistantRuntimeImpl {
|
|
4496
4799
|
static create(_core) {
|
4497
4800
|
return new _LocalRuntimeImpl(
|
4498
4801
|
_core,
|
4499
|
-
AssistantRuntimeImpl.
|
4802
|
+
AssistantRuntimeImpl.createMainThreadRuntime(_core, ThreadRuntimeImpl)
|
4500
4803
|
);
|
4501
4804
|
}
|
4502
4805
|
};
|
4503
4806
|
var useLocalRuntime = (adapter, options = {}) => {
|
4504
|
-
const
|
4505
|
-
|
4506
|
-
|
4507
|
-
|
4807
|
+
const opt = {
|
4808
|
+
...options,
|
4809
|
+
adapters: {
|
4810
|
+
...options.adapters,
|
4811
|
+
chatModel: adapter
|
4812
|
+
}
|
4813
|
+
};
|
4814
|
+
const [runtime] = _react.useState.call(void 0, () => new LocalRuntimeCore(opt));
|
4815
|
+
_react.useEffect.call(void 0, () => {
|
4816
|
+
runtime.setOptions(opt);
|
4508
4817
|
});
|
4509
4818
|
return _react.useMemo.call(void 0, () => LocalRuntimeImpl.create(runtime), [runtime]);
|
4510
4819
|
};
|
@@ -4512,6 +4821,92 @@ var useLocalRuntime = (adapter, options = {}) => {
|
|
4512
4821
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
4513
4822
|
|
4514
4823
|
|
4824
|
+
// src/runtimes/external-store/ExternalStoreThreadManagementAdapter.tsx
|
4825
|
+
var EMPTY_ARRAY2 = Object.freeze([]);
|
4826
|
+
var DEFAULT_THREAD_ID = "DEFAULT_THREAD_ID";
|
4827
|
+
var ExternalStoreThreadManagerRuntimeCore = (_class14 = class {
|
4828
|
+
constructor(adapter = {}, threadFactory) {;_class14.prototype.__init35.call(this);
|
4829
|
+
this.adapter = adapter;
|
4830
|
+
this.threadFactory = threadFactory;
|
4831
|
+
this._mainThread = this.threadFactory(DEFAULT_THREAD_ID);
|
4832
|
+
}
|
4833
|
+
get threads() {
|
4834
|
+
return _nullishCoalesce(this.adapter.threads, () => ( EMPTY_ARRAY2));
|
4835
|
+
}
|
4836
|
+
get archivedThreads() {
|
4837
|
+
return _nullishCoalesce(this.adapter.archivedThreads, () => ( EMPTY_ARRAY2));
|
4838
|
+
}
|
4839
|
+
|
4840
|
+
get mainThread() {
|
4841
|
+
return this._mainThread;
|
4842
|
+
}
|
4843
|
+
setAdapter(adapter) {
|
4844
|
+
const previousAdapter = this.adapter;
|
4845
|
+
this.adapter = adapter;
|
4846
|
+
const newThreadId = _nullishCoalesce(adapter.threadId, () => ( DEFAULT_THREAD_ID));
|
4847
|
+
const newThreads = _nullishCoalesce(adapter.threads, () => ( EMPTY_ARRAY2));
|
4848
|
+
const newArchivedThreads = _nullishCoalesce(adapter.archivedThreads, () => ( EMPTY_ARRAY2));
|
4849
|
+
if (previousAdapter.threadId === newThreadId && previousAdapter.threads === newThreads && previousAdapter.archivedThreads === newArchivedThreads) {
|
4850
|
+
return;
|
4851
|
+
}
|
4852
|
+
if (previousAdapter.threadId !== newThreadId) {
|
4853
|
+
this._mainThread._notifyEventSubscribers("switched-away");
|
4854
|
+
this._mainThread = this.threadFactory(newThreadId);
|
4855
|
+
this._mainThread._notifyEventSubscribers("switched-to");
|
4856
|
+
}
|
4857
|
+
this._notifySubscribers();
|
4858
|
+
}
|
4859
|
+
switchToThread(threadId) {
|
4860
|
+
if (_optionalChain([this, 'access', _244 => _244._mainThread, 'optionalAccess', _245 => _245.threadId]) === threadId) return;
|
4861
|
+
const onSwitchToThread = this.adapter.onSwitchToThread;
|
4862
|
+
if (!onSwitchToThread)
|
4863
|
+
throw new Error(
|
4864
|
+
"External store adapter does not support switching to thread"
|
4865
|
+
);
|
4866
|
+
onSwitchToThread(threadId);
|
4867
|
+
}
|
4868
|
+
switchToNewThread() {
|
4869
|
+
const onSwitchToNewThread = this.adapter.onSwitchToNewThread;
|
4870
|
+
if (!onSwitchToNewThread)
|
4871
|
+
throw new Error(
|
4872
|
+
"External store adapter does not support switching to new thread"
|
4873
|
+
);
|
4874
|
+
onSwitchToNewThread();
|
4875
|
+
}
|
4876
|
+
async rename(threadId, newTitle) {
|
4877
|
+
const onRename = this.adapter.onRename;
|
4878
|
+
if (!onRename)
|
4879
|
+
throw new Error("External store adapter does not support renaming");
|
4880
|
+
onRename(threadId, newTitle);
|
4881
|
+
}
|
4882
|
+
async archive(threadId) {
|
4883
|
+
const onArchive = this.adapter.onArchive;
|
4884
|
+
if (!onArchive)
|
4885
|
+
throw new Error("External store adapter does not support archiving");
|
4886
|
+
onArchive(threadId);
|
4887
|
+
}
|
4888
|
+
async unarchive(threadId) {
|
4889
|
+
const onUnarchive = this.adapter.onUnarchive;
|
4890
|
+
if (!onUnarchive)
|
4891
|
+
throw new Error("External store adapter does not support unarchiving");
|
4892
|
+
onUnarchive(threadId);
|
4893
|
+
}
|
4894
|
+
async delete(threadId) {
|
4895
|
+
const onDelete = this.adapter.onDelete;
|
4896
|
+
if (!onDelete)
|
4897
|
+
throw new Error("External store adapter does not support deleting");
|
4898
|
+
onDelete(threadId);
|
4899
|
+
}
|
4900
|
+
__init35() {this._subscriptions = /* @__PURE__ */ new Set()}
|
4901
|
+
subscribe(callback) {
|
4902
|
+
this._subscriptions.add(callback);
|
4903
|
+
return () => this._subscriptions.delete(callback);
|
4904
|
+
}
|
4905
|
+
_notifySubscribers() {
|
4906
|
+
for (const callback of this._subscriptions) callback();
|
4907
|
+
}
|
4908
|
+
}, _class14);
|
4909
|
+
|
4515
4910
|
// src/runtimes/external-store/getExternalStoreMessage.tsx
|
4516
4911
|
var symbolInnerMessage = Symbol("innerMessage");
|
4517
4912
|
var getExternalStoreMessage = (message) => {
|
@@ -4519,8 +4914,8 @@ var getExternalStoreMessage = (message) => {
|
|
4519
4914
|
};
|
4520
4915
|
|
4521
4916
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
4522
|
-
var ThreadMessageConverter = (
|
4523
|
-
|
4917
|
+
var ThreadMessageConverter = (_class15 = class {constructor() { _class15.prototype.__init36.call(this); }
|
4918
|
+
__init36() {this.cache = /* @__PURE__ */ new WeakMap()}
|
4524
4919
|
convertMessages(messages2, converter) {
|
4525
4920
|
return messages2.map((m, idx) => {
|
4526
4921
|
const cached = this.cache.get(m);
|
@@ -4529,7 +4924,7 @@ var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototy
|
|
4529
4924
|
return newMessage;
|
4530
4925
|
});
|
4531
4926
|
}
|
4532
|
-
},
|
4927
|
+
}, _class15);
|
4533
4928
|
|
4534
4929
|
// src/runtimes/external-store/auto-status.tsx
|
4535
4930
|
var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
|
@@ -4615,13 +5010,13 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
4615
5010
|
};
|
4616
5011
|
|
4617
5012
|
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
4618
|
-
var
|
5013
|
+
var EMPTY_ARRAY3 = Object.freeze([]);
|
4619
5014
|
var hasUpcomingMessage = (isRunning, messages2) => {
|
4620
|
-
return isRunning && _optionalChain([messages2, 'access',
|
5015
|
+
return isRunning && _optionalChain([messages2, 'access', _246 => _246[messages2.length - 1], 'optionalAccess', _247 => _247.role]) !== "assistant";
|
4621
5016
|
};
|
4622
|
-
var ExternalStoreThreadRuntimeCore = (
|
4623
|
-
|
4624
|
-
|
5017
|
+
var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntimeCore {
|
5018
|
+
__init37() {this.assistantOptimisticId = null}
|
5019
|
+
__init38() {this._capabilities = {
|
4625
5020
|
switchToBranch: false,
|
4626
5021
|
edit: false,
|
4627
5022
|
reload: false,
|
@@ -4643,41 +5038,38 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class extends BaseThreadRuntime
|
|
4643
5038
|
get adapters() {
|
4644
5039
|
return this._store.adapters;
|
4645
5040
|
}
|
4646
|
-
|
4647
|
-
|
4648
|
-
|
5041
|
+
__init39() {this.suggestions = []}
|
5042
|
+
__init40() {this.extras = void 0}
|
5043
|
+
__init41() {this._converter = new ThreadMessageConverter()}
|
4649
5044
|
|
4650
5045
|
beginEdit(messageId) {
|
4651
|
-
if (!this.
|
5046
|
+
if (!this._store.onEdit)
|
4652
5047
|
throw new Error("Runtime does not support editing.");
|
4653
5048
|
super.beginEdit(messageId);
|
4654
5049
|
}
|
4655
|
-
constructor(configProvider, store) {
|
4656
|
-
super(configProvider);
|
4657
|
-
this.
|
4658
|
-
|
4659
|
-
get store() {
|
4660
|
-
return this._store;
|
5050
|
+
constructor(configProvider, threadId, store) {
|
5051
|
+
super(configProvider);_class16.prototype.__init37.call(this);_class16.prototype.__init38.call(this);_class16.prototype.__init39.call(this);_class16.prototype.__init40.call(this);_class16.prototype.__init41.call(this);_class16.prototype.__init42.call(this);;
|
5052
|
+
this.threadId = threadId;
|
5053
|
+
this.setStore(store);
|
4661
5054
|
}
|
4662
|
-
|
5055
|
+
setStore(store) {
|
4663
5056
|
if (this._store === store) return;
|
4664
|
-
this.threadId = _nullishCoalesce(_nullishCoalesce(store.threadId, () => ( this.threadId)), () => ( generateId()));
|
4665
5057
|
const isRunning = _nullishCoalesce(store.isRunning, () => ( false));
|
4666
5058
|
this.isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
|
4667
5059
|
const oldStore = this._store;
|
4668
5060
|
this._store = store;
|
4669
5061
|
this.extras = store.extras;
|
4670
|
-
this.suggestions = _nullishCoalesce(store.suggestions, () => (
|
5062
|
+
this.suggestions = _nullishCoalesce(store.suggestions, () => ( EMPTY_ARRAY3));
|
4671
5063
|
this._capabilities = {
|
4672
5064
|
switchToBranch: this._store.setMessages !== void 0,
|
4673
5065
|
edit: this._store.onEdit !== void 0,
|
4674
5066
|
reload: this._store.onReload !== void 0,
|
4675
5067
|
cancel: this._store.onCancel !== void 0,
|
4676
|
-
speech: _optionalChain([this, 'access',
|
4677
|
-
unstable_copy: _optionalChain([this, 'access',
|
5068
|
+
speech: _optionalChain([this, 'access', _251 => _251._store, 'access', _252 => _252.adapters, 'optionalAccess', _253 => _253.speech]) !== void 0,
|
5069
|
+
unstable_copy: _optionalChain([this, 'access', _254 => _254._store, 'access', _255 => _255.unstable_capabilities, 'optionalAccess', _256 => _256.copy]) !== false,
|
4678
5070
|
// default true
|
4679
|
-
attachments: !!_optionalChain([this, 'access',
|
4680
|
-
feedback: !!_optionalChain([this, 'access',
|
5071
|
+
attachments: !!_optionalChain([this, 'access', _257 => _257._store, 'access', _258 => _258.adapters, 'optionalAccess', _259 => _259.attachments]),
|
5072
|
+
feedback: !!_optionalChain([this, 'access', _260 => _260._store, 'access', _261 => _261.adapters, 'optionalAccess', _262 => _262.feedback])
|
4681
5073
|
};
|
4682
5074
|
if (oldStore) {
|
4683
5075
|
if (oldStore.convertMessage !== store.convertMessage) {
|
@@ -4704,7 +5096,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class extends BaseThreadRuntime
|
|
4704
5096
|
for (let i = 0; i < messages2.length; i++) {
|
4705
5097
|
const message = messages2[i];
|
4706
5098
|
const parent = messages2[i - 1];
|
4707
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
5099
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _263 => _263.id]), () => ( null)), message);
|
4708
5100
|
}
|
4709
5101
|
if (this.assistantOptimisticId) {
|
4710
5102
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -4712,7 +5104,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class extends BaseThreadRuntime
|
|
4712
5104
|
}
|
4713
5105
|
if (hasUpcomingMessage(isRunning, messages2)) {
|
4714
5106
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
4715
|
-
_nullishCoalesce(_optionalChain([messages2, 'access',
|
5107
|
+
_nullishCoalesce(_optionalChain([messages2, 'access', _264 => _264.at, 'call', _265 => _265(-1), 'optionalAccess', _266 => _266.id]), () => ( null)),
|
4716
5108
|
{
|
4717
5109
|
role: "assistant",
|
4718
5110
|
content: []
|
@@ -4720,7 +5112,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class extends BaseThreadRuntime
|
|
4720
5112
|
);
|
4721
5113
|
}
|
4722
5114
|
this.repository.resetHead(
|
4723
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access',
|
5115
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _267 => _267.at, 'call', _268 => _268(-1), 'optionalAccess', _269 => _269.id]))), () => ( null))
|
4724
5116
|
);
|
4725
5117
|
this._messages = this.repository.getMessages();
|
4726
5118
|
this._notifySubscribers();
|
@@ -4732,7 +5124,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class extends BaseThreadRuntime
|
|
4732
5124
|
this.updateMessages(this.repository.getMessages());
|
4733
5125
|
}
|
4734
5126
|
async append(message) {
|
4735
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
5127
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _270 => _270.messages, 'access', _271 => _271.at, 'call', _272 => _272(-1), 'optionalAccess', _273 => _273.id]), () => ( null)))) {
|
4736
5128
|
if (!this._store.onEdit)
|
4737
5129
|
throw new Error("Runtime does not support editing messages.");
|
4738
5130
|
await this._store.onEdit(message);
|
@@ -4755,7 +5147,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class extends BaseThreadRuntime
|
|
4755
5147
|
}
|
4756
5148
|
let messages2 = this.repository.getMessages();
|
4757
5149
|
const previousMessage = messages2[messages2.length - 1];
|
4758
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
5150
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _274 => _274.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _275 => _275.at, 'call', _276 => _276(-1), 'optionalAccess', _277 => _277.id])) {
|
4759
5151
|
this.repository.deleteMessage(previousMessage.id);
|
4760
5152
|
if (!this.composer.text.trim()) {
|
4761
5153
|
this.composer.setText(getThreadMessageText(previousMessage));
|
@@ -4773,57 +5165,41 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class extends BaseThreadRuntime
|
|
4773
5165
|
throw new Error("Runtime does not support tool results.");
|
4774
5166
|
this._store.onAddToolResult(options);
|
4775
5167
|
}
|
4776
|
-
|
4777
|
-
_optionalChain([this, 'access',
|
5168
|
+
__init42() {this.updateMessages = (messages2) => {
|
5169
|
+
_optionalChain([this, 'access', _278 => _278._store, 'access', _279 => _279.setMessages, 'optionalCall', _280 => _280(
|
4778
5170
|
messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
4779
5171
|
)]);
|
4780
5172
|
}}
|
4781
|
-
},
|
5173
|
+
}, _class16);
|
4782
5174
|
|
4783
5175
|
// src/runtimes/external-store/ExternalStoreRuntimeCore.tsx
|
5176
|
+
var getThreadManagerAdapter = (store) => {
|
5177
|
+
return {
|
5178
|
+
threadId: store.threadId,
|
5179
|
+
onSwitchToNewThread: store.onSwitchToNewThread,
|
5180
|
+
onSwitchToThread: store.onSwitchToThread,
|
5181
|
+
..._optionalChain([store, 'access', _281 => _281.adapters, 'optionalAccess', _282 => _282.threadManager])
|
5182
|
+
};
|
5183
|
+
};
|
4784
5184
|
var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
4785
5185
|
|
5186
|
+
|
4786
5187
|
constructor(store) {
|
4787
|
-
|
4788
|
-
|
4789
|
-
this.
|
4790
|
-
|
4791
|
-
|
4792
|
-
return this._proxyConfigProvider.getModelConfig();
|
4793
|
-
}
|
4794
|
-
registerModelConfigProvider(provider) {
|
4795
|
-
return this._proxyConfigProvider.registerModelConfigProvider(provider);
|
4796
|
-
}
|
4797
|
-
async switchToNewThread() {
|
4798
|
-
if (!this.thread.store.onSwitchToNewThread)
|
4799
|
-
throw new Error("Runtime does not support switching to new threads.");
|
4800
|
-
this.thread = new ExternalStoreThreadRuntimeCore(
|
4801
|
-
this._proxyConfigProvider,
|
4802
|
-
{
|
4803
|
-
...this.thread.store,
|
4804
|
-
messages: []
|
4805
|
-
}
|
4806
|
-
);
|
4807
|
-
await this.thread.store.onSwitchToNewThread();
|
4808
|
-
this.thread._notifyEventSubscribers("switched-to");
|
4809
|
-
}
|
4810
|
-
async switchToThread(threadId) {
|
4811
|
-
if (threadId !== null) {
|
4812
|
-
if (!this.thread.store.onSwitchToThread)
|
4813
|
-
throw new Error("Runtime does not support switching threads.");
|
4814
|
-
this.thread = new ExternalStoreThreadRuntimeCore(
|
5188
|
+
super();
|
5189
|
+
this._store = store;
|
5190
|
+
this.threadManager = new ExternalStoreThreadManagerRuntimeCore(
|
5191
|
+
getThreadManagerAdapter(store),
|
5192
|
+
(threadId) => new ExternalStoreThreadRuntimeCore(
|
4815
5193
|
this._proxyConfigProvider,
|
4816
|
-
|
4817
|
-
|
4818
|
-
|
4819
|
-
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
|
4824
|
-
|
4825
|
-
this.switchToNewThread();
|
4826
|
-
}
|
5194
|
+
threadId,
|
5195
|
+
this._store
|
5196
|
+
)
|
5197
|
+
);
|
5198
|
+
}
|
5199
|
+
setStore(store) {
|
5200
|
+
this._store = store;
|
5201
|
+
this.threadManager.setAdapter(getThreadManagerAdapter(store));
|
5202
|
+
this.threadManager.mainThread.setStore(store);
|
4827
5203
|
}
|
4828
5204
|
};
|
4829
5205
|
|
@@ -4831,7 +5207,7 @@ var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4831
5207
|
var useExternalStoreRuntime = (store) => {
|
4832
5208
|
const [runtime] = _react.useState.call(void 0, () => new ExternalStoreRuntimeCore(store));
|
4833
5209
|
_react.useEffect.call(void 0, () => {
|
4834
|
-
runtime.
|
5210
|
+
runtime.setStore(store);
|
4835
5211
|
});
|
4836
5212
|
return _react.useMemo.call(void 0,
|
4837
5213
|
() => AssistantRuntimeImpl.create(runtime, ThreadRuntimeImpl),
|
@@ -4994,18 +5370,18 @@ var DangerousInBrowserAdapter = class {
|
|
4994
5370
|
this.options = options;
|
4995
5371
|
}
|
4996
5372
|
async *run({ messages: messages2, abortSignal, config }) {
|
4997
|
-
const res = await
|
5373
|
+
const res = await _chunkC6UZOY5Ajs.getEdgeRuntimeStream.call(void 0, {
|
4998
5374
|
options: this.options,
|
4999
5375
|
abortSignal,
|
5000
5376
|
requestData: {
|
5001
5377
|
system: config.system,
|
5002
|
-
messages:
|
5003
|
-
tools: config.tools ?
|
5378
|
+
messages: _chunkC6UZOY5Ajs.toCoreMessages.call(void 0, messages2),
|
5379
|
+
tools: config.tools ? _chunkC6UZOY5Ajs.toLanguageModelTools.call(void 0, config.tools) : [],
|
5004
5380
|
...config.callSettings,
|
5005
5381
|
...config.config
|
5006
5382
|
}
|
5007
5383
|
});
|
5008
|
-
const stream = res.pipeThrough(
|
5384
|
+
const stream = res.pipeThrough(_chunkC6UZOY5Ajs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkC6UZOY5Ajs.runResultStream.call(void 0, ));
|
5009
5385
|
for await (const update of asAsyncIterable(stream)) {
|
5010
5386
|
yield update;
|
5011
5387
|
}
|
@@ -5021,8 +5397,7 @@ var useDangerousInBrowserRuntime = (options) => {
|
|
5021
5397
|
|
5022
5398
|
// src/runtimes/speech/WebSpeechSynthesisAdapter.ts
|
5023
5399
|
var WebSpeechSynthesisAdapter = class {
|
5024
|
-
speak(
|
5025
|
-
const text = getThreadMessageText(message);
|
5400
|
+
speak(text) {
|
5026
5401
|
const utterance = new SpeechSynthesisUtterance(text);
|
5027
5402
|
const subscribers = /* @__PURE__ */ new Set();
|
5028
5403
|
const handleEnd = (reason, error) => {
|
@@ -5061,8 +5436,8 @@ var WebSpeechSynthesisAdapter = class {
|
|
5061
5436
|
};
|
5062
5437
|
|
5063
5438
|
// src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
|
5064
|
-
var SimpleImageAttachmentAdapter = (
|
5065
|
-
|
5439
|
+
var SimpleImageAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init43.call(this); }
|
5440
|
+
__init43() {this.accept = "image/*"}
|
5066
5441
|
async add(state) {
|
5067
5442
|
return {
|
5068
5443
|
id: state.file.name,
|
@@ -5087,7 +5462,7 @@ var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.p
|
|
5087
5462
|
}
|
5088
5463
|
async remove() {
|
5089
5464
|
}
|
5090
|
-
},
|
5465
|
+
}, _class17);
|
5091
5466
|
var getFileDataURL = (file) => new Promise((resolve, reject) => {
|
5092
5467
|
const reader = new FileReader();
|
5093
5468
|
reader.onload = () => resolve(reader.result);
|
@@ -5096,8 +5471,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
|
|
5096
5471
|
});
|
5097
5472
|
|
5098
5473
|
// src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
|
5099
|
-
var SimpleTextAttachmentAdapter = (
|
5100
|
-
|
5474
|
+
var SimpleTextAttachmentAdapter = (_class18 = class {constructor() { _class18.prototype.__init44.call(this); }
|
5475
|
+
__init44() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
|
5101
5476
|
async add(state) {
|
5102
5477
|
return {
|
5103
5478
|
id: state.file.name,
|
@@ -5124,7 +5499,7 @@ ${await getFileText(attachment.file)}
|
|
5124
5499
|
}
|
5125
5500
|
async remove() {
|
5126
5501
|
}
|
5127
|
-
},
|
5502
|
+
}, _class18);
|
5128
5503
|
var getFileText = (file) => new Promise((resolve, reject) => {
|
5129
5504
|
const reader = new FileReader();
|
5130
5505
|
reader.onload = () => resolve(reader.result);
|
@@ -5225,7 +5600,7 @@ var ThreadConfigProvider = ({
|
|
5225
5600
|
}) => {
|
5226
5601
|
const hasAssistant = !!useAssistantRuntime({ optional: true });
|
5227
5602
|
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 });
|
5228
|
-
if (!_optionalChain([config, 'optionalAccess',
|
5603
|
+
if (!_optionalChain([config, 'optionalAccess', _283 => _283.runtime])) return configProvider;
|
5229
5604
|
if (hasAssistant) {
|
5230
5605
|
throw new Error(
|
5231
5606
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -5553,7 +5928,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
5553
5928
|
{
|
5554
5929
|
components: {
|
5555
5930
|
...componentsProp,
|
5556
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
5931
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _284 => _284.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
|
5557
5932
|
tools: toolsComponents
|
5558
5933
|
}
|
5559
5934
|
}
|
@@ -5664,7 +6039,7 @@ var useAttachmentSrc = () => {
|
|
5664
6039
|
const { file, src } = useAttachment((a) => {
|
5665
6040
|
if (a.type !== "image") return {};
|
5666
6041
|
if (a.file) return { file: a.file };
|
5667
|
-
const src2 = _optionalChain([a, 'access',
|
6042
|
+
const src2 = _optionalChain([a, 'access', _285 => _285.content, 'optionalAccess', _286 => _286.filter, 'call', _287 => _287((c) => c.type === "image"), 'access', _288 => _288[0], 'optionalAccess', _289 => _289.image]);
|
5668
6043
|
if (!src2) return {};
|
5669
6044
|
return { src: src2 };
|
5670
6045
|
});
|
@@ -5808,7 +6183,7 @@ var ComposerAttachments = ({ components }) => {
|
|
5808
6183
|
{
|
5809
6184
|
components: {
|
5810
6185
|
...components,
|
5811
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6186
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _290 => _290.Attachment]), () => ( attachment_default))
|
5812
6187
|
}
|
5813
6188
|
}
|
5814
6189
|
) });
|
@@ -5917,8 +6292,13 @@ var ThreadWelcomeMessageStyled = withDefaults("p", {
|
|
5917
6292
|
className: "aui-thread-welcome-message"
|
5918
6293
|
});
|
5919
6294
|
var ThreadWelcomeMessage = _react.forwardRef.call(void 0, ({ message: messageProp, ...rest }, ref) => {
|
5920
|
-
const {
|
5921
|
-
|
6295
|
+
const {
|
6296
|
+
welcome: { message } = {},
|
6297
|
+
strings: {
|
6298
|
+
welcome: { message: defaultMessage = "How can I help you today?" } = {}
|
6299
|
+
} = {}
|
6300
|
+
} = useThreadConfig();
|
6301
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeMessageStyled, { ...rest, ref, children: _nullishCoalesce(_nullishCoalesce(messageProp, () => ( message)), () => ( defaultMessage)) });
|
5922
6302
|
});
|
5923
6303
|
ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
|
5924
6304
|
var ThreadWelcomeSuggestionContainer = withDefaults("div", {
|
@@ -5936,7 +6316,7 @@ var ThreadWelcomeSuggestions = () => {
|
|
5936
6316
|
const suggestions2 = useThread((t) => t.suggestions);
|
5937
6317
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
5938
6318
|
const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
|
5939
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess',
|
6319
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _291 => _291.map, 'call', _292 => _292((suggestion, idx) => {
|
5940
6320
|
const key = `${suggestion.prompt}-${idx}`;
|
5941
6321
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
5942
6322
|
})]) });
|
@@ -6014,7 +6394,7 @@ var UserMessageContent = _react.forwardRef.call(void 0, ({ components, ...props
|
|
6014
6394
|
{
|
6015
6395
|
components: {
|
6016
6396
|
...components,
|
6017
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6397
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _293 => _293.Text]), () => ( content_part_default.Text))
|
6018
6398
|
}
|
6019
6399
|
}
|
6020
6400
|
) });
|
@@ -6031,7 +6411,7 @@ var UserMessageAttachments = ({
|
|
6031
6411
|
{
|
6032
6412
|
components: {
|
6033
6413
|
...components,
|
6034
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6414
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _294 => _294.Attachment]), () => ( attachment_default))
|
6035
6415
|
}
|
6036
6416
|
}
|
6037
6417
|
) }) });
|
@@ -6134,10 +6514,10 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
|
|
6134
6514
|
thread_exports.Messages,
|
6135
6515
|
{
|
6136
6516
|
components: {
|
6137
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6138
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6139
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6140
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6517
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _295 => _295.UserMessage]), () => ( user_message_default)),
|
6518
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _296 => _296.EditComposer]), () => ( edit_composer_default)),
|
6519
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _297 => _297.AssistantMessage]), () => ( assistant_message_default)),
|
6520
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _298 => _298.SystemMessage]), () => ( SystemMessage))
|
6141
6521
|
},
|
6142
6522
|
...rest
|
6143
6523
|
}
|
@@ -6148,7 +6528,7 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
|
|
6148
6528
|
ThreadMessages.displayName = "ThreadMessages";
|
6149
6529
|
var ThreadFollowupSuggestions = () => {
|
6150
6530
|
const suggestions = useThread((t) => t.suggestions);
|
6151
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess',
|
6531
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess', _299 => _299.map, 'call', _300 => _300((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
6152
6532
|
thread_exports.Suggestion,
|
6153
6533
|
{
|
6154
6534
|
className: "aui-thread-followup-suggestion",
|
@@ -6381,5 +6761,7 @@ var assistant_modal_default = Object.assign(AssistantModal, exports12);
|
|
6381
6761
|
|
6382
6762
|
|
6383
6763
|
|
6384
|
-
|
6764
|
+
|
6765
|
+
|
6766
|
+
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.AttachmentPrimitive = attachment_exports; exports.AttachmentUI = attachment_default; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = 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 = 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 = _chunkC6UZOY5Ajs.toCoreMessage; exports.toCoreMessages = _chunkC6UZOY5Ajs.toCoreMessages; exports.toLanguageModelMessages = _chunkC6UZOY5Ajs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkC6UZOY5Ajs.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.useThreadManager = useThreadManager; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadModelConfig = useThreadModelConfig; 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;
|
6385
6767
|
//# sourceMappingURL=index.js.map
|