@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/runtime.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
|
|
|
@@ -34297,15 +34297,14 @@ init_define_PACKAGE_VERSIONS();
|
|
|
34297
34297
|
// src/globals.ts
|
|
34298
34298
|
init_define_BUILD();
|
|
34299
34299
|
init_define_PACKAGE_VERSIONS();
|
|
34300
|
-
var DefinedGlobalObjects = [
|
|
34301
|
-
"__PACKAGE_VERSIONS__",
|
|
34302
|
-
"__BUILD__"
|
|
34303
|
-
];
|
|
34300
|
+
var DefinedGlobalObjects = ["__PACKAGE_VERSIONS__", "__BUILD__"];
|
|
34304
34301
|
for (const key of Object.keys(DefinedGlobalObjects)) {
|
|
34305
34302
|
if (typeof globalThis[key] === "string") {
|
|
34306
34303
|
try {
|
|
34304
|
+
;
|
|
34307
34305
|
globalThis[key] = JSON.parse(globalThis[key]);
|
|
34308
34306
|
} catch {
|
|
34307
|
+
;
|
|
34309
34308
|
globalThis[key] = DefinedGlobalObjects[key];
|
|
34310
34309
|
}
|
|
34311
34310
|
}
|
|
@@ -34320,6 +34319,7 @@ init_define_BUILD();
|
|
|
34320
34319
|
init_define_PACKAGE_VERSIONS();
|
|
34321
34320
|
function getSingleton(key, factory2) {
|
|
34322
34321
|
if (!globalThis[key]) {
|
|
34322
|
+
;
|
|
34323
34323
|
globalThis[key] = factory2();
|
|
34324
34324
|
}
|
|
34325
34325
|
return globalThis[key];
|
|
@@ -34583,10 +34583,7 @@ var INDEX_DIR2 = path2.join(DIR2, "index");
|
|
|
34583
34583
|
var append = (o) => fs2.appendFile(LIVE, JSON.stringify(o) + "\n", () => {
|
|
34584
34584
|
});
|
|
34585
34585
|
var appendToDay = (o) => {
|
|
34586
|
-
const dayFile2 = path2.join(
|
|
34587
|
-
DIR2,
|
|
34588
|
-
`${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
|
|
34589
|
-
);
|
|
34586
|
+
const dayFile2 = path2.join(DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
|
|
34590
34587
|
fs2.appendFile(dayFile2, JSON.stringify(o) + "\n", () => {
|
|
34591
34588
|
});
|
|
34592
34589
|
};
|
|
@@ -34596,10 +34593,7 @@ var appendToTrace = (traceId, o) => {
|
|
|
34596
34593
|
});
|
|
34597
34594
|
};
|
|
34598
34595
|
var appendToIndex = (o) => {
|
|
34599
|
-
const indexFile2 = path2.join(
|
|
34600
|
-
INDEX_DIR2,
|
|
34601
|
-
`${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
|
|
34602
|
-
);
|
|
34596
|
+
const indexFile2 = path2.join(INDEX_DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
|
|
34603
34597
|
fs2.appendFile(indexFile2, JSON.stringify(o) + "\n", () => {
|
|
34604
34598
|
});
|
|
34605
34599
|
};
|
|
@@ -34613,8 +34607,7 @@ var LiveFileSpanProcessor = class {
|
|
|
34613
34607
|
this.timer = setInterval(() => {
|
|
34614
34608
|
if (!this.active.size) return;
|
|
34615
34609
|
const ts = nowNs();
|
|
34616
|
-
for (const [spanId, traceId] of this.active)
|
|
34617
|
-
append({ t: "beat", traceId, spanId, ts });
|
|
34610
|
+
for (const [spanId, traceId] of this.active) append({ t: "beat", traceId, spanId, ts });
|
|
34618
34611
|
}, beatMs);
|
|
34619
34612
|
this.timer.unref?.();
|
|
34620
34613
|
}
|
|
@@ -34624,9 +34617,7 @@ var LiveFileSpanProcessor = class {
|
|
|
34624
34617
|
onStart(span2, _ctx) {
|
|
34625
34618
|
const ctx = span2.spanContext();
|
|
34626
34619
|
this.active.set(ctx.spanId, ctx.traceId);
|
|
34627
|
-
const startNs = Number(
|
|
34628
|
-
span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs()
|
|
34629
|
-
);
|
|
34620
|
+
const startNs = Number(span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs());
|
|
34630
34621
|
const startEvent = {
|
|
34631
34622
|
t: "start",
|
|
34632
34623
|
traceId: ctx.traceId,
|
|
@@ -34651,13 +34642,7 @@ var LiveFileSpanProcessor = class {
|
|
|
34651
34642
|
handler: span2.name
|
|
34652
34643
|
// Use span name as handler
|
|
34653
34644
|
};
|
|
34654
|
-
const trackedIds = [
|
|
34655
|
-
"conversationId",
|
|
34656
|
-
"messageId",
|
|
34657
|
-
"eventId",
|
|
34658
|
-
"userId",
|
|
34659
|
-
"workflowId"
|
|
34660
|
-
];
|
|
34645
|
+
const trackedIds = ["conversationId", "messageId", "eventId", "userId", "workflowId"];
|
|
34661
34646
|
for (const idKey of trackedIds) {
|
|
34662
34647
|
if (span2.attributes[idKey]) {
|
|
34663
34648
|
indexEntry[idKey] = span2.attributes[idKey];
|
|
@@ -34759,8 +34744,7 @@ function extractIds(fullUrl, body) {
|
|
|
34759
34744
|
if (userMatch?.[1]) ids.userId = userMatch[1];
|
|
34760
34745
|
if (eventMatch?.[1]) ids.eventId = eventMatch[1];
|
|
34761
34746
|
if (body && typeof body === "object") {
|
|
34762
|
-
if (body.conversationId && !ids.conversationId)
|
|
34763
|
-
ids.conversationId = body.conversationId;
|
|
34747
|
+
if (body.conversationId && !ids.conversationId) ids.conversationId = body.conversationId;
|
|
34764
34748
|
if (body.messageId && !ids.messageId) ids.messageId = body.messageId;
|
|
34765
34749
|
if (body.workflowId && !ids.workflowId) ids.workflowId = body.workflowId;
|
|
34766
34750
|
if (body.userId && !ids.userId) ids.userId = body.userId;
|
|
@@ -34768,9 +34752,7 @@ function extractIds(fullUrl, body) {
|
|
|
34768
34752
|
}
|
|
34769
34753
|
return ids;
|
|
34770
34754
|
}
|
|
34771
|
-
function installHttpClientInstrumentation({
|
|
34772
|
-
injectTraceHeader = true
|
|
34773
|
-
} = {}) {
|
|
34755
|
+
function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
34774
34756
|
const restores = [];
|
|
34775
34757
|
const genId = (n) => randomBytes(n).toString("hex");
|
|
34776
34758
|
const makeTraceparent = () => `00-${genId(16)}-${genId(8)}-01`;
|
|
@@ -34840,8 +34822,7 @@ function installHttpClientInstrumentation({
|
|
|
34840
34822
|
},
|
|
34841
34823
|
context.active()
|
|
34842
34824
|
);
|
|
34843
|
-
if (injectTraceHeader && !("traceparent" in options.headers))
|
|
34844
|
-
options.headers.traceparent = traceparent;
|
|
34825
|
+
if (injectTraceHeader && !("traceparent" in options.headers)) options.headers.traceparent = traceparent;
|
|
34845
34826
|
let req;
|
|
34846
34827
|
if (typeof args[0] === "string" || args[0] instanceof URL) {
|
|
34847
34828
|
req = requestFn.call(this, args[0], options, cb);
|
|
@@ -34863,18 +34844,12 @@ function installHttpClientInstrumentation({
|
|
|
34863
34844
|
}
|
|
34864
34845
|
if (requestBodyChunks.length > 0) {
|
|
34865
34846
|
const bodyString = Buffer.concat(requestBodyChunks).toString("utf-8");
|
|
34866
|
-
span2.setAttribute(
|
|
34867
|
-
isBotpress ? "botpress.request.body" : "http.request.body",
|
|
34868
|
-
bodyString
|
|
34869
|
-
);
|
|
34847
|
+
span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", bodyString);
|
|
34870
34848
|
}
|
|
34871
34849
|
return origEnd(chunk, ...args2);
|
|
34872
34850
|
};
|
|
34873
34851
|
req.on("response", (res) => {
|
|
34874
|
-
span2.setAttribute(
|
|
34875
|
-
isBotpress ? "botpress.status_code" : "http.status_code",
|
|
34876
|
-
res.statusCode || 0
|
|
34877
|
-
);
|
|
34852
|
+
span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", res.statusCode || 0);
|
|
34878
34853
|
const responseBodyChunks = [];
|
|
34879
34854
|
res.on("data", (chunk) => {
|
|
34880
34855
|
responseBodyChunks.push(chunk);
|
|
@@ -34882,10 +34857,7 @@ function installHttpClientInstrumentation({
|
|
|
34882
34857
|
res.on("end", () => {
|
|
34883
34858
|
if (responseBodyChunks.length > 0) {
|
|
34884
34859
|
const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
|
|
34885
|
-
span2.setAttribute(
|
|
34886
|
-
isBotpress ? "botpress.response.body" : "http.response.body",
|
|
34887
|
-
bodyString
|
|
34888
|
-
);
|
|
34860
|
+
span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
|
|
34889
34861
|
}
|
|
34890
34862
|
if ((res.statusCode || 0) >= 400) {
|
|
34891
34863
|
span2.setStatus({
|
|
@@ -34897,10 +34869,7 @@ function installHttpClientInstrumentation({
|
|
|
34897
34869
|
});
|
|
34898
34870
|
});
|
|
34899
34871
|
req.on("error", (err) => {
|
|
34900
|
-
span2.setAttribute(
|
|
34901
|
-
isBotpress ? "botpress.error" : "http.error",
|
|
34902
|
-
err.message
|
|
34903
|
-
);
|
|
34872
|
+
span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
|
|
34904
34873
|
span2.recordException(err);
|
|
34905
34874
|
span2.setStatus({
|
|
34906
34875
|
code: SpanStatusCode.ERROR,
|
|
@@ -34918,6 +34887,7 @@ function installHttpClientInstrumentation({
|
|
|
34918
34887
|
httpsRequest: https.request,
|
|
34919
34888
|
httpsGet: https.get
|
|
34920
34889
|
};
|
|
34890
|
+
;
|
|
34921
34891
|
http.request = wrapRequest2(orig.httpRequest);
|
|
34922
34892
|
https.request = wrapRequest2(orig.httpsRequest);
|
|
34923
34893
|
http.get = function wrappedGet(...a) {
|
|
@@ -35011,10 +34981,7 @@ function installHttpClientInstrumentation({
|
|
|
35011
34981
|
}
|
|
35012
34982
|
}
|
|
35013
34983
|
if (requestBody) {
|
|
35014
|
-
span2.setAttribute(
|
|
35015
|
-
isBotpress ? "botpress.request.body" : "http.request.body",
|
|
35016
|
-
requestBody
|
|
35017
|
-
);
|
|
34984
|
+
span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", requestBody);
|
|
35018
34985
|
}
|
|
35019
34986
|
}
|
|
35020
34987
|
const traceparent = makeTraceparent();
|
|
@@ -35022,10 +34989,7 @@ function installHttpClientInstrumentation({
|
|
|
35022
34989
|
if (Array.isArray(opts.headers)) {
|
|
35023
34990
|
headers.push(...opts.headers);
|
|
35024
34991
|
} else if (opts.headers && typeof opts.headers === "object") {
|
|
35025
|
-
for (const [k, v] of Object.entries(
|
|
35026
|
-
opts.headers
|
|
35027
|
-
))
|
|
35028
|
-
headers.push(k, String(v));
|
|
34992
|
+
for (const [k, v] of Object.entries(opts.headers)) headers.push(k, String(v));
|
|
35029
34993
|
}
|
|
35030
34994
|
headers.push(INSTRUMENTED_HEADER, "true");
|
|
35031
34995
|
if (injectTraceHeader) {
|
|
@@ -35043,10 +35007,7 @@ function installHttpClientInstrumentation({
|
|
|
35043
35007
|
onConnect: handler.onConnect?.bind(handler),
|
|
35044
35008
|
onUpgrade: handler.onUpgrade?.bind(handler),
|
|
35045
35009
|
onHeaders: (statusCode, rawHeaders, resume) => {
|
|
35046
|
-
span2.setAttribute(
|
|
35047
|
-
isBotpress ? "botpress.status_code" : "http.status_code",
|
|
35048
|
-
statusCode
|
|
35049
|
-
);
|
|
35010
|
+
span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", statusCode);
|
|
35050
35011
|
if (statusCode >= 500) {
|
|
35051
35012
|
span2.setStatus({
|
|
35052
35013
|
code: SpanStatusCode.ERROR,
|
|
@@ -35061,10 +35022,7 @@ function installHttpClientInstrumentation({
|
|
|
35061
35022
|
handler.onHeaders?.(statusCode, rawHeaders, resume);
|
|
35062
35023
|
},
|
|
35063
35024
|
onError: (err) => {
|
|
35064
|
-
span2.setAttribute(
|
|
35065
|
-
isBotpress ? "botpress.error" : "http.error",
|
|
35066
|
-
err.message
|
|
35067
|
-
);
|
|
35025
|
+
span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
|
|
35068
35026
|
span2.recordException(err);
|
|
35069
35027
|
span2.setStatus({
|
|
35070
35028
|
code: SpanStatusCode.ERROR,
|
|
@@ -35081,10 +35039,7 @@ function installHttpClientInstrumentation({
|
|
|
35081
35039
|
onComplete: (trailers) => {
|
|
35082
35040
|
if (responseBodyChunks.length > 0) {
|
|
35083
35041
|
const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
|
|
35084
|
-
span2.setAttribute(
|
|
35085
|
-
isBotpress ? "botpress.response.body" : "http.response.body",
|
|
35086
|
-
bodyString
|
|
35087
|
-
);
|
|
35042
|
+
span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
|
|
35088
35043
|
}
|
|
35089
35044
|
span2.end();
|
|
35090
35045
|
handler.onComplete?.(trailers);
|
|
@@ -35164,10 +35119,8 @@ function inspectToJsonSize(input, opts) {
|
|
|
35164
35119
|
if (value === null) return null;
|
|
35165
35120
|
const t = typeof value;
|
|
35166
35121
|
if (t === "boolean" || t === "number") return value;
|
|
35167
|
-
if (t === "string")
|
|
35168
|
-
|
|
35169
|
-
if (t === "bigint")
|
|
35170
|
-
return elideString(String(value), limits2.head, limits2.tail);
|
|
35122
|
+
if (t === "string") return elideString(value, limits2.head, limits2.tail);
|
|
35123
|
+
if (t === "bigint") return elideString(String(value), limits2.head, limits2.tail);
|
|
35171
35124
|
if (t === "symbol" || t === "function" || t === "undefined") {
|
|
35172
35125
|
return null;
|
|
35173
35126
|
}
|
|
@@ -35222,8 +35175,7 @@ function inspectToJsonSize(input, opts) {
|
|
|
35222
35175
|
const k = keys[i];
|
|
35223
35176
|
props[k] = summarize(value[k], seen, nextLimits);
|
|
35224
35177
|
}
|
|
35225
|
-
if (keys.length > keep)
|
|
35226
|
-
props["__truncated__"] = `+${keys.length - keep} keys`;
|
|
35178
|
+
if (keys.length > keep) props["__truncated__"] = `+${keys.length - keep} keys`;
|
|
35227
35179
|
seen.delete(value);
|
|
35228
35180
|
return { [`<${tag}>`]: props };
|
|
35229
35181
|
}
|
|
@@ -35433,10 +35385,7 @@ function getAssetsMetadata() {
|
|
|
35433
35385
|
init_define_BUILD();
|
|
35434
35386
|
init_define_PACKAGE_VERSIONS();
|
|
35435
35387
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
35436
|
-
var storage = getSingleton(
|
|
35437
|
-
"__ADK_GLOBAL_CTX_STORAGE",
|
|
35438
|
-
() => new AsyncLocalStorage2()
|
|
35439
|
-
);
|
|
35388
|
+
var storage = getSingleton("__ADK_GLOBAL_CTX_STORAGE", () => new AsyncLocalStorage2());
|
|
35440
35389
|
var context2 = {
|
|
35441
35390
|
enterWith: (data) => {
|
|
35442
35391
|
storage.enterWith(data);
|
|
@@ -35451,10 +35400,7 @@ var context2 = {
|
|
|
35451
35400
|
},
|
|
35452
35401
|
getAll: () => {
|
|
35453
35402
|
const store = storage.getStore();
|
|
35454
|
-
if (!store)
|
|
35455
|
-
throw new Error(
|
|
35456
|
-
"No context found. Did you forget to call `context.run()`?"
|
|
35457
|
-
);
|
|
35403
|
+
if (!store) throw new Error("No context found. Did you forget to call `context.run()`?");
|
|
35458
35404
|
return store;
|
|
35459
35405
|
},
|
|
35460
35406
|
get: (key, opts) => {
|
|
@@ -35524,10 +35470,7 @@ var InstrumentedCognitive = class _InstrumentedCognitive extends Cognitive {
|
|
|
35524
35470
|
"ai.top_p": input.topP,
|
|
35525
35471
|
"ai.system_length": input.systemPrompt?.length || 0,
|
|
35526
35472
|
"ai.messages_count": input.messages?.length || 0,
|
|
35527
|
-
"ai.input_length": input.messages?.reduce(
|
|
35528
|
-
(acc, m) => acc + (m.content?.length || 0),
|
|
35529
|
-
0
|
|
35530
|
-
) || 0,
|
|
35473
|
+
"ai.input_length": input.messages?.reduce((acc, m) => acc + (m.content?.length || 0), 0) || 0,
|
|
35531
35474
|
"ai.prompt_category": input.meta?.promptCategory,
|
|
35532
35475
|
"ai.prompt_source": input.meta?.promptSource,
|
|
35533
35476
|
"ai.instructions": input.systemPrompt,
|
|
@@ -35540,10 +35483,7 @@ var InstrumentedCognitive = class _InstrumentedCognitive extends Cognitive {
|
|
|
35540
35483
|
s.setAttribute("ai.output_tokens", result.meta.tokens.output || 0);
|
|
35541
35484
|
s.setAttribute("ai.cost_input", result.meta.cost.input || 0);
|
|
35542
35485
|
s.setAttribute("ai.cost_output", result.meta.cost.output || 0);
|
|
35543
|
-
s.setAttribute(
|
|
35544
|
-
"ai.cost",
|
|
35545
|
-
(result.meta.cost.input || 0) + (result.meta.cost.output || 0)
|
|
35546
|
-
);
|
|
35486
|
+
s.setAttribute("ai.cost", (result.meta.cost.input || 0) + (result.meta.cost.output || 0));
|
|
35547
35487
|
s.setAttribute("ai.model", result.meta.model.model);
|
|
35548
35488
|
s.setAttribute("ai.provider", result.meta.model.integration);
|
|
35549
35489
|
return result;
|
|
@@ -35613,9 +35553,7 @@ var getPromiseTracker = () => {
|
|
|
35613
35553
|
if (tracker) {
|
|
35614
35554
|
return tracker;
|
|
35615
35555
|
}
|
|
35616
|
-
throw new Error(
|
|
35617
|
-
"PromiseTracker not found in context. Make sure to initialize it in your runtime setup."
|
|
35618
|
-
);
|
|
35556
|
+
throw new Error("PromiseTracker not found in context. Make sure to initialize it in your runtime setup.");
|
|
35619
35557
|
};
|
|
35620
35558
|
function trackPromise(promise) {
|
|
35621
35559
|
return getPromiseTracker().register(promise);
|
|
@@ -35705,14 +35643,10 @@ function parseHttpRequest(req) {
|
|
|
35705
35643
|
if (!req.headers) {
|
|
35706
35644
|
return void 0;
|
|
35707
35645
|
}
|
|
35708
|
-
const headerKey = Object.keys(req.headers).find(
|
|
35709
|
-
(key) => key.toLowerCase().trim() === name.toLowerCase().trim()
|
|
35710
|
-
);
|
|
35646
|
+
const headerKey = Object.keys(req.headers).find((key) => key.toLowerCase().trim() === name.toLowerCase().trim());
|
|
35711
35647
|
return headerKey ? req.headers[headerKey] : void 0;
|
|
35712
35648
|
};
|
|
35713
|
-
const operation = getHeader(
|
|
35714
|
-
OPERATION_TYPE_HEADER
|
|
35715
|
-
);
|
|
35649
|
+
const operation = getHeader(OPERATION_TYPE_HEADER);
|
|
35716
35650
|
const botId = getHeader(BOT_ID_HEADER) || "unknown";
|
|
35717
35651
|
const botUserId = getHeader(BOT_USER_ID_HEADER) || "";
|
|
35718
35652
|
const webhookId = getHeader(WEBHOOK_ID_HEADER) || "";
|
|
@@ -35735,9 +35669,7 @@ function parseHttpRequest(req) {
|
|
|
35735
35669
|
if (contentType.includes("application/json")) {
|
|
35736
35670
|
body = parseJson(body);
|
|
35737
35671
|
}
|
|
35738
|
-
let configuration = decodeBase64Obj(
|
|
35739
|
-
config || ""
|
|
35740
|
-
);
|
|
35672
|
+
let configuration = decodeBase64Obj(config || "");
|
|
35741
35673
|
if (configuration && typeof configuration === "object" && "payload" in configuration) {
|
|
35742
35674
|
configuration.payload = parseJson(configuration.payload);
|
|
35743
35675
|
}
|
|
@@ -35800,16 +35732,11 @@ var AgentRegistry = class {
|
|
|
35800
35732
|
}
|
|
35801
35733
|
ensureInitialized() {
|
|
35802
35734
|
if (!this._data) {
|
|
35803
|
-
throw new Error(
|
|
35804
|
-
"Agent registry not initialized. Call agentRegistry.initialize() during bot startup."
|
|
35805
|
-
);
|
|
35735
|
+
throw new Error("Agent registry not initialized. Call agentRegistry.initialize() during bot startup.");
|
|
35806
35736
|
}
|
|
35807
35737
|
}
|
|
35808
35738
|
};
|
|
35809
|
-
var agentRegistry = getSingleton(
|
|
35810
|
-
"__ADK_GLOBAL_AGENT_REGISTRY",
|
|
35811
|
-
() => new AgentRegistry()
|
|
35812
|
-
);
|
|
35739
|
+
var agentRegistry = getSingleton("__ADK_GLOBAL_AGENT_REGISTRY", () => new AgentRegistry());
|
|
35813
35740
|
|
|
35814
35741
|
// src/runtime/tracked-state.ts
|
|
35815
35742
|
init_define_BUILD();
|
|
@@ -39607,9 +39534,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
39607
39534
|
init_define_BUILD();
|
|
39608
39535
|
init_define_PACKAGE_VERSIONS();
|
|
39609
39536
|
init_esm();
|
|
39610
|
-
import {
|
|
39611
|
-
getValue
|
|
39612
|
-
} from "llmz";
|
|
39537
|
+
import { getValue } from "llmz";
|
|
39613
39538
|
import {
|
|
39614
39539
|
Tool as LlmzTool,
|
|
39615
39540
|
ThinkSignal as _ThinkSignal,
|
|
@@ -39627,9 +39552,7 @@ init_define_BUILD();
|
|
|
39627
39552
|
init_define_PACKAGE_VERSIONS();
|
|
39628
39553
|
function createJoinedAbortController(signals) {
|
|
39629
39554
|
const controller = new AbortController();
|
|
39630
|
-
const validSignals = signals.filter(
|
|
39631
|
-
(signal) => signal != null
|
|
39632
|
-
);
|
|
39555
|
+
const validSignals = signals.filter((signal) => signal != null);
|
|
39633
39556
|
if (validSignals.length === 0) {
|
|
39634
39557
|
return controller;
|
|
39635
39558
|
}
|
|
@@ -39754,9 +39677,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39754
39677
|
const client = context2.get("client");
|
|
39755
39678
|
const citations = context2.get("citations");
|
|
39756
39679
|
if (!client) {
|
|
39757
|
-
throw new Error(
|
|
39758
|
-
"Client is not available in this context. Make sure to run in a context with a client."
|
|
39759
|
-
);
|
|
39680
|
+
throw new Error("Client is not available in this context. Make sure to run in a context with a client.");
|
|
39760
39681
|
}
|
|
39761
39682
|
const { passages } = await client.searchFiles({
|
|
39762
39683
|
query,
|
|
@@ -39806,9 +39727,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39806
39727
|
citationMetadata.sourceId = tags[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID];
|
|
39807
39728
|
}
|
|
39808
39729
|
const { tag } = citations.registerSource(citationMetadata);
|
|
39809
|
-
message.push(
|
|
39810
|
-
`<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`
|
|
39811
|
-
);
|
|
39730
|
+
message.push(`<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`);
|
|
39812
39731
|
message.push(p.content);
|
|
39813
39732
|
message.push(`</${tag}>`);
|
|
39814
39733
|
}
|
|
@@ -39824,9 +39743,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39824
39743
|
return async (props) => {
|
|
39825
39744
|
const cognitive = context2.get("cognitive");
|
|
39826
39745
|
if (!cognitive) {
|
|
39827
|
-
throw new Error(
|
|
39828
|
-
"Cognitive client is not available in this context. Make sure to run in a cognitive context."
|
|
39829
|
-
);
|
|
39746
|
+
throw new Error("Cognitive client is not available in this context. Make sure to run in a cognitive context.");
|
|
39830
39747
|
}
|
|
39831
39748
|
const defaultTemperature = 0.7;
|
|
39832
39749
|
const maxLoops = import_lodash2.default.clamp(props.iterations ?? 10, 1, 100);
|
|
@@ -39838,10 +39755,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39838
39755
|
"autonomous.mode": options.mode
|
|
39839
39756
|
},
|
|
39840
39757
|
async (execSpan) => {
|
|
39841
|
-
const joinedSignal = createJoinedAbortSignal([
|
|
39842
|
-
props.signal,
|
|
39843
|
-
options.interruption
|
|
39844
|
-
]);
|
|
39758
|
+
const joinedSignal = createJoinedAbortSignal([props.signal, options.interruption]);
|
|
39845
39759
|
const llmz_execute = (await import("llmz")).execute;
|
|
39846
39760
|
const asyncResource = new AsyncResource("autonomous.execution");
|
|
39847
39761
|
const getNewIteration = (index) => createSpan(
|
|
@@ -39859,17 +39773,11 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39859
39773
|
);
|
|
39860
39774
|
const _chat = options.mode === "chat" ? context2.get("chat") : void 0;
|
|
39861
39775
|
if (options.mode === "chat" && !_chat) {
|
|
39862
|
-
throw new Error(
|
|
39863
|
-
"Chat is not available in this context. Make sure to run in chat mode with a chat context."
|
|
39864
|
-
);
|
|
39776
|
+
throw new Error("Chat is not available in this context. Make sure to run in chat mode with a chat context.");
|
|
39865
39777
|
}
|
|
39866
39778
|
const chat = _chat ? {
|
|
39867
|
-
components: bindContext(
|
|
39868
|
-
|
|
39869
|
-
),
|
|
39870
|
-
transcript: bindContext(
|
|
39871
|
-
(ctx) => getValue(_chat.transcript, ctx)
|
|
39872
|
-
),
|
|
39779
|
+
components: bindContext((ctx) => getValue(_chat.components, ctx)),
|
|
39780
|
+
transcript: bindContext((ctx) => getValue(_chat.transcript, ctx)),
|
|
39873
39781
|
handler: bindContext(_chat.handler),
|
|
39874
39782
|
onExecutionDone: bindContext(_chat.onExecutionDone)
|
|
39875
39783
|
} : void 0;
|
|
@@ -39904,10 +39812,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
39904
39812
|
...props.objects && {
|
|
39905
39813
|
objects: async (ctx) => {
|
|
39906
39814
|
const objs = await getValue(props.objects, ctx) ?? [];
|
|
39907
|
-
iterationSpan?.setAttribute(
|
|
39908
|
-
"autonomous.objects",
|
|
39909
|
-
objs.map((o) => o.name).join(", ")
|
|
39910
|
-
);
|
|
39815
|
+
iterationSpan?.setAttribute("autonomous.objects", objs.map((o) => o.name).join(", "));
|
|
39911
39816
|
for (const obj of objs) {
|
|
39912
39817
|
obj.tools = obj.tools?.map(
|
|
39913
39818
|
(tool) => tool.clone({
|
|
@@ -39971,10 +39876,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
39971
39876
|
if (search_knowledge) {
|
|
39972
39877
|
allTools.push(search_knowledge);
|
|
39973
39878
|
}
|
|
39974
|
-
iterationSpan?.setAttribute(
|
|
39975
|
-
"autonomous.tools",
|
|
39976
|
-
allTools?.map((t) => t.name).join(", ")
|
|
39977
|
-
);
|
|
39879
|
+
iterationSpan?.setAttribute("autonomous.tools", allTools?.map((t) => t.name).join(", "));
|
|
39978
39880
|
return allTools.map(
|
|
39979
39881
|
(tool) => tool.clone({
|
|
39980
39882
|
handler: asyncResource.bind((args, ctx2) => {
|
|
@@ -40036,9 +39938,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40036
39938
|
onAfterTool: asyncResource.bind(props.hooks.onAfterTool)
|
|
40037
39939
|
},
|
|
40038
39940
|
...props.hooks?.onBeforeExecution && {
|
|
40039
|
-
onBeforeExecution: asyncResource.bind(
|
|
40040
|
-
props.hooks.onBeforeExecution
|
|
40041
|
-
)
|
|
39941
|
+
onBeforeExecution: asyncResource.bind(props.hooks.onBeforeExecution)
|
|
40042
39942
|
},
|
|
40043
39943
|
...props.hooks?.onExit && {
|
|
40044
39944
|
onExit: asyncResource.bind(props.hooks.onExit)
|
|
@@ -40057,9 +39957,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40057
39957
|
});
|
|
40058
39958
|
}
|
|
40059
39959
|
if (props.hooks?.onTrace) {
|
|
40060
|
-
return asyncResource.runInAsyncScope(
|
|
40061
|
-
() => props.hooks.onTrace({ trace: trace2, iteration })
|
|
40062
|
-
);
|
|
39960
|
+
return asyncResource.runInAsyncScope(() => props.hooks.onTrace({ trace: trace2, iteration }));
|
|
40063
39961
|
}
|
|
40064
39962
|
},
|
|
40065
39963
|
onIterationEnd: async (iteration, controller) => {
|
|
@@ -40085,9 +39983,7 @@ ${iteration.status.execution_error.stack}`;
|
|
|
40085
39983
|
} else if (iteration.status.type === "invalid_code_error") {
|
|
40086
39984
|
message = `Iteration failed due to invalid code: ${iteration.status.invalid_code_error.message}`;
|
|
40087
39985
|
}
|
|
40088
|
-
iterationSpan?.recordException(
|
|
40089
|
-
iteration.error ?? new Error(message)
|
|
40090
|
-
);
|
|
39986
|
+
iterationSpan?.recordException(iteration.error ?? new Error(message));
|
|
40091
39987
|
iterationSpan?.setStatus({
|
|
40092
39988
|
code: SpanStatusCode.ERROR,
|
|
40093
39989
|
message
|
|
@@ -40109,16 +40005,11 @@ ${iteration.status.execution_error.stack}`;
|
|
|
40109
40005
|
}
|
|
40110
40006
|
iterationSpan?.end();
|
|
40111
40007
|
if (props.hooks?.onIterationEnd) {
|
|
40112
|
-
return await asyncResource.runInAsyncScope(
|
|
40113
|
-
() => props.hooks.onIterationEnd(iteration, controller)
|
|
40114
|
-
);
|
|
40008
|
+
return await asyncResource.runInAsyncScope(() => props.hooks.onIterationEnd(iteration, controller));
|
|
40115
40009
|
}
|
|
40116
40010
|
}
|
|
40117
40011
|
});
|
|
40118
|
-
execSpan.setAttribute(
|
|
40119
|
-
"autonomous.execution_id",
|
|
40120
|
-
execution.context.id
|
|
40121
|
-
);
|
|
40012
|
+
execSpan.setAttribute("autonomous.execution_id", execution.context.id);
|
|
40122
40013
|
return execution;
|
|
40123
40014
|
}
|
|
40124
40015
|
);
|
|
@@ -40161,22 +40052,16 @@ var actions = new Proxy({}, {
|
|
|
40161
40052
|
}
|
|
40162
40053
|
integrations ??= context2.get("integrations", { optional: true });
|
|
40163
40054
|
client ??= context2.get("client", { optional: true });
|
|
40164
|
-
const integration = integrations.find(
|
|
40165
|
-
(i) => i.alias === integrationName
|
|
40166
|
-
);
|
|
40055
|
+
const integration = integrations.find((i) => i.alias === integrationName);
|
|
40167
40056
|
const actionDef = integration?.definition.actions?.[actionName];
|
|
40168
40057
|
const handler = async (params) => {
|
|
40169
40058
|
integrations ??= context2.get("integrations", { optional: true });
|
|
40170
40059
|
client ??= context2.get("client", { optional: true });
|
|
40171
40060
|
if (!integration || !actionDef) {
|
|
40172
|
-
throw new Error(
|
|
40173
|
-
`Could not find integration "${integrationName}" and action "${actionName}"`
|
|
40174
|
-
);
|
|
40061
|
+
throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
|
|
40175
40062
|
}
|
|
40176
40063
|
if (!integration.definition.actions?.[actionName]) {
|
|
40177
|
-
throw new Error(
|
|
40178
|
-
`Action "${actionName}" not found in integration "${integrationName}"`
|
|
40179
|
-
);
|
|
40064
|
+
throw new Error(`Action "${actionName}" not found in integration "${integrationName}"`);
|
|
40180
40065
|
}
|
|
40181
40066
|
return client.callAction({
|
|
40182
40067
|
type: `${integration.alias}:${actionName}`,
|
|
@@ -40185,9 +40070,7 @@ var actions = new Proxy({}, {
|
|
|
40185
40070
|
};
|
|
40186
40071
|
handler.asTool = () => {
|
|
40187
40072
|
if (!integration || !actionDef) {
|
|
40188
|
-
throw new Error(
|
|
40189
|
-
`Could not find integration "${integrationName}" and action "${actionName}"`
|
|
40190
|
-
);
|
|
40073
|
+
throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
|
|
40191
40074
|
}
|
|
40192
40075
|
return new Autonomous.Tool({
|
|
40193
40076
|
name: actionName,
|
|
@@ -40205,9 +40088,7 @@ var actions = new Proxy({}, {
|
|
|
40205
40088
|
optional: true
|
|
40206
40089
|
});
|
|
40207
40090
|
if (!integrations2) return [];
|
|
40208
|
-
const integration = integrations2.find(
|
|
40209
|
-
(i) => i.alias === integrationName
|
|
40210
|
-
);
|
|
40091
|
+
const integration = integrations2.find((i) => i.alias === integrationName);
|
|
40211
40092
|
if (!integration?.definition?.actions) return [];
|
|
40212
40093
|
return Object.keys(integration.definition.actions);
|
|
40213
40094
|
} catch {
|
|
@@ -40220,9 +40101,7 @@ var actions = new Proxy({}, {
|
|
|
40220
40101
|
optional: true
|
|
40221
40102
|
});
|
|
40222
40103
|
if (!integrations2) return false;
|
|
40223
|
-
const integration = integrations2.find(
|
|
40224
|
-
(i) => i.alias === integrationName
|
|
40225
|
-
);
|
|
40104
|
+
const integration = integrations2.find((i) => i.alias === integrationName);
|
|
40226
40105
|
return !!integration?.definition?.actions?.[actionName];
|
|
40227
40106
|
} catch {
|
|
40228
40107
|
return false;
|
|
@@ -40530,11 +40409,7 @@ var BaseConversationInstance = class {
|
|
|
40530
40409
|
* Start typing indicator
|
|
40531
40410
|
*/
|
|
40532
40411
|
async startTyping() {
|
|
40533
|
-
const mapping = InterfaceMappings.getIntegrationAction(
|
|
40534
|
-
"typingIndicator",
|
|
40535
|
-
"startTypingIndicator",
|
|
40536
|
-
this.integration
|
|
40537
|
-
);
|
|
40412
|
+
const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "startTypingIndicator", this.integration);
|
|
40538
40413
|
if (mapping) {
|
|
40539
40414
|
const message = context2.get("message", { optional: true });
|
|
40540
40415
|
await this.client.callAction({
|
|
@@ -40551,11 +40426,7 @@ var BaseConversationInstance = class {
|
|
|
40551
40426
|
* Stop typing indicator
|
|
40552
40427
|
*/
|
|
40553
40428
|
async stopTyping() {
|
|
40554
|
-
const mapping = InterfaceMappings.getIntegrationAction(
|
|
40555
|
-
"typingIndicator",
|
|
40556
|
-
"stopTypingIndicator",
|
|
40557
|
-
this.integration
|
|
40558
|
-
);
|
|
40429
|
+
const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "stopTypingIndicator", this.integration);
|
|
40559
40430
|
if (mapping) {
|
|
40560
40431
|
const message = context2.get("message", { optional: true });
|
|
40561
40432
|
await this.client.callAction({
|
|
@@ -40631,10 +40502,7 @@ var Definitions;
|
|
|
40631
40502
|
});
|
|
40632
40503
|
const actionDefinitionSchema = z3.object({
|
|
40633
40504
|
type: z3.literal("action"),
|
|
40634
|
-
name: z3.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(
|
|
40635
|
-
/^[a-zA-Z][a-zA-Z0-9]*$/,
|
|
40636
|
-
"Name must be alphanumeric with no special characters"
|
|
40637
|
-
),
|
|
40505
|
+
name: z3.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"),
|
|
40638
40506
|
title: z3.string().optional(),
|
|
40639
40507
|
description: z3.string().optional(),
|
|
40640
40508
|
attributes: z3.record(z3.string()).optional(),
|
|
@@ -40735,9 +40603,7 @@ var createSyncWorkflow = (props) => new BaseWorkflow({
|
|
|
40735
40603
|
}
|
|
40736
40604
|
const source = kb.sources.find((s) => s.id === sourceId);
|
|
40737
40605
|
if (!source) {
|
|
40738
|
-
throw new Error(
|
|
40739
|
-
`Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`
|
|
40740
|
-
);
|
|
40606
|
+
throw new Error(`Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`);
|
|
40741
40607
|
}
|
|
40742
40608
|
console.log(
|
|
40743
40609
|
`\u{1F504} Starting sync for data source '${sourceId}' of type '${source.type}' in knowledge base '${kbName}'`
|
|
@@ -42277,17 +42143,8 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42277
42143
|
this.urls = options.urls ?? void 0;
|
|
42278
42144
|
this.filterFn = "filter" in options ? options.filter : void 0;
|
|
42279
42145
|
this.customFetch = options.fetch ?? void 0;
|
|
42280
|
-
this.maxPages = Math.max(
|
|
42281
|
-
|
|
42282
|
-
Math.min(
|
|
42283
|
-
("maxPages" in options ? options.maxPages : void 0) ?? 5e4,
|
|
42284
|
-
5e4
|
|
42285
|
-
)
|
|
42286
|
-
);
|
|
42287
|
-
this.maxDepth = Math.max(
|
|
42288
|
-
1,
|
|
42289
|
-
Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20)
|
|
42290
|
-
);
|
|
42146
|
+
this.maxPages = Math.max(1, Math.min(("maxPages" in options ? options.maxPages : void 0) ?? 5e4, 5e4));
|
|
42147
|
+
this.maxDepth = Math.max(1, Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20));
|
|
42291
42148
|
}
|
|
42292
42149
|
isBrowserIntegrationAvailable() {
|
|
42293
42150
|
return !!adk.project.integrations.get("browser");
|
|
@@ -42451,9 +42308,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42451
42308
|
}
|
|
42452
42309
|
return passed;
|
|
42453
42310
|
});
|
|
42454
|
-
console.log(
|
|
42455
|
-
`Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`
|
|
42456
|
-
);
|
|
42311
|
+
console.log(`Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`);
|
|
42457
42312
|
}
|
|
42458
42313
|
return filteredUrls.map((url2) => ({ loc: url2 }));
|
|
42459
42314
|
}
|
|
@@ -42485,20 +42340,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42485
42340
|
await step2(`processing sitemap ${item.url}`, async () => {
|
|
42486
42341
|
try {
|
|
42487
42342
|
const { content, contentType } = await this.fetchSitemap(item.url);
|
|
42488
|
-
console.log(
|
|
42489
|
-
`Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`
|
|
42490
|
-
);
|
|
42343
|
+
console.log(`Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`);
|
|
42491
42344
|
console.log(content, contentType);
|
|
42492
42345
|
try {
|
|
42493
42346
|
const { urls, sitemaps } = this.parseSitemapXml(content);
|
|
42494
|
-
console.log(
|
|
42495
|
-
`Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`
|
|
42496
|
-
);
|
|
42347
|
+
console.log(`Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`);
|
|
42497
42348
|
for (const url2 of urls) {
|
|
42498
42349
|
if (state.urls.length >= this.maxPages) {
|
|
42499
|
-
console.log(
|
|
42500
|
-
`Reached maxPages limit (${this.maxPages}), stopping URL discovery`
|
|
42501
|
-
);
|
|
42350
|
+
console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
|
|
42502
42351
|
break;
|
|
42503
42352
|
}
|
|
42504
42353
|
const filterContext = {
|
|
@@ -42519,20 +42368,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42519
42368
|
state.queue.push({ url: sitemapUrl, depth: item.depth + 1 });
|
|
42520
42369
|
}
|
|
42521
42370
|
} else if (sitemaps.length > 0) {
|
|
42522
|
-
console.log(
|
|
42523
|
-
`Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`
|
|
42524
|
-
);
|
|
42371
|
+
console.log(`Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`);
|
|
42525
42372
|
}
|
|
42526
42373
|
} catch (xmlErr) {
|
|
42527
|
-
console.log(
|
|
42528
|
-
`XML parsing failed for ${item.url}, trying TXT format...`
|
|
42529
|
-
);
|
|
42374
|
+
console.log(`XML parsing failed for ${item.url}, trying TXT format...`);
|
|
42530
42375
|
const { urls } = this.parseSitemapTxt(content);
|
|
42531
42376
|
for (const url2 of urls) {
|
|
42532
42377
|
if (state.urls.length >= this.maxPages) {
|
|
42533
|
-
console.log(
|
|
42534
|
-
`Reached maxPages limit (${this.maxPages}), stopping URL discovery`
|
|
42535
|
-
);
|
|
42378
|
+
console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
|
|
42536
42379
|
break;
|
|
42537
42380
|
}
|
|
42538
42381
|
const filterContext = { url: url2.loc };
|
|
@@ -42550,13 +42393,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42550
42393
|
}
|
|
42551
42394
|
});
|
|
42552
42395
|
}
|
|
42553
|
-
console.log(
|
|
42554
|
-
`URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`
|
|
42555
|
-
);
|
|
42396
|
+
console.log(`URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`);
|
|
42556
42397
|
if (state.urls.length >= this.maxPages) {
|
|
42557
|
-
console.log(
|
|
42558
|
-
`Note: Discovery stopped at maxPages limit (${this.maxPages})`
|
|
42559
|
-
);
|
|
42398
|
+
console.log(`Note: Discovery stopped at maxPages limit (${this.maxPages})`);
|
|
42560
42399
|
}
|
|
42561
42400
|
return state.urls.slice(0, this.maxPages);
|
|
42562
42401
|
}
|
|
@@ -42569,13 +42408,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42569
42408
|
console.log(
|
|
42570
42409
|
`Starting sync for WebsiteSource [${this.id}] in mode [${this.mode}, maxPages=${this.maxPages}, maxDepth=${this.maxDepth}, baseUrl=${this.baseUrl}, sitemapUrl=${this.sitemapUrl}]`
|
|
42571
42410
|
);
|
|
42572
|
-
console.log(
|
|
42573
|
-
`Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`
|
|
42574
|
-
);
|
|
42411
|
+
console.log(`Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`);
|
|
42575
42412
|
if (input.force) {
|
|
42576
|
-
console.log(
|
|
42577
|
-
"\u{1F504} FORCE MODE: Re-indexing all files regardless of changes"
|
|
42578
|
-
);
|
|
42413
|
+
console.log("\u{1F504} FORCE MODE: Re-indexing all files regardless of changes");
|
|
42579
42414
|
}
|
|
42580
42415
|
const tags = {
|
|
42581
42416
|
[WellKnownTags.knowledge.KNOWLEDGE]: "true",
|
|
@@ -42583,10 +42418,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42583
42418
|
[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_TYPE]: this.type,
|
|
42584
42419
|
[WellKnownTags.knowledge.KNOWLEDGE_BASE_NAME]: input.kbName
|
|
42585
42420
|
};
|
|
42586
|
-
const discoveredUrls = await step2(
|
|
42587
|
-
"discover urls from sitemap",
|
|
42588
|
-
() => this.discoverUrls(step2, state)
|
|
42589
|
-
);
|
|
42421
|
+
const discoveredUrls = await step2("discover urls from sitemap", () => this.discoverUrls(step2, state));
|
|
42590
42422
|
console.log(`Discovered ${discoveredUrls.length} URLs from sitemap`);
|
|
42591
42423
|
console.log(`Will process up to ${this.maxPages} pages`);
|
|
42592
42424
|
const existingFiles = await step2(
|
|
@@ -42596,16 +42428,18 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
42596
42428
|
}).collect()
|
|
42597
42429
|
);
|
|
42598
42430
|
const existingFileMap = new Map(
|
|
42599
|
-
existingFiles.map((f) => [
|
|
42600
|
-
f.metadata?.[WellKnownMetadata.knowledge.URL],
|
|
42601
|
-
f
|
|
42602
|
-
])
|
|
42431
|
+
existingFiles.map((f) => [f.metadata?.[WellKnownMetadata.knowledge.URL], f])
|
|
42603
42432
|
);
|
|
42604
42433
|
const toRemove = existingFiles.filter(
|
|
42605
|
-
(f) => !discoveredUrls.find(
|
|
42606
|
-
(u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL]
|
|
42607
|
-
)
|
|
42434
|
+
(f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
|
|
42608
42435
|
);
|
|
42436
|
+
if (existingFiles.length > 0 && toRemove.length >= existingFiles.length * 0.8) {
|
|
42437
|
+
console.error(
|
|
42438
|
+
`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.`
|
|
42439
|
+
);
|
|
42440
|
+
await step2.sleep("retry wait", 5 * 60 * 1e3);
|
|
42441
|
+
throw new Error("Aborting sync due to potential misconfiguration (all files to be removed)");
|
|
42442
|
+
}
|
|
42609
42443
|
const toFetch = [];
|
|
42610
42444
|
let skippedUnchanged = 0;
|
|
42611
42445
|
for (const url2 of discoveredUrls) {
|
|
@@ -42751,9 +42585,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
42751
42585
|
state: z7.object({}),
|
|
42752
42586
|
handler: async ({ input, step: step2, client }) => {
|
|
42753
42587
|
if (!adk.environment.isDevelopment()) {
|
|
42754
|
-
console.log(
|
|
42755
|
-
"Directory ingestion is only supported in development environment"
|
|
42756
|
-
);
|
|
42588
|
+
console.log("Directory ingestion is only supported in development environment");
|
|
42757
42589
|
return {
|
|
42758
42590
|
added: [],
|
|
42759
42591
|
updated: [],
|
|
@@ -42769,10 +42601,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
42769
42601
|
const path4 = await import("path");
|
|
42770
42602
|
const fs3 = await import("fs/promises");
|
|
42771
42603
|
const crypto3 = await import("crypto");
|
|
42772
|
-
const directory = path4.resolve(
|
|
42773
|
-
adk.environment.agent.directory,
|
|
42774
|
-
this.directoryPath
|
|
42775
|
-
);
|
|
42604
|
+
const directory = path4.resolve(adk.environment.agent.directory, this.directoryPath);
|
|
42776
42605
|
const tags = {
|
|
42777
42606
|
[WellKnownTags.knowledge.KNOWLEDGE]: "true",
|
|
42778
42607
|
[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID]: this.id,
|
|
@@ -42812,11 +42641,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
42812
42641
|
const toRemove = existingFiles.filter(
|
|
42813
42642
|
(f) => !allFiles.find((af) => af.rel === f.metadata?.relPath)
|
|
42814
42643
|
);
|
|
42815
|
-
const toAdd = allFiles.filter(
|
|
42816
|
-
(af) => !existingFiles.find(
|
|
42817
|
-
(f) => f.metadata?.relPath === af.rel
|
|
42818
|
-
)
|
|
42819
|
-
);
|
|
42644
|
+
const toAdd = allFiles.filter((af) => !existingFiles.find((f) => f.metadata?.relPath === af.rel));
|
|
42820
42645
|
const toUpdate = allFiles.filter(
|
|
42821
42646
|
(af) => existingFiles.find((f) => f.metadata?.relPath === af.rel)
|
|
42822
42647
|
);
|
|
@@ -42878,18 +42703,11 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
42878
42703
|
size: uploaded.file.size ?? -1
|
|
42879
42704
|
};
|
|
42880
42705
|
};
|
|
42881
|
-
const added = await step2.map(
|
|
42882
|
-
|
|
42883
|
-
|
|
42884
|
-
|
|
42885
|
-
|
|
42886
|
-
);
|
|
42887
|
-
const updated = await step2.map(
|
|
42888
|
-
"to update files",
|
|
42889
|
-
toUpdate,
|
|
42890
|
-
(f) => upsertFile(f),
|
|
42891
|
-
{ concurrency: 5, maxAttempts: 2 }
|
|
42892
|
-
);
|
|
42706
|
+
const added = await step2.map("to add files", toAdd, (f) => upsertFile(f), { concurrency: 5, maxAttempts: 2 });
|
|
42707
|
+
const updated = await step2.map("to update files", toUpdate, (f) => upsertFile(f), {
|
|
42708
|
+
concurrency: 5,
|
|
42709
|
+
maxAttempts: 2
|
|
42710
|
+
});
|
|
42893
42711
|
return {
|
|
42894
42712
|
processed: allFiles.length,
|
|
42895
42713
|
deleted,
|
|
@@ -42979,10 +42797,7 @@ var BaseConversation = class {
|
|
|
42979
42797
|
const chat = context2.get("chat");
|
|
42980
42798
|
const client = context2.get("client");
|
|
42981
42799
|
const botpressConversation = context2.get("conversation");
|
|
42982
|
-
const conversationInstance = new BaseConversationInstance(
|
|
42983
|
-
botpressConversation,
|
|
42984
|
-
client
|
|
42985
|
-
);
|
|
42800
|
+
const conversationInstance = new BaseConversationInstance(botpressConversation, client);
|
|
42986
42801
|
let type;
|
|
42987
42802
|
let requestObject = void 0;
|
|
42988
42803
|
if (message) {
|
|
@@ -43021,9 +42836,7 @@ var BaseConversation = class {
|
|
|
43021
42836
|
conversationId: conversationInstance.id,
|
|
43022
42837
|
status: "pending"
|
|
43023
42838
|
});
|
|
43024
|
-
const newEvents = events.filter(
|
|
43025
|
-
(e) => e.createdAt > event?.createdAt && e.id !== event?.id
|
|
43026
|
-
);
|
|
42839
|
+
const newEvents = events.filter((e) => e.createdAt > event?.createdAt && e.id !== event?.id);
|
|
43027
42840
|
if (newEvents.length) {
|
|
43028
42841
|
s.setAttributes({
|
|
43029
42842
|
"interruption.detected": true,
|
|
@@ -43051,9 +42864,7 @@ var BaseConversation = class {
|
|
|
43051
42864
|
}
|
|
43052
42865
|
}
|
|
43053
42866
|
if (newEvents.length) {
|
|
43054
|
-
controller.abort(
|
|
43055
|
-
`More messages were received during processing, aborting current processing.`
|
|
43056
|
-
);
|
|
42867
|
+
controller.abort(`More messages were received during processing, aborting current processing.`);
|
|
43057
42868
|
} else {
|
|
43058
42869
|
s.setAttribute("interruption.detected", false);
|
|
43059
42870
|
}
|
|
@@ -43150,9 +42961,7 @@ var BaseKnowledge = class {
|
|
|
43150
42961
|
async refreshSource(sourceId, options) {
|
|
43151
42962
|
const source = this.sources.find((s) => s.id === sourceId);
|
|
43152
42963
|
if (!source) {
|
|
43153
|
-
throw new Error(
|
|
43154
|
-
`Data source with id "${sourceId}" not found in knowledge base "${this.name}"`
|
|
43155
|
-
);
|
|
42964
|
+
throw new Error(`Data source with id "${sourceId}" not found in knowledge base "${this.name}"`);
|
|
43156
42965
|
}
|
|
43157
42966
|
await source.syncWorkflow.getOrCreate({
|
|
43158
42967
|
key: `${this.name}:${sourceId}`,
|
|
@@ -43184,9 +42993,7 @@ var BaseAction = class {
|
|
|
43184
42993
|
handler;
|
|
43185
42994
|
constructor(props) {
|
|
43186
42995
|
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
|
|
43187
|
-
throw new Error(
|
|
43188
|
-
`Action name "${props.name}" must be alphanumeric with no special characters or spaces`
|
|
43189
|
-
);
|
|
42996
|
+
throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
|
|
43190
42997
|
}
|
|
43191
42998
|
this.name = props.name;
|
|
43192
42999
|
if (props.title !== void 0) {
|
|
@@ -43232,9 +43039,7 @@ var BaseAction = class {
|
|
|
43232
43039
|
/**
|
|
43233
43040
|
* Execute the action with input validation and output validation
|
|
43234
43041
|
*/
|
|
43235
|
-
async execute({
|
|
43236
|
-
input
|
|
43237
|
-
}) {
|
|
43042
|
+
async execute({ input }) {
|
|
43238
43043
|
return this.handler(input);
|
|
43239
43044
|
}
|
|
43240
43045
|
};
|
|
@@ -43322,6 +43127,7 @@ var BaseTable = class {
|
|
|
43322
43127
|
for (const col of Object.keys(this.columns)) {
|
|
43323
43128
|
if (this.computedColumns.has(col) || this.nullableColumns.has(col)) {
|
|
43324
43129
|
if ("properties" in schema && schema.properties && col in schema.properties && typeof schema.properties[col] === "object" && schema.properties[col] !== null) {
|
|
43130
|
+
;
|
|
43325
43131
|
schema.properties[col].nullable = true;
|
|
43326
43132
|
}
|
|
43327
43133
|
if ("required" in schema && Array.isArray(schema.required)) {
|
|
@@ -43447,10 +43253,7 @@ var Typings6;
|
|
|
43447
43253
|
Typings8.Primitive = "trigger";
|
|
43448
43254
|
})(Typings6 || (Typings6 = {}));
|
|
43449
43255
|
var TriggerSchema = z11.object({
|
|
43450
|
-
name: z11.string().min(3, "Trigger name must be at least 3 characters").max(255, "Trigger name must be less than 255 characters").regex(
|
|
43451
|
-
/^[a-zA-Z0-9_]+$/,
|
|
43452
|
-
"Trigger name must contain only alphanumeric characters and underscores"
|
|
43453
|
-
),
|
|
43256
|
+
name: z11.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"),
|
|
43454
43257
|
description: z11.string().max(1024, "Description must be less than 1024 characters").optional(),
|
|
43455
43258
|
events: z11.array(z11.string()),
|
|
43456
43259
|
handler: z11.function().describe("Handler function for the trigger")
|
|
@@ -43463,10 +43266,7 @@ var Trigger = class {
|
|
|
43463
43266
|
constructor(props) {
|
|
43464
43267
|
const result = TriggerSchema.safeParse(props);
|
|
43465
43268
|
if (!result.success) {
|
|
43466
|
-
throw new Errors.InvalidPrimitiveError(
|
|
43467
|
-
"Trigger validation failed",
|
|
43468
|
-
result.error
|
|
43469
|
-
);
|
|
43269
|
+
throw new Errors.InvalidPrimitiveError("Trigger validation failed", result.error);
|
|
43470
43270
|
}
|
|
43471
43271
|
this.name = result.data.name;
|
|
43472
43272
|
this.description = result.data.description;
|
|
@@ -43552,9 +43352,7 @@ var bot = {
|
|
|
43552
43352
|
get state() {
|
|
43553
43353
|
const botId = context2.get("botId");
|
|
43554
43354
|
const states = context2.get("states", { optional: true }) ?? [];
|
|
43555
|
-
const state = states.find(
|
|
43556
|
-
(x) => x.type === "bot" && x.name === "botState" && x.id === botId
|
|
43557
|
-
);
|
|
43355
|
+
const state = states.find((x) => x.type === "bot" && x.name === "botState" && x.id === botId);
|
|
43558
43356
|
if (!state) {
|
|
43559
43357
|
throw new Error("Bot state not initialized.");
|
|
43560
43358
|
}
|
|
@@ -43563,9 +43361,7 @@ var bot = {
|
|
|
43563
43361
|
set state(value) {
|
|
43564
43362
|
const botId = context2.get("botId");
|
|
43565
43363
|
const states = context2.get("states", { optional: true }) ?? [];
|
|
43566
|
-
const state = states.find(
|
|
43567
|
-
(x) => x.type === "bot" && x.name === "botState" && x.id === botId
|
|
43568
|
-
);
|
|
43364
|
+
const state = states.find((x) => x.type === "bot" && x.name === "botState" && x.id === botId);
|
|
43569
43365
|
if (!state) {
|
|
43570
43366
|
throw new Error("Bot state not initialized.");
|
|
43571
43367
|
}
|
|
@@ -43579,9 +43375,7 @@ var user = {
|
|
|
43579
43375
|
throw new Error("User not found in context.");
|
|
43580
43376
|
}
|
|
43581
43377
|
const states = context2.get("states", { optional: true }) ?? [];
|
|
43582
|
-
const state = states.find(
|
|
43583
|
-
(x) => x.type === "user" && x.name === "userState" && x.id === user2.id
|
|
43584
|
-
);
|
|
43378
|
+
const state = states.find((x) => x.type === "user" && x.name === "userState" && x.id === user2.id);
|
|
43585
43379
|
if (!state) {
|
|
43586
43380
|
throw new Error("User state not initialized.");
|
|
43587
43381
|
}
|
|
@@ -43593,9 +43387,7 @@ var user = {
|
|
|
43593
43387
|
throw new Error("User not found in context.");
|
|
43594
43388
|
}
|
|
43595
43389
|
const states = context2.get("states", { optional: true }) ?? [];
|
|
43596
|
-
const state = states.find(
|
|
43597
|
-
(x) => x.type === "user" && x.name === "userState" && x.id === user2.id
|
|
43598
|
-
);
|
|
43390
|
+
const state = states.find((x) => x.type === "user" && x.name === "userState" && x.id === user2.id);
|
|
43599
43391
|
if (!state) {
|
|
43600
43392
|
throw new Error("User state not initialized.");
|
|
43601
43393
|
}
|
|
@@ -43660,10 +43452,7 @@ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
|
43660
43452
|
import { transforms as transforms3 } from "@botpress/sdk";
|
|
43661
43453
|
var DEFAULT_MAX_ATTEMPTS = 5;
|
|
43662
43454
|
var MIN_STEP_REMAINING_TIME_MS = 1e4;
|
|
43663
|
-
var storage2 = getSingleton(
|
|
43664
|
-
"__ADK_GLOBAL_CTX_WORKFLOW_STEP",
|
|
43665
|
-
() => new AsyncLocalStorage3()
|
|
43666
|
-
);
|
|
43455
|
+
var storage2 = getSingleton("__ADK_GLOBAL_CTX_WORKFLOW_STEP", () => new AsyncLocalStorage3());
|
|
43667
43456
|
async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
43668
43457
|
spanFunc,
|
|
43669
43458
|
stepType
|
|
@@ -43681,9 +43470,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
|
43681
43470
|
}
|
|
43682
43471
|
const remainingTime = context2.get("runtime").getRemainingExecutionTimeInMs();
|
|
43683
43472
|
if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
|
|
43684
|
-
await new Promise(
|
|
43685
|
-
(resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
|
|
43686
|
-
);
|
|
43473
|
+
await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
|
|
43687
43474
|
throw createStepSignal();
|
|
43688
43475
|
}
|
|
43689
43476
|
const stepContext = storage2.getStore();
|
|
@@ -43763,13 +43550,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
|
43763
43550
|
}
|
|
43764
43551
|
if (shouldRetry) {
|
|
43765
43552
|
await new Promise(
|
|
43766
|
-
(resolve) => setTimeout(
|
|
43767
|
-
resolve,
|
|
43768
|
-
Math.min(
|
|
43769
|
-
100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1),
|
|
43770
|
-
5e3
|
|
43771
|
-
)
|
|
43772
|
-
)
|
|
43553
|
+
(resolve) => setTimeout(resolve, Math.min(100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1), 5e3))
|
|
43773
43554
|
);
|
|
43774
43555
|
continue;
|
|
43775
43556
|
}
|
|
@@ -43874,10 +43655,7 @@ step.sleep = async (name, ms3) => {
|
|
|
43874
43655
|
);
|
|
43875
43656
|
};
|
|
43876
43657
|
step.sleepUntil = async (name, date) => {
|
|
43877
|
-
const ms3 = Math.max(
|
|
43878
|
-
0,
|
|
43879
|
-
new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS
|
|
43880
|
-
);
|
|
43658
|
+
const ms3 = Math.max(0, new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS);
|
|
43881
43659
|
await step.sleep(name, ms3);
|
|
43882
43660
|
};
|
|
43883
43661
|
step.waitForWorkflow = async (name, workflowId) => {
|
|
@@ -43923,10 +43701,9 @@ step.executeWorkflow = async (name, workflow, input) => _step(
|
|
|
43923
43701
|
// Ensures idempotency
|
|
43924
43702
|
})).id
|
|
43925
43703
|
);
|
|
43926
|
-
return _step(
|
|
43927
|
-
|
|
43928
|
-
|
|
43929
|
-
).then((finishedWorkflow) => finishedWorkflow.output);
|
|
43704
|
+
return _step(`${name}-wait`, async () => step.waitForWorkflow(`${name}-wait`, wfId)).then(
|
|
43705
|
+
(finishedWorkflow) => finishedWorkflow.output
|
|
43706
|
+
);
|
|
43930
43707
|
},
|
|
43931
43708
|
{}
|
|
43932
43709
|
);
|
|
@@ -43943,9 +43720,7 @@ async function processWithConcurrency(items, processor, maxConcurrency = 5) {
|
|
|
43943
43720
|
}
|
|
43944
43721
|
const remainingTime = context2.get("runtime").getRemainingExecutionTimeInMs();
|
|
43945
43722
|
if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
|
|
43946
|
-
await new Promise(
|
|
43947
|
-
(resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
|
|
43948
|
-
);
|
|
43723
|
+
await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
|
|
43949
43724
|
throw createStepSignal();
|
|
43950
43725
|
}
|
|
43951
43726
|
const promise = processor(items[i], i).then((result) => {
|
|
@@ -44013,17 +43788,11 @@ step.request = async (request, message, stepName) => {
|
|
|
44013
43788
|
const workflowControlContext = context2.get("workflowControlContext");
|
|
44014
43789
|
const client = context2.get("client");
|
|
44015
43790
|
if (!workflowControlContext.workflow.conversationId) {
|
|
44016
|
-
throw new Error(
|
|
44017
|
-
`Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`
|
|
44018
|
-
);
|
|
43791
|
+
throw new Error(`Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`);
|
|
44019
43792
|
}
|
|
44020
|
-
const workflowDef = adk.project.workflows.find(
|
|
44021
|
-
(w) => w.name === workflowControlContext.workflow.name
|
|
44022
|
-
);
|
|
43793
|
+
const workflowDef = adk.project.workflows.find((w) => w.name === workflowControlContext.workflow.name);
|
|
44023
43794
|
if (!workflowDef) {
|
|
44024
|
-
throw new Error(
|
|
44025
|
-
`Workflow definition not found for "${workflowControlContext.workflow.name}"`
|
|
44026
|
-
);
|
|
43795
|
+
throw new Error(`Workflow definition not found for "${workflowControlContext.workflow.name}"`);
|
|
44027
43796
|
}
|
|
44028
43797
|
const requestSchema = workflowDef._requestsSchemas?.[request];
|
|
44029
43798
|
if (!requestSchema) {
|
|
@@ -44031,10 +43800,7 @@ step.request = async (request, message, stepName) => {
|
|
|
44031
43800
|
`Request "${request}" not found in workflow "${workflowDef.name}". Available requests: ${Object.keys(workflowDef._requestsSchemas || {}).join(", ") || "none"}`
|
|
44032
43801
|
);
|
|
44033
43802
|
}
|
|
44034
|
-
const state = createWorkflowExecutionState(
|
|
44035
|
-
client._inner,
|
|
44036
|
-
workflowControlContext.workflow.id
|
|
44037
|
-
);
|
|
43803
|
+
const state = createWorkflowExecutionState(client._inner, workflowControlContext.workflow.id);
|
|
44038
43804
|
if (!state.value) {
|
|
44039
43805
|
throw new Error("Workflow execution state not loaded");
|
|
44040
43806
|
}
|
|
@@ -44114,9 +43880,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44114
43880
|
// @internal
|
|
44115
43881
|
TrackedState;
|
|
44116
43882
|
constructor(workflow, client) {
|
|
44117
|
-
const definition = adk.project.workflows.find(
|
|
44118
|
-
(w) => w.name === workflow.name
|
|
44119
|
-
);
|
|
43883
|
+
const definition = adk.project.workflows.find((w) => w.name === workflow.name);
|
|
44120
43884
|
this.TrackedState = TrackedState2.create({
|
|
44121
43885
|
type: "workflow",
|
|
44122
43886
|
client: client._inner,
|
|
@@ -44139,9 +43903,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44139
43903
|
const client = context2.get("client");
|
|
44140
43904
|
const workflow = props.workflow ? props.workflow : await client.getWorkflow({ id: props.id }).then((x) => x.workflow);
|
|
44141
43905
|
if (!adk.project.workflows.find((w) => w.name === workflow.name)) {
|
|
44142
|
-
throw new Error(
|
|
44143
|
-
`No ADK Workflow definition found for "${workflow.name}"`
|
|
44144
|
-
);
|
|
43906
|
+
throw new Error(`No ADK Workflow definition found for "${workflow.name}"`);
|
|
44145
43907
|
}
|
|
44146
43908
|
return new _BaseWorkflowInstance(workflow, client);
|
|
44147
43909
|
}
|
|
@@ -44168,10 +43930,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44168
43930
|
*/
|
|
44169
43931
|
async provide(request, data) {
|
|
44170
43932
|
const client = context2.get("client");
|
|
44171
|
-
const state = createWorkflowExecutionState(
|
|
44172
|
-
client._inner,
|
|
44173
|
-
this.id
|
|
44174
|
-
);
|
|
43933
|
+
const state = createWorkflowExecutionState(client._inner, this.id);
|
|
44175
43934
|
await state.load();
|
|
44176
43935
|
if (!state.value) {
|
|
44177
43936
|
throw new Error(`Workflow execution state not found for workflow ${this.id}`);
|
|
@@ -44198,13 +43957,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44198
43957
|
}
|
|
44199
43958
|
// @internal
|
|
44200
43959
|
async handle() {
|
|
44201
|
-
const handler = adk.project.workflows.find(
|
|
44202
|
-
(w) => w.name === this.name
|
|
44203
|
-
)._handler;
|
|
43960
|
+
const handler = adk.project.workflows.find((w) => w.name === this.name)._handler;
|
|
44204
43961
|
if (!handler) {
|
|
44205
|
-
throw new Error(
|
|
44206
|
-
`No ADK Workflow handler found for "${this.name}"`
|
|
44207
|
-
);
|
|
43962
|
+
throw new Error(`No ADK Workflow handler found for "${this.name}"`);
|
|
44208
43963
|
}
|
|
44209
43964
|
await TrackedState2.loadAll();
|
|
44210
43965
|
const workflowControlContext = {
|
|
@@ -44229,9 +43984,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44229
43984
|
}
|
|
44230
43985
|
const eventId = context2.get("event")?.id;
|
|
44231
43986
|
if (!eventId) {
|
|
44232
|
-
throw new Error(
|
|
44233
|
-
`Event ID not found in context. Cannot ack workflow ${this.id}`
|
|
44234
|
-
);
|
|
43987
|
+
throw new Error(`Event ID not found in context. Cannot ack workflow ${this.id}`);
|
|
44235
43988
|
}
|
|
44236
43989
|
workflowControlContext.acked = true;
|
|
44237
43990
|
await updateWorkflow({
|
|
@@ -44243,15 +43996,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
44243
43996
|
};
|
|
44244
43997
|
try {
|
|
44245
43998
|
const ctx = context2.getAll();
|
|
44246
|
-
const workflowExecutionState = createWorkflowExecutionState(
|
|
44247
|
-
ctx.client._inner,
|
|
44248
|
-
this.id
|
|
44249
|
-
);
|
|
43999
|
+
const workflowExecutionState = createWorkflowExecutionState(ctx.client._inner, this.id);
|
|
44250
44000
|
await workflowExecutionState.load();
|
|
44251
|
-
assert2(
|
|
44252
|
-
workflowExecutionState.value,
|
|
44253
|
-
"Workflow execution state is not loaded"
|
|
44254
|
-
);
|
|
44001
|
+
assert2(workflowExecutionState.value, "Workflow execution state is not loaded");
|
|
44255
44002
|
workflowExecutionState.value.executionCount++;
|
|
44256
44003
|
if (!this.TrackedState.value) {
|
|
44257
44004
|
this.TrackedState.value = {};
|
|
@@ -44418,12 +44165,7 @@ var BaseWorkflow = class {
|
|
|
44418
44165
|
*/
|
|
44419
44166
|
async getOrCreate(props) {
|
|
44420
44167
|
const client = context2.get("client");
|
|
44421
|
-
const statuses = props.statuses || [
|
|
44422
|
-
"pending",
|
|
44423
|
-
"in_progress",
|
|
44424
|
-
"listening",
|
|
44425
|
-
"paused"
|
|
44426
|
-
];
|
|
44168
|
+
const statuses = props.statuses || ["pending", "in_progress", "listening", "paused"];
|
|
44427
44169
|
const validatedInput = this._inputSchema.parse(props.input);
|
|
44428
44170
|
const tags = {};
|
|
44429
44171
|
if (props.key) {
|
|
@@ -44437,9 +44179,7 @@ var BaseWorkflow = class {
|
|
|
44437
44179
|
tags,
|
|
44438
44180
|
conversationId: context2.get("conversation", { optional: true })?.id,
|
|
44439
44181
|
parentWorkflowId: context2.get("workflow", { optional: true })?.id,
|
|
44440
|
-
timeoutAt: new Date(
|
|
44441
|
-
Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
|
|
44442
|
-
).toISOString(),
|
|
44182
|
+
timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString(),
|
|
44443
44183
|
...discriminator && { discriminateBy: { tags: discriminator } }
|
|
44444
44184
|
};
|
|
44445
44185
|
let { workflow } = await client._inner.getOrCreateWorkflow(createArgs);
|
|
@@ -44465,21 +44205,12 @@ var BaseWorkflow = class {
|
|
|
44465
44205
|
async provide(event, data) {
|
|
44466
44206
|
const client = context2.get("client");
|
|
44467
44207
|
const { workflowId, stepName } = event.payload;
|
|
44468
|
-
const state = createWorkflowExecutionState(
|
|
44469
|
-
client._inner,
|
|
44470
|
-
workflowId
|
|
44471
|
-
);
|
|
44208
|
+
const state = createWorkflowExecutionState(client._inner, workflowId);
|
|
44472
44209
|
await state.load();
|
|
44473
44210
|
if (!state.value) {
|
|
44474
|
-
throw new Error(
|
|
44475
|
-
`Workflow execution state not found for workflow ${workflowId}`
|
|
44476
|
-
);
|
|
44211
|
+
throw new Error(`Workflow execution state not found for workflow ${workflowId}`);
|
|
44477
44212
|
}
|
|
44478
|
-
console.log(
|
|
44479
|
-
`Providing data to workflow ${workflowId} step ${stepName}`,
|
|
44480
|
-
data,
|
|
44481
|
-
stepName
|
|
44482
|
-
);
|
|
44213
|
+
console.log(`Providing data to workflow ${workflowId} step ${stepName}`, data, stepName);
|
|
44483
44214
|
if (!state.value.steps[stepName]) {
|
|
44484
44215
|
state.value.steps[stepName] = {
|
|
44485
44216
|
output: data,
|
|
@@ -44511,9 +44242,7 @@ var BaseWorkflow = class {
|
|
|
44511
44242
|
input: validatedInput,
|
|
44512
44243
|
parentWorkflowId: workflow?.id,
|
|
44513
44244
|
conversationId: context2.get("conversation", { optional: true })?.id,
|
|
44514
|
-
timeoutAt: new Date(
|
|
44515
|
-
Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
|
|
44516
|
-
).toISOString()
|
|
44245
|
+
timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString()
|
|
44517
44246
|
});
|
|
44518
44247
|
return await BaseWorkflowInstance.load({
|
|
44519
44248
|
id: res.workflow.id,
|
|
@@ -44664,12 +44393,8 @@ var adk = {
|
|
|
44664
44393
|
config: state.projectConfig,
|
|
44665
44394
|
integrations: Object.assign(state.primitives.integrations, {
|
|
44666
44395
|
get(name) {
|
|
44667
|
-
const byAlias = state.primitives.integrations.find(
|
|
44668
|
-
|
|
44669
|
-
);
|
|
44670
|
-
const byName = state.primitives.integrations.find(
|
|
44671
|
-
(int) => int.definition.name === name
|
|
44672
|
-
);
|
|
44396
|
+
const byAlias = state.primitives.integrations.find((int) => int.alias === name);
|
|
44397
|
+
const byName = state.primitives.integrations.find((int) => int.definition.name === name);
|
|
44673
44398
|
return byAlias || byName;
|
|
44674
44399
|
}
|
|
44675
44400
|
}),
|
|
@@ -44767,9 +44492,7 @@ var TrackedState2 = class _TrackedState {
|
|
|
44767
44492
|
}
|
|
44768
44493
|
static create(props) {
|
|
44769
44494
|
const states = context2.get("states", { optional: true });
|
|
44770
|
-
const match2 = states?.find(
|
|
44771
|
-
(x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state")
|
|
44772
|
-
);
|
|
44495
|
+
const match2 = states?.find((x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state"));
|
|
44773
44496
|
if (match2) {
|
|
44774
44497
|
return match2;
|
|
44775
44498
|
}
|
|
@@ -44849,9 +44572,7 @@ var TrackedState2 = class _TrackedState {
|
|
|
44849
44572
|
});
|
|
44850
44573
|
}
|
|
44851
44574
|
const states = context2.get("states", { optional: true });
|
|
44852
|
-
const promises = Promise.allSettled(
|
|
44853
|
-
states?.map((state) => state.load()) ?? []
|
|
44854
|
-
);
|
|
44575
|
+
const promises = Promise.allSettled(states?.map((state) => state.load()) ?? []);
|
|
44855
44576
|
void importScheduledHeavyImports();
|
|
44856
44577
|
await promises;
|
|
44857
44578
|
});
|
|
@@ -44886,9 +44607,7 @@ var TrackedState2 = class _TrackedState {
|
|
|
44886
44607
|
const { data } = await axios_default.get(file.url);
|
|
44887
44608
|
this.value = typeof data === "string" ? JSON.parse(data) : data;
|
|
44888
44609
|
} catch (err) {
|
|
44889
|
-
console.error(
|
|
44890
|
-
`Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`
|
|
44891
|
-
);
|
|
44610
|
+
console.error(`Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`);
|
|
44892
44611
|
this.value = void 0;
|
|
44893
44612
|
}
|
|
44894
44613
|
} else {
|
|
@@ -44974,9 +44693,7 @@ var TrackedState2 = class _TrackedState {
|
|
|
44974
44693
|
contentType: "application/json",
|
|
44975
44694
|
content: JSON.stringify(this.value),
|
|
44976
44695
|
accessPolicies: [],
|
|
44977
|
-
expiresAt: new Date(
|
|
44978
|
-
Date.now() + 30 * 24 * 60 * 60 * 1e3
|
|
44979
|
-
).toISOString(),
|
|
44696
|
+
expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1e3).toISOString(),
|
|
44980
44697
|
tags: {
|
|
44981
44698
|
system: "true",
|
|
44982
44699
|
purpose: "swap"
|
|
@@ -44996,9 +44713,7 @@ var TrackedState2 = class _TrackedState {
|
|
|
44996
44713
|
error: err instanceof Error ? err.message : String(err),
|
|
44997
44714
|
size_bytes: stateSize
|
|
44998
44715
|
});
|
|
44999
|
-
console.error(
|
|
45000
|
-
`Failed to swap state: ${err instanceof Error ? err.message : String(err)}`
|
|
45001
|
-
);
|
|
44716
|
+
console.error(`Failed to swap state: ${err instanceof Error ? err.message : String(err)}`);
|
|
45002
44717
|
payload = {
|
|
45003
44718
|
value: this.value,
|
|
45004
44719
|
location: { type: "state" }
|
|
@@ -45118,9 +44833,7 @@ async function handleInspectorChrome() {
|
|
|
45118
44833
|
let devtoolsFrontendUrl = null;
|
|
45119
44834
|
if (inspectorPort && inspectorUrl) {
|
|
45120
44835
|
try {
|
|
45121
|
-
const response = await fetch(
|
|
45122
|
-
`http://127.0.0.1:${inspectorPort}/json/list`
|
|
45123
|
-
);
|
|
44836
|
+
const response = await fetch(`http://127.0.0.1:${inspectorPort}/json/list`);
|
|
45124
44837
|
const data = await response.json();
|
|
45125
44838
|
if (data && data.length > 0 && data[0]) {
|
|
45126
44839
|
webSocketDebuggerUrl = data[0].webSocketDebuggerUrl || null;
|
|
@@ -45294,10 +45007,7 @@ var patchHandlers = (bot2) => {
|
|
|
45294
45007
|
}
|
|
45295
45008
|
}
|
|
45296
45009
|
const RUNTIME_SAFETY_MARGIN = 5e3;
|
|
45297
|
-
const remainingTime = Math.max(
|
|
45298
|
-
lambdaCtx.getRemainingTimeInMillis() - RUNTIME_SAFETY_MARGIN,
|
|
45299
|
-
100
|
|
45300
|
-
);
|
|
45010
|
+
const remainingTime = Math.max(lambdaCtx.getRemainingTimeInMillis() - RUNTIME_SAFETY_MARGIN, 100);
|
|
45301
45011
|
return await new Promise(async (resolve, reject) => {
|
|
45302
45012
|
const started = Date.now();
|
|
45303
45013
|
const timeout = setTimeout(
|
|
@@ -45343,6 +45053,7 @@ var patchHandlers = (bot2) => {
|
|
|
45343
45053
|
props.client.getConversation({
|
|
45344
45054
|
id: props.event.conversationId
|
|
45345
45055
|
}).then(({ conversation }) => {
|
|
45056
|
+
;
|
|
45346
45057
|
props.conversation = conversation;
|
|
45347
45058
|
}).catch(() => {
|
|
45348
45059
|
})
|
|
@@ -45354,6 +45065,7 @@ var patchHandlers = (bot2) => {
|
|
|
45354
45065
|
// @ts-ignore
|
|
45355
45066
|
id: props.event.workflowId
|
|
45356
45067
|
}).then(({ workflow }) => {
|
|
45068
|
+
;
|
|
45357
45069
|
props.workflow = workflow;
|
|
45358
45070
|
}).catch(() => {
|
|
45359
45071
|
})
|
|
@@ -45364,6 +45076,7 @@ var patchHandlers = (bot2) => {
|
|
|
45364
45076
|
props.client.getUser({
|
|
45365
45077
|
id: props.event.userId
|
|
45366
45078
|
}).then(({ user: user2 }) => {
|
|
45079
|
+
;
|
|
45367
45080
|
props.user = user2;
|
|
45368
45081
|
}).catch(() => {
|
|
45369
45082
|
})
|
|
@@ -45421,11 +45134,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
45421
45134
|
// src/runtime/chat/chat.ts
|
|
45422
45135
|
init_define_BUILD();
|
|
45423
45136
|
init_define_PACKAGE_VERSIONS();
|
|
45424
|
-
import {
|
|
45425
|
-
Chat,
|
|
45426
|
-
DefaultComponents,
|
|
45427
|
-
isAnyComponent as isAnyComponent2
|
|
45428
|
-
} from "llmz";
|
|
45137
|
+
import { Chat, DefaultComponents, isAnyComponent as isAnyComponent2 } from "llmz";
|
|
45429
45138
|
|
|
45430
45139
|
// src/runtime/chat/truncate-transcript.ts
|
|
45431
45140
|
init_define_BUILD();
|
|
@@ -45961,17 +45670,12 @@ var BotpressChat = class extends Chat {
|
|
|
45961
45670
|
const items = this._transcript?.splice(
|
|
45962
45671
|
0,
|
|
45963
45672
|
// We want to keep the last N items as higher-precision context
|
|
45964
|
-
Math.max(
|
|
45965
|
-
this._transcript.length - Config.Transcript.SUMMARY_END_PADDING,
|
|
45966
|
-
0
|
|
45967
|
-
)
|
|
45673
|
+
Math.max(this._transcript.length - Config.Transcript.SUMMARY_END_PADDING, 0)
|
|
45968
45674
|
);
|
|
45969
45675
|
try {
|
|
45970
|
-
const summary = await adk.zai.summarize(
|
|
45971
|
-
|
|
45972
|
-
|
|
45973
|
-
length: 250,
|
|
45974
|
-
prompt: dedent_default`
|
|
45676
|
+
const summary = await adk.zai.summarize(JSON.stringify(items, null, 2), {
|
|
45677
|
+
length: 250,
|
|
45678
|
+
prompt: dedent_default`
|
|
45975
45679
|
You are a transcript summarizer tasked with compressing a long conversation between a user and an AI agent.
|
|
45976
45680
|
Your goal is to drastically reduce the transcript length while retaining all key information, decisions, facts, user goals, and outputs.
|
|
45977
45681
|
|
|
@@ -45985,8 +45689,7 @@ var BotpressChat = class extends Chat {
|
|
|
45985
45689
|
|
|
45986
45690
|
The final output should feel like a high-value executive summary of a working session, not a chat log.
|
|
45987
45691
|
`.trim()
|
|
45988
|
-
|
|
45989
|
-
);
|
|
45692
|
+
});
|
|
45990
45693
|
this._transcript?.unshift({
|
|
45991
45694
|
id: `summary-${Date.now()}`,
|
|
45992
45695
|
role: "summary",
|
|
@@ -46037,9 +45740,7 @@ var BotpressChat = class extends Chat {
|
|
|
46037
45740
|
"message.type": message.type
|
|
46038
45741
|
},
|
|
46039
45742
|
async (s) => {
|
|
46040
|
-
const [payload, citations] = this.citations.removeCitationsFromObject(
|
|
46041
|
-
message.payload
|
|
46042
|
-
);
|
|
45743
|
+
const [payload, citations] = this.citations.removeCitationsFromObject(message.payload);
|
|
46043
45744
|
const { message: created } = await this.client.createMessage({
|
|
46044
45745
|
conversationId: this.conversation.id,
|
|
46045
45746
|
tags: message.tags || {},
|
|
@@ -46095,9 +45796,7 @@ var BotpressChat = class extends Chat {
|
|
|
46095
45796
|
(c) => c.definition.name.toLowerCase() === message.type.toLowerCase() || c.definition.aliases?.map((x) => x.toLowerCase()).includes(message.type.toLowerCase())
|
|
46096
45797
|
);
|
|
46097
45798
|
if (!component) {
|
|
46098
|
-
throw new Error(
|
|
46099
|
-
`Could not find component for message type "${message.type}"`
|
|
46100
|
-
);
|
|
45799
|
+
throw new Error(`Could not find component for message type "${message.type}"`);
|
|
46101
45800
|
}
|
|
46102
45801
|
await this.sendMessage({
|
|
46103
45802
|
type: component.definition.name,
|
|
@@ -46199,9 +45898,7 @@ ${footer}`.trim();
|
|
|
46199
45898
|
return cleaned.trim();
|
|
46200
45899
|
}
|
|
46201
45900
|
if (Array.isArray(obj)) {
|
|
46202
|
-
return obj.map(
|
|
46203
|
-
(item) => expandCitationsInObject(item, citationsManager)
|
|
46204
|
-
);
|
|
45901
|
+
return obj.map((item) => expandCitationsInObject(item, citationsManager));
|
|
46205
45902
|
}
|
|
46206
45903
|
if (obj && typeof obj === "object") {
|
|
46207
45904
|
const result = {};
|
|
@@ -46223,12 +45920,7 @@ var AttachmentSchema = z23.object({
|
|
|
46223
45920
|
});
|
|
46224
45921
|
var TranscriptItemSchema = z23.object({
|
|
46225
45922
|
id: z23.string(),
|
|
46226
|
-
role: z23.union([
|
|
46227
|
-
z23.literal("assistant"),
|
|
46228
|
-
z23.literal("user"),
|
|
46229
|
-
z23.literal("event"),
|
|
46230
|
-
z23.literal("summary")
|
|
46231
|
-
]),
|
|
45923
|
+
role: z23.union([z23.literal("assistant"), z23.literal("user"), z23.literal("event"), z23.literal("summary")]),
|
|
46232
45924
|
name: z23.string().optional(),
|
|
46233
45925
|
createdAt: z23.string().optional(),
|
|
46234
45926
|
content: z23.string().optional(),
|
|
@@ -46262,9 +45954,7 @@ function matchesChannel(handlerChannel, incomingChannel) {
|
|
|
46262
45954
|
}
|
|
46263
45955
|
}
|
|
46264
45956
|
function findMatchingHandler(handlers2, incomingChannel) {
|
|
46265
|
-
const matchingHandlers = handlers2.filter(
|
|
46266
|
-
(h) => matchesChannel(h.channel, incomingChannel)
|
|
46267
|
-
);
|
|
45957
|
+
const matchingHandlers = handlers2.filter((h) => matchesChannel(h.channel, incomingChannel));
|
|
46268
45958
|
return matchingHandlers.sort((a, b) => {
|
|
46269
45959
|
const aScore = a.channel === "*" ? 0 : Array.isArray(a.channel) ? 1 : 2;
|
|
46270
45960
|
const bScore = b.channel === "*" ? 0 : Array.isArray(b.channel) ? 1 : 2;
|
|
@@ -46274,53 +45964,42 @@ function findMatchingHandler(handlers2, incomingChannel) {
|
|
|
46274
45964
|
|
|
46275
45965
|
// src/runtime/handlers/conversation.ts
|
|
46276
45966
|
var setup = (bot2) => {
|
|
46277
|
-
bot2.on.message(
|
|
46278
|
-
|
|
46279
|
-
|
|
46280
|
-
|
|
46281
|
-
|
|
46282
|
-
|
|
46283
|
-
|
|
46284
|
-
|
|
46285
|
-
|
|
46286
|
-
|
|
46287
|
-
|
|
46288
|
-
|
|
46289
|
-
|
|
46290
|
-
|
|
46291
|
-
|
|
46292
|
-
|
|
46293
|
-
|
|
46294
|
-
|
|
46295
|
-
|
|
46296
|
-
|
|
46297
|
-
|
|
46298
|
-
|
|
46299
|
-
handlerName
|
|
46300
|
-
);
|
|
46301
|
-
if (!handler) {
|
|
46302
|
-
logger.debug(
|
|
46303
|
-
`Skipping message, no ADK Conversation defined for "${handlerName}"`
|
|
46304
|
-
);
|
|
46305
|
-
return;
|
|
46306
|
-
}
|
|
46307
|
-
const chat = new BotpressChat(context2.getAll());
|
|
46308
|
-
context2.set("chat", chat);
|
|
46309
|
-
const [transcript, _statesLoaded] = await Promise.all([
|
|
46310
|
-
chat.fetchTranscript(),
|
|
46311
|
-
TrackedState2.loadAll()
|
|
46312
|
-
]);
|
|
46313
|
-
if (transcript.find((x) => x.id === message.id)) {
|
|
46314
|
-
return;
|
|
46315
|
-
}
|
|
46316
|
-
await chat.addMessage(message);
|
|
46317
|
-
await handler[ConversationHandler]();
|
|
46318
|
-
await TrackedState2.saveAllDirty();
|
|
46319
|
-
await chat.saveTranscript();
|
|
45967
|
+
bot2.on.message("*", async ({ conversation, message, logger, ctx, event, user: user2 }) => {
|
|
45968
|
+
await span(
|
|
45969
|
+
"handler.conversation",
|
|
45970
|
+
{
|
|
45971
|
+
botId: ctx.botId,
|
|
45972
|
+
conversationId: conversation.id,
|
|
45973
|
+
eventId: event.id,
|
|
45974
|
+
integration: conversation.integration,
|
|
45975
|
+
channel: conversation.channel,
|
|
45976
|
+
"event.type": event.type,
|
|
45977
|
+
messageId: message.id,
|
|
45978
|
+
userId: user2.id,
|
|
45979
|
+
"message.type": message.type,
|
|
45980
|
+
"message.payload": message.payload,
|
|
45981
|
+
"event.payload": event.payload
|
|
45982
|
+
},
|
|
45983
|
+
async () => {
|
|
45984
|
+
const handlerName = conversation.integration + "." + conversation.channel;
|
|
45985
|
+
const handler = findMatchingHandler(adk.project.conversations, handlerName);
|
|
45986
|
+
if (!handler) {
|
|
45987
|
+
logger.debug(`Skipping message, no ADK Conversation defined for "${handlerName}"`);
|
|
45988
|
+
return;
|
|
46320
45989
|
}
|
|
46321
|
-
|
|
46322
|
-
|
|
46323
|
-
|
|
45990
|
+
const chat = new BotpressChat(context2.getAll());
|
|
45991
|
+
context2.set("chat", chat);
|
|
45992
|
+
const [transcript, _statesLoaded] = await Promise.all([chat.fetchTranscript(), TrackedState2.loadAll()]);
|
|
45993
|
+
if (transcript.find((x) => x.id === message.id)) {
|
|
45994
|
+
return;
|
|
45995
|
+
}
|
|
45996
|
+
await chat.addMessage(message);
|
|
45997
|
+
await handler[ConversationHandler]();
|
|
45998
|
+
await TrackedState2.saveAllDirty();
|
|
45999
|
+
await chat.saveTranscript();
|
|
46000
|
+
}
|
|
46001
|
+
);
|
|
46002
|
+
});
|
|
46324
46003
|
};
|
|
46325
46004
|
|
|
46326
46005
|
// src/runtime/handlers/trigger.ts
|
|
@@ -46342,13 +46021,9 @@ var setup2 = (bot2) => {
|
|
|
46342
46021
|
}
|
|
46343
46022
|
const [integration, event] = name.split(":");
|
|
46344
46023
|
const names = /* @__PURE__ */ new Set([name]);
|
|
46345
|
-
const int = adk.project.integrations.find(
|
|
46346
|
-
(x) => x.alias === integration || x.definition.name === integration
|
|
46347
|
-
);
|
|
46024
|
+
const int = adk.project.integrations.find((x) => x.alias === integration || x.definition.name === integration);
|
|
46348
46025
|
if (!int) {
|
|
46349
|
-
console.warn(
|
|
46350
|
-
`Integration "${integration}" not found for event "${name}". Skipping trigger registration.`
|
|
46351
|
-
);
|
|
46026
|
+
console.warn(`Integration "${integration}" not found for event "${name}". Skipping trigger registration.`);
|
|
46352
46027
|
continue;
|
|
46353
46028
|
}
|
|
46354
46029
|
names.add(`${int.definition.name}:${event}`);
|
|
@@ -46368,9 +46043,7 @@ var setup2 = (bot2) => {
|
|
|
46368
46043
|
userId: event2.userId
|
|
46369
46044
|
},
|
|
46370
46045
|
async () => {
|
|
46371
|
-
console.log(
|
|
46372
|
-
`Evaluating trigger "${trigger.name}" for event "${originalName}" (mapped to "${name2}")`
|
|
46373
|
-
);
|
|
46046
|
+
console.log(`Evaluating trigger "${trigger.name}" for event "${originalName}" (mapped to "${name2}")`);
|
|
46374
46047
|
await trigger.handler({
|
|
46375
46048
|
event: {
|
|
46376
46049
|
...event2,
|
|
@@ -46395,13 +46068,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
46395
46068
|
init_esm();
|
|
46396
46069
|
var import_ms2 = __toESM(require_ms(), 1);
|
|
46397
46070
|
var setup3 = (bot2) => {
|
|
46398
|
-
const handler = async function({
|
|
46399
|
-
workflow,
|
|
46400
|
-
event,
|
|
46401
|
-
client,
|
|
46402
|
-
ctx,
|
|
46403
|
-
conversation
|
|
46404
|
-
}) {
|
|
46071
|
+
const handler = async function({ workflow, event, client, ctx, conversation }) {
|
|
46405
46072
|
await span(
|
|
46406
46073
|
"handler.workflow",
|
|
46407
46074
|
{
|
|
@@ -46417,9 +46084,7 @@ var setup3 = (bot2) => {
|
|
|
46417
46084
|
"workflow.status.initial": workflow.status
|
|
46418
46085
|
},
|
|
46419
46086
|
async (s) => {
|
|
46420
|
-
const workflowDefinition = adk.project.workflows.find(
|
|
46421
|
-
(w) => w.name === workflow.name
|
|
46422
|
-
);
|
|
46087
|
+
const workflowDefinition = adk.project.workflows.find((w) => w.name === workflow.name);
|
|
46423
46088
|
if (!workflowDefinition?._handler) {
|
|
46424
46089
|
console.warn(`No ADK Workflow handler found for "${workflow.name}"`);
|
|
46425
46090
|
s.setAttribute("handler", false);
|
|
@@ -46437,9 +46102,7 @@ var setup3 = (bot2) => {
|
|
|
46437
46102
|
const currentTimeoutDuration = currentTimeoutAt - workflowStartedAt;
|
|
46438
46103
|
const isDefaultTimeout = Math.abs(currentTimeoutDuration - DEFAULT_TIMEOUT_MS) < 1e4;
|
|
46439
46104
|
if (isDefaultTimeout) {
|
|
46440
|
-
const newTimeoutAt = new Date(
|
|
46441
|
-
workflowStartedAt + configuredTimeout
|
|
46442
|
-
).toISOString();
|
|
46105
|
+
const newTimeoutAt = new Date(workflowStartedAt + configuredTimeout).toISOString();
|
|
46443
46106
|
await updateWorkflow({
|
|
46444
46107
|
id: workflow.id,
|
|
46445
46108
|
timeoutAt: newTimeoutAt
|
|
@@ -46577,26 +46240,19 @@ __export(event_exports, {
|
|
|
46577
46240
|
init_define_BUILD();
|
|
46578
46241
|
init_define_PACKAGE_VERSIONS();
|
|
46579
46242
|
var setup4 = (bot2) => {
|
|
46580
|
-
const conversationEventTypes = [
|
|
46581
|
-
WorkflowCallbackEvent.name,
|
|
46582
|
-
WorkflowDataRequestEvent.name
|
|
46583
|
-
];
|
|
46243
|
+
const conversationEventTypes = [WorkflowCallbackEvent.name, WorkflowDataRequestEvent.name];
|
|
46584
46244
|
for (const eventType of conversationEventTypes) {
|
|
46585
46245
|
bot2.on.event(eventType, async ({ event, client, logger, ctx }) => {
|
|
46586
46246
|
const payload = event.payload;
|
|
46587
46247
|
const conversation = context2.get("conversation");
|
|
46588
46248
|
if (!conversation) {
|
|
46589
|
-
logger.warn(
|
|
46590
|
-
`Skipping ${WorkflowCallbackEvent.name} event, conversation not found in context`
|
|
46591
|
-
);
|
|
46249
|
+
logger.warn(`Skipping ${WorkflowCallbackEvent.name} event, conversation not found in context`);
|
|
46592
46250
|
return;
|
|
46593
46251
|
}
|
|
46594
46252
|
const handlerName = conversation.integration + "." + conversation.channel;
|
|
46595
46253
|
const handler = findMatchingHandler(adk.project.conversations, handlerName);
|
|
46596
46254
|
if (!handler) {
|
|
46597
|
-
logger.debug(
|
|
46598
|
-
`Skipping message, no ADK Conversation defined for "${handlerName}"`
|
|
46599
|
-
);
|
|
46255
|
+
logger.debug(`Skipping message, no ADK Conversation defined for "${handlerName}"`);
|
|
46600
46256
|
return;
|
|
46601
46257
|
}
|
|
46602
46258
|
await span(
|
|
@@ -46628,43 +46284,27 @@ var setup4 = (bot2) => {
|
|
|
46628
46284
|
);
|
|
46629
46285
|
});
|
|
46630
46286
|
}
|
|
46631
|
-
bot2.on.event(
|
|
46632
|
-
|
|
46633
|
-
|
|
46634
|
-
|
|
46635
|
-
|
|
46636
|
-
|
|
46637
|
-
|
|
46638
|
-
|
|
46639
|
-
|
|
46640
|
-
const workflowDefinition = adk.project.workflows.find(
|
|
46641
|
-
(w) => w.name === workflowName
|
|
46642
|
-
);
|
|
46643
|
-
if (!workflowDefinition) {
|
|
46644
|
-
logger.error(
|
|
46645
|
-
`Workflow definition not found for: ${workflowName}`
|
|
46646
|
-
);
|
|
46647
|
-
return;
|
|
46648
|
-
}
|
|
46649
|
-
await client._inner.createWorkflow({
|
|
46650
|
-
name: workflowName,
|
|
46651
|
-
status: "pending",
|
|
46652
|
-
input: {},
|
|
46653
|
-
timeoutAt: new Date(
|
|
46654
|
-
Date.now() + workflowDefinition.timeout
|
|
46655
|
-
).toISOString()
|
|
46656
|
-
});
|
|
46657
|
-
logger.info(
|
|
46658
|
-
`Successfully created workflow instance for: ${workflowName}`
|
|
46659
|
-
);
|
|
46660
|
-
} catch (error) {
|
|
46661
|
-
logger.error(
|
|
46662
|
-
`Failed to create workflow instance for ${workflowName}:`,
|
|
46663
|
-
error
|
|
46664
|
-
);
|
|
46287
|
+
bot2.on.event(WorkflowScheduleEvent.name, async ({ event, client, logger }) => {
|
|
46288
|
+
const payload = event.payload;
|
|
46289
|
+
const workflowName = payload.workflow;
|
|
46290
|
+
logger.info(`Executing scheduled workflow: ${workflowName} at ${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
46291
|
+
try {
|
|
46292
|
+
const workflowDefinition = adk.project.workflows.find((w) => w.name === workflowName);
|
|
46293
|
+
if (!workflowDefinition) {
|
|
46294
|
+
logger.error(`Workflow definition not found for: ${workflowName}`);
|
|
46295
|
+
return;
|
|
46665
46296
|
}
|
|
46297
|
+
await client._inner.createWorkflow({
|
|
46298
|
+
name: workflowName,
|
|
46299
|
+
status: "pending",
|
|
46300
|
+
input: {},
|
|
46301
|
+
timeoutAt: new Date(Date.now() + workflowDefinition.timeout).toISOString()
|
|
46302
|
+
});
|
|
46303
|
+
logger.info(`Successfully created workflow instance for: ${workflowName}`);
|
|
46304
|
+
} catch (error) {
|
|
46305
|
+
logger.error(`Failed to create workflow instance for ${workflowName}:`, error);
|
|
46666
46306
|
}
|
|
46667
|
-
);
|
|
46307
|
+
});
|
|
46668
46308
|
};
|
|
46669
46309
|
|
|
46670
46310
|
// src/runtime/handlers/index.ts
|
|
@@ -46795,15 +46435,7 @@ var IncomingRequestSpan = {
|
|
|
46795
46435
|
},
|
|
46796
46436
|
"request.method": {
|
|
46797
46437
|
type: "enum",
|
|
46798
|
-
enum: [
|
|
46799
|
-
"GET",
|
|
46800
|
-
"POST",
|
|
46801
|
-
"PUT",
|
|
46802
|
-
"DELETE",
|
|
46803
|
-
"PATCH",
|
|
46804
|
-
"HEAD",
|
|
46805
|
-
"OPTIONS"
|
|
46806
|
-
],
|
|
46438
|
+
enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
|
|
46807
46439
|
description: "The HTTP method",
|
|
46808
46440
|
title: "HTTP Method",
|
|
46809
46441
|
required: true
|
|
@@ -46962,14 +46594,7 @@ var BotpressClientSpan = {
|
|
|
46962
46594
|
"botpress.request.body": { type: "string" },
|
|
46963
46595
|
"botpress.response.body": { type: "string" },
|
|
46964
46596
|
"trace.traceparent": { type: "string" },
|
|
46965
|
-
...optional(
|
|
46966
|
-
"conversationId",
|
|
46967
|
-
"messageId",
|
|
46968
|
-
"workflowId",
|
|
46969
|
-
"userId",
|
|
46970
|
-
"eventId",
|
|
46971
|
-
"action.name"
|
|
46972
|
-
)
|
|
46597
|
+
...optional("conversationId", "messageId", "workflowId", "userId", "eventId", "action.name")
|
|
46973
46598
|
}
|
|
46974
46599
|
};
|
|
46975
46600
|
var HttpSpan = {
|
|
@@ -47001,21 +46626,8 @@ var ConversationHandlerSpan = {
|
|
|
47001
46626
|
name: "handler.conversation",
|
|
47002
46627
|
importance: "high",
|
|
47003
46628
|
attributes: {
|
|
47004
|
-
...required(
|
|
47005
|
-
|
|
47006
|
-
"conversationId",
|
|
47007
|
-
"eventId",
|
|
47008
|
-
"integration",
|
|
47009
|
-
"channel",
|
|
47010
|
-
"event.type"
|
|
47011
|
-
),
|
|
47012
|
-
...optional(
|
|
47013
|
-
"messageId",
|
|
47014
|
-
"userId",
|
|
47015
|
-
"event.payload",
|
|
47016
|
-
"message.payload",
|
|
47017
|
-
"message.type"
|
|
47018
|
-
)
|
|
46629
|
+
...required("botId", "conversationId", "eventId", "integration", "channel", "event.type"),
|
|
46630
|
+
...optional("messageId", "userId", "event.payload", "message.payload", "message.type")
|
|
47019
46631
|
}
|
|
47020
46632
|
};
|
|
47021
46633
|
var TriggerHandlerSpan = {
|
|
@@ -47023,15 +46635,7 @@ var TriggerHandlerSpan = {
|
|
|
47023
46635
|
importance: "high",
|
|
47024
46636
|
attributes: {
|
|
47025
46637
|
...required("botId", "eventId", "event.type"),
|
|
47026
|
-
...optional(
|
|
47027
|
-
"conversationId",
|
|
47028
|
-
"messageId",
|
|
47029
|
-
"userId",
|
|
47030
|
-
"integration",
|
|
47031
|
-
"channel",
|
|
47032
|
-
"workflowId",
|
|
47033
|
-
"parentWorkflowId"
|
|
47034
|
-
)
|
|
46638
|
+
...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
|
|
47035
46639
|
}
|
|
47036
46640
|
};
|
|
47037
46641
|
var EventHandlerSpan = {
|
|
@@ -47039,15 +46643,7 @@ var EventHandlerSpan = {
|
|
|
47039
46643
|
importance: "high",
|
|
47040
46644
|
attributes: {
|
|
47041
46645
|
...required("botId", "eventId", "event.type"),
|
|
47042
|
-
...optional(
|
|
47043
|
-
"conversationId",
|
|
47044
|
-
"messageId",
|
|
47045
|
-
"userId",
|
|
47046
|
-
"integration",
|
|
47047
|
-
"channel",
|
|
47048
|
-
"workflowId",
|
|
47049
|
-
"parentWorkflowId"
|
|
47050
|
-
)
|
|
46646
|
+
...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
|
|
47051
46647
|
}
|
|
47052
46648
|
};
|
|
47053
46649
|
var WorkflowHandlerSpan = {
|
|
@@ -47055,27 +46651,11 @@ var WorkflowHandlerSpan = {
|
|
|
47055
46651
|
importance: "high",
|
|
47056
46652
|
attributes: {
|
|
47057
46653
|
...required("botId", "workflowId", "eventId", "event.type"),
|
|
47058
|
-
...optional(
|
|
47059
|
-
"messageId",
|
|
47060
|
-
"userId",
|
|
47061
|
-
"integration",
|
|
47062
|
-
"channel",
|
|
47063
|
-
"conversationId",
|
|
47064
|
-
"parentWorkflowId"
|
|
47065
|
-
),
|
|
46654
|
+
...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
|
|
47066
46655
|
"workflow.name": { type: "string" },
|
|
47067
46656
|
"workflow.status.initial": {
|
|
47068
46657
|
type: "enum",
|
|
47069
|
-
enum: [
|
|
47070
|
-
"pending",
|
|
47071
|
-
"in_progress",
|
|
47072
|
-
"listening",
|
|
47073
|
-
"paused",
|
|
47074
|
-
"completed",
|
|
47075
|
-
"failed",
|
|
47076
|
-
"timedout",
|
|
47077
|
-
"cancelled"
|
|
47078
|
-
]
|
|
46658
|
+
enum: ["pending", "in_progress", "listening", "paused", "completed", "failed", "timedout", "cancelled"]
|
|
47079
46659
|
},
|
|
47080
46660
|
"workflow.status.final": {
|
|
47081
46661
|
type: "enum",
|
|
@@ -47101,14 +46681,7 @@ var ActionHandlerSpan = {
|
|
|
47101
46681
|
importance: "high",
|
|
47102
46682
|
attributes: {
|
|
47103
46683
|
...required("botId", "workflowId", "eventId", "event.type"),
|
|
47104
|
-
...optional(
|
|
47105
|
-
"messageId",
|
|
47106
|
-
"userId",
|
|
47107
|
-
"integration",
|
|
47108
|
-
"channel",
|
|
47109
|
-
"conversationId",
|
|
47110
|
-
"parentWorkflowId"
|
|
47111
|
-
),
|
|
46684
|
+
...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
|
|
47112
46685
|
"action.name": { type: "string", required: true },
|
|
47113
46686
|
"action.input": { type: "json", required: true }
|
|
47114
46687
|
}
|
|
@@ -47493,9 +47066,7 @@ function span(name, attributes, optionsOrF, f) {
|
|
|
47493
47066
|
options = optionsOrF;
|
|
47494
47067
|
handler = f;
|
|
47495
47068
|
}
|
|
47496
|
-
const spanDef = Object.values(Spans).find(
|
|
47497
|
-
(def) => def.name === name
|
|
47498
|
-
);
|
|
47069
|
+
const spanDef = Object.values(Spans).find((def) => def.name === name);
|
|
47499
47070
|
const attrsWithImportance = {
|
|
47500
47071
|
...attributes
|
|
47501
47072
|
};
|
|
@@ -47524,20 +47095,13 @@ function span(name, attributes, optionsOrF, f) {
|
|
|
47524
47095
|
}
|
|
47525
47096
|
};
|
|
47526
47097
|
if (parentContext) {
|
|
47527
|
-
return tracer.startActiveSpan(
|
|
47528
|
-
name,
|
|
47529
|
-
spanOptions,
|
|
47530
|
-
parentContext,
|
|
47531
|
-
executeInSpan
|
|
47532
|
-
);
|
|
47098
|
+
return tracer.startActiveSpan(name, spanOptions, parentContext, executeInSpan);
|
|
47533
47099
|
} else {
|
|
47534
47100
|
return tracer.startActiveSpan(name, spanOptions, executeInSpan);
|
|
47535
47101
|
}
|
|
47536
47102
|
}
|
|
47537
47103
|
var createSpan = (name, attributes, { parentContext } = {}) => {
|
|
47538
|
-
const spanDef = Object.values(Spans).find(
|
|
47539
|
-
(def) => def.name === name
|
|
47540
|
-
);
|
|
47104
|
+
const spanDef = Object.values(Spans).find((def) => def.name === name);
|
|
47541
47105
|
const attrsWithImportance = {
|
|
47542
47106
|
...attributes
|
|
47543
47107
|
};
|