@dremio/js-sdk 0.59.0 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/cloud/ai/AIResource.d.ts +93 -13
- package/dist/cloud/projects/Project.d.ts +5 -0
- package/dist/cloud/projects/projectPropertiesCodec.d.ts +15 -0
- package/dist/cloud/projects/projectPropertiesCodec.js +6 -0
- package/dist/cloud/projects/projectPropertiesCodec.js.map +1 -1
- package/dist/enterprise/ai/AIResource.d.ts +93 -13
- package/dist/enterprise/ai/chat/chatEventSchema.d.ts +26 -3
- package/dist/enterprise/ai/chat/chatEventSchema.js +61 -11
- package/dist/enterprise/ai/chat/chatEventSchema.js.map +1 -1
- package/dist/enterprise/ai/conversations/AgentConversation.d.ts +30 -4
- package/dist/enterprise/ai/conversations/createConversationMachine.d.ts +97 -13
- package/dist/enterprise/ai/conversations/createConversationMachine.js +83 -13
- package/dist/enterprise/ai/conversations/createConversationMachine.js.map +1 -1
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.d.ts +15 -2
- package/dist/enterprise/ai/conversations/reduceChatEvents.d.ts +1 -1
- package/dist/enterprise/ai/conversations/reduceChatEvents.js +4 -1
- package/dist/enterprise/ai/conversations/reduceChatEvents.js.map +1 -1
- package/dist-iife/cloud.js +219 -40
- package/dist-iife/enterprise.js +213 -40
- package/package.json +1 -1
package/dist-iife/enterprise.js
CHANGED
|
@@ -12251,16 +12251,16 @@ var DremioEnterprise = (() => {
|
|
|
12251
12251
|
|
|
12252
12252
|
// node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js
|
|
12253
12253
|
var timeoutProvider = {
|
|
12254
|
-
setTimeout: function(handler,
|
|
12254
|
+
setTimeout: function(handler, timeout2) {
|
|
12255
12255
|
var args = [];
|
|
12256
12256
|
for (var _i2 = 2; _i2 < arguments.length; _i2++) {
|
|
12257
12257
|
args[_i2 - 2] = arguments[_i2];
|
|
12258
12258
|
}
|
|
12259
12259
|
var delegate = timeoutProvider.delegate;
|
|
12260
12260
|
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
12261
|
-
return delegate.setTimeout.apply(delegate, __spreadArray2([handler,
|
|
12261
|
+
return delegate.setTimeout.apply(delegate, __spreadArray2([handler, timeout2], __read(args)));
|
|
12262
12262
|
}
|
|
12263
|
-
return setTimeout.apply(void 0, __spreadArray2([handler,
|
|
12263
|
+
return setTimeout.apply(void 0, __spreadArray2([handler, timeout2], __read(args)));
|
|
12264
12264
|
},
|
|
12265
12265
|
clearTimeout: function(handle) {
|
|
12266
12266
|
var delegate = timeoutProvider.delegate;
|
|
@@ -12929,16 +12929,16 @@ var DremioEnterprise = (() => {
|
|
|
12929
12929
|
|
|
12930
12930
|
// node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js
|
|
12931
12931
|
var intervalProvider = {
|
|
12932
|
-
setInterval: function(handler,
|
|
12932
|
+
setInterval: function(handler, timeout2) {
|
|
12933
12933
|
var args = [];
|
|
12934
12934
|
for (var _i2 = 2; _i2 < arguments.length; _i2++) {
|
|
12935
12935
|
args[_i2 - 2] = arguments[_i2];
|
|
12936
12936
|
}
|
|
12937
12937
|
var delegate = intervalProvider.delegate;
|
|
12938
12938
|
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
12939
|
-
return delegate.setInterval.apply(delegate, __spreadArray2([handler,
|
|
12939
|
+
return delegate.setInterval.apply(delegate, __spreadArray2([handler, timeout2], __read(args)));
|
|
12940
12940
|
}
|
|
12941
|
-
return setInterval.apply(void 0, __spreadArray2([handler,
|
|
12941
|
+
return setInterval.apply(void 0, __spreadArray2([handler, timeout2], __read(args)));
|
|
12942
12942
|
},
|
|
12943
12943
|
clearInterval: function(handle) {
|
|
12944
12944
|
var delegate = intervalProvider.delegate;
|
|
@@ -13553,6 +13553,60 @@ var DremioEnterprise = (() => {
|
|
|
13553
13553
|
return value instanceof Date && !isNaN(value);
|
|
13554
13554
|
}
|
|
13555
13555
|
|
|
13556
|
+
// node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/timeout.js
|
|
13557
|
+
var TimeoutError = createErrorClass(function(_super) {
|
|
13558
|
+
return function TimeoutErrorImpl(info) {
|
|
13559
|
+
if (info === void 0) {
|
|
13560
|
+
info = null;
|
|
13561
|
+
}
|
|
13562
|
+
_super(this);
|
|
13563
|
+
this.message = "Timeout has occurred";
|
|
13564
|
+
this.name = "TimeoutError";
|
|
13565
|
+
this.info = info;
|
|
13566
|
+
};
|
|
13567
|
+
});
|
|
13568
|
+
function timeout(config3, schedulerArg) {
|
|
13569
|
+
var _a = isValidDate(config3) ? { first: config3 } : typeof config3 === "number" ? { each: config3 } : config3, first = _a.first, each = _a.each, _b = _a.with, _with = _b === void 0 ? timeoutErrorFactory : _b, _c = _a.scheduler, scheduler = _c === void 0 ? schedulerArg !== null && schedulerArg !== void 0 ? schedulerArg : asyncScheduler : _c, _d = _a.meta, meta = _d === void 0 ? null : _d;
|
|
13570
|
+
if (first == null && each == null) {
|
|
13571
|
+
throw new TypeError("No timeout provided.");
|
|
13572
|
+
}
|
|
13573
|
+
return operate(function(source, subscriber) {
|
|
13574
|
+
var originalSourceSubscription;
|
|
13575
|
+
var timerSubscription;
|
|
13576
|
+
var lastValue = null;
|
|
13577
|
+
var seen = 0;
|
|
13578
|
+
var startTimer = function(delay) {
|
|
13579
|
+
timerSubscription = executeSchedule(subscriber, scheduler, function() {
|
|
13580
|
+
try {
|
|
13581
|
+
originalSourceSubscription.unsubscribe();
|
|
13582
|
+
innerFrom(_with({
|
|
13583
|
+
meta,
|
|
13584
|
+
lastValue,
|
|
13585
|
+
seen
|
|
13586
|
+
})).subscribe(subscriber);
|
|
13587
|
+
} catch (err) {
|
|
13588
|
+
subscriber.error(err);
|
|
13589
|
+
}
|
|
13590
|
+
}, delay);
|
|
13591
|
+
};
|
|
13592
|
+
originalSourceSubscription = source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
|
13593
|
+
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
13594
|
+
seen++;
|
|
13595
|
+
subscriber.next(lastValue = value);
|
|
13596
|
+
each > 0 && startTimer(each);
|
|
13597
|
+
}, void 0, void 0, function() {
|
|
13598
|
+
if (!(timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.closed)) {
|
|
13599
|
+
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
13600
|
+
}
|
|
13601
|
+
lastValue = null;
|
|
13602
|
+
}));
|
|
13603
|
+
!seen && startTimer(first != null ? typeof first === "number" ? first : +first - scheduler.now() : each);
|
|
13604
|
+
});
|
|
13605
|
+
}
|
|
13606
|
+
function timeoutErrorFactory(info) {
|
|
13607
|
+
throw new TimeoutError(info);
|
|
13608
|
+
}
|
|
13609
|
+
|
|
13556
13610
|
// node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/map.js
|
|
13557
13611
|
function map(project, thisArg) {
|
|
13558
13612
|
return operate(function(source, subscriber) {
|
|
@@ -16056,6 +16110,14 @@ var DremioEnterprise = (() => {
|
|
|
16056
16110
|
var endOfStreamChunkSchema = object({
|
|
16057
16111
|
chunkType: literal("endOfStream")
|
|
16058
16112
|
});
|
|
16113
|
+
var endOfStreamInputSchema = object({
|
|
16114
|
+
chunkType: literal("endOfStream"),
|
|
16115
|
+
conversationId: string2(),
|
|
16116
|
+
createdAt: string2().check(iso_exports.datetime()),
|
|
16117
|
+
modelName: string2(),
|
|
16118
|
+
modelProviderId: string2(),
|
|
16119
|
+
runId: string2()
|
|
16120
|
+
});
|
|
16059
16121
|
var interruptChunkSchema = object({
|
|
16060
16122
|
chunkType: literal("interrupt")
|
|
16061
16123
|
});
|
|
@@ -16075,6 +16137,14 @@ var DremioEnterprise = (() => {
|
|
|
16075
16137
|
stepName: string2(),
|
|
16076
16138
|
text: string2()
|
|
16077
16139
|
});
|
|
16140
|
+
var sandboxStdoutChunkSchema = object({
|
|
16141
|
+
callId: string2().check(_trim(), _minLength(1)),
|
|
16142
|
+
chunkType: literal("sandboxStdout"),
|
|
16143
|
+
isFinal: boolean2(),
|
|
16144
|
+
text: string2()
|
|
16145
|
+
});
|
|
16146
|
+
var sandboxStdoutContentSchema = sandboxStdoutChunkSchema;
|
|
16147
|
+
var sandboxStdoutChatEventSchema = extend2(sandboxStdoutChunkSchema, chatEventSharedSchema);
|
|
16078
16148
|
var toolPlanSchema = record(string2(), unknown());
|
|
16079
16149
|
var toolRequestChunkSchema = object({
|
|
16080
16150
|
arguments: record(string2(), unknown()),
|
|
@@ -16112,12 +16182,13 @@ var DremioEnterprise = (() => {
|
|
|
16112
16182
|
]);
|
|
16113
16183
|
var chatEventInputSchema = discriminatedUnion("chunkType", [
|
|
16114
16184
|
extend2(errorChunkV2Schema, chatEventSharedSchema),
|
|
16115
|
-
|
|
16185
|
+
endOfStreamInputSchema,
|
|
16116
16186
|
extend2(interruptChunkSchema, chatEventSharedSchema),
|
|
16117
16187
|
extend2(conversationUpdateChunkSchema, chatEventSharedSchema),
|
|
16118
16188
|
extend2(jobUpdateChunkSchema, chatEventSharedSchema),
|
|
16119
16189
|
extend2(modelChunkSchema, chatEventSharedSchema),
|
|
16120
16190
|
extend2(sandboxProgressChunkSchema, chatEventSharedSchema),
|
|
16191
|
+
sandboxStdoutChatEventSchema,
|
|
16121
16192
|
extend2(toolRequestChunkSchema, chatEventSharedSchema),
|
|
16122
16193
|
extend2(toolResponseChunkSchema, chatEventSharedSchema),
|
|
16123
16194
|
extend2(userMessageChunkSchema, chatEventSharedSchema)
|
|
@@ -16126,13 +16197,14 @@ var DremioEnterprise = (() => {
|
|
|
16126
16197
|
createdAt: _instanceof(Xn.Instant),
|
|
16127
16198
|
id: string2()
|
|
16128
16199
|
});
|
|
16200
|
+
var endOfStreamOutputSchema = omit2(chatEventOutputSharedSchema, { id: true });
|
|
16129
16201
|
var chatEventOutputSchema = union([
|
|
16130
16202
|
extend2(chatEventOutputSharedSchema, {
|
|
16131
16203
|
content: conversationUpdateChunkSchema,
|
|
16132
16204
|
role: literal("agent")
|
|
16133
16205
|
}),
|
|
16134
16206
|
extend2(chatEventOutputSharedSchema, { content: errorChunkV2Schema, role: literal("agent") }),
|
|
16135
|
-
extend2(
|
|
16207
|
+
extend2(endOfStreamOutputSchema, {
|
|
16136
16208
|
content: endOfStreamChunkSchema,
|
|
16137
16209
|
role: literal("agent")
|
|
16138
16210
|
}),
|
|
@@ -16149,6 +16221,10 @@ var DremioEnterprise = (() => {
|
|
|
16149
16221
|
content: sandboxProgressChunkSchema,
|
|
16150
16222
|
role: literal("agent")
|
|
16151
16223
|
}),
|
|
16224
|
+
extend2(chatEventOutputSharedSchema, {
|
|
16225
|
+
content: sandboxStdoutContentSchema,
|
|
16226
|
+
role: literal("agent")
|
|
16227
|
+
}),
|
|
16152
16228
|
extend2(chatEventOutputSharedSchema, {
|
|
16153
16229
|
content: toolRequestChunkSchema,
|
|
16154
16230
|
role: literal("agent")
|
|
@@ -16164,6 +16240,17 @@ var DremioEnterprise = (() => {
|
|
|
16164
16240
|
]);
|
|
16165
16241
|
var chatEventCodec = codec(chatEventInputSchema, chatEventOutputSchema, {
|
|
16166
16242
|
decode(v2) {
|
|
16243
|
+
if (v2.chunkType === "endOfStream") {
|
|
16244
|
+
return {
|
|
16245
|
+
content: { chunkType: "endOfStream" },
|
|
16246
|
+
conversationId: v2.conversationId,
|
|
16247
|
+
createdAt: Xn.Instant.from(v2.createdAt),
|
|
16248
|
+
modelName: v2.modelName,
|
|
16249
|
+
modelProviderId: v2.modelProviderId,
|
|
16250
|
+
role: "agent",
|
|
16251
|
+
runId: v2.runId
|
|
16252
|
+
};
|
|
16253
|
+
}
|
|
16167
16254
|
const sharedProperties = {
|
|
16168
16255
|
conversationId: v2.conversationId,
|
|
16169
16256
|
createdAt: Xn.Instant.from(v2.createdAt),
|
|
@@ -16193,14 +16280,6 @@ var DremioEnterprise = (() => {
|
|
|
16193
16280
|
},
|
|
16194
16281
|
role: "agent"
|
|
16195
16282
|
};
|
|
16196
|
-
case "endOfStream":
|
|
16197
|
-
return {
|
|
16198
|
-
...sharedProperties,
|
|
16199
|
-
content: {
|
|
16200
|
-
chunkType: "endOfStream"
|
|
16201
|
-
},
|
|
16202
|
-
role: "agent"
|
|
16203
|
-
};
|
|
16204
16283
|
case "interrupt":
|
|
16205
16284
|
return {
|
|
16206
16285
|
...sharedProperties,
|
|
@@ -16241,6 +16320,17 @@ var DremioEnterprise = (() => {
|
|
|
16241
16320
|
},
|
|
16242
16321
|
role: "agent"
|
|
16243
16322
|
};
|
|
16323
|
+
case "sandboxStdout":
|
|
16324
|
+
return {
|
|
16325
|
+
...sharedProperties,
|
|
16326
|
+
content: {
|
|
16327
|
+
callId: v2.callId,
|
|
16328
|
+
chunkType: "sandboxStdout",
|
|
16329
|
+
isFinal: v2.isFinal,
|
|
16330
|
+
text: v2.text
|
|
16331
|
+
},
|
|
16332
|
+
role: "agent"
|
|
16333
|
+
};
|
|
16244
16334
|
case "toolRequest":
|
|
16245
16335
|
return {
|
|
16246
16336
|
...sharedProperties,
|
|
@@ -16277,10 +16367,21 @@ var DremioEnterprise = (() => {
|
|
|
16277
16367
|
}
|
|
16278
16368
|
},
|
|
16279
16369
|
encode(v2) {
|
|
16370
|
+
if (v2.content.chunkType === "endOfStream") {
|
|
16371
|
+
return {
|
|
16372
|
+
chunkType: "endOfStream",
|
|
16373
|
+
conversationId: v2.conversationId,
|
|
16374
|
+
createdAt: v2.createdAt.toString(),
|
|
16375
|
+
modelName: v2.modelName,
|
|
16376
|
+
modelProviderId: v2.modelProviderId,
|
|
16377
|
+
runId: v2.runId
|
|
16378
|
+
};
|
|
16379
|
+
}
|
|
16380
|
+
const id = v2.id;
|
|
16280
16381
|
return {
|
|
16281
16382
|
conversationId: v2.conversationId,
|
|
16282
16383
|
createdAt: v2.createdAt.toString(),
|
|
16283
|
-
messageId:
|
|
16384
|
+
messageId: id,
|
|
16284
16385
|
modelName: v2.modelName,
|
|
16285
16386
|
modelProviderId: v2.modelProviderId,
|
|
16286
16387
|
runId: v2.runId,
|
|
@@ -17952,8 +18053,10 @@ var DremioEnterprise = (() => {
|
|
|
17952
18053
|
case "error":
|
|
17953
18054
|
case "model":
|
|
17954
18055
|
case "sandboxProgress":
|
|
18056
|
+
case "sandboxStdout":
|
|
17955
18057
|
case "userMessage": {
|
|
17956
|
-
|
|
18058
|
+
const event = chatEvent;
|
|
18059
|
+
conversationExchange.messages.set(event.id, event);
|
|
17957
18060
|
break;
|
|
17958
18061
|
}
|
|
17959
18062
|
case "toolRequest":
|
|
@@ -18475,20 +18578,20 @@ var DremioEnterprise = (() => {
|
|
|
18475
18578
|
};
|
|
18476
18579
|
const scheduledEventId = createScheduledEventId(source, id);
|
|
18477
18580
|
system._snapshot._scheduledEvents[scheduledEventId] = scheduledEvent;
|
|
18478
|
-
const
|
|
18581
|
+
const timeout2 = clock.setTimeout(() => {
|
|
18479
18582
|
delete timerMap[scheduledEventId];
|
|
18480
18583
|
delete system._snapshot._scheduledEvents[scheduledEventId];
|
|
18481
18584
|
system._relay(source, target, event);
|
|
18482
18585
|
}, delay);
|
|
18483
|
-
timerMap[scheduledEventId] =
|
|
18586
|
+
timerMap[scheduledEventId] = timeout2;
|
|
18484
18587
|
},
|
|
18485
18588
|
cancel: (source, id) => {
|
|
18486
18589
|
const scheduledEventId = createScheduledEventId(source, id);
|
|
18487
|
-
const
|
|
18590
|
+
const timeout2 = timerMap[scheduledEventId];
|
|
18488
18591
|
delete timerMap[scheduledEventId];
|
|
18489
18592
|
delete system._snapshot._scheduledEvents[scheduledEventId];
|
|
18490
|
-
if (
|
|
18491
|
-
clock.clearTimeout(
|
|
18593
|
+
if (timeout2 !== void 0) {
|
|
18594
|
+
clock.clearTimeout(timeout2);
|
|
18492
18595
|
}
|
|
18493
18596
|
},
|
|
18494
18597
|
cancelAll: (actorRef) => {
|
|
@@ -21452,6 +21555,15 @@ ${err.message}`);
|
|
|
21452
21555
|
}
|
|
21453
21556
|
|
|
21454
21557
|
// dist/enterprise/ai/conversations/createConversationMachine.js
|
|
21558
|
+
var RETRIEVE_STATE_TIMEOUT_MS = 1e4;
|
|
21559
|
+
var STREAM_IDLE_TIMEOUT_MS = 6e4;
|
|
21560
|
+
var STREAM_RETRY_DELAY_MS = 2500;
|
|
21561
|
+
var MAX_STREAM_RETRIES = 5;
|
|
21562
|
+
var STREAM_STATE_RESET = {
|
|
21563
|
+
receivedEndOfStream: false,
|
|
21564
|
+
streamRetryCount: 0,
|
|
21565
|
+
userRequestedStop: false
|
|
21566
|
+
};
|
|
21455
21567
|
var createConversationMachine = (config3) => setup({
|
|
21456
21568
|
actors: {
|
|
21457
21569
|
createConversation: fromPromise2(({ input }) => createConversation(config3)(input).then((result) => {
|
|
@@ -21473,9 +21585,13 @@ ${err.message}`);
|
|
|
21473
21585
|
return result.value;
|
|
21474
21586
|
})),
|
|
21475
21587
|
retrieveState: fromPromise2(async ({ input, signal }) => {
|
|
21588
|
+
const timeoutSignal = AbortSignal.any([
|
|
21589
|
+
signal,
|
|
21590
|
+
AbortSignal.timeout(RETRIEVE_STATE_TIMEOUT_MS)
|
|
21591
|
+
]);
|
|
21476
21592
|
const [conversationResult, historyResult] = await Promise.all([
|
|
21477
|
-
retrieveConversation(config3)(input.conversationId, { signal }),
|
|
21478
|
-
retrieveConversationHistory(config3)(input.conversationId, { signal })
|
|
21593
|
+
retrieveConversation(config3)(input.conversationId, { signal: timeoutSignal }),
|
|
21594
|
+
retrieveConversationHistory(config3)(input.conversationId, { signal: timeoutSignal })
|
|
21479
21595
|
]);
|
|
21480
21596
|
if (conversationResult.isErr()) {
|
|
21481
21597
|
throw conversationResult.error;
|
|
@@ -21500,7 +21616,10 @@ ${err.message}`);
|
|
|
21500
21616
|
}
|
|
21501
21617
|
return result.value;
|
|
21502
21618
|
})),
|
|
21503
|
-
streamRun: fromObservable(({ input }) => fromTextEventStream(({ signal }) => streamRunEvents(config3)({ conversationId: input.conversationId, runId: input.runId }, { signal })).pipe(map((event) => decode(chatEventCodec, JSON.parse(event.data)))))
|
|
21619
|
+
streamRun: fromObservable(({ input }) => fromTextEventStream(({ signal }) => streamRunEvents(config3)({ conversationId: input.conversationId, runId: input.runId }, { signal })).pipe(map((event) => decode(chatEventCodec, JSON.parse(event.data))), timeout({ each: STREAM_IDLE_TIMEOUT_MS })))
|
|
21620
|
+
},
|
|
21621
|
+
delays: {
|
|
21622
|
+
STREAM_RETRY_DELAY: STREAM_RETRY_DELAY_MS
|
|
21504
21623
|
},
|
|
21505
21624
|
types: {
|
|
21506
21625
|
context: {},
|
|
@@ -21513,7 +21632,8 @@ ${err.message}`);
|
|
|
21513
21632
|
conversationId: input.conversationId,
|
|
21514
21633
|
conversationSnapshot: void 0,
|
|
21515
21634
|
currentRunId: void 0,
|
|
21516
|
-
messageAttempt: void 0
|
|
21635
|
+
messageAttempt: void 0,
|
|
21636
|
+
...STREAM_STATE_RESET
|
|
21517
21637
|
}),
|
|
21518
21638
|
id: "agentConversation",
|
|
21519
21639
|
initial: "uninitialized",
|
|
@@ -21540,7 +21660,8 @@ ${err.message}`);
|
|
|
21540
21660
|
}
|
|
21541
21661
|
],
|
|
21542
21662
|
currentRunId: ({ event }) => event.output.currentRunId,
|
|
21543
|
-
messageAttempt: void 0
|
|
21663
|
+
messageAttempt: void 0,
|
|
21664
|
+
...STREAM_STATE_RESET
|
|
21544
21665
|
}),
|
|
21545
21666
|
emit(({ event }) => ({
|
|
21546
21667
|
id: event.output.id,
|
|
@@ -21603,7 +21724,8 @@ ${err.message}`);
|
|
|
21603
21724
|
{
|
|
21604
21725
|
actions: assign({
|
|
21605
21726
|
conversationSnapshot: ({ context: context2, event }) => AgentConversation.reduceChatEvents(context2.conversationSnapshot, event.output.history.data),
|
|
21606
|
-
currentRunId: ({ event }) => event.output.conversation.currentRunId
|
|
21727
|
+
currentRunId: ({ event }) => event.output.conversation.currentRunId,
|
|
21728
|
+
receivedEndOfStream: false
|
|
21607
21729
|
}),
|
|
21608
21730
|
guard: ({ event }) => !!event.output.conversation.currentRunId,
|
|
21609
21731
|
target: "streaming"
|
|
@@ -21611,7 +21733,8 @@ ${err.message}`);
|
|
|
21611
21733
|
{
|
|
21612
21734
|
actions: assign({
|
|
21613
21735
|
conversationSnapshot: ({ context: context2, event }) => AgentConversation.reduceChatEvents(context2.conversationSnapshot, event.output.history.data),
|
|
21614
|
-
currentRunId: ({ event }) => event.output.conversation.currentRunId
|
|
21736
|
+
currentRunId: ({ event }) => event.output.conversation.currentRunId,
|
|
21737
|
+
...STREAM_STATE_RESET
|
|
21615
21738
|
}),
|
|
21616
21739
|
target: "idle"
|
|
21617
21740
|
}
|
|
@@ -21620,10 +21743,16 @@ ${err.message}`);
|
|
|
21620
21743
|
{
|
|
21621
21744
|
guard: ({ event }) => {
|
|
21622
21745
|
const e2 = event.error;
|
|
21746
|
+
if (e2?.name === "TimeoutError")
|
|
21747
|
+
return false;
|
|
21623
21748
|
return e2?.name === "AbortError" || e2?.message?.includes("aborted") || e2?.code === "ABORT_ERR";
|
|
21624
21749
|
},
|
|
21625
21750
|
target: "uninitialized"
|
|
21626
21751
|
},
|
|
21752
|
+
{
|
|
21753
|
+
guard: ({ context: context2 }) => context2.streamRetryCount > 0,
|
|
21754
|
+
target: "stream_interrupted"
|
|
21755
|
+
},
|
|
21627
21756
|
{
|
|
21628
21757
|
actions: [
|
|
21629
21758
|
assign({
|
|
@@ -21640,6 +21769,30 @@ ${err.message}`);
|
|
|
21640
21769
|
src: "retrieveState"
|
|
21641
21770
|
}
|
|
21642
21771
|
},
|
|
21772
|
+
stream_interrupted: {
|
|
21773
|
+
after: {
|
|
21774
|
+
STREAM_RETRY_DELAY: [
|
|
21775
|
+
{
|
|
21776
|
+
actions: assign({
|
|
21777
|
+
streamRetryCount: ({ context: context2 }) => context2.streamRetryCount + 1
|
|
21778
|
+
}),
|
|
21779
|
+
guard: ({ context: context2 }) => context2.streamRetryCount < MAX_STREAM_RETRIES,
|
|
21780
|
+
target: "retrieving_history"
|
|
21781
|
+
},
|
|
21782
|
+
{
|
|
21783
|
+
target: "stream_recovery_failed"
|
|
21784
|
+
}
|
|
21785
|
+
]
|
|
21786
|
+
}
|
|
21787
|
+
},
|
|
21788
|
+
stream_recovery_failed: {
|
|
21789
|
+
on: {
|
|
21790
|
+
REFRESH_HISTORY: {
|
|
21791
|
+
actions: assign({ lastError: void 0, streamRetryCount: 0 }),
|
|
21792
|
+
target: "retrieving_history"
|
|
21793
|
+
}
|
|
21794
|
+
}
|
|
21795
|
+
},
|
|
21643
21796
|
streaming: {
|
|
21644
21797
|
description: "Manages monitoring and canceling the current run",
|
|
21645
21798
|
initial: "monitoring_replies",
|
|
@@ -21653,20 +21806,37 @@ ${err.message}`);
|
|
|
21653
21806
|
runId: context2.currentRunId
|
|
21654
21807
|
};
|
|
21655
21808
|
},
|
|
21656
|
-
onDone:
|
|
21657
|
-
|
|
21658
|
-
|
|
21659
|
-
|
|
21660
|
-
|
|
21661
|
-
|
|
21662
|
-
|
|
21663
|
-
|
|
21809
|
+
onDone: [
|
|
21810
|
+
{
|
|
21811
|
+
actions: assign({ currentRunId: null, userRequestedStop: false }),
|
|
21812
|
+
guard: ({ context: context2 }) => !!context2.receivedEndOfStream || !!context2.userRequestedStop,
|
|
21813
|
+
target: "idle"
|
|
21814
|
+
},
|
|
21815
|
+
{
|
|
21816
|
+
actions: assign({ currentRunId: null }),
|
|
21817
|
+
target: "stream_interrupted"
|
|
21818
|
+
}
|
|
21819
|
+
],
|
|
21820
|
+
onError: [
|
|
21821
|
+
{
|
|
21822
|
+
actions: assign({ currentRunId: null, userRequestedStop: false }),
|
|
21823
|
+
guard: ({ context: context2 }) => !!context2.receivedEndOfStream || !!context2.userRequestedStop,
|
|
21824
|
+
target: "idle"
|
|
21825
|
+
},
|
|
21826
|
+
{
|
|
21827
|
+
actions: assign({ currentRunId: null }),
|
|
21828
|
+
target: "stream_interrupted"
|
|
21829
|
+
}
|
|
21830
|
+
],
|
|
21664
21831
|
onSnapshot: {
|
|
21665
21832
|
actions: enqueueActions(({ context: context2, enqueue, event }) => {
|
|
21666
21833
|
const chatEvent = event.snapshot.context;
|
|
21667
21834
|
if (!chatEvent) {
|
|
21668
21835
|
return;
|
|
21669
21836
|
}
|
|
21837
|
+
if (chatEvent.content.chunkType === "endOfStream" && !context2.receivedEndOfStream) {
|
|
21838
|
+
enqueue.assign({ receivedEndOfStream: true });
|
|
21839
|
+
}
|
|
21670
21840
|
const nextSnapshot = AgentConversation.reduceChatEvents(context2.conversationSnapshot, [chatEvent]);
|
|
21671
21841
|
enqueue.assign({
|
|
21672
21842
|
conversationSnapshot: nextSnapshot
|
|
@@ -21684,6 +21854,7 @@ ${err.message}`);
|
|
|
21684
21854
|
description: "Attached to the run event stream",
|
|
21685
21855
|
on: {
|
|
21686
21856
|
STOP_RUN: {
|
|
21857
|
+
actions: assign({ userRequestedStop: true }),
|
|
21687
21858
|
target: "stopping"
|
|
21688
21859
|
}
|
|
21689
21860
|
}
|
|
@@ -21696,10 +21867,11 @@ ${err.message}`);
|
|
|
21696
21867
|
runId: context2.currentRunId
|
|
21697
21868
|
}),
|
|
21698
21869
|
onDone: {
|
|
21699
|
-
actions: assign({ currentRunId: void 0 }),
|
|
21870
|
+
actions: assign({ currentRunId: void 0, userRequestedStop: false }),
|
|
21700
21871
|
target: "#agentConversation.idle"
|
|
21701
21872
|
},
|
|
21702
21873
|
onError: {
|
|
21874
|
+
actions: assign({ userRequestedStop: false }),
|
|
21703
21875
|
target: "#agentConversation.retrieving_history"
|
|
21704
21876
|
},
|
|
21705
21877
|
src: "stopRun"
|
|
@@ -21741,7 +21913,8 @@ ${err.message}`);
|
|
|
21741
21913
|
}
|
|
21742
21914
|
],
|
|
21743
21915
|
currentRunId: ({ event }) => event.output.currentRunId,
|
|
21744
|
-
messageAttempt: void 0
|
|
21916
|
+
messageAttempt: void 0,
|
|
21917
|
+
...STREAM_STATE_RESET
|
|
21745
21918
|
}),
|
|
21746
21919
|
target: "streaming"
|
|
21747
21920
|
},
|