@botpress/runtime 1.13.11 → 1.13.13

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.11", adk: "1.13.11", sdk: "5.0.2", llmz: "0.0.37", zai: "2.5.6", cognitive: "0.3.3" };
51
+ define_PACKAGE_VERSIONS_default = { runtime: "1.13.13", adk: "1.13.13", sdk: "5.0.2", llmz: "0.0.37", zai: "2.5.6", cognitive: "0.3.3" };
52
52
  }
53
53
  });
54
54
 
@@ -101,7 +101,10 @@ var init_context = __esm({
101
101
  return storage.run(data, callback);
102
102
  },
103
103
  getAll: () => {
104
- const store = storage.getStore();
104
+ let store = storage.getStore();
105
+ if (!store && defaultContext.value) {
106
+ store = defaultContext.value;
107
+ }
105
108
  if (!store) throw new Error("No context found. Did you forget to call `context.run()`?");
106
109
  return store;
107
110
  },
@@ -41169,7 +41172,8 @@ var init_source_website = __esm({
41169
41172
  toFetch.push(url2);
41170
41173
  } else {
41171
41174
  const existingMetadata = existing.metadata;
41172
- 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) {
41173
41177
  toFetch.push(url2);
41174
41178
  } else {
41175
41179
  skippedUnchanged++;
@@ -41256,14 +41260,18 @@ var init_source_website = __esm({
41256
41260
  return null;
41257
41261
  }
41258
41262
  };
41259
- 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
+ );
41260
41266
  const indexed = await step2.map(
41261
41267
  "fetching and indexing pages",
41262
41268
  toFetch.slice(0, this.maxPages),
41263
41269
  (url2) => fetchAndIndex(url2),
41264
41270
  { concurrency: 20, maxAttempts: 2 }
41265
41271
  );
41266
- 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
+ );
41267
41275
  const successful = indexed.filter((f) => f !== null);
41268
41276
  console.log(`[SYNC DEBUG] Starting dsData registration...`);
41269
41277
  await step2("register web page source", async () => {
@@ -41302,7 +41310,9 @@ var init_source_website = __esm({
41302
41310
  console.warn("Failed to register web page source in dsData state:", err);
41303
41311
  }
41304
41312
  });
41305
- 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
+ );
41306
41316
  return {
41307
41317
  processed: discoveredUrls.length,
41308
41318
  deleted,
@@ -48264,11 +48274,14 @@ var init_source_directory = __esm({
48264
48274
  const content = await fs3.readFile(local.abs);
48265
48275
  const hash = crypto2.createHash("sha256").update(content).digest("hex");
48266
48276
  const { file } = await client2.getFile({ id: key }).catch(() => ({ file: null }));
48267
- 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) {
48268
48279
  console.log(`Skipping unchanged file: ${local.rel}`);
48269
48280
  return null;
48270
48281
  }
48271
- 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) {
48272
48285
  console.log(`Force re-indexing file (unchanged): ${local.rel}`);
48273
48286
  }
48274
48287
  const title = path4.basename(local.name, path4.extname(local.name));