@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/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.12", adk: "1.13.12", sdk: "5.0.2", llmz: "0.0.37", zai: "2.5.6", cognitive: "0.3.3" };
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
 
@@ -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 crypto2 = __require("crypto");
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 = "--------------------------" + crypto2.randomBytes(12).toString("hex");
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 crypto from "crypto";
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
- crypto.randomFillSync(randomValues);
26992
+ crypto2.randomFillSync(randomValues);
26993
26993
  for (let i = 0; i < size; i++) {
26994
26994
  str += alphabet[randomValues[i] % length];
26995
26995
  }
@@ -41124,7 +41124,7 @@ var init_source_website = __esm({
41124
41124
  type: "website",
41125
41125
  state: State,
41126
41126
  async handler({ input, step: step2, state, client: client2 }) {
41127
- const crypto2 = await import("crypto");
41127
+ const crypto3 = await import("crypto");
41128
41128
  console.log(
41129
41129
  `Starting sync for WebsiteSource [${this.id}] in mode [${this.mode}, maxPages=${this.maxPages}, maxDepth=${this.maxDepth}, baseUrl=${this.baseUrl}, sitemapUrl=${this.sitemapUrl}]`
41130
41130
  );
@@ -41172,7 +41172,8 @@ var init_source_website = __esm({
41172
41172
  toFetch.push(url2);
41173
41173
  } else {
41174
41174
  const existingMetadata = existing.metadata;
41175
- if (url2.lastmod && existingMetadata?.lastmod !== url2.lastmod) {
41175
+ const isFailed = existing.status === "indexing_failed" || existing.status === "upload_failed" || existing.status === "upload_pending";
41176
+ if (isFailed || url2.lastmod && existingMetadata?.lastmod !== url2.lastmod) {
41176
41177
  toFetch.push(url2);
41177
41178
  } else {
41178
41179
  skippedUnchanged++;
@@ -41206,7 +41207,7 @@ var init_source_website = __esm({
41206
41207
  content,
41207
41208
  metadata: fetchMetadata
41208
41209
  } = await this.fetchUrl(sitemapUrl.loc);
41209
- const hash = crypto2.createHash("sha256").update(content).digest("hex");
41210
+ const hash = crypto3.createHash("sha256").update(content).digest("hex");
41210
41211
  let contentType = fetchedContentType;
41211
41212
  if (!contentType) {
41212
41213
  contentType = content.includes("<html") ? "text/html" : "text/markdown";
@@ -41259,14 +41260,18 @@ var init_source_website = __esm({
41259
41260
  return null;
41260
41261
  }
41261
41262
  };
41262
- console.log(`[SYNC DEBUG] Starting 'fetching and indexing pages' for ${toFetch.slice(0, this.maxPages).length} URLs...`);
41263
+ console.log(
41264
+ `[SYNC DEBUG] Starting 'fetching and indexing pages' for ${toFetch.slice(0, this.maxPages).length} URLs...`
41265
+ );
41263
41266
  const indexed = await step2.map(
41264
41267
  "fetching and indexing pages",
41265
41268
  toFetch.slice(0, this.maxPages),
41266
41269
  (url2) => fetchAndIndex(url2),
41267
41270
  { concurrency: 20, maxAttempts: 2 }
41268
41271
  );
41269
- console.log(`[SYNC DEBUG] Fetch complete. ${indexed.length} attempted, ${indexed.filter((f) => f !== null).length} successful`);
41272
+ console.log(
41273
+ `[SYNC DEBUG] Fetch complete. ${indexed.length} attempted, ${indexed.filter((f) => f !== null).length} successful`
41274
+ );
41270
41275
  const successful = indexed.filter((f) => f !== null);
41271
41276
  console.log(`[SYNC DEBUG] Starting dsData registration...`);
41272
41277
  await step2("register web page source", async () => {
@@ -41305,7 +41310,9 @@ var init_source_website = __esm({
41305
41310
  console.warn("Failed to register web page source in dsData state:", err);
41306
41311
  }
41307
41312
  });
41308
- console.log(`[SYNC DEBUG] \u2705 WebsiteSource sync complete for "${this.id}". Processed: ${discoveredUrls.length}, Added: ${successful.length}, Deleted: ${deleted.length}`);
41313
+ console.log(
41314
+ `[SYNC DEBUG] \u2705 WebsiteSource sync complete for "${this.id}". Processed: ${discoveredUrls.length}, Added: ${successful.length}, Deleted: ${deleted.length}`
41315
+ );
41309
41316
  return {
41310
41317
  processed: discoveredUrls.length,
41311
41318
  deleted,
@@ -48203,7 +48210,7 @@ var init_source_directory = __esm({
48203
48210
  const glob2 = await Promise.resolve().then(() => (init_esm9(), esm_exports3));
48204
48211
  const path4 = await import("path");
48205
48212
  const fs3 = await import("fs/promises");
48206
- const crypto2 = await import("crypto");
48213
+ const crypto3 = await import("crypto");
48207
48214
  const directory = path4.resolve(adk.environment.agent.directory, this.directoryPath);
48208
48215
  const tags = {
48209
48216
  [WellKnownTags.knowledge.KNOWLEDGE]: "knowledge-base",
@@ -48265,13 +48272,16 @@ var init_source_directory = __esm({
48265
48272
  const upsertFile = async (local) => {
48266
48273
  const key = `data_source://${this.type}/${this.id}/${local.rel}`;
48267
48274
  const content = await fs3.readFile(local.abs);
48268
- const hash = crypto2.createHash("sha256").update(content).digest("hex");
48275
+ const hash = crypto3.createHash("sha256").update(content).digest("hex");
48269
48276
  const { file } = await client2.getFile({ id: key }).catch(() => ({ file: null }));
48270
- if (!input.force && file?.metadata?.hash === hash) {
48277
+ const isFailed = file?.status === "indexing_failed" || file?.status === "upload_failed" || file?.status === "upload_pending";
48278
+ if (!input.force && !isFailed && file?.metadata?.hash === hash) {
48271
48279
  console.log(`Skipping unchanged file: ${local.rel}`);
48272
48280
  return null;
48273
48281
  }
48274
- if (input.force && file?.metadata?.hash === hash) {
48282
+ if (isFailed) {
48283
+ console.log(`Re-indexing failed file (status: ${file?.status}): ${local.rel}`);
48284
+ } else if (input.force && file?.metadata?.hash === hash) {
48275
48285
  console.log(`Force re-indexing file (unchanged): ${local.rel}`);
48276
48286
  }
48277
48287
  const title = path4.basename(local.name, path4.extname(local.name));