@botpress/runtime 1.7.19 → 1.8.0

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.
@@ -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.7.19", adk: "1.7.19", sdk: "4.19.0", llmz: "0.0.33", zai: "2.5.0", cognitive: "0.2.0" };
51
+ define_PACKAGE_VERSIONS_default = { runtime: "1.8.0", adk: "1.8.0", sdk: "4.19.0", llmz: "0.0.33", zai: "2.5.0", cognitive: "0.2.0" };
52
52
  }
53
53
  });
54
54
 
@@ -40673,6 +40673,15 @@ var TableSource = class _TableSource extends DataSource {
40673
40673
  this.table = table;
40674
40674
  this.transformFn = options.transform ?? void 0;
40675
40675
  }
40676
+ /** Get serializable configuration for change detection */
40677
+ getConfig() {
40678
+ return {
40679
+ id: this.id,
40680
+ type: this.type,
40681
+ tableName: this.table.name,
40682
+ transformFn: this.transformFn?.toString() || null
40683
+ };
40684
+ }
40676
40685
  get syncWorkflow() {
40677
40686
  return createSyncWorkflow({
40678
40687
  type: "table",
@@ -42286,6 +42295,27 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42286
42295
  this.maxPages = Math.max(1, Math.min(("maxPages" in options ? options.maxPages : void 0) ?? 5e4, 5e4));
42287
42296
  this.maxDepth = Math.max(1, Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20));
42288
42297
  }
42298
+ /** Get serializable configuration for change detection (only user-provided options) */
42299
+ getConfig() {
42300
+ const config = {
42301
+ mode: this.mode,
42302
+ fetchStrategy: this.fetchStrategy
42303
+ };
42304
+ if (this.mode === "website") {
42305
+ config.baseUrl = this.baseUrl;
42306
+ config.maxPages = this.maxPages;
42307
+ config.maxDepth = this.maxDepth;
42308
+ } else if (this.mode === "sitemap") {
42309
+ config.sitemapUrl = this.sitemapUrl;
42310
+ config.maxPages = this.maxPages;
42311
+ } else if (this.mode === "urls") {
42312
+ config.urls = this.urls;
42313
+ }
42314
+ if (this.filterFn) {
42315
+ config.filterFn = this.filterFn.toString();
42316
+ }
42317
+ return config;
42318
+ }
42289
42319
  isBrowserIntegrationAvailable() {
42290
42320
  return !!adk.project.integrations.get("browser");
42291
42321
  }
@@ -42605,28 +42635,28 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42605
42635
  tags
42606
42636
  }).collect()
42607
42637
  );
42608
- const existingFileMap = new Map(
42609
- existingFiles.map((f) => [f.metadata?.[WellKnownMetadata.knowledge.URL], f])
42610
- );
42611
- const toRemove = existingFiles.filter(
42612
- (f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
42613
- );
42614
- if (existingFiles.length > 0 && toRemove.length >= existingFiles.length * 0.8) {
42615
- console.error(
42616
- `Warning: All existing files (${existingFiles.length}) are scheduled for removal. Please check if the sitemap URL is correct and the website is accessible. We will try again in 5 minutes.`
42638
+ if (input.force && existingFiles.length > 0) {
42639
+ console.warn(
42640
+ `\u26A0\uFE0F Website source configuration changed - deleting ${existingFiles.length} existing files and recrawling`
42641
+ );
42642
+ await step2.map(
42643
+ "deleting all existing files for recrawl",
42644
+ existingFiles,
42645
+ (f) => client.deleteFile({ id: f.id }).catch(() => null),
42646
+ { concurrency: 5 }
42617
42647
  );
42618
- await step2.sleep("retry wait", 5 * 60 * 1e3);
42619
- throw new Error("Aborting sync due to potential misconfiguration (all files to be removed)");
42648
+ console.log(`\u2705 Deleted ${existingFiles.length} files, starting fresh crawl`);
42620
42649
  }
42650
+ const existingFileMap = input.force ? /* @__PURE__ */ new Map() : new Map(existingFiles.map((f) => [f.metadata?.[WellKnownMetadata.knowledge.URL], f]));
42651
+ const toRemove = input.force ? [] : existingFiles.filter(
42652
+ (f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
42653
+ );
42621
42654
  const toFetch = [];
42622
42655
  let skippedUnchanged = 0;
42623
42656
  for (const url2 of discoveredUrls) {
42624
42657
  const existing = existingFileMap.get(url2.loc);
42625
42658
  if (!existing) {
42626
42659
  toFetch.push(url2);
42627
- } else if (input.force) {
42628
- console.log(`Force re-indexing page: ${url2.loc}`);
42629
- toFetch.push(url2);
42630
42660
  } else {
42631
42661
  const existingMetadata = existing.metadata;
42632
42662
  if (url2.lastmod && existingMetadata?.lastmod !== url2.lastmod) {
@@ -42740,7 +42770,17 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42740
42770
  return new _WebsiteSource(id, "sitemap", { ...options, sitemapUrl });
42741
42771
  }
42742
42772
  static fromUrls(urls, options = {}) {
42743
- const id = options.id || `urls_${urls.length}_pages`;
42773
+ let defaultId = `urls_${urls.length}_pages`;
42774
+ if (urls.length > 0) {
42775
+ try {
42776
+ const firstUrl = new URL(urls[0]);
42777
+ const domain = firstUrl.hostname.replace(/^www\./, "").replace(/\./g, "_");
42778
+ const urlsHash = urls.slice().sort().join("|").split("").reduce((hash, char) => (hash << 5) - hash + char.charCodeAt(0) | 0, 0).toString(16).replace("-", "").slice(0, 8);
42779
+ defaultId = `urls_${domain}_${urlsHash}`;
42780
+ } catch {
42781
+ }
42782
+ }
42783
+ const id = options.id || defaultId;
42744
42784
  return new _WebsiteSource(id, "urls", { ...options, urls });
42745
42785
  }
42746
42786
  };
@@ -42750,12 +42790,29 @@ init_define_BUILD();
42750
42790
  init_define_PACKAGE_VERSIONS();
42751
42791
  import { z as z11 } from "@botpress/sdk";
42752
42792
  var DirectorySource = class _DirectorySource extends DataSource {
42753
- directoryPath;
42754
- filterFn;
42793
+ _directoryPath;
42794
+ _filterFn;
42755
42795
  constructor(id, directoryPath, options = {}) {
42756
42796
  super(id, "directory");
42757
- this.directoryPath = directoryPath;
42758
- this.filterFn = options.filter ?? void 0;
42797
+ this._directoryPath = directoryPath;
42798
+ this._filterFn = options.filter ?? void 0;
42799
+ }
42800
+ /** Get the directory path for this source */
42801
+ get directoryPath() {
42802
+ return this._directoryPath;
42803
+ }
42804
+ /** Get the filter function for this source */
42805
+ get filterFn() {
42806
+ return this._filterFn;
42807
+ }
42808
+ /** Get serializable configuration for change detection */
42809
+ getConfig() {
42810
+ return {
42811
+ id: this.id,
42812
+ type: this.type,
42813
+ directoryPath: this._directoryPath,
42814
+ filterFn: this._filterFn?.toString() || null
42815
+ };
42759
42816
  }
42760
42817
  get syncWorkflow() {
42761
42818
  return createSyncWorkflow({
@@ -42902,6 +42959,17 @@ var DirectorySource = class _DirectorySource extends DataSource {
42902
42959
  }
42903
42960
  };
42904
42961
 
42962
+ // src/primitives/data-sources/index.ts
42963
+ function isDirectorySource(source) {
42964
+ return source.type === "directory";
42965
+ }
42966
+ function isWebsiteSource(source) {
42967
+ return source.type === "website";
42968
+ }
42969
+ function isTableSource(source) {
42970
+ return source.type === "table";
42971
+ }
42972
+
42905
42973
  // src/primitives/conversation.ts
42906
42974
  init_define_BUILD();
42907
42975
  init_define_PACKAGE_VERSIONS();
@@ -43477,6 +43545,9 @@ var DataSource2;
43477
43545
  DataSource3.Table = TableSource;
43478
43546
  DataSource3.Website = WebsiteSource;
43479
43547
  DataSource3.Directory = DirectorySource;
43548
+ DataSource3.isDirectory = isDirectorySource;
43549
+ DataSource3.isWebsite = isWebsiteSource;
43550
+ DataSource3.isTable = isTableSource;
43480
43551
  })(DataSource2 || (DataSource2 = {}));
43481
43552
 
43482
43553
  // src/primitives/workflow-utils.ts