@assistant-ui/react 0.5.72 → 0.5.73
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-5KIEXJRK.js → chunk-KVXP3Q6K.js} +60 -21
- package/dist/chunk-KVXP3Q6K.js.map +1 -0
- package/dist/{chunk-DC342I2Q.mjs → chunk-SNNYBBO6.mjs} +57 -18
- package/dist/chunk-SNNYBBO6.mjs.map +1 -0
- package/dist/{edge-DRioHVD9.d.mts → edge-rTP-G718.d.mts} +17 -6
- package/dist/{edge-DRioHVD9.d.ts → edge-rTP-G718.d.ts} +17 -6
- package/dist/edge.d.mts +9 -2
- package/dist/edge.d.ts +9 -2
- package/dist/edge.js +56 -17
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +56 -17
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +26 -17
- package/dist/index.d.ts +26 -17
- package/dist/index.js +116 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -35
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +1 -1
- package/package.json +4 -4
- package/dist/chunk-5KIEXJRK.js.map +0 -1
- package/dist/chunk-DC342I2Q.mjs.map +0 -1
package/dist/index.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
|
12
|
-
var
|
12
|
+
var _chunkKVXP3Q6Kjs = require('./chunk-KVXP3Q6K.js');
|
13
13
|
|
14
14
|
|
15
15
|
var _chunkPZ5AY32Cjs = require('./chunk-PZ5AY32C.js');
|
@@ -3109,7 +3109,7 @@ var DefaultThreadComposerRuntimeCore = (_class9 = class extends BaseComposerRunt
|
|
3109
3109
|
var ProxyConfigProvider = (_class10 = class {constructor() { _class10.prototype.__init19.call(this); }
|
3110
3110
|
__init19() {this._providers = /* @__PURE__ */ new Set()}
|
3111
3111
|
getModelConfig() {
|
3112
|
-
return
|
3112
|
+
return _chunkKVXP3Q6Kjs.mergeModelConfigs.call(void 0, this._providers);
|
3113
3113
|
}
|
3114
3114
|
registerModelConfigProvider(provider) {
|
3115
3115
|
this._providers.add(provider);
|
@@ -3687,7 +3687,7 @@ var ThreadRuntimeImpl = (_class12 = class {
|
|
3687
3687
|
}, _class12);
|
3688
3688
|
|
3689
3689
|
// src/runtimes/edge/converters/fromLanguageModelMessages.ts
|
3690
|
-
var fromLanguageModelMessages = (lm, {
|
3690
|
+
var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
3691
3691
|
const messages2 = [];
|
3692
3692
|
for (const lmMessage of lm) {
|
3693
3693
|
const role = lmMessage.role;
|
@@ -3750,7 +3750,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
3750
3750
|
}
|
3751
3751
|
return part;
|
3752
3752
|
});
|
3753
|
-
if (
|
3753
|
+
if (mergeSteps) {
|
3754
3754
|
const previousMessage = messages2[messages2.length - 1];
|
3755
3755
|
if (_optionalChain([previousMessage, 'optionalAccess', _181 => _181.role]) === "assistant") {
|
3756
3756
|
previousMessage.content.push(...newContent);
|
@@ -3841,14 +3841,14 @@ function streamPartDecoderStream() {
|
|
3841
3841
|
controller.enqueue(decodeStreamPart(chunk));
|
3842
3842
|
}
|
3843
3843
|
});
|
3844
|
-
return new (0,
|
3844
|
+
return new (0, _chunkKVXP3Q6Kjs.PipeableTransformStream)((readable) => {
|
3845
3845
|
return readable.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(decodeStream);
|
3846
3846
|
});
|
3847
3847
|
}
|
3848
3848
|
|
3849
3849
|
// src/runtimes/edge/streams/utils/index.ts
|
3850
3850
|
var streamUtils = {
|
3851
|
-
streamPartEncoderStream:
|
3851
|
+
streamPartEncoderStream: _chunkKVXP3Q6Kjs.streamPartEncoderStream,
|
3852
3852
|
streamPartDecoderStream
|
3853
3853
|
};
|
3854
3854
|
|
@@ -3861,7 +3861,7 @@ function assistantDecoderStream() {
|
|
3861
3861
|
let currentToolCall;
|
3862
3862
|
return new TransformStream({
|
3863
3863
|
transform({ type, value }, controller) {
|
3864
|
-
if (currentToolCall && type !== "
|
3864
|
+
if (currentToolCall && type !== "c" /* ToolCallDelta */ && type !== "3" /* Error */) {
|
3865
3865
|
controller.enqueue({
|
3866
3866
|
type: "tool-call",
|
3867
3867
|
toolCallType: "function",
|
@@ -3879,48 +3879,82 @@ function assistantDecoderStream() {
|
|
3879
3879
|
});
|
3880
3880
|
break;
|
3881
3881
|
}
|
3882
|
-
case "
|
3883
|
-
const { id, name } = value;
|
3882
|
+
case "b" /* ToolCallBegin */: {
|
3883
|
+
const { toolCallId: id, toolName: name } = value;
|
3884
3884
|
toolCallNames.set(id, name);
|
3885
3885
|
currentToolCall = { id, name, argsText: "" };
|
3886
3886
|
break;
|
3887
3887
|
}
|
3888
|
-
case "
|
3889
|
-
const
|
3890
|
-
currentToolCall.
|
3888
|
+
case "c" /* ToolCallDelta */: {
|
3889
|
+
const { toolCallId, argsTextDelta } = value;
|
3890
|
+
if (_optionalChain([currentToolCall, 'optionalAccess', _183 => _183.id]) !== toolCallId) {
|
3891
|
+
throw new Error(
|
3892
|
+
`Received tool call delta for unknown tool call "${toolCallId}".`
|
3893
|
+
);
|
3894
|
+
}
|
3895
|
+
currentToolCall.argsText += argsTextDelta;
|
3891
3896
|
controller.enqueue({
|
3892
3897
|
type: "tool-call-delta",
|
3893
3898
|
toolCallType: "function",
|
3894
3899
|
toolCallId: currentToolCall.id,
|
3895
3900
|
toolName: currentToolCall.name,
|
3896
|
-
argsTextDelta
|
3901
|
+
argsTextDelta
|
3897
3902
|
});
|
3898
3903
|
break;
|
3899
3904
|
}
|
3900
|
-
case "
|
3905
|
+
case "a" /* ToolCallResult */: {
|
3901
3906
|
controller.enqueue({
|
3902
3907
|
type: "tool-result",
|
3903
3908
|
toolCallType: "function",
|
3904
|
-
toolCallId: value.
|
3905
|
-
toolName: toolCallNames.get(value.
|
3909
|
+
toolCallId: value.toolCallId,
|
3910
|
+
toolName: toolCallNames.get(value.toolCallId),
|
3906
3911
|
result: value.result
|
3907
3912
|
});
|
3908
3913
|
break;
|
3909
3914
|
}
|
3910
|
-
case "
|
3915
|
+
case "d" /* Finish */: {
|
3911
3916
|
controller.enqueue({
|
3912
3917
|
type: "finish",
|
3913
3918
|
...value
|
3914
3919
|
});
|
3915
3920
|
break;
|
3916
3921
|
}
|
3917
|
-
case "
|
3922
|
+
case "3" /* Error */: {
|
3918
3923
|
controller.enqueue({
|
3919
3924
|
type: "error",
|
3920
3925
|
error: value
|
3921
3926
|
});
|
3922
3927
|
break;
|
3923
3928
|
}
|
3929
|
+
case "9" /* ToolCall */: {
|
3930
|
+
const { toolCallId, toolName, args } = value;
|
3931
|
+
const argsText = JSON.stringify(args);
|
3932
|
+
controller.enqueue({
|
3933
|
+
type: "tool-call-delta",
|
3934
|
+
toolCallType: "function",
|
3935
|
+
toolCallId,
|
3936
|
+
toolName,
|
3937
|
+
argsTextDelta: argsText
|
3938
|
+
});
|
3939
|
+
controller.enqueue({
|
3940
|
+
type: "tool-call",
|
3941
|
+
toolCallType: "function",
|
3942
|
+
toolCallId,
|
3943
|
+
toolName,
|
3944
|
+
args: argsText
|
3945
|
+
});
|
3946
|
+
break;
|
3947
|
+
}
|
3948
|
+
case "e" /* StepFinish */: {
|
3949
|
+
controller.enqueue({
|
3950
|
+
type: "step-finish",
|
3951
|
+
...value
|
3952
|
+
});
|
3953
|
+
break;
|
3954
|
+
}
|
3955
|
+
// TODO
|
3956
|
+
case "2" /* Data */:
|
3957
|
+
break;
|
3924
3958
|
default: {
|
3925
3959
|
const unhandledType = type;
|
3926
3960
|
throw new Error(`Unhandled chunk type: ${unhandledType}`);
|
@@ -3957,8 +3991,8 @@ var EdgeChatAdapter = class {
|
|
3957
3991
|
credentials: _nullishCoalesce(this.options.credentials, () => ( "same-origin")),
|
3958
3992
|
body: JSON.stringify({
|
3959
3993
|
system: config.system,
|
3960
|
-
messages:
|
3961
|
-
tools: config.tools ?
|
3994
|
+
messages: _chunkKVXP3Q6Kjs.toCoreMessages.call(void 0, messages2),
|
3995
|
+
tools: config.tools ? _chunkKVXP3Q6Kjs.toLanguageModelTools.call(void 0, config.tools) : [],
|
3962
3996
|
...config.callSettings,
|
3963
3997
|
...config.config,
|
3964
3998
|
...this.options.body
|
@@ -3968,7 +4002,7 @@ var EdgeChatAdapter = class {
|
|
3968
4002
|
if (!result.ok) {
|
3969
4003
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
3970
4004
|
}
|
3971
|
-
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(
|
4005
|
+
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkKVXP3Q6Kjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkKVXP3Q6Kjs.runResultStream.call(void 0, ));
|
3972
4006
|
let update;
|
3973
4007
|
for await (update of asAsyncIterable(stream)) {
|
3974
4008
|
yield update;
|
@@ -3980,9 +4014,14 @@ var EdgeChatAdapter = class {
|
|
3980
4014
|
|
3981
4015
|
// src/runtimes/local/LocalRuntimeOptions.tsx
|
3982
4016
|
var splitLocalRuntimeOptions = (options) => {
|
3983
|
-
const { initialMessages, maxToolRoundtrips, adapters, ...rest } = options;
|
4017
|
+
const { initialMessages, maxToolRoundtrips, maxSteps, adapters, ...rest } = options;
|
3984
4018
|
return {
|
3985
|
-
localRuntimeOptions: {
|
4019
|
+
localRuntimeOptions: {
|
4020
|
+
initialMessages,
|
4021
|
+
maxToolRoundtrips,
|
4022
|
+
maxSteps,
|
4023
|
+
adapters
|
4024
|
+
},
|
3986
4025
|
otherOptions: rest
|
3987
4026
|
};
|
3988
4027
|
};
|
@@ -3995,7 +4034,7 @@ var useEdgeRuntime = (options) => {
|
|
3995
4034
|
};
|
3996
4035
|
|
3997
4036
|
// src/runtimes/local/shouldContinue.tsx
|
3998
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
4037
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _184 => _184.status, 'optionalAccess', _185 => _185.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
3999
4038
|
|
4000
4039
|
// src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
|
4001
4040
|
var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
@@ -4083,18 +4122,18 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4083
4122
|
set options({ initialMessages, ...options }) {
|
4084
4123
|
this._options = options;
|
4085
4124
|
let hasUpdates = false;
|
4086
|
-
const canSpeak = _optionalChain([options, 'access',
|
4125
|
+
const canSpeak = _optionalChain([options, 'access', _186 => _186.adapters, 'optionalAccess', _187 => _187.speech]) !== void 0;
|
4087
4126
|
if (this.capabilities.speak !== canSpeak) {
|
4088
4127
|
this.capabilities.speak = canSpeak;
|
4089
4128
|
hasUpdates = true;
|
4090
4129
|
}
|
4091
|
-
this.composer.setAttachmentAdapter(_optionalChain([options, 'access',
|
4092
|
-
const canAttach = _optionalChain([options, 'access',
|
4130
|
+
this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _188 => _188.adapters, 'optionalAccess', _189 => _189.attachments]));
|
4131
|
+
const canAttach = _optionalChain([options, 'access', _190 => _190.adapters, 'optionalAccess', _191 => _191.attachments]) !== void 0;
|
4093
4132
|
if (this.capabilities.attachments !== canAttach) {
|
4094
4133
|
this.capabilities.attachments = canAttach;
|
4095
4134
|
hasUpdates = true;
|
4096
4135
|
}
|
4097
|
-
const canFeedback = _optionalChain([options, 'access',
|
4136
|
+
const canFeedback = _optionalChain([options, 'access', _192 => _192.adapters, 'optionalAccess', _193 => _193.feedback]) !== void 0;
|
4098
4137
|
if (this.capabilities.feedback !== canFeedback) {
|
4099
4138
|
this.capabilities.feedback = canFeedback;
|
4100
4139
|
hasUpdates = true;
|
@@ -4153,33 +4192,25 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4153
4192
|
}
|
4154
4193
|
async performRoundtrip(parentId, message) {
|
4155
4194
|
const messages2 = this.repository.getMessages();
|
4156
|
-
_optionalChain([this, 'access',
|
4195
|
+
_optionalChain([this, 'access', _194 => _194.abortController, 'optionalAccess', _195 => _195.abort, 'call', _196 => _196()]);
|
4157
4196
|
this.abortController = new AbortController();
|
4158
4197
|
const initialContent = message.content;
|
4159
|
-
const
|
4160
|
-
const initalCustom = _optionalChain([message, 'access',
|
4198
|
+
const initialSteps = _optionalChain([message, 'access', _197 => _197.metadata, 'optionalAccess', _198 => _198.steps]);
|
4199
|
+
const initalCustom = _optionalChain([message, 'access', _199 => _199.metadata, 'optionalAccess', _200 => _200.custom]);
|
4161
4200
|
const updateMessage = (m) => {
|
4201
|
+
const newSteps = _optionalChain([m, 'access', _201 => _201.metadata, 'optionalAccess', _202 => _202.steps]) || _optionalChain([m, 'access', _203 => _203.metadata, 'optionalAccess', _204 => _204.roundtrips]);
|
4202
|
+
const steps2 = newSteps ? [..._nullishCoalesce(initialSteps, () => ( [])), ...newSteps] : void 0;
|
4162
4203
|
message = {
|
4163
4204
|
...message,
|
4164
4205
|
...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
|
4165
4206
|
status: _nullishCoalesce(m.status, () => ( message.status)),
|
4166
4207
|
// TODO deprecated, remove in v0.6
|
4167
|
-
...
|
4168
|
-
roundtrips: [
|
4169
|
-
..._nullishCoalesce(initialRoundtrips, () => ( [])),
|
4170
|
-
...m.metadata.roundtrips
|
4171
|
-
]
|
4172
|
-
} : void 0,
|
4208
|
+
...steps2 ? { roundtrips: steps2 } : void 0,
|
4173
4209
|
...m.metadata ? {
|
4174
4210
|
metadata: {
|
4175
4211
|
...message.metadata,
|
4176
|
-
...
|
4177
|
-
|
4178
|
-
..._nullishCoalesce(initialRoundtrips, () => ( [])),
|
4179
|
-
...m.metadata.roundtrips
|
4180
|
-
]
|
4181
|
-
} : void 0,
|
4182
|
-
..._optionalChain([m, 'access', _202 => _202.metadata, 'optionalAccess', _203 => _203.custom]) ? {
|
4212
|
+
...steps2 ? { roundtrips: steps2, steps: steps2 } : void 0,
|
4213
|
+
..._optionalChain([m, 'access', _205 => _205.metadata, 'optionalAccess', _206 => _206.custom]) ? {
|
4183
4214
|
custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
|
4184
4215
|
} : void 0
|
4185
4216
|
}
|
@@ -4188,9 +4219,9 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4188
4219
|
this.repository.addOrUpdateMessage(parentId, message);
|
4189
4220
|
this.notifySubscribers();
|
4190
4221
|
};
|
4191
|
-
const
|
4192
|
-
const
|
4193
|
-
if (
|
4222
|
+
const maxSteps = this.options.maxSteps ? this.options.maxSteps : (_nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1))) + 1;
|
4223
|
+
const steps = _nullishCoalesce(_optionalChain([message, 'access', _207 => _207.metadata, 'optionalAccess', _208 => _208.steps, 'optionalAccess', _209 => _209.length]), () => ( 0));
|
4224
|
+
if (steps >= maxSteps) {
|
4194
4225
|
updateMessage({
|
4195
4226
|
status: {
|
4196
4227
|
type: "incomplete",
|
@@ -4288,7 +4319,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4288
4319
|
// TODO lift utterance state to thread runtime
|
4289
4320
|
|
4290
4321
|
speak(messageId) {
|
4291
|
-
const adapter = _optionalChain([this, 'access',
|
4322
|
+
const adapter = _optionalChain([this, 'access', _210 => _210.options, 'access', _211 => _211.adapters, 'optionalAccess', _212 => _212.speech]);
|
4292
4323
|
if (!adapter) throw new Error("Speech adapter not configured");
|
4293
4324
|
const { message } = this.repository.getMessage(messageId);
|
4294
4325
|
if (this._utterance) {
|
@@ -4305,7 +4336,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4305
4336
|
return this._utterance;
|
4306
4337
|
}
|
4307
4338
|
submitFeedback({ messageId, type }) {
|
4308
|
-
const adapter = _optionalChain([this, 'access',
|
4339
|
+
const adapter = _optionalChain([this, 'access', _213 => _213.options, 'access', _214 => _214.adapters, 'optionalAccess', _215 => _215.feedback]);
|
4309
4340
|
if (!adapter) throw new Error("Feedback adapter not configured");
|
4310
4341
|
const { message } = this.repository.getMessage(messageId);
|
4311
4342
|
adapter.submit({ message, type });
|
@@ -4352,7 +4383,7 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4352
4383
|
const messages2 = fromCoreMessages(initialMessages);
|
4353
4384
|
this.thread.import({
|
4354
4385
|
messages: messages2.map((m, idx) => ({
|
4355
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
4386
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _216 => _216[idx - 1], 'optionalAccess', _217 => _217.id]), () => ( null)),
|
4356
4387
|
message: m
|
4357
4388
|
}))
|
4358
4389
|
});
|
@@ -4486,7 +4517,7 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
4486
4517
|
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
4487
4518
|
var EMPTY_ARRAY2 = Object.freeze([]);
|
4488
4519
|
var hasUpcomingMessage = (isRunning, messages2) => {
|
4489
|
-
return isRunning && _optionalChain([messages2, 'access',
|
4520
|
+
return isRunning && _optionalChain([messages2, 'access', _218 => _218[messages2.length - 1], 'optionalAccess', _219 => _219.role]) !== "assistant";
|
4490
4521
|
};
|
4491
4522
|
var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
4492
4523
|
constructor(configProvider, store) {;_class15.prototype.__init33.call(this);_class15.prototype.__init34.call(this);_class15.prototype.__init35.call(this);_class15.prototype.__init36.call(this);_class15.prototype.__init37.call(this);_class15.prototype.__init38.call(this);_class15.prototype.__init39.call(this);_class15.prototype.__init40.call(this);_class15.prototype.__init41.call(this);_class15.prototype.__init42.call(this);
|
@@ -4552,12 +4583,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4552
4583
|
reload: this._store.onReload !== void 0,
|
4553
4584
|
cancel: this._store.onCancel !== void 0,
|
4554
4585
|
speak: this._store.onSpeak !== void 0,
|
4555
|
-
unstable_copy: _optionalChain([this, 'access',
|
4586
|
+
unstable_copy: _optionalChain([this, 'access', _223 => _223._store, 'access', _224 => _224.unstable_capabilities, 'optionalAccess', _225 => _225.copy]) !== false,
|
4556
4587
|
// default true
|
4557
|
-
attachments: !!_optionalChain([this, 'access',
|
4558
|
-
feedback: !!_optionalChain([this, 'access',
|
4588
|
+
attachments: !!_optionalChain([this, 'access', _226 => _226.store, 'access', _227 => _227.adapters, 'optionalAccess', _228 => _228.attachments]),
|
4589
|
+
feedback: !!_optionalChain([this, 'access', _229 => _229.store, 'access', _230 => _230.adapters, 'optionalAccess', _231 => _231.feedback])
|
4559
4590
|
};
|
4560
|
-
this.composer.setAttachmentAdapter(_optionalChain([this, 'access',
|
4591
|
+
this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _232 => _232._store, 'access', _233 => _233.adapters, 'optionalAccess', _234 => _234.attachments]));
|
4561
4592
|
if (oldStore) {
|
4562
4593
|
if (oldStore.convertMessage !== store.convertMessage) {
|
4563
4594
|
this._converter = new ThreadMessageConverter();
|
@@ -4583,7 +4614,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4583
4614
|
for (let i = 0; i < messages2.length; i++) {
|
4584
4615
|
const message = messages2[i];
|
4585
4616
|
const parent = messages2[i - 1];
|
4586
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
4617
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _235 => _235.id]), () => ( null)), message);
|
4587
4618
|
}
|
4588
4619
|
if (this.assistantOptimisticId) {
|
4589
4620
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -4591,7 +4622,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4591
4622
|
}
|
4592
4623
|
if (hasUpcomingMessage(isRunning, messages2)) {
|
4593
4624
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
4594
|
-
_nullishCoalesce(_optionalChain([messages2, 'access',
|
4625
|
+
_nullishCoalesce(_optionalChain([messages2, 'access', _236 => _236.at, 'call', _237 => _237(-1), 'optionalAccess', _238 => _238.id]), () => ( null)),
|
4595
4626
|
{
|
4596
4627
|
role: "assistant",
|
4597
4628
|
content: []
|
@@ -4599,7 +4630,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4599
4630
|
);
|
4600
4631
|
}
|
4601
4632
|
this.repository.resetHead(
|
4602
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access',
|
4633
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _239 => _239.at, 'call', _240 => _240(-1), 'optionalAccess', _241 => _241.id]))), () => ( null))
|
4603
4634
|
);
|
4604
4635
|
this.messages = this.repository.getMessages();
|
4605
4636
|
this.notifySubscribers();
|
@@ -4620,7 +4651,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4620
4651
|
this.updateMessages(this.repository.getMessages());
|
4621
4652
|
}
|
4622
4653
|
async append(message) {
|
4623
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
4654
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _242 => _242.messages, 'access', _243 => _243.at, 'call', _244 => _244(-1), 'optionalAccess', _245 => _245.id]), () => ( null)))) {
|
4624
4655
|
if (!this._store.onEdit)
|
4625
4656
|
throw new Error("Runtime does not support editing messages.");
|
4626
4657
|
await this._store.onEdit(message);
|
@@ -4643,7 +4674,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4643
4674
|
}
|
4644
4675
|
let messages2 = this.repository.getMessages();
|
4645
4676
|
const previousMessage = messages2[messages2.length - 1];
|
4646
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
4677
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _246 => _246.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _247 => _247.at, 'call', _248 => _248(-1), 'optionalAccess', _249 => _249.id])) {
|
4647
4678
|
this.repository.deleteMessage(previousMessage.id);
|
4648
4679
|
if (!this.composer.text.trim()) {
|
4649
4680
|
this.composer.setText(getThreadMessageText(previousMessage));
|
@@ -4668,7 +4699,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4668
4699
|
return this._store.onSpeak(message);
|
4669
4700
|
}
|
4670
4701
|
submitFeedback({ messageId, type }) {
|
4671
|
-
const adapter = _optionalChain([this, 'access',
|
4702
|
+
const adapter = _optionalChain([this, 'access', _250 => _250._store, 'access', _251 => _251.adapters, 'optionalAccess', _252 => _252.feedback]);
|
4672
4703
|
if (!adapter) throw new Error("Feedback adapter not configured");
|
4673
4704
|
const { message } = this.repository.getMessage(messageId);
|
4674
4705
|
adapter.submit({ message, type });
|
@@ -4678,7 +4709,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4678
4709
|
return () => this._subscriptions.delete(callback);
|
4679
4710
|
}
|
4680
4711
|
__init42() {this.updateMessages = (messages2) => {
|
4681
|
-
_optionalChain([this, 'access',
|
4712
|
+
_optionalChain([this, 'access', _253 => _253._store, 'access', _254 => _254.setMessages, 'optionalCall', _255 => _255(
|
4682
4713
|
messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
4683
4714
|
)]);
|
4684
4715
|
}}
|
@@ -4902,18 +4933,18 @@ var DangerousInBrowserAdapter = class {
|
|
4902
4933
|
this.options = options;
|
4903
4934
|
}
|
4904
4935
|
async *run({ messages: messages2, abortSignal, config }) {
|
4905
|
-
const res = await
|
4936
|
+
const res = await _chunkKVXP3Q6Kjs.getEdgeRuntimeStream.call(void 0, {
|
4906
4937
|
options: this.options,
|
4907
4938
|
abortSignal,
|
4908
4939
|
requestData: {
|
4909
4940
|
system: config.system,
|
4910
|
-
messages:
|
4911
|
-
tools: config.tools ?
|
4941
|
+
messages: _chunkKVXP3Q6Kjs.toCoreMessages.call(void 0, messages2),
|
4942
|
+
tools: config.tools ? _chunkKVXP3Q6Kjs.toLanguageModelTools.call(void 0, config.tools) : [],
|
4912
4943
|
...config.callSettings,
|
4913
4944
|
...config.config
|
4914
4945
|
}
|
4915
4946
|
});
|
4916
|
-
const stream = res.pipeThrough(
|
4947
|
+
const stream = res.pipeThrough(_chunkKVXP3Q6Kjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkKVXP3Q6Kjs.runResultStream.call(void 0, ));
|
4917
4948
|
for await (const update of asAsyncIterable(stream)) {
|
4918
4949
|
yield update;
|
4919
4950
|
}
|
@@ -5133,7 +5164,7 @@ var ThreadConfigProvider = ({
|
|
5133
5164
|
}) => {
|
5134
5165
|
const hasAssistant = !!useAssistantRuntime({ optional: true });
|
5135
5166
|
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 });
|
5136
|
-
if (!_optionalChain([config, 'optionalAccess',
|
5167
|
+
if (!_optionalChain([config, 'optionalAccess', _256 => _256.runtime])) return configProvider;
|
5137
5168
|
if (hasAssistant) {
|
5138
5169
|
throw new Error(
|
5139
5170
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -5461,7 +5492,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
5461
5492
|
{
|
5462
5493
|
components: {
|
5463
5494
|
...componentsProp,
|
5464
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
5495
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _257 => _257.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
|
5465
5496
|
tools: toolsComponents
|
5466
5497
|
}
|
5467
5498
|
}
|
@@ -5603,7 +5634,7 @@ var ComposerAttachments = ({ components }) => {
|
|
5603
5634
|
{
|
5604
5635
|
components: {
|
5605
5636
|
...components,
|
5606
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5637
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _258 => _258.Attachment]), () => ( composer_attachment_default))
|
5607
5638
|
}
|
5608
5639
|
}
|
5609
5640
|
) });
|
@@ -5729,7 +5760,7 @@ var ThreadWelcomeSuggestions = () => {
|
|
5729
5760
|
const suggestions2 = useThread((t) => t.suggestions);
|
5730
5761
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
5731
5762
|
const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
|
5732
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess',
|
5763
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _259 => _259.map, 'call', _260 => _260((suggestion, idx) => {
|
5733
5764
|
const key = `${suggestion.prompt}-${idx}`;
|
5734
5765
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
5735
5766
|
})]) });
|
@@ -5828,7 +5859,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
|
|
5828
5859
|
{
|
5829
5860
|
components: {
|
5830
5861
|
...components,
|
5831
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5862
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _261 => _261.Text]), () => ( content_part_default.Text))
|
5832
5863
|
}
|
5833
5864
|
}
|
5834
5865
|
) });
|
@@ -5846,7 +5877,7 @@ var UserMessageAttachments = ({
|
|
5846
5877
|
{
|
5847
5878
|
components: {
|
5848
5879
|
...components,
|
5849
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5880
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _262 => _262.Attachment]), () => ( user_message_attachment_default))
|
5850
5881
|
}
|
5851
5882
|
}
|
5852
5883
|
) }) });
|
@@ -5915,9 +5946,14 @@ var edit_composer_default = Object.assign(EditComposer, exports11);
|
|
5915
5946
|
// src/ui/thread.tsx
|
5916
5947
|
|
5917
5948
|
var Thread = (config) => {
|
5918
|
-
const {
|
5949
|
+
const {
|
5950
|
+
components: {
|
5951
|
+
Composer: ComposerComponent = composer_default,
|
5952
|
+
ThreadWelcome: ThreadWelcomeComponent = thread_welcome_default
|
5953
|
+
} = {}
|
5954
|
+
} = config;
|
5919
5955
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRoot, { config, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewport, { children: [
|
5920
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
5956
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeComponent, {}),
|
5921
5957
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessages, {}),
|
5922
5958
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadFollowupSuggestions, {}),
|
5923
5959
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewportFooter, { children: [
|
@@ -5950,10 +5986,10 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
|
|
5950
5986
|
thread_exports.Messages,
|
5951
5987
|
{
|
5952
5988
|
components: {
|
5953
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5954
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5955
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5956
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5989
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _263 => _263.UserMessage]), () => ( user_message_default)),
|
5990
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _264 => _264.EditComposer]), () => ( edit_composer_default)),
|
5991
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _265 => _265.AssistantMessage]), () => ( assistant_message_default)),
|
5992
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _266 => _266.SystemMessage]), () => ( SystemMessage))
|
5957
5993
|
},
|
5958
5994
|
...rest
|
5959
5995
|
}
|
@@ -5964,7 +6000,7 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
|
|
5964
6000
|
ThreadMessages.displayName = "ThreadMessages";
|
5965
6001
|
var ThreadFollowupSuggestions = () => {
|
5966
6002
|
const suggestions = useThread((t) => t.suggestions);
|
5967
|
-
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',
|
6003
|
+
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', _267 => _267.map, 'call', _268 => _268((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
5968
6004
|
thread_exports.Suggestion,
|
5969
6005
|
{
|
5970
6006
|
className: "aui-thread-followup-suggestion",
|
@@ -6192,5 +6228,5 @@ var assistant_modal_default = Object.assign(AssistantModal, exports13);
|
|
6192
6228
|
|
6193
6229
|
|
6194
6230
|
|
6195
|
-
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage =
|
6231
|
+
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkKVXP3Q6Kjs.toCoreMessage; exports.toCoreMessages = _chunkKVXP3Q6Kjs.toCoreMessages; exports.toLanguageModelMessages = _chunkKVXP3Q6Kjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkKVXP3Q6Kjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarFeedbackNegative = useActionBarFeedbackNegative; exports.useActionBarFeedbackPositive = useActionBarFeedbackPositive; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantActions = useAssistantActions; exports.useAssistantActionsStore = useAssistantActionsStore; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantRuntime = useAssistantRuntime; exports.useAssistantRuntimeStore = useAssistantRuntimeStore; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposer = useComposer; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerRuntime = useComposerRuntime; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartRuntime = useContentPartRuntime; exports.useContentPartStore = useContentPartStore; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useEditComposer = useEditComposer; exports.useEditComposerStore = useEditComposerStore; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessage = useMessage; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useMessageRuntime = useMessageRuntime; exports.useMessageStore = useMessageStore; exports.useMessageUtils = useMessageUtils; exports.useMessageUtilsStore = useMessageUtilsStore; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThread = useThread; exports.useThreadActions = useThreadActions; exports.useThreadActionsStore = useThreadActionsStore; exports.useThreadComposer = useThreadComposer; exports.useThreadComposerStore = useThreadComposerStore; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadRuntime = useThreadRuntime; exports.useThreadRuntimeStore = useThreadRuntimeStore; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadStore = useThreadStore; exports.useThreadSuggestion = useThreadSuggestion; exports.useThreadViewport = useThreadViewport; exports.useThreadViewportStore = useThreadViewportStore; exports.useToolUIs = useToolUIs; exports.useToolUIsStore = useToolUIsStore;
|
6196
6232
|
//# sourceMappingURL=index.js.map
|