@assistant-ui/react 0.5.88 → 0.5.90
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-CKNRD26B.mjs → chunk-C57XMNDQ.mjs} +10 -2
- package/dist/chunk-C57XMNDQ.mjs.map +1 -0
- package/dist/{chunk-75WIGDCW.js → chunk-MRIZ4RHI.js} +10 -2
- package/dist/chunk-MRIZ4RHI.js.map +1 -0
- package/dist/{edge-B3YIacNl.d.mts → edge-Bycfnl_J.d.mts} +58 -3
- package/dist/{edge-B3YIacNl.d.ts → edge-Bycfnl_J.d.ts} +58 -3
- package/dist/edge.d.mts +56 -1
- package/dist/edge.d.ts +56 -1
- package/dist/edge.js +9 -1
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +9 -1
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +113 -105
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -22
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles/index.css.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-75WIGDCW.js.map +0 -1
- package/dist/chunk-CKNRD26B.mjs.map +0 -1
package/dist/index.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
|
12
|
-
var
|
12
|
+
var _chunkMRIZ4RHIjs = require('./chunk-MRIZ4RHI.js');
|
13
13
|
|
14
14
|
|
15
15
|
var _chunkPZ5AY32Cjs = require('./chunk-PZ5AY32C.js');
|
@@ -2325,6 +2325,7 @@ var defaultComponents = {
|
|
2325
2325
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
|
2326
2326
|
] }),
|
2327
2327
|
Image: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveImage, {}),
|
2328
|
+
Unstable_Audio: () => null,
|
2328
2329
|
UI: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveDisplay, {})
|
2329
2330
|
};
|
2330
2331
|
var MessageContentPartComponent = ({
|
@@ -2333,33 +2334,32 @@ var MessageContentPartComponent = ({
|
|
2333
2334
|
Empty,
|
2334
2335
|
Image: Image2 = defaultComponents.Image,
|
2335
2336
|
UI = defaultComponents.UI,
|
2337
|
+
Unstable_Audio: Audio = defaultComponents.Unstable_Audio,
|
2336
2338
|
tools: { by_name = {}, Fallback: Fallback2 = void 0 } = {}
|
2337
2339
|
} = {}
|
2338
2340
|
}) => {
|
2339
2341
|
const contentPartRuntime = useContentPartRuntime();
|
2340
2342
|
const part = useContentPart();
|
2341
2343
|
const type = part.type;
|
2344
|
+
if (type === "tool-call") {
|
2345
|
+
const Tool = by_name[part.toolName] || Fallback2;
|
2346
|
+
const addResult = (result) => contentPartRuntime.addToolResult(result);
|
2347
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ToolUIDisplay, { ...part, part, UI: Tool, addResult });
|
2348
|
+
}
|
2349
|
+
if (part.status.type === "requires-action")
|
2350
|
+
throw new Error("Encountered unexpected requires-action status");
|
2342
2351
|
switch (type) {
|
2343
2352
|
case "text":
|
2344
|
-
if (part.status.type === "requires-action")
|
2345
|
-
throw new Error("Encountered unexpected requires-action status");
|
2346
2353
|
if (part.part === EMPTY_CONTENT && !!Empty) {
|
2347
2354
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Empty, { status: part.status });
|
2348
2355
|
}
|
2349
2356
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text2, { ...part, part });
|
2350
2357
|
case "image":
|
2351
|
-
if (part.status.type === "requires-action")
|
2352
|
-
throw new Error("Encountered unexpected requires-action status");
|
2353
2358
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Image2, { ...part, part });
|
2359
|
+
case "audio":
|
2360
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Audio, { ...part, part });
|
2354
2361
|
case "ui":
|
2355
|
-
if (part.status.type === "requires-action")
|
2356
|
-
throw new Error("Encountered unexpected requires-action status");
|
2357
2362
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UI, { ...part, part });
|
2358
|
-
case "tool-call": {
|
2359
|
-
const Tool = by_name[part.toolName] || Fallback2;
|
2360
|
-
const addResult = (result) => contentPartRuntime.addToolResult(result);
|
2361
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ToolUIDisplay, { ...part, part, UI: Tool, addResult });
|
2362
|
-
}
|
2363
2363
|
default:
|
2364
2364
|
const unhandledType = type;
|
2365
2365
|
throw new Error(`Unknown content part type: ${unhandledType}`);
|
@@ -2378,7 +2378,7 @@ var MessageContentPartImpl = ({
|
|
2378
2378
|
};
|
2379
2379
|
var MessageContentPart = _react.memo.call(void 0,
|
2380
2380
|
MessageContentPartImpl,
|
2381
|
-
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _90 => _90.components, 'optionalAccess', _91 => _91.Text]) === _optionalChain([next, 'access', _92 => _92.components, 'optionalAccess', _93 => _93.Text]) && _optionalChain([prev, 'access', _94 => _94.components, 'optionalAccess', _95 => _95.Image]) === _optionalChain([next, 'access', _96 => _96.components, 'optionalAccess', _97 => _97.Image]) && _optionalChain([prev, 'access', _98 => _98.components, 'optionalAccess', _99 => _99.
|
2381
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _90 => _90.components, 'optionalAccess', _91 => _91.Text]) === _optionalChain([next, 'access', _92 => _92.components, 'optionalAccess', _93 => _93.Text]) && _optionalChain([prev, 'access', _94 => _94.components, 'optionalAccess', _95 => _95.Image]) === _optionalChain([next, 'access', _96 => _96.components, 'optionalAccess', _97 => _97.Image]) && _optionalChain([prev, 'access', _98 => _98.components, 'optionalAccess', _99 => _99.Unstable_Audio]) === _optionalChain([next, 'access', _100 => _100.components, 'optionalAccess', _101 => _101.Unstable_Audio]) && _optionalChain([prev, 'access', _102 => _102.components, 'optionalAccess', _103 => _103.UI]) === _optionalChain([next, 'access', _104 => _104.components, 'optionalAccess', _105 => _105.UI]) && _optionalChain([prev, 'access', _106 => _106.components, 'optionalAccess', _107 => _107.tools]) === _optionalChain([next, 'access', _108 => _108.components, 'optionalAccess', _109 => _109.tools])
|
2382
2382
|
);
|
2383
2383
|
var MessagePrimitiveContent = ({
|
2384
2384
|
components
|
@@ -2444,11 +2444,11 @@ var getComponent = (components, attachment) => {
|
|
2444
2444
|
const type = attachment.type;
|
2445
2445
|
switch (type) {
|
2446
2446
|
case "image":
|
2447
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2447
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _110 => _110.Image]), () => ( _optionalChain([components, 'optionalAccess', _111 => _111.Attachment])));
|
2448
2448
|
case "document":
|
2449
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2449
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _112 => _112.Document]), () => ( _optionalChain([components, 'optionalAccess', _113 => _113.Attachment])));
|
2450
2450
|
case "file":
|
2451
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2451
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _114 => _114.File]), () => ( _optionalChain([components, 'optionalAccess', _115 => _115.Attachment])));
|
2452
2452
|
default:
|
2453
2453
|
const _exhaustiveCheck = type;
|
2454
2454
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
@@ -2471,7 +2471,7 @@ var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
2471
2471
|
};
|
2472
2472
|
var MessageAttachment = _react.memo.call(void 0,
|
2473
2473
|
MessageAttachmentImpl,
|
2474
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2474
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _116 => _116.components, 'optionalAccess', _117 => _117.Image]) === _optionalChain([next, 'access', _118 => _118.components, 'optionalAccess', _119 => _119.Image]) && _optionalChain([prev, 'access', _120 => _120.components, 'optionalAccess', _121 => _121.Document]) === _optionalChain([next, 'access', _122 => _122.components, 'optionalAccess', _123 => _123.Document]) && _optionalChain([prev, 'access', _124 => _124.components, 'optionalAccess', _125 => _125.File]) === _optionalChain([next, 'access', _126 => _126.components, 'optionalAccess', _127 => _127.File]) && _optionalChain([prev, 'access', _128 => _128.components, 'optionalAccess', _129 => _129.Attachment]) === _optionalChain([next, 'access', _130 => _130.components, 'optionalAccess', _131 => _131.Attachment])
|
2475
2475
|
);
|
2476
2476
|
var MessagePrimitiveAttachments = ({ components }) => {
|
2477
2477
|
const attachmentsCount = useMessage(({ message }) => {
|
@@ -2597,7 +2597,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
2597
2597
|
const { isRunning } = threadRuntime.getState();
|
2598
2598
|
if (!isRunning) {
|
2599
2599
|
e.preventDefault();
|
2600
|
-
_optionalChain([textareaRef, 'access',
|
2600
|
+
_optionalChain([textareaRef, 'access', _132 => _132.current, 'optionalAccess', _133 => _133.closest, 'call', _134 => _134("form"), 'optionalAccess', _135 => _135.requestSubmit, 'call', _136 => _136()]);
|
2601
2601
|
}
|
2602
2602
|
}
|
2603
2603
|
};
|
@@ -2671,11 +2671,11 @@ var getComponent2 = (components, attachment) => {
|
|
2671
2671
|
const type = attachment.type;
|
2672
2672
|
switch (type) {
|
2673
2673
|
case "image":
|
2674
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2674
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _137 => _137.Image]), () => ( _optionalChain([components, 'optionalAccess', _138 => _138.Attachment])));
|
2675
2675
|
case "document":
|
2676
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2676
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _139 => _139.Document]), () => ( _optionalChain([components, 'optionalAccess', _140 => _140.Attachment])));
|
2677
2677
|
case "file":
|
2678
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2678
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _141 => _141.File]), () => ( _optionalChain([components, 'optionalAccess', _142 => _142.Attachment])));
|
2679
2679
|
default:
|
2680
2680
|
const _exhaustiveCheck = type;
|
2681
2681
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
@@ -2698,7 +2698,7 @@ var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
2698
2698
|
};
|
2699
2699
|
var ComposerAttachment = _react.memo.call(void 0,
|
2700
2700
|
ComposerAttachmentImpl,
|
2701
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2701
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _143 => _143.components, 'optionalAccess', _144 => _144.Image]) === _optionalChain([next, 'access', _145 => _145.components, 'optionalAccess', _146 => _146.Image]) && _optionalChain([prev, 'access', _147 => _147.components, 'optionalAccess', _148 => _148.Document]) === _optionalChain([next, 'access', _149 => _149.components, 'optionalAccess', _150 => _150.Document]) && _optionalChain([prev, 'access', _151 => _151.components, 'optionalAccess', _152 => _152.File]) === _optionalChain([next, 'access', _153 => _153.components, 'optionalAccess', _154 => _154.File]) && _optionalChain([prev, 'access', _155 => _155.components, 'optionalAccess', _156 => _156.Attachment]) === _optionalChain([next, 'access', _157 => _157.components, 'optionalAccess', _158 => _158.Attachment])
|
2702
2702
|
);
|
2703
2703
|
var ComposerPrimitiveAttachments = ({ components }) => {
|
2704
2704
|
const attachmentsCount = useComposer((s) => s.attachments.length);
|
@@ -3042,7 +3042,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
3042
3042
|
let first = true;
|
3043
3043
|
let cleanup;
|
3044
3044
|
const inner = () => {
|
3045
|
-
_optionalChain([cleanup, 'optionalCall',
|
3045
|
+
_optionalChain([cleanup, 'optionalCall', _159 => _159()]);
|
3046
3046
|
cleanup = runtime.threadManager.mainThread.subscribe(callback);
|
3047
3047
|
if (!first) {
|
3048
3048
|
callback();
|
@@ -3053,7 +3053,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
3053
3053
|
inner();
|
3054
3054
|
return () => {
|
3055
3055
|
unsubscribe();
|
3056
|
-
_optionalChain([cleanup, 'optionalCall',
|
3056
|
+
_optionalChain([cleanup, 'optionalCall', _160 => _160()]);
|
3057
3057
|
};
|
3058
3058
|
};
|
3059
3059
|
|
@@ -3064,17 +3064,17 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
3064
3064
|
var ProxyConfigProvider = (_class5 = class {constructor() { _class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this); }
|
3065
3065
|
__init9() {this._providers = /* @__PURE__ */ new Set()}
|
3066
3066
|
getModelConfig() {
|
3067
|
-
return
|
3067
|
+
return _chunkMRIZ4RHIjs.mergeModelConfigs.call(void 0, this._providers);
|
3068
3068
|
}
|
3069
3069
|
registerModelConfigProvider(provider) {
|
3070
3070
|
this._providers.add(provider);
|
3071
|
-
const unsubscribe = _optionalChain([provider, 'access',
|
3071
|
+
const unsubscribe = _optionalChain([provider, 'access', _161 => _161.subscribe, 'optionalCall', _162 => _162(() => {
|
3072
3072
|
this.notifySubscribers();
|
3073
3073
|
})]);
|
3074
3074
|
this.notifySubscribers();
|
3075
3075
|
return () => {
|
3076
3076
|
this._providers.delete(provider);
|
3077
|
-
_optionalChain([unsubscribe, 'optionalCall',
|
3077
|
+
_optionalChain([unsubscribe, 'optionalCall', _163 => _163()]);
|
3078
3078
|
this.notifySubscribers();
|
3079
3079
|
};
|
3080
3080
|
}
|
@@ -3119,7 +3119,7 @@ var isAttachmentComplete = (a) => a.status.type === "complete";
|
|
3119
3119
|
var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototype.__init12.call(this);_class7.prototype.__init13.call(this);_class7.prototype.__init14.call(this);_class7.prototype.__init15.call(this); }
|
3120
3120
|
__init12() {this.isEditing = true}
|
3121
3121
|
getAttachmentAccept() {
|
3122
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
3122
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _164 => _164.getAttachmentAdapter, 'call', _165 => _165(), 'optionalAccess', _166 => _166.accept]), () => ( "*"));
|
3123
3123
|
}
|
3124
3124
|
__init13() {this._attachments = []}
|
3125
3125
|
set attachments(value) {
|
@@ -3151,7 +3151,7 @@ var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototyp
|
|
3151
3151
|
this.attachments.map(async (a) => {
|
3152
3152
|
if (isAttachmentComplete(a)) return a;
|
3153
3153
|
const result = await adapter.send(a);
|
3154
|
-
if (_optionalChain([result, 'access',
|
3154
|
+
if (_optionalChain([result, 'access', _167 => _167.status, 'optionalAccess', _168 => _168.type]) !== "complete") {
|
3155
3155
|
result.status = { type: "complete" };
|
3156
3156
|
}
|
3157
3157
|
return result;
|
@@ -3210,7 +3210,7 @@ var DefaultThreadComposerRuntimeCore = (_class8 = class extends BaseComposerRunt
|
|
3210
3210
|
return super.attachments;
|
3211
3211
|
}
|
3212
3212
|
getAttachmentAdapter() {
|
3213
|
-
return _optionalChain([this, 'access',
|
3213
|
+
return _optionalChain([this, 'access', _169 => _169.runtime, 'access', _170 => _170.adapters, 'optionalAccess', _171 => _171.attachments]);
|
3214
3214
|
}
|
3215
3215
|
connect() {
|
3216
3216
|
return this.runtime.subscribe(() => {
|
@@ -3223,7 +3223,7 @@ var DefaultThreadComposerRuntimeCore = (_class8 = class extends BaseComposerRunt
|
|
3223
3223
|
async handleSend(message) {
|
3224
3224
|
this.runtime.append({
|
3225
3225
|
...message,
|
3226
|
-
parentId: _nullishCoalesce(_optionalChain([this, 'access',
|
3226
|
+
parentId: _nullishCoalesce(_optionalChain([this, 'access', _172 => _172.runtime, 'access', _173 => _173.messages, 'access', _174 => _174.at, 'call', _175 => _175(-1), 'optionalAccess', _176 => _176.id]), () => ( null))
|
3227
3227
|
});
|
3228
3228
|
}
|
3229
3229
|
async cancel() {
|
@@ -3342,7 +3342,7 @@ var MessageRepository = (_class9 = class {constructor() { _class9.prototype.__in
|
|
3342
3342
|
}
|
3343
3343
|
}
|
3344
3344
|
getMessages() {
|
3345
|
-
const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access',
|
3345
|
+
const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access', _177 => _177.head, 'optionalAccess', _178 => _178.level]), () => ( 0)));
|
3346
3346
|
for (let current = this.head; current; current = current.prev) {
|
3347
3347
|
messages2[current.level] = current.current;
|
3348
3348
|
}
|
@@ -3380,7 +3380,7 @@ var MessageRepository = (_class9 = class {constructor() { _class9.prototype.__in
|
|
3380
3380
|
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
3381
3381
|
);
|
3382
3382
|
return {
|
3383
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3383
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _179 => _179.prev, 'optionalAccess', _180 => _180.current, 'access', _181 => _181.id]), () => ( null)),
|
3384
3384
|
message: message.current
|
3385
3385
|
};
|
3386
3386
|
}
|
@@ -3464,11 +3464,11 @@ var MessageRepository = (_class9 = class {constructor() { _class9.prototype.__in
|
|
3464
3464
|
for (const [, message] of this.messages) {
|
3465
3465
|
exportItems.push({
|
3466
3466
|
message: message.current,
|
3467
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3467
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _182 => _182.prev, 'optionalAccess', _183 => _183.current, 'access', _184 => _184.id]), () => ( null))
|
3468
3468
|
});
|
3469
3469
|
}
|
3470
3470
|
return {
|
3471
|
-
headId: _nullishCoalesce(_optionalChain([this, 'access',
|
3471
|
+
headId: _nullishCoalesce(_optionalChain([this, 'access', _185 => _185.head, 'optionalAccess', _186 => _186.current, 'access', _187 => _187.id]), () => ( null)),
|
3472
3472
|
messages: exportItems
|
3473
3473
|
};
|
3474
3474
|
}
|
@@ -3476,7 +3476,7 @@ var MessageRepository = (_class9 = class {constructor() { _class9.prototype.__in
|
|
3476
3476
|
for (const { message, parentId } of messages2) {
|
3477
3477
|
this.addOrUpdateMessage(parentId, message);
|
3478
3478
|
}
|
3479
|
-
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access',
|
3479
|
+
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access', _188 => _188.at, 'call', _189 => _189(-1), 'optionalAccess', _190 => _190.message, 'access', _191 => _191.id]))), () => ( null)));
|
3480
3480
|
}
|
3481
3481
|
}, _class9);
|
3482
3482
|
|
@@ -3580,7 +3580,7 @@ TooltipIconButton.displayName = "TooltipIconButton";
|
|
3580
3580
|
var toAppendMessage = (messages2, message) => {
|
3581
3581
|
if (typeof message === "string") {
|
3582
3582
|
return {
|
3583
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
3583
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _192 => _192.at, 'call', _193 => _193(-1), 'optionalAccess', _194 => _194.id]), () => ( null)),
|
3584
3584
|
role: "user",
|
3585
3585
|
content: [{ type: "text", text: message }],
|
3586
3586
|
attachments: []
|
@@ -3590,7 +3590,7 @@ var toAppendMessage = (messages2, message) => {
|
|
3590
3590
|
return message;
|
3591
3591
|
}
|
3592
3592
|
return {
|
3593
|
-
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access',
|
3593
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access', _195 => _195.at, 'call', _196 => _196(-1), 'optionalAccess', _197 => _197.id]))), () => ( null)),
|
3594
3594
|
role: _nullishCoalesce(message.role, () => ( "user")),
|
3595
3595
|
content: message.content,
|
3596
3596
|
attachments: _nullishCoalesce(message.attachments, () => ( []))
|
@@ -3602,7 +3602,7 @@ var getThreadState = (runtime) => {
|
|
3602
3602
|
threadId: runtime.threadId,
|
3603
3603
|
capabilities: runtime.capabilities,
|
3604
3604
|
isDisabled: runtime.isDisabled,
|
3605
|
-
isRunning: _optionalChain([lastMessage, 'optionalAccess',
|
3605
|
+
isRunning: _optionalChain([lastMessage, 'optionalAccess', _198 => _198.role]) !== "assistant" ? false : lastMessage.status.type === "running",
|
3606
3606
|
messages: runtime.messages,
|
3607
3607
|
suggestions: runtime.suggestions,
|
3608
3608
|
extras: runtime.extras,
|
@@ -3780,7 +3780,7 @@ var ThreadRuntimeImpl = (_class10 = class {
|
|
3780
3780
|
if (!message) return void 0;
|
3781
3781
|
return {
|
3782
3782
|
message,
|
3783
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
3783
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _199 => _199[idx - 1], 'optionalAccess', _200 => _200.id]), () => ( null))
|
3784
3784
|
};
|
3785
3785
|
}
|
3786
3786
|
);
|
@@ -3809,12 +3809,12 @@ var ThreadRuntimeImpl = (_class10 = class {
|
|
3809
3809
|
return {
|
3810
3810
|
...message,
|
3811
3811
|
message,
|
3812
|
-
isLast: _optionalChain([messages2, 'access',
|
3812
|
+
isLast: _optionalChain([messages2, 'access', _201 => _201.at, 'call', _202 => _202(-1), 'optionalAccess', _203 => _203.id]) === message.id,
|
3813
3813
|
parentId,
|
3814
3814
|
branches,
|
3815
3815
|
branchNumber: branches.indexOf(message.id) + 1,
|
3816
3816
|
branchCount: branches.length,
|
3817
|
-
speech: _optionalChain([speechState, 'optionalAccess',
|
3817
|
+
speech: _optionalChain([speechState, 'optionalAccess', _204 => _204.messageId]) === message.id ? speechState : void 0,
|
3818
3818
|
submittedFeedback
|
3819
3819
|
};
|
3820
3820
|
},
|
@@ -3998,7 +3998,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
|
3998
3998
|
});
|
3999
3999
|
if (mergeSteps) {
|
4000
4000
|
const previousMessage = messages2[messages2.length - 1];
|
4001
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
4001
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _205 => _205.role]) === "assistant") {
|
4002
4002
|
previousMessage.content.push(...newContent);
|
4003
4003
|
break;
|
4004
4004
|
}
|
@@ -4011,7 +4011,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
|
4011
4011
|
}
|
4012
4012
|
case "tool": {
|
4013
4013
|
const previousMessage = messages2[messages2.length - 1];
|
4014
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
4014
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _206 => _206.role]) !== "assistant")
|
4015
4015
|
throw new Error(
|
4016
4016
|
"A tool message must be preceded by an assistant message."
|
4017
4017
|
);
|
@@ -4087,14 +4087,14 @@ function streamPartDecoderStream() {
|
|
4087
4087
|
controller.enqueue(decodeStreamPart(chunk));
|
4088
4088
|
}
|
4089
4089
|
});
|
4090
|
-
return new (0,
|
4090
|
+
return new (0, _chunkMRIZ4RHIjs.PipeableTransformStream)((readable) => {
|
4091
4091
|
return readable.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(decodeStream);
|
4092
4092
|
});
|
4093
4093
|
}
|
4094
4094
|
|
4095
4095
|
// src/runtimes/edge/streams/utils/index.ts
|
4096
4096
|
var streamUtils = {
|
4097
|
-
streamPartEncoderStream:
|
4097
|
+
streamPartEncoderStream: _chunkMRIZ4RHIjs.streamPartEncoderStream,
|
4098
4098
|
streamPartDecoderStream
|
4099
4099
|
};
|
4100
4100
|
|
@@ -4138,7 +4138,7 @@ function assistantDecoderStream() {
|
|
4138
4138
|
case "c" /* ToolCallDelta */: {
|
4139
4139
|
const { toolCallId, argsTextDelta } = value;
|
4140
4140
|
const toolName = toolCallNames.get(toolCallId);
|
4141
|
-
if (_optionalChain([currentToolCall, 'optionalAccess',
|
4141
|
+
if (_optionalChain([currentToolCall, 'optionalAccess', _207 => _207.id]) === toolCallId) {
|
4142
4142
|
currentToolCall.argsText += argsTextDelta;
|
4143
4143
|
}
|
4144
4144
|
controller.enqueue({
|
@@ -4240,8 +4240,8 @@ var EdgeChatAdapter = class {
|
|
4240
4240
|
credentials: _nullishCoalesce(this.options.credentials, () => ( "same-origin")),
|
4241
4241
|
body: JSON.stringify({
|
4242
4242
|
system: config.system,
|
4243
|
-
messages:
|
4244
|
-
tools: config.tools ?
|
4243
|
+
messages: _chunkMRIZ4RHIjs.toCoreMessages.call(void 0, messages2),
|
4244
|
+
tools: config.tools ? _chunkMRIZ4RHIjs.toLanguageModelTools.call(void 0, config.tools) : [],
|
4245
4245
|
...config.callSettings,
|
4246
4246
|
...config.config,
|
4247
4247
|
...this.options.body
|
@@ -4251,7 +4251,7 @@ var EdgeChatAdapter = class {
|
|
4251
4251
|
if (!result.ok) {
|
4252
4252
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
4253
4253
|
}
|
4254
|
-
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(
|
4254
|
+
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkMRIZ4RHIjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkMRIZ4RHIjs.runResultStream.call(void 0, ));
|
4255
4255
|
let update;
|
4256
4256
|
for await (update of asAsyncIterable(stream)) {
|
4257
4257
|
yield update;
|
@@ -4285,7 +4285,7 @@ var useEdgeRuntime = (options) => {
|
|
4285
4285
|
};
|
4286
4286
|
|
4287
4287
|
// src/runtimes/local/shouldContinue.tsx
|
4288
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
4288
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _208 => _208.status, 'optionalAccess', _209 => _209.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
4289
4289
|
|
4290
4290
|
// src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
|
4291
4291
|
var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
@@ -4305,7 +4305,7 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
4305
4305
|
return true;
|
4306
4306
|
}
|
4307
4307
|
getAttachmentAdapter() {
|
4308
|
-
return _optionalChain([this, 'access',
|
4308
|
+
return _optionalChain([this, 'access', _210 => _210.runtime, 'access', _211 => _211.adapters, 'optionalAccess', _212 => _212.attachments]);
|
4309
4309
|
}
|
4310
4310
|
|
4311
4311
|
|
@@ -4386,7 +4386,7 @@ var BaseThreadRuntimeCore = (_class11 = class {
|
|
4386
4386
|
return this._submittedFeedback[messageId];
|
4387
4387
|
}
|
4388
4388
|
submitFeedback({ messageId, type }) {
|
4389
|
-
const adapter = _optionalChain([this, 'access',
|
4389
|
+
const adapter = _optionalChain([this, 'access', _213 => _213.adapters, 'optionalAccess', _214 => _214.feedback]);
|
4390
4390
|
if (!adapter) throw new Error("Feedback adapter not configured");
|
4391
4391
|
const { message } = this.repository.getMessage(messageId);
|
4392
4392
|
adapter.submit({ message, type });
|
@@ -4396,10 +4396,10 @@ var BaseThreadRuntimeCore = (_class11 = class {
|
|
4396
4396
|
|
4397
4397
|
|
4398
4398
|
speak(messageId) {
|
4399
|
-
const adapter = _optionalChain([this, 'access',
|
4399
|
+
const adapter = _optionalChain([this, 'access', _215 => _215.adapters, 'optionalAccess', _216 => _216.speech]);
|
4400
4400
|
if (!adapter) throw new Error("Speech adapter not configured");
|
4401
4401
|
const { message } = this.repository.getMessage(messageId);
|
4402
|
-
_optionalChain([this, 'access',
|
4402
|
+
_optionalChain([this, 'access', _217 => _217._stopSpeaking, 'optionalCall', _218 => _218()]);
|
4403
4403
|
const utterance = adapter.speak(getThreadMessageText(message));
|
4404
4404
|
const unsub = utterance.subscribe(() => {
|
4405
4405
|
if (utterance.status.type === "ended") {
|
@@ -4434,7 +4434,7 @@ var BaseThreadRuntimeCore = (_class11 = class {
|
|
4434
4434
|
__init26() {this._eventSubscribers = /* @__PURE__ */ new Map()}
|
4435
4435
|
unstable_on(event, callback) {
|
4436
4436
|
if (event === "model-config-update") {
|
4437
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
4437
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _219 => _219.configProvider, 'access', _220 => _220.subscribe, 'optionalCall', _221 => _221(callback)]), () => ( (() => {
|
4438
4438
|
})));
|
4439
4439
|
}
|
4440
4440
|
const subscribers = this._eventSubscribers.get(event);
|
@@ -4455,7 +4455,7 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
|
|
4455
4455
|
constructor(configProvider, threadId, options) {
|
4456
4456
|
super(configProvider);_class12.prototype.__init27.call(this);_class12.prototype.__init28.call(this);_class12.prototype.__init29.call(this);_class12.prototype.__init30.call(this);;
|
4457
4457
|
this.threadId = threadId;
|
4458
|
-
this.
|
4458
|
+
this.setOptions(options);
|
4459
4459
|
}
|
4460
4460
|
__init27() {this.capabilities = {
|
4461
4461
|
switchToBranch: true,
|
@@ -4481,17 +4481,17 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
|
|
4481
4481
|
if (this._options === options) return;
|
4482
4482
|
this._options = options;
|
4483
4483
|
let hasUpdates = false;
|
4484
|
-
const canSpeak = _optionalChain([options, 'access',
|
4484
|
+
const canSpeak = _optionalChain([options, 'access', _222 => _222.adapters, 'optionalAccess', _223 => _223.speech]) !== void 0;
|
4485
4485
|
if (this.capabilities.speech !== canSpeak) {
|
4486
4486
|
this.capabilities.speech = canSpeak;
|
4487
4487
|
hasUpdates = true;
|
4488
4488
|
}
|
4489
|
-
const canAttach = _optionalChain([options, 'access',
|
4489
|
+
const canAttach = _optionalChain([options, 'access', _224 => _224.adapters, 'optionalAccess', _225 => _225.attachments]) !== void 0;
|
4490
4490
|
if (this.capabilities.attachments !== canAttach) {
|
4491
4491
|
this.capabilities.attachments = canAttach;
|
4492
4492
|
hasUpdates = true;
|
4493
4493
|
}
|
4494
|
-
const canFeedback = _optionalChain([options, 'access',
|
4494
|
+
const canFeedback = _optionalChain([options, 'access', _226 => _226.adapters, 'optionalAccess', _227 => _227.feedback]) !== void 0;
|
4495
4495
|
if (this.capabilities.feedback !== canFeedback) {
|
4496
4496
|
this.capabilities.feedback = canFeedback;
|
4497
4497
|
hasUpdates = true;
|
@@ -4527,13 +4527,13 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
|
|
4527
4527
|
}
|
4528
4528
|
async performRoundtrip(parentId, message) {
|
4529
4529
|
const messages2 = this.repository.getMessages();
|
4530
|
-
_optionalChain([this, 'access',
|
4530
|
+
_optionalChain([this, 'access', _228 => _228.abortController, 'optionalAccess', _229 => _229.abort, 'call', _230 => _230()]);
|
4531
4531
|
this.abortController = new AbortController();
|
4532
4532
|
const initialContent = message.content;
|
4533
|
-
const initialSteps = _optionalChain([message, 'access',
|
4534
|
-
const initalCustom = _optionalChain([message, 'access',
|
4533
|
+
const initialSteps = _optionalChain([message, 'access', _231 => _231.metadata, 'optionalAccess', _232 => _232.steps]);
|
4534
|
+
const initalCustom = _optionalChain([message, 'access', _233 => _233.metadata, 'optionalAccess', _234 => _234.custom]);
|
4535
4535
|
const updateMessage = (m) => {
|
4536
|
-
const newSteps = _optionalChain([m, 'access',
|
4536
|
+
const newSteps = _optionalChain([m, 'access', _235 => _235.metadata, 'optionalAccess', _236 => _236.steps]) || _optionalChain([m, 'access', _237 => _237.metadata, 'optionalAccess', _238 => _238.roundtrips]);
|
4537
4537
|
const steps2 = newSteps ? [..._nullishCoalesce(initialSteps, () => ( [])), ...newSteps] : void 0;
|
4538
4538
|
message = {
|
4539
4539
|
...message,
|
@@ -4545,7 +4545,7 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
|
|
4545
4545
|
metadata: {
|
4546
4546
|
...message.metadata,
|
4547
4547
|
...steps2 ? { roundtrips: steps2, steps: steps2 } : void 0,
|
4548
|
-
..._optionalChain([m, 'access',
|
4548
|
+
..._optionalChain([m, 'access', _239 => _239.metadata, 'optionalAccess', _240 => _240.custom]) ? {
|
4549
4549
|
custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
|
4550
4550
|
} : void 0
|
4551
4551
|
}
|
@@ -4555,7 +4555,7 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
|
|
4555
4555
|
this._notifySubscribers();
|
4556
4556
|
};
|
4557
4557
|
const maxSteps = this._options.maxSteps ? this._options.maxSteps : (_nullishCoalesce(this._options.maxToolRoundtrips, () => ( 1))) + 1;
|
4558
|
-
const steps = _nullishCoalesce(_optionalChain([message, 'access',
|
4558
|
+
const steps = _nullishCoalesce(_optionalChain([message, 'access', _241 => _241.metadata, 'optionalAccess', _242 => _242.steps, 'optionalAccess', _243 => _243.length]), () => ( 0));
|
4559
4559
|
if (steps >= maxSteps) {
|
4560
4560
|
updateMessage({
|
4561
4561
|
status: {
|
@@ -4607,7 +4607,7 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
|
|
4607
4607
|
return message;
|
4608
4608
|
}
|
4609
4609
|
cancelRun() {
|
4610
|
-
_optionalChain([this, 'access',
|
4610
|
+
_optionalChain([this, 'access', _244 => _244.abortController, 'optionalAccess', _245 => _245.abort, 'call', _246 => _246()]);
|
4611
4611
|
this.abortController = null;
|
4612
4612
|
}
|
4613
4613
|
addToolResult({
|
@@ -4766,7 +4766,7 @@ var getExportFromInitialMessages = (initialMessages) => {
|
|
4766
4766
|
const messages2 = fromCoreMessages(initialMessages);
|
4767
4767
|
return {
|
4768
4768
|
messages: messages2.map((m, idx) => ({
|
4769
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
4769
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _247 => _247[idx - 1], 'optionalAccess', _248 => _248.id]), () => ( null)),
|
4770
4770
|
message: m
|
4771
4771
|
}))
|
4772
4772
|
};
|
@@ -4877,7 +4877,7 @@ var ExternalStoreThreadManagerRuntimeCore = (_class14 = class {
|
|
4877
4877
|
this._notifySubscribers();
|
4878
4878
|
}
|
4879
4879
|
switchToThread(threadId) {
|
4880
|
-
if (_optionalChain([this, 'access',
|
4880
|
+
if (_optionalChain([this, 'access', _249 => _249._mainThread, 'optionalAccess', _250 => _250.threadId]) === threadId) return;
|
4881
4881
|
const onSwitchToThread = this.adapter.onSwitchToThread;
|
4882
4882
|
if (!onSwitchToThread)
|
4883
4883
|
throw new Error(
|
@@ -5003,6 +5003,7 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
5003
5003
|
case "text":
|
5004
5004
|
case "ui":
|
5005
5005
|
case "image":
|
5006
|
+
case "audio":
|
5006
5007
|
return part;
|
5007
5008
|
default: {
|
5008
5009
|
const unhandledType = type;
|
@@ -5032,7 +5033,7 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
5032
5033
|
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
5033
5034
|
var EMPTY_ARRAY3 = Object.freeze([]);
|
5034
5035
|
var hasUpcomingMessage = (isRunning, messages2) => {
|
5035
|
-
return isRunning && _optionalChain([messages2, 'access',
|
5036
|
+
return isRunning && _optionalChain([messages2, 'access', _251 => _251[messages2.length - 1], 'optionalAccess', _252 => _252.role]) !== "assistant";
|
5036
5037
|
};
|
5037
5038
|
var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntimeCore {
|
5038
5039
|
__init37() {this.assistantOptimisticId = null}
|
@@ -5085,11 +5086,11 @@ var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntime
|
|
5085
5086
|
edit: this._store.onEdit !== void 0,
|
5086
5087
|
reload: this._store.onReload !== void 0,
|
5087
5088
|
cancel: this._store.onCancel !== void 0,
|
5088
|
-
speech: _optionalChain([this, 'access',
|
5089
|
-
unstable_copy: _optionalChain([this, 'access',
|
5089
|
+
speech: _optionalChain([this, 'access', _256 => _256._store, 'access', _257 => _257.adapters, 'optionalAccess', _258 => _258.speech]) !== void 0,
|
5090
|
+
unstable_copy: _optionalChain([this, 'access', _259 => _259._store, 'access', _260 => _260.unstable_capabilities, 'optionalAccess', _261 => _261.copy]) !== false,
|
5090
5091
|
// default true
|
5091
|
-
attachments: !!_optionalChain([this, 'access',
|
5092
|
-
feedback: !!_optionalChain([this, 'access',
|
5092
|
+
attachments: !!_optionalChain([this, 'access', _262 => _262._store, 'access', _263 => _263.adapters, 'optionalAccess', _264 => _264.attachments]),
|
5093
|
+
feedback: !!_optionalChain([this, 'access', _265 => _265._store, 'access', _266 => _266.adapters, 'optionalAccess', _267 => _267.feedback])
|
5093
5094
|
};
|
5094
5095
|
if (oldStore) {
|
5095
5096
|
if (oldStore.convertMessage !== store.convertMessage) {
|
@@ -5116,7 +5117,7 @@ var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntime
|
|
5116
5117
|
for (let i = 0; i < messages2.length; i++) {
|
5117
5118
|
const message = messages2[i];
|
5118
5119
|
const parent = messages2[i - 1];
|
5119
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
5120
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _268 => _268.id]), () => ( null)), message);
|
5120
5121
|
}
|
5121
5122
|
if (this.assistantOptimisticId) {
|
5122
5123
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -5124,7 +5125,7 @@ var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntime
|
|
5124
5125
|
}
|
5125
5126
|
if (hasUpcomingMessage(isRunning, messages2)) {
|
5126
5127
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
5127
|
-
_nullishCoalesce(_optionalChain([messages2, 'access',
|
5128
|
+
_nullishCoalesce(_optionalChain([messages2, 'access', _269 => _269.at, 'call', _270 => _270(-1), 'optionalAccess', _271 => _271.id]), () => ( null)),
|
5128
5129
|
{
|
5129
5130
|
role: "assistant",
|
5130
5131
|
content: []
|
@@ -5132,7 +5133,7 @@ var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntime
|
|
5132
5133
|
);
|
5133
5134
|
}
|
5134
5135
|
this.repository.resetHead(
|
5135
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access',
|
5136
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _272 => _272.at, 'call', _273 => _273(-1), 'optionalAccess', _274 => _274.id]))), () => ( null))
|
5136
5137
|
);
|
5137
5138
|
this._messages = this.repository.getMessages();
|
5138
5139
|
this._notifySubscribers();
|
@@ -5144,7 +5145,7 @@ var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntime
|
|
5144
5145
|
this.updateMessages(this.repository.getMessages());
|
5145
5146
|
}
|
5146
5147
|
async append(message) {
|
5147
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
5148
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _275 => _275.messages, 'access', _276 => _276.at, 'call', _277 => _277(-1), 'optionalAccess', _278 => _278.id]), () => ( null)))) {
|
5148
5149
|
if (!this._store.onEdit)
|
5149
5150
|
throw new Error("Runtime does not support editing messages.");
|
5150
5151
|
await this._store.onEdit(message);
|
@@ -5167,7 +5168,7 @@ var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntime
|
|
5167
5168
|
}
|
5168
5169
|
let messages2 = this.repository.getMessages();
|
5169
5170
|
const previousMessage = messages2[messages2.length - 1];
|
5170
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
5171
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _279 => _279.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _280 => _280.at, 'call', _281 => _281(-1), 'optionalAccess', _282 => _282.id])) {
|
5171
5172
|
this.repository.deleteMessage(previousMessage.id);
|
5172
5173
|
if (!this.composer.text.trim()) {
|
5173
5174
|
this.composer.setText(getThreadMessageText(previousMessage));
|
@@ -5186,7 +5187,7 @@ var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntime
|
|
5186
5187
|
this._store.onAddToolResult(options);
|
5187
5188
|
}
|
5188
5189
|
__init42() {this.updateMessages = (messages2) => {
|
5189
|
-
_optionalChain([this, 'access',
|
5190
|
+
_optionalChain([this, 'access', _283 => _283._store, 'access', _284 => _284.setMessages, 'optionalCall', _285 => _285(
|
5190
5191
|
messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
5191
5192
|
)]);
|
5192
5193
|
}}
|
@@ -5198,7 +5199,7 @@ var getThreadManagerAdapter = (store) => {
|
|
5198
5199
|
threadId: store.threadId,
|
5199
5200
|
onSwitchToNewThread: store.onSwitchToNewThread,
|
5200
5201
|
onSwitchToThread: store.onSwitchToThread,
|
5201
|
-
..._optionalChain([store, 'access',
|
5202
|
+
..._optionalChain([store, 'access', _286 => _286.adapters, 'optionalAccess', _287 => _287.threadManager])
|
5202
5203
|
};
|
5203
5204
|
};
|
5204
5205
|
var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
@@ -5390,18 +5391,18 @@ var DangerousInBrowserAdapter = class {
|
|
5390
5391
|
this.options = options;
|
5391
5392
|
}
|
5392
5393
|
async *run({ messages: messages2, abortSignal, config }) {
|
5393
|
-
const res = await
|
5394
|
+
const res = await _chunkMRIZ4RHIjs.getEdgeRuntimeStream.call(void 0, {
|
5394
5395
|
options: this.options,
|
5395
5396
|
abortSignal,
|
5396
5397
|
requestData: {
|
5397
5398
|
system: config.system,
|
5398
|
-
messages:
|
5399
|
-
tools: config.tools ?
|
5399
|
+
messages: _chunkMRIZ4RHIjs.toCoreMessages.call(void 0, messages2),
|
5400
|
+
tools: config.tools ? _chunkMRIZ4RHIjs.toLanguageModelTools.call(void 0, config.tools) : [],
|
5400
5401
|
...config.callSettings,
|
5401
5402
|
...config.config
|
5402
5403
|
}
|
5403
5404
|
});
|
5404
|
-
const stream = res.pipeThrough(
|
5405
|
+
const stream = res.pipeThrough(_chunkMRIZ4RHIjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkMRIZ4RHIjs.runResultStream.call(void 0, ));
|
5405
5406
|
for await (const update of asAsyncIterable(stream)) {
|
5406
5407
|
yield update;
|
5407
5408
|
}
|
@@ -5620,7 +5621,7 @@ var ThreadConfigProvider = ({
|
|
5620
5621
|
}) => {
|
5621
5622
|
const hasAssistant = !!useAssistantRuntime({ optional: true });
|
5622
5623
|
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 });
|
5623
|
-
if (!_optionalChain([config, 'optionalAccess',
|
5624
|
+
if (!_optionalChain([config, 'optionalAccess', _288 => _288.runtime])) return configProvider;
|
5624
5625
|
if (hasAssistant) {
|
5625
5626
|
throw new Error(
|
5626
5627
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -5948,7 +5949,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
5948
5949
|
{
|
5949
5950
|
components: {
|
5950
5951
|
...componentsProp,
|
5951
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
5952
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _289 => _289.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
|
5952
5953
|
tools: toolsComponents
|
5953
5954
|
}
|
5954
5955
|
}
|
@@ -6035,6 +6036,8 @@ DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
6035
6036
|
|
6036
6037
|
// src/ui/attachment.tsx
|
6037
6038
|
|
6039
|
+
var _shallow = require('zustand/shallow');
|
6040
|
+
|
6038
6041
|
|
6039
6042
|
var AttachmentRoot = withDefaults(attachment_exports.Root, {
|
6040
6043
|
className: "aui-attachment-root"
|
@@ -6056,13 +6059,15 @@ var useFileSrc = (file) => {
|
|
6056
6059
|
return src;
|
6057
6060
|
};
|
6058
6061
|
var useAttachmentSrc = () => {
|
6059
|
-
const { file, src } = useAttachment(
|
6060
|
-
|
6061
|
-
|
6062
|
-
|
6063
|
-
|
6064
|
-
|
6065
|
-
|
6062
|
+
const { file, src } = useAttachment(
|
6063
|
+
_shallow.useShallow.call(void 0, (a) => {
|
6064
|
+
if (a.type !== "image") return {};
|
6065
|
+
if (a.file) return { file: a.file };
|
6066
|
+
const src2 = _optionalChain([a, 'access', _290 => _290.content, 'optionalAccess', _291 => _291.filter, 'call', _292 => _292((c) => c.type === "image"), 'access', _293 => _293[0], 'optionalAccess', _294 => _294.image]);
|
6067
|
+
if (!src2) return {};
|
6068
|
+
return { src: src2 };
|
6069
|
+
})
|
6070
|
+
);
|
6066
6071
|
return _nullishCoalesce(useFileSrc(file), () => ( src));
|
6067
6072
|
};
|
6068
6073
|
var AttachmentPreview = ({ src }) => {
|
@@ -6092,7 +6097,10 @@ var AttachmentPreviewDialog = ({ children }) => {
|
|
6092
6097
|
if (!src) return children;
|
6093
6098
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Dialog, { children: [
|
6094
6099
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTrigger, { className: "aui-attachment-preview-trigger", asChild: true, children }),
|
6095
|
-
/* @__PURE__ */ _jsxruntime.
|
6100
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogContent, { children: [
|
6101
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactdialog.DialogTitle, { className: "aui-sr-only", children: "Image Attachment Preview" }),
|
6102
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentPreview, { src })
|
6103
|
+
] })
|
6096
6104
|
] });
|
6097
6105
|
};
|
6098
6106
|
var AttachmentThumb = () => {
|
@@ -6203,7 +6211,7 @@ var ComposerAttachments = ({ components }) => {
|
|
6203
6211
|
{
|
6204
6212
|
components: {
|
6205
6213
|
...components,
|
6206
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6214
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _295 => _295.Attachment]), () => ( attachment_default))
|
6207
6215
|
}
|
6208
6216
|
}
|
6209
6217
|
) });
|
@@ -6336,7 +6344,7 @@ var ThreadWelcomeSuggestions = () => {
|
|
6336
6344
|
const suggestions2 = useThread((t) => t.suggestions);
|
6337
6345
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
6338
6346
|
const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
|
6339
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess',
|
6347
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _296 => _296.map, 'call', _297 => _297((suggestion, idx) => {
|
6340
6348
|
const key = `${suggestion.prompt}-${idx}`;
|
6341
6349
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
6342
6350
|
})]) });
|
@@ -6414,7 +6422,7 @@ var UserMessageContent = _react.forwardRef.call(void 0, ({ components, ...props
|
|
6414
6422
|
{
|
6415
6423
|
components: {
|
6416
6424
|
...components,
|
6417
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6425
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _298 => _298.Text]), () => ( content_part_default.Text))
|
6418
6426
|
}
|
6419
6427
|
}
|
6420
6428
|
) });
|
@@ -6431,7 +6439,7 @@ var UserMessageAttachments = ({
|
|
6431
6439
|
{
|
6432
6440
|
components: {
|
6433
6441
|
...components,
|
6434
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6442
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _299 => _299.Attachment]), () => ( attachment_default))
|
6435
6443
|
}
|
6436
6444
|
}
|
6437
6445
|
) }) });
|
@@ -6534,10 +6542,10 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
|
|
6534
6542
|
thread_exports.Messages,
|
6535
6543
|
{
|
6536
6544
|
components: {
|
6537
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6538
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6539
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6540
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6545
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _300 => _300.UserMessage]), () => ( user_message_default)),
|
6546
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _301 => _301.EditComposer]), () => ( edit_composer_default)),
|
6547
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _302 => _302.AssistantMessage]), () => ( assistant_message_default)),
|
6548
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _303 => _303.SystemMessage]), () => ( SystemMessage))
|
6541
6549
|
},
|
6542
6550
|
...rest
|
6543
6551
|
}
|
@@ -6548,7 +6556,7 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
|
|
6548
6556
|
ThreadMessages.displayName = "ThreadMessages";
|
6549
6557
|
var ThreadFollowupSuggestions = () => {
|
6550
6558
|
const suggestions = useThread((t) => t.suggestions);
|
6551
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess',
|
6559
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess', _304 => _304.map, 'call', _305 => _305((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
6552
6560
|
thread_exports.Suggestion,
|
6553
6561
|
{
|
6554
6562
|
className: "aui-thread-followup-suggestion",
|
@@ -6786,5 +6794,5 @@ var assistant_modal_default = Object.assign(AssistantModal, exports12);
|
|
6786
6794
|
|
6787
6795
|
|
6788
6796
|
|
6789
|
-
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.AttachmentPrimitive = attachment_exports; exports.AttachmentUI = attachment_default; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage =
|
6797
|
+
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.AttachmentPrimitive = attachment_exports; exports.AttachmentUI = attachment_default; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkMRIZ4RHIjs.toCoreMessage; exports.toCoreMessages = _chunkMRIZ4RHIjs.toCoreMessages; exports.toLanguageModelMessages = _chunkMRIZ4RHIjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkMRIZ4RHIjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarFeedbackNegative = useActionBarFeedbackNegative; exports.useActionBarFeedbackPositive = useActionBarFeedbackPositive; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantActions = useAssistantActions; exports.useAssistantActionsStore = useAssistantActionsStore; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantRuntime = useAssistantRuntime; exports.useAssistantRuntimeStore = useAssistantRuntimeStore; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useAttachment = useAttachment; exports.useAttachmentRuntime = useAttachmentRuntime; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposer = useComposer; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerRuntime = useComposerRuntime; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartRuntime = useContentPartRuntime; exports.useContentPartStore = useContentPartStore; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useEditComposer = useEditComposer; exports.useEditComposerStore = useEditComposerStore; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useInlineRender = useInlineRender; exports.useLocalRuntime = useLocalRuntime; exports.useMessage = useMessage; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useMessageRuntime = useMessageRuntime; exports.useMessageStore = useMessageStore; exports.useMessageUtils = useMessageUtils; exports.useMessageUtilsStore = useMessageUtilsStore; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThread = useThread; exports.useThreadActions = useThreadActions; exports.useThreadActionsStore = useThreadActionsStore; exports.useThreadComposer = useThreadComposer; exports.useThreadComposerStore = useThreadComposerStore; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadManager = useThreadManager; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadModelConfig = useThreadModelConfig; exports.useThreadRuntime = useThreadRuntime; exports.useThreadRuntimeStore = useThreadRuntimeStore; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadStore = useThreadStore; exports.useThreadSuggestion = useThreadSuggestion; exports.useThreadViewport = useThreadViewport; exports.useThreadViewportStore = useThreadViewportStore; exports.useToolUIs = useToolUIs; exports.useToolUIsStore = useToolUIsStore;
|
6790
6798
|
//# sourceMappingURL=index.js.map
|