@botpress/runtime 1.13.12 → 1.13.14
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 +25 -15
- package/dist/definition.js.map +3 -3
- package/dist/internal.js +25 -15
- package/dist/internal.js.map +3 -3
- package/dist/library.js +25 -15
- package/dist/library.js.map +3 -3
- package/dist/primitives/data-sources/source-directory.d.ts.map +1 -1
- package/dist/primitives/data-sources/source-website.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.js +57 -17
- package/dist/runtime.js.map +3 -3
- package/package.json +2 -2
package/dist/definition.js
CHANGED
|
@@ -48,7 +48,7 @@ var init_define_BUILD = __esm({
|
|
|
48
48
|
var define_PACKAGE_VERSIONS_default;
|
|
49
49
|
var init_define_PACKAGE_VERSIONS = __esm({
|
|
50
50
|
"<define:__PACKAGE_VERSIONS__>"() {
|
|
51
|
-
define_PACKAGE_VERSIONS_default = { runtime: "1.13.
|
|
51
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.13.14", adk: "1.13.14", sdk: "5.0.2", llmz: "0.0.37", zai: "2.5.6", cognitive: "0.3.3" };
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -10657,7 +10657,7 @@ var require_form_data = __commonJS({
|
|
|
10657
10657
|
var parseUrl = __require("url").parse;
|
|
10658
10658
|
var fs3 = __require("fs");
|
|
10659
10659
|
var Stream2 = __require("stream").Stream;
|
|
10660
|
-
var
|
|
10660
|
+
var crypto3 = __require("crypto");
|
|
10661
10661
|
var mime = require_mime_types();
|
|
10662
10662
|
var asynckit = require_asynckit();
|
|
10663
10663
|
var setToStringTag = require_es_set_tostringtag();
|
|
@@ -10863,7 +10863,7 @@ var require_form_data = __commonJS({
|
|
|
10863
10863
|
return Buffer.concat([dataBuffer, Buffer.from(this._lastBoundary())]);
|
|
10864
10864
|
};
|
|
10865
10865
|
FormData3.prototype._generateBoundary = function() {
|
|
10866
|
-
this._boundary = "--------------------------" +
|
|
10866
|
+
this._boundary = "--------------------------" + crypto3.randomBytes(12).toString("hex");
|
|
10867
10867
|
};
|
|
10868
10868
|
FormData3.prototype.getLengthSync = function() {
|
|
10869
10869
|
var knownLength = this._overheadLength + this._valueLength;
|
|
@@ -11284,7 +11284,7 @@ var init_URLSearchParams = __esm({
|
|
|
11284
11284
|
});
|
|
11285
11285
|
|
|
11286
11286
|
// ../../node_modules/axios/lib/platform/node/index.js
|
|
11287
|
-
import
|
|
11287
|
+
import crypto2 from "crypto";
|
|
11288
11288
|
var ALPHA, DIGIT, ALPHABET, generateString, node_default;
|
|
11289
11289
|
var init_node = __esm({
|
|
11290
11290
|
"../../node_modules/axios/lib/platform/node/index.js"() {
|
|
@@ -11303,7 +11303,7 @@ var init_node = __esm({
|
|
|
11303
11303
|
let str = "";
|
|
11304
11304
|
const { length } = alphabet;
|
|
11305
11305
|
const randomValues = new Uint32Array(size);
|
|
11306
|
-
|
|
11306
|
+
crypto2.randomFillSync(randomValues);
|
|
11307
11307
|
for (let i = 0; i < size; i++) {
|
|
11308
11308
|
str += alphabet[randomValues[i] % length];
|
|
11309
11309
|
}
|
|
@@ -37033,7 +37033,7 @@ var init_source_website = __esm({
|
|
|
37033
37033
|
type: "website",
|
|
37034
37034
|
state: State,
|
|
37035
37035
|
async handler({ input, step: step2, state, client: client2 }) {
|
|
37036
|
-
const
|
|
37036
|
+
const crypto3 = await import("crypto");
|
|
37037
37037
|
console.log(
|
|
37038
37038
|
`Starting sync for WebsiteSource [${this.id}] in mode [${this.mode}, maxPages=${this.maxPages}, maxDepth=${this.maxDepth}, baseUrl=${this.baseUrl}, sitemapUrl=${this.sitemapUrl}]`
|
|
37039
37039
|
);
|
|
@@ -37081,7 +37081,8 @@ var init_source_website = __esm({
|
|
|
37081
37081
|
toFetch.push(url2);
|
|
37082
37082
|
} else {
|
|
37083
37083
|
const existingMetadata = existing.metadata;
|
|
37084
|
-
|
|
37084
|
+
const isFailed = existing.status === "indexing_failed" || existing.status === "upload_failed" || existing.status === "upload_pending";
|
|
37085
|
+
if (isFailed || url2.lastmod && existingMetadata?.lastmod !== url2.lastmod) {
|
|
37085
37086
|
toFetch.push(url2);
|
|
37086
37087
|
} else {
|
|
37087
37088
|
skippedUnchanged++;
|
|
@@ -37115,7 +37116,7 @@ var init_source_website = __esm({
|
|
|
37115
37116
|
content,
|
|
37116
37117
|
metadata: fetchMetadata
|
|
37117
37118
|
} = await this.fetchUrl(sitemapUrl.loc);
|
|
37118
|
-
const hash =
|
|
37119
|
+
const hash = crypto3.createHash("sha256").update(content).digest("hex");
|
|
37119
37120
|
let contentType = fetchedContentType;
|
|
37120
37121
|
if (!contentType) {
|
|
37121
37122
|
contentType = content.includes("<html") ? "text/html" : "text/markdown";
|
|
@@ -37168,14 +37169,18 @@ var init_source_website = __esm({
|
|
|
37168
37169
|
return null;
|
|
37169
37170
|
}
|
|
37170
37171
|
};
|
|
37171
|
-
console.log(
|
|
37172
|
+
console.log(
|
|
37173
|
+
`[SYNC DEBUG] Starting 'fetching and indexing pages' for ${toFetch.slice(0, this.maxPages).length} URLs...`
|
|
37174
|
+
);
|
|
37172
37175
|
const indexed = await step2.map(
|
|
37173
37176
|
"fetching and indexing pages",
|
|
37174
37177
|
toFetch.slice(0, this.maxPages),
|
|
37175
37178
|
(url2) => fetchAndIndex(url2),
|
|
37176
37179
|
{ concurrency: 20, maxAttempts: 2 }
|
|
37177
37180
|
);
|
|
37178
|
-
console.log(
|
|
37181
|
+
console.log(
|
|
37182
|
+
`[SYNC DEBUG] Fetch complete. ${indexed.length} attempted, ${indexed.filter((f) => f !== null).length} successful`
|
|
37183
|
+
);
|
|
37179
37184
|
const successful = indexed.filter((f) => f !== null);
|
|
37180
37185
|
console.log(`[SYNC DEBUG] Starting dsData registration...`);
|
|
37181
37186
|
await step2("register web page source", async () => {
|
|
@@ -37214,7 +37219,9 @@ var init_source_website = __esm({
|
|
|
37214
37219
|
console.warn("Failed to register web page source in dsData state:", err);
|
|
37215
37220
|
}
|
|
37216
37221
|
});
|
|
37217
|
-
console.log(
|
|
37222
|
+
console.log(
|
|
37223
|
+
`[SYNC DEBUG] \u2705 WebsiteSource sync complete for "${this.id}". Processed: ${discoveredUrls.length}, Added: ${successful.length}, Deleted: ${deleted.length}`
|
|
37224
|
+
);
|
|
37218
37225
|
return {
|
|
37219
37226
|
processed: discoveredUrls.length,
|
|
37220
37227
|
deleted,
|
|
@@ -44112,7 +44119,7 @@ var init_source_directory = __esm({
|
|
|
44112
44119
|
const glob2 = await Promise.resolve().then(() => (init_esm9(), esm_exports3));
|
|
44113
44120
|
const path4 = await import("path");
|
|
44114
44121
|
const fs3 = await import("fs/promises");
|
|
44115
|
-
const
|
|
44122
|
+
const crypto3 = await import("crypto");
|
|
44116
44123
|
const directory = path4.resolve(adk.environment.agent.directory, this.directoryPath);
|
|
44117
44124
|
const tags = {
|
|
44118
44125
|
[WellKnownTags.knowledge.KNOWLEDGE]: "knowledge-base",
|
|
@@ -44174,13 +44181,16 @@ var init_source_directory = __esm({
|
|
|
44174
44181
|
const upsertFile = async (local) => {
|
|
44175
44182
|
const key = `data_source://${this.type}/${this.id}/${local.rel}`;
|
|
44176
44183
|
const content = await fs3.readFile(local.abs);
|
|
44177
|
-
const hash =
|
|
44184
|
+
const hash = crypto3.createHash("sha256").update(content).digest("hex");
|
|
44178
44185
|
const { file } = await client2.getFile({ id: key }).catch(() => ({ file: null }));
|
|
44179
|
-
|
|
44186
|
+
const isFailed = file?.status === "indexing_failed" || file?.status === "upload_failed" || file?.status === "upload_pending";
|
|
44187
|
+
if (!input.force && !isFailed && file?.metadata?.hash === hash) {
|
|
44180
44188
|
console.log(`Skipping unchanged file: ${local.rel}`);
|
|
44181
44189
|
return null;
|
|
44182
44190
|
}
|
|
44183
|
-
if (
|
|
44191
|
+
if (isFailed) {
|
|
44192
|
+
console.log(`Re-indexing failed file (status: ${file?.status}): ${local.rel}`);
|
|
44193
|
+
} else if (input.force && file?.metadata?.hash === hash) {
|
|
44184
44194
|
console.log(`Force re-indexing file (unchanged): ${local.rel}`);
|
|
44185
44195
|
}
|
|
44186
44196
|
const title = path4.basename(local.name, path4.extname(local.name));
|