@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/cloud.js
CHANGED
|
@@ -13124,16 +13124,16 @@ var DremioCloud = (() => {
|
|
|
13124
13124
|
|
|
13125
13125
|
// node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js
|
|
13126
13126
|
var timeoutProvider = {
|
|
13127
|
-
setTimeout: function(handler,
|
|
13127
|
+
setTimeout: function(handler, timeout2) {
|
|
13128
13128
|
var args = [];
|
|
13129
13129
|
for (var _i2 = 2; _i2 < arguments.length; _i2++) {
|
|
13130
13130
|
args[_i2 - 2] = arguments[_i2];
|
|
13131
13131
|
}
|
|
13132
13132
|
var delegate = timeoutProvider.delegate;
|
|
13133
13133
|
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
13134
|
-
return delegate.setTimeout.apply(delegate, __spreadArray2([handler,
|
|
13134
|
+
return delegate.setTimeout.apply(delegate, __spreadArray2([handler, timeout2], __read(args)));
|
|
13135
13135
|
}
|
|
13136
|
-
return setTimeout.apply(void 0, __spreadArray2([handler,
|
|
13136
|
+
return setTimeout.apply(void 0, __spreadArray2([handler, timeout2], __read(args)));
|
|
13137
13137
|
},
|
|
13138
13138
|
clearTimeout: function(handle) {
|
|
13139
13139
|
var delegate = timeoutProvider.delegate;
|
|
@@ -13802,16 +13802,16 @@ var DremioCloud = (() => {
|
|
|
13802
13802
|
|
|
13803
13803
|
// node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js
|
|
13804
13804
|
var intervalProvider = {
|
|
13805
|
-
setInterval: function(handler,
|
|
13805
|
+
setInterval: function(handler, timeout2) {
|
|
13806
13806
|
var args = [];
|
|
13807
13807
|
for (var _i2 = 2; _i2 < arguments.length; _i2++) {
|
|
13808
13808
|
args[_i2 - 2] = arguments[_i2];
|
|
13809
13809
|
}
|
|
13810
13810
|
var delegate = intervalProvider.delegate;
|
|
13811
13811
|
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
13812
|
-
return delegate.setInterval.apply(delegate, __spreadArray2([handler,
|
|
13812
|
+
return delegate.setInterval.apply(delegate, __spreadArray2([handler, timeout2], __read(args)));
|
|
13813
13813
|
}
|
|
13814
|
-
return setInterval.apply(void 0, __spreadArray2([handler,
|
|
13814
|
+
return setInterval.apply(void 0, __spreadArray2([handler, timeout2], __read(args)));
|
|
13815
13815
|
},
|
|
13816
13816
|
clearInterval: function(handle) {
|
|
13817
13817
|
var delegate = intervalProvider.delegate;
|
|
@@ -14426,6 +14426,60 @@ var DremioCloud = (() => {
|
|
|
14426
14426
|
return value instanceof Date && !isNaN(value);
|
|
14427
14427
|
}
|
|
14428
14428
|
|
|
14429
|
+
// node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/timeout.js
|
|
14430
|
+
var TimeoutError = createErrorClass(function(_super) {
|
|
14431
|
+
return function TimeoutErrorImpl(info) {
|
|
14432
|
+
if (info === void 0) {
|
|
14433
|
+
info = null;
|
|
14434
|
+
}
|
|
14435
|
+
_super(this);
|
|
14436
|
+
this.message = "Timeout has occurred";
|
|
14437
|
+
this.name = "TimeoutError";
|
|
14438
|
+
this.info = info;
|
|
14439
|
+
};
|
|
14440
|
+
});
|
|
14441
|
+
function timeout(config3, schedulerArg) {
|
|
14442
|
+
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;
|
|
14443
|
+
if (first == null && each == null) {
|
|
14444
|
+
throw new TypeError("No timeout provided.");
|
|
14445
|
+
}
|
|
14446
|
+
return operate(function(source, subscriber) {
|
|
14447
|
+
var originalSourceSubscription;
|
|
14448
|
+
var timerSubscription;
|
|
14449
|
+
var lastValue = null;
|
|
14450
|
+
var seen = 0;
|
|
14451
|
+
var startTimer = function(delay) {
|
|
14452
|
+
timerSubscription = executeSchedule(subscriber, scheduler, function() {
|
|
14453
|
+
try {
|
|
14454
|
+
originalSourceSubscription.unsubscribe();
|
|
14455
|
+
innerFrom(_with({
|
|
14456
|
+
meta,
|
|
14457
|
+
lastValue,
|
|
14458
|
+
seen
|
|
14459
|
+
})).subscribe(subscriber);
|
|
14460
|
+
} catch (err) {
|
|
14461
|
+
subscriber.error(err);
|
|
14462
|
+
}
|
|
14463
|
+
}, delay);
|
|
14464
|
+
};
|
|
14465
|
+
originalSourceSubscription = source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
|
14466
|
+
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
14467
|
+
seen++;
|
|
14468
|
+
subscriber.next(lastValue = value);
|
|
14469
|
+
each > 0 && startTimer(each);
|
|
14470
|
+
}, void 0, void 0, function() {
|
|
14471
|
+
if (!(timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.closed)) {
|
|
14472
|
+
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
14473
|
+
}
|
|
14474
|
+
lastValue = null;
|
|
14475
|
+
}));
|
|
14476
|
+
!seen && startTimer(first != null ? typeof first === "number" ? first : +first - scheduler.now() : each);
|
|
14477
|
+
});
|
|
14478
|
+
}
|
|
14479
|
+
function timeoutErrorFactory(info) {
|
|
14480
|
+
throw new TimeoutError(info);
|
|
14481
|
+
}
|
|
14482
|
+
|
|
14429
14483
|
// node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/map.js
|
|
14430
14484
|
function map(project, thisArg) {
|
|
14431
14485
|
return operate(function(source, subscriber) {
|
|
@@ -14927,6 +14981,12 @@ var DremioCloud = (() => {
|
|
|
14927
14981
|
clientSecret: string2(),
|
|
14928
14982
|
tenantId: string2(),
|
|
14929
14983
|
type: literal("AZURE_STORAGE_CLIENT_CREDENTIALS")
|
|
14984
|
+
}),
|
|
14985
|
+
object({
|
|
14986
|
+
clientId: string2(),
|
|
14987
|
+
storageAccountName: string2(),
|
|
14988
|
+
tenantId: string2(),
|
|
14989
|
+
type: literal("AZURE_WORKLOAD_IDENTITY")
|
|
14930
14990
|
})
|
|
14931
14991
|
])),
|
|
14932
14992
|
id: string2(),
|
|
@@ -17131,6 +17191,14 @@ var DremioCloud = (() => {
|
|
|
17131
17191
|
var endOfStreamChunkSchema = object({
|
|
17132
17192
|
chunkType: literal("endOfStream")
|
|
17133
17193
|
});
|
|
17194
|
+
var endOfStreamInputSchema = object({
|
|
17195
|
+
chunkType: literal("endOfStream"),
|
|
17196
|
+
conversationId: string2(),
|
|
17197
|
+
createdAt: string2().check(iso_exports.datetime()),
|
|
17198
|
+
modelName: string2(),
|
|
17199
|
+
modelProviderId: string2(),
|
|
17200
|
+
runId: string2()
|
|
17201
|
+
});
|
|
17134
17202
|
var interruptChunkSchema = object({
|
|
17135
17203
|
chunkType: literal("interrupt")
|
|
17136
17204
|
});
|
|
@@ -17150,6 +17218,14 @@ var DremioCloud = (() => {
|
|
|
17150
17218
|
stepName: string2(),
|
|
17151
17219
|
text: string2()
|
|
17152
17220
|
});
|
|
17221
|
+
var sandboxStdoutChunkSchema = object({
|
|
17222
|
+
callId: string2().check(_trim(), _minLength(1)),
|
|
17223
|
+
chunkType: literal("sandboxStdout"),
|
|
17224
|
+
isFinal: boolean2(),
|
|
17225
|
+
text: string2()
|
|
17226
|
+
});
|
|
17227
|
+
var sandboxStdoutContentSchema = sandboxStdoutChunkSchema;
|
|
17228
|
+
var sandboxStdoutChatEventSchema = extend2(sandboxStdoutChunkSchema, chatEventSharedSchema);
|
|
17153
17229
|
var toolPlanSchema = record(string2(), unknown());
|
|
17154
17230
|
var toolRequestChunkSchema = object({
|
|
17155
17231
|
arguments: record(string2(), unknown()),
|
|
@@ -17187,12 +17263,13 @@ var DremioCloud = (() => {
|
|
|
17187
17263
|
]);
|
|
17188
17264
|
var chatEventInputSchema = discriminatedUnion("chunkType", [
|
|
17189
17265
|
extend2(errorChunkV2Schema, chatEventSharedSchema),
|
|
17190
|
-
|
|
17266
|
+
endOfStreamInputSchema,
|
|
17191
17267
|
extend2(interruptChunkSchema, chatEventSharedSchema),
|
|
17192
17268
|
extend2(conversationUpdateChunkSchema, chatEventSharedSchema),
|
|
17193
17269
|
extend2(jobUpdateChunkSchema, chatEventSharedSchema),
|
|
17194
17270
|
extend2(modelChunkSchema, chatEventSharedSchema),
|
|
17195
17271
|
extend2(sandboxProgressChunkSchema, chatEventSharedSchema),
|
|
17272
|
+
sandboxStdoutChatEventSchema,
|
|
17196
17273
|
extend2(toolRequestChunkSchema, chatEventSharedSchema),
|
|
17197
17274
|
extend2(toolResponseChunkSchema, chatEventSharedSchema),
|
|
17198
17275
|
extend2(userMessageChunkSchema, chatEventSharedSchema)
|
|
@@ -17201,13 +17278,14 @@ var DremioCloud = (() => {
|
|
|
17201
17278
|
createdAt: _instanceof(Xn.Instant),
|
|
17202
17279
|
id: string2()
|
|
17203
17280
|
});
|
|
17281
|
+
var endOfStreamOutputSchema = omit2(chatEventOutputSharedSchema, { id: true });
|
|
17204
17282
|
var chatEventOutputSchema = union([
|
|
17205
17283
|
extend2(chatEventOutputSharedSchema, {
|
|
17206
17284
|
content: conversationUpdateChunkSchema,
|
|
17207
17285
|
role: literal("agent")
|
|
17208
17286
|
}),
|
|
17209
17287
|
extend2(chatEventOutputSharedSchema, { content: errorChunkV2Schema, role: literal("agent") }),
|
|
17210
|
-
extend2(
|
|
17288
|
+
extend2(endOfStreamOutputSchema, {
|
|
17211
17289
|
content: endOfStreamChunkSchema,
|
|
17212
17290
|
role: literal("agent")
|
|
17213
17291
|
}),
|
|
@@ -17224,6 +17302,10 @@ var DremioCloud = (() => {
|
|
|
17224
17302
|
content: sandboxProgressChunkSchema,
|
|
17225
17303
|
role: literal("agent")
|
|
17226
17304
|
}),
|
|
17305
|
+
extend2(chatEventOutputSharedSchema, {
|
|
17306
|
+
content: sandboxStdoutContentSchema,
|
|
17307
|
+
role: literal("agent")
|
|
17308
|
+
}),
|
|
17227
17309
|
extend2(chatEventOutputSharedSchema, {
|
|
17228
17310
|
content: toolRequestChunkSchema,
|
|
17229
17311
|
role: literal("agent")
|
|
@@ -17239,6 +17321,17 @@ var DremioCloud = (() => {
|
|
|
17239
17321
|
]);
|
|
17240
17322
|
var chatEventCodec = codec(chatEventInputSchema, chatEventOutputSchema, {
|
|
17241
17323
|
decode(v2) {
|
|
17324
|
+
if (v2.chunkType === "endOfStream") {
|
|
17325
|
+
return {
|
|
17326
|
+
content: { chunkType: "endOfStream" },
|
|
17327
|
+
conversationId: v2.conversationId,
|
|
17328
|
+
createdAt: Xn.Instant.from(v2.createdAt),
|
|
17329
|
+
modelName: v2.modelName,
|
|
17330
|
+
modelProviderId: v2.modelProviderId,
|
|
17331
|
+
role: "agent",
|
|
17332
|
+
runId: v2.runId
|
|
17333
|
+
};
|
|
17334
|
+
}
|
|
17242
17335
|
const sharedProperties = {
|
|
17243
17336
|
conversationId: v2.conversationId,
|
|
17244
17337
|
createdAt: Xn.Instant.from(v2.createdAt),
|
|
@@ -17268,14 +17361,6 @@ var DremioCloud = (() => {
|
|
|
17268
17361
|
},
|
|
17269
17362
|
role: "agent"
|
|
17270
17363
|
};
|
|
17271
|
-
case "endOfStream":
|
|
17272
|
-
return {
|
|
17273
|
-
...sharedProperties,
|
|
17274
|
-
content: {
|
|
17275
|
-
chunkType: "endOfStream"
|
|
17276
|
-
},
|
|
17277
|
-
role: "agent"
|
|
17278
|
-
};
|
|
17279
17364
|
case "interrupt":
|
|
17280
17365
|
return {
|
|
17281
17366
|
...sharedProperties,
|
|
@@ -17316,6 +17401,17 @@ var DremioCloud = (() => {
|
|
|
17316
17401
|
},
|
|
17317
17402
|
role: "agent"
|
|
17318
17403
|
};
|
|
17404
|
+
case "sandboxStdout":
|
|
17405
|
+
return {
|
|
17406
|
+
...sharedProperties,
|
|
17407
|
+
content: {
|
|
17408
|
+
callId: v2.callId,
|
|
17409
|
+
chunkType: "sandboxStdout",
|
|
17410
|
+
isFinal: v2.isFinal,
|
|
17411
|
+
text: v2.text
|
|
17412
|
+
},
|
|
17413
|
+
role: "agent"
|
|
17414
|
+
};
|
|
17319
17415
|
case "toolRequest":
|
|
17320
17416
|
return {
|
|
17321
17417
|
...sharedProperties,
|
|
@@ -17352,10 +17448,21 @@ var DremioCloud = (() => {
|
|
|
17352
17448
|
}
|
|
17353
17449
|
},
|
|
17354
17450
|
encode(v2) {
|
|
17451
|
+
if (v2.content.chunkType === "endOfStream") {
|
|
17452
|
+
return {
|
|
17453
|
+
chunkType: "endOfStream",
|
|
17454
|
+
conversationId: v2.conversationId,
|
|
17455
|
+
createdAt: v2.createdAt.toString(),
|
|
17456
|
+
modelName: v2.modelName,
|
|
17457
|
+
modelProviderId: v2.modelProviderId,
|
|
17458
|
+
runId: v2.runId
|
|
17459
|
+
};
|
|
17460
|
+
}
|
|
17461
|
+
const id = v2.id;
|
|
17355
17462
|
return {
|
|
17356
17463
|
conversationId: v2.conversationId,
|
|
17357
17464
|
createdAt: v2.createdAt.toString(),
|
|
17358
|
-
messageId:
|
|
17465
|
+
messageId: id,
|
|
17359
17466
|
modelName: v2.modelName,
|
|
17360
17467
|
modelProviderId: v2.modelProviderId,
|
|
17361
17468
|
runId: v2.runId,
|
|
@@ -19376,8 +19483,10 @@ var DremioCloud = (() => {
|
|
|
19376
19483
|
case "error":
|
|
19377
19484
|
case "model":
|
|
19378
19485
|
case "sandboxProgress":
|
|
19486
|
+
case "sandboxStdout":
|
|
19379
19487
|
case "userMessage": {
|
|
19380
|
-
|
|
19488
|
+
const event = chatEvent;
|
|
19489
|
+
conversationExchange.messages.set(event.id, event);
|
|
19381
19490
|
break;
|
|
19382
19491
|
}
|
|
19383
19492
|
case "toolRequest":
|
|
@@ -19899,20 +20008,20 @@ var DremioCloud = (() => {
|
|
|
19899
20008
|
};
|
|
19900
20009
|
const scheduledEventId = createScheduledEventId(source, id);
|
|
19901
20010
|
system._snapshot._scheduledEvents[scheduledEventId] = scheduledEvent;
|
|
19902
|
-
const
|
|
20011
|
+
const timeout2 = clock.setTimeout(() => {
|
|
19903
20012
|
delete timerMap[scheduledEventId];
|
|
19904
20013
|
delete system._snapshot._scheduledEvents[scheduledEventId];
|
|
19905
20014
|
system._relay(source, target, event);
|
|
19906
20015
|
}, delay);
|
|
19907
|
-
timerMap[scheduledEventId] =
|
|
20016
|
+
timerMap[scheduledEventId] = timeout2;
|
|
19908
20017
|
},
|
|
19909
20018
|
cancel: (source, id) => {
|
|
19910
20019
|
const scheduledEventId = createScheduledEventId(source, id);
|
|
19911
|
-
const
|
|
20020
|
+
const timeout2 = timerMap[scheduledEventId];
|
|
19912
20021
|
delete timerMap[scheduledEventId];
|
|
19913
20022
|
delete system._snapshot._scheduledEvents[scheduledEventId];
|
|
19914
|
-
if (
|
|
19915
|
-
clock.clearTimeout(
|
|
20023
|
+
if (timeout2 !== void 0) {
|
|
20024
|
+
clock.clearTimeout(timeout2);
|
|
19916
20025
|
}
|
|
19917
20026
|
},
|
|
19918
20027
|
cancelAll: (actorRef) => {
|
|
@@ -22876,6 +22985,15 @@ ${err.message}`);
|
|
|
22876
22985
|
}
|
|
22877
22986
|
|
|
22878
22987
|
// dist/enterprise/ai/conversations/createConversationMachine.js
|
|
22988
|
+
var RETRIEVE_STATE_TIMEOUT_MS = 1e4;
|
|
22989
|
+
var STREAM_IDLE_TIMEOUT_MS = 6e4;
|
|
22990
|
+
var STREAM_RETRY_DELAY_MS = 2500;
|
|
22991
|
+
var MAX_STREAM_RETRIES = 5;
|
|
22992
|
+
var STREAM_STATE_RESET = {
|
|
22993
|
+
receivedEndOfStream: false,
|
|
22994
|
+
streamRetryCount: 0,
|
|
22995
|
+
userRequestedStop: false
|
|
22996
|
+
};
|
|
22879
22997
|
var createConversationMachine = (config3) => setup({
|
|
22880
22998
|
actors: {
|
|
22881
22999
|
createConversation: fromPromise2(({ input }) => createConversation(config3)(input).then((result) => {
|
|
@@ -22897,9 +23015,13 @@ ${err.message}`);
|
|
|
22897
23015
|
return result.value;
|
|
22898
23016
|
})),
|
|
22899
23017
|
retrieveState: fromPromise2(async ({ input, signal }) => {
|
|
23018
|
+
const timeoutSignal = AbortSignal.any([
|
|
23019
|
+
signal,
|
|
23020
|
+
AbortSignal.timeout(RETRIEVE_STATE_TIMEOUT_MS)
|
|
23021
|
+
]);
|
|
22900
23022
|
const [conversationResult, historyResult] = await Promise.all([
|
|
22901
|
-
retrieveConversation(config3)(input.conversationId, { signal }),
|
|
22902
|
-
retrieveConversationHistory(config3)(input.conversationId, { signal })
|
|
23023
|
+
retrieveConversation(config3)(input.conversationId, { signal: timeoutSignal }),
|
|
23024
|
+
retrieveConversationHistory(config3)(input.conversationId, { signal: timeoutSignal })
|
|
22903
23025
|
]);
|
|
22904
23026
|
if (conversationResult.isErr()) {
|
|
22905
23027
|
throw conversationResult.error;
|
|
@@ -22924,7 +23046,10 @@ ${err.message}`);
|
|
|
22924
23046
|
}
|
|
22925
23047
|
return result.value;
|
|
22926
23048
|
})),
|
|
22927
|
-
streamRun: fromObservable(({ input }) => fromTextEventStream(({ signal }) => streamRunEvents(config3)({ conversationId: input.conversationId, runId: input.runId }, { signal })).pipe(map((event) => decode(chatEventCodec, JSON.parse(event.data)))))
|
|
23049
|
+
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 })))
|
|
23050
|
+
},
|
|
23051
|
+
delays: {
|
|
23052
|
+
STREAM_RETRY_DELAY: STREAM_RETRY_DELAY_MS
|
|
22928
23053
|
},
|
|
22929
23054
|
types: {
|
|
22930
23055
|
context: {},
|
|
@@ -22937,7 +23062,8 @@ ${err.message}`);
|
|
|
22937
23062
|
conversationId: input.conversationId,
|
|
22938
23063
|
conversationSnapshot: void 0,
|
|
22939
23064
|
currentRunId: void 0,
|
|
22940
|
-
messageAttempt: void 0
|
|
23065
|
+
messageAttempt: void 0,
|
|
23066
|
+
...STREAM_STATE_RESET
|
|
22941
23067
|
}),
|
|
22942
23068
|
id: "agentConversation",
|
|
22943
23069
|
initial: "uninitialized",
|
|
@@ -22964,7 +23090,8 @@ ${err.message}`);
|
|
|
22964
23090
|
}
|
|
22965
23091
|
],
|
|
22966
23092
|
currentRunId: ({ event }) => event.output.currentRunId,
|
|
22967
|
-
messageAttempt: void 0
|
|
23093
|
+
messageAttempt: void 0,
|
|
23094
|
+
...STREAM_STATE_RESET
|
|
22968
23095
|
}),
|
|
22969
23096
|
emit(({ event }) => ({
|
|
22970
23097
|
id: event.output.id,
|
|
@@ -23027,7 +23154,8 @@ ${err.message}`);
|
|
|
23027
23154
|
{
|
|
23028
23155
|
actions: assign({
|
|
23029
23156
|
conversationSnapshot: ({ context: context2, event }) => AgentConversation.reduceChatEvents(context2.conversationSnapshot, event.output.history.data),
|
|
23030
|
-
currentRunId: ({ event }) => event.output.conversation.currentRunId
|
|
23157
|
+
currentRunId: ({ event }) => event.output.conversation.currentRunId,
|
|
23158
|
+
receivedEndOfStream: false
|
|
23031
23159
|
}),
|
|
23032
23160
|
guard: ({ event }) => !!event.output.conversation.currentRunId,
|
|
23033
23161
|
target: "streaming"
|
|
@@ -23035,7 +23163,8 @@ ${err.message}`);
|
|
|
23035
23163
|
{
|
|
23036
23164
|
actions: assign({
|
|
23037
23165
|
conversationSnapshot: ({ context: context2, event }) => AgentConversation.reduceChatEvents(context2.conversationSnapshot, event.output.history.data),
|
|
23038
|
-
currentRunId: ({ event }) => event.output.conversation.currentRunId
|
|
23166
|
+
currentRunId: ({ event }) => event.output.conversation.currentRunId,
|
|
23167
|
+
...STREAM_STATE_RESET
|
|
23039
23168
|
}),
|
|
23040
23169
|
target: "idle"
|
|
23041
23170
|
}
|
|
@@ -23044,10 +23173,16 @@ ${err.message}`);
|
|
|
23044
23173
|
{
|
|
23045
23174
|
guard: ({ event }) => {
|
|
23046
23175
|
const e2 = event.error;
|
|
23176
|
+
if (e2?.name === "TimeoutError")
|
|
23177
|
+
return false;
|
|
23047
23178
|
return e2?.name === "AbortError" || e2?.message?.includes("aborted") || e2?.code === "ABORT_ERR";
|
|
23048
23179
|
},
|
|
23049
23180
|
target: "uninitialized"
|
|
23050
23181
|
},
|
|
23182
|
+
{
|
|
23183
|
+
guard: ({ context: context2 }) => context2.streamRetryCount > 0,
|
|
23184
|
+
target: "stream_interrupted"
|
|
23185
|
+
},
|
|
23051
23186
|
{
|
|
23052
23187
|
actions: [
|
|
23053
23188
|
assign({
|
|
@@ -23064,6 +23199,30 @@ ${err.message}`);
|
|
|
23064
23199
|
src: "retrieveState"
|
|
23065
23200
|
}
|
|
23066
23201
|
},
|
|
23202
|
+
stream_interrupted: {
|
|
23203
|
+
after: {
|
|
23204
|
+
STREAM_RETRY_DELAY: [
|
|
23205
|
+
{
|
|
23206
|
+
actions: assign({
|
|
23207
|
+
streamRetryCount: ({ context: context2 }) => context2.streamRetryCount + 1
|
|
23208
|
+
}),
|
|
23209
|
+
guard: ({ context: context2 }) => context2.streamRetryCount < MAX_STREAM_RETRIES,
|
|
23210
|
+
target: "retrieving_history"
|
|
23211
|
+
},
|
|
23212
|
+
{
|
|
23213
|
+
target: "stream_recovery_failed"
|
|
23214
|
+
}
|
|
23215
|
+
]
|
|
23216
|
+
}
|
|
23217
|
+
},
|
|
23218
|
+
stream_recovery_failed: {
|
|
23219
|
+
on: {
|
|
23220
|
+
REFRESH_HISTORY: {
|
|
23221
|
+
actions: assign({ lastError: void 0, streamRetryCount: 0 }),
|
|
23222
|
+
target: "retrieving_history"
|
|
23223
|
+
}
|
|
23224
|
+
}
|
|
23225
|
+
},
|
|
23067
23226
|
streaming: {
|
|
23068
23227
|
description: "Manages monitoring and canceling the current run",
|
|
23069
23228
|
initial: "monitoring_replies",
|
|
@@ -23077,20 +23236,37 @@ ${err.message}`);
|
|
|
23077
23236
|
runId: context2.currentRunId
|
|
23078
23237
|
};
|
|
23079
23238
|
},
|
|
23080
|
-
onDone:
|
|
23081
|
-
|
|
23082
|
-
|
|
23083
|
-
|
|
23084
|
-
|
|
23085
|
-
|
|
23086
|
-
|
|
23087
|
-
|
|
23239
|
+
onDone: [
|
|
23240
|
+
{
|
|
23241
|
+
actions: assign({ currentRunId: null, userRequestedStop: false }),
|
|
23242
|
+
guard: ({ context: context2 }) => !!context2.receivedEndOfStream || !!context2.userRequestedStop,
|
|
23243
|
+
target: "idle"
|
|
23244
|
+
},
|
|
23245
|
+
{
|
|
23246
|
+
actions: assign({ currentRunId: null }),
|
|
23247
|
+
target: "stream_interrupted"
|
|
23248
|
+
}
|
|
23249
|
+
],
|
|
23250
|
+
onError: [
|
|
23251
|
+
{
|
|
23252
|
+
actions: assign({ currentRunId: null, userRequestedStop: false }),
|
|
23253
|
+
guard: ({ context: context2 }) => !!context2.receivedEndOfStream || !!context2.userRequestedStop,
|
|
23254
|
+
target: "idle"
|
|
23255
|
+
},
|
|
23256
|
+
{
|
|
23257
|
+
actions: assign({ currentRunId: null }),
|
|
23258
|
+
target: "stream_interrupted"
|
|
23259
|
+
}
|
|
23260
|
+
],
|
|
23088
23261
|
onSnapshot: {
|
|
23089
23262
|
actions: enqueueActions(({ context: context2, enqueue, event }) => {
|
|
23090
23263
|
const chatEvent = event.snapshot.context;
|
|
23091
23264
|
if (!chatEvent) {
|
|
23092
23265
|
return;
|
|
23093
23266
|
}
|
|
23267
|
+
if (chatEvent.content.chunkType === "endOfStream" && !context2.receivedEndOfStream) {
|
|
23268
|
+
enqueue.assign({ receivedEndOfStream: true });
|
|
23269
|
+
}
|
|
23094
23270
|
const nextSnapshot = AgentConversation.reduceChatEvents(context2.conversationSnapshot, [chatEvent]);
|
|
23095
23271
|
enqueue.assign({
|
|
23096
23272
|
conversationSnapshot: nextSnapshot
|
|
@@ -23108,6 +23284,7 @@ ${err.message}`);
|
|
|
23108
23284
|
description: "Attached to the run event stream",
|
|
23109
23285
|
on: {
|
|
23110
23286
|
STOP_RUN: {
|
|
23287
|
+
actions: assign({ userRequestedStop: true }),
|
|
23111
23288
|
target: "stopping"
|
|
23112
23289
|
}
|
|
23113
23290
|
}
|
|
@@ -23120,10 +23297,11 @@ ${err.message}`);
|
|
|
23120
23297
|
runId: context2.currentRunId
|
|
23121
23298
|
}),
|
|
23122
23299
|
onDone: {
|
|
23123
|
-
actions: assign({ currentRunId: void 0 }),
|
|
23300
|
+
actions: assign({ currentRunId: void 0, userRequestedStop: false }),
|
|
23124
23301
|
target: "#agentConversation.idle"
|
|
23125
23302
|
},
|
|
23126
23303
|
onError: {
|
|
23304
|
+
actions: assign({ userRequestedStop: false }),
|
|
23127
23305
|
target: "#agentConversation.retrieving_history"
|
|
23128
23306
|
},
|
|
23129
23307
|
src: "stopRun"
|
|
@@ -23165,7 +23343,8 @@ ${err.message}`);
|
|
|
23165
23343
|
}
|
|
23166
23344
|
],
|
|
23167
23345
|
currentRunId: ({ event }) => event.output.currentRunId,
|
|
23168
|
-
messageAttempt: void 0
|
|
23346
|
+
messageAttempt: void 0,
|
|
23347
|
+
...STREAM_STATE_RESET
|
|
23169
23348
|
}),
|
|
23170
23349
|
target: "streaming"
|
|
23171
23350
|
},
|