@botpress/runtime 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_types/actions.d.ts +1 -1
- package/dist/_types/actions.d.ts.map +1 -1
- package/dist/_types/channels.d.ts +1 -1
- package/dist/_types/channels.d.ts.map +1 -1
- package/dist/_types/conversations.d.ts +3 -3
- package/dist/_types/conversations.d.ts.map +1 -1
- package/dist/_types/events.d.ts +1 -1
- package/dist/_types/events.d.ts.map +1 -1
- package/dist/_types/integration-actions.d.ts +1 -1
- package/dist/_types/integration-actions.d.ts.map +1 -1
- package/dist/_types/integrations.d.ts +1 -1
- package/dist/_types/integrations.d.ts.map +1 -1
- package/dist/_types/state.d.ts +1 -1
- package/dist/_types/state.d.ts.map +1 -1
- package/dist/_types/tables.d.ts +1 -1
- package/dist/_types/tables.d.ts.map +1 -1
- package/dist/_types/triggers.d.ts +1 -1
- package/dist/_types/triggers.d.ts.map +1 -1
- package/dist/_types/workflows.d.ts +4 -4
- package/dist/_types/workflows.d.ts.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/consts.d.ts.map +1 -1
- package/dist/debugging/node-inspector.d.ts +1 -1
- package/dist/debugging/node-inspector.d.ts.map +1 -1
- package/dist/define-config.d.ts +3 -3
- package/dist/define-config.d.ts.map +1 -1
- package/dist/definition.d.ts +4 -4
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +144 -494
- package/dist/definition.js.map +2 -2
- package/dist/environment.d.ts +17 -17
- package/dist/environment.d.ts.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/globals.d.ts.map +1 -1
- package/dist/internal.d.ts +9 -9
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +163 -549
- package/dist/internal.js.map +2 -2
- package/dist/library.d.ts +18 -18
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +148 -506
- package/dist/library.js.map +2 -2
- package/dist/primitives/action.d.ts +7 -7
- package/dist/primitives/action.d.ts.map +1 -1
- package/dist/primitives/asset.d.ts.map +1 -1
- package/dist/primitives/conversation-instance.d.ts +6 -6
- package/dist/primitives/conversation-instance.d.ts.map +1 -1
- package/dist/primitives/conversation.d.ts +15 -15
- package/dist/primitives/conversation.d.ts.map +1 -1
- package/dist/primitives/data-sources/index.d.ts +5 -5
- package/dist/primitives/data-sources/index.d.ts.map +1 -1
- package/dist/primitives/data-sources/source-base.d.ts +3 -3
- package/dist/primitives/data-sources/source-base.d.ts.map +1 -1
- package/dist/primitives/data-sources/source-directory.d.ts +1 -1
- package/dist/primitives/data-sources/source-directory.d.ts.map +1 -1
- package/dist/primitives/data-sources/source-table.d.ts +2 -2
- package/dist/primitives/data-sources/source-table.d.ts.map +1 -1
- package/dist/primitives/data-sources/source-website.d.ts +2 -2
- package/dist/primitives/data-sources/source-website.d.ts.map +1 -1
- package/dist/primitives/definition.d.ts +8 -8
- package/dist/primitives/definition.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +18 -18
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/knowledge.d.ts +2 -2
- package/dist/primitives/knowledge.d.ts.map +1 -1
- package/dist/primitives/table.d.ts +31 -31
- package/dist/primitives/table.d.ts.map +1 -1
- package/dist/primitives/trigger.d.ts +5 -5
- package/dist/primitives/trigger.d.ts.map +1 -1
- package/dist/primitives/workflow-instance.d.ts +8 -8
- package/dist/primitives/workflow-instance.d.ts.map +1 -1
- package/dist/primitives/workflow-step.d.ts +4 -4
- package/dist/primitives/workflow-step.d.ts.map +1 -1
- package/dist/primitives/workflow-utils.d.ts +5 -5
- package/dist/primitives/workflow-utils.d.ts.map +1 -1
- package/dist/primitives/workflow.d.ts +13 -13
- package/dist/primitives/workflow.d.ts.map +1 -1
- package/dist/runtime/actions.d.ts +2 -2
- package/dist/runtime/actions.d.ts.map +1 -1
- package/dist/runtime/adk.d.ts +7 -7
- package/dist/runtime/adk.d.ts.map +1 -1
- package/dist/runtime/agent-registry.d.ts +1 -1
- package/dist/runtime/agent-registry.d.ts.map +1 -1
- package/dist/runtime/assets.d.ts.map +1 -1
- package/dist/runtime/autonomous.d.ts +16 -16
- package/dist/runtime/autonomous.d.ts.map +1 -1
- package/dist/runtime/chat/chat.d.ts +4 -4
- package/dist/runtime/chat/chat.d.ts.map +1 -1
- package/dist/runtime/chat/citations.d.ts +1 -1
- package/dist/runtime/chat/citations.d.ts.map +1 -1
- package/dist/runtime/chat/components.d.ts +21 -21
- package/dist/runtime/chat/components.d.ts.map +1 -1
- package/dist/runtime/chat/html.d.ts.map +1 -1
- package/dist/runtime/chat/index.d.ts +4 -4
- package/dist/runtime/chat/index.d.ts.map +1 -1
- package/dist/runtime/chat/messages.d.ts +2 -2
- package/dist/runtime/chat/messages.d.ts.map +1 -1
- package/dist/runtime/chat/transcript.d.ts +5 -5
- package/dist/runtime/chat/transcript.d.ts.map +1 -1
- package/dist/runtime/chat/truncate-object.d.ts.map +1 -1
- package/dist/runtime/chat/truncate-transcript.d.ts +1 -1
- package/dist/runtime/chat/truncate-transcript.d.ts.map +1 -1
- package/dist/runtime/config.d.ts.map +1 -1
- package/dist/runtime/context/cognitive.d.ts +1 -1
- package/dist/runtime/context/cognitive.d.ts.map +1 -1
- package/dist/runtime/context/context.d.ts +10 -10
- package/dist/runtime/context/context.d.ts.map +1 -1
- package/dist/runtime/context/handlers.d.ts +5 -5
- package/dist/runtime/context/handlers.d.ts.map +1 -1
- package/dist/runtime/context/http.d.ts +4 -4
- package/dist/runtime/context/http.d.ts.map +1 -1
- package/dist/runtime/context/inspector-handler.d.ts.map +1 -1
- package/dist/runtime/context/promises.d.ts.map +1 -1
- package/dist/runtime/events.d.ts.map +1 -1
- package/dist/runtime/handlers/conversation-matching.d.ts.map +1 -1
- package/dist/runtime/handlers/conversation.d.ts +1 -1
- package/dist/runtime/handlers/conversation.d.ts.map +1 -1
- package/dist/runtime/handlers/event.d.ts +1 -1
- package/dist/runtime/handlers/event.d.ts.map +1 -1
- package/dist/runtime/handlers/index.d.ts +4 -4
- package/dist/runtime/handlers/index.d.ts.map +1 -1
- package/dist/runtime/handlers/trigger.d.ts +1 -1
- package/dist/runtime/handlers/trigger.d.ts.map +1 -1
- package/dist/runtime/handlers/workflow.d.ts +1 -1
- package/dist/runtime/handlers/workflow.d.ts.map +1 -1
- package/dist/runtime/heavy-imports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +11 -11
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/interfaces.d.ts.map +1 -1
- package/dist/runtime/singletons.d.ts.map +1 -1
- package/dist/runtime/state.d.ts +1 -1
- package/dist/runtime/state.d.ts.map +1 -1
- package/dist/runtime/tracked-state-schema.d.ts.map +1 -1
- package/dist/runtime/tracked-state.d.ts +5 -5
- package/dist/runtime/tracked-state.d.ts.map +1 -1
- package/dist/runtime/workflows/index.d.ts +1 -1
- package/dist/runtime/workflows/index.d.ts.map +1 -1
- package/dist/runtime/workflows/knowledge-indexing.d.ts +1 -1
- package/dist/runtime/workflows/knowledge-indexing.d.ts.map +1 -1
- package/dist/runtime.d.ts +13 -13
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +230 -666
- package/dist/runtime.js.map +2 -2
- package/dist/telemetry/context-manager.d.ts +2 -2
- package/dist/telemetry/context-manager.d.ts.map +1 -1
- package/dist/telemetry/file-exporter.d.ts +1 -1
- package/dist/telemetry/file-exporter.d.ts.map +1 -1
- package/dist/telemetry/instrument-http.d.ts +1 -1
- package/dist/telemetry/instrument-http.d.ts.map +1 -1
- package/dist/telemetry/live-file-processor.d.ts +2 -2
- package/dist/telemetry/live-file-processor.d.ts.map +1 -1
- package/dist/telemetry/span-helpers.d.ts +8 -8
- package/dist/telemetry/span-helpers.d.ts.map +1 -1
- package/dist/telemetry/spans/factory.d.ts +11 -11
- package/dist/telemetry/spans/factory.d.ts.map +1 -1
- package/dist/telemetry/spans/index.d.ts +98 -98
- package/dist/telemetry/spans/index.d.ts.map +1 -1
- package/dist/telemetry/spans/well-known-attributes.d.ts +5 -5
- package/dist/telemetry/spans/well-known-attributes.d.ts.map +1 -1
- package/dist/telemetry/structured-logging.d.ts.map +1 -1
- package/dist/telemetry/tracing.d.ts +3 -3
- package/dist/telemetry/tracing.d.ts.map +1 -1
- package/dist/telemetry/utils.d.ts +1 -1
- package/dist/telemetry/utils.d.ts.map +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/ui.d.ts +4 -4
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +9 -76
- package/dist/ui.js.map +2 -2
- package/dist/utilities/abort-signal.d.ts.map +1 -1
- package/dist/utilities/events.d.ts +2 -2
- package/dist/utilities/events.d.ts.map +1 -1
- package/dist/utilities/promises.d.ts.map +1 -1
- package/dist/utilities/size.d.ts.map +1 -1
- package/dist/utilities/strings.d.ts.map +1 -1
- package/dist/utilities/trigger-tags.d.ts.map +1 -1
- package/dist/utilities/types.d.ts.map +1 -1
- package/dist/workers/dev_worker.d.ts +1 -1
- package/dist/workers/dev_worker.d.ts.map +1 -1
- package/dist/workers/index.d.ts +3 -3
- package/dist/workers/index.d.ts.map +1 -1
- package/dist/workers/parent_worker.d.ts +1 -1
- package/dist/workers/parent_worker.d.ts.map +1 -1
- package/dist/workers/worker_pool.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/definition.js
CHANGED
|
@@ -48,7 +48,7 @@ var init_define_BUILD = __esm({
|
|
|
48
48
|
var define_PACKAGE_VERSIONS_default;
|
|
49
49
|
var init_define_PACKAGE_VERSIONS = __esm({
|
|
50
50
|
"<define:__PACKAGE_VERSIONS__>"() {
|
|
51
|
-
define_PACKAGE_VERSIONS_default = { runtime: "1.6.
|
|
51
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.6.5", adk: "not-installed", sdk: "4.17.3", llmz: "0.0.27", zai: "2.4.0", cognitive: "0.2.0" };
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -34304,12 +34304,7 @@ var AttachmentSchema = z.object({
|
|
|
34304
34304
|
});
|
|
34305
34305
|
var TranscriptItemSchema = z.object({
|
|
34306
34306
|
id: z.string(),
|
|
34307
|
-
role: z.union([
|
|
34308
|
-
z.literal("assistant"),
|
|
34309
|
-
z.literal("user"),
|
|
34310
|
-
z.literal("event"),
|
|
34311
|
-
z.literal("summary")
|
|
34312
|
-
]),
|
|
34307
|
+
role: z.union([z.literal("assistant"), z.literal("user"), z.literal("event"), z.literal("summary")]),
|
|
34313
34308
|
name: z.string().optional(),
|
|
34314
34309
|
createdAt: z.string().optional(),
|
|
34315
34310
|
content: z.string().optional(),
|
|
@@ -38230,10 +38225,7 @@ var INDEX_DIR2 = path2.join(DIR2, "index");
|
|
|
38230
38225
|
var append2 = (o) => fs2.appendFile(LIVE, JSON.stringify(o) + "\n", () => {
|
|
38231
38226
|
});
|
|
38232
38227
|
var appendToDay = (o) => {
|
|
38233
|
-
const dayFile2 = path2.join(
|
|
38234
|
-
DIR2,
|
|
38235
|
-
`${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
|
|
38236
|
-
);
|
|
38228
|
+
const dayFile2 = path2.join(DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
|
|
38237
38229
|
fs2.appendFile(dayFile2, JSON.stringify(o) + "\n", () => {
|
|
38238
38230
|
});
|
|
38239
38231
|
};
|
|
@@ -38243,10 +38235,7 @@ var appendToTrace = (traceId, o) => {
|
|
|
38243
38235
|
});
|
|
38244
38236
|
};
|
|
38245
38237
|
var appendToIndex = (o) => {
|
|
38246
|
-
const indexFile2 = path2.join(
|
|
38247
|
-
INDEX_DIR2,
|
|
38248
|
-
`${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
|
|
38249
|
-
);
|
|
38238
|
+
const indexFile2 = path2.join(INDEX_DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
|
|
38250
38239
|
fs2.appendFile(indexFile2, JSON.stringify(o) + "\n", () => {
|
|
38251
38240
|
});
|
|
38252
38241
|
};
|
|
@@ -38260,8 +38249,7 @@ var LiveFileSpanProcessor = class {
|
|
|
38260
38249
|
this.timer = setInterval(() => {
|
|
38261
38250
|
if (!this.active.size) return;
|
|
38262
38251
|
const ts = nowNs();
|
|
38263
|
-
for (const [spanId, traceId] of this.active)
|
|
38264
|
-
append2({ t: "beat", traceId, spanId, ts });
|
|
38252
|
+
for (const [spanId, traceId] of this.active) append2({ t: "beat", traceId, spanId, ts });
|
|
38265
38253
|
}, beatMs);
|
|
38266
38254
|
this.timer.unref?.();
|
|
38267
38255
|
}
|
|
@@ -38271,9 +38259,7 @@ var LiveFileSpanProcessor = class {
|
|
|
38271
38259
|
onStart(span2, _ctx) {
|
|
38272
38260
|
const ctx = span2.spanContext();
|
|
38273
38261
|
this.active.set(ctx.spanId, ctx.traceId);
|
|
38274
|
-
const startNs = Number(
|
|
38275
|
-
span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs()
|
|
38276
|
-
);
|
|
38262
|
+
const startNs = Number(span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs());
|
|
38277
38263
|
const startEvent = {
|
|
38278
38264
|
t: "start",
|
|
38279
38265
|
traceId: ctx.traceId,
|
|
@@ -38298,13 +38284,7 @@ var LiveFileSpanProcessor = class {
|
|
|
38298
38284
|
handler: span2.name
|
|
38299
38285
|
// Use span name as handler
|
|
38300
38286
|
};
|
|
38301
|
-
const trackedIds = [
|
|
38302
|
-
"conversationId",
|
|
38303
|
-
"messageId",
|
|
38304
|
-
"eventId",
|
|
38305
|
-
"userId",
|
|
38306
|
-
"workflowId"
|
|
38307
|
-
];
|
|
38287
|
+
const trackedIds = ["conversationId", "messageId", "eventId", "userId", "workflowId"];
|
|
38308
38288
|
for (const idKey of trackedIds) {
|
|
38309
38289
|
if (span2.attributes[idKey]) {
|
|
38310
38290
|
indexEntry[idKey] = span2.attributes[idKey];
|
|
@@ -38406,8 +38386,7 @@ function extractIds(fullUrl, body) {
|
|
|
38406
38386
|
if (userMatch?.[1]) ids.userId = userMatch[1];
|
|
38407
38387
|
if (eventMatch?.[1]) ids.eventId = eventMatch[1];
|
|
38408
38388
|
if (body && typeof body === "object") {
|
|
38409
|
-
if (body.conversationId && !ids.conversationId)
|
|
38410
|
-
ids.conversationId = body.conversationId;
|
|
38389
|
+
if (body.conversationId && !ids.conversationId) ids.conversationId = body.conversationId;
|
|
38411
38390
|
if (body.messageId && !ids.messageId) ids.messageId = body.messageId;
|
|
38412
38391
|
if (body.workflowId && !ids.workflowId) ids.workflowId = body.workflowId;
|
|
38413
38392
|
if (body.userId && !ids.userId) ids.userId = body.userId;
|
|
@@ -38415,9 +38394,7 @@ function extractIds(fullUrl, body) {
|
|
|
38415
38394
|
}
|
|
38416
38395
|
return ids;
|
|
38417
38396
|
}
|
|
38418
|
-
function installHttpClientInstrumentation({
|
|
38419
|
-
injectTraceHeader = true
|
|
38420
|
-
} = {}) {
|
|
38397
|
+
function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
38421
38398
|
const restores = [];
|
|
38422
38399
|
const genId = (n) => randomBytes(n).toString("hex");
|
|
38423
38400
|
const makeTraceparent = () => `00-${genId(16)}-${genId(8)}-01`;
|
|
@@ -38487,8 +38464,7 @@ function installHttpClientInstrumentation({
|
|
|
38487
38464
|
},
|
|
38488
38465
|
context.active()
|
|
38489
38466
|
);
|
|
38490
|
-
if (injectTraceHeader && !("traceparent" in options.headers))
|
|
38491
|
-
options.headers.traceparent = traceparent;
|
|
38467
|
+
if (injectTraceHeader && !("traceparent" in options.headers)) options.headers.traceparent = traceparent;
|
|
38492
38468
|
let req;
|
|
38493
38469
|
if (typeof args[0] === "string" || args[0] instanceof URL) {
|
|
38494
38470
|
req = requestFn.call(this, args[0], options, cb);
|
|
@@ -38510,18 +38486,12 @@ function installHttpClientInstrumentation({
|
|
|
38510
38486
|
}
|
|
38511
38487
|
if (requestBodyChunks.length > 0) {
|
|
38512
38488
|
const bodyString = Buffer.concat(requestBodyChunks).toString("utf-8");
|
|
38513
|
-
span2.setAttribute(
|
|
38514
|
-
isBotpress ? "botpress.request.body" : "http.request.body",
|
|
38515
|
-
bodyString
|
|
38516
|
-
);
|
|
38489
|
+
span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", bodyString);
|
|
38517
38490
|
}
|
|
38518
38491
|
return origEnd(chunk, ...args2);
|
|
38519
38492
|
};
|
|
38520
38493
|
req.on("response", (res) => {
|
|
38521
|
-
span2.setAttribute(
|
|
38522
|
-
isBotpress ? "botpress.status_code" : "http.status_code",
|
|
38523
|
-
res.statusCode || 0
|
|
38524
|
-
);
|
|
38494
|
+
span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", res.statusCode || 0);
|
|
38525
38495
|
const responseBodyChunks = [];
|
|
38526
38496
|
res.on("data", (chunk) => {
|
|
38527
38497
|
responseBodyChunks.push(chunk);
|
|
@@ -38529,10 +38499,7 @@ function installHttpClientInstrumentation({
|
|
|
38529
38499
|
res.on("end", () => {
|
|
38530
38500
|
if (responseBodyChunks.length > 0) {
|
|
38531
38501
|
const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
|
|
38532
|
-
span2.setAttribute(
|
|
38533
|
-
isBotpress ? "botpress.response.body" : "http.response.body",
|
|
38534
|
-
bodyString
|
|
38535
|
-
);
|
|
38502
|
+
span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
|
|
38536
38503
|
}
|
|
38537
38504
|
if ((res.statusCode || 0) >= 400) {
|
|
38538
38505
|
span2.setStatus({
|
|
@@ -38544,10 +38511,7 @@ function installHttpClientInstrumentation({
|
|
|
38544
38511
|
});
|
|
38545
38512
|
});
|
|
38546
38513
|
req.on("error", (err) => {
|
|
38547
|
-
span2.setAttribute(
|
|
38548
|
-
isBotpress ? "botpress.error" : "http.error",
|
|
38549
|
-
err.message
|
|
38550
|
-
);
|
|
38514
|
+
span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
|
|
38551
38515
|
span2.recordException(err);
|
|
38552
38516
|
span2.setStatus({
|
|
38553
38517
|
code: SpanStatusCode.ERROR,
|
|
@@ -38565,6 +38529,7 @@ function installHttpClientInstrumentation({
|
|
|
38565
38529
|
httpsRequest: https2.request,
|
|
38566
38530
|
httpsGet: https2.get
|
|
38567
38531
|
};
|
|
38532
|
+
;
|
|
38568
38533
|
http2.request = wrapRequest2(orig.httpRequest);
|
|
38569
38534
|
https2.request = wrapRequest2(orig.httpsRequest);
|
|
38570
38535
|
http2.get = function wrappedGet(...a) {
|
|
@@ -38658,10 +38623,7 @@ function installHttpClientInstrumentation({
|
|
|
38658
38623
|
}
|
|
38659
38624
|
}
|
|
38660
38625
|
if (requestBody) {
|
|
38661
|
-
span2.setAttribute(
|
|
38662
|
-
isBotpress ? "botpress.request.body" : "http.request.body",
|
|
38663
|
-
requestBody
|
|
38664
|
-
);
|
|
38626
|
+
span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", requestBody);
|
|
38665
38627
|
}
|
|
38666
38628
|
}
|
|
38667
38629
|
const traceparent = makeTraceparent();
|
|
@@ -38669,10 +38631,7 @@ function installHttpClientInstrumentation({
|
|
|
38669
38631
|
if (Array.isArray(opts.headers)) {
|
|
38670
38632
|
headers.push(...opts.headers);
|
|
38671
38633
|
} else if (opts.headers && typeof opts.headers === "object") {
|
|
38672
|
-
for (const [k, v] of Object.entries(
|
|
38673
|
-
opts.headers
|
|
38674
|
-
))
|
|
38675
|
-
headers.push(k, String(v));
|
|
38634
|
+
for (const [k, v] of Object.entries(opts.headers)) headers.push(k, String(v));
|
|
38676
38635
|
}
|
|
38677
38636
|
headers.push(INSTRUMENTED_HEADER, "true");
|
|
38678
38637
|
if (injectTraceHeader) {
|
|
@@ -38690,10 +38649,7 @@ function installHttpClientInstrumentation({
|
|
|
38690
38649
|
onConnect: handler.onConnect?.bind(handler),
|
|
38691
38650
|
onUpgrade: handler.onUpgrade?.bind(handler),
|
|
38692
38651
|
onHeaders: (statusCode, rawHeaders, resume) => {
|
|
38693
|
-
span2.setAttribute(
|
|
38694
|
-
isBotpress ? "botpress.status_code" : "http.status_code",
|
|
38695
|
-
statusCode
|
|
38696
|
-
);
|
|
38652
|
+
span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", statusCode);
|
|
38697
38653
|
if (statusCode >= 500) {
|
|
38698
38654
|
span2.setStatus({
|
|
38699
38655
|
code: SpanStatusCode.ERROR,
|
|
@@ -38708,10 +38664,7 @@ function installHttpClientInstrumentation({
|
|
|
38708
38664
|
handler.onHeaders?.(statusCode, rawHeaders, resume);
|
|
38709
38665
|
},
|
|
38710
38666
|
onError: (err) => {
|
|
38711
|
-
span2.setAttribute(
|
|
38712
|
-
isBotpress ? "botpress.error" : "http.error",
|
|
38713
|
-
err.message
|
|
38714
|
-
);
|
|
38667
|
+
span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
|
|
38715
38668
|
span2.recordException(err);
|
|
38716
38669
|
span2.setStatus({
|
|
38717
38670
|
code: SpanStatusCode.ERROR,
|
|
@@ -38728,10 +38681,7 @@ function installHttpClientInstrumentation({
|
|
|
38728
38681
|
onComplete: (trailers) => {
|
|
38729
38682
|
if (responseBodyChunks.length > 0) {
|
|
38730
38683
|
const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
|
|
38731
|
-
span2.setAttribute(
|
|
38732
|
-
isBotpress ? "botpress.response.body" : "http.response.body",
|
|
38733
|
-
bodyString
|
|
38734
|
-
);
|
|
38684
|
+
span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
|
|
38735
38685
|
}
|
|
38736
38686
|
span2.end();
|
|
38737
38687
|
handler.onComplete?.(trailers);
|
|
@@ -38768,6 +38718,7 @@ init_define_BUILD();
|
|
|
38768
38718
|
init_define_PACKAGE_VERSIONS();
|
|
38769
38719
|
function getSingleton(key, factory2) {
|
|
38770
38720
|
if (!globalThis[key]) {
|
|
38721
|
+
;
|
|
38771
38722
|
globalThis[key] = factory2();
|
|
38772
38723
|
}
|
|
38773
38724
|
return globalThis[key];
|
|
@@ -38915,10 +38866,8 @@ function inspectToJsonSize(input, opts) {
|
|
|
38915
38866
|
if (value === null) return null;
|
|
38916
38867
|
const t = typeof value;
|
|
38917
38868
|
if (t === "boolean" || t === "number") return value;
|
|
38918
|
-
if (t === "string")
|
|
38919
|
-
|
|
38920
|
-
if (t === "bigint")
|
|
38921
|
-
return elideString(String(value), limits2.head, limits2.tail);
|
|
38869
|
+
if (t === "string") return elideString(value, limits2.head, limits2.tail);
|
|
38870
|
+
if (t === "bigint") return elideString(String(value), limits2.head, limits2.tail);
|
|
38922
38871
|
if (t === "symbol" || t === "function" || t === "undefined") {
|
|
38923
38872
|
return null;
|
|
38924
38873
|
}
|
|
@@ -38973,8 +38922,7 @@ function inspectToJsonSize(input, opts) {
|
|
|
38973
38922
|
const k = keys[i];
|
|
38974
38923
|
props[k] = summarize(value[k], seen, nextLimits);
|
|
38975
38924
|
}
|
|
38976
|
-
if (keys.length > keep)
|
|
38977
|
-
props["__truncated__"] = `+${keys.length - keep} keys`;
|
|
38925
|
+
if (keys.length > keep) props["__truncated__"] = `+${keys.length - keep} keys`;
|
|
38978
38926
|
seen.delete(value);
|
|
38979
38927
|
return { [`<${tag}>`]: props };
|
|
38980
38928
|
}
|
|
@@ -39076,10 +39024,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
39076
39024
|
init_define_BUILD();
|
|
39077
39025
|
init_define_PACKAGE_VERSIONS();
|
|
39078
39026
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
39079
|
-
var storage = getSingleton(
|
|
39080
|
-
"__ADK_GLOBAL_CTX_STORAGE",
|
|
39081
|
-
() => new AsyncLocalStorage2()
|
|
39082
|
-
);
|
|
39027
|
+
var storage = getSingleton("__ADK_GLOBAL_CTX_STORAGE", () => new AsyncLocalStorage2());
|
|
39083
39028
|
var context2 = {
|
|
39084
39029
|
enterWith: (data) => {
|
|
39085
39030
|
storage.enterWith(data);
|
|
@@ -39094,10 +39039,7 @@ var context2 = {
|
|
|
39094
39039
|
},
|
|
39095
39040
|
getAll: () => {
|
|
39096
39041
|
const store = storage.getStore();
|
|
39097
|
-
if (!store)
|
|
39098
|
-
throw new Error(
|
|
39099
|
-
"No context found. Did you forget to call `context.run()`?"
|
|
39100
|
-
);
|
|
39042
|
+
if (!store) throw new Error("No context found. Did you forget to call `context.run()`?");
|
|
39101
39043
|
return store;
|
|
39102
39044
|
},
|
|
39103
39045
|
get: (key, opts) => {
|
|
@@ -39137,9 +39079,7 @@ var getPromiseTracker = () => {
|
|
|
39137
39079
|
if (tracker) {
|
|
39138
39080
|
return tracker;
|
|
39139
39081
|
}
|
|
39140
|
-
throw new Error(
|
|
39141
|
-
"PromiseTracker not found in context. Make sure to initialize it in your runtime setup."
|
|
39142
|
-
);
|
|
39082
|
+
throw new Error("PromiseTracker not found in context. Make sure to initialize it in your runtime setup.");
|
|
39143
39083
|
};
|
|
39144
39084
|
function trackPromise(promise) {
|
|
39145
39085
|
return getPromiseTracker().register(promise);
|
|
@@ -39203,16 +39143,11 @@ var AgentRegistry = class {
|
|
|
39203
39143
|
}
|
|
39204
39144
|
ensureInitialized() {
|
|
39205
39145
|
if (!this._data) {
|
|
39206
|
-
throw new Error(
|
|
39207
|
-
"Agent registry not initialized. Call agentRegistry.initialize() during bot startup."
|
|
39208
|
-
);
|
|
39146
|
+
throw new Error("Agent registry not initialized. Call agentRegistry.initialize() during bot startup.");
|
|
39209
39147
|
}
|
|
39210
39148
|
}
|
|
39211
39149
|
};
|
|
39212
|
-
var agentRegistry = getSingleton(
|
|
39213
|
-
"__ADK_GLOBAL_AGENT_REGISTRY",
|
|
39214
|
-
() => new AgentRegistry()
|
|
39215
|
-
);
|
|
39150
|
+
var agentRegistry = getSingleton("__ADK_GLOBAL_AGENT_REGISTRY", () => new AgentRegistry());
|
|
39216
39151
|
|
|
39217
39152
|
// src/runtime/heavy-imports.ts
|
|
39218
39153
|
init_define_BUILD();
|
|
@@ -39300,11 +39235,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
39300
39235
|
// src/runtime/chat/chat.ts
|
|
39301
39236
|
init_define_BUILD();
|
|
39302
39237
|
init_define_PACKAGE_VERSIONS();
|
|
39303
|
-
import {
|
|
39304
|
-
Chat,
|
|
39305
|
-
DefaultComponents,
|
|
39306
|
-
isAnyComponent as isAnyComponent2
|
|
39307
|
-
} from "llmz";
|
|
39238
|
+
import { Chat, DefaultComponents, isAnyComponent as isAnyComponent2 } from "llmz";
|
|
39308
39239
|
|
|
39309
39240
|
// src/runtime/chat/truncate-transcript.ts
|
|
39310
39241
|
init_define_BUILD();
|
|
@@ -39633,9 +39564,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
39633
39564
|
init_define_BUILD();
|
|
39634
39565
|
init_define_PACKAGE_VERSIONS();
|
|
39635
39566
|
init_esm();
|
|
39636
|
-
import {
|
|
39637
|
-
getValue
|
|
39638
|
-
} from "llmz";
|
|
39567
|
+
import { getValue } from "llmz";
|
|
39639
39568
|
import {
|
|
39640
39569
|
Tool as LlmzTool,
|
|
39641
39570
|
ThinkSignal as _ThinkSignal,
|
|
@@ -39653,9 +39582,7 @@ init_define_BUILD();
|
|
|
39653
39582
|
init_define_PACKAGE_VERSIONS();
|
|
39654
39583
|
function createJoinedAbortController(signals) {
|
|
39655
39584
|
const controller = new AbortController();
|
|
39656
|
-
const validSignals = signals.filter(
|
|
39657
|
-
(signal) => signal != null
|
|
39658
|
-
);
|
|
39585
|
+
const validSignals = signals.filter((signal) => signal != null);
|
|
39659
39586
|
if (validSignals.length === 0) {
|
|
39660
39587
|
return controller;
|
|
39661
39588
|
}
|
|
@@ -39780,9 +39707,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39780
39707
|
const client = context2.get("client");
|
|
39781
39708
|
const citations = context2.get("citations");
|
|
39782
39709
|
if (!client) {
|
|
39783
|
-
throw new Error(
|
|
39784
|
-
"Client is not available in this context. Make sure to run in a context with a client."
|
|
39785
|
-
);
|
|
39710
|
+
throw new Error("Client is not available in this context. Make sure to run in a context with a client.");
|
|
39786
39711
|
}
|
|
39787
39712
|
const { passages } = await client.searchFiles({
|
|
39788
39713
|
query,
|
|
@@ -39832,9 +39757,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39832
39757
|
citationMetadata.sourceId = tags[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID];
|
|
39833
39758
|
}
|
|
39834
39759
|
const { tag } = citations.registerSource(citationMetadata);
|
|
39835
|
-
message.push(
|
|
39836
|
-
`<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`
|
|
39837
|
-
);
|
|
39760
|
+
message.push(`<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`);
|
|
39838
39761
|
message.push(p.content);
|
|
39839
39762
|
message.push(`</${tag}>`);
|
|
39840
39763
|
}
|
|
@@ -39850,9 +39773,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39850
39773
|
return async (props) => {
|
|
39851
39774
|
const cognitive = context2.get("cognitive");
|
|
39852
39775
|
if (!cognitive) {
|
|
39853
|
-
throw new Error(
|
|
39854
|
-
"Cognitive client is not available in this context. Make sure to run in a cognitive context."
|
|
39855
|
-
);
|
|
39776
|
+
throw new Error("Cognitive client is not available in this context. Make sure to run in a cognitive context.");
|
|
39856
39777
|
}
|
|
39857
39778
|
const defaultTemperature = 0.7;
|
|
39858
39779
|
const maxLoops = import_lodash2.default.clamp(props.iterations ?? 10, 1, 100);
|
|
@@ -39864,10 +39785,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39864
39785
|
"autonomous.mode": options.mode
|
|
39865
39786
|
},
|
|
39866
39787
|
async (execSpan) => {
|
|
39867
|
-
const joinedSignal = createJoinedAbortSignal([
|
|
39868
|
-
props.signal,
|
|
39869
|
-
options.interruption
|
|
39870
|
-
]);
|
|
39788
|
+
const joinedSignal = createJoinedAbortSignal([props.signal, options.interruption]);
|
|
39871
39789
|
const llmz_execute = (await import("llmz")).execute;
|
|
39872
39790
|
const asyncResource = new AsyncResource("autonomous.execution");
|
|
39873
39791
|
const getNewIteration = (index) => createSpan(
|
|
@@ -39885,17 +39803,11 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39885
39803
|
);
|
|
39886
39804
|
const _chat = options.mode === "chat" ? context2.get("chat") : void 0;
|
|
39887
39805
|
if (options.mode === "chat" && !_chat) {
|
|
39888
|
-
throw new Error(
|
|
39889
|
-
"Chat is not available in this context. Make sure to run in chat mode with a chat context."
|
|
39890
|
-
);
|
|
39806
|
+
throw new Error("Chat is not available in this context. Make sure to run in chat mode with a chat context.");
|
|
39891
39807
|
}
|
|
39892
39808
|
const chat = _chat ? {
|
|
39893
|
-
components: bindContext(
|
|
39894
|
-
|
|
39895
|
-
),
|
|
39896
|
-
transcript: bindContext(
|
|
39897
|
-
(ctx) => getValue(_chat.transcript, ctx)
|
|
39898
|
-
),
|
|
39809
|
+
components: bindContext((ctx) => getValue(_chat.components, ctx)),
|
|
39810
|
+
transcript: bindContext((ctx) => getValue(_chat.transcript, ctx)),
|
|
39899
39811
|
handler: bindContext(_chat.handler),
|
|
39900
39812
|
onExecutionDone: bindContext(_chat.onExecutionDone)
|
|
39901
39813
|
} : void 0;
|
|
@@ -39930,10 +39842,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
39930
39842
|
...props.objects && {
|
|
39931
39843
|
objects: async (ctx) => {
|
|
39932
39844
|
const objs = await getValue(props.objects, ctx) ?? [];
|
|
39933
|
-
iterationSpan?.setAttribute(
|
|
39934
|
-
"autonomous.objects",
|
|
39935
|
-
objs.map((o) => o.name).join(", ")
|
|
39936
|
-
);
|
|
39845
|
+
iterationSpan?.setAttribute("autonomous.objects", objs.map((o) => o.name).join(", "));
|
|
39937
39846
|
for (const obj of objs) {
|
|
39938
39847
|
obj.tools = obj.tools?.map(
|
|
39939
39848
|
(tool) => tool.clone({
|
|
@@ -39997,10 +39906,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
39997
39906
|
if (search_knowledge) {
|
|
39998
39907
|
allTools.push(search_knowledge);
|
|
39999
39908
|
}
|
|
40000
|
-
iterationSpan?.setAttribute(
|
|
40001
|
-
"autonomous.tools",
|
|
40002
|
-
allTools?.map((t) => t.name).join(", ")
|
|
40003
|
-
);
|
|
39909
|
+
iterationSpan?.setAttribute("autonomous.tools", allTools?.map((t) => t.name).join(", "));
|
|
40004
39910
|
return allTools.map(
|
|
40005
39911
|
(tool) => tool.clone({
|
|
40006
39912
|
handler: asyncResource.bind((args, ctx2) => {
|
|
@@ -40062,9 +39968,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40062
39968
|
onAfterTool: asyncResource.bind(props.hooks.onAfterTool)
|
|
40063
39969
|
},
|
|
40064
39970
|
...props.hooks?.onBeforeExecution && {
|
|
40065
|
-
onBeforeExecution: asyncResource.bind(
|
|
40066
|
-
props.hooks.onBeforeExecution
|
|
40067
|
-
)
|
|
39971
|
+
onBeforeExecution: asyncResource.bind(props.hooks.onBeforeExecution)
|
|
40068
39972
|
},
|
|
40069
39973
|
...props.hooks?.onExit && {
|
|
40070
39974
|
onExit: asyncResource.bind(props.hooks.onExit)
|
|
@@ -40083,9 +39987,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40083
39987
|
});
|
|
40084
39988
|
}
|
|
40085
39989
|
if (props.hooks?.onTrace) {
|
|
40086
|
-
return asyncResource.runInAsyncScope(
|
|
40087
|
-
() => props.hooks.onTrace({ trace: trace2, iteration })
|
|
40088
|
-
);
|
|
39990
|
+
return asyncResource.runInAsyncScope(() => props.hooks.onTrace({ trace: trace2, iteration }));
|
|
40089
39991
|
}
|
|
40090
39992
|
},
|
|
40091
39993
|
onIterationEnd: async (iteration, controller) => {
|
|
@@ -40111,9 +40013,7 @@ ${iteration.status.execution_error.stack}`;
|
|
|
40111
40013
|
} else if (iteration.status.type === "invalid_code_error") {
|
|
40112
40014
|
message = `Iteration failed due to invalid code: ${iteration.status.invalid_code_error.message}`;
|
|
40113
40015
|
}
|
|
40114
|
-
iterationSpan?.recordException(
|
|
40115
|
-
iteration.error ?? new Error(message)
|
|
40116
|
-
);
|
|
40016
|
+
iterationSpan?.recordException(iteration.error ?? new Error(message));
|
|
40117
40017
|
iterationSpan?.setStatus({
|
|
40118
40018
|
code: SpanStatusCode.ERROR,
|
|
40119
40019
|
message
|
|
@@ -40135,16 +40035,11 @@ ${iteration.status.execution_error.stack}`;
|
|
|
40135
40035
|
}
|
|
40136
40036
|
iterationSpan?.end();
|
|
40137
40037
|
if (props.hooks?.onIterationEnd) {
|
|
40138
|
-
return await asyncResource.runInAsyncScope(
|
|
40139
|
-
() => props.hooks.onIterationEnd(iteration, controller)
|
|
40140
|
-
);
|
|
40038
|
+
return await asyncResource.runInAsyncScope(() => props.hooks.onIterationEnd(iteration, controller));
|
|
40141
40039
|
}
|
|
40142
40040
|
}
|
|
40143
40041
|
});
|
|
40144
|
-
execSpan.setAttribute(
|
|
40145
|
-
"autonomous.execution_id",
|
|
40146
|
-
execution.context.id
|
|
40147
|
-
);
|
|
40042
|
+
execSpan.setAttribute("autonomous.execution_id", execution.context.id);
|
|
40148
40043
|
return execution;
|
|
40149
40044
|
}
|
|
40150
40045
|
);
|
|
@@ -40187,22 +40082,16 @@ var actions = new Proxy({}, {
|
|
|
40187
40082
|
}
|
|
40188
40083
|
integrations ??= context2.get("integrations", { optional: true });
|
|
40189
40084
|
client ??= context2.get("client", { optional: true });
|
|
40190
|
-
const integration = integrations.find(
|
|
40191
|
-
(i) => i.alias === integrationName
|
|
40192
|
-
);
|
|
40085
|
+
const integration = integrations.find((i) => i.alias === integrationName);
|
|
40193
40086
|
const actionDef = integration?.definition.actions?.[actionName];
|
|
40194
40087
|
const handler = async (params) => {
|
|
40195
40088
|
integrations ??= context2.get("integrations", { optional: true });
|
|
40196
40089
|
client ??= context2.get("client", { optional: true });
|
|
40197
40090
|
if (!integration || !actionDef) {
|
|
40198
|
-
throw new Error(
|
|
40199
|
-
`Could not find integration "${integrationName}" and action "${actionName}"`
|
|
40200
|
-
);
|
|
40091
|
+
throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
|
|
40201
40092
|
}
|
|
40202
40093
|
if (!integration.definition.actions?.[actionName]) {
|
|
40203
|
-
throw new Error(
|
|
40204
|
-
`Action "${actionName}" not found in integration "${integrationName}"`
|
|
40205
|
-
);
|
|
40094
|
+
throw new Error(`Action "${actionName}" not found in integration "${integrationName}"`);
|
|
40206
40095
|
}
|
|
40207
40096
|
return client.callAction({
|
|
40208
40097
|
type: `${integration.alias}:${actionName}`,
|
|
@@ -40211,9 +40100,7 @@ var actions = new Proxy({}, {
|
|
|
40211
40100
|
};
|
|
40212
40101
|
handler.asTool = () => {
|
|
40213
40102
|
if (!integration || !actionDef) {
|
|
40214
|
-
throw new Error(
|
|
40215
|
-
`Could not find integration "${integrationName}" and action "${actionName}"`
|
|
40216
|
-
);
|
|
40103
|
+
throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
|
|
40217
40104
|
}
|
|
40218
40105
|
return new Autonomous.Tool({
|
|
40219
40106
|
name: actionName,
|
|
@@ -40231,9 +40118,7 @@ var actions = new Proxy({}, {
|
|
|
40231
40118
|
optional: true
|
|
40232
40119
|
});
|
|
40233
40120
|
if (!integrations2) return [];
|
|
40234
|
-
const integration = integrations2.find(
|
|
40235
|
-
(i) => i.alias === integrationName
|
|
40236
|
-
);
|
|
40121
|
+
const integration = integrations2.find((i) => i.alias === integrationName);
|
|
40237
40122
|
if (!integration?.definition?.actions) return [];
|
|
40238
40123
|
return Object.keys(integration.definition.actions);
|
|
40239
40124
|
} catch {
|
|
@@ -40246,9 +40131,7 @@ var actions = new Proxy({}, {
|
|
|
40246
40131
|
optional: true
|
|
40247
40132
|
});
|
|
40248
40133
|
if (!integrations2) return false;
|
|
40249
|
-
const integration = integrations2.find(
|
|
40250
|
-
(i) => i.alias === integrationName
|
|
40251
|
-
);
|
|
40134
|
+
const integration = integrations2.find((i) => i.alias === integrationName);
|
|
40252
40135
|
return !!integration?.definition?.actions?.[actionName];
|
|
40253
40136
|
} catch {
|
|
40254
40137
|
return false;
|
|
@@ -40556,11 +40439,7 @@ var BaseConversationInstance = class {
|
|
|
40556
40439
|
* Start typing indicator
|
|
40557
40440
|
*/
|
|
40558
40441
|
async startTyping() {
|
|
40559
|
-
const mapping = InterfaceMappings.getIntegrationAction(
|
|
40560
|
-
"typingIndicator",
|
|
40561
|
-
"startTypingIndicator",
|
|
40562
|
-
this.integration
|
|
40563
|
-
);
|
|
40442
|
+
const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "startTypingIndicator", this.integration);
|
|
40564
40443
|
if (mapping) {
|
|
40565
40444
|
const message = context2.get("message", { optional: true });
|
|
40566
40445
|
await this.client.callAction({
|
|
@@ -40577,11 +40456,7 @@ var BaseConversationInstance = class {
|
|
|
40577
40456
|
* Stop typing indicator
|
|
40578
40457
|
*/
|
|
40579
40458
|
async stopTyping() {
|
|
40580
|
-
const mapping = InterfaceMappings.getIntegrationAction(
|
|
40581
|
-
"typingIndicator",
|
|
40582
|
-
"stopTypingIndicator",
|
|
40583
|
-
this.integration
|
|
40584
|
-
);
|
|
40459
|
+
const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "stopTypingIndicator", this.integration);
|
|
40585
40460
|
if (mapping) {
|
|
40586
40461
|
const message = context2.get("message", { optional: true });
|
|
40587
40462
|
await this.client.callAction({
|
|
@@ -40657,10 +40532,7 @@ var Definitions;
|
|
|
40657
40532
|
});
|
|
40658
40533
|
const actionDefinitionSchema = z7.object({
|
|
40659
40534
|
type: z7.literal("action"),
|
|
40660
|
-
name: z7.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(
|
|
40661
|
-
/^[a-zA-Z][a-zA-Z0-9]*$/,
|
|
40662
|
-
"Name must be alphanumeric with no special characters"
|
|
40663
|
-
),
|
|
40535
|
+
name: z7.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(/^[a-zA-Z][a-zA-Z0-9]*$/, "Name must be alphanumeric with no special characters"),
|
|
40664
40536
|
title: z7.string().optional(),
|
|
40665
40537
|
description: z7.string().optional(),
|
|
40666
40538
|
attributes: z7.record(z7.string()).optional(),
|
|
@@ -40761,9 +40633,7 @@ var createSyncWorkflow = (props) => new BaseWorkflow({
|
|
|
40761
40633
|
}
|
|
40762
40634
|
const source = kb.sources.find((s) => s.id === sourceId);
|
|
40763
40635
|
if (!source) {
|
|
40764
|
-
throw new Error(
|
|
40765
|
-
`Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`
|
|
40766
|
-
);
|
|
40636
|
+
throw new Error(`Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`);
|
|
40767
40637
|
}
|
|
40768
40638
|
console.log(
|
|
40769
40639
|
`\u{1F504} Starting sync for data source '${sourceId}' of type '${source.type}' in knowledge base '${kbName}'`
|
|
@@ -42303,17 +42173,8 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42303
42173
|
this.urls = options.urls ?? void 0;
|
|
42304
42174
|
this.filterFn = "filter" in options ? options.filter : void 0;
|
|
42305
42175
|
this.customFetch = options.fetch ?? void 0;
|
|
42306
|
-
this.maxPages = Math.max(
|
|
42307
|
-
|
|
42308
|
-
Math.min(
|
|
42309
|
-
("maxPages" in options ? options.maxPages : void 0) ?? 5e4,
|
|
42310
|
-
5e4
|
|
42311
|
-
)
|
|
42312
|
-
);
|
|
42313
|
-
this.maxDepth = Math.max(
|
|
42314
|
-
1,
|
|
42315
|
-
Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20)
|
|
42316
|
-
);
|
|
42176
|
+
this.maxPages = Math.max(1, Math.min(("maxPages" in options ? options.maxPages : void 0) ?? 5e4, 5e4));
|
|
42177
|
+
this.maxDepth = Math.max(1, Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20));
|
|
42317
42178
|
}
|
|
42318
42179
|
isBrowserIntegrationAvailable() {
|
|
42319
42180
|
return !!adk.project.integrations.get("browser");
|
|
@@ -42477,9 +42338,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42477
42338
|
}
|
|
42478
42339
|
return passed;
|
|
42479
42340
|
});
|
|
42480
|
-
console.log(
|
|
42481
|
-
`Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`
|
|
42482
|
-
);
|
|
42341
|
+
console.log(`Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`);
|
|
42483
42342
|
}
|
|
42484
42343
|
return filteredUrls.map((url2) => ({ loc: url2 }));
|
|
42485
42344
|
}
|
|
@@ -42511,20 +42370,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42511
42370
|
await step2(`processing sitemap ${item.url}`, async () => {
|
|
42512
42371
|
try {
|
|
42513
42372
|
const { content, contentType } = await this.fetchSitemap(item.url);
|
|
42514
|
-
console.log(
|
|
42515
|
-
`Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`
|
|
42516
|
-
);
|
|
42373
|
+
console.log(`Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`);
|
|
42517
42374
|
console.log(content, contentType);
|
|
42518
42375
|
try {
|
|
42519
42376
|
const { urls, sitemaps } = this.parseSitemapXml(content);
|
|
42520
|
-
console.log(
|
|
42521
|
-
`Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`
|
|
42522
|
-
);
|
|
42377
|
+
console.log(`Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`);
|
|
42523
42378
|
for (const url2 of urls) {
|
|
42524
42379
|
if (state.urls.length >= this.maxPages) {
|
|
42525
|
-
console.log(
|
|
42526
|
-
`Reached maxPages limit (${this.maxPages}), stopping URL discovery`
|
|
42527
|
-
);
|
|
42380
|
+
console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
|
|
42528
42381
|
break;
|
|
42529
42382
|
}
|
|
42530
42383
|
const filterContext = {
|
|
@@ -42545,20 +42398,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42545
42398
|
state.queue.push({ url: sitemapUrl, depth: item.depth + 1 });
|
|
42546
42399
|
}
|
|
42547
42400
|
} else if (sitemaps.length > 0) {
|
|
42548
|
-
console.log(
|
|
42549
|
-
`Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`
|
|
42550
|
-
);
|
|
42401
|
+
console.log(`Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`);
|
|
42551
42402
|
}
|
|
42552
42403
|
} catch (xmlErr) {
|
|
42553
|
-
console.log(
|
|
42554
|
-
`XML parsing failed for ${item.url}, trying TXT format...`
|
|
42555
|
-
);
|
|
42404
|
+
console.log(`XML parsing failed for ${item.url}, trying TXT format...`);
|
|
42556
42405
|
const { urls } = this.parseSitemapTxt(content);
|
|
42557
42406
|
for (const url2 of urls) {
|
|
42558
42407
|
if (state.urls.length >= this.maxPages) {
|
|
42559
|
-
console.log(
|
|
42560
|
-
`Reached maxPages limit (${this.maxPages}), stopping URL discovery`
|
|
42561
|
-
);
|
|
42408
|
+
console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
|
|
42562
42409
|
break;
|
|
42563
42410
|
}
|
|
42564
42411
|
const filterContext = { url: url2.loc };
|
|
@@ -42576,13 +42423,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42576
42423
|
}
|
|
42577
42424
|
});
|
|
42578
42425
|
}
|
|
42579
|
-
console.log(
|
|
42580
|
-
`URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`
|
|
42581
|
-
);
|
|
42426
|
+
console.log(`URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`);
|
|
42582
42427
|
if (state.urls.length >= this.maxPages) {
|
|
42583
|
-
console.log(
|
|
42584
|
-
`Note: Discovery stopped at maxPages limit (${this.maxPages})`
|
|
42585
|
-
);
|
|
42428
|
+
console.log(`Note: Discovery stopped at maxPages limit (${this.maxPages})`);
|
|
42586
42429
|
}
|
|
42587
42430
|
return state.urls.slice(0, this.maxPages);
|
|
42588
42431
|
}
|
|
@@ -42595,13 +42438,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42595
42438
|
console.log(
|
|
42596
42439
|
`Starting sync for WebsiteSource [${this.id}] in mode [${this.mode}, maxPages=${this.maxPages}, maxDepth=${this.maxDepth}, baseUrl=${this.baseUrl}, sitemapUrl=${this.sitemapUrl}]`
|
|
42597
42440
|
);
|
|
42598
|
-
console.log(
|
|
42599
|
-
`Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`
|
|
42600
|
-
);
|
|
42441
|
+
console.log(`Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`);
|
|
42601
42442
|
if (input.force) {
|
|
42602
|
-
console.log(
|
|
42603
|
-
"\u{1F504} FORCE MODE: Re-indexing all files regardless of changes"
|
|
42604
|
-
);
|
|
42443
|
+
console.log("\u{1F504} FORCE MODE: Re-indexing all files regardless of changes");
|
|
42605
42444
|
}
|
|
42606
42445
|
const tags = {
|
|
42607
42446
|
[WellKnownTags.knowledge.KNOWLEDGE]: "true",
|
|
@@ -42609,10 +42448,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42609
42448
|
[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_TYPE]: this.type,
|
|
42610
42449
|
[WellKnownTags.knowledge.KNOWLEDGE_BASE_NAME]: input.kbName
|
|
42611
42450
|
};
|
|
42612
|
-
const discoveredUrls = await step2(
|
|
42613
|
-
"discover urls from sitemap",
|
|
42614
|
-
() => this.discoverUrls(step2, state)
|
|
42615
|
-
);
|
|
42451
|
+
const discoveredUrls = await step2("discover urls from sitemap", () => this.discoverUrls(step2, state));
|
|
42616
42452
|
console.log(`Discovered ${discoveredUrls.length} URLs from sitemap`);
|
|
42617
42453
|
console.log(`Will process up to ${this.maxPages} pages`);
|
|
42618
42454
|
const existingFiles = await step2(
|
|
@@ -42622,16 +42458,18 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42622
42458
|
}).collect()
|
|
42623
42459
|
);
|
|
42624
42460
|
const existingFileMap = new Map(
|
|
42625
|
-
existingFiles.map((f) => [
|
|
42626
|
-
f.metadata?.[WellKnownMetadata.knowledge.URL],
|
|
42627
|
-
f
|
|
42628
|
-
])
|
|
42461
|
+
existingFiles.map((f) => [f.metadata?.[WellKnownMetadata.knowledge.URL], f])
|
|
42629
42462
|
);
|
|
42630
42463
|
const toRemove = existingFiles.filter(
|
|
42631
|
-
(f) => !discoveredUrls.find(
|
|
42632
|
-
(u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL]
|
|
42633
|
-
)
|
|
42464
|
+
(f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
|
|
42634
42465
|
);
|
|
42466
|
+
if (existingFiles.length > 0 && toRemove.length >= existingFiles.length * 0.8) {
|
|
42467
|
+
console.error(
|
|
42468
|
+
`Warning: All existing files (${existingFiles.length}) are scheduled for removal. Please check if the sitemap URL is correct and the website is accessible. We will try again in 5 minutes.`
|
|
42469
|
+
);
|
|
42470
|
+
await step2.sleep("retry wait", 5 * 60 * 1e3);
|
|
42471
|
+
throw new Error("Aborting sync due to potential misconfiguration (all files to be removed)");
|
|
42472
|
+
}
|
|
42635
42473
|
const toFetch = [];
|
|
42636
42474
|
let skippedUnchanged = 0;
|
|
42637
42475
|
for (const url2 of discoveredUrls) {
|
|
@@ -42777,9 +42615,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
42777
42615
|
state: z11.object({}),
|
|
42778
42616
|
handler: async ({ input, step: step2, client }) => {
|
|
42779
42617
|
if (!adk.environment.isDevelopment()) {
|
|
42780
|
-
console.log(
|
|
42781
|
-
"Directory ingestion is only supported in development environment"
|
|
42782
|
-
);
|
|
42618
|
+
console.log("Directory ingestion is only supported in development environment");
|
|
42783
42619
|
return {
|
|
42784
42620
|
added: [],
|
|
42785
42621
|
updated: [],
|
|
@@ -42795,10 +42631,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
42795
42631
|
const path4 = await import("path");
|
|
42796
42632
|
const fs3 = await import("fs/promises");
|
|
42797
42633
|
const crypto3 = await import("crypto");
|
|
42798
|
-
const directory = path4.resolve(
|
|
42799
|
-
adk.environment.agent.directory,
|
|
42800
|
-
this.directoryPath
|
|
42801
|
-
);
|
|
42634
|
+
const directory = path4.resolve(adk.environment.agent.directory, this.directoryPath);
|
|
42802
42635
|
const tags = {
|
|
42803
42636
|
[WellKnownTags.knowledge.KNOWLEDGE]: "true",
|
|
42804
42637
|
[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID]: this.id,
|
|
@@ -42838,11 +42671,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
42838
42671
|
const toRemove = existingFiles.filter(
|
|
42839
42672
|
(f) => !allFiles.find((af) => af.rel === f.metadata?.relPath)
|
|
42840
42673
|
);
|
|
42841
|
-
const toAdd = allFiles.filter(
|
|
42842
|
-
(af) => !existingFiles.find(
|
|
42843
|
-
(f) => f.metadata?.relPath === af.rel
|
|
42844
|
-
)
|
|
42845
|
-
);
|
|
42674
|
+
const toAdd = allFiles.filter((af) => !existingFiles.find((f) => f.metadata?.relPath === af.rel));
|
|
42846
42675
|
const toUpdate = allFiles.filter(
|
|
42847
42676
|
(af) => existingFiles.find((f) => f.metadata?.relPath === af.rel)
|
|
42848
42677
|
);
|
|
@@ -42904,18 +42733,11 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
42904
42733
|
size: uploaded.file.size ?? -1
|
|
42905
42734
|
};
|
|
42906
42735
|
};
|
|
42907
|
-
const added = await step2.map(
|
|
42908
|
-
|
|
42909
|
-
|
|
42910
|
-
|
|
42911
|
-
|
|
42912
|
-
);
|
|
42913
|
-
const updated = await step2.map(
|
|
42914
|
-
"to update files",
|
|
42915
|
-
toUpdate,
|
|
42916
|
-
(f) => upsertFile(f),
|
|
42917
|
-
{ concurrency: 5, maxAttempts: 2 }
|
|
42918
|
-
);
|
|
42736
|
+
const added = await step2.map("to add files", toAdd, (f) => upsertFile(f), { concurrency: 5, maxAttempts: 2 });
|
|
42737
|
+
const updated = await step2.map("to update files", toUpdate, (f) => upsertFile(f), {
|
|
42738
|
+
concurrency: 5,
|
|
42739
|
+
maxAttempts: 2
|
|
42740
|
+
});
|
|
42919
42741
|
return {
|
|
42920
42742
|
processed: allFiles.length,
|
|
42921
42743
|
deleted,
|
|
@@ -42986,10 +42808,7 @@ var BaseConversation = class {
|
|
|
42986
42808
|
const chat = context2.get("chat");
|
|
42987
42809
|
const client = context2.get("client");
|
|
42988
42810
|
const botpressConversation = context2.get("conversation");
|
|
42989
|
-
const conversationInstance = new BaseConversationInstance(
|
|
42990
|
-
botpressConversation,
|
|
42991
|
-
client
|
|
42992
|
-
);
|
|
42811
|
+
const conversationInstance = new BaseConversationInstance(botpressConversation, client);
|
|
42993
42812
|
let type;
|
|
42994
42813
|
let requestObject = void 0;
|
|
42995
42814
|
if (message) {
|
|
@@ -43028,9 +42847,7 @@ var BaseConversation = class {
|
|
|
43028
42847
|
conversationId: conversationInstance.id,
|
|
43029
42848
|
status: "pending"
|
|
43030
42849
|
});
|
|
43031
|
-
const newEvents = events.filter(
|
|
43032
|
-
(e) => e.createdAt > event?.createdAt && e.id !== event?.id
|
|
43033
|
-
);
|
|
42850
|
+
const newEvents = events.filter((e) => e.createdAt > event?.createdAt && e.id !== event?.id);
|
|
43034
42851
|
if (newEvents.length) {
|
|
43035
42852
|
s.setAttributes({
|
|
43036
42853
|
"interruption.detected": true,
|
|
@@ -43058,9 +42875,7 @@ var BaseConversation = class {
|
|
|
43058
42875
|
}
|
|
43059
42876
|
}
|
|
43060
42877
|
if (newEvents.length) {
|
|
43061
|
-
controller.abort(
|
|
43062
|
-
`More messages were received during processing, aborting current processing.`
|
|
43063
|
-
);
|
|
42878
|
+
controller.abort(`More messages were received during processing, aborting current processing.`);
|
|
43064
42879
|
} else {
|
|
43065
42880
|
s.setAttribute("interruption.detected", false);
|
|
43066
42881
|
}
|
|
@@ -43157,9 +42972,7 @@ var BaseKnowledge = class {
|
|
|
43157
42972
|
async refreshSource(sourceId, options) {
|
|
43158
42973
|
const source = this.sources.find((s) => s.id === sourceId);
|
|
43159
42974
|
if (!source) {
|
|
43160
|
-
throw new Error(
|
|
43161
|
-
`Data source with id "${sourceId}" not found in knowledge base "${this.name}"`
|
|
43162
|
-
);
|
|
42975
|
+
throw new Error(`Data source with id "${sourceId}" not found in knowledge base "${this.name}"`);
|
|
43163
42976
|
}
|
|
43164
42977
|
await source.syncWorkflow.getOrCreate({
|
|
43165
42978
|
key: `${this.name}:${sourceId}`,
|
|
@@ -43191,9 +43004,7 @@ var BaseAction = class {
|
|
|
43191
43004
|
handler;
|
|
43192
43005
|
constructor(props) {
|
|
43193
43006
|
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
|
|
43194
|
-
throw new Error(
|
|
43195
|
-
`Action name "${props.name}" must be alphanumeric with no special characters or spaces`
|
|
43196
|
-
);
|
|
43007
|
+
throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
|
|
43197
43008
|
}
|
|
43198
43009
|
this.name = props.name;
|
|
43199
43010
|
if (props.title !== void 0) {
|
|
@@ -43239,9 +43050,7 @@ var BaseAction = class {
|
|
|
43239
43050
|
/**
|
|
43240
43051
|
* Execute the action with input validation and output validation
|
|
43241
43052
|
*/
|
|
43242
|
-
async execute({
|
|
43243
|
-
input
|
|
43244
|
-
}) {
|
|
43053
|
+
async execute({ input }) {
|
|
43245
43054
|
return this.handler(input);
|
|
43246
43055
|
}
|
|
43247
43056
|
};
|
|
@@ -43329,6 +43138,7 @@ var BaseTable = class {
|
|
|
43329
43138
|
for (const col of Object.keys(this.columns)) {
|
|
43330
43139
|
if (this.computedColumns.has(col) || this.nullableColumns.has(col)) {
|
|
43331
43140
|
if ("properties" in schema && schema.properties && col in schema.properties && typeof schema.properties[col] === "object" && schema.properties[col] !== null) {
|
|
43141
|
+
;
|
|
43332
43142
|
schema.properties[col].nullable = true;
|
|
43333
43143
|
}
|
|
43334
43144
|
if ("required" in schema && Array.isArray(schema.required)) {
|
|
@@ -43454,10 +43264,7 @@ var Typings6;
|
|
|
43454
43264
|
Typings8.Primitive = "trigger";
|
|
43455
43265
|
})(Typings6 || (Typings6 = {}));
|
|
43456
43266
|
var TriggerSchema = z15.object({
|
|
43457
|
-
name: z15.string().min(3, "Trigger name must be at least 3 characters").max(255, "Trigger name must be less than 255 characters").regex(
|
|
43458
|
-
/^[a-zA-Z0-9_]+$/,
|
|
43459
|
-
"Trigger name must contain only alphanumeric characters and underscores"
|
|
43460
|
-
),
|
|
43267
|
+
name: z15.string().min(3, "Trigger name must be at least 3 characters").max(255, "Trigger name must be less than 255 characters").regex(/^[a-zA-Z0-9_]+$/, "Trigger name must contain only alphanumeric characters and underscores"),
|
|
43461
43268
|
description: z15.string().max(1024, "Description must be less than 1024 characters").optional(),
|
|
43462
43269
|
events: z15.array(z15.string()),
|
|
43463
43270
|
handler: z15.function().describe("Handler function for the trigger")
|
|
@@ -43470,10 +43277,7 @@ var Trigger = class {
|
|
|
43470
43277
|
constructor(props) {
|
|
43471
43278
|
const result = TriggerSchema.safeParse(props);
|
|
43472
43279
|
if (!result.success) {
|
|
43473
|
-
throw new Errors.InvalidPrimitiveError(
|
|
43474
|
-
"Trigger validation failed",
|
|
43475
|
-
result.error
|
|
43476
|
-
);
|
|
43280
|
+
throw new Errors.InvalidPrimitiveError("Trigger validation failed", result.error);
|
|
43477
43281
|
}
|
|
43478
43282
|
this.name = result.data.name;
|
|
43479
43283
|
this.description = result.data.description;
|
|
@@ -43529,15 +43333,14 @@ init_define_PACKAGE_VERSIONS();
|
|
|
43529
43333
|
// src/globals.ts
|
|
43530
43334
|
init_define_BUILD();
|
|
43531
43335
|
init_define_PACKAGE_VERSIONS();
|
|
43532
|
-
var DefinedGlobalObjects = [
|
|
43533
|
-
"__PACKAGE_VERSIONS__",
|
|
43534
|
-
"__BUILD__"
|
|
43535
|
-
];
|
|
43336
|
+
var DefinedGlobalObjects = ["__PACKAGE_VERSIONS__", "__BUILD__"];
|
|
43536
43337
|
for (const key of Object.keys(DefinedGlobalObjects)) {
|
|
43537
43338
|
if (typeof globalThis[key] === "string") {
|
|
43538
43339
|
try {
|
|
43340
|
+
;
|
|
43539
43341
|
globalThis[key] = JSON.parse(globalThis[key]);
|
|
43540
43342
|
} catch {
|
|
43343
|
+
;
|
|
43541
43344
|
globalThis[key] = DefinedGlobalObjects[key];
|
|
43542
43345
|
}
|
|
43543
43346
|
}
|
|
@@ -43717,10 +43520,7 @@ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
|
43717
43520
|
import { transforms as transforms3 } from "@botpress/sdk";
|
|
43718
43521
|
var DEFAULT_MAX_ATTEMPTS = 5;
|
|
43719
43522
|
var MIN_STEP_REMAINING_TIME_MS = 1e4;
|
|
43720
|
-
var storage2 = getSingleton(
|
|
43721
|
-
"__ADK_GLOBAL_CTX_WORKFLOW_STEP",
|
|
43722
|
-
() => new AsyncLocalStorage3()
|
|
43723
|
-
);
|
|
43523
|
+
var storage2 = getSingleton("__ADK_GLOBAL_CTX_WORKFLOW_STEP", () => new AsyncLocalStorage3());
|
|
43724
43524
|
async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
43725
43525
|
spanFunc,
|
|
43726
43526
|
stepType
|
|
@@ -43738,9 +43538,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
|
43738
43538
|
}
|
|
43739
43539
|
const remainingTime = context2.get("runtime").getRemainingExecutionTimeInMs();
|
|
43740
43540
|
if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
|
|
43741
|
-
await new Promise(
|
|
43742
|
-
(resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
|
|
43743
|
-
);
|
|
43541
|
+
await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
|
|
43744
43542
|
throw createStepSignal();
|
|
43745
43543
|
}
|
|
43746
43544
|
const stepContext = storage2.getStore();
|
|
@@ -43820,13 +43618,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
|
43820
43618
|
}
|
|
43821
43619
|
if (shouldRetry) {
|
|
43822
43620
|
await new Promise(
|
|
43823
|
-
(resolve) => setTimeout(
|
|
43824
|
-
resolve,
|
|
43825
|
-
Math.min(
|
|
43826
|
-
100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1),
|
|
43827
|
-
5e3
|
|
43828
|
-
)
|
|
43829
|
-
)
|
|
43621
|
+
(resolve) => setTimeout(resolve, Math.min(100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1), 5e3))
|
|
43830
43622
|
);
|
|
43831
43623
|
continue;
|
|
43832
43624
|
}
|
|
@@ -43931,10 +43723,7 @@ step.sleep = async (name, ms3) => {
|
|
|
43931
43723
|
);
|
|
43932
43724
|
};
|
|
43933
43725
|
step.sleepUntil = async (name, date) => {
|
|
43934
|
-
const ms3 = Math.max(
|
|
43935
|
-
0,
|
|
43936
|
-
new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS
|
|
43937
|
-
);
|
|
43726
|
+
const ms3 = Math.max(0, new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS);
|
|
43938
43727
|
await step.sleep(name, ms3);
|
|
43939
43728
|
};
|
|
43940
43729
|
step.waitForWorkflow = async (name, workflowId) => {
|
|
@@ -43980,10 +43769,9 @@ step.executeWorkflow = async (name, workflow, input) => _step(
|
|
|
43980
43769
|
// Ensures idempotency
|
|
43981
43770
|
})).id
|
|
43982
43771
|
);
|
|
43983
|
-
return _step(
|
|
43984
|
-
|
|
43985
|
-
|
|
43986
|
-
).then((finishedWorkflow) => finishedWorkflow.output);
|
|
43772
|
+
return _step(`${name}-wait`, async () => step.waitForWorkflow(`${name}-wait`, wfId)).then(
|
|
43773
|
+
(finishedWorkflow) => finishedWorkflow.output
|
|
43774
|
+
);
|
|
43987
43775
|
},
|
|
43988
43776
|
{}
|
|
43989
43777
|
);
|
|
@@ -44000,9 +43788,7 @@ async function processWithConcurrency(items, processor, maxConcurrency = 5) {
|
|
|
44000
43788
|
}
|
|
44001
43789
|
const remainingTime = context2.get("runtime").getRemainingExecutionTimeInMs();
|
|
44002
43790
|
if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
|
|
44003
|
-
await new Promise(
|
|
44004
|
-
(resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
|
|
44005
|
-
);
|
|
43791
|
+
await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
|
|
44006
43792
|
throw createStepSignal();
|
|
44007
43793
|
}
|
|
44008
43794
|
const promise = processor(items[i], i).then((result) => {
|
|
@@ -44070,17 +43856,11 @@ step.request = async (request, message, stepName) => {
|
|
|
44070
43856
|
const workflowControlContext = context2.get("workflowControlContext");
|
|
44071
43857
|
const client = context2.get("client");
|
|
44072
43858
|
if (!workflowControlContext.workflow.conversationId) {
|
|
44073
|
-
throw new Error(
|
|
44074
|
-
`Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`
|
|
44075
|
-
);
|
|
43859
|
+
throw new Error(`Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`);
|
|
44076
43860
|
}
|
|
44077
|
-
const workflowDef = adk.project.workflows.find(
|
|
44078
|
-
(w) => w.name === workflowControlContext.workflow.name
|
|
44079
|
-
);
|
|
43861
|
+
const workflowDef = adk.project.workflows.find((w) => w.name === workflowControlContext.workflow.name);
|
|
44080
43862
|
if (!workflowDef) {
|
|
44081
|
-
throw new Error(
|
|
44082
|
-
`Workflow definition not found for "${workflowControlContext.workflow.name}"`
|
|
44083
|
-
);
|
|
43863
|
+
throw new Error(`Workflow definition not found for "${workflowControlContext.workflow.name}"`);
|
|
44084
43864
|
}
|
|
44085
43865
|
const requestSchema = workflowDef._requestsSchemas?.[request];
|
|
44086
43866
|
if (!requestSchema) {
|
|
@@ -44088,10 +43868,7 @@ step.request = async (request, message, stepName) => {
|
|
|
44088
43868
|
`Request "${request}" not found in workflow "${workflowDef.name}". Available requests: ${Object.keys(workflowDef._requestsSchemas || {}).join(", ") || "none"}`
|
|
44089
43869
|
);
|
|
44090
43870
|
}
|
|
44091
|
-
const state = createWorkflowExecutionState(
|
|
44092
|
-
client._inner,
|
|
44093
|
-
workflowControlContext.workflow.id
|
|
44094
|
-
);
|
|
43871
|
+
const state = createWorkflowExecutionState(client._inner, workflowControlContext.workflow.id);
|
|
44095
43872
|
if (!state.value) {
|
|
44096
43873
|
throw new Error("Workflow execution state not loaded");
|
|
44097
43874
|
}
|
|
@@ -44171,9 +43948,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44171
43948
|
// @internal
|
|
44172
43949
|
TrackedState;
|
|
44173
43950
|
constructor(workflow, client) {
|
|
44174
|
-
const definition = adk.project.workflows.find(
|
|
44175
|
-
(w) => w.name === workflow.name
|
|
44176
|
-
);
|
|
43951
|
+
const definition = adk.project.workflows.find((w) => w.name === workflow.name);
|
|
44177
43952
|
this.TrackedState = TrackedState.create({
|
|
44178
43953
|
type: "workflow",
|
|
44179
43954
|
client: client._inner,
|
|
@@ -44196,9 +43971,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44196
43971
|
const client = context2.get("client");
|
|
44197
43972
|
const workflow = props.workflow ? props.workflow : await client.getWorkflow({ id: props.id }).then((x) => x.workflow);
|
|
44198
43973
|
if (!adk.project.workflows.find((w) => w.name === workflow.name)) {
|
|
44199
|
-
throw new Error(
|
|
44200
|
-
`No ADK Workflow definition found for "${workflow.name}"`
|
|
44201
|
-
);
|
|
43974
|
+
throw new Error(`No ADK Workflow definition found for "${workflow.name}"`);
|
|
44202
43975
|
}
|
|
44203
43976
|
return new _BaseWorkflowInstance(workflow, client);
|
|
44204
43977
|
}
|
|
@@ -44225,10 +43998,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44225
43998
|
*/
|
|
44226
43999
|
async provide(request, data) {
|
|
44227
44000
|
const client = context2.get("client");
|
|
44228
|
-
const state = createWorkflowExecutionState(
|
|
44229
|
-
client._inner,
|
|
44230
|
-
this.id
|
|
44231
|
-
);
|
|
44001
|
+
const state = createWorkflowExecutionState(client._inner, this.id);
|
|
44232
44002
|
await state.load();
|
|
44233
44003
|
if (!state.value) {
|
|
44234
44004
|
throw new Error(`Workflow execution state not found for workflow ${this.id}`);
|
|
@@ -44255,13 +44025,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44255
44025
|
}
|
|
44256
44026
|
// @internal
|
|
44257
44027
|
async handle() {
|
|
44258
|
-
const handler = adk.project.workflows.find(
|
|
44259
|
-
(w) => w.name === this.name
|
|
44260
|
-
)._handler;
|
|
44028
|
+
const handler = adk.project.workflows.find((w) => w.name === this.name)._handler;
|
|
44261
44029
|
if (!handler) {
|
|
44262
|
-
throw new Error(
|
|
44263
|
-
`No ADK Workflow handler found for "${this.name}"`
|
|
44264
|
-
);
|
|
44030
|
+
throw new Error(`No ADK Workflow handler found for "${this.name}"`);
|
|
44265
44031
|
}
|
|
44266
44032
|
await TrackedState.loadAll();
|
|
44267
44033
|
const workflowControlContext = {
|
|
@@ -44286,9 +44052,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44286
44052
|
}
|
|
44287
44053
|
const eventId = context2.get("event")?.id;
|
|
44288
44054
|
if (!eventId) {
|
|
44289
|
-
throw new Error(
|
|
44290
|
-
`Event ID not found in context. Cannot ack workflow ${this.id}`
|
|
44291
|
-
);
|
|
44055
|
+
throw new Error(`Event ID not found in context. Cannot ack workflow ${this.id}`);
|
|
44292
44056
|
}
|
|
44293
44057
|
workflowControlContext.acked = true;
|
|
44294
44058
|
await updateWorkflow({
|
|
@@ -44300,15 +44064,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44300
44064
|
};
|
|
44301
44065
|
try {
|
|
44302
44066
|
const ctx = context2.getAll();
|
|
44303
|
-
const workflowExecutionState = createWorkflowExecutionState(
|
|
44304
|
-
ctx.client._inner,
|
|
44305
|
-
this.id
|
|
44306
|
-
);
|
|
44067
|
+
const workflowExecutionState = createWorkflowExecutionState(ctx.client._inner, this.id);
|
|
44307
44068
|
await workflowExecutionState.load();
|
|
44308
|
-
assert2(
|
|
44309
|
-
workflowExecutionState.value,
|
|
44310
|
-
"Workflow execution state is not loaded"
|
|
44311
|
-
);
|
|
44069
|
+
assert2(workflowExecutionState.value, "Workflow execution state is not loaded");
|
|
44312
44070
|
workflowExecutionState.value.executionCount++;
|
|
44313
44071
|
if (!this.TrackedState.value) {
|
|
44314
44072
|
this.TrackedState.value = {};
|
|
@@ -44475,12 +44233,7 @@ var BaseWorkflow = class {
|
|
|
44475
44233
|
*/
|
|
44476
44234
|
async getOrCreate(props) {
|
|
44477
44235
|
const client = context2.get("client");
|
|
44478
|
-
const statuses = props.statuses || [
|
|
44479
|
-
"pending",
|
|
44480
|
-
"in_progress",
|
|
44481
|
-
"listening",
|
|
44482
|
-
"paused"
|
|
44483
|
-
];
|
|
44236
|
+
const statuses = props.statuses || ["pending", "in_progress", "listening", "paused"];
|
|
44484
44237
|
const validatedInput = this._inputSchema.parse(props.input);
|
|
44485
44238
|
const tags = {};
|
|
44486
44239
|
if (props.key) {
|
|
@@ -44494,9 +44247,7 @@ var BaseWorkflow = class {
|
|
|
44494
44247
|
tags,
|
|
44495
44248
|
conversationId: context2.get("conversation", { optional: true })?.id,
|
|
44496
44249
|
parentWorkflowId: context2.get("workflow", { optional: true })?.id,
|
|
44497
|
-
timeoutAt: new Date(
|
|
44498
|
-
Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
|
|
44499
|
-
).toISOString(),
|
|
44250
|
+
timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString(),
|
|
44500
44251
|
...discriminator && { discriminateBy: { tags: discriminator } }
|
|
44501
44252
|
};
|
|
44502
44253
|
let { workflow } = await client._inner.getOrCreateWorkflow(createArgs);
|
|
@@ -44522,21 +44273,12 @@ var BaseWorkflow = class {
|
|
|
44522
44273
|
async provide(event, data) {
|
|
44523
44274
|
const client = context2.get("client");
|
|
44524
44275
|
const { workflowId, stepName } = event.payload;
|
|
44525
|
-
const state = createWorkflowExecutionState(
|
|
44526
|
-
client._inner,
|
|
44527
|
-
workflowId
|
|
44528
|
-
);
|
|
44276
|
+
const state = createWorkflowExecutionState(client._inner, workflowId);
|
|
44529
44277
|
await state.load();
|
|
44530
44278
|
if (!state.value) {
|
|
44531
|
-
throw new Error(
|
|
44532
|
-
`Workflow execution state not found for workflow ${workflowId}`
|
|
44533
|
-
);
|
|
44279
|
+
throw new Error(`Workflow execution state not found for workflow ${workflowId}`);
|
|
44534
44280
|
}
|
|
44535
|
-
console.log(
|
|
44536
|
-
`Providing data to workflow ${workflowId} step ${stepName}`,
|
|
44537
|
-
data,
|
|
44538
|
-
stepName
|
|
44539
|
-
);
|
|
44281
|
+
console.log(`Providing data to workflow ${workflowId} step ${stepName}`, data, stepName);
|
|
44540
44282
|
if (!state.value.steps[stepName]) {
|
|
44541
44283
|
state.value.steps[stepName] = {
|
|
44542
44284
|
output: data,
|
|
@@ -44568,9 +44310,7 @@ var BaseWorkflow = class {
|
|
|
44568
44310
|
input: validatedInput,
|
|
44569
44311
|
parentWorkflowId: workflow?.id,
|
|
44570
44312
|
conversationId: context2.get("conversation", { optional: true })?.id,
|
|
44571
|
-
timeoutAt: new Date(
|
|
44572
|
-
Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
|
|
44573
|
-
).toISOString()
|
|
44313
|
+
timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString()
|
|
44574
44314
|
});
|
|
44575
44315
|
return await BaseWorkflowInstance.load({
|
|
44576
44316
|
id: res.workflow.id,
|
|
@@ -44662,12 +44402,8 @@ var adk = {
|
|
|
44662
44402
|
config: state.projectConfig,
|
|
44663
44403
|
integrations: Object.assign(state.primitives.integrations, {
|
|
44664
44404
|
get(name) {
|
|
44665
|
-
const byAlias = state.primitives.integrations.find(
|
|
44666
|
-
|
|
44667
|
-
);
|
|
44668
|
-
const byName = state.primitives.integrations.find(
|
|
44669
|
-
(int) => int.definition.name === name
|
|
44670
|
-
);
|
|
44405
|
+
const byAlias = state.primitives.integrations.find((int) => int.alias === name);
|
|
44406
|
+
const byName = state.primitives.integrations.find((int) => int.definition.name === name);
|
|
44671
44407
|
return byAlias || byName;
|
|
44672
44408
|
}
|
|
44673
44409
|
}),
|
|
@@ -44845,15 +44581,7 @@ var IncomingRequestSpan = {
|
|
|
44845
44581
|
},
|
|
44846
44582
|
"request.method": {
|
|
44847
44583
|
type: "enum",
|
|
44848
|
-
enum: [
|
|
44849
|
-
"GET",
|
|
44850
|
-
"POST",
|
|
44851
|
-
"PUT",
|
|
44852
|
-
"DELETE",
|
|
44853
|
-
"PATCH",
|
|
44854
|
-
"HEAD",
|
|
44855
|
-
"OPTIONS"
|
|
44856
|
-
],
|
|
44584
|
+
enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
|
|
44857
44585
|
description: "The HTTP method",
|
|
44858
44586
|
title: "HTTP Method",
|
|
44859
44587
|
required: true
|
|
@@ -45012,14 +44740,7 @@ var BotpressClientSpan = {
|
|
|
45012
44740
|
"botpress.request.body": { type: "string" },
|
|
45013
44741
|
"botpress.response.body": { type: "string" },
|
|
45014
44742
|
"trace.traceparent": { type: "string" },
|
|
45015
|
-
...optional(
|
|
45016
|
-
"conversationId",
|
|
45017
|
-
"messageId",
|
|
45018
|
-
"workflowId",
|
|
45019
|
-
"userId",
|
|
45020
|
-
"eventId",
|
|
45021
|
-
"action.name"
|
|
45022
|
-
)
|
|
44743
|
+
...optional("conversationId", "messageId", "workflowId", "userId", "eventId", "action.name")
|
|
45023
44744
|
}
|
|
45024
44745
|
};
|
|
45025
44746
|
var HttpSpan = {
|
|
@@ -45051,21 +44772,8 @@ var ConversationHandlerSpan = {
|
|
|
45051
44772
|
name: "handler.conversation",
|
|
45052
44773
|
importance: "high",
|
|
45053
44774
|
attributes: {
|
|
45054
|
-
...required(
|
|
45055
|
-
|
|
45056
|
-
"conversationId",
|
|
45057
|
-
"eventId",
|
|
45058
|
-
"integration",
|
|
45059
|
-
"channel",
|
|
45060
|
-
"event.type"
|
|
45061
|
-
),
|
|
45062
|
-
...optional(
|
|
45063
|
-
"messageId",
|
|
45064
|
-
"userId",
|
|
45065
|
-
"event.payload",
|
|
45066
|
-
"message.payload",
|
|
45067
|
-
"message.type"
|
|
45068
|
-
)
|
|
44775
|
+
...required("botId", "conversationId", "eventId", "integration", "channel", "event.type"),
|
|
44776
|
+
...optional("messageId", "userId", "event.payload", "message.payload", "message.type")
|
|
45069
44777
|
}
|
|
45070
44778
|
};
|
|
45071
44779
|
var TriggerHandlerSpan = {
|
|
@@ -45073,15 +44781,7 @@ var TriggerHandlerSpan = {
|
|
|
45073
44781
|
importance: "high",
|
|
45074
44782
|
attributes: {
|
|
45075
44783
|
...required("botId", "eventId", "event.type"),
|
|
45076
|
-
...optional(
|
|
45077
|
-
"conversationId",
|
|
45078
|
-
"messageId",
|
|
45079
|
-
"userId",
|
|
45080
|
-
"integration",
|
|
45081
|
-
"channel",
|
|
45082
|
-
"workflowId",
|
|
45083
|
-
"parentWorkflowId"
|
|
45084
|
-
)
|
|
44784
|
+
...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
|
|
45085
44785
|
}
|
|
45086
44786
|
};
|
|
45087
44787
|
var EventHandlerSpan = {
|
|
@@ -45089,15 +44789,7 @@ var EventHandlerSpan = {
|
|
|
45089
44789
|
importance: "high",
|
|
45090
44790
|
attributes: {
|
|
45091
44791
|
...required("botId", "eventId", "event.type"),
|
|
45092
|
-
...optional(
|
|
45093
|
-
"conversationId",
|
|
45094
|
-
"messageId",
|
|
45095
|
-
"userId",
|
|
45096
|
-
"integration",
|
|
45097
|
-
"channel",
|
|
45098
|
-
"workflowId",
|
|
45099
|
-
"parentWorkflowId"
|
|
45100
|
-
)
|
|
44792
|
+
...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
|
|
45101
44793
|
}
|
|
45102
44794
|
};
|
|
45103
44795
|
var WorkflowHandlerSpan = {
|
|
@@ -45105,27 +44797,11 @@ var WorkflowHandlerSpan = {
|
|
|
45105
44797
|
importance: "high",
|
|
45106
44798
|
attributes: {
|
|
45107
44799
|
...required("botId", "workflowId", "eventId", "event.type"),
|
|
45108
|
-
...optional(
|
|
45109
|
-
"messageId",
|
|
45110
|
-
"userId",
|
|
45111
|
-
"integration",
|
|
45112
|
-
"channel",
|
|
45113
|
-
"conversationId",
|
|
45114
|
-
"parentWorkflowId"
|
|
45115
|
-
),
|
|
44800
|
+
...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
|
|
45116
44801
|
"workflow.name": { type: "string" },
|
|
45117
44802
|
"workflow.status.initial": {
|
|
45118
44803
|
type: "enum",
|
|
45119
|
-
enum: [
|
|
45120
|
-
"pending",
|
|
45121
|
-
"in_progress",
|
|
45122
|
-
"listening",
|
|
45123
|
-
"paused",
|
|
45124
|
-
"completed",
|
|
45125
|
-
"failed",
|
|
45126
|
-
"timedout",
|
|
45127
|
-
"cancelled"
|
|
45128
|
-
]
|
|
44804
|
+
enum: ["pending", "in_progress", "listening", "paused", "completed", "failed", "timedout", "cancelled"]
|
|
45129
44805
|
},
|
|
45130
44806
|
"workflow.status.final": {
|
|
45131
44807
|
type: "enum",
|
|
@@ -45151,14 +44827,7 @@ var ActionHandlerSpan = {
|
|
|
45151
44827
|
importance: "high",
|
|
45152
44828
|
attributes: {
|
|
45153
44829
|
...required("botId", "workflowId", "eventId", "event.type"),
|
|
45154
|
-
...optional(
|
|
45155
|
-
"messageId",
|
|
45156
|
-
"userId",
|
|
45157
|
-
"integration",
|
|
45158
|
-
"channel",
|
|
45159
|
-
"conversationId",
|
|
45160
|
-
"parentWorkflowId"
|
|
45161
|
-
),
|
|
44830
|
+
...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
|
|
45162
44831
|
"action.name": { type: "string", required: true },
|
|
45163
44832
|
"action.input": { type: "json", required: true }
|
|
45164
44833
|
}
|
|
@@ -45543,9 +45212,7 @@ function span(name, attributes, optionsOrF, f) {
|
|
|
45543
45212
|
options = optionsOrF;
|
|
45544
45213
|
handler = f;
|
|
45545
45214
|
}
|
|
45546
|
-
const spanDef = Object.values(Spans).find(
|
|
45547
|
-
(def) => def.name === name
|
|
45548
|
-
);
|
|
45215
|
+
const spanDef = Object.values(Spans).find((def) => def.name === name);
|
|
45549
45216
|
const attrsWithImportance = {
|
|
45550
45217
|
...attributes
|
|
45551
45218
|
};
|
|
@@ -45574,20 +45241,13 @@ function span(name, attributes, optionsOrF, f) {
|
|
|
45574
45241
|
}
|
|
45575
45242
|
};
|
|
45576
45243
|
if (parentContext) {
|
|
45577
|
-
return tracer.startActiveSpan(
|
|
45578
|
-
name,
|
|
45579
|
-
spanOptions,
|
|
45580
|
-
parentContext,
|
|
45581
|
-
executeInSpan
|
|
45582
|
-
);
|
|
45244
|
+
return tracer.startActiveSpan(name, spanOptions, parentContext, executeInSpan);
|
|
45583
45245
|
} else {
|
|
45584
45246
|
return tracer.startActiveSpan(name, spanOptions, executeInSpan);
|
|
45585
45247
|
}
|
|
45586
45248
|
}
|
|
45587
45249
|
var createSpan = (name, attributes, { parentContext } = {}) => {
|
|
45588
|
-
const spanDef = Object.values(Spans).find(
|
|
45589
|
-
(def) => def.name === name
|
|
45590
|
-
);
|
|
45250
|
+
const spanDef = Object.values(Spans).find((def) => def.name === name);
|
|
45591
45251
|
const attrsWithImportance = {
|
|
45592
45252
|
...attributes
|
|
45593
45253
|
};
|
|
@@ -45716,9 +45376,7 @@ var TrackedState = class _TrackedState {
|
|
|
45716
45376
|
}
|
|
45717
45377
|
static create(props) {
|
|
45718
45378
|
const states = context2.get("states", { optional: true });
|
|
45719
|
-
const match2 = states?.find(
|
|
45720
|
-
(x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state")
|
|
45721
|
-
);
|
|
45379
|
+
const match2 = states?.find((x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state"));
|
|
45722
45380
|
if (match2) {
|
|
45723
45381
|
return match2;
|
|
45724
45382
|
}
|
|
@@ -45798,9 +45456,7 @@ var TrackedState = class _TrackedState {
|
|
|
45798
45456
|
});
|
|
45799
45457
|
}
|
|
45800
45458
|
const states = context2.get("states", { optional: true });
|
|
45801
|
-
const promises = Promise.allSettled(
|
|
45802
|
-
states?.map((state) => state.load()) ?? []
|
|
45803
|
-
);
|
|
45459
|
+
const promises = Promise.allSettled(states?.map((state) => state.load()) ?? []);
|
|
45804
45460
|
void importScheduledHeavyImports();
|
|
45805
45461
|
await promises;
|
|
45806
45462
|
});
|
|
@@ -45835,9 +45491,7 @@ var TrackedState = class _TrackedState {
|
|
|
45835
45491
|
const { data } = await axios_default.get(file.url);
|
|
45836
45492
|
this.value = typeof data === "string" ? JSON.parse(data) : data;
|
|
45837
45493
|
} catch (err) {
|
|
45838
|
-
console.error(
|
|
45839
|
-
`Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`
|
|
45840
|
-
);
|
|
45494
|
+
console.error(`Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`);
|
|
45841
45495
|
this.value = void 0;
|
|
45842
45496
|
}
|
|
45843
45497
|
} else {
|
|
@@ -45923,9 +45577,7 @@ var TrackedState = class _TrackedState {
|
|
|
45923
45577
|
contentType: "application/json",
|
|
45924
45578
|
content: JSON.stringify(this.value),
|
|
45925
45579
|
accessPolicies: [],
|
|
45926
|
-
expiresAt: new Date(
|
|
45927
|
-
Date.now() + 30 * 24 * 60 * 60 * 1e3
|
|
45928
|
-
).toISOString(),
|
|
45580
|
+
expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1e3).toISOString(),
|
|
45929
45581
|
tags: {
|
|
45930
45582
|
system: "true",
|
|
45931
45583
|
purpose: "swap"
|
|
@@ -45945,9 +45597,7 @@ var TrackedState = class _TrackedState {
|
|
|
45945
45597
|
error: err instanceof Error ? err.message : String(err),
|
|
45946
45598
|
size_bytes: stateSize
|
|
45947
45599
|
});
|
|
45948
|
-
console.error(
|
|
45949
|
-
`Failed to swap state: ${err instanceof Error ? err.message : String(err)}`
|
|
45950
|
-
);
|
|
45600
|
+
console.error(`Failed to swap state: ${err instanceof Error ? err.message : String(err)}`);
|
|
45951
45601
|
payload = {
|
|
45952
45602
|
value: this.value,
|
|
45953
45603
|
location: { type: "state" }
|