@botpress/runtime 1.6.2 → 1.6.4
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 +137 -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 +156 -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 +141 -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 +223 -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 -6
package/dist/library.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.4", 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
|
|
|
@@ -34313,16 +34313,14 @@ init_define_BUILD();
|
|
|
34313
34313
|
init_define_PACKAGE_VERSIONS();
|
|
34314
34314
|
function getSingleton(key, factory2) {
|
|
34315
34315
|
if (!globalThis[key]) {
|
|
34316
|
+
;
|
|
34316
34317
|
globalThis[key] = factory2();
|
|
34317
34318
|
}
|
|
34318
34319
|
return globalThis[key];
|
|
34319
34320
|
}
|
|
34320
34321
|
|
|
34321
34322
|
// src/runtime/context/context.ts
|
|
34322
|
-
var storage = getSingleton(
|
|
34323
|
-
"__ADK_GLOBAL_CTX_STORAGE",
|
|
34324
|
-
() => new AsyncLocalStorage()
|
|
34325
|
-
);
|
|
34323
|
+
var storage = getSingleton("__ADK_GLOBAL_CTX_STORAGE", () => new AsyncLocalStorage());
|
|
34326
34324
|
var context = {
|
|
34327
34325
|
enterWith: (data) => {
|
|
34328
34326
|
storage.enterWith(data);
|
|
@@ -34337,10 +34335,7 @@ var context = {
|
|
|
34337
34335
|
},
|
|
34338
34336
|
getAll: () => {
|
|
34339
34337
|
const store = storage.getStore();
|
|
34340
|
-
if (!store)
|
|
34341
|
-
throw new Error(
|
|
34342
|
-
"No context found. Did you forget to call `context.run()`?"
|
|
34343
|
-
);
|
|
34338
|
+
if (!store) throw new Error("No context found. Did you forget to call `context.run()`?");
|
|
34344
34339
|
return store;
|
|
34345
34340
|
},
|
|
34346
34341
|
get: (key, opts) => {
|
|
@@ -34514,10 +34509,7 @@ var INDEX_DIR2 = path2.join(DIR2, "index");
|
|
|
34514
34509
|
var append = (o) => fs2.appendFile(LIVE, JSON.stringify(o) + "\n", () => {
|
|
34515
34510
|
});
|
|
34516
34511
|
var appendToDay = (o) => {
|
|
34517
|
-
const dayFile2 = path2.join(
|
|
34518
|
-
DIR2,
|
|
34519
|
-
`${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
|
|
34520
|
-
);
|
|
34512
|
+
const dayFile2 = path2.join(DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
|
|
34521
34513
|
fs2.appendFile(dayFile2, JSON.stringify(o) + "\n", () => {
|
|
34522
34514
|
});
|
|
34523
34515
|
};
|
|
@@ -34527,10 +34519,7 @@ var appendToTrace = (traceId, o) => {
|
|
|
34527
34519
|
});
|
|
34528
34520
|
};
|
|
34529
34521
|
var appendToIndex = (o) => {
|
|
34530
|
-
const indexFile2 = path2.join(
|
|
34531
|
-
INDEX_DIR2,
|
|
34532
|
-
`${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
|
|
34533
|
-
);
|
|
34522
|
+
const indexFile2 = path2.join(INDEX_DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
|
|
34534
34523
|
fs2.appendFile(indexFile2, JSON.stringify(o) + "\n", () => {
|
|
34535
34524
|
});
|
|
34536
34525
|
};
|
|
@@ -34544,8 +34533,7 @@ var LiveFileSpanProcessor = class {
|
|
|
34544
34533
|
this.timer = setInterval(() => {
|
|
34545
34534
|
if (!this.active.size) return;
|
|
34546
34535
|
const ts = nowNs();
|
|
34547
|
-
for (const [spanId, traceId] of this.active)
|
|
34548
|
-
append({ t: "beat", traceId, spanId, ts });
|
|
34536
|
+
for (const [spanId, traceId] of this.active) append({ t: "beat", traceId, spanId, ts });
|
|
34549
34537
|
}, beatMs);
|
|
34550
34538
|
this.timer.unref?.();
|
|
34551
34539
|
}
|
|
@@ -34555,9 +34543,7 @@ var LiveFileSpanProcessor = class {
|
|
|
34555
34543
|
onStart(span2, _ctx) {
|
|
34556
34544
|
const ctx = span2.spanContext();
|
|
34557
34545
|
this.active.set(ctx.spanId, ctx.traceId);
|
|
34558
|
-
const startNs = Number(
|
|
34559
|
-
span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs()
|
|
34560
|
-
);
|
|
34546
|
+
const startNs = Number(span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs());
|
|
34561
34547
|
const startEvent = {
|
|
34562
34548
|
t: "start",
|
|
34563
34549
|
traceId: ctx.traceId,
|
|
@@ -34582,13 +34568,7 @@ var LiveFileSpanProcessor = class {
|
|
|
34582
34568
|
handler: span2.name
|
|
34583
34569
|
// Use span name as handler
|
|
34584
34570
|
};
|
|
34585
|
-
const trackedIds = [
|
|
34586
|
-
"conversationId",
|
|
34587
|
-
"messageId",
|
|
34588
|
-
"eventId",
|
|
34589
|
-
"userId",
|
|
34590
|
-
"workflowId"
|
|
34591
|
-
];
|
|
34571
|
+
const trackedIds = ["conversationId", "messageId", "eventId", "userId", "workflowId"];
|
|
34592
34572
|
for (const idKey of trackedIds) {
|
|
34593
34573
|
if (span2.attributes[idKey]) {
|
|
34594
34574
|
indexEntry[idKey] = span2.attributes[idKey];
|
|
@@ -34690,8 +34670,7 @@ function extractIds(fullUrl, body) {
|
|
|
34690
34670
|
if (userMatch?.[1]) ids.userId = userMatch[1];
|
|
34691
34671
|
if (eventMatch?.[1]) ids.eventId = eventMatch[1];
|
|
34692
34672
|
if (body && typeof body === "object") {
|
|
34693
|
-
if (body.conversationId && !ids.conversationId)
|
|
34694
|
-
ids.conversationId = body.conversationId;
|
|
34673
|
+
if (body.conversationId && !ids.conversationId) ids.conversationId = body.conversationId;
|
|
34695
34674
|
if (body.messageId && !ids.messageId) ids.messageId = body.messageId;
|
|
34696
34675
|
if (body.workflowId && !ids.workflowId) ids.workflowId = body.workflowId;
|
|
34697
34676
|
if (body.userId && !ids.userId) ids.userId = body.userId;
|
|
@@ -34699,9 +34678,7 @@ function extractIds(fullUrl, body) {
|
|
|
34699
34678
|
}
|
|
34700
34679
|
return ids;
|
|
34701
34680
|
}
|
|
34702
|
-
function installHttpClientInstrumentation({
|
|
34703
|
-
injectTraceHeader = true
|
|
34704
|
-
} = {}) {
|
|
34681
|
+
function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
34705
34682
|
const restores = [];
|
|
34706
34683
|
const genId = (n) => randomBytes(n).toString("hex");
|
|
34707
34684
|
const makeTraceparent = () => `00-${genId(16)}-${genId(8)}-01`;
|
|
@@ -34771,8 +34748,7 @@ function installHttpClientInstrumentation({
|
|
|
34771
34748
|
},
|
|
34772
34749
|
context2.active()
|
|
34773
34750
|
);
|
|
34774
|
-
if (injectTraceHeader && !("traceparent" in options.headers))
|
|
34775
|
-
options.headers.traceparent = traceparent;
|
|
34751
|
+
if (injectTraceHeader && !("traceparent" in options.headers)) options.headers.traceparent = traceparent;
|
|
34776
34752
|
let req;
|
|
34777
34753
|
if (typeof args[0] === "string" || args[0] instanceof URL) {
|
|
34778
34754
|
req = requestFn.call(this, args[0], options, cb);
|
|
@@ -34794,18 +34770,12 @@ function installHttpClientInstrumentation({
|
|
|
34794
34770
|
}
|
|
34795
34771
|
if (requestBodyChunks.length > 0) {
|
|
34796
34772
|
const bodyString = Buffer.concat(requestBodyChunks).toString("utf-8");
|
|
34797
|
-
span2.setAttribute(
|
|
34798
|
-
isBotpress ? "botpress.request.body" : "http.request.body",
|
|
34799
|
-
bodyString
|
|
34800
|
-
);
|
|
34773
|
+
span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", bodyString);
|
|
34801
34774
|
}
|
|
34802
34775
|
return origEnd(chunk, ...args2);
|
|
34803
34776
|
};
|
|
34804
34777
|
req.on("response", (res) => {
|
|
34805
|
-
span2.setAttribute(
|
|
34806
|
-
isBotpress ? "botpress.status_code" : "http.status_code",
|
|
34807
|
-
res.statusCode || 0
|
|
34808
|
-
);
|
|
34778
|
+
span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", res.statusCode || 0);
|
|
34809
34779
|
const responseBodyChunks = [];
|
|
34810
34780
|
res.on("data", (chunk) => {
|
|
34811
34781
|
responseBodyChunks.push(chunk);
|
|
@@ -34813,10 +34783,7 @@ function installHttpClientInstrumentation({
|
|
|
34813
34783
|
res.on("end", () => {
|
|
34814
34784
|
if (responseBodyChunks.length > 0) {
|
|
34815
34785
|
const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
|
|
34816
|
-
span2.setAttribute(
|
|
34817
|
-
isBotpress ? "botpress.response.body" : "http.response.body",
|
|
34818
|
-
bodyString
|
|
34819
|
-
);
|
|
34786
|
+
span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
|
|
34820
34787
|
}
|
|
34821
34788
|
if ((res.statusCode || 0) >= 400) {
|
|
34822
34789
|
span2.setStatus({
|
|
@@ -34828,10 +34795,7 @@ function installHttpClientInstrumentation({
|
|
|
34828
34795
|
});
|
|
34829
34796
|
});
|
|
34830
34797
|
req.on("error", (err) => {
|
|
34831
|
-
span2.setAttribute(
|
|
34832
|
-
isBotpress ? "botpress.error" : "http.error",
|
|
34833
|
-
err.message
|
|
34834
|
-
);
|
|
34798
|
+
span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
|
|
34835
34799
|
span2.recordException(err);
|
|
34836
34800
|
span2.setStatus({
|
|
34837
34801
|
code: SpanStatusCode.ERROR,
|
|
@@ -34849,6 +34813,7 @@ function installHttpClientInstrumentation({
|
|
|
34849
34813
|
httpsRequest: https.request,
|
|
34850
34814
|
httpsGet: https.get
|
|
34851
34815
|
};
|
|
34816
|
+
;
|
|
34852
34817
|
http.request = wrapRequest2(orig.httpRequest);
|
|
34853
34818
|
https.request = wrapRequest2(orig.httpsRequest);
|
|
34854
34819
|
http.get = function wrappedGet(...a) {
|
|
@@ -34942,10 +34907,7 @@ function installHttpClientInstrumentation({
|
|
|
34942
34907
|
}
|
|
34943
34908
|
}
|
|
34944
34909
|
if (requestBody) {
|
|
34945
|
-
span2.setAttribute(
|
|
34946
|
-
isBotpress ? "botpress.request.body" : "http.request.body",
|
|
34947
|
-
requestBody
|
|
34948
|
-
);
|
|
34910
|
+
span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", requestBody);
|
|
34949
34911
|
}
|
|
34950
34912
|
}
|
|
34951
34913
|
const traceparent = makeTraceparent();
|
|
@@ -34953,10 +34915,7 @@ function installHttpClientInstrumentation({
|
|
|
34953
34915
|
if (Array.isArray(opts.headers)) {
|
|
34954
34916
|
headers.push(...opts.headers);
|
|
34955
34917
|
} else if (opts.headers && typeof opts.headers === "object") {
|
|
34956
|
-
for (const [k, v] of Object.entries(
|
|
34957
|
-
opts.headers
|
|
34958
|
-
))
|
|
34959
|
-
headers.push(k, String(v));
|
|
34918
|
+
for (const [k, v] of Object.entries(opts.headers)) headers.push(k, String(v));
|
|
34960
34919
|
}
|
|
34961
34920
|
headers.push(INSTRUMENTED_HEADER, "true");
|
|
34962
34921
|
if (injectTraceHeader) {
|
|
@@ -34974,10 +34933,7 @@ function installHttpClientInstrumentation({
|
|
|
34974
34933
|
onConnect: handler.onConnect?.bind(handler),
|
|
34975
34934
|
onUpgrade: handler.onUpgrade?.bind(handler),
|
|
34976
34935
|
onHeaders: (statusCode, rawHeaders, resume) => {
|
|
34977
|
-
span2.setAttribute(
|
|
34978
|
-
isBotpress ? "botpress.status_code" : "http.status_code",
|
|
34979
|
-
statusCode
|
|
34980
|
-
);
|
|
34936
|
+
span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", statusCode);
|
|
34981
34937
|
if (statusCode >= 500) {
|
|
34982
34938
|
span2.setStatus({
|
|
34983
34939
|
code: SpanStatusCode.ERROR,
|
|
@@ -34992,10 +34948,7 @@ function installHttpClientInstrumentation({
|
|
|
34992
34948
|
handler.onHeaders?.(statusCode, rawHeaders, resume);
|
|
34993
34949
|
},
|
|
34994
34950
|
onError: (err) => {
|
|
34995
|
-
span2.setAttribute(
|
|
34996
|
-
isBotpress ? "botpress.error" : "http.error",
|
|
34997
|
-
err.message
|
|
34998
|
-
);
|
|
34951
|
+
span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
|
|
34999
34952
|
span2.recordException(err);
|
|
35000
34953
|
span2.setStatus({
|
|
35001
34954
|
code: SpanStatusCode.ERROR,
|
|
@@ -35012,10 +34965,7 @@ function installHttpClientInstrumentation({
|
|
|
35012
34965
|
onComplete: (trailers) => {
|
|
35013
34966
|
if (responseBodyChunks.length > 0) {
|
|
35014
34967
|
const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
|
|
35015
|
-
span2.setAttribute(
|
|
35016
|
-
isBotpress ? "botpress.response.body" : "http.response.body",
|
|
35017
|
-
bodyString
|
|
35018
|
-
);
|
|
34968
|
+
span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
|
|
35019
34969
|
}
|
|
35020
34970
|
span2.end();
|
|
35021
34971
|
handler.onComplete?.(trailers);
|
|
@@ -35187,10 +35137,8 @@ function inspectToJsonSize(input, opts) {
|
|
|
35187
35137
|
if (value === null) return null;
|
|
35188
35138
|
const t = typeof value;
|
|
35189
35139
|
if (t === "boolean" || t === "number") return value;
|
|
35190
|
-
if (t === "string")
|
|
35191
|
-
|
|
35192
|
-
if (t === "bigint")
|
|
35193
|
-
return elideString(String(value), limits2.head, limits2.tail);
|
|
35140
|
+
if (t === "string") return elideString(value, limits2.head, limits2.tail);
|
|
35141
|
+
if (t === "bigint") return elideString(String(value), limits2.head, limits2.tail);
|
|
35194
35142
|
if (t === "symbol" || t === "function" || t === "undefined") {
|
|
35195
35143
|
return null;
|
|
35196
35144
|
}
|
|
@@ -35245,8 +35193,7 @@ function inspectToJsonSize(input, opts) {
|
|
|
35245
35193
|
const k = keys[i];
|
|
35246
35194
|
props[k] = summarize(value[k], seen, nextLimits);
|
|
35247
35195
|
}
|
|
35248
|
-
if (keys.length > keep)
|
|
35249
|
-
props["__truncated__"] = `+${keys.length - keep} keys`;
|
|
35196
|
+
if (keys.length > keep) props["__truncated__"] = `+${keys.length - keep} keys`;
|
|
35250
35197
|
seen.delete(value);
|
|
35251
35198
|
return { [`<${tag}>`]: props };
|
|
35252
35199
|
}
|
|
@@ -35456,15 +35403,7 @@ var IncomingRequestSpan = {
|
|
|
35456
35403
|
},
|
|
35457
35404
|
"request.method": {
|
|
35458
35405
|
type: "enum",
|
|
35459
|
-
enum: [
|
|
35460
|
-
"GET",
|
|
35461
|
-
"POST",
|
|
35462
|
-
"PUT",
|
|
35463
|
-
"DELETE",
|
|
35464
|
-
"PATCH",
|
|
35465
|
-
"HEAD",
|
|
35466
|
-
"OPTIONS"
|
|
35467
|
-
],
|
|
35406
|
+
enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
|
|
35468
35407
|
description: "The HTTP method",
|
|
35469
35408
|
title: "HTTP Method",
|
|
35470
35409
|
required: true
|
|
@@ -35623,14 +35562,7 @@ var BotpressClientSpan = {
|
|
|
35623
35562
|
"botpress.request.body": { type: "string" },
|
|
35624
35563
|
"botpress.response.body": { type: "string" },
|
|
35625
35564
|
"trace.traceparent": { type: "string" },
|
|
35626
|
-
...optional(
|
|
35627
|
-
"conversationId",
|
|
35628
|
-
"messageId",
|
|
35629
|
-
"workflowId",
|
|
35630
|
-
"userId",
|
|
35631
|
-
"eventId",
|
|
35632
|
-
"action.name"
|
|
35633
|
-
)
|
|
35565
|
+
...optional("conversationId", "messageId", "workflowId", "userId", "eventId", "action.name")
|
|
35634
35566
|
}
|
|
35635
35567
|
};
|
|
35636
35568
|
var HttpSpan = {
|
|
@@ -35662,21 +35594,8 @@ var ConversationHandlerSpan = {
|
|
|
35662
35594
|
name: "handler.conversation",
|
|
35663
35595
|
importance: "high",
|
|
35664
35596
|
attributes: {
|
|
35665
|
-
...required(
|
|
35666
|
-
|
|
35667
|
-
"conversationId",
|
|
35668
|
-
"eventId",
|
|
35669
|
-
"integration",
|
|
35670
|
-
"channel",
|
|
35671
|
-
"event.type"
|
|
35672
|
-
),
|
|
35673
|
-
...optional(
|
|
35674
|
-
"messageId",
|
|
35675
|
-
"userId",
|
|
35676
|
-
"event.payload",
|
|
35677
|
-
"message.payload",
|
|
35678
|
-
"message.type"
|
|
35679
|
-
)
|
|
35597
|
+
...required("botId", "conversationId", "eventId", "integration", "channel", "event.type"),
|
|
35598
|
+
...optional("messageId", "userId", "event.payload", "message.payload", "message.type")
|
|
35680
35599
|
}
|
|
35681
35600
|
};
|
|
35682
35601
|
var TriggerHandlerSpan = {
|
|
@@ -35684,15 +35603,7 @@ var TriggerHandlerSpan = {
|
|
|
35684
35603
|
importance: "high",
|
|
35685
35604
|
attributes: {
|
|
35686
35605
|
...required("botId", "eventId", "event.type"),
|
|
35687
|
-
...optional(
|
|
35688
|
-
"conversationId",
|
|
35689
|
-
"messageId",
|
|
35690
|
-
"userId",
|
|
35691
|
-
"integration",
|
|
35692
|
-
"channel",
|
|
35693
|
-
"workflowId",
|
|
35694
|
-
"parentWorkflowId"
|
|
35695
|
-
)
|
|
35606
|
+
...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
|
|
35696
35607
|
}
|
|
35697
35608
|
};
|
|
35698
35609
|
var EventHandlerSpan = {
|
|
@@ -35700,15 +35611,7 @@ var EventHandlerSpan = {
|
|
|
35700
35611
|
importance: "high",
|
|
35701
35612
|
attributes: {
|
|
35702
35613
|
...required("botId", "eventId", "event.type"),
|
|
35703
|
-
...optional(
|
|
35704
|
-
"conversationId",
|
|
35705
|
-
"messageId",
|
|
35706
|
-
"userId",
|
|
35707
|
-
"integration",
|
|
35708
|
-
"channel",
|
|
35709
|
-
"workflowId",
|
|
35710
|
-
"parentWorkflowId"
|
|
35711
|
-
)
|
|
35614
|
+
...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
|
|
35712
35615
|
}
|
|
35713
35616
|
};
|
|
35714
35617
|
var WorkflowHandlerSpan = {
|
|
@@ -35716,27 +35619,11 @@ var WorkflowHandlerSpan = {
|
|
|
35716
35619
|
importance: "high",
|
|
35717
35620
|
attributes: {
|
|
35718
35621
|
...required("botId", "workflowId", "eventId", "event.type"),
|
|
35719
|
-
...optional(
|
|
35720
|
-
"messageId",
|
|
35721
|
-
"userId",
|
|
35722
|
-
"integration",
|
|
35723
|
-
"channel",
|
|
35724
|
-
"conversationId",
|
|
35725
|
-
"parentWorkflowId"
|
|
35726
|
-
),
|
|
35622
|
+
...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
|
|
35727
35623
|
"workflow.name": { type: "string" },
|
|
35728
35624
|
"workflow.status.initial": {
|
|
35729
35625
|
type: "enum",
|
|
35730
|
-
enum: [
|
|
35731
|
-
"pending",
|
|
35732
|
-
"in_progress",
|
|
35733
|
-
"listening",
|
|
35734
|
-
"paused",
|
|
35735
|
-
"completed",
|
|
35736
|
-
"failed",
|
|
35737
|
-
"timedout",
|
|
35738
|
-
"cancelled"
|
|
35739
|
-
]
|
|
35626
|
+
enum: ["pending", "in_progress", "listening", "paused", "completed", "failed", "timedout", "cancelled"]
|
|
35740
35627
|
},
|
|
35741
35628
|
"workflow.status.final": {
|
|
35742
35629
|
type: "enum",
|
|
@@ -35762,14 +35649,7 @@ var ActionHandlerSpan = {
|
|
|
35762
35649
|
importance: "high",
|
|
35763
35650
|
attributes: {
|
|
35764
35651
|
...required("botId", "workflowId", "eventId", "event.type"),
|
|
35765
|
-
...optional(
|
|
35766
|
-
"messageId",
|
|
35767
|
-
"userId",
|
|
35768
|
-
"integration",
|
|
35769
|
-
"channel",
|
|
35770
|
-
"conversationId",
|
|
35771
|
-
"parentWorkflowId"
|
|
35772
|
-
),
|
|
35652
|
+
...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
|
|
35773
35653
|
"action.name": { type: "string", required: true },
|
|
35774
35654
|
"action.input": { type: "json", required: true }
|
|
35775
35655
|
}
|
|
@@ -36154,9 +36034,7 @@ function span(name, attributes, optionsOrF, f) {
|
|
|
36154
36034
|
options = optionsOrF;
|
|
36155
36035
|
handler = f;
|
|
36156
36036
|
}
|
|
36157
|
-
const spanDef = Object.values(Spans).find(
|
|
36158
|
-
(def) => def.name === name
|
|
36159
|
-
);
|
|
36037
|
+
const spanDef = Object.values(Spans).find((def) => def.name === name);
|
|
36160
36038
|
const attrsWithImportance = {
|
|
36161
36039
|
...attributes
|
|
36162
36040
|
};
|
|
@@ -36185,20 +36063,13 @@ function span(name, attributes, optionsOrF, f) {
|
|
|
36185
36063
|
}
|
|
36186
36064
|
};
|
|
36187
36065
|
if (parentContext) {
|
|
36188
|
-
return tracer.startActiveSpan(
|
|
36189
|
-
name,
|
|
36190
|
-
spanOptions,
|
|
36191
|
-
parentContext,
|
|
36192
|
-
executeInSpan
|
|
36193
|
-
);
|
|
36066
|
+
return tracer.startActiveSpan(name, spanOptions, parentContext, executeInSpan);
|
|
36194
36067
|
} else {
|
|
36195
36068
|
return tracer.startActiveSpan(name, spanOptions, executeInSpan);
|
|
36196
36069
|
}
|
|
36197
36070
|
}
|
|
36198
36071
|
var createSpan = (name, attributes, { parentContext } = {}) => {
|
|
36199
|
-
const spanDef = Object.values(Spans).find(
|
|
36200
|
-
(def) => def.name === name
|
|
36201
|
-
);
|
|
36072
|
+
const spanDef = Object.values(Spans).find((def) => def.name === name);
|
|
36202
36073
|
const attrsWithImportance = {
|
|
36203
36074
|
...attributes
|
|
36204
36075
|
};
|
|
@@ -36266,9 +36137,7 @@ var getPromiseTracker = () => {
|
|
|
36266
36137
|
if (tracker) {
|
|
36267
36138
|
return tracker;
|
|
36268
36139
|
}
|
|
36269
|
-
throw new Error(
|
|
36270
|
-
"PromiseTracker not found in context. Make sure to initialize it in your runtime setup."
|
|
36271
|
-
);
|
|
36140
|
+
throw new Error("PromiseTracker not found in context. Make sure to initialize it in your runtime setup.");
|
|
36272
36141
|
};
|
|
36273
36142
|
function trackPromise(promise) {
|
|
36274
36143
|
return getPromiseTracker().register(promise);
|
|
@@ -36332,16 +36201,11 @@ var AgentRegistry = class {
|
|
|
36332
36201
|
}
|
|
36333
36202
|
ensureInitialized() {
|
|
36334
36203
|
if (!this._data) {
|
|
36335
|
-
throw new Error(
|
|
36336
|
-
"Agent registry not initialized. Call agentRegistry.initialize() during bot startup."
|
|
36337
|
-
);
|
|
36204
|
+
throw new Error("Agent registry not initialized. Call agentRegistry.initialize() during bot startup.");
|
|
36338
36205
|
}
|
|
36339
36206
|
}
|
|
36340
36207
|
};
|
|
36341
|
-
var agentRegistry = getSingleton(
|
|
36342
|
-
"__ADK_GLOBAL_AGENT_REGISTRY",
|
|
36343
|
-
() => new AgentRegistry()
|
|
36344
|
-
);
|
|
36208
|
+
var agentRegistry = getSingleton("__ADK_GLOBAL_AGENT_REGISTRY", () => new AgentRegistry());
|
|
36345
36209
|
|
|
36346
36210
|
// src/runtime/tracked-state.ts
|
|
36347
36211
|
init_define_BUILD();
|
|
@@ -40139,9 +40003,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
40139
40003
|
init_define_BUILD();
|
|
40140
40004
|
init_define_PACKAGE_VERSIONS();
|
|
40141
40005
|
init_esm();
|
|
40142
|
-
import {
|
|
40143
|
-
getValue
|
|
40144
|
-
} from "llmz";
|
|
40006
|
+
import { getValue } from "llmz";
|
|
40145
40007
|
import {
|
|
40146
40008
|
Tool as LlmzTool,
|
|
40147
40009
|
ThinkSignal as _ThinkSignal,
|
|
@@ -40159,9 +40021,7 @@ init_define_BUILD();
|
|
|
40159
40021
|
init_define_PACKAGE_VERSIONS();
|
|
40160
40022
|
function createJoinedAbortController(signals) {
|
|
40161
40023
|
const controller = new AbortController();
|
|
40162
|
-
const validSignals = signals.filter(
|
|
40163
|
-
(signal) => signal != null
|
|
40164
|
-
);
|
|
40024
|
+
const validSignals = signals.filter((signal) => signal != null);
|
|
40165
40025
|
if (validSignals.length === 0) {
|
|
40166
40026
|
return controller;
|
|
40167
40027
|
}
|
|
@@ -40286,9 +40146,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
40286
40146
|
const client = context.get("client");
|
|
40287
40147
|
const citations = context.get("citations");
|
|
40288
40148
|
if (!client) {
|
|
40289
|
-
throw new Error(
|
|
40290
|
-
"Client is not available in this context. Make sure to run in a context with a client."
|
|
40291
|
-
);
|
|
40149
|
+
throw new Error("Client is not available in this context. Make sure to run in a context with a client.");
|
|
40292
40150
|
}
|
|
40293
40151
|
const { passages } = await client.searchFiles({
|
|
40294
40152
|
query,
|
|
@@ -40338,9 +40196,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
40338
40196
|
citationMetadata.sourceId = tags[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID];
|
|
40339
40197
|
}
|
|
40340
40198
|
const { tag } = citations.registerSource(citationMetadata);
|
|
40341
|
-
message.push(
|
|
40342
|
-
`<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`
|
|
40343
|
-
);
|
|
40199
|
+
message.push(`<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`);
|
|
40344
40200
|
message.push(p.content);
|
|
40345
40201
|
message.push(`</${tag}>`);
|
|
40346
40202
|
}
|
|
@@ -40356,9 +40212,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
40356
40212
|
return async (props) => {
|
|
40357
40213
|
const cognitive = context.get("cognitive");
|
|
40358
40214
|
if (!cognitive) {
|
|
40359
|
-
throw new Error(
|
|
40360
|
-
"Cognitive client is not available in this context. Make sure to run in a cognitive context."
|
|
40361
|
-
);
|
|
40215
|
+
throw new Error("Cognitive client is not available in this context. Make sure to run in a cognitive context.");
|
|
40362
40216
|
}
|
|
40363
40217
|
const defaultTemperature = 0.7;
|
|
40364
40218
|
const maxLoops = import_lodash2.default.clamp(props.iterations ?? 10, 1, 100);
|
|
@@ -40370,10 +40224,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
40370
40224
|
"autonomous.mode": options.mode
|
|
40371
40225
|
},
|
|
40372
40226
|
async (execSpan) => {
|
|
40373
|
-
const joinedSignal = createJoinedAbortSignal([
|
|
40374
|
-
props.signal,
|
|
40375
|
-
options.interruption
|
|
40376
|
-
]);
|
|
40227
|
+
const joinedSignal = createJoinedAbortSignal([props.signal, options.interruption]);
|
|
40377
40228
|
const llmz_execute = (await import("llmz")).execute;
|
|
40378
40229
|
const asyncResource = new AsyncResource("autonomous.execution");
|
|
40379
40230
|
const getNewIteration = (index) => createSpan(
|
|
@@ -40391,17 +40242,11 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
40391
40242
|
);
|
|
40392
40243
|
const _chat = options.mode === "chat" ? context.get("chat") : void 0;
|
|
40393
40244
|
if (options.mode === "chat" && !_chat) {
|
|
40394
|
-
throw new Error(
|
|
40395
|
-
"Chat is not available in this context. Make sure to run in chat mode with a chat context."
|
|
40396
|
-
);
|
|
40245
|
+
throw new Error("Chat is not available in this context. Make sure to run in chat mode with a chat context.");
|
|
40397
40246
|
}
|
|
40398
40247
|
const chat = _chat ? {
|
|
40399
|
-
components: bindContext(
|
|
40400
|
-
|
|
40401
|
-
),
|
|
40402
|
-
transcript: bindContext(
|
|
40403
|
-
(ctx) => getValue(_chat.transcript, ctx)
|
|
40404
|
-
),
|
|
40248
|
+
components: bindContext((ctx) => getValue(_chat.components, ctx)),
|
|
40249
|
+
transcript: bindContext((ctx) => getValue(_chat.transcript, ctx)),
|
|
40405
40250
|
handler: bindContext(_chat.handler),
|
|
40406
40251
|
onExecutionDone: bindContext(_chat.onExecutionDone)
|
|
40407
40252
|
} : void 0;
|
|
@@ -40436,10 +40281,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40436
40281
|
...props.objects && {
|
|
40437
40282
|
objects: async (ctx) => {
|
|
40438
40283
|
const objs = await getValue(props.objects, ctx) ?? [];
|
|
40439
|
-
iterationSpan?.setAttribute(
|
|
40440
|
-
"autonomous.objects",
|
|
40441
|
-
objs.map((o) => o.name).join(", ")
|
|
40442
|
-
);
|
|
40284
|
+
iterationSpan?.setAttribute("autonomous.objects", objs.map((o) => o.name).join(", "));
|
|
40443
40285
|
for (const obj of objs) {
|
|
40444
40286
|
obj.tools = obj.tools?.map(
|
|
40445
40287
|
(tool) => tool.clone({
|
|
@@ -40503,10 +40345,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40503
40345
|
if (search_knowledge) {
|
|
40504
40346
|
allTools.push(search_knowledge);
|
|
40505
40347
|
}
|
|
40506
|
-
iterationSpan?.setAttribute(
|
|
40507
|
-
"autonomous.tools",
|
|
40508
|
-
allTools?.map((t) => t.name).join(", ")
|
|
40509
|
-
);
|
|
40348
|
+
iterationSpan?.setAttribute("autonomous.tools", allTools?.map((t) => t.name).join(", "));
|
|
40510
40349
|
return allTools.map(
|
|
40511
40350
|
(tool) => tool.clone({
|
|
40512
40351
|
handler: asyncResource.bind((args, ctx2) => {
|
|
@@ -40568,9 +40407,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40568
40407
|
onAfterTool: asyncResource.bind(props.hooks.onAfterTool)
|
|
40569
40408
|
},
|
|
40570
40409
|
...props.hooks?.onBeforeExecution && {
|
|
40571
|
-
onBeforeExecution: asyncResource.bind(
|
|
40572
|
-
props.hooks.onBeforeExecution
|
|
40573
|
-
)
|
|
40410
|
+
onBeforeExecution: asyncResource.bind(props.hooks.onBeforeExecution)
|
|
40574
40411
|
},
|
|
40575
40412
|
...props.hooks?.onExit && {
|
|
40576
40413
|
onExit: asyncResource.bind(props.hooks.onExit)
|
|
@@ -40589,9 +40426,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40589
40426
|
});
|
|
40590
40427
|
}
|
|
40591
40428
|
if (props.hooks?.onTrace) {
|
|
40592
|
-
return asyncResource.runInAsyncScope(
|
|
40593
|
-
() => props.hooks.onTrace({ trace: trace2, iteration })
|
|
40594
|
-
);
|
|
40429
|
+
return asyncResource.runInAsyncScope(() => props.hooks.onTrace({ trace: trace2, iteration }));
|
|
40595
40430
|
}
|
|
40596
40431
|
},
|
|
40597
40432
|
onIterationEnd: async (iteration, controller) => {
|
|
@@ -40617,9 +40452,7 @@ ${iteration.status.execution_error.stack}`;
|
|
|
40617
40452
|
} else if (iteration.status.type === "invalid_code_error") {
|
|
40618
40453
|
message = `Iteration failed due to invalid code: ${iteration.status.invalid_code_error.message}`;
|
|
40619
40454
|
}
|
|
40620
|
-
iterationSpan?.recordException(
|
|
40621
|
-
iteration.error ?? new Error(message)
|
|
40622
|
-
);
|
|
40455
|
+
iterationSpan?.recordException(iteration.error ?? new Error(message));
|
|
40623
40456
|
iterationSpan?.setStatus({
|
|
40624
40457
|
code: SpanStatusCode.ERROR,
|
|
40625
40458
|
message
|
|
@@ -40641,16 +40474,11 @@ ${iteration.status.execution_error.stack}`;
|
|
|
40641
40474
|
}
|
|
40642
40475
|
iterationSpan?.end();
|
|
40643
40476
|
if (props.hooks?.onIterationEnd) {
|
|
40644
|
-
return await asyncResource.runInAsyncScope(
|
|
40645
|
-
() => props.hooks.onIterationEnd(iteration, controller)
|
|
40646
|
-
);
|
|
40477
|
+
return await asyncResource.runInAsyncScope(() => props.hooks.onIterationEnd(iteration, controller));
|
|
40647
40478
|
}
|
|
40648
40479
|
}
|
|
40649
40480
|
});
|
|
40650
|
-
execSpan.setAttribute(
|
|
40651
|
-
"autonomous.execution_id",
|
|
40652
|
-
execution.context.id
|
|
40653
|
-
);
|
|
40481
|
+
execSpan.setAttribute("autonomous.execution_id", execution.context.id);
|
|
40654
40482
|
return execution;
|
|
40655
40483
|
}
|
|
40656
40484
|
);
|
|
@@ -40693,22 +40521,16 @@ var actions = new Proxy({}, {
|
|
|
40693
40521
|
}
|
|
40694
40522
|
integrations ??= context.get("integrations", { optional: true });
|
|
40695
40523
|
client ??= context.get("client", { optional: true });
|
|
40696
|
-
const integration = integrations.find(
|
|
40697
|
-
(i) => i.alias === integrationName
|
|
40698
|
-
);
|
|
40524
|
+
const integration = integrations.find((i) => i.alias === integrationName);
|
|
40699
40525
|
const actionDef = integration?.definition.actions?.[actionName];
|
|
40700
40526
|
const handler = async (params) => {
|
|
40701
40527
|
integrations ??= context.get("integrations", { optional: true });
|
|
40702
40528
|
client ??= context.get("client", { optional: true });
|
|
40703
40529
|
if (!integration || !actionDef) {
|
|
40704
|
-
throw new Error(
|
|
40705
|
-
`Could not find integration "${integrationName}" and action "${actionName}"`
|
|
40706
|
-
);
|
|
40530
|
+
throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
|
|
40707
40531
|
}
|
|
40708
40532
|
if (!integration.definition.actions?.[actionName]) {
|
|
40709
|
-
throw new Error(
|
|
40710
|
-
`Action "${actionName}" not found in integration "${integrationName}"`
|
|
40711
|
-
);
|
|
40533
|
+
throw new Error(`Action "${actionName}" not found in integration "${integrationName}"`);
|
|
40712
40534
|
}
|
|
40713
40535
|
return client.callAction({
|
|
40714
40536
|
type: `${integration.alias}:${actionName}`,
|
|
@@ -40717,9 +40539,7 @@ var actions = new Proxy({}, {
|
|
|
40717
40539
|
};
|
|
40718
40540
|
handler.asTool = () => {
|
|
40719
40541
|
if (!integration || !actionDef) {
|
|
40720
|
-
throw new Error(
|
|
40721
|
-
`Could not find integration "${integrationName}" and action "${actionName}"`
|
|
40722
|
-
);
|
|
40542
|
+
throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
|
|
40723
40543
|
}
|
|
40724
40544
|
return new Autonomous.Tool({
|
|
40725
40545
|
name: actionName,
|
|
@@ -40737,9 +40557,7 @@ var actions = new Proxy({}, {
|
|
|
40737
40557
|
optional: true
|
|
40738
40558
|
});
|
|
40739
40559
|
if (!integrations2) return [];
|
|
40740
|
-
const integration = integrations2.find(
|
|
40741
|
-
(i) => i.alias === integrationName
|
|
40742
|
-
);
|
|
40560
|
+
const integration = integrations2.find((i) => i.alias === integrationName);
|
|
40743
40561
|
if (!integration?.definition?.actions) return [];
|
|
40744
40562
|
return Object.keys(integration.definition.actions);
|
|
40745
40563
|
} catch {
|
|
@@ -40752,9 +40570,7 @@ var actions = new Proxy({}, {
|
|
|
40752
40570
|
optional: true
|
|
40753
40571
|
});
|
|
40754
40572
|
if (!integrations2) return false;
|
|
40755
|
-
const integration = integrations2.find(
|
|
40756
|
-
(i) => i.alias === integrationName
|
|
40757
|
-
);
|
|
40573
|
+
const integration = integrations2.find((i) => i.alias === integrationName);
|
|
40758
40574
|
return !!integration?.definition?.actions?.[actionName];
|
|
40759
40575
|
} catch {
|
|
40760
40576
|
return false;
|
|
@@ -41017,15 +40833,14 @@ init_define_PACKAGE_VERSIONS();
|
|
|
41017
40833
|
// src/globals.ts
|
|
41018
40834
|
init_define_BUILD();
|
|
41019
40835
|
init_define_PACKAGE_VERSIONS();
|
|
41020
|
-
var DefinedGlobalObjects = [
|
|
41021
|
-
"__PACKAGE_VERSIONS__",
|
|
41022
|
-
"__BUILD__"
|
|
41023
|
-
];
|
|
40836
|
+
var DefinedGlobalObjects = ["__PACKAGE_VERSIONS__", "__BUILD__"];
|
|
41024
40837
|
for (const key of Object.keys(DefinedGlobalObjects)) {
|
|
41025
40838
|
if (typeof globalThis[key] === "string") {
|
|
41026
40839
|
try {
|
|
40840
|
+
;
|
|
41027
40841
|
globalThis[key] = JSON.parse(globalThis[key]);
|
|
41028
40842
|
} catch {
|
|
40843
|
+
;
|
|
41029
40844
|
globalThis[key] = DefinedGlobalObjects[key];
|
|
41030
40845
|
}
|
|
41031
40846
|
}
|
|
@@ -41126,9 +40941,7 @@ var bot = {
|
|
|
41126
40941
|
get state() {
|
|
41127
40942
|
const botId = context.get("botId");
|
|
41128
40943
|
const states = context.get("states", { optional: true }) ?? [];
|
|
41129
|
-
const state = states.find(
|
|
41130
|
-
(x) => x.type === "bot" && x.name === "botState" && x.id === botId
|
|
41131
|
-
);
|
|
40944
|
+
const state = states.find((x) => x.type === "bot" && x.name === "botState" && x.id === botId);
|
|
41132
40945
|
if (!state) {
|
|
41133
40946
|
throw new Error("Bot state not initialized.");
|
|
41134
40947
|
}
|
|
@@ -41137,9 +40950,7 @@ var bot = {
|
|
|
41137
40950
|
set state(value) {
|
|
41138
40951
|
const botId = context.get("botId");
|
|
41139
40952
|
const states = context.get("states", { optional: true }) ?? [];
|
|
41140
|
-
const state = states.find(
|
|
41141
|
-
(x) => x.type === "bot" && x.name === "botState" && x.id === botId
|
|
41142
|
-
);
|
|
40953
|
+
const state = states.find((x) => x.type === "bot" && x.name === "botState" && x.id === botId);
|
|
41143
40954
|
if (!state) {
|
|
41144
40955
|
throw new Error("Bot state not initialized.");
|
|
41145
40956
|
}
|
|
@@ -41153,9 +40964,7 @@ var user = {
|
|
|
41153
40964
|
throw new Error("User not found in context.");
|
|
41154
40965
|
}
|
|
41155
40966
|
const states = context.get("states", { optional: true }) ?? [];
|
|
41156
|
-
const state = states.find(
|
|
41157
|
-
(x) => x.type === "user" && x.name === "userState" && x.id === user2.id
|
|
41158
|
-
);
|
|
40967
|
+
const state = states.find((x) => x.type === "user" && x.name === "userState" && x.id === user2.id);
|
|
41159
40968
|
if (!state) {
|
|
41160
40969
|
throw new Error("User state not initialized.");
|
|
41161
40970
|
}
|
|
@@ -41167,9 +40976,7 @@ var user = {
|
|
|
41167
40976
|
throw new Error("User not found in context.");
|
|
41168
40977
|
}
|
|
41169
40978
|
const states = context.get("states", { optional: true }) ?? [];
|
|
41170
|
-
const state = states.find(
|
|
41171
|
-
(x) => x.type === "user" && x.name === "userState" && x.id === user2.id
|
|
41172
|
-
);
|
|
40979
|
+
const state = states.find((x) => x.type === "user" && x.name === "userState" && x.id === user2.id);
|
|
41173
40980
|
if (!state) {
|
|
41174
40981
|
throw new Error("User state not initialized.");
|
|
41175
40982
|
}
|
|
@@ -41278,10 +41085,7 @@ function isWorkflowDataRequest(event) {
|
|
|
41278
41085
|
// src/primitives/workflow-step.ts
|
|
41279
41086
|
var DEFAULT_MAX_ATTEMPTS = 5;
|
|
41280
41087
|
var MIN_STEP_REMAINING_TIME_MS = 1e4;
|
|
41281
|
-
var storage2 = getSingleton(
|
|
41282
|
-
"__ADK_GLOBAL_CTX_WORKFLOW_STEP",
|
|
41283
|
-
() => new AsyncLocalStorage3()
|
|
41284
|
-
);
|
|
41088
|
+
var storage2 = getSingleton("__ADK_GLOBAL_CTX_WORKFLOW_STEP", () => new AsyncLocalStorage3());
|
|
41285
41089
|
async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
41286
41090
|
spanFunc,
|
|
41287
41091
|
stepType
|
|
@@ -41299,9 +41103,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
|
41299
41103
|
}
|
|
41300
41104
|
const remainingTime = context.get("runtime").getRemainingExecutionTimeInMs();
|
|
41301
41105
|
if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
|
|
41302
|
-
await new Promise(
|
|
41303
|
-
(resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
|
|
41304
|
-
);
|
|
41106
|
+
await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
|
|
41305
41107
|
throw createStepSignal();
|
|
41306
41108
|
}
|
|
41307
41109
|
const stepContext = storage2.getStore();
|
|
@@ -41381,13 +41183,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
|
41381
41183
|
}
|
|
41382
41184
|
if (shouldRetry) {
|
|
41383
41185
|
await new Promise(
|
|
41384
|
-
(resolve) => setTimeout(
|
|
41385
|
-
resolve,
|
|
41386
|
-
Math.min(
|
|
41387
|
-
100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1),
|
|
41388
|
-
5e3
|
|
41389
|
-
)
|
|
41390
|
-
)
|
|
41186
|
+
(resolve) => setTimeout(resolve, Math.min(100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1), 5e3))
|
|
41391
41187
|
);
|
|
41392
41188
|
continue;
|
|
41393
41189
|
}
|
|
@@ -41492,10 +41288,7 @@ step.sleep = async (name, ms3) => {
|
|
|
41492
41288
|
);
|
|
41493
41289
|
};
|
|
41494
41290
|
step.sleepUntil = async (name, date) => {
|
|
41495
|
-
const ms3 = Math.max(
|
|
41496
|
-
0,
|
|
41497
|
-
new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS
|
|
41498
|
-
);
|
|
41291
|
+
const ms3 = Math.max(0, new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS);
|
|
41499
41292
|
await step.sleep(name, ms3);
|
|
41500
41293
|
};
|
|
41501
41294
|
step.waitForWorkflow = async (name, workflowId) => {
|
|
@@ -41541,10 +41334,9 @@ step.executeWorkflow = async (name, workflow, input) => _step(
|
|
|
41541
41334
|
// Ensures idempotency
|
|
41542
41335
|
})).id
|
|
41543
41336
|
);
|
|
41544
|
-
return _step(
|
|
41545
|
-
|
|
41546
|
-
|
|
41547
|
-
).then((finishedWorkflow) => finishedWorkflow.output);
|
|
41337
|
+
return _step(`${name}-wait`, async () => step.waitForWorkflow(`${name}-wait`, wfId)).then(
|
|
41338
|
+
(finishedWorkflow) => finishedWorkflow.output
|
|
41339
|
+
);
|
|
41548
41340
|
},
|
|
41549
41341
|
{}
|
|
41550
41342
|
);
|
|
@@ -41561,9 +41353,7 @@ async function processWithConcurrency(items, processor, maxConcurrency = 5) {
|
|
|
41561
41353
|
}
|
|
41562
41354
|
const remainingTime = context.get("runtime").getRemainingExecutionTimeInMs();
|
|
41563
41355
|
if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
|
|
41564
|
-
await new Promise(
|
|
41565
|
-
(resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
|
|
41566
|
-
);
|
|
41356
|
+
await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
|
|
41567
41357
|
throw createStepSignal();
|
|
41568
41358
|
}
|
|
41569
41359
|
const promise = processor(items[i], i).then((result) => {
|
|
@@ -41631,17 +41421,11 @@ step.request = async (request, message, stepName) => {
|
|
|
41631
41421
|
const workflowControlContext = context.get("workflowControlContext");
|
|
41632
41422
|
const client = context.get("client");
|
|
41633
41423
|
if (!workflowControlContext.workflow.conversationId) {
|
|
41634
|
-
throw new Error(
|
|
41635
|
-
`Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`
|
|
41636
|
-
);
|
|
41424
|
+
throw new Error(`Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`);
|
|
41637
41425
|
}
|
|
41638
|
-
const workflowDef = adk.project.workflows.find(
|
|
41639
|
-
(w) => w.name === workflowControlContext.workflow.name
|
|
41640
|
-
);
|
|
41426
|
+
const workflowDef = adk.project.workflows.find((w) => w.name === workflowControlContext.workflow.name);
|
|
41641
41427
|
if (!workflowDef) {
|
|
41642
|
-
throw new Error(
|
|
41643
|
-
`Workflow definition not found for "${workflowControlContext.workflow.name}"`
|
|
41644
|
-
);
|
|
41428
|
+
throw new Error(`Workflow definition not found for "${workflowControlContext.workflow.name}"`);
|
|
41645
41429
|
}
|
|
41646
41430
|
const requestSchema = workflowDef._requestsSchemas?.[request];
|
|
41647
41431
|
if (!requestSchema) {
|
|
@@ -41649,10 +41433,7 @@ step.request = async (request, message, stepName) => {
|
|
|
41649
41433
|
`Request "${request}" not found in workflow "${workflowDef.name}". Available requests: ${Object.keys(workflowDef._requestsSchemas || {}).join(", ") || "none"}`
|
|
41650
41434
|
);
|
|
41651
41435
|
}
|
|
41652
|
-
const state = createWorkflowExecutionState(
|
|
41653
|
-
client._inner,
|
|
41654
|
-
workflowControlContext.workflow.id
|
|
41655
|
-
);
|
|
41436
|
+
const state = createWorkflowExecutionState(client._inner, workflowControlContext.workflow.id);
|
|
41656
41437
|
if (!state.value) {
|
|
41657
41438
|
throw new Error("Workflow execution state not loaded");
|
|
41658
41439
|
}
|
|
@@ -41732,9 +41513,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
41732
41513
|
// @internal
|
|
41733
41514
|
TrackedState;
|
|
41734
41515
|
constructor(workflow, client) {
|
|
41735
|
-
const definition = adk.project.workflows.find(
|
|
41736
|
-
(w) => w.name === workflow.name
|
|
41737
|
-
);
|
|
41516
|
+
const definition = adk.project.workflows.find((w) => w.name === workflow.name);
|
|
41738
41517
|
this.TrackedState = TrackedState.create({
|
|
41739
41518
|
type: "workflow",
|
|
41740
41519
|
client: client._inner,
|
|
@@ -41757,9 +41536,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
41757
41536
|
const client = context.get("client");
|
|
41758
41537
|
const workflow = props.workflow ? props.workflow : await client.getWorkflow({ id: props.id }).then((x) => x.workflow);
|
|
41759
41538
|
if (!adk.project.workflows.find((w) => w.name === workflow.name)) {
|
|
41760
|
-
throw new Error(
|
|
41761
|
-
`No ADK Workflow definition found for "${workflow.name}"`
|
|
41762
|
-
);
|
|
41539
|
+
throw new Error(`No ADK Workflow definition found for "${workflow.name}"`);
|
|
41763
41540
|
}
|
|
41764
41541
|
return new _BaseWorkflowInstance(workflow, client);
|
|
41765
41542
|
}
|
|
@@ -41786,10 +41563,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
41786
41563
|
*/
|
|
41787
41564
|
async provide(request, data) {
|
|
41788
41565
|
const client = context.get("client");
|
|
41789
|
-
const state = createWorkflowExecutionState(
|
|
41790
|
-
client._inner,
|
|
41791
|
-
this.id
|
|
41792
|
-
);
|
|
41566
|
+
const state = createWorkflowExecutionState(client._inner, this.id);
|
|
41793
41567
|
await state.load();
|
|
41794
41568
|
if (!state.value) {
|
|
41795
41569
|
throw new Error(`Workflow execution state not found for workflow ${this.id}`);
|
|
@@ -41816,13 +41590,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
41816
41590
|
}
|
|
41817
41591
|
// @internal
|
|
41818
41592
|
async handle() {
|
|
41819
|
-
const handler = adk.project.workflows.find(
|
|
41820
|
-
(w) => w.name === this.name
|
|
41821
|
-
)._handler;
|
|
41593
|
+
const handler = adk.project.workflows.find((w) => w.name === this.name)._handler;
|
|
41822
41594
|
if (!handler) {
|
|
41823
|
-
throw new Error(
|
|
41824
|
-
`No ADK Workflow handler found for "${this.name}"`
|
|
41825
|
-
);
|
|
41595
|
+
throw new Error(`No ADK Workflow handler found for "${this.name}"`);
|
|
41826
41596
|
}
|
|
41827
41597
|
await TrackedState.loadAll();
|
|
41828
41598
|
const workflowControlContext = {
|
|
@@ -41847,9 +41617,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
41847
41617
|
}
|
|
41848
41618
|
const eventId = context.get("event")?.id;
|
|
41849
41619
|
if (!eventId) {
|
|
41850
|
-
throw new Error(
|
|
41851
|
-
`Event ID not found in context. Cannot ack workflow ${this.id}`
|
|
41852
|
-
);
|
|
41620
|
+
throw new Error(`Event ID not found in context. Cannot ack workflow ${this.id}`);
|
|
41853
41621
|
}
|
|
41854
41622
|
workflowControlContext.acked = true;
|
|
41855
41623
|
await updateWorkflow({
|
|
@@ -41861,15 +41629,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
|
|
|
41861
41629
|
};
|
|
41862
41630
|
try {
|
|
41863
41631
|
const ctx = context.getAll();
|
|
41864
|
-
const workflowExecutionState = createWorkflowExecutionState(
|
|
41865
|
-
ctx.client._inner,
|
|
41866
|
-
this.id
|
|
41867
|
-
);
|
|
41632
|
+
const workflowExecutionState = createWorkflowExecutionState(ctx.client._inner, this.id);
|
|
41868
41633
|
await workflowExecutionState.load();
|
|
41869
|
-
assert2(
|
|
41870
|
-
workflowExecutionState.value,
|
|
41871
|
-
"Workflow execution state is not loaded"
|
|
41872
|
-
);
|
|
41634
|
+
assert2(workflowExecutionState.value, "Workflow execution state is not loaded");
|
|
41873
41635
|
workflowExecutionState.value.executionCount++;
|
|
41874
41636
|
if (!this.TrackedState.value) {
|
|
41875
41637
|
this.TrackedState.value = {};
|
|
@@ -42036,12 +41798,7 @@ var BaseWorkflow = class {
|
|
|
42036
41798
|
*/
|
|
42037
41799
|
async getOrCreate(props) {
|
|
42038
41800
|
const client = context.get("client");
|
|
42039
|
-
const statuses = props.statuses || [
|
|
42040
|
-
"pending",
|
|
42041
|
-
"in_progress",
|
|
42042
|
-
"listening",
|
|
42043
|
-
"paused"
|
|
42044
|
-
];
|
|
41801
|
+
const statuses = props.statuses || ["pending", "in_progress", "listening", "paused"];
|
|
42045
41802
|
const validatedInput = this._inputSchema.parse(props.input);
|
|
42046
41803
|
const tags = {};
|
|
42047
41804
|
if (props.key) {
|
|
@@ -42055,9 +41812,7 @@ var BaseWorkflow = class {
|
|
|
42055
41812
|
tags,
|
|
42056
41813
|
conversationId: context.get("conversation", { optional: true })?.id,
|
|
42057
41814
|
parentWorkflowId: context.get("workflow", { optional: true })?.id,
|
|
42058
|
-
timeoutAt: new Date(
|
|
42059
|
-
Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
|
|
42060
|
-
).toISOString(),
|
|
41815
|
+
timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString(),
|
|
42061
41816
|
...discriminator && { discriminateBy: { tags: discriminator } }
|
|
42062
41817
|
};
|
|
42063
41818
|
let { workflow } = await client._inner.getOrCreateWorkflow(createArgs);
|
|
@@ -42083,21 +41838,12 @@ var BaseWorkflow = class {
|
|
|
42083
41838
|
async provide(event, data) {
|
|
42084
41839
|
const client = context.get("client");
|
|
42085
41840
|
const { workflowId, stepName } = event.payload;
|
|
42086
|
-
const state = createWorkflowExecutionState(
|
|
42087
|
-
client._inner,
|
|
42088
|
-
workflowId
|
|
42089
|
-
);
|
|
41841
|
+
const state = createWorkflowExecutionState(client._inner, workflowId);
|
|
42090
41842
|
await state.load();
|
|
42091
41843
|
if (!state.value) {
|
|
42092
|
-
throw new Error(
|
|
42093
|
-
`Workflow execution state not found for workflow ${workflowId}`
|
|
42094
|
-
);
|
|
41844
|
+
throw new Error(`Workflow execution state not found for workflow ${workflowId}`);
|
|
42095
41845
|
}
|
|
42096
|
-
console.log(
|
|
42097
|
-
`Providing data to workflow ${workflowId} step ${stepName}`,
|
|
42098
|
-
data,
|
|
42099
|
-
stepName
|
|
42100
|
-
);
|
|
41846
|
+
console.log(`Providing data to workflow ${workflowId} step ${stepName}`, data, stepName);
|
|
42101
41847
|
if (!state.value.steps[stepName]) {
|
|
42102
41848
|
state.value.steps[stepName] = {
|
|
42103
41849
|
output: data,
|
|
@@ -42129,9 +41875,7 @@ var BaseWorkflow = class {
|
|
|
42129
41875
|
input: validatedInput,
|
|
42130
41876
|
parentWorkflowId: workflow?.id,
|
|
42131
41877
|
conversationId: context.get("conversation", { optional: true })?.id,
|
|
42132
|
-
timeoutAt: new Date(
|
|
42133
|
-
Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
|
|
42134
|
-
).toISOString()
|
|
41878
|
+
timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString()
|
|
42135
41879
|
});
|
|
42136
41880
|
return await BaseWorkflowInstance.load({
|
|
42137
41881
|
id: res.workflow.id,
|
|
@@ -42179,9 +41923,7 @@ var createSyncWorkflow = (props) => new BaseWorkflow({
|
|
|
42179
41923
|
}
|
|
42180
41924
|
const source = kb.sources.find((s) => s.id === sourceId);
|
|
42181
41925
|
if (!source) {
|
|
42182
|
-
throw new Error(
|
|
42183
|
-
`Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`
|
|
42184
|
-
);
|
|
41926
|
+
throw new Error(`Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`);
|
|
42185
41927
|
}
|
|
42186
41928
|
console.log(
|
|
42187
41929
|
`\u{1F504} Starting sync for data source '${sourceId}' of type '${source.type}' in knowledge base '${kbName}'`
|
|
@@ -42280,12 +42022,8 @@ var adk = {
|
|
|
42280
42022
|
config: state.projectConfig,
|
|
42281
42023
|
integrations: Object.assign(state.primitives.integrations, {
|
|
42282
42024
|
get(name) {
|
|
42283
|
-
const byAlias = state.primitives.integrations.find(
|
|
42284
|
-
|
|
42285
|
-
);
|
|
42286
|
-
const byName = state.primitives.integrations.find(
|
|
42287
|
-
(int) => int.definition.name === name
|
|
42288
|
-
);
|
|
42025
|
+
const byAlias = state.primitives.integrations.find((int) => int.alias === name);
|
|
42026
|
+
const byName = state.primitives.integrations.find((int) => int.definition.name === name);
|
|
42289
42027
|
return byAlias || byName;
|
|
42290
42028
|
}
|
|
42291
42029
|
}),
|
|
@@ -42380,9 +42118,7 @@ var TrackedState = class _TrackedState {
|
|
|
42380
42118
|
}
|
|
42381
42119
|
static create(props) {
|
|
42382
42120
|
const states = context.get("states", { optional: true });
|
|
42383
|
-
const match2 = states?.find(
|
|
42384
|
-
(x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state")
|
|
42385
|
-
);
|
|
42121
|
+
const match2 = states?.find((x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state"));
|
|
42386
42122
|
if (match2) {
|
|
42387
42123
|
return match2;
|
|
42388
42124
|
}
|
|
@@ -42462,9 +42198,7 @@ var TrackedState = class _TrackedState {
|
|
|
42462
42198
|
});
|
|
42463
42199
|
}
|
|
42464
42200
|
const states = context.get("states", { optional: true });
|
|
42465
|
-
const promises = Promise.allSettled(
|
|
42466
|
-
states?.map((state) => state.load()) ?? []
|
|
42467
|
-
);
|
|
42201
|
+
const promises = Promise.allSettled(states?.map((state) => state.load()) ?? []);
|
|
42468
42202
|
void importScheduledHeavyImports();
|
|
42469
42203
|
await promises;
|
|
42470
42204
|
});
|
|
@@ -42499,9 +42233,7 @@ var TrackedState = class _TrackedState {
|
|
|
42499
42233
|
const { data } = await axios_default.get(file.url);
|
|
42500
42234
|
this.value = typeof data === "string" ? JSON.parse(data) : data;
|
|
42501
42235
|
} catch (err) {
|
|
42502
|
-
console.error(
|
|
42503
|
-
`Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`
|
|
42504
|
-
);
|
|
42236
|
+
console.error(`Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`);
|
|
42505
42237
|
this.value = void 0;
|
|
42506
42238
|
}
|
|
42507
42239
|
} else {
|
|
@@ -42587,9 +42319,7 @@ var TrackedState = class _TrackedState {
|
|
|
42587
42319
|
contentType: "application/json",
|
|
42588
42320
|
content: JSON.stringify(this.value),
|
|
42589
42321
|
accessPolicies: [],
|
|
42590
|
-
expiresAt: new Date(
|
|
42591
|
-
Date.now() + 30 * 24 * 60 * 60 * 1e3
|
|
42592
|
-
).toISOString(),
|
|
42322
|
+
expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1e3).toISOString(),
|
|
42593
42323
|
tags: {
|
|
42594
42324
|
system: "true",
|
|
42595
42325
|
purpose: "swap"
|
|
@@ -42609,9 +42339,7 @@ var TrackedState = class _TrackedState {
|
|
|
42609
42339
|
error: err instanceof Error ? err.message : String(err),
|
|
42610
42340
|
size_bytes: stateSize
|
|
42611
42341
|
});
|
|
42612
|
-
console.error(
|
|
42613
|
-
`Failed to swap state: ${err instanceof Error ? err.message : String(err)}`
|
|
42614
|
-
);
|
|
42342
|
+
console.error(`Failed to swap state: ${err instanceof Error ? err.message : String(err)}`);
|
|
42615
42343
|
payload = {
|
|
42616
42344
|
value: this.value,
|
|
42617
42345
|
location: { type: "state" }
|
|
@@ -42751,11 +42479,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
42751
42479
|
// src/runtime/chat/chat.ts
|
|
42752
42480
|
init_define_BUILD();
|
|
42753
42481
|
init_define_PACKAGE_VERSIONS();
|
|
42754
|
-
import {
|
|
42755
|
-
Chat,
|
|
42756
|
-
DefaultComponents,
|
|
42757
|
-
isAnyComponent as isAnyComponent2
|
|
42758
|
-
} from "llmz";
|
|
42482
|
+
import { Chat, DefaultComponents, isAnyComponent as isAnyComponent2 } from "llmz";
|
|
42759
42483
|
|
|
42760
42484
|
// src/runtime/chat/truncate-transcript.ts
|
|
42761
42485
|
init_define_BUILD();
|
|
@@ -43087,12 +42811,7 @@ var AttachmentSchema = z15.object({
|
|
|
43087
42811
|
});
|
|
43088
42812
|
var TranscriptItemSchema = z15.object({
|
|
43089
42813
|
id: z15.string(),
|
|
43090
|
-
role: z15.union([
|
|
43091
|
-
z15.literal("assistant"),
|
|
43092
|
-
z15.literal("user"),
|
|
43093
|
-
z15.literal("event"),
|
|
43094
|
-
z15.literal("summary")
|
|
43095
|
-
]),
|
|
42814
|
+
role: z15.union([z15.literal("assistant"), z15.literal("user"), z15.literal("event"), z15.literal("summary")]),
|
|
43096
42815
|
name: z15.string().optional(),
|
|
43097
42816
|
createdAt: z15.string().optional(),
|
|
43098
42817
|
content: z15.string().optional(),
|
|
@@ -43166,11 +42885,7 @@ var BaseConversationInstance = class {
|
|
|
43166
42885
|
* Start typing indicator
|
|
43167
42886
|
*/
|
|
43168
42887
|
async startTyping() {
|
|
43169
|
-
const mapping = InterfaceMappings.getIntegrationAction(
|
|
43170
|
-
"typingIndicator",
|
|
43171
|
-
"startTypingIndicator",
|
|
43172
|
-
this.integration
|
|
43173
|
-
);
|
|
42888
|
+
const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "startTypingIndicator", this.integration);
|
|
43174
42889
|
if (mapping) {
|
|
43175
42890
|
const message = context.get("message", { optional: true });
|
|
43176
42891
|
await this.client.callAction({
|
|
@@ -43187,11 +42902,7 @@ var BaseConversationInstance = class {
|
|
|
43187
42902
|
* Stop typing indicator
|
|
43188
42903
|
*/
|
|
43189
42904
|
async stopTyping() {
|
|
43190
|
-
const mapping = InterfaceMappings.getIntegrationAction(
|
|
43191
|
-
"typingIndicator",
|
|
43192
|
-
"stopTypingIndicator",
|
|
43193
|
-
this.integration
|
|
43194
|
-
);
|
|
42905
|
+
const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "stopTypingIndicator", this.integration);
|
|
43195
42906
|
if (mapping) {
|
|
43196
42907
|
const message = context.get("message", { optional: true });
|
|
43197
42908
|
await this.client.callAction({
|
|
@@ -43288,10 +42999,7 @@ var BaseConversation = class {
|
|
|
43288
42999
|
const chat = context.get("chat");
|
|
43289
43000
|
const client = context.get("client");
|
|
43290
43001
|
const botpressConversation = context.get("conversation");
|
|
43291
|
-
const conversationInstance = new BaseConversationInstance(
|
|
43292
|
-
botpressConversation,
|
|
43293
|
-
client
|
|
43294
|
-
);
|
|
43002
|
+
const conversationInstance = new BaseConversationInstance(botpressConversation, client);
|
|
43295
43003
|
let type;
|
|
43296
43004
|
let requestObject = void 0;
|
|
43297
43005
|
if (message) {
|
|
@@ -43330,9 +43038,7 @@ var BaseConversation = class {
|
|
|
43330
43038
|
conversationId: conversationInstance.id,
|
|
43331
43039
|
status: "pending"
|
|
43332
43040
|
});
|
|
43333
|
-
const newEvents = events.filter(
|
|
43334
|
-
(e) => e.createdAt > event?.createdAt && e.id !== event?.id
|
|
43335
|
-
);
|
|
43041
|
+
const newEvents = events.filter((e) => e.createdAt > event?.createdAt && e.id !== event?.id);
|
|
43336
43042
|
if (newEvents.length) {
|
|
43337
43043
|
s.setAttributes({
|
|
43338
43044
|
"interruption.detected": true,
|
|
@@ -43360,9 +43066,7 @@ var BaseConversation = class {
|
|
|
43360
43066
|
}
|
|
43361
43067
|
}
|
|
43362
43068
|
if (newEvents.length) {
|
|
43363
|
-
controller.abort(
|
|
43364
|
-
`More messages were received during processing, aborting current processing.`
|
|
43365
|
-
);
|
|
43069
|
+
controller.abort(`More messages were received during processing, aborting current processing.`);
|
|
43366
43070
|
} else {
|
|
43367
43071
|
s.setAttribute("interruption.detected", false);
|
|
43368
43072
|
}
|
|
@@ -43458,10 +43162,7 @@ var Definitions;
|
|
|
43458
43162
|
});
|
|
43459
43163
|
const actionDefinitionSchema = z17.object({
|
|
43460
43164
|
type: z17.literal("action"),
|
|
43461
|
-
name: z17.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(
|
|
43462
|
-
/^[a-zA-Z][a-zA-Z0-9]*$/,
|
|
43463
|
-
"Name must be alphanumeric with no special characters"
|
|
43464
|
-
),
|
|
43165
|
+
name: z17.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"),
|
|
43465
43166
|
title: z17.string().optional(),
|
|
43466
43167
|
description: z17.string().optional(),
|
|
43467
43168
|
attributes: z17.record(z17.string()).optional(),
|
|
@@ -45049,17 +44750,8 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45049
44750
|
this.urls = options.urls ?? void 0;
|
|
45050
44751
|
this.filterFn = "filter" in options ? options.filter : void 0;
|
|
45051
44752
|
this.customFetch = options.fetch ?? void 0;
|
|
45052
|
-
this.maxPages = Math.max(
|
|
45053
|
-
|
|
45054
|
-
Math.min(
|
|
45055
|
-
("maxPages" in options ? options.maxPages : void 0) ?? 5e4,
|
|
45056
|
-
5e4
|
|
45057
|
-
)
|
|
45058
|
-
);
|
|
45059
|
-
this.maxDepth = Math.max(
|
|
45060
|
-
1,
|
|
45061
|
-
Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20)
|
|
45062
|
-
);
|
|
44753
|
+
this.maxPages = Math.max(1, Math.min(("maxPages" in options ? options.maxPages : void 0) ?? 5e4, 5e4));
|
|
44754
|
+
this.maxDepth = Math.max(1, Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20));
|
|
45063
44755
|
}
|
|
45064
44756
|
isBrowserIntegrationAvailable() {
|
|
45065
44757
|
return !!adk.project.integrations.get("browser");
|
|
@@ -45223,9 +44915,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45223
44915
|
}
|
|
45224
44916
|
return passed;
|
|
45225
44917
|
});
|
|
45226
|
-
console.log(
|
|
45227
|
-
`Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`
|
|
45228
|
-
);
|
|
44918
|
+
console.log(`Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`);
|
|
45229
44919
|
}
|
|
45230
44920
|
return filteredUrls.map((url2) => ({ loc: url2 }));
|
|
45231
44921
|
}
|
|
@@ -45257,20 +44947,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45257
44947
|
await step2(`processing sitemap ${item.url}`, async () => {
|
|
45258
44948
|
try {
|
|
45259
44949
|
const { content, contentType } = await this.fetchSitemap(item.url);
|
|
45260
|
-
console.log(
|
|
45261
|
-
`Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`
|
|
45262
|
-
);
|
|
44950
|
+
console.log(`Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`);
|
|
45263
44951
|
console.log(content, contentType);
|
|
45264
44952
|
try {
|
|
45265
44953
|
const { urls, sitemaps } = this.parseSitemapXml(content);
|
|
45266
|
-
console.log(
|
|
45267
|
-
`Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`
|
|
45268
|
-
);
|
|
44954
|
+
console.log(`Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`);
|
|
45269
44955
|
for (const url2 of urls) {
|
|
45270
44956
|
if (state.urls.length >= this.maxPages) {
|
|
45271
|
-
console.log(
|
|
45272
|
-
`Reached maxPages limit (${this.maxPages}), stopping URL discovery`
|
|
45273
|
-
);
|
|
44957
|
+
console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
|
|
45274
44958
|
break;
|
|
45275
44959
|
}
|
|
45276
44960
|
const filterContext = {
|
|
@@ -45291,20 +44975,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45291
44975
|
state.queue.push({ url: sitemapUrl, depth: item.depth + 1 });
|
|
45292
44976
|
}
|
|
45293
44977
|
} else if (sitemaps.length > 0) {
|
|
45294
|
-
console.log(
|
|
45295
|
-
`Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`
|
|
45296
|
-
);
|
|
44978
|
+
console.log(`Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`);
|
|
45297
44979
|
}
|
|
45298
44980
|
} catch (xmlErr) {
|
|
45299
|
-
console.log(
|
|
45300
|
-
`XML parsing failed for ${item.url}, trying TXT format...`
|
|
45301
|
-
);
|
|
44981
|
+
console.log(`XML parsing failed for ${item.url}, trying TXT format...`);
|
|
45302
44982
|
const { urls } = this.parseSitemapTxt(content);
|
|
45303
44983
|
for (const url2 of urls) {
|
|
45304
44984
|
if (state.urls.length >= this.maxPages) {
|
|
45305
|
-
console.log(
|
|
45306
|
-
`Reached maxPages limit (${this.maxPages}), stopping URL discovery`
|
|
45307
|
-
);
|
|
44985
|
+
console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
|
|
45308
44986
|
break;
|
|
45309
44987
|
}
|
|
45310
44988
|
const filterContext = { url: url2.loc };
|
|
@@ -45322,13 +45000,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45322
45000
|
}
|
|
45323
45001
|
});
|
|
45324
45002
|
}
|
|
45325
|
-
console.log(
|
|
45326
|
-
`URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`
|
|
45327
|
-
);
|
|
45003
|
+
console.log(`URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`);
|
|
45328
45004
|
if (state.urls.length >= this.maxPages) {
|
|
45329
|
-
console.log(
|
|
45330
|
-
`Note: Discovery stopped at maxPages limit (${this.maxPages})`
|
|
45331
|
-
);
|
|
45005
|
+
console.log(`Note: Discovery stopped at maxPages limit (${this.maxPages})`);
|
|
45332
45006
|
}
|
|
45333
45007
|
return state.urls.slice(0, this.maxPages);
|
|
45334
45008
|
}
|
|
@@ -45341,13 +45015,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45341
45015
|
console.log(
|
|
45342
45016
|
`Starting sync for WebsiteSource [${this.id}] in mode [${this.mode}, maxPages=${this.maxPages}, maxDepth=${this.maxDepth}, baseUrl=${this.baseUrl}, sitemapUrl=${this.sitemapUrl}]`
|
|
45343
45017
|
);
|
|
45344
|
-
console.log(
|
|
45345
|
-
`Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`
|
|
45346
|
-
);
|
|
45018
|
+
console.log(`Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`);
|
|
45347
45019
|
if (input.force) {
|
|
45348
|
-
console.log(
|
|
45349
|
-
"\u{1F504} FORCE MODE: Re-indexing all files regardless of changes"
|
|
45350
|
-
);
|
|
45020
|
+
console.log("\u{1F504} FORCE MODE: Re-indexing all files regardless of changes");
|
|
45351
45021
|
}
|
|
45352
45022
|
const tags = {
|
|
45353
45023
|
[WellKnownTags.knowledge.KNOWLEDGE]: "true",
|
|
@@ -45355,10 +45025,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45355
45025
|
[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_TYPE]: this.type,
|
|
45356
45026
|
[WellKnownTags.knowledge.KNOWLEDGE_BASE_NAME]: input.kbName
|
|
45357
45027
|
};
|
|
45358
|
-
const discoveredUrls = await step2(
|
|
45359
|
-
"discover urls from sitemap",
|
|
45360
|
-
() => this.discoverUrls(step2, state)
|
|
45361
|
-
);
|
|
45028
|
+
const discoveredUrls = await step2("discover urls from sitemap", () => this.discoverUrls(step2, state));
|
|
45362
45029
|
console.log(`Discovered ${discoveredUrls.length} URLs from sitemap`);
|
|
45363
45030
|
console.log(`Will process up to ${this.maxPages} pages`);
|
|
45364
45031
|
const existingFiles = await step2(
|
|
@@ -45368,15 +45035,10 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45368
45035
|
}).collect()
|
|
45369
45036
|
);
|
|
45370
45037
|
const existingFileMap = new Map(
|
|
45371
|
-
existingFiles.map((f) => [
|
|
45372
|
-
f.metadata?.[WellKnownMetadata.knowledge.URL],
|
|
45373
|
-
f
|
|
45374
|
-
])
|
|
45038
|
+
existingFiles.map((f) => [f.metadata?.[WellKnownMetadata.knowledge.URL], f])
|
|
45375
45039
|
);
|
|
45376
45040
|
const toRemove = existingFiles.filter(
|
|
45377
|
-
(f) => !discoveredUrls.find(
|
|
45378
|
-
(u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL]
|
|
45379
|
-
)
|
|
45041
|
+
(f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
|
|
45380
45042
|
);
|
|
45381
45043
|
const toFetch = [];
|
|
45382
45044
|
let skippedUnchanged = 0;
|
|
@@ -45523,9 +45185,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45523
45185
|
state: z20.object({}),
|
|
45524
45186
|
handler: async ({ input, step: step2, client }) => {
|
|
45525
45187
|
if (!adk.environment.isDevelopment()) {
|
|
45526
|
-
console.log(
|
|
45527
|
-
"Directory ingestion is only supported in development environment"
|
|
45528
|
-
);
|
|
45188
|
+
console.log("Directory ingestion is only supported in development environment");
|
|
45529
45189
|
return {
|
|
45530
45190
|
added: [],
|
|
45531
45191
|
updated: [],
|
|
@@ -45541,10 +45201,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45541
45201
|
const path4 = await import("path");
|
|
45542
45202
|
const fs3 = await import("fs/promises");
|
|
45543
45203
|
const crypto3 = await import("crypto");
|
|
45544
|
-
const directory = path4.resolve(
|
|
45545
|
-
adk.environment.agent.directory,
|
|
45546
|
-
this.directoryPath
|
|
45547
|
-
);
|
|
45204
|
+
const directory = path4.resolve(adk.environment.agent.directory, this.directoryPath);
|
|
45548
45205
|
const tags = {
|
|
45549
45206
|
[WellKnownTags.knowledge.KNOWLEDGE]: "true",
|
|
45550
45207
|
[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID]: this.id,
|
|
@@ -45584,11 +45241,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45584
45241
|
const toRemove = existingFiles.filter(
|
|
45585
45242
|
(f) => !allFiles.find((af) => af.rel === f.metadata?.relPath)
|
|
45586
45243
|
);
|
|
45587
|
-
const toAdd = allFiles.filter(
|
|
45588
|
-
(af) => !existingFiles.find(
|
|
45589
|
-
(f) => f.metadata?.relPath === af.rel
|
|
45590
|
-
)
|
|
45591
|
-
);
|
|
45244
|
+
const toAdd = allFiles.filter((af) => !existingFiles.find((f) => f.metadata?.relPath === af.rel));
|
|
45592
45245
|
const toUpdate = allFiles.filter(
|
|
45593
45246
|
(af) => existingFiles.find((f) => f.metadata?.relPath === af.rel)
|
|
45594
45247
|
);
|
|
@@ -45650,18 +45303,11 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45650
45303
|
size: uploaded.file.size ?? -1
|
|
45651
45304
|
};
|
|
45652
45305
|
};
|
|
45653
|
-
const added = await step2.map(
|
|
45654
|
-
|
|
45655
|
-
|
|
45656
|
-
|
|
45657
|
-
|
|
45658
|
-
);
|
|
45659
|
-
const updated = await step2.map(
|
|
45660
|
-
"to update files",
|
|
45661
|
-
toUpdate,
|
|
45662
|
-
(f) => upsertFile(f),
|
|
45663
|
-
{ concurrency: 5, maxAttempts: 2 }
|
|
45664
|
-
);
|
|
45306
|
+
const added = await step2.map("to add files", toAdd, (f) => upsertFile(f), { concurrency: 5, maxAttempts: 2 });
|
|
45307
|
+
const updated = await step2.map("to update files", toUpdate, (f) => upsertFile(f), {
|
|
45308
|
+
concurrency: 5,
|
|
45309
|
+
maxAttempts: 2
|
|
45310
|
+
});
|
|
45665
45311
|
return {
|
|
45666
45312
|
processed: allFiles.length,
|
|
45667
45313
|
deleted,
|
|
@@ -45728,9 +45374,7 @@ var BaseKnowledge = class {
|
|
|
45728
45374
|
async refreshSource(sourceId, options) {
|
|
45729
45375
|
const source = this.sources.find((s) => s.id === sourceId);
|
|
45730
45376
|
if (!source) {
|
|
45731
|
-
throw new Error(
|
|
45732
|
-
`Data source with id "${sourceId}" not found in knowledge base "${this.name}"`
|
|
45733
|
-
);
|
|
45377
|
+
throw new Error(`Data source with id "${sourceId}" not found in knowledge base "${this.name}"`);
|
|
45734
45378
|
}
|
|
45735
45379
|
await source.syncWorkflow.getOrCreate({
|
|
45736
45380
|
key: `${this.name}:${sourceId}`,
|
|
@@ -45762,9 +45406,7 @@ var BaseAction = class {
|
|
|
45762
45406
|
handler;
|
|
45763
45407
|
constructor(props) {
|
|
45764
45408
|
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
|
|
45765
|
-
throw new Error(
|
|
45766
|
-
`Action name "${props.name}" must be alphanumeric with no special characters or spaces`
|
|
45767
|
-
);
|
|
45409
|
+
throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
|
|
45768
45410
|
}
|
|
45769
45411
|
this.name = props.name;
|
|
45770
45412
|
if (props.title !== void 0) {
|
|
@@ -45810,9 +45452,7 @@ var BaseAction = class {
|
|
|
45810
45452
|
/**
|
|
45811
45453
|
* Execute the action with input validation and output validation
|
|
45812
45454
|
*/
|
|
45813
|
-
async execute({
|
|
45814
|
-
input
|
|
45815
|
-
}) {
|
|
45455
|
+
async execute({ input }) {
|
|
45816
45456
|
return this.handler(input);
|
|
45817
45457
|
}
|
|
45818
45458
|
};
|
|
@@ -45900,6 +45540,7 @@ var BaseTable = class {
|
|
|
45900
45540
|
for (const col of Object.keys(this.columns)) {
|
|
45901
45541
|
if (this.computedColumns.has(col) || this.nullableColumns.has(col)) {
|
|
45902
45542
|
if ("properties" in schema && schema.properties && col in schema.properties && typeof schema.properties[col] === "object" && schema.properties[col] !== null) {
|
|
45543
|
+
;
|
|
45903
45544
|
schema.properties[col].nullable = true;
|
|
45904
45545
|
}
|
|
45905
45546
|
if ("required" in schema && Array.isArray(schema.required)) {
|
|
@@ -46025,10 +45666,7 @@ var Typings7;
|
|
|
46025
45666
|
Typings8.Primitive = "trigger";
|
|
46026
45667
|
})(Typings7 || (Typings7 = {}));
|
|
46027
45668
|
var TriggerSchema = z23.object({
|
|
46028
|
-
name: z23.string().min(3, "Trigger name must be at least 3 characters").max(255, "Trigger name must be less than 255 characters").regex(
|
|
46029
|
-
/^[a-zA-Z0-9_]+$/,
|
|
46030
|
-
"Trigger name must contain only alphanumeric characters and underscores"
|
|
46031
|
-
),
|
|
45669
|
+
name: z23.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"),
|
|
46032
45670
|
description: z23.string().max(1024, "Description must be less than 1024 characters").optional(),
|
|
46033
45671
|
events: z23.array(z23.string()),
|
|
46034
45672
|
handler: z23.function().describe("Handler function for the trigger")
|
|
@@ -46041,10 +45679,7 @@ var Trigger = class {
|
|
|
46041
45679
|
constructor(props) {
|
|
46042
45680
|
const result = TriggerSchema.safeParse(props);
|
|
46043
45681
|
if (!result.success) {
|
|
46044
|
-
throw new Errors.InvalidPrimitiveError(
|
|
46045
|
-
"Trigger validation failed",
|
|
46046
|
-
result.error
|
|
46047
|
-
);
|
|
45682
|
+
throw new Errors.InvalidPrimitiveError("Trigger validation failed", result.error);
|
|
46048
45683
|
}
|
|
46049
45684
|
this.name = result.data.name;
|
|
46050
45685
|
this.description = result.data.description;
|