@assistant-ui/react 0.5.46 → 0.5.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BQ3MRWUV.js → chunk-BNSCUYW7.js} +9 -5
- package/dist/chunk-BNSCUYW7.js.map +1 -0
- package/dist/{chunk-5ZTUOAPH.mjs → chunk-TZO3D3VQ.mjs} +9 -5
- package/dist/chunk-TZO3D3VQ.mjs.map +1 -0
- package/dist/{edge-6dYzFCV5.d.mts → edge-Dwfu6YTG.d.mts} +16 -1
- package/dist/{edge-6dYzFCV5.d.ts → edge-Dwfu6YTG.d.ts} +16 -1
- package/dist/edge.d.mts +75 -75
- package/dist/edge.d.ts +75 -75
- package/dist/edge.js +8 -4
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +8 -4
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +189 -58
- package/dist/index.d.ts +189 -58
- package/dist/index.js +828 -231
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +888 -291
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +55 -3
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +33 -5
- package/package.json +1 -1
- package/dist/chunk-5ZTUOAPH.mjs.map +0 -1
- package/dist/chunk-BQ3MRWUV.js.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;"use client";
|
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;"use client";
|
2
2
|
|
3
3
|
|
4
4
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
var
|
13
|
+
var _chunkBNSCUYW7js = require('./chunk-BNSCUYW7.js');
|
14
14
|
|
15
15
|
|
16
16
|
var _chunkDCHYNTHIjs = require('./chunk-DCHYNTHI.js');
|
@@ -42,7 +42,7 @@ var _zustand = require('zustand');
|
|
42
42
|
var ProxyConfigProvider = (_class = class {constructor() { _class.prototype.__init.call(this); }
|
43
43
|
__init() {this._providers = /* @__PURE__ */ new Set()}
|
44
44
|
getModelConfig() {
|
45
|
-
return
|
45
|
+
return _chunkBNSCUYW7js.mergeModelConfigs.call(void 0, this._providers);
|
46
46
|
}
|
47
47
|
registerModelConfigProvider(provider) {
|
48
48
|
this._providers.add(provider);
|
@@ -125,21 +125,26 @@ var makeComposerStore = (useThreadRuntime) => {
|
|
125
125
|
setValue(value) {
|
126
126
|
get().setText(value);
|
127
127
|
},
|
128
|
+
attachments: runtime.composer.attachments,
|
129
|
+
addAttachment: (file) => {
|
130
|
+
useThreadRuntime.getState().composer.addAttachment(file);
|
131
|
+
},
|
132
|
+
removeAttachment: (attachmentId) => {
|
133
|
+
useThreadRuntime.getState().composer.removeAttachment(attachmentId);
|
134
|
+
},
|
135
|
+
reset: () => {
|
136
|
+
useThreadRuntime.getState().composer.reset();
|
137
|
+
},
|
128
138
|
text: runtime.composer.text,
|
129
|
-
setText: (
|
130
|
-
useThreadRuntime.getState().composer.setText(
|
139
|
+
setText: (text) => {
|
140
|
+
useThreadRuntime.getState().composer.setText(text);
|
131
141
|
},
|
132
142
|
canCancel: runtime.capabilities.cancel,
|
133
143
|
isEditing: true,
|
144
|
+
isEmpty: runtime.composer.isEmpty,
|
134
145
|
send: () => {
|
135
146
|
const runtime2 = useThreadRuntime.getState();
|
136
|
-
|
137
|
-
runtime2.composer.setText("");
|
138
|
-
runtime2.append({
|
139
|
-
parentId: _nullishCoalesce(_optionalChain([runtime2, 'access', _6 => _6.messages, 'access', _7 => _7.at, 'call', _8 => _8(-1), 'optionalAccess', _9 => _9.id]), () => ( null)),
|
140
|
-
role: "user",
|
141
|
-
content: [{ type: "text", text }]
|
142
|
-
});
|
147
|
+
runtime2.composer.send();
|
143
148
|
},
|
144
149
|
cancel: () => {
|
145
150
|
useThreadRuntime.getState().cancelRun();
|
@@ -167,7 +172,7 @@ var getThreadStateFromRuntime = (runtime) => {
|
|
167
172
|
threadId: runtime.threadId,
|
168
173
|
capabilities: runtime.capabilities,
|
169
174
|
isDisabled: runtime.isDisabled,
|
170
|
-
isRunning: _optionalChain([lastMessage, 'optionalAccess',
|
175
|
+
isRunning: _optionalChain([lastMessage, 'optionalAccess', _6 => _6.role]) !== "assistant" ? false : lastMessage.status.type === "running"
|
171
176
|
});
|
172
177
|
};
|
173
178
|
var makeThreadStore = (runtimeRef) => {
|
@@ -228,7 +233,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
228
233
|
let first = true;
|
229
234
|
let cleanup;
|
230
235
|
const inner = () => {
|
231
|
-
_optionalChain([cleanup, 'optionalCall',
|
236
|
+
_optionalChain([cleanup, 'optionalCall', _7 => _7()]);
|
232
237
|
cleanup = runtime.thread.subscribe(callback);
|
233
238
|
if (!first) {
|
234
239
|
callback();
|
@@ -239,7 +244,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
239
244
|
inner();
|
240
245
|
return () => {
|
241
246
|
unsubscribe();
|
242
|
-
_optionalChain([cleanup, 'optionalCall',
|
247
|
+
_optionalChain([cleanup, 'optionalCall', _8 => _8()]);
|
243
248
|
};
|
244
249
|
};
|
245
250
|
|
@@ -275,6 +280,7 @@ _chunkDCHYNTHIjs.__export.call(void 0, internal_exports, {
|
|
275
280
|
BaseAssistantRuntime: () => BaseAssistantRuntime,
|
276
281
|
MessageRepository: () => MessageRepository,
|
277
282
|
ProxyConfigProvider: () => ProxyConfigProvider,
|
283
|
+
ThreadRuntimeComposer: () => ThreadRuntimeComposer,
|
278
284
|
TooltipIconButton: () => TooltipIconButton,
|
279
285
|
generateId: () => generateId,
|
280
286
|
useSmooth: () => useSmooth,
|
@@ -282,6 +288,76 @@ _chunkDCHYNTHIjs.__export.call(void 0, internal_exports, {
|
|
282
288
|
withSmoothContextProvider: () => withSmoothContextProvider
|
283
289
|
});
|
284
290
|
|
291
|
+
// src/runtimes/utils/ThreadRuntimeComposer.tsx
|
292
|
+
var ThreadRuntimeComposer = (_class3 = class {
|
293
|
+
constructor(runtime, notifySubscribers) {;_class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);
|
294
|
+
this.runtime = runtime;
|
295
|
+
this.notifySubscribers = notifySubscribers;
|
296
|
+
}
|
297
|
+
|
298
|
+
__init4() {this.attachmentAccept = "*"}
|
299
|
+
get isEmpty() {
|
300
|
+
return !this.text.trim() && !this.attachments.length;
|
301
|
+
}
|
302
|
+
setAttachmentAdapter(adapter) {
|
303
|
+
this._attachmentAdapter = adapter;
|
304
|
+
const accept = _nullishCoalesce(_optionalChain([adapter, 'optionalAccess', _9 => _9.accept]), () => ( "*"));
|
305
|
+
if (this.attachmentAccept !== accept) {
|
306
|
+
this.attachmentAccept = accept;
|
307
|
+
return true;
|
308
|
+
}
|
309
|
+
return false;
|
310
|
+
}
|
311
|
+
__init5() {this._attachments = []}
|
312
|
+
get attachments() {
|
313
|
+
return this._attachments;
|
314
|
+
}
|
315
|
+
async addAttachment(file) {
|
316
|
+
if (!this._attachmentAdapter)
|
317
|
+
throw new Error("Attachments are not supported");
|
318
|
+
const attachment = await this._attachmentAdapter.add({ file });
|
319
|
+
this._attachments = [...this._attachments, attachment];
|
320
|
+
this.notifySubscribers();
|
321
|
+
}
|
322
|
+
async removeAttachment(attachmentId) {
|
323
|
+
if (!this._attachmentAdapter)
|
324
|
+
throw new Error("Attachments are not supported");
|
325
|
+
const index = this._attachments.findIndex((a) => a.id === attachmentId);
|
326
|
+
if (index === -1) throw new Error("Attachment not found");
|
327
|
+
const attachment = this._attachments[index];
|
328
|
+
await this._attachmentAdapter.remove(attachment);
|
329
|
+
this._attachments = this._attachments.toSpliced(index, 1);
|
330
|
+
this.notifySubscribers();
|
331
|
+
}
|
332
|
+
__init6() {this._text = ""}
|
333
|
+
get text() {
|
334
|
+
return this._text;
|
335
|
+
}
|
336
|
+
setText(value) {
|
337
|
+
this._text = value;
|
338
|
+
this.notifySubscribers();
|
339
|
+
}
|
340
|
+
reset() {
|
341
|
+
this._text = "";
|
342
|
+
this._attachments = [];
|
343
|
+
this.notifySubscribers();
|
344
|
+
}
|
345
|
+
async send() {
|
346
|
+
const attachments = this._attachmentAdapter ? await Promise.all(
|
347
|
+
this.attachments.map(
|
348
|
+
async (a) => await this._attachmentAdapter.send(a)
|
349
|
+
)
|
350
|
+
) : [];
|
351
|
+
this.runtime.append({
|
352
|
+
parentId: _nullishCoalesce(_optionalChain([this, 'access', _10 => _10.runtime, 'access', _11 => _11.messages, 'access', _12 => _12.at, 'call', _13 => _13(-1), 'optionalAccess', _14 => _14.id]), () => ( null)),
|
353
|
+
role: "user",
|
354
|
+
content: this.text ? [{ type: "text", text: this.text }] : [],
|
355
|
+
attachments
|
356
|
+
});
|
357
|
+
this.reset();
|
358
|
+
}
|
359
|
+
}, _class3);
|
360
|
+
|
285
361
|
// src/utils/idUtils.tsx
|
286
362
|
var _nonsecure = require('nanoid/non-secure');
|
287
363
|
var generateId = _nonsecure.customAlphabet.call(void 0,
|
@@ -324,7 +400,8 @@ var fromCoreMessage = (message, {
|
|
324
400
|
return {
|
325
401
|
...commonProps,
|
326
402
|
role,
|
327
|
-
content: message.content
|
403
|
+
content: message.content,
|
404
|
+
attachments: []
|
328
405
|
};
|
329
406
|
case "system":
|
330
407
|
return {
|
@@ -345,11 +422,11 @@ var findHead = (message) => {
|
|
345
422
|
if ("current" in message) return message;
|
346
423
|
return null;
|
347
424
|
};
|
348
|
-
var MessageRepository = (
|
349
|
-
|
425
|
+
var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__init7.call(this);_class4.prototype.__init8.call(this);_class4.prototype.__init9.call(this); }
|
426
|
+
__init7() {this.messages = /* @__PURE__ */ new Map()}
|
350
427
|
// message_id -> item
|
351
|
-
|
352
|
-
|
428
|
+
__init8() {this.head = null}
|
429
|
+
__init9() {this.root = {
|
353
430
|
children: [],
|
354
431
|
next: null
|
355
432
|
}}
|
@@ -391,7 +468,7 @@ var MessageRepository = (_class3 = class {constructor() { _class3.prototype.__in
|
|
391
468
|
}
|
392
469
|
}
|
393
470
|
getMessages() {
|
394
|
-
const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access',
|
471
|
+
const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access', _15 => _15.head, 'optionalAccess', _16 => _16.level]), () => ( 0)));
|
395
472
|
for (let current = this.head; current; current = current.prev) {
|
396
473
|
messages[current.level] = current.current;
|
397
474
|
}
|
@@ -429,7 +506,7 @@ var MessageRepository = (_class3 = class {constructor() { _class3.prototype.__in
|
|
429
506
|
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
430
507
|
);
|
431
508
|
return {
|
432
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
509
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _17 => _17.prev, 'optionalAccess', _18 => _18.current, 'access', _19 => _19.id]), () => ( null)),
|
433
510
|
message: message.current
|
434
511
|
};
|
435
512
|
}
|
@@ -513,11 +590,11 @@ var MessageRepository = (_class3 = class {constructor() { _class3.prototype.__in
|
|
513
590
|
for (const [, message] of this.messages) {
|
514
591
|
exportItems.push({
|
515
592
|
message: message.current,
|
516
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
593
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _20 => _20.prev, 'optionalAccess', _21 => _21.current, 'access', _22 => _22.id]), () => ( null))
|
517
594
|
});
|
518
595
|
}
|
519
596
|
return {
|
520
|
-
headId: _nullishCoalesce(_optionalChain([this, 'access',
|
597
|
+
headId: _nullishCoalesce(_optionalChain([this, 'access', _23 => _23.head, 'optionalAccess', _24 => _24.current, 'access', _25 => _25.id]), () => ( null)),
|
521
598
|
messages: exportItems
|
522
599
|
};
|
523
600
|
}
|
@@ -525,9 +602,9 @@ var MessageRepository = (_class3 = class {constructor() { _class3.prototype.__in
|
|
525
602
|
for (const { message, parentId } of messages) {
|
526
603
|
this.addOrUpdateMessage(parentId, message);
|
527
604
|
}
|
528
|
-
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access',
|
605
|
+
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access', _26 => _26.at, 'call', _27 => _27(-1), 'optionalAccess', _28 => _28.message, 'access', _29 => _29.id]))), () => ( null)));
|
529
606
|
}
|
530
|
-
},
|
607
|
+
}, _class4);
|
531
608
|
|
532
609
|
// src/utils/smooth/useSmooth.tsx
|
533
610
|
|
@@ -564,7 +641,7 @@ var withSmoothContextProvider = (Component) => {
|
|
564
641
|
};
|
565
642
|
function useSmoothContext(options) {
|
566
643
|
const context = _react.useContext.call(void 0, SmoothContext);
|
567
|
-
if (!_optionalChain([options, 'optionalAccess',
|
644
|
+
if (!_optionalChain([options, 'optionalAccess', _30 => _30.optional]) && !context)
|
568
645
|
throw new Error(
|
569
646
|
"This component must be used within a SmoothContextProvider."
|
570
647
|
);
|
@@ -577,14 +654,14 @@ var useSmoothStatus = () => {
|
|
577
654
|
|
578
655
|
// src/utils/smooth/useSmooth.tsx
|
579
656
|
var _reactusecallbackref = require('@radix-ui/react-use-callback-ref');
|
580
|
-
var TextStreamAnimator = (
|
581
|
-
constructor(currentText, setText) {;
|
657
|
+
var TextStreamAnimator = (_class5 = class {
|
658
|
+
constructor(currentText, setText) {;_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);
|
582
659
|
this.currentText = currentText;
|
583
660
|
this.setText = setText;
|
584
661
|
}
|
585
|
-
|
586
|
-
|
587
|
-
|
662
|
+
__init10() {this.animationFrameId = null}
|
663
|
+
__init11() {this.lastUpdateTime = Date.now()}
|
664
|
+
__init12() {this.targetText = ""}
|
588
665
|
start() {
|
589
666
|
if (this.animationFrameId !== null) return;
|
590
667
|
this.lastUpdateTime = Date.now();
|
@@ -596,7 +673,7 @@ var TextStreamAnimator = (_class4 = class {
|
|
596
673
|
this.animationFrameId = null;
|
597
674
|
}
|
598
675
|
}
|
599
|
-
|
676
|
+
__init13() {this.animate = () => {
|
600
677
|
const currentTime = Date.now();
|
601
678
|
const deltaTime = currentTime - this.lastUpdateTime;
|
602
679
|
let timeToConsume = deltaTime;
|
@@ -620,7 +697,7 @@ var TextStreamAnimator = (_class4 = class {
|
|
620
697
|
this.lastUpdateTime = currentTime - timeToConsume;
|
621
698
|
this.setText(this.currentText);
|
622
699
|
}}
|
623
|
-
},
|
700
|
+
}, _class5);
|
624
701
|
var SMOOTH_STATUS = Object.freeze({
|
625
702
|
type: "running"
|
626
703
|
});
|
@@ -635,10 +712,10 @@ var useSmooth = (state, smooth = false) => {
|
|
635
712
|
const [displayedText, setDisplayedText] = _react.useState.call(void 0, text);
|
636
713
|
const setText = _reactusecallbackref.useCallbackRef.call(void 0, (text2) => {
|
637
714
|
setDisplayedText(text2);
|
638
|
-
_optionalChain([useSmoothStatus2, 'optionalAccess',
|
715
|
+
_optionalChain([useSmoothStatus2, 'optionalAccess', _31 => _31.setState, 'call', _32 => _32(text2 !== state.part.text ? SMOOTH_STATUS : state.status)]);
|
639
716
|
});
|
640
717
|
_react.useEffect.call(void 0, () => {
|
641
|
-
_optionalChain([useSmoothStatus2, 'optionalAccess',
|
718
|
+
_optionalChain([useSmoothStatus2, 'optionalAccess', _33 => _33.setState, 'call', _34 => _34(text !== displayedText ? SMOOTH_STATUS : state.status)]);
|
642
719
|
}, [useSmoothStatus2, text, displayedText, state.status]);
|
643
720
|
const [animatorRef] = _react.useState.call(void 0,
|
644
721
|
new TextStreamAnimator(text, setText)
|
@@ -832,7 +909,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
832
909
|
});
|
833
910
|
if (mergeRoundtrips) {
|
834
911
|
const previousMessage = messages[messages.length - 1];
|
835
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
912
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _35 => _35.role]) === "assistant") {
|
836
913
|
previousMessage.content.push(...newContent);
|
837
914
|
break;
|
838
915
|
}
|
@@ -845,7 +922,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
845
922
|
}
|
846
923
|
case "tool": {
|
847
924
|
const previousMessage = messages[messages.length - 1];
|
848
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
925
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _36 => _36.role]) !== "assistant")
|
849
926
|
throw new Error(
|
850
927
|
"A tool message must be preceded by an assistant message."
|
851
928
|
);
|
@@ -921,14 +998,14 @@ function streamPartDecoderStream() {
|
|
921
998
|
controller.enqueue(decodeStreamPart(chunk));
|
922
999
|
}
|
923
1000
|
});
|
924
|
-
return new (0,
|
1001
|
+
return new (0, _chunkBNSCUYW7js.PipeableTransformStream)((readable) => {
|
925
1002
|
return readable.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(decodeStream);
|
926
1003
|
});
|
927
1004
|
}
|
928
1005
|
|
929
1006
|
// src/runtimes/edge/streams/utils/index.ts
|
930
1007
|
var streamUtils = {
|
931
|
-
streamPartEncoderStream:
|
1008
|
+
streamPartEncoderStream: _chunkBNSCUYW7js.streamPartEncoderStream,
|
932
1009
|
streamPartDecoderStream
|
933
1010
|
};
|
934
1011
|
|
@@ -1037,8 +1114,8 @@ var EdgeChatAdapter = class {
|
|
1037
1114
|
credentials: _nullishCoalesce(this.options.credentials, () => ( "same-origin")),
|
1038
1115
|
body: JSON.stringify({
|
1039
1116
|
system: config.system,
|
1040
|
-
messages:
|
1041
|
-
tools: config.tools ?
|
1117
|
+
messages: _chunkBNSCUYW7js.toCoreMessages.call(void 0, messages),
|
1118
|
+
tools: config.tools ? _chunkBNSCUYW7js.toLanguageModelTools.call(void 0, config.tools) : [],
|
1042
1119
|
...config.callSettings,
|
1043
1120
|
...config.config,
|
1044
1121
|
...this.options.body
|
@@ -1048,7 +1125,7 @@ var EdgeChatAdapter = class {
|
|
1048
1125
|
if (result.status !== 200) {
|
1049
1126
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
1050
1127
|
}
|
1051
|
-
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(
|
1128
|
+
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkBNSCUYW7js.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkBNSCUYW7js.runResultStream.call(void 0, ));
|
1052
1129
|
let update;
|
1053
1130
|
for await (update of asAsyncIterable(stream)) {
|
1054
1131
|
yield update;
|
@@ -1074,11 +1151,11 @@ var useEdgeRuntime = ({
|
|
1074
1151
|
};
|
1075
1152
|
|
1076
1153
|
// src/runtimes/local/shouldContinue.tsx
|
1077
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
1154
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _37 => _37.status, 'optionalAccess', _38 => _38.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
1078
1155
|
|
1079
1156
|
// src/runtimes/local/LocalThreadRuntime.tsx
|
1080
|
-
var LocalThreadRuntime = (
|
1081
|
-
constructor(configProvider, adapter, { initialMessages, ...options }) {;
|
1157
|
+
var LocalThreadRuntime = (_class6 = class {
|
1158
|
+
constructor(configProvider, adapter, { initialMessages, ...options }) {;_class6.prototype.__init14.call(this);_class6.prototype.__init15.call(this);_class6.prototype.__init16.call(this);_class6.prototype.__init17.call(this);_class6.prototype.__init18.call(this);_class6.prototype.__init19.call(this);
|
1082
1159
|
this.configProvider = configProvider;
|
1083
1160
|
this.adapter = adapter;
|
1084
1161
|
this.threadId = generateId();
|
@@ -1092,40 +1169,46 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1092
1169
|
}
|
1093
1170
|
}
|
1094
1171
|
}
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1172
|
+
__init14() {this._subscriptions = /* @__PURE__ */ new Set()}
|
1173
|
+
__init15() {this.abortController = null}
|
1174
|
+
__init16() {this.repository = new MessageRepository()}
|
1175
|
+
__init17() {this.capabilities = {
|
1099
1176
|
switchToBranch: true,
|
1100
1177
|
edit: true,
|
1101
1178
|
reload: true,
|
1102
1179
|
cancel: true,
|
1103
1180
|
unstable_copy: true,
|
1104
|
-
speak: false
|
1181
|
+
speak: false,
|
1182
|
+
attachments: false
|
1105
1183
|
}}
|
1106
1184
|
|
1107
|
-
|
1185
|
+
__init18() {this.isDisabled = false}
|
1108
1186
|
get messages() {
|
1109
1187
|
return this.repository.getMessages();
|
1110
1188
|
}
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
this.notifySubscribers();
|
1116
|
-
}
|
1117
|
-
}}
|
1189
|
+
__init19() {this.composer = new ThreadRuntimeComposer(
|
1190
|
+
this,
|
1191
|
+
this.notifySubscribers.bind(this)
|
1192
|
+
)}
|
1118
1193
|
|
1119
1194
|
get options() {
|
1120
1195
|
return this._options;
|
1121
1196
|
}
|
1122
1197
|
set options({ initialMessages, ...options }) {
|
1123
1198
|
this._options = options;
|
1124
|
-
|
1199
|
+
let hasUpdates = false;
|
1200
|
+
const canSpeak = _optionalChain([options, 'access', _39 => _39.adapters, 'optionalAccess', _40 => _40.speech]) !== void 0;
|
1125
1201
|
if (this.capabilities.speak !== canSpeak) {
|
1126
1202
|
this.capabilities.speak = canSpeak;
|
1127
|
-
|
1203
|
+
hasUpdates = true;
|
1204
|
+
}
|
1205
|
+
this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _41 => _41.adapters, 'optionalAccess', _42 => _42.attachments]));
|
1206
|
+
const canAttach = _optionalChain([options, 'access', _43 => _43.adapters, 'optionalAccess', _44 => _44.attachments]) !== void 0;
|
1207
|
+
if (this.capabilities.attachments !== canAttach) {
|
1208
|
+
this.capabilities.attachments = canAttach;
|
1209
|
+
hasUpdates = true;
|
1128
1210
|
}
|
1211
|
+
if (hasUpdates) this.notifySubscribers();
|
1129
1212
|
}
|
1130
1213
|
getBranches(messageId) {
|
1131
1214
|
return this.repository.getBranches(messageId);
|
@@ -1144,6 +1227,7 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1144
1227
|
id: userMessageId,
|
1145
1228
|
role: "user",
|
1146
1229
|
content: message.content,
|
1230
|
+
attachments: _nullishCoalesce(message.attachments, () => ( [])),
|
1147
1231
|
createdAt: /* @__PURE__ */ new Date()
|
1148
1232
|
};
|
1149
1233
|
this.repository.addOrUpdateMessage(message.parentId, userMessage);
|
@@ -1165,18 +1249,18 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1165
1249
|
}
|
1166
1250
|
async performRoundtrip(parentId, message) {
|
1167
1251
|
const messages = this.repository.getMessages();
|
1168
|
-
_optionalChain([this, 'access',
|
1252
|
+
_optionalChain([this, 'access', _45 => _45.abortController, 'optionalAccess', _46 => _46.abort, 'call', _47 => _47()]);
|
1169
1253
|
this.abortController = new AbortController();
|
1170
1254
|
const initialContent = message.content;
|
1171
|
-
const initialRoundtrips = _optionalChain([message, 'access',
|
1172
|
-
const initalCustom = _optionalChain([message, 'access',
|
1255
|
+
const initialRoundtrips = _optionalChain([message, 'access', _48 => _48.metadata, 'optionalAccess', _49 => _49.roundtrips]);
|
1256
|
+
const initalCustom = _optionalChain([message, 'access', _50 => _50.metadata, 'optionalAccess', _51 => _51.custom]);
|
1173
1257
|
const updateMessage = (m) => {
|
1174
1258
|
message = {
|
1175
1259
|
...message,
|
1176
1260
|
...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
|
1177
1261
|
status: _nullishCoalesce(m.status, () => ( message.status)),
|
1178
1262
|
// TODO deprecated, remove in v0.6
|
1179
|
-
..._optionalChain([m, 'access',
|
1263
|
+
..._optionalChain([m, 'access', _52 => _52.metadata, 'optionalAccess', _53 => _53.roundtrips]) ? {
|
1180
1264
|
roundtrips: [
|
1181
1265
|
..._nullishCoalesce(initialRoundtrips, () => ( [])),
|
1182
1266
|
...m.metadata.roundtrips
|
@@ -1191,7 +1275,7 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1191
1275
|
...m.metadata.roundtrips
|
1192
1276
|
]
|
1193
1277
|
} : void 0,
|
1194
|
-
..._optionalChain([m, 'access',
|
1278
|
+
..._optionalChain([m, 'access', _54 => _54.metadata, 'optionalAccess', _55 => _55.custom]) ? {
|
1195
1279
|
custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
|
1196
1280
|
} : void 0
|
1197
1281
|
}
|
@@ -1201,7 +1285,7 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1201
1285
|
this.notifySubscribers();
|
1202
1286
|
};
|
1203
1287
|
const maxToolRoundtrips = _nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1));
|
1204
|
-
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access',
|
1288
|
+
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _56 => _56.metadata, 'optionalAccess', _57 => _57.roundtrips, 'optionalAccess', _58 => _58.length]), () => ( 0));
|
1205
1289
|
if (toolRoundtrips > maxToolRoundtrips) {
|
1206
1290
|
updateMessage({
|
1207
1291
|
status: {
|
@@ -1298,7 +1382,7 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1298
1382
|
// TODO lift utterance state to thread runtime
|
1299
1383
|
|
1300
1384
|
speak(messageId) {
|
1301
|
-
const adapter = _optionalChain([this, 'access',
|
1385
|
+
const adapter = _optionalChain([this, 'access', _59 => _59.options, 'access', _60 => _60.adapters, 'optionalAccess', _61 => _61.speech]);
|
1302
1386
|
if (!adapter) throw new Error("Speech adapter not configured");
|
1303
1387
|
const { message } = this.repository.getMessage(messageId);
|
1304
1388
|
if (this._utterance) {
|
@@ -1321,7 +1405,7 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1321
1405
|
this.repository.import(data);
|
1322
1406
|
this.notifySubscribers();
|
1323
1407
|
}
|
1324
|
-
},
|
1408
|
+
}, _class6);
|
1325
1409
|
|
1326
1410
|
// src/runtimes/local/LocalRuntime.tsx
|
1327
1411
|
var LocalRuntime = class extends BaseAssistantRuntime {
|
@@ -1359,7 +1443,7 @@ var LocalRuntime = class extends BaseAssistantRuntime {
|
|
1359
1443
|
const messages = fromCoreMessages(initialMessages);
|
1360
1444
|
this.thread.import({
|
1361
1445
|
messages: messages.map((m, idx) => ({
|
1362
|
-
parentId: _nullishCoalesce(_optionalChain([messages, 'access',
|
1446
|
+
parentId: _nullishCoalesce(_optionalChain([messages, 'access', _62 => _62[idx - 1], 'optionalAccess', _63 => _63.id]), () => ( null)),
|
1363
1447
|
message: m
|
1364
1448
|
}))
|
1365
1449
|
});
|
@@ -1383,8 +1467,8 @@ var getExternalStoreMessage = (message) => {
|
|
1383
1467
|
};
|
1384
1468
|
|
1385
1469
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
1386
|
-
var ThreadMessageConverter = (
|
1387
|
-
|
1470
|
+
var ThreadMessageConverter = (_class7 = class {constructor() { _class7.prototype.__init20.call(this); }
|
1471
|
+
__init20() {this.cache = /* @__PURE__ */ new WeakMap()}
|
1388
1472
|
convertMessages(messages, converter) {
|
1389
1473
|
return messages.map((m, idx) => {
|
1390
1474
|
const cached = this.cache.get(m);
|
@@ -1393,7 +1477,7 @@ var ThreadMessageConverter = (_class6 = class {constructor() { _class6.prototype
|
|
1393
1477
|
return newMessage;
|
1394
1478
|
});
|
1395
1479
|
}
|
1396
|
-
},
|
1480
|
+
}, _class7);
|
1397
1481
|
|
1398
1482
|
// src/runtimes/external-store/auto-status.tsx
|
1399
1483
|
var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
|
@@ -1406,12 +1490,14 @@ var getAutoStatus = (isLast, isRunning) => isLast && isRunning ? AUTO_STATUS_RUN
|
|
1406
1490
|
|
1407
1491
|
// src/runtimes/external-store/ThreadMessageLike.tsx
|
1408
1492
|
var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
1409
|
-
const { role, id, createdAt, status } = like;
|
1493
|
+
const { role, id, createdAt, attachments, status } = like;
|
1410
1494
|
const common = {
|
1411
1495
|
id: _nullishCoalesce(id, () => ( fallbackId)),
|
1412
1496
|
createdAt: _nullishCoalesce(createdAt, () => ( /* @__PURE__ */ new Date()))
|
1413
1497
|
};
|
1414
1498
|
const content = typeof like.content === "string" ? [{ type: "text", text: like.content }] : like.content;
|
1499
|
+
if (role !== "user" && attachments)
|
1500
|
+
throw new Error("Attachments are only supported for user messages");
|
1415
1501
|
switch (role) {
|
1416
1502
|
case "assistant":
|
1417
1503
|
return {
|
@@ -1456,7 +1542,8 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
1456
1542
|
throw new Error(`Unknown content part type: ${unhandledType}`);
|
1457
1543
|
}
|
1458
1544
|
}
|
1459
|
-
})
|
1545
|
+
}),
|
1546
|
+
attachments: _nullishCoalesce(attachments, () => ( []))
|
1460
1547
|
};
|
1461
1548
|
case "system":
|
1462
1549
|
if (content.length !== 1 || content[0].type !== "text")
|
@@ -1485,19 +1572,20 @@ var getThreadMessageText = (message) => {
|
|
1485
1572
|
|
1486
1573
|
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
1487
1574
|
var hasUpcomingMessage = (isRunning, messages) => {
|
1488
|
-
return isRunning && _optionalChain([messages, 'access',
|
1575
|
+
return isRunning && _optionalChain([messages, 'access', _64 => _64[messages.length - 1], 'optionalAccess', _65 => _65.role]) !== "assistant";
|
1489
1576
|
};
|
1490
|
-
var ExternalStoreThreadRuntime = (
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1577
|
+
var ExternalStoreThreadRuntime = (_class8 = class {
|
1578
|
+
__init21() {this._subscriptions = /* @__PURE__ */ new Set()}
|
1579
|
+
__init22() {this.repository = new MessageRepository()}
|
1580
|
+
__init23() {this.assistantOptimisticId = null}
|
1581
|
+
__init24() {this._capabilities = {
|
1495
1582
|
switchToBranch: false,
|
1496
1583
|
edit: false,
|
1497
1584
|
reload: false,
|
1498
1585
|
cancel: false,
|
1499
1586
|
unstable_copy: false,
|
1500
|
-
speak: false
|
1587
|
+
speak: false,
|
1588
|
+
attachments: false
|
1501
1589
|
}}
|
1502
1590
|
get capabilities() {
|
1503
1591
|
return this._capabilities;
|
@@ -1505,16 +1593,13 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1505
1593
|
|
1506
1594
|
|
1507
1595
|
|
1508
|
-
|
1596
|
+
__init25() {this.converter = new ThreadMessageConverter()}
|
1509
1597
|
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
}
|
1516
|
-
}}
|
1517
|
-
constructor(store) {;_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);_class7.prototype.__init22.call(this);_class7.prototype.__init23.call(this);_class7.prototype.__init24.call(this);
|
1598
|
+
__init26() {this.composer = new ThreadRuntimeComposer(
|
1599
|
+
this,
|
1600
|
+
this.notifySubscribers.bind(this)
|
1601
|
+
)}
|
1602
|
+
constructor(store) {;_class8.prototype.__init21.call(this);_class8.prototype.__init22.call(this);_class8.prototype.__init23.call(this);_class8.prototype.__init24.call(this);_class8.prototype.__init25.call(this);_class8.prototype.__init26.call(this);_class8.prototype.__init27.call(this);
|
1518
1603
|
this.store = store;
|
1519
1604
|
}
|
1520
1605
|
get store() {
|
@@ -1532,9 +1617,12 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1532
1617
|
edit: this._store.onEdit !== void 0,
|
1533
1618
|
reload: this._store.onReload !== void 0,
|
1534
1619
|
cancel: this._store.onCancel !== void 0,
|
1535
|
-
|
1536
|
-
|
1620
|
+
speak: this._store.onSpeak !== void 0,
|
1621
|
+
unstable_copy: _optionalChain([this, 'access', _69 => _69._store, 'access', _70 => _70.unstable_capabilities, 'optionalAccess', _71 => _71.copy]) !== false,
|
1622
|
+
// default true
|
1623
|
+
attachments: !!_optionalChain([this, 'access', _72 => _72.store, 'access', _73 => _73.adapters, 'optionalAccess', _74 => _74.attachments])
|
1537
1624
|
};
|
1625
|
+
this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _75 => _75._store, 'access', _76 => _76.adapters, 'optionalAccess', _77 => _77.attachments]));
|
1538
1626
|
if (oldStore) {
|
1539
1627
|
if (oldStore.convertMessage !== store.convertMessage) {
|
1540
1628
|
this.converter = new ThreadMessageConverter();
|
@@ -1560,7 +1648,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1560
1648
|
for (let i = 0; i < messages.length; i++) {
|
1561
1649
|
const message = messages[i];
|
1562
1650
|
const parent = messages[i - 1];
|
1563
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
1651
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _78 => _78.id]), () => ( null)), message);
|
1564
1652
|
}
|
1565
1653
|
if (this.assistantOptimisticId) {
|
1566
1654
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -1568,7 +1656,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1568
1656
|
}
|
1569
1657
|
if (hasUpcomingMessage(isRunning, messages)) {
|
1570
1658
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
1571
|
-
_nullishCoalesce(_optionalChain([messages, 'access',
|
1659
|
+
_nullishCoalesce(_optionalChain([messages, 'access', _79 => _79.at, 'call', _80 => _80(-1), 'optionalAccess', _81 => _81.id]), () => ( null)),
|
1572
1660
|
{
|
1573
1661
|
role: "assistant",
|
1574
1662
|
content: []
|
@@ -1576,7 +1664,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1576
1664
|
);
|
1577
1665
|
}
|
1578
1666
|
this.repository.resetHead(
|
1579
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access',
|
1667
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _82 => _82.at, 'call', _83 => _83(-1), 'optionalAccess', _84 => _84.id]))), () => ( null))
|
1580
1668
|
);
|
1581
1669
|
this.messages = this.repository.getMessages();
|
1582
1670
|
this.notifySubscribers();
|
@@ -1594,7 +1682,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1594
1682
|
this.updateMessages(this.repository.getMessages());
|
1595
1683
|
}
|
1596
1684
|
async append(message) {
|
1597
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
1685
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _85 => _85.messages, 'access', _86 => _86.at, 'call', _87 => _87(-1), 'optionalAccess', _88 => _88.id]), () => ( null)))) {
|
1598
1686
|
if (!this._store.onEdit)
|
1599
1687
|
throw new Error("Runtime does not support editing messages.");
|
1600
1688
|
await this._store.onEdit(message);
|
@@ -1617,7 +1705,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1617
1705
|
}
|
1618
1706
|
let messages = this.repository.getMessages();
|
1619
1707
|
const previousMessage = messages[messages.length - 1];
|
1620
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
1708
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _89 => _89.role]) === "user" && previousMessage.id === _optionalChain([messages, 'access', _90 => _90.at, 'call', _91 => _91(-1), 'optionalAccess', _92 => _92.id])) {
|
1621
1709
|
this.repository.deleteMessage(previousMessage.id);
|
1622
1710
|
if (!this.composer.text.trim()) {
|
1623
1711
|
this.composer.setText(getThreadMessageText(previousMessage));
|
@@ -1645,18 +1733,18 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1645
1733
|
this._subscriptions.add(callback);
|
1646
1734
|
return () => this._subscriptions.delete(callback);
|
1647
1735
|
}
|
1648
|
-
|
1649
|
-
_optionalChain([this, 'access',
|
1736
|
+
__init27() {this.updateMessages = (messages) => {
|
1737
|
+
_optionalChain([this, 'access', _93 => _93._store, 'access', _94 => _94.setMessages, 'optionalCall', _95 => _95(
|
1650
1738
|
messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
1651
1739
|
)]);
|
1652
1740
|
}}
|
1653
|
-
},
|
1741
|
+
}, _class8);
|
1654
1742
|
|
1655
1743
|
// src/runtimes/external-store/ExternalStoreRuntime.tsx
|
1656
|
-
var ExternalStoreRuntime = (
|
1657
|
-
|
1744
|
+
var ExternalStoreRuntime = (_class9 = class extends BaseAssistantRuntime {
|
1745
|
+
__init28() {this._proxyConfigProvider = new ProxyConfigProvider()}
|
1658
1746
|
constructor(store) {
|
1659
|
-
super(new ExternalStoreThreadRuntime(store));
|
1747
|
+
super(new ExternalStoreThreadRuntime(store));_class9.prototype.__init28.call(this);;
|
1660
1748
|
}
|
1661
1749
|
get store() {
|
1662
1750
|
return this.thread.store;
|
@@ -1689,7 +1777,7 @@ var ExternalStoreRuntime = (_class8 = class extends BaseAssistantRuntime {
|
|
1689
1777
|
await this.store.onNewThread();
|
1690
1778
|
}
|
1691
1779
|
}
|
1692
|
-
},
|
1780
|
+
}, _class9);
|
1693
1781
|
|
1694
1782
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
1695
1783
|
|
@@ -1857,18 +1945,18 @@ var DangerousInBrowserAdapter = class {
|
|
1857
1945
|
this.options = options;
|
1858
1946
|
}
|
1859
1947
|
async *run({ messages, abortSignal, config }) {
|
1860
|
-
const res = await
|
1948
|
+
const res = await _chunkBNSCUYW7js.getEdgeRuntimeStream.call(void 0, {
|
1861
1949
|
options: this.options,
|
1862
1950
|
abortSignal,
|
1863
1951
|
requestData: {
|
1864
1952
|
system: config.system,
|
1865
|
-
messages:
|
1866
|
-
tools: config.tools ?
|
1953
|
+
messages: _chunkBNSCUYW7js.toCoreMessages.call(void 0, messages),
|
1954
|
+
tools: config.tools ? _chunkBNSCUYW7js.toLanguageModelTools.call(void 0, config.tools) : [],
|
1867
1955
|
...config.callSettings,
|
1868
1956
|
...config.config
|
1869
1957
|
}
|
1870
1958
|
});
|
1871
|
-
const stream = res.pipeThrough(
|
1959
|
+
const stream = res.pipeThrough(_chunkBNSCUYW7js.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkBNSCUYW7js.runResultStream.call(void 0, ));
|
1872
1960
|
for await (const update of asAsyncIterable(stream)) {
|
1873
1961
|
yield update;
|
1874
1962
|
}
|
@@ -1925,6 +2013,147 @@ var WebSpeechSynthesisAdapter = class {
|
|
1925
2013
|
}
|
1926
2014
|
};
|
1927
2015
|
|
2016
|
+
// src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
|
2017
|
+
var SimpleImageAttachmentAdapter = (_class10 = class {constructor() { _class10.prototype.__init29.call(this); }
|
2018
|
+
__init29() {this.accept = "image/*"}
|
2019
|
+
async add(state) {
|
2020
|
+
return {
|
2021
|
+
id: state.file.name,
|
2022
|
+
type: "image",
|
2023
|
+
name: state.file.name,
|
2024
|
+
file: state.file
|
2025
|
+
};
|
2026
|
+
}
|
2027
|
+
async send(attachment) {
|
2028
|
+
return {
|
2029
|
+
...attachment,
|
2030
|
+
content: [
|
2031
|
+
{
|
2032
|
+
type: "image",
|
2033
|
+
image: await getFileDataURL(attachment.file)
|
2034
|
+
}
|
2035
|
+
]
|
2036
|
+
};
|
2037
|
+
}
|
2038
|
+
async remove() {
|
2039
|
+
}
|
2040
|
+
}, _class10);
|
2041
|
+
var getFileDataURL = (file) => new Promise((resolve, reject) => {
|
2042
|
+
const reader = new FileReader();
|
2043
|
+
reader.onload = () => resolve(reader.result);
|
2044
|
+
reader.onerror = (error) => reject(error);
|
2045
|
+
reader.readAsDataURL(file);
|
2046
|
+
});
|
2047
|
+
|
2048
|
+
// src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
|
2049
|
+
var SimpleTextAttachmentAdapter = (_class11 = class {constructor() { _class11.prototype.__init30.call(this); }
|
2050
|
+
__init30() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
|
2051
|
+
async add(state) {
|
2052
|
+
return {
|
2053
|
+
id: state.file.name,
|
2054
|
+
type: "document",
|
2055
|
+
name: state.file.name,
|
2056
|
+
file: state.file
|
2057
|
+
};
|
2058
|
+
}
|
2059
|
+
async send(attachment) {
|
2060
|
+
return {
|
2061
|
+
...attachment,
|
2062
|
+
content: [
|
2063
|
+
{
|
2064
|
+
type: "text",
|
2065
|
+
text: `<attachment name=${attachment.name}>
|
2066
|
+
${await getFileText(attachment.file)}
|
2067
|
+
</attachment>`
|
2068
|
+
}
|
2069
|
+
]
|
2070
|
+
};
|
2071
|
+
}
|
2072
|
+
async remove() {
|
2073
|
+
}
|
2074
|
+
}, _class11);
|
2075
|
+
var getFileText = (file) => new Promise((resolve, reject) => {
|
2076
|
+
const reader = new FileReader();
|
2077
|
+
reader.onload = () => resolve(reader.result);
|
2078
|
+
reader.onerror = (error) => reject(error);
|
2079
|
+
reader.readAsText(file);
|
2080
|
+
});
|
2081
|
+
|
2082
|
+
// src/runtimes/attachment/CompositeAttachmentAdapter.ts
|
2083
|
+
function fileMatchesAccept(file, acceptString) {
|
2084
|
+
if (acceptString === "*") {
|
2085
|
+
return true;
|
2086
|
+
}
|
2087
|
+
const allowedTypes = acceptString.split(",").map((type) => type.trim().toLowerCase());
|
2088
|
+
const fileExtension = "." + file.name.split(".").pop().toLowerCase();
|
2089
|
+
const fileMimeType = file.type.toLowerCase();
|
2090
|
+
for (const type of allowedTypes) {
|
2091
|
+
if (type.startsWith(".") && type === fileExtension) {
|
2092
|
+
return true;
|
2093
|
+
}
|
2094
|
+
if (type.includes("/") && type === fileMimeType) {
|
2095
|
+
return true;
|
2096
|
+
}
|
2097
|
+
if (type === "image/*" || type === "video/*" || type === "audio/*") {
|
2098
|
+
if (type.endsWith("/*")) {
|
2099
|
+
const generalType = type.split("/")[0];
|
2100
|
+
if (fileMimeType.startsWith(generalType + "/")) {
|
2101
|
+
return true;
|
2102
|
+
}
|
2103
|
+
}
|
2104
|
+
}
|
2105
|
+
}
|
2106
|
+
return false;
|
2107
|
+
}
|
2108
|
+
var CompositeAttachmentAdapter = class {
|
2109
|
+
|
2110
|
+
|
2111
|
+
constructor(adapters) {
|
2112
|
+
this._adapters = adapters;
|
2113
|
+
const wildcardIdx = adapters.findIndex((a) => a.accept === "*");
|
2114
|
+
if (wildcardIdx !== -1) {
|
2115
|
+
if (wildcardIdx !== adapters.length - 1)
|
2116
|
+
throw new Error(
|
2117
|
+
"A wildcard adapter (handling all files) can only be specified as the last adapter."
|
2118
|
+
);
|
2119
|
+
this.accept = "*";
|
2120
|
+
} else {
|
2121
|
+
this.accept = adapters.map((a) => a.accept).join(",");
|
2122
|
+
}
|
2123
|
+
}
|
2124
|
+
async add(state) {
|
2125
|
+
for (const adapter of this._adapters) {
|
2126
|
+
if (fileMatchesAccept(state.file, adapter.accept)) {
|
2127
|
+
return adapter.add(state);
|
2128
|
+
}
|
2129
|
+
}
|
2130
|
+
throw new Error("No matching adapter found for file");
|
2131
|
+
}
|
2132
|
+
async send(attachment) {
|
2133
|
+
const adapters = this._adapters.slice();
|
2134
|
+
for (const adapter of adapters) {
|
2135
|
+
if (fileMatchesAccept(attachment.file, adapter.accept)) {
|
2136
|
+
return adapter.send(attachment);
|
2137
|
+
}
|
2138
|
+
}
|
2139
|
+
throw new Error("No matching adapter found for attachment");
|
2140
|
+
}
|
2141
|
+
async remove(attachment) {
|
2142
|
+
const adapters = this._adapters.slice();
|
2143
|
+
for (const adapter of adapters) {
|
2144
|
+
if (fileMatchesAccept(attachment.file, adapter.accept)) {
|
2145
|
+
return adapter.remove(attachment);
|
2146
|
+
}
|
2147
|
+
}
|
2148
|
+
throw new Error("No matching adapter found for attachment");
|
2149
|
+
}
|
2150
|
+
};
|
2151
|
+
|
2152
|
+
// src/context/ReadonlyStore.ts
|
2153
|
+
var writableStore = (store) => {
|
2154
|
+
return store;
|
2155
|
+
};
|
2156
|
+
|
1928
2157
|
// src/context/providers/ThreadProvider.tsx
|
1929
2158
|
|
1930
2159
|
var ThreadProvider = ({
|
@@ -1954,18 +2183,20 @@ var ThreadProvider = ({
|
|
1954
2183
|
const state = getThreadStateFromRuntime(thread);
|
1955
2184
|
if (oldState.threadId !== state.threadId || oldState.isDisabled !== state.isDisabled || oldState.isRunning !== state.isRunning || // TODO ensure capabilities is memoized
|
1956
2185
|
oldState.capabilities !== state.capabilities) {
|
1957
|
-
context.useThread.setState(
|
1958
|
-
state,
|
1959
|
-
true
|
1960
|
-
);
|
2186
|
+
writableStore(context.useThread).setState(state, true);
|
1961
2187
|
}
|
1962
2188
|
if (thread.messages !== context.useThreadMessages.getState()) {
|
1963
|
-
context.useThreadMessages.setState(
|
2189
|
+
writableStore(context.useThreadMessages).setState(
|
2190
|
+
thread.messages,
|
2191
|
+
true
|
2192
|
+
);
|
1964
2193
|
}
|
1965
2194
|
const composerState = context.useComposer.getState();
|
1966
|
-
if (thread.composer.text !== composerState.text || state.capabilities.cancel !== composerState.canCancel) {
|
1967
|
-
context.useComposer.setState({
|
2195
|
+
if (thread.composer.isEmpty !== composerState.isEmpty || thread.composer.text !== composerState.text || thread.composer.attachments !== composerState.attachments || state.capabilities.cancel !== composerState.canCancel) {
|
2196
|
+
writableStore(context.useComposer).setState({
|
2197
|
+
isEmpty: thread.composer.isEmpty,
|
1968
2198
|
text: thread.composer.text,
|
2199
|
+
attachments: thread.composer.attachments,
|
1969
2200
|
canCancel: state.capabilities.cancel
|
1970
2201
|
});
|
1971
2202
|
}
|
@@ -1975,7 +2206,7 @@ var ThreadProvider = ({
|
|
1975
2206
|
}, [provider, context]);
|
1976
2207
|
_react.useInsertionEffect.call(void 0,
|
1977
2208
|
() => provider.subscribe(() => {
|
1978
|
-
context.useThreadRuntime.setState(provider.thread, true);
|
2209
|
+
writableStore(context.useThreadRuntime).setState(provider.thread, true);
|
1979
2210
|
}),
|
1980
2211
|
[provider, context]
|
1981
2212
|
);
|
@@ -2027,7 +2258,7 @@ var AssistantProvider = ({ children, runtime }) => {
|
|
2027
2258
|
return runtime.registerModelConfigProvider(getModelConfig);
|
2028
2259
|
}, [runtime, getModelConfig]);
|
2029
2260
|
_react.useEffect.call(void 0,
|
2030
|
-
() => context.useAssistantRuntime.setState(runtime, true),
|
2261
|
+
() => writableStore(context.useAssistantRuntime).setState(runtime, true),
|
2031
2262
|
[runtime, context]
|
2032
2263
|
);
|
2033
2264
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantContext.Provider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadProvider, { provider: runtime, children }) });
|
@@ -2048,7 +2279,7 @@ var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProvider
|
|
2048
2279
|
var MessageContext = _react.createContext.call(void 0, null);
|
2049
2280
|
function useMessageContext(options) {
|
2050
2281
|
const context = _react.useContext.call(void 0, MessageContext);
|
2051
|
-
if (!_optionalChain([options, 'optionalAccess',
|
2282
|
+
if (!_optionalChain([options, 'optionalAccess', _96 => _96.optional]) && !context)
|
2052
2283
|
throw new Error(
|
2053
2284
|
"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
|
2054
2285
|
);
|
@@ -2075,7 +2306,7 @@ var ContentPartContext = _react.createContext.call(void 0,
|
|
2075
2306
|
);
|
2076
2307
|
function useContentPartContext(options) {
|
2077
2308
|
const context = _react.useContext.call(void 0, ContentPartContext);
|
2078
|
-
if (!_optionalChain([options, 'optionalAccess',
|
2309
|
+
if (!_optionalChain([options, 'optionalAccess', _97 => _97.optional]) && !context)
|
2079
2310
|
throw new Error(
|
2080
2311
|
"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
|
2081
2312
|
);
|
@@ -2087,15 +2318,17 @@ function useContentPartContext(options) {
|
|
2087
2318
|
var toAppendMessage = (useThreadMessages, message) => {
|
2088
2319
|
if (typeof message === "string") {
|
2089
2320
|
return {
|
2090
|
-
parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access',
|
2321
|
+
parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _98 => _98.getState, 'call', _99 => _99(), 'access', _100 => _100.at, 'call', _101 => _101(-1), 'optionalAccess', _102 => _102.id]), () => ( null)),
|
2091
2322
|
role: "user",
|
2092
|
-
content: [{ type: "text", text: message }]
|
2323
|
+
content: [{ type: "text", text: message }],
|
2324
|
+
attachments: []
|
2093
2325
|
};
|
2094
2326
|
}
|
2095
2327
|
return {
|
2096
|
-
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access',
|
2328
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _103 => _103.getState, 'call', _104 => _104(), 'access', _105 => _105.at, 'call', _106 => _106(-1), 'optionalAccess', _107 => _107.id]))), () => ( null)),
|
2097
2329
|
role: _nullishCoalesce(message.role, () => ( "user")),
|
2098
|
-
content: message.content
|
2330
|
+
content: message.content,
|
2331
|
+
attachments: _nullishCoalesce(message.attachments, () => ( []))
|
2099
2332
|
};
|
2100
2333
|
};
|
2101
2334
|
var useAppendMessage = () => {
|
@@ -2145,7 +2378,7 @@ var useAssistantTool = (tool) => {
|
|
2145
2378
|
const unsub2 = render ? setToolUI(toolName, render) : void 0;
|
2146
2379
|
return () => {
|
2147
2380
|
unsub1();
|
2148
|
-
_optionalChain([unsub2, 'optionalCall',
|
2381
|
+
_optionalChain([unsub2, 'optionalCall', _108 => _108()]);
|
2149
2382
|
};
|
2150
2383
|
}, [registerModelConfigProvider, setToolUI, tool]);
|
2151
2384
|
};
|
@@ -2400,7 +2633,7 @@ var useComposerSend = () => {
|
|
2400
2633
|
const { useComposer } = useComposerContext();
|
2401
2634
|
const disabled = useCombinedStore(
|
2402
2635
|
[useThread, useComposer],
|
2403
|
-
(t, c) => t.isRunning || !c.isEditing || c.
|
2636
|
+
(t, c) => t.isRunning || !c.isEditing || c.isEmpty
|
2404
2637
|
);
|
2405
2638
|
const callback = _react.useCallback.call(void 0, () => {
|
2406
2639
|
const composerState = useComposer.getState();
|
@@ -2413,6 +2646,30 @@ var useComposerSend = () => {
|
|
2413
2646
|
return callback;
|
2414
2647
|
};
|
2415
2648
|
|
2649
|
+
// src/primitive-hooks/composer/useComposerAddAttachment.tsx
|
2650
|
+
|
2651
|
+
var useComposerAddAttachment = () => {
|
2652
|
+
const { useComposer, useThreadRuntime } = useThreadContext();
|
2653
|
+
const disabled = useComposer((c) => !c.isEditing);
|
2654
|
+
const callback = _react.useCallback.call(void 0, () => {
|
2655
|
+
const { addAttachment } = useComposer.getState();
|
2656
|
+
const { attachmentAccept } = useThreadRuntime.getState().composer;
|
2657
|
+
const input = document.createElement("input");
|
2658
|
+
input.type = "file";
|
2659
|
+
if (attachmentAccept !== "*") {
|
2660
|
+
input.accept = attachmentAccept;
|
2661
|
+
}
|
2662
|
+
input.onchange = (e) => {
|
2663
|
+
const file = _optionalChain([e, 'access', _109 => _109.target, 'access', _110 => _110.files, 'optionalAccess', _111 => _111[0]]);
|
2664
|
+
if (!file) return;
|
2665
|
+
addAttachment(file);
|
2666
|
+
};
|
2667
|
+
input.click();
|
2668
|
+
}, [useComposer, useThreadRuntime]);
|
2669
|
+
if (disabled) return null;
|
2670
|
+
return callback;
|
2671
|
+
};
|
2672
|
+
|
2416
2673
|
// src/primitive-hooks/contentPart/useContentPartDisplay.tsx
|
2417
2674
|
var useContentPartDisplay = () => {
|
2418
2675
|
const { useContentPart } = useContentPartContext();
|
@@ -2467,6 +2724,10 @@ var useMessageIf = (props) => {
|
|
2467
2724
|
if (props.copied === false && isCopied) return false;
|
2468
2725
|
if (props.speaking === true && !isSpeaking) return false;
|
2469
2726
|
if (props.speaking === false && isSpeaking) return false;
|
2727
|
+
if (props.hasAttachments === true && (message.role !== "user" || !message.attachments.length))
|
2728
|
+
return false;
|
2729
|
+
if (props.hasAttachments === false && message.role === "user" && !!message.attachments.length)
|
2730
|
+
return false;
|
2470
2731
|
return true;
|
2471
2732
|
}
|
2472
2733
|
);
|
@@ -2612,7 +2873,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
|
2612
2873
|
...primitiveProps,
|
2613
2874
|
ref: forwardedRef,
|
2614
2875
|
onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
|
2615
|
-
_optionalChain([callback, 'optionalCall',
|
2876
|
+
_optionalChain([callback, 'optionalCall', _112 => _112()]);
|
2616
2877
|
})
|
2617
2878
|
}
|
2618
2879
|
);
|
@@ -2668,7 +2929,7 @@ var ActionBarPrimitiveStopSpeaking = _react.forwardRef.call(void 0, (props, ref)
|
|
2668
2929
|
...props,
|
2669
2930
|
ref,
|
2670
2931
|
onClick: _primitive.composeEventHandlers.call(void 0, props.onClick, () => {
|
2671
|
-
_optionalChain([callback, 'optionalCall',
|
2932
|
+
_optionalChain([callback, 'optionalCall', _113 => _113()]);
|
2672
2933
|
})
|
2673
2934
|
}
|
2674
2935
|
);
|
@@ -2844,6 +3105,7 @@ BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
|
|
2844
3105
|
// src/primitives/message/index.ts
|
2845
3106
|
var message_exports = {};
|
2846
3107
|
_chunkDCHYNTHIjs.__export.call(void 0, message_exports, {
|
3108
|
+
Attachments: () => MessagePrimitiveAttachments,
|
2847
3109
|
Content: () => MessagePrimitiveContent,
|
2848
3110
|
If: () => MessagePrimitiveIf,
|
2849
3111
|
InProgress: () => MessagePrimitiveInProgress,
|
@@ -2954,7 +3216,7 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
|
|
2954
3216
|
}
|
2955
3217
|
}
|
2956
3218
|
const status = toContentPartStatus(message, partIndex, part);
|
2957
|
-
const currentState = _optionalChain([useContentPart, 'optionalAccess',
|
3219
|
+
const currentState = _optionalChain([useContentPart, 'optionalAccess', _114 => _114.getState, 'call', _115 => _115()]);
|
2958
3220
|
if (currentState && currentState.part === part && currentState.status === status)
|
2959
3221
|
return null;
|
2960
3222
|
return Object.freeze({ part, status });
|
@@ -2975,7 +3237,7 @@ var useContentPartContext2 = (partIndex) => {
|
|
2975
3237
|
partIndex
|
2976
3238
|
);
|
2977
3239
|
if (!newState) return;
|
2978
|
-
context.useContentPart.setState(newState, true);
|
3240
|
+
writableStore(context.useContentPart).setState(newState, true);
|
2979
3241
|
};
|
2980
3242
|
syncContentPart(useMessage.getState());
|
2981
3243
|
return useMessage.subscribe(syncContentPart);
|
@@ -3112,24 +3374,14 @@ var MessageContentPartImpl = ({
|
|
3112
3374
|
};
|
3113
3375
|
var MessageContentPart = _react.memo.call(void 0,
|
3114
3376
|
MessageContentPartImpl,
|
3115
|
-
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access',
|
3377
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _116 => _116.components, 'optionalAccess', _117 => _117.Text]) === _optionalChain([next, 'access', _118 => _118.components, 'optionalAccess', _119 => _119.Text]) && _optionalChain([prev, 'access', _120 => _120.components, 'optionalAccess', _121 => _121.Image]) === _optionalChain([next, 'access', _122 => _122.components, 'optionalAccess', _123 => _123.Image]) && _optionalChain([prev, 'access', _124 => _124.components, 'optionalAccess', _125 => _125.UI]) === _optionalChain([next, 'access', _126 => _126.components, 'optionalAccess', _127 => _127.UI]) && _optionalChain([prev, 'access', _128 => _128.components, 'optionalAccess', _129 => _129.tools]) === _optionalChain([next, 'access', _130 => _130.components, 'optionalAccess', _131 => _131.tools])
|
3116
3378
|
);
|
3117
3379
|
var MessagePrimitiveContent = ({
|
3118
3380
|
components
|
3119
3381
|
}) => {
|
3120
3382
|
const { useMessage } = useMessageContext();
|
3121
3383
|
const contentLength = useMessage((s) => s.message.content.length) || 1;
|
3122
|
-
return
|
3123
|
-
const partIndex = idx;
|
3124
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
3125
|
-
MessageContentPart,
|
3126
|
-
{
|
3127
|
-
partIndex,
|
3128
|
-
components
|
3129
|
-
},
|
3130
|
-
partIndex
|
3131
|
-
);
|
3132
|
-
});
|
3384
|
+
return Array.from({ length: contentLength }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContentPart, { partIndex: index, components }, index));
|
3133
3385
|
};
|
3134
3386
|
MessagePrimitiveContent.displayName = "MessagePrimitive.Content";
|
3135
3387
|
|
@@ -3139,6 +3391,125 @@ var MessagePrimitiveInProgress = () => {
|
|
3139
3391
|
};
|
3140
3392
|
MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
|
3141
3393
|
|
3394
|
+
// src/primitives/message/MessageAttachments.tsx
|
3395
|
+
|
3396
|
+
|
3397
|
+
// src/context/react/AttachmentContext.ts
|
3398
|
+
|
3399
|
+
var AttachmentContext = _react.createContext.call(void 0,
|
3400
|
+
null
|
3401
|
+
);
|
3402
|
+
function useAttachmentContext(options) {
|
3403
|
+
const context = _react.useContext.call(void 0, AttachmentContext);
|
3404
|
+
if (_optionalChain([options, 'optionalAccess', _132 => _132.type]) === "composer" && _optionalChain([context, 'optionalAccess', _133 => _133.type]) !== "composer")
|
3405
|
+
throw new Error(
|
3406
|
+
"This component must be used within a ComposerPrimitive.Attachments component."
|
3407
|
+
);
|
3408
|
+
if (_optionalChain([options, 'optionalAccess', _134 => _134.type]) === "message" && _optionalChain([context, 'optionalAccess', _135 => _135.type]) !== "message")
|
3409
|
+
throw new Error(
|
3410
|
+
"This component must be used within a MessagePrimitive.Attachments component."
|
3411
|
+
);
|
3412
|
+
if (!_optionalChain([options, 'optionalAccess', _136 => _136.optional]) && !context)
|
3413
|
+
throw new Error(
|
3414
|
+
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
3415
|
+
);
|
3416
|
+
return context;
|
3417
|
+
}
|
3418
|
+
|
3419
|
+
// src/context/providers/MessageAttachmentProvider.tsx
|
3420
|
+
|
3421
|
+
|
3422
|
+
|
3423
|
+
var getAttachment = ({ message }, useAttachment, partIndex) => {
|
3424
|
+
if (message.role !== "user") return null;
|
3425
|
+
const attachments = message.attachments;
|
3426
|
+
let attachment = attachments[partIndex];
|
3427
|
+
if (!attachment) return null;
|
3428
|
+
const currentState = _optionalChain([useAttachment, 'optionalAccess', _137 => _137.getState, 'call', _138 => _138()]);
|
3429
|
+
if (currentState && currentState.attachment === attachment) return null;
|
3430
|
+
return Object.freeze({ attachment });
|
3431
|
+
};
|
3432
|
+
var useMessageAttachmentContext = (partIndex) => {
|
3433
|
+
const { useMessage } = useMessageContext();
|
3434
|
+
const [context] = _react.useState.call(void 0,
|
3435
|
+
() => {
|
3436
|
+
const useAttachment = _zustand.create.call(void 0,
|
3437
|
+
() => getAttachment(useMessage.getState(), void 0, partIndex)
|
3438
|
+
);
|
3439
|
+
return { type: "message", useAttachment };
|
3440
|
+
}
|
3441
|
+
);
|
3442
|
+
_react.useEffect.call(void 0, () => {
|
3443
|
+
const syncAttachment = (messageState) => {
|
3444
|
+
const newState = getAttachment(
|
3445
|
+
messageState,
|
3446
|
+
context.useAttachment,
|
3447
|
+
partIndex
|
3448
|
+
);
|
3449
|
+
if (!newState) return;
|
3450
|
+
writableStore(context.useAttachment).setState(newState, true);
|
3451
|
+
};
|
3452
|
+
syncAttachment(useMessage.getState());
|
3453
|
+
return useMessage.subscribe(syncAttachment);
|
3454
|
+
}, [context, useMessage, partIndex]);
|
3455
|
+
return context;
|
3456
|
+
};
|
3457
|
+
var MessageAttachmentProvider = ({
|
3458
|
+
attachmentIndex: partIndex,
|
3459
|
+
children
|
3460
|
+
}) => {
|
3461
|
+
const context = useMessageAttachmentContext(partIndex);
|
3462
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentContext.Provider, { value: context, children });
|
3463
|
+
};
|
3464
|
+
|
3465
|
+
// src/primitives/message/MessageAttachments.tsx
|
3466
|
+
|
3467
|
+
var getComponent = (components, attachment) => {
|
3468
|
+
const type = attachment.type;
|
3469
|
+
switch (type) {
|
3470
|
+
case "image":
|
3471
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _139 => _139.Image]), () => ( _optionalChain([components, 'optionalAccess', _140 => _140.Attachment])));
|
3472
|
+
case "document":
|
3473
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _141 => _141.Document]), () => ( _optionalChain([components, 'optionalAccess', _142 => _142.Attachment])));
|
3474
|
+
case "file":
|
3475
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _143 => _143.File]), () => ( _optionalChain([components, 'optionalAccess', _144 => _144.Attachment])));
|
3476
|
+
default:
|
3477
|
+
const _exhaustiveCheck = type;
|
3478
|
+
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
3479
|
+
}
|
3480
|
+
};
|
3481
|
+
var AttachmentComponent = ({ components }) => {
|
3482
|
+
const { useAttachment } = useAttachmentContext({ type: "message" });
|
3483
|
+
const Component = useAttachment(
|
3484
|
+
(a) => getComponent(components, a.attachment)
|
3485
|
+
);
|
3486
|
+
if (!Component) return null;
|
3487
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, {});
|
3488
|
+
};
|
3489
|
+
var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
3490
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageAttachmentProvider, { attachmentIndex, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentComponent, { components }) });
|
3491
|
+
};
|
3492
|
+
var MessageAttachment = _react.memo.call(void 0,
|
3493
|
+
MessageAttachmentImpl,
|
3494
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _145 => _145.components, 'optionalAccess', _146 => _146.Image]) === _optionalChain([next, 'access', _147 => _147.components, 'optionalAccess', _148 => _148.Image]) && _optionalChain([prev, 'access', _149 => _149.components, 'optionalAccess', _150 => _150.Document]) === _optionalChain([next, 'access', _151 => _151.components, 'optionalAccess', _152 => _152.Document]) && _optionalChain([prev, 'access', _153 => _153.components, 'optionalAccess', _154 => _154.File]) === _optionalChain([next, 'access', _155 => _155.components, 'optionalAccess', _156 => _156.File]) && _optionalChain([prev, 'access', _157 => _157.components, 'optionalAccess', _158 => _158.Attachment]) === _optionalChain([next, 'access', _159 => _159.components, 'optionalAccess', _160 => _160.Attachment])
|
3495
|
+
);
|
3496
|
+
var MessagePrimitiveAttachments = ({ components }) => {
|
3497
|
+
const { useMessage } = useMessageContext();
|
3498
|
+
const attachmentsCount = useMessage(({ message }) => {
|
3499
|
+
if (message.role !== "user") return 0;
|
3500
|
+
return message.attachments.length;
|
3501
|
+
});
|
3502
|
+
return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
3503
|
+
MessageAttachment,
|
3504
|
+
{
|
3505
|
+
attachmentIndex: index,
|
3506
|
+
components
|
3507
|
+
},
|
3508
|
+
index
|
3509
|
+
));
|
3510
|
+
};
|
3511
|
+
MessagePrimitiveAttachments.displayName = "MessagePrimitive.Attachments";
|
3512
|
+
|
3142
3513
|
// src/primitives/branchPicker/BranchPickerRoot.tsx
|
3143
3514
|
|
3144
3515
|
var BranchPickerPrimitiveRoot = _react.forwardRef.call(void 0, ({ hideWhenSingleBranch, ...rest }, ref) => {
|
@@ -3149,6 +3520,8 @@ BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
|
|
3149
3520
|
// src/primitives/composer/index.ts
|
3150
3521
|
var composer_exports = {};
|
3151
3522
|
_chunkDCHYNTHIjs.__export.call(void 0, composer_exports, {
|
3523
|
+
AddAttachment: () => ComposerPrimitiveAddAttachment,
|
3524
|
+
Attachments: () => ComposerPrimitiveAttachments,
|
3152
3525
|
Cancel: () => ComposerPrimitiveCancel,
|
3153
3526
|
If: () => ComposerPrimitiveIf,
|
3154
3527
|
Input: () => ComposerPrimitiveInput,
|
@@ -3227,7 +3600,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
3227
3600
|
const { isRunning } = useThread.getState();
|
3228
3601
|
if (!isRunning) {
|
3229
3602
|
e.preventDefault();
|
3230
|
-
_optionalChain([textareaRef, 'access',
|
3603
|
+
_optionalChain([textareaRef, 'access', _161 => _161.current, 'optionalAccess', _162 => _162.closest, 'call', _163 => _163("form"), 'optionalAccess', _164 => _164.requestSubmit, 'call', _165 => _165()]);
|
3231
3604
|
}
|
3232
3605
|
}
|
3233
3606
|
};
|
@@ -3268,29 +3641,111 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
3268
3641
|
ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
|
3269
3642
|
|
3270
3643
|
// src/primitives/composer/ComposerSend.tsx
|
3644
|
+
var ComposerPrimitiveSend = createActionButton(
|
3645
|
+
"ComposerPrimitive.Send",
|
3646
|
+
useComposerSend
|
3647
|
+
);
|
3648
|
+
|
3649
|
+
// src/primitives/composer/ComposerCancel.tsx
|
3650
|
+
var ComposerPrimitiveCancel = createActionButton(
|
3651
|
+
"ComposerPrimitive.Cancel",
|
3652
|
+
useComposerCancel
|
3653
|
+
);
|
3271
3654
|
|
3655
|
+
// src/primitives/composer/ComposerAddAttachment.tsx
|
3656
|
+
var ComposerPrimitiveAddAttachment = createActionButton(
|
3657
|
+
"ComposerPrimitive.AddAttachment",
|
3658
|
+
useComposerAddAttachment
|
3659
|
+
);
|
3272
3660
|
|
3661
|
+
// src/primitives/composer/ComposerAttachments.tsx
|
3273
3662
|
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3278
|
-
|
3279
|
-
|
3280
|
-
|
3281
|
-
|
3282
|
-
|
3283
|
-
|
3663
|
+
|
3664
|
+
// src/context/providers/ComposerAttachmentProvider.tsx
|
3665
|
+
|
3666
|
+
|
3667
|
+
|
3668
|
+
var getAttachment2 = ({ attachments }, useAttachment, partIndex) => {
|
3669
|
+
let attachment = attachments[partIndex];
|
3670
|
+
if (!attachment) return null;
|
3671
|
+
const currentState = _optionalChain([useAttachment, 'optionalAccess', _166 => _166.getState, 'call', _167 => _167()]);
|
3672
|
+
if (currentState && currentState.attachment === attachment) return null;
|
3673
|
+
return Object.freeze({ attachment });
|
3674
|
+
};
|
3675
|
+
var useComposerAttachmentContext = (partIndex) => {
|
3676
|
+
const { useComposer } = useThreadContext();
|
3677
|
+
const [context] = _react.useState.call(void 0,
|
3678
|
+
() => {
|
3679
|
+
const useAttachment = _zustand.create.call(void 0,
|
3680
|
+
() => getAttachment2(useComposer.getState(), void 0, partIndex)
|
3681
|
+
);
|
3682
|
+
return { type: "composer", useAttachment };
|
3284
3683
|
}
|
3285
3684
|
);
|
3286
|
-
|
3287
|
-
|
3685
|
+
_react.useEffect.call(void 0, () => {
|
3686
|
+
const syncAttachment = (composer) => {
|
3687
|
+
const newState = getAttachment2(
|
3688
|
+
composer,
|
3689
|
+
context.useAttachment,
|
3690
|
+
partIndex
|
3691
|
+
);
|
3692
|
+
if (!newState) return;
|
3693
|
+
writableStore(context.useAttachment).setState(newState, true);
|
3694
|
+
};
|
3695
|
+
syncAttachment(useComposer.getState());
|
3696
|
+
return useComposer.subscribe(syncAttachment);
|
3697
|
+
}, [context, useComposer, partIndex]);
|
3698
|
+
return context;
|
3699
|
+
};
|
3700
|
+
var ComposerAttachmentProvider = ({ attachmentIndex: partIndex, children }) => {
|
3701
|
+
const context = useComposerAttachmentContext(partIndex);
|
3702
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentContext.Provider, { value: context, children });
|
3703
|
+
};
|
3288
3704
|
|
3289
|
-
// src/primitives/composer/
|
3290
|
-
|
3291
|
-
|
3292
|
-
|
3705
|
+
// src/primitives/composer/ComposerAttachments.tsx
|
3706
|
+
|
3707
|
+
var getComponent2 = (components, attachment) => {
|
3708
|
+
const type = attachment.type;
|
3709
|
+
switch (type) {
|
3710
|
+
case "image":
|
3711
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _168 => _168.Image]), () => ( _optionalChain([components, 'optionalAccess', _169 => _169.Attachment])));
|
3712
|
+
case "document":
|
3713
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _170 => _170.Document]), () => ( _optionalChain([components, 'optionalAccess', _171 => _171.Attachment])));
|
3714
|
+
case "file":
|
3715
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _172 => _172.File]), () => ( _optionalChain([components, 'optionalAccess', _173 => _173.Attachment])));
|
3716
|
+
default:
|
3717
|
+
const _exhaustiveCheck = type;
|
3718
|
+
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
3719
|
+
}
|
3720
|
+
};
|
3721
|
+
var AttachmentComponent2 = ({ components }) => {
|
3722
|
+
const { useAttachment } = useAttachmentContext({ type: "composer" });
|
3723
|
+
const Component = useAttachment(
|
3724
|
+
(a) => getComponent2(components, a.attachment)
|
3725
|
+
);
|
3726
|
+
if (!Component) return null;
|
3727
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, {});
|
3728
|
+
};
|
3729
|
+
var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
3730
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAttachmentProvider, { attachmentIndex, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentComponent2, { components }) });
|
3731
|
+
};
|
3732
|
+
var ComposerAttachment = _react.memo.call(void 0,
|
3733
|
+
ComposerAttachmentImpl,
|
3734
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _174 => _174.components, 'optionalAccess', _175 => _175.Image]) === _optionalChain([next, 'access', _176 => _176.components, 'optionalAccess', _177 => _177.Image]) && _optionalChain([prev, 'access', _178 => _178.components, 'optionalAccess', _179 => _179.Document]) === _optionalChain([next, 'access', _180 => _180.components, 'optionalAccess', _181 => _181.Document]) && _optionalChain([prev, 'access', _182 => _182.components, 'optionalAccess', _183 => _183.File]) === _optionalChain([next, 'access', _184 => _184.components, 'optionalAccess', _185 => _185.File]) && _optionalChain([prev, 'access', _186 => _186.components, 'optionalAccess', _187 => _187.Attachment]) === _optionalChain([next, 'access', _188 => _188.components, 'optionalAccess', _189 => _189.Attachment])
|
3293
3735
|
);
|
3736
|
+
var ComposerPrimitiveAttachments = ({ components }) => {
|
3737
|
+
const { useComposer } = useThreadContext();
|
3738
|
+
const attachmentsCount = useComposer((s) => s.attachments.length);
|
3739
|
+
return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
3740
|
+
ComposerAttachment,
|
3741
|
+
{
|
3742
|
+
attachmentIndex: index,
|
3743
|
+
components
|
3744
|
+
},
|
3745
|
+
index
|
3746
|
+
));
|
3747
|
+
};
|
3748
|
+
ComposerPrimitiveAttachments.displayName = "ComposerPrimitive.Attachments";
|
3294
3749
|
|
3295
3750
|
// src/primitives/composer/ComposerIf.tsx
|
3296
3751
|
var ComposerPrimitiveIf = ({
|
@@ -3438,9 +3893,7 @@ var useThreadViewportAutoScroll = ({
|
|
3438
3893
|
isScrollingToBottomRef.current = false;
|
3439
3894
|
}
|
3440
3895
|
if (newIsAtBottom !== isAtBottom) {
|
3441
|
-
useViewport.setState({
|
3442
|
-
isAtBottom: newIsAtBottom
|
3443
|
-
});
|
3896
|
+
writableStore(useViewport).setState({ isAtBottom: newIsAtBottom });
|
3444
3897
|
}
|
3445
3898
|
}
|
3446
3899
|
lastScrollTop.current = div.scrollTop;
|
@@ -3496,13 +3949,19 @@ var makeEditComposerStore = ({
|
|
3496
3949
|
},
|
3497
3950
|
text: "",
|
3498
3951
|
setText: (text) => {
|
3499
|
-
set({ text });
|
3952
|
+
set({ text, isEmpty: text.trim().length === 0 });
|
3500
3953
|
},
|
3501
3954
|
canCancel: false,
|
3502
3955
|
isEditing: false,
|
3956
|
+
isEmpty: true,
|
3503
3957
|
edit: () => {
|
3504
3958
|
const text = onEdit();
|
3505
|
-
set({
|
3959
|
+
set({
|
3960
|
+
isEditing: true,
|
3961
|
+
canCancel: true,
|
3962
|
+
isEmpty: text.trim().length === 0,
|
3963
|
+
text
|
3964
|
+
});
|
3506
3965
|
},
|
3507
3966
|
send: () => {
|
3508
3967
|
const text = get().text;
|
@@ -3529,7 +3988,7 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
|
|
3529
3988
|
},
|
3530
3989
|
isSpeaking: false,
|
3531
3990
|
stopSpeaking: () => {
|
3532
|
-
_optionalChain([utterance, 'optionalAccess',
|
3991
|
+
_optionalChain([utterance, 'optionalAccess', _190 => _190.cancel, 'call', _191 => _191()]);
|
3533
3992
|
},
|
3534
3993
|
addUtterance: (utt) => {
|
3535
3994
|
utterance = utt;
|
@@ -3544,15 +4003,15 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
|
|
3544
4003
|
// src/context/providers/MessageProvider.tsx
|
3545
4004
|
|
3546
4005
|
var getIsLast = (messages, message) => {
|
3547
|
-
return _optionalChain([messages, 'access',
|
4006
|
+
return _optionalChain([messages, 'access', _192 => _192[messages.length - 1], 'optionalAccess', _193 => _193.id]) === message.id;
|
3548
4007
|
};
|
3549
4008
|
var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
3550
|
-
const parentId = _nullishCoalesce(_optionalChain([messages, 'access',
|
4009
|
+
const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _194 => _194[messageIndex - 1], 'optionalAccess', _195 => _195.id]), () => ( null));
|
3551
4010
|
const message = messages[messageIndex];
|
3552
4011
|
if (!message) return null;
|
3553
4012
|
const isLast = getIsLast(messages, message);
|
3554
4013
|
const branches = getBranches(message.id);
|
3555
|
-
const currentState = _optionalChain([useMessage, 'optionalAccess',
|
4014
|
+
const currentState = _optionalChain([useMessage, 'optionalAccess', _196 => _196.getState, 'call', _197 => _197()]);
|
3556
4015
|
if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
|
3557
4016
|
return null;
|
3558
4017
|
return Object.freeze({
|
@@ -3596,7 +4055,8 @@ var useMessageContext2 = (messageIndex) => {
|
|
3596
4055
|
useThreadActions.getState().append({
|
3597
4056
|
parentId,
|
3598
4057
|
role: "user",
|
3599
|
-
content: [{ type: "text", text }, ...nonTextParts]
|
4058
|
+
content: [{ type: "text", text }, ...nonTextParts],
|
4059
|
+
attachments: message.attachments
|
3600
4060
|
});
|
3601
4061
|
}
|
3602
4062
|
});
|
@@ -3611,10 +4071,7 @@ var useMessageContext2 = (messageIndex) => {
|
|
3611
4071
|
messageIndex
|
3612
4072
|
);
|
3613
4073
|
if (!newState) return;
|
3614
|
-
context.useMessage.setState(
|
3615
|
-
newState,
|
3616
|
-
true
|
3617
|
-
);
|
4074
|
+
writableStore(context.useMessage).setState(newState, true);
|
3618
4075
|
};
|
3619
4076
|
syncMessage(useThreadMessages.getState());
|
3620
4077
|
return useThreadMessages.subscribe(syncMessage);
|
@@ -3664,22 +4121,12 @@ var ThreadPrimitiveMessagesImpl = ({
|
|
3664
4121
|
const { useThreadMessages } = useThreadContext();
|
3665
4122
|
const messagesLength = useThreadMessages((t) => t.length);
|
3666
4123
|
if (messagesLength === 0) return null;
|
3667
|
-
return
|
3668
|
-
const messageIndex = idx;
|
3669
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
3670
|
-
ThreadMessage,
|
3671
|
-
{
|
3672
|
-
messageIndex,
|
3673
|
-
components
|
3674
|
-
},
|
3675
|
-
messageIndex
|
3676
|
-
);
|
3677
|
-
});
|
4124
|
+
return Array.from({ length: messagesLength }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessage, { messageIndex: index, components }, index));
|
3678
4125
|
};
|
3679
4126
|
ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
|
3680
4127
|
var ThreadPrimitiveMessages = _react.memo.call(void 0,
|
3681
4128
|
ThreadPrimitiveMessagesImpl,
|
3682
|
-
(prev, next) => _optionalChain([prev, 'access',
|
4129
|
+
(prev, next) => _optionalChain([prev, 'access', _198 => _198.components, 'optionalAccess', _199 => _199.Message]) === _optionalChain([next, 'access', _200 => _200.components, 'optionalAccess', _201 => _201.Message]) && _optionalChain([prev, 'access', _202 => _202.components, 'optionalAccess', _203 => _203.UserMessage]) === _optionalChain([next, 'access', _204 => _204.components, 'optionalAccess', _205 => _205.UserMessage]) && _optionalChain([prev, 'access', _206 => _206.components, 'optionalAccess', _207 => _207.EditComposer]) === _optionalChain([next, 'access', _208 => _208.components, 'optionalAccess', _209 => _209.EditComposer]) && _optionalChain([prev, 'access', _210 => _210.components, 'optionalAccess', _211 => _211.AssistantMessage]) === _optionalChain([next, 'access', _212 => _212.components, 'optionalAccess', _213 => _213.AssistantMessage]) && _optionalChain([prev, 'access', _214 => _214.components, 'optionalAccess', _215 => _215.SystemMessage]) === _optionalChain([next, 'access', _216 => _216.components, 'optionalAccess', _217 => _217.SystemMessage])
|
3683
4130
|
);
|
3684
4131
|
|
3685
4132
|
// src/primitives/thread/ThreadScrollToBottom.tsx
|
@@ -3711,7 +4158,7 @@ var ThreadConfigProvider = ({
|
|
3711
4158
|
}) => {
|
3712
4159
|
const assistant = useAssistantContext({ optional: true });
|
3713
4160
|
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 });
|
3714
|
-
if (!_optionalChain([config, 'optionalAccess',
|
4161
|
+
if (!_optionalChain([config, 'optionalAccess', _218 => _218.runtime])) return configProvider;
|
3715
4162
|
if (assistant) {
|
3716
4163
|
throw new Error(
|
3717
4164
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -3798,8 +4245,7 @@ var AssistantActionBarSpeak = _react.forwardRef.call(void 0, (props, ref) => {
|
|
3798
4245
|
} = {}
|
3799
4246
|
} = useThreadConfig();
|
3800
4247
|
const allowSpeak = useAllowSpeak();
|
3801
|
-
|
3802
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Speak, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AudioLinesIcon, {}))) }) });
|
4248
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Speak, { disabled: !allowSpeak, asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AudioLinesIcon, {}))) }) });
|
3803
4249
|
});
|
3804
4250
|
AssistantActionBarSpeak.displayName = "AssistantActionBarSpeak";
|
3805
4251
|
var AssistantActionBarStopSpeaking = _react.forwardRef.call(void 0, (props, ref) => {
|
@@ -3811,8 +4257,7 @@ var AssistantActionBarStopSpeaking = _react.forwardRef.call(void 0, (props, ref)
|
|
3811
4257
|
} = {}
|
3812
4258
|
} = useThreadConfig();
|
3813
4259
|
const allowSpeak = useAllowSpeak();
|
3814
|
-
|
3815
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.StopSpeaking, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip: stopTooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.StopCircleIcon, {}))) }) });
|
4260
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.StopSpeaking, { disabled: !allowSpeak, asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip: stopTooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.StopCircleIcon, {}))) }) });
|
3816
4261
|
});
|
3817
4262
|
AssistantActionBarStopSpeaking.displayName = "AssistantActionBarStopSpeaking";
|
3818
4263
|
var AssistantActionBarReload = _react.forwardRef.call(void 0, (props, ref) => {
|
@@ -3822,8 +4267,7 @@ var AssistantActionBarReload = _react.forwardRef.call(void 0, (props, ref) => {
|
|
3822
4267
|
} = {}
|
3823
4268
|
} = useThreadConfig();
|
3824
4269
|
const allowReload = useAllowReload();
|
3825
|
-
|
3826
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Reload, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCwIcon, {}) }) });
|
4270
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Reload, { disabled: !allowReload, asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCwIcon, {}) }) });
|
3827
4271
|
});
|
3828
4272
|
AssistantActionBarReload.displayName = "AssistantActionBarReload";
|
3829
4273
|
var exports = {
|
@@ -3846,11 +4290,11 @@ var assistant_action_bar_default = Object.assign(
|
|
3846
4290
|
|
3847
4291
|
|
3848
4292
|
|
3849
|
-
var useAllowBranchPicker = () => {
|
4293
|
+
var useAllowBranchPicker = (ensureCapability = false) => {
|
3850
4294
|
const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
|
3851
4295
|
const { useThread } = useThreadContext();
|
3852
4296
|
const branchPickerSupported = useThread((t) => t.capabilities.edit);
|
3853
|
-
return
|
4297
|
+
return allowBranchPicker && (!ensureCapability || branchPickerSupported);
|
3854
4298
|
};
|
3855
4299
|
var BranchPicker = () => {
|
3856
4300
|
const allowBranchPicker = useAllowBranchPicker();
|
@@ -3872,7 +4316,8 @@ var BranchPickerPrevious2 = _react.forwardRef.call(void 0, (props, ref) => {
|
|
3872
4316
|
branchPicker: { previous: { tooltip = "Previous" } = {} } = {}
|
3873
4317
|
} = {}
|
3874
4318
|
} = useThreadConfig();
|
3875
|
-
|
4319
|
+
const allowBranchPicker = useAllowBranchPicker();
|
4320
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Previous, { disabled: !allowBranchPicker, asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon, {}))) }) });
|
3876
4321
|
});
|
3877
4322
|
BranchPickerPrevious2.displayName = "BranchPickerPrevious";
|
3878
4323
|
var BranchPickerStateWrapper = withDefaults("span", {
|
@@ -3890,7 +4335,8 @@ var BranchPickerNext = _react.forwardRef.call(void 0, (props, ref) => {
|
|
3890
4335
|
const {
|
3891
4336
|
strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {}
|
3892
4337
|
} = useThreadConfig();
|
3893
|
-
|
4338
|
+
const allowBranchPicker = useAllowBranchPicker();
|
4339
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Next, { disabled: !allowBranchPicker, asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ChevronRightIcon, {}))) }) });
|
3894
4340
|
});
|
3895
4341
|
BranchPickerNext.displayName = "BranchPickerNext";
|
3896
4342
|
var exports2 = {
|
@@ -3967,21 +4413,26 @@ var AssistantMessageContentWrapper = withDefaults("div", {
|
|
3967
4413
|
});
|
3968
4414
|
var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: componentsProp, ...rest }, ref) => {
|
3969
4415
|
const { tools, assistantMessage: { components = {} } = {} } = useThreadConfig();
|
4416
|
+
const toolsComponents = _react.useMemo.call(void 0,
|
4417
|
+
() => ({
|
4418
|
+
by_name: !tools ? void 0 : Object.fromEntries(
|
4419
|
+
tools.map((t) => [
|
4420
|
+
t.unstable_tool.toolName,
|
4421
|
+
t.unstable_tool.render
|
4422
|
+
])
|
4423
|
+
),
|
4424
|
+
Fallback: components.ToolFallback
|
4425
|
+
}),
|
4426
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
4427
|
+
[..._nullishCoalesce(tools, () => ( [])), components.ToolFallback]
|
4428
|
+
);
|
3970
4429
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
3971
4430
|
message_exports.Content,
|
3972
4431
|
{
|
3973
4432
|
components: {
|
3974
4433
|
...componentsProp,
|
3975
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
3976
|
-
tools:
|
3977
|
-
by_name: !tools ? void 0 : Object.fromEntries(
|
3978
|
-
tools.map((t) => [
|
3979
|
-
t.unstable_tool.toolName,
|
3980
|
-
t.unstable_tool.render
|
3981
|
-
])
|
3982
|
-
),
|
3983
|
-
Fallback: components.ToolFallback
|
3984
|
-
}
|
4434
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _219 => _219.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
|
4435
|
+
tools: toolsComponents
|
3985
4436
|
}
|
3986
4437
|
}
|
3987
4438
|
) });
|
@@ -4026,10 +4477,71 @@ var CircleStopIcon = () => {
|
|
4026
4477
|
};
|
4027
4478
|
CircleStopIcon.displayName = "CircleStopIcon";
|
4028
4479
|
|
4480
|
+
// src/ui/composer-attachment.tsx
|
4481
|
+
|
4482
|
+
|
4483
|
+
|
4484
|
+
var ComposerAttachmentRoot = withDefaults("div", {
|
4485
|
+
className: "aui-composer-attachment-root"
|
4486
|
+
});
|
4487
|
+
ComposerAttachmentRoot.displayName = "ComposerAttachmentRoot";
|
4488
|
+
var ComposerAttachment2 = () => {
|
4489
|
+
const { useAttachment } = useAttachmentContext({ type: "composer" });
|
4490
|
+
const attachment = useAttachment((a) => a.attachment);
|
4491
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ComposerAttachmentRoot, { children: [
|
4492
|
+
".",
|
4493
|
+
attachment.name.split(".").pop(),
|
4494
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAttachmentRemove, {})
|
4495
|
+
] });
|
4496
|
+
};
|
4497
|
+
ComposerAttachment2.displayName = "ComposerAttachment";
|
4498
|
+
var ComposerAttachmentRemove = _react.forwardRef.call(void 0, (props, ref) => {
|
4499
|
+
const {
|
4500
|
+
strings: {
|
4501
|
+
composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {}
|
4502
|
+
} = {}
|
4503
|
+
} = useThreadConfig();
|
4504
|
+
const { useComposer } = useThreadContext();
|
4505
|
+
const { useAttachment } = useAttachmentContext();
|
4506
|
+
const handleRemoveAttachment = () => {
|
4507
|
+
useComposer.getState().removeAttachment(useAttachment.getState().attachment.id);
|
4508
|
+
};
|
4509
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4510
|
+
TooltipIconButton,
|
4511
|
+
{
|
4512
|
+
tooltip,
|
4513
|
+
className: "aui-composer-attachment-remove",
|
4514
|
+
side: "top",
|
4515
|
+
...props,
|
4516
|
+
onClick: handleRemoveAttachment,
|
4517
|
+
ref,
|
4518
|
+
children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CircleXIcon, {})))
|
4519
|
+
}
|
4520
|
+
);
|
4521
|
+
});
|
4522
|
+
ComposerAttachmentRemove.displayName = "ComposerAttachmentRemove";
|
4523
|
+
var exports5 = {
|
4524
|
+
Root: ComposerAttachmentRoot,
|
4525
|
+
Remove: ComposerAttachmentRemove
|
4526
|
+
};
|
4527
|
+
var composer_attachment_default = Object.assign(
|
4528
|
+
ComposerAttachment2,
|
4529
|
+
exports5
|
4530
|
+
);
|
4531
|
+
|
4029
4532
|
// src/ui/composer.tsx
|
4030
4533
|
|
4534
|
+
var useAllowAttachments = (ensureCapability = false) => {
|
4535
|
+
const { composer: { allowAttachments = true } = {} } = useThreadConfig();
|
4536
|
+
const { useThread } = useThreadContext();
|
4537
|
+
const attachmentsSupported = useThread((t) => t.capabilities.attachments);
|
4538
|
+
return allowAttachments && (!ensureCapability || attachmentsSupported);
|
4539
|
+
};
|
4031
4540
|
var Composer = () => {
|
4541
|
+
const allowAttachments = useAllowAttachments(true);
|
4032
4542
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ComposerRoot, { children: [
|
4543
|
+
allowAttachments && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAttachments, {}),
|
4544
|
+
allowAttachments && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAddAttachment, {}),
|
4033
4545
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerInput, { autoFocus: true }),
|
4034
4546
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAction, {})
|
4035
4547
|
] });
|
@@ -4055,6 +4567,43 @@ var ComposerInput = _react.forwardRef.call(void 0,
|
|
4055
4567
|
}
|
4056
4568
|
);
|
4057
4569
|
ComposerInput.displayName = "ComposerInput";
|
4570
|
+
var ComposerAttachmentsContainer = withDefaults("div", {
|
4571
|
+
className: "aui-composer-attachments"
|
4572
|
+
});
|
4573
|
+
var ComposerAttachments = ({ components }) => {
|
4574
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAttachmentsContainer, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4575
|
+
composer_exports.Attachments,
|
4576
|
+
{
|
4577
|
+
components: {
|
4578
|
+
...components,
|
4579
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _220 => _220.Attachment]), () => ( composer_attachment_default))
|
4580
|
+
}
|
4581
|
+
}
|
4582
|
+
) });
|
4583
|
+
};
|
4584
|
+
var ComposerAttachButton = withDefaults(TooltipIconButton, {
|
4585
|
+
variant: "default",
|
4586
|
+
className: "aui-composer-attach"
|
4587
|
+
});
|
4588
|
+
var ComposerAddAttachment = _react.forwardRef.call(void 0, (props, ref) => {
|
4589
|
+
const {
|
4590
|
+
strings: {
|
4591
|
+
composer: { addAttachment: { tooltip = "Attach file" } = {} } = {}
|
4592
|
+
} = {}
|
4593
|
+
} = useThreadConfig();
|
4594
|
+
const allowAttachments = useAllowAttachments();
|
4595
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.AddAttachment, { disabled: !allowAttachments, asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4596
|
+
ComposerAttachButton,
|
4597
|
+
{
|
4598
|
+
tooltip,
|
4599
|
+
variant: "ghost",
|
4600
|
+
...props,
|
4601
|
+
ref,
|
4602
|
+
children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.PaperclipIcon, {})))
|
4603
|
+
}
|
4604
|
+
) });
|
4605
|
+
});
|
4606
|
+
ComposerAddAttachment.displayName = "ComposerAddAttachment";
|
4058
4607
|
var useAllowCancel = () => {
|
4059
4608
|
const { useThread } = useThreadContext();
|
4060
4609
|
const cancelSupported = useThread((t) => t.capabilities.cancel);
|
@@ -4091,14 +4640,16 @@ var ComposerCancel = _react.forwardRef.call(void 0, (props, ref) => {
|
|
4091
4640
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerCancelButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleStopIcon, {}))) }) });
|
4092
4641
|
});
|
4093
4642
|
ComposerCancel.displayName = "ComposerCancel";
|
4094
|
-
var
|
4643
|
+
var exports6 = {
|
4095
4644
|
Root: ComposerRoot,
|
4096
4645
|
Input: ComposerInput,
|
4097
4646
|
Action: ComposerAction,
|
4098
4647
|
Send: ComposerSend,
|
4099
|
-
Cancel: ComposerCancel
|
4648
|
+
Cancel: ComposerCancel,
|
4649
|
+
AddAttachment: ComposerAddAttachment,
|
4650
|
+
Attachments: ComposerAttachments
|
4100
4651
|
};
|
4101
|
-
var composer_default = Object.assign(Composer,
|
4652
|
+
var composer_default = Object.assign(Composer, exports6);
|
4102
4653
|
|
4103
4654
|
// src/ui/thread-welcome.tsx
|
4104
4655
|
|
@@ -4158,13 +4709,13 @@ var ThreadWelcomeSuggestion = ({
|
|
4158
4709
|
};
|
4159
4710
|
var ThreadWelcomeSuggestions = () => {
|
4160
4711
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
4161
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess',
|
4712
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _221 => _221.map, 'call', _222 => _222((suggestion, idx) => {
|
4162
4713
|
const key = `${suggestion.prompt}-${idx}`;
|
4163
4714
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
4164
4715
|
})]) });
|
4165
4716
|
};
|
4166
4717
|
ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
|
4167
|
-
var
|
4718
|
+
var exports7 = {
|
4168
4719
|
Root: ThreadWelcomeRoot,
|
4169
4720
|
Center: ThreadWelcomeCenter,
|
4170
4721
|
Avatar: ThreadWelcomeAvatar,
|
@@ -4172,7 +4723,7 @@ var exports6 = {
|
|
4172
4723
|
Suggestions: ThreadWelcomeSuggestions,
|
4173
4724
|
Suggestion: ThreadWelcomeSuggestion
|
4174
4725
|
};
|
4175
|
-
var thread_welcome_default = Object.assign(ThreadWelcome,
|
4726
|
+
var thread_welcome_default = Object.assign(ThreadWelcome, exports7);
|
4176
4727
|
|
4177
4728
|
// src/ui/user-message.tsx
|
4178
4729
|
|
@@ -4202,20 +4753,43 @@ var UserActionBarEdit = _react.forwardRef.call(void 0, (props, ref) => {
|
|
4202
4753
|
strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
|
4203
4754
|
} = useThreadConfig();
|
4204
4755
|
const allowEdit = useAllowEdit();
|
4205
|
-
|
4206
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Edit, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.PencilIcon, {}))) }) });
|
4756
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Edit, { disabled: !allowEdit, asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.PencilIcon, {}))) }) });
|
4207
4757
|
});
|
4208
4758
|
UserActionBarEdit.displayName = "UserActionBarEdit";
|
4209
|
-
var
|
4759
|
+
var exports8 = {
|
4210
4760
|
Root: UserActionBarRoot,
|
4211
4761
|
Edit: UserActionBarEdit
|
4212
4762
|
};
|
4213
|
-
var user_action_bar_default = Object.assign(UserActionBar,
|
4763
|
+
var user_action_bar_default = Object.assign(UserActionBar, exports8);
|
4764
|
+
|
4765
|
+
// src/ui/user-message-attachment.tsx
|
4766
|
+
|
4767
|
+
var UserMessageAttachmentRoot = withDefaults("div", {
|
4768
|
+
className: "aui-user-message-attachment-root"
|
4769
|
+
});
|
4770
|
+
UserMessageAttachmentRoot.displayName = "UserMessageAttachmentRoot";
|
4771
|
+
var UserMessageAttachment = () => {
|
4772
|
+
const { useAttachment } = useAttachmentContext();
|
4773
|
+
const attachment = useAttachment((a) => a.attachment);
|
4774
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageAttachmentRoot, { children: [
|
4775
|
+
".",
|
4776
|
+
attachment.name.split(".").pop()
|
4777
|
+
] });
|
4778
|
+
};
|
4779
|
+
UserMessageAttachment.displayName = "UserMessageAttachment";
|
4780
|
+
var exports9 = {
|
4781
|
+
Root: UserMessageAttachmentRoot
|
4782
|
+
};
|
4783
|
+
var user_message_attachment_default = Object.assign(
|
4784
|
+
UserMessageAttachment,
|
4785
|
+
exports9
|
4786
|
+
);
|
4214
4787
|
|
4215
4788
|
// src/ui/user-message.tsx
|
4216
4789
|
|
4217
4790
|
var UserMessage = () => {
|
4218
4791
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageRoot, { children: [
|
4792
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageAttachments, {}),
|
4219
4793
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, user_action_bar_default, {}),
|
4220
4794
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContent, {}),
|
4221
4795
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, branch_picker_default, {})
|
@@ -4236,18 +4810,35 @@ var UserMessageContent = _react.forwardRef.call(void 0,
|
|
4236
4810
|
{
|
4237
4811
|
components: {
|
4238
4812
|
...components,
|
4239
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4813
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _223 => _223.Text]), () => ( content_part_default.Text))
|
4240
4814
|
}
|
4241
4815
|
}
|
4242
4816
|
) });
|
4243
4817
|
}
|
4244
4818
|
);
|
4245
4819
|
UserMessageContent.displayName = "UserMessageContent";
|
4246
|
-
var
|
4820
|
+
var UserMessageAttachmentsContainer = withDefaults("div", {
|
4821
|
+
className: "aui-user-message-attachments"
|
4822
|
+
});
|
4823
|
+
var UserMessageAttachments = ({
|
4824
|
+
components
|
4825
|
+
}) => {
|
4826
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { hasAttachments: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageAttachmentsContainer, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4827
|
+
message_exports.Attachments,
|
4828
|
+
{
|
4829
|
+
components: {
|
4830
|
+
...components,
|
4831
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _224 => _224.Attachment]), () => ( user_message_attachment_default))
|
4832
|
+
}
|
4833
|
+
}
|
4834
|
+
) }) });
|
4835
|
+
};
|
4836
|
+
var exports10 = {
|
4247
4837
|
Root: UserMessageRoot,
|
4248
|
-
Content: UserMessageContent
|
4838
|
+
Content: UserMessageContent,
|
4839
|
+
Attachments: UserMessageAttachments
|
4249
4840
|
};
|
4250
|
-
var user_message_default = Object.assign(UserMessage,
|
4841
|
+
var user_message_default = Object.assign(UserMessage, exports10);
|
4251
4842
|
|
4252
4843
|
// src/ui/edit-composer.tsx
|
4253
4844
|
|
@@ -4294,14 +4885,14 @@ var EditComposerSend = _react.forwardRef.call(void 0,
|
|
4294
4885
|
}
|
4295
4886
|
);
|
4296
4887
|
EditComposerSend.displayName = "EditComposerSend";
|
4297
|
-
var
|
4888
|
+
var exports11 = {
|
4298
4889
|
Root: EditComposerRoot,
|
4299
4890
|
Input: EditComposerInput,
|
4300
4891
|
Footer: EditComposerFooter,
|
4301
4892
|
Cancel: EditComposerCancel,
|
4302
4893
|
Send: EditComposerSend
|
4303
4894
|
};
|
4304
|
-
var edit_composer_default = Object.assign(EditComposer,
|
4895
|
+
var edit_composer_default = Object.assign(EditComposer, exports11);
|
4305
4896
|
|
4306
4897
|
// src/ui/thread.tsx
|
4307
4898
|
|
@@ -4338,10 +4929,10 @@ var ThreadMessages = ({ components, ...rest }) => {
|
|
4338
4929
|
thread_exports.Messages,
|
4339
4930
|
{
|
4340
4931
|
components: {
|
4341
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4342
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4343
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4344
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4932
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _225 => _225.UserMessage]), () => ( user_message_default)),
|
4933
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _226 => _226.EditComposer]), () => ( edit_composer_default)),
|
4934
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _227 => _227.AssistantMessage]), () => ( assistant_message_default)),
|
4935
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _228 => _228.SystemMessage]), () => ( SystemMessage))
|
4345
4936
|
},
|
4346
4937
|
...rest
|
4347
4938
|
}
|
@@ -4361,14 +4952,14 @@ var ThreadScrollToBottom = _react.forwardRef.call(void 0, (props, ref) => {
|
|
4361
4952
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArrowDownIcon, {}))) }) });
|
4362
4953
|
});
|
4363
4954
|
ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
|
4364
|
-
var
|
4955
|
+
var exports12 = {
|
4365
4956
|
Root: ThreadRoot,
|
4366
4957
|
Viewport: ThreadViewport,
|
4367
4958
|
Messages: ThreadMessages,
|
4368
4959
|
ScrollToBottom: ThreadScrollToBottom,
|
4369
4960
|
ViewportFooter: ThreadViewportFooter
|
4370
4961
|
};
|
4371
|
-
var thread_default = Object.assign(Thread,
|
4962
|
+
var thread_default = Object.assign(Thread, exports12);
|
4372
4963
|
|
4373
4964
|
// src/ui/assistant-modal.tsx
|
4374
4965
|
|
@@ -4442,14 +5033,20 @@ var AssistantModalContent = withDefaults(assistantModal_exports.Content, {
|
|
4442
5033
|
sideOffset: 16
|
4443
5034
|
});
|
4444
5035
|
AssistantModalContent.displayName = "AssistantModalContent";
|
4445
|
-
var
|
5036
|
+
var exports13 = {
|
4446
5037
|
Root: AssistantModalRoot,
|
4447
5038
|
Trigger: AssistantModalTrigger,
|
4448
5039
|
Content: AssistantModalContent,
|
4449
5040
|
Button: AssistantModalButton,
|
4450
5041
|
Anchor: AssistantModalAnchor
|
4451
5042
|
};
|
4452
|
-
var assistant_modal_default = Object.assign(AssistantModal,
|
5043
|
+
var assistant_modal_default = Object.assign(AssistantModal, exports13);
|
5044
|
+
|
5045
|
+
|
5046
|
+
|
5047
|
+
|
5048
|
+
|
5049
|
+
|
4453
5050
|
|
4454
5051
|
|
4455
5052
|
|
@@ -4524,5 +5121,5 @@ var assistant_modal_default = Object.assign(AssistantModal, exports11);
|
|
4524
5121
|
|
4525
5122
|
|
4526
5123
|
|
4527
|
-
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerPrimitive = composer_exports; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; 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.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 =
|
5124
|
+
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkBNSCUYW7js.toCoreMessage; exports.toCoreMessages = _chunkBNSCUYW7js.toCoreMessages; exports.toLanguageModelMessages = _chunkBNSCUYW7js.toLanguageModelMessages; exports.toLanguageModelTools = _chunkBNSCUYW7js.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadSuggestion = useThreadSuggestion;
|
4528
5125
|
//# sourceMappingURL=index.js.map
|