@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/internal.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
|
|
|
@@ -26654,7 +26654,7 @@ var require_form_data = __commonJS({
|
|
|
26654
26654
|
var parseUrl = __require("url").parse;
|
|
26655
26655
|
var fs3 = __require("fs");
|
|
26656
26656
|
var Stream2 = __require("stream").Stream;
|
|
26657
|
-
var
|
|
26657
|
+
var crypto3 = __require("crypto");
|
|
26658
26658
|
var mime = require_mime_types();
|
|
26659
26659
|
var asynckit = require_asynckit();
|
|
26660
26660
|
var setToStringTag = require_es_set_tostringtag();
|
|
@@ -26860,7 +26860,7 @@ var require_form_data = __commonJS({
|
|
|
26860
26860
|
return Buffer.concat([dataBuffer, Buffer.from(this._lastBoundary())]);
|
|
26861
26861
|
};
|
|
26862
26862
|
FormData3.prototype._generateBoundary = function() {
|
|
26863
|
-
this._boundary = "--------------------------" +
|
|
26863
|
+
this._boundary = "--------------------------" + crypto3.randomBytes(12).toString("hex");
|
|
26864
26864
|
};
|
|
26865
26865
|
FormData3.prototype.getLengthSync = function() {
|
|
26866
26866
|
var knownLength = this._overheadLength + this._valueLength;
|
|
@@ -27281,7 +27281,7 @@ var init_URLSearchParams = __esm({
|
|
|
27281
27281
|
});
|
|
27282
27282
|
|
|
27283
27283
|
// ../../node_modules/axios/lib/platform/node/index.js
|
|
27284
|
-
import
|
|
27284
|
+
import crypto2 from "crypto";
|
|
27285
27285
|
var ALPHA, DIGIT, ALPHABET, generateString, node_default;
|
|
27286
27286
|
var init_node2 = __esm({
|
|
27287
27287
|
"../../node_modules/axios/lib/platform/node/index.js"() {
|
|
@@ -27300,7 +27300,7 @@ var init_node2 = __esm({
|
|
|
27300
27300
|
let str = "";
|
|
27301
27301
|
const { length } = alphabet;
|
|
27302
27302
|
const randomValues = new Uint32Array(size);
|
|
27303
|
-
|
|
27303
|
+
crypto2.randomFillSync(randomValues);
|
|
27304
27304
|
for (let i = 0; i < size; i++) {
|
|
27305
27305
|
str += alphabet[randomValues[i] % length];
|
|
27306
27306
|
}
|
|
@@ -41101,7 +41101,7 @@ var init_source_website = __esm({
|
|
|
41101
41101
|
type: "website",
|
|
41102
41102
|
state: State,
|
|
41103
41103
|
async handler({ input, step: step2, state, client: client2 }) {
|
|
41104
|
-
const
|
|
41104
|
+
const crypto3 = await import("crypto");
|
|
41105
41105
|
console.log(
|
|
41106
41106
|
`Starting sync for WebsiteSource [${this.id}] in mode [${this.mode}, maxPages=${this.maxPages}, maxDepth=${this.maxDepth}, baseUrl=${this.baseUrl}, sitemapUrl=${this.sitemapUrl}]`
|
|
41107
41107
|
);
|
|
@@ -41149,7 +41149,8 @@ var init_source_website = __esm({
|
|
|
41149
41149
|
toFetch.push(url2);
|
|
41150
41150
|
} else {
|
|
41151
41151
|
const existingMetadata = existing.metadata;
|
|
41152
|
-
|
|
41152
|
+
const isFailed = existing.status === "indexing_failed" || existing.status === "upload_failed" || existing.status === "upload_pending";
|
|
41153
|
+
if (isFailed || url2.lastmod && existingMetadata?.lastmod !== url2.lastmod) {
|
|
41153
41154
|
toFetch.push(url2);
|
|
41154
41155
|
} else {
|
|
41155
41156
|
skippedUnchanged++;
|
|
@@ -41183,7 +41184,7 @@ var init_source_website = __esm({
|
|
|
41183
41184
|
content,
|
|
41184
41185
|
metadata: fetchMetadata
|
|
41185
41186
|
} = await this.fetchUrl(sitemapUrl.loc);
|
|
41186
|
-
const hash =
|
|
41187
|
+
const hash = crypto3.createHash("sha256").update(content).digest("hex");
|
|
41187
41188
|
let contentType = fetchedContentType;
|
|
41188
41189
|
if (!contentType) {
|
|
41189
41190
|
contentType = content.includes("<html") ? "text/html" : "text/markdown";
|
|
@@ -41236,14 +41237,18 @@ var init_source_website = __esm({
|
|
|
41236
41237
|
return null;
|
|
41237
41238
|
}
|
|
41238
41239
|
};
|
|
41239
|
-
console.log(
|
|
41240
|
+
console.log(
|
|
41241
|
+
`[SYNC DEBUG] Starting 'fetching and indexing pages' for ${toFetch.slice(0, this.maxPages).length} URLs...`
|
|
41242
|
+
);
|
|
41240
41243
|
const indexed = await step2.map(
|
|
41241
41244
|
"fetching and indexing pages",
|
|
41242
41245
|
toFetch.slice(0, this.maxPages),
|
|
41243
41246
|
(url2) => fetchAndIndex(url2),
|
|
41244
41247
|
{ concurrency: 20, maxAttempts: 2 }
|
|
41245
41248
|
);
|
|
41246
|
-
console.log(
|
|
41249
|
+
console.log(
|
|
41250
|
+
`[SYNC DEBUG] Fetch complete. ${indexed.length} attempted, ${indexed.filter((f) => f !== null).length} successful`
|
|
41251
|
+
);
|
|
41247
41252
|
const successful = indexed.filter((f) => f !== null);
|
|
41248
41253
|
console.log(`[SYNC DEBUG] Starting dsData registration...`);
|
|
41249
41254
|
await step2("register web page source", async () => {
|
|
@@ -41282,7 +41287,9 @@ var init_source_website = __esm({
|
|
|
41282
41287
|
console.warn("Failed to register web page source in dsData state:", err);
|
|
41283
41288
|
}
|
|
41284
41289
|
});
|
|
41285
|
-
console.log(
|
|
41290
|
+
console.log(
|
|
41291
|
+
`[SYNC DEBUG] \u2705 WebsiteSource sync complete for "${this.id}". Processed: ${discoveredUrls.length}, Added: ${successful.length}, Deleted: ${deleted.length}`
|
|
41292
|
+
);
|
|
41286
41293
|
return {
|
|
41287
41294
|
processed: discoveredUrls.length,
|
|
41288
41295
|
deleted,
|
|
@@ -48180,7 +48187,7 @@ var init_source_directory = __esm({
|
|
|
48180
48187
|
const glob2 = await Promise.resolve().then(() => (init_esm9(), esm_exports3));
|
|
48181
48188
|
const path5 = await import("path");
|
|
48182
48189
|
const fs3 = await import("fs/promises");
|
|
48183
|
-
const
|
|
48190
|
+
const crypto3 = await import("crypto");
|
|
48184
48191
|
const directory = path5.resolve(adk.environment.agent.directory, this.directoryPath);
|
|
48185
48192
|
const tags = {
|
|
48186
48193
|
[WellKnownTags.knowledge.KNOWLEDGE]: "knowledge-base",
|
|
@@ -48242,13 +48249,16 @@ var init_source_directory = __esm({
|
|
|
48242
48249
|
const upsertFile = async (local) => {
|
|
48243
48250
|
const key = `data_source://${this.type}/${this.id}/${local.rel}`;
|
|
48244
48251
|
const content = await fs3.readFile(local.abs);
|
|
48245
|
-
const hash =
|
|
48252
|
+
const hash = crypto3.createHash("sha256").update(content).digest("hex");
|
|
48246
48253
|
const { file } = await client2.getFile({ id: key }).catch(() => ({ file: null }));
|
|
48247
|
-
|
|
48254
|
+
const isFailed = file?.status === "indexing_failed" || file?.status === "upload_failed" || file?.status === "upload_pending";
|
|
48255
|
+
if (!input.force && !isFailed && file?.metadata?.hash === hash) {
|
|
48248
48256
|
console.log(`Skipping unchanged file: ${local.rel}`);
|
|
48249
48257
|
return null;
|
|
48250
48258
|
}
|
|
48251
|
-
if (
|
|
48259
|
+
if (isFailed) {
|
|
48260
|
+
console.log(`Re-indexing failed file (status: ${file?.status}): ${local.rel}`);
|
|
48261
|
+
} else if (input.force && file?.metadata?.hash === hash) {
|
|
48252
48262
|
console.log(`Force re-indexing file (unchanged): ${local.rel}`);
|
|
48253
48263
|
}
|
|
48254
48264
|
const title = path5.basename(local.name, path5.extname(local.name));
|