@botpress/runtime 1.13.13 → 1.13.15
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/definition.js +1993 -1944
- package/dist/definition.js.map +4 -4
- package/dist/internal.js +69 -20
- package/dist/internal.js.map +3 -3
- package/dist/library.js +69 -20
- package/dist/library.js.map +3 -3
- package/dist/primitives/conversation.d.ts +9 -5
- package/dist/primitives/conversation.d.ts.map +1 -1
- package/dist/primitives/workflow-instance.d.ts.map +1 -1
- package/dist/runtime/actions.d.ts.map +1 -1
- package/dist/runtime/handlers/trigger.d.ts +2 -0
- package/dist/runtime/handlers/trigger.d.ts.map +1 -1
- package/dist/runtime/tracked-state.d.ts.map +1 -1
- package/dist/runtime/tracked-tags.d.ts +5 -0
- package/dist/runtime/tracked-tags.d.ts.map +1 -1
- package/dist/runtime.js +101 -22
- package/dist/runtime.js.map +3 -3
- package/package.json +2 -2
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.13.
|
|
51
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.13.15", adk: "1.13.15", sdk: "5.0.2", llmz: "0.0.37", zai: "2.5.6", cognitive: "0.3.3" };
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -26343,7 +26343,7 @@ var require_form_data = __commonJS({
|
|
|
26343
26343
|
var parseUrl = __require("url").parse;
|
|
26344
26344
|
var fs3 = __require("fs");
|
|
26345
26345
|
var Stream2 = __require("stream").Stream;
|
|
26346
|
-
var
|
|
26346
|
+
var crypto3 = __require("crypto");
|
|
26347
26347
|
var mime = require_mime_types();
|
|
26348
26348
|
var asynckit = require_asynckit();
|
|
26349
26349
|
var setToStringTag = require_es_set_tostringtag();
|
|
@@ -26549,7 +26549,7 @@ var require_form_data = __commonJS({
|
|
|
26549
26549
|
return Buffer.concat([dataBuffer, Buffer.from(this._lastBoundary())]);
|
|
26550
26550
|
};
|
|
26551
26551
|
FormData3.prototype._generateBoundary = function() {
|
|
26552
|
-
this._boundary = "--------------------------" +
|
|
26552
|
+
this._boundary = "--------------------------" + crypto3.randomBytes(12).toString("hex");
|
|
26553
26553
|
};
|
|
26554
26554
|
FormData3.prototype.getLengthSync = function() {
|
|
26555
26555
|
var knownLength = this._overheadLength + this._valueLength;
|
|
@@ -26970,7 +26970,7 @@ var init_URLSearchParams = __esm({
|
|
|
26970
26970
|
});
|
|
26971
26971
|
|
|
26972
26972
|
// ../../node_modules/axios/lib/platform/node/index.js
|
|
26973
|
-
import
|
|
26973
|
+
import crypto2 from "crypto";
|
|
26974
26974
|
var ALPHA, DIGIT, ALPHABET, generateString, node_default;
|
|
26975
26975
|
var init_node2 = __esm({
|
|
26976
26976
|
"../../node_modules/axios/lib/platform/node/index.js"() {
|
|
@@ -26989,7 +26989,7 @@ var init_node2 = __esm({
|
|
|
26989
26989
|
let str = "";
|
|
26990
26990
|
const { length } = alphabet;
|
|
26991
26991
|
const randomValues = new Uint32Array(size);
|
|
26992
|
-
|
|
26992
|
+
crypto2.randomFillSync(randomValues);
|
|
26993
26993
|
for (let i = 0; i < size; i++) {
|
|
26994
26994
|
str += alphabet[randomValues[i] % length];
|
|
26995
26995
|
}
|
|
@@ -34609,10 +34609,15 @@ var init_actions = __esm({
|
|
|
34609
34609
|
if (typeof propertyName !== "string") {
|
|
34610
34610
|
return void 0;
|
|
34611
34611
|
}
|
|
34612
|
+
let client2;
|
|
34613
|
+
client2 ??= context.get("client", { optional: true });
|
|
34612
34614
|
const botAction = adk.project.actions.find((a) => a.name === propertyName);
|
|
34613
34615
|
if (botAction) {
|
|
34614
34616
|
const handler = async (input) => {
|
|
34615
|
-
return await botAction.handler(
|
|
34617
|
+
return await botAction.handler({
|
|
34618
|
+
input,
|
|
34619
|
+
client: client2
|
|
34620
|
+
});
|
|
34616
34621
|
};
|
|
34617
34622
|
handler.asTool = () => new Autonomous.Tool({
|
|
34618
34623
|
name: botAction.name,
|
|
@@ -34624,9 +34629,7 @@ var init_actions = __esm({
|
|
|
34624
34629
|
return handler;
|
|
34625
34630
|
}
|
|
34626
34631
|
let integrations;
|
|
34627
|
-
let client2;
|
|
34628
34632
|
integrations ??= context.get("integrations", { optional: true });
|
|
34629
|
-
client2 ??= context.get("client", { optional: true });
|
|
34630
34633
|
const integrationName = propertyName.replace("__", "/");
|
|
34631
34634
|
return new Proxy(
|
|
34632
34635
|
{},
|
|
@@ -36828,9 +36831,13 @@ var init_workflow_instance = __esm({
|
|
|
36828
36831
|
const trackedState = this.TrackedState;
|
|
36829
36832
|
const stateProxy = new Proxy(this.TrackedState.value, {
|
|
36830
36833
|
set(target, prop, value) {
|
|
36831
|
-
const
|
|
36832
|
-
|
|
36833
|
-
|
|
36834
|
+
const oldValue = target[prop];
|
|
36835
|
+
if (oldValue !== value) {
|
|
36836
|
+
const result = Reflect.set(target, prop, value);
|
|
36837
|
+
trackedState.markDirty();
|
|
36838
|
+
return result;
|
|
36839
|
+
}
|
|
36840
|
+
return true;
|
|
36834
36841
|
}
|
|
36835
36842
|
});
|
|
36836
36843
|
if (this.workflow.status === "pending") {
|
|
@@ -37292,7 +37299,8 @@ var init_tracked_state = __esm({
|
|
|
37292
37299
|
} else {
|
|
37293
37300
|
this.value = value;
|
|
37294
37301
|
}
|
|
37295
|
-
|
|
37302
|
+
const needsDefaults = this.value == null || this.value === void 0;
|
|
37303
|
+
if (needsDefaults) {
|
|
37296
37304
|
if (this.state && "parse" in this.state) {
|
|
37297
37305
|
try {
|
|
37298
37306
|
this.value = this.state.parse({});
|
|
@@ -37495,6 +37503,7 @@ var init_tracked_tags = __esm({
|
|
|
37495
37503
|
init_define_PACKAGE_VERSIONS();
|
|
37496
37504
|
init_context();
|
|
37497
37505
|
init_tracing();
|
|
37506
|
+
init_adk();
|
|
37498
37507
|
TrackedTags = class _TrackedTags {
|
|
37499
37508
|
type;
|
|
37500
37509
|
id;
|
|
@@ -37719,13 +37728,49 @@ var init_tracked_tags = __esm({
|
|
|
37719
37728
|
}
|
|
37720
37729
|
return {};
|
|
37721
37730
|
}
|
|
37731
|
+
/**
|
|
37732
|
+
* Get the list of valid tag keys from the agent configuration.
|
|
37733
|
+
* Only tags defined in agent.config.ts can be persisted.
|
|
37734
|
+
*/
|
|
37735
|
+
getValidTagKeys() {
|
|
37736
|
+
const validKeys = /* @__PURE__ */ new Set();
|
|
37737
|
+
try {
|
|
37738
|
+
const config = adk.project.config;
|
|
37739
|
+
if (this.type === "bot" && config.bot?.tags) {
|
|
37740
|
+
Object.keys(config.bot.tags).forEach((key) => validKeys.add(key));
|
|
37741
|
+
} else if (this.type === "user" && config.user?.tags) {
|
|
37742
|
+
Object.keys(config.user.tags).forEach((key) => validKeys.add(key));
|
|
37743
|
+
} else if (this.type === "conversation" && config.conversation?.tags) {
|
|
37744
|
+
Object.keys(config.conversation.tags).forEach((key) => validKeys.add(key));
|
|
37745
|
+
} else if (this.type === "workflow" && config.workflow?.tags) {
|
|
37746
|
+
Object.keys(config.workflow.tags).forEach((key) => validKeys.add(key));
|
|
37747
|
+
}
|
|
37748
|
+
} catch (err) {
|
|
37749
|
+
console.warn(`[TrackedTags] Could not load tag definitions from config: ${err}`);
|
|
37750
|
+
}
|
|
37751
|
+
return validKeys;
|
|
37752
|
+
}
|
|
37722
37753
|
async persistTags(tags) {
|
|
37754
|
+
const validKeys = this.getValidTagKeys();
|
|
37723
37755
|
const tagsForApi = {};
|
|
37756
|
+
const skippedTags = [];
|
|
37724
37757
|
for (const [key, value] of Object.entries(tags)) {
|
|
37725
|
-
if (value
|
|
37758
|
+
if (value === void 0 || isSystemTag(key)) {
|
|
37759
|
+
continue;
|
|
37760
|
+
}
|
|
37761
|
+
if (validKeys.size === 0 || validKeys.has(key)) {
|
|
37726
37762
|
tagsForApi[key] = value;
|
|
37763
|
+
} else {
|
|
37764
|
+
skippedTags.push(key);
|
|
37765
|
+
delete this._tags[key];
|
|
37766
|
+
delete this._initialTags[key];
|
|
37727
37767
|
}
|
|
37728
37768
|
}
|
|
37769
|
+
if (skippedTags.length > 0) {
|
|
37770
|
+
console.warn(
|
|
37771
|
+
`[TrackedTags] Skipping tags not defined in agent.config.ts for ${this.type}/${this.id}: ${skippedTags.join(", ")}`
|
|
37772
|
+
);
|
|
37773
|
+
}
|
|
37729
37774
|
try {
|
|
37730
37775
|
if (this.type === "bot") {
|
|
37731
37776
|
await this.client.updateBot({ id: this.id, tags: tagsForApi });
|
|
@@ -38824,9 +38869,13 @@ var init_conversation = __esm({
|
|
|
38824
38869
|
}
|
|
38825
38870
|
const stateProxy = new Proxy(conversationInstance.TrackedState.value, {
|
|
38826
38871
|
set(target, prop, value) {
|
|
38827
|
-
const
|
|
38828
|
-
|
|
38829
|
-
|
|
38872
|
+
const oldValue = target[prop];
|
|
38873
|
+
if (oldValue !== value) {
|
|
38874
|
+
const result = Reflect.set(target, prop, value);
|
|
38875
|
+
conversationInstance.TrackedState.markDirty();
|
|
38876
|
+
return result;
|
|
38877
|
+
}
|
|
38878
|
+
return true;
|
|
38830
38879
|
}
|
|
38831
38880
|
});
|
|
38832
38881
|
await this.#handler({
|
|
@@ -41124,7 +41173,7 @@ var init_source_website = __esm({
|
|
|
41124
41173
|
type: "website",
|
|
41125
41174
|
state: State,
|
|
41126
41175
|
async handler({ input, step: step2, state, client: client2 }) {
|
|
41127
|
-
const
|
|
41176
|
+
const crypto3 = await import("crypto");
|
|
41128
41177
|
console.log(
|
|
41129
41178
|
`Starting sync for WebsiteSource [${this.id}] in mode [${this.mode}, maxPages=${this.maxPages}, maxDepth=${this.maxDepth}, baseUrl=${this.baseUrl}, sitemapUrl=${this.sitemapUrl}]`
|
|
41130
41179
|
);
|
|
@@ -41207,7 +41256,7 @@ var init_source_website = __esm({
|
|
|
41207
41256
|
content,
|
|
41208
41257
|
metadata: fetchMetadata
|
|
41209
41258
|
} = await this.fetchUrl(sitemapUrl.loc);
|
|
41210
|
-
const hash =
|
|
41259
|
+
const hash = crypto3.createHash("sha256").update(content).digest("hex");
|
|
41211
41260
|
let contentType = fetchedContentType;
|
|
41212
41261
|
if (!contentType) {
|
|
41213
41262
|
contentType = content.includes("<html") ? "text/html" : "text/markdown";
|
|
@@ -48210,7 +48259,7 @@ var init_source_directory = __esm({
|
|
|
48210
48259
|
const glob2 = await Promise.resolve().then(() => (init_esm9(), esm_exports3));
|
|
48211
48260
|
const path4 = await import("path");
|
|
48212
48261
|
const fs3 = await import("fs/promises");
|
|
48213
|
-
const
|
|
48262
|
+
const crypto3 = await import("crypto");
|
|
48214
48263
|
const directory = path4.resolve(adk.environment.agent.directory, this.directoryPath);
|
|
48215
48264
|
const tags = {
|
|
48216
48265
|
[WellKnownTags.knowledge.KNOWLEDGE]: "knowledge-base",
|
|
@@ -48272,7 +48321,7 @@ var init_source_directory = __esm({
|
|
|
48272
48321
|
const upsertFile = async (local) => {
|
|
48273
48322
|
const key = `data_source://${this.type}/${this.id}/${local.rel}`;
|
|
48274
48323
|
const content = await fs3.readFile(local.abs);
|
|
48275
|
-
const hash =
|
|
48324
|
+
const hash = crypto3.createHash("sha256").update(content).digest("hex");
|
|
48276
48325
|
const { file } = await client2.getFile({ id: key }).catch(() => ({ file: null }));
|
|
48277
48326
|
const isFailed = file?.status === "indexing_failed" || file?.status === "upload_failed" || file?.status === "upload_pending";
|
|
48278
48327
|
if (!input.force && !isFailed && file?.metadata?.hash === hash) {
|